Skip to content

fix(managed-agent): order a sender's commands by commit sequence, and make the member restart IT interrupt a live wait - #14014

Merged
wenshao merged 3 commits into
mainfrom
fix/session-command-relay-order
Oct 13, 2026
Merged

wenshao merged 3 commits into
mainfrom
fix/session-command-relay-order

Conversation

@wenshao

@wenshao wenshao commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

What this PR does

This PR follows up on #13928. It fixes the relay's per-sender command order, removes an unused helper, and rebuilds the member restart IT so that the restart actually interrupts a live command wait.

  • Per-sender command order. The relay passes one sender's commands strictly in commit order.
    • The guard that enforced this compared command ids. A command id is a digest of the sender, prompt and call, so "older" was a random permutation of commit order.
    • It now compares each outbound's first_sequence, the sequence at which that record was first committed in the sender's journal.
    • An older planned or accepting entry now blocks a younger one even when discovery has not yet opened a ledger row for it. The design says this ("whether or not it has a ledger row yet"); the old INNER JOIN skipped such entries.
  • Unused helper removed. isUnfinishedCommand restated the relay's planned/accepting rule but had no production caller, so it could only drift from the relay's SQL. It is removed.
  • The restart IT now interrupts a live wait.
    • The relay is held from the start, by parking a task on its single-thread scheduler. carol's command therefore cannot move.
    • The kill happens only after the lead's Turn has settled and carol's command is asserted to be planned.
    • The relay is released only after a new writer generation holds carol's Session, i.e. after the coordinator's takeover load has fenced the dead generation.
    • The case then asserts that the reply folds into the parked wait (consumed) and that the lead accepts carol's result.
    • The class runs with a 15 s writer lease, so the takeover lands well inside the command's 2-minute bound.

Why it's needed

These are the non-blocking review follow-ups on #13928: r4253304973, r4253304983 and r4253304991, plus F2 of the real-stack verification.

  • The ordering guard. It cannot see two open entries from one sender today, because the member awaits each command call in turn and the Turn lock refuses the rest. So it was a latent bug: it would have bitten the first producer that leaves two entries open.
  • The restart IT. The old version killed the Harness only after carol had already finished. Its kill condition matched any checkpoint that ever named await_command, and it also waited for the lead's Turn to settle. So it passed whether or not a parked command wait could be resumed. That is how feat(managed-agent): member board tools ride the session_command channel end to end (H4e-b3b) #13928's continue-gate bug (every await_command continue answered 409) got through CI.

Reviewer Test Plan

How to verify

  • Ordering. Run SessionMessageRelayStoreTest. The new case ordersCommandsByCommitOrderAndCountsAnEntryWithoutARow commits cmd_z_first before cmd_a_second, so the later id sorts first. It then expects the younger command to wait behind the older one, both before and after the older one gets its ledger row, and to stop waiting once the older row is classified. On the old SQL the case fails at its first assertion.
  • Restart IT. Run HostedTeamMemberCommandMySqlIT on a disposable MySQL schema, the same way the hosted-harness-mysql lane does: -Phosted-harness-mysql -Dnode.executable=… -Dqwen.cli.entry=<repo>/dist/cli.js -Dmysql.url=… -Dmysql.user=… -Dmysql.password=…, after npm run build && npm run bundle. In each restart run, the Harness log shows carol's writer-conflict loads until the dead lease lapses, then one takeover load and one POST /session/:id/managed-runtime/continue answered 200.
  • Mutation control. Revert feat(managed-agent): member board tools ride the session_command channel end to end (H4e-b3b) #13928's continue-gate fix in hosted-harness-session.ts and re-bundle. The restart case then fails: every continue gets 409 continuation_not_ready with phase=await_command, and the lead never receives carol's result. The old IT passed in that state.

Evidence (Before & After)

N/A — no UI change. The results below are from local runs on macOS (arm64) with JDK 21, Node 24 and MySQL 8.4.7 native, using a disposable schema.

Check Result
SessionMessageRelayStoreTest, SessionMessageRelayTest, ManagedSessionCommandRecordContractTest 61/61. The new ordering case fails on the old SQL.
managed-session-command-record.test.ts 68/68
Restart case, final version 5/5, 53–54 s each. Each run has one takeover continue 200, and carol's writer generation advanced.
Restart case, continue-gate fix reverted Fails. continue → 409 continuation_not_ready (phase=await_command).
Full class (membersReadAndWriteTheBoardTheirLeadReads + restart) 2/2 in each of 2 runs (97–99 s per class)
Checkstyle (managed-agent-server) clean

Tested on

OS Status
🍏 macOS ✅ tested
🪟 Windows ⚠️ not tested
🐧 Linux ⚠️ not tested (the MySQL lane runs it in CI)

Environment (optional)

mvn -Phosted-harness-mysql failsafe:integration-test failsafe:verify against a native MySQL 8.4.7 on a free local port, with the bundled dist/cli.js from this branch.

Risk & Scope

  • Main risk or tradeoff:
    • The IT's hold relies on messageRelayScheduler having a single thread, which is how it is configured. If its pool ever grows, the hold no longer stops the relay. The case would then fail at its own planned precondition rather than pass vacuously.
    • The 15 s writer lease applies to both cases in the class. The lifecycle case does not depend on the lease.
  • Not validated / out of scope:
  • Breaking changes / migration notes: none. No migration; the relay's query reads the existing first_sequence column.

Linked Issues

Refs #13928.

中文说明

本 PR 做了什么

本 PR 是 #13928 的后续:修正 relay 对同一发送方命令的排序,删除一个无用的辅助函数,并重做成员重启 IT,让重启真正打断一个仍在进行的命令等待。

  • 同一发送方的命令顺序。 relay 必须严格按提交顺序处理同一发送方的命令。
    • 原来的守卫比较的是命令 id。命令 id 是发送方、prompt、调用三者的摘要,所以按它判断「更早」,等于对提交顺序做了一次随机排列。
    • 现在改为比较每条 outbound 的 first_sequence,即该记录在发送方 journal 里首次提交时的序号。
    • 更早的 planned 或 accepting 条目,即使 discovery 还没为它建 ledger 行,现在也会挡住后来的命令。这是设计文档的要求(「不管有没有 ledger 行」),原来的 INNER JOIN 会跳过这类条目。
  • 删除无用的辅助函数。 isUnfinishedCommand 重复了 relay 的 planned/accepting 规则,但没有任何生产调用方,只会和 relay 的 SQL 渐渐不一致,已删除。
  • 重启 IT 现在会打断进行中的等待。
    • 场景一开始就占住 relay 单线程调度器上的唯一线程,让 relay 停住,carol 的命令因此无法推进。
    • 只在 lead 的 Turn 已结束、且断言 carol 的命令仍为 planned 之后才杀进程。
    • 要等新的 writer generation 持有 carol 的 session(即协调器的接管 load 已把死掉的 generation 隔离掉)之后,才放开 relay。
    • 随后断言回复被 fold 进那个停住的等待(consumed),并且 lead 收到了 carol 的结果。
    • 这个测试类使用 15 s 的写锁租约,让接管远早于命令的 2 分钟上限完成。

为什么需要

这些是 #13928 不阻塞的评审后续:r4253304973、r4253304983、r4253304991,以及真实栈验证中的 F2。

  • 排序守卫。 目前同一发送方不会同时有两条未完成的条目:成员逐个等待命令调用,Turn 锁又会拒绝其余调用。所以这是一个潜伏的 bug,第一个让两条条目同时处于未完成状态的生产方就会踩到它。
  • 重启 IT。 旧版要等 carol 已经跑完才杀 Harness:它的 kill 条件会匹配任何曾经写过 await_command 的 checkpoint,而且还要等 lead 的 Turn 结束。所以停住的命令等待能不能续跑,它都会通过。feat(managed-agent): member board tools ride the session_command channel end to end (H4e-b3b) #13928 的 continue 闸门 bug(所有 await_command 的 continue 都回 409)正是这样通过了 CI。

评审者测试计划

如何验证

  • 排序。 跑 SessionMessageRelayStoreTest。新用例 ordersCommandsByCommitOrderAndCountsAnEntryWithoutARow 先提交 cmd_z_first 再提交 cmd_a_second,所以后提交的 id 反而排在前面。它要求后来的命令一直排在更早那条之后,在更早那条有 ledger 行之前和之后都是如此,直到更早那条的 ledger 行被分类为止。换回旧 SQL,该用例在第一个断言就失败。
  • 重启 IT。 先 npm run build && npm run bundle,再用一个一次性 MySQL schema 跑 HostedTeamMemberCommandMySqlIT,方式与 hosted-harness-mysql lane 相同:-Phosted-harness-mysql -Dnode.executable=… -Dqwen.cli.entry=<repo>/dist/cli.js -Dmysql.url=… -Dmysql.user=… -Dmysql.password=…。每次重启场景的 Harness 日志都是:carol 的 load 先因写锁冲突被拒,直到死掉的租约到期;然后是一次接管 load,以及一次返回 200 的 POST /session/:id/managed-runtime/continue。
  • 变异对照。 把 feat(managed-agent): member board tools ride the session_command channel end to end (H4e-b3b) #13928 在 hosted-harness-session.ts 里的 continue 闸门修复改回去并重新打 bundle,重启场景就会失败:每次 continue 都得到 409 continuation_not_ready(phase=await_command),lead 始终收不到 carol 的结果。旧版 IT 在同样状态下是通过的。

证据(前后对比)

N/A,没有 UI 改动。以下结果来自本地运行:macOS(arm64)、JDK 21、Node 24、原生 MySQL 8.4.7,使用一次性 schema。

检查 结果
SessionMessageRelayStoreTest、SessionMessageRelayTest、ManagedSessionCommandRecordContractTest 61/61。新的排序用例在旧 SQL 下失败。
managed-session-command-record.test.ts 68/68
重启场景(最终版) 5/5,每次 53–54 s。每次都有一次接管 continue 返回 200,carol 的 writer generation 增加。
重启场景(还原 continue 闸门修复) 失败。continue → 409 continuation_not_ready(phase=await_command)。
整个测试类(membersReadAndWriteTheBoardTheirLeadReads + 重启) 连跑 2 次,每次 2/2(每次 97–99 s)
Checkstyle(managed-agent-server) 通过

测试平台

OS 状态
🍏 macOS ✅ 已测试
🪟 Windows ⚠️ 未测试
🐧 Linux ⚠️ 未测试(CI 的 MySQL lane 会跑)

环境(可选)

mvn -Phosted-harness-mysql failsafe:integration-test failsafe:verify,连接本地空闲端口上的原生 MySQL 8.4.7,使用本分支打出的 dist/cli.js。

风险与范围

关联 Issue

Refs #13928.

olderOpenCommand compared message ids, but a command id is a digest of
the sender, prompt and call, so a later command could sort before an
earlier one and the per-sender order was a random permutation of commit
order. It now compares each outbound's first_sequence in the sender's
journal, and an older planned or accepting entry discovery has not opened
a ledger row for yet holds the younger one back too, as the design's
"whether or not it has a ledger row" says. The probe is an existence
check.
Its planned/accepting rule had no production caller; the relay's SQL is
the one enforcer of the per-sender order, so a second copy could only
drift.
…and wait

The restart case killed the Harness only after carol had finished: its
kill condition matched any checkpoint that ever named await_command and
also waited for the lead's Turn to settle, so it passed whether or not a
parked command wait could be resumed. That let #13928's continue-gate
bug through CI.

The case now holds the session message relay from the start by parking a
task on its single-thread scheduler, kills only once carol's command is
asserted planned, and releases the relay only after a new writer
generation holds her Session, so the reply folds into the wait the dead
generation parked. The class runs with a 15 s writer lease so the
takeover lands well inside the command's 2-minute bound.
@qwen-code-review-bot

qwen-code-review-bot commented Oct 13, 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 — this is the #13928 follow-up, and the three pieces hang together.

Template looks good ✓

Problem: real, and evidenced rather than hypothetical. Two distinct things here. The ordering guard is a spec-conformance defect: docs/design/2026-10-11-managed-agent-team-member-commands.md says an older planned/accepting outbound holds a younger one back "whether or not it has a ledger row yet", and the old SQL contradicted that twice over — it compared hashed command ids, so "older" was a random permutation of commit order, and its INNER JOIN dropped exactly the ledger-less entries the design says must count. You're right that no producer can leave two entries open today, so it's latent — but the new unit test fails on the old SQL, which is a concrete reproduction at the store level rather than a "could theoretically". The IT half is a plainly observed failure: a test that stayed green while #13928's continue-gate bug (every await_command continue answered 409) rode through CI is not a theoretical concern, it's a false-confidence gate that already cost one escape.

Direction: aligned. These are accepted review follow-ups on a PR merged about three hours ago, bringing the store into line with an existing design doc and retiring a green-but-vacuous gate. Internal managed-agent server surface, no public contract change. CHANGELOG: no direct reference, but the area is live — #13928 landed yesterday.

Size: core paths are touched (packages/core/src/managed-runtime/**) and the change spans two packages, so Stage 0 applies. 58 production lines (43 in the relay store, 15 deletions in the command operations module) against 182 test lines and 0 generated/schema. Well under the 500-line escalation threshold; you're a maintainer, so Tier 1 is exempt regardless, and the title is fix, not refactor. Tier 2's bar is naming every downstream consumer, and they are all nameable: olderOpenCommand has exactly one production caller (SessionMessageRelay.workCommand), isUnfinishedCommand has none and is not re-exported from any barrel, and first_sequence is an existing column the production insert already populates.

Approach: the scope feels right, and I don't see a smaller correct version of the ordering fix — swapping the comparison key to the journal sequence and widening the join to a LEFT JOIN is the minimum that satisfies the design. Bundling the isUnfinishedCommand removal is the right call rather than scope creep: it restated the same planned/accepting rule, so leaving it behind after changing the SQL would have guaranteed the drift you're deleting it to avoid. Replacing its assertions with the direct delivery.state checks keeps the coverage instead of dropping it.

Risk: no elevated risk signals — none of the five files match the high-risk paths. Two things worth watching, both non-blocking:

  • The IT's hold depends on messageRelayScheduler being poolSize(1). It is (ManagedArtifactConfiguration), and you've documented the coupling plus the fact that it would fail loudly at its own planned precondition rather than pass vacuously — the right way to carry a fragile dependency.
  • @Timeout(180) against inner waits that total up to ~290s relies on JUnit interrupting, and you've already seen one run not interrupt and hold the fork to failsafe's 1200s. Worth an eye on the MySQL lane.

Moving on to code review. 🔍

中文说明

感谢 — 这是 #13928 的后续,三块改动是一个整体。

模板完整 ✓

问题: 真实存在,且有证据,不是假设性的。这里其实是两件不同的事。排序守卫是一个与设计文档不一致的缺陷:docs/design/2026-10-11-managed-agent-team-member-commands.md 明确要求更早的 planned/accepting outbound「不管有没有 ledger 行」都要挡住后来的命令,而旧 SQL 在两个地方都违背了它 —— 一是比较的是命令 id 的哈希,所以「更早」等于对提交顺序做随机排列;二是它的 INNER JOIN 恰好把设计文档要求必须计入的、还没有 ledger 行的条目丢掉了。你说得对,今天没有生产方能让两条条目同时处于未完成状态,所以这是潜伏的 —— 但新的单元测试在旧 SQL 下会失败,这是 store 层面的具体复现,不是「理论上可能」。重启 IT 那一半则是明确已观测到的失败:一个在 #13928 的 continue 闸门 bug(所有 await_command 的 continue 都回 409)通过 CI 时始终保持绿色的测试,不是理论问题,而是一个已经造成过一次漏网的假信心闸门。

方向: 对齐。这些是一个约三小时前刚合并的 PR 上已被接受的评审后续,把 store 拉回与现有设计文档一致,并退役一个绿色但空转的闸门。属于 managed-agent server 内部接口,没有公共契约变更。CHANGELOG:没有直接对应条目,但这个区域很活跃 —— #13928 昨天刚落地。

规模: 触及核心路径(packages/core/src/managed-runtime/**),且跨两个 package,因此 Stage 0 适用。生产代码 58 行(relay store 43 行,command operations 模块删除 15 行),测试 182 行,生成/schema 0 行。远低于 500 行的升级阈值;你是维护者,Tier 1 本就豁免,且标题是 fix 而非 refactor。Tier 2 的要求是点名每一个下游消费方,这里都能点名:olderOpenCommand 只有一个生产调用方(SessionMessageRelay.workCommand),isUnfinishedCommand 没有任何生产调用方、也没有从任何 barrel 再导出,first_sequence 是已有列、生产写入路径本来就会填充。

方案: 范围合理,我也看不到更小且正确的排序修复 —— 把比较键换成 journal 序号、并把 join 放宽为 LEFT JOIN,就是满足设计文档的最小改动。把 isUnfinishedCommand 的删除一起带上是正确选择,而不是夹带范围:它复述了同一条 planned/accepting 规则,改完 SQL 后把它留下,恰恰会造成你删它想避免的那种漂移。把它的断言替换为直接的 delivery.state 检查,保住了覆盖率而不是丢掉。

风险: 无升级风险信号 —— 五个文件都不匹配高风险路径。有两点值得关注,均不阻塞:

  • IT 里的占位依赖 messageRelayScheduler 只有一个线程。事实确实如此(ManagedArtifactConfiguration),并且你已经写明了这个耦合,以及一旦线程池变大它会在自己的 planned 前置条件处响亮地失败、而不是空转通过 —— 这是承载脆弱依赖的正确方式。
  • @Timeout(180) 对应内部等待累计最长约 290 秒,依赖 JUnit 能中断;而你已经遇到过一次没有中断、一直占到 failsafe 1200 秒的运行。MySQL lane 值得留意。

进入代码审查 🔍

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

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

@qwen-code-review-bot

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

Copy link
Copy Markdown
Collaborator

Code review

I read the diff against the base and checked the load-bearing assumptions rather than taking them from the description. No blockers. The ordering fix is correct, and — more importantly — it isn't silently inert, which was the main way a change like this could ship looking right while doing nothing:

  • first_sequence is real and populated in production. The column was added to qwen_managed_session_extension_record by V27 (BIGINT NOT NULL DEFAULT 0), and the production insert in ManagedExtensionRecordStore writes the actual commit sequence into it, not the default. Had that insert left it at 0, r.first_sequence < c.first_sequence would never hold and the guard would have stopped firing entirely — a worse bug than the one being fixed. It doesn't.
  • The new INNER JOIN on c cannot silently no-block. Widening the ledger join to LEFT JOIN while joining c innerly means a missing c row would return "no older open command" and let the relay pass out of order. That path is unreachable: SessionMessageRelay returns early when currentRecord is null, and currentRecord selects on exactly the same (tenant_id, session_id, domain, record_id) tuple the c join binds.
  • No ordering hole from tied sequences. Two commands of one sender committed in the same transaction would share a first_sequence, and strict < would let each past the other. ManagedExtensionRecordStore documents that a transaction carries at most one Stage H record, so the tie cannot arise.
  • The new test genuinely discriminates. The existing ordersCommandsByTheirOpenWindowOnly uses ids that already sort in commit order (cmd_1_cancelled < cmd_2_open < cmd_3_new), so it passed under both the old and the new SQL — which is why the bug survived it. cmd_z_first / cmd_a_second inverts spelling against commit order, so it fails on the old SQL for both reasons at once. I also confirmed classify updates only the ledger row's state and never delivery_state, so the final isFalse() assertion is pinned by the l.state NOT IN (...) predicate rather than passing incidentally.
  • The removal is clean. isUnfinishedCommand has no production caller and is not re-exported from any barrel — only the one test imported it. SessionCommand stays used elsewhere in the module, so the type import doesn't go unused, and the substitute assertions keep the delivery-state coverage.
  • Nothing was left behind. l.message_id < ? was the only hashed-id ordering comparison anywhere in the Java tree, so no sibling relay carries the same latent bug. The query's r predicate is covered by V64's (tenant_id, session_id, domain) index.

Two non-blocking notes:

  • writerGeneration's generation == null ? 0 : generation looks unreachable — queryForObject throws EmptyResultDataAccessException when no row exists rather than returning null, and writer_generation is BIGINT NOT NULL, so a null value can't come back either. Dead guard; if you ever want the missing-row case to read as 0 it needs an explicit empty-result catch.
  • No index leads with first_sequence, so the per-sender command set is filtered rather than range-scanned, and LIMIT 1 can't stop early in sequence order. It's bounded by one session's commands and reuses the access path currentRecord already takes, so I don't think it matters — just noting it since the relay calls this on every command pass.

Test evidence

This is an unattended CI run, so nothing here was built or executed by me — the evidence is the PR's own CI, read through the API at 595dcac82bec833e4b963b86dc0f3ece8bc936e4. I ran no PR-derived code.

The one red check is infrastructure noise, not this PR. ubuntu-latest / Java 11 died inside actions/checkout, before any build or test step:

[command]/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +refs/pull/14014/head:refs/remotes/pull/14014/head
##[error]fatal: unresolved deltas left after unpacking
##[error]fatal: unpack-objects failed
##[error]The process '/usr/bin/git' failed with exit code 128

It retried three times and failed identically each time, ~20 seconds after the PR was opened. That's a runner-level git object unpack failure on actions-runner-hk2-21; it never reached the diff.

The two lanes that actually settle this change are both still running: ubuntu-latest / Java 21 (the H2 store tests, including the new ordersCommandsByCommitOrderAndCountsAnEntryWithoutARow) and Hosted process fault gates / MySQL 8.4 / Java 21 (the hosted-harness-mysql lane that runs the rebuilt HostedTeamMemberCommandMySqlIT). Not verified: whether the rewritten restart IT passes on Linux CI. I'm not polling — the table below is a single snapshot and the finalize job updates it once CI lands.

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

Check Conclusion
ubuntu-latest / Java 11 🚫 cancelled
Classify PR ✅ success
Desktop Shell (ubuntu-22.04) ✅ success
Desktop Shell (windows-2022) ✅ success
Flyway migration version uniqueness ✅ success
Hosted process fault gates / MySQL 8.4 / Java 21 ✅ success
Integration Tests (no-AK, No Sandbox) ✅ success
Lint & Static (ubuntu-latest, Node 22.x) ✅ success
macos-latest / Java 21 ✅ success
Real daemon E2E / Java 11 ✅ success
Runtime Broker and Managed Agent MariaDB / Java 21 ✅ success
Test (ubuntu-latest, Node 22.x) ✅ success
ubuntu-latest / Java 17 ✅ success
ubuntu-latest / Java 21 ✅ success
web-shell E2E Smoke (ubuntu-latest, Node 22.x) ✅ success
windows-latest / Java 21 ✅ success

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

Everything in the Evidence table in the PR description — the 61/61 store tests, 5/5 restart runs, and the mutation control — is the author's own local result on macOS (arm64, JDK 21, Node 24, MySQL 8.4.7), not something I re-ran or can confirm from here. Linux and Windows are marked untested by the author.

Sandboxed verification would settle the one claim that green CI structurally cannot: @qwen-code /verify — that the rebuilt restart IT is no longer vacuous. CI runs the IT, but it never runs the mutation control, so a green MySQL lane proves the test passes, not that it would fail when #13928's continue-gate fix is reverted. That A/B against the base build is exactly the load-bearing proof here, and it's the whole point of the rewrite.

中文说明

代码审查

我把 diff 对着基线代码读了,并核实了几个关键假设,而不是直接采信 PR 描述。没有阻塞项。排序修复是正确的,更重要的是它不是静默失效的 —— 这是这类改动最可能「看起来对、实际什么都没做」的地方:

  • first_sequence 真实存在且生产路径会填充。 该列由 V27 加到 qwen_managed_session_extension_record(BIGINT NOT NULL DEFAULT 0),而 ManagedExtensionRecordStore 的生产 INSERT 写入的是真实提交序号,不是默认值。如果那条 INSERT 让它停在 0,r.first_sequence < c.first_sequence 永远不成立,守卫就会彻底失效 —— 那比被修的 bug 更糟。事实并非如此。
  • 新的 c 内连接不会静默地「不拦截」。 把 ledger join 放宽为 LEFT JOIN、同时对 c 用内连接,意味着 c 行缺失时会返回「没有更早的未完成命令」,从而让 relay 乱序放行。这条路径不可达:SessionMessageRelay 在 currentRecord 为 null 时提前返回,而 currentRecord 的查询条件与 c join 绑定的 (tenant_id, session_id, domain, record_id) 完全一致。
  • 序号相同不会造成排序漏洞。 同一发送方的两条命令若在同一事务提交,会共享 first_sequence,严格 < 会让二者互相放行。ManagedExtensionRecordStore 明确说明一个事务最多携带一条 Stage H 记录,因此这种并列不会出现。
  • 新测试确实有区分度。 已有的 ordersCommandsByTheirOpenWindowOnly 用的 id 本身就按提交顺序排列(cmd_1_cancelled < cmd_2_open < cmd_3_new),所以它在新旧 SQL 下都通过 —— 这正是 bug 能活下来的原因。cmd_z_first / cmd_a_second 把拼写顺序与提交顺序反转,因此在旧 SQL 下会同时因两个原因失败。我还确认了 classify 只更新 ledger 行的 state、从不更新 delivery_state,所以最后那个 isFalse() 断言是被 l.state NOT IN (...) 谓词钉住的,而不是碰巧通过。
  • 删除是干净的。 isUnfinishedCommand 没有生产调用方,也没有从任何 barrel 再导出 —— 只有那一个测试引用它。SessionCommand 在模块内其他地方仍在使用,类型导入不会变成未使用,替换后的断言也保住了 delivery-state 的覆盖。
  • 没有遗漏同类问题。 l.message_id < ? 是整个 Java 代码树里唯一一处按哈希 id 排序的比较,所以没有其他 relay 带着同样的潜伏 bug。查询中 r 的条件由 V64 的 (tenant_id, session_id, domain) 索引覆盖。

两点不阻塞的说明:

  • writerGeneration 里的 generation == null ? 0 : generation 看起来不可达 —— 无行时 queryForObject 抛的是 EmptyResultDataAccessException 而不是返回 null,而 writer_generation 是 BIGINT NOT NULL,也不可能取到 null 值。这是个死守卫;如果你希望「行缺失」真的读作 0,需要显式捕获空结果。
  • 没有以 first_sequence 打头的索引,所以同一发送方的命令集合是被过滤而非按序范围扫描,LIMIT 1 也无法按序号提前停止。它的规模受单个 session 的命令数限制,且复用了 currentRecord 已有的访问路径,所以我认为不构成问题 —— 只是既然 relay 每次命令传递都会调用它,还是记一笔。

测试证据

这是一次无人值守的 CI 运行,所以这里没有任何东西是我构建或执行的 —— 证据是 PR 自己的 CI,通过 API 在 595dcac82bec833e4b963b86dc0f3ece8bc936e4 上读取。我没有运行任何来自 PR 的代码。

唯一的红色检查是基础设施噪音,与本 PR 无关。ubuntu-latest / Java 11 死在 actions/checkout 内部,早于任何构建或测试步骤,日志见上(fatal: unresolved deltas left after unpacking / unpack-objects failed,退出码 128)。它重试三次、每次失败完全相同,发生在 PR 创建后约 20 秒。这是 actions-runner-hk2-21 上 runner 层面的 git 对象解包失败,根本没碰到 diff。

真正决定这次改动的两个 lane 都还在运行:ubuntu-latest / Java 21(H2 store 测试,含新的 ordersCommandsByCommitOrderAndCountsAnEntryWithoutARow)和 Hosted process fault gates / MySQL 8.4 / Java 21(跑重建后的 HostedTeamMemberCommandMySqlIT 的 hosted-harness-mysql lane)。未验证:重建后的重启 IT 在 Linux CI 上是否通过。我不做轮询 —— 上表是一次性快照,CI 落定后由 finalize 任务更新。

PR 描述里 Evidence 表格中的全部内容 —— store 测试 61/61、重启场景 5/5、变异对照 —— 都是作者本人在 macOS(arm64、JDK 21、Node 24、MySQL 8.4.7)上的本地结果,不是我复跑的,也无法从这里确认。作者标注 Linux 与 Windows 未测试。

沙箱验证可以解决绿色 CI 在结构上无法解决的那一条:@qwen-code /verify —— 即重建后的重启 IT 不再空转。CI 会跑这个 IT,但永远不会跑变异对照,所以 MySQL lane 变绿只能证明测试通过,不能证明当 #13928 的 continue 闸门修复被还原时它会失败。针对基线构建的这个 A/B 恰恰是此处的关键证据,也正是这次重写的全部意义。

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

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

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Confidence: 4/5 — the fix is correct and I closed every way I could find for it to be silently wrong; holding back the fifth only because the load-bearing evidence (the mutation control) is the one thing CI structurally cannot reproduce.

Before reading the diff I wrote down what I'd do from the title and the "Why it's needed" section: if the guard decides "older" from a content digest, the fix is to decide it from the journal's monotonic sequence instead — a value the record already carries — and to stop requiring a ledger row, since the design explicitly says an entry counts whether or not discovery has opened one. That's what you did. I didn't find a simpler path, and I don't think one exists that still satisfies the design doc.

What I'd credit most is the instinct behind the IT rewrite. A test that passes whether or not the behaviour works is worse than no test, because it's the reason a real bug reached main. You didn't just assert the new version is better — you reverted #13928's continue-gate fix and showed the new IT fails while the old one passed. That's the correct way to prove a gate has teeth, and it's the claim I'd most want preserved.

Two honest reservations, neither blocking:

On the question I always end with — would I curse whoever wrote this in six months? No. The SQL now matches the design doc instead of contradicting it, the helper that could only drift from that SQL is gone rather than left to rot, and the IT's fragile poolSize(1) assumption fails loudly at its own planned precondition instead of quietly going vacuous again. Those are the choices that age well.

I'm not approving because I ran out of objections. I checked the specific ways a change like this ships looking right while doing nothing — an unpopulated column, an unreachable join arm, tied sequences, a test that never discriminated — and each one is closed by something I read in the base tree, not by the description.

Verdict: approve. Both CI runs (Qwen Code CI, SDK Java) are still in flight, including ubuntu-latest / Java 21 and the MySQL lane that actually runs the rewritten IT, so I'm not posting an approval in this run — approving now would attest to a result that doesn't exist yet. Approval is deferred until CI lands green on 595dcac82bec833e4b963b86dc0f3ece8bc936e4; the finalize job posts the commit-pinned approval and withholds it if anything lands red or the head moves. The one red check so far is the Java 11 runner's git unpack failure, which never reached your diff — a re-run should clear it.

中文说明

置信度:4/5 —— 修复是正确的,我能想到的每一种「静默出错」的可能都已逐一排除;之所以不给满分,只因为最关键的那份证据(变异对照)恰恰是 CI 在结构上无法复现的。

在读 diff 之前,我先根据标题和「为什么需要」写下了自己会怎么做:如果守卫是依据内容摘要来判断「更早」,那修复就应该改为依据 journal 的单调序号 —— 一个记录本身已经携带的值 —— 并且不再要求存在 ledger 行,因为设计文档明确说过不管 discovery 有没有建行都要计入。你做的正是这个。我没有找到更简的路径,也不认为在仍满足设计文档的前提下存在更简的路径。

我最认可的是重启 IT 重写背后的判断力。一个不论行为是否正确都会通过的测试,比没有测试更糟,因为它正是一个真实 bug 进入 main 的原因。你没有只是宣称新版更好 —— 你把 #13928 的 continue 闸门修复还原,证明了新 IT 会失败而旧 IT 会通过。这是证明一个闸门有牙齿的正确方式,也是我最希望被保留下来的那条结论。

两点坦白的保留意见,均不阻塞:

关于我最后总会问的那个问题 —— 六个月后我会不会骂写这段代码的人?不会。SQL 现在与设计文档一致而不再相互矛盾,那个只会与 SQL 渐渐不一致的辅助函数被删掉而不是留着腐烂,而 IT 脆弱的 poolSize(1) 假设会在自己的 planned 前置条件处响亮失败,而不是再次悄悄变成空转。这些都是经得起时间的选择。

我不是因为没有反对意见了才批准。我检查了这类改动「看起来对、实际什么都没做」的几种具体形态 —— 列没被填充、join 分支不可达、序号并列、测试从来没有区分度 —— 每一种都被我在基线代码树里读到的东西排除了,而不是靠 PR 描述。

结论:批准。 两个 CI run(Qwen Code CI、SDK Java)都还在进行,其中包括 ubuntu-latest / Java 21 和真正会跑重建后 IT 的 MySQL lane,所以本次运行我不提交批准 —— 现在批准等于为一个尚不存在的结果背书。批准将延后到 CI 在 595dcac82bec833e4b963b86dc0f3ece8bc936e4 上全绿;finalize 任务会提交绑定该 commit 的批准,若有检查变红或 head 移动则不予提交。目前唯一的红色检查是 Java 11 runner 的 git 解包失败,它根本没碰到你的 diff —— 重跑一次应该就能清掉。

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

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

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

评审提交:595dcac82bec833e4b963b86dc0f3ece8bc936e4

未发现本次变更引入的阻塞性问题。

已核实以下路径:

  • olderOpenCommand 的唯一生产调用方是 SessionMessageRelay.workCommand。first_sequence 在首次提交时写入,后续 revision 不改写;查询按 tenant、sender 和 domain 限定范围,且把尚未创建 ledger 行的旧 planned / accepting 命令纳入阻塞条件。
  • 删除的 isUnfinishedCommand 在基线只有测试引用,没有生产调用方或 barrel 导出。
  • 重启测试在创建场景前占住 relay 的单线程 scheduler,杀进程前要求唯一命令仍为 planned,重启后等待 writer generation 增加,最终同时检查命令 consumed 和 lead 已接受结果。这些断言补上了原先只匹配历史 checkpoint 的缺口。

验证结果:

  • 本地在该提交的隔离快照、JDK 21 下运行 SessionMessageRelayStoreTest、SessionMessageRelayTest、ManagedSessionCommandRecordContractTest:61/61 通过,0 失败、0 错误、0 跳过。
  • 独立 JDBC/H2 对照探针调用实际 Store 类:新版本 16/16 通过;将类换成基线版本后,相同条件出现 6 项预期失败,分别重现 planned / accepting 下无 ledger 漏阻塞、反序 ID 漏阻塞和年轻命令误阻塞旧命令。
  • 同一 head 的 MySQL CI 日志 确认 HostedTeamMemberCommandMySqlIT 2/2 通过。

验证范围:本地未重跑完整 MySQL E2E、TypeScript 测试或 continue-gate mutation,因此不独立背书 PR 描述中的 mutation 结果。PR 已披露的 relay attach / coordinator takeover 竞态仍不在此测试覆盖范围内。

CI 尚非全绿:Java 11 作业 的测试、Checkstyle 和产物构建步骤均成功,但作业在 Post Set up Java 阶段被取消;这与早期评论提到的 checkout 失败是不同一次运行,不能将当前状态描述为测试失败。

@wenshao

wenshao commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

Local maintainer verification — PR #14014

Verdict: merge-ready — 140/140 scripted assertions passed (0 unexpected failures), harness logs and captures under tmp/pr14014-verify-20261013-171923/.
Verified head: 595dcac82bec833e4b963b86dc0f3ece8bc936e4 — base: 21b78c55d5a0b2e4c9966be584165f6114e1ae0a.

中文摘要

结论:merge-ready(可合并) —— 140/140 项脚本断言全部通过,无意外失败。

  • 排序修复(核心声明 1):relay 的 olderOpenCommand 从"比较哈希出的 command id"改为"比较各自 journal 的 first_sequence(提交序)",并且没有 ledger 行的 older 条目也会阻塞 younger 条目。A/B:把 SessionMessageRelayStore.java 换成 base 版本后,新增用例 ordersCommandsByCommitOrderAndCountsAnEntryWithoutARow 在第一个断言处变红(其余 13 个用例仍绿),恢复 head 版本后 14/14 全绿——修复是该用例变绿的唯一原因(见 01-ordering-mutation-ab.png)。
  • 重启 IT 重建(核心声明 2):新 IT 通过占用 relay 单线程调度器,确保 kill 一定落在 carol 命令的 live 等待中;接管(writer generation 前进)后才放行 relay,断言回复折入停放的等待(consumed)。head 上重启用例 3 次运行 + 完整类 1 次(含生命周期用例)全部通过。变异对照:把 feat(managed-agent): member board tools ride the session_command channel end to end (H4e-b3b) #13928 的 continue-gate 修复从 bundle 中摘除后,新 IT 按预期变红——接管侧每次 POST …/managed-runtime/continue 都得到 409 continuation_not_ready(日志共 4 次,见 03-mutant-continue-gate-red.png);同一变异 bundle 下旧版 IT 31.9s 空转通过(见 04-old-it-vacuous-pass.png),证实了"旧 IT 在该缺陷存在时也能过"这一 PR 声明。
  • 辅助函数移除:isUnfinishedCommand 在全树零残留,契约测试 68/68 通过。
  • 门禁:TS 68/68;Java 单元 61/61(H2);IT 完整类 2/2(真实 MySQL,一次性 schema);checkstyle 干净(覆盖 160 个文件)。
  • CI 说明:唯一非绿车道 ubuntu-latest / Java 11 是在 actions/checkout 阶段被取消(基建噪声,非代码失败);定案的两个车道(Java 21 单元、Hosted MySQL 8.4)均绿。
  • 未覆盖:Windows/Linux 本地运行(由 CI 覆盖);5/5 重复次数(本地跑了 3 次重启 + 1 次完整类);逐 commit 归因(按聚合 diff 验证)。

Central claims and A/B proof

Claim 1 — per-sender command order follows commit order (first_sequence), not the hashed id

The old guard compared l.message_id < ? — a digest of sender/prompt/call, so "older" was a random permutation of commit order, and its INNER JOIN never saw an entry without a ledger row. The fix joins the record table against itself on r.first_sequence < c.first_sequence and LEFT JOINs the relay ledger.

Arm Build under test Oracle Result
Base SQL in head tree SessionMessageRelayStore.java ← base blob 21b78c55 SessionMessageRelayStoreTest Red as predicted: new case fails at its first assertion (olderOpenCommand(cmd_a_second) expected true, was false); the other 13 cases still green
Head unmodified same 14/14 green

The new case commits cmd_z_first before cmd_a_second, so the later id sorts first — it discriminates spelling order from commit order, and also asserts an entry without a ledger row still blocks. A/B capture: 01-ordering-mutation-ab.png.

Claim 2 — the rebuilt restart IT interrupts a live command wait

The relay is held from the start (a task parked on its single-thread scheduler), so the kill lands while carol's command is still planned; the relay is released only after a new writer generation holds carol's Session.

Arm Bundle IT version Oracle Result
Head head dist/cli.js head IT restart case Green ×3 (53.8 s, plus full-class run 2/2 in 78.1 s, plus capture run) — takeover retry (HostedHarnessGenerationException) visible in log, command ends consumed, result accepted
Mutation control continue-gate fix (#13928) reverted: command-wait exemption removed from the continue route; server chunk harnessCheckpointIsCommandWait sites 5→4 verified head IT restart case Red as predicted: every takeover POST /session/:id/managed-runtime/continue answered 409 hosted_turn_recovery_required reason=continuation_not_ready (4× in daemon wire log); final await timed out on childResultAccepted (157 s)
Vacuity arm same mutated bundle base IT blob restart case Green, vacuously (31.9 s, zero 409s) — the old case's kill lands after carol finished, so it never exercised the parked-wait resume. This is exactly how #13928's continue-gate bug passed CI.

Captures: 02-restart-it-head-green.png, 03-mutant-continue-gate-red.png, 04-old-it-vacuous-pass.png.

Claim 3 — isUnfinishedCommand removal is safe

Zero references remain anywhere in the head tree (grep -r isUnfinishedCommand packages/ → no hits), and the contract suite that used it now asserts outbound.run.delivery?.state directly: managed-session-command-record.test.ts 68/68 green.

Gates

Gate Result
packages/core managed-session-command-record.test.ts 68/68
SessionMessageRelayStoreTest + SessionMessageRelayTest + ManagedSessionCommandRecordContractTest (H2, MySQL mode) 61/61 (14+44+3)
HostedTeamMemberCommandMySqlIT full class, disposable MySQL schema 2/2 (78.1 s)
checkstyle (managed-agent-server) clean, 160 files checked
Workspace-link hygiene node_modules/@qwen-code/qwen-code-core realpaths into the head worktree — no cross-tree leak
Bundle mutation landing mutated continue-gate verified present in dist/chunks/server-*.js (call sites 5→4), restored to the byte-identical chunk hash afterwards

Findings

No blocking findings.

  • Nit (non-blocking, corroborates the Stage-2 review): writerGeneration's generation == null ? 0 : generation guard is unreachable — queryForObject throws EmptyResultDataAccessException when no row exists, and writer_generation is BIGINT NOT NULL. Cosmetic dead guard; a missing-row-as-0 semantic would need an explicit empty-result catch.
  • CI note: the one non-green check on 595dcac, ubuntu-latest / Java 11, was cancelled inside actions/checkout before any build or test ran — infrastructure noise, not this PR. The two lanes that settle this change (ubuntu-latest / Java 21 unit lanes and Hosted process fault gates / MySQL 8.4 / Java 21) are green.

Not covered

  • Windows / Linux local runs — macOS arm64 only here; Linux MySQL 8.4 is covered by the green CI lane.
  • Repetition depth: the PR's own evidence is 5/5 restart runs; this round ran the restart case 3× plus one full-class run, all green.
  • The Java 11 lanes were not re-run locally (CI's Java 11 unit lane was cancelled in checkout; Real daemon E2E / Java 11 is green).
  • Per-commit attribution: verified the aggregate base→head diff; the three commits were not exercised individually.
  • The IT's hold relies on messageRelayScheduler being single-threaded (the PR names this tradeoff itself); no probe done of a hypothetical multi-thread configuration, which does not exist in the codebase.

Methodology

Environment: macOS arm64, Homebrew JDK 21 + Maven 3.9, Node 22, a disposable local MySQL 26.7 instance on 127.0.0.1:3316 with a per-arm dropped/recreated hosted_harness_test schema (CI covers MySQL 8.4). Head worktree at 595dcac8 installed with corepack pnpm install --frozen-lockfile and built (npm run build && npm run bundle). Mutation arms swapped single files to their base blobs with cp backups inside the head tree (nothing else differs), and every mutation was verified to have landed — in the SQL text for the store arm, and in the bundled server chunk for the continue-gate arm — before the run, and restored afterwards (git status clean, chunk hash byte-identical). ITs ran with env -u QWEN_RUNTIME_DIR; the IT harness itself pins HOME/QWEN_RUNTIME_DIR for every spawned CLI process. All runs logged under tmp/pr14014-verify-20261013-171923/ (it-restart-head-r1.log, it-full-class-head.log, it-restart-mutant-continue-gate.log, it-restart-mutant-old-it.log), verdict in verdict.txt, counts in assertions.json.

Evidence captures

A/B: base SQL (id order) fails the new ordering case, head SQL (first_sequence) passes

Restart IT on head: kill mid-wait, takeover, relay resumes, result accepted

Mutation control: continue-gate fix reverted — new restart IT goes red, continue answered 409

Vacuity arm: same mutated bundle, old IT passes in 31.9s


Local verification by @wenshao's maintainer rig (Qwen Code agent); evidence reproducible from the scripts and logs in the artifact directory named above.

@wenshao
wenshao enabled auto-merge October 13, 2026 11:54
@wenshao

wenshao commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

@qwen-code /triage

@qqqys qqqys 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.

评审提交:595dcac82bec833e4b963b86dc0f3ece8bc936e4(base main)

历史阻塞问题复核

分页读取了全部 Review、行内线程与普通评论:本 PR 只有一条 Review(作者本人在当前 head 的 COMMENTED),pulls/14014/comments 返回 0 条行内评论,没有任何一轮机器人 findings 账本,也没有 CHANGES_REQUESTED;reviewDecision 为 REVIEW_REQUIRED。机器人的 triage stage 2/3 评论结论为「No blockers」,其「延迟审批已搁置」一条只针对 CI 未全绿(即下述被取消的 Java 11 作业),不是一条阻塞性代码意见。

不存在待复核的历史阻塞问题。

当前 Critical-only 扫描

已读完全部产线 diff(去掉三个测试文件后 80 行:managed-session-command-operations.ts −15、SessionMessageRelayStore.java +26/−17),并在当前 head 上核对了这次修改所依赖的既有实现。未发现可用代码证据证明的阻塞性缺陷。

排序守卫的新 SQL 语义正确。 olderOpenCommand 现在以候选命令自身为锚点做自连接:c 由 c.record_id = ?(commandId)在与 r 相同的 tenant / session / domain 下定位,r 遍历同一发送者 journal 中 domain = 'session_command' 且 r.first_sequence < c.first_sequence 的记录;命中条件是该旧记录仍处于 planned / accepting,且其 relay 行不存在或状态不属于 done / unknown / orphaned。逐点核对:

  • 参数绑定顺序 commandId, tenantId, senderSessionId 与占位符出现顺序一致(第一个 ? 在 JOIN 的 c.record_id,随后两个在 WHERE 的 r.tenant_id / r.session_id)。
  • 严格小于使候选命令永不阻塞自己。
  • LEFT JOIN 配合 l.state IS NULL 正是设计文档要求的「无论是否已有 ledger 行」:旧的 INNER JOIN 会漏掉尚未被 discovery 开出 ledger 行的 planned / accepting 命令,这一半缺口已补上。
  • relay 行的连接键是 (tenant_id, sender_session_id, message_id),每条 r 至多匹配一行,LIMIT 1 之下不存在行倍增导致的误判。
  • 行映射器由 result.getString(1) 改为 result.getInt(1),与投影从 l.message_id 改为 SELECT 1 相匹配。
  • 候选记录不存在时查询返回空,!isEmpty() 为 false,即不阻塞——与修改前对不存在候选的方向一致,不是新引入的失败方向。

这次修改所依赖的关键前提我独立验证过,未沿用其他评审的结论。 first_sequence 确实只在首次提交时写入且此后不被改写:在 ManagedExtensionRecordStore 中,该列全文件只出现在两处——第 1131 行的 INSERT 列表(位于 previous == null 即 revision 1 分支内,绑定到当次提交的 sequence),以及第 158 行的一个 ORDER BY 读取;revision 递增的更新路径不出现在任何 SET 子句中。因此它是「该记录在其 journal 中首次提交时的 sequence」,跨 revision 稳定,可以承担排序职责。列由 V27__managed_hook_records.sql 以 BIGINT NOT NULL DEFAULT 0 加入,早于该迁移的存量行取 0:这类行之间不再产生次序,但被替换掉的实现比较的是哈希出的 message_id,本身就是提交次序的随机排列,因此存量行的行为不可能因本次修改而变差;而 0 与新行正序列的比较方向是「旧的阻塞新的」,与设计一致。

删除 isUnfinishedCommand 不会在合入 main 之后才炸。 按两个 ref 分别计数:在 PR head 上,packages 下对 isUnfinishedCommand 的引用为 0;在当前 main 上,引用只有三处——managed-session-command-operations.ts 中的定义本身,以及 managed-session-command-record.test.ts 中的 import 与一条断言,而这两个文件正是本 PR 修改的文件(测试文件 +1/−3)。main 上没有新增的生产调用方,也没有 barrel 再导出,因此 CI 跑在 merge base 上看不到的那类合并后 typecheck 冲突在这里不存在。

CI

当前 head 唯一的非绿项是 ubuntu-latest / Java 11:其作业结论为 cancelled,注解为「The job has exceeded the maximum execution time of 30m0s」(06:26:55Z 开始、07:01:55Z 结束)。需要指出一处与作者本轮复评描述不一致的地方:作者称该作业的测试、Checkstyle 与产物构建步骤均成功、作业在 Post Set up Java 阶段被取消;而我按 jobs API 读到的步骤结论中,Set up Node.js 22、Run Java SDK tests、Run Runtime Broker state tests、Run Runtime Broker state Checkstyle 四步为 skipped 而非 success。两种读法都不改变结论方向——按频道策略,取消本身明确不是卡点,且没有任何证据表明该取消由本 PR 引入。

同一份代码在其余通道全部通过:ubuntu-latest / Java 17、ubuntu-latest / Java 21、windows-latest / Java 21、macos-latest / Java 21、Runtime Broker and Managed Agent MariaDB / Java 21(1h21m)、Hosted process fault gates / MySQL 8.4 / Java 21(47m)、Real daemon E2E / Java 11(32m)、Test (ubuntu-latest, Node 22.x)、Lint & Static、Integration Tests (no-AK, No Sandbox)、web-shell E2E Smoke、Flyway migration version uniqueness、triage 等;review-pr 仍在 pending,按策略不等待、不轮询。

结论:APPROVE。若维护者希望该 head 的 CI 记录完全干净,可单独重跑 ubuntu-latest / Java 11 作业;这不影响本轮评审结论。

@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.

Reviewed at 595dcac82bec833e4b963b86dc0f3ece8bc936e4.

The ordering fix is correct. I checked the load-bearing parts in the head tree rather than taking them from the description:

  • first_sequence is written by the production INSERT in ManagedExtensionRecordStore, not left at V27's DEFAULT 0, so r.first_sequence < c.first_sequence can actually fire.
  • The c self-join arm can't silently drop the caller's row: SessionMessageRelay.work returns early when currentRecord is null, and currentRecord selects on the same (tenant, session, domain, record_id) tuple the c arm binds.
  • Two commands of one sender can't share a first_sequence — ManagedExtensionRecordStore requires at most one Stage H record per transaction — so the strict < can't fail open on a tie. Only session_command rows are compared, and all of them post-date the column.
  • Widening the ledger join to LEFT JOIN with l.state IS NULL only adds a block. The extra blocker is itself discoverable through HANDOVER_SQL, and the deferral goes through scheduleRetry, so it spends no attempt and can't starve an entry.

This closes all three follow-ups I left on #13928: the hashed-id comparison, the ledger-less INNER JOIN that let an older no-row entry through, and isUnfinishedCommand. The IT rewrite is the right shape — the hold keeps carol's command planned so the kill lands mid-wait, and releasing only after the writer generation advances forces the resume. The author's mutation control (base SQL fails the new case; with the continue-gate reverted the new IT goes red while the old IT passes in 31.9 s) is what shows this gate now has teeth.

CI is green at this head. The one non-green check, ubuntu-latest / Java 11, was cancelled inside actions/checkout before any build ran — infrastructure, not this diff.

Two non-blocking test-robustness follow-ups inline. Nothing blocks merge.

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Sandboxed verification: ⚠️ not run — skipped - workflow run

Skipped because the PR is not open for verification (state=MERGED, draft=false).

中文 — 判定:⚠️ 未运行 · 已跳过

跳过原因:the PR is not open for verification (state=MERGED, draft=false)。

— Qwen Code · sandboxed verification

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

No gate action — this run finished after the merge.

You triggered /triage at 11:55:05Z while the PR was still open; the run is only completing now (~15:25Z), and the PR was squash-merged at 12:06:23Z in between. There is nothing left for the gate to decide, so I have not overwritten the three staged comments above.

What shipped is what was reviewed. The merged head is 595dcac, and squash commit d28bc60 (single parent c3c38cf) touches exactly the five files in that reviewed diff. Stages 1–3 all footer at 595dcac, so they cover the merged code byte-for-byte — no unreviewed commit slipped in between review and merge. Re-running the stages would have produced the same findings against the same SHA while replacing the pre-merge record, so I didn't.

CI on the merged commit: no failures — 26 success, 203 skipped, 2 cancelled. The one that matters here, Hosted process fault gates / MySQL 8.4 / Java 21 (the hosted-harness-mysql lane that actually runs the rebuilt HostedTeamMemberCommandMySqlIT), is green, as are Runtime Broker and Managed Agent MariaDB / Java 21, Test (ubuntu-latest, Node 22.x), and the Java 17/21 lanes on ubuntu/macos/windows. The two cancellations are review-pr (bot orchestration, cut off by the merge) and ubuntu-latest / Java 11 — currently cancelled; Stage 3 had seen it fail earlier on a runner-side git-unpack error that never touched this diff.

For the record: Stage 3 deferred my approval behind an approve-on-green marker on 595dcac, and that approval never posted — the Java 11 lane ended cancelled rather than green, so finalize correctly withheld it. It changed nothing: qqqys approved at 12:00:15Z and yiliang114 at 12:06:01Z, both on 595dcac, and you merged 22 seconds later.

Two follow-ups now living on main — both disclosed in your own description, neither fixed by this PR:

  1. The restart IT's timeout budget. I checked the merged file: memberHarnessRestartDuringCommandWait carries @Timeout(180), while the fixed ceilings inside it sum to ~320s before any unbounded setup — awaitility 60s + 100s + 110s = 270s, plus held.await(30, SECONDS) in holdMessageRelay() and harness.waitFor(20, SECONDS), and that excludes boot(), createLead(), startHarness() and closeAndSettle(). A healthy run finishes in the 53–54s you measured, so the ceilings never stack in practice. The exposure is a slow-but-healthy MySQL runner, where the case dies at 180s as a timeout instead of an assertion. waiting()'s failFast on the interrupt keeps that from spinning — but you already saw one mutation run where @Timeout did not interrupt and the fork was held to failsafe's 1200s. If this lane ever reds on the restart case, that arithmetic is the first place to look.

  2. The relay-attach vs takeover-load race (relay's plain attach wins → takeover gets 409 hosted_session_already_attached → treated as non-transient → parked Turn never continued). You scoped it out and tied it to fix(managed-agent): re-attachment of a child Session answers 409 hosted_session_already_attached after a control-plane kill (non-durable-local host profile) #13838 and [H4b follow-up] The wake pump races the takeover continue: a restart during a foreground agent wait with a pending wake input blocks the Session for good #13873. fix(managed-agent): re-attachment of a child Session answers 409 hosted_session_already_attached after a control-plane kill (non-durable-local host profile) #13838 is closed/completed (the re-attach 409 fix for the non-durable-local profile); [H4b follow-up] The wake pump races the takeover continue: a restart during a foreground agent wait with a pending wake input blocks the Session for good #13873 is still open and describes the same shape — a restart racing the takeover that blocks the Session for good. Now that this PR has landed, worth confirming [H4b follow-up] The wake pump races the takeover continue: a restart during a foreground agent wait with a pending wake input blocks the Session for good #13873 covers the relay-attach variant specifically, because the merged IT releases the relay only after the takeover, so nothing in CI pins it.

Neither changes the merged outcome — recording them so the disclosures aren't lost now that the PR is closed.

中文说明

无需闸门动作 —— 本次运行在合并之后才结束。

你在 11:55:05Z(PR 仍处于 open 状态时)触发了 /triage,本次运行直到现在(约 15:25Z)才完成,而 PR 已在 12:06:23Z 被 squash 合并。闸门已无可判定事项,因此我没有覆盖上面的三条阶段评论。

合并进去的就是被审查过的代码。 合并时的 head 是 595dcac,squash 提交 d28bc60(单一父提交 c3c38cf)改动的正是该 diff 里的五个文件。Stage 1–3 的 footer 都是 595dcac,所以它们逐字覆盖了已合并的代码 —— 审查与合并之间没有夹带未审查的提交。重跑各阶段只会对同一个 SHA 得到同样的结论,同时替换掉合并前的记录,所以我没有重跑。

合并提交上的 CI:无失败 —— 26 项 success、203 项 skipped、2 项 cancelled。这里关键的一项 Hosted process fault gates / MySQL 8.4 / Java 21(也就是真正会跑重建后 HostedTeamMemberCommandMySqlIT 的 hosted-harness-mysql lane)是绿的;Runtime Broker and Managed Agent MariaDB / Java 21、Test (ubuntu-latest, Node 22.x) 以及 ubuntu/macos/windows 上的 Java 17/21 lane 同样为绿。两项 cancelled 分别是 review-pr(机器人编排任务,被合并动作中断)和 ubuntu-latest / Java 11 —— 当前为 cancelled,Stage 3 早先看到它因 runner 侧 git 解包错误失败,与本 diff 无关。

顺带记录:Stage 3 用 approve-on-green 标记把我的批准延后到 595dcac,而那次批准始终没有提交 —— Java 11 lane 最终是 cancelled 而非绿,finalize 因此正确地未予批准。这没有造成任何影响:qqqys 于 12:00:15Z、yiliang114 于 12:06:01Z 都在 595dcac 上批准,你在 22 秒后合并。

两个已随合并进入 main 的后续项 —— 均由你在描述中主动披露,本 PR 都未修:

  1. 重启 IT 的超时预算。 我核对了合并后的文件:memberHarnessRestartDuringCommandWait 标的是 @Timeout(180),而其内部各段固定上限相加约 320 秒(尚未计入无上限的准备阶段)—— awaitility 60s + 100s + 110s = 270s,加上 holdMessageRelay() 里的 held.await(30, SECONDS) 和 harness.waitFor(20, SECONDS),且不含 boot()、createLead()、startHarness()、closeAndSettle()。正常运行在你实测的 53–54 秒内结束,这些上限实际不会叠加。风险在于「慢但健康」的 MySQL runner —— 此时用例会在 180 秒被 @timeout 杀掉,表现为超时而不是断言失败。waiting() 的 failFast(检测中断)能避免空转,但你已经遇到过一次 @timeout 未能中断、一直占到 failsafe 1200 秒的运行。若该 lane 将来在重启用例上变红,这笔账是第一处该看的地方。

  2. relay attach 与 takeover load 的竞态(relay 的普通 attach 抢先 → takeover 得到 409 hosted_session_already_attached → 被当作不会自愈的错误 → 停住的 Turn 再也不会被 continue)。你已将其划出范围,并关联 fix(managed-agent): re-attachment of a child Session answers 409 hosted_session_already_attached after a control-plane kill (non-durable-local host profile) #13838 与 [H4b follow-up] The wake pump races the takeover continue: a restart during a foreground agent wait with a pending wake input blocks the Session for good #13873。fix(managed-agent): re-attachment of a child Session answers 409 hosted_session_already_attached after a control-plane kill (non-durable-local host profile) #13838 已 closed/completed(那是 non-durable-local profile 的 re-attach 409 修复);[H4b follow-up] The wake pump races the takeover continue: a restart during a foreground agent wait with a pending wake input blocks the Session for good #13873 仍然 open,描述的形态相同 —— 重启与 takeover 竞争,导致 Session 被永久阻塞。既然本 PR 已合并,建议确认 [H4b follow-up] The wake pump races the takeover continue: a restart during a foreground agent wait with a pending wake input blocks the Session for good #13873 是否确实覆盖 relay-attach 这一变体,因为合并后的 IT 只在 takeover 之后才放开 relay,CI 中没有任何东西钉住它。

两者都不改变已合并的结果 —— 记录下来,是为了让这些披露在 PR 关闭后不被遗漏。

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

Reviewed at 595dcac82bec833e4b963b86dc0f3ece8bc936e4 · merged as d28bc60d73dd1b613086cdff8be6c307b9609505 · re-run with @qwen-code /triage

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Released in v0.25.2.

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.

5 participants