Repository navigation
Conversation
ProcessSession.scopeKey is a required string and registerProcessSession is the only exported way to track a process (it replaces createProcessSession plus addSession). The four spawn paths (exec runtime, survivor adoption, durable restore, lost ordinary report) register through it, and resolveProcessToolScopeKey always returns a scope. A session-less exec tool's processes belong to the session's agent, resolved once in resolveExecToolScopeKey. Tests build and track fixtures through the registry test API. Co-authored-by: obviyus <[email protected]>
The shared per-file teardown checks both registries through their test APIs: a live, non-durable process with no stop requested that belongs to a hidden subagent whose rows have all ended fails the file and is killed. Co-authored-by: obviyus <[email protected]>
Survivors carry the process group they ran in at hand-off. Chat end and Gateway stop signal that group (SIGTERM, grace, SIGKILL) while the survivor still runs in it and it is not the Gateway's own group, so children a survivor forked after adoption stop with it. A single process kill still stops only that process. Co-authored-by: obviyus <[email protected]>
Agent exec owns its process tree on every POSIX host, so a command's survivors are handed off to the service-child relay and adopted by the chat on an unmanaged macOS Gateway too. Before, only Linux (for its memory budget, #193044) and marked services did; elsewhere survivors were neither tracked nor stopped. The shared memory budget stays Linux-only. Co-authored-by: obviyus <[email protected]>
An isolated cron run session (:run:) takes no turn after its run, so its services and leftover processes had no manager until the session reaper ran. The run-context disposal now stops them through stopSessionExecProcesses, unless the run yielded on a command whose exit continues it. The disposal moves to session-cleanup.ts beside the other run-session cleanup. Co-authored-by: obviyus <[email protected]>
…eps it Co-authored-by: obviyus <[email protected]>
A yield on the run's commands resumes inside executeCronRun, so by the time the run context is disposed the run has ended; an awaited command still alive then belongs to a wait the executor gave up. Co-authored-by: obviyus <[email protected]>
…e group Co-authored-by: obviyus <[email protected]>
…esses and survivors' later children OpenClaw-Publication: 2e40d2b9-63b0-857b-ae29-59e8afd582c5
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Collaborator
Author
Detailed evidence
|
…bers When the survivor exits on SIGTERM before its group, the members it left keep the rest of the shared grace before the group is forced. Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 1dc87eeb-cb87-8589-8da8-6eea3950a2e5
Only ESRCH proves a survivor's process group empty; EPERM means a member this Gateway cannot signal still runs. After the grace and SIGKILL, the stop confirms the group's extinction and otherwise reports uncertain, so the adopted record and the chat-end failure stay visible. Observed proof for this PR (isolated Gateways from dist, env -i, scratch state; base origin/main 9d6f4a9): - Isolated cron run, real model openai/gpt-6.2-sol: base left the run's background HTTP server and nohup process alive after the run ended ok; this branch leaves nothing. - Scripted-model fault matrix through the Gateway: isolated cron run end base R2/R3/R4/R5/R6 alive -> branch only the documented setsid R6; subagent kill, parent delete and archive: a survivor's later child stayed alive on base and is stopped here; macOS without the service marker: base left survivors untracked, branch stops them. - Real-process tests: lifecycle contract table, cron run session, group-grace and group-denied cases, red on base or the previous head. Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 8ceac546-c2a9-87f3-9632-bad0a9f3671a
A survivor that ignores SIGTERM reaches the SIGKILL branch; its group's extinction is now confirmed there as after the grace, so a member the Gateway cannot signal leaves the stop uncertain. Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 937f6c50-e514-8c30-9623-9b1c8ad0a1e7
An unconfirmed group stop keeps the group on the adopted record: the reaper settles it only once the group is empty, and a later stop retries the group instead of reporting success because the original pid exited. Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: f34eba88-7033-8a43-99a1-33bc7a823604
Contributor
|
Codex review: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 4f755169-4c8c-8679-bba1-dbedd79bf142
This was referenced Nov 27, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #201157, #199079
What Problem This Solves
#201157 made a hidden subagent's task end and archive stop the chat's processes. Four gaps of the same class remained, all reproduced on isolated Gateways:
agent:<id>:cron:<job>:run:<id>) takes no turn after its run, but itsbackground: trueservices,yieldMshand-offs andnohup … &survivors kept running until the session reaper ran. The run session is hidden, so nothing showed them. Reproduced withopenai/gpt-6.2-sol: after a successful cron run, its HTTP server andnohupprocess were still alive.ProcessSession.scopeKeywas optional, so a process could be tracked without an owning chat (adoptSurvivorpassedscopeKey ?? "",stopSessionExecProcessesfiltered!== undefined,resolveProcessToolScopeKeycould returnundefined), and records were built and registered separately.Why This Change Was Made
The chat stays the one owner of its processes, and
stopSessionExecProcessesstays the one stop.ProcessSession.scopeKeyis a requiredstring.registerProcessSession(params)is the only exported way to track a process; it replacescreateProcessSessionplusaddSessionat the four spawn paths (exec runtime, survivor adoption, durable restore, lost-ordinary report).resolveProcessToolScopeKeyalways returns a scope; an exec tool without a session resolves its agent once through the session-agent owner (resolveExecToolScopeKey, used by tool assembly andcreateExecTool).runExecProcessandprocessGatewayAllowlistrequire the scope, so a spawn call without one does not compile.process killon one survivor still stops only that process, so it cannot take siblings with it.run.tstosession-cleanup.ts) stops the:run:session's processes. A yield on the run's commands resumes insideexecuteCronRun, so it has settled by then. Persistent cron targets are not:run:sessions and are unchanged.canStop: false(audit note) is not a defect:openclaw gateway callconnects with least-privilege scopes (operator.readforsessions.processes.list), andcanStopcorrectly says that client may not stop. A write-scoped client (the Control UI) getstrue, assession-processes.test.tsasserts. No UI change.User Impact
durable: true.cmd &andnohupsurvivors are tracked, listed byprocess list, and stopped at chat end, as they already were on Linux and under launchd.agent --localhand-off are unchanged.Evidence
Tests with real child processes, red on
origin/main9d6f4a94adf5, green here:subagent-task-end-processes.lifecycle.test.ts: the survivor now forks a child after adoption. Base: all 5 stop rows fail with that child alive; branch: all pass. New row "complete without a service marker": base leaves the survivor and its child alive; the branch stops both.run.session-processes.test.ts(entersrunCronIsolatedAgentTurn): base leaves the run session's service alive; the branch stops it.subagent-process-census.test.ts: the census reports an ended subagent's live process and ignores a running subagent's or one already being stopped. The census ran over the subagent and exec suites with no leak found.tsgocore, core tests and extensions pass. RemovingscopeKeyfrom aregisterProcessSessionorrunExecProcesscall fails to compile (Property 'scopeKey' is missing).run.*suites (39 files): green. Three failures in that run were checked on base: two are load-timing flakes that also fail on base, and one matches the worktree path (it contains "process").pnpm pack, global install,--version,cron add --help).Fault matrix on isolated Gateways (
env -i, scratch state, service marker unless noted, scripted model). R2yieldMshand-off, R3background: true, R4nohup &, R5 child a survivor forks after adoption, R6setsiddouble fork. Alive after the cell:Real model (
openai/gpt-6.2-sol, isolated Gateway): an isolated cron job ran abackground: trueHTTP server, anohupprocess and a foreground command; the run endedok. Base: server and survivor alive afterwards. Branch: nothing left.psexcerpts are in the comment below.The live Gateway was untouched (launchd pid unchanged, config equal to its backup), and every process the proof started is gone.
Merge danger and blast radius
scopeKeyfalls back to the row'ssessionKey).durable: truekeeps them.session-cleanup.ts, −34 inrun.ts) and the scope resolver. Tests and fixtures: about +380/−140, mostly mechanical fixture moves.