Repository navigation
fix(runtime): simplify shell execution and bound process cleanup - #1051
Conversation
XuPeng-SH
left a comment
There was a problem hiding this comment.
Recommendation: REQUEST_CHANGES — one P1 issue is detailed inline.
Submitted as COMMENT because the independently verified authenticated identity, XuPeng-SH / 39627130, is also the PR author.
Reviewed all 29 changed files against base a82eb6e47e35bb014737721a191560b8dfcc1846 at head 150fb6a785a1b89df053153afaf121a9b61eade2, including actual CLI/Server entrypoints, process ownership/drop/cancellation, callback and durable Edge identity, journal projection, completion/recovery, schema/context callers, and the owning design contracts. The external scan/lease/receipt/ledger/recovery retirement is coherent; workspace coordination, explicit verification, source preservation and native Memoria user/session context retain their owners. No database query/schema or new shared I/O path is introduced. The remaining defect is the missing uncertainty boundary for started timeouts.
Local verification:
- All nine PR-added boundary tests passed: public CLI 4/4, callback/loop evidence 4/4, configured Server optional-observation 1/1.
- A real CLI timeout probe committed an external temporary marker before termination and returned executed/started/possible-side-effect facts with no typed failure kind.
- An isolated callback → journal → full-loop regression fails as expected: executed, failed
tool_timeoutbecomesCompletedwithinterruption=None, despite no reconciliation. Existing cancellation/unknown cases pass. - Broader tools suite: 979 passed, 4 failed, 16 ignored outside filesystem metadata remapping. One failure passes with standard umask 022; three descendant-warning assertions remain local verification limitations in unchanged shell/process sources. I have not claimed a clean-base reproduction for those three.
- Exact base/head
git diff --checkpassed.
Source footprint, excluding unchanged block realignment using histogram diff and separating inline tests: implementation +128/-1798; tests +396/-3114; docs +23/-12.
Immediately before submission I rechecked open state, exact head/base, author numeric ID, authenticated identity, paginated reviews/comments/requests, all check-run/status/workflow pages, current protected-branch check/app bindings, and both active rulesets. No other review activity appeared. Required gate: 13 successes plus the two source-proven SDK/Web scope exclusions; all 15 contexts bind to GitHub Actions app 15368, and all five workflows are terminal success. Full admin protection reads are integration-restricted; the current branch endpoint exposes the complete required-check bindings used here.
No live DB/provider, paid API, or sanitizer verification was performed.
| && !record.ok | ||
| && matches!( | ||
| record.error_kind, | ||
| Some(astra_core::ErrorKind::Cancelled | astra_core::ErrorKind::ToolOutcomeUnknown) |
There was a problem hiding this comment.
[P1] Preserve uncertainty when a started shell hits its deadline
This guard covers cancellation and unknown results but misses executor-enforced timeouts, which also kill a process after it may have committed effects. Server emits tool_timeout (server_bash_execution.rs:572–573); CLI's started-error path adds execution facts without a typed failure kind (shell.rs:4881–4895). Neither matches this predicate. With external completion/replay fencing removed, an external-only operation can therefore finish without an incomplete disposition after a timeout.
I reproduced both boundaries: a real CLI command wrote an external temporary marker before timing out, and a callback → journal → full-loop test with an executed, failed tool_timeout record then accepted the final response as Completed, interruption=None. The equivalent cancellation/unknown cases remain incomplete. Preserve a typed post-start timeout/unknown-outcome fact at the producer and require reconciliation without a generic replay. Add this timeout regression alongside the new cancellation tests; keep proven pre-start refusals separate.
… into fix/execution-evidence-boundaries
XuPeng-SH
left a comment
There was a problem hiding this comment.
Recommendation: APPROVE. No material findings remain on 8d08ea9995bc0ae76009f53e04af3e2b8328fea7.
Submitted as COMMENT because the freshly verified authenticated identity XuPeng-SH / 39627130 is also the PR author. This recommendation supersedes my earlier REQUEST_CHANGES recommendation on 150fb6a785a1b89df053153afaf121a9b61eade2. That review's original line 2924 thread is historical, outdated and still unresolved in GitHub; its timeout-settlement defect is fixed in the current source.
Reviewed the full 36-file change against base a82eb6e47e35bb014737721a191560b8dfcc1846. I verified 23 files remain byte-identical to the prior reviewed revision and reviewed all 13 changed/added files and their actual entrypoints/callers, including the substantive #1050 workdir and #1057 cleanup expansion.
- Behavior/ownership: CLI started errors carry typed timeout/uncertainty facts; shared completion retains started side-effecting timeouts as incomplete. Pre-start and proven read-only cases remain distinct; callback/journal tests retain causal call counts without a recovery write.
- Process lifecycle: cleanup polls actual exit status against a fixed deadline. Supervisor cancellation precedes forced helper termination; forced-helper/owner-loss paths retain no receipt authority. Startup transfers the whole abort guard, supervised provenance survives owner handoff, and error output draining is bounded. Framed callers reuse the same cleanup owner.
- Isolation/cost: pinned cwd installation is shared across foreground, detached/adopted and explicit environment-background commands/readiness. Workspace policy remains the authority; cwd is per invocation. Read provenance, inferred source capture, authorized external/symlink reads and declared source-root behavior retain tested contracts. External scans/leases/receipt/retry machinery is retired without a replacement ledger. No database query/schema or new shared I/O path is introduced; native memory user/session context remains unchanged.
- Complexity/recovery: shared execution facts, prepared-directory handling and the existing process owner remain canonical. I found no duplicate active observer/completion path or new cancellation state machine.
Independent current-head local verification: 67 relevant tests passed: process-isolation/framed 43; loop evidence 5; public CLI 5; workdir 10; background readiness/cwd 1; Ctrl-B adoption/cwd 1; actual public Server timeout producer 1; unavailable optional Server observation 1. Exact base/head diff check passed. A separate real Server-to-loop diagnostic observed partial effects, typed ExecutionIncomplete and explicit no-automatic-retry guidance, so the suspected Server retry defect was not substantiated. Its wording-only scratch assertion was overstrict and is not counted as a pass.
Local limits: 13 Linux sandbox receipt-dependent checks and one CLI receipt assertion failed. A separate native read proved this environment lacks its own /proc/<pid>/task/<pid>/children file (ENOENT), which the existing subreaper uses; these results are not claimed as PR regressions or local authority passes. The current successful core CI job explicitly runs astra-sandbox, preserving the Linux platform obligation. I did not reproduce the claimed Darwin/ThreadSanitizer totals or run live DB/provider/paid API checks. Scratch source changes were removed and the detached checkout is clean.
Move/indent-normalized source footprint (histogram diff; inline tests separated): implementation +479/-1953, net -1474; tests +1044/-3123, net -2079; docs +55/-12, net +43. Total net -3510 lines; Git's raw diff is +5218/-8728.
Immediately before submission I rechecked exact open/non-draft head/base, identity and author numeric ID, all review bodies/SHAs and original thread anchors, review requests, paginated checks/statuses/workflows, current protected-branch check/app bindings and both active rulesets. No competing review activity appeared. Required review-admission gate: 13 SUCCESS plus two source-proven SDK/Web exclusions; all 15 bindings match app 15368. Check pages are 40/0; workflow pages 6/0. The newer same-head PR-title run 39072492452/check 117512804018 SUCCESS supersedes run 39072491345/check 117512799091 CANCELLED, with matching workflow ID/path and source PR concurrency. The five selected current workflows are successful. This establishes review admission; cancellation actor and strict merge eligibility were not established.
Summary
Remove the mandatory external-state evidence protocol that could reject authorized cleanup before startup or demand another mutation after the desired state already existed. Large directory scans and unavailable/deleted observation roots must not own ordinary shell admission or completion.
Honor CLI Bash
workdirthrough the canonical pinned directory handle in foreground, detached/adopted and environment-background execution/readiness. Relative path checks, inferred source backup and read provenance use the same cwd while retaining the configured workspace authority and authorized external operands. Declared source artifacts keep their root-relative contract.Preserve typed execution uncertainty across cancellation, worker failure and started timeouts. Bound isolated-process cleanup: a demonstrated timeout reached its deadline, then remained pending in Tokio kill/wait. The existing owner now polls actual exit status with a fixed cleanup deadline, retains owner custody and uses its existing bounded output drain. Supervised cleanup asks the helper to settle descendants before a possible forced kill; forced-helper termination never authorizes a receipt.
Related issue
Closes #1048.
Closes #1050.
Closes #1057.
Change type
User and compatibility impact
The Bash external_state_paths argument, external delta receipts/journal projection and external completion recovery state/action are removed end to end. No aliases, migration adapters, feature flags or parallel compatibility path. Strict checkpoints containing removed fields/actions no longer decode as current authority.
Permission, sandbox, selected CLI/User Runner, workspace lease/epoch/quarantine, source backup, process ownership, native memory and canonical Work boundaries retain their owners. Server gains no implicit host filesystem access. Started interrupted/unknown/timeout mutations cannot become completed from unrelated successes or be automatically replayed. Canonical finalization preserves provider partial text separately from typed lifecycle status.
Architecture and complexity delta
Verification
Final source: commit8d08ea9995bc0ae76009f53e04af3e2b8328fea7,36-file manifest fingerprint41426fe67fcdc116af6e482c3b495508544f8927d21f6153b563c167f6f309c3; merge base main a82eb6e. Concurrent remote timeout work was merged without force or discarded changes.
cargo clippy --locked --all-targets -p astra-sandbox -p astra-tools -p astra-cli -p astra-runtime -- -D warnings;make format-check, explicit rustfmt check of the included shell-workdir fixture andgit diff --check. All passed on final source; Clippy completed in2m28s.Public entrypoints/unhappy paths: real CLI ToolExecutor temporary Git worktree plus64MiB ignored artifact and separate absence probe; actual Ctrl-B process adoption, real background readiness and cwd retarget; source restore in an effective worktree; authorized external/symlink read→edit; actual Server producer; callback→journal→typed incomplete terminal. Coverage retains pre-start rejection/cancellation, executed partial failures, started cancellation/timeout, unknown worker outcome, mixed workspace ownership and untrusted/failed settlement.
The cleanup old-fails/new-passes evidence is executed: an independent stage-print-only build reached operation deadline and entered kill-await, then exceeded strict30s; the final canonical timeout and real Server tests pass with the original budgets. A minimal Tokio sanitizer probe passes, so no upstream signal or blanket sanitizer root cause is claimed. The corrected contract is bounded owner cleanup independent of that wake.
Database/live provider verification: not applicable to these changes; no schema/query/new HTTP route. Native Memoria identity/result semantics are unchanged. No live credentials, deployment or service restart.
Platform/CI limits: Linux supervisor/subreaper/cgroup/framed authority tests, including the new real START-barrier guard-handoff control, are preserved and source reviewed but cannot execute on native Darwin; Linux CI remains required before merge. GitHub CI is not claimed passed. Additional repository metadata validation has an existing Darwin relocated-/bin/sleep signing fixture failure, reproduced in clean main; lifecycle/security scripts are unchanged.
Final checklist