Repository navigation
fix(exec): count only declared services and drop the survivor settle window - #200268
Conversation
The service cap is enforced only where a service is declared, and adoption never stops a survivor for capacity, so a helper that is still exiting at root exit costs nothing. The settle window and its repeated census are not needed: adopt what the census names at root exit again. Co-authored-by: obviyus <[email protected]>
Adopted survivors are tracked but no longer counted, so helpers that are still exiting at root exit never block a background: true start. The cap is enforced only for declared services, through reserveServiceSlot. Co-authored-by: obviyus <[email protected]>
Yielded ordinary commands are backgrounded sessions too, but they are not declared services. Count only sessions started with background: true. Co-authored-by: obviyus <[email protected]>
|
🦞👀 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. |
|
Codex review: needs changes before merge. What this changesThis PR counts only explicitly declared background services against service limits and removes the survivor settling window. Example: A session has 20 adopted survivors and no declared services.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains This PR provides a useful, focused repair, but its new filter incorrectly excludes restored durable services from capacity enforcement. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherExec admission reserves service capacity, the process supervisor reports surviving descendants, and the process registry exposes their handles and cleanup operations. flowchart TD
A[Exec request] --> B[Service admission]
B --> C[Process supervisor]
C --> D[Survivor census]
D --> E[Process registry]
F[Durable process restoration] --> E
E --> B
E --> G[Process tools and cleanup]
Technical reviewBest possible solution: Keep the existing admission owner and immediate census while preserving declared-service counting across durable restoration. Do we have a high-confidence way to reproduce the issue? Current-main source confirms that survivors and yielded commands consume service capacity; the supplied Gateway comparison exercises the reported problem, while this review used source inspection without executing target code. Is this the best way to solve the issue? Filtering by the existing declaration marker is appropriately small, but all producers and restorers of counted sessions must preserve that distinction. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 48cd549b1c48. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource -38, Tests +8, Docs 0. Total -30 across 5 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 16, 2026, 5:21 PM ET / 22:21 UTC. |
|
Landed in 744a001.
|
…window (openclaw#200268) ## Problem openclaw#200250 added a 2 s settle window before survivor adoption, so that helpers still exiting at root exit (`git`, `cp`, `tee`) would not take service slots. That is a heuristic on top of the real defect: the service cap counted processes that were never declared as services. Survivors and yielded ordinary commands were counted against the 16-per-session limit, so they could block a `background: true` start. ## Fix The cap now belongs to declared services only. - `serviceCapacityError` counts only sessions with `independentService` (started with `background: true`) plus reservations. It does not count adopted survivors or yielded ordinary commands. - The settle window and its repeated census are deleted. The process owner again reports what runs at root exit, and adoption tracks all of it. openclaw#200250 already removed the overflow kill, so no survivor is stopped for capacity. Production code: +20 / −58. Together with openclaw#200250, compared with the code before it: +18 / −60. ## User impact - A helper that a command leaves behind never blocks a declared service and is never stopped. Its session drops out within one 5 s reap interval after it exits. - Commands that leave processes running return without the 2 s delay that openclaw#200250 added. - Tool results name every survivor again, including short-lived helpers. - At 16 declared services, the 17th `background: true` start is still refused. - Survivors are still tracked, listed, and stopped on session reset and Gateway stop. ## Proof **Real Gateway E2E** (dist build, macOS, scratch state, service-managed exec path, real model `claude-opus-5-5`). Base is the code before openclaw#200250 (`ed37fd25`), from the openclaw#200250 run. | Journey | Base (`ed37fd25`) | Head | |---|---|---| | 20 calls of `for i in $(seq 18); do (git status --short; sleep 0.5) & done; …; cp a.txt b.txt` | "16 of 16" on every call; 431 helpers stopped | 720 adopted, 0 stopped | | `nohup python3 -m http.server &`, then 16 × `nohup sleep &` | 16 adopted, 17th stopped | 17 adopted, 0 stopped | | 17 × `background: true` in a new session | — | 16 start; the 17th is refused with "16 of 16 allowed services" | | busy fork loop `while :; do sleep 0.05; done &` | adopted | adopted | | `/reset` of the servers session | — | `nohup` server and 16 survivors: all stopped (17 → 0) | | Gateway stop | 0 left | 0 left | **Tests** (`bash-tools.exec-group-cleanup.real.test.ts`, vitest-source, real processes, macOS): - New: three calls each leave 17 `sleep 0.5` helpers, then a `background: true` start succeeds at once, then a fork loop is tracked. Fails on `ed37fd25` ("Stopped 1 process … 16 of 16 allowed services") and passes on head. - The cap tests now fill 15 declared services plus a survivor, then show that exactly one of two concurrent starts wins and the next is refused. - Whole file on head: 10 passed, 3 skipped (Linux only). Gates: `tsgo:core`, `check:test-types`, oxlint and oxfmt on changed files, `ocx build --dts` and a packed install smoke (`openclaw --version`). Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
#200250 added a 2 s settle window before survivor adoption, so that helpers still exiting at root exit (
git,cp,tee) would not take service slots. That is a heuristic on top of the real defect: the service cap counted processes that were never declared as services.Survivors and yielded ordinary commands were counted against the 16-per-session limit, so they could block a
background: truestart.Fix
The cap now belongs to declared services only.
serviceCapacityErrorcounts only sessions withindependentService(started withbackground: true) plus reservations. It does not count adopted survivors or yielded ordinary commands.Production code: +20 / −58. Together with #200250, compared with the code before it: +18 / −60.
User impact
background: truestart is still refused.Proof
Real Gateway E2E (dist build, macOS, scratch state, service-managed exec path, real model
claude-opus-5-5). Base is the code before #200250 (aa4d490a), from the #200250 run.aa4d490a)for i in $(seq 18); do (git status --short; sleep 0.5) & done; …; cp a.txt b.txtnohup python3 -m http.server &, then 16 ×nohup sleep &background: truein a new sessionwhile :; do sleep 0.05; done &/resetof the servers sessionnohupserver and 16 survivors: all stopped (17 → 0)Tests (
bash-tools.exec-group-cleanup.real.test.ts, vitest-source, real processes, macOS):sleep 0.5helpers, then abackground: truestart succeeds at once, then a fork loop is tracked. Fails onaa4d490a("Stopped 1 process … 16 of 16 allowed services") and passes on head.Gates:
tsgo:core,check:test-types, oxlint and oxfmt on changed files,ocx build --dtsand a packed install smoke (openclaw --version).