Skip to content

fix(queue): 修复 wait=true 漏等下游索引任务 - #4813

Open
qin-ctx wants to merge 1 commit into
mainfrom
fix/content-write-request-wait
Open

qin-ctx wants to merge 1 commit into
mainfrom
fix/content-write-request-wait

Conversation

@qin-ctx

@qin-ctx qin-ctx commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Description

修复文件写入 wait=true 提前报告索引完成的问题。

例如创建一个文件:

POST /api/v1/content/write
{"uri":"viking://resources/docs/note.md","content":"hello","mode":"create","wait":true}
  • 修改前:文件摘要生成完后,接口可能就返回 vector_status: "complete",但这个文件的索引还没写完。开启 ACL 时,创建者紧接着查询文件权限,可能短暂收到 403。
  • 修改后:在等待未超时的情况下,只有本次请求的摘要和索引都处理成功,才返回 semantic_status: "complete"、vector_status: "complete";索引处理失败则返回 vector_status: "failed"。

原因是等待方使用原请求编号,但下游索引消息从后台监控上下文取编号。原请求的监控对象未注册时,两边编号不一致,等待方就漏掉了索引任务。本次让索引消息沿用上游语义消息已有的 telemetry_id,不再依赖监控对象是否注册。

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

无独立 Issue。此等待回归在 #3636 改为流式提交索引任务后暴露。

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • 从语义消息到文件、目录的索引消息,显式传递同一个请求编号;同时覆盖目录 DAG 和 memory 目录处理路径。
  • 保留流式并行处理及按请求等待,不恢复全局队列等待。直接提交索引的调用方仍使用当前请求编号;上游显式传入空编号时保持为空。
  • 合并并改写已有等待测试,通过暂停实际索引写入,验证接口不会提前返回;覆盖监控开关、索引失败和并发请求隔离。

Testing

仅改写现有测试,没有新增测试文件或测试函数。

  • 同一份延迟索引回归测试:修复前 main 的 4 个场景全部复现漏等;修复后全部通过。

  • 基于已合入 restricted 模式的 main,153 项相关测试通过,包括文件创建后立即查询 ACL、restricted/inherit 切换、HTTP 写入和 wait=false。

  • 测试使用真实本地队列与存储、模拟模型输出;不是在线模型服务联调。

  • Ruff lint、git diff --check 通过。

  • I have added tests that prove my fix is effective or that my feature works

  • New and existing unit tests pass locally with my changes

  • I have tested this on the following platforms:

    • Linux
    • macOS
    • Windows

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

不适用。

Additional Notes

不修改 ACL 授权规则、公开 API 或消息 Schema,无需数据迁移。

沿用语义消息的请求编号,避免监控上下文未注册时索引工作脱离原请求的等待范围;改写现有测试覆盖延迟写入、索引失败与并发隔离。

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant