Skip to content

[PR] fix: plan-aware search respects TodoWrite task status (#5047) - #5083

Open
ranxianglei wants to merge 5 commits into
masterfrom
wt-5047-ework-daemon
Open

ranxianglei wants to merge 5 commits into
masterfrom
wt-5047-ework-daemon

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Summary

Fixes #5047. The opt-in compress.search.planAware path (#1419/#1336) tokenized the ENTIRE latest planning-tool snapshot, so a task's status never changed the extracted terms and repeated completed-task descriptions could dominate the single active task — swapping only two TodoWrite statuses changed retrieval at all.

What changed (src/decompress-shared.ts)

Extraction — a recognized complete TodoWrite/todowrite snapshot now contributes only its active tier to the plan signal:

  • in_progress descriptions, or pending descriptions when none are in progress;
  • completed/cancelled descriptions stop contributing plan signal (their historical blocks stay lexically searchable);
  • unrecognized shapes (custom planning tools, incremental updates, malformed/truncated JSON, foreign or missing status) keep the legacy whole-text path unchanged.

Ranking — an explicit historical query retains priority over a less-relevant active task:

Behavior change (flagged per policy)

  • Default behavior: unchanged. compress.search.planAware stays opt-in and default-off; with it off, search output is byte-identical (covered by the existing planAware off leaves the search output untouched e2e test).
  • When enabled: old = whole-snapshot lexical split (status-blind; terminal tasks contributed) → new = active-tier-only extraction + discriminating-query outranks plan affinity. Intended consequence: status swaps now flip retrieval, and an explicit topic query is no longer displaced by an unrelated active task.

Scope

Single module (src/decompress-shared.ts). No kernel, persistence-format, provider-payload, wire-shape, or new-config changes. No version bump (content branch).

Tests

tests/search-plan-aware.test.ts — 7 new deterministic cases: active-tier extraction, pending fallback, fully-terminal → null, legacy fallback (invalid JSON / foreign status / missing status), oversized char-cap, the reported status-swap repro, and explicit-historical-query protection. Local targeted run: 20/20 pass (incl. both Anthropic e2e roundtrips); full-suite verdict deferred to CI.

Closes #5047

@ranxianglei ranxianglei changed the title fix: plan-aware search respects TodoWrite task status (#5047) [PR] fix: plan-aware search respects TodoWrite task status (#5047) Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: wt-5047-ework-daemon (595f0d8)

Latest build — install this exact version

npm install -g billion-context@0.0.7183-pr.5083.3930bc8

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
595f0d8 billion-context@0.0.7183-pr.5083.3930bc8 build
1cffa5b billion-context@0.0.6929-pr.5083.958b61b build
85198f4 billion-context@0.0.6906-pr.5083.34b9ae4 build
3ed90ae billion-context@0.0.6711-pr.5083.81f7077 build
13f35c3 billion-context@0.0.6689-pr.5083.5e13533 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr5083.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复——#5047 是本 PR 对应的唯一 issue;按失败签名(plan-aware search 整快照 tokenize / status-blind 排序)检索 open+closed issue 与 PR,无其他同机制条目。

标签: bug + scope/kernel + p2(修的是 src 侧检索决策面的缺陷;仅影响显式开启 compress.search.planAware 的用户,默认关闭、无数据/缓存影响 → p2)。

审核进行中,先报进度:

  • diff 已逐行通读(2 文件 +185/−4,单模块 src/decompress-shared.ts + 测试,无 version/kernel/lockfile 触碰);
  • 本地定向验证:tests/search-plan-aware.test.ts 20/20 绿(含两个 Anthropic e2e roundtrip)+ typecheck 干净;
  • 负向对照(把新测试跑在 base b08fbf3 源码上):7 个新测试中 4 个变红,含 status-swap 报告复现本身——回归测试有牙,不是假测试;
  • 原 head 的 CI 全绿(30 checks,0 failed);head 落后 master 18 个提交且两文件零重叠 → 正在 rebase 到 master,CI 转绿后按八问体例给结论。

A recognized complete TodoWrite/todowrite snapshot now contributes only its active tier (in_progress, else pending) to the plan signal instead of a whole-snapshot lexical split, so completed/cancelled tasks stop contributing while their historical blocks remain lexically searchable. Unrecognized shapes (custom tools, incremental updates, malformed/truncated JSON, foreign or missing status) keep the legacy whole-text path.

Ranking: a query term that discriminates within the candidate pool (matches some but not all blocks) marks its blocks as explicit-query matches that outrank plan-only affinity; a shared query term (hits every block) degrades to the pure #1336 plan ranking, preserving ambiguous queries.

compress.search.planAware stays opt-in/default-off; no kernel, persistence, provider-payload, wire-shape, or new-config changes.
@ranxianglei ranxianglei added bug Something isn't working p2 scope/kernel labels Oct 29, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

进度汇报(进程曾因长轮询被重启,现恢复):

审核工作已全部完成,只差新 head 的 CI 转绿:

  1. 代码审核:diff 逐行通读完毕(提取侧 active-tier + 排序侧 discriminating-query 保护),独立结论与 issue 侧一致——方向正确、打到根因层(共享提取/排序策略),默认关闭路径字节不变;
  2. 本地验证:rebase 后 head 上 tests/search-plan-aware.test.ts 20/20 绿 + typecheck 干净;负向对照确认回归测试有牙(status-swap 复现在旧源码上必红);
  3. 已完成 rebase:原 head 落后 master,已 rebase 到当前 master tip(6b298c3)并推送,新 head = 3ed90ae,PR 不再 behind;
  4. 待办:新 head 的 CI 结果(镜像缓存此前一直停留在旧 head 的运行记录,正在复查)。CI 绿后按八问体例给最终结论。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

审核结论(独立审读 diff + 本地定向验证 + 负向对照 + CI)

做了什么:PR 原 head 落后 master 18 个提交(两文件零重叠),已 rebase 到当前 master tip(6b298c3)并推送,新 head 3ed90ae;rebase 后本地 tests/search-plan-aware.test.ts 20/20 绿、typecheck 干净;新 head CI 全绿(30 checks:14 success + 16 skipped 条件车道,0 failed)。

八问

  1. 是什么问题:opt-in 的 compress.search.planAware 检索排序(feat: CCR v3 — planning-aware retrieval for search_context (compress.search.planAware) #1419/Feature: CCR v3 — planning-aware retrieval (rank candidates against todo/task state, LineRetriever-style) #1336)把最新 TodoWrite 快照整段做词元化——状态词全是停用词,任务状态永远不改变提取出的计划信号;重复出现的已完成任务描述能把唯一活跃任务挤出排序头部。只交换两个任务的状态,检索结果纹丝不动。
  2. 什么原因导致的:根因在共享的提取/排序策略层(src/decompress-shared.ts 的 extractPlanState + executeSearchContext 重排):提取端对 status 盲视(whole-text tokenize),排序端没有显式查询保护(纯计划亲和度排序)。不是 kernel/存储/wire 层的问题——issue 的分析直接打到了根因层,方向正确。
  3. 影响范围与严重程度:仅显式开启 compress.search.planAware 的用户(默认关闭)。对他们:检索质量退化(错误块排第一、明确的历史主题查询被无关活跃任务挤掉)。p2——无数据丢失、无缓存泄露、默认用户零影响。
  4. 怎么修复的:同模块内两处配合。(a) 提取端:parseTodoSnapshot 严格识别「完整 TodoWrite 快照」(todos 非空数组、每项 string content+status 且 status ∈ 四值词表),识别成功则只贡献活跃层(in_progress;全非 in_progress 时取 pending),终态描述不再贡献计划信号;任何未识别形状(自定义工具/增量更新/坏 JSON/外来或缺失 status)返回 null 走旧版整段路径,失败方向保守。(b) 排序端:在候选池内有区分力的查询词(命中部分而非全部块)把命中块标记为显式查询匹配,优先于纯计划亲和度;共享词(命中全部块)不带此信号,歧义查询精确退化为旧 Feature: CCR v3 — planning-aware retrieval (rank candidates against todo/task state, LineRetriever-style) #1336 排序(q 全 0 时比较器与旧版逐项等价)。
  5. 是否有回归问题:对触碰路径的既有行为逐项清点——flag 关(默认):gate plan && … 不成立,路径完全不走,e2e planAware off leaves the search output untouched 钉住字节不变 ✓;pool ≤ limit 不重排(gate 未动)✓;foreign-session 检索保持纯词典序(gate 排除)✓;共享词查询顺序与旧版逐项等价 ✓。有意变更(均在 opt-in 路径内、PR 正文已披露):终态任务不再参与计划信号;全终态快照可令 planState=null → 该轮完全不重排(旧行为是贡献 weight-2 整段词元);pending 层在无 in_progress 时成为信号;区分力查询词现在即使双方计划得分为 0 也优先。高危模式逐项过:无 fail-fast 变吞错(parse 失败→旧路径,保守方向)、无阈值/时序/输出格式漂移、日志行格式不变。
  6. 是否破坏缓存:不涉及——search_context 是对压缩块的只读工具,不触碰前缀缓存/重试/增量游标/去重键。
  7. 是否改了设计方向:不涉及——完全留在既有 plan-aware 检索机制内,无架构/边界/数据流转向。
  8. 是否引入了新的配置:不涉及——沿用既有 compress.search.planAware(opt-in、默认 off),无新 env/config/默认值。

测试有效性(独立核查)

  • 负向对照:把 PR 的测试文件跑在 base b08fbf3 源码上 → 7 个新测试中 4 个变红,含 status-swap 报告复现本身——回归测试有牙;另 3 个在旧码上也过,属新代码路径的行为守卫(断言具体词元存活/具体赢家块,非常态断言),设计合理。
  • 断言均检查具体提取词与具体赢家块 id,无恒真断言;两个 Anthropic e2e roundtrip 覆盖 wire 侧稳定性。

diff 整洁度与代码质量

2 文件 +185/−4,每一行都与本 PR 目的相关;无 version/kernel/lockfile 触碰;命名达意(parseTodoSnapshot/activeTodoDescriptions/PLAN_TODO_STATUSES)、无死代码、注释讲为什么且与代码事实一致、风格与仓库既有代码一致。未发现需顺手修的小问题。

判定:可合(mergeable)。GitHub 显示 mergeable_state=blocked 是分支保护等人工合并,非 CI 问题;按规则合并由你执行:#5083

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

收尾说明:上一条八问结论即最终审核结果,本 PR 的审核工作已全部完成,无待办事项(进程重启发生在收工之后)。当前状态复核:head 3ed90ae CI 全绿(30 checks,0 failed),等待人工合并——按规则我不执行合并:#5083

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

merge-guard 同步完成:分支已合入 master tip 44067a5bc(merge commit 595f0d803 已推送),无冲突;定向测试 tests/search-plan-aware.test.ts 20/20 绿。当前状态:head=595f0d803,mergeable=true、mergeable_state=blocked(仅因新 head 的 CI 还在跑,非冲突)。镜像 git 端点 502 已恢复。

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

bug Something isn't working p2 scope/kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plan-aware search ignores TodoWrite task status for ambiguous queries

1 participant