Repository navigation
fix(sdk-java): Close Hosted Harness review criticals from #12654 - #13314
Conversation
#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).
|
CI attribution note for the transient 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 one pending lane is the scheduled re-review ( |
…view-criticals # Conflicts: # packages/sdk-java/qwencode/src/test/java/com/alibaba/qwen/code/daemon/HostedHarnessClientTest.java
|
@qwen-code /takeover |
|
🤝 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 循环现在管理此 PR —— 将持续处理新的评审反馈与 base 冲突,直到移除标签或达到轮次上限。移除 |
…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>
|
🤖 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 clientCommit Resolved in the code
Folded in with the same edited sentences/lines:
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 ( Notes for the reviewer
Verification
中文说明本轮摘要 —— Hosted Harness 客户端第三轮 review Critical 收尾提交 已在代码中解决
随同一批被修改的句子/行一并收尾的:
顺延到下一轮(均已在各自 thread 回复)按每轮批量上限,十四条 Suggestion 顺延一轮:rc:4177489248 与 rc:4177489254(CLI keepalive 可观测性用例与写入防护)、rc:4177489265( 给 reviewer 的说明
验证
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/模型 |
|
/qwen-code /takeover |
…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
|
🤖 Addressed the latest review feedback (round 2/100). What changed, and what I pushed back on: · 已处理最新评审反馈(第 2/100 轮)。改动内容与我反驳保留之处如下: Round 4 — review findings addressedAll nine round-3 inline findings are resolved in code, each pinned by a Findings
The four Merge conflict notes
Verification
中文说明第 4 轮 —— 评审发现处理完毕第 3 轮的 9 条行内发现全部在代码中解决,每条都用变异探针验证(打上变异体、确认对应测试变红、还原变异体、套件恢复全绿)。同时按 发现逐条处置
第 3 轮收敛姿态下列出的 4 条 合并冲突说明按 验证
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/模型 |
…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
|
🤖 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 ( Findings addressed (10 of 10; none declined, deferred, or escalated)
Review body Verification
中文说明审查处理轮次 —— PR #13314(第 5 轮)增长审计(本窗口必需)结论:sound(见 已处理的发现(10 条全部处理;无拒绝、无延后、无升级)
评审正文 验证
Deferred non-Critical feedbackCritical-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). ( 中文说明已进入仅处理 Critical 的模式:本计数窗口内 diff 净增长已达 源码 665 / 测试 0 行(预算 400/400)。本轮可执行区域已排除下方非 Critical 反馈;这些条目保持开放,留待人工跟进。纯增长触发期间维护者反馈照常流动(按作者的批次预算仅在完成 5 个产生改动的轮次后生效)。(评论 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/模型 |
|
🔀 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 将重新运行。 |
|
🔀 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 将重新运行。 |
|
⏸️ 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 中文说明⏸️ AutoFix 已因评审收敛信号暂停:3 轮自动评审连续发出机器可读的不收敛信号(自上次维护者响应以来观察到的信号码;若无响应则自窗口开始:batch-fixes, root-cause-triage)——评审仍在以不降的速率发现新缺陷,而循环在继续扩大 diff,再跑一轮自动修复难以收敛本 PR。维护者在本 PR 上作出回应后循环自动恢复(评论或评审均可,并将作为后续轮次的指引);若信号再持续 3 轮会再次暂停。可选做法:把反复出问题的簇拆成独立 PR、把剩余修复攒成一批一次推送、评论 |
🩺 serve daemon A/BBuilt the PR base vs this PR head
|
| 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.
|
🔀 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
left a comment
There was a problem hiding this comment.
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)
…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.
|
🤖 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 roundOne commit, Feedback dispositionsrc:4288526219 — R21-1 (Critical, certifies-falsely) — fixedThe claim verified: rv:5529265828 — @wenshao re-review of
|
|
🔀 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 将重新运行。 |
|
🤖 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: 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/模型 |
|
🤖 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: 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/模型 |
wenshao
left a comment
There was a problem hiding this comment.
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/admitPromptand the existingreplays a settled prompt admission from the journal after a reloadtest. Running that TypeScript test locally was blocked by missing workspace build outputs; no end-to-end server run is claimed.
中文:上次三个已验证问题已修复;本次更新新增两处回归:detach 后重放已完成轮次会阻塞下一轮,以及并发重载时旧 detach 可能清除新轮次的活跃标记。两条均已完成新旧版本对照。
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.
|
Took over this round. I merged Merge
Seven existing veto tests now have Fixes
The same two defects were present on the DELETE route ( Test runtimeTen pre-existing cases had a vetoed submit whose probe hit an unrouted Verification
AuditBefore 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.
Deferred (non-Critical, recorded here)
中文说明本轮由我接手:已合入
|
wenshao
left a comment
There was a problem hiding this comment.
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.
|
Merged Resolution.
Verification.
Deferred (Low, from 中文说明再次合入 验证:Java 模块 387 个测试 0 失败(9 个需要环境的跳过);CLI hosted 测试 543 个全部通过;用合并后的 SDK 跑 #14323 的 managed-agent-server 测试 447 个全部通过;一轮配对审计无 Critical。 延后的 Low 来自 main:两个 |
|
Verdict: Verified head: 中文摘要结论:
Previous findings — status at the new headThe previous round reported merge-ready with no open findings. Its carried measurements, re-measured at
Delta since the verified head, and its central claim
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 matrixControl arm: the previous verified head
Witness: FindingsF1 (operational, merge-blocking state — not a code defect): the PR conflicts with current Not covered
MethodologymacOS 11.7 (x86_64), Zulu JDK 17.0.20 / 11.0.32, Maven 3.9.9 (wrapper dist, 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 Evidence capturesLocal maintainer verification by @wenshao — head |
yiliang114
left a comment
There was a problem hiding this comment.
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 insideobserveEventall run under theactivePromptsbin lock, andgetStatusclears 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) vsretireStaleLedger(deletion-proving) vsdiscardObservedAttachment/discardLocalSessionStateare each applied only to the answers that license them. HarnessEventStream:waitingSincedoubles as the waiting flag and the park stamp;close()never takescursorLock, so a parked read stays abortable; an idle abort reaches the parked consumer asDaemonTransportException, whileIllegalStateExceptionstays reserved for a caller arriving after the close. The CLI keepalive clears both timers on every teardown path and setsX-Accel-Buffering: no.- Digest:
computePayloadDigesthashes the canonical formtoJson()emits, through a singleJsonSupport.encodeentry 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
scheduleHeartbeatretires the attachment on a definitivehosted_session_not_found404 (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)
- The
deletedarms ofcloseSession(HarnessSessionRef),detachSessionanddetachLifecycle(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. - 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. - 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_found404 上退役 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
qqqys
left a comment
There was a problem hiding this comment.
评审提交: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。
五、下一步(很窄)
- 让 Java 侧在本 head 上有一次可核对的执行证据:
HostedHarnessClientTest+HarnessEventStreamCloseTest的运行输出(或夜间sdk-javalane 在该 head 的结果),使 209/5 与 5/5 探针不再是纯本地数据。 - 上一轮那两条由维护者用负对照确认修复的回归(detach 后重放已完成 turn、旧 detach 与新 attachment 竞争),若希望在下一轮由我自行确认,请指出各自的生产代码位置;本轮预算不足以在 1.5k 行里定位并复核它们。
- 三条被延后的 Critical 我已逐条在 head 上确认解决,建议把 findings 工件里的这三条标记为已关闭,避免下一轮评审继续把它们当作未决项携带。
|
Released in v0.25.3. |



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
mainbefore 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:
promptmember was not, and the hosted route re-derives the digest from the received bytes — everyaddTextsubmission drew400 invalid_hosted_prompt.toJson()now emits the canonical form, the digest reuses theJsonSupport.encodefacade 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).Builder.sseIdleTimeoutacceptsDuration.ZEROfor callers that own the deadline. A new test keeps a consumer parked innext()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.DaemonExceptionfamily: when the watchdog fired while the consumer was betweennext()calls, the closed guard threwIllegalStateException, contradicting the new javadoc and invisible to consumers classifying byDaemonException. The guard now distinguishes who closed the stream: idle abort →DaemonTransportException('Hosted Harness SSE idle timeout'), caller close →IllegalStateException.IOExceptionas "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 bareRejectedExecutionException(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.DaemonHttpExceptionwith its status preserved.detachSessionretires 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 oncursorLockwhen the stream closes re-checks inside the lock and gets the closed-stream signal instead of a transport error; thesession_snapshotcomment now names the actual producer (the bridge'swithSnapshoton 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 thatsnapshot(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)
HarnessEventStreamno longer parksclose()behind a consumer blocked innext()— the closed flag is atomic and the raw input is closed without any stream monitor, soHostedHarnessClient.close()always completes and a blockednext()fails withDaemonTransportException(the idle watchdog above completes this picture).PromptAlreadyActiveException); a definitive non-409 failure on a same-identity retry releases the slot it retained for that retry; andgetStatus()snapshots the active-prompt entry before the remote read and only ever removes that exact registration, so a stalehasActivePrompt:falsecan no longer delete a different prompt admitted while the read was in flight.X-Qwen-Harness-Boot-Idfence header on a mutation path is classified as outcome-unknown instead of a bareDaemonProtocolException, because a response that never passed the fencing middleware cannot prove the mutation did not execute; and a purely local executor rejection surfaces asDaemonTransportExceptioninstead of claiming the request may have reached the server.closeSession(HarnessSessionRef)treats a definitive 404 as already-done and tears down the attachment and the active-prompt ledger, anddetachSessiontolerates 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.streamEventsfalls 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 (andLast-Event-IDresumes 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 syntheticsession_snapshotframe produced by the primary transport's snapshot subscription.computePayloadDigesthashes a canonical form (object keys sorted recursively, array order preserved) instead of process-randomMapiteration order, so the dedup key is reproducible across JVMs and across map implementations (fastjson2'sMapSortFieldwas ruled out by probe: it does not sort maps nested inside a collection); andHarnessRuntimeExecutionRecoveryenforces at construction that aknownoutcome carries its status map, instead of NPE-ing later insideisContinuationReady().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:All green locally on JDK 17;
clean testgreen on JDK 11 (module targets release 11; two executor-rejection cases skip themselves on JDK 11, whoseHttpClientparks 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):
requireNonNull(status)forknownoutcomespromptContentagainactivePrompts.remove(key)validateGenerationclientId == nullsession_snapshotout of the id-less setnext()/close()on one monitor againIOExceptionagainMutation witnesses, second round:
toJson()emits the raw list againIllegalStateExceptionrequireMutationStatusonlyEvidence (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 21lane 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
Environment (optional)
Local:
JAVA_HOME=jdk17(full suite) andjdk11(mvn clean test), Maven 3.9.11, inpackages/sdk-java/qwencode;npx vitest run src/serve/hosted-harness-session.test.tsinpackages/cli.Risk & Scope
next()now also seeDaemonTransportExceptionon an idle abort — including the between-calls arm, which previously surfaced asIllegalStateException.Prompt*exception redesign for per-codemarker 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 itsensureOpen()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.submitTurnon a 409 now throwsPromptAlreadyActiveExceptioninstead ofDaemonHttpException; definitive unfenced 4xx on mutation paths now throwDaemonHttpExceptioncarrying the status instead of outcome-unknown types;submitTurn'stoJson()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 个关键缺陷:
prompt字段没有,hosted 路由又按收到的字节重算 digest——每个addText提交都拿到400 invalid_hosted_prompt。toJson()现在输出规范形式,digest 经JsonSupport.encode门面处理同一个值(唯一序列化入口),钉住测试断言线上字节与 digest 是字面相等的同一个值(字节字面量断言 + 规范 digest 常量)。Builder.sseIdleTimeout接受Duration.ZERO供自管期限的调用方关闭。新测试让消费者停在next()里跨三个空闲预算、对端仅靠 keepalive 存活;既有空闲超时用例在移除看门狗后仍变红。DaemonException家族:看门狗在消费者处于两次next()之间触发时, closed 守卫抛IllegalStateException,与新增 javadoc 矛盾、且按DaemonException分类的消费者捕不到。守卫现在区分关闭由谁发起:空闲中止 →DaemonTransportException('Hosted Harness SSE idle timeout'),调用方主动 close →IllegalStateException。IOException都认证为"从未派发",但响应投递也运行在调用方提供的执行器上——在服务端已受理之后才出现的拒绝,会把一个已被 admit 的轮次的活跃标记丢掉并报告为"确定未提交"。现在只有原始RejectedExecutionException(提交时)或执行器已终止两种情形归为饱和/已知;中途形状一律保持 outcome-unknown 并保留标记。通过包级执行器测试缝以"停住 worker + 填满队列 + 延迟应答 202"的方式确定性钉住。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失败(上面的空闲看门狗补全了这一图景)。PromptAlreadyActiveException);同身份重试收到确定性非 409 失败时释放该重试保留的槽位;getStatus()在远端读取前快照活跃 prompt 条目且只删除那一次注册,陈旧的hasActivePrompt:false不再能删掉读取在途期间准入的另一个 prompt 的登记。X-Qwen-Harness-Boot-Idfence 头的响应被分类为结果未知而非裸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帧。computePayloadDigest对规范形式(对象键递归排序、数组顺序保持)做哈希,而不是对进程随机的Map迭代序做哈希,去重键可跨 JVM、跨 map 实现复现(实测否决了 fastjson2 的MapSortField:它不对集合内嵌套的 map 排序);HarnessRuntimeExecutionRecovery在构造时强制knownoutcome 必带 status map,而不是之后在isContinuationReady()里 NPE。每条发现由新测试钉住,并已运行变异见证:单独还原该发现的修复,钉住它的测试即变红(见证表见“如何验证”)。
为什么需要
Hosted Harness 客户端是私有 hosted profile 的 Java 控制面传输,其公开契约承诺 fail-closed 行为(有界资源、结果未知分类、每会话单活跃 prompt、epoch-fenced 续传)。第一轮评审证明了每一项承诺都存在具体违例;第二轮又用执行证明第一轮自己的修复在 stub 看不到的那些面上带着一处跨语言回归(CI 结论一致)以及另外四处同类违例(服务端重算 digest、hosted 路由的静默、执行器的派发/投递双重角色、closed 守卫的异常类型)。在合入前处理完两轮评审,比带着断掉的 prompt 路径上线再返工便宜。
评审者测试计划
如何验证
这些行为由
HostedHarnessClientTest的 23 个新用例钉住。运行:本机 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
环境(可选)
本机:
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。风险与范围
next()的消费者现在也会在空闲中止时看到DaemonTransportException——包括"两次调用之间"这一臂,此前表现为IllegalStateException。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+ 的执行器拒绝测试刻意流经该路径并在注释中写明耦合。submitTurn收到 409 时现在抛PromptAlreadyActiveException而不是DaemonHttpException;变更路径上的确定性无 fence 4xx 现在抛携带状态码的DaemonHttpException而不是 outcome-unknown 类型;submitTurn的toJson()现在输出按键排序的 content block(服务端接受——它只校验形状并重算 digest)。关联 Issue
Refs #12654(本 PR 修复其合入后评审发现)与 #13313(两轮评审推迟剩余项的 backlog)。