Skip to content

fix(test): stop isolated state runs leaking lifecycle locks - #137014

Closed
Grynn wants to merge 40 commits into
openclaw:mainfrom
Grynn:fix/lifecycle-coordinator-lock-cleanup
Closed

Grynn wants to merge 40 commits into
openclaw:mainfrom
Grynn:fix/lifecycle-coordinator-lock-cleanup

Conversation

@Grynn

@Grynn Grynn commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #136552

What Problem This Solves

Fixes isolated state tests leaving SQLite lifecycle locks in the shared temporary directory after repeated runs.

User Impact

Developers and CI get task-owned cleanup without unlinking active coordination locks. Real-home and external databases keep the stable production lock root. The follow-up fixes also retire shared-state handles when CLI commands fail and when Gateway shutdown records its final outcome.

Why This Change Was Made

Owned test launchers propagate a validated temporary resource context through repository-owned workers and child processes. Cleanup closes admission and verifies descendants and claims before removing the namespace. Indeterminate cleanup retains its evidence.

Deliberately terminated native workers use a distinct, exact-owner exit receipt; it is not a successful JavaScript close receipt and cannot settle unrelated claims. CLI error handling now unwinds through cleanup, and a final Gateway boot-outcome write closes only the handle it opened.

Preserves Grynn's contribution and commit ancestry. Managed-update handoff databases still require explicit task-private injection in every executor; this namespace does not replace it.

Compatibility

This repair adds no user-facing configuration or application database schema. Only databases inside validated test-owned roots use the owned coordination namespace; production and external databases retain stable coordination. Ownership/exit receipts are disposable test metadata, not stored application data or a migration. The Docker helper retains the same metadata format and validation while consuming stdin asynchronously. Existing Doctor success, refusal and rollback contracts remain covered; the managed-case timing failures below are still unresolved.

Latest fixture cleanup correction

Published signed head: 9d9481f947631925cf20c02ac4fb81870da0e053.

The follow-up changes only four test/support files. The placement read-view fixture now supplies its required policy configuration. Restored-session delivery waits for actual announcement entry, then drains the existing root work; the wait uses Vitest's abort signal so a missing announcement still reaches cleanup. The intentional schema-reader cancellation fixture observes and joins its actual child processes before releasing private state. Production behavior, assertions, deadlines, general claims, and descendant-process exclusions are unchanged.

Verification retained for this correction:

  • Complete affected files: 186 registry + 3 placement cases passed (163.35 s, 958 private SQLite opens, no retained claims); 10 schema cases passed (130.86 s, 1,349 private opens), observing 76 actual child exits including the intentional SIGKILL cancellation.
  • Original-order security replay: 2,562 passed, 7 existing platform skips (356.83 s, 10,266 private opens), no retained claims, and observed native process exit 0. An earlier replay terminated prematurely with six parent-thread claims; the later pass does not establish that termination's cause.
  • Final abort-aware delta: normal delivery passed under its ordinary deadline (40.13 s, 30 private opens, no retained claims). A deliberate missing-announcement probe timed out both before and after the fix: only the repaired path ran the explicit cleanup marker, with no retained claims. This is failure-cleanup proof, not a passing test. The temporary fault and shortened diagnostic timeout were removed.
  • All 26 affected core type graphs and selected guards/dead-export scans passed before the final refinements. Final formatting, typed lint, affected type graph, and both line-limit guards passed (44.27 s). Fresh independent API-direct review found no actionable P0–P2 findings on the exact four-file patch.

Compatibility review: the hosted review's generic config/data-model checklist is not a new migration requirement. Its own inspected compatibility boundary confirms that external databases keep their stable production coordination root, while the changed receipts are disposable launcher-owned test metadata. There is no operator setting, application schema, retention policy, or upgrade-format change in this follow-up. Existing production-boundary and external-path contention proof is retained.

The preceding published head's CI run 35883476151 completed with failures (146 successful jobs, 11 failed, 15 skipped). Doctor exit timeouts/descendant claims, CLI and Gateway cleanup failures, Windows native shutdown failure, and publication/startup/RPC timing failures remain disclosed; this correction is not a claimed repair for those. The local original-order Gateway replay had 3,525 passed, 15 failed, 7 skipped and no retained claims. The original-order chat-history replay reported 3,161 passed, one failed assertion, one existing skip, and one unhandled worker error (1,357.25 s, 38,517 private SQLite opens, 0 retained claims). The original history request passed in 3.46 s, so its hosted timeout remains unexplained, not fixed. The replay instead failed the unchanged full-mode media-containment assertion and a cron-delivery fork exhausted its roughly 4 GiB V8 heap; it is not a whole-shard pass. No assertions, deadlines, heap limits, or skip rules were relaxed. Required CI and review gates must pass on the actual published head before landing.

Earlier integration verification (56f6ef8)

The signed candidate 56f6ef87af (tree 0c748d2ddd) integrates pinned main 11867abe45 and preserves Grynn's contribution and the preceding repair commits. Of 645 incoming main paths, 13 overlap this PR. Both manual conflicts were additive: the worker cancellation-authority import now coexists with agent/shared database cleanup, and the sparse-checkout helper coexists with the upstream release-retry test. Every non-overlapping blob is preserved exactly. Existing PR deltas also survive on the overlapping files; the package-fixture environment line now exists in main itself.

  • The complete affected runtime selection passed 203 tests (265.68 s); four system-service cases retain their existing platform skips on this host. All 3,697 SQLite opens and all resolved handoff paths were private, with zero retained claims. This includes the upstream relocated relay-token binding case, worker cancellation/cleanup, agent lifecycle and archive-placement contracts.
  • All 778 tests across the three complete tooling files passed (877.13 s), including CI inventory planning, continuation workflow and package-acceptance contracts. Every executor resolved a private handoff path, no SQLite opens occurred, and cleanup completed without retained claims.
  • All six affected type graphs, root typed lint and 13-file formatting checks passed. Initial core typed lint correctly rejected the expanded relay fixture at 1,003/1,000 lines. Returning the existing database-close promise directly and using the equivalent required-record assertion removes redundant code without changing coverage, deadlines, skips or cleanup. The final complete relay file passes 23 tests including cleanup (97.68 s, 272 private SQLite opens, zero claims); its typed lint, canonical type graph and formatting pass (31.74 s).
  • Independent API-direct review found no actionable P0–P2 issue in the 13 integration deltas and both complete conflicted modules; its limits on omitted unchanged surrounding implementations remain recorded. A separate exact-delta/full-relay-file review confirms the final simplification preserves teardown failure propagation and the required-record guard. Prior unchanged source-bound whole-file audits and runtime proof are retained, not rerun or reclassified.

The earlier failed/interrupted CLI, Doctor, chat and other diagnostics below remain disclosed; these narrower successes do not turn them into passing runs. Required exact-head CI/security/review, supported retained-outcome recovery, verified landing and cleanup are still required. No live handoff store, Odin/Mac update or service restart was used.

Earlier correction verification (39d5320)

The previous head 7b7789cf97 completed CI with 148 successful and 15 skipped jobs, seven failing test jobs and the failed aggregate gate. It is not landed. The published correction 39d5320bee integrates the exact tested main 31dd34ff19 without conflicts; all 40 incoming blobs match that pinned main.

  • Two QA assertions now name the canonical .mjs ownership preload. Original-order shard 3/4 passes 1,067 tests; shard 1/4 records 1,368 passed, one failed, one skipped. Both corrected assertions pass. The remaining local auth-profile fixture returned its SQLite-contention failure; that is not represented as a passing shard. Both runs have private stores and zero retained claims. Static checks and independent API-direct review of the two-line change are clean.
  • Incoming main deliberately adds advisory plugin migration recovery warnings. The original four-file Doctor replay reproduced both stale singleton-warning expectations: 50 passed, three failed, 9,778 private SQLite opens and zero retained claims (540.10 s). The third failure remains the existing managed-v1 child deadline.
  • The Doctor expectation now checks the exact ordered warning list, including all eleven declared advisory owners. No containment filter, looser array assertion, rollback-byte check, deadline or skip was introduced or removed. Both updated warning assertions pass. The complete unmanaged rollback case passes; managed-pnpm later reaches the unchanged 60-second post-core child guard and retains four descendant claims. That affected run is one passed, one failed, fifteen unselected, with 5,888 private opens (316.74 s), not a full pass. Typed lint, the Doctor type graph, formatting, growth/assertion-safety checks and independent API review pass.
  • The complete Gateway-client replay passed all 663 test bodies but failed wrapper cleanup. Unsampled tracing identified the actual producer: client.watchdog.test.ts creates the real default device-identity database and omitted shared-store closure. The unchanged standalone test reproduced the same wrapper failure (31.94 s, eight private opens). Awaiting the existing shared-database close in afterAll repairs it without changing real proxy/IPv6 behavior, assertions or deadlines. The standalone case passes including cleanup (55.19 s, nine private opens); the complete original 46 files / 663 tests then pass including cleanup (115.14 s, 1,136 private opens, zero retained claims). Typed lint, its canonical type graph and independent API review are clean.
  • The preceding original Gateway-core group recorded 3,466 passed, four failed, two skipped, with 10,335 private SQLite opens and zero retained claims (561.80 s). Failures were the local large-workspace fixture and three native desktop-authority cases. The CLI job passed 9,092 hosted test bodies before a separate retained claim. Its original-order private replay exited without a final Vitest summary, with 53,935 private opens and three native claims acquired as update-command-run.test.ts began; it is not a completed-shard pass (385.00 s). That unchanged file then passed all 41 tests including cleanup, with 873 private opens and zero claims (141.69 s). A bounded replay of the same CLI plan with observational exit tracing passed that file but was stopped after native-fixture timeouts and task-guard refusals: 924 observed passes, 12 failures, no complete summary, 57,390 private opens (707.40 s). The guard blocked the attempted shared path before opening it. After the deliberate interruption only the parent wrapper claim remained; this is not natural-exit cleanup proof. No CLI source repair is inferred, no deadline changed, and the unexplained hosted cleanup failure remains disclosed. Other retained hosted failures include the unchanged 500 ms relay-token deadline and six chat media/finalizer polling assertions plus one sessions-send transport deadline. These are not claimed repaired or unrelated across their full dependency closures.

The original chat job plan was replayed without source changes: its first 305-test group passed, and 1,427 test bodies were observed passing overall with no assertion failures. All seven formerly failing cases passed, but the outer command ended with SIGTERM near 30 minutes while the final effort-scopes fixture was active. There is no complete Gateway-group or wrapper pass. All 40,429 observed SQLite opens were private; the six claims retained at interruption were preserved as interruption evidence, not attributed as a natural-exit leak. The root was removed only after no process/open-file consumers remained. The hosted failures remain unexplained, not claimed fixed.

Native publication verified signed head 39d5320bee (tree e2c0d40611). Required exact-head CI/review, supported retained-outcome recovery, verified landing and cleanup remain pending.

Previous candidate validation

The signed head 7b7789cf97 (tree b244d4c668) integrates main 4f43e47518 to resolve the verified worker-pool import conflict. Native publication verified the same remote head and tree. Exact-head CI, security/review gates and native merge recovery remain required; this is not a landing claim.

The latest repairs drain agent databases before shared state in the standalone migrated-update finalizer, register fixture teardown before fallible native ownership capture, and give owned Doctor children their CLI startup flags before launch. Startup respawn checks, exact-process settlement, unrelated-claim exclusions and existing deadlines remain intact.

  • The real shipped-9.2 rollback case passed through native Doctor, post-core update and wrapper cleanup: 1 passed, 16 unselected, 2,865 private SQLite opens, zero retained claims (182.59 s including the build). The complete launcher file passed 8 tests (36.76 s); the finalizer and two delivery fixtures passed 27 tests (43.67 s). These exercise real process/Worker lifetime, which helper-only assertions cannot prove.
  • Independent API-direct reviews of the integration and subsequent repairs are complete. The integration's teardown-registration finding was repaired and re-reviewed; the final cleanup and launcher deltas have no actionable P0–P2 findings. Affected typechecks, typed lint, formatting and growth guards passed. The broader integrated static run still reported two untouched incoming-main line-cap failures; they are not represented as passed or waived.
  • The five-file Doctor consumer run recorded 39 passed, 3 failed (632.27 s), with all 13,672 observed SQLite opens and every resolved handoff path private. One failure came from the task-only diagnostic preload adding an agent-directory selector to an intentionally allowlisted environment. Preserving its absence restored both session receipts; the unchanged receipt test then passed with 35 private opens and zero claims (45.10 s). No product assertion was removed or relaxed.
  • The other two failures hit the unchanged 60-second child guard in the managed-v1 and managed-pnpm success cases. Doctor had completed in the v1 case when final config validation started. The pnpm case retained finalizer claims after timeout, so the wrapper correctly failed. Those failures and their timing uncertainty remain open; a focused pass will not retroactively turn this broad run green. The malformed/missing handoff, failed-schema and stopped-run cases passed.
  • The corrected diagnostic environment did not resolve the two managed success-case timeouts: their focused original-order run recorded 2 failed, 15 unselected (208.32 s), with 3,124 private SQLite opens and eight claims retained after forced timeout. These are still failures, not a repaired timing defect.
  • Conflict integration preserved all non-overlapping PR and upstream blobs. The affected pool and commentary run recorded 141 passed, 1 failed (174.24 s), with 264 private SQLite opens and zero retained claims. The unchanged upstream graceful-rotation fixture timed out waiting for its startup counter before reaching the operation under test; its teardown also reported an unjoined rejection. The cause of slow startup remains unresolved. Core, infra and messaging typechecks plus affected lint, format and growth checks passed. Independent API-direct review of the exact integrated candidate completed four passes with no actionable P0–P2 findings; it does not resolve the recorded runtime failures. No deadline or assertion was changed.
  • Completed private fixture roots were removed only after checking current processes and open files. No claim receipts were fabricated. No live handoff store, Odin/Mac update or service restart was used.

Earlier candidate validation

The signed candidate 5824fb426d (tree f5e258df44) preserves the reviewed 7a4c801c76 ancestry and integrated main 5e5f9c2755. The superseded exact-head CI run failed; it is not claimed as a hosted pass. The previous run failed eleven jobs plus its aggregate. Their recorded failures drove the following repairs rather than blind reruns:

  • Scoped explicit/inherited fork pools and the unsharded Gateway now use the existing exact-process settlement adapter. Its real fork + Worker regression fails through the actual commands configuration before registration and passes afterward. General claims and descendant-process claims remain excluded.
  • Native fixture children register their actual close event before capture, kill/join on capture failure, and settle only their exact process/Workers. The extension signal fixture uses the canonical source runner and kills/joins known surviving children before joining wrapper pipes. Existing deadlines and failure assertions are unchanged.
  • The announce-loop fixture resets its same-generation registry. A redundant injected-field roundtrip and duplicated process-wait helpers were removed after whole-file audit; distinct behavior coverage remains.
  • A 2.30 MB tracked Git inventory exceeded Node's default buffer and fell back into disappearing generated directories. The inventory helper now uses the existing repository-standard 16 MiB bound. A real index-only 6,000-path regression verifies the complete ordered inventory, fails before repair and passes afterward.
  • Final original-order storage replay: 1,343 passed, 3 unchanged skips, 15,935 private SQLite opens, zero retained claims. Device and isolated-core original groups passed 86 and 936 tests. Complete extension and fork-pool files passed 190 and 8; the final planner and native Git files passed 198 + 1. Actual commands/orphan-recovery producers passed 35 tests with 913 private opens.
  • Original-order commands replay recorded 750 passed, 130 excluded but remains failed at the unchanged local agent-exec attribution guard. Support recorded 3,079 passed, 1 failed, 16 skipped; its unchanged local permissions fixture expected 0640 but observed 0600. Both now have zero unreleased claims. Neither run is represented as a full pass or as a repaired unrelated behavior.
  • Independent API-direct reviews of the exact eleven-file repair are scoped-clean with no actionable P0–P2 findings. The aggregate full-file audit covers touched tests, hooks, imports, helpers, fixtures and assertions; individual review batches have documented static-evidence limits. Final affected static checks passed, reusing unchanged completed type-graph evidence. No assertions, retries, deadlines or source skips were weakened.
  • Every observed physical SQLite path and resolved handoff path was task-private in each executed process/Worker. Completed roots and consumed generated output were removed after consumer checks. No live store, Odin/Mac update or service restart was used.

Prior applicable integration, native lifecycle, QA packaging and failure-path proof is retained below and in the review record. Required exact-head CI, applicable security/review gates, native preparation and retained-outcome recovery remain mandatory. Earlier runs deferred handoff-consumer subsets that lacked explicit isolation. The current task-only runner supplies and verifies private resolution in every executor; historical failed or interrupted runs are not reclassified as passes.

Evidence

  • The original real-SQLite lock reproduction fails on control main and passes with the owned test namespace. Existing native worker, CLI/Gateway, packaging, memory and wrapper proofs are preserved.
  • Failed CI shards were replayed in their recorded order where executable. Confirmed leaked fixture owners now await their database shutdown; deliberately terminated children use only observed exact-process/Worker exit accounting. Original failed namespaces and missing-close evidence are retained.
  • Whole-file API-direct test audits exposed additional false-positive oracles. Real wrong-agent, premature-broker-close, wrong-authority and expiry and abnormal-signal mutations passed the old assertions and failed the corrected assertions; normal cases pass after exact source restoration. Distinct valid coverage is preserved; moved fixture helpers do not remove tests.
  • Latest complete affected fixtures: schema lifetime 21 tests, Gateway startup 12, config cleanup 45, and preview signals/ledger 41 pass with namespace cleanup. The final extracted preview script also passes all 13 native signal variants with strict exit-code/signal checks with zero retained claims (46.82 s); its complete pre-extraction fixture took 61.64 s. Native process termination and restart/state persistence require the real child/Worker boundary. Type-aware lint, affected type graphs, formatting and file-growth checks pass for these final changes.
  • Current-main integration preserves upstream memory-repair rendezvous and worker-placement cleanup while retaining the stronger disconnected-request close join. The initial six affected fixtures passed 132 tests: Gateway 67 (127.73 s), memory 3 (135.95 s), and storage/native 62 (178.42 s across three fixtures). The completed Gateway and memory namespaces contain no retained claims.
  • The integration audit also found three ineffective assertions. Removing returned-reclaim validation and Gateway shutdown cleanup, and returning JSON instead of base64 float32 bytes, passed all three old cases (51.32 s). The repaired cases each reject the corresponding mutation (57.66 s). All temporary production changes were restored exactly; the full 67-case Gateway replay passes afterward (125.57 s), and its final cancellation-aware version passes all 67 again (121.44 s) with zero retained claims. Timeout cancellation is restored for the queued-disconnect test. No scenarios or assertions were removed; one unchanged response helper moved into existing test support.
  • The complete current-main package acceptance workflow fixture passes all 561 cases (838.33 s). Selected source guards, all selected typecheck lanes, dead-code scans, and core/script/root-test lint pass. Broad extension lint initially refused the nested checkout's ancestor dependency lookup. The identical relevant source then passed all 10,428 extension lint files in the existing standalone checkout (162.58 s, zero warnings/errors) with private dependencies and no declaration-boundary bypass. Final Gateway/worker type-aware lint, all selected core test graphs, and line/assertion guards also passed (109.52 s).
  • Worker cleanup failures were also exercised through real native fixtures. Injecting an error after the real supervisor join retained one claim in the old fixture; the repair released all 20 claims while preserving the failure. An earlier process-cleanup error likewise leaked only before the repair (47.39 s / 48.71 s). When environment stop and database close both reported errors after their real operations completed, the old fixture hid the first error; the repair reported both, with zero retained claims (56.17 s / 71.57 s). All injected faults were removed exactly. The final whole-file API audit is clean; all four distinct crash scenarios and EOF coverage remain intact.
  • Broad CLI replay: 8,997 passed, 8 failed, 89 skipped. Four failures are caused by the private diagnostic preload changing the exact environment observed by a launcher fixture; four unchanged Doctor service-definition cases also reproduce with private isolation only. The 12 native preview claims identified by that replay are repaired and pass targeted cleanup proof. This is not a passing full-shard result.

The last uninstrumented four-case worker run passed three cases but missed the anchor-crash capacity deadline (155.92 s); all 747 native claims still settled. One bounded same-order diagnostic run passed all four (83.76 s) and observed dead runtime/command identities before capacity release; all 2,048 claims settled. The diagnostic did not establish the original failure's root cause. Its temporary logging was removed exactly, and no deadline or assertion changed. This remains a disclosed local uncertainty, not a claimed fix.

Remaining local uncertainties include unchanged macOS native-supervisor and Doctor service-definition failures, filesystem-watch snapshot observation and triage admission cases, interrupted broad replays, and fixtures refused by genuine disk-capacity guards. No assertions, timeouts or capacity thresholds were weakened. These are documented limits of the local evidence, not claims of repaired behavior. Required CI and reviews must pass on the actual published candidate before landing.

Earlier runs deferred the mutable-signals/lifecycle subset until explicit handoff-store injection was available. Every helper executed by the current diagnostic runner uses an explicitly private handoff resolver with resolved-path verification; incomplete replays do not establish complete-subset coverage. No live handoff store or Odin/Mac update was used as a fixture.

Inspectable original lock-leak reproduction and follow-up output

Recorded before the later cleanup fixes; this is the original regression proof, not a claim of final-head hosted CI. Both runs resolved their coordinator path inside a private fixture before acquiring real SQLite coordination. A Node child loaded the lifecycle preload, acquired and released the coordinator, and the parent closed claim admission and removed the owned namespace. Paths below replace host/user identifiers with fixture labels.

Control main: 1775705e3a244276ffddc9ed1345e96c36b338e9
Node child: --import <lifecycle-preload> --import <tsx-loader> --input-type=module -e <acquire/release probe>
main:
  resolved/path: <private-fixture>/private-production/<lock-directory>/state-lifecycle.<hash>.lock.sqlite
  closed: true
  privateRuntimeVerified: true
  lockSurvivedNamespaceCleanup: true
candidate:
  resolved/path: <private-fixture>/owned/<lock-directory>/state-lifecycle.<hash>.lock.sqlite
  closed: true
  privateRuntimeVerified: true
  lockSurvivedNamespaceCleanup: false
allFixturesRemoved: true
handoffAPIsExecuted: false

Latest uninstrumented local follow-up output:

commands: Test Files 4 passed; Tests 46 passed
[test] passed 1 Vitest shard in 320.51s

Gateway + resource coordinator: Tests 47 passed
QA child preload: Tests 1 passed
[test] passed 2 Vitest shards in 55.43s

extracted wrapper: Test Files 1 passed; Tests 14 passed
[test] passed 1 Vitest shard in 30.60s

The standalone-inventory finding was reproduced by the existing extracted-wrapper regressions and repaired by including the complete executable ownership/preload dependency list. The receipt format is ephemeral, launcher-owned test metadata, not an application database migration. Existing schema-17 Doctor success, refusal and rollback assertions remain intact and passed in the commands shard.

@clawsweeper

clawsweeper Bot commented Sep 3, 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 docs Improvements or additions to documentation scripts Repository scripts extensions: qa-lab size: XL labels Sep 3, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR gives isolated test resources explicit ownership and waits for database, worker, and child-process cleanup before removing temporary state.

Example: An isolated Linux test opens a temporary state database and finishes.

  • Before: Its hash-named lifecycle SQLite lock survives outside the test namespace in shared /tmp.
  • After: The candidate places owned coordination inside the test namespace and removes it after verified resource settlement.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Meaningful cleanup work has real execution evidence, but architectural reconciliation and the retained SDK contract remain unresolved; no new discrete defect was verified in the inspected paths.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Recorded real-SQLite control/candidate output and managed test-launcher runs exercise owned resource cleanup, native exits, and cancellation; this evidence remains valid for the reviewed implementation and does not establish a conflict-resolved candidate or a passing broad CI run.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Repeated isolated test runs leave coordination resources outside their cleanup boundary and can exhaust temporary storage.
Reason: The cleanup invariant has clear value and recorded maintainer support; the public SDK surface retained after architectural reconciliation still needs an owner decision.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep this PR open: it contains meaningful cleanup work, has active maintainer involvement, and remains paired with an unresolved issue; its conflicting branch still needs reconciliation with main’s replacement SQLite owners.

Priority: P2
Reviewed head: 9d9481f947631925cf20c02ac4fb81870da0e053
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Which QA and testing SDK exports introduced by this PR should remain supported after reconciliation with main?
  • Recommendation: Retain only necessary generic exports: Approve the smallest supported SDK surface required by the surviving bundled callers and document its contract.
  • Why: The latest review requests a minimal export contract, and the unchanged head contains no recorded owner decision settling that public boundary.

Before merge

  • Resolve merge risk - Before merge, reconcile coordinator-dependent cleanup with main’s replacement SQLite and shutdown owners without restoring retired coordination machinery.
  • Complete next step - Investigate the failed exact-head CI jobs and distinguish patch-caused failures from outside causes before requesting landing.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Provenance

  • Separate SQLite coordination: original intent not found (8b16e53: Current main intentionally removes redundant coordinator databases and uses actual-database transactions with bounded lifecycle ownership.)
Agent review details

How this fits together

The managed test launcher creates temporary namespaces, propagates ownership into Node children and workers, and consumes close or native-exit receipts before deleting those namespaces.

flowchart TD
A[Managed test launcher] --> B[Owned temporary namespace]
A --> C[Validated resource context]
C --> D[Node children and workers]
D --> E[SQLite resource owners]
E --> F[Close and native exit receipts]
F --> G[Verified namespace cleanup]
B --> G
Loading

Technical review

Best possible solution:

Retain the useful cleanup changes through current ownership APIs and omit machinery whose responsibility main has retired.

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

The original defect has recorded real-SQLite before/after proof and matching base source; no current-main reproduction was run, and main has since removed its original coordinator producer.

Is this the best way to solve the issue?

Owned cleanup respects the established retention invariant, but the best current implementation must reuse main’s replacement owners rather than carry forward obsolete coordination.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1507c89eaa51.

Merge-risk options

Maintainer options:

  1. Adapt the surviving cleanup changes (recommended)
    Resolve the conflict using main’s current SQLite owners and preserve the distinct cleanup regressions.
  2. Pause for a narrower integration
    Keep the contribution available while the assigned owner identifies and separates changes still needed on main.

Provenance checked

  • Test-resource receipt ownership keeps the original intent (1cf0c31: Require positive release evidence and retain resources when nested cleanup or descendant completion is uncertain.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Active repair ownership and confirmed conflict: Live REST metadata retains fuller-stack-dev as assignee and reports mergeable=false, mergeable_state=dirty on the reviewed head; the maintainer’s September 22 comment records substantive repair work, and the author’s October 11 comment requests a coordinated continuation. (9d9481f94763)
  • Pinned introduced behavior: The verified introduction diff moves resource ownership into one shared implementation, closes claim admission before cleanup, and preserves the production coordination location for external databases. (src/infra/state-database-coordinator-paths.ts:73, 9d9481f94763)
  • Main replaced the original coordination machinery: Merged fix: prevent temporary-file exhaustion from SQLite coordination #157413 replaces separate coordination databases with transactions on the actual databases; current main’s tree no longer contains the coordinator files this PR modifies, while its test-resource owner still uses the earlier pending/released contract. (scripts/lib/vitest-resource-ownership.mts:25, 1507c89eaa51)
  • Established ownership invariant: The earlier merged resource-owner change explicitly requires positive release evidence and preserves uncertainty after worker crashes; this PR extends that intent with distinct exact-owner native-exit receipts. (scripts/lib/vitest-resource-ownership.mts:12, 1cf0c31f305e)
  • Retained behavior proof: The full PR body supplies before/after real-SQLite output showing the lock surviving control cleanup and disappearing with the candidate, plus managed-runner and native cancellation results; it explicitly preserves failed and interrupted runs as failures. The supplied body identity is SHA-256 011708f641902d248e2df9581320fd1e44abe7af08fe8adb40778f188db1de1f. (9d9481f94763)
  • SDK contract remains an owner choice: The introduced diff adds child-context forwarding and trajectory-reading exports to QA/testing SDK facades; the latest projected review already asks for the minimal retained export contract, and the head has not changed. (src/plugin-sdk/qa-runtime.ts:10, 9d9481f94763)

PR surface

PR surface statistics unavailable: the file list is incomplete.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: Resource cleanup matters for repeated developer and CI runs, but the evidence establishes no urgent current-main outage.
  • merge-risk: 🚨 compatibility: The branch changes SDK exports and depends on coordinator machinery that current main has replaced.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (23 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-23T10:05:08.600Z sha 5824fb4 :: blocked before merge. :: [P2] [P2] Update configuration assertions with the fork-pool cutover
  • reviewed 2026-09-23T11:50:04.416Z sha 60fb0d1 :: blocked before merge. :: none
  • reviewed 2026-09-23T13:58:31.825Z sha 7b7789c :: blocked before merge. :: none
  • reviewed 2026-09-23T15:01:10.171Z sha 7b7789c :: blocked before merge. :: [P2] Align both QA expectations with the emitted .mjs preload | [P2] Drain the watchdog fixture’s shared database before teardown
  • reviewed 2026-09-23T15:19:47.277Z sha 39d5320 :: blocked before merge. :: none
  • reviewed 2026-09-23T15:53:27.471Z sha 56f6ef8 :: blocked before merge. :: none
  • reviewed 2026-09-23T17:13:02.209Z sha 9d9481f :: blocked before merge. :: none
  • reviewed 2026-10-04T14:09:13.765Z sha 9d9481f :: blocked before merge. :: none

Reviewed October 18, 2026, 7:57 AM ET / 11:57 UTC (Revision 24).

@fuller-stack-dev fuller-stack-dev self-assigned this Sep 22, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Sep 22, 2026
@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review September 22, 2026 03:33
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 22, 2026
Preserve the original PR ancestry while integrating current main.

Record explicitly joined native-worker exits separately from graceful close,
retain failed receipt publication for retry, unwind default CLI failures
through shared-state cleanup, and close a terminal Gateway outcome handle
only when that operation opened it. Preserve distinct crash regressions.

Complete the standalone PR-wrapper runtime dependency inventory and observe
child-local claim admissions without racing parallel workers. Keep terminal
Gateway bookkeeping fail-open while preserving native cleanup retry custody.
@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram cli CLI command changes commands Command implementations labels Sep 22, 2026
@Grynn

Grynn commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

@fuller-stack-dev, are you still owning the integration of this takeover, or would you prefer a coordinated handoff of a narrowly scoped part?

I rechecked: head remains 9d9481f947631925cf20c02ac4fb81870da0e053; the October 4 review still calls for current-main conflict resolution, adaptation to the replacement SQLite owners (without restoring retired coordinator machinery), and a decision on the QA/test-environment export compatibility. The recorded failing/incomplete runs must stay distinct from the successful focused proof.

I have not edited your branch or started a competing repair. Please keep this out of automatic stale closure while ownership and those remaining gates are decided.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@Grynn

Grynn commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

October 21 relevance check: please keep this open, with @fuller-stack-dev's existing ownership intact. Current-main f91bca9546f5 still records pending resource claims and a released receipt; it does not itself represent the exact native-worker-exit handoff proposed here. That surviving distinction is why the whole proposal is not made obsolete by #157413 replacing the separate SQLite coordinator database.

This is a fresh source-level relevance check, not a fresh reproduction or approval of the old coordinator patch. The current review's conflict/CI and SDK-surface decision remain outstanding. I have not overwritten the assigned repair lane or duplicated its work; the earlier ownership/handoff question remains open.

This was referenced Oct 22, 2026
@Grynn

Grynn commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Closing this as superseded by #157413. I'll close #136552 as fixed by the same change.

I rechecked the original defect against current main 022048904b5e:

  • fix: prevent temporary-file exhaustion from SQLite coordination #157413 (merged 2026-09-27, 8b16e5328e) removed the separate SQLite coordinators, including state-database-coordinator-paths.ts, which built /tmp/openclaw-state-locks-<uid>/<family>.<hash>.lock.sqlite on POSIX. Nothing on main creates that directory anymore. The only remaining reference is scripts/verify-mac-runtime.mjs, which asserts those files are absent and removes any leftovers. It does not create them.
  • On Linux and macOS, the remaining owner lock is state.<hash>.lock under <stateDir>/tmp/openclaw-<uid>/ (src/infra/gateway-state-owner-directory.ts, resolveGatewayLockDirForCanonicalStateDir in src/config/paths.ts). For isolated tests this is inside the fixture's temporary state dir, so it gets removed with the test namespace instead of piling up in shared /tmp.
  • This PR's lock-routing change edits those deleted coordinator files, and git merge-tree against current main reports 291 conflicting paths.

This is a source-level check, not a fresh Vitest reproduction. It also revises my October 21 note. Main's scripts/lib/vitest-resource-ownership.mts still lacks the native-exit receipt distinction, but that is a separate test-launcher refinement, not this bug, and it doesn't justify keeping this branch open.

@fuller-stack-dev, thanks for all the repair work here. If the receipt piece is still wanted, a narrow PR against current main would be easier than reconciling this branch. I'm happy to reopen if you see something I've missed.

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

Labels

agents Agent runtime and tooling channel: reef Channel integration: reef channel: telegram Channel integration: telegram cli CLI command changes commands Command implementations docker Docker and sandbox tooling docs Improvements or additions to documentation extensions: codex extensions: qa-lab gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL stale Marked as stale due to inactivity status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Isolated test state databases leak lifecycle locks into shared /tmp

2 participants