Skip to content

fix(managed-agent): close shell profiles after native file calls - #14045

Merged
doudouOUC merged 1 commit into
QwenLM:mainfrom
doudouOUC:fix/hosted-native-file-close
Oct 13, 2026
Merged

doudouOUC merged 1 commit into
QwenLM:mainfrom
doudouOUC:fix/hosted-native-file-close

Conversation

@doudouOUC

Copy link
Copy Markdown
Collaborator

What this PR does

Shell-profile Sessions can close after native Read, Write, Edit or Glob calls. The close verifier identifies a native file invocation from its committed input, original Harness/Runtime Session identities and exact reserved payload digest, while retaining the existing settled-execution and Shell output receipt checks. This also adds a public regression on both API surfaces and recognizes distro-packaged MySQL in the Linux acceptance fixtures through JDBC product metadata.

Why it's needed

Ordinary native file calls save their results and history without producing an O3 Shell capture receipt. The close verifier incorrectly required that receipt from every invocation in a Shell profile, leaving a file-only Write/Read Session in CLOSING with workspace_lifecycle_resources_unsettled. The same defect blocked closing a Session after a successfully cancelled foreground Shell and a later Read.

Reviewer Test Plan

How to verify

Run the Linux Hosted public integration gate against disposable MySQL and the packaged CLI. Verify that a Shell-profile Session executes native Write/Edit/Read on both API surfaces, then closes, stops the original durable worker, releases its owner and preserves readable history. Verify that foreground Shell allow/deny still behaves correctly. The focused lifecycle tests must continue refusing unknown executions, mismatched identities/digests, corrupt or uncommitted inputs, and Shell/v3/publication calls missing their receipts.

Locally, the two lifecycle unit suites passed 98 tests with no skips, Java packaging and SpotBugs passed, the independent file-only reproduction and running Shell cancellation→same-Session Shell/Read→close loop passed, and the existing seven public integration cases passed. The new native-close regression and original Shell allow/deny passed together as three cases with no skips. Exact selectors and the Linux acceptance scope are recorded in the separate E2E report comment.

Evidence (Before & After)

Before: a Shell-profile Session with two settled native file calls and no Shell capture sources admitted close but remained RECOVERY_BLOCKED with workspace_lifecycle_resources_unsettled. After: the same Write/Read flow completes close with zero Shell capture sources. The full cancelled-Shell flow also completes close, stops the original worker and retains 71 durable resource identities/hashes and public history.

Tested on

OS Status
🍏 macOS ⚠️ not tested
🪟 Windows ⚠️ not tested
🐧 Linux ✅ tested

Environment (optional)

Ubuntu 26.04 arm64 in a Lima VM, Linux 7.0.0-38-generic, Node 22.22.1, OpenJDK 21.0.12.1, native MySQL 8.4.11 and Maven 3.9.14. Model calls use deterministic fixtures and Shell output collection uses the MySQL inline OSS adapter. Production baseline: main d8558bb plus this fix; the CLI artifact is unchanged.

Risk & Scope

  • Main risk or tradeoff: accepting a file invocation with the wrong identity could weaken lifecycle closure; the committed-resource reader, original Session identities, exact payload digest, explicit file-tool allowlist and settled ledger remain required.
  • Not validated / out of scope: real model providers, external OSS, MariaDB, Windows, macOS and optional team/background/Monitor/MCP/CSI/MQ/retention capabilities. Lifecycle v2 advertisement remains opt-in.
  • Breaking changes / migration notes: none; no schema or public contract changes. The English design and Chinese design include the same native-file closure rule and acceptance criteria.

Linked Issues

Related to #12380.

中文说明

本 PR 做了什么

Shell profile 的 Session 在调用原生 Read、Write、Edit 或 Glob 后可以完成关闭。关闭校验通过已提交输入、原 Harness/Runtime Session 身份和精确的预留请求摘要识别文件调用,同时保留原有的执行结算和 Shell 输出收据检查。本 PR 还加入覆盖两个公开 API 入口的回归,并用 JDBC 数据库产品元数据识别 Linux 验收夹具中的发行版 MySQL。

为什么需要

普通原生文件调用保存结果与历史,不产生 O3 Shell capture receipt。原关闭校验错误地要求 Shell profile 的每个调用都有该收据,使仅执行 Write/Read 的 Session 卡在 CLOSING,并返回 workspace_lifecycle_resources_unsettled。同一缺陷也使已成功取消前台 Shell、随后执行 Read 的 Session 无法关闭。

评审测试计划

如何验证

在 Linux 上,用可丢弃 MySQL 和打包后的 CLI 运行 Hosted 公开集成门禁。核验 Shell profile 的 Session 经两个 API 入口执行原生 Write/Edit/Read 后可关闭、停止原 durable worker、释放其持有者,并保留可读取历史。核验前台 Shell 的允许/拒绝仍正确。聚焦生命周期测试必须继续拒绝未知执行、身份/摘要不匹配、损坏或未提交的输入,以及缺少收据的 Shell/v3/publication 调用。

本地两个生命周期单测套件共 98 个测试通过且无跳过,Java 打包与 SpotBugs 通过;独立文件调用复现和运行中 Shell 取消→同 Session Shell/Read→close 闭环通过,原有七个公开集成用例通过。新增 native-close 回归与原 Shell 允许/拒绝一起执行,共三个用例通过且无跳过。精确 selector 与 Linux 验收范围记录在独立 E2E 报告评论中。

证据(修改前后)

修改前:Shell profile 的 Session 有两个已结算原生文件调用且没有 Shell capture source,close 准入后仍停留在 RECOVERY_BLOCKED,错误为 workspace_lifecycle_resources_unsettled。修改后:同一 Write/Read 流程在没有 Shell capture source 的情况下完成 close。完整的 Shell 取消流程也能完成 close、停止原 worker,并保留 71 个持久资源身份/摘要及公开历史。

测试平台

OS 状态
🍏 macOS ⚠️ 未测试
🪟 Windows ⚠️ 未测试
🐧 Linux ✅ 已测试

环境(可选)

Lima VM 中的 Ubuntu 26.04 arm64、Linux 7.0.0-38-generic、Node 22.22.1、OpenJDK 21.0.12.1、原生 MySQL 8.4.11 和 Maven 3.9.14。模型调用使用确定性夹具,Shell 输出清理使用 MySQL inline OSS 适配器。生产基线为 main d8558bb 加本修复;CLI 产物未改变。

风险与范围

  • 主要风险或权衡:错误识别文件调用身份可能削弱生命周期关闭校验;仍要求已提交资源读取器、原 Session 身份、精确请求摘要、明确文件工具名单和已结算台账。
  • 未验证或范围外:真实模型服务、外部 OSS、MariaDB、Windows、macOS,以及可选的团队/后台 Shell/Monitor/MCP/CSI/MQ/retention 能力。生命周期 v2 广告仍通过 opt-in 启用。
  • 破坏性变化或迁移说明:无;不修改 schema 或公开契约。英文设计 与 中文设计 包含相同的原生文件关闭规则与验收标准。

关联议题

关联 #12380。

@doudouOUC

Copy link
Copy Markdown
Collaborator Author

Linux E2E verification for head 1d9abdd94f03097d3278ba614963df1e57884dd9 (frozen production main d8558bba0198c1cdadac1523940c88c04b038f62 plus this fix):

  • Environment: Ubuntu 26.04 arm64, Linux 7.0.0-38-generic, Node 22.22.1, OpenJDK 21.0.12.1, native MySQL 8.4.11, Maven 3.9.14; deterministic model fixture and inline MySQL output adapter.
  • WorkspaceProfileLifecycleTest,WorkspaceLifecycleStoreTest: 98 tests passed, zero failures/errors/skips. Java packaging and SpotBugs passed with zero reported errors/warnings.
  • HostedPublicWorkspaceIT#shellProfileClosesAfterNativeFileToolsOnBothSurfaces+publicForegroundShellUsesMandatoryApprovalOnBothSurfaces: 3 tests passed, zero skips, 19.88 seconds. Native Write/Edit/Read on both API surfaces completes close with two CLOSED Shell-profile Sessions and zero O3 sources; original durable workers disappear, registrations become RETIRED, bindings/holders become RELEASED and durable history remains readable. Original foreground Shell allow/deny passes.
  • HostedPublicWorkspaceIT#publicCreationRunsFilesThroughProductionWorkspaceBinding+ownerAnswersHostedApprovalsThroughBothSurfaces+publicForegroundShellUsesMandatoryApprovalOnBothSurfaces+durableCloseStopsOriginalWorkersAndRetainsHistoryAndFiles+publicShellV2DeletionTriggersCollectionWithoutRetirementSeams: all 7 cases passed, zero skips, 181.993 seconds. Physical deletion collected 539 inline bytes per API surface while the companion Session remained intact.
  • Independent public running-Shell fixture: parent/child/process-group death after cancellation, committed cancelled capture, same-Session approved Shell plus native Read, then successful close and physical original-worker retirement. All 71 durable resource identities/hashes and public history were read back unchanged. The original failing baseline and candidate logs were kept separately.

Failsafe execution used -Phosted-harness-mysql -DskipTests=false with the exact selectors above and the packaged CLI. No result is inferred from a disabled/skipped integration suite. Candidate server SHA256: b34000183d871e58026631ff10fb8eacc5966106c4b49f8d95737ee2512ee030; unchanged CLI SHA256: dd745c76f408dda788f917391f435d99ad9e49b735cfb8e846fae4ae431380bc.

These are local Linux results, not CI or production acceptance. Real model providers, external OSS, MariaDB, Windows/macOS, multi-instance recovery and optional team/background/Monitor/MCP/CSI/MQ/retention paths are outside this report. The broader real-VM-reboot continuation gate is still being investigated independently and is not claimed as passing by this PR.

中文:以上为该 head 的本地 Linux 验收:98 个生命周期单测、SpotBugs、3 个新增回归及 Shell 允许/拒绝用例、原 7 个公开集成用例全部通过且没有跳过;运行中 Shell 的进程树取消、同 Session 续轮、关闭、物理退役和 71 个持久资源摘要读回也通过。该报告不代表 CI 或生产验收;真实 VM 重启后的原 Turn 续轮仍在单独调查,未计为通过。

@doudouOUC
doudouOUC force-pushed the fix/hosted-native-file-close branch from 1d9abdd to 847cb8c Compare October 13, 2026 11:21
@github-actions

Copy link
Copy Markdown
Contributor

Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration.

中文

请勿对活跃的 PR 执行 rebase 或 force-push,因为这会使已有的评审评论失效。另外,供日后参考:作为集成流程的一部分,机器人始终会自动将所有改动压缩(squash)为单个提交。

@doudouOUC

Copy link
Copy Markdown
Collaborator Author

Rebased to current main 07461c0e575f6b61da675538299df78d730b593f to incorporate the updated lint gate; new head is 847cb8c90b. The eight-file patch is unchanged. The earlier Linux E2E report refers specifically to the frozen d8558bba production baseline plus this fix and retains its original artifact hashes; it is not a claim that newly merged MQ2b/team-plan/file-history changes were included in that local run. Exact-head CI is now re-running under the current gate.

中文:已同步最新 main 的 lint 门禁,8 文件修复补丁不变。前述 Linux 验收明确基于固定 d8558bb 加修复,未将之后合入的 MQ2b、团队计划审批和文件历史门禁改动计入本地验收;新 head 的 CI 正在重新运行。

@doudouOUC

doudouOUC commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator Author

Linux Hosted core acceptance — final combined candidate

All 11 independent final runs passed: 3 real VM reboot arms, 1 public API run (8 JUnit cases, 0 failures/errors/skips), 1 running foreground Shell loop, and all 6 canonical G3 modes (allow, deny, cancel, expiry, continuation, freeze). These are 8 JUnit cases plus 10 fully executed standalone script scenarios. Repeated historical baseline runs are excluded from this final count.

The frozen production baseline is main 07461c0e575f6b61da675538299df78d730b593f plus the native-file close fix in #14045 (847cb8c90bcabcc7b2385bbaaaeb716a4b9f5705) and the bounded retired-result continuation fix in #14059 (2fbe5a0b8b647d9ad990e0e44aea5c17a655ee2a). Linux source/test parity was verified against both exact PR heads. Each PR contains its independent fix; neither isolated branch is claimed to include both. Later main additions #13952/#14014 were not included in this frozen candidate.

  • Linux CLI entry (dist/cli.js) SHA256: 5da2cc412718265bfda7f60f2ebf657c14da1df958f721d10263374d6d6f0178.
  • Linux server SHA256: 1bbee385e0474bd09dd2a343540d9ef02737a980fd16a9d88e4fabd98acf38ca.
  • Complete CLI bundle: all 1,709 archived dist/ file hashes were verified. Canonical file-hash map SHA256 is eb0a5e06474cebeb782cc01d2b3057be228a532f115a5d05c25185ccc2a3615a; archive SHA256 is 309ffe5d69b86d22a7db3ba778ec18e39fcb37836a2b20cf6640aca6119b5108. The entry hash alone does not represent the code-split bundle.
  • Full build, bundle, typecheck and final focused ESLint passed. Recovery/tool-turn/file-history tests: 299/299 passed. Java lifecycle tests: 98/98 passed, 0 skips. SpotBugs reported 0 errors/warnings. Local verification is distinct from still-running exact-head CI.
  • Environment: Ubuntu 26.04 arm64 in Lima, kernel 7.0.0-38-generic, Node 22.22.1, OpenJDK 21.0.12.1, native MySQL 8.4.11 and Maven 3.9.14. A deterministic local model provider and MySQL inline OSS adapter are used; Java control plane, Broker, durable worker, packaged Harness, SQL state and physical files/processes are real.

Actual reboot evidence

Each arm began with a physically live original worker, held owner, SETTLED execution and dispatch generation 1. The parent independently read PID/start ticks, SQL, file bytes and boot identity before a force VM stop/start. The same MySQL datadir and original stored pin/deadline were retained; no business SQL was changed to admit recovery.

  1. Committed Edit: boot 3c8c0c35 → 44e42a09, Session da2c5f6a-907d-4093-a949-6bafbb5d503d. The exact saved model request completed; original Edit remained once with bytes xx. A new Write/Read Turn used Runtime generation 2; replaying the old release could not clear its actual holder. Public close physically retired the new worker and retained history.
  2. Immediate new physical call after recovery: boot 44e42a09 → 67d3a33a, Session c81f1660-4a30-454e-9ccf-aa59e588ea87. The valid new Write was refused before acquisition/dispatch with no new execution/file. The original Turn became a known FAILED result while the Session stayed ACTIVE. The next Write/Read Turn and physical close passed, including old-release fencing.
  3. Read-only without file history: boot 67d3a33a → e5a8232a, Session ca6afbc6-2a39-4170-a747-48d45aaf626f. File-history resource count was 0; original Read/result/dispatch and bytes x were unchanged. Saved request recovery, generation-2 next Turn, old-release fencing and physical close/history passed.

The final public API run passed 8/8 cases on both public surfaces, including the new native-file close regression under the Shell profile. The running Shell loop independently observed parent/child/process-group disappearance after cancel, complete/committed cancelled output, the same Session's next approved Shell/Read Turn, physical worker close and all 71 resource hashes/history retained. G3 freeze actually SIGCONT-resumed the old Harness and confirmed healthy but fenced behavior: generation-2 journal/boot/terminal/text and old-generation transaction count 21 were unchanged. Final /proc observation found no surviving Java/Node or temporary canonical MySQL processes.

Scope

Retired-result model continuation is limited to hosted-workspace-files/1 without Hooks/MCP and complete committed native results. New physical work in a retired original Turn requires a new Turn. Unknown effects, unreadable outcomes, missing Write/Edit history, ambiguous old release and Workspace generation drift remain blocked. This is single-instance local Linux qualification, not production deployment, real-provider/external-OSS acceptance, Shell/MCP/Hook cold recovery expansion, cross-host/multi-control-plane HA or bare-metal unflushed power-loss qualification.

中文验收说明

最终组合候选的 11 次独立运行全部通过:3 次真实 VM 重启、1 次公开 API(8 个 JUnit cases、0 失败/错误/跳过)、1 次运行中前台 Shell 和 G3 的 allow/deny/cancel/expiry/continuation/freeze 六模式。合计 8 个 JUnit cases 与 10 个全部实际执行的独立脚本场景,历史基线重复运行不计入最终数量。

固定 main 07461c0e 加 #14045 原生文件关闭修复及 #14059 限定的已提交结果恢复修复;Linux 文件已逐个核对两个 PR 精确 head。两个 PR 分别只含自身修复,单 PR 分支不等于组合候选。期间新合入的 #13952/#14014 不计入此次冻结候选。CLI/server SHA256 如上;完整 build/bundle/typecheck/最终 ESLint、299 个 CLI 测试、98 个 Java 生命周期测试与 SpotBugs 均通过。本地结果与仍在运行的 CI 分开记录。

三个真实重启分别验证已提交 Edit 续跑、恢复后请求新 Write 被明确拒绝、首次 Read 没有文件历史。每次重启前独立核验原 worker 的 PID/start ticks、持有者、SQL SETTLED/dispatch1、物理文件和 boot;使用同一 MySQL datadir 和未改动的 pin/deadline,未改业务 SQL 准入恢复。三个场景均保留原执行/结果、同 Session 下一 Write/Read Turn 使用 generation 2、旧清理不能清新 holder,公开 close 自身物理退役新 worker 并保留历史。新 Write 拒绝场景原 Turn 为已知 FAILED,而 Session 保持 ACTIVE。

公开 API 两种 surface 的 8 个案例通过;运行中 Shell 的父子进程与进程组取消、输出提交、同 Session 下一个已审批 Shell/Read、worker 物理关闭及全部 71 个资源身份/摘要与公开历史保留通过。G3 freeze 实际唤醒旧 Harness 并确认 health;新代 journal/boot/终态/文本和旧代事务数 21 均不变。最终 /proc 未发现残留 Java/Node 或 canonical 临时 MySQL。此为单实例 Linux 受控模型的功能/故障验收,不代表生产、真实模型/外部 OSS、Shell/MCP/Hook 冷恢复扩展、多主机/多控制面 HA 或裸机未刷新掉电验收。退役原 Turn 的新物理工作需要新 Turn;未知效果等证据不足路径保持阻塞。

@doudouOUC
doudouOUC requested review from qwen-code-review-bot and wenshao and a balanced review from Copilot October 13, 2026 13:36
@doudouOUC doudouOUC self-assigned this Oct 13, 2026
@doudouOUC
doudouOUC removed the request for review from Copilot October 13, 2026 13:36

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

Review

No blocking findings.
Approval blockers: none.


Scope

Reviewed:

  • WorkspaceProfileLifecycleVerifier.java — full file at HEAD, not diff-only
  • WorkspaceProfileLifecycleTest.java — new parameterized test (13 modes)
  • HostedPublicWorkspaceIT.java — new integration test and modelReply refactor
  • HostedHarnessMySqlIT, HostedProcessCrashIT, HostedWorkspaceToolTurnIT — MySQL-detection changes
  • Design docs (EN + ZH)

Not reviewed: macOS/Windows runtime behaviour (not tested by the PR, outside this scope). Working tree unavailable so execution rungs were not run.


Core logic — nativeFileInputs() and the bypass condition

Profile guard is correct. verifyResources calls if (!WorkspaceToolProfiles.SHELL.equals(profile)) { unsettled(); } before nativeFileInputs() is reached. The bypass is unreachable for MCP (returns early) and throws for every other profile. No surface for non-Shell profiles to exploit the new path.

Key format is consistent. nativeFileInputs adds runtimeSessionId + ":sha256:" + ToolPublicationContract.sha256(payload). The lookup in verifyResources builds execution.getRuntimeSessionId() + ":" + execution.getRequestDigest(). The stored requestDigest carries the "sha256:" prefix (confirmed by the test fixture and the design doc excerpt). The two sides produce the same string. ✓

Five-condition guard is layered correctly.

  1. sources.isEmpty() — no O3 receipt present
  2. dispatchMode == "deferred" — excludes streaming/protocol dispatch
  3. runtimeProtocol == null — excludes v3 deferred path
  4. publicationId == null — excludes publication-grant executions
  5. fileInputs.contains(...) — requires a committed, identity-verified, digest-matched managed-tool-input resource in the same Session

Any single condition failing keeps the execution blocked. The design doc's stated rule maps 1:1 to these guards.

call.size() == 2 check. Enforces the exact {toolName, input} payload structure. Intentional — prevents a Shell invocation with a mismatched payload from accidentally matching. Consistent with the protocol spec.

records field type. ManagedExtensionRecordStore is instantiated directly from jdbc in the constructor — no BeanProvider indirection; no NPE risk from missing bean.

Exception propagation. readRecordResource in nativeFileInputs is not wrapped in try-catch. This is consistent with the existing verifyEffects pattern (also unwrapped). A corrupt record throws ApiException which propagates out and blocks closure — correct behaviour, same as calling unsettled(). For the corrupt test mode this is confirmed by assertThatThrownBy(...).isInstanceOf(ApiException.class).


Test coverage

Unit test shellProfileNativeFileInputsRequireOriginalIdentityAndKnownSettlement (13 modes):

  • 4 acceptance paths: read_file, write_file, edit, glob
  • 9 rejection paths: wrong_digest, wrong_runtime, wrong_harness, shell, v3, publication, unreferenced, corrupt, unsettled

The rejection cases cover every bypass condition individually. The wrong_harness mode tests the harnessSessionId == operation.sessionId() identity check; unreferenced tests the state = 'REFERENCED' DB filter; corrupt tests the digest-integrity check in readRecordResource.

Integration test shellProfileClosesAfterNativeFileToolsOnBothSurfaces: exercises both API surfaces with shell=true, approvals=true, shellLifecycleV2=true, asserts 2 CLOSED sessions and zero lingering tool results. The modelReply runShell refactor correctly distinguishes prompts containing G0_SHELL from file-tool-only prompts.


MySQL-detection changes

The three IT files replacing @@version_comment string-contains checks with getMetaData().getDatabaseProductName() are straightforward — JDBC metadata is the canonical way to identify the connected database product and is more reliable than parsing @@version_comment (which varies across distro packages).


Cross-check against prior reviews

No prior reviews or inline comments found on this PR. Nothing to reconcile.


Unreviewed dimensions

  • macOS and Windows runtime behaviour: no host available, not exercised.
  • Execution-tier tests (mutation, non-vacuity probe): working tree unavailable. The author's report of 98 unit test passes and E2E confirmation is noted but not independently run.

Reviewed with AI assistance.

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

LGTM. At 847cb8c the new acceptance branch in WorkspaceProfileLifecycleVerifier (lines 132-137 / 261-284) admits a native file invocation only when it can identify it from committed input: a REFERENCED managed-tool-input whose wrapper names this harness session, whose bytes re-verify, and whose payload is {toolName,input} with toolName in the read_file/write_file/edit/glob allowlist — and only together with sources.isEmpty() and dispatchMode == "deferred" and runtimeProtocol == null and publicationId == null. A Shell/v2 call always carries inputDigest (→ runtimeProtocol: 3) and an O2/v3 publication carries publicationId, so both stay blocked, and a Shell payload digest cannot equal a file-tool digest.

No NPE: ToolExecutionRecord rejects a null reference in its constructor and hold(execution) already dereferences getReference() before the new branch. The digest key matches — getRequestDigest() is the sha256:<hex> digest of payloadJson that nativeFileInputs recomputes, and the runtime-session ids coincide. CI is green on this head. The new unit coverage pins the refusal directions (unknown execution, identity/digest mismatch, corrupt/uncommitted input).

@doudouOUC
doudouOUC added this pull request to the merge queue Oct 13, 2026
Merged via the queue into QwenLM:main with commit d0450a1 Oct 13, 2026
87 checks passed
@doudouOUC
doudouOUC deleted the fix/hosted-native-file-close branch October 13, 2026 14:06
@qwen-code-review-bot

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

Copy link
Copy Markdown
Collaborator

✅ Qwen Triage finished — view run. See the stage comments in this thread for the result.

✅ Qwen Triage 已完成 —— 查看运行。结果见本线程中的各阶段评论。

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Confidence: 4/5 — sound change, tightly guarded; recording it post-merge because this triage run finished after the PR landed.

This merged on 2026-10-13, before this run completed, so there is nothing left to gate: no approval, no request-changes, no close. The review below is for the record, in case anything warrants a follow-up.

What it does. WorkspaceProfileLifecycleVerifier.verifyResources demanded a capture/receipt source from every settled execution on a Shell profile. Native read_file/write_file/edit/glob calls store ordinary file results and never produce an O3 capture receipt, so a file-only Session sat in CLOSING with workspace_lifecycle_resources_unsettled. The fix adds one allow-path: an execution with no sources may satisfy closure when it is provably a native file call.

Why I'm comfortable with it. The allow-path is a six-way conjunction, and every branch fails closed:

  • dispatchMode == "deferred", no runtimeProtocol, no publicationId — v3, O2 and publication flows keep their existing receipt checks.
  • The input must be a REFERENCED managed-tool-input in the same session. readRecordResource → readCommittedResource → requireReference validates the committed bytes and digest, so corrupt, unreferenced or uncommitted inputs block.
  • harnessSessionId must equal the operation's session and runtimeSessionId must match the execution's — no cross-session or cross-owner reuse.
  • The execution's requestDigest must equal sha256: plus the digest of the stored payloadJson, so a Shell execution could only match by producing a SHA-256 collision against a file-tool payload.
  • The payload must be exactly {toolName, input} with toolName in the four-tool allowlist — the same canonical shape ManagedActionService.inputPreview already enforces, so this follows an existing convention rather than inventing one.

Two things I checked directly, because each could have made the fix silently inert or silently unsafe:

  • The continue sits after the isSettled() and hold/background checks in the loop, so unsettled executions still block. Read in the file, not inferred from the diff hunk.
  • requestDigest really does carry the sha256: prefix in production. ToolExecutionRecord's constructor forces requestDigest == reference.argsDigest for non-deferred_v3 modes, and the hosted harness writers build "sha256:" + hex (RuntimeBrokerService, SubmitHarnessTurn), with HostedHarnessClient requiring ^sha256:[0-9a-f]{64}$. Had that prefix been absent, the new branch would never match and the bug would survive behind a green suite — the unit test constructs the prefix itself, so it would not have caught that.

Design docs are updated in English and Chinese in the same change, with matching rules and acceptance criteria.

Non-blocking. nativeFileInputs() issues its FOR UPDATE query on every Shell-profile close, including sessions where no execution is missing sources. Negligible; not worth a follow-up.

Test evidence — the PR's own CI on the reviewed head.

Check Conclusion
Lint & Static (ubuntu-latest, Node 22.x) success
macos-latest / Java 21 success
windows-latest / Java 21 success
Real daemon E2E / Java 11 success
Integration Tests (no-AK, No Sandbox) success
Flyway migration version uniqueness success
Desktop Shell (ubuntu-22.04, windows-2022) success
Serve A/B (ubuntu-latest, Node 22.x) success
OpenTUI no-flicker gate success
TUI parity snapshots (ink vs opentui) success
Integration Tests (CLI, No Sandbox) skipped
Test (macos-latest / windows-latest, Node 22.x) skipped

97 check-runs on the head: 22 success, 75 skipped, 0 failures.

The gap worth naming: the new integration regression and the three MySQL fixture changes are @EnabledOnOs(OS.LINUX), and this head's Java matrix is macOS and Windows only — there is no Linux Java runner in the check set. Those tests were skipped by OS gate, not executed. The new WorkspaceProfileLifecycleTest case carries no OS gate, so it did run under the Java 21 jobs, and it covers the negative paths (wrong digest / wrong runtime / wrong harness / shell / v3 / publication / unreferenced / corrupt / unsettled) alongside the four allowed tools.

Not verified: the Linux acceptance run. The author reports 98 lifecycle tests passing plus a public integration gate on Ubuntu 26.04 arm64 with native MySQL 8.4.11 — that is their claim from a local environment, attributed as such and not re-run here. The usual remedy would be a sponsored @qwen-code /verify, but that lane refuses a PR that is not open, so it is unavailable now that this has merged; a maintainer who wants that coverage closed would need to run it manually in a disposable environment. This run executes no PR-derived code by design.

The MySQL fixture switch is from @@version_comment string matching to JDBC getDatabaseProductName(). In HostedHarnessMySqlIT that is strictly stronger (isEqualTo("MySQL") replaces containsIgnoringCase("mysql")) and the explicit MariaDB version guard is retained, so the MariaDB exclusion is not weakened by the change.

中文说明

信心度:4/5 —— 改动本身合理、防护严密;之所以现在才记录,是因为本次 triage 运行时 PR 已经合并。

本 PR 已于 2026-10-13 合并,早于本次运行结束,因此已无可把关的动作:不批准、不要求修改、不关闭。以下评审仅作记录,如需后续跟进可参考。

改了什么。 WorkspaceProfileLifecycleVerifier.verifyResources 原先要求 Shell profile 下每个已结算的执行都必须有 capture/receipt 来源。原生 read_file/write_file/edit/glob 调用保存的是普通文件结果,不产生 O3 capture receipt,因此只有文件调用的 Session 会卡在 CLOSING,并报 workspace_lifecycle_resources_unsettled。本修复新增一条放行路径:当某个无来源的执行能被证明是原生文件调用时,允许其满足资源关闭条件。

为什么可以放心。 这条放行路径是六个条件的合取,且每个分支都失败即阻塞:

  • 必须是 dispatchMode == "deferred"、无 runtimeProtocol、无 publicationId —— v3、O2 与 publication 流程仍走原有 receipt 校验。
  • 输入必须是同一 Session 中状态为 REFERENCED 的 managed-tool-input。readRecordResource → readCommittedResource → requireReference 会校验已提交的字节与摘要,因此损坏、未引用或未提交的输入都会被阻塞。
  • harnessSessionId 必须等于操作的 session,runtimeSessionId 必须与执行记录一致 —— 不能跨 Session 或跨持有者复用。
  • 执行记录的 requestDigest 必须等于 sha256: 加上所存 payloadJson 的摘要,因此 Shell 执行只有造出 SHA-256 碰撞才可能匹配到文件工具载荷。
  • 载荷必须恰好是 {toolName, input},且 toolName 在四个工具的白名单内 —— 这与 ManagedActionService.inputPreview 已有的规范形状一致,属于沿用既有约定而非另造一套。

有两点我特意直接核对过,因为它们任一出错都会让修复「静默失效」或「静默变松」:

  • 新增的 continue 位于循环中 isSettled() 与 hold/background 判断之后,因此未结算的执行仍会被阻塞。这是读源文件确认的,不是从 diff 片段推断的。
  • 生产环境的 requestDigest 确实带 sha256: 前缀。ToolExecutionRecord 构造函数在非 deferred_v3 模式下强制 requestDigest == reference.argsDigest,而 hosted harness 的写入方(RuntimeBrokerService、SubmitHarnessTurn)构造的是 "sha256:" + hex,HostedHarnessClient 也要求 ^sha256:[0-9a-f]{64}$。若该前缀不存在,新分支永远不会命中,缺陷会在测试全绿的表象下继续存在 —— 而单测自己构造了该前缀,因此无法发现这一点。

设计文档在同一次改动中同时更新了英文与中文版本,规则与验收标准一致。

非阻塞项。 nativeFileInputs() 在每次 Shell profile 关闭时都会发出一次 FOR UPDATE 查询,包括没有任何执行缺少来源的 Session。开销可忽略,不值得单独跟进。

测试证据 —— 被评审 head 上 PR 自身的 CI。 该 head 共 97 个 check-run:22 个 success、75 个 skipped、0 个 failure。

需要点明的缺口:新增的集成回归和三处 MySQL 夹具改动都带 @EnabledOnOs(OS.LINUX),而该 head 的 Java 矩阵只有 macOS 与 Windows,check 集合中没有 Linux Java runner。也就是说这些测试是被 OS 条件跳过,而非实际执行。新增的 WorkspaceProfileLifecycleTest 用例没有 OS 限制,确实在 Java 21 任务中运行过,覆盖了各类反例(摘要错误 / runtime 错误 / harness 错误 / shell / v3 / publication / 未引用 / 损坏 / 未结算)以及四个允许的文件工具。

未验证:Linux 验收运行。作者报告在 Ubuntu 26.04 arm64、原生 MySQL 8.4.11 环境下 98 个生命周期测试通过、公开集成门禁通过 —— 这是其本地环境的自述,此处仅作转述,未重新执行。通常的补救方式是由维护者发起 @qwen-code /verify,但该通道会拒绝非 open 状态的 PR,因此在本 PR 已合并的情况下不可用;若维护者希望补齐这部分覆盖,需要在一次性环境中手动执行。按设计,本次运行不执行任何来自 PR 的代码。

MySQL 夹具的改动是从 @@version_comment 字符串匹配切换到 JDBC 的 getDatabaseProductName()。在 HostedHarnessMySqlIT 中这一改动实际上更严格(isEqualTo("MySQL") 取代 containsIgnoringCase("mysql")),且显式的 MariaDB 版本判断被保留,因此 MariaDB 排除并未被削弱。

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

Reviewed at 847cb8c90bcabcc7b2385bbaaaeb716a4b9f5705 · re-run with @qwen-code /triage

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Released in v0.25.2.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants