Skip to content

fix: join process shutdown and isolate runtime fixtures - #174359

Merged
steipete merged 1 commit into
mainfrom
steipete/bunfix-bunci3-1016
Oct 16, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/bunfix-bunci3-1016

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Bun test failures caused by Darwin fixtures reaching the host's native process census, stale cleanup expectations, and incomplete lifecycle settlement during cancellation and Gateway shutdown.

User Impact

Brokered child completion now includes IPC disconnection. Gateway shutdown avoids importing model recovery after all catalog owners retire. The test fixture changes preserve the same custody, cancellation, and admitted-work assertions on Node and the pinned Bun fork.

Why This Change Was Made

Test Classification and repair
openclaw-process-census.test.ts Bucket 2: mocked Darwin platform still selected Bun's real libproc census on Linux. Supply the synthetic process inventory to both census implementations, including consistent foreign UID facts.
doctor-plugin-source-captures.test.ts Bucket 2: the same native census escaped its synthetic ps fixture. Mock the native boundary with the same self/peer records.
node-worker-supervisor.lifetime.test.ts Bucket 2: the native owner uses Node's Linux subreaper even when Vitest runs on Bun. Expect cleanup mode from the platform.
heartbeat-runner.model-override.test.ts Bucket 2: an epoch-zero clock stamped a new isolated session as expired while maintenance used real time. Use the current clock, as the adjacent fixtures do.
sqlite-readonly-worker.auth.test.ts Bucket 1: a broker proxy could publish close after process exit but before its IPC disconnect receipt, allowing cancellation to settle with connected === true. Join both receipts in the existing child owner; add deterministic event-order regression tests.
server-close.model-acquisition.test.ts Bucket 1: failed catalog recovery imported the model runtime after async cleanup had retired its owners. Recheck retirement/current borrowers before the lazy import. Existing shutdown and positive recovery suites protect both sides.

No Bun-only skips, timeout increases, dependency changes, or new runtime owners. The simplification pass retained the existing protocol and ownership boundaries. Production delta is +5/-1 (net +4): the IPC completion check and post-cleanup recovery guard have no coherent nearby deletion to offset them. Test delta is +62/-4 (net +58). Main now owns the shared-row synthetic census fixture in the Doctor test; this PR retains its isolation annotation.

Evidence

Refreshed head c8aea392eeaada6d61e1123122e60e586ffe8295 includes main's launcher-bound maintenance fix (#174268) and baseline ratchet repair (#171916). The Doctor conflict preserves main's complete fixture and assertions, including one shared synthetic process inventory for ps and native Darwin census; the duplicate mock was removed. Both doctor-plugin-source-captures.test.ts and openclaw-process-census.test.ts passed 3/3 on Node and 3/3 on pinned Bun. The other three touched test files passed once on each runtime: 18 whole-file executions, 762 test cases, no failures. Commands used TMPDIR=/private/tmp/oc-bunci3, CI=1, OPENCLAW_VITEST_RUNTIME=node|bun, and pnpm test <files> --maxWorkers=1. Bun revision and executable SHA-256 match the repository pin. Conflict-file formatting/lint and git diff --check pass; fresh Codex autoreview found no actionable P0–P2 findings. Exact refreshed-head CI run 38926585552, attempt 1, completed with one inherited failure: check-guards rejects main’s new cli-parent-lifetime.mjs because the duplicate-scan targets omit it; openclaw/ci-gate fails downstream. All other selected jobs passed, including checks-fast-baseline-ratchets. The failure table calls this new relative to scheduled main 9151847f, which predates the file. The failed job checked out merge f93da3ed over main 5aec2058; its root file, scanner, and tracked-path inventory match that main parent exactly. node scripts/check-duplicates.mjs --coverage reproduces the same failure. Landing uses the coordinator-authorized inherited-failure exception; CI remains recorded as failed. The older CI result below remains prior-head evidence.

Linux candidate: all 26 whole-file runs passed (13 files under both runtimes), including the six tests listed above, the broker event-order regression, positive catalog-pool recovery, and the five remaining Gateway siblings. The new IPC tests fail on the original child owner under both runtimes and pass with the repair. Formatting, targeted lint, core typecheck, scoped test typechecks, and pnpm build all passed. Exact-head native CI watch is GREEN for 336cf242b2ff273448ce39e2be4955321eea5307: run 38922899998, zero pending/current failures. GitHub's aggregate still includes 79 superseded cancellations; the repository watcher reconciled them. pnpm test:ci-failed 174359 --json reported no failed jobs or tests, so no replay was needed.

The starting snapshot a60b6a7f77902f5eb1e306138c511a816b03150a was repeated three times per runtime on one direct AWS Crabbox lease (72 whole-file executions). Census, Doctor capture, and native-supervisor fixtures failed 3/3 on Bun and passed 3/3 on Node. All six Gateway files, heartbeat, and user preferences passed 3/3 on both runtimes. The auth-reader cancellation case passed every run; an unrelated observation-count case failed once on Node. All Bun commands use the repository pin 1.4.3-canary.1+c45839085.

Linux used Node v24.19.0 and the pinned Bun revision. Each listed test used these commands; focused macOS census, Doctor, and IPC runs also passed on both runtimes:

export TMPDIR=/tmp/oc-bunci3
export PATH=/tmp/ocbun/bin:$PATH
export OPENCLAW_VITEST_WORKER_CACHE=1
CI=1 OPENCLAW_VITEST_RUNTIME=bun pnpm test <file> --maxWorkers=1
CI=1 OPENCLAW_VITEST_RUNTIME=node pnpm test <file> --maxWorkers=1

For original-code regression proof, both commands additionally used -t 'joins IPC' with the original src/process/spawn-broker/child.ts restored temporarily on the remote lease; both exited 1 with the premature-close assertions. No local source was reverted.

Static/build gates (all exit 0): pnpm exec oxfmt --check <seven changed files>; node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json <seven changed files>; pnpm tsgo:core; node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.<area>.json for infra, other, gateway-other, and services; pnpm build (290 seconds).

Candidate whole-command wall times, Bun/Node in seconds: census 29.72/11.23, Doctor 10.83/12.08, auth 15.44/21.05, lifetime 29.36/35.47, heartbeat 19.75/25.01, event-order 9.58/10.73, shutdown 27.56/34.82, positive recovery 46.65/57.66. These include compiler/worker preparation; the cold census run rebuilt the worker cache.

Codex autoreview of the final diff and surrounding lifecycle modules: scoped-clean through P2. git diff --check passes.

Trial Findings and Limits

The original agent-chat shard never reached its terminal summary. Its final snapshot recorded severe CPU, memory, and I/O pressure; the current dual-all wiring already doubles deadlines. Individual baseline repeats distinguish those late timeout/cleanup failures from the reproducible fixture and lifecycle defects; no speculative trial-wiring change is included.

user-preferences.test.ts passed all 13 cases on both runtimes in the saved trial-2 log. A test name containing on FAIL was not a failed status.

The auth-reader baseline separately exposed a pre-existing Node exact-count flake: disabling fs.watch leaves fallback recovery polling active at the next wall-clock boundary, which may legally publish an unchanged observation. The cancellation case passed. That unrelated assertion is unchanged.

@clawsweeper

clawsweeper Bot commented Oct 16, 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.

@steipete
steipete marked this pull request as ready for review October 16, 2026 15:18
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T15:48:59.582670Z c8aea39 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Oct 16, 2026
@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR joins brokered child exit with IPC disconnection, skips catalog recovery after owner retirement, and corrects runtime-dependent test fixtures.

Example: Brokered child PID 123 exits with SIGKILL before its IPC disconnect receipt arrives.

  • Before: The proxy can publish close while its IPC connection still appears open.
  • After: The proxy publishes close after both exit and IPC disconnection have settled.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch is correct by source review and has passing aggregate CI; behavior evidence is limited to reported tests and production-path harnesses.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence covers Node and pinned-Bun lifecycle harnesses and fixture regressions, rather than a shipped-entry-point demonstration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Cancellation can finish before brokered IPC disconnects, and Gateway teardown can start model recovery after its owners retire.
Reason: The maintainer-authored direction repairs existing lifecycle contracts with narrow changes and preserves runtime coverage.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it makes focused lifecycle repairs and preserves runtime coverage, with no actionable introduced defect found and the exact-head aggregate CI gate passing.

Priority: P2
Reviewed head: 336cf242b2ff273448ce39e2be4955321eea5307

Before merge

None.

Findings

None.

Agent review details

How this fits together

The spawn broker translates native child lifecycle receipts into caller-visible process events; the catalog worker manages discovery and recovery for Gateway model-runtime borrowers.

flowchart TD
  A[Gateway callers] --> B[Spawn broker host]
  B --> C[Native child process]
  C --> D[Broker child lifecycle]
  D --> A
  A --> E[Catalog worker pool]
  E --> F[Current runtime borrowers]
Loading

Technical review

Best possible solution:

Retain these repairs in the existing child and catalog lifecycle owners.

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

Source shows premature close when exit precedes IPC disconnection and unconditional recovery import after cleanup; the body also reports original-code IPC regression failures, but this review executed no target code.

Is this the best way to solve the issue?

The repairs enforce completion and retirement at their existing owners, while fixture changes preserve custody and cancellation assertions across runtimes.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8079cb87aefe.

Provenance checked

  • Broker child completion keeps the original intent (67cedc3: Move spawning into a lightweight broker while preserving streams, IPC, cancellation, and cleanup ownership.)
  • Catalog recovery keeps the original intent (c19dc23: Keep admission and recovery generation-owned and avoid automatic recapture after stalled admission.)
  • Darwin census and Doctor fixtures keeps the original intent (fix: reclaim captures beside unreadable macOS processes #159370: Preserve same-account uncertainty and foreign-owned captures while permitting cleanup beside unreadable foreign-account processes.)
  • Native supervisor fixture keeps the original intent (24ca81d: Retain distinct worker lifecycle regressions during test consolidation.)
  • Heartbeat fixture clock changes intended behavior with a stated reason (e5d4585: Test consolidation retained admitted-work coverage; the current PR explains that epoch-zero timestamps conflict with real-time session maintenance.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit c19dc23 adds src/agents/prepared-model-catalog-worker.ts:218 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c19dc239d20b; files: src/agents/prepared-model-catalog-worker.ts)

PR surface

Source +4, Tests +68. Total +72 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 5 1 +4
Tests 5 80 12 +68
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 85 13 +72

Review metrics

Metric Value Why it matters
Production versus test changes Production +5/-1; tests +80/-12 Small lifecycle changes are supported by distinct event-order regressions and fixture corrections without new production abstractions.

Labels

Label changes:

  • add P2: Focused process completion and shutdown repairs have concrete value without evidence of an urgent widespread runtime failure.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Focused process completion and shutdown repairs have concrete value without evidence of an urgent widespread runtime failure.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 16, 2026, 11:35 AM ET / 15:35 UTC.

@steipete
steipete force-pushed the steipete/bunfix-bunci3-1016 branch from 336cf24 to f222828 Compare October 16, 2026 15:36
Wait for IPC disconnection before completing brokered children, and stop
catalog recovery before importing a runtime whose owners have retired.

Keep Darwin census fixtures synthetic under Bun, expect the native Linux
subreaper independently of the test runtime, and avoid epoch-zero session
expiry in heartbeat model-override tests.
@steipete
steipete force-pushed the steipete/bunfix-bunci3-1016 branch from f222828 to c8aea39 Compare October 16, 2026 15:45
@steipete
steipete enabled auto-merge (squash) October 16, 2026 15:50
@steipete
steipete disabled auto-merge October 16, 2026 16:04
@steipete
steipete merged commit cb196c3 into main Oct 16, 2026
146 of 151 checks passed
@steipete
steipete deleted the steipete/bunfix-bunci3-1016 branch October 16, 2026 16:20
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

vincentkoc added a commit that referenced this pull request Oct 16, 2026
* commit '14e993fff3ecb84eb1d7c9724c4ceda235d797e4': (110 commits)
  fix(decisions): align accounting ratchet evidence
  feat(memory): activate PostgreSQL memory search and lifecycle (#174374)
  fix: join process shutdown and isolate runtime fixtures (#174359)
  refactor(ui): scope native gateway observation to Solid (#174367)
  refactor(ui): own canvas widget lifetime in Solid (#174370)
  perf(control-ui): keep agent avatar faces stable across agent publications (#174239)
  perf(models): release unused account catalog instructions (#174361)
  refactor(ui): own composer command menus in Solid stores (#174321)
  refactor(ui): separate sidebar filter state from view lifecycle (#174352)
  test(release): make artifact qualification deadlines deterministic
  fix(codex): preserve sandboxed process inspection and setup errors (#174284)
  fix(gateway): stop worker processes before draining their queues (#174312)
  refactor(agents): reuse prepared tool facts (#174349)
  test(gateway,plugins,ui): remove low-value tests (batch d174) (#174331)
  refactor(ui): replace MCP retirement host adapters with a factory (#174375)
  refactor(logging): remove redundant native success traces (#174330)
  refactor(test): remove dead control-plane fixture branches (#174377)
  refactor(mcp): remove test-only session runtime seams (#174347)
  feat(matrix): account-root state databases follow the selected engine (#174315)
  refactor(discord): collapse private interaction and factory seams (#174322)
  ...
vincentkoc added a commit that referenced this pull request Oct 16, 2026
* commit '14e993fff3ecb84eb1d7c9724c4ceda235d797e4': (110 commits)
  fix(decisions): align accounting ratchet evidence
  feat(memory): activate PostgreSQL memory search and lifecycle (#174374)
  fix: join process shutdown and isolate runtime fixtures (#174359)
  refactor(ui): scope native gateway observation to Solid (#174367)
  refactor(ui): own canvas widget lifetime in Solid (#174370)
  perf(control-ui): keep agent avatar faces stable across agent publications (#174239)
  perf(models): release unused account catalog instructions (#174361)
  refactor(ui): own composer command menus in Solid stores (#174321)
  refactor(ui): separate sidebar filter state from view lifecycle (#174352)
  test(release): make artifact qualification deadlines deterministic
  fix(codex): preserve sandboxed process inspection and setup errors (#174284)
  fix(gateway): stop worker processes before draining their queues (#174312)
  refactor(agents): reuse prepared tool facts (#174349)
  test(gateway,plugins,ui): remove low-value tests (batch d174) (#174331)
  refactor(ui): replace MCP retirement host adapters with a factory (#174375)
  refactor(logging): remove redundant native success traces (#174330)
  refactor(test): remove dead control-plane fixture branches (#174377)
  refactor(mcp): remove test-only session runtime seams (#174347)
  feat(matrix): account-root state databases follow the selected engine (#174315)
  refactor(discord): collapse private interaction and factory seams (#174322)
  ...
vincentkoc added a commit that referenced this pull request Oct 16, 2026
* commit '0c6c7ee5837ed93f6fb09ca58b280e76878c21f1': (109 commits)
  feat(memory): activate PostgreSQL memory search and lifecycle (#174374)
  fix: join process shutdown and isolate runtime fixtures (#174359)
  refactor(ui): scope native gateway observation to Solid (#174367)
  refactor(ui): own canvas widget lifetime in Solid (#174370)
  perf(control-ui): keep agent avatar faces stable across agent publications (#174239)
  perf(models): release unused account catalog instructions (#174361)
  refactor(ui): own composer command menus in Solid stores (#174321)
  refactor(ui): separate sidebar filter state from view lifecycle (#174352)
  test(release): make artifact qualification deadlines deterministic
  fix(codex): preserve sandboxed process inspection and setup errors (#174284)
  fix(gateway): stop worker processes before draining their queues (#174312)
  refactor(agents): reuse prepared tool facts (#174349)
  test(gateway,plugins,ui): remove low-value tests (batch d174) (#174331)
  refactor(ui): replace MCP retirement host adapters with a factory (#174375)
  refactor(logging): remove redundant native success traces (#174330)
  refactor(test): remove dead control-plane fixture branches (#174377)
  refactor(mcp): remove test-only session runtime seams (#174347)
  feat(matrix): account-root state databases follow the selected engine (#174315)
  refactor(discord): collapse private interaction and factory seams (#174322)
  refactor(feishu): reuse streaming merge in dispatcher tests (#174371)
  ...
vincentkoc added a commit that referenced this pull request Oct 16, 2026
* commit '14e993fff3ecb84eb1d7c9724c4ceda235d797e4': (110 commits)
  fix(decisions): align accounting ratchet evidence
  feat(memory): activate PostgreSQL memory search and lifecycle (#174374)
  fix: join process shutdown and isolate runtime fixtures (#174359)
  refactor(ui): scope native gateway observation to Solid (#174367)
  refactor(ui): own canvas widget lifetime in Solid (#174370)
  perf(control-ui): keep agent avatar faces stable across agent publications (#174239)
  perf(models): release unused account catalog instructions (#174361)
  refactor(ui): own composer command menus in Solid stores (#174321)
  refactor(ui): separate sidebar filter state from view lifecycle (#174352)
  test(release): make artifact qualification deadlines deterministic
  fix(codex): preserve sandboxed process inspection and setup errors (#174284)
  fix(gateway): stop worker processes before draining their queues (#174312)
  refactor(agents): reuse prepared tool facts (#174349)
  test(gateway,plugins,ui): remove low-value tests (batch d174) (#174331)
  refactor(ui): replace MCP retirement host adapters with a factory (#174375)
  refactor(logging): remove redundant native success traces (#174330)
  refactor(test): remove dead control-plane fixture branches (#174377)
  refactor(mcp): remove test-only session runtime seams (#174347)
  feat(matrix): account-root state databases follow the selected engine (#174315)
  refactor(discord): collapse private interaction and factory seams (#174322)
  ...
vincentkoc added a commit that referenced this pull request Oct 16, 2026
* commit '0c6c7ee5837ed93f6fb09ca58b280e76878c21f1': (109 commits)
  feat(memory): activate PostgreSQL memory search and lifecycle (#174374)
  fix: join process shutdown and isolate runtime fixtures (#174359)
  refactor(ui): scope native gateway observation to Solid (#174367)
  refactor(ui): own canvas widget lifetime in Solid (#174370)
  perf(control-ui): keep agent avatar faces stable across agent publications (#174239)
  perf(models): release unused account catalog instructions (#174361)
  refactor(ui): own composer command menus in Solid stores (#174321)
  refactor(ui): separate sidebar filter state from view lifecycle (#174352)
  test(release): make artifact qualification deadlines deterministic
  fix(codex): preserve sandboxed process inspection and setup errors (#174284)
  fix(gateway): stop worker processes before draining their queues (#174312)
  refactor(agents): reuse prepared tool facts (#174349)
  test(gateway,plugins,ui): remove low-value tests (batch d174) (#174331)
  refactor(ui): replace MCP retirement host adapters with a factory (#174375)
  refactor(logging): remove redundant native success traces (#174330)
  refactor(test): remove dead control-plane fixture branches (#174377)
  refactor(mcp): remove test-only session runtime seams (#174347)
  feat(matrix): account-root state databases follow the selected engine (#174315)
  refactor(discord): collapse private interaction and factory seams (#174322)
  refactor(feishu): reuse streaming merge in dispatcher tests (#174371)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
)

Wait for IPC disconnection before completing brokered children, and stop
catalog recovery before importing a runtime whose owners have retired.

Keep Darwin census fixtures synthetic under Bun, expect the native Linux
subreaper independently of the test runtime, and avoid epoch-zero session
expiry in heartbeat model-override tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawsweeper:intake:bug Preliminary submission classification; full source review pending. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant