Skip to content

fix(sdk-java): Close Hosted Harness review criticals from #12654 - #13314

Merged
wenshao merged 51 commits into
mainfrom
fix/sdk-java-12654-review-criticals
Oct 16, 2026
Merged

wenshao merged 51 commits into
mainfrom
fix/sdk-java-12654-review-criticals

Conversation

@wenshao

@wenshao wenshao commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does

This PR lands the fixes for the 11 Critical and 2 Minor findings from the post-merge review of #12654 (the Hosted Harness private Java client), plus the closures for the second review round filed against this PR itself. #12654 merged before its review round was processed (all 62 threads were still open); every finding in scope was re-verified against current main before fixing. The remaining 49 Suggestion-level findings from the #12654 round are dispositioned in their threads and tracked as a backlog in #13313; #13313 also tracks the deferred remainder of this PR's own review round.

Second round (addressing the CHANGES_REQUESTED review of this PR)

The second round execution-proved one real regression in the first commit — CI's fault-gates lane agreed — and five more critical defects around it:

  • Wire/digest mismatch (CI-confirmed): the digest was canonicalized but the wire prompt member was not, and the hosted route re-derives the digest from the received bytes — every addText submission drew 400 invalid_hosted_prompt. toJson() now emits the canonical form, the digest reuses the JsonSupport.encode facade over that same value (one serialization entry point), and the pinning test asserts the wire bytes and the digest are literally the same value (byte-literal expectation plus the canonical digest constant).
  • Idle watchdog vs. silent hosted route: the 45s bound was inherited from the stdio transport, whose server writes heartbeat comments; the hosted events route wrote nothing while no event was committed, so healthy silent streams — long tool calls, slow model phases, the ten-minute approval wait — were aborted and re-dispatched forever. The hosted route now mirrors the primary route's keepalive comment every 15s, and Builder.sseIdleTimeout accepts Duration.ZERO for callers that own the deadline. A new test keeps a consumer parked in next() for three idle budgets while the peer stays alive on keepalive comments alone; the pre-existing idle-timeout test still goes red when the watchdog is removed.
  • Idle abort surfaced outside the DaemonException family: when the watchdog fired while the consumer was between next() calls, the closed guard threw IllegalStateException, contradicting the new javadoc and invisible to consumers classifying by DaemonException. The guard now distinguishes who closed the stream: idle abort → DaemonTransportException('Hosted Harness SSE idle timeout'), caller close → IllegalStateException.
  • Executor-rejection overreach: the cause-chain scan certified any rejection-shaped IOException as "never dispatched", but response delivery also runs on the caller-supplied executor — a rejection surfacing after the server accepted a turn dropped the active-prompt marker for an admitted turn and reported it definitively not submitted. Now only a bare RejectedExecutionException (submit time) or a rejection with the executor already shut down classifies as saturated/known; mid-flight shapes stay outcome-unknown and keep the marker. This is pinned deterministically by staging a parked worker + a full queue + a delayed 202 answer through a package-private executor seam.
  • Boot-headerless 4xx misclassified as outcome-unknown: the missing-header wrap treated the server's own pre-middleware refusals (413 body-too-large, 429) the same as a gateway's error page. All four mutation sites now re-derive: ambiguous (408/5xx) keeps outcome-unknown; a definitive unfenced refusal surfaces as DaemonHttpException with its status preserved.
  • Folded-in adjacent closures: detachSession retires the local attachment on every definitive answer (not just 204/404), so a 403 after an auth revocation no longer leaks a heartbeat timer; a caller queued on cursorLock when the stream closes re-checks inside the lock and gets the closed-stream signal instead of a transport error; the session_snapshot comment now names the actual producer (the bridge's withSnapshot on the primary events route — the hosted route ignores the query parameter and stamps every frame with an id); the builder javadoc records the cursor-fallback precedence and that snapshot(true) is a primary-transport option; the README retry section and both design-doc languages now state the canonical digest as a cross-language wire contract and record that changing the digest algorithm requires quiescing (or rewriting) in-flight turn rows before upgrading; and two previously unpinned arms (an explicit cursor beating the ref watermark, and a definitive boot-headerless DELETE) got their own discriminating tests.

First round (post-merge review of #12654)

  • Stream lifecycle: HarnessEventStream no longer parks close() behind a consumer blocked in next() — the closed flag is atomic and the raw input is closed without any stream monitor, so HostedHarnessClient.close() always completes and a blocked next() fails with DaemonTransportException (the idle watchdog above completes this picture).
  • Turn ledger correctness: a 409 rejection no longer retains an uncloseable marker keyed by the rejected promptId (it releases the slot and throws PromptAlreadyActiveException); a definitive non-409 failure on a same-identity retry releases the slot it retained for that retry; and getStatus() snapshots the active-prompt entry before the remote read and only ever removes that exact registration, so a stale hasActivePrompt:false can no longer delete a different prompt admitted while the read was in flight.
  • Outcome classification (first-cut form, narrowed in the second round — see above): a response missing the X-Qwen-Harness-Boot-Id fence header on a mutation path is classified as outcome-unknown instead of a bare DaemonProtocolException, because a response that never passed the fencing middleware cannot prove the mutation did not execute; and a purely local executor rejection surfaces as DaemonTransportException instead of claiming the request may have reached the server.
  • Lifecycle cleanup: closeSession(HarnessSessionRef) treats a definitive 404 as already-done and tears down the attachment and the active-prompt ledger, and detachSession tolerates 404 the same way for the attachment (it does not clear the active-prompt ledger — that asymmetry stays, tracked in [Backlog] sdk-java Hosted Harness client — 49 deferred review findings from #12654 post-merge review #13313), so the heartbeat timer no longer keeps posting to a session the server has already reclaimed.
  • Protocol interop: streamEvents falls back to the session ref's validated watermark when the builder omits the resume pair, so the epoch fence the README promises is actually enforced (and Last-Event-ID resumes from the ref's cursor), while a ref carrying no watermark keeps today's unfenced fresh-stream shape; and the shared SSE parser accepts the id-less synthetic session_snapshot frame produced by the primary transport's snapshot subscription.
  • Digest and model invariants: computePayloadDigest hashes a canonical form (object keys sorted recursively, array order preserved) instead of process-random Map iteration order, so the dedup key is reproducible across JVMs and across map implementations (fastjson2's MapSortField was ruled out by probe: it does not sort maps nested inside a collection); and HarnessRuntimeExecutionRecovery enforces at construction that a known outcome carries its status map, instead of NPE-ing later inside isContinuationReady().

Every finding is pinned by new tests whose mutation witnesses were run: reverting that finding's fix turns its test red (witness tables under "How to verify").

Why it's needed

The Hosted Harness client is the Java control-plane transport for the private hosted profile, and its public contract promises fail-closed behaviour (bounded resources, outcome-unknown classification, single active prompt per session, epoch-fenced resume). The first review demonstrated each of these promises had a concrete violation; the second review then execution-proved that the first round's own fixes carried one cross-language regression (CI agreed) and four more fail-closed violations of the same class, in exactly the surfaces the stubs cannot see (the server re-deriving the digest, the hosted route's silence, the executor's dual dispatch/delivery role, and the closed guard's type). Working through both rounds before merge is cheaper than shipping the client with a broken prompt path and correcting it afterwards.

Reviewer Test Plan

How to verify

The behaviors are pinned by 23 new cases in HostedHarnessClientTest. Run:

cd packages/sdk-java/qwencode
mvn -o test -Dtest=HostedHarnessClientTest     # 42 tests (19 pre-existing + 23 new)
mvn -o test                                    # full module: 189 tests, 9 env-gated skips
cd ../cli && npx vitest run src/serve/hosted-harness-session.test.ts   # 181 tests

All green locally on JDK 17; clean test green on JDK 11 (module targets release 11; two executor-rejection cases skip themselves on JDK 11, whose HttpClient parks a send to a struggling executor instead of surfacing the rejection — probed on 11/17/21).

Mutation witnesses, first round (revert the fix → the pinning test goes red):

Fix Reverted shape Mutant result
F1 (null guard) drop requireNonNull(status) for known outcomes RED
R1-6 (digest order) hash raw promptContent again RED
R1-4 (stale getStatus) unconditional activePrompts.remove(key) RED
R1-2 + F2 (409 / retry slot) restore retain-on-409 / retry-keeps-slot RED (both tests)
R1-5 ×3 sites bare validateGeneration RED ×3
R1-3 (close 404) tolerance limited to clientId == null RED
R1-46 (detach 404) detach requires 204 unconditionally RED
R1-47 (snapshot frame) session_snapshot out of the id-less set RED
R1-44 (ref watermark) fence/cursor from the request only RED
R1-1 (shared monitor) next()/close() on one monitor again RED (timeout arms the hang)
R1-43 (watchdog) watchdog disabled RED (timeout arms the hang)
R1-45 (rejection type) wrap as IOException again RED

Mutation witnesses, second round:

Fix Reverted shape Mutant result
Wire = digest toJson() emits the raw list again RED (byte-literal asserts the type-first wire)
Idle-abort type closed guard always IllegalStateException RED
In-lock re-check queued caller never re-checks RED
Rejection gate unbounded cause walk again RED (mid-flight rejection certified as saturated)
Boot-header narrow ×2 blanket outcome-unknown at the prompt and DELETE sites RED ×2
Detach finally cleanup after requireMutationStatus only RED (heartbeats keep beating)
Watchdog/keepalive pair watchdog removed RED on the idle case, GREEN on the keepalive case
Explicit cursor wins ref-only resume fallback RED

Evidence (Before & After)

N/A — non-UI protocol/transport fix; the mutation tables above are the before/after. CI's Hosted process fault gates / MySQL 8.4 / Java 21 lane was green at the merge base and red at the first commit — it is the integration-level evidence for the wire/digest regression and should return to green on this head.

Tested on

OS Status
🍏 macOS ✅
🪟 Windows N/A
🐧 Linux N/A (CI)

Environment (optional)

Local: JAVA_HOME=jdk17 (full suite) and jdk11 (mvn clean test), Maven 3.9.11, in packages/sdk-java/qwencode; npx vitest run src/serve/hosted-harness-session.test.ts in packages/cli.

Risk & Scope

  • Main risk or tradeoff: the payload digest is now a canonical cross-language contract — digests computed by the previous release differ for the same content, which is the point of the fix (old values were JVM-random and could never be reproduced across processes). The design doc (both languages) now records that an upgrade altering the digest must quiesce or rewrite in-flight turn rows first; the coordinator-side one-time recompute fallback is deliberately not in this slice (it lives in the managed-agent-server module and is tracked in [Backlog] sdk-java Hosted Harness client — 49 deferred review findings from #12654 post-merge review #13313). Consumers blocked in next() now also see DaemonTransportException on an idle abort — including the between-calls arm, which previously surfaced as IllegalStateException.
  • Not validated / out of scope: the 49 Suggestion-level findings from the feat(sdk-java): Add the Hosted Harness private client #12654 round (tracked in [Backlog] sdk-java Hosted Harness client — 49 deferred review findings from #12654 post-merge review #13313). From this PR's own round: the code-carrying Prompt* exception redesign for per-code marker rules (needs route-semantics-level API work, tracked with the verified gate-order table), the coordinator's missing terminal escape for post-admission outcome-unknown (managed-agent-server slice, tracked), the remaining witness-table coverage items (three of six addressed here), and pinning the JDK-11 executor behavior rather than skipping it (the 11/17/21 difference is now disclosed in the tests, the builder javadoc, and the design doc). closeSession(String) still lacks its ensureOpen() guard ([Backlog] sdk-java Hosted Harness client — 49 deferred review findings from #12654 post-merge review #13313's R1-50): the post-close executor-rejection test deliberately routes through that path on JDK 17+ and documents the coupling.
  • Breaking changes / migration notes: digest change as above; submitTurn on a 409 now throws PromptAlreadyActiveException instead of DaemonHttpException; definitive unfenced 4xx on mutation paths now throw DaemonHttpException carrying the status instead of outcome-unknown types; submitTurn's toJson() now emits key-sorted content blocks (the server accepts them — it validates shape and re-derives the digest).

Linked Issues

Refs #12654 (post-merge review findings fixed here) and #13313 (backlog of the deferred remainder from both rounds).

中文说明

本 PR 做了什么

本 PR 落地了 #12654(Hosted Harness 私有 Java 客户端)合入后评审的 11 条 Critical 与 2 条 Minor 修复,以及针对本 PR 自身第二轮评审的闭环。#12654 在评审处理前已合入(62 条 thread 全部开放);范围内每条发现都在当前 main 上重新核实后才修复。其余 49 条 Suggestion 级发现在各自 thread 中给出处置并汇总进 #13313;#13313 同时跟踪本 PR 评审轮次中推迟的剩余项。

第二轮(针对本 PR 的 CHANGES_REQUESTED 评审)

第二轮用执行证明了首个提交中的一处真回归——CI 的 fault-gates 车道结论一致——以及围绕它的另外 5 个关键缺陷:

  • 线上字节与 digest 不一致(CI 实测确认):digest 被规范化而线上 prompt 字段没有,hosted 路由又按收到的字节重算 digest——每个 addText 提交都拿到 400 invalid_hosted_prompt。toJson() 现在输出规范形式,digest 经 JsonSupport.encode 门面处理同一个值(唯一序列化入口),钉住测试断言线上字节与 digest 是字面相等的同一个值(字节字面量断言 + 规范 digest 常量)。
  • 空闲看门狗与静默 hosted 路由:45s 上界继承自 stdio 传输,那一侧服务端每 15s 写心跳注释;hosted 事件路由在无新事件提交时一个字节都不写,于是健康的静默流——长工具调用、慢模型阶段、十分钟审批等待——被中止并无限重派。hosted 路由现在以与主路由相同的方式每 15s 写一次 keepalive 注释,且 Builder.sseIdleTimeout 接受 Duration.ZERO 供自管期限的调用方关闭。新测试让消费者停在 next() 里跨三个空闲预算、对端仅靠 keepalive 存活;既有空闲超时用例在移除看门狗后仍变红。
  • 空闲中止的异常类型不属于 DaemonException 家族:看门狗在消费者处于两次 next() 之间触发时, closed 守卫抛 IllegalStateException,与新增 javadoc 矛盾、且按 DaemonException 分类的消费者捕不到。守卫现在区分关闭由谁发起:空闲中止 → DaemonTransportException('Hosted Harness SSE idle timeout'),调用方主动 close → IllegalStateException。
  • 执行器拒绝分类越界:cause 链扫描把任何"拒绝形状"的 IOException 都认证为"从未派发",但响应投递也运行在调用方提供的执行器上——在服务端已受理之后才出现的拒绝,会把一个已被 admit 的轮次的活跃标记丢掉并报告为"确定未提交"。现在只有原始 RejectedExecutionException(提交时)或执行器已终止两种情形归为饱和/已知;中途形状一律保持 outcome-unknown 并保留标记。通过包级执行器测试缝以"停住 worker + 填满队列 + 延迟应答 202"的方式确定性钉住。
  • 缺 boot 头的 4xx 被误分类为 outcome-unknown:缺头 wrap 把服务端自身在中间件之前发出的确定性拒绝(413 body 过大、429)与网关错误页一视同仁。四个变更路径现在重新推导:歧义(408/5xx)保持 outcome-unknown;确定性无 fence 拒绝以携带状态码的 DaemonHttpException 呈现。
  • 顺带闭环的同簇项:detachSession 对任何确定性应答都拆除本地 attachment(不再只有 204/404),认证吊销后的 403 不再泄漏心跳定时器;流关闭时排在 cursorLock 上的调用方在锁内重检并得到"流已关闭"信号而非传输错误;session_snapshot 注释现在写明真实生产者(主事件路由上 bridge 的 withSnapshot——hosted 路由从不读取该查询参数且每一帧都带 id);builder javadoc 记录游标兜底优先级与 snapshot(true) 是主传输选项;README 重试段落与两份设计文档现在把规范 digest 写成跨语言线上契约,并记录"改变 digest 算法的升级必须先排空(或重写)在途 turn 行";另有两个此前未钉住的分支(显式游标压过 ref 水印、确定性缺头 DELETE)获得了有判别力的用例。

第一轮(#12654 合入后评审)

  • 流生命周期:HarnessEventStream 的 close() 不再停放在阻塞于 next() 的消费者之后——关闭标志为原子量,原始输入在不取任何流监视器的情况下关闭,HostedHarnessClient.close() 总能完成,被阻塞的 next() 以 DaemonTransportException 失败(上面的空闲看门狗补全了这一图景)。
  • 轮次台账正确性:409 拒绝不再保留以被拒绝 promptId 为键、永远无法清除的标记(释放槽位并抛 PromptAlreadyActiveException);同身份重试收到确定性非 409 失败时释放该重试保留的槽位;getStatus() 在远端读取前快照活跃 prompt 条目且只删除那一次注册,陈旧的 hasActivePrompt:false 不再能删掉读取在途期间准入的另一个 prompt 的登记。
  • 结果分类(第一版形态,第二轮已收窄——见上):变更路径上缺少 X-Qwen-Harness-Boot-Id fence 头的响应被分类为结果未知而非裸 DaemonProtocolException,因为未经 fence 中间件的响应无法证明变更未执行;纯本地执行器拒绝以 DaemonTransportException 呈现,而不是谎称请求可能已到达服务端。
  • 生命周期清理:closeSession(HarnessSessionRef) 把确定性 404 视为已完成并拆除 attachment 与活跃 prompt 台账,detachSession 对 attachment 同样容忍 404(它不清活跃 prompt 台账——该不对称保留,记入 [Backlog] sdk-java Hosted Harness client — 49 deferred review findings from #12654 post-merge review #13313),心跳定时器不再向已被服务端回收的会话持续投递。
  • 协议互操作:streamEvents 在 builder 省略续传对时回退到 session ref 上已校验的水印,README 承诺的 epoch fence 真正生效(Last-Event-ID 也从 ref 游标续传);不携带水印的 ref 保持无 fence 的全新流形态。共享 SSE 解析器现在接受主传输 snapshot 订阅产生的无 id 合成 session_snapshot 帧。
  • digest 与模型不变量:computePayloadDigest 对规范形式(对象键递归排序、数组顺序保持)做哈希,而不是对进程随机的 Map 迭代序做哈希,去重键可跨 JVM、跨 map 实现复现(实测否决了 fastjson2 的 MapSortField:它不对集合内嵌套的 map 排序);HarnessRuntimeExecutionRecovery 在构造时强制 known outcome 必带 status map,而不是之后在 isContinuationReady() 里 NPE。

每条发现由新测试钉住,并已运行变异见证:单独还原该发现的修复,钉住它的测试即变红(见证表见“如何验证”)。

为什么需要

Hosted Harness 客户端是私有 hosted profile 的 Java 控制面传输,其公开契约承诺 fail-closed 行为(有界资源、结果未知分类、每会话单活跃 prompt、epoch-fenced 续传)。第一轮评审证明了每一项承诺都存在具体违例;第二轮又用执行证明第一轮自己的修复在 stub 看不到的那些面上带着一处跨语言回归(CI 结论一致)以及另外四处同类违例(服务端重算 digest、hosted 路由的静默、执行器的派发/投递双重角色、closed 守卫的异常类型)。在合入前处理完两轮评审,比带着断掉的 prompt 路径上线再返工便宜。

评审者测试计划

如何验证

这些行为由 HostedHarnessClientTest 的 23 个新用例钉住。运行:

cd packages/sdk-java/qwencode
mvn -o test -Dtest=HostedHarnessClientTest     # 42 个测试(19 既有 + 23 新增)
mvn -o test                                    # 全模块:189 个测试,9 个环境门控跳过
cd ../cli && npx vitest run src/serve/hosted-harness-session.test.ts   # 181 个测试

本机 JDK 17 全绿;JDK 11 上 clean test 绿(模块目标 release 11;两个执行器拒绝用例在 JDK 11 上自行跳过——JDK 11 的 HttpClient 对挣扎中的执行器表现为停放 send 而不是抛出拒绝,已在 11/17/21 上实测)。

变异见证:第一轮表格 13 行、第二轮表格 9 行(见英文部分),每行为"还原形态 → 变异结果(全部 RED)";第二轮"看门狗/keepalive 对"一行同时记录空闲用例 RED 与 keepalive 用例 GREEN 的双向判别。

证据(Before & After)

N/A —— 非 UI 的协议/传输修复;上方变异表即为前后对照。CI 的 Hosted process fault gates / MySQL 8.4 / Java 21 车道在合并基为绿、在首个提交为红——它是线上字节/digest 回归的集成级证据,本 head 上应恢复为绿。

Tested on

OS Status
🍏 macOS ✅
🪟 Windows N/A
🐧 Linux N/A (CI)

环境(可选)

本机:JAVA_HOME=jdk17(全套件)与 jdk11(mvn clean test)、Maven 3.9.11,在 packages/sdk-java/qwencode;packages/cli 内 npx vitest run src/serve/hosted-harness-session.test.ts。

风险与范围

  • 主要风险/权衡:payload digest 现在是跨语言规范契约——旧版本对同一内容算出的 digest 会不同,这正是修复的目的(旧值是 JVM 随机值,跨进程本就复现不出)。设计文档(中英)现在记录了改变 digest 的升级必须先排空或重写在途 turn 行;协调器侧的一次性重算兜底刻意不在本切片(在 managed-agent-server 模块,记入 [Backlog] sdk-java Hosted Harness client — 49 deferred review findings from #12654 post-merge review #13313)。阻塞在 next() 的消费者现在也会在空闲中止时看到 DaemonTransportException——包括"两次调用之间"这一臂,此前表现为 IllegalStateException。
  • 未验证/范围外:feat(sdk-java): Add the Hosted Harness private client #12654 轮的 49 条 Suggestion(记入 [Backlog] sdk-java Hosted Harness client — 49 deferred review findings from #12654 post-merge review #13313)。本 PR 自身轮次中推迟的:按 code 决定标记规则的 Prompt* 异常重新设计(需要路由语义级的 API 工作,连同已核实的路由门顺序表一并记账)、协调器在 outcome-unknown 之后缺少终态出口(managed-agent-server 切片,记账)、见证表剩余覆盖项(六项中本 PR 处理了另外三项)、以及把 JDK 11 的执行器行为钉住而不只是跳过(11/17/21 的差异现在同时披露在测试、builder javadoc 与设计文档中)。closeSession(String) 仍缺 ensureOpen() 守卫([Backlog] sdk-java Hosted Harness client — 49 deferred review findings from #12654 post-merge review #13313 的 R1-50):JDK 17+ 的执行器拒绝测试刻意流经该路径并在注释中写明耦合。
  • 破坏性变更/迁移说明:digest 变更见上;submitTurn 收到 409 时现在抛 PromptAlreadyActiveException 而不是 DaemonHttpException;变更路径上的确定性无 fence 4xx 现在抛携带状态码的 DaemonHttpException 而不是 outcome-unknown 类型;submitTurn 的 toJson() 现在输出按键排序的 content block(服务端接受——它只校验形状并重算 digest)。

关联 Issue

Refs #12654(本 PR 修复其合入后评审发现)与 #13313(两轮评审推迟剩余项的 backlog)。

#12654 merged before its second review round was processed. This closes
the 11 Critical and 2 Minor findings, each re-verified against main and
pinned by a new HostedHarnessClientTest case whose mutation witness was
run (reverting the fix reddens the test):

- HarnessEventStream close() no longer parks behind a next() blocked in
  the socket read: the closed flag is atomic, the raw input is closed
  without any stream monitor, and HostedHarnessClient.close() completes;
  the blocked consumer fails with DaemonTransportException (R1-1).
- The hosted SSE transport gains the idle watchdog its stdio sibling
  has: Builder.sseIdleTimeout defaults to 45s, and a silent peer makes
  next() fail with "Hosted Harness SSE idle timeout" (R1-43).
- submitTurn releases the active-prompt slot on a definitive 409 and
  throws PromptAlreadyActiveException; retaining a marker keyed by the
  rejected promptId wedged the session client-side (R1-2). A definitive
  non-409 failure on a same-identity retry releases that slot too (F2).
- getStatus() snapshots the entry before the remote read and removes
  only that registration, so a stale hasActivePrompt:false cannot delete
  a different prompt admitted in flight (R1-4).
- Responses missing the X-Qwen-Harness-Boot-Id fence header on mutation
  paths are classified outcome-unknown (create/prompt/mutation/delete)
  instead of a bare DaemonProtocolException (R1-5).
- A local executor rejection (saturated or terminated pool) surfaces as
  DaemonTransportException instead of claiming the request may have
  reached the daemon (R1-45).
- closeSession(ref) and detachSession treat a definitive 404 as done and
  tear down the heartbeat timer (R1-3, R1-46).
- streamEvents falls back to the session ref's validated watermark when
  the builder omits the resume pair, so the epoch fence actually
  applies (R1-44).
- The shared SSE parser accepts the id-less session_snapshot frame, so
  StreamHarnessEvents.snapshot(true) works (R1-47).
- computePayloadDigest hashes a sorted-key canonical form, so the wire
  dedup key is reproducible across JVM processes (R1-6).
- HarnessRuntimeExecutionRecovery requires status for known outcomes at
  construction instead of NPE-ing in isContinuationReady() (F1).

Test: HostedHarnessClientTest 34/34 (15 new); full module 181 green with
9 env-gated skips on JDK 17 and clean test green on JDK 11; 14 mutation
witness arms all red. The remaining 49 Suggestion-level findings are
dispositioned in their review threads and tracked in #13313.
Addresses the CHANGES_REQUESTED round on #13314, which execution-proved
one real regression in the first commit plus five more critical defects
around it:

- R1-1 (the regression CI confirmed on the fault-gates lane): the digest
  was canonicalized but the wire `prompt` member was not, and the hosted
  route re-derives the digest from the received bytes — every addText
  submission drew `400 invalid_hosted_prompt`. toJson() now emits the
  canonical form, the digest reuses the JsonSupport.encode facade over
  that same value, and the test asserts the wire bytes and the digest
  are literally the same value.
- R1-3: the 45s idle watchdog was inherited from the stdio transport,
  whose server heartbeats; the hosted events route wrote nothing while
  no event was committed, so healthy silent streams (tool calls, the
  10-minute approval wait) were aborted. The hosted route now mirrors
  the primary route's keepalive comment every 15s, and
  Builder.sseIdleTimeout accepts Duration.ZERO for callers that own the
  deadline. A keepalive-only peer is covered by a new test (consumer
  parked in read for three idle budgets).
- R1-4: an idle abort while the consumer was between next() calls
  surfaced IllegalStateException (not the DaemonException family). The
  closed guard now distinguishes who closed the stream: idle abort ->
  DaemonTransportException("Hosted Harness SSE idle timeout"),
  caller close -> IllegalStateException, matching the javadoc.
- R1-5: the cause-chain scan certified any rejection-shaped IOException
  as "never dispatched", but delivery also runs on the caller executor,
  so a rejection after the server accepted the prompt dropped the
  active-prompt marker for an admitted turn. Only the bare
  RejectedExecutionException (submit-time) and the terminated-executor
  case now classify as saturated/known; everything mid-flight stays
  outcome-unknown. A deterministic delivery-phase test drives this via
  a package-private executor seam (park the worker, fill the queue,
  then answer 202).
- R1-6: the missing-boot-header wrap reclassified every unfenced
  response as outcome-unknown, including definitive 4xx the server
  emits itself before the fencing middleware (413, 429). All four
  sites now re-derive: ambiguous (408/5xx) keeps outcome-unknown,
  definitive unfenced statuses surface as DaemonHttpException with
  their status preserved.
- R1-7 (suggestion folded in, same hunk family): detachSession tears
  the local attachment down for every definitive answer, not just 204
  and 404 — a 403/400/410 no longer leaks a heartbeat timer.
- R1-13 (suggestion, adjacent): a caller queued on cursorLock when the
  stream closes re-checks inside the lock and gets the closed-stream
  signal instead of a transport error.

Also: the snapshot frame comment now names the actual producer (the
bridge's withSnapshot on the primary events route — never the hosted
route); the StreamHarnessEvents builder javadoc documents the
lastEventId fallback precedence and that snapshot(true) is a
primary-transport option; the README retry section and both design-doc
languages now state the canonical digest as a cross-language wire
contract and record that changing the digest algorithm requires
quiescing or rewriting in-flight turn rows (R1-2's deployment note);
the two 10ms heartbeat tests assert liveness instead of comparing
zeros; and an explicit-cursor-wins case plus a definitive
boot-headerless DELETE case close the two remaining unpinned arms.

Test: HostedHarnessClientTest 42/42 (full module 189 green, 9
env-gated skips) on JDK 17; clean test green on JDK 11 (2 additional
version-gated skips: JDK 11 parks such sends instead of surfacing the
rejection); hosted-harness-session.test.ts 181/181. Nine mutation
witness arms all red (revert toJson canonicalization, forget idle
signal in the closed guard, drop the in-lock re-check, unbounded
cause-walk, blanket boot-header wrap at prompt and DELETE sites,
detach without finally, watchdog removed with the keepalive arm
staying green, ref-only resume fallback).
@wenshao

wenshao commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author

CI attribution note for the transient Hosted process fault gates / MySQL 8.4 / Java 21 failure on 448c645160.

Outcome: flaky, not this PR. The rerun of the same lane on the same head is green.

Evidence set, because a red lane of this job once before meant something (this same lane caught the genuine wire/digest regression on the first commit, which the new head fixes end-to-end):

  • The two suites that caught that regression — HostedHarnessMySqlIT (2/2) and HostedPublicWorkspaceIT (4/4) — were green inside the failed run, so the wire/digest contract the regression lived in was exercised and passed on this head.
  • The single failure was HostedWorkspaceToolTurnIT (the TS scenario driver): javaLoad at :836 expected 200 and got 409 hosted_turn_recovery_required. The same route had already shown the recovery-boundary shape seconds earlier (files/rewind answered 409 then, on retry, 200), which is what a slow activation-recovery boundary looks like — the lane elapsed 22m38s vs 17m25s on the previous run (≈ +30% runner slowdown in that window).
  • Causal exclusion of this PR's only server-side change: the lane log contains zero GET /session/:id/events calls, so the new hosted-route keepalive timer never executed in the failing scenario; and the keepalive's first possible tick (15s) postdates the failure timestamp anyway. The Java-side admit path is vouched green by the two suites above.
  • Same signature on main: the last 8 sdk-java.yml runs on main are all green, and the retrievable failed-job logs contain zero occurrences of hosted_turn_recovery_required on this driver.

The one pending lane is the scheduled re-review (review-pr); its verdict belongs to the next round.

…view-criticals

# Conflicts:
#	packages/sdk-java/qwencode/src/test/java/com/alibaba/qwen/code/daemon/HostedHarnessClientTest.java
@wenshao

wenshao commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author

@qwen-code /takeover

@qwen-code-dev-bot qwen-code-dev-bot added the autofix/takeover Summon the autofix loop to manage this PR (remove to release; needs triage+) label Oct 4, 2026
@qwen-code-dev-bot

Copy link
Copy Markdown
Collaborator

🤝 Takeover engaged: the autofix loop now manages this PR — it will address new review feedback and resolve base conflicts until the label is removed or the round cap is reached. Remove the autofix/takeover label (or comment @qwen-code /takeover stop) to release.

中文说明

🤝 已接管:autofix 循环现在管理此 PR —— 将持续处理新的评审反馈与 base 冲突,直到移除标签或达到轮次上限。移除 autofix/takeover 标签(或评论 @qwen-code /takeover stop)即可释放。

@qwen-code-dev-bot

qwen-code-dev-bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

⚠️ AutoFix round 11 ended without publishing a report — view run.

中文说明

⚠️ AutoFix 第 11 轮结束但未发布报告 —— 查看运行。

…ss client (#13314)

- submitTurn: a definitive unfenced refusal (a response without a valid
  boot header that is not an ambiguous 408/5xx) now releases only the
  active-prompt marker the call owns, in both the validateGeneration arm
  and the post-consume arm; a refusal produced before the route's
  promptId lookup can no longer delete an earlier same-identity entry
  whose outcome is unknown, and a refused fresh submission no longer
  wedges the session.
- send: snapshot the executor termination state before dispatch so a
  close() racing an in-flight send keeps its outcome-unknown
  classification instead of certifying non-dispatch.
- StreamHarnessEvents: an explicit lastEventId cursor now always wins,
  including a deliberate 0 (replay from the beginning), which
  HarnessCoordinator passes for turn rows without a recorded watermark;
  only an omitted cursor falls back to the session ref's watermark.
- HarnessEventStream: the idle watchdog now measures peer silence only
  while a consumer is parked in next(), so time between calls (a
  blocking queue handoff, a slow event handler) no longer aborts a
  healthy keepalived stream.
- docs: the payload digest is re-derived by the server from its own
  re-serialization of the parsed prompt member (JSON.stringify form),
  not from the received bytes; the README qualifies cross-release digest
  stability and the keepalive floor for a custom idle timeout.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
@qwen-code-dev-bot

Copy link
Copy Markdown
Collaborator

🤖 Addressed the latest review feedback (round 1/100). What changed, and what I pushed back on: · 已处理最新评审反馈(第 1/100 轮)。改动内容与我反驳保留之处如下:

Round summary — third-round review criticals on the Hosted Harness client

Commit 7ef81640fd on fix/sdk-java-12654-review-criticals. This round closed all six Critical findings from the second-round review (plus five Suggestions that shared the same edited lines) and deferred the remaining fourteen Suggestions to the next round per the per-round batch bound (Criticals first); each deferral is answered on its own thread.

Resolved in the code

  • rc:4177489211 (Critical, owned marker not released on definitive unfenced refusal). submitTurn's validateGeneration arm now releases the marker this call owns (two-arg remove, same as the 409 arm) before throwing DaemonHttpException, so a definitive pre-route refusal (e.g. a headerless 413 from the body parser) no longer wedges the session behind the local veto. aDefinitiveBootHeaderless4xxKeepsItsStatus now re-points the route at a 202 after the 413 and asserts a second identity reaches the wire; the mutation probe (delete the added remove) reds it with exactly the reviewer's wedge signature (DaemonException: Hosted Harness session already has a running turn).
  • rc:4177489221 (Critical, definitive non-409 arm deleted a marker it did not own). The post-consume definitive arm keeps the ownership guard: only a marker this call owns is released; a same-identity entry stays, because a refusal produced before the route's promptId lookup (auth 401/403, rate-limit 429, body-parse 400/413 — none carrying a valid boot id) cannot prove the earlier submission was not admitted. aDefinitiveRetryFailureReleasesTheRetainedEntry was rewritten as anUnfencedDefinitiveRefusalKeepsTheRetainedEntry (503 → headerless 401 → a third identity is vetoed locally, promptCalls == 2); reverting to the non-owned release reds it. This also closes rc:4177489309 (Suggestion): the impossible 400 bad_request fixture is gone — the rewritten test drives the arm with a 401, a refusal the real route genuinely produces before the promptId lookup.
  • rc:4177489227 (Critical, primitive-long cursor swallowed an explicit 0). StreamHarnessEvents now carries Long lastEventId (null = omitted): an explicit cursor always wins, including a deliberate 0 (replay from the beginning — what HarnessCoordinator passes for a turn row without a recorded watermark), and only an omitted cursor falls back to the ref's watermark. The builder javadoc now says so instead of documenting the gap. New anExplicitZeroCursorReplaysFromTheBeginning loads a ref with watermark 7 and asserts the wire still carries Last-Event-ID: 0; a ref-only-fallback mutation reds it (and anExplicitResumePairWinsOverTheRefsWatermark still pins the explicit-nonzero half).
  • rc:4177489237 (Critical, close() racing an in-flight send misclassified as known-undelivered). send snapshots terminatedBeforeSend = httpExecutor.isShutdown() ahead of dispatch and requires that snapshot (instead of the catch-time state) for the known-undelivered classification; a termination that lands mid-flight keeps PromptAdmissionUnknownException. New aMidFlightExecutorShutdownKeepsAdmissionUnknown (17+, same JDK caveat as the queue-full case: 11 parks such sends) shuts the override executor down after the stub saw the prompt and asserts admission-unknown plus the retained marker; reverting the guard reds it with the exact misclassification from the reviewer's probe. aLocalExecutorRejectionIsNotReportedAsOutcomeUnknown still pins the terminated-before-dispatch case and stays green.
  • rc:4177489200 (Critical, watchdog measured consumer reads, not peer liveness). The idle budget is now park-scoped: next() arms it on entry (and re-stamps the clock), disarms in finally, and the watchdog skips streams with no parked consumer — so time between calls (the in-repo consumer's blocking queue handoff, an approval wait handled outside the stream, a slow event handler) no longer aborts a healthy keepalived stream, while a consumer parked against a silent peer still gets the abort. anIdleAbortBetweenNextCallsReportsTheIdleTimeout was replaced by aConsumerStallBetweenReadsKeepsAHealthyStream (stub writes an event, keepalives through a 3×-budget consumer stall, then a second event; the next next() returns it) — dropping the arming gate reds it with the reviewer's DaemonTransportException: Hosted Harness SSE idle timeout. anIdlePeerFailsTheStreamWithinTheIdleBudget is unchanged and additionally pins the post-abort closed guard (a later caller gets the DaemonException-family idle signal, not IllegalStateException), which reds when the idleTimedOut branch of closedFailure() is removed. The close()-never-takes-cursorLock invariant is untouched; closeReleasesAConsumerBlockedInNext stays green.
  • rc:4177489194 (Critical, digest docs claimed the server hashes the received bytes). Corrected in both design-doc languages, the README, and the SubmitHarnessTurn.computePayloadDigest comment: the route re-serializes the parsed prompt member with JavaScript JSON.stringify semantics (compact separators, literal non-ASCII) and hashes those bytes, so a client in any language must emit that member in exactly that form. No code-side change: the Java client already emits that form (probe in the finding confirms), and raw-body capture was the optional alternative.

Folded in with the same edited sentences/lines:

  • rc:4177489258 — the README no longer promises digest reproducibility "across SDK releases"; it now states the form is SDK-versioned and an upgrade must quiesce or rewrite in-flight turn rows, matching the design doc.
  • rc:4177489306 + rc:4177489244 — the sseIdleTimeout javadoc, README, and both design docs now state the measured quantity (peer silence while a consumer is parked in next(); time between calls is not charged) and the keepalive floor (a custom bound should stay comfortably above the route's 15-second keepalive interval). The optional named-constant hoist in the CLI route was skipped — optional per the finding, and it travels with the deferred CLI keepalive items.

Deferred to the next round (each answered on its thread)

Per the per-round batch bound, fourteen Suggestions wait one round: rc:4177489248 + rc:4177489254 (CLI keepalive observability test and write containment), rc:4177489265 (Duration.ZERO opt-out test), rc:4177489268 (watchdog-scheduling race; needs a scheduler seam), rc:4177489275 (dispatch-phase DaemonTransportException release-arm test), rc:4177489277 (carry status/code on PromptAlreadyActiveException), rc:4177489283 (getStatus admit-after-eval race), rc:4177489288 (detach teardown constrained to definitive answers), rc:4177489292 (terminal client-unusable state for selector-manager closing), rc:4177489301 ("shut down" vs "saturated" message), rc:4177489319 (Java-11 self-skip; ensureOpen() on closeSession(String), paired with rc:4177489301), rc:4177489311 (DELETE wrap-site ambiguous test), rc:4177489314 (closeByRef DELETE counter assertion), rc:4177489325 (closeSession finally-teardown parity with detach).

Notes for the reviewer

  • Also resolved this round, after re-verifying each still holds in the tree: the twelve round-1 threads whose fixes landed in 448c645160 (R1-1/R1-2 wire-vs-digest and digest-value disclosure, R1-3 keepalive+watchdog, R1-4 closed-guard routing, R1-5 executor-rejection narrowing, R1-6 headerless-response classification, R1-7 detach 404 tolerance, R1-8 cursor precedence — now completed by this round's explicit-0 semantics, R1-9 session_snapshot producer comment, R1-10 README retry contract, R1-13 in-lock re-check, R1-12 JDK-11 gate disclosure). The two round-1 threads with maintainer-recorded deferrals stay open: rc:4175182432 (R1-11, code-dependent marker rules in [Backlog] sdk-java Hosted Harness client — 49 deferred review findings from #12654 post-merge review #13313 — this round's ownership guards rework the same arms but do not settle the deferred API slice) and rc:4175182441 (R1-14, four witness items remain in [Backlog] sdk-java Hosted Harness client — 49 deferred review findings from #12654 post-merge review #13313).

  • Two pre-existing test methods in HostedHarnessClientTest were replaced rather than extended, because the behaviors they pinned were the defects the Criticals closed: aDefinitiveRetryFailureReleasesTheRetainedEntry (pinned releasing a non-owned marker on a definitive refusal — disproved by rc:4177489221, and its 400 fixture was unreachable per rc:4177489309) and anIdleAbortBetweenNextCallsReportsTheIdleTimeout (pinned between-calls idle aborts — the defect rc:4177489200 closed). The replacements pin the new contract and each reds on its mutation, recorded below. (The gate's test-weakening parser watches JS/TS files only; these are Java, so no test-weakening.json entries apply — the evidence is here.)

  • aMidFlightExecutorShutdownKeepsAdmissionUnknown and the two pre-existing executor tests self-skip on Java 11 (the send parks there instead of surfacing the rejection — the same version axis the reviewer probed); the full matrix executes them on 17/21, and both were executed green locally on Temurin 21.0.12.1, with the mutation probe red on 21.

Verification

  • mvn -o verify -Dgpg.skip=true in packages/sdk-java/qwencode on Temurin 21.0.12.1 — BUILD SUCCESS; HostedHarnessClientTest 50 run, 0 failures, 0 skipped (executor tests execute); module total 197 run, 0 failures, 9 skipped (pre-existing env-gated E2Es); 0 Checkstyle violations.
  • mvn -o test in packages/sdk-java/qwencode on Temurin 11.0.32.1 — BUILD SUCCESS; HostedHarnessClientTest 50 run, 0 failures, 3 skipped (the 17+-gated executor tests); module total 197 run, 0 failures.
  • Mutation probes (each: apply → focused mvn test -Dtest=HostedHarnessClientTest → confirm RED → revert → suite green again):
    • remove the owned-release from the validateGeneration arm → aDefinitiveBootHeaderless4xxKeepsItsStatus reds (DaemonException: …already has a running turn).
    • restore the non-owned release in the definitive non-409 arm → anUnfencedDefinitiveRefusalKeepsTheRetainedEntry reds (third call reaches the wire).
    • ref-only cursor fallback → anExplicitZeroCursorReplaysFromTheBeginning and anExplicitResumePairWinsOverTheRefsWatermark red.
    • drop the parked-consumer gate from the watchdog → aConsumerStallBetweenReadsKeepsAHealthyStream reds (DaemonTransportException: …idle timeout).
    • remove the idleTimedOut branch of closedFailure() → anIdlePeerFailsTheStreamWithinTheIdleBudget reds (post-abort caller gets IllegalStateException).
    • revert terminatedBeforeSend to catch-time isShutdown() (on JDK 21) → aMidFlightExecutorShutdownKeepsAdmissionUnknown reds with the reviewer's exact misclassification (DaemonTransportException: …executor is saturated).
  • mvn -o install -DskipTests -Dgpg.skip=true for qwencode-sdk, then mvn -o compile and mvn -o test-compile for managed-agent-server on JDK 21 — both green against the modified artifact (the StreamHarnessEvents cursor change is source-compatible for its only out-of-package caller, QwenHostedHarnessConnector).
  • npm run build — passed (needed COREPACK_HOME=/tmp/corepack-cache: the sandbox denies writes to $HOME/.cache; the first attempt failed on that permission alone, before any compilation).
  • npm run typecheck — passed (same COREPACK_HOME).
  • npm run lint — passed. Note: the first run reported 728 errors, all inside packages/sdk-java/qwencode/target/site/jacoco/** — report files generated by my own Maven runs; after removing the target/ build output, lint is clean. The round's diff contains no JS/TS changes.
  • managed-agent-server full surefire run on JDK 21 shows 1 failure + 23 errors, all in runtime-broker Spring/H2 schema tests (RuntimeBrokerDefaultOnTest, RuntimeBrokerFlywaySchemaTest, WorkspaceRecoveryTest, WorkspaceRuntimeTest: Column "phase" not found in qwen_runtime_harness_drain). None of those classes load the changed package, the PR never touches that module, and the same failure signature appears in this runner's 2026-10-02 pre-round log (/tmp/mvn-mas-test2.log: 418 run, 105 errors) — pre-existing environmental breakage, not from this round.
  • In-round self-review: not armed (Self-review: off).
中文说明

本轮摘要 —— Hosted Harness 客户端第三轮 review Critical 收尾

提交 7ef81640fd(分支 fix/sdk-java-12654-review-criticals)。本轮关闭了第二轮 review 的全部六条 Critical(外加五条与所改行重叠的 Suggestion),并按每轮批量上限(Critical 优先)把其余十四条 Suggestion 顺延到下一轮,每条都在各自 thread 中回复了去向。

已在代码中解决

  • rc:4177489211(Critical,确定性无 fence 拒绝不释放自有标记)。 submitTurn 的 validateGeneration 分支在抛 DaemonHttpException 前释放本调用自有的标记(与 409 分支相同的双参 remove),路由前的确定性拒绝(如 body parser 的无 header 413)不再让会话被本地否决卡住。aDefinitiveBootHeaderless4xxKeepsItsStatus 现在在 413 之后把路由指到 202 并断言第二个身份能上达网络;变异探针(删掉新增的 remove)使其变红,报错正是 reviewer 的楔死特征(DaemonException: Hosted Harness session already has a running turn)。
  • rc:4177489221(Critical,确定性非 409 分支删除了不属于它的标记)。 consume 后的确定性分支恢复所有权守卫:只释放本调用自有的标记;同身份旧条目保留,因为在路由的 promptId 查找之前产生的拒绝(auth 401/403、限流 429、body 解析 400/413——都不带合法 boot id)无法证明先前的提交未被受理。aDefinitiveRetryFailureReleasesTheRetainedEntry 被改写为 anUnfencedDefinitiveRefusalKeepsTheRetainedEntry(503 → 无 header 401 → 第三个身份被本地否决,promptCalls == 2);恢复非自有释放的变异使其变红。这同时关闭了 rc:4177489309(Suggestion):不可能的 400 bad_request 夹具已不存在——改写后的用例用 401 驱动该分支,401 是真实路由在 promptId 查找之前确实会产生的拒绝。
  • rc:4177489227(Critical,原始 long 游标吞掉显式 0)。 StreamHarnessEvents 改为携带 Long lastEventId(null 表示未设置):显式游标永远生效,包括刻意的 0(从头重放——HarnessCoordinator 对没有记录水位线的 turn 行传的正是 0);只有未设置游标时才回退到 ref 水位线。builder javadoc 也改为如实描述而不再是记录缺陷。新增 anExplicitZeroCursorReplaysFromTheBeginning:加载水位线为 7 的 ref,断言线上仍携带 Last-Event-ID: 0;仅按 ref 回退的变异使其变红(anExplicitResumePairWinsOverTheRefsWatermark 继续钉住显式非零的一半)。
  • rc:4177489237(Critical,close() 与在途 send 竞态被误判为已知未派发)。 send 在派发前快照 terminatedBeforeSend = httpExecutor.isShutdown(),已知未派发的判定要求该快照(而非 catch 时刻的状态);派发后才发生的终止保持 PromptAdmissionUnknownException。新增 aMidFlightExecutorShutdownKeepsAdmissionUnknown(17+,与队列满用例相同的 JDK 限制:11 会挂起此类 send):在 stub 收到 prompt 后关闭覆写执行器,断言 admission-unknown 且标记保留;回退该守卫会以 reviewer 探针中的误判形态变红。aLocalExecutorRejectionIsNotReportedAsOutcomeUnknown 继续钉住派发前已终止的情形,保持绿色。
  • rc:4177489200(Critical,看门狗度量的是消费者读取而非对端活性)。 空闲预算改为按“停放”计:next() 进入时启动(并重新打点)、finally 中解除,看门狗跳过没有停放消费者的流——因此两次调用之间的时间(仓库内消费者的阻塞队列交接、在流外处理的审批等待、慢事件处理)不再中断健康且有 keepalive 的流;而停放着却遇到静默对端的消费者仍会按时中止。anIdleAbortBetweenNextCallsReportsTheIdleTimeout 被替换为 aConsumerStallBetweenReadsKeepsAHealthyStream(stub 先写一个事件,在 3 倍预算的消费者停滞期间持续 keepalive,再写第二个事件;下一次 next() 返回该事件)——去掉启动条件的变异使其以 reviewer 的 DaemonTransportException: Hosted Harness SSE idle timeout 变红。anIdlePeerFailsTheStreamWithinTheIdleBudget 不变,并新增钉住中止后的关闭守卫(后来的调用者得到 DaemonException 族的空闲信号,而非 IllegalStateException),删掉 closedFailure() 的 idleTimedOut 分支时该断言变红。close() 不取 cursorLock 的不变量未动;closeReleasesAConsumerBlockedInNext 保持绿色。
  • rc:4177489194(Critical,digest 文档声称服务端对收到的字节取哈希)。 已在两个语言的设计文档、README 与 SubmitHarnessTurn.computePayloadDigest 注释中更正:路由把解析后的 prompt 成员按 JavaScript JSON.stringify 语义(紧凑分隔符、非 ASCII 字面)重新序列化并对这些字节取哈希,因此任何语言的客户端都必须以该形式发出这个成员。无代码侧改动:Java 客户端本来就以该形式发出(finding 中的探针已确认),而原始请求体捕获只是可选的另一方案。

随同一批被修改的句子/行一并收尾的:

  • rc:4177489258 —— README 不再承诺 digest“跨 SDK 版本可复现”;现在写明该形式随 SDK 版本而定,升级必须先排空或重写在途 turn 行,与设计文档一致。
  • rc:4177489306 + rc:4177489244 —— sseIdleTimeout javadoc、README 与两份设计文档现在都写明被度量的量(消费者停在 next() 内期间的对端静默;两次调用之间的时间不计入)以及 keepalive 下限(自定义预算应明显高于路由 15 秒的 keepalive 间隔)。finding 中可选的 CLI 路由具名常量提炼未做——finding 标注为可选,且它随顺延的 CLI keepalive 条目一起走。

顺延到下一轮(均已在各自 thread 回复)

按每轮批量上限,十四条 Suggestion 顺延一轮:rc:4177489248 与 rc:4177489254(CLI keepalive 可观测性用例与写入防护)、rc:4177489265(Duration.ZERO 关闭看门狗用例)、rc:4177489268(看门狗排程竞态,需要 scheduler 测试缝)、rc:4177489275(派发阶段 DaemonTransportException 释放分支用例)、rc:4177489277(PromptAlreadyActiveException 携带状态码与 code)、rc:4177489283(getStatus 的 admit-after-eval 竞态)、rc:4177489288(detach 拆除限定在确定性应答)、rc:4177489292(selector-manager 关闭后的客户端终态)、rc:4177489301(“shut down”与“saturated”文案区分)、rc:4177489319(Java 11 自动跳过;closeSession(String) 加 ensureOpen(),与 rc:4177489301 配套)、rc:4177489311(DELETE wrap 分支的模糊状态用例)、rc:4177489314(closeByRef 的 DELETE 计数断言)、rc:4177489325(closeSession 与 detach 的 finally 拆除对齐)。

给 reviewer 的说明

  • 本轮还关闭了十二条第一轮 thread(逐条复核在当前代码树中仍然成立,修复均落地于 448c645160):R1-1/R1-2 线上字节与 digest 一致及 digest 取值变更披露、R1-3 keepalive+看门狗、R1-4 关闭守卫路由、R1-5 执行器拒绝收窄、R1-6 无 header 响应分类、R1-7 detach 404 容忍、R1-8 游标优先级(本轮的显式 0 语义将其补齐)、R1-9 session_snapshot 来源注释、R1-10 README 重试契约、R1-13 锁内复查、R1-12 JDK-11 门控披露。两条带有维护者记录的顺延决定的第一轮 thread 保持打开:rc:4175182432(R1-11,按 code 决定标记处置的 API 切片在 [Backlog] sdk-java Hosted Harness client — 49 deferred review findings from #12654 post-merge review #13313——本轮的所有权守卫改写了同一批分支但并不结算该顺延切片)与 rc:4175182441(R1-14,四个 witness 项仍在 [Backlog] sdk-java Hosted Harness client — 49 deferred review findings from #12654 post-merge review #13313)。

  • HostedHarnessClientTest 中两个既有测试方法是被替换而非扩展,因为它们钉住的行为正是 Critical 所关闭的缺陷:aDefinitiveRetryFailureReleasesTheRetainedEntry(钉住“确定性拒绝释放非自有标记”——被 rc:4177489221 证伪,且其 400 夹具按 rc:4177489309 不可达)与 anIdleAbortBetweenNextCallsReportsTheIdleTimeout(钉住“调用之间”的空闲中止——即 rc:4177489200 关闭的缺陷)。替换用例钉住新契约,且各自在变异下变红,见下方记录。(gate 的测试弱化解析器只监控 JS/TS 文件;这些是 Java 文件,因此无需 test-weakening.json 条目——证据记录在此。)

  • aMidFlightExecutorShutdownKeepsAdmissionUnknown 与两个既有执行器用例在 Java 11 上自动跳过(11 会挂起此类 send 而不抛出拒绝——与 reviewer 探测的版本轴一致);完整矩阵在 17/21 上执行它们,本地已在 Temurin 21.0.12.1 上执行并通过,变异探针在 21 上变红。

验证

  • mvn -o verify -Dgpg.skip=true(packages/sdk-java/qwencode,Temurin 21.0.12.1)——BUILD SUCCESS;HostedHarnessClientTest 50 跑、0 失败、0 跳过(执行器用例实际执行);模块共 197 跑、0 失败、9 跳过(既有的环境门控 E2E);Checkstyle 0 违规。
  • mvn -o test(同模块,Temurin 11.0.32.1)——BUILD SUCCESS;HostedHarnessClientTest 50 跑、0 失败、3 跳过(17+ 门控的执行器用例);模块共 197 跑、0 失败。
  • 变异探针(每个:打入 → 聚焦 mvn test -Dtest=HostedHarnessClientTest → 确认变红 → 还原 → 套件回绿):
    • 删除 validateGeneration 分支的自有释放 → aDefinitiveBootHeaderless4xxKeepsItsStatus 变红(DaemonException: …already has a running turn)。
    • 在确定性非 409 分支恢复非自有释放 → anUnfencedDefinitiveRefusalKeepsTheRetainedEntry 变红(第三个调用到达网络)。
    • 仅按 ref 的游标回退 → anExplicitZeroCursorReplaysFromTheBeginning 与 anExplicitResumePairWinsOverTheRefsWatermark 变红。
    • 去掉看门狗的停放消费者条件 → aConsumerStallBetweenReadsKeepsAHealthyStream 变红(DaemonTransportException: …idle timeout)。
    • 删除 closedFailure() 的 idleTimedOut 分支 → anIdlePeerFailsTheStreamWithinTheIdleBudget 变红(中止后的调用者拿到 IllegalStateException)。
    • 把 terminatedBeforeSend 回退为 catch 时刻的 isShutdown()(JDK 21 上)→ aMidFlightExecutorShutdownKeepsAdmissionUnknown 以 reviewer 的误判形态变红(DaemonTransportException: …executor is saturated)。
  • mvn -o install -DskipTests -Dgpg.skip=true(qwencode-sdk),随后 JDK 21 上对 managed-agent-server 执行 mvn -o compile 与 mvn -o test-compile——均通过(StreamHarnessEvents 游标改动对其唯一的包外调用方 QwenHostedHarnessConnector 源码兼容)。
  • npm run build——通过(需要 COREPACK_HOME=/tmp/corepack-cache:沙箱禁止写 $HOME/.cache;首次失败仅因该权限问题,尚未进入编译)。
  • npm run typecheck——通过(同上 COREPACK_HOME)。
  • npm run lint——通过。说明:首次运行报 728 个错误,全部位于 packages/sdk-java/qwencode/target/site/jacoco/**——是我自己的 Maven 运行生成的报告文件;删除 target/ 构建产物后 lint 干净。本轮 diff 不含任何 JS/TS 改动。
  • JDK 21 上 managed-agent-server 的完整 surefire 运行有 1 失败 + 23 错误,全部在 runtime-broker 的 Spring/H2 schema 测试(RuntimeBrokerDefaultOnTest、RuntimeBrokerFlywaySchemaTest、WorkspaceRecoveryTest、WorkspaceRuntimeTest:qwen_runtime_harness_drain 表 Column "phase" not found)。这些类不加载被改的包,本 PR 也从未触碰该模块,且本 runner 2026-10-02 的本轮前日志(/tmp/mvn-mas-test2.log:418 跑、105 错误)已出现相同特征——属既有环境性破坏,与本轮无关。
  • 轮内自审:未启用(Self-review: off)。

Base-conflict check · 基分支冲突检查: no conflict with main. · 与 main 无冲突。

🧵 Resolved all 23 selected review thread(s). · 已关闭全部选中的 23 条评审线程。

Re-review when you have a moment. After round 100 this bot stops and leaves the PR for a human. · 有空请复审;第 100 轮后本 bot 停止并将 PR 交给人工。


🧠 Handled by Qwen Code · model/模型 kimi-k3 · CLI 0.24.7

@wenshao

wenshao commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author

/qwen-code /takeover

qwen-code-ci-bot added 2 commits October 4, 2026 21:42
…view-criticals

# Conflicts:
#	packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/daemon/HarnessEventStream.java
…ss client (#13314)

- Carry the wire status and machine-readable code through
  PromptAlreadyActiveException instead of collapsing every 409 into a
  fixed message
- Keep a prompt marker whose submission is still in flight from being
  cleared by a status answer that predates the admission
- Map a watchdog scheduling rejection to DaemonTransportException and
  drop the stranded stream registration
- Document the enforced idle-abort window (budget to 1.5x) and the
  peer-side backpressure limit on consumer pauses
- Pin the fenced definitive-refusal release, the Duration.ZERO watchdog
  opt-out, the next() entry stamp, and the terminated-executor release
  with dedicated regression tests
@qwen-code-dev-bot

Copy link
Copy Markdown
Collaborator

🤖 Addressed the latest review feedback (round 2/100). What changed, and what I pushed back on: · 已处理最新评审反馈(第 2/100 轮)。改动内容与我反驳保留之处如下:

Round 4 — review findings addressed

All nine round-3 inline findings are resolved in code, each pinned by a
mutation probe (mutant applied, focused test confirmed red, mutant
reverted, suite confirmed green). The branch was also merged with
origin/main (conflict resolution: the PR's HarnessEventStream
rewrite now uses a ReentrantLock instead of a monitor, carrying over
main's virtual-thread carrier-pinning fix from #13388 so main's
HarnessEventStreamPinningTest keeps passing on JDK 21).

Findings

  • R3-1 (rc:4179235828, README.md:162) — Fixed. The documented
    45-second idle bound understated the enforcement window. README.md,
    docs/design/2026-09-21-hosted-harness-private-protocol.md and its
    .zh-CN.md twin now state that the watchdog checks every half-budget,
    so an idle abort lands between the budget and 1.5x it (45–67.5 s at
    the default) and any outer supervisor deadline should sit above the
    upper bound. Doc-side only; the shared half-budget poll mechanism is
    unchanged.
  • R2-17 (rc:4179235831, HostedHarnessClient.java sseIdleTimeout
    javadoc)
    — Fixed. The "does not lose a healthy stream" sentence
    over-promised: the hosted events route ends the SSE response on
    backpressure (write buffer full, no drain listener), which the
    client can only observe as a clean EOF. The javadoc now says the
    watchdog never charges time between next() calls but the peer does
    not share that patience, so a pausing consumer must bound the pause
    and re-open from getLastEventId()/getEventEpoch() when the stream
    ends early.
  • R3-2 (rc:4179235834, fenced definitive-non-409 release arm) —
    Fixed with aFencedDefinitiveRefusalReleasesTheOwnedEntry: first
    attempt answered with a fenced 400 (boot id present via
    sendSessionJson), then a different-identity 202. Recipe adaptation
    note: the suggested 503→400 retry shape cannot pin the release —
    under the ownsActivePrompt guard the retry is a non-owner, and the
    finding's own refutation shows that arm is an identity-CAS no-op. The
    pin the finding demands ("different identity vetoed locally instead of
    reaching the wire when the release is deleted") requires the refusal
    on the owner attempt, which is what the test does. Probe: deleting the
    release at HostedHarnessClient.java's definitive non-409 arm turns
    the test red with the local veto (already has a running turn).
  • R3-3 (rc:4179235835, aConsumerStallBetweenReadsKeepsAHealthyStream) —
    Fixed. The test now stops the keepalive loop before the 1200 ms stall
    (second latch) so the socket is empty when the consumer re-enters, and
    the handler waits 250 ms — strictly between the 200 ms tick and the
    400 ms budget — before writing event 2. Probe: deleting the
    lastActivity entry stamp in HarnessEventStream.next() turns the
    test red with DaemonTransportException: Hosted Harness SSE idle timeout. The rewrite still pins the consumerWaiting gate (removing
    it aborts the stream mid-stall).
  • R2-9 (rc:4179235837, Duration.ZERO opt-out) — Fixed with
    aZeroIdleTimeoutDisablesTheWatchdog: a consumer parked against a
    peer silent for 500 ms (several would-be ticks) receives the event
    written afterwards. Probe: deleting the isZero() early return (a
    1 ms budget with a 100 ms poll) turns the test red with an idle
    timeout.
  • R2-10 (rc:4179235942, startIdleWatchdog rejection) — Fixed both
    halves: the schedule call is wrapped so a racing client.close()
    surfaces DaemonTransportException (the mapping send() uses), and
    the just-registered stream is unregistered so it is not stranded.
    aWatchdogSchedulingFailureUnregistersTheStream arms a stream, shuts
    the scheduler down, re-arms, and asserts the mapped exception plus an
    empty registration set. Probes: dropping the unregister fails on
    expected:<0> but was:<1>; dropping the wrap fails with the raw
    RejectedExecutionException. The direct idleWatchdog assignment
    order is unchanged, so a self-cancelling first tick still sees the
    future.
  • R2-11 (rc:4179236034, terminated-executor release arm) — Fixed
    with aTerminatedHttpExecutorReleasesTheOwnedMarker: the override
    executor is terminated while the client stays open, the first
    submission fails at dispatch with DaemonTransportException
    ("saturated"), and a different identity then also fails at dispatch
    instead of being vetoed locally. Probe: deleting the release in the
    DaemonTransportException catch turns the test red with the local
    veto. (Same JDK 17+ assumption as the sibling rejection tests: JDK 11
    parks such sends.)
  • R2-12 (rc:4179236142, 409 collapses status/body) — Fixed.
    PromptAlreadyActiveException now carries the HTTP status and the
    parsed code member of the refusal body (validated against the
    refusal-code vocabulary, best-effort), following the
    HarnessSessionRefusedException pattern; the no-status constructor is
    kept for the local veto. aRejectedAdmissionDoesNotWedgeTheSession
    now asserts the surfaced status and hosted_turn_active code, and a
    new hosted_session_closing arm pins a non-conflict code. Probe:
    dropping the carried code turns both red (expected:<hosted_...> but was:<null>). The marker release stays unconditional across all 409
    reasons.
  • R2-13 (rc:4179236246, status read clearing an in-flight
    submission's marker)
    — Fixed. ActivePrompt gains a volatile
    admissionSettled flag that submitTurn flips when its send attempt
    concludes (answer received, or in-flight failure), and getStatus
    skips the removal when the pre-read snapshot has not settled. The flag
    is sampled with the snapshot so a send concluding during the status
    round trip cannot reopen the race, and outcome-unknown markers whose
    calls already concluded stay status-clearable (the documented recovery
    path). No equals/hashCode added — two-arg remove stays an
    identity CAS. aStatusReadRacingAnInFlightSubmissionKeepsItsMarker
    parks the prompt POST, serves hasActivePrompt:false, releases a 202,
    and asserts the different identity is vetoed locally with the route
    hit exactly once. Probe: dropping the settled gate turns the test red
    (second submission reaches the wire, no veto thrown).

The four D3-* items listed under the round-3 convergence posture were
explicitly deferred by the reviewer ("recorded, not requested in this
round") and were not touched. No feedback was declined, deferred, or
escalated this round.

Merge conflict notes

--conflict true: merged origin/main (9915c7f). Only
HarnessEventStream.java conflicted; the resolution keeps the PR's
watchdog/atomics structure but swaps the cursorLock monitor for a
ReentrantLock, preserving main's JDK 21 virtual-thread pinning fix.
hosted-harness-session.ts auto-merged (the PR's keepalive block is
intact); main's DaemonSessionClient side did not touch the PR's
session_snapshot hunk, which is preserved.

Verification

  • mvn -o test (packages/sdk-java/qwencode, JDK 21) — 204 tests,
    0 failures, 0 errors (includes the 6 new tests and main's
    HarnessEventStreamPinningTest)
  • mvn -o checkstyle:check (packages/sdk-java/qwencode) — passed
  • npm run build (repo root) — passed
  • npm run typecheck — passed
  • npm run lint — passed (after removing the gitignored
    packages/sdk-java/qwencode/target/ JaCoCo output my local Maven
    runs generated, which eslint was scanning)
  • npx vitest run src/serve/hosted-harness-session.test.ts src/serve/hosted-harness-session.issue-13328.test.ts
    (packages/cli) — 189 passed
  • Mutation probes (each: mutant applied, focused test red, mutant
    reverted, suite green) — R3-2 release deletion, R3-3 entry-stamp
    deletion, R2-9 isZero guard deletion, R2-10 wrap removal and
    unregister removal (two probes), R2-11 dispatch-release deletion,
    R2-12 dropped code, R2-13 settled-gate removal — all 8 confirmed the
    new tests kill their mutant
中文说明

第 4 轮 —— 评审发现处理完毕

第 3 轮的 9 条行内发现全部在代码中解决,每条都用变异探针验证(打上变异体、确认对应测试变红、还原变异体、套件恢复全绿)。同时按 --conflict true 合并了 origin/main(冲突解决:本 PR 重写的 HarnessEventStream 改用 ReentrantLock 替代监视器锁,承接 main 在 #13388 中修复的 JDK 21 虚拟线程载体钉住问题,使 main 新增的 HarnessEventStreamPinningTest 在 JDK 21 上保持通过)。

发现逐条处置

  • R3-1(rc:4179235828,README.md:162)——已修复。文档中的 45 秒空闲上限低估了实际生效窗口。README.md、docs/design/2026-09-21-hosted-harness-private-protocol.md 及其中文版现在写明:看门狗每半个预算检查一次,空闲中止发生在预算的 1 倍到 1.5 倍之间(默认 45–67.5 秒),任何外层监督时限都应高于该上限。仅改文档;共享的半预算轮询机制未动。
  • R2-17(rc:4179235831,HostedHarnessClient.java 的 sseIdleTimeout javadoc)——已修复。"不会失去健康的流" 一句过度承诺:hosted 事件路由在背压(写缓冲满、无 drain 监听)时会结束 SSE 响应,客户端只能观察到与正常结束无法区分的 clean EOF。javadoc 现在写明:看门狗不计算两次 next() 之间的时间,但对端没有同样的耐心,暂停的消费者必须自行限制暂停时长,并在流提前结束时用 getLastEventId()/getEventEpoch() 重开。
  • R3-2(rc:4179235834,带 fence 的确定性非 409 释放臂)——已修复,新增 aFencedDefinitiveRefusalReleasesTheOwnedEntry:首次尝试应答带 fence 的 400(经 sendSessionJson 携带 boot id),随后不同身份获得 202。对建议用法的调整说明:建议的 503→400 重试形态无法钉住释放臂——在 ownsActivePrompt 守卫下重试是非属主,而发现自身已证伪该臂为身份 CAS 无操作。发现要求的钉("删除释放逻辑后,不同身份被本地否决而非到达线上")要求拒绝发生在属主尝试上,测试正是这样做的。探针:删除确定性非 409 臂的释放逻辑后,测试因本地否决(already has a running turn)变红。
  • R3-3(rc:4179235835,aConsumerStallBetweenReadsKeepsAHealthyStream)——已修复。测试现在在 1200 ms 停顿前停止 keepalive 循环(第二个门闩),使消费者重新进入时 socket 为空;handler 在写入事件 2 前等待 250 ms——严格介于 200 ms tick 与 400 ms 预算之间。探针:删除 HarnessEventStream.next() 的 lastActivity 进入打戳后,测试以 DaemonTransportException: Hosted Harness SSE idle timeout 变红。改写后仍钉住 consumerWaiting 门(删掉它会在停顿期间中止流)。
  • R2-9(rc:4179235837,Duration.ZERO 关闭选项)——已修复,新增 aZeroIdleTimeoutDisablesTheWatchdog:消费者停在 next() 中、对端静默 500 ms(数倍于原本应有的 tick)后仍能收到随后写入的事件。探针:删除 isZero() 早返回(变成 1 ms 预算、100 ms 轮询)后,测试因空闲超时变红。
  • R2-10(rc:4179235942,startIdleWatchdog 拒绝)——两半都已修复:调度调用被包装,并发的 client.close() 导致的拒绝映射为 DaemonTransportException(与 send() 的映射一致),同时注销刚注册的流使其不被滞留。aWatchdogSchedulingFailureUnregistersTheStream 先正常武装流,再关闭调度器、再次武装,断言映射后的异常与空的注册集合。探针:只删注销逻辑时报 expected:<0> but was:<1>;删包装时裸 RejectedExecutionException 逃逸。idleWatchdog 的直接赋值顺序未变,自取消的首个 tick 仍能读到该 future。
  • R2-11(rc:4179236034,executor 终止释放臂)——已修复,新增 aTerminatedHttpExecutorReleasesTheOwnedMarker:在客户端保持打开时终止覆写 executor,首次提交在派发阶段以 DaemonTransportException("saturated")失败,随后不同身份同样在派发阶段失败而不是被本地否决。探针:删除 DaemonTransportException catch 中的释放逻辑后,测试因本地否决变红。(与同组拒绝测试相同的 JDK 17+ 假设:JDK 11 会停住此类发送。)
  • R2-12(rc:4179236142,409 折叠丢失状态码与响应体)——已修复。PromptAlreadyActiveException 现在携带 HTTP 状态码与拒绝体中解析出的 code 成员(按拒绝码词表校验、尽力而为),沿用 HarnessSessionRefusedException 的模式;本地否决保留无状态码构造器。aRejectedAdmissionDoesNotWedgeTheSession 现在断言浮出的状态码与 hosted_turn_active 码,并新增 hosted_session_closing 臂钉住非冲突码。探针:丢掉携带的 code 后两个测试都变红(expected:<hosted_...> but was:<null>)。所有 409 原因下的标记释放保持无条件。
  • R2-13(rc:4179236246,状态读清除在途提交的标记)——已修复。ActivePrompt 新增 volatile admissionSettled 标志,submitTurn 在其发送尝试结束时(收到应答或途中失败)置位;getStatus 在读前快照未 settle 时跳过删除。标志随快照一起采样,因此在状态往返期间结束的发送无法重新打开该竞态;调用已结束的结果未知标记仍可被状态读清除(文档记载的恢复路径)。未添加 equals/hashCode——两参 remove 仍是身份 CAS。aStatusReadRacingAnInFlightSubmissionKeepsItsMarker 将 prompt POST 停住、从另一线程应答 hasActivePrompt:false、再以 202 放行,断言不同身份被本地否决且路由只被命中一次。探针:删除 settle 门后测试变红(第二个提交到达线上,没有否决抛出)。

第 3 轮收敛姿态下列出的 4 条 D3-* 项由评审方明确延后("已记录,本轮不要求修改"),本轮未触碰。本轮没有被拒绝、延后或升级的反馈。

合并冲突说明

按 --conflict true 合并了 origin/main(9915c7ff8f)。仅 HarnessEventStream.java 冲突;解决保留了本 PR 的看门狗/原子结构,但把 cursorLock 监视器换成 ReentrantLock,保住 main 的 JDK 21 虚拟线程钉住修复。hosted-harness-session.ts 自动合并(本 PR 的 keepalive 块完好);main 侧的 DaemonSessionClient 未触碰本 PR 的 session_snapshot 块,该块保持原样。

验证

  • mvn -o test(packages/sdk-java/qwencode,JDK 21)——204 个测试,0 失败,0 错误(含 6 个新测试与 main 的 HarnessEventStreamPinningTest)
  • mvn -o checkstyle:check(packages/sdk-java/qwencode)——通过
  • npm run build(仓库根)——通过
  • npm run typecheck——通过
  • npm run lint——通过(先删除了本地 Maven 运行生成的、已被 gitignore 的 packages/sdk-java/qwencode/target/ JaCoCo 输出——eslint 会扫描到它)
  • npx vitest run src/serve/hosted-harness-session.test.ts src/serve/hosted-harness-session.issue-13328.test.ts(packages/cli)——189 个通过
  • 变异探针(每个:打变异体、对应测试变红、还原、套件转绿)——R3-2 释放删除、R3-3 进入打戳删除、R2-9 isZero 守卫删除、R2-10 包装删除与注销删除(两个探针)、R2-11 派发释放删除、R2-12 丢弃 code、R2-13 settle 门删除——全部 8 个探针确认新测试能杀死对应变异体

Base-conflict check · 基分支冲突检查: conflicted with main — resolved in this push. · 与 main 有冲突——已在本次推送中解决。

🧵 Resolved all 9 selected review thread(s). · 已关闭全部选中的 9 条评审线程。

Re-review when you have a moment. After round 100 this bot stops and leaves the PR for a human. · 有空请复审;第 100 轮后本 bot 停止并将 PR 交给人工。


🧠 Handled by Qwen Code · model/模型 kimi-k3 · CLI 0.24.7

…s client (#13314)

- Retain the active-prompt marker when a fenced 409 carries
  hosted_prompt_recovery_required: that code proves the promptId is in
  the durable input log, so releasing the marker would admit a second
  identity into a session with two unsettled inputs and fail every
  recovery entrance closed; every other 409 code still releases it
- Clear the hosted events keepalive from stop() as well as from the
  close handler, and send X-Accel-Buffering: no so a buffering
  intermediary cannot swallow the keepalives the client watchdog relies
  on
- Pin the settled status-read clearing, the failed-close unregister, and
  the disabled watchdog's empty scheduler queue with positive witnesses,
  and extract the shared fenced-SSE response prelude in the client tests
- Correct the documented idle-abort window with the 100 ms poll floor,
  state the digest's sha256: wire encoding in the README, and narrow the
  PromptAlreadyActiveException javadoc to what the code does
@qwen-code-dev-bot

Copy link
Copy Markdown
Collaborator

🤖 Addressed the latest review feedback (round 3/100). What changed, and what I pushed back on: · 已处理最新评审反馈(第 3/100 轮)。改动内容与我反驳保留之处如下:

Address-review round — PR #13314 (round 5)

Growth audit (required this window)

Verdict: sound (growth-audit.json, both axes pass). KISS: I assumed the PR is over-engineered and tried to prove it — the candidate simpler shapes (a socket read timeout instead of the consumer-parked watchdog; one shared outcome-unknown exception; dropping admissionSettled) each break a documented contract or a pinned failure mode, and every accumulated guard is witness-pinned to a specific finding. Minimal change: every changed file traces to the PR's problem (#12654 hosted-harness recovery criticals), an accepted round 1–4 finding, or the contract documentation those findings demanded; no untraceable hunks. The window's growth came from per-finding guards across four rounds, not from a wandering approach; this round's own additions are deliberately minimal or subtractive (R4-2 removes ~60 duplicated test lines).

Findings addressed (10 of 10; none declined, deferred, or escalated)

  • R4-1 [Critical] rc:4180612866 — fenced 409 releases the marker even for hosted_prompt_recovery_required. Reproduced by reading the route's gate order (hosted-harness-session.ts:2057–2078): the same-identity replay branch returns 202 before hosted_turn_active, and hosted_prompt_recovery_required is answered from hasAcceptedInput, so it proves the promptId sits in the durable input log and the daemon still owes it a terminal. Fixed by narrowing the release by refusal code: the marker this call owns is released for every 409 code except hosted_prompt_recovery_required, whose entry stays until a terminal event or status read clears it. Witness: new aRecoveryRequiredRefusalKeepsTheOwnedMarker — a first-attempt fenced 409 with that code, then a different promptId is vetoed locally and promptCalls stays 1. Red pre-round by construction: the old arm released on any 409, so the second submission reaches the wire (promptCalls becomes 2) and throws a refusal whose message differs from the local veto's. The existing hosted_turn_active case (aRejectedAdmissionDoesNotWedgeTheSession) is unaffected and keeps pinning the release side.
  • R3-1 [Suggestion] rc:4180612871 — the "1.5x" idle-abort band is falsified below a 200 ms budget by the 100 ms poll floor. Doc-side fix per the finding's own constraint (the half-budget poll is shared with DaemonSessionClient): README and both design-doc twins now read "checked every half-budget but no more often than every 100 ms, so an idle abort lands between the budget and the budget plus max(100 ms, half the budget)".
  • R4-2 [Suggestion] rc:4180612874 — seven verbatim copies of the fenced-SSE prelude. Extracted sendSseHeaders(exchange) (headers + sendResponseHeaders(200, 0), exchange left open) and replaced all 7 sites; the 5 sites that flush keep their explicit flush. Deviation from the suggested signature: no boolean fenced parameter — all 7 sites set the boot-id header, so the flag would be a dead switch; sendSse stays untouched because it closes the exchange after a fixed-length body.
  • R4-3 [Suggestion] rc:4180612876 — missing X-Accel-Buffering: no. Added to the header block before flushHeaders(), mirroring routes/sse-events.ts:563; no compression introduced (the client's validateSseHeaders still sees identity). Witnessed by the new route test's x-accel-buffering header assertion.
  • R4-4 [Suggestion] rc:4180612880 — keepalive interval survives stop(). Fixed so stop() clears both timers. Deviation in shape, not substance: the finding allowed either a hoisted let slot or keeping every invocation after the synchronous route body; the hoisted let tripped prefer-const (single unconditional assignment), so stop is now declared after both timers are armed and clears them unconditionally — the route body is synchronous, so registration still precedes any path that can fire. Witness: new clears the keepalive timer when backpressure stops the stream, which drives the pump's stop() via a mocked full write buffer with res.end() stubbed open (so no close event fires — the finding's exact leak shape) and asserts the 15-second interval's handle was cleared.
  • R4-5 [Suggestion] rc:4180612882 — the moved unregisterStream in close()'s finally was pinned by nothing. Added aFailedStreamCloseStillUnregistersTheStream: a stream whose input.close() throws IOException still leaves registeredStreamCount() == 0. Only the finally unregister can satisfy it (the rejection-path unregister never runs). Required one new package-private seam, registerStream, which streamEvents now uses too — it mirrors the existing unregisterStream/registeredStreamCount test seams.
  • R4-6 [Suggestion] rc:4180612884 — digest contract stated without its wire encoding. The README sentence now reads "sent on the wire as sha256:<64 lowercase hex>", matching both regexes (HostedHarnessClient.java:46-47, hosted-harness-session.ts:112) and the design doc's existing phrasing.
  • R4-7 [Suggestion] rc:4180612889 — status-read clearing had only must-NOT-clear witnesses. Added the positive control aSettledStatusReadClearsTheRegisteredMarker: settled P1 (202, call fully returned so the snapshot is the map's own ActivePrompt instance), /status answers hasActivePrompt:false, getStatus, then a different promptId is admitted (promptCalls == 2). Deleting the remove(key, observed) turns it red (P2 is vetoed); the two must-not-clear tests stay green.
  • R4-8 [Suggestion] rc:4180612891 — the Duration.ZERO disable was pinned only by a 500 ms sleep. aZeroIdleTimeoutDisablesTheWatchdog now asserts client.scheduler().getQueue().size() == 0 right after streamEvents (client open, before any shutdownNow); the sibling aKeepaliveOnlyPeerStaysUsablePastTheIdleBudget asserts the same read is > 0 as the positive control, so the pair cannot both be satisfied by a dead watchdog. Both clients build with heartbeatInterval(Duration.ZERO), so nothing else occupies the pool.
  • R4-9 [Suggestion] rc:4180612894 — class javadoc claimed three things the code doesn't do. Rewritten: the type is thrown for the Hosted Harness's definitive HTTP 409 refusal (vocabulary wider than a turn conflict); getCode() is documented as nullable; the only no-status producer is named as DaemonSessionClient's local veto, with HostedHarnessClient's own veto correctly attributed to a bare DaemonException.

Review body rv:5409882937 (CHANGES_REQUESTED, "partially reviewed — gaps disclosed"): the disclosed gaps (integration suite skipped in CI, reverse audit stopped by budget) are not code findings; its deferred list is explicitly "recorded, not requested in this round". Nothing actionable remained beyond the inline items above. The review's "Test Plan: src/serve/hosted-harness-session.test.ts — no such file or directory" note was a scratch-tree artifact — the file exists and runs green below.

Verification

  • npm run build — passed (with COREPACK_HOME=/tmp/corepack-home; the runner's default corepack cache path is EACCES in this sandbox).
  • npm run typecheck — passed.
  • npm run lint — passed (a first pass caught prefer-const on the initially hoisted let keepaliveTimer; fixed by the declaration-order restructure described in R4-4).
  • cd packages/cli && npx vitest run src/serve/hosted-harness-session.test.ts — 189 passed, including the new keepalive witness (confirmed in junit.xml).
  • cd packages/cli && npx vitest run src/serve/hosted-harness-session.issue-13328.test.ts — 1 passed.
  • Same two files re-run against the committed tree — 190 passed.
  • Mutation probes (executed, TS side): with clearInterval(keepaliveTimer) removed from stop() the new witness FAILS; with the X-Accel-Buffering header removed it FAILS; with both restored it passes. The R4-1 Java witness is red pre-round by construction (see above); the deterministic gate's pre-round re-run covers it mechanically.
  • Not run: the Java suite (mvn test for packages/sdk-java/qwencode). This runner has no JDK or Maven (java, javac, mvn, gradle all absent, /usr/lib/jvm missing), so Java compilation, tests, and the Java mutation probes could not be executed locally; the new Java code was reviewed line-by-line against Java 11 syntax, the module's checkstyle rules (import order, indentation, @Override, braces), and the existing fixtures it reuses. The sdk-java CI job remains the verification gate for those files.
  • Integration tests (npm run test:integration:*) not run: the touched behavior is exercised directly by the route-level vitest suite above, not only through the bundled CLI.
  • npm run generate:settings-schema not applicable — no settings source changed; the build regenerated the schema byte-identically (absent from git status).
  • One transient observed once in three runs of the new witness: an ENOTEMPTY from the suite's temp-dir teardown (rm of the test root racing session cleanup), not from an assertion; the same teardown shape exists in the pre-existing backpressure test. Green on rerun and in both full-suite runs.
中文说明

审查处理轮次 —— PR #13314(第 5 轮)

增长审计(本窗口必需)

结论:sound(见 growth-audit.json,两个维度均通过)。KISS 维度:我先假设本 PR 过度设计并尝试证明——候选的更简单形态(用 socket 读超时替代"消费者驻停"看门狗;合并为一个共享的 outcome-unknown 异常;去掉 admissionSettled)每一个都会破坏已写入文档的契约或已被测试钉住的故障模式,且现有每一处守护都有针对具体发现的见证测试。最小改动维度:每个被改文件都可追溯到 PR 原始问题(#12654 hosted-harness 恢复缺陷)、第 1–4 轮已接受的发现、或这些发现要求补写的契约文档;不存在无法追溯的代码块。本窗口的增长来自四轮中按发现逐个添加的守护,而非方法跑偏;本轮自身的新增刻意保持最小或为减量化(R4-2 删除了约 60 行重复测试代码)。

已处理的发现(10 条全部处理;无拒绝、无延后、无升级)

  • R4-1 [Critical] rc:4180612866 —— fenced 409 即使携带 hosted_prompt_recovery_required 也释放标记。 通过阅读路由闸门顺序复现(hosted-harness-session.ts:2057–2078):同身份重放分支在 hosted_turn_active 之前已返回 202,而 hosted_prompt_recovery_required 由 hasAcceptedInput 应答,因此它证明该 promptId 已在持久化 input 日志中、daemon 仍欠其终态事件。修复为按拒绝 code 收窄释放:除 hosted_prompt_recovery_required 外的所有 409 code 都释放本调用持有的标记,而该 code 的条目保留,直到终态事件或 status 读取将其清除。见证:新增 aRecoveryRequiredRefusalKeepsTheOwnedMarker —— 首次提交收到携带该 code 的 fenced 409 后,不同 promptId 仍在本地被否决且 promptCalls 保持为 1。在轮前代码上必然变红:旧分支对任何 409 都释放,第二个提交会到达服务端(promptCalls 变为 2)并抛出消息不同于本地否决的拒绝。现有 hosted_turn_active 用例(aRejectedAdmissionDoesNotWedgeTheSession)不受影响,继续钉住释放一侧。
  • R3-1 [Suggestion] rc:4180612871 —— "1.5 倍"空闲中止区间在预算低于 200 ms 时被 100 ms 轮询下限证伪。 按发现自身的约束在文档侧修复(半预算轮询与 DaemonSessionClient 共享):README 与两份设计文档副本现写明"每半个预算检查一次,但频率不高于每 100 ms 一次,因此空闲中止发生在预算与预算加 max(100 ms, 半预算) 之间"。
  • R4-2 [Suggestion] rc:4180612874 —— fenced-SSE 前导在七处逐字重复。 抽出 sendSseHeaders(exchange)(设置响应头 + sendResponseHeaders(200, 0),exchange 保持打开),替换全部 7 处;其中 5 处的显式 flush 保留。对建议签名的偏离:不加 boolean fenced 参数——7 处全都设置 boot-id 头,该参数会成为死开关;sendSse 保持不动,因为它在定长 body 后关闭 exchange。
  • R4-3 [Suggestion] rc:4180612876 —— 缺少 X-Accel-Buffering: no。 已加入 flushHeaders() 之前的响应头块,对齐 routes/sse-events.ts:563;未引入压缩(客户端 validateSseHeaders 仍看到 identity)。由新路由测试的 x-accel-buffering 响应头断言见证。
  • R4-4 [Suggestion] rc:4180612880 —— keepalive 定时器在 stop() 后仍存活。 修复为 stop() 同时清除两个定时器。形态上有偏离、实质一致:发现允许"提前声明 let 槽位"或"保证所有调用都发生在同步路由体之后";提前声明的 let 触发了 prefer-const(单次无条件赋值),因此 stop 现在声明于两个定时器武装之后并无条件清除它们——路由体是同步的,注册仍先于任何可能触发的路径。见证:新增 clears the keepalive timer when backpressure stops the stream,用 mock 的满写缓冲驱动 pump 的 stop() 路径,并将 res.end() 桩为保持打开(因此不触发 close 事件——即发现所述的泄漏形态),断言 15 秒定时器句柄已被清除。
  • R4-5 [Suggestion] rc:4180612882 —— 移入 close() 的 finally 的 unregisterStream 此前无任何测试钉住。 新增 aFailedStreamCloseStillUnregistersTheStream:input.close() 抛 IOException 的流在关闭后仍使 registeredStreamCount() == 0。只有 finally 中的 unregister 能满足它(拒绝路径的 unregister 不会执行)。为此新增了一个包级私有接缝 registerStream,streamEvents 也改走它——与既有 unregisterStream/registeredStreamCount 测试接缝对称。
  • R4-6 [Suggestion] rc:4180612884 —— digest 契约缺少线上编码形式。 README 该句现写明"在线上以 sha256:<64 位小写十六进制> 发送",与两个正则(HostedHarnessClient.java:46-47、hosted-harness-session.ts:112)及设计文档的既有措辞一致。
  • R4-7 [Suggestion] rc:4180612889 —— status 读取清除此前只有"不得清除"一侧的见证。 新增正向对照 aSettledStatusReadClearsTheRegisteredMarker:P1 已结算(202 且调用完全返回,使快照正是 map 持有的那个 ActivePrompt 实例),/status 应答 hasActivePrompt:false,调用 getStatus 后不同 promptId 被 admit(promptCalls == 2)。删除 remove(key, observed) 会使其变红(P2 被否决);两个"不得清除"测试保持绿色。
  • R4-8 [Suggestion] rc:4180612891 —— Duration.ZERO 禁用此前仅由一次 500 ms sleep 钉住。 aZeroIdleTimeoutDisablesTheWatchdog 现在在 streamEvents 之后立即断言 client.scheduler().getQueue().size() == 0(客户端仍开放、在任何 shutdownNow 之前);同族 aKeepaliveOnlyPeerStaysUsablePastTheIdleBudget 断言同一读取 > 0 作为正向对照,使两者不可能同时被一个已死的看门狗满足。两个客户端都以 heartbeatInterval(Duration.ZERO) 构建,因此线程池中没有其他任务。
  • R4-9 [Suggestion] rc:4180612894 —— 类 javadoc 有三处与代码不符。 已重写:该类型对应 Hosted Harness 的 HTTP 409 确定性拒绝(词表比 turn 冲突更宽);getCode() 明确标注可为 null;唯一不带状态码的抛出方正确命名为 DaemonSessionClient 的本地否决,并正确指出 HostedHarnessClient 的本地否决抛出的是裸 DaemonException。

评审正文 rv:5409882937(CHANGES_REQUESTED,"部分审查——缺口已披露"):所披露的缺口(CI 跳过了集成套件、反向审计因预算中止)并非代码发现;其延后列表明确"已记录,本轮不要求处理"。除上述行内条目外无可处理项。评审的"Test Plan:src/serve/hosted-harness-session.test.ts — no such file or directory"注记是 scratch-tree 产物——该文件存在且下方运行全绿。

验证

  • npm run build —— 通过(使用 COREPACK_HOME=/tmp/corepack-home;runner 默认的 corepack 缓存路径在本沙箱中为 EACCES)。
  • npm run typecheck —— 通过。
  • npm run lint —— 通过(第一轮曾捕获最初提升的 let keepaliveTimer 违反 prefer-const,已通过 R4-4 所述的声明顺序重构修复)。
  • cd packages/cli && npx vitest run src/serve/hosted-harness-session.test.ts —— 189 通过,包含新的 keepalive 见证(已在 junit.xml 中确认)。
  • cd packages/cli && npx vitest run src/serve/hosted-harness-session.issue-13328.test.ts —— 1 通过。
  • 上述两个文件在提交后的树上重跑 —— 190 通过。
  • 变异探针(已执行,TS 侧):从 stop() 移除 clearInterval(keepaliveTimer) 后新见证失败;移除 X-Accel-Buffering 响应头后失败;两者恢复后转绿。R4-1 的 Java 见证按构造在轮前代码上变红(见上);确定性闸门的轮前重跑会机械覆盖它。
  • 未运行:Java 套件(packages/sdk-java/qwencode 的 mvn test)。本 runner 没有 JDK 或 Maven(java、javac、mvn、gradle 均不存在,/usr/lib/jvm 缺失),因此 Java 编译、测试与 Java 侧变异探针无法在本地执行;新增 Java 代码已按 Java 11 语法、模块 checkstyle 规则(import 顺序、缩进、@Override、大括号)及其复用的既有 fixture 逐行审查。这些文件的验证闸门由 sdk-java CI 作业承担。
  • 集成测试(npm run test:integration:*)未运行:所触行为已由上述路由级 vitest 套件直接演练,而非仅经打包 CLI 可见。
  • npm run generate:settings-schema 不适用——未改动任何 settings 源;构建重新生成的 schema 逐字节一致(git status 中无此项)。
  • 在新见证的三次运行中观察到一次瞬时故障:套件临时目录拆除阶段的 ENOTEMPTY(对测试根目录的 rm 与 session 清理竞争),并非断言失败;既有的 backpressure 测试具有相同的拆除形态。重跑及两次完整套件运行均全绿。

Deferred non-Critical feedback

Critical-only mode is active: the PR's diff grew src 665 / test 0 net lines beyond this counting window's baseline (budgets: 400/400). The workflow excluded the non-Critical feedback below from this round's actionable sections; the items remain open for human follow-up. Maintainer feedback continues to flow unaffected during a growth-only engagement (the per-author batch budget applies only after 5 change-producing rounds). (@qwen-code /retry starts a fresh counting window.)

中文说明

已进入仅处理 Critical 的模式:本计数窗口内 diff 净增长已达 源码 665 / 测试 0 行(预算 400/400)。本轮可执行区域已排除下方非 Critical 反馈;这些条目保持开放,留待人工跟进。纯增长触发期间维护者反馈照常流动(按作者的批次预算仅在完成 5 个产生改动的轮次后生效)。(评论 @qwen-code /retry 可开启新的计数窗口。)

Base-conflict check · 基分支冲突检查: no conflict with main. · 与 main 无冲突。

🧵 Resolved all 10 selected review thread(s). · 已关闭全部选中的 10 条评审线程。

Re-review when you have a moment. After round 100 this bot stops and leaves the PR for a human. · 有空请复审;第 100 轮后本 bot 停止并将 PR 交给人工。


🧠 Handled by Qwen Code · model/模型 kimi-k3 · CLI 0.24.7

@qwen-code-dev-bot

Copy link
Copy Markdown
Collaborator

🔀 Base updated: red check(s) [ubuntu-latest / Java 11, ubuntu-latest / Java 17, ubuntu-latest / Java 21, macos-latest / Java 21, windows-latest / Java 21] pass on current main — merged current main via update-branch; CI will re-run.

中文说明

🔀 已更新 base:红色检查 [ubuntu-latest / Java 11, ubuntu-latest / Java 17, ubuntu-latest / Java 21, macos-latest / Java 21, windows-latest / Java 21] 在当前 main 上通过 —— 已通过 update-branch 合入当前 main,CI 将重新运行。

@qwen-code-dev-bot

Copy link
Copy Markdown
Collaborator

🔀 Base updated: red check(s) [ubuntu-latest / Java 11, ubuntu-latest / Java 17, ubuntu-latest / Java 21, macos-latest / Java 21, windows-latest / Java 21] pass on current main — merged current main via update-branch; CI will re-run.

中文说明

🔀 已更新 base:红色检查 [ubuntu-latest / Java 11, ubuntu-latest / Java 17, ubuntu-latest / Java 21, macos-latest / Java 21, windows-latest / Java 21] 在当前 main 上通过 —— 已通过 update-branch 合入当前 main,CI 将重新运行。

@qwen-code-dev-bot

Copy link
Copy Markdown
Collaborator

⏸️ AutoFix paused by a review convergence signal: 3 consecutive automated review round(s) signalled machine-readable non-convergence (codes observed since the last maintainer response, or the window start if none: batch-fixes, root-cause-triage) — the reviewer keeps finding new defects at a rate that is not falling while the loop keeps widening the diff, so another automatic round is unlikely to converge this PR. The loop resumes once a maintainer responds on this PR (a review or comment counts, and steers the next rounds), and pauses again if the signal persists for 3 more round(s). Alternatives: split the recurring cluster into its own PR, batch the remaining fixes into one push, comment @qwen-code /retry to re-arm a fresh window, or @qwen-code /takeover stop to release takeover. While paused, new feedback and base conflicts stay unhandled.

中文说明

⏸️ AutoFix 已因评审收敛信号暂停:3 轮自动评审连续发出机器可读的不收敛信号(自上次维护者响应以来观察到的信号码;若无响应则自窗口开始:batch-fixes, root-cause-triage)——评审仍在以不降的速率发现新缺陷,而循环在继续扩大 diff,再跑一轮自动修复难以收敛本 PR。维护者在本 PR 上作出回应后循环自动恢复(评论或评审均可,并将作为后续轮次的指引);若信号再持续 3 轮会再次暂停。可选做法:把反复出问题的簇拆成独立 PR、把剩余修复攒成一批一次推送、评论 @qwen-code /retry 重开计数窗口、或评论 @qwen-code /takeover stop 释放接管。暂停期间,新反馈与 base 冲突不会被处理。

@qwen-code-review-bot

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

Copy link
Copy Markdown
Collaborator

🩺 serve daemon A/B

Built the PR base vs this PR head 7c1fb57, drove a fixed endpoint set against each, and diffed the JSON responses. Only fields that changed are shown.

health-deep-with-session

field PR base (before) this PR (after)
activeWorkStaleMs 9 6

— Qwen Code · serve A/B

Close the corridor the next-round review's close/detach receipts queued:
local attachments (and their heartbeat timers) must not survive a
definitive refusal, and must NOT be torn down on outcome-unknown.

- detachSession: the unconditional `finally { removeAttachment }` also
  ran when requireMutationStatus surfaced unexpected-success as
  MutationOutcomeUnknownException — a state where the server's answer is
  not decided and the lease must keep beating. Teardown now runs on the
  definitive limb (204 or tolerated 404) and inside the
  DaemonHttpException arm only; outcome-unknown surfaces keep the
  attachment (anUnexpectedDetachAnswerKeepsTheAttachment).
- closeSession(HarnessSessionRef) and closeSession(String): mirror the
  same try/catch — a definitive DELETE refusal (e.g. 403) now also retires
  the attachment and the active-prompt ledger instead of leaking the
  timer until close(), while ambiguous answers keep them
  (aRefusedCloseStillTearsDownTheHeartbeat ×2 overloads,
  anUnexpectedCloseAnswerKeepsTheAttachment,
  aBootHeaderlessCloseKeepsTheAttachment for the gateway-502 shape).
- closeSession(String) gains the ensureOpen() guard every other public
  entry has (a deferral receipt plus #13313's R1-50): the closed-client
  path is JVM-independent again, so aLocalExecutorRejectionIsNotReported
  AsOutcomeUnknown becomes closeSessionByIdFailsFastAfterClientClose —
  IllegalStateException on every JDK — and the saturated/terminated
  taxonomy stays pinned by aTerminatedHttpExecutorReleasesTheOwnedMarker.
- closeByRefTreatsAnAbsentHarnessSessionAsClosed now also counts the
  DELETE request (dropping the remote call reddens assertEquals(1)).
- Housekeeping of the takeover branch: aRecoveryRequiredRefusalKeepsThe
  OwnedMarker's stub never incremented its promptCalls counter, so its
  trailing assertion could never pass once it ran (CI never reached it
  through the verify-checkout race) — fixed by counting in the handler.

Witnesses: full module 214/214 green on JDK 17 (clean test green on JDK
11, 13 skips = 9 env + 4 version-gated); corridor mutation arms all red —
detach with an unconditional finally flattens the keep-beating assertion,
removing either close-mirror makes refused-close heartbeats keep growing
(9→14, 10→16), and removing ensureOpen flips the fail-fast test from
IllegalStateException back to the transport exception.
@qwen-code-dev-bot

Copy link
Copy Markdown
Collaborator

🔀 Base updated: red check(s) [Test (ubuntu-latest, Node 22.x)] pass on current main — merged current main via update-branch; CI will re-run.

中文说明

🔀 已更新 base:红色检查 [Test (ubuntu-latest, Node 22.x)] 在当前 main 上通过 —— 已通过 update-branch 合入当前 main,CI 将重新运行。

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

Partially reviewed — gaps disclosed.

4 Suggestion-level finding(s) this review confirmed are already reported on this PR and are not repeated:

  • Keepalive emission and its disconnect-clear are unpinned by any test — already reported (open threads R1-11 and R1-12)
  • Keepalive discards res.write's return value — already reported (round-20 deferral, hosted-harness-session.ts:8390)
  • retireStaleLedger's early return leaks the terminal record — already reported (round-18 deferral, HostedHarnessClient.java:1319)
  • detachSession's comment names an exception sendMutation cannot raise — already reported (round-19 deferral)

Unresolved, please confirm:

  • [Critical] R16-1 (HostedHarnessClient.java:1264, thread 4249317558) — the identity-scoping asymmetry between the attachment and the admission ledger on a deletion-proving 204 is present and unchanged at HEAD, but this round could neither demonstrate n…

Not reviewed: build-and-test — Integration Tests (CLI, No Sandbox) was skipped in CI and its suite did not run locally.

Not explored to full depth (tool budget reached): "agent 1c": I did not read the ~6,200 added lines of HostedHarnessClientTest.java (diff lines 3,431–9,650) linearly; I sampled the regions that pin the production claims …; "agent reverse-audit (round 2)": none — chunk 5 (diff lines 1168-1522) was walked in full; the JVM-cost lens found nothing to file (no per-call Pattern.compile , no String += in a loop, no b…; "agent reverse-audit (round 1)": verifying against JDK sources that HttpClient.sendAsync performs exactly one synchronous executor submission before any dispatch — the claim send() 's "prova….

Not reviewed: reverse audit — stopped before round 5 by the review time budget.

Test Plan (not a blocker): src/serve/hosted-harness-session.test.ts — no such file or directory.

Deferred under the convergence posture (round 21, not a blocker) — recorded, not requested in this round; 4 Critical(s) among them are deferred by their axes — fails-closed on new surface, where no wrong result is certified and the merge base had neither the surface nor the defect — and remain follow-up work recorded in the findings artifact:

  • packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/daemon/HostedHarnessClient.java:427 — [probe] Critical [fails-closed] [new-surface] Unfenced 409 recovery arm blocks the release…
  • packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/daemon/HostedHarnessClient.java:571 — [probe] Critical [fails-closed] [new-surface] A stale releaseBlocked permanently defeats the…
  • packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/daemon/HostedHarnessClient.java:1121 — [probe] Critical [fails-closed] [new-surface] Retirement helpers write the terminal record before the…
  • packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/daemon/HostedHarnessClient.java:1533 — [probe] Critical [fails-closed] [new-surface] Single-slot terminal record cannot answer the any-value…
  • packages/cli/src/serve/hosted-harness-session.ts:8925 — [review] The hosted events route is the only SSE route that does…
  • packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/daemon/DaemonHttpException.java:20 — [probe] Un-finaling DaemonHttpException falsifies its own…
  • packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/daemon/HostedHarnessClient.java:95 — [probe] The getStatus test seam is invoked before both snapshot…
  • packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/daemon/HostedHarnessClient.java:921 — [probe] The comment on streamEvents' close-race guard describes a…
  • packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/daemon/HostedHarnessClient.java:953 — [review] heartbeat()'s generation catch duplicates a retirement the…
  • packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/daemon/HostedHarnessClient.java:1309 — [probe] The promised one-heartbeat-interval cap does not exist for…
  • packages/sdk-java/qwencode/src/test/java/com/alibaba/qwen/code/daemon/HostedHarnessClientTest.java:4569 — [probe] awaitSchedulerDrained's assertion cannot fail at the…
  • packages/sdk-java/qwencode/src/test/java/com/alibaba/qwen/code/daemon/HostedHarnessClientTest.java:6743 — [probe] The 700 ms bound does not pin the watchdog formula its own…
  • packages/sdk-java/qwencode/src/test/java/com/alibaba/qwen/code/daemon/HostedHarnessClientTest.java:7951 — [probe] The 60-round race fixture records nothing about whether…
中文说明

仅完成部分审查,审查缺口已披露。

本轮确认的 4 条建议级发现已在 PR 上报告过,不再重复发布(列表见上方英文部分)。

未决,请确认:共 1 条(原文未翻译,列表见上方英文部分)。

未审查(原文为英文):build-and-test — Integration Tests (CLI, No Sandbox) was skipped in CI and its suite did not run locally.

未探索到全部深度(达到工具调用预算):"agent 1c":I did not read the ~6,200 added lines of HostedHarnessClientTest.java (diff lines 3,431–9,650) linearly; I sampled the regions that pin the production claims …;"agent reverse-audit (round 2)":none — chunk 5 (diff lines 1168-1522) was walked in full; the JVM-cost lens found nothing to file (no per-call Pattern.compile , no String += in a loop, no b…;"agent reverse-audit (round 1)":verifying against JDK sources that HttpClient.sendAsync performs exactly one synchronous executor submission before any dispatch — the claim send() 's "prova…。

未审查:反向审计——评审时间预算不足,未能开始第 5 轮。

Test Plan(非阻断):src/serve/hosted-harness-session.test.ts — no such file or directory。

收敛姿态下延后(第 21 轮,非阻断)——已记录,本轮不要求修改;其中 4 条 Critical 按其失败方向与对照基线延后——fails-closed 且 new-surface:未认证任何错误结果,且 merge base 既无该功能面也无该缺陷——作为后续工作记录在 findings 工件中:共 13 条(原文未翻译,列表见上方英文部分)。

— qwen3.8-max via Qwen Code /review (v0.25.2)

Comment thread packages/sdk-java/qwencode/README.md Resolved
…nts (#13314)

The published digest contract claimed object keys are sorted
recursively, but JsonSupport.ownKeyOrder and the route's
sha256(JSON.stringify(prompt)) re-derivation use ECMAScript own-key
order: array-index keys ascend numerically first, then the remaining
keys in insertion order. A second-language client built on the
published sentence computes a different digest and is refused with
invalid_hosted_prompt.
@qwen-code-dev-bot

Copy link
Copy Markdown
Collaborator

🤖 Addressed the latest review feedback (round 9/100). What changed, and what I pushed back on: · 已处理最新评审反馈(第 9/100 轮)。改动内容与我反驳保留之处如下:

Autofix round — PR #13314 (address-review)

What changed this round

One commit, cfae71d215 — docs-only. It corrects the digest canonical-form sentence this PR publishes in three places (packages/sdk-java/qwencode/README.md, docs/design/2026-09-21-hosted-harness-private-protocol.md, and its .zh-CN twin). No production or test code changed, so no mutation probe applies to this round's diff (the gate's red-witness rule covers code behavior; this round adds no guard, branch, or behavior). All other actionable findings were verified as already fixed by earlier commits on this branch and re-proven green at HEAD this round.

Feedback dispositions

rc:4288526219 — R21-1 (Critical, certifies-falsely) — fixed

The claim verified: JsonSupport.ownKeyOrder (packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/daemon/JsonSupport.java:97-127) emits ECMAScript own-key order — array-index keys ("0".."4294967294", no leading zero) ascending numerically first, then the remaining keys in insertion order — pinned by JsonSupportTest.encodeOrdersKeysAsJsonStringifyDoes (expects "2" before "10", i.e. not a lexicographic sort), and the route re-derives sha256(JSON.stringify(prompt)) over the parsed member (packages/cli/src/serve/hosted-harness-session.ts:5951), which Node renders the same way. The published "object keys sorted recursively" sentence would lead a second-language implementer to a different digest and a 400 invalid_hosted_prompt refusal. All three occurrences (the three files above) now state the own-key order rule instead: array-index keys ascending numerically first, then the remaining keys in insertion order, applied recursively, array order preserved.

rv:5529265828 — @wenshao re-review of 4e36f27cbe — all three items already fixed at HEAD, re-verified this round

The reviewed head 4e36f27cbe predates 9440fc868b ("retire hosted admission state on journal replays and deleting lifecycle detaches"), which is the commit @wenshao's later comment (ic:6188264335) verified as merge-ready. Each item was re-verified at HEAD (cfae71d215) by running the pinning tests:

  • R10-4 (thread 4242662305, confirmed regression): fixed by 9440fc868b. detachLifecycle(ref)'s deletion-proving 204 arm now runs retireStaleLedger, which retires a marker whose planting identity no longer owns the attachment (covering the abandoned-identity marker) while the two-arg remove preserves a live replacement planted during the round trip. Pinning tests green: aTurnActiveCloseThenLifecycleDetachReleasesTheLedger, aLifecycleDetachRacingAMarkerPlantLeavesNoVeto (ref arm), lifecycleDetachReleasesOnlyTheOriginalPrompt.
  • R15-2 (thread 4244037775, pre-existing on the merge base): fixed at HEAD. The id-only detachLifecycle retires the admission marker by key when no re-load raced the round trip, and the terminal-event record retires with the dead incarnation. Pinning tests green: aLifecycleDetachRacingAMarkerPlantLeavesNoVeto (id arm), aHeaderlessLifecycleDetachRetiresTheTerminalRecord. The narrowed claim is respected: no indiscriminate terminal-record deletion was added — ordinary detach/load keeps relying on the durable journal replay.
  • R17-2 (thread 4275234105, pre-existing on the merge base): fixed at HEAD. The 202 arm checks the terminal record under the bin lock before any republish, and a non-owning replay answered from the journal after the terminal event discharges the owed release instead of replacing the entry with a stranded fresh marker. Pinning tests green: the R17-2 owning and non-owning ordering tests (HostedHarnessClientTest.java:5077, :5157).

rv:5540235935 — @qwen-code-review-bot CHANGES_REQUESTED — R16-1 (thread 4249317558) — already fixed at HEAD, re-verified this round; no further change

The claimed harm — an attachment registered mid-flight under a different client id surviving a deletion-proving 204 so its heartbeat task is never cancelled — does not hold at HEAD:

  • 4884dc8197 added the scheduleHeartbeat definitive-404 hosted_session_not_found self-retirement (HostedHarnessClient.java:2146-2160), which caps a stale attachment's life at one heartbeat interval on both overloads. A probe of the exact R16-1 scenario is pinned and green: aCloseByRefKeepsAMidFlightAttachmentUntilItsHeartbeat404 (concurrent load mints client-2 mid-DELETE, close answers 204, the survivor's next heartbeat meets the 404, the scheduler queue drains, heartbeats stop) and aSessionNotFoundHeartbeatRetiresTheAttachment.
  • The identity-blind discard R16-1 originally proposed was measured harmful by R17-4's probe: it cancels an attachment a concurrent loadSession registered for a re-opened incarnation after the server processed the DELETE — a live attachment whose heartbeats the peer accepts. HEAD implements the R17-4-coordinated durable fix R16-1's own restatement (comment 4263656571) prescribed: the 404 self-retirement plus observed-snapshot retirement on the deletion arms (the by-id overload uses discardObservedAttachment; on the ref overloads identity-matched and observed-snapshot retirement coincide because the server mints a fresh randomUUID() client id per open, hosted-harness-session.ts:4277, so two registrations never share a client id).
  • The residual asymmetry the review notes (ledger retired unconditionally vs attachment identity-matched on the 204 arm) is the deliberate fails-closed/fails-open split: a stale ledger marker can never be cleared for a deleted session and would veto every later identity, while a stale attachment self-heals at the next heartbeat — the same trade-off the by-id overload documents ("capping a stale task at one heartbeat interval").

Re-verified at HEAD this round: both pinning tests pass (HostedHarnessClientTest 180/180 overall).

ic:6188264335 — @wenshao merge-ready verification at 9440fc868b

Informational; no action.

Deferred non-Critical feedback

Untouched per the critical-only posture: that section is an audit record, not work — no code changes, thread resolutions, or replies for those items.

Verification

  • COREPACK_HOME=/tmp/corepack-cache npm run build — passed (exit 0). COREPACK_HOME redirects corepack's cache to a writable path; the runner's ~/.cache is read-only (EACCES otherwise — infrastructure, not code).
  • npm run typecheck — passed (exit 0).
  • COREPACK_HOME=/tmp/corepack-cache npm run lint — passed (exit 0, 0 errors). Note: the first lint run failed only because the Maven test run's generated reports under packages/sdk-java/qwencode/target/site/jacoco/*.js were scanned by ESLint; removing the git-ignored target/ build output restored a clean lint. No source file was implicated.
  • mvn test -Dtest='HostedHarnessClientTest,JsonSupportTest,HarnessEventStreamCloseTest' (Temurin JDK 21.0.12.1, Maven 3.9.16, module packages/sdk-java/qwencode) — 205 tests, 0 failures, 0 errors: HostedHarnessClientTest 180/180 (includes every R10-4/R15-2/R17-2/R16-1 pinning test cited above), JsonSupportTest 20/20 (includes the own-key-order pin), HarnessEventStreamCloseTest 5/5.
  • npx prettier --check on the three edited docs — passed.
  • git diff --check — passed; git status shows only the three intended files.
  • Focused Vitest / integration tests — not applicable: this round changes no TypeScript/JavaScript source (docs and a README only); the CLI-side suites were verified green at this head by the maintainer (599/599) and a docs-only diff cannot affect them.
  • Settings schema — not applicable; no settings source changed.
  • Mutation probes — not applicable: this round's commit adds no guard, branch, or behavior (docs-only). The re-verified behaviors were already mutation-pinned by their dedicated fixtures (e.g. the R16-1 probe goes red if the heartbeat 404 self-retirement is removed).
中文说明

Autofix 轮次总结 —— PR #13314(address-review)

本轮改动

仅一个提交 cfae71d215——只改文档。它修正了本 PR 在三处发布的 digest 规范形式表述(packages/sdk-java/qwencode/README.md、docs/design/2026-09-21-hosted-harness-private-protocol.md 及其 .zh-CN 中文版本)。未改动任何生产或测试代码,因此本轮 diff 不适用变异探针(门禁的红色见证规则针对代码行为;本轮未新增任何守卫、分支或行为)。其余可执行发现经核实均已被本分支上的较早提交修复,并在本轮于 HEAD 重新验证为绿色。

反馈处置

rc:4288526219 —— R21-1(Critical,certifies-falsely)—— 已修复

该发现属实:JsonSupport.ownKeyOrder(packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/daemon/JsonSupport.java:97-127)按 ECMAScript own-key 顺序输出——数组索引键("0" 到 "4294967294",无前导零)先按数值升序排列,其余键随后按插入顺序排列——由 JsonSupportTest.encodeOrdersKeysAsJsonStringifyDoes 固定(期望 "2" 排在 "10" 之前,即并非字典序排序);路由则对解析后的成员按 sha256(JSON.stringify(prompt)) 重算(packages/cli/src/serve/hosted-harness-session.ts:5951),Node 的渲染顺序与之相同。此前发布的「对象键递归排序」会误导其他语言的实现者算出不同的 digest,从而被 400 invalid_hosted_prompt 拒绝。三处(上述三个文件)均已改为描述 own-key 顺序规则:数组索引键先按数值升序,其余键按插入顺序,递归应用,数组顺序保持。

rv:5529265828 —— @wenshao 对 4e36f27cbe 的复审 —— 三项均已在 HEAD 修复,本轮重新验证

被复审的 4e36f27cbe 早于 9440fc868b(「retire hosted admission state on journal replays and deleting lifecycle detaches」),而 @wenshao 随后的评论(ic:6188264335)已在 9440fc868b 上给出 merge-ready 验证。本轮在 HEAD(cfae71d215)上通过运行固定测试逐项重新验证:

  • R10-4(会话 4242662305,已确认回归):由 9440fc868b 修复。detachLifecycle(ref) 的证明删除 204 分支现在走 retireStaleLedger:当标记的种植身份不再持有 attachment 时将其撤销(覆盖被遗弃身份留下的标记),同时两参数 remove 保留了往返期间注册的存活替换标记。固定测试全绿:aTurnActiveCloseThenLifecycleDetachReleasesTheLedger、aLifecycleDetachRacingAMarkerPlantLeavesNoVeto(ref 臂)、lifecycleDetachReleasesOnlyTheOriginalPrompt。
  • R15-2(会话 4244037775,merge base 上同样存在):已在 HEAD 修复。无 client id 的 detachLifecycle 在没有 re-load 竞争往返时按键撤销 admission 标记,terminal 事件记录随已消亡的化身一并撤销。固定测试全绿:aLifecycleDetachRacingAMarkerPlantLeavesNoVeto(id 臂)、aHeaderlessLifecycleDetachRetiresTheTerminalRecord。已遵守收窄后的结论:未新增任何无差别删除 terminal 记录的逻辑——普通 detach/load 仍依赖持久日志重放。
  • R17-2(会话 4275234105,merge base 上同样存在):已在 HEAD 修复。202 分支在任何重发布之前于 bin 锁内检查 terminal 记录;terminal 事件之后从日志应答的非 owning 重放会清偿欠下的释放,而不是用一个无法再清除的新标记替换表项。固定测试全绿:R17-2 的 owning 与 non-owning 时序测试(HostedHarnessClientTest.java:5077、:5157)。

rv:5540235935 —— @qwen-code-review-bot CHANGES_REQUESTED —— R16-1(会话 4249317558)—— 已在 HEAD 修复,本轮重新验证;无需进一步改动

其所称危害——并发 load 以不同 client id 注册的 attachment 在证明删除的 204 之后残留、其心跳任务永不取消——在 HEAD 不成立:

  • 4884dc8197 在 scheduleHeartbeat 中加入了确定性 404 hosted_session_not_found 自我撤销(HostedHarnessClient.java:2146-2160),使陈旧 attachment 的寿命在两个重载上都被封顶为一个心跳间隔。R16-1 精确场景的探针已被固定且为绿色:aCloseByRefKeepsAMidFlightAttachmentUntilItsHeartbeat404(DELETE 在途时并发 load 生成 client-2,close 应答 204,残留者的下一次心跳遇到 404,调度队列排空,心跳停止)与 aSessionNotFoundHeartbeatRetiresTheAttachment。
  • R16-1 最初提出的身份无关撤销被 R17-4 的探针实测为有害:它会取消并发 loadSession 在服务端处理完 DELETE 之后为重新打开的化身注册的 attachment——那是对端仍接受心跳的存活 attachment。HEAD 实现的正是 R16-1 自己的重述(评论 4263656571)所开处方的 R17-4 协调后持久修复:404 自我撤销 + 删除分支上的观测快照撤销(by-id 重载用 discardObservedAttachment;在 ref 重载上,身份匹配与观测快照撤销等价,因为服务端每次 open 都生成新的 randomUUID() client id,见 hosted-harness-session.ts:4277,两次注册绝不会共享 client id)。
  • 评审指出的残余不对称(204 分支上 ledger 无条件撤销、attachment 身份匹配撤销)是刻意的 fails-closed/fails-open 分工:对已删除会话,陈旧 ledger 标记永远无法被清除、会否决之后的每个身份;而陈旧 attachment 会在下一次心跳自愈——这与 by-id 重载文档化的折中一致(「把陈旧任务的寿命封顶为一个心跳间隔」)。

本轮已在 HEAD 重新验证:两个固定测试均通过(HostedHarnessClientTest 整体 180/180)。

ic:6188264335 —— @wenshao 在 9440fc868b 的 merge-ready 验证

信息性评论;无需处理。

延后的非 Critical 反馈

按仅处理 Critical 的姿态未动:该区域是审计记录而非工作项——不为其修改代码、不解决会话、不回复。

验证

  • COREPACK_HOME=/tmp/corepack-cache npm run build —— 通过(退出码 0)。COREPACK_HOME 将 corepack 缓存重定向到可写路径;本 runner 的 ~/.cache 只读(否则 EACCES——属基础设施问题,非代码问题)。
  • npm run typecheck —— 通过(退出码 0)。
  • COREPACK_HOME=/tmp/corepack-cache npm run lint —— 通过(退出码 0,0 错误)。说明:首次 lint 失败仅因为 Maven 测试在 packages/sdk-java/qwencode/target/site/jacoco/*.js 生成的报告被 ESLint 扫描;删除该 git 忽略的 target/ 构建产物后 lint 恢复干净。不涉及任何源文件。
  • mvn test -Dtest='HostedHarnessClientTest,JsonSupportTest,HarnessEventStreamCloseTest'(Temurin JDK 21.0.12.1,Maven 3.9.16,模块 packages/sdk-java/qwencode)—— 205 个测试,0 失败,0 错误:HostedHarnessClientTest 180/180(包含上述全部 R10-4/R15-2/R17-2/R16-1 固定测试),JsonSupportTest 20/20(含 own-key 顺序固定测试),HarnessEventStreamCloseTest 5/5。
  • 对三个被改文档运行 npx prettier --check —— 通过。
  • git diff --check —— 通过;git status 仅显示三个预期文件。
  • 聚焦 Vitest / 集成测试 —— 不适用:本轮未改动任何 TypeScript/JavaScript 源码(仅文档与 README);CLI 侧测试已由维护者在此 head 验证为绿(599/599),纯文档 diff 不可能影响它们。
  • settings schema —— 不适用;未改动任何 settings 源。
  • 变异探针 —— 不适用:本轮提交未新增任何守卫、分支或行为(纯文档)。被重新验证的行为本就由专门的固定测试提供变异证明(例如移除心跳 404 自我撤销后 R16-1 探针即变红)。

Deferred non-Critical feedback

Critical-only mode is active: 5 change-producing rounds are complete. The workflow excluded the non-Critical feedback below from this round's actionable sections; the items remain open for human follow-up. Maintainer feedback is deferred only after its author has used 2 regular feedback batches in this window's Critical-only tail; authors at that budget, if any, are named below. (@qwen-code /retry starts a fresh counting window.)

中文说明

已进入仅处理 Critical 的模式:已完成 5 个产生改动的轮次。本轮可执行区域已排除下方非 Critical 反馈;这些条目保持开放,留待人工跟进。维护者反馈仅在其本人于本窗口 Critical-only 阶段已使用 2 批常规反馈预算后才会延后;达到预算的作者(如有)在下方点名。(评论 @qwen-code /retry 可开启新的计数窗口。)

Base-conflict check · 基分支冲突检查: no conflict with main. · 与 main 无冲突。

🧵 Resolved all 5 selected review thread(s). · 已关闭全部选中的 5 条评审线程。

Re-review when you have a moment. After round 100 this bot stops and leaves the PR for a human. · 有空请复审;第 100 轮后本 bot 停止并将 PR 交给人工。


🧠 Handled by Qwen Code · model/模型 kimi-k3 · CLI 0.25.2

@qwen-code-dev-bot

Copy link
Copy Markdown
Collaborator

🔀 Base updated: red check(s) [Lint & Static (ubuntu-latest, Node 22.x)] pass on current main — merged current main via update-branch; CI will re-run.

中文说明

🔀 已更新 base:红色检查 [Lint & Static (ubuntu-latest, Node 22.x)] 在当前 main 上通过 —— 已通过 update-branch 合入当前 main,CI 将重新运行。

@qwen-code-dev-bot

Copy link
Copy Markdown
Collaborator

🤖 Could not produce a passing fix for this feedback (round 10/100). This item now needs a human; the loop stays engaged and still picks up new feedback and base conflicts, but will not retry this item on its own.

What I found before stopping:
Qwen hit the tool-call loop guard during address-review. A human should take over this feedback batch.

See the Qwen Autofix agent step logs for model/tool output.

中文说明

🤖 未能为该反馈产生可通过验证的修复(第 10/100 轮)。此项现在需要人工处理;循环保持在线,仍会拾取新反馈与 base 冲突,但不会自行重试此项。

Run log: https://github.com/QwenLM/qwen-code/actions/runs/38842981497


🧠 Handled by Qwen Code · model/模型 kimi-k3 · CLI 0.25.2

@qwen-code-dev-bot

Copy link
Copy Markdown
Collaborator

🤖 Could not produce a passing fix for this feedback (round 11/100). This item now needs a human; the loop stays engaged and still picks up new feedback and base conflicts, but will not retry this item on its own.

What I found before stopping:
Qwen hit the tool-call loop guard during address-review. A human should take over this feedback batch.

See the Qwen Autofix agent step logs for model/tool output.

中文说明

🤖 未能为该反馈产生可通过验证的修复(第 11/100 轮)。此项现在需要人工处理;循环保持在线,仍会拾取新反馈与 base 冲突,但不会自行重试此项。

Run log: https://github.com/QwenLM/qwen-code/actions/runs/38845250250


🧠 Handled by Qwen Code · model/模型 kimi-k3 · CLI 0.25.2

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

Re-reviewed updated head 868b26950233367e5c249b170a1a313ac726c76c against the previously reviewed 4e36f27cbe315eb1458e2c5abbedbc2a408457b4. Two new regressions introduced by the latest lifecycle-detach change are documented inline.

The previously reported R10-4, R15-2 snapshot race, and R17-2 now pass independent HTTP/SSE reproductions. The earlier suggestion that retaining a terminal record alone was a defect does not hold: detach/load preserves the durable journal, so an identical completed prompt is still a replay.

Validation on JDK 21.0.11 / Maven 3.9.11:

  • Existing HostedHarnessClientTest + HarnessEventStreamCloseTest: 185 passed, no skips.
  • Independent probes using a byte-for-byte copy of current production Java: the three prior scenarios pass; the two new scenarios fail.
  • The same two new probes against the previously reviewed head: 2 passed, confirming both are update-induced regressions.
  • Server behavior was cross-checked against close/admitPrompt and the existing replays a settled prompt admission from the journal after a reload test. Running that TypeScript test locally was blocked by missing workspace build outputs; no end-to-end server run is claimed.

中文:上次三个已验证问题已修复;本次更新新增两处回归:detach 后重放已完成轮次会阻塞下一轮,以及并发重载时旧 detach 可能清除新轮次的活跃标记。两条均已完成新旧版本对照。

@wenshao wenshao removed the autofix/takeover Summon the autofix loop to manage this PR (remove to release; needs triage+) label Oct 16, 2026
Resolve the submitTurn conflict with #13219's busy-turn status probe:
the probe now runs on top of this branch's bin-locked registration
(registerAdmission), so a vetoing marker is cleared only by an idle
status read taken while no send attempt is open on it. Tests that
assert a local veto after a stale or racing status read now have the
Harness report the admitted prompt running for the veto check, so the
probe reads a live answer instead of healing the marker.
…story (#13314)

A detach or a DELETE closes only the live Hosted session: the durable
journal survives it, and after a re-load the prompt route answers a
settled promptId's same-identity replay with a 202 that owes no terminal
event. Retiring the terminal-event record on teardown therefore left
that replay's marker vetoing every later prompt. No teardown retires the
record any more; the map is bounded instead (least recently used past
4096 sessions), and an evicted session's replay marker is cleared by the
busy-turn status probe.

The headerless lifecycle detach also removed the admission marker
unconditionally after its attachment snapshot, so a re-load that
registered a new attachment and admitted a turn inside that window lost
its marker and a different prompt reached the wire. Every definitive
teardown answer (detach 204 on all three entrances, the headerless
tolerated 404, DELETE 204 on both overloads) now retires through one
bin-locked decision that reads the current attachment under the
marker's lock: a marker the current attachment's identity planted, or
joined with a same-identity retry, stays; an abandoned identity's marker
retires. The identity-scoped tolerated-404 retirement keeps a marker
another identity's retry joined, under the same lock.

Tests: the teardown cases are parameterized over all five entrances;
fixtures whose vetoed submit hit an unrouted /status now answer the
busy-turn probe instead of waiting out the request timeout (the class
drops from ~320 s to ~20 s), and the probe's generation-change and
send-clock behavior are pinned.
@wenshao

wenshao commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator Author

Took over this round. I merged main (eae5f1f) and fixed both review threads from the 868b269 re-review (b4670af).

Merge

main's #13219 added a busy-turn status probe to submitTurn, and it conflicted with this branch's bin-locked admission ledger. The probe now sits on top of the extracted registerAdmission:

  • a vetoed submit opens no send attempt on the entry that vetoes it;
  • the marker is cleared only by an idle getStatus read taken while no send attempt is open on it and with an unchanged send clock;
  • a probe failure surfaces as the plain busy refusal, except a generation change, which propagates.

Seven existing veto tests now have /status report the admitted prompt as running before their veto check. Without that, the probe would heal the very marker they pin. Status-gate mutations still turn the five race tests red.

Fixes

  • P1 (r4290721770): no teardown retires the terminal-event record. The map is bounded by an LRU cap of 4096 sessions. Details are in the thread.
  • P2 (r4290721775): every definitive teardown retires through one bin-locked decision that keeps the current attachment's planted or joined marker. Details are in the thread.

The same two defects were present on the DELETE route (closeSession), so it is fixed the same way.

Test runtime

Ten pre-existing cases had a vetoed submit whose probe hit an unrouted /status. Each one waited out the 30 s request timeout. With a runningStatusRoute() fixture, HostedHarnessClientTest drops from ~320 s to ~20 s.

Verification

  • mvn -o test in packages/sdk-java/qwencode (JDK 25): 382 tests, 0 failures, 9 env-gated skips. Checkstyle and git diff --check are clean.
  • HostedHarnessClientTest + HarnessEventStreamCloseTest on JDK 17.0.8 (macOS x86_64): 214 tests, 211 pass. The 3 failures were already there before this change:
    • writerTokenLengthBoundsMatchTheSharedFixture cannot find the shared fixture in a module-only copy.
    • aMidFlightRejectionKeepsAdmissionUnknown and aMidFlightExecutorShutdownKeepsAdmissionUnknown time out on their first submission.get. They time out the same way at 868b269 on that host, twice in a row, so 17.0.8 appears to park those sends the way JDK 11 does. The >= 17 gate may need a patch-level bound; recorded, not changed here.
  • Every new guard was mutation-checked: reverting it turns its test red.

Audit

Before committing I ran three rounds of paired audits, each with an undirected auditor and a reverse auditor working independently on a frozen snapshot. The committed tree is byte-identical to the round-3 snapshot.

Round Found Outcome
1 30 s probe stalls; terminal records grow per session; DELETE has the same P1/P2 shape; two probe behaviors unpinned All fixed
2 Same-identity retry joining across a teardown; abandoned-marker branch unpinned; two older tests healed by the probe All fixed
3 No Critical Low findings deferred (below)

Deferred (non-Critical, recorded here)

  1. settleLifecycle's receipt identity check still throws DaemonProtocolException after a 200. JsonSupport.requiredInt(receipt, "protocolVersion", …) runs outside fix(managed-agent): bound retry loops with terminal states #13219's HostedHarnessSettleAnsweredException wrap, so a v2 receipt with a missing or non-integer protocolVersion reads as "never settled" in SessionLifecycleCoordinator. That code arrived from main and is not touched here; three auditors reproduced it independently. fix(managed-agent): bound retry loops with terminal states #13219's parseObject wrap is also untested.
  2. joinedClientId is a single slot. A stale identity's late retry that joins after the current identity's retry overwrites it, so the next teardown can retire the current identity's marker. The window is narrow and the server's hosted_turn_active 409 still refuses the second prompt. A set would close it.
  3. The busy-turn probe (from fix(managed-agent): bound retry loops with terminal states #13219) always runs:
    • it runs even when the vetoing marker has a send in flight, where it can never clear the marker, and can cost up to requestTimeout per veto;
    • it drops probeFailure as the cause;
    • an unchecked exception from a custom httpExecutorOverride escapes the probe unwrapped.
  4. Two branches are not pinned by a dedicated test: the tolerated-404 retireLedger retirement, and the atomicity of retireStaleLedger's in-lock decision. The two-arg remove already covers most of the latter.
中文说明

本轮由我接手:已合入 main(eae5f1f75b),并修复 868b269 复审中的两条线程(b4670af39a)。

  • 合并:main 的 fix(managed-agent): bound retry loops with terminal states #13219 给 submitTurn 加了 busy-turn 状态探测,与本分支的桶锁 ledger 冲突。探测现在建立在新抽出的 registerAdmission 之上:被拦截的提交不会在拦截它的条目上开启发送;只有在该条目没有发送中请求、且 send clock 未变时,空闲的 status 读取才能清除标记。7 个原有测试改为在检查本地拦截前让 /status 报告有 prompt 在运行,防止探测把它们要固定的标记"治愈"。
  • 修复:P1 —— 任何拆除操作都不再撤销 terminal 记录,改用上限 4096 的 LRU 表限制增长;P2 —— 所有确定性拆除应答都在桶锁内统一判定,保留当前 attachment 身份种下或 join 过的标记。DELETE(closeSession)有同样的两个缺陷,一并修正。
  • 测试耗时:10 个原有用例因探测打到未注册的 /status,各自空等 30 秒;加 runningStatusRoute() 后,测试类从约 320 秒降到约 20 秒。
  • 验证:JDK 25 全模块 382 个测试 0 失败(9 个需要环境的跳过)。JDK 17.0.8(macOS)下有 3 个失败,都在本次改动之前就存在:一个是只复制模块导致找不到共享夹具;两个 aMidFlight* 在 868b269 上同样超时,像是 17.0.8 也会像 JDK 11 那样挂起这类发送,>= 17 的判断可能需要按补丁版本细化,已记录未改。每个新守卫都做了变异验证。
  • 审计:提交前做了 3 轮配对审计(无方向 + 反向,各自独立,基于冻结快照)。第 1、2 轮的发现全部修复;第 3 轮无 Critical,Low 级发现记录在上方英文"Deferred"中(包括来自 main 的 settleLifecycle 收据校验问题)。提交的树与第 3 轮快照逐字一致。

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

Re-reviewed b4670af39a3629d470482c8fc59150ed8cd69d88, focusing on the changes since 868b26950233367e5c249b170a1a313ac726c76c and the busy-turn status-probe merge resolution. No new blocking findings. Both findings from my previous review are verified fixed.

  • Completed-turn replay after detach: the independent reproduction now admits Q after completing P, detach/load, and replaying P. It records 3 prompt requests and 0 status requests, so automatic status recovery does not mask the fix.
  • Old detach racing a new attachment: after the replacement attachment admits P inside the cancellation window, the old detach preserves the marker. A valid active-status response keeps Q locally vetoed; only 1 prompt request reaches the wire.

Validation: HostedHarnessClientTest 209 passed plus HarnessEventStreamCloseTest 5 passed, zero skips, on JDK 21.0.11 / Maven 3.9.11. The independent HTTP/SSE probe suite passes 5/5 at this head, including the earlier R10/R15/R17 scenarios. The identical two regression probes still fail against 868b269, confirming that the tests discriminate the fixes. Production Java was unchanged and the private test copy was verified against the reviewed source.

I also checked all five teardown entrances, identity-scoped 404 handling, joined retries, terminal-record eviction, and the connector/coordinator failure paths. This is an incremental re-review; existing deferred suggestions are unchanged. Validation uses the actual Java HTTP/SSE implementation against a local fixture server; a full daemon E2E run was unavailable because the review worktree lacks the local CLI bundle. The code-related CI checks currently pass; the automated review job is still pending.

中文:本轮未发现新的阻塞问题,上轮两条回归均已独立验证修复。214 项现有测试和 5 项独立探针全部通过;旧版本负对照仍能复现两条问题。

Resolve the HostedHarnessClient conflict with #14323's model and
approval selections: ActivePrompt keeps this branch's planting client
id and send-window bookkeeping and gains both selections, which
matches() compares alongside promptId and digest. The capability gates
stay ahead of registerAdmission, so a refused selection registers no
marker.
@wenshao

wenshao commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

Merged main again (7c1fb57) to clear the new conflict with #14323's model and approval selections.

Resolution. HostedHarnessClient had one conflict:

  • ActivePrompt keeps this branch's planting client id and send-window bookkeeping, and gains both selections.
  • matches() compares the selections alongside promptId and digest (not client id).
  • The capability gates stay ahead of registerAdmission, so a refused selection registers no marker.
  • SubmitHarnessTurn auto-merged: toJson() emits the canonical wire prompt followed by the selection members, and the digest still hashes exactly the wire prompt bytes.

Verification.

Deferred (Low, from main, not touched here). refusesModelSelectionWhenTheHostDidNotAdvertiseIt and refusesApprovalSelectionWhenTheHostDidNotAdvertiseIt still pass with their capability gate deleted. The /session catch-all answers the /prompt POST with 200, which surfaces as PromptAdmissionUnknownException, and that still satisfies assertThrows(DaemonException.class, …). Asserting the exact message, or that no /prompt POST was sent, would pin the gates.

中文说明

再次合入 main(7c1fb575ae),解决与 #14323 model/approval selection 的冲突。ActivePrompt 保留本分支的 client id 与发送窗口记账,并新增两项 selection 参与 matches() 比较;能力检查仍在 registerAdmission 之前,被拒绝的 selection 不会留下标记。

验证:Java 模块 387 个测试 0 失败(9 个需要环境的跳过);CLI hosted 测试 543 个全部通过;用合并后的 SDK 跑 #14323 的 managed-agent-server 测试 447 个全部通过;一轮配对审计无 Critical。

延后的 Low 来自 main:两个 refuses*Selection… 测试在删掉能力检查后仍通过,因为兜底路由把 /prompt 的 POST 答成 200,抛出的 PromptAdmissionUnknownException 仍满足 assertThrows(DaemonException.class, …)。

@wenshao

wenshao commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

Verdict: ⚠️ findings @ b4670af39a — 2179 assertions green across the re-measured gates, a 6-mutant matrix on the delta, a re-run TS mutation witness, and a trial merge into current main; one operational finding: the PR now conflicts with main (2 hunks in HostedHarnessClient.java), so it needs one more base update before it can land.

Verified head: b4670af39a3629d470482c8fc59150ed8cd69d88 · merge-base with origin/main: 2eab3cc4313961adb1fd8b64fc06803c5703f91f · main tip at trial-merge: 547a91809d8b6ac54b64bb30a0a344a4f68df746. This is a follow-up round to the merge-ready report @ 9440fc868b (2026-10-15); everything below was re-measured at the new head.

中文摘要

结论:⚠️ findings —— 代码本身在 head 与试合并树上全绿,但 PR 当前与 main 有真实冲突,落地前需要再做一次 base 更新。

  • 上一轮结论复核:上轮 merge-ready(9440fc868b)无未决发现;本轮按其口径在新 head 全部重测:qwencode 全模块 372 通过/10 环境跳过(JDK 17)、JDK 11 clean test 368 通过/14 跳过、checkstyle 0 违规、CLI 三个变更文件 vitest 661/661,对照旧 head 9440fc868b 单跑 179/179。
  • delta 的核心主张(b4670af:teardown 不再退役终态记录,改为 LRU 4096 有界 map + 准入标记的 joined 身份)由变异矩阵证明承重:6 个变异(含 1 个对照)全部如期被钉住测试击杀,无一幸存;TS 侧 keepalive 变异(泄漏形态)在新 head 重测同样被击杀。
  • 发现(唯一,运维性质):试合并当前 main(547a9180)在 HostedHarnessClient.java 复现 2 处冲突,来自 main 后合入的 feat(managed-agent): add Shell Full Access and session approval switching #14323(ActivePrompt 增加 model/approval selection)与本 PR 的 bin-locked 准入账本同改一处。我用同时携带两侧意图的暂用解决(scratch、未推送)编译并跑全模块 387 通过/0 失败——说明冲突解决是机械性的,但该解决不在 PR 分支上,GitHub 仍报 CONFLICTING。
  • 未覆盖:Hosted*IT 故障门禁集成车道(需 MySQL,上轮已证 head/base 记分板一致)、CI 每日车道状态、Windows。

Previous findings — status at the new head

The previous round reported merge-ready with no open findings. Its carried measurements, re-measured at b4670af39a:

# Previous measurement Status at b4670af39a
1 qwencode HostedHarnessClientTest green (179) re-measured green: 209/209 (delta added 30 tests)
2 qwencode full module green (352, 9 skips) re-measured green: 372 passed / 10 env-gated skips
3 CLI vitest on 3 changed files green (599) re-measured green: 661/661
4 checkstyle 0 violations re-measured: 0 violations
5 TS keepalive mutation killed (hosted-harness-session.ts load-bearing) re-measured killed at the new head (see matrix)
6 Trial merge into main clean + gates green changed: now CONFLICTING — see Findings
7 JDK 11 clean test green (PR body claim) re-measured green: 368 passed / 14 skips (Zulu 11)

Delta since the verified head, and its central claim

9440fc868b..b4670af39a contains one docs-only commit (cfae71d215), two merges of main, and one substantive fix (b4670af39a). The conflict-resolved files in merge eae5f1f75b: hosted-harness-session.{ts,test.ts}, HostedHarnessClient{,.test}.java.

Central claim of the delta (b4670af): a detach/DELETE closes only the live session; the durable journal survives, so retiring the terminal-event record on teardown left a journal-replay marker vetoing every later prompt. The fix keeps the record (LRU-bounded at 4096 sessions) and routes all five definitive teardown entrances through one bin-locked retirement that spares a marker the current attachment's identity planted or joined.

A/B and mutation matrix

Control arm: the previous verified head 9440fc868b (old behaviour, old suite) — HostedHarnessClientTest 179/179 green run solo. Head arm: 209/209. The load-bearing proof for the new guards is the mutation matrix (each mutant applied to the head source, recompiled, driven through its pinning tests; M6 is the positive control proving the harness can fail):

# Mutant (reverted guard) Pinning test(s) Result
M1 teardown retires the terminal record again aTeardownKeepsTheTerminalRecordForAJournalReplay ×5 entrances killed (5 errors: already has a running turn — the veto returns)
M2 terminal map unbounded (ConcurrentHashMap) terminalRecordsStayBoundedLeastRecentlyUsedFirst killed (1 failure)
M3 retireStaleLedger drops the joined-identity check aTeardownKeepsAMarkerAReloadedRetryJoined ×5 killed (5 failures)
M4 retireLedger drops joinedClientId == null aStaleRefTolerated404KeepsAMarkerAReloadedRetryJoined ×3 killed (3 failures)
M5 admission never records a join both joined-marker tests killed (8 failures)
M6 control: stale ledger always kept aTeardownRacingAReloadRetiresTheAbandonedMarker ×5 killed (5 errors)
M7 TS: stop() leaks the keepalive timer clears the keepalive timer when backpressure stops the stream killed (1 failure)

Witness: 01-mutant-terminal-record-retired-red.png (M1 red, the veto exception visible) vs 02-head-terminal-record-kept-green.png (same tests green at head); scoreboard in 03-gates-and-mutation-scoreboard.png.

Findings

F1 (operational, merge-blocking state — not a code defect): the PR conflicts with current main. A trial merge of b4670af39a into 547a91809d reproduces GitHub's CONFLICTING: 2 hunks in packages/sdk-java/qwencode/.../HostedHarnessClient.java, both in ActivePrompt/its construction. Cause: main's #14323 (af9bd8ed05, Shell Full Access / approval switching) added modelSelection/approvalSelection to ActivePrompt after this PR's last base update, while the PR replaced putIfAbsent with the bin-locked registerAdmission and added clientId/joinedClientId/send-window fields. The resolution is mechanical — carry both intents (5-arg constructor, both field sets, registerAdmission kept; main's matches() comparing the selections already compiles against them). A scratch resolution built exactly this way passes the full qwencode module on the merged tree: 387 tests, 0 failures, 10 skips. This resolution is measurement-only and was not pushed. Reproducing commands: git worktree add t 547a91809d && git -C t merge b4670af39a → 2 conflict hunks.

Not covered

  • Hosted*IT fault-gate integration lane (real qwen serve + MySQL): not re-run this round; the previous round showed identical head/base scoreboards, and the delta's surface (client-side ledger) is below that lane's resolution.
  • CI's daily Hosted process fault gates / MySQL 8.4 lane state on current main (previous round flagged it red on main — pre-existing, unchanged area).
  • The exact conflict resolution the author/autofix will land; F1's scratch resolution proves feasibility, not the final text.
  • Windows; the sibling Suggestion-level backlog in [Backlog] sdk-java Hosted Harness client — 49 deferred review findings from #12654 post-merge review #13313.

Methodology

macOS 11.7 (x86_64), Zulu JDK 17.0.20 / 11.0.32, Maven 3.9.9 (wrapper dist, -o against the populated local repo), Node v22.23.3. Worktrees: tmp/pr13314-head @ b4670af39a (full pnpm install --ignore-scripts + patch-package + npm run build; vitest's nested esbuild 0.28.2 replaced with the top-level 0.25.12 — its postinstall binary requires macOS 12), tmp/pr13314-prev @ 9440fc868b (Java-only control), tmp/pr13314-mutant @ head (mutation matrix), tmp/pr13314-trial-merge @ 547a91809d + scratch resolution commit e117ceaed9. Raw logs under tmp/pr13314-verify-20261016-192245/.

Voided measurements, disclosed: (a) the first prev-head control run executed concurrently with the head full-module run and showed 2 timing-sensitive heartbeat failures; both passed solo, and the full class re-run solo was 179/179 — not counted. (b) Two early mutation runs used mvn surefire:test, which does not recompile — those no-op runs were discarded and re-run through mvn test; only the recompiled results appear above. (c) A payload-only TS keepalive mutation survived because the pinning test asserts timer arming/clearing, not the payload bytes; the correct leak mutation (M7) is the one reported.

Evidence captures

Mutant: teardown retires the terminal record — 5/5 red
Head: terminal record survives teardown — 5/5 green
Gates and mutation scoreboard


Local maintainer verification by @wenshao — head b4670af39a, artifacts under tmp/pr13314-verify-20261016-192245/.

@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 head 7c1fb575ae — the full production diff (11 Java main files, the CLI hosted route, README and both design docs, ~1.57k production lines). I sampled rather than read the 7.4k lines of HostedHarnessClientTest additions linearly, and I did not run Maven locally, so the author's local gate numbers stand unreproduced by me.

No blocking finding.

What holds at head

  • Prompt admission: the per-attempt windows (inFlightSends/sendClock), registerAdmission / releaseOwnedMarker / dischargeOwedRelease, and the terminal clear inside observeEvent all run under the activePrompts bin lock, and getStatus clears only the instance it snapshotted with an unchanged send clock. Every release arm separates a definitive answer from an outcome-unknown one, and the veto stays on the conservative side.
  • Teardown classification: retireLedger (identity-matched, for a tolerated 404 that cannot prove a deletion) vs retireStaleLedger (deletion-proving) vs discardObservedAttachment / discardLocalSessionState are each applied only to the answers that license them.
  • HarnessEventStream: waitingSince doubles as the waiting flag and the park stamp; close() never takes cursorLock, so a parked read stays abortable; an idle abort reaches the parked consumer as DaemonTransportException, while IllegalStateException stays reserved for a caller arriving after the close. The CLI keepalive clears both timers on every teardown path and sets X-Accel-Buffering: no.
  • Digest: computePayloadDigest hashes the canonical form toJson() emits, through a single JsonSupport.encode entry point, and the legacy-digest arm keeps the as-built key order on the wire. The breaking-change / migration note is in the README and both design docs.
  • Scope and linkage: #12654 (merged — the Hosted Harness client) and #13313 (open — the deferred-findings backlog) both exist and match the PR's stated linkage.

On the standing CHANGES_REQUESTED

reviewDecision is still CHANGES_REQUESTED, carried solely by qwen-code-review-bot's review 5540235935, pinned at 7ff9d70f — a superseded head (three commits and two main merges behind, including the #14323 selection conflict resolution at 7c1fb575). That review's own body defers the rest of its list, and the one item it asks to confirm is answered at head:

  • R16-1 (thread 4249317558) is already resolved, and its stated hazard no longer holds: the heartbeat task it describes as "never cancelled" after a deletion-proving 204 is bounded now, because scheduleHeartbeat retires the attachment on a definitive hosted_session_not_found 404 (HostedHarnessClient.java:2192), and the heartbeat route answers exactly that code for an absent session (hosted-harness-session.ts:9443). The identity-scoping asymmetry it names is still the code shape, but its consequence is a bounded, self-healing cleanup rather than the unbounded leak.
  • The four Critical [fails-closed] [new-surface] entries in the <!-- qwen-review-deferred --> block are recorded follow-up work under the convergence posture, not merge blockers; each is a conservative veto that a later status read or teardown clears, so no wrong result is certified.

Non-blocking notes (none of these holds the merge)

  1. The deleted arms of closeSession(HarnessSessionRef), detachSession and detachLifecycle(ref, …) still retire the attachment identity-matched while retiring the ledger unconditionally. Routing them through the same unconditional retirement would remove the class instead of leaning on the one-heartbeat-interval self-heal.
  2. The two mid-flight executor tests are gated assumeTrue(… >= 17) but time out on JDK 17.0.8 the way the PR says JDK 11 parks the send; a patch-level bound (or asserting the park) would keep that lane honest.
  3. The terminal record is a single slot per session, so a journal replay of a completed promptId other than the latest keeps its planted marker until the next status probe clears it — fail-closed and bounded, worth one line beside the LRU comment.
中文说明

已在 head 7c1fb575ae 完成评审(生产侧改动全量读过;HostedHarnessClientTest 新增的 7.4k 行只抽读承重用例,未在本机跑 Maven)。无阻塞项。

  • 准入台账:每次发送窗口(inFlightSends/sendClock)、registerAdmission/releaseOwnedMarker/dischargeOwedRelease,以及 observeEvent 里的终态清除,全部在同一把 activePrompts 桶锁内;getStatus 只清除它快照到、且 send clock 未变的那个实例。每条释放分支都区分「确定性应答」与「结果未知」,否决方向保持 fail-closed。
  • 拆除分类:retireLedger(按身份匹配,用于无法证明删除的容忍 404)、retireStaleLedger(以 204 证明删除)、discardObservedAttachment/discardLocalSessionState 都只用在各自的授权应答上。
  • HarnessEventStream:waitingSince 同时充当等待标志与停放时间戳;close() 不取 cursorLock,停放的读始终可中止;空闲中止以 DaemonTransportException 到达停放中的消费者,IllegalStateException 只留给 close 之后才来的调用方。CLI keepalive 在每条拆除路径上都清双定时器,并设置 X-Accel-Buffering: no。
  • digest:computePayloadDigest 对 toJson() 实际发出的规范形式取哈希(唯一 JsonSupport.encode 入口),兼容臂按原键序上线。破坏性变更/迁移说明已写进 README 与两份设计文档。
  • 范围与关联:#12654(已合入)与 #13313(开放)都存在且与正文声明一致。

关于仍挂着的 CHANGES_REQUESTED:它只来自 qwen-code-review-bot 的 5540235935,钉在 7ff9d70f——已被取代的 head(落后 3 个提交 + 2 次 main 合并,含 7c1fb575 上 #14323 的 selection 冲突解决)。该评审正文自身把其余项都记为延后;它唯一要求确认的一条在 head 上已不成立:

  • R16-1(线程 4249317558)早已 resolved;它描述的「204 证明删除后心跳任务永不取消」在当前 head 有界:scheduleHeartbeat 会在确定性的 hosted_session_not_found 404 上退役 attachment(HostedHarnessClient.java:2192),而心跳路由对不存在的会话正是回这个 code(hosted-harness-session.ts:9443)。它指出的身份匹配不对称仍是代码形状,但后果已是有界、可自愈的清理,而非无界泄漏。
  • <!-- qwen-review-deferred --> 里的 4 条 Critical [fails-closed] [new-surface] 是收敛姿态下的记账跟进项、非合并阻塞项;每条都是保守否决,会被后续 status 读取或拆除清除,不会认证出错误结果。

非阻塞建议(均不阻塞合并):① 三处 deleted 分支对 attachment 仍按身份匹配退役、对台账却无条件退役,统一成无条件退役可整类消除(现靠 ≤1 个心跳间隔自愈兜底);② 两个 mid-flight 执行器用例门控为 >= 17,但在 JDK 17.0.8 上会像 JDK 11 那样挂起,建议按补丁版本细化或改为断言 park;③ 终态记录每会话单槽,导致非最新 promptId 的重放会保留其标记直到下一次 status 探测清除——fail-closed 且有界,值得在 LRU 注释旁加一行。

— yiliang114 via Qwen Code /review

@wenshao
wenshao dismissed stale reviews from qwen-code-review-bot and ghost October 16, 2026 12:19

fixed

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

评审提交:7c1fb575aeeb859a09bf538b62995272621eb400(base main,merge base 53a24a5ddf)。Critical-only,预算内完成。取证方式为 git fetch upstream refs/pull/13314/head 后在该 sha 上 git show / git diff / git grep,不读工作树,也不采信作者或他人评审的转述。

结论:提交 COMMENT,本轮不予 Approve。 我没有发现能用代码证据证明的新 Critical,而且此前挂着的全部三条 Critical 我都在 head 上确认已解决;不 Approve 的唯一原因是本 PR 约 1.57k 行 Java 生产改动我无法在预算内完成独立扫描,且该 head 上没有任何 CI lane 会执行它们。

一、已在 head 代码上确认解决的历史 Critical

bot 第 20 轮(review 5528971892 @ 4e36f27c)以收敛姿态延后了三条 Critical。三条在当前 head 上都不再成立:

1. R17-2「non-owning 202 republish 丢弃被替换 entry 的 releaseOwed」(HostedHarnessClient.java:549)— 已解决。 head 上 republish 走的是同一次 bin 锁内的 activePrompts.compute(...):先 if (active != registered) return active; 拒绝替换他人 entry;terminal-replay 分支不再 republish,而是保留现有 entry —— 已 settle 时按 active.releaseBlocked ? active : null 退休,未 settle 时 active.releaseOwed = true; return active;,即欠账记在被保留的 entry 上而不是随新实例丢失;只有 ownsActivePrompt ? active : candidate 这一非 terminal 分支才会发布新 entry。该处注释也逐字写出了这条 Critical 的后果:「never republish: a fresh instance would drop an owed release and could never be cleared, vetoing every later identity for this client's lifetime」。releaseOwed 在 head 上的全部读写点是 :608、:1484、:1499 与字段声明 :2411,没有别的 republish 路径绕过它。

2. 「README 公布的 digest key order 与实现的 ECMAScript array-index-first 顺序不一致」(packages/sdk-java/qwencode/README.md:162)— 已解决。 head 上的该段现在明确写的是「object members appear in JavaScript JSON.stringify own-key order — array-index keys ("0" through "4294967294", no leading zero) ascending numerically first, then the remaining keys in insertion order — applied recursively, array order preserved」,即 ECMAScript 的数组下标键优先顺序;同段还写清了 legacy digest 兼容臂只覆盖一代、以及「Do not rewrite a stored digest or a stored input to make it match」。我核对的是文档表述本身(这正是该 finding 的对象),未逐行核对 computePayloadDigest 的实现与之一致。

3. 「terminalPromptIds 是 last-value slot,但读取处问的是 any-value 问题」(HostedHarnessClient.java:551)— 已解决。 head 上 terminalPromptIds 只有一个读取点(:602),形式是 candidate.promptId.equals(terminalPromptIds.get(sessionId)),问的是「这个 promptId 是否就是那条终态记录」,是特定值比较而非存在性判断;唯一的写入点是 :1585 的 put,其余出现处(:70、:99、:1415)是注释与声明。

另外,reviewDecision 曾由 bot 在 7ff9d70f 的 CHANGES_REQUESTED(review 5540235935)承载,该 review 现在是 DISMISSED,我读元数据时 reviewDecision 为 REVIEW_REQUIRED;两者都不作为门禁。wenshao 在 b4670af3(2026-10-16T10:58)的复评结论是「No new blocking findings. Both findings from my previous review are verified fixed」,并附了负对照(同样的两个复现探针在 868b269 上仍然失败),这两条我未自行在代码上复核,见下。

二、我自己扫描过的当前代码

packages/cli/src/serve/hosted-harness-session.ts(+26/−5,本 PR 唯一的 TS 生产改动)已完整读过,未发现问题。 三处改动:新增 X-Accel-Buffering: no;新增 15s keepalive(res.write(': keepalive\n\n'),并在 res.destroyed || res.writableEnded 时直接返回);以及把 stop 闭包与 session.streams.add(stop) 从两个 timer 之前移到之后,使其能同时 clearInterval(timer) 与 clearInterval(keepaliveTimer)。

这次移动是本轮唯一有 TDZ / 漏注册风险的形状,我按 head 上的实际行序核对了:const pump 在前,stop() 只在 pump 的异步体内被引用;const timer = setInterval(...) 与 const keepaliveTimer = setInterval(...) 之后到 const stop = ...、session.streams.add(stop)、res.on('close', ...)、void pump() 之间全是同步语句,没有 await(该区间唯一的 await 在 pump 体内)。因此两个 timer 的回调不可能在 stop 初始化之前执行,pump() 的首次同步调用也发生在 stop 初始化之后;res.on('close') 的注册与 timer 创建处于同一同步块内,Node 不会在此之前投递 close 事件。res.on('close') 也同时清理了两个 timer 并从 session.streams 删除 stop,没有留下只清一个 timer 的拆除路径。

三、本轮无法确认的门禁(这是不予 Approve 的原因)

约 1.57k 行 Java 生产改动没有经过我的独立扫描。 本 PR 的生产面包括 HostedHarnessClient.java(+1051/−141)、HarnessEventStream.java(+122/−24)、SubmitHarnessTurn.java(+53/−6)、StreamHarnessEvents.java(+16/−4)、PromptAlreadyActiveException(+26/−2)、DaemonEvent、DaemonHttpException、DaemonSessionClient、DaemonTransportException、HarnessRuntimeExecutionRecovery。我实际读到的只有上面第一节引用的那段 refusal / republish 区域(约 85 行)、releaseOwed 与 terminalPromptIds 的全量读写点普查,以及 README 的那一段。prompt 准入的窗口与 bin 锁、各 release 臂对「确定答案」与「结果未知」的区分、teardown 分类(retireLedger / retireStaleLedger / discardObservedAttachment / discardLocalSessionState)、joined retry、terminal-record 淘汰、以及 SSE 关闭语义(waitingSince 兼作 waiting 标志与 park 时间戳、close() 不取 cursorLock、idle abort 以 DaemonTransportException 到达 parked consumer)我都没有读到能下结论的深度。因此对这些路径我既不能证明有 Critical,也不能证明没有。

该 head 上没有任何 CI lane 执行这些 Java 测试。 gh pr checks 13314 列出的通过项全是 Node 侧(Test (ubuntu-latest, Node 22.x) pass 31m22s、Lint & Static pass 16m34s、Integration Tests (no-AK, No Sandbox) pass 9m3s、Serve A/B pass 21m37s、Build and verify reference distribution pass、web-shell E2E Smoke 与 review-pr pending,其余 skipping),没有 Java / Maven lane;sdk-java.yml 不含 pull_request 触发。所以 HostedHarnessClientTest(作者报告 209 通过)与 HarnessEventStreamCloseTest(5 通过)在本 head 上没有自动执行记录。本机也没有 JRE,我无法编译或运行任何 Java,作者给出的本地门禁数字与 5/5 独立 HTTP/SSE 探针结果我无法复现。按频道规则,pending 与不存在的 lane 都不单独作为卡点,但它们意味着这条门禁只能由人来关。

四、CI 摘要

该 head 无失败项:Node 侧主要 lane 全绿,web-shell E2E Smoke 与 review-pr 仍在排队(未等待、未轮询)。没有证据表明任何 CI 失败由本 PR 引入;Java 侧如上,本 head 无 lane。

五、下一步(很窄)

  1. 让 Java 侧在本 head 上有一次可核对的执行证据:HostedHarnessClientTest + HarnessEventStreamCloseTest 的运行输出(或夜间 sdk-java lane 在该 head 的结果),使 209/5 与 5/5 探针不再是纯本地数据。
  2. 上一轮那两条由维护者用负对照确认修复的回归(detach 后重放已完成 turn、旧 detach 与新 attachment 竞争),若希望在下一轮由我自行确认,请指出各自的生产代码位置;本轮预算不足以在 1.5k 行里定位并复核它们。
  3. 三条被延后的 Critical 我已逐条在 head 上确认解决,建议把 findings 工件里的这三条标记为已关闭,避免下一轮评审继续把它们当作未决项携带。

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Released in v0.25.3.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants