Repository navigation
fix(managed-agent): close shell profiles after native file calls - #14045
Conversation
|
Linux E2E verification for head
Failsafe execution used 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 续轮仍在单独调查,未计为通过。 |
Co-authored-by: Qwen-Coder <[email protected]>
1d9abdd to
847cb8c
Compare
|
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)为单个提交。 |
|
Rebased to current main 中文:已同步最新 main 的 lint 门禁,8 文件修复补丁不变。前述 Linux 验收明确基于固定 d8558bb 加修复,未将之后合入的 MQ2b、团队计划审批和文件历史门禁改动计入本地验收;新 head 的 CI 正在重新运行。 |
Linux Hosted core acceptance — final combined candidateAll 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
Actual reboot evidenceEach 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.
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 ScopeRetired-result model continuation is limited to 中文验收说明最终组合候选的 11 次独立运行全部通过:3 次真实 VM 重启、1 次公开 API(8 个 JUnit cases、0 失败/错误/跳过)、1 次运行中前台 Shell 和 G3 的 allow/deny/cancel/expiry/continuation/freeze 六模式。合计 8 个 JUnit cases 与 10 个全部实际执行的独立脚本场景,历史基线重复运行不计入最终数量。 固定 main 三个真实重启分别验证已提交 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;未知效果等证据不足路径保持阻塞。 |
chiga0
left a comment
There was a problem hiding this comment.
Review
No blocking findings.
Approval blockers: none.
Scope
Reviewed:
WorkspaceProfileLifecycleVerifier.java— full file at HEAD, not diff-onlyWorkspaceProfileLifecycleTest.java— new parameterized test (13 modes)HostedPublicWorkspaceIT.java— new integration test andmodelReplyrefactorHostedHarnessMySqlIT,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.
sources.isEmpty()— no O3 receipt presentdispatchMode == "deferred"— excludes streaming/protocol dispatchruntimeProtocol == null— excludes v3 deferred pathpublicationId == null— excludes publication-grant executionsfileInputs.contains(...)— requires a committed, identity-verified, digest-matchedmanaged-tool-inputresource 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
left a comment
There was a problem hiding this comment.
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).
|
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. Why I'm comfortable with it. The allow-path is a six-way conjunction, and every branch fails closed:
Two things I checked directly, because each could have made the fix silently inert or silently unsafe:
Design docs are updated in English and Chinese in the same change, with matching rules and acceptance criteria. Non-blocking. Test evidence — the PR's own CI on the reviewed head.
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 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 The MySQL fixture switch is from 中文说明信心度:4/5 —— 改动本身合理、防护严密;之所以现在才记录,是因为本次 triage 运行时 PR 已经合并。 本 PR 已于 2026-10-13 合并,早于本次运行结束,因此已无可把关的动作:不批准、不要求修改、不关闭。以下评审仅作记录,如需后续跟进可参考。 改了什么。 为什么可以放心。 这条放行路径是六个条件的合取,且每个分支都失败即阻塞:
有两点我特意直接核对过,因为它们任一出错都会让修复「静默失效」或「静默变松」:
设计文档在同一次改动中同时更新了英文与中文版本,规则与验收标准一致。 非阻塞项。 测试证据 —— 被评审 head 上 PR 自身的 CI。 该 head 共 97 个 check-run:22 个 success、75 个 skipped、0 个 failure。 需要点明的缺口:新增的集成回归和三处 MySQL 夹具改动都带 未验证:Linux 验收运行。作者报告在 Ubuntu 26.04 arm64、原生 MySQL 8.4.11 环境下 98 个生命周期测试通过、公开集成门禁通过 —— 这是其本地环境的自述,此处仅作转述,未重新执行。通常的补救方式是由维护者发起 MySQL 夹具的改动是从 — Qwen Code · qwen3.8-max-2026-09-02 Reviewed at |
|
Released in v0.25.2. |
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
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
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 个持久资源身份/摘要及公开历史。
测试平台
环境(可选)
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 产物未改变。
风险与范围
关联议题
关联 #12380。