Skip to content

Serve hostPlatform's data methods; withdraw the execHost face - #2002

Merged
eric8810 merged 95 commits into
mainfrom
dim/1295-host-platform-service
Nov 25, 2026
Merged

eric8810 merged 95 commits into
mainfrom
dim/1295-host-platform-service

Conversation

@eric8810

@eric8810 eric8810 commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #1292 · Refs #1295

What changed

hostPlatform is the process-scope data face; the separate execHost face is withdrawn. The implementation follows the design at docs/design/research/1295-host-platform-task-owner.md, built from 984f6b59d1 in seven reviewable steps.

  • One TaskRecord/TaskKind table for exec commands, shell commands, shell jobs and the persistent shell. One terminal watch, first terminal wins; terminal snapshots are immutable.
  • One typed TaskFailure and one WaitReply: inline text, output path/bytes/truncation, preview, failure, status, exit code/signal, duration. retainOutput switches a running inline capture to a file and side-copies a terminal inline result without mutating it.
  • Normal exec uses owner task ids: foreground wait/cancel, handoff to BackgroundExec, live preview/page and recovery call spawn/wait/output/tail/kill/settle. ExecProcess and the live capture handle are gone from callers.
  • The public shell event API is removed. Reads are terminal records plus wait/output/tail/retainOutput; the owner line queue is private to ShellSession and never crosses the face. This closes the non-ack 1 MiB stall.
  • Owner line splitter and final-line flush; shell exit sweeps child commands/jobs to terminal and wakes waiters; shell command/job reads and kill use the owner record; TaskEnded covers writes to a dead shell; settle is idempotent.
  • UTF-8-safe capture/page boundaries; shell log registration and retention across settle; outputPath in a model result only when the file exists; strict output-directory removal; typed confined timeout/output-limit errors.
  • Normal exec passes the Session workspace and the authorized workspace roots to the owner; selecting a working directory no longer adds it to the writable set. spawnConfined maps typed outcomes; MCP child PATH uses the native OsStr path.
  • session.exec.stop selects the branch dyn ExecStop when the profile provides it (minimal: ShellSession), otherwise BackgroundExec. Neither task owner gains a dependency on the other.

Round-26 fixes: pwsh job completion is watched by the owner; any registered job id accepts its pid; execRoot is a typed string; a failed shell-log registration removes its file; a pending stop keeps a watcher for the terminal fact; spawnWithStdin aborts its waiter before error mapping; log-location docs now match the owner output directory.

Round-25 fixes: retained shell logs survive settle; shell-command pages report consumed bytes, totalBytes and an absent cursor on an empty page; a second active command answers task_running; a shell whose log registration fails is stopped and settled; write decodes before reserving; a pid-less stop keeps its background entry until the watcher observes the terminal; the native MCP PATH keeps non-UTF-8 bytes.

The previous af6752a2 patch stack is not the branch base; it exists only in the local tag backup/pr-2002-af675.

Verification

  • cargo test -p dim-agent-capabilities — 651 capabilities flow, 4 ignored (one unrelated flow flaked once under load, then passed on rerun)
  • cargo test -p dim-agent-integration-tests --test integration_flow — 235 passed, 1 ignored
  • cargo test -p dim-app-server --test transport_flow — 616 passed, 1 ignored
  • cargo test -p dim-modality --test modality_suite — 65 passed, 15 ignored
  • cargo clippy --workspace --all-targets --locked -- -D warnings — pass
  • cargo fmt --all -- --check — pass
  • cargo run -p xtask -- types / check — pass
  • Windows CI is required for the native Windows confined/shell paths.

CI is running for head e36922d5e: changes, verify (linux), windows-cli, macos-native, static-checks and ci-ok all pass. The previous review's P1/P2/P3 items are mapped in the latest review-closure comment.

A public service is its own contract: rutis serves its public &self methods by name in the scope it is provided. Remove the separate process-scope execHost face, keep hostPlatform's own data methods, and leave the task and shell operations on toolHost, backgroundExec and sessionMethods.shell. No ownership move and no rename.
Mark HostPlatform's data methods with #[rutis::service] and add info, which returns the process facts consumers read today. Handle methods (spawn, spawn_pty, build_process_spec) stay off the service. The bridge generates the dispatch; xtask types generates the TypeScript declarations. No new face type and no process ownership move.

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

The service split matches the design in #1295. I found no shipped execHost call to migrate, and task execution, cancellation, and branch shell ownership stay with their existing services.

[P2] Define the path encoding at the new service boundary. crates/dim-agent-capabilities/src/host_platform/service.rs:12–24 puts native PathBuf values directly in HostInfo. The Unix home lookup accepts native paths, but Serde rejects a path that is not UTF-8. A valid native home or execution-root path can therefore prevent the entire hostPlatform.info response from being encoded, and the separate execRoot response has the same issue. Please define how this string-path contract handles an unrepresentable native path, use that policy consistently in both replies, and cover it with a small serialization test. Return a documented, explicit error if the protocol only supports UTF-8; avoid silently returning a path that identifies a different location.

Static review of this head. macOS native and static CI passed; Linux and ci-ok were still pending in the exact-head run.

@yyhhyyyyyy yyhhyyyyyy 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: #2002 Serve hostPlatform's data methods; withdraw the execHost face

Reviewed head 21c6e246d6db58b0ad52e21e12c3ad2a7d20db28 against origin/main 1880616e2ad57c6902a963b418ad550410466314.

Summary

The change makes hostPlatform a process-scope data face. It moves exec_shell, sandbox_backend and exec_root into a #[rutis::service] impl, adds info returning HostInfo, registers the shared name, drops the internal(object) reason, updates the design documents, and regenerates the catalog and the TypeScript declarations. The withdrawn execHost face was design-only on main: no code, generated artifact or TypeScript call site used it, so no call site needed migration. toolHost.execute, backgroundExec and the shell services already carry the task and shell operations.

The service shape, scope, HostInfo field sources and generated catalog are correct. The committed TypeScript is correct for Linux. The blockers below are portability defects that make the repository's documented verification fail on macOS, plus documentation errors introduced by the rewrite.

Verdict: REQUEST_CHANGES

Both the macOS clippy failure and the host-dependent generated TypeScript must be fixed before merge. The verify (macos) job that runs on push to main executes exactly these commands, and the PR matrix does not run it on the pull request (.github/workflows/ci.yml:228, :268, :278).

Findings

Blocking: macOS clippy fails on an unused import

Problem: service.rs imports super::isolation under #[cfg(unix)], but its only user is the bubblewrap branch of sandbox_backend, which is #[cfg(all(unix, not(target_os = "macos")))]. On macOS the import is unused.

Failure scenario: a macOS contributor or the post-merge verify (macos) job runs cargo clippy --workspace --all-targets --locked -- -D warnings; rustc emits unused import: super::isolation and the job fails before xtask check runs.

Evidence: crates/dim-agent-capabilities/src/host_platform/service.rs:3-4, :67-77; local run with the pinned 1.100.0 toolchain failed exactly at service.rs:4:5 with -D unused-imports.

Fix: gate the import with the same cfg as its use (#[cfg(all(unix, not(target_os = "macos")))] use super::isolation;), or use one sandbox_backend method whose body carries the cfg branches.

Verification: reproduced on macOS with cargo clippy -p dim-agent-capabilities --all-targets -- -D warnings.

Blocking: generated TypeScript depends on the host OS

Problem: the three sandbox_backend definitions carry different doc comments, and xtask types selects one by the host cfg. The committed npm/branch-services.d.ts contains the Linux doc, which cargo run -p xtask -- types reproduces on Linux. On macOS the generator selects the macOS definition, and on Windows the Windows definition, so each host writes a different doc.

Failure scenario: cargo run --locked -p xtask -- check, the documented command after changing capabilities, fails on macOS and Windows with service declarations are stale. If a macOS developer regenerates and commits the macOS output, the Linux static-checks job fails instead. No single committed file satisfies all hosts.

Evidence: crates/dim-agent-capabilities/src/host_platform/service.rs:51-52, :60-68; npm/branch-services.d.ts:191-195; regenerating on macOS produced a one-hunk diff that changed only the sandboxBackend doc to macOS always has sandbox-exec; with that generated file the rest of xtask check passed, including the service catalog.

Fix: give all three cfg variants the same doc comment, or use one method with the cfg branches inside its body, then regenerate the declarations once.

Verification: reproduced with cargo run -p xtask -- check and xtask types under the pinned toolchain on macOS; the Windows variant has the third distinct doc.

Medium: dangling section references after the execHost deletion

Problem: the rewrite removes sections 3.2 through 3.10, including the settlement rules, but leaves references to section 3.8 in the open decisions. The retained-task-records decision now points at a section that no longer exists, and its premise (a provider-held task record, explicit settlement, repeated start refusal) is no longer described in this document.

Failure scenario: an implementer following open decision 8 cannot find the settlement contract; the decision cannot be evaluated as written.

Evidence: docs/design/resource-faces.md:724-726. The new document has only ## 3. Process and task services and ### 3.1 (docs/design/resource-faces.md:91, :120).

Fix: point the decision at the task owner's contract (docs/architecture/rust-agent/plugins/WorkspaceTools.md#data-face, and the background-output contract for the terminal facts), or remove the decision if settlement now belongs wholly to that owner.

Verification: heading and reference scan of the head file.

Medium: persistent PTY operations are attributed to the wrong service

Problem: the new text says sessionMethods.shell keeps the PTY primitives, and the new table maps sessionMethods.shell and ShellSession to one ShellInput owner document. sessionMethods.shell is ShellInput's namespace for shell.run, shell.stop and shell.list, which runs a command through the exec path. The persistent PTY is the branch ShellSession, with run and stop. The removed design's write and resize operations have no replacement on any service, yet open decision 4 still treats them as available.

Failure scenario: an implementer wiring PTY support for #1295 reads the ablation and believes raw PTY write/resize already crosses languages; there is no operation to call, and the open decision cannot be resolved.

Evidence: docs/design/resource-faces.md:106, :114-115, :734, :711-714; docs/design/contracts/resource-owner-operations.md:10; docs/design/service-faces.md:126, :163; crates/dim-agent-capabilities/src/shell_input.rs:48, :55, :629-631; crates/dim-agent-capabilities/src/shell_session.rs:360, :1305; crates/dim-agent-capabilities/src/lib.rs:121.

Fix: attribute the PTY to ShellSession and link its owner material (docs/design/shell-exec-recovery.md); either state plainly that write/resize remain Rust-internal and are deferred, or restore them as a data operation set; correct the ablation sentence.

Verification: code inspection of both shell paths and the owner documents.

Low: wrong or hypothetical Rust method names for owner calls

Problem: the new text names removeOutputDirectory/remove_output_directory as SessionStore's Rust call. The actual method is HostPlatform::remove_exec_directory. It also names hostPlatform.configured and confined as if they were current Rust methods. Hooks uses build_process_spec plus spawn_with_stdin, and OCR uses spawn_confined.

Failure scenario: a reader searching for the named methods finds nothing and cannot connect the contract to the code.

Evidence: docs/design/resource-faces.md:112, :642, :649; crates/dim-agent-capabilities/src/host_platform.rs:2249, :511, :408; crates/dim-agent-capabilities/src/host_platform/confined.rs:179; crates/dim-agent-capabilities/src/hooks/runner.rs:390, :407; crates/dim-modality/src/engine.rs:2304.

Fix: use remove_exec_directory, name the actual process-start methods, and mark configured/confined as proposed data operations rather than existing ones.

Verification: grep of the workspace.

Low: plugin.d.ts does not re-export the execShell and sandboxBackend reply types

Problem: plugin.d.ts re-exports HostPlatform and HostInfo, but not ShellStatus, SandboxBackend, ExecShellRuntime, Os, ShellEdition, ShellSource or OutputEncoding. The authoring guide says the generated service types are re-exported through the same entry point as Services, and comparable generated data types such as WorkflowFileEntry and ResourceRef are re-exported.

Failure scenario: a TypeScript plugin following the guide cannot name the reply type of execShell or sandboxBackend from dimcode/plugin and must deep-import branch-services.js or use structural inference.

Evidence: npm/plugin.d.ts:261-267; npm/branch-services.d.ts:145-201; docs/typescript-plugin-authoring.md:12-15.

Fix: add the helper types to the re-export list.

Verification: type-name scan of both declaration files.

Notes and verification

  • No execHost code or generated call site existed on main; HostDispatch and host_key usage for the face is generated by #[rutis::service]. No callId or cancel operation remains in the new contract. The remaining execHost mentions are in docs/design/research/remote-plugins.md, a research draft that the new design still links for leaf mounting; consider updating or marking them historical.
  • The four hostPlatform methods take no cancelled parameter. exec_shell can read FileStorage and run shell detection under the shell mutex, and macro-generated bridge calls use a non-cancellable future, so a foreign caller cannot cancel that work. This is unchanged Rust behavior, but it is worth stating whether rule 7 is intended to cover these read operations.
  • Optional timezone is Option<String> with skip_serializing_if, so the wire omits it; the generated TypeScript is timezone?: string | null, the generator's standard Option mapping. The declaration accepts null although the wire never carries it, which is consistent with the other generated optional fields.
  • The text says the handle methods stay #[service(skip)]; they are simply outside the marked impl and carry no marker. Wording only. One stale link text also remains at docs/design/service-faces.md:132 (resource and store data faces) after the document was renamed to Resource and store services.
  • Targeted tests: cargo test -p dim-agent-capabilities --test capabilities_flow host_platform_flow passed (17 tests on macOS; the two non-macOS bubblewrap tests are cfg-gated, giving the 19 the PR reports on Linux), including the new the_host_platform_service_answers_info.
  • cargo run -p xtask -- check passes on macOS only after regenerating the declarations for macOS; the committed file fails as described above. The service catalog check itself passed. I reran xtask graph and the generated directory and plugin pages match the committed head exactly, including the added services.json entries (provider 29 in the app server, provider 5 locally).
  • node --test runtime/plugin-sdk.test.mjs could not run in this checkout because zod is not installed; unverified.
  • CI: static-checks and macos-native passed. verify (linux) failed in mcp_session_flow::project_visibility_disable_refresh_failure_and_permission_use_real_sources with Elapsed(()) at crates/dim-app-server/tests/mcp_session_flow.rs:782, a 5 second Ready timeout in code untouched by this PR. I reran that exact test locally and it passed in 0.19 s; this looks like a load-related flake and needs a rerun, not a code change here. ci-ok therefore also failed.
  • Cross-PR: merge-tree is clean against origin/main and the current head of #1997 (9b9d93f36). It reports conflicts against #1911 (3bb0a8514), #1909 (6f36d5d90) and #1908 (52d7ec38e). In the files this PR touches, the conflicts are mechanical: adjacent lines in the register_faces list of crates/dim-app-server/src/lib.rs (the other PRs add branchOpening, submitChecks or sessionLoader next to the removed hostPlatform row), generated catalog and services snapshots for #1911 and #1909, and the plugin.d.ts re-export list for #1909. Resolve by keeping both changes and regenerating. #1911 and #1908 are themselves conflicting with main, so some of those conflicts are inherited.
  • Unverified: Windows build and test of the new service path; full workspace clippy and tests beyond the targeted commands; behavior of info on a Windows host; and the design claim that a branch service can cross a leaf by mounting a part copy, which depends on #1296.

#[cfg(windows)]
use super::WINDOWS_SANDBOX_UNAVAILABLE;
#[cfg(unix)]
use super::isolation;

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.

On macOS this import is unused: its only user is the bubblewrap branch of sandbox_backend, which is #[cfg(all(unix, not(target_os = "macos")))] at line 69. With the pinned 1.100.0 toolchain, cargo clippy -p dim-agent-capabilities --all-targets -- -D warnings fails here with unused import: super::isolation, and the verify (macos) job runs the workspace clippy with -D warnings on push. Gate the import with the same cfg, or use one sandbox_backend method with cfg branches in its body.

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.

Fixed in cbe4b75. service.rs was folded into host_platform.rs, where #[cfg(unix)] mod isolation is used on macOS by the preparation path as well as by the non-macOS sandbox_backend. cargo clippy -p dim-agent-capabilities -p dim-app-server --all-targets --locked -- -D warnings passes on macOS at b6ed380 with the pinned 1.100.0 toolchain.

SandboxBackend::Available
}

/// The sandbox backend a new process would use: the same bubblewrap

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.

This Linux-only doc comment is why the committed npm/branch-services.d.ts is host-dependent. xtask types selects the method by host cfg, so on macOS it picks the #[cfg(target_os = "macos")] definition at line 60 and writes macOS always has sandbox-exec; on Windows it picks the definition at line 51 with the shared preparation doc. cargo run -p xtask -- check then reports service declarations are stale on both hosts, while committing either host's output would fail Linux static-checks. No single file satisfies all hosts. Give all three sandbox_backend definitions the same doc, or use one method with cfg in the body, and regenerate once. I reproduced the one-hunk macOS difference and confirmed the rest of xtask check passes with the macOS output.

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.

Still open at b6ed380. The three sandbox_backend definitions still carry different docs (crates/dim-agent-capabilities/src/host_platform.rs:598-621), and the committed npm/branch-services.d.ts:267-271 still has the Linux doc. On macOS, cargo run -p xtask -- check fails with service declarations are stale; xtask types changes only that doc to macOS always has sandbox-exec, and the same check passes with that file. Give all three variants one doc, or use one method with the cfg branches in the body, then regenerate.

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.

Fixed at 1e1f8c7. The three sandbox_backend definitions now share one doc comment (crates/dim-agent-capabilities/src/host_platform.rs:972-995), and cargo run --locked -p xtask -- check passes on macOS, so the committed declarations no longer depend on the host OS (npm/branch-services.d.ts:409).

Comment thread docs/design/resource-faces.md Outdated
`child_path`) stay `#[service(skip)]`; they carry process handles and cannot cross.
`backgroundExec.start` stays skip too: it takes the live `ExecProcess`, and the cross-language
start entry is `toolHost.execute` with the `exec` tool. `configured` and `confined` remain Rust
calls until a foreign caller needs them; `removeOutputDirectory` is SessionStore's Rust call.

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.

removeOutputDirectory is not the Rust call. SessionStore calls HostPlatform::remove_exec_directory (crates/dim-agent-capabilities/src/host_platform.rs:2249) from crates/dim-app-server/src/storage/files.rs:373. The same wrong name appears in the caller matrix at line 642 (remove_output_directory). configured and confined are also not current HostPlatform methods: Hooks uses build_process_spec plus spawn_with_stdin (hooks/runner.rs:390, :407) and OCR uses spawn_confined (host_platform/confined.rs:179). Name the actual methods, and mark the future data operations as proposed.

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.

Partly fixed in b6ed380. The Stage 1 paragraph no longer names removeOutputDirectory, but the caller matrix still does: docs/design/resource-faces.md:643 says remove_output_directory, and the real call is HostPlatform::remove_exec_directory at crates/dim-agent-capabilities/src/host_platform.rs:2575. docs/design/resource-faces.md:650 still names hostPlatform.configured, which does not exist and is deferred to Stage 3. Also docs/design/resource-faces.md:627 now says the public methods are only the original four, which contradicts section 3 and the served catalog. Please finish the rename and the method list.

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.

Partly fixed at a3c0e72. HostPlatform::remove_output_directory is now a served method (host_platform.rs:746), and SessionFiles calls it through the service (storage/files.rs:371), so the wrong Rust name is gone from this row. configured is still named at resource-faces.md:657 and :704, while the served operation is spawnWithStdin (host_platform.rs:764) and configured is the in-process core; rename those two references. The removal boundary itself is still lexical and is the P1 in the new review.

that already owns it: `hostPlatform.info` (and its `execShell`/`sandboxBackend`/`execRoot`
methods) reads the platform facts the process owner already has; `toolHost.execute` and
`backgroundExec.output`/`outputPage`/`wait`/`stop` are the existing tool and task operations;
`sessionMethods.shell` keeps the PTY primitives the shell already has. No process or PTY state

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.

sessionMethods.shell is ShellInput's namespace for shell.run, shell.stop and shell.list (crates/dim-agent-capabilities/src/shell_input.rs:48, :629-631), not a PTY operation set. The persistent PTY is the branch ShellSession (run at crates/dim-agent-capabilities/src/shell_session.rs:360, stop at :1305), registered as a branch service at crates/dim-agent-capabilities/src/lib.rs:121. The same conflation is in the table row at line 106 and in docs/design/contracts/resource-owner-operations.md:10; open decision 4 at lines 711-714 still treats the removed write/resize/output operations as available. Attribute the PTY to ShellSession with its owner document, and state clearly that raw write/resize remain internal and deferred, or restore them as a data operation set.

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.

Still open at b6ed380. docs/design/resource-faces.md:735 still says sessionMethods.shell keeps the PTY primitives, and the table at :106 still groups sessionMethods.shell and ShellSession under ShellInput. sessionMethods.shell serves shell.run, shell.stop and shell.list (crates/dim-agent-capabilities/src/shell_input.rs:49, :624-646); the persistent PTY is the branch ShellSession (crates/dim-agent-capabilities/src/shell_session.rs:360, :1305), registered at crates/dim-agent-capabilities/src/lib.rs:121. Open decision 4 at docs/design/resource-faces.md:712-715 still describes write, resize and output as available. Attribute the PTY to ShellSession, link its owner document, and state that raw write and resize remain internal until Stage 2.

Comment thread npm/plugin.d.ts Outdated
export type {
AgentErrorThrown, BranchLifecycle, Dispatcher, PartRegistry, PartScope, ProcessActivity, Services, SessionFault, SessionIdentity, SessionLifecycle,
TimelineIdentity, TreeCommands, PermissionState, SessionPermissions, SessionsErrorThrown,
HostPlatform, HostInfo,

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.

Only HostPlatform and HostInfo are re-exported. The public methods also return ShellStatus, SandboxBackend, ExecShellRuntime, Os, ShellEdition, ShellSource and OutputEncoding, which are generated and exported only from branch-services.d.ts. A TypeScript plugin following the authoring guide (type-only imports from dimcode/plugin) cannot name those reply types; comparable generated data types such as WorkflowFileEntry and ResourceRef are re-exported here. Add them to this list.

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.

Still open at b6ed380. npm/plugin.d.ts:261-267 re-exports only HostPlatform and HostInfo. The face now also returns ShellStatus, SandboxBackend, ExecShellRuntime, Os, ShellEdition, ShellSource, OutputEncoding, OutputPage, OutputTail and OutputPathReply, and takes SpawnRequest, SpawnReply, WaitRequest, TaskRequest, OutputRequest and HostPlatformError. A plugin following docs/typescript-plugin-authoring.md:12-15 cannot name any of them from dimcode/plugin.

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.

Fixed and extended at 05c6d9d. npm/plugin.d.ts:261-272 re-exports the data types, including the new ShellJobStart; all 56 names exist in npm/branch-services.d.ts, there are no duplicates, and the committed declarations are verified current because static-checks runs xtask check, which includes the types staleness check. The only nit is that OutputPage is a WorkspaceTools type and is not used by the HostPlatform methods.

No further action needed on this thread.

Keep the service block on the existing impl HostPlatform instead of a new module. The data methods (execShell, sandboxBackend, execRoot, info) are served from that block; the handle and builder methods are #[service(skip)]. No new file and no new service object.
HostPlatform owns the command task table and output file. spawn returns a task id; wait, kill, settle, output, retainOutput and tail work by that id. WorkspaceTools and BackgroundExec use the owner's task; handle methods stay #[service(skip)]. info and the existing data methods are served from the original impl block. No new file; xtask types generates the declarations.

@yyhhyyyyyy yyhhyyyyyy 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: #2002 Serve hostPlatform's data methods; withdraw the execHost face

Reviewed head b6ed380 against origin/main 1880616.

Summary

The change makes hostPlatform a process-scope data face, removes the design-only execHost face, and moves the command task operations onto the owner: spawn returns a task id, and wait, kill, settle, output, retainOutput and tail work by that id. WorkspaceTools exec and BackgroundExec now use the owner's task and output file. The service shape, scope, catalog entries and the generated TypeScript for Linux are correct. The macOS clippy blocker from the previous review is fixed, and the new head passes targeted tests and macOS clippy.

The macOS generated declaration blocker remains: as committed, cargo run -p xtask -- check fails on macOS. The new commit also leaves contract contradictions in the design and owner documents, and the new spawn and wait operations have two real lifecycle defects.

Verdict: REQUEST_CHANGES

The macOS declaration issue alone keeps the documented verification and the post-merge verify (macos) job failing. The code defects below can lose a running command or its work; the document contradictions make the face unimplementable as written.

Blocking

P1: The committed TypeScript still depends on the host OS

Problem: the three sandbox_backend definitions carry different doc comments, and xtask types selects one by host cfg. The committed npm/branch-services.d.ts contains the Linux doc.

Failure scenario: a macOS contributor runs the documented cargo run -p xtask -- check after changing a capability. It fails with service declarations are stale. The post-merge verify (macos) job runs the same command (.github/workflows/ci.yml:227-228, :278), so main fails after merge. Committing the macOS output instead fails the Linux static-checks job.

Evidence: crates/dim-agent-capabilities/src/host_platform.rs:598-621; npm/branch-services.d.ts:267-271. At this head on macOS, xtask check exited 1, xtask types changed only the sandboxBackend doc to macOS always has sandbox-exec, and xtask check passed with that file.

Fix: give all three variants one doc comment, or use one sandbox_backend method with the cfg branches in its body, then regenerate once.

P2: wait's timeout kills the task, and the reply is untyped

Problem: timeoutMs is documented as bounding the wait. CommandTask::wait cancels self.timeout, the supervisor maps that to Observed::TimedOut, and it terminates the process tree. wait is therefore a read that kills, while resource-faces.md:82 says cancelling a process is kill. The reply is serde_json::Value, generated as BridgeJsonValue (npm/branch-services.d.ts:285), so callers cannot type the terminal record.

Failure scenario: a caller polls wait({taskId, timeoutMs: 1000}) on a long build. After one second the build is killed and the task is terminal timed_out. A second caller waiting on the same task without a timeout loses it too. A TypeScript plugin cannot name the reply fields.

Evidence: crates/dim-agent-capabilities/src/host_platform.rs:703-706; crates/dim-agent-capabilities/src/workspace_tools/exec.rs:2314-2326, :2218-2234; npm/branch-services.d.ts:282-285.

Fix: remove the cancellation from wait and rely on SpawnRequest.timeoutMs plus kill, or define a terminating deadline in the owner document and the generated comment. Return a typed terminal struct instead of serde_json::Value, and test both timeout paths.

P2: spawn reuses a task id whose log already exists, and the error mapping hides duplicates

Problem: spawn lets the caller choose taskId, and start_command checks only the live table. The output capture opens <outputDir>/<taskId>.log with create_new(true) (exec.rs:1864). A settled task keeps its log, so the same id can be spawned again; when the new command's output spills to the log after 30,000 UTF-16 units, or the caller calls retainOutput, the capture fails, the supervisor kills the tree, and wait reports failed after spawn reported success. The duplicate path returns ProcessSpecError { code: "task_exists" }, but HostPlatform::spawn maps every ProcessSpecError to HostPlatformError::Failed (host_platform.rs:694-696), so the generated task_exists code never occurs and a retry cannot tell duplicate from a start failure.

Failure scenario: a caller uses a stable id such as build, settles the task when it ends, and later spawns build again. The second spawn returns a task id and output path; once the command writes enough output to spill to the log, the capture fails and the tree is killed, so wait reports failed and the work is lost. The same happens after a host restart while the log remains. An outputDir that cannot be created or is not a directory also fails only after the process starts.

Evidence: crates/dim-agent-capabilities/src/workspace_tools/exec.rs:1864, :1985-1990, :1996-2008; crates/dim-agent-capabilities/src/host_platform.rs:414, :648-700; npm/branch-services.d.ts:202-210.

Fix: before starting, check both the live table and the planned log path, and return HostPlatformError::TaskExists. Map known ProcessSpecError codes to their variants. Reject Windows reserved device names such as CON, NUL and COM1, because ids are caller chosen. Add tests for a duplicate id, a reused id after settle, and an unusable outputDir.

P2: service-faces.md contradicts itself about the hostPlatform methods

Problem: the table at docs/design/service-faces.md:126 lists the Stage 1 operations on hostPlatform, but the paragraph at :163 says its public methods are only info, execShell, persistentShell, sandboxBackend and execRoot, and that task operations stay on toolHost, backgroundExec and sessionMethods.shell. The same commit wrote both statements.

Failure scenario: an implementer following section 3.4 adds or keeps a duplicate task operation on backgroundExec, or records spawn as internal(object) again, because two statements in the same contract disagree.

Evidence: docs/design/service-faces.md:126, :163; docs/architecture/rust-agent/generated/catalog.md:27; docs/design/resource-faces.md:103.

Fix: update the paragraph to list the Stage 1 operations and say only the remaining shell operations stay with their owners, or remove the operations from the table. Keep one shape.

P2: resource-faces.md section 6 contradicts section 3 and the catalog

Problem: docs/design/resource-faces.md:627 still says the public data methods are only info, exec_shell, sandbox_backend and exec_root, and that the spawn methods are internals. Section 3 at :103 and the generated catalog serve spawn, wait, kill, settle, output, retainOutput and tail. Only spawn_tree and spawn_with_stdin are #[service(skip)]; spawn_pty, build_process_spec and child_path are outside the served impl.

Failure scenario: a caller migration uses this row as the provider and binding map and calls the Rust handle methods instead of the data operations, or marks hostPlatform internal(object) again. The migration records the wrong contract.

Evidence: docs/design/resource-faces.md:103, :108-114, :627; docs/architecture/rust-agent/generated/catalog.md:27; npm/branch-services.d.ts:261-311.

Fix: replace the method list with the full public set and name the skipped handle methods.

P2: the HostPlatform owner document denies the state the new code adds

Problem: docs/architecture/rust-agent/plugins/HostPlatform.md:17 says No Timeline events or plugin background tasks, and :47-49 says Spawned process lifetime belongs to each caller/supervisor, not this plugin and that raw spawn and tree termination are execution mechanics. The new code has a process command table, a TaskTracker of supervisor tasks plus pipe pumps, a shutdown effect that cancels and waits for them, and retained tasks that stay in this plugin's table until a caller settles them (host_platform.rs:247-249, :1354-1370; exec.rs:1969-2052). The page also has no data face section, although resource-faces.md:103 names it as the owner document for info, spawn, wait, kill, settle, output, retainOutput and tail.

Failure scenario: a leaf implementer cannot find the settlement rule, the task id scope, the timeout rule, the output path lifetime or the error codes, and a reviewer cannot check the face against the owner contract. A later change can move or remove these operations without the page noticing.

Evidence: docs/architecture/rust-agent/plugins/HostPlatform.md:15-49, :367-374; crates/dim-agent-capabilities/src/host_platform.rs:247-249, :459-769, :1354-1370; crates/dim-agent-capabilities/src/workspace_tools/exec.rs:1969-2087.

Fix: add a Data face section in the form of WorkspaceTools.md, covering requests, replies, errors, task id scope, explicit settle, log retention and unload cancellation. Update Events and lifetime, and rename the spawn reference at :138 to spawn_tree.

P2: the PTY is still attributed to the wrong service

Problem: docs/design/resource-faces.md:735 says sessionMethods.shell keeps the PTY primitives, and the table at :106 groups sessionMethods.shell and ShellSession under ShellInput. sessionMethods.shell serves shell.run, shell.stop and shell.list; the persistent PTY is the branch ShellSession.

Failure scenario: an implementer wiring PTY for #1295 looks for the operations on sessionMethods.shell, finds none, and either duplicates the PTY or assumes raw write and resize already cross. Open decision 4 at :712-715 still treats them as available.

Evidence: docs/design/resource-faces.md:106, :712-715, :735; crates/dim-agent-capabilities/src/shell_input.rs:49, :624-646; crates/dim-agent-capabilities/src/shell_session.rs:360, :1305; crates/dim-agent-capabilities/src/lib.rs:121.

Fix: attribute the PTY to ShellSession and link its owner material. State that raw write and resize stay Rust internal until Stage 2, or restore them as data operations, and correct the ablation sentence.

P2: open decision 8 points at a removed settlement section

Problem: docs/design/resource-faces.md:725-727 says settlement is explicit in section 3.8 and registered file retention follows that section, but the document now has only sections 3 and 3.1. The new spawn operation makes this the missing contract: who settles, when, what happens if the caller never settles, whether a repeated start after settle is allowed, and who removes the log.

Failure scenario: an implementer of the new data face cannot answer those questions from the design, so the task table and the logs can leak until the host unloads, or a repeated start is refused or accepted by accident.

Evidence: docs/design/resource-faces.md:91, :121, :725-727; crates/dim-agent-capabilities/src/host_platform.rs:718-725; crates/dim-agent-capabilities/src/workspace_tools/exec.rs:2061-2069.

Fix: write the settlement and retention rule in section 3 and point the decision at it, or move the rule to the owner document and link it.

P2: non-UTF-8 paths still have no policy, and the new replies repeat the problem

Problem: the previous review raised this for info; the new replies repeat it. HostInfo stores PathBuf (host_platform.rs:447-457); serde rejects a non-UTF-8 path, so the whole info reply fails to encode. The new SpawnReply.output_path is also a PathBuf (:372-377), CommandTask::wait puts self.path into json! (exec.rs:2339-2342), and OutputPathReply converts with to_string_lossy (exec.rs:1930-1943). The same native path can fail, panic, or be silently replaced depending on the operation.

Failure scenario: a host whose home or output root contains non-UTF-8 bytes cannot answer info; a caller gets a serialization failure instead of the facts. A wait on such a task can panic in json! (the macro unwraps to_value), and retainOutput returns a replacement-character path that names a different file.

Evidence: crates/dim-agent-capabilities/src/host_platform.rs:372-377, :447-457; crates/dim-agent-capabilities/src/workspace_tools/exec.rs:1930-1943, :2339-2342; npm/branch-services.d.ts:175-185.

Fix: define one string-path policy at the boundary, apply it to every reply, and test it. If the protocol is UTF-8 only, return an explicit error instead of a lossy path or a panic.

Non-blocking

  • P3: npm/plugin.d.ts:261-267 re-exports only HostPlatform and HostInfo. The face also returns ShellStatus, SandboxBackend, ExecShellRuntime, Os, ShellEdition, ShellSource, OutputEncoding, OutputPage, OutputTail and OutputPathReply, and takes SpawnRequest, SpawnReply, WaitRequest, TaskRequest, OutputRequest and HostPlatformError. A plugin following docs/typescript-plugin-authoring.md:12-15 cannot name them from dimcode/plugin.
  • P3: docs/design/resource-faces.md:643 still says remove_output_directory, but the call is HostPlatform::remove_exec_directory (host_platform.rs:2575). :650 still names hostPlatform.configured, which does not exist and is deferred to Stage 3.
  • P3: command_files is never set to Some in production or in the integration tests (crates/dim-app-server/src/lib.rs:997, tests/integration/tests/local_execution.rs:165, tests/integration/tests/minimal_execution.rs:132). The command_files term in uses_storage and the FileStorage branch in retained_output_page are dead and untested. Remove them until an assembly wires that path.
  • P3: the new face tests cover spawn, wait, output and settle on the happy path only. kill, tail, retainOutput, duplicate ids, invalid requests, the wait timeout, unload cleanup and a sandboxed spawn are untested.
  • P3: the PR description still says spawn and the other handle methods stay off the service, and that task operations keep their existing services. The head serves spawn and the task operations. docs/architecture/rust-agent/plugins/WorkspaceTools.md:578 says P:HostPlatform is used to stop a running task, but BackgroundExec stops through its own cancel token and only reads retained output through the platform.
  • P3: HostPlatform::output clamps a zero limit to one byte (host_platform.rs:729-736), while backgroundExec.outputPage rejects zero with invalidLimit (WorkspaceTools.md:555). Pick one rule and document the default and clamp.
  • P3: docs/design/service-faces.md:132 still links resource and store data faces after the document was renamed to Resource and store services.

Old findings

  • Fixed: the macOS clippy unused import on the removed service.rs. service.rs was folded into host_platform.rs in cbe4b75, where mod isolation is used on macOS by preparation as well as by the non-macOS sandbox_backend. macOS clippy passes at this head.
  • Still open: the host-dependent generated TypeScript (P1 above), the PTY attribution (P2 above), the plugin.d.ts re-exports (P3 above), the dangling section 3.8 reference (P2 above), and the non-UTF-8 path policy (P2 above).
  • Partly fixed: the wrong Rust method names. The Stage 1 paragraph no longer names removeOutputDirectory, but the caller matrix still does, and configured remains. The wording note about handle methods without a #[service(skip)] marker also remains partly true: spawn_tree and spawn_with_stdin carry it, while spawn_pty, build_process_spec and child_path are outside the served impl.
  • No inline finding is withdrawn. The optional timezone note can be dropped; the generated shape is unchanged and consistent with the generator.

Verification

  • cargo clippy -p dim-agent-capabilities -p dim-app-server --all-targets --locked -- -D warnings with the pinned 1.100.0 toolchain on macOS: passed.
  • cargo run -p xtask -- check on macOS as committed: failed with service declarations are stale. With the macOS generated branch-services.d.ts, the same command passed, including the service catalog.
  • cargo test -p dim-agent-capabilities --test capabilities_flow host_platform_flow: 18 passed on macOS, including the_host_platform_service_starts_and_waits_for_a_command.
  • CI at the reviewed head: static-checks, verify (linux), macos-native and ci-ok passed. The PR matrix does not run the macOS compile verify; verify (macos) runs only on push to main.

Cross-PR

  • Against origin/main 1880616: merge-tree clean, MERGEABLE.
  • Conflicts with #1909 in npm/plugin.d.ts (both edit the re-export list) and with #1881 in npm/branch-services.d.ts (both carry an OutputPage declaration at a different position). Both are mechanical; regenerate branch-services.d.ts and keep both entries in plugin.d.ts.
  • Clean against #1911, #1908, #1916, #1997 and #2001.

Unverified

  • Windows behavior of spawn and the generated declarations on Windows, including reserved device names.
  • The FileStorage branch of retained_output_page, which no assembly configures.
  • The leaf deployment claim in resource-faces.md:93-97, which depends on #1296.

Comment thread docs/design/service-faces.md Outdated
这些名字在 catalog 里是 `data`,Rust 类型仍由部件在同一实例按类型键读取。

`hostPlatform`、`fileStorage`、`timelineStore` 不按对象分类保留:数据面就是公开契约,`execHost`、`fsHost`、`store`、`timelineStore` 的操作就是它们的接口,旧名字是提供方和它的 Rust binding,调用方在进程内直接调这组操作,不再有第二套公开 API。凭据是操作内部用的能力,不是保留 `internal` 的理由。`hostPlatform`、`fileStorage` 的提供方在持有资源的那个 daemon(控制节点自己的插件,或 #1296 挂载的资源 leaf);`store` 在持有 Session 状态的那个 daemon,SQLite 还是 PostgreSQL 只是实现(#1298,[resource and store data faces](resource-faces.md) §6)。
`hostPlatform`、`fileStorage`、`timelineStore` 不按对象分类保留:服务本身就是公开契约;一个 service 的公开方法就是它的接口,没有单独的 face 对象,也没有第二套公开 API。凭据是操作内部用的能力,不是保留 `internal` 的理由。`hostPlatform` 的公开方法只有 `info`、`execShell`、`persistentShell`、`sandboxBackend`、`execRoot`;任务与 shell 操作留在 `toolHost`、`backgroundExec`、`sessionMethods.shell` 各自的 scope。`hostPlatform`、`fileStorage` 的提供方在持有资源的那个 daemon(控制节点自己的插件,或 #1296 挂载的资源 leaf);`store` 在持有 Session 状态的那个 daemon,SQLite 还是 PostgreSQL 只是实现(#1298,[resource and store services](resource-faces.md) §6)。

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.

Problem: this paragraph contradicts the table above it. The table at line 126 lists the Stage 1 command task operations on hostPlatform, but this paragraph says its public methods are only info, execShell, persistentShell, sandboxBackend and execRoot, and that task operations stay on toolHost, backgroundExec and sessionMethods.shell. The same commit wrote both statements.

Failure scenario: an implementer following this section adds or keeps a duplicate task operation on backgroundExec, or records spawn as internal(object) again, because two statements in the same contract disagree.

Evidence: docs/design/service-faces.md:126 and :163; docs/architecture/rust-agent/generated/catalog.md:27; docs/design/resource-faces.md:103.

Fix: update this paragraph to list the Stage 1 operations and say only the remaining shell operations stay with their owners, or remove the operations from the table. Keep one shape.

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.

Fixed at 05c6d9d. The paragraph at docs/design/service-faces.md:163 no longer says the public methods are only info/execShell/persistentShell/sandboxBackend/execRoot; it now includes the command task and persistent shell operations and matches the table at :126. The reference it adds ("see section 3.4") points at the section it is in, which is harmless but could point at the table instead.

No further action needed on this thread.

Comment thread docs/design/resource-faces.md Outdated
| Old name | Face | What the name is now |
| --- | --- | --- |
| `hostPlatform` | `execHost` | The provider and its Rust binding: `ProcessTree`, `PtyProcessTree`, temporary directories and shell preparation are its internals, reached through the operations |
| `hostPlatform` | `hostPlatform` | The process service and its Rust binding; its public data methods are `info`, `exec_shell`, `sandbox_backend` and `exec_root`. `ProcessTree`, `PtyProcessTree`, temporary directories, shell preparation and the spawn methods are internals (`#[service(skip)]`) |

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.

Problem: this row still says hostPlatform's public data methods are only info, exec_shell, sandbox_backend and exec_root, and that the spawn methods are internals. Section 3 of the same document at line 103 and the generated catalog serve spawn, wait, kill, settle, output, retainOutput and tail; only spawn_tree and spawn_with_stdin are #[service(skip)], and spawn_pty, build_process_spec and child_path are outside the served impl.

Failure scenario: a caller migration uses this row as the provider and binding map and calls the Rust handle methods instead of the data operations, or marks hostPlatform internal(object) again. The migration records the wrong contract.

Evidence: docs/design/resource-faces.md:103, :108-114, :627; docs/architecture/rust-agent/generated/catalog.md:27; npm/branch-services.d.ts:261-311.

Fix: replace the method list with the full public set and name the skipped handle methods.

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.

Fixed at 05c6d9d. The hostPlatform row at docs/design/resource-faces.md:656 now names the command task and persistent shell operations instead of the old info/exec_shell/sandbox_backend/exec_root list, and the skip list uses spawn_with_stdin_process and child_path_process. The new section 3.2 carries the settlement rules.

No further action needed on this thread.

}

/// Waits for a task's terminal record; `timeoutMs` bounds the wait.
pub async fn wait(&self, request: WaitRequest) -> Result<serde_json::Value, HostPlatformError> {

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.

Problem: timeoutMs is documented as bounding the wait, but CommandTask::wait cancels self.timeout, the supervisor maps that to Observed::TimedOut, and it terminates the process tree. A read operation kills the task, while docs/design/resource-faces.md:82 says cancelling a process is kill. The reply is also serde_json::Value, generated as BridgeJsonValue at npm/branch-services.d.ts:285, so callers cannot type the terminal record.

Failure scenario: a caller polls wait({taskId, timeoutMs: 1000}) on a long build. After one second the build is killed and the task is terminal timed_out; a second waiter without a timeout loses it too. A TypeScript plugin cannot name the reply fields.

Evidence: crates/dim-agent-capabilities/src/host_platform.rs:703-706; crates/dim-agent-capabilities/src/workspace_tools/exec.rs:2218-2234, :2314-2326; npm/branch-services.d.ts:282-285.

Fix: remove the cancellation from wait and rely on SpawnRequest.timeoutMs plus kill, or define a terminating deadline in the owner document and the generated comment. Return a typed terminal struct instead of serde_json::Value, and test both timeout paths.

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.

The typed reply is fixed: WaitReply is a serde struct (host_platform.rs:375-391) and the generated wait returns it (branch-services.d.ts:412-427). The timeout half remains. CommandTask::wait still cancels self.timeout when the wait deadline elapses (exec.rs:2314-2326); the supervisor maps that to Observed::TimedOut and terminates the tree (exec.rs:2218-2234). ShellTask::wait does the same (host_platform.rs:3515-3524). The new generated comment says cancelled ends only the wait, which makes timeoutMs look harmless. Remove the cancellation from wait and return a non-terminal result, or document the terminating deadline, and test both task kinds.

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.

Fixed at 2d1e643 for both task kinds: CommandTask::wait (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:2317-2339) and ShellTask::wait (crates/dim-agent-capabilities/src/host_platform.rs:3724-3767) now answer running on the deadline and cancel nothing, so spawn.timeoutMs is still the only deadline that terminates a command. The new test proves the command path. Two gaps remain at this head, reported separately: WaitStatus and WaitReply are still documented as an ended, terminal record (host_platform.rs:364, :376; npm/branch-services.d.ts:297, :300), and the running command reply hardcodes previewTruncated: false (workspace_tools/exec.rs:2337). The shell wait timeout has no test.

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.

The remaining type-doc and preview-flag gaps are fixed at 1e1f8c7: the public docs describe a wait reply that can be running (crates/dim-agent-capabilities/src/host_platform.rs:364-376, npm/branch-services.d.ts:297-303) and the running reply computes preview_truncated (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:1954-1957, :2353). The residual preview computation differs from the terminal branch for control bytes; I noted it on the preview thread. This thread can close.

reason: "Execution host closed".into(),
});
}
if commands.contains_key(task_id) {

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.

Problem: spawn lets the caller choose taskId, and this check covers only the live table. The output capture opens <outputDir>/<taskId>.log with create_new(true) at line 1864. A settled task keeps its log, so the same id can be spawned again; when the new command's output spills to the log after 30,000 UTF-16 units, or the caller calls retainOutput, the capture fails, the supervisor kills the tree, and wait reports failed after spawn reported success. The duplicate path returns ProcessSpecError { code: task_exists }, but HostPlatform::spawn maps every ProcessSpecError to HostPlatformError::Failed at host_platform.rs:694-696, so the generated task_exists code never occurs and a retry cannot tell duplicate from a start failure.

Failure scenario: a caller uses a stable id such as build, settles the task when it ends, and later spawns build again. The second spawn returns a task id and output path; once the command writes enough output to spill to the log, the capture fails and the tree is killed, so wait reports failed and the work is lost. The same happens after a host restart while the log remains. An outputDir that cannot be created or is not a directory also fails only after the process starts.

Evidence: crates/dim-agent-capabilities/src/workspace_tools/exec.rs:1864, :1985-1990, :1996-2008; crates/dim-agent-capabilities/src/host_platform.rs:414, :648-700; npm/branch-services.d.ts:202-210.

Fix: before starting, check both the live table and the planned log path, and return HostPlatformError::TaskExists. Map known ProcessSpecError codes to their variants. Reject Windows reserved device names such as CON, NUL and COM1. Add tests for a duplicate id, a reused id after settle, and an unusable outputDir.

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.

Fixed at 1e1f8c7 for the reported case. start_command refuses an existing <taskId>.log and an unusable output directory before starting (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:1984-1995), and HostPlatform::spawn maps task_exists and invalid_request through process_error (crates/dim-agent-capabilities/src/host_platform.rs:1021-1030, :1064-1078), so the generated task_exists code is reachable. Residual, P3: the check uses Path::exists(), which is false for a dangling symlink; a dangling <taskId>.log still passes and create_new fails later, after the spawn reported success. Use symlink_metadata or reserve the id before starting. No test covers duplicate or reused ids.

/// means the profile has no home; the shell is resolved automatically.
pub exec_shell_file: Option<(usize, PathBuf)>,
/// Storage root and relative directory holding retained command logs.
pub command_files: Option<(usize, PathBuf)>,

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.

Problem: command_files is never set to Some. The App Server sets None at crates/dim-app-server/src/lib.rs:997, and both integration assemblies set None at tests/integration/tests/local_execution.rs:165 and tests/integration/tests/minimal_execution.rs:132. The command_files term in uses_storage and the FileStorage branch in retained_output_page are therefore dead, and that branch has never run.

Failure scenario: a future caller sets the field and gets a read path with no test coverage, while a reviewer assumes retained output is read through FileStorage although BackgroundExec always opens the file directly today.

Evidence: crates/dim-agent-capabilities/src/host_platform.rs:252, :1272, :1304, :1342-1348, :2623-2650; crates/dim-app-server/src/lib.rs:997.

Fix: remove command_files and the FileStorage branch until an assembly wires them, or wire them and add a test for the FileStorage path.

wait now answers WaitReply with a WaitStatus union, exit code or signal, output file and bounded preview, instead of a generic JSON value. xtask types generates the TypeScript type.
HostPlatform owns the shell PTY and task record. shell returns a task id; write, resize, output, wait, kill and settle work by that id. ShellSession runs its marker protocol over the owner's shell task. The shell module is inline in host_platform.rs; no new file. xtask types generates the declarations.
spawn_with_stdin and spawn_confined are the data methods Hooks and OCR call, with request/reply shapes and the existing cancelled callback. The low-level process cores are renamed to *_process and stay off the service. SystemServices gains Deserialize; xtask types generates the declarations.
removeOutputDirectory and childPath are data methods on the same owner; the existing Rust helpers stay as the in-process binding for SessionFiles and MCP. xtask types generates the declarations.

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

[P1] Enforce the resolved execution-root boundary in the newly exposed removal service. crates/dim-agent-capabilities/src/host_platform.rs:3020–3042 does not establish the strict resolved containment required by the output-directory contract in docs/design/resource-faces.md:289–296. The owner should verify and retain the target’s resolved directory boundary throughout removal and preserve the contract’s successful no-op for an already absent target. Please keep this guarantee at the owner boundary rather than relying on every caller. This is a defensive source finding; no removal probe was run.

The existing path reply and cross-platform and lifecycle reviews remain relevant. The exact CI run passed macOS native, but Linux and static checks stopped on formatting in host_platform.rs.

The shell reader writes its bounded capture to outputPath. wait takes the existing cancelled callback. spawnConfined drops the always-false truncation fields and reports invalid paths as data. Hooks, OCR, SessionFiles and MCP call the data methods; the cores stay as the shared implementation.
Record the plugin-built owner requirement, the UTF-8 request boundary, the wait cancellation meaning and the confined success condition.

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

[P2] Start a fresh output capture when a settled shell task ID is reused. Shell log creation and byte accounting open the ID-derived file in append mode but start counting from zero. After settlement, a new shell using the same ID can mix its output with the previous task’s log and exceed the per-file limit. Allocate a fresh capture for the new task without overwriting the settled task’s retained output, as the settlement contract requires.

The previous removal contract blocker also remains. Static source review only. Exact CI has passed static checks and macOS native; Linux verification was still running at review time.

@yyhhyyyyyy yyhhyyyyyy 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: #2002 Serve hostPlatform's data methods; withdraw the execHost face

Reviewed head a3c0e722b477a4cd389242c16a4582267c3fff59 against origin/main b48595585910bf5c880ef2358f3f105940fd79a2. This is a full main...head review; the six commits after b6ed380f are included.

Summary

The change makes hostPlatform a process-scope data face and withdraws the design-only execHost. It serves info, the command task operations, the persistent shell operations, the configured and confined helpers, output removal and child path; Hooks, OCR, SessionFiles, MCP and BackgroundExec now call these operations. The service scope, catalog entry and Linux generated TypeScript are consistent. macOS targeted tests and clippy pass.

The head still has three blockers: a path traversal in the served removal, an existing modality test that now fails because the confined path error type is lost, and the host-dependent committed declaration. The contract contradictions, the missing settlement rule and the untyped path boundary from previous rounds also remain.

Verdict: REQUEST_CHANGES

Blocking

P1: removeOutputDirectory deletes directories outside execRoot

Problem: remove_output_directory (host_platform.rs:746) delegates to remove_exec_directory, which accepts any path that is a lexical starts_with of the root (host_platform.rs:3052) and calls std::fs::remove_dir_all (:3058). Path::starts_with compares components without normalizing, so execRoot/sub/../../outside passes.

Failure scenario: any plugin in the process scope calls removeOutputDirectory({path: "<home>/.dim/exec/../.."}). The check passes, and remove_dir_all deletes <home>, <home>/.dim, or any directory the user can write, including the session database. I verified with the pinned 1.100.0 toolchain that Path::starts_with returns true for this shape and fs::remove_dir_all deletes the target outside the root. The SessionFiles caller repeats the same lexical check (storage/files.rs:369), so the owner has no stricter boundary. The new test only passes exec_root itself (host_platform_flow.rs:1590-1596).

Fix: reject non-Normal components; canonicalize the target, or its parent when absent, and compare against the canonical root; remove through a handle that does not follow symlinks. Add tests for .., a symlinked component, an absent target and exec_root itself.

P1: the confined path error is flattened and an existing test fails

Problem: spawn_confined maps ConfinedError::InvalidPath to HostPlatformError::Invalid(String) (host_platform.rs:724-727), so HostPlatformError::InvalidPath is never constructed. The OCR engine still matches that variant to tell a helper copy that disappeared (executor_error, "unreadable") from a caller path error (modality/engine.rs:2342-2351); that branch is dead.

Failure scenario: ocr_plugin_helper_copy_gone_before_spawn_fails_the_task now gets invalid_input and "invalid request: invalid confinement path ... No such file or directory" instead of executor_error and "unreadable". CI verify (linux) failed on this test at the head (run 45014510911); I reproduced the same failure locally on macOS with the pinned toolchain.

Fix: map the typed error to HostPlatformError::InvalidPath { path }, keep the reason in the message or add it to the variant, and rerun the modality suite.

P1: the committed TypeScript still depends on the host OS

Problem: the three sandbox_backend definitions carry different doc comments (host_platform.rs:939-965) and xtask types selects one by host cfg. The committed file contains the Linux doc (npm/branch-services.d.ts:392-396); the final commit did not change this.

Failure scenario: at this head on macOS, cargo run -p xtask -- check exits 1 with service declarations are stale. xtask types changes only that comment to macOS always has sandbox-exec, and the check passes with it. The post-merge verify (macos) job runs the same check on push, so main fails after merge; committing the macOS output fails Linux static-checks.

Fix: give the three variants one doc comment, or one method with cfg branches in its body, then regenerate once.

P2: wait with timeoutMs still terminates the task

Problem: the typed reply is fixed (WaitReply, host_platform.rs:375-391), but the timeout still kills. CommandTask::wait cancels self.timeout when the wait deadline elapses (exec.rs:2314-2326); the supervisor maps it to Observed::TimedOut and terminates the tree (exec.rs:2218-2234). ShellTask::wait does the same (host_platform.rs:3515-3524). The generated comment now says cancelled ends only the wait, which makes timeoutMs look harmless (npm/branch-services.d.ts:412-427).

Failure scenario: a caller polls wait({taskId, timeoutMs: 1000}) on a long build; after one second the build is killed and the record is terminal timed_out. A second waiter without a timeout then loses the task too. resource-faces.md:82 says cancelling a process is kill.

Fix: remove the cancellation from wait and return a non-terminal result, or document the terminating deadline in the owner document and the generated comment, and test both task kinds.

P2: spawn still reuses a settled id whose log exists, and task_exists is unreachable

Problem: spawn lets the caller choose the id; start_command checks only the live table (exec.rs:1985-1990), while the capture opens <outputDir>/<taskId>.log with create_new(true) (exec.rs:1864). A settled task keeps the log, so the same id can be spawned again. HostPlatform::spawn maps every ProcessSpecError to Failed (host_platform.rs:1039-1041), so the generated task_exists code never occurs.

Failure scenario: a caller uses a stable id build, settles it, and spawns build again. The second spawn returns success; when the command writes enough output to spill, the capture fails, the supervisor kills the tree, and wait reports failed. The same happens with an unusable outputDir, and with a Windows reserved name such as CON.

Fix: check the planned log path before starting, use unique ids or create_new semantics, map known ProcessSpecError codes to TaskExists, and test duplicate, reused and unusable paths.

P1: the persistent shell log is unowned, never removed, and persists private output

Problem: start_shell opens <outputDir>/<id>.log with create plus append (host_platform.rs:3292-3300) and writes every PTY chunk there (:3341-3347). The file is opened without a mode on Unix, unlike command logs, which use 0600 (exec.rs:1865-1866), so the shell log is created 0644 under the default umask. ShellSession registers only occupying and background task logs (shell_session.rs:1024-1052, :1119); Session deletion builds candidates from session_output_owners rows (storage/files.rs:324-377). A session that only runs a foreground shell command leaves its shell log without a row, so delete never removes it. A caller-chosen shell id reused after settle appends to the old log.

Failure scenario: every deleted foreground-only session leaks a log of up to 64 MiB under <home>/.dim/exec; a reused id mixes two sessions' output in one file; !! private command output, which previously stayed in memory, is persisted and can be readable by another local user when the home directory is traversable. ADR 013 D2 says shell output registers.

Fix: create a new log with create_new and mode 0600, register the shell log with SessionFiles when the shell starts (ADR 013 D2), and test a foreground-only session delete.

P2: service-faces.md still contradicts itself and misnames skipped methods

Problem: line 163 says hostPlatform's public methods are only info, execShell, persistentShell, sandboxBackend and execRoot, and that task and shell operations stay on toolHost, backgroundExec and sessionMethods.shell. Line 126 lists spawn, wait, kill, settle, output, retainOutput, tail, shell, write, resize, spawnWithStdin, spawnConfined, removeOutputDirectory and childPath; the catalog serves them (catalog.md:27). Line 126 also says spawn_with_stdin and child_path stay skipped, but those are the served names; the skipped methods are spawn_with_stdin_process and child_path_process (host_platform.rs:866, :1288). It also places the already served shell, write and resize in Stage 2 and names configured and confined, the internal cores, for Stage 3.

Failure scenario: an implementer using this section either records served operations as internal or waits for Stage 2/3 work that is already in the head.

Fix: one method list, the real skipped Rust names, and no Stage labels for operations already served.

P2: resource-faces.md section 6 still contradicts section 3

Problem: line 634 says the public data methods are only info, exec_shell, sandbox_backend and exec_root, and that the spawn methods are internals. Section 3 at line 103 and the catalog serve the full set.

Failure scenario: a caller migration records the wrong contract or re-adds internal(object).

Fix: replace the method list, as requested in the previous round.

P2: the HostPlatform owner document still denies the new state and has no data face

Problem: HostPlatform.md:17 says no plugin background tasks; :47-50 says process lifetime belongs to each caller/supervisor and raw spawn is an execution mechanic; :138 describes spawn as the primitive. The head has a process task table, supervisors, pipe pumps, a shutdown effect and tasks retained until settle (host_platform.rs:251-253, :1828-1843; exec.rs:1969-2052). The page named as the owner document for the face (resource-faces.md:103) has no data face section, no task id scope, no settle rule, no error codes and no precondition for removeOutputDirectory.

Failure scenario: a leaf implementer cannot find the settlement, id reuse, output retention or removal boundary rules, and the removal traversal above goes unnoticed.

Fix: add a data face section in the form of WorkspaceTools.md, update Events and lifetime, and rename the primitive references to spawn_tree and spawn_with_stdin_process.

P2: the PTY is still attributed to the wrong service

Problem: resource-faces.md:742 says sessionMethods.shell keeps the PTY primitives, and the table at :106 groups sessionMethods.shell and ShellSession. sessionMethods.shell serves shell.run, shell.stop and shell.list (shell_input.rs:4-6); the persistent PTY is owned by ShellSession, and the served primitives are hostPlatform.shell, write, resize and output (host_platform.rs:1103, :1160, :1174, :1188). Open decision 4 at :719-722 still describes them as future work.

Failure scenario: an implementer looks for the PTY operations on sessionMethods.shell, finds none, and duplicates or defers them.

Fix: attribute the PTY to ShellSession and hostPlatform, link the owner material, and close or rewrite decision 4.

P2: the settlement and retention rule is still missing

Problem: open decision 8 cites section 3.8 twice (resource-faces.md:732, :734), but the document has no section 3.8. No section states who must settle, what happens if a caller never settles, whether an id can be reused, or who removes a log. The new spawn makes the table grow until the owner unloads, and the shell log leak above is the first consequence.

Failure scenario: a provider that spawns tasks and never settles grows the process table without bound; a provider that settles loses the terminal record; a repeated start is accepted and fails later.

Fix: state the rule in section 3 or in the owner document and point decision 8 at it.

P2: PathBuf still crosses the data face, and the migrated callers replace native paths

Problem: service faces section 1 and AGENTS.md say PathBuf and OsString do not cross. The new requests and replies use PathBuf in HostInfo.home, exec_root and platform_roots (host_platform.rs:612-621), SpawnRequest and SpawnReply.output_path (:525-540), WaitReply.output_path (:384), ShellRequest and RemoveOutputDirectoryRequest. Serde rejects a non-UTF-8 PathBuf when it encodes the reply. The final commit documented the UTF-8 boundary only for ChildPathRequest and SpawnWithStdinRequest.

Failure scenario: a host whose home contains non-UTF-8 bytes cannot answer info; a spawn whose output path is non-UTF-8 starts the task but fails to encode SpawnReply, so the caller loses the task id. The migrated in-process callers also convert native values lossily: Hooks converts DIMCODE_HOME and DIM_PLUGIN_ROOT (hooks/runner.rs:488, :495), MCP converts the PATH base (mcp/server/stdio.rs:161-165), and OCR converts the helper program, arguments and environment (modality/engine.rs:2291-2305). An MCP child with a non-UTF-8 PATH entry silently loses the runtime directories.

Fix: define one string path policy with an explicit error when a value cannot be represented; apply it to every request and reply; keep a lossless in-process binding for native values or reject them; test one non-UTF-8 home and one non-UTF-8 PATH.

Non-blocking

  • P3: Hooks now reports a handler cancelled by unload as failed cancelled instead of Hooks was unloaded. cancelled_by cancels the process on the unload gate (hooks/runner.rs:505-530), spawn_with_stdin returns Ok with status Cancelled, and run_one maps that to failed("cancelled") (:437) before the unload select can answer unloaded_run (:717-723). Hooks.md:186 and :504 require the unloaded reason.
  • P3: the generated spawnConfined comment carries the old spawnWithStdin text (Self::spawn and stdin; host_platform.rs:688-691, branch-services.d.ts:368).
  • P3: retainOutput returns TaskUnknown for a shell id while output, tail, wait, kill and settle accept it (host_platform.rs:1212-1218; exec.rs:2070-2076).
  • P3: spawn_with_stdin leaks its cancellation waiter on every early error. It spawns the waiter at host_platform.rs:769-776 but calls waiter.abort() only after configured returns Ok (:794-806), so invalid base64, a preparation failure, a spawn failure or a wait failure returns early and leaves the waiter alive until the caller's token is cancelled. Repeated invalid requests leak one task each.
  • P3: WorkspaceTools.md:578 still says P:HostPlatform is used to stop a running task, but BackgroundExec.stop uses its own cancel token; the dependency is for retained output.
  • P3: resource-owner-operations.md:10 repeats the wrong skipped names and the Stage 2/3 labels from service-faces.md:126.
  • P3: npm/plugin.d.ts:261-267 re-exports only HostPlatform and HostInfo; the request and reply types are not nameable from dimcode/plugin.
  • P3: command_files is never Some (crates/dim-app-server/src/lib.rs:997 and the integration tests), so the FileStorage branch of retained_output_page is dead (host_platform.rs:3098-3135).
  • P3: the new face tests are still thin. They cover info, spawn/wait/output/settle, one shell, spawnWithStdin, spawnConfined and one removal. They miss kill, tail, retainOutput, duplicate and reused ids, invalid requests, both wait timeouts, unload cleanup, sandboxed spawn, removal traversal and symlinks, and session deletion cleanup (host_platform_flow.rs:1199-1598).
  • P3: the PR description still says spawn, spawnWithStdin, childPath and the other handle methods stay off the service, that task operations stay in their existing services, and that 19 tests pass. The head serves them and the modality test fails.
  • P3: HostPlatform::output clamps a zero limit to one byte (host_platform.rs:1192), while backgroundExec.outputPage rejects zero (WorkspaceTools.md:555). Pick one rule.
  • P3: service-faces.md:132 still links resource and store data faces after the rename.

Previous findings

  • Fixed: the macOS unused import. service.rs was folded into host_platform.rs, and clippy passes on macOS at this head.
  • Partly fixed: removeOutputDirectory is now the served method and SessionFiles calls it; configured is still named at resource-faces.md:657 and :704. The wait reply is typed; the timeout still terminates. The UTF-8 request boundary is documented for two request types only.
  • Withdrawn: the broad dangling section reference finding; only the section 3.8 references remain, under the settlement finding. The optional timezone note is withdrawn.
  • The inline findings on service-faces.md:163, resource-faces.md:634, the spawn lifecycle, the dead command_files branch, the PTY attribution and the plugin.d.ts exports are unchanged. They are not repeated inline.

Verification

  • cargo run --locked -p xtask -- check with the pinned 1.100.0 toolchain on macOS: exit 1, service declarations are stale. xtask types changes only the sandboxBackend doc, then the check passes.
  • cargo clippy --locked -p dim-agent-capabilities -p dim-app-server -p dim-modality --all-targets -- -D warnings on macOS: passed.
  • cargo test --locked -p dim-agent-capabilities --test capabilities_flow host_platform_flow: 22 passed.
  • cargo test --locked -p dim-modality --test modality_suite ocr_plugin_helper_copy_gone_before_spawn_fails_the_task: failed with invalid_input.
  • The traversal probe used Path::starts_with and fs::remove_dir_all with a .. path and confirmed the target outside the root was removed.
  • The migrated callers keep their boundary and do not drop failures: start_command still calls prepare_isolated_process (exec.rs:1977), Hooks' configured command keeps its existing no-approval path, OCR still requests the confined helper, SessionFiles maps the removal error, and Hooks reports spawn and wait failures. The OCR error classification changed, as the P1 above states. No new Approval or Permission path is added.
  • CI at this head: changes, macos-native and static-checks passed; verify (linux) failed on the modality test; ci-ok failed. The PR matrix does not run verify (macos).

Cross-PR

  • Against new origin/main b485955: merge-tree clean. The new main changes 21 files in CONTRIBUTING.md, README.md, the CLI and TUI, and one CLI test; none of them is touched by this PR, so no finding changes.
  • #1916 and #1997 merge cleanly with the head.
  • #1908 conflicts in crates/dim-app-server/src/lib.rs.
  • #1909 conflicts in shell_input.rs, crates/dim-app-server/src/lib.rs, npm/plugin.d.ts, service-faces.md and the generated catalog/local service files.
  • #1911 conflicts in crates/dim-app-server/src/lib.rs, service-faces.md and the generated catalog/local service files.
  • Those three PRs already conflict with current main in their own rebase; the shared generated files need regeneration after either side merges. #1881 conflicts only in crates/dim-report files this PR does not touch. #2001 is merged.

Unverified

  • Windows behavior of the new operations, including reserved task ids, path separators and the generated declarations.
  • The FileStorage branch of retained_output_page, which no assembly configures.
  • The leaf deployment claim in resource-faces.md:93-97, which depends on #1296.
  • The Hooks unload classification is source-level; no test exercises a handler running when the unload gate fires.
  • The shell log leak and the session delete path are source-level; no end-to-end delete test exists.

request: RemoveOutputDirectoryRequest,
) -> Result<(), HostPlatformError> {
let platform = self.clone();
tokio::task::spawn_blocking(move || platform.remove_exec_directory(&request.path))

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.

Problem: this serves remove_exec_directory, which validates with path.starts_with(&root) (line 3052). starts_with compares components lexically, so execRoot/sub/../../outside passes, and remove_dir_all (line 3058) resolves it outside the root. I confirmed with the pinned 1.100.0 toolchain that the check passes and the deletion reaches the sibling directory.

Failure scenario: a plugin in the process scope calls removeOutputDirectory({path: "<home>/.dim/exec/../.."}) and deletes <home>, <home>/.dim, the session database, or any directory the user can write. The SessionFiles caller repeats the same lexical check (storage/files.rs:369), so the owner boundary does not hold anywhere.

Fix: reject non-Normal components; canonicalize the target, or its parent when absent, and compare against the canonical root; remove without following symlinks. Add tests for .., a symlinked component, an absent target and exec_root itself; the current test only passes exec_root (host_platform_flow.rs:1590-1596).

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.

Fixed at 1e1f8c7. remove_exec_directory rejects non-absolute paths and . or .. components, canonicalizes the root and the deepest existing prefix, rejects a target outside the canonical root or equal to it, and rejects a final symlink (crates/dim-agent-capabilities/src/host_platform.rs:3103-3141). output_removal_refuses_traversal_and_links covers .., the root itself, a final symlink and an absent directory, and passes. SessionFiles uses the served method and falls through only on Invalid or InvalidPath (crates/dim-app-server/src/storage/files.rs:366-377). Residual, not blocking: an intermediate symlink that resolves inside execRoot is followed, and the test does not cover a symlinked root or the SessionFiles fallback.

let result = self.spawn_confined_process(spec, confinement, cancel).await;
waiter.abort();
let output = result.map_err(|error| match error {
confined::ConfinedError::InvalidPath { .. } => {

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.

Problem: ConfinedError::InvalidPath becomes HostPlatformError::Invalid(String), so HostPlatformError::InvalidPath is never constructed. The OCR engine still matches that variant at modality/engine.rs:2343 to classify a disappeared plugin copy as executor_error with "unreadable"; that branch is now dead.

Failure scenario: the existing test ocr_plugin_helper_copy_gone_before_spawn_fails_the_task fails. It receives invalid_input and "invalid request: invalid confinement path ...", not executor_error. CI verify (linux) failed on it at this head (run 45014510911), and I reproduced it locally on macOS.

Fix: map the typed error to HostPlatformError::InvalidPath { path }, keep the reason in the message or add a field for it, and rerun the modality suite.

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.

Fixed at 1e1f8c7. spawn_confined maps ConfinedError::InvalidPath { path, reason } to HostPlatformError::InvalidPath (crates/dim-agent-capabilities/src/host_platform.rs:754-763), and the OCR match destructures the new field (crates/dim-modality/src/engine.rs:2343-2344). cargo test --locked -p dim-modality --test modality_suite ocr_plugin_helper_copy_gone_before_spawn_fails_the_task passes with executor_error, and CI verify (linux) also passes.

Comment thread npm/branch-services.d.ts Outdated
*/
execShell(): Promise<ShellStatus>
/**
* The sandbox backend a new process would use: the same bubblewrap

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.

Problem: this generated file is host dependent. The three sandbox_backend definitions carry different doc comments (host_platform.rs:939-965), and xtask types selects one by host cfg. The committed file contains the Linux text.

Failure scenario: at this head on macOS, cargo run -p xtask -- check exits 1 with service declarations are stale. xtask types changes only this comment to macOS always has sandbox-exec, and the check passes with it. The post-merge verify (macos) job runs the same check on push, so main fails; committing the macOS output fails Linux static-checks.

Fix: give the three variants one doc comment, or one method with cfg branches in its body, then regenerate once.

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.

Fixed at 1e1f8c7. The three sandbox_backend definitions share one doc comment (crates/dim-agent-capabilities/src/host_platform.rs:972-995), the committed declarations carry it (npm/branch-services.d.ts:409), and cargo run --locked -p xtask -- check passes on macOS. CI static-checks and verify (linux) pass as well.

reason: error.to_string(),
})?;
let path = directory.join(format!("{id}.log"));
let mut file = std::fs::OpenOptions::new()

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.

Problem: the shell log is opened with create plus append and is never registered. ShellSession registers only occupying and background task logs (shell_session.rs:1024-1052, :1119), while Session deletion builds candidates from session_output_owners rows (storage/files.rs:324-377). A session that only runs a foreground shell command leaves <home>/.dim/exec/<session>/<branch>/shell-<uuid>.log with no row, so delete never removes it. The pump writes every PTY byte here (:3341-3347), including !! private command output that previously stayed in memory, and a caller-chosen shell task id reused after settle appends to the old log.

Failure scenario: deleted foreground-only sessions leak up to 64 MiB each; a reused id mixes two sessions' output in one file; private output is persisted. ADR 013 D2 says shell output registers.

Fix: open a new log with create_new, register the shell log with SessionFiles when the shell starts, and test a foreground-only session delete.

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.

Not fixed at ed06e16, and one correction to my earlier comment: this log carries the model's persistent execute shell, not the operator's !! input, which keeps its output in memory and in the Timeline (crates/dim-agent-capabilities/src/shell_input.rs:499-528). The new in-memory event queue (ShellEvents, crates/dim-agent-capabilities/src/host_platform.rs:3289-3349) writes no file and registers nothing. The pump still opens <outputDir>/<id>.log with create plus append and no mode (host_platform.rs:3416-3424) and writes every chunk there (:3467-3474). ShellSession still registers only the occupying and background logs (crates/dim-agent-capabilities/src/shell_session.rs:1038-1053, :1064-1066, :1131-1133), and Session deletion still builds candidates from session_output_owners rows (crates/dim-app-server/src/storage/files.rs:311-375). A foreground-only session still leaks the log, and the file is still created 0644 under a 022 umask, so the registration, cleanup and permission defects are unchanged. Dropping the log and its outputPath is the simpler fix now that the event queue serves remote readers; otherwise register it per ADR 013 D2 and add the foreground-only delete test.

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.

Fixed at 1e1f8c7 for the leak. The shell log is opened create_new with mode 0600 (crates/dim-agent-capabilities/src/host_platform.rs:3485-3500) and Drop for ShellTask removes it when the record is released (:3325-3329); the_host_platform_service_serves_a_shell asserts both. I withdraw the registration half: nothing reads the file now that the event queue serves readers. Two residuals, both P3. A PTY start failure after the open leaves an empty 0600 file and makes a retry with the same task id return task_exists (inline note). docs/design/resource-faces.md:120 still advertises the shell outputPath for file reads although the file disappears at settle. The simplest follow-up is to drop the log and its path entirely.

self.sources
.0
.home()
.map(|home| home.to_string_lossy().into_owned()),

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.

Problem: this in-process caller sends native paths through a UTF-8 data request, so home and plugin_root are replaced with U+FFFD by to_string_lossy (lines 488 and 495). The request comment says a non-UTF-8 environment belongs to the in-process binding, but the served spawn_with_stdin takes Strings only, and its in-process core configured now takes the same String request.

Failure scenario: a Session whose home or plugin root contains non-UTF-8 bytes on Unix gets a wrong DIMCODE_HOME or DIM_PLUGIN_ROOT; a hook that changes directory or reads under it fails or touches a replacement-character path. The same conversion is at mcp/server/stdio.rs:161-165 for the child PATH and at modality/engine.rs:2291-2305 for the OCR helper program, arguments and environment; a non-UTF-8 PATH entry silently drops the runtime directories.

Fix: keep the in-process binding lossless (pass OsString values through configured), or return an explicit error instead of a lossy conversion.

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.

Status changed at 984f6b5: fixed for the listed shapes and the callers, with two residuals. WaitReply.output_path, SpawnRequest, SpawnReply, ShellRequest, RemoveOutputDirectoryRequest, HostInfo and ExecShellRuntime are String or Vec<String> now; the Hooks, MCP, OCR, SessionFiles and test callers were updated; info rejects a non-UTF-8 home, exec root or platform root with HostPlatformError::Invalid, and available_shell rejects a non-UTF-8 shell path. Residual 1: execRoot still returns PathBuf; with a non-UTF-8 home, serde_json::to_value(platform.exec_root()) fails with path contains invalid UTF-8 characters instead of returning a typed error. Residual 2: ShellSession still converts its output_dir and workspace roots with to_string_lossy (crates/dim-agent-capabilities/src/shell_session.rs:452-459), and CommandTask output paths are lossy for a non-UTF-8 output root. Please keep this open for those two residuals.

Comment thread docs/design/service-faces.md Outdated
| 名字 | 现在的对象 | 目标操作 |
| --- | --- | --- |
| `hostPlatform` | `ProcessTree`、`PtyProcessTree`、临时目录 | 数据面 `execHost`:`start`/`wait`/`kill`/`settle`/`output`/`tail`/`removeOutputDirectory`/`shell`/`write`/`resize`/`info`/`confined`/`configured`([resource and store data faces](resource-faces.md) §3,#1295);`hostPlatform` 是提供方和它的 Rust binding |
| `hostPlatform` | `ProcessTree`、`PtyProcessTree`、临时目录 | 服务自身的方法就是公开操作:`info`、`execShell`、`persistentShell`、`sandboxBackend`、`execRoot`,以及 Stage 1 的命令任务操作 `spawn`/`wait`/`kill`/`settle`/`output`/`retainOutput`/`tail`/`shell`/`write`/`resize`/`spawnWithStdin`/`spawnConfined`/`removeOutputDirectory`/`childPath`;`spawn_tree`/`spawn_with_stdin`/`spawn_pty`/`build_process_spec`/`child_path` 保持 `#[service(skip)]`。不建 `execHost`;`shell`/`write`/`resize` 在 Stage 2,`configured`/`confined` 在 Stage 3([resource and store services](resource-faces.md) §3,#1295) |

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.

Problem: this row contradicts the head. spawn_with_stdin is served (host_platform.rs:764); the skipped method is spawn_with_stdin_process (:866). child_path is served (:740); the internal is child_path_process (:1288). shell, write and resize are served now (:1103, :1160, :1174), and the Stage 3 names configured and confined are the internal cores; the served operations are spawnWithStdin and spawnConfined (:764, :692).

Failure scenario: an implementer reads this as the migration map and records three served operations as internal, or defers work that is already in the catalog (catalog.md:27).

Fix: list only the truly skipped methods with their Rust names and drop the Stage labels for the operations already served.

The shell owner records the regularized stream as ordered ShellEvents with a cursor and ShellState. output takes eventCursor and waitMs, so a reader can page the stream and receive state; ShellSession consumes that log instead of the in-process channel. The optional channel sender stays for the A3 cleanup.
ShellSession reads the owner's event log, so start_shell no longer takes an output sender. The shell stream has one reader and one data path.

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

[P2] Drain the shell output before settling on exit. In the new event reader, an output read can go pending just before the owner publishes the terminal event page. If the liveness tick then observes exit, it settles and breaks without consuming that page. The branch can drop the last output or miss a completion marker and record a failure instead. Keep the single owner stream, but consume its remaining events through the terminal cursor before settling this generation.

The existing output capture and OCR findings remain in their respective reviews. This finding is from static inspection. Exact CI had passed static and macOS native checks; Linux was still running.

@yyhhyyyyyy yyhhyyyyyy 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: #2002 Serve hostPlatform's data methods; withdraw the execHost face

Reviewed head ed06e166 against origin/main b4859558. Full main...head review. This is round 7; the two commits after a3c0e722 add an in-memory shell event log (509ba413f) and remove the in-process channel (ed06e1660).

Summary

The face itself is coherent: hostPlatform is a process data face with 19 served methods, the catalog and Linux TypeScript agree, and Hooks, OCR, SessionFiles, MCP and BackgroundExec call the owner. macOS clippy for the touched crates passes, and the 22 host_platform tests pass. Four P1 defects remain, and CI verify (linux) still fails on the OCR test.

The new event log does not touch the unregistered shell log file. It adds a bounded, lossy queue in front of the persistent shell, and a reader that falls 1 MiB behind now terminates a healthy shell. Its ShellState is derived from the echoed wrapper line, so it reports ready while a command runs.

Verdict: REQUEST_CHANGES.

Blocking

P1: removeOutputDirectory still deletes directories outside execRoot

Problem: remove_exec_directory validates with path.starts_with(&root) (crates/dim-agent-capabilities/src/host_platform.rs:3102) and then calls std::fs::remove_dir_all(path) (:3108). Path::starts_with compares components lexically, so .. passes, and remove_dir_all follows an intermediate symlink. The served method (:774-789) exposes this to every process-scope caller; SessionFiles repeats the same lexical check (crates/dim-app-server/src/storage/files.rs:369-375).

Failure scenario: a plugin calls removeOutputDirectory({path: "<info.execRoot>/session/branch/../../../../../somewhere"}) and deletes any directory the user can write, including the database directory. I reran the probe with the pinned 1.100.0 toolchain: starts_with returns true for that shape, remove_dir_all deletes the target outside the root, and a path through an intermediate symlink also deletes the linked directory. A second failure sits in the same comparison: exec_root() canonicalizes the root (host_platform.rs:996-999) while ShellSession registers non-canonical paths (crates/dim-agent-capabilities/src/shell_session.rs:1516-1520), so a symlinked ~/.dim/exec makes every shell candidate fail the starts_with test and blocks session deletion.

Fix: reject .. and . components, canonicalize the target or its deepest existing ancestor and compare against the canonical root, and remove without following symlinks. Use the same canonical form on both sides of the comparison. Add tests for .., an intermediate symlink, an absent target, a symlinked execRoot, and execRoot itself; the current test only covers an existing child and execRoot (crates/dim-agent-capabilities/tests/host_platform_flow.rs:1571-1604).

P1: the confined path error is flattened, and an existing test fails

Problem: spawn_confined still maps ConfinedError::InvalidPath to HostPlatformError::Invalid(String) (crates/dim-agent-capabilities/src/host_platform.rs:752-755), so HostPlatformError::InvalidPath is never constructed. The OCR engine matches that variant to tell a helper copy that disappeared (crates/dim-modality/src/engine.rs:2343-2352) from a caller path error; the branch is dead.

Failure scenario: the existing test ocr_plugin_helper_copy_gone_before_spawn_fails_the_task fails. At this head I reproduced invalid_input and "invalid request: invalid confinement path /pp-ocr-plugin: No such file or directory" instead of executor_error and "unreadable". CI verify (linux) failed on the same test in run 45019591519, job 137199526132.

Fix: map the typed error to HostPlatformError::InvalidPath { path }, keep the reason in the message or add a field, and rerun the modality suite.

P1: the committed TypeScript still depends on the host OS

Problem: the three sandbox_backend definitions still carry different doc comments (crates/dim-agent-capabilities/src/host_platform.rs:967-993), and xtask types selects one by host cfg. The committed file has the Linux bubblewrap text (npm/branch-services.d.ts:410-411).

Failure scenario: at this head on macOS with the pinned 1.100.0 toolchain, cargo run --locked -p xtask -- check exits 1 with service declarations are stale. xtask types changes only that comment to macOS always has sandbox-exec, and the check then passes. The post-merge verify (macos) job runs the same check on push, so main fails after merge; committing the macOS output fails Linux static-checks.

Fix: give the three variants one doc comment, or one method with cfg branches in its body, then regenerate once.

P1: the persistent shell log is unowned, never removed, and persists unbounded shell output

Problem: the new commits do not change this path. start_shell opens <outputDir>/<id>.log with create plus append and no mode (crates/dim-agent-capabilities/src/host_platform.rs:3416-3424), unlike command logs, which use create_new and 0600 (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:1851-1866). The pump writes every PTY chunk there (host_platform.rs:3467-3474). ShellSession registers only the occupying and background logs (crates/dim-agent-capabilities/src/shell_session.rs:1038-1053, :1064-1066, :1131-1133), and Session deletion builds candidates from session_output_owners rows (crates/dim-app-server/src/storage/files.rs:311-375). The new ShellEvents queue is in memory only (host_platform.rs:3289-3349); it does not register or remove the file.

Failure scenario: every deleted foreground-only session leaks a log of up to 64 MiB under <home>/.dim/exec, and a caller-chosen shell id reused after settle appends to the old log. The log is created 0644 under a 022 umask, so the full output of the model's persistent shell, which previously stayed in the 64 KiB in-memory capture and the bounded tool result, is now persisted beyond the session and readable by another local user who can traverse the home. This is the model's execute shell, not the operator's !! input, which keeps its output in memory and in the Timeline (crates/dim-agent-capabilities/src/shell_input.rs:499-528). ADR 013 D2 says shell output registers.

Fix: open a new log with create_new and mode 0600, and register the shell log with SessionFiles when the shell starts, or drop the shell log and its outputPath now that the event queue serves remote readers. Add a foreground-only session delete test.

P2: the new event log terminates a healthy shell when 1 MiB is exceeded

Problem: ShellSession treats a reset from the event page, or eventRetainedFrom > eventCursor, as shell death and calls shell.terminate() (crates/dim-agent-capabilities/src/shell_session.rs:622-630). The owner retains only EVENT_RETAIN_CHARS = 1 MiB and drops the oldest events (crates/dim-agent-capabilities/src/host_platform.rs:3287, :3321-3326). The reader thread pushes 4 KiB chunks without backpressure (:3445-3481), while handle_output consumes a page one event at a time.

Failure scenario: a persistent shell command such as seq 1 400000, cat of a large file, or a multi-megabyte build log emits more than 1 MiB while the consumer processes a page. retained_from advances past event_cursor, the next output call returns reset, and the read path kills the PTY. handle_shell_exit(generation, None) then fails the occupying task and the POSIX background jobs with [shell exited], and the command result becomes an error. Before these two commits the unbounded mpsc channel never dropped chunks, so the same command completed and only the bounded 16 KiB tool result was truncated.

Fix: keep the session's delivery lossless. The simplest options are to restore the in-process channel for ShellSession and serve the bounded event log only to other readers, or to make the queue unbounded or blocking for the session reader. Do not terminate the shell from the read path; a reader that falls behind should fail its own read, and kill should remain the only operation that ends a process.

P2: ShellState reports ready while a command runs

Problem: ShellEvents::push derives state from prefix scans of the raw stream (crates/dim-agent-capabilities/src/host_platform.rs:3298-3313). An interactive shell echoes the wrapper command line before running it, and that echo contains both __DIM_START_ and __DIM_END_ (crates/dim-agent-capabilities/src/shell_session.rs:1801-1810). The echoed chunk therefore sets busy=false, ready=true, and last_code to the quoted shell syntax after the echoed end prefix. A later chunk that contains only the start marker then sets busy=true; if the echo and the start marker share a chunk, the state stays ready=true for the whole command. A chunk boundary inside the end marker leaves last_code stale, because the second half carries no __DIM_END_.

Failure scenario: a remote reader that uses state.ready to gate the next command, which is what the new read advertises, receives the echo event page with ready=true while the command is still running and sends the next command into the occupied shell. A command that prints __DIM_START_ also flips busy, and a printed fake marker changes lastCode.

Fix: buffer the tail across chunks and recognize the full marker (__DIM_START_ plus two 8-hex runs and __, and the end marker plus its code), as Capture::append and marker_code already do, so the echo and user output cannot match. Alternatively keep the state parser in ShellSession and do not expose ShellState until it is correct.

P2: wait with timeoutMs still terminates the task

Problem: the typed reply is fixed, but the deadline still kills. CommandTask::wait cancels self.timeout when the wait deadline elapses (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:2314-2326); the supervisor maps it to Observed::TimedOut and terminates the tree (:2212-2233). ShellTask::wait does the same (crates/dim-agent-capabilities/src/host_platform.rs:3676-3685). The generated comment says cancelled ends only the wait, which makes timeoutMs look harmless (npm/branch-services.d.ts:428-432), and resource-faces says cancelling a process is kill (docs/design/resource-faces.md:84-85).

Failure scenario: a caller polls wait({taskId, timeoutMs: 1000}) on a long build; after one second the build is killed and the record is terminal timed_out. A second waiter without a timeout loses the task too.

Fix: remove the cancellation from wait and return a non-terminal result, or document the terminating deadline in the owner document and the generated comment, and test both task kinds.

P2: spawn still reuses a settled id, and task_exists is unreachable

Problem: start_command checks only the live table (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:1985-1990), while the capture opens <outputDir>/<taskId>.log with create_new(true) (:1864). A settled task keeps its log, so the same id can be spawned again. HostPlatform::spawn maps every ProcessSpecError to Failed (crates/dim-agent-capabilities/src/host_platform.rs:1051-1069), and shell does the same (:1177-1179), so the generated task_exists code never occurs (npm/branch-services.d.ts:188, :1712).

Failure scenario: a caller settles build and spawns build again. The second spawn returns success; when the command writes enough output to spill, the capture fails, the supervisor kills the tree, and wait reports failed after the spawn reported success. An unusable outputDir and a Windows reserved name such as CON fail the same way.

Fix: check the planned log path before starting, map known ProcessSpecError codes to TaskExists, and test duplicate, reused and unusable ids.

P2: the contract documents still contradict the served face

Problem: docs/design/service-faces.md:126 still names spawn_with_stdin and child_path as skipped, but the served methods are spawnWithStdin and childPath and the skipped cores are spawn_with_stdin_process and child_path_process (crates/dim-agent-capabilities/src/host_platform.rs:894, :1338). It also puts the already served shell, write and resize in Stage 2 and the internal cores configured and confined in Stage 3. docs/design/service-faces.md:163 says the public methods are only info, execShell, persistentShell, sandboxBackend and execRoot, and that task and shell operations stay on other owners. docs/design/resource-faces.md:636 says the same four methods. docs/design/resource-faces.md:106 and :744 attribute the PTY to sessionMethods.shell / ShellInput, while ShellInput serves shell.run, shell.stop and shell.list (crates/dim-agent-capabilities/src/shell_input.rs:628-633) and ShellSession owns the persistent PTY. Open decision 4 at resource-faces.md:721-723 still treats write, resize and output as future work.

Failure scenario: an implementer reading the migration map records served operations as internal, keeps a duplicate task operation on backgroundExec, or waits for Stage 2 work that is already in the catalog (docs/architecture/rust-agent/generated/catalog.md:27).

Fix: one method list in each document, the real skipped Rust names, no Stage labels for served operations, and the PTY attributed to ShellSession and hostPlatform.

P2: the HostPlatform owner document has no data face and denies the owner's state

Problem: docs/architecture/rust-agent/plugins/HostPlatform.md:17 says no plugin background tasks, and :47-49 says process lifetime belongs to each caller or supervisor. The head has a process task table, supervisors, pipe pumps, a shutdown effect and tasks retained until settle (crates/dim-agent-capabilities/src/host_platform.rs:251-253, :1828-1843; crates/dim-agent-capabilities/src/workspace_tools/exec.rs:1969-2053). The document has no data face section, no task id scope, no settle rule, no error codes, no remove_output_directory precondition, and no description of OutputRequest.eventCursor, waitMs, ShellEvent or ShellState. :138 names the core spawn_with_stdin as the primitive, which is now the served request method.

Failure scenario: a leaf implementer cannot find the settlement, id reuse, output retention, event reset or removal boundary rules, and the traversal above goes unnoticed. The new event read exists only as a paragraph in docs/design/resource-faces.md:118-125, not in the linked owner.

Fix: add a data face section in the form of WorkspaceTools.md, update Events and lifetime, rename the primitives, and state the event cursor and reset semantics. Update the Tests list.

P2: the settlement rule is still missing

Problem: open decision 8 cites section 3.8 twice (docs/design/resource-faces.md:734, :736), but the document has no section 3.8. No section states who must settle, what happens if a caller never settles, whether an id can be reused, or who removes a log.

Failure scenario: a provider that spawns tasks and never settles grows the process table until the owner unloads; a provider that settles loses the terminal record; a repeated start is accepted and fails later.

Fix: state the rule in section 3 or in the owner document and point decision 8 at it.

P2: PathBuf still crosses the data face, and the migrated callers replace native paths

Problem: service faces section 1 and AGENTS.md say PathBuf and OsString do not cross. The requests and replies use PathBuf in HostInfo.home, exec_root and platform_roots (crates/dim-agent-capabilities/src/host_platform.rs:638-650), SpawnRequest and SpawnReply.output_path (:546-564), WaitReply.output_path (:377-384), ShellRequest and RemoveOutputDirectoryRequest. Serde rejects a non-UTF-8 PathBuf when it encodes the reply. Hooks converts DIMCODE_HOME and DIM_PLUGIN_ROOT with to_string_lossy (crates/dim-agent-capabilities/src/hooks/runner.rs:483-496), MCP converts the PATH base (crates/dim-app-server/src/mcp/server/stdio.rs:157-166), and OCR converts the helper program, arguments and environment (crates/dim-modality/src/engine.rs:2291-2305).

Failure scenario: a host whose home contains non-UTF-8 bytes cannot answer info; a spawn whose output path is non-UTF-8 starts the task but fails to encode SpawnReply, so the caller loses the task id. A hook or MCP child with a non-UTF-8 path gets U+FFFD and silently loses the runtime directories.

Fix: define one string path policy with an explicit error when a value cannot be represented, apply it to every request and reply, and keep a lossless in-process binding for native values or reject them. Test one non-UTF-8 home and one non-UTF-8 PATH.

Non-blocking

  • P3: the new event test asserts only that one page is non-empty after the shell exited (crates/dim-agent-capabilities/tests/host_platform_flow.rs:1412-1419). It does not test waitMs when no event exists, cursor paging, retention and reset, ShellState, a second reader, or ShellSession consuming the stream. No test runs a burst beyond 1 MiB, which is where the reset path above is reached.
  • P3: the event path ignores OutputRequest.limit (crates/dim-agent-capabilities/src/host_platform.rs:1219-1234), so a caller asking for a small page can receive the whole 1 MiB retention. The generated output comment still says only "Reads a page of a task's captured output" and documents neither the event fields nor the reset.
  • P3: WorkspaceTools.md:578 says P:HostPlatform is used to "stop a running task", but BackgroundExec.stop cancels its own token (crates/dim-agent-capabilities/src/workspace_tools/background.rs:502-510); the dependency is for retained output.
  • P3: Hooks still reports a handler cancelled by unload as failed cancelled, not Hooks was unloaded. cancelled_by cancels the process on the unload gate (crates/dim-agent-capabilities/src/hooks/runner.rs:505-526), spawn_with_stdin returns status Cancelled, and run_one maps that to failed("cancelled") (:437) before the gate branch at :408-410 can answer, which is unreachable because configured is called with no gate (crates/dim-agent-capabilities/src/host_platform.rs:822-833).
  • P3: the generated spawnConfined comment carries the old spawnWithStdin text (crates/dim-agent-capabilities/src/host_platform.rs:716-719; npm/branch-services.d.ts:386-393).
  • P3: retainOutput returns TaskUnknown for a shell id while output, tail, wait, kill and settle accept it (crates/dim-agent-capabilities/src/host_platform.rs:1262-1268; crates/dim-agent-capabilities/src/workspace_tools/exec.rs:2070).
  • P3: spawn_with_stdin leaks its cancellation waiter on every early error. It spawns the waiter at crates/dim-agent-capabilities/src/host_platform.rs:798-804 but calls waiter.abort() only after configured returns Ok (:834), so invalid base64, a preparation failure, a spawn failure or a wait failure returns early and leaves the waiter alive until the caller's token is cancelled.
  • P3: docs/design/contracts/resource-owner-operations.md:10 repeats the wrong skipped names and the Stage 2/3 labels from service-faces.md:126.
  • P3: npm/plugin.d.ts:264 re-exports only HostPlatform and HostInfo. The face now also returns or takes ShellStatus, SandboxBackend, ExecShellRuntime, Os, ShellEdition, ShellSource, OutputEncoding, OutputPage, OutputTail, OutputPathReply, ShellEvent, ShellState, SpawnRequest, SpawnReply, WaitRequest, TaskRequest, OutputRequest and HostPlatformError. A plugin following the authoring guide cannot name them from dimcode/plugin.
  • P3: command_files is never Some (crates/dim-app-server/src/lib.rs:997; both integration assemblies), so the FileStorage branch of retained_output_page is dead (crates/dim-agent-capabilities/src/host_platform.rs:3148-3185). Wiring it or removing it is a follow-up.
  • P3: the PR description still says spawn, spawnWithStdin, childPath and the other handle methods stay off the service, that task operations stay in their existing services, and that 19 tests pass. The head serves them, has 22 host_platform tests, and adds the event read.
  • P3: HostPlatform::output clamps a zero limit to one byte (crates/dim-agent-capabilities/src/host_platform.rs:1219), while backgroundExec.outputPage rejects zero (docs/architecture/rust-agent/plugins/WorkspaceTools.md:555). Pick one rule.

Previous findings

  • Fixed at this head: none of the six inline findings. 509ba413f and ed06e1660 do not touch the removal validation, the confined error mapping, the generated declaration, the shell log, the lossy path conversions, or service-faces.md:126.
  • Still open: the six inline findings and every P2 above.
  • Withdrawn: none. The previously withdrawn broad dangling-reference and timezone notes stay withdrawn. The command_files dead branch and the stale PR description can move to a follow-up if the blocking items are fixed first.
  • The new commits add public contract surface (ShellEvent, ShellState, eventCursor, waitMs) and a regression, while four P1s remain. If the session does not need to read through the face, reverting the two commits and keeping the in-process channel is the smaller change; the event read can be a separate PR with its own tests.

Verification

  • cargo run --locked -p xtask -- check with the pinned 1.100.0 toolchain on macOS: exit 1, service declarations are stale (npm/branch-services.d.ts).
  • cargo clippy --locked -p dim-agent-capabilities -p dim-modality --all-targets -- -D warnings on macOS: passed.
  • cargo test --locked -p dim-agent-capabilities --test capabilities_flow host_platform_flow: 22 passed.
  • cargo test --locked -p dim-modality --test modality_suite ocr_plugin_helper_copy_gone_before_spawn_fails_the_task: failed with invalid_input.
  • The traversal probe used the pinned toolchain and confirmed the lexical starts_with pass, the deletion outside the root, and the intermediate symlink follow.
  • The event reset and state findings are source-level; no test drives a burst past 1 MiB or reads ShellState during the echo.
  • CI at this head: changes, static-checks and macos-native passed; verify (linux) failed on the OCR test; ci-ok failed. The PR matrix does not run verify (macos).

Cross-PR

  • Against origin/main b4859558: merge-tree clean. Main changed no file this PR touches.
  • #1916 and #1997 merge cleanly with the head.
  • #1908 conflicts in crates/dim-app-server/src/lib.rs.
  • #1909 conflicts in crates/dim-agent-capabilities/src/shell_input.rs, crates/dim-app-server/src/lib.rs, the connection and tree files, crates/dim-report/src/evidence.rs, npm/plugin.d.ts, docs/design/service-faces.md, the generated catalog and local service files, the plugin pages and the timeline branch docs.
  • #1911 conflicts in the prompt and recovery files, crates/dim-agent-runtime/src/agent.rs, names.rs, crates/dim-app-server/src/lib.rs, the connection and session TypeScript files, docs/design/service-faces.md, the generated catalog and local service files, and the prompt integration test.
  • #1881 conflicts only in crates/dim-report/src/draft.rs and evidence.rs, which this PR does not touch. #2001 is merged.
  • The three conflicting PRs already conflict with current main in their own rebase; the shared generated files need regeneration after either side merges.

Unverified

  • Whether the 1 MiB event retention is exceeded in normal use on a loaded runtime; the failure is source-level and has no deterministic reproduction here.
  • Windows behavior of the new operations, including reserved task ids, path separators and the generated declarations.
  • The FileStorage branch of retained_output_page, which no assembly configures.
  • The leaf deployment claim in resource-faces.md:93-97, which depends on #1296.
  • The Hooks unload classification is source-level; no test exercises a handler running when the unload gate fires.
  • The shell log leak and the session delete path are source-level; no end-to-end delete test exists.

wait_ms: Some(100),
event_cursor: Some(event_cursor),
}) => if let Ok(page) = page {
if page.reset == Some(true)

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.

Problem: this treats a reset from the owner's event page as shell death and terminates the shell (lines 623-630). The owner retains only EVENT_RETAIN_CHARS = 1 MiB (crates/dim-agent-capabilities/src/host_platform.rs:3287) and drops the oldest events (ShellEvents::push, :3321-3326), while the pump pushes 4 KiB chunks with no backpressure (:3445-3481). A page that takes time to handle can lose its cursor to the trim.

Failure scenario: a persistent execute command such as seq 1 400000, a large cat, or a multi-megabyte build log emits more than 1 MiB while handle_output processes a page. retained_from advances past event_cursor, the next output call returns reset, and this branch kills the PTY. handle_shell_exit(generation, None) then fails the occupying task and the POSIX background jobs with [shell exited]. Before these two commits the unbounded mpsc channel delivered every chunk, so the command completed and only the bounded 16 KiB result was truncated.

Evidence: crates/dim-agent-capabilities/src/shell_session.rs:616-637; crates/dim-agent-capabilities/src/host_platform.rs:3287, :3298-3348, :3445-3481, :3561-3579; the channel is removed in ed06e1660.

Fix: keep the session reader lossless. Restore the in-process channel for ShellSession and serve the bounded event log only to other readers, or make the session's queue unbounded or blocking. Do not terminate a process from a read path; fail that read instead and leave kill as the only way to end a task.

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.

Fixed at a56c536. The session read loop no longer stops the shell on a reset or on eventRetainedFrom > eventCursor (crates/dim-agent-capabilities/src/shell_session.rs:631-641). The owner page acknowledges the cursor, drops consumed events and wakes the pump (crates/dim-agent-capabilities/src/host_platform.rs:3666-3694, :3977), and the pump waits instead of dropping (:3859-3868), so the single session reader cannot fall behind its base. The 400k-line burst tests occupying_task_settles_when_the_output_bursts_past_the_retained_window and occupying_task_settles_after_large_output pass. Residual, P3: a second event reader can still advance base past the session cursor, and the session now skips that window silently instead of noting a reset.


impl ShellEvents {
fn push(&mut self, text: String) {
if text.contains("__DIM_START_") {

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.

Problem: ShellState is derived from prefix scans of the raw stream, but an interactive shell echoes the wrapper command line before running it. The echoed line contains both __DIM_START_ and __DIM_END_ (the wrapper is built at crates/dim-agent-capabilities/src/shell_session.rs:1801-1810), so this chunk sets busy=false, ready=true, and last_code to the quoted shell syntax after the echoed end prefix. A later chunk that contains only the start marker then sets busy=true; if the echo and the start marker share a chunk, the state stays ready=true for the whole command. A chunk boundary inside the end marker leaves last_code stale because the second half carries no __DIM_END_.

Failure scenario: the advertised remote reader uses state.ready to decide when the shell is free. After the echo page it sees ready=true while the command is still running and sends the next command, which the occupied shell queues or mixes with the current one. A command that prints __DIM_START_ also flips busy, and a printed fake marker changes lastCode.

Evidence: crates/dim-agent-capabilities/src/host_platform.rs:3298-3313; crates/dim-agent-capabilities/src/shell_session.rs:102-113, :1801-1810; npm/branch-services.d.ts:353-357.

Fix: buffer the tail across chunks and match the full marker (__DIM_START_ plus two 8-hex runs and __, and the end marker plus its code), as Capture::append and marker_code already do, so the echo and user output cannot match. Or keep the state in ShellSession and do not expose ShellState until it is correct.

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.

Fixed at a56c536. ShellState is now derived from whole lines and full markers (crates/dim-agent-capabilities/src/host_platform.rs:3589-3617, :3630-3664). The POSIX wrapper echo with split fragments is not a full marker, and the three shell_marker_tests unit tests pass; an init line that carries both markers is classified by its last marker. Residual, P3: a command that prints a well formed marker line can still flip ready and lastCode.

)
.await
.unwrap();
assert!(!events["events"].as_array().unwrap().is_empty());

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.

Problem: the only test for the new read asserts that one page is non-empty after the shell already exited. It does not exercise waitMs when no event exists, cursor paging, retention and reset, ShellState, a second reader, or ShellSession consuming the stream, and no test produces a burst beyond the 1 MiB retention.

Failure scenario: the reset-kill and the wrong ready state above both pass the suite, so the feature ships untested at its failure points.

Evidence: crates/dim-agent-capabilities/tests/host_platform_flow.rs:1412-1419.

Fix: add a flow test that drives the persistent shell through ShellSession with output past 1 MiB and asserts the shell survives with the truncated result, a waitMs timeout with no event, and a state check across the echo and both markers.

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.

Partly addressed at a56c536. Two new flow tests and a unit test module exist, and the burst test does read event pages with a cursor (crates/dim-agent-capabilities/tests/host_platform_flow.rs:1764-1857). But the burst test fails on this host: 3 of 3 runs stopped after 2000 immediate page reads with 381046, 346176 and 336832 bytes served, below its 1 MB assertion (:1812, :1843), while CI macos-native passed at the same head. The fixed iteration count instead of a deadline makes it timing dependent, and it does not prove the 1 MiB cap was reached. The capture test never checks that the shell still produces output after the capture ends, which is why it misses the pump deadlock.

ShellSession starts with shell and uses write, resize, output, wait, kill and settle; NativeShell and the ShellTask handle are gone. Background shell jobs register in the owner under the branch task id; kill and settle translate the node-local pid, which never crosses the service boundary.

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

[P1] Keep task registration under HostPlatform ownership. The new background job registration path in host_platform.rs:3481–3493 does not enforce an owner-issued pending registration or preserve an occupied task ID. That breaks the task table’s identity invariant: later lifecycle calls may address the wrong record. Reserve the ID in the owner, match registration to that reservation and shell generation, and reject invalid or duplicate transitions without changing an existing record.

The branch now attempts to drain on exit, but the prior terminal-output review still needs a stable end-of-stream boundary. Static review only. Exact CI passed static and macOS checks; Linux verification was still running.

CommandTask and ShellTask wait no longer cancel the command deadline on timeout; they answer WaitStatus::Running and leave the task alive. The command's own spawn timeout still terminates it; kill stays explicit. This removes the old execHost design's wait-timeout kill and the copied implementation.

@yyhhyyyyyy yyhhyyyyyy 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: #2002 Serve hostPlatform's data methods; withdraw the execHost face

Reviewed head 2d1e643d against origin/main b4859558. Full main...head review, round 9. The only commit after my last review is 2d1e643d (5 files, +123/-28): a wait timeout now stops waiting instead of killing the task.

Summary

The face split is coherent: hostPlatform is a process data face with 19 served methods, the catalog and the generated declarations agree on Linux, the 23 host_platform tests pass, and clippy passes for the touched crates. The wait fix is correct for both task kinds and the new test proves the command case, but the public type docs still call the reply terminal, and the running reply reports a wrong preview flag.

The two P1 regressions introduced by c5d4e53 are untouched by this commit and confirmed at this head. Four earlier P1s also remain. CI at this head has changes, static-checks and macos-native passing, while verify (linux) failed on the same minimal_execution and OCR tests seen at c5d4e53.

Verdict: REQUEST_CHANGES.

Blocking

P1: every shell command fails in the minimal execution assembly

Problem: ensure_shell starts its shell with self.host.shell(...) (crates/dim-agent-capabilities/src/shell_session.rs:563-576). HostPlatform::shell calls self.arc()? (crates/dim-agent-capabilities/src/host_platform.rs:1183), and arc() returns Closed ("execution host closed") unless the instance was built with Arc::new_cyclic by HostPlatformPlugin (:1017-1019, :1898-1900). HostPlatform::current leaves mounted empty (:677), and the minimal execution assembly provides exactly that value (tests/integration/tests/minimal_execution.rs:100-115, :152-156; installed by crates/dim-agent-capabilities/src/defaults.rs:236-248). Before c5d4e53 this code called start_shell on the platform directly and did not need the mounted owner.

Failure scenario: every execute in the minimal execution assembly, and in any embedding that constructs HostPlatform::current as docs/architecture/rust-agent/plugins/HostPlatform.md:39 describes, fails with execution host closed before the PTY starts. At this head minimal_execution::foreground_echo_returns_output fails at minimal_execution.rs:799 on macOS with the pinned 1.100.0 toolchain. CI verify (linux) at c5d4e53 failed 17 minimal_execution tests with the same error (run 45022085240), including shell_exit_settles_tasks, shell_exit_kills_background_jobs, timeout_occupies_shell_and_wakes and state_persists_across_calls. The new commit touches neither the shell route nor the assembly.

Fix: start_shell takes &self (host_platform.rs:3384-3392), so shell does not need arc(); call self.start_shell(...) there, or have ShellSession call start_shell directly. Add cargo test --workspace --locked to the PR verification, since the integration suite already covers this profile.

P1: background shell jobs survive the shell and their records leak

Problem: the job cleanup loop stops each orphaned background job with HostPlatform::kill by task id (crates/dim-agent-capabilities/src/shell_session.rs:884-899). kill resolves a job through shell.job_pid (host_platform.rs:1107-1118), and ShellTask::job_pid requires the live PTY (:3656-3662). The shell worker takes the PTY before it publishes the terminal (:3561, :3569-3574), and the reset path already called stop_shell before this handler (shell_session.rs:633-639). Every termination path reaches the loop with no PTY or no shell entry, so kill fails with "Shell is not running" or task_unknown, killed.is_ok() is false, and the job record is not settled. Before c5d4e53 the branch stored the resolved pid at background start and kill_job worked after the shell died.

Failure scenario: start execute with runInBackground (a dev server or a long build), then let the shell exit (exit, a crash, or a reset after the event loss below). The disowned job keeps running and its log keeps growing, the tool reports "Job could not be terminated", and the ExecutionTask::Job record stays in the process table forever because settle is only called after a successful kill (host_platform.rs:1136-1138). minimal_execution::shell_exit_kills_background_jobs (tests/integration/tests/minimal_execution.rs:1268-1315) asserts the old behavior and will fail at gone(&pid) (:1300-1312) once the shell starts.

Fix: resolve the node-local pid while the PTY is alive, store it in ShellJob, and kill by that pid. Remove the job records when the shell settles and settle them even when the kill fails. Keep docs/design/resource-faces.md:124-125 only if the owner can honor it.

P1: removeOutputDirectory still deletes directories outside execRoot

Problem: remove_exec_directory validates with path.starts_with(&root) (crates/dim-agent-capabilities/src/host_platform.rs:3106-3118) and then calls std::fs::remove_dir_all(path). Path::starts_with compares components lexically, so .. passes, and remove_dir_all follows an intermediate symlink. The served method (:775-791) exposes this to every process-scope caller; SessionFiles repeats the same lexical check (crates/dim-app-server/src/storage/files.rs:369-376). Thread 4657866326 remains open.

Failure scenario: a plugin calls removeOutputDirectory({path: "<info.execRoot>/session/branch/../../../../../somewhere"}) and deletes any directory the user can write, including the database directory. I reran the probe on an earlier head: starts_with returns true for that shape, remove_dir_all deletes the target outside the root, and a path through an intermediate symlink also deletes the linked directory. A second failure sits in the same comparison: exec_root() canonicalizes the root (host_platform.rs:996-1000) while ShellSession builds its output directory from the non-canonical host.home (crates/dim-agent-capabilities/src/shell_session.rs:1553-1557) and registers those paths (:1080-1096), so a symlinked ~/.dim/exec makes every shell candidate fail the starts_with test and blocks session deletion.

Fix: reject .. and . components, canonicalize the target or its deepest existing ancestor and compare against the canonical root, and remove without following symlinks. Add tests for .., an intermediate symlink, an absent target, a symlinked execRoot, and execRoot itself.

P1: the confined path error is flattened, and the OCR test fails

Problem: spawn_confined still maps ConfinedError::InvalidPath to HostPlatformError::Invalid(String) (crates/dim-agent-capabilities/src/host_platform.rs:754-757), so HostPlatformError::InvalidPath is never constructed. The OCR engine matches that variant to tell a helper copy that disappeared (crates/dim-modality/src/engine.rs:2343-2352) from a caller path error; the branch is dead. Thread 4657866331 remains open.

Failure scenario: the existing test fails. At this head ocr_plugin_helper_copy_gone_before_spawn_fails_the_task returns invalid_input and "invalid request: invalid confinement path /pp-ocr-plugin: No such file or directory" instead of executor_error and "unreadable"; I reproduced it at crates/dim-modality/tests/modality_flow.rs:6138 with the pinned toolchain. CI verify (linux) failed on the same test at c5d4e53.

Fix: map the typed error to HostPlatformError::InvalidPath { path }, keep the reason in the message or add a field, and rerun the modality suite.

P1: the committed TypeScript still depends on the host OS

Problem: the three sandbox_backend definitions still carry different doc comments (crates/dim-agent-capabilities/src/host_platform.rs:969-995), and xtask types selects one by host cfg. The committed file has the Linux bubblewrap text (npm/branch-services.d.ts:409-412). Thread 4657866334 remains open.

Failure scenario: at this head on macOS with the pinned toolchain, cargo run --locked -p xtask -- check exits 1 with "service declarations are stale". xtask types changes only that comment to the macOS text and the check then passes. The post-merge verify (macos) job runs the same check on push, so main fails after merge; committing the macOS output fails Linux static-checks.

Fix: give the three variants one doc comment, or one method with cfg branches in its body, then regenerate once.

P1: the persistent shell log is unowned, never removed, and 0644

Problem: start_shell opens <outputDir>/<id>.log with create plus append and no mode (crates/dim-agent-capabilities/src/host_platform.rs:3440-3448), unlike command logs, which use create_new and 0600 (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:1851-1867). The pump writes every PTY chunk there (host_platform.rs:3508-3515). ShellSession registers only the occupying and background logs (crates/dim-agent-capabilities/src/shell_session.rs:1080-1096, :1107-1108, :1174-1175), and Session deletion builds candidates from session_output_owners rows (crates/dim-app-server/src/storage/files.rs:311-375). Threads 4657866338 and 4658058149 remain open.

Failure scenario: every deleted foreground-only session leaks a log of up to 64 MiB under <home>/.dim/exec. Because the file is created 0644 under a 022 umask, the full output of the model's persistent shell, which previously stayed in the 64 KiB in-memory capture and the bounded tool result, is persisted beyond the session and readable by another local user who can traverse the home. A caller-chosen shell id reused after settle appends to the old log.

Fix: open a new log with create_new and mode 0600, and register the shell log with SessionFiles when the shell starts, or drop the shell log and its outputPath now that the event queue serves remote readers. Add a foreground-only session delete test.

Non-blocking

P2: the wait reply is documented as a terminal record

Problem: the new commit adds WaitStatus::Running, but WaitStatus is still documented as "How a command task ended" (crates/dim-agent-capabilities/src/host_platform.rs:364) and WaitReply as "A command task's terminal record" (:376). The same block is generated into npm/branch-services.d.ts:297 and :300, and the wait doc one page below says it answers running (host_platform.rs:1078-1081). The contract contradicts itself.

Failure scenario: a TypeScript caller that trusts the generated type docs treats every wait reply as terminal and stops polling on status: "running", or does not handle the new value at all.

Fix: document the type as a wait reply that can be non-terminal, and regenerate the declarations. In the running branch, preview_truncated is also hardcoded false (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:2337) while the terminal branch computes it (:2259-2268, :2371-2372), so a running command with more output than the preview budget returns a shortened preview marked complete. Compute the flag the same way, and add a shell wait timeout test: the commit changed ShellTask::wait too (host_platform.rs:3724-3767) but the new test covers only CommandTask.

P2: a reset from the event page still kills a healthy shell

Problem: ShellSession treats a reset from the event page, or eventRetainedFrom > eventCursor, as shell death and calls stop_shell (crates/dim-agent-capabilities/src/shell_session.rs:633-639). The owner retains only EVENT_RETAIN_CHARS = 1 MiB and drops the oldest events (host_platform.rs:3298, :3345-3350). The pump thread pushes 4 KiB chunks without backpressure (:3474-3521), while the reader consumes one page at a time. Thread 4658057591 remains open.

Failure scenario: a persistent-shell command such as seq 1 400000, cat of a large file, or a multi-megabyte build log emits more than 1 MiB while the consumer processes a page. retained_from advances past event_cursor, the next output call returns reset, and the read path kills the PTY. Before the shell-event commits the unbounded channel never dropped chunks, so the same command completed.

Fix: keep the session's delivery lossless. The simplest option is to restore the in-process channel for ShellSession and serve the bounded event log only to other readers. Do not terminate the shell from the read path; a reader that falls behind should fail its own read, and kill should remain the only operation that ends a process.

P2: ShellState still reports ready during the echo

Problem: ShellEvents::push derives state from prefix scans of the raw stream (crates/dim-agent-capabilities/src/host_platform.rs:3323-3337). An interactive shell echoes the wrapper command line before running it, and that echo contains both __DIM_START_ and __DIM_END_ (crates/dim-agent-capabilities/src/shell_session.rs:1840-1849). The echoed chunk therefore sets busy=false, ready=true, and a later lastCode. A command that prints __DIM_START_ also flips busy. Thread 4658057597 remains open.

Failure scenario: a remote reader that uses state.ready to gate the next command, which is what the new read advertises, receives the echo event page with ready=true while the command is still running and sends the next command into the occupied shell. A command that prints a fake marker changes lastCode.

Fix: buffer the tail across chunks and recognize the full marker (start marker plus two 8-hex runs and __, end marker plus its code), as Capture::append and marker_code already do, or keep the state parser in ShellSession and do not expose ShellState until it is correct.

P2: spawn still reuses a settled id and task_exists is unreachable

Problem: start_command checks only the live table (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:1988-1993), while the capture opens <outputDir>/<taskId>.log with create_new(true) (:1863-1867). A settled task keeps its log, so the same id can be spawned again. HostPlatform::spawn maps every ProcessSpecError to Failed (crates/dim-agent-capabilities/src/host_platform.rs:1069-1071), and shell does the same (:1196-1198), so the generated task_exists code never occurs (npm/branch-services.d.ts:188, :1713); TaskExists is never constructed (host_platform.rs:609). Threads 4657510974 and 4657510979 remain open.

Failure scenario: a caller settles build and spawns build again. The second spawn returns success; when the command writes enough output to spill, the capture fails, the supervisor kills the tree, and wait reports failed after the spawn reported success. An unusable outputDir and a Windows reserved name such as CON fail the same way.

Fix: check the planned log path before starting, map the known ProcessSpecError codes to TaskExists, and test duplicate, reused and unusable ids.

P2: contract documents still contradict the served face

Problem: docs/design/service-faces.md:126 still names spawn_with_stdin and child_path as skipped, but the served methods are spawnWithStdin and childPath; the skipped cores are spawn_with_stdin_process and child_path_process (crates/dim-agent-capabilities/src/host_platform.rs:794, :896, :1357). The same row puts the served shell/write/resize in Stage 2 and the internal configured/confined in Stage 3. service-faces.md:163 says the public methods are only info, execShell, persistentShell, sandboxBackend and execRoot, and that task and shell operations stay on other owners. docs/design/resource-faces.md:639 says the same about four methods, :655 says removal stays a Rust call although removeOutputDirectory is served, :662 and :709 name configured, and :747 gives the PTY to sessionMethods.shell while :119-120 gives it to hostPlatform. docs/design/contracts/resource-owner-operations.md:10 repeats the wrong skipped names and Stage labels. Thread 4657866341 and the earlier thread 4657510963 remain open.

Failure scenario: an implementer reading the migration map records served operations as internal, keeps a duplicate task operation on backgroundExec, or waits for Stage 2 work that is already in the catalog (docs/architecture/rust-agent/generated/catalog.md:27).

Fix: one method list in each document, the real skipped Rust names, no Stage labels for served operations, and the PTY attributed to ShellSession and hostPlatform.

P2: the settlement section is gone but still cited

Problem: the rewrite deleted the old execHost sections 3.2 to 3.10, including the settlement rule, the output cursor and reset rules, the error table and the removal precondition. docs/design/resource-faces.md:737 and :739 still cite section 3.8 twice, and the document has no section 3.8. The owner document has no data face section to replace it.

Failure scenario: a provider that spawns tasks and never settles grows the process table until the owner unloads; a provider that settles loses the terminal record; a repeated start is accepted and fails later; a caller cannot find the reset or error contract.

Fix: restore one settlement and error section, point decision 8 at it, and state the output reset and removal rules in the owner document.

P2: the HostPlatform owner document still denies the owner's state

Problem: docs/architecture/rust-agent/plugins/HostPlatform.md:17 says no plugin background tasks, and :47-49 says process lifetime belongs to each caller or supervisor. The head has a process task table, supervisors, pipe pumps, a shell worker, a shutdown effect and tasks retained until settle (crates/dim-agent-capabilities/src/host_platform.rs:251-253, :1898-1912). :121-125 says ShellSession stores the typed pid and resolves it through PtyProcessTree::job_pid; c5d4e53 moved that registration into the owner and the branch no longer stores a pid, which is also why the P1 above exists. The document has no data face section, no task id scope, no settle rule, no error codes, and no description of OutputRequest.eventCursor, waitMs, ShellEvent, ShellState or the wait running reply.

Failure scenario: a leaf implementer cannot find the settlement, id reuse, output retention, event reset or removal boundary rules, and the job regression above goes unnoticed.

Fix: add a data face section in the form of WorkspaceTools.md, update Events and lifetime, replace the stale pid paragraph with the owner registration rule, and state the event cursor, reset and wait semantics.

P2: PathBuf still crosses the face and callers replace native paths

Problem: service faces section 1 and AGENTS.md say PathBuf and OsString do not cross. The requests and replies use PathBuf in HostInfo.home, exec_root and platform_roots (crates/dim-agent-capabilities/src/host_platform.rs:642-652), SpawnRequest and SpawnReply.output_path (:551-565), WaitReply.output_path (:376-393), ShellRequest (:436-446) and RemoveOutputDirectoryRequest (:507-509). Serde rejects a non-UTF-8 PathBuf when it encodes the reply. Hooks converts DIMCODE_HOME and DIM_PLUGIN_ROOT with to_string_lossy (crates/dim-agent-capabilities/src/hooks/runner.rs:483-496), MCP converts the PATH base (crates/dim-app-server/src/mcp/server/stdio.rs:160-166), and OCR converts the helper program, arguments and environment (crates/dim-modality/src/engine.rs:2291-2305). The new SpawnWithStdinRequest doc says a non-UTF-8 environment belongs to the in-process binding, but Hooks is in-process and uses the same data request. Thread 4657866340 remains open.

Failure scenario: a host whose home contains non-UTF-8 bytes cannot answer info; a spawn whose output path is non-UTF-8 starts the task but fails to encode SpawnReply, so the caller loses the task id. A hook or MCP child with a non-UTF-8 path gets U+FFFD and silently loses the runtime directories.

Fix: define one string path policy with an explicit error when a value cannot be represented, apply it to every request and reply, and keep a lossless in-process binding for native values or reject them. Test one non-UTF-8 home and one non-UTF-8 PATH.

P3 and smaller items

  • parse_shell_job matches any line that contains __DIM_START_ and accepts whatever follows the next __ as <pid> <taskId> (crates/dim-agent-capabilities/src/host_platform.rs:3300-3311), without checking the random marker halves (crates/dim-agent-capabilities/src/shell_session.rs:1813-1824). A command that prints a well-formed marker registers a job, and the unconditional insert at :3487-3494 replaces any record with that id. Match the full random marker and the exact wrapper line, reject a duplicate id, or register the job through an operation.
  • The PID_WAIT loop no longer has a consumer: it keeps only .is_some() (crates/dim-agent-capabilities/src/shell_session.rs:1260-1271), so every background start can still wait two seconds for a marker whose value is discarded, and registration is not verified. Delete it or make registration an operation with a reply.
  • settle accepts a running job and removes its record (host_platform.rs:1136-1138), unlike shells and command tasks; retainOutput rejects a shell id while the other task operations accept it (crates/dim-agent-capabilities/src/host_platform.rs:1281-1286, crates/dim-agent-capabilities/src/workspace_tools/exec.rs:2057-2062); output ignores OutputRequest.limit on the event path (host_platform.rs:1238) and clamps a zero limit to one byte.
  • The timeout tokens on CommandTask (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:2187, observed at :2222) and ShellTask (host_platform.rs:3280, observed at :3533) are never cancelled after this commit removed the last timeout.cancel(). The shell timed_out status is unreachable. Remove the tokens and arms, or say what still cancels them.
  • Hooks still reports a handler cancelled by unload as failed "cancelled": cancelled_by cancels the call (crates/dim-agent-capabilities/src/hooks/runner.rs:505-526), spawn_with_stdin returns status Cancelled (host_platform.rs:794-825), and run_one maps it to failed("cancelled") (hooks/runner.rs:436-437) before the gate branch can answer. ConfiguredError::Unloaded and the gate parameter of configured are dead because the only caller passes None (host_platform.rs:825, :3795, :3839).
  • The ShellSession module doc still says a dedicated OS thread forwards chunks through a channel (crates/dim-agent-capabilities/src/shell_session.rs:6-8); the branch now polls owner event pages.
  • WorkspaceTools.md:578 says P:HostPlatform is used to stop a running task, but BackgroundExec.stop cancels its own token (crates/dim-agent-capabilities/src/workspace_tools/background.rs:502-510); the dependency reads retained output.
  • The generated spawnConfined comment carries the old spawnWithStdin text (host_platform.rs:716-720; npm/branch-services.d.ts:384-390).
  • npm/plugin.d.ts:264 re-exports only HostPlatform and HostInfo; the face now also returns or takes ShellStatus, SandboxBackend, ExecShellRuntime, Os, ShellEdition, ShellSource, OutputEncoding, OutputPage, OutputTail, OutputPathReply, ShellEvent, ShellState, SpawnRequest, SpawnReply, WaitRequest, WaitReply, TaskRequest, OutputRequest and HostPlatformError.
  • command_files is still never Some (crates/dim-app-server/src/lib.rs:997; the integration assemblies), so the FileStorage branch of retained_output_page is dead (host_platform.rs:3154-3190).
  • spawn_with_stdin leaks its cancellation waiter on every early error: it spawns the waiter (host_platform.rs:799-805) but aborts it only after configured returns (:836).
  • The PR description still says the handle methods stay off the service, that task operations stay in their existing services, and that 19 tests pass. The head serves them and has 23 host_platform tests.
  • resource-faces.md:723-726 still treats write/resize/output as undecided although this commit uses them.

Fixed, withdrawn, changed

  • Fixed at this head: wait({timeoutMs}) no longer terminates the task. Both CommandTask::wait (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:2317-2339) and ShellTask::wait (host_platform.rs:3724-3767) return running on the deadline and cancel nothing; spawn.timeoutMs still terminates at its deadline. The earlier typed-reply part of thread 4657510970 was fixed before this head. I answered that thread with the remaining type-doc and preview-flag gaps.
  • Withdrawn: the P2 "wait with timeoutMs still terminates the task" from review 6012156371. No other finding is withdrawn, and the previously withdrawn broad dangling-reference and timezone notes stay withdrawn.
  • Still open: the six inline findings from earlier reviews, the two c5d4e53 P1s and its pending-buffer P2, and every P2 listed above. No other thread changed status at this head, so I left the rest unanswered.
  • If ShellSession does not need the remote event read yet, reverting 509ba41, ed06e16 and the c5d4e53 reroute and keeping the in-process channel is smaller than fixing the job registry, the reset path, the pending buffer and the log ownership at once. The face can then be its own PR with a test and the log fix.

Verification

  • cargo test --locked -p dim-agent-capabilities --test capabilities_flow host_platform_flow with the pinned 1.100.0 toolchain: 23 passed, including a_wait_timeout_leaves_the_command_running.
  • cargo test --locked -p dim-agent-integration-tests --test integration_flow minimal_execution::foreground_echo_returns_output: failed with execution host closed at tests/integration/tests/minimal_execution.rs:799.
  • cargo test --locked -p dim-modality --test modality_suite ocr_plugin_helper_copy_gone_before_spawn_fails_the_task: failed with invalid_input instead of executor_error at crates/dim-modality/tests/modality_flow.rs:6138.
  • cargo clippy --locked -p dim-agent-capabilities -p dim-modality --all-targets -- -D warnings on macOS: passed.
  • cargo run --locked -p xtask -- check on macOS: exit 1, "service declarations are stale".
  • The traversal probe was rerun on an earlier head and the removal code is unchanged at this head.
  • The job-survival and reset scenarios are source-level; the minimal shell test fails earlier, so I did not observe a live background process after shell death.
  • CI at this head: changes, static-checks and macos-native passed; verify (linux) failed, reproducing the c5d4e53 minimal_execution and OCR failures (run 45022085240); ci-ok fails.

Cross-PR

  • Against origin/main b4859558: merge-tree clean. Main changed no file this PR touches.
  • #1916, #1997, #1985, #1986, #1993, #1994, #1999, #2003, #2004 and #1963, #1967, #1976 merge cleanly with this head.
  • #1902 conflicts in crates/dim-app-server/src/lib.rs, crates/dim-app-server/src/mcp/publication.rs, the generated catalog and docs/design/contracts/resource-owner-operations.md.
  • #1904 conflicts in crates/dim-app-server/src/agents.rs, src/lib.rs, src/storage/mod.rs and the generated catalog.
  • #1906 conflicts in the app-server session/collaboration files, the generated catalog, service-faces.md, branch-services.d.ts and plugin.d.ts.
  • #1907 and #1908 conflict in crates/dim-app-server/src/lib.rs.
  • #1909, #1911, #1912 and #1913 conflict in the shared runtime, app-server, generated service and service-faces.md files; #1913 also conflicts in shell_input.rs and the ToolExecution page.
  • #1881 conflicts only in crates/dim-report/src/draft.rs and evidence.rs. #1306 conflicts in the Cargo files and generated module graphs.
  • The conflicting PRs already conflict with current main in their own rebase; the shared generated files need regeneration after either side merges.

Unverified

  • Windows behavior of the job scanner, the kill translation, the pending buffer and the generated declarations.
  • The pending-buffer memory limit is source-level; I did not drive it past the memory limit.
  • The exact burst that reaches the reset branch depends on consumer speed; no deterministic test drives it.
  • The dialect race between persistent_shell() and the owner's own resolution in start_shell is source-level; the reply does not carry the edition.
  • The shell log leak and the Session delete path are source-level; no end-to-end delete test exists.
  • The new shell wait timeout path is source-verified; the added test covers only the command path.

let reply = self
.host
.prepare_isolated_process(spec, &roots, Some(&self.config.output_dir))
.shell(ShellRequest {

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.

Problem: this routes every shell start through the served shell operation, which requires the plugin-built owner. HostPlatform::shell calls self.arc()? (crates/dim-agent-capabilities/src/host_platform.rs:1183), and arc() returns Closed ("execution host closed") unless mounted was set by HostPlatformPlugin with Arc::new_cyclic (:1017-1019, :1898-1900). HostPlatform::current leaves mounted empty (:677), and the minimal execution assembly provides exactly that value (tests/integration/tests/minimal_execution.rs:100-115, :152-156; installed by crates/dim-agent-capabilities/src/defaults.rs:236-248). Before c5d4e53 this code called start_shell on the platform directly and did not need the mounted owner.

Failure scenario: every execute in the minimal execution assembly, and in any embedding that constructs HostPlatform::current as docs/architecture/rust-agent/plugins/HostPlatform.md:39 describes, fails with execution host closed before the PTY starts. At this head minimal_execution::foreground_echo_returns_output fails at minimal_execution.rs:799 on macOS with the pinned 1.100.0 toolchain, and CI verify (linux) at c5d4e53 failed 17 minimal_execution tests with the same error (run 45022085240). The new commit does not touch this path.

Fix: start_shell takes &self (host_platform.rs:3384-3392), so shell does not need arc(); call self.start_shell(...) there, or have ShellSession call start_shell directly. Add cargo test --workspace --locked to the PR verification.

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.

Fixed at 1e1f8c7. HostPlatform::shell calls self.start_shell directly (crates/dim-agent-capabilities/src/host_platform.rs:1183) and no longer goes through arc(). cargo test --locked -p dim-agent-integration-tests --test integration_flow minimal_execution:: now passes 22 tests, including foreground_echo_returns_output, shell_exit_settles_tasks, shell_exit_kills_background_jobs, timeout_occupies_shell_and_wakes and state_persists_across_calls; CI verify (linux) also passes at this head. The public shell doc still says it requires the plugin-built owner; I left an inline note on that line.

let killed = self
.host
.kill(TaskRequest {
task_id: task.task_id.clone(),

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.

Problem: this stops an orphaned background job with HostPlatform::kill by task id, but kill resolves the job through shell.job_pid (crates/dim-agent-capabilities/src/host_platform.rs:1107-1118) and ShellTask::job_pid requires the live PTY (:3656-3662). The shell worker takes the PTY before it publishes the terminal (:3561, :3569-3574), and the reset path already called stop_shell before this handler (crates/dim-agent-capabilities/src/shell_session.rs:633-639). Every termination path reaches this loop with no PTY or no shell entry, so kill fails with "Shell is not running" or task_unknown, killed.is_ok() is false, and the job record is not settled (host_platform.rs:1136-1138). Before c5d4e53 the branch stored the resolved pid at background start and kill_job worked after the shell died.

Failure scenario: start execute with runInBackground, then let the shell exit (exit, a crash, or a reset after the 1 MiB event loss). The disowned job keeps running and its log keeps growing, the tool reports "Job could not be terminated", and the ExecutionTask::Job record stays in the process table forever. minimal_execution::shell_exit_kills_background_jobs (tests/integration/tests/minimal_execution.rs:1268-1315) asserts the old behavior and will fail at gone(&pid) (:1300-1312) once the shell starts.

Fix: resolve the node-local pid while the PTY is alive, store it in ShellJob, and kill by that pid; remove the job records when the shell settles and settle them even when the kill fails. Keep docs/design/resource-faces.md:124-125 only if the owner can honor it.

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.

Fixed at 1e1f8c7. The pump resolves the reported pid through PtyProcessTree::job_pid while the PTY is alive and stores it in ShellJob (crates/dim-agent-capabilities/src/host_platform.rs:3538-3549, :3331-3333); kill uses that pid directly (:1116-1119); both cleanup paths settle the record even when the kill fails (crates/dim-agent-capabilities/src/shell_session.rs:892-897, :1410-1415). shell_exit_kills_background_jobs passes. Residual, not required here: if the shell root is taken before the pump reads the pid marker, no record is created and that job still survives; the PID_WAIT loop no longer proves registration.

break;
};
let chunk = crate::shell_session::regularize_output(&bytes[..n]);
pending.push_str(&chunk);

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.

Problem: this line scan buffers shell output without a bound. Every chunk is appended to pending (:3475-3484), and pending.find('\n') rescans the whole buffer after each 4 KiB read (:3485). A line with no newline stays for the life of the shell, and the scan is quadratic in its length.

Failure scenario: head -c 200000000 /dev/zero, cat of a binary without 0x0A, or a minified document with no newline makes the owner hold the whole output in pending and rescan it every 4 KiB, so memory grows to the output size and the pump thread burns CPU. The capture (:3497-3507), the event queue (:3517-3520) and the log (:3508-3515) are bounded; before c5d4e53 the branch had no line buffer.

Fix: cap pending at the longest pid line (about 96 bytes); when it grows past the cap without a newline, drop it and skip to the next newline. Add a multi-megabyte, no-newline test.

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.

Still open at a56c536, and narrower. 13964033 bounded the event-side ShellEvents.pending (crates/dim-agent-capabilities/src/host_platform.rs:3656-3663), but the pump's own line buffer is unchanged (:3805, :3814-3815): every chunk is appended to pending and find(' ') restarts at the front, so a long unterminated line still grows without bound and scans quadratically. It now also gates the new capture and job parsing, so a long line stalls those too. Cap it at the marker line length as before.

const EVENT_RETAIN_CHARS: usize = 1024 * 1024;

fn parse_shell_job(line: &str) -> Option<(String, u32)> {
let start = line.find("__DIM_START_")?;

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.

Problem: parse_shell_job matches any line that contains __DIM_START_ and accepts whatever follows the next __ as <pid> <taskId>, without checking the random marker halves the branch generates (crates/dim-agent-capabilities/src/shell_session.rs:1813-1824). Every line the shell prints is scanned, including command output, and the insert at :3488-3494 overwrites any existing record with that id.

Failure scenario: a command that prints __DIM_START_aaaaaaaa_bbbbbbbb__ 1234 exec-fake registers a Job under exec-fake; kill then resolves that pid through the PTY and sends SIGKILL to its process group (:1107-1118). The same line can replace a live command or shell record because the insert is unconditional, so the owner can lose a running task record from command output.

Fix: register the job through an operation instead of parsing the stream. If the parser stays, match the full random start marker and the exact wrapper line, and reject a duplicate id without changing an existing record.

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.

Partly fixed at 1e1f8c7. The parser now keys on __DIM_END_, requires an exec- task id, and resolves the reported pid through the live PTY (crates/dim-agent-capabilities/src/host_platform.rs:3345-3356, :3538-3549). It still does not verify the random marker halves. A foreground command can print __DIM_END_<8hex>_<8hex>__<pid> exec-<id>; on macOS and Windows job_pid returns the reported pid unchanged (:2812-2822), so the owner registers a job it did not start, and a later kill on that id targets that process group. On Linux the pid must be in the PTY session, which narrows but does not close the forgery. Register the job from the branch, which knows the expected pid marker, or verify the full random marker and the exact wrapper line before inserting.

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.

Further hardened at a56c536, still open. parse_shell_job now takes the last full marker and requires the __DIM_END_ prefix plus two 8-hex halves (crates/dim-agent-capabilities/src/host_platform.rs:3589-3617), so arbitrary __DIM_END_ text no longer registers a job. The random halves are still not compared with the branch's pair, and on macOS and Windows job_pid returns the reported pid unchanged (:2888-2898). A foreground command can still print __DIM_END_<8hex>_<8hex>__<pid> exec-<id> and register a job the owner did not start. Keeping this P3.

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.

Further narrowed at 05c6d9d, still open. A pid marker can no longer create a job: the reader only fills an existing reservation (crates/dim-agent-capabilities/src/host_platform.rs:3953-3961), so a forged marker cannot add a task id. What remains is the same trust model: the two marker halves are not checked against a secret, job_pid still returns the reported pid unchanged off Linux (:2958-2967), and a forged marker for an already reserved id can fill that reservation's pid out of order. The new end-marker scan has the same problem: a caller-supplied end marker is matched as a bare substring, so ordinary output can end a job (see the new inline comment at :3967).

Status: narrowed, still open.

let found = {
let inner = self.inner.lock().await;
marker_code(&inner.retained, &pid_marker_full)
marker_code(&inner.retained, &pid_marker_full).is_some()

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.

Problem: this loop no longer has a consumer. It keeps only .is_some() and discards the pid, while the owner now registers the job from the stream (crates/dim-agent-capabilities/src/host_platform.rs:3487-3494). A missing pid marker no longer fails anything, but every background start still waits up to PID_WAIT (2 s, crates/dim-agent-capabilities/src/shell_session.rs:53) for it, and the branch no longer verifies that registration happened.

Failure scenario: a late or lost pid line delays the execute result by up to two seconds with no effect, and a job the owner failed to register is reported as started.

Fix: delete PID_WAIT and the loop, or make registration an operation with a reply and use that reply.

#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize)]
#[serde(rename_all = "snake_case")]
pub enum WaitStatus {
Running,

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.

Problem: Running is now a normal WaitStatus, but the public docs still say the opposite. WaitStatus is documented as "How a command task ended" (:364) and WaitReply as "A command task's terminal record" (:376); the same block is generated into npm/branch-services.d.ts:297 and :300. The wait doc one page below says it answers running (:1078-1081), so the contract contradicts itself.

Failure scenario: a TypeScript caller that reads the generated type docs treats every wait reply as terminal and stops polling on status: "running", or treats running as an unknown state.

Fix: document the type as a wait reply that may be non-terminal, for example WaitStatus as "A task state a wait can report" and WaitReply as "A wait result, terminal only when status is not running", then regenerate the declarations. In the running reply, preview_truncated is also hardcoded false (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:2337) while the terminal branch computes it (:2259-2268, :2371-2372), so a running command with more output than the preview budget returns a shortened preview marked complete.

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.

Fixed at 1e1f8c7. WaitStatus is documented as a wait status that can be running, and WaitReply as terminal or running (crates/dim-agent-capabilities/src/host_platform.rs:364-376); the generated declarations match (npm/branch-services.d.ts:297-303) and cargo run --locked -p xtask -- check passes.

output_bytes: self.output.total().await,
output_truncated: self.output.truncated().await,
preview: self.output.preview().await,
preview_truncated: false,

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.

Problem: the running reply hardcodes preview_truncated: false, while the terminal reply computes it from the preview buffer (:2259-2268, :2371-2372). preview() itself truncates to the preview budget (:1944-1946), so a running command with more output than the preview budget returns a shortened preview marked complete.

Failure scenario: a caller polls wait({taskId, timeoutMs}) on a long build, receives status: "running" with a 50 KiB preview and previewTruncated: false, and shows it as the complete output so far. The same call without a timeout reports previewTruncated: true.

Fix: compute the flag the same way as the terminal path, or return the same tail structure as tail.

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.

Fixed at 1e1f8c7: the running reply now takes preview_truncated from the capture (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:1954-1957, :2353). One edge remains: bounded_preview also counts output_bytes > preview.len() and compares against sanitize(preview).len(), while the new method compares truncate_preview(preview).len() with the raw preview length (:1819-1824, :2275, :2388). A preview that contains control bytes can be reported truncated while running and complete when terminal. Use bounded_preview(&capture.preview, capture.output_bytes as usize) for both. The shell wait timeout still has no test (see the other thread).

}

#[tokio::test]
async fn a_wait_timeout_leaves_the_command_running() {

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.

Problem: this test covers only the command task. The same commit changed ShellTask::wait to return running (crates/dim-agent-capabilities/src/host_platform.rs:3724-3767), but no test starts a shell, waits with a short timeoutMs, and then proves the shell is still alive. It also does not assert the running reply's preview flags or that spawn.timeoutMs still terminates the task.

Failure scenario: a later change reintroduces timeout.cancel() in either wait path; the command test catches the command case only, and the shell case silently goes back to killing the PTY on a poll.

Fix: add a shell wait timeout test that writes a command after the timed-out wait and still receives its output, and assert the running reply's fields.

…aries

shell starts through start_shell without the mounted Arc, so the minimal execution assembly works. Background jobs resolve their node pid while the PTY is alive and settle even when kill fails. Output removal rejects traversal and symlinks against a canonical root. spawn/shell map task_exists and invalid requests. Shell logs are create_new, 0600, and removed with the task. InvalidPath carries path and reason; the sandbox doc is host-independent; wait running docs and the preview flag are corrected.

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

[P2] Keep the returned shell output file available after settlement. shell returns an output path documented for file reads. settle_shell releases the task record, and ShellTask::drop now unlinks that file. This makes a recorded output path unreadable after normal settlement, contrary to the output retention contract. Keep exclusive private creation, give each task incarnation a distinct capture and let the output owner clean it up separately from the task record.

The minimal-profile startup and OCR mapping fixes look correct in source. The earlier task registration and terminal drain findings are not yet fully resolved. Exact CI passed static checks and macOS native; Linux tests were still running.

@yyhhyyyyyy yyhhyyyyyy 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: #2002 Serve hostPlatform's data methods; withdraw the execHost face

Reviewed head 1e1f8c792 against origin/main b4859558. Full main...head review, round 10. The only commit after my last review is 1e1f8c792 (7 files, +235/-99): restore the minimal profile, harden the removal boundary and the confined error mapping, make the shell log private and remove it at settle, and map process errors to task errors.

Summary

The commit fixes the two P1s introduced by c5d4e53e and the four other P1s from my review at 2d1e643d. The minimal execution assembly starts shells again, background jobs are killed and settled after shell death, output removal refuses traversal, spawnConfined preserves InvalidPath, the committed declarations are host independent, and the shell log is 0600 and does not outlive its record. CI at this head is green: changes, static-checks, macos-native, verify (linux) and ci-ok pass. Locally 24 host_platform tests, 22 minimal execution tests, the OCR helper test, xtask check, clippy and fmt pass.

Seven P2s remain, mostly unchanged from the previous round: the event reader kills a healthy shell when it falls behind, the owner pump buffers a line without a bound, ShellState still reads the wrapper echo as a completed command, the contract documents still contradict the served face, the settlement section is still cited but absent, the owner document still denies the owner's task and shell state, and PathBuf still crosses the face.

Verdict: REQUEST_CHANGES.

Blocking

P2: a reset from the event page still kills a healthy shell

Problem: ShellSession treats a reset from the owner's event page, or eventRetainedFrom > eventCursor, as shell death and calls stop_shell (crates/dim-agent-capabilities/src/shell_session.rs:632-639). The owner retains only EVENT_RETAIN_CHARS = 1 MiB and drops the oldest events (crates/dim-agent-capabilities/src/host_platform.rs:3343, :3390-3395), while the pump pushes 4 KiB chunks without backpressure (:3524-3576). Thread 4658057591 remains open.

Failure scenario: a persistent-shell command such as seq 1 400000, cat of a large file, or a multi-megabyte build log emits more than 1 MiB while the consumer processes a page. retained_from advances past event_cursor, the next output call returns reset, and the read path kills the PTY and marks the shell reset. Before the shell-event commits the in-process channel never dropped chunks, so the same command completed.

Evidence: crates/dim-agent-capabilities/src/shell_session.rs:632-639, crates/dim-agent-capabilities/src/host_platform.rs:3343, :3390-3395, :3524-3576.

Fix: keep the session's delivery lossless. The simplest option is to restore the in-process channel for ShellSession and serve the bounded event log only to other readers. Do not terminate the shell from the read path; a reader that falls behind should fail its own read, and kill should remain the only operation that ends a process.

P2: the owner pump buffers an unterminated line without a bound

Problem: the pump appends every chunk to pending and searches it for a newline with pending.find('\n') (crates/dim-agent-capabilities/src/host_platform.rs:3526-3536). There is no cap, and the scan restarts at the front after every 4 KiB read. Thread 4658199693 remains open.

Failure scenario: a command writes a long line without a newline, for example a base64 blob, a binary stream, or head -c 500M /dev/zero | tr '\0' a. pending grows with the full line, the scan cost is quadratic in its length, and the pump thread and process memory grow until the shell stalls or the process is killed. Capture is bounded to 64 KiB and events to 1 MiB, so this buffer is the only unbounded copy.

Evidence: crates/dim-agent-capabilities/src/host_platform.rs:3524-3536.

Fix: cap pending at the longest marker line plus a small slack; when it exceeds the cap, keep only the tail that can still become a marker, as marker_hold does in shell_session.rs:1729-1744. The parser only needs the current line tail near __DIM_END_.

P2: ShellState still reports ready during the wrapper echo

Problem: ShellEvents::push derives state from prefix scans of the raw stream (crates/dim-agent-capabilities/src/host_platform.rs:3368-3382). An interactive shell echoes the wrapper command line before running it, and that echo contains both __DIM_START_ and __DIM_END_ because the wrapper writes them as two quoted fragments (crates/dim-agent-capabilities/src/shell_session.rs:1836-1871). The echoed chunk therefore sets busy=false, ready=true, and a later last_code from the $? text. Thread 4658057597 remains open.

Failure scenario: a remote reader that uses state.ready to gate the next command, which is what the new output read advertises, receives the echo event page with ready=true while the command is still running and writes the next command into the occupied shell. A command that prints a fake marker changes lastCode as well.

Evidence: crates/dim-agent-capabilities/src/host_platform.rs:3368-3382, crates/dim-agent-capabilities/src/shell_session.rs:1836-1871.

Fix: buffer the tail across chunks and recognize the full marker (prefix plus two 8-hex runs and __, then the exit token), as Capture::append and marker_code already do, or keep the state parser in ShellSession and do not expose ShellState until it is correct.

P2: the contract documents still contradict the served face

Problem: docs/design/service-faces.md:126 still keeps spawn_with_stdin and child_path as skipped and puts shell/write/resize in Stage 2, while the served names are spawnWithStdin and childPath and the skipped cores are spawn_with_stdin_process and child_path_process (crates/dim-agent-capabilities/src/host_platform.rs:899, :1354). docs/design/service-faces.md:163 still says the public methods are only info, execShell, persistentShell, sandboxBackend and execRoot, and that task and shell operations stay on other owners. docs/design/resource-faces.md:639 says the public methods are four and the spawn methods are internals; :655 says shell output removal stays the Rust call while crates/dim-app-server/src/storage/files.rs:366-377 calls the served method; :662 and :709 name configured, which is a pub(crate) function (crates/dim-agent-capabilities/src/host_platform.rs:3868); :747 gives the PTY to sessionMethods.shell while :103 gives shell/write/resize to hostPlatform. docs/design/contracts/resource-owner-operations.md:10 repeats the wrong skipped names and Stage labels. Threads 4657510963, 4657510969 and 4657866341 remain open.

Failure scenario: an implementer reading the migration map records served operations as internal, keeps a duplicate task operation on backgroundExec, or waits for Stage 2 work that is already in the catalog (docs/architecture/rust-agent/generated/catalog.md:27).

Evidence: the documents and code lines above.

Fix: one method list in each document, the real skipped Rust names, no Stage labels for served operations, and the PTY attributed to ShellSession and hostPlatform.

P2: the settlement section is gone but still cited

Problem: the resource-faces.md rewrite deleted the old sections 3.2 to 3.10, including the settlement rule, the output cursor and reset rules, the error table and the removal precondition. docs/design/resource-faces.md:737 and :739 still cite section 3.8 twice, and the document has no section 3.8 (the last section under 3 is 3.1). The owner document has no data face section to replace it.

Failure scenario: a provider that spawns tasks and never settles grows the process table until the owner unloads; a provider that settles loses the terminal record; a repeated start is accepted and fails later; a caller cannot find the reset or error contract.

Evidence: docs/design/resource-faces.md:737, :739; the section headings stop at ### 3.1.

Fix: restore one settlement and error section, point decision 8 at it, and state the output reset and removal rules in the owner document.

P2: the HostPlatform owner document still denies the owner's state

Problem: docs/architecture/rust-agent/plugins/HostPlatform.md:17 says no plugin background tasks, and :47-49 says process lifetime belongs to each caller or supervisor. The head has a process task table, supervisors, pipe pumps, a shell worker, a shutdown effect and tasks retained until settle (crates/dim-agent-capabilities/src/host_platform.rs:252-254, :1899-1909). :121-125 says ShellSession stores the typed pid and resolves it through PtyProcessTree::job_pid; c5d4e53e moved that registration into the owner, the pump resolves the pid and stores it in ShellJob (crates/dim-agent-capabilities/src/host_platform.rs:3538-3549, :3331-3333), and the branch no longer stores a pid. The document has no data face section, no task id scope, no settle rule, no error codes, and no description of OutputRequest.eventCursor, waitMs, ShellEvent, ShellState or the wait running reply.

Failure scenario: a leaf implementer cannot find the settlement, id reuse, output retention, event reset or removal boundary rules, and the job regression from the previous round went unnoticed because the document described a different owner.

Evidence: the document and code lines above.

Fix: add a data face section in the form of WorkspaceTools.md, update Events and lifetime, replace the stale pid paragraph with the owner registration rule, and state the event cursor, reset and wait semantics.

P2: PathBuf still crosses the face and callers replace native paths

Problem: service faces section 1 and AGENTS.md say PathBuf and OsString do not cross. The requests and replies use PathBuf in HostInfo.home, exec_root and platform_roots (crates/dim-agent-capabilities/src/host_platform.rs:645-649), SpawnRequest and SpawnReply.output_path (:554-565), WaitReply.output_path (:386), ShellRequest (:438-440) and RemoveOutputDirectoryRequest (:508). Serde rejects a non-UTF-8 PathBuf when it encodes the reply. Hooks converts DIMCODE_HOME and DIM_PLUGIN_ROOT with to_string_lossy (crates/dim-agent-capabilities/src/hooks/runner.rs:483-496), MCP converts the PATH base (crates/dim-app-server/src/mcp/server/stdio.rs:160-166), and OCR converts the helper program, arguments and environment (crates/dim-modality/src/engine.rs:2291-2305). Thread 4657866340 remains open.

Failure scenario: a host whose home contains non-UTF-8 bytes cannot answer info; a spawn whose output path is non-UTF-8 starts the task but fails to encode SpawnReply, so the caller loses the task id. A hook or MCP child with a non-UTF-8 path gets U+FFFD and silently loses the runtime directories.

Evidence: the lines above.

Fix: define one string path policy with an explicit error when a value cannot be represented, apply it to every request and reply, and keep a lossless in-process binding for native values or reject them. Test one non-UTF-8 home and one non-UTF-8 PATH.

Fixed at this head

  • Minimal execution P1 (4658199686): HostPlatform::shell calls self.start_shell directly and no longer needs arc() (crates/dim-agent-capabilities/src/host_platform.rs:1183). cargo test -p dim-agent-integration-tests --test integration_flow minimal_execution:: passed 22 tests, including foreground_echo_returns_output, shell_exit_settles_tasks, shell_exit_kills_background_jobs, timeout_occupies_shell_and_wakes and state_persists_across_calls. CI verify (linux) passes as well.
  • Background job P1 (4658199691): the pump resolves the reported pid through PtyProcessTree::job_pid while the PTY is alive and stores it in ShellJob (crates/dim-agent-capabilities/src/host_platform.rs:3538-3549, :3331-3333); kill uses it directly (:1116-1119); both cleanup paths settle the record even when the kill fails (crates/dim-agent-capabilities/src/shell_session.rs:892-897, :1410-1415). shell_exit_kills_background_jobs passes.
  • Removal P1 (4657866326): remove_exec_directory rejects non-absolute paths and ./.. components, canonicalizes the root and the deepest existing prefix, rejects a target outside the canonical root or equal to it, and rejects a final symlink (crates/dim-agent-capabilities/src/host_platform.rs:3103-3141). The new output_removal_refuses_traversal_and_links test passes; SessionFiles uses the served method and falls through only on Invalid/InvalidPath (crates/dim-app-server/src/storage/files.rs:366-377). The earlier resolved-boundary review finding is closed by the same change.
  • Confined error P1 (4657866331): spawn_confined maps ConfinedError::InvalidPath { path, reason } to HostPlatformError::InvalidPath (crates/dim-agent-capabilities/src/host_platform.rs:754-763), and OCR destructures the new field (crates/dim-modality/src/engine.rs:2343-2344). ocr_plugin_helper_copy_gone_before_spawn_fails_the_task passes, and CI verify (linux) passes.
  • Host dependent declarations P1 (4657866334 and 4657312851): the three sandbox_backend definitions share one doc comment (crates/dim-agent-capabilities/src/host_platform.rs:972-995), the committed declarations carry it (npm/branch-services.d.ts:409), and cargo run -p xtask -- check passes on macOS.
  • Shell log P1 (4657866338): the log is opened create_new with mode 0600 (crates/dim-agent-capabilities/src/host_platform.rs:3485-3500) and Drop for ShellTask removes it when the record is released (:3325-3329); the_host_platform_service_serves_a_shell asserts both. The registration half of this finding is withdrawn; the file is still dead weight, see P3 below. The create_new open also closes the earlier shell id reuse concern about appending a new task to a settled log.
  • Wait docs P2 (4658199703): WaitStatus and WaitReply now describe a reply that can be running (crates/dim-agent-capabilities/src/host_platform.rs:364-376), and npm/branch-services.d.ts:297-303 is regenerated.
  • Preview flag P2 (4658199708): the running reply computes preview_truncated from the capture (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:1954-1957, :2353). The computation still differs from the terminal one in one edge, see P3 below.
  • Spawn id reuse P2 (4657510974): start_command refuses an existing <taskId>.log and an unusable output directory before starting (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:1984-1995), and HostPlatform::spawn maps task_exists and invalid_request through process_error (crates/dim-agent-capabilities/src/host_platform.rs:1021-1030, :1064-1078), so the generated task_exists code is reachable.
  • Apart from the shell log registration half noted above, no prior finding is withdrawn. The earlier withdrawn broad dangling-reference and timezone notes stay withdrawn.

Remaining P3 and smaller items

  • The marker parser is only partly hardened (4658199697): it now keys on __DIM_END_, requires an exec- task id, and resolves the reported pid through the live PTY (crates/dim-agent-capabilities/src/host_platform.rs:3345-3356, :3538-3549), but it does not verify the random marker halves. On macOS and Windows job_pid returns the reported pid unchanged (:2812-2822), so any foreground command can print __DIM_END_<8hex>_<8hex>__<pid> exec-<id> and register a job the owner did not start; a later kill on that id targets that process group. On Linux the pid must be in the PTY session, which narrows but does not close the forgery.
  • The PID_WAIT loop still waits up to two seconds and discards the marker (crates/dim-agent-capabilities/src/shell_session.rs:1258-1269), so registration is not verified (4658199698).
  • settle removes a running job record (crates/dim-agent-capabilities/src/host_platform.rs:1136-1139); retainOutput rejects a shell id while settle and kill accept it (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:2089-2095); output ignores OutputRequest.limit on the event path (crates/dim-agent-capabilities/src/host_platform.rs:1235-1249).
  • The timeout tokens on CommandTask and ShellTask are never cancelled after the wait change, so the shell timed_out status is unreachable (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:2203, crates/dim-agent-capabilities/src/host_platform.rs:3520, :3588).
  • Hooks still reports a command cancelled by the unload gate as failed("cancelled") because spawn_with_stdin answers Ok(Cancelled) after the gate fires (crates/dim-agent-capabilities/src/hooks/runner.rs:408-437); ConfiguredError::Unloaded and the gate parameter are dead because the only caller passes None (crates/dim-agent-capabilities/src/host_platform.rs:3868, :3886).
  • crates/dim-agent-capabilities/src/shell_session.rs:6-8 still says the branch forwards chunks through a channel.
  • docs/architecture/rust-agent/plugins/WorkspaceTools.md:578 says P:HostPlatform stops a running task; BackgroundExec.stop cancels its own token (crates/dim-agent-capabilities/src/workspace_tools/background.rs:502-510).
  • spawnConfined still carries the old spawnWithStdin comment (crates/dim-agent-capabilities/src/host_platform.rs:717-721; npm/branch-services.d.ts:384-390).
  • npm/plugin.d.ts:264 re-exports only HostPlatform and HostInfo; the face also returns ShellStatus, SandboxBackend, ExecShellRuntime, Os, ShellEdition, ShellSource, OutputEncoding, OutputPage, OutputTail, OutputPathReply, ShellEvent, ShellState and the request and error types.
  • command_files is still never Some (crates/dim-app-server/src/lib.rs:997), so the FileStorage branch of retained_output_page is dead.
  • spawn_with_stdin still leaks its cancellation waiter on every early error (crates/dim-agent-capabilities/src/host_platform.rs:799-838).
  • The PR description still says the handle methods stay off the service, that task operations stay in their existing services, and that 19 tests pass; the head serves them and has 24 host_platform tests.
  • docs/design/resource-faces.md:723-726 still treats write/resize/output as undecided, and :120 still advertises the shell outputPath for file reads although the new Drop deletes it at settle.

New at this head:

  • The shell doc still says "Requires the plugin-built owner" (crates/dim-agent-capabilities/src/host_platform.rs:1149, npm/branch-services.d.ts:443) although the method no longer calls arc(). The inline note on this line has the details.
  • shell now runs on a HostPlatform::current platform (crates/dim-agent-capabilities/src/host_platform.rs:1183), but that constructor has no cleanup effect: its command_shutdown is never cancelled and its command_workers is never closed (:680-681). An embedding that starts a shell on such a platform and drops it without kill/settle leaves the shell worker and PTY running until the runtime stops. The plugin path is unaffected because its effect cancels and waits (:1900-1909). If current is meant to run shells, give the assembly a shutdown effect or state the caller obligation.
  • A PTY start failure after the log is created leaves an empty 0600 file and makes a retry with the same task id return task_exists (crates/dim-agent-capabilities/src/host_platform.rs:3485-3504). The inline note on the open has the details.
  • The running preview_truncated omits output_bytes > preview.len() and compares against the raw preview length, so previews that contain control bytes can be reported truncated while the terminal reply says complete (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:1954-1957 against :1819-1824, :2275, :2388). Use bounded_preview(&capture.preview, capture.output_bytes as usize) for both.
  • process_error maps exec_invalid_request, which start_command returns for a failed spawn, to Invalid (crates/dim-agent-capabilities/src/host_platform.rs:1021-1030). A host failure reads as caller input.
  • start_command uses Path::exists(), which is false for a dangling symlink; a dangling <taskId>.log still passes the check and fails later at create_new (crates/dim-agent-capabilities/src/workspace_tools/exec.rs:1990-1994, :1863-1867).
  • An intermediate symlink that resolves inside execRoot is followed; the new removal test covers .., the root itself, a final symlink and an absent directory, not a symlinked root, an intermediate link or the SessionFiles fallback.

Cross-PR

  • Against origin/main b4859558: merge-tree clean. Main has changed no file this head touches since the merge base.
  • #1916 and #1997 merge cleanly with this head.
  • #1911, #1909, #1908 and #1881 already conflict with origin/main in their own rebase; pairwise with this head they conflict in the same shared files (#1911 and #1909: app-server lib.rs, generated catalog, service-faces.md, npm/branch-services.d.ts, npm/plugin.d.ts, minimal_execution.rs; #1908: app-server lib.rs; #1881: crates/dim-report/src/draft.rs and evidence.rs). This PR adds no new conflict class, but the generated files need regeneration after either side merges.

Verification

  • cargo test --locked -p dim-agent-capabilities --test capabilities_flow host_platform_flow: 24 passed, including the_host_platform_service_serves_a_shell and output_removal_refuses_traversal_and_links.
  • cargo test --locked -p dim-agent-integration-tests --test integration_flow minimal_execution::: 22 passed.
  • cargo test --locked -p dim-modality --test modality_suite ocr_plugin_helper_copy_gone_before_spawn_fails_the_task: 1 passed.
  • cargo run --locked -p xtask -- check: passed, including service declarations and the generated catalog.
  • cargo clippy --locked -p dim-agent-capabilities -p dim-modality -p dim-app-server --all-targets -- -D warnings: passed.
  • cargo fmt --all -- --check: passed.
  • Pinned toolchain 1.100.0-aarch64-apple-darwin, isolated HOME, TMPDIR and XDG directories and CARGO_TARGET_DIR under the review data directory, LC_ALL=en_US.UTF-8.
  • CI at this head: changes, static-checks, macos-native, verify (linux) and ci-ok completed successfully; dependencies, scripts, web, windows-cli and acp-registry are skipped. The combined commit status still reads pending because of the skipped contexts.

Unverified

  • Windows behavior of the job pid resolution, the removal canonicalization and the shell log deletion while the file is open.
  • The pending-buffer memory growth and the reset burst are source-level; no deterministic test drives either.
  • The shell-exit and pid-marker race is source-level; the minimal test covers the normal path.
  • The intermediate-symlink-inside-root and symlinked-root removal cases are source-level.
  • Non-UTF-8 PathBuf behavior on the wire is source-level.
  • The preview_truncated control-byte difference is source-level.

}

/// Starts a persistent PTY shell on this node and returns the task id.
/// Requires the plugin-built owner.

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.

Problem: this sentence is now false. shell calls self.start_shell directly (line 1183) and no longer uses arc(), so a platform built by HostPlatform::current can start a shell. The same text is generated into npm/branch-services.d.ts:442-443, so a TypeScript caller is told the operation needs the plugin owner.

Failure scenario: a host that provides a current platform with with_execution_settings has a working shell, but the public contract says it should fail Closed; a caller avoids the operation or handles a failure that cannot occur.

Evidence: crates/dim-agent-capabilities/src/host_platform.rs:1149, :1183; npm/branch-services.d.ts:442-443.

Fix: delete the sentence. If spawn keeps the owner requirement, document the difference between the two methods.

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.

Still open at a56c536, on the same line (crates/dim-agent-capabilities/src/host_platform.rs:1185, generated npm/branch-services.d.ts:449). shell still calls self.start_shell directly at :1219-1231, so a HostPlatform::current platform with execution settings can start a shell. The sentence still tells a caller that the operation needs the plugin-built owner. Delete it.

use std::os::unix::fs::OpenOptionsExt;
options.mode(0o600);
}
let mut file = options.open(&path).map_err(|error| ProcessSpecError {

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.

Problem: the log is created with create_new before spawn_pty (line 3501). If the PTY cannot start, start_shell returns the error without constructing ShellTask, so Drop for ShellTask (line 3325) never removes the file.

Failure scenario: a transient spawn_pty failure (no PTY device, file descriptor exhaustion, shell executable gone) leaves <outputDir>/<taskId>.log; a retry with the same task id now fails task_exists at this open, permanently for that id, and the empty 0600 file remains until the directory is deleted.

Evidence: crates/dim-agent-capabilities/src/host_platform.rs:3485-3504, :3325-3329.

Fix: open the log after the PTY starts, or remove path on every error path after the open. The log has no in-tree reader now that the event queue serves readers; dropping it would remove this case entirely.

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.

Still open at a56c536. The log is still opened with create_new before spawn_pty (crates/dim-agent-capabilities/src/host_platform.rs:3762-3777, spawn at :3778), so a PTY start failure leaves an empty 0600 file and a retry with the same id returns task_exists. The new capture path adds a related case: its WaitReply.outputPath names a file that is never created, noted on the capture wait line.

The event page now acknowledges its cursor and the reader waits when the bounded queue is full instead of dropping chunks; a burst no longer resets or kills a healthy shell. ShellState is derived from full markers with cross-chunk line buffering, so the echoed wrapper does not flip ready. Job registration validates the full end marker.
@eric8810

Copy link
Copy Markdown
Collaborator Author

Head 9fbd475eb: the 30-second failed{terminate_failed} deadline now applies regardless of whether a later enumeration returned a tree, closing the pid-reuse path noted in 4697518825. Clippy clean.

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

One lifecycle requirement remains: Stop must report a bounded, explicit failure when release is unconfirmed without dropping cleanup ownership. Do not publish Cancelled or allow settlement until release of the original job is verified.

The new observer deadline now also covers jobs with a captured process list. If a tracked process remains alive at the deadline, terminal Failed lets the branch watcher settle and discard tracking before verifying release. The earlier initial-snapshot fix stays closed; a later view that cannot account for the original job still does not establish release.

Static finding. CI at verification: macOS passed; Linux and Windows in progress.

@yyhhyyyyyy yyhhyyyyyy 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: #2002 Serve hostPlatform's data methods; withdraw the execHost face

Reviewed head 9fbd475e against origin/main c8417f1f; merge base 1ca651ba. The full diff is 44 files, 8,216 insertions and 2,468 deletions. Round 49. Verdict: APPROVE.

The PR serves hostPlatform's task and shell methods as a process data face and withdraws the design-only execHost face. The increment since the round 48 approval at bc4e0bd1 is one line at crates/dim-agent-capabilities/src/host_platform.rs:3650: the failed-stop observer's 30 s deadline no longer requires tree.is_none().

The increment is correct

  • A confirmed release still wins. job_released is checked first (:3636-3648), so a release seen before the deadline records Cancelled with TerminateFailed "job release was not confirmed at stop; it ended later"; only a still-unconfirmed release reaches Failed{TerminateFailed "job release could not be confirmed"} (:3650-3662).
  • Failing while processes may still be alive is the documented outcome, not a new one. A running job's kill answers cancelled or failed{terminate_failed} (docs/design/research/1295-host-platform-task-owner.md:59), and failed remains an error "including when the process tree could not be released" (docs/architecture/rust-agent/plugins/WorkspaceTools.md:145-146). The terminal does not claim the processes are dead; it says release could not be confirmed, which is the actual state when a reused pid, or an OpenProcess failure that process_alive reads as alive (:2882-2894), keeps job_released false. The only false failure would be a tree that releases after 30 s, and a forced TerminateProcess/SIGKILL tree that survives 30 s is not a legitimate slow stop. A bounded failure is the intended contract.
  • The bound now actually bounds. Before this commit a known tree defeated the deadline, so the observer polled until unload. On Unix job_tree returns None (:3704-3714), so the gate was always true and Unix behavior is unchanged; job_released can spend up to 2 s in wait_job_exit (:3728-3747), which makes the effective Unix bound about 32 s. That is still a bound, and I agree with the earlier review that the Unix deadline is intended.
  • The claim is released and the waiters finish. Both job-stop call sites remove the claim after the observer returns (:1310-1311, :1358-1359), and a later kill on the terminal record is Ok (:1233-1235). The ShellSession kill-failed watcher waits with no timeout (crates/dim-agent-capabilities/src/shell_session.rs:1615-1643); it now gets Failed within the bound, publishes the exec/ended fact through ended_from_reply (:1905-1936), and settles. No terminal is lost: finish is first-wins (crates/dim-agent-capabilities/src/host_platform/task.rs:98-108), so a later job marker or shell sweep cannot overwrite the record; TaskStatus::Failed maps to WaitStatus::Failed (task.rs:25-33) and the reply carries the failure (task.rs:199-212).

Prior items

  • The round 48 P3 1 (deadline gated on tree.is_none()) is fixed by 9fbd475e; withdrawn.
  • Correction to my round 48 rationale: the unbounded waiters behind this path are ShellSession's kill-failed watcher and any hostPlatform.wait without a timeout. stop_owner (crates/dim-agent-capabilities/src/workspace_tools/background.rs:282-302) and BackgroundExec::stop (:673-714) wait on exec command records, whose worker finishes after the bounded terminate (host_platform.rs:4739-4783); the job observer never blocked them. The gate defect itself was real and is fixed.
  • Prior optional items still open, unchanged by this commit: threads 4694970077 (the design record still says settle(shellId) removes child records), 4695132946 (the two contract pages say a second kill while a stop is pending answers task_running, which holds only for jobs), and 4693473857 (cleanup_unconfirmed kills the shell without settling it).
  • I agree with the earlier review's post-termination re-enumeration limit, the unused tree_alive/pid note and the missing TaskKind::Job kill test; this commit changes none of them.

Cross-PR and main

  • git merge-tree --write-tree against origin/main c8417f1f is clean; git diff --check is clean.
  • Clean against #2202 674789c8, #2201 8ac1b6fb, #2200 487bb694, #2198 c4fb791d, #2197 68ffb90b, #2178 b1387a0b, #2148 c8710c8b and #1767 03e5dfd4. #2174 f5d21296, #2171 04c7b701, #1881 ff9825d2 and #1306 9775537c conflict only in paths this PR does not touch (generated docs, xtask/src/catalog.rs, docs/design/plugins/EnvironmentSettings.md, docs/design/plugins/Report.md, Cargo.toml/Cargo.lock).

Verification

  • cargo test --locked --offline -p dim-agent-capabilities --test capabilities_flow -- host_platform_flow::a_job_write_terminalizes_and_reads_its_output: 1 passed, 698 filtered.
  • cargo test --locked --offline -p dim-agent-integration-tests --test integration_flow -- minimal_execution::stop_background_task: 1 passed, 235 filtered.
  • cargo clippy --locked --offline -p dim-agent-capabilities --all-targets -- -D warnings: pass.
  • Isolated HOME, TMPDIR and XDG under the review data directory; LC_ALL=en_US.UTF-8; offline; worktree clean; no residual processes.
  • CI at 9fbd475e: changes, macos-native and windows-cli pass; verify (linux) is in progress.

Unverified

  • The Windows deadline path is not entered by any local test; windows-cli compiles it. The existing gap that no test kills a TaskKind::Job remains, and the deadline itself was not waited out here.

yyhhyyyyyy
yyhhyyyyyy previously approved these changes Nov 25, 2026

@yyhhyyyyyy yyhhyyyyyy 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: #2002 Serve hostPlatform's data methods; withdraw the execHost face

Reviewed head 9fbd475e against origin/main c8417f1f; merge base 1ca651ba. The full diff is 44 files, 8,216 insertions and 2,468 deletions. Round 49. Verdict: APPROVE.

The PR serves hostPlatform's task and shell methods as a process data face and withdraws the design-only execHost face. The increment since the round 48 approval at bc4e0bd1 is one line at crates/dim-agent-capabilities/src/host_platform.rs:3650: the failed-stop observer's 30 s deadline no longer requires tree.is_none().

The increment is correct

  • A confirmed release still wins. job_released is checked first (:3636-3648), so a release seen before the deadline records Cancelled with TerminateFailed "job release was not confirmed at stop; it ended later"; only a still-unconfirmed release reaches Failed{TerminateFailed "job release could not be confirmed"} (:3650-3662).
  • Failing while processes may still be alive is the documented outcome, not a new one. A running job's kill answers cancelled or failed{terminate_failed} (docs/design/research/1295-host-platform-task-owner.md:59), and failed remains an error "including when the process tree could not be released" (docs/architecture/rust-agent/plugins/WorkspaceTools.md:145-146). The terminal does not claim the processes are dead; it says release could not be confirmed, which is the actual state when a reused pid, or an OpenProcess failure that process_alive reads as alive (:2882-2894), keeps job_released false. The only false failure would be a tree that releases after 30 s, and a forced TerminateProcess/SIGKILL tree that survives 30 s is not a legitimate slow stop. A bounded failure is the intended contract.
  • The bound now actually bounds. Before this commit a known tree defeated the deadline, so the observer polled until unload. On Unix job_tree returns None (:3704-3714), so the gate was always true and Unix behavior is unchanged; job_released can spend up to 2 s in wait_job_exit (:3728-3747), which makes the effective Unix bound about 32 s. That is still a bound, and I agree with the earlier review that the Unix deadline is intended.
  • The claim is released and the waiters finish. Both job-stop call sites remove the claim after the observer returns (:1310-1311, :1358-1359), and a later kill on the terminal record is Ok (:1233-1235). The ShellSession kill-failed watcher waits with no timeout (crates/dim-agent-capabilities/src/shell_session.rs:1615-1643); it now gets Failed within the bound, publishes the exec/ended fact through ended_from_reply (:1905-1936), and settles. No terminal is lost: finish is first-wins (crates/dim-agent-capabilities/src/host_platform/task.rs:98-108), so a later job marker or shell sweep cannot overwrite the record; TaskStatus::Failed maps to WaitStatus::Failed (task.rs:25-33) and the reply carries the failure (task.rs:199-212).

Prior items

  • The round 48 P3 1 (deadline gated on tree.is_none()) is fixed by 9fbd475e; withdrawn.
  • Correction to my round 48 rationale: the unbounded waiters behind this path are ShellSession's kill-failed watcher and any hostPlatform.wait without a timeout. stop_owner (crates/dim-agent-capabilities/src/workspace_tools/background.rs:282-302) and BackgroundExec::stop (:673-714) wait on exec command records, whose worker finishes after the bounded terminate (host_platform.rs:4739-4783); the job observer never blocked them. The gate defect itself was real and is fixed.
  • Prior optional items still open, unchanged by this commit: threads 4694970077 (the design record still says settle(shellId) removes child records), 4695132946 (the two contract pages say a second kill while a stop is pending answers task_running, which holds only for jobs), and 4693473857 (cleanup_unconfirmed kills the shell without settling it).
  • I agree with the earlier review's post-termination re-enumeration limit, the unused tree_alive/pid note and the missing TaskKind::Job kill test; this commit changes none of them.

Cross-PR and main

  • git merge-tree --write-tree against origin/main c8417f1f is clean; git diff --check is clean.
  • Clean against #2202 674789c8, #2201 8ac1b6fb, #2200 487bb694, #2198 c4fb791d, #2197 68ffb90b, #2178 b1387a0b, #2148 c8710c8b and #1767 03e5dfd4. #2174 f5d21296, #2171 04c7b701, #1881 ff9825d2 and #1306 9775537c conflict only in paths this PR does not touch (generated docs, xtask/src/catalog.rs, docs/design/plugins/EnvironmentSettings.md, docs/design/plugins/Report.md, Cargo.toml/Cargo.lock).

Verification

  • cargo test --locked --offline -p dim-agent-capabilities --test capabilities_flow -- host_platform_flow::a_job_write_terminalizes_and_reads_its_output: 1 passed, 698 filtered.
  • cargo test --locked --offline -p dim-agent-integration-tests --test integration_flow -- minimal_execution::stop_background_task: 1 passed, 235 filtered.
  • cargo clippy --locked --offline -p dim-agent-capabilities --all-targets -- -D warnings: pass.
  • Isolated HOME, TMPDIR and XDG under the review data directory; LC_ALL=en_US.UTF-8; offline; worktree clean; no residual processes.
  • CI at 9fbd475e: changes, macos-native and windows-cli pass; verify (linux) is in progress.

Unverified

  • The Windows deadline path is not entered by any local test; windows-cli compiles it. The existing gap that no test kills a TaskKind::Job remains, and the deadline itself was not waited out here.

yyhhyyyyyy
yyhhyyyyyy previously approved these changes Nov 25, 2026

@yyhhyyyyyy yyhhyyyyyy 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: #2002 Serve hostPlatform's data methods; withdraw the execHost face

Reviewed head 9fbd475e against origin/main c8417f1f; merge base 1ca651ba. The full diff is 44 files, 8,216 insertions and 2,468 deletions. Round 49. Verdict: APPROVE.

The PR serves hostPlatform's task and shell methods as a process data face and withdraws the design-only execHost face. The increment since the round 48 approval at bc4e0bd1 is one line at crates/dim-agent-capabilities/src/host_platform.rs:3650: the failed-stop observer's 30 s deadline no longer requires tree.is_none().

The increment is correct

  • A confirmed release still wins. job_released is checked first (:3636-3648), so a release seen before the deadline records Cancelled with TerminateFailed "job release was not confirmed at stop; it ended later"; only a still-unconfirmed release reaches Failed{TerminateFailed "job release could not be confirmed"} (:3650-3662).
  • Failing while processes may still be alive is the documented outcome, not a new one. A running job's kill answers cancelled or failed{terminate_failed} (docs/design/research/1295-host-platform-task-owner.md:59), and failed remains an error "including when the process tree could not be released" (docs/architecture/rust-agent/plugins/WorkspaceTools.md:145-146). The terminal does not claim the processes are dead; it says release could not be confirmed, which is the actual state when a reused pid, or an OpenProcess failure that process_alive reads as alive (:2882-2894), keeps job_released false. The only false failure would be a tree that releases after 30 s, and a forced TerminateProcess/SIGKILL tree that survives 30 s is not a legitimate slow stop. A bounded failure is the intended contract.
  • The bound now actually bounds. Before this commit a known tree defeated the deadline, so the observer polled until unload. On Unix job_tree returns None (:3704-3714), so the gate was always true and Unix behavior is unchanged; job_released can spend up to 2 s in wait_job_exit (:3728-3747), which makes the effective Unix bound about 32 s. That is still a bound, and I agree with the earlier review that the Unix deadline is intended.
  • The claim is released and the waiters finish. Both job-stop call sites remove the claim after the observer returns (:1310-1311, :1358-1359), and a later kill on the terminal record is Ok (:1233-1235). The ShellSession kill-failed watcher waits with no timeout (crates/dim-agent-capabilities/src/shell_session.rs:1615-1643); it now gets Failed within the bound, publishes the exec/ended fact through ended_from_reply (:1905-1936), and settles. No terminal is lost: finish is first-wins (crates/dim-agent-capabilities/src/host_platform/task.rs:98-108), so a later job marker or shell sweep cannot overwrite the record; TaskStatus::Failed maps to WaitStatus::Failed (task.rs:25-33) and the reply carries the failure (task.rs:199-212).

Prior items

  • The round 48 P3 1 (deadline gated on tree.is_none()) is fixed by 9fbd475e; withdrawn.
  • Correction to my round 48 rationale: the unbounded waiters behind this path are ShellSession's kill-failed watcher and any hostPlatform.wait without a timeout. stop_owner (crates/dim-agent-capabilities/src/workspace_tools/background.rs:282-302) and BackgroundExec::stop (:673-714) wait on exec command records, whose worker finishes after the bounded terminate (host_platform.rs:4739-4783); the job observer never blocked them. The gate defect itself was real and is fixed.
  • Prior optional items still open, unchanged by this commit: threads 4694970077 (the design record still says settle(shellId) removes child records), 4695132946 (the two contract pages say a second kill while a stop is pending answers task_running, which holds only for jobs), and 4693473857 (cleanup_unconfirmed kills the shell without settling it).
  • I agree with the earlier review's post-termination re-enumeration limit, the unused tree_alive/pid note and the missing TaskKind::Job kill test; this commit changes none of them.

Cross-PR and main

  • git merge-tree --write-tree against origin/main c8417f1f is clean; git diff --check is clean.
  • Clean against #2202 674789c8, #2201 8ac1b6fb, #2200 487bb694, #2198 c4fb791d, #2197 68ffb90b, #2178 b1387a0b, #2148 c8710c8b and #1767 03e5dfd4. #2174 f5d21296, #2171 04c7b701, #1881 ff9825d2 and #1306 9775537c conflict only in paths this PR does not touch (generated docs, xtask/src/catalog.rs, docs/design/plugins/EnvironmentSettings.md, docs/design/plugins/Report.md, Cargo.toml/Cargo.lock).

Verification

  • cargo test --locked --offline -p dim-agent-capabilities --test capabilities_flow -- host_platform_flow::a_job_write_terminalizes_and_reads_its_output: 1 passed, 698 filtered.
  • cargo test --locked --offline -p dim-agent-integration-tests --test integration_flow -- minimal_execution::stop_background_task: 1 passed, 235 filtered.
  • cargo clippy --locked --offline -p dim-agent-capabilities --all-targets -- -D warnings: pass.
  • Isolated HOME, TMPDIR and XDG under the review data directory; LC_ALL=en_US.UTF-8; offline; worktree clean; no residual processes.
  • CI at 9fbd475e: changes, macos-native and windows-cli pass; verify (linux) is in progress.

Unverified

  • The Windows deadline path is not entered by any local test; windows-cli compiles it. The existing gap that no test kills a TaskKind::Job remains, and the deadline itself was not waited out here.

yyhhyyyyyy
yyhhyyyyyy previously approved these changes Nov 25, 2026

@yyhhyyyyyy yyhhyyyyyy 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: #2002 Serve hostPlatform's data methods; withdraw the execHost face

Reviewed head 9fbd475e against origin/main c8417f1f; merge base 1ca651ba. The full diff is 44 files, 8,216 insertions and 2,468 deletions. Round 49. Verdict: APPROVE.

The PR serves hostPlatform's task and shell methods as a process data face and withdraws the design-only execHost face. The increment since the round 48 approval at bc4e0bd1 is one line at crates/dim-agent-capabilities/src/host_platform.rs:3650: the failed-stop observer's 30 s deadline no longer requires tree.is_none().

The increment is correct

  • A confirmed release still wins. job_released is checked first (:3636-3648), so a release seen before the deadline records Cancelled with TerminateFailed "job release was not confirmed at stop; it ended later"; only a still-unconfirmed release reaches Failed{TerminateFailed "job release could not be confirmed"} (:3650-3662).
  • Failing while processes may still be alive is the documented outcome, not a new one. A running job's kill answers cancelled or failed{terminate_failed} (docs/design/research/1295-host-platform-task-owner.md:59), and failed remains an error "including when the process tree could not be released" (docs/architecture/rust-agent/plugins/WorkspaceTools.md:145-146). The terminal does not claim the processes are dead; it says release could not be confirmed, which is the actual state when a reused pid, or an OpenProcess failure that process_alive reads as alive (:2882-2894), keeps job_released false. The only false failure would be a tree that releases after 30 s, and a forced TerminateProcess/SIGKILL tree that survives 30 s is not a legitimate slow stop. A bounded failure is the intended contract.
  • The bound now actually bounds. Before this commit a known tree defeated the deadline, so the observer polled until unload. On Unix job_tree returns None (:3704-3714), so the gate was always true and Unix behavior is unchanged; job_released can spend up to 2 s in wait_job_exit (:3728-3747), which makes the effective Unix bound about 32 s. That is still a bound, and I agree with the earlier review that the Unix deadline is intended.
  • The claim is released and the waiters finish. Both job-stop call sites remove the claim after the observer returns (:1310-1311, :1358-1359), and a later kill on the terminal record is Ok (:1233-1235). The ShellSession kill-failed watcher waits with no timeout (crates/dim-agent-capabilities/src/shell_session.rs:1615-1643); it now gets Failed within the bound, publishes the exec/ended fact through ended_from_reply (:1905-1936), and settles. No terminal is lost: finish is first-wins (crates/dim-agent-capabilities/src/host_platform/task.rs:98-108), so a later job marker or shell sweep cannot overwrite the record; TaskStatus::Failed maps to WaitStatus::Failed (task.rs:25-33) and the reply carries the failure (task.rs:199-212).

Prior items

  • The round 48 P3 1 (deadline gated on tree.is_none()) is fixed by 9fbd475e; withdrawn.
  • Correction to my round 48 rationale: the unbounded waiters behind this path are ShellSession's kill-failed watcher and any hostPlatform.wait without a timeout. stop_owner (crates/dim-agent-capabilities/src/workspace_tools/background.rs:282-302) and BackgroundExec::stop (:673-714) wait on exec command records, whose worker finishes after the bounded terminate (host_platform.rs:4739-4783); the job observer never blocked them. The gate defect itself was real and is fixed.
  • Prior optional items still open, unchanged by this commit: threads 4694970077 (the design record still says settle(shellId) removes child records), 4695132946 (the two contract pages say a second kill while a stop is pending answers task_running, which holds only for jobs), and 4693473857 (cleanup_unconfirmed kills the shell without settling it).
  • I agree with the earlier review's post-termination re-enumeration limit, the unused tree_alive/pid note and the missing TaskKind::Job kill test; this commit changes none of them.

Cross-PR and main

  • git merge-tree --write-tree against origin/main c8417f1f is clean; git diff --check is clean.
  • Clean against #2202 674789c8, #2201 8ac1b6fb, #2200 487bb694, #2198 c4fb791d, #2197 68ffb90b, #2178 b1387a0b, #2148 c8710c8b and #1767 03e5dfd4. #2174 f5d21296, #2171 04c7b701, #1881 ff9825d2 and #1306 9775537c conflict only in paths this PR does not touch (generated docs, xtask/src/catalog.rs, docs/design/plugins/EnvironmentSettings.md, docs/design/plugins/Report.md, Cargo.toml/Cargo.lock).

Verification

  • cargo test --locked --offline -p dim-agent-capabilities --test capabilities_flow -- host_platform_flow::a_job_write_terminalizes_and_reads_its_output: 1 passed, 698 filtered.
  • cargo test --locked --offline -p dim-agent-integration-tests --test integration_flow -- minimal_execution::stop_background_task: 1 passed, 235 filtered.
  • cargo clippy --locked --offline -p dim-agent-capabilities --all-targets -- -D warnings: pass.
  • Isolated HOME, TMPDIR and XDG under the review data directory; LC_ALL=en_US.UTF-8; offline; worktree clean; no residual processes.
  • CI at 9fbd475e: changes, macos-native and windows-cli pass; verify (linux) is in progress.

Unverified

  • The Windows deadline path is not entered by any local test; windows-cli compiles it. The existing gap that no test kills a TaskKind::Job remains, and the deadline itself was not waited out here.

The observer no longer turns an unconfirmed release into a terminal after 30 seconds; Stop already reports the bounded failure, and the owner keeps observing until the original tree is released.
@eric8810

Copy link
Copy Markdown
Collaborator Author

Head a22492beb: an unconfirmed release no longer becomes a terminal after 30 seconds. Stop still returns its bounded failure, while the owner observer keeps the job Running and cleanup obligation until the original tree is released. stop_background_task and clippy pass.

@yyhhyyyyyy yyhhyyyyyy 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: #2002 Serve hostPlatform's data methods; withdraw the execHost face

Reviewed head a22492be against origin/main c8417f1f; merge base 1ca651ba. The full diff is 44 files, 8,201 insertions and 2,468 deletions. Round 50. Verdict: APPROVE.

The PR serves hostPlatform's task and shell methods as a process data face and withdraws the design-only execHost face. The increment since the round 49 approval at 9fbd475e is one commit in crates/dim-agent-capabilities/src/host_platform.rs (15 deletions): observe_job_release no longer carries the 30 s timer or finishes failed{terminate_failed} while release is unconfirmed.

The reversal keeps the lifecycle requirement

  • The round 47/48 P2 was a Stop that waited. No Stop call waits on this observer. kill captures the tree, waits at most 2 s in kill_job (crates/dim-agent-capabilities/src/host_platform.rs:3659-3687, :3713-3732 for the Unix group probe), spawns the observer, and returns Failed at :1361. ShellSession::stop turns that into a failed result at crates/dim-agent-capabilities/src/shell_session.rs:1588-1603 and keeps the watcher at :1605-1644. The pid-unknown path answers task_running after its 2 s pid wait (host_platform.rs:1276-1279, :1348). BackgroundExec::stop and stop_owner wait on Command records, not on this observer.
  • Cleanup ownership is preserved as the author's comment describes. The record stays Running and the stop claim (host_platform.rs:1271-1272) stays set, so settle refuses (:1383-1385) and a second host kill answers task_running, which the two contract pages document (docs/design/resource-faces.md:164, docs/architecture/rust-agent/plugins/HostPlatform.md:29). Nothing publishes Cancelled before job_released returns true (:3635-3647). The record and the claim end when release is observed, or when the shell record's terminal sweeps its children on shell exit or owner unload (:4836-4881, crates/dim-agent-capabilities/src/host_platform/task.rs:125-131).
  • A terminal that bounds waiters without allowing settlement would need a new task state. The Stop reply already carries the explicit failure, so that mechanism is not needed for this requirement. The tradeoff is correct: the Stop reply is already bounded, and the record stays live so cleanup can still run.
  • One wording limit: with a captured tree that stays None, job_released is false forever (host_platform.rs:3701-3710), so the state is bounded by the shell record's end, not by observing the original tree. The code is safe; the research record should say so.

Optional (P3)

  1. docs/design/research/1295-host-platform-task-owner.md:59 still lists failed{terminate_failed} as a job kill terminal. After this commit a job record ends cancelled on verified release or failed{shell_exited}/failed{owner_unloaded} on the sweep; the terminate failure is the kill reply, not a terminal. An implementer restoring the row would reintroduce settlement before release. State the pending stop and the two real ends.
  2. No test kills a TaskKind::Job or exercises a failed stop. The new state, a Running record with the claim held until the shell ends, is what protects cleanup ownership, and a regression would be silent. Add a test that a failed stop stays Running, a second kill answers task_running, and the shell exit publishes one failed{shell_exited}.

Prior items

  • My round 49 rationale that the 30 s Failed terminal is the intended bound is withdrawn; the earlier review's lifecycle requirement governs, and this head implements it. My round 49 statement that the waiters get a terminal within the bound no longer holds while the shell lives: the terminal follows release, the shell exit or unload.
  • The optional bound I asked for in thread 4696422322 is withdrawn for the same reason.
  • Prior optional items are unchanged: thread 4694970077 (settle wording), 4695132946 (second kill wording), 4693473857 (cleanup_unconfirmed does not settle the shell), 4696041924 (pre-terminate snapshot). I agree with the earlier optional notes on pid reuse, the post-termination enumeration limit, the unused tree_alive, and the missing job kill test; this commit changes none of them.

Cross-PR and main

  • git merge-tree --write-tree origin/main HEAD is clean; git diff --check is clean.
  • Against #2202 674789c8, #2201 8ac1b6fb, #2200 487bb694, #2198 c4fb791d, #2197 68ffb90b, #2178 b1387a0b, #2148 c8710c8b and #1767 03e5dfd4 it is clean. #2174 f5d21296, #2171 04c7b701, #1881 ff9825d2 and #1306 9775537c conflict only in generated docs, xtask/src/catalog.rs, docs/design/plugins/EnvironmentSettings.md, docs/design/plugins/Report.md and Cargo.toml/Cargo.lock, paths this PR does not touch.

Verification

  • cargo test --locked --offline -p dim-agent-capabilities --test capabilities_flow -- host_platform_flow::a_job_write_terminalizes_and_reads_its_output: 1 passed, 698 filtered.
  • cargo test --locked --offline -p dim-agent-integration-tests --test integration_flow -- minimal_execution::stop_background_task: 1 passed, 235 filtered.
  • cargo test --locked --offline -p dim-agent-integration-tests --test integration_flow -- minimal_execution::shell_exit: 2 passed, 234 filtered.
  • cargo clippy --locked --offline -p dim-agent-capabilities --all-targets -- -D warnings: pass.
  • Isolated HOME, TMPDIR and XDG under the review data directory; LC_ALL=en_US.UTF-8; offline; worktree clean; no residual processes.
  • CI at a22492be: changes, macos-native and windows-cli pass; verify (linux) is in progress.

Unverified

  • The failed-stop state needs a real kill_job failure; no local test forces one, and the Windows branches were not run here. The None behavior is read from source (host_platform.rs:3701-3710), not exercised.

shutdown: CancellationToken,
mut tree: Option<Vec<u32>>,
) {
loop {

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.

P3: this loop now carries the whole cleanup obligation for a failed stop, and no test reaches it. When kill_job fails (a Windows tree that cannot be enumerated, or a tree alive after 2 s), kill returns the bounded Failed at :1361 and leaves this observer to keep the record Running and the claim at :1271-1272 set, so settle answers task_running and a second host kill answers task_running until release is observed or the shell record's sweep runs (:4836-4881). Failure scenario: a regression that finishes the record early (the 30 s path this commit removed) again lets settle drop the child record while the process tree may still be alive, and a regression that forgets the claim release leaks stopping for the life of the owner; nothing fails. Evidence: the only job test, crates/dim-agent-capabilities/tests/host_platform_flow.rs:2222, ends the job through its marker. Fix: cover a failed stop, a second kill, and exactly one failed{shell_exited} at shell exit.

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.

Still open at d71528c. The commit changes only the research record; no test makes kill_job fail, so observe_job_release, the Running record and the claim release are unexercised. stop_background_task covers only the successful job kill (tests/integration/tests/minimal_execution.rs:960-991).


| Action | Exec command | Shell command | Job | Shell |
| --- | --- | --- | --- | --- |
| `kill` running | cancel + terminate; await release; `cancelled` or `failed{terminate_failed}` | ETX only if active; terminal from marker or sweep | signal pid; `cancelled` or `failed{terminate_failed}`; missing pid answers `task_running` and keeps a pid watcher | terminate PTY; `cancelled` or `failed{terminate_failed}`; sweep |

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.

P3: this cell no longer matches the code. A job record is now cancelled only when job_released confirms the original tree (crates/dim-agent-capabilities/src/host_platform.rs:3635-3647), or failed{shell_exited}/failed{owner_unloaded} when the shell record's sweep ends it (:4836-4881); a terminate failure is the kill reply (:1361), not a job terminal. An implementer who restores failed{terminate_failed} here would terminalize before release and reopen settlement while the process may still run. Fix: state the pending stop and the two real ends.

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.

Partly fixed in d71528c: the cell now states the pending stop and the two ends. One sweep outcome is still missing: a shell killed for an interrupt sweeps jobs to failed{shell_reset} (crates/dim-agent-capabilities/src/host_platform.rs:4836-4846), as this record already says at line 229. Inline note on the new cell.

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.

Fixed in 88afcf1. The Job kill cell now lists failed{shell_reset} with the other sweep outcomes, so the sweep carries the shell end (shell_exited, shell_reset, owner_unloaded).

A job stays pending until release or the shell sweep; settle removes only the requested shell record.
@eric8810

Copy link
Copy Markdown
Collaborator Author

Head d71528c9e: aligned the research record with a22492b. A job stays pending until release or the shell sweep; a terminate failure is the kill reply, not a job terminal; settle removes only the requested shell record.

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

The bounded Stop reply and deadline-driven settlement are fixed: the caller can report failure while cleanup remains owned.

One part of the existing release requirement remains. On Windows, if the initial snapshot is unavailable, the release observer can treat a later view that does not account for the original job as proof of release. It can publish Cancelled and let the branch settle even though release is still unconfirmed. Acceptance: a failed initial observation must not make the original job eligible for cancellation or settlement unless its release is independently confirmed. The Stop response can still be bounded and explicit.

Static finding. Exact-head CI passed on Windows, macOS, and Linux.

@yyhhyyyyyy yyhhyyyyyy 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: #2002 Serve hostPlatform's data methods; withdraw the execHost face

Reviewed head d71528c9 against origin/main c8417f1f; merge base 1ca651ba. Full diff: 44 files, 8,201 insertions, 2,468 deletions. Round 51. Verdict: APPROVE.

The PR serves hostPlatform's task and shell methods as a process data face and withdraws the design-only execHost face. Since the round 50 approval at a22492be, the only commit is d71528c9, a docs-only change to the research record (+4/-4). No code changed.

The increment matches the code

  • Job kill: kill inserts the stop claim (crates/dim-agent-capabilities/src/host_platform.rs:1271-1273), signals the pid through kill_job, which waits at most 2 s (:3659-3687), and on failure spawns the release observer and returns the bounded failure (:1361). Release finishes cancelled (:1315-1323, :3636-3647); a shell terminal sweeps non-terminal children (:4836-4881). A missing pid answers task_running after the 2 s pid wait and keeps the pid watcher (:1276-1348). The cell matches these paths except the sweep outcome below.
  • Settle: HostPlatform::settle removes only the requested record (:1379-1392); for a shell it calls sweep (:1388-1390), which terminalizes non-terminal children but removes none (:4858-4881). The paragraph and the settle row now say this. Thread 4694970077 is closed.
  • "A job whose release is unconfirmed stays Running until release or the shell's sweep" matches the observer's exits: release (:3635-3647), the record's terminal from the sweep (crates/dim-agent-capabilities/src/host_platform/task.rs:98-107, :125-131), or shutdown (:3649-3652). The unload terminal also sweeps the children (:4733-4734, :4767, :4836-4881).

Optional (P3)

  1. The new Job cell lists failed{shell_exited}/failed{owner_unloaded} as the sweep outcomes, but a shell killed for an interrupt finishes cancelled and its sweep ends each non-terminal child failed{shell_reset} (crates/dim-agent-capabilities/src/host_platform.rs:1250-1258, :4836-4846). The record already says so at line 229. Inline on line 59.
  2. The round 50 test gap is open: no test makes kill_job fail, so observe_job_release, the Running record and the claim release are unexercised. stop_background_task covers only the successful job kill (tests/integration/tests/minimal_execution.rs:960-991), and this commit changes no test.

Prior items

  • Round 50 P3 1, the Job kill cell: fixed apart from the failed{shell_reset} outcome above.
  • Round 50 P3 2, the failed-stop test: open.
  • Thread 4694970077, the settle wording: fixed in d71528c9; withdrawn.
  • I agree with the earlier review's optional notes on pid reuse and the unused tree_alive/pid; none blocks.

Other review and blocking state

The earlier change request (review 6061031744 at 9fbd475e) required a bounded stop failure without dropping cleanup ownership. a22492be keeps the bounded kill failure and the Running record, and d71528c9 records that outcome. That review predates both heads, so the PR still shows a change request at a stale commit.

Cross-PR and main

  • git merge-tree --write-tree origin/main HEAD is clean and git diff --check is clean.
  • The new commit touches only docs/design/research/1295-host-platform-task-owner.md, a path no other open PR touches. The heads that moved since round 50 (#2200 7f96aa5c, #2197 89471284, #2171 02d4e23b) share no path with it.

Verification

  • Docs-only; no build. The record's references are valid: §1, §2.2, §3.1 and §3.2 are its own sections; docs/design/resource-faces.md §3 and docs/design/service-faces.md §3.4 exist; it has no external links or anchors.
  • git diff --check origin/main...HEAD: clean.
  • CI at d71528c9: changes, macos-native and windows-cli pass; verify (linux) is in progress; static-checks and the path-filtered jobs are skipped.

Unverified

  • The Windows sweep and failed-stop paths were not run locally; windows-cli compiles them.
  • No test exercises the failed{shell_reset} sweep for a job; the finding is read from source (host_platform.rs:4836-4846).


| Action | Exec command | Shell command | Job | Shell |
| --- | --- | --- | --- | --- |
| `kill` running | cancel + terminate; await release; `cancelled` or `failed{terminate_failed}` | ETX only if active; terminal from marker or sweep | signal pid; pending stop until release; `cancelled` on release, `failed{shell_exited}`/`failed{owner_unloaded}` on sweep; missing pid answers `task_running` and keeps a pid watcher | terminate PTY; `cancelled` or `failed{terminate_failed}`; sweep |

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.

P3: this cell omits one sweep outcome. When a job's stop is pending and the shell is killed for an interrupt, the shell terminal is cancelled (crates/dim-agent-capabilities/src/host_platform.rs:1250-1258, :4733-4752, :5109-5144) and sweep ends each non-terminal child with failed{shell_reset} (:4836-4846); this record already states it at docs/design/research/1295-host-platform-task-owner.md:229. Failure scenario: a test or implementation built from this cell expects failed{shell_exited} for a job in a killed shell, or drops ShellReset as unreachable, so the job terminal disagrees with the owner. Fix: list failed{shell_reset} as the third sweep outcome, or say the sweep carries the shell end (shell_exited, shell_reset, owner_unloaded).

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.

Fixed in 88afcf1. sweep writes ShellReset when the shell terminal is cancelled without OwnerUnloaded (crates/dim-agent-capabilities/src/host_platform.rs:4836-4846), and the Job kill cell now lists it as the third sweep outcome (docs/design/research/1295-host-platform-task-owner.md:59).

A shell killed for an interrupt sweeps its job children to failed{shell_reset}.
@eric8810

Copy link
Copy Markdown
Collaborator Author

Head 88afcf11a: the Job kill cell now includes failed{shell_reset}, the sweep outcome for a shell killed by an interrupt. The failed-stop test gap remains optional.

@yyhhyyyyyy yyhhyyyyyy 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: #2002 Serve hostPlatform's data methods; withdraw the execHost face

Reviewed head 88afcf11 against origin/main c8417f1f; merge base 1ca651ba. Full diff: 44 files, 8,201 insertions, 2,468 deletions. Round 52. Verdict: APPROVE.

The PR serves hostPlatform's task and shell methods as a process data face and withdraws the design-only execHost face. Since the round 51 approval at d71528c9, the only commit is 88afcf11, a docs-only change to the research record (+1/-1). No code changed.

The change is accurate and closes the round 51 P3

  • The Job kill cell now lists failed{shell_exited}, failed{shell_reset} and failed{owner_unloaded} as the sweep outcomes (docs/design/research/1295-host-platform-task-owner.md:59). sweep selects ShellReset when the shell terminal is cancelled without an OwnerUnloaded failure (crates/dim-agent-capabilities/src/host_platform.rs:4836-4846) and fails every non-terminal child, jobs included (:4858-4881). ShellReset is constructed only there and consumed at crates/dim-agent-capabilities/src/shell_session.rs:1905-1917.
  • "On sweep" is the right qualifier. A confirmed job release finishes cancelled (host_platform.rs:1363-1371), and the failed-stop observer finishes cancelled with TerminateFailed when the group disappears (:3636-3646). Neither release path reaches ShellReset.
  • The row now agrees with the interrupt flow at line 229 and with the code that kills the shell after the bounded wait when Ctrl+C does not end the command (crates/dim-agent-capabilities/src/shell_session.rs:997-1082, :384-397).
  • The concern in thread 4698234823 is now addressed.

Remaining P3

The round 50 test gap is unchanged. No test makes kill_job fail, and no test pins a job's failed{shell_reset} terminal. stop_background_task covers only the successful job kill (tests/integration/tests/minimal_execution.rs:960-991); shell_exit_kills_background_jobs covers a normal shell exit and asserts only the shared "[shell was reset]" text (:1297-1301), which reset_result also emits for ShellExited (crates/dim-agent-capabilities/src/shell_session.rs:1905-1917). This does not block.

Prior items

  • Round 51 P3 1, the missing failed{shell_reset}: fixed in 88afcf11; withdrawn.
  • Round 51 P3 2, the failed-stop test: open as above.
  • Round 50's removal of the 30 s deadline and the cleanup-ownership tradeoff are unchanged and not reopened.

Other review and blocking state

The other reviewer's change request (review 6061770716 at d71528c9) concerns the Windows release observer and is untouched by this docs commit. The PR therefore still shows CHANGES_REQUESTED; this review does not address that item.

Cross-PR and main

  • git merge-tree --write-tree origin/main HEAD at c8417f1f is clean, and git diff --check is clean.
  • #2200 7f96aa5c and #2197 87f89c06 (current head) merge cleanly.
  • #2174 f5d21296 and #1881 ff9825d2 conflict, but each also conflicts with origin/main alone on the same files: generated catalog and services files plus xtask/src/catalog.rs, and docs/design/plugins/Report.md. This PR touches none of those paths, and #2174 is a draft. Neither conflict comes from this PR.

Verification

  • Docs-only; no tests run and no build needed. The changed line was checked against the code paths above.
  • CI at 88afcf11 (run 45663244438): changes, macos-native, verify (linux), windows-cli and ci-ok pass; the path-filtered jobs are skipped.

Unverified

  • The sweep and failed-stop paths are read from source; no test runs them (the P3 above).
  • Windows behavior was not run locally; windows-cli compiles it.

When the pre-termination snapshot is unavailable, a later enumeration cannot account for the original job; the observer keeps it pending until the shell sweep.
@eric8810

Copy link
Copy Markdown
Collaborator Author

Head 9448f8c8f: if the pre-termination Windows snapshot is unavailable, a later enumeration is no longer used as release evidence. The record stays pending with the owned cleanup until the shell sweep; the Stop reply remains bounded. stop_background_task and clippy pass.

@yyhhyyyyyy yyhhyyyyyy 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: #2002 Serve hostPlatform's data methods; withdraw the execHost face

Reviewed head 9448f8c8 against origin/main c8417f1f; merge base 1ca651ba. Full diff: 44 files, 8,200 insertions, 2,468 deletions. Round 53. Verdict: APPROVE.

The PR serves hostPlatform's task and shell methods as a process data face and withdraws the design-only execHost face. Since the round 52 approval at 88afcf11, the only commit is 9448f8c8, which removes the later job_tree(pid) re-enumeration from observe_job_release (+1/-2 in crates/dim-agent-capabilities/src/host_platform.rs).

The other reviewer's acceptance item is met

The acceptance item in review 6061770716 is met at this head:

  • observe_job_release passes the stop-time tree to job_released(pid, tree.as_deref()) on every tick (host_platform.rs:3634). On Windows job_released is tree.is_some_and(...) (:3708), so a None snapshot can never report release, and no later enumeration is consulted. On Unix the snapshot is always None and release comes from wait_job_exit(pid) probing the group (:3701-3705, :3713-3731), so the failed-observation case does not arise there.
  • A Some snapshot is a complete pre-termination walk, because the earlier commits return None on a first-entry or partial tree_pids failure (:2906-2920). Release is confirmed only when every original pid is dead. A pid reused by an unrelated process can delay release, not fabricate it, because no new pid enters the set.
  • The failed stop stays bounded. kill_job calls terminate_tree(pid) first, then returns TimedOut when the tree is unavailable (:3658-3686), and kill returns the typed failure at :1361. The record stays Running, so settle answers task_running (:1383-1384) and a second kill answers task_running through the stop claim (:1271-1272).
  • The terminal sources left for that record are independent of the failed observation: the pwsh completion marker (:1663, :4522-4527) and the shell terminal sweep, which writes failed{shell_exited}, failed{shell_reset} or failed{owner_unloaded} (:4836-4881). They are the documented shell-exit and sweep outcomes (docs/design/research/1295-host-platform-task-owner.md:59, :61, :65), not a cancelled from a later view.

On Windows, when the initial snapshot is unavailable and the shell stays alive, a job that did exit remains Running until its completion marker or the shell sweep or owner unload. This is the cleanup-ownership tradeoff accepted in rounds 50 to 52: the stop already returned a bounded failure or task_running from the pid wait, and the branch watcher waits on the record, not on this observer (crates/dim-agent-capabilities/src/shell_session.rs:1605-1644, crates/dim-agent-capabilities/src/workspace_tools/background.rs:282-302). I am not reopening the removed deadline. The observer never writes a terminal for an unconfirmed release; the sweep remains the one documented failure terminal for an unconfirmed child, and it is not a release claim.

Remaining P3

The failed-stop path, including the new None rule, still has no test. No test calls kill_job, job_released or observe_job_release; the only job stop test is the successful one (tests/integration/tests/minimal_execution.rs:960-991), the shell-exit test covers a normal exit only (:1270-1317), and the only job terminal test ends on its end marker (crates/dim-agent-capabilities/tests/host_platform_flow.rs:2222-2301). A #[cfg(windows)] test that asserts job_released(pid, None) is false, or a seam that injects a snapshot failure, would pin this commit's rule. Carried from round 51; does not block.

Prior items

  • Round 52 said the other reviewer's change request was unaddressed. It is addressed here; that statement is superseded.
  • Round 51 P3 1, the missing failed{shell_reset}: fixed in 88afcf11; withdrawn.
  • Round 51 P3 2, the failed-stop test: open as above.
  • The earlier optional asks to retry job_tree or to end the observer on a timer (threads 4696422322, 4697518825) stay withdrawn. Removing the retry is the intended fix, so a later enumeration is not a recovery path.
  • Round 50's removal of the 30 s deadline and the cleanup-ownership tradeoff are unchanged and not reopened.

Other review and blocking state

The other reviewer's latest review is 6061770716 at d71528c9, CHANGES_REQUESTED, with the item above. 9448f8c8 is the response; the reviewer has not re-reviewed this head, so GitHub still shows CHANGES_REQUESTED. This review records that the acceptance criterion is met but does not clear that state.

Cross-PR and main

  • git merge-tree --write-tree origin/main HEAD at c8417f1f is clean, and git diff --check is clean.
  • #2200 7f96aa5c and #2197 87f89c06 (current heads) merge cleanly. #2197 is a draft.
  • #2174 f5d21296 and #1881 ff9825d2 conflict, but each also conflicts with origin/main alone on the same paths: generated catalog and services files plus xtask/src/catalog.rs, and docs/design/plugins/Report.md. This PR touches none of those paths, and #2174 is a draft. Neither conflict comes from this PR.

Verification

  • Read the changed hunk (host_platform.rs:3623-3653) and the touched paths: job_released (:3700-3710), kill_job (:3658-3686), the stop call sites (lines 1270 to 1373) and sweep (:4835-4882). Checked 1295-host-platform-task-owner.md:56-65 and :229; no nearby sentence still relies on a later enumeration or a None snapshot resolving on its own.
  • CI at 9448f8c8 (run 45667552747): changes, macos-native and windows-cli pass; verify (linux) was still in progress when read; the path-filtered jobs are skipped.
  • PR is open, not draft, head 9448f8c8.
  • No local build or test run; the Windows snapshot-failure path is not runnable on this host.

Unverified

  • verify (linux) had not finished; the workspace suite at this head is not confirmed.
  • The None-snapshot path and the failed-stop observer are read from source; no test runs them and Windows was not exercised locally.
  • The other reviewer's acceptance is assessed statically; no snapshot failure was injected.

@eric8810

Copy link
Copy Markdown
Collaborator Author

Head 9448f8c8f is approved by yyhhyyyyyy. The 6061770716 acceptance item is implemented: a None pre-termination snapshot never becomes release evidence, and no later enumeration is consulted. ci-ok is green; only zerob13's stale change request remains.

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

The remaining Windows release criterion is met. An unavailable initial observation remains unconfirmed rather than letting a later view publish Cancelled or settle the job. The caller still returns a bounded outcome while the owner retains cleanup; genuine completion and owner teardown remain available. No remaining blockers.

Exact-head CI passed on Windows, macOS, and Linux. The missing-snapshot path was checked statically; the hosted Windows suite did not exercise that failure.

@eric8810

Copy link
Copy Markdown
Collaborator Author

Post-merge follow-up: main CI is red from three xtask scenario tests because the fixture injected a second HostPlatform after this PR made it a provided service. #2205 fixes it; CI is green.

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