Skip to content

fix(process): join relay reaping before extinction probe - #140134

Merged
steipete merged 1 commit into
mainfrom
codex/fix-posix-anchor-reaping-01a0750a
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-posix-anchor-reaping-01a0750a

Conversation

@steipete

@steipete steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes a race where a service-managed command can report uncertain cleanup after its control channel closes but before the relay reaps the anchor process. On Darwin, querying an unreaped zombie process group can return EPERM even though its leader has exited.

Why This Change Was Made

Join the existing relay child-exit lifecycle before the first POSIX group-disappearance probe. Joining consumes the same deadline captured when control closes. The existing kernel check still requires ESRCH to confirm extinction; EPERM and other errors remain failures after the join. No new receipt, signal, timeout increase or retry of EPERM is introduced.

User Impact

Normal command cleanup waits for its owner to reap the anchor before observing group disappearance. Root-result/output delivery stays independent, and cancellation, missing-receipt failure, source authority and Windows Job cleanup retain their current behavior. The join remains bounded when the relay stalls.

Evidence

Found while diagnosing the macOS argv0 service-lifecycle failure in run 34032828960 for #139995. That native change does not modify process sources. The failure's PID state was not captured; an isolated owned-child Darwin probe separately demonstrates live-group success, zombie-group EPERM, then ESRCH after parent reaping. A deterministic regression using the actual host implementation reproduces premature failure when control EOF precedes relay exit, and fails before this repair.

All 32 host cases pass, including the original ordering, unchanged deadline, stalled relay, EPERM/EIO, missing receipt and Windows branches. Real service-child lifecycle tests pass 26 cases on macOS and 26 on Linux, including argv0. A normal Linux build and root lifecycle E2E pass at source tree 1e605bc1f37f630ca9c6970655028ded4c3c9b69: Testbox run 34035221374. The owned lease is stopped and verified completed.

All 29 selected checks and fresh complete-candidate P2 review pass. The existing timeout helper clears its timer; its import adds no new runtime module to the prior source closure. This correctness repair adds 23 production and 75 test code lines. No schema, configuration, dependency or protocol change.

@steipete steipete self-assigned this Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 6, 2026
@steipete
steipete marked this pull request as ready for review September 6, 2026 13:25
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 9:31 AM ET / 13:31 UTC.

ClawSweeper review

What this changes

The process supervisor waits for the relay to exit before checking whether a command’s POSIX process group has disappeared, with regression coverage for ordering and timeout behavior.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused repair: pinned main still has the premature extinction probe, and no blocking introduced defect was found. Maintainer-authored work also remains protected from automatic closure.

Priority: P2
Reviewed head: 3b223440e0b72c7d8099149268022d86b86e6171

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful ordering and deadline coverage and no blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-author exemption applies, and this ordering repair does not materially transfer authority. The captured body reports real macOS/Linux lifecycle runs through the child adapter and a separate Darwin kernel probe; linked logs were unavailable for independent inspection.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-author exemption applies, and this ordering repair does not materially transfer authority. The captured body reports real macOS/Linux lifecycle runs through the child adapter and a separate Darwin kernel probe; linked logs were unavailable for independent inspection.
Evidence reviewed 8 items Introduced change and merge scope: The complete host-provided merge-base delta contains only the relay host and its tests. The locally inspected test-merge record has the pinned base followed by the exact PR head as parents; its production diff contains the same bounded join.
Main still contains the reported ordering: Pinned main starts the process-group probe directly after validating the closing receipt, without joining relay exit. EPERM remains an immediate cleanup-observation failure.
Relay lifecycle supports the join: The anchor sends its closing receipt and ends control before exiting; the relay exits from its anchor exit callback. Waiting for relay exit therefore orders the probe after normal anchor reaping without requiring a host acknowledgement.
Findings None None.
Security None None.

How this fits together

OpenClaw’s process supervisor runs managed commands through a relay and process-group anchor. It reports command output separately from cleanup completion, which requires evidence that the owned process group has disappeared.

flowchart TD
  A[Managed command] --> B[Relay and process anchor]
  B --> C[Command result and output]
  B --> D[Closing receipt and control closure]
  D --> E[Wait for relay exit within deadline]
  E --> F[Kernel process group probe]
  F --> G[Confirmed cleanup or explicit uncertainty]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +25, Tests +82. Total +107 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 25 0 +25
Tests 1 85 3 +82
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 110 3 +107

Review metrics

Metric Value Why it matters
Cleanup deadline Unchanged: 5 seconds shared by relay join and group observation The repair changes ordering without extending the cleanup window.

Technical review

Best possible solution:

Keep cleanup observation ordered after relay reaping while preserving the shared deadline, independent output delivery, and strict kernel disappearance check.

Do we have a high-confidence way to reproduce the issue?

Yes, at the source boundary: control closure before relay exit combined with a transient EPERM makes pinned main reject cleanup prematurely. The added deterministic test models this ordering; no runtime reproduction was executed during this review.

Is this the best way to solve the issue?

Yes. Joining the existing child-exit lifecycle repairs the ordering at its owner while retaining the same timeout and ESRCH-only success condition.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 21dc7d5d7b6c.

Labels

Label changes:

  • add P2: This fixes a bounded process-cleanup race without evidence of a widespread current outage.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-author exemption applies, and this ordering repair does not materially transfer authority. The captured body reports real macOS/Linux lifecycle runs through the child adapter and a separate Darwin kernel probe; linked logs were unavailable for independent inspection.

Label justifications:

  • P2: This fixes a bounded process-cleanup race without evidence of a widespread current outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-author exemption applies, and this ordering repair does not materially transfer authority. The captured body reports real macOS/Linux lifecycle runs through the child adapter and a separate Darwin kernel probe; linked logs were unavailable for independent inspection.

Evidence

What I checked:

  • Introduced change and merge scope: The complete host-provided merge-base delta contains only the relay host and its tests. The locally inspected test-merge record has the pinned base followed by the exact PR head as parents; its production diff contains the same bounded join. (src/process/supervisor/service-child-relay-host.ts:347, 0f168c29b5f1)
  • Main still contains the reported ordering: Pinned main starts the process-group probe directly after validating the closing receipt, without joining relay exit. EPERM remains an immediate cleanup-observation failure. (src/process/supervisor/service-child-relay-host.ts:335, 21dc7d5d7b6c)
  • Relay lifecycle supports the join: The anchor sends its closing receipt and ends control before exiting; the relay exits from its anchor exit callback. Waiting for relay exit therefore orders the probe after normal anchor reaping without requiring a host acknowledgement. (src/process/supervisor/service-child-relay.ts:125, 3b223440e0b7)
  • Regression coverage: Three added cases independently control control-channel closure and relay exit, verify that no early probe occurs, preserve the original deadline, and reject a stalled relay. Existing cases retain EPERM/EIO failure, missing-receipt rejection, root-result independence, and Windows behavior. Tests were inspected, not executed. (src/process/supervisor/service-child-relay-host.test.ts:472, 3b223440e0b7)
  • Captured validation claims: The supplied complete PR body reports 32 host cases and 26 real service-child lifecycle cases on each of macOS and Linux, plus Linux build/lifecycle evidence at source tree 1e605bc1f37f630ca9c6970655028ded4c3c9b69. It explicitly separates an isolated Darwin zombie-group probe from the original CI failure, whose PID state was not captured. The linked run https://github.com/openclaw/openclaw/actions/runs/34035221374 could not be retrieved by this reviewer; these results remain author-reported.
  • Existing timeout dependency: The new import uses the existing facade re-export of @openclaw/fs-safe/advanced; package.json pins 0.8.1, and existing production callers use the same promise, duration, and message-options shape. Dependency implementation files were unavailable locally, so timer cleanup was not independently verified. No Codex dependency signal applies to this change. (src/infra/fs-safe.ts:61, 3b223440e0b7)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit b8ef27d into main Sep 6, 2026
247 checks passed
@steipete
steipete deleted the codex/fix-posix-anchor-reaping-01a0750a branch September 6, 2026 13:44
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant