Repository navigation
fix(java): return correlated errors for control callback failures - #17113
Conversation
|
Thanks for the PR — the description matches what the diff actually does, which is not a given. Template looks good ✓ (all required sections, plus a complete Chinese translation). Problem: real and statically provable, not theoretical hardening. I walked the chain on Direction: aligned. The Python SDK already emits exactly this frame ( Size: Stage 0 not applicable — no core paths, single package, no cross-package reach. 38 production lines (24 response model, 10 session, 4 README) against 195 test lines. Approach: minimal, and close to what I'd have written from the description alone before looking at the diff. Reading Risk: no high-risk path match. The real risk here is evidentiary rather than structural: no CI has run on this head at all. Details in the code-review comment. Moving on to code review. 🔍 中文说明感谢贡献!PR 描述与实际 diff 一致,这点很难得。 模板完整 ✓(必需章节齐全,并有完整的中文翻译)。 问题: 真实存在且可静态证明,不是理论性加固。我在 方向: 对齐。Python SDK 已经发送完全相同的帧( 规模: Stage 0 不适用——未触及核心路径,单一 package,不跨包。生产代码 38 行(响应模型 24、session 10、README 4),测试 195 行。 方案: 改动最小,和我在看 diff 之前仅凭描述想到的方案基本一致。从原始 风险: 未命中高风险路径。这里真正的风险是证据层面而非结构层面:这个 head 上完全没有跑过 CI。详见代码审查评论。 进入代码审查 🔍 — Qwen Code · qwen3.8-max-2026-09-02 Reviewed at |
Code reviewBefore opening the diff I wrote down what I'd do from the title and the "Why it's needed" paragraph alone: funnel all four failure modes (throw / timeout / null / empty envelope) into one place, read the original What I could verify statically, I verified rather than assumed:
No blocking issues. Three non-blocking notes:
The one thing the diff does not contain is the cross-language fixture the description's Before/After table rests on — the committed test asserts the envelope shape in Java, against its own expectations, and never reaches the real TypeScript guard. That is a gap in the evidence, not in the code; I closed it by reading sequenceDiagram
participant P1 as CLI permission controller
participant P2 as CLI ControlDispatcher
participant P3 as Java Session
participant P4 as SDK consumer callback
P1->>P2: sendControlRequest (can_use_tool, request id 42)
P2->>P3: control_request frame
P3->>P4: onControlRequest
P4-->>P3: throws, times out, or returns no envelope
P3-->>P2: control_response, request id 42, subtype error, error text
P2-->>P1: pending request rejected with that error
P1->>P1: cancels the tool call with a message instead of waiting 60s
TestingThis was an unattended CI run, so I did not build, run, or execute anything from this PR — no The headline is that there is no CI evidence for this head. All four So, explicitly:
Sandboxed verification would settle the part static review cannot: 中文说明代码审查。 在看 diff 之前,我仅凭标题和"为什么需要"写下了自己的方案:把四种失败情况(抛错/超时/返回 null/返回空封装)汇聚到一处,从收到的帧里取原始 凡是能静态确认的,我都自己确认过,而不是照单接受:
没有阻塞性问题。三条非阻塞意见:
diff 里唯一缺的,是描述中 Before/After 表格所依赖的跨语言夹具——已提交的测试只在 Java 侧按自己的预期断言封装形状,从未触及真实的 TypeScript 识别函数。这是证据的缺口,不是代码的缺口;我改为通读 上面的时序图展示了关联链路:CLI 发出带请求编号的控制请求,Java 回调失败,Session 回送携带同一编号的错误帧,CLI 据此立刻拒绝待处理请求并取消工具调用,而不是等满 60 秒。 测试。 本次为无人值守 CI 运行,因此我没有构建、运行或执行本 PR 的任何代码——没有 结论是:这个 head 没有任何 CI 证据。 因此明确说明:
沙箱验证能解决静态审查解决不了的部分: — Qwen Code · qwen3.8-max-2026-09-02 Reviewed at |
|
Confidence: 3/5 — the code review came back clean and I'd be comfortable maintaining this, but nothing has actually executed: every CI lane on this head is Stepping back. The problem is real, and I confirmed it independently instead of inheriting the PR's framing — the old fallback could never have been accepted by the CLI's guard, so any handler failure left a permission request hanging for a full minute. The fix is the smallest correct one: it mirrors the frame the Python SDK already sends, adds the Six months from now this reads fine. The three notes in the review are cosmetic — a duplicated test double, a verbose error string on the wire, a synthetic ERROR log for a benign What stops me approving is evidentiary, not substantive. So: no approval and no request-changes in this run — the code doesn't warrant the latter, and the evidence doesn't yet support the former. Deferring with both questions named. Once CI has run green on this head, a re-run of 中文说明置信度:3/5 —— 代码审查结果是干净的,这份代码交由我维护我没有意见;但实际上一切都还没有执行过:这个 head 上所有 CI 通道都是 退一步看整体。问题是真实的,而且我是自己独立确认的,没有直接沿用 PR 的叙述——旧的兜底帧不可能被 CLI 的识别函数接受,因此任何 handler 失败都会让一次权限请求整整挂起一分钟。修复是最小的正确解:它与 Python SDK 已经在发送的帧一致,补上了协议早已定义、而 Java 模型缺失的 半年后再看这份代码不会让人难受。审查中的三条意见都属于表面问题——重复的测试替身、线路上偏冗长的错误字符串、为一个无害的 阻止我批准的是证据层面,不是实质层面。 所以:本轮既不批准,也不要求修改——代码不足以支持后者,证据还不足以支持前者。两个问题都已点名,转交维护者。一旦 CI 在这个 head 上跑绿,重新运行 — Qwen Code · qwen3.8-max-2026-09-02 Reviewed at |
|
⏸️ Deferring to the maintainers — needs a human call on this one. Escalating this one rather than approving or rejecting it. The code review itself found no blockers — the fix is minimal, mirrors the frame the Python SDK already sends, and I traced the CLI's consumer side to confirm a rejected control request becomes a cancelled tool call with a message rather than an escaped rejection. Two things I cannot resolve from the diff, the tests, and the PR description:
Optional, and only if you want the cross-language claim proven rather than read: Non-blocking notes from the review are in the Stage 2 comment: a third hand-rolled 这个 PR 我不批准也不打回,而是转交维护者。代码审查本身没有发现阻塞项——修复是最小的,与 Python SDK 已经在发送的帧一致,我也追到了 CLI 的消费侧,确认被拒绝的控制请求会转成带说明的工具调用取消,而不是逃逸的 rejection。有两点我无法从 diff、测试和 PR 描述中解决:
可选项,且仅在你希望把跨语言断言"证明出来"而不是"读出来"时:以受赞助方式运行 审查中的非阻塞意见在 Stage 2 评论里:同包内第三个手写 |
qwen-code-review-bot
left a comment
There was a problem hiding this comment.
Reviewed. Suggestions are inline.
Not explored to full depth (tool budget reached): "agent reverse-audit (round 3)": did not compile or javap any class (shared worktree, mvn /in-place build forbidden by the brief), so the JVM walk above rests on the source shapes and call f…; "agent 1c": none — I stopped with the walk complete..
中文说明
已审查。 建议见行内评论。
未探索到全部深度(达到工具调用预算):"agent reverse-audit (round 3)":did not compile or javap any class (shared worktree, mvn /in-place build forbidden by the brief), so the JVM walk above rests on the source shapes and call f…;"agent 1c":none — I stopped with the walk complete.。
— deepseek-v4.1-flash-1017 via Qwen Code /review (v0.27.2)
qwen-code-review-bot
left a comment
There was a problem hiding this comment.
Reviewed — no blockers. Suggestions are inline.
中文说明
已审查——无阻断问题。 建议见行内评论。
— deepseek-v4.1-flash-1017@1f214e4e via Qwen Code /review (v0.27.2)
qwen-code-review-bot
left a comment
There was a problem hiding this comment.
Reviewed. Suggestions are inline.
Not explored to full depth (tool budget reached): "agent reverse-audit (round 3)": did not compile and run the two changed test files (needs a maven build in the shared worktree), so their compile/pass status is inferred from source reading, n…; "agent reverse-audit (round 3)": did not execute a live CLI session to re-derive the 60-second/30-second budgets at runtime; those figures come from reading permissionController.ts:42 , baseC….
Convergence: round 3 posted 4 inline comment(s), 4 of them reported for the first time; the previous round posted 6 (4 new). Findings keep coming back to the same files: packages/sdk-java/qwencode/src/test/java/com/alibaba/qwen/code/cli/session/SessionControlRequestTest.java (findings in round 1; 2 more now); packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/cli/session/Session.java (findings in rounds 1, 2; 1 more now); packages/sdk-java/qwencode/README.md (findings in round 1; 1 more now). The rate of new findings is not falling. A cluster that keeps producing siblings usually means the fixes are treating instances of a shared root cause — triaging that cause before the next round, or splitting an independent cluster into its own pull request, tends to end the loop faster than fixing them one at a time. Batching the remaining fixes and verifying them before the next push, or dropping this PR's reviews to --severity-floor critical, keeps the loop from re-deriving the same set. No Critical finding is open on this round, so merging and moving the remaining Suggestion threads to a follow-up issue is available as an ending — a merged pull request cannot diverge further. (Observation only — nothing was withheld from this review because of this observation.)
中文说明
已审查。 建议见行内评论。
未探索到全部深度(达到工具调用预算):"agent reverse-audit (round 3)":did not compile and run the two changed test files (needs a maven build in the shared worktree), so their compile/pass status is inferred from source reading, n…;"agent reverse-audit (round 3)":did not execute a live CLI session to re-derive the 60-second/30-second budgets at runtime; those figures come from reading permissionController.ts:42 , baseC…。
收敛情况:第 3 轮发布了 4 条行内评论,其中 4 条是首次提出;上一轮发布了 6 条(其中 4 条首次提出)。发现反复回到同一批文件:packages/sdk-java/qwencode/src/test/java/com/alibaba/qwen/code/cli/session/SessionControlRequestTest.java(第 1 轮已出过发现,本轮又有 2 条);packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/cli/session/Session.java(第 1、2 轮已出过发现,本轮又有 1 条);packages/sdk-java/qwencode/README.md(第 1 轮已出过发现,本轮又有 1 条)。新发现的产出速度没有下降。一个不断再生兄弟发现的簇,通常意味着逐条修复只在处理同一根因的实例——先定位并处理该根因,或把独立的簇拆成单独的 PR,通常比逐条修复更快结束循环。把剩余修复攒成一批、验证后再推送,或将本 PR 的评审降到 --severity-floor critical,可以避免循环反复推导同一组发现。本轮没有未决的 Critical,因此"合入后把剩余 Suggestion 线程转到后续 issue"是一个可选的结束方式——已合入的 PR 不会继续发散。(仅为观察——本轮评审未因此扣留任何内容。)
— deepseek-v4.1-flash-1017 via Qwen Code /review (v0.27.2)
qwen-code-review-bot
left a comment
There was a problem hiding this comment.
Reviewed — no blockers. Suggestions are inline.
Deferred under the convergence posture (round 4, not a blocker) — recorded, not requested in this round:
packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/cli/protocol/message/control/CLIControlResponse.java:137 — [review] setError leaves subtype at its default success, so an error-only envelope is rewritten and the consumer's mes…packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/cli/session/Session.java:248 — [review] The documented null onControlRequestTimeout fallback to the session's 60 seconds is exercised by no test
Convergence: round 4 posted 1 inline comment(s), 1 of them reported for the first time; the previous round posted 4 (4 new). Findings keep coming back to the same files: packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/cli/session/Session.java (findings in round 3; 1 more now). A cluster that keeps producing siblings usually means the fixes are treating instances of a shared root cause — triaging that cause before the next round, or splitting an independent cluster into its own pull request, tends to end the loop faster than fixing them one at a time. (Observation only — nothing was withheld from this review because of this observation.)
中文说明
已审查——无阻断问题。 建议见行内评论。
收敛姿态下延后(第 4 轮,非阻断)——已记录,本轮不要求修改:共 2 条(原文未翻译,列表见上方英文部分)。
收敛情况:第 4 轮发布了 1 条行内评论,其中 1 条是首次提出;上一轮发布了 4 条(其中 4 条首次提出)。发现反复回到同一批文件:packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/cli/session/Session.java(第 3 轮已出过发现,本轮又有 1 条)。一个不断再生兄弟发现的簇,通常意味着逐条修复只在处理同一根因的实例——先定位并处理该根因,或把独立的簇拆成单独的 PR,通常比逐条修复更快结束循环。(仅为观察——本轮评审未因此扣留任何内容。)
— deepseek-v4.1-flash-1017 via Qwen Code /review (v0.27.2)
qwen-code-review-bot
left a comment
There was a problem hiding this comment.
Reviewed. Suggestions are inline.
Not explored to full depth (tool budget reached): "agent reverse-audit (round 7)": no javac/javap bytecode measurement of the grown sendPrompt consumer lambda — target/classes exists in the tree but assembling the fastjson2/slf4j/commons-l….
Deferred under the convergence posture (round 5, not a blocker) — recorded, not requested in this round:
packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/cli/session/Session.java:264 — [review] timeout-provider and deserialization failures are reported as control-request handler failurespackages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/cli/session/Session.java:262 — [review] an interrupted wait is reported as a handler failure and the interrupt flag is lostpackages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/cli/session/Session.java:276 — [review] an error subtype carrying no error value is forwarded and the CLI rejects with "Unknown error"packages/sdk-java/qwencode/src/test/java/com/alibaba/qwen/code/cli/session/SessionControlRequestTest.java:329 — [review] assertErrorResponse never checks that the rejected payload is dropped, so envelope reuse survives the suitepackages/sdk-java/qwencode/src/test/java/com/alibaba/qwen/code/cli/session/SessionControlRequestTest.java:98 — [review] three error-branch tests leave their CLI-visible message literals unpinnedpackages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/cli/session/Session.java:265 — [review] nothing pins that the SDK log keeps the throwable the wire text points atpackages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/cli/session/Session.java:264 — [review] getSimpleName() is empty for an anonymous throwable, so the wire error reads "failed ()"
Convergence: round 5 posted 1 inline comment(s), 1 of them reported for the first time; the previous round posted 1 (1 new). Findings keep coming back to the same files: packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/cli/session/Session.java (findings in round 4; 1 more now). The rate of new findings is not falling. A cluster that keeps producing siblings usually means the fixes are treating instances of a shared root cause — triaging that cause before the next round, or splitting an independent cluster into its own pull request, tends to end the loop faster than fixing them one at a time. Batching the remaining fixes and verifying them before the next push, or dropping this PR's reviews to --severity-floor critical, keeps the loop from re-deriving the same set. (Observation only — nothing was withheld from this review because of this observation.)
中文说明
已审查。 建议见行内评论。
未探索到全部深度(达到工具调用预算):"agent reverse-audit (round 7)":no javac/javap bytecode measurement of the grown sendPrompt consumer lambda — target/classes exists in the tree but assembling the fastjson2/slf4j/commons-l…。
收敛姿态下延后(第 5 轮,非阻断)——已记录,本轮不要求修改:共 7 条(原文未翻译,列表见上方英文部分)。
收敛情况:第 5 轮发布了 1 条行内评论,其中 1 条是首次提出;上一轮发布了 1 条(其中 1 条首次提出)。发现反复回到同一批文件:packages/sdk-java/qwencode/src/main/java/com/alibaba/qwen/code/cli/session/Session.java(第 4 轮已出过发现,本轮又有 1 条)。新发现的产出速度没有下降。一个不断再生兄弟发现的簇,通常意味着逐条修复只在处理同一根因的实例——先定位并处理该根因,或把独立的簇拆成单独的 PR,通常比逐条修复更快结束循环。把剩余修复攒成一批、验证后再推送,或将本 PR 的评审降到 --severity-floor critical,可以避免循环反复推导同一组发现。(仅为观察——本轮评审未因此扣留任何内容。)
— deepseek-v4.1-flash-1017 via Qwen Code /review (v0.27.2)
|
PR 17113 round 1 verification — Verdict: merge-ready — 202/202 scripted assertions passed, 0 failed. Verified head: 中文摘要结论:merge-ready。 202 条脚本断言全部通过;Java SDK 的控制请求失败回包在 head 上成为 CLI 可识别、可关联原请求的 error,base 则留下无人接管的 pending 请求(缺 ID 时)或错误地结算另一条待处理请求(ID 错配时)。 A/B 表显示 15 个场景中 14 个的消费者可观察结果改变,31 个请求结算格中 15 个改变;唯一的对照格 非阻塞发现一条(Low): 未覆盖:真实 CLI 进程/真实模型轮次、macOS/Windows、上游 Java CI 车道(该 workflow 不在 PR 上触发)、与 CLI 60s/30s 期限的真实计时竞态、 ScopeCentral claim. When a custom Secondary claims. (1) The shipped simple consumers keep their two-layer fallback: an inner permission timeout returns the deny behavior, an inner other-control timeout returns an empty non-null payload, and only the outer wait expiring emits a timeout error. (2) The exception's reported type is the host handler's own type, its message stays in the SDK log rather than the wire, and a cyclic cause chain terminates. A/B: load-bearing proofThe harness is an independent Java program compiled against each arm's production classes. It drives the real Every scenario emitted exactly one frame (two for the two-request scenario), the handler ran exactly once per request (twice for two requests), and the result line was consumed in every head cell.
Labels: Counts: base arm 99/99, head arm 103/103, total 202/202. 14 of 15 scenarios change their consumer-visible outcome; 15 of 31 request-settlement cells change. The only unchanged scenario is the valid-success control (row 10). Row 7 is the sharpest base defect: a handler reply carrying another request's ID resolves that unrelated request in the CLI while the original stays pending. Witness: Counterfactual and mutation matrixPrevious-head counterfactual. The candidate suite was copied unchanged onto With the candidate production code the same suite is 21/21. This reproduces the author's stated counterfactual on the exact commits. Mutation matrix. Thirteen one-shot mutations were applied to the head
13/13 killed, 0 survived. Restore check: Witness: Targeted gates
The +22 head tests over base are exactly the 21 new Witness: Environment event, A/A-controlled. The first base full-suite run hit Existing review findings
The last review comment records the #17174 follow-up for the wrapper-ownership note. None of the 16 threads is a blocker, and none was left FindingsF1 — Low, non-blocking: a throwing
|
yiliang114
left a comment
There was a problem hiding this comment.
Expert review of the control callback error handling change. The Session now validates every callback result — null returns, empty envelopes, missing/wrong request IDs, unknown subtypes, and success without a payload all produce a correlated error with the original request_id. Exception unwrapping is correctly bounded to two layers (ExecutionException → RuntimeException → actual cause), the wire error names only the exception type (not the message), and full details stay in SDK logs. Default inner/outer timeout layering is preserved, and the README documents the relationship between SDK and CLI deadlines clearly.
Test coverage is thorough: SessionControlRequestTest exercises all seven declared failure modes, the real default producers (permission denial + empty other-control payload), inner/outer timeout layering, cyclic cause unwrapping, request ID echo from the deserialized request, and valid response passthrough. The ProcessTransport characterization test documents the existing read-loop limitation without claiming it is fixed — scope is clearly bounded.
No P0 or P1 findings. All bot review suggestions from earlier rounds have been addressed at the current head. Fork CI evidence shows 21/21 control-request tests, 0 Checkstyle violations, and successful Java 11 release compilation.
中文说明
专家级 review:控制回调异常处理逻辑正确,校验链覆盖 null/空封装/ID 不匹配/无内容 success/未知子类型等全部声明的失效模式;异常解包限两层、线报只含异常类型名不含文本、完整栈保留在 SDK 日志;默认超时分层不变。测试覆盖充分:21 个用例覆盖所有失效模式 + 真实 producer + 超时分层 + 循环 cause + ID 回显。无 P0/P1 发现。
|
The remaining gate is closeout evidence. This changes protocol behavior ( |
|
|
Released in v0.27.4. |



What this PR does
Sends a correlated error response when a legacy Java SDK control-request callback throws, times out, returns null or an empty envelope, omits or mismatches the incoming request ID, uses an unknown response subtype, or returns success without a response payload. The error carries the incoming request ID, the error subtype and an error value. Valid success responses and valid error responses without a success payload pass through unchanged.
Why it's needed
The original fallback could serialize only
{"type":"control_response"}, which the CLI's actual message guard rejects because it lacksresponse. An initialized but empty inner envelope is a different case:{"type":"control_response","response":{"subtype":"success"}}has a default success subtype but no request ID or payload. Merely checking that the outer response exists leaves that case, mismatched IDs and payload-free success responses unchecked.A missing ID leaves the original request pending; a wrong ID can settle another pending request; success without a payload can resolve the request without its required result. The fix checks correlation, the closed
success/errorsubtype set and the success payload before writing, and gives malformed callback results a usable error envelope for the original request. The response model also gains the protocol's optional error field.Unexpected handler failures report the host callback's exception type after removing the asynchronous execution envelope and the SDK's single wrapper. The handler's own exception and cause remain intact; its message and full cause chain stay in SDK logs. This fixed two-layer boundary also avoids traversing a cyclic host cause chain. Outer callback timeouts name the configured budget. Controlled validation errors retain useful diagnostics, including expected and returned request IDs.
The default consumer has two timeout layers. An inner permission callback timeout is logged and returns an ordinary success envelope with the default deny behavior; an inner other-control timeout returns success with an empty, non-null payload. These inner fallbacks do not emit a timeout error. Only expiry of the outer control-request wait produces the correlated timeout error. The default outer limit is 180 seconds and the inner limits are 60 seconds; the Session fallback is 60 seconds when the outer timeout method returns null.
CLI deadlines depend on the request path: leader and workflow tool approvals default to 60 seconds unless configured otherwise; teammate approvals use the generic 30-second deadline. Configure the outer SDK limit below the shortest applicable CLI deadline with time for delivery. Inner limits below the outer limit allow their normal fallback replies to settle first; an outer timeout instead produces an error and can discard a later inner approval. This change preserves existing timeout defaults and fallback policies.
Reviewer Test Plan
How to verify
ControlDispatcherwith the original and an unrelated request pending. Confirm malformed callback results reject the original request and leave the unrelated request pending. Valid success and valid error responses must still settle the original request normally.ProcessTransportsubprocess fixture, close its input writer during a control callback, and confirm the existing read-loop behavior:sendPromptreturns without consuming a result. This characterizes the separately tracked asynchronous-wait limitation, not a write-error propagation guarantee.request_idannotation must turn this test red.At the preceding head
839d8cd3298121b6e6b4b050a69b5a62efaed86b, native Linux validation reported 449 tests, 0 failures, 0 errors and 9 conditional skips (440 executed successfully), zero Checkstyle violations, and successful packaging. That preceding revision's maintained control-request suite passed 20 tests. Java 11 release compilation is unchanged.Preceding hosted validation passed for exact commit
839d8cd3298121b6e6b4b050a69b5a62efaed86b. The Java job passed on Linux with Temurin 21.0.13 and Maven 3.9.15: 449 tests, 0 failures, 0 errors and 9 skips (440 executed successfully), zero Checkstyle violations and successful packaging. Its control-request suite passed all 20 cases. A separate Node.js 22.23.4 job passed the full workspace build, all workspace/integration type checks, README formatting and a clean-source check. The nine conditional Java skips remain one Windows-specific ProcessTransport case and eight daemon/managed-runtime end-to-end cases. This is fork validation; upstream workflow authorization remains separate.For the current two-file follow-up at
7408a7fe20febe0f1d2f4cc2316a62eb82921234: Hosted Java validation passed on Linux with Temurin 21.0.13 and Maven 3.9.15: 450 reported tests, 441 executed successfully, 9 conditional skips, 0 failures and 0 errors, zero Checkstyle violations and successful packaging. The control-request suite passed 21/21, with the Java 11 release target unchanged. The hosted counterfactual restored only the preceding Session source while retaining the new regression and produced exactly one direct assertion failure, 0 errors and 0 skips. Restoring the exact candidate returned the control suite to 21/21 and left the source clean. Separate workspace validation passed on Node.js 22.23.4 with pnpm 11.24.0: frozen dependency installation, the full workspace build, all workspace/integration type checks and a clean-source check.Evidence (Before & After)
The earlier wire-contract validation used an independent Java fixture running the real Session callback dispatcher and serializer over a controlled in-memory transport. Its emitted JSON passes through the actual TypeScript CLI
isControlResponseguard andControlDispatcher.handleControlResponse, with two pending requests registered through the real registry.The unchanged five-case fixture produced three failures and two passing controls before, then five passes after. The earlier three-case fixture for throwing, null and successful callbacks also passed after the initial fix; that earlier fixture checked wire shape and CLI guard acceptance. Neither fixture is a separately timed 60-second stall or a live model run.
For the preceding follow-up, six independent native probes on
d4c3989gave four passing controls and two direct assertion failures: the fixture continued after a stop signal, and a two-node cause cycle left the reader running with no reply. At839d8cd, those unchanged probes passed 6/6: one callback after a stop signal, and a terminated reader with one correlated error and a consumed result after the cyclic exception. The real default producer, inner permission denial, inner other-control empty payload and outer timeout controls keep their observed behavior.That preceding follow-up also used five temporary mutations, each producing exactly one target assertion failure and no test errors: remove the cause-depth bound; omit the permission producer's request ID; omit its payload; remove the implicit success subtype; or stop reading immediately after the control request. All source files were restored to that preceding revision's blobs. The restored focused suites reported 23 tests, 0 failures, 0 errors and 1 Windows-specific skip (22 executed successfully).
For the wrapper-boundary regression, the new maintained test fails on unchanged
839d8cdwith one direct assertion failure: expected RuntimeException, observed IllegalStateException. After the fix, all 21 control-request cases pass, including the real default producers, inner fallback, outer timeout and cyclic-cause controls. Restoring only the old Session source with the candidate test retained reproduces the same single failure; restoring the candidate returns the control suite to 21/21. The initial combined control/ProcessTransport run reported 24 tests, 23 executed successfully and one Windows-specific skip, with no failures or errors. The unchanged two-case independent native probe changed from one direct assertion failure and one passing control at839d8cdto 2/2 passes with the candidate, with zero errors or skips; it verifies the serialized exception types, correlation and continued result consumption through the real Session.Tested on
Environment
Current native Java validation uses Zulu JDK 21.0.13 and Maven 3.9.15, with the module's unchanged
--release 11compilation target. The earlier CLI consumer fixture used Node.js v24.22.1. Tests use isolated temporary files, controlled transports and the module's HTTP fixtures; live provider integrations are not enabled.Risk & Scope
ProcessTransportread loop currently swallows internal callback write failures and can return without a result. That broader behavior remains a separate follow-up; this PR changes no transport API or read-loop implementation.Linked Issues
Refs #8835, specifically java-session-control-request-fallback-response-dropped-by-cli.
The separate transport limitation is tracked under java-runnable-runandwait-swallows-timeout.
中文说明
此 PR 的改动
当旧版 Java SDK 的控制请求回调抛错、超时、返回 null 或空封装、遗漏或错用收到的请求编号、使用未知响应子类型,或返回缺少实际内容的成功响应时,发送能够关联原请求的错误响应。回包包含收到的请求编号、错误子类型和错误值。有效的成功响应,以及不含成功内容的有效错误响应,仍原样发送。
为什么需要
原兜底逻辑可能只序列化
{"type":"control_response"},CLI 的实际消息识别函数会因缺少response拒绝它。已经初始化但内容为空的内层封装是另一种情况:{"type":"control_response","response":{"subtype":"success"}}带有默认成功子类型,却没有请求编号和实际内容。仅检查外层响应是否存在,无法防住这种空封装、错误编号和缺少内容的成功响应。缺少编号会让原请求继续等待;错用编号可能结束另一个待处理请求;没有内容的成功响应可能让请求在缺少所需结果时被错误完成。本次修复在写入前校验关联关系、
success/error封闭子类型集合和成功内容,将这些无效回调结果转换为针对原请求的可用错误封装。响应模型同时补充协议中的可选错误字段。非预期的宿主回调异常只移除异步执行封装及 SDK 加入的一层包装,然后报告宿主 handler 自身抛出的异常类型;不继续剥离 handler 自己的异常及其 cause。宿主异常文本和完整原因链保留在 SDK 日志。固定的两层解包也避免遍历宿主的循环 cause 链。外层回调超时明确写出配置的预算。受控的校验错误保留必要诊断,包括期望及实际返回的请求编号。
默认消费者有两层超时。内层权限回调超时会记日志,并返回带默认拒绝行为的普通成功封装;内层其他控制回调超时返回带空但非 null 内容的成功封装。这两类内层兜底都不发送超时错误。只有外层控制请求等待到期才产生关联超时错误。默认外层期限为 180 秒,内层为 60 秒;外层 timeout 方法返回 null 时,Session 使用自身 60 秒兜底。
CLI 的期限取决于请求路径:leader 和 workflow 的工具审批默认 60 秒,可配置覆盖;teammate 审批使用通用 30 秒期限。外层 SDK 期限应小于所服务路径中最短的 CLI 期限,并留出传输时间。内层先于外层到期时发送原有兜底回包;外层先到期则产生错误,并可能丢弃内层稍后给出的授权。本次修改保留已有默认超时和兜底策略。
审阅者验证计划
如何验证
ControlDispatcher,同时登记原请求和一个无关的待处理请求。确认无效回调结果拒绝原请求,并让无关请求保持等待;有效成功和有效错误仍按原有方式结束原请求。ProcessTransport子进程夹具,在控制回调中关闭输入 writer,确认现有读取循环的行为:sendPrompt正常返回,但没有消费结果。这记录单独跟踪的异步等待限制,不宣称写入异常已能够向外传播。request_id注解后,该测试必须失败。前一提交
839d8cd3298121b6e6b4b050a69b5a62efaed86b的原生 Linux 验证报告 449 项测试、0 失败、0 错误、9 项条件跳过(440 项实际执行通过),Checkstyle 零违规,打包成功。该提交的控制请求定向套件通过 20 项测试;Java 11 release 编译目标保持不变。前一轮托管验证已针对精确提交
839d8cd3298121b6e6b4b050a69b5a62efaed86b通过。Java 任务在 Linux、Temurin 21.0.13 和 Maven 3.9.15 下通过:449 项测试、0 失败、0 错误、9 跳过(440 项实际执行通过),Checkstyle 零违规,打包成功;其中控制请求套件 20/20 通过。独立的 Node.js 22.23.4 任务完成全仓构建、全部 workspace/integration 类型检查、README 格式和源码未改动检查,均通过。 九项 Java 条件跳过仍是一项 Windows 平台测试和八项 daemon / managed-runtime 端到端测试。这是 fork 验证,上游工作流授权仍独立处理。当前两文件跟进的精确提交为
7408a7fe20febe0f1d2f4cc2316a62eb82921234:托管 Java 验证已在 Linux、Temurin 21.0.13 和 Maven 3.9.15 下通过:报告 450 项测试,441 项实际执行通过,9 项条件跳过,0 失败、0 错误;Checkstyle 零违规,打包成功。控制请求套件 21/21 通过,Java 11 release 目标保持不变。托管反例仅恢复前一版 Session 源码并保留新增回归,恰好产生 1 项直接断言失败、0 错误、0 跳过;恢复精确候选后控制套件重新 21/21 通过,源码保持干净。独立 workspace 验证已在 Node.js 22.23.4、pnpm 11.24.0 下通过锁定依赖安装、全仓构建、全部 workspace/integration 类型检查和源码未改动检查。修改前后证据
此前的线协议验证使用独立 Java 夹具,在受控内存传输上运行真实 Session 回调分发及序列化,再将输出 JSON 交给真实 TypeScript CLI 的
isControlResponse和ControlDispatcher.handleControlResponse;两个待处理请求通过真实 registry 登记。相同五项夹具在修改前为 三项失败、两项对照通过,修改后 五项全部通过。此前针对抛错、null 和成功回调的三项夹具,在初次修复后也全部通过;此前夹具验证的是实际序列化形状和 CLI 识别函数接受情况。两套夹具均不宣称另行计时了 60 秒卡顿或运行了真实模型。
此前针对
d4c3989的六项独立原生 probe 得到 四项对照通过、两项直接断言失败:夹具在要求停止后继续调用;两个异常构成的 cause 环使读取线程持续运行且没有回包。该轮相同 probe 在839d8cd上 6/6 通过:停止信号后只调用一次;循环异常后读取线程终止、发送一条关联错误并消费结果。真实默认 producer、内层权限拒绝、内层其他控制空内容,以及外层超时对照均保留原行为。前一轮的五项临时变异每项均恰好触发一个目标断言失败,且没有测试 error:移除 cause 遍历上限、遗漏权限 producer 的请求编号、遗漏其内容、移除隐式 success 子类型、或在控制请求后提前停止读取。该轮所有源文件均已恢复并与
839d8cd的 blob 一致。恢复后的定向套件报告 23 项测试、0 失败、0 错误、1 项 Windows 平台跳过(22 项实际执行通过)。针对本轮包装边界回归,新增的维护测试在未修改的
839d8cd上恰好产生一个直接断言失败:期望 RuntimeException,实际为 IllegalStateException。修复后 21 项控制请求测试全部通过,其中包括真实默认 producer、内层兜底、外层超时和循环 cause 对照。仅恢复旧 Session 源码、保留候选测试后,同一用例再次单独失败;恢复候选后控制套件重新 21/21 通过。最初合并运行控制请求和 ProcessTransport 套件报告 24 项测试、23 项实际执行通过、1 项 Windows 条件跳过,0 失败、0 错误。原封不动的两项独立原生 probe 从839d8cd上的一项直接断言失败、一项对照通过,变为候选上的 2/2 通过,0 错误、0 跳过;它经真实 Session 检查序列化后的异常类型、请求关联及继续消费结果。测试平台
环境
本次原生 Java 验证使用 Zulu JDK 21.0.13、Maven 3.9.15,保留模块的
--release 11编译目标。此前的真实 CLI 消费方夹具使用 Node.js v24.22.1。测试使用隔离临时文件、受控传输及模块内 HTTP 夹具,未启用真实提供方集成。风险与范围
ProcessTransport读取循环目前会吞掉内部回调写入异常,并可能在没有消费结果时正常返回。该较广的行为单独跟进,本 PR 不改变 transport API 或读取循环实现。关联问题
关联 #8835 中的 java-session-control-request-fallback-response-dropped-by-cli 条目。
独立的传输层限制由 java-runnable-runandwait-swallows-timeout 条目跟踪。