Repository navigation
fix(managed-agent): order a sender's commands by commit sequence, and make the member restart IT interrupt a live wait - #14014
Conversation
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.
|
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: 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 ( 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 Risk: no elevated risk signals — none of the five files match the high-risk paths. Two things worth watching, both non-blocking:
Moving on to code review. 🔍 中文说明感谢 — 这是 #13928 的后续,三块改动是一个整体。 模板完整 ✓ 问题: 真实存在,且有证据,不是假设性的。这里其实是两件不同的事。排序守卫是一个与设计文档不一致的缺陷: 方向: 对齐。这些是一个约三小时前刚合并的 PR 上已被接受的评审后续,把 store 拉回与现有设计文档一致,并退役一个绿色但空转的闸门。属于 managed-agent server 内部接口,没有公共契约变更。CHANGELOG:没有直接对应条目,但这个区域很活跃 —— #13928 昨天刚落地。 规模: 触及核心路径( 方案: 范围合理,我也看不到更小且正确的排序修复 —— 把比较键换成 journal 序号、并把 join 放宽为 风险: 无升级风险信号 —— 五个文件都不匹配高风险路径。有两点值得关注,均不阻塞:
进入代码审查 🔍 — Qwen Code · qwen3.8-max-2026-09-02 Reviewed at |
Code reviewI 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:
Two non-blocking notes:
Test evidenceThis 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 The one red check is infrastructure noise, not this PR. 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 The two lanes that actually settle this change are both still running: Final CI results for
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: 中文说明代码审查我把 diff 对着基线代码读了,并核实了几个关键假设,而不是直接采信 PR 描述。没有阻塞项。排序修复是正确的,更重要的是它不是静默失效的 —— 这是这类改动最可能「看起来对、实际什么都没做」的地方:
两点不阻塞的说明:
测试证据这是一次无人值守的 CI 运行,所以这里没有任何东西是我构建或执行的 —— 证据是 PR 自己的 CI,通过 API 在 唯一的红色检查是基础设施噪音,与本 PR 无关。 真正决定这次改动的两个 lane 都还在运行: PR 描述里 Evidence 表格中的全部内容 —— store 测试 61/61、重启场景 5/5、变异对照 —— 都是作者本人在 macOS(arm64、JDK 21、Node 24、MySQL 8.4.7)上的本地结果,不是我复跑的,也无法从这里确认。作者标注 Linux 与 Windows 未测试。 沙箱验证可以解决绿色 CI 在结构上无法解决的那一条: — Qwen Code · qwen3.8-max-2026-09-02 Reviewed at |
|
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 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 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 ( 中文说明置信度:4/5 —— 修复是正确的,我能想到的每一种「静默出错」的可能都已逐一排除;之所以不给满分,只因为最关键的那份证据(变异对照)恰恰是 CI 在结构上无法复现的。 在读 diff 之前,我先根据标题和「为什么需要」写下了自己会怎么做:如果守卫是依据内容摘要来判断「更早」,那修复就应该改为依据 journal 的单调序号 —— 一个记录本身已经携带的值 —— 并且不再要求存在 ledger 行,因为设计文档明确说过不管 discovery 有没有建行都要计入。你做的正是这个。我没有找到更简的路径,也不认为在仍满足设计文档的前提下存在更简的路径。 我最认可的是重启 IT 重写背后的判断力。一个不论行为是否正确都会通过的测试,比没有测试更糟,因为它正是一个真实 bug 进入 两点坦白的保留意见,均不阻塞:
关于我最后总会问的那个问题 —— 六个月后我会不会骂写这段代码的人?不会。SQL 现在与设计文档一致而不再相互矛盾,那个只会与 SQL 渐渐不一致的辅助函数被删掉而不是留着腐烂,而 IT 脆弱的 我不是因为没有反对意见了才批准。我检查了这类改动「看起来对、实际什么都没做」的几种具体形态 —— 列没被填充、join 分支不可达、序号并列、测试从来没有区分度 —— 每一种都被我在基线代码树里读到的东西排除了,而不是靠 PR 描述。 结论:批准。 两个 CI run( — Qwen Code · qwen3.8-max-2026-09-02 Reviewed at |
wenshao
left a comment
There was a problem hiding this comment.
评审提交: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 日志 确认
HostedTeamMemberCommandMySqlIT2/2 通过。
验证范围:本地未重跑完整 MySQL E2E、TypeScript 测试或 continue-gate mutation,因此不独立背书 PR 描述中的 mutation 结果。PR 已披露的 relay attach / coordinator takeover 竞态仍不在此测试覆盖范围内。
CI 尚非全绿:Java 11 作业 的测试、Checkstyle 和产物构建步骤均成功,但作业在 Post Set up Java 阶段被取消;这与早期评论提到的 checkout 失败是不同一次运行,不能将当前状态描述为测试失败。
Local maintainer verification — PR #14014Verdict: 中文摘要结论:merge-ready(可合并) —— 140/140 项脚本断言全部通过,无意外失败。
Central claims and A/B proofClaim 1 — per-sender command order follows commit order (
|
| 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'sgeneration == null ? 0 : generationguard is unreachable —queryForObjectthrowsEmptyResultDataAccessExceptionwhen no row exists, andwriter_generationisBIGINT 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 insideactions/checkoutbefore any build or test ran — infrastructure noise, not this PR. The two lanes that settle this change (ubuntu-latest / Java 21unit lanes andHosted 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 11is green). - Per-commit attribution: verified the aggregate base→head diff; the three commits were not exercised individually.
- The IT's hold relies on
messageRelaySchedulerbeing 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
Local verification by @wenshao's maintainer rig (Qwen Code agent); evidence reproducible from the scripts and logs in the artifact directory named above.
|
@qwen-code /triage |
qqqys
left a comment
There was a problem hiding this comment.
评审提交: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
left a comment
There was a problem hiding this comment.
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_sequenceis written by the production INSERT inManagedExtensionRecordStore, not left at V27'sDEFAULT 0, sor.first_sequence < c.first_sequencecan actually fire.- The
cself-join arm can't silently drop the caller's row:SessionMessageRelay.workreturns early whencurrentRecordis null, andcurrentRecordselects on the same(tenant, session, domain, record_id)tuple thecarm binds. - Two commands of one sender can't share a
first_sequence—ManagedExtensionRecordStorerequires at most one Stage H record per transaction — so the strict<can't fail open on a tie. Onlysession_commandrows are compared, and all of them post-date the column. - Widening the ledger join to
LEFT JOINwithl.state IS NULLonly adds a block. The extra blocker is itself discoverable throughHANDOVER_SQL, and the deferral goes throughscheduleRetry, 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.
|
Sandboxed verification: Skipped because the PR is not open for verification (state=MERGED, draft=false). 中文 — 判定:
|
|
No gate action — this run finished after the merge. You triggered What shipped is what was reviewed. The merged head is CI on the merged commit: no failures — 26 success, 203 skipped, 2 cancelled. The one that matters here, For the record: Stage 3 deferred my approval behind an approve-on-green marker on Two follow-ups now living on main — both disclosed in your own description, neither fixed by this PR:
Neither changes the merged outcome — recording them so the disclosures aren't lost now that the PR is closed. 中文说明无需闸门动作 —— 本次运行在合并之后才结束。 你在 11:55:05Z(PR 仍处于 open 状态时)触发了 合并进去的就是被审查过的代码。 合并时的 head 是 合并提交上的 CI:无失败 —— 26 项 success、203 项 skipped、2 项 cancelled。这里关键的一项 顺带记录:Stage 3 用 approve-on-green 标记把我的批准延后到 两个已随合并进入 main 的后续项 —— 均由你在描述中主动披露,本 PR 都未修:
两者都不改变已合并的结果 —— 记录下来,是为了让这些披露在 PR 关闭后不被遗漏。 — Qwen Code · qwen3.8-max-2026-09-02 Reviewed at |
|
Released in v0.25.2. |




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.
first_sequence, the sequence at which that record was first committed in the sender's journal.plannedoracceptingentry 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 oldINNER JOINskipped such entries.isUnfinishedCommandrestated the relay's planned/accepting rule but had no production caller, so it could only drift from the relay's SQL. It is removed.planned.consumed) and that the lead accepts carol's result.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.
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 (everyawait_commandcontinue answered 409) got through CI.Reviewer Test Plan
How to verify
SessionMessageRelayStoreTest. The new caseordersCommandsByCommitOrderAndCountsAnEntryWithoutARowcommitscmd_z_firstbeforecmd_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.HostedTeamMemberCommandMySqlITon a disposable MySQL schema, the same way thehosted-harness-mysqllane does:-Phosted-harness-mysql -Dnode.executable=… -Dqwen.cli.entry=<repo>/dist/cli.js -Dmysql.url=… -Dmysql.user=… -Dmysql.password=…, afternpm 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 onePOST /session/:id/managed-runtime/continueanswered 200.hosted-harness-session.tsand re-bundle. The restart case then fails: every continue gets 409continuation_not_readywithphase=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.
SessionMessageRelayStoreTest,SessionMessageRelayTest,ManagedSessionCommandRecordContractTestmanaged-session-command-record.test.tscontinue200, and carol's writer generation advanced.continue→ 409continuation_not_ready(phase=await_command).membersReadAndWriteTheBoardTheirLeadReads+ restart)managed-agent-server)Tested on
Environment (optional)
mvn -Phosted-harness-mysql failsafe:integration-test failsafe:verifyagainst a native MySQL 8.4.7 on a free local port, with the bundleddist/cli.jsfrom this branch.Risk & Scope
messageRelaySchedulerhaving 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 ownplannedprecondition rather than pass vacuously.hosted_session_already_attached, the coordinator treats that as non-transient, and the parked Turn is never continued. In the earlier IT draft, which released the relay right after the restart, the race showed up in 1 of the 3 runs whose logs I captured. The final IT releases the relay only after the takeover, so it does not pin this race. It is a separate product issue (related 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) and is not fixed here.@Timeout. It held its fork until failsafe's 1200 s fork timeout. I did not trace that hang.first_sequencecolumn.Linked Issues
Refs #13928.
中文说明
本 PR 做了什么
本 PR 是 #13928 的后续:修正 relay 对同一发送方命令的排序,删除一个无用的辅助函数,并重做成员重启 IT,让重启真正打断一个仍在进行的命令等待。
first_sequence,即该记录在发送方 journal 里首次提交时的序号。planned或accepting条目,即使 discovery 还没为它建 ledger 行,现在也会挡住后来的命令。这是设计文档的要求(「不管有没有 ledger 行」),原来的INNER JOIN会跳过这类条目。isUnfinishedCommand重复了 relay 的 planned/accepting 规则,但没有任何生产调用方,只会和 relay 的 SQL 渐渐不一致,已删除。planned之后才杀进程。consumed),并且 lead 收到了 carol 的结果。为什么需要
这些是 #13928 不阻塞的评审后续:r4253304973、r4253304983、r4253304991,以及真实栈验证中的 F2。
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,该用例在第一个断言就失败。npm run build && npm run bundle,再用一个一次性 MySQL schema 跑HostedTeamMemberCommandMySqlIT,方式与hosted-harness-mysqllane 相同:-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。hosted-harness-session.ts里的 continue 闸门修复改回去并重新打 bundle,重启场景就会失败:每次 continue 都得到 409continuation_not_ready(phase=await_command),lead 始终收不到 carol 的结果。旧版 IT 在同样状态下是通过的。证据(前后对比)
N/A,没有 UI 改动。以下结果来自本地运行:macOS(arm64)、JDK 21、Node 24、原生 MySQL 8.4.7,使用一次性 schema。
SessionMessageRelayStoreTest、SessionMessageRelayTest、ManagedSessionCommandRecordContractTestmanaged-session-command-record.test.tscontinue返回 200,carol 的 writer generation 增加。continue→ 409continuation_not_ready(phase=await_command)。membersReadAndWriteTheBoardTheirLeadReads+ 重启)managed-agent-server)测试平台
环境(可选)
mvn -Phosted-harness-mysql failsafe:integration-test failsafe:verify,连接本地空闲端口上的原生 MySQL 8.4.7,使用本分支打出的dist/cli.js。风险与范围
messageRelayScheduler只有一个线程,这是它当前的配置。如果线程池以后变大,占位就停不住 relay。届时用例会在它自己的planned前置条件处失败,而不会空转通过。hosted_session_already_attached,协调器把它当作不会自愈的错误,停住的 Turn 就再也不会被 continue。早期版本的 IT 在重启后立即放开 relay,保留了日志的 3 次运行中有 1 次出现了这个竞态。最终版只在接管之后才放开 relay,所以不覆盖这个竞态。它是一个独立的产品问题(与 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 相关),本 PR 不修。@Timeout处结束,而是一直占着 fork,直到 failsafe 的 1200 s fork 超时。这个卡住我没有追查。first_sequence列。关联 Issue
Refs #13928.