Repository navigation
fix(tui): stop local shell descendants on exit - #127652
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 21, 2026, 8:00 PM ET / August 22, 2026, 00:00 UTC. ClawSweeper reviewWhat this changesThis PR moves TUI local shell commands into supervised scopes so shutdown cancels and joins owned descendants, with a Windows Job Object implementation for process ownership. Merge readiness⛔ Blocked until stronger real behavior proof is added - 8 items remain Keep open: the prior P2 remains on the latest head, because a descendant holding inherited stdout or stderr still prevents the local command result from returning. The Windows native authority path also needs independently checkable dependency-contract evidence before merge. Priority: P2 Review scores
Verification
How this fits togetherThe local TUI sends approved flowchart LR
A[Approved TUI shell command] --> B[Process supervisor scope]
B --> C[Platform process owner]
C --> D[Root command result]
C --> E[Output drain]
B --> F[Scope cancellation]
F --> G[Descendant extinction]
G --> H[Terminal teardown]
Before merge
Findings
Agent review detailsSecurityNeeds attention: The native Windows Job authority path and direct Koffi update require contract evidence before this security-sensitive process-kill boundary can be cleared. PR surfaceSource +1302, Tests +257, Config +1, Other +5. Total +1565 across 26 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Make root-result settlement independent of shared output-pipe EOF while retaining output draining and Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: run a local Is this the best way to solve the issue? No: the scope owner is the right layer, but the patch still conflates root-result delivery with output drain. The result must settle independently while scope extinction remains the teardown boundary. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b765944a9f60. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
Acceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
Dependency GuardThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
Dependency graph changes notedThis PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin, a member of
Security review is still recommended before merge when the dependency graph change is intentional. |
Keep local shell root results independent from authoritative process-scope extinction, and make TUI shutdown cancel and join its ProcessSupervisor scope. On Windows, create commands atomically inside a retained non-breakaway Job Object and prove extinction from exact Job accounting. Fixes #127488
595c781 to
b34b7eb
Compare
|
Land-ready verification is complete for
ClawSweeper dispositions:
Known proof gap: Windows ARM64 was not exercised live. The implementation is restricted to x64/arm64, validates the shared 64-bit layouts, and Koffi ships both Windows prebuilds. |
|
Merged via squash.
|
* fix(tui): own local shell process scopes Keep local shell root results independent from authoritative process-scope extinction, and make TUI shutdown cancel and join its ProcessSupervisor scope. On Windows, create commands atomically inside a retained non-breakaway Job Object and prove extinction from exact Job accounting. Fixes openclaw#127488 * fix(process): preserve optional extinction waits
Closes #127488
What Problem This Solves
Fixes an issue where users running local TUI
!commands could see the root command finish and then exit the TUI while redirected descendant processes remained alive.Existing process-tree cleanup loses authority after the shell leader exits: POSIX callers cannot safely treat a dead process-group leader as authority, and Windows
taskkill /Trequires a live root and risks PID reuse if the dead PID is retained.Why This Change Was Made
The canonical
ProcessSupervisornow records root-result settlement separately from authoritative process-scope extinction. TUI local-shell commands run under a unique supervisor scope; shutdown cancels and joins that scope before terminal teardown.POSIX keeps the existing live in-group anchor. Windows creates the root atomically inside a retained non-breakaway Job Object through
PROC_THREAD_ATTRIBUTE_JOB_LIST, preserves separate stdout/stderr, and proves extinction from exact Job accounting. The implementation does not use dead-roottaskkill, PID polling, process-tree enumeration, or a fallback path.The Windows FFI contract was checked directly against Koffi 3.1.5 source/types and Microsoft/Codex Job Object implementations. The Job and inherited-handle backing arrays remain live through
CreateProcessWand attribute-list deletion; a successful root is born inside the Job. Koffi is an intentional exact root dependency because core imports it; the lockfile adds/removes no packages and updates the already-present Koffi family from 3.1.2 to 3.1.5.This is AI-assisted. I reviewed the final ownership model, source contracts, tests, and platform proof.
User Impact
Local TUI shell commands can still report their root result promptly, but
/exitnow guarantees that all processes owned by that TUI shell scope are gone before shutdown completes.This deliberately treats descendants launched by an approved local
!command as session-owned resources. Operators who need a long-lived service should launch it outside the TUI session rather than relying on it to survive/exit.Evidence
node scripts/check-changed.mjs.pnpm build./exitresolves.