Skip to content

docs(managed-agent): name the pre-dispatch commit-spy assertion - #14756

Merged
yiliang114 merged 1 commit into
mainfrom
docs/fg13d-pre-dispatch-witness
Oct 19, 2026
Merged

yiliang114 merged 1 commit into
mainfrom
docs/fg13d-pre-dispatch-witness

Conversation

@wenshao

@wenshao wenshao commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

What this PR does

Adds the missing sentence to the FG13d design docs (English and Chinese) naming the assertion that actually pins the pre-dispatch cancel arm: the commitExtensionRecord spy on the child record's dispatch_started commit.

Why it's needed

#14735 added that test. Its design section described the cell as asserting cancelled / not_started_proven with zero hook-execute requests, which is what the test does — but those assertions do not discriminate. A third cancel checkpoint after the dispatch_started commit catches the same condition, so removing the post-acquisition check leaves the final record and the zero-hook-execute count green. Only the spy sees the commit that should not have happened. A future maintainer reading the doc, running the obvious mutant, and seeing green would wrongly conclude the arm is unpinned.

Reviewer Test Plan

How to verify

Read the "Pre-dispatch cancel (unit instrument)" section in both language versions; they now carry the same sentence. The claim matches the merged test: the spy records dispatch_started only for records whose hookId is not __plan__, and the cell asserts that list is empty.

Evidence (Before & After)

N/A — documentation only.

Tested on

OS Status
🍏 macOS ✅ Prettier
🪟 Windows N/A
🐧 Linux N/A

Risk & Scope

  • Main risk or tradeoff: none; two design documents.
  • Not validated / out of scope: no code or test changes.
  • Breaking changes / migration notes: none.
  • Design documents: English and 简体中文.

Linked Issues

Follow-up to #14735 and part of #14449.

@qwen-code-review-bot

qwen-code-review-bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Qwen Triage finished — view run. See the stage comments in this thread for the result.

✅ Qwen Triage 已完成 —— 查看运行。结果见本线程中的各阶段评论。

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Thanks for the PR!

Template looks good ✓

Problem: observed, and I confirmed it against the code rather than taking the description's word for it. On main, the "Pre-dispatch cancel (unit instrument)" section describes the cell as asserting cancelled / not_started_proven with zero hook-execute requests — and reading perform() in packages/cli/src/serve/hosted-hook-session.ts, those assertions genuinely do not discriminate. The intent branch carries three cancel checkpoints: pre-acquisition, post-acquisition (after executionBroker), and a third immediately after the dispatch_started commit. All three funnel into the same cancelBeforeDispatch(), which overwrites run to cancelled / not_started_proven and returns before any hook-execute is issued. Drop the middle one and the third still catches the same condition, so the final record and the request count stay green. The doc gap is real.

Direction: aligned. This is what the neighbouring "Mutation witnesses" section already does for the MySQL-lane cells, extended to the unit instrument, and AGENTS.md requires design docs to stay complete and synchronized in both languages. CHANGELOG: no direct reference — docs/design/ only, as expected.

Size: not applicable. No core paths; 2 files, +10/-0, all prose (production 0 / test 0 / generated-schema 0).

Approach: minimal, and correctly placed. Adding a paragraph to the existing section beats folding it into the mutation-witnesses list — that list is scoped to the integration cells, while this is the unit instrument. Nothing to cut, no drive-by edits, both languages in the same change as the design-doc rules require.

Risk: no elevated risk signals (Stage 1e matched nothing).

Moving on to code review. 🔍

中文说明

感谢贡献!

模板完整 ✓

问题:是实际存在的,我对照代码确认过,没有只采信 PR 描述。main 上「派发前取消(单测仪器)」一节把该用例描述为断言 cancelled / not_started_proven 且 hook-execute 请求为零——而读 packages/cli/src/serve/hosted-hook-session.ts 的 perform() 可以确认,这些断言确实不具备区分度。intent 分支上有三个取消检查点:获取前、获取后(executionBroker 之后),以及 dispatch_started 提交之后紧接着的第三个。三者都汇入同一个 cancelBeforeDispatch(),它把 run 覆写为 cancelled / not_started_proven,并在发出任何 hook-execute 之前返回。去掉中间那个,第三个仍会以相同条件兜住,因此最终记录与请求数依然为绿。文档缺口是真实存在的。

方向:对齐。这正是相邻「变异见证」一节为 MySQL lane 用例所做的事,现在延伸到单测仪器;且 AGENTS.md 要求设计文档在两种语言下都完整同步。CHANGELOG:无直接相关记录——仅涉及 docs/design/,符合预期。

规模:不适用。未触及核心路径;2 个文件,+10/-0,全为文字(生产 0 / 测试 0 / 生成-schema 0)。

方案:改动最小,位置也正确。在现有小节中新增一段,比并入「变异见证」列表更合适——那份列表针对集成用例,而这里是单测仪器。没有可砍的部分,没有夹带无关改动,且按设计文档规则在同一次变更中同时更新两种语言。

风险:无升级风险信号(Stage 1e 未命中任何路径)。

进入代码审查 🔍

— Qwen Code · qwen3.8-max-2026-09-02

Reviewed at e2dc40b0da5c604c442913d0cfecdcb3f7197af1 · re-run with @qwen-code /triage

@qwen-code-review-bot

qwen-code-review-bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Code review

No blockers, and no AGENTS.md violations. The interesting part of a docs PR is whether the prose is actually true, so I checked both claims against the code instead of against the description.

The spy claim matches the merged test exactly. In packages/cli/src/serve/hosted-hook-session.test.ts, the cell cancels a Hook while the dispatch acquisition is held, before dispatch_started installs a commitExtensionRecord spy that pushes into dispatched only when record.hookId !== '__plan__' && record.run?.execution === 'dispatch_started', then asserts expect(dispatched).toEqual([]). That is precisely what both language versions now say — including the __plan__ exclusion, which is the detail most likely to be paraphrased away and wasn't.

The mutation claim holds structurally. In hosted-hook-session.ts, perform() guards the intent branch with the identical condition executionSignal.aborted || this.cancelRequested(id) || this.cancelRequested(marker.hookExecutionId) at three points: before the executionBroker acquisition, after it, and again after await this.commit('hook_execution', id, record) writes execution: 'dispatch_started'. All three return cancelBeforeDispatch(), which commits state: 'cancelled' / execution: 'not_started_proven' — overriding the dispatch_started it just wrote — and returns cancelledResult() before any hook-execute goes out. So removing the middle checkpoint leaves the third to catch the same condition: toMatchObject({ state: 'cancelled', execution: 'not_started_proven' }) and the zero-length hook-execute filter both stay green, while the dispatch_started commit really does happen and only the spy sees it. The paragraph is accurate, not just plausible.

Design-doc conventions. Checked against the docs/design/README.md review checklist: both versions updated in the same PR; reciprocal language links already resolve in both directions; section order and heading levels stay aligned, with the new paragraph landing in "Pre-dispatch cancel (unit instrument)" and 「派发前取消(单测仪器)」 — the matching section in each, immediately before Non-goals / 非目标; and the technical identifiers (commitExtensionRecord, dispatch_started, hook-execute) are preserved verbatim in the translation rather than localized. No status, date, or milestone drift.

Nothing to cut. Adding a paragraph to the existing section rather than a bullet under "Mutation witnesses" is the right call — that list is scoped to the MySQL-lane integration cells, and this is the unit instrument.

Test evidence

This is an unattended CI run, so no PR-derived code was built, run, or mutated; the evidence below is the PR's own CI, read through the API for the reviewed commit. Everything that ran is green, and the skips are the expected ones for a docs/design/-only diff — no macOS/Windows matrix, no web-shell E2E, no tmux or verify lane. Lint & Static (ubuntu-latest, Node 22.x) passing is what substantiates the author's Prettier claim on the Markdown. delay-automatic-review and triage are bot orchestration jobs, not PR CI, and were still in flight at read time.

Final CI results for e2dc40b (auto-updated by the triage finalize job after CI completed):

Check Conclusion
Classify PR ✅ success
Integration Tests (no-AK, No Sandbox) ✅ success
Lint & Static (ubuntu-latest, Node 22.x) ✅ success
Managed Agent gate ✅ success
Select the Managed Agent tier ✅ success
Test (ubuntu-latest, Node 22.x) ✅ success

One row per check name (latest run); skipped checks omitted; failures sort first. / 每个检查名一行(取最新一次运行),省略 skipped,失败项排在最前。

Real-scenario testing: N/A — documentation only, nothing user-visible to drive.

Sandboxed lane: skipped, explicitly. The diff is prose with an unchanged public surface, so there is no behavioural delta for /verify to A/B against the base build, and no TUI surface for /tmux. Worth being precise about why: the mutant the paragraph describes is a change to already-merged production code, not to this PR, so no lane triggered on this head would execute it. The claim is settled by the static reading above, which is deterministic here — three identical conditions and one shared cancelBeforeDispatch().

中文说明

代码审查

无阻塞问题,也无 AGENTS.md 违规。文档型 PR 的关键在于文字是否属实,所以我对照代码而非对照 PR 描述核验了两处论断。

探针论断与已合并的单测完全一致。 packages/cli/src/serve/hosted-hook-session.test.ts 中的用例 cancels a Hook while the dispatch acquisition is held, before dispatch_started 安装了 commitExtensionRecord 探针,仅当 record.hookId !== '__plan__' && record.run?.execution === 'dispatch_started' 时压入 dispatched,随后断言 expect(dispatched).toEqual([])。这正是两个语言版本现在的表述——包括 __plan__ 这个排除条件,它是最容易在转述中丢失的细节,而没有丢。

变异论断在结构上成立。 hosted-hook-session.ts 的 perform() 在 intent 分支上用完全相同的条件 executionSignal.aborted || this.cancelRequested(id) || this.cancelRequested(marker.hookExecutionId) 设了三处检查点:executionBroker 获取之前、获取之后,以及 await this.commit('hook_execution', id, record) 写入 execution: 'dispatch_started' 之后。三者都返回 cancelBeforeDispatch(),它提交 state: 'cancelled' / execution: 'not_started_proven'——覆盖掉刚写入的 dispatch_started——并在发出任何 hook-execute 之前返回 cancelledResult()。因此去掉中间那个检查点,第三个仍会以相同条件兜住:toMatchObject({ state: 'cancelled', execution: 'not_started_proven' }) 与 hook-execute 的零长度过滤都保持为绿,而 dispatch_started 提交确实发生了,只有探针看得见。这段文字是准确的,不只是听起来合理。

设计文档规范。 对照 docs/design/README.md 的审查清单核验:两个语言版本在同一 PR 中更新;双向语言链接均可解析;章节顺序与标题层级保持对齐,新段落分别落在 "Pre-dispatch cancel (unit instrument)" 与「派发前取消(单测仪器)」——两边对应的小节,紧接在 Non-goals / 非目标 之前;技术标识符(commitExtensionRecord、dispatch_started、hook-execute)在译文中逐字保留而未本地化。无状态、日期或里程碑漂移。

没有可删减之处。相比在「变异见证」下加一条列表项,在现有小节中新增一段更合适——那份列表针对 MySQL lane 的集成用例,而这里是单测仪器。

测试证据

本次为无人值守 CI 运行,因此未构建、未执行、也未变异任何 PR 派生代码;以下证据来自 PR 自身的 CI,通过 API 针对被审查的 commit 读取。所有实际运行的检查均为绿,跳过项也符合仅改动 docs/design/ 的预期——没有 macOS/Windows 矩阵,没有 web-shell E2E,没有 tmux 或 verify lane。Lint & Static (ubuntu-latest, Node 22.x) 通过即佐证了作者在 Markdown 上的 Prettier 声明。delay-automatic-review 与 triage 是机器人编排任务,不属于 PR CI,读取时仍在运行中。

(CI 结果见上方表格。)

真实场景测试:N/A——仅文档改动,无可驱动的用户可见行为。

沙箱验证 lane:明确跳过。 本次 diff 为文字,公开接口未变,因此没有可供 /verify 与基线构建做 A/B 的行为差异,也没有可供 /tmux 验证的 TUI 界面。需要说清楚原因:该段落描述的变异体是对已合并生产代码的改动,而非对本 PR 的改动,所以在此 head 上触发的任何 lane 都不会执行它。该论断由上方的静态阅读判定,且在此处是确定性的——三个完全相同的条件,一个共享的 cancelBeforeDispatch()。

— Qwen Code · qwen3.8-max-2026-09-02

Reviewed at e2dc40b0da5c604c442913d0cfecdcb3f7197af1 · re-run with @qwen-code /triage

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Confidence: 5/5 — clean at every stage; I verified the prose against the code rather than against the PR description, and it holds.

My independent proposal before opening the diff was: the "Pre-dispatch cancel (unit instrument)" section names assertions that don't discriminate, so add a sentence identifying the spy that does, and mirror it in the Chinese version. That is exactly what this PR does, at that length, in that place. No simpler path was missed, and there is nothing in the diff that isn't needed for that goal — +10/-0, no drive-by edits, no reformatting of the surrounding text.

The part I'd normally be suspicious of is a docs PR asserting something about test strength, because those claims are cheap to write and rarely checked. This one survives checking. perform() really does guard the intent branch with the same condition at three points, the third sitting after the dispatch_started commit, and all three route to a cancelBeforeDispatch() that overwrites run to cancelled / not_started_proven and returns before any hook-execute is issued. So the middle checkpoint is genuinely invisible to every assertion the section previously named, and the spy is the only thing that sees the commit that shouldn't have happened. The doc was under-describing its own test; now it doesn't.

Six months from now this is the paragraph that stops someone from deleting that checkpoint, watching the suite stay green, and concluding the arm was never pinned. That's a real maintenance saving for ten lines of prose, and it matches the mutation-witness discipline the rest of the document already keeps. Both languages moved together with identifiers preserved verbatim, which is what the design-doc rules ask for.

One thing to be explicit about rather than bury: the mutant itself was never executed. This was an unattended CI run, so no PR-derived code was built or run, and in any case the mutation described here is a change to already-merged production code rather than to this diff — no sandboxed lane triggered on this head would run it. I settled it by reading the three checkpoints and the shared cancelBeforeDispatch(), which is a deterministic argument, not an empirical one. If a maintainer would rather see the red/green than take the structural reading, that's a two-minute local experiment, but I don't think the merge should wait on it.

Approving. ✅

中文说明

Confidence: 5/5 — 各阶段均无问题;我是对照代码而非对照 PR 描述核验这段文字的,结论成立。

在看 diff 之前,我的独立方案是:「派发前取消(单测仪器)」一节所列的断言不具备区分度,因此应补一句点明真正承重的探针,并在中文版同步。这正是本 PR 所做的——篇幅相当、位置相同。没有遗漏更简的路径,diff 中也没有任何与该目标无关的内容:+10/-0,无夹带改动,未重排周围文字。

我通常会警惕的一点,是文档型 PR 对测试强度作出论断——这类话写起来很廉价,也很少被核验。而这一次经得起核验。perform() 确实在 intent 分支上以相同条件设了三处检查点,第三处位于 dispatch_started 提交之后,且三者都汇入 cancelBeforeDispatch();该函数把 run 覆写为 cancelled / not_started_proven,并在发出任何 hook-execute 之前返回。所以中间那个检查点对该节此前列出的每一个断言都是不可见的,而探针是唯一能看见那次「本不该发生的提交」的东西。文档此前低估了自己的测试;现在不会了。

半年之后,正是这一段能阻止某人删掉那个检查点、看着测试套件仍为绿、进而得出「该分支从未被钉住」的结论。用十行文字换来这个实际的维护收益是划算的,也与文档其余部分一贯保持的变异见证纪律相符。两种语言同步更新且标识符逐字保留,这正是设计文档规则所要求的。

有一点要明确说出来而不是含糊带过:变异体本身并未被执行。本次为无人值守 CI 运行,因此未构建、未运行任何 PR 派生代码;而且此处描述的变异是对已合并生产代码的改动,而非对本 diff 的改动——在此 head 上触发的任何沙箱 lane 都不会执行它。我通过阅读三处检查点与共享的 cancelBeforeDispatch() 来判定,这是一个确定性的论证,而非经验性的论证。如果维护者更愿意看到实际的红/绿结果而非接受这一结构性阅读,那是一个两分钟的本地实验,但我认为合并不应为此等待。

已批准。✅

— Qwen Code · qwen3.8-max-2026-09-02

Reviewed at e2dc40b0da5c604c442913d0cfecdcb3f7197af1 · re-run with @qwen-code /triage

@qwen-code-review-bot qwen-code-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, looks ready to ship. ✅

@yiliang114 yiliang114 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I checked the new paragraph against the code at e2dc40b0 instead of taking the description's word for it, and the mechanism it describes is the real one.

  • packages/cli/src/serve/hosted-hook-session.ts has exactly three cancelBeforeDispatch() call sites inside perform: pre-acquisition (1209), post-acquisition (1219), and one after the dispatch_started commit (1244). So "a third cancel checkpoint after the dispatch_started commit" is accurate, not an approximation.
  • Deleting the post-acquisition check still lands on that third checkpoint, which commits cancelled / not_started_proven and returns before any dispatch. That is why the final-record assertion and the zero-hook-execute count stay green under the mutant, exactly as the paragraph claims. The only thing that goes red is expect(dispatched).toEqual([]) in the FG13d cell (test line 1205), fed by the commitExtensionRecord spy filtered to hookId !== '__plan__' && run.execution === 'dispatch_started'.
  • The EN and .zh-CN paragraphs carry the same mechanism and the same checkpoint count — no twin drift, which is the failure mode I usually find in these design-doc pairs.

Scope is cohesive (+10/-0 across the two design docs, one commit), and Lint & Static is green at this head. Nothing blocking.

@yiliang114 yiliang114 added scope/documentation Documentation tooling type/documentation Documentation improvements or additions labels Oct 19, 2026
@yiliang114
yiliang114 merged commit 5dcf7c7 into main Oct 19, 2026
87 of 88 checks passed
@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Released in v0.26.0.

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

Labels

scope/documentation Documentation tooling type/documentation Documentation improvements or additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants