Skip to content

fix(pipeline): L2 runner 零记录时返回现有 cursor 而非 void#99

Open
yuanrengu wants to merge 2 commits into
Tencent:mainfrom
yuanrengu:fix/l2-runner-cursor-advancement
Open

fix(pipeline): L2 runner 零记录时返回现有 cursor 而非 void#99
yuanrengu wants to merge 2 commits into
Tencent:mainfrom
yuanrengu:fix/l2-runner-cursor-advancement

Conversation

@yuanrengu
Copy link
Copy Markdown
Contributor

@yuanrengu yuanrengu commented May 27, 2026

Summary

修复 L2 runner 在零记录/提取失败时不返回 cursor 导致 last_extraction_updated_time 永不推进的问题。

改动 1:src/utils/pipeline-factory.ts(runner 侧)

VectorStore 和 JSONL fallback 路径在 0 记录时返回 { latestCursor: cursor } 而非 void,让 runL2 保留已有 cursor。提取失败路径保持 void 返回以保留重试语义。

改动 2:src/utils/pipeline-manager.ts(runL2 侧)

当 runner 返回 void 且 last_extraction_updated_time 仍为空字符串时,将其初始化为当前时间。这解决了 runner 侧改动无法覆盖的边界情况:首次运行时 cursor 为空,cursor || undefined 仍为 undefined,返回 { latestCursor: undefined }return; 效果相同。

各场景行为

场景 cursor 初始值 最终 cursor 行为
零记录 + cursor 为空 "" 当前时间 不再全量扫描 ✓
零记录 + 已有 cursor "2024-01-01" "2024-01-01" 保留不变 ✓
提取成功 "" max(updatedAt) 正常推进 ✓
提取失败 + 已有 cursor "2024-01-01" "2024-01-01" 保留重试 ✓
提取失败 + cursor 为空 "" 当前时间 避免永远全量扫描

与 PR #2 的区别

PR #2latestCursor 计算移到 if 块外并无条件返回,导致提取失败(如 LLM 超时)时 cursor 也会推进到 max(records.updatedAt),未成功提取的记录被永久跳过。本 PR 仅在零记录路径返回 cursor,提取失败时保留原始的重试语义。

Test plan

  • 现有测试通过 (npx vitest run)
  • 手动验证:首次 L2 运行(cursor 为空)后 cursor 不再为空
  • 手动验证:提取失败 + 已有 cursor 时 cursor 不推进
  • 手动验证:零记录 + 已有 cursor 时 cursor 保持不变

Closes #98

yuanrengu added 2 commits May 27, 2026 14:06
VectorStore 和 JSONL fallback 路径在 0 记录时返回 void,导致
runL2 无法更新 last_extraction_updated_time,每次 L2 运行都全量
扫描而非增量查询。

修复:零记录时返回 { latestCursor: cursor },让 runL2 保留已有
cursor。提取失败路径保持 void 返回以保留重试语义。

Closes Tencent#98

Signed-off-by: yuanrengu <heyonggang0811@126.com>
当 L2 runner 返回 void(零记录或提取失败)且 last_extraction_updated_time
仍为空字符串时,将其设为当前时间。防止每次 L2 运行都全量扫描。

已有 cursor 时提取失败不推进,保留重试语义。

Closes Tencent#98

Signed-off-by: yuanrengu <heyonggang0811@126.com>
@Maxwell-Code07
Copy link
Copy Markdown
Collaborator

您的修复、测试方案很周到,感谢您的贡献!我们会尽快开始review,有结果会及时同步。

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] L2 runner 在零记录/提取失败时不返回 cursor,导致 last_extraction_updated_time 永不推进

2 participants