Skip to content

fix: release Doctor inspection resources and rejected locks - #170530

Merged
steipete merged 2 commits into
mainfrom
dbasync/retainleak2
Oct 13, 2026
Merged

steipete merged 2 commits into
mainfrom
dbasync/retainleak2

Conversation

@steipete

@steipete steipete commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes retained plugin source directories after repeated Doctor/startup inspections, and a stranded filesystem lock when its post-acquisition handoff guard rejects ownership.

Related: #170439.

User Impact

Repeated in-process preflight operations release their inspection resources. A rejected lock acquisition releases the acquired lock before rethrowing, so later operations can acquire it normally. Public SDK signatures, stored formats, schema, permissions, and update behavior are unchanged.

Why This Change Was Made

Fresh preflight caches now belong to the creating preflight operation. Superseded and failed reads retire there; the final cache transfers only after surrounding cleanup succeeds. Doctor carries that ownership in its existing disposable stack, ordinary CLI validation releases it on exit, and Gateway startup transfers it to the process cache owner. Ambient borrowed caches and metadata-only discovery behavior stay with their existing owners. The old unowned snapshot-reader export is removed and all callers migrate together.

The file-lock owner releases the underlying acquired handle when the handoff assertion throws. The restrictive guard on public release remains: it protects a borrowed resource at a real effect boundary. No new checks, generations, or synchronization protocols are introduced; no validation checks are removed in this lifecycle-only change, so there are no newly accepted check-removal edge cases.

The CLI transcript fallback item is already fixed by #170439 (efd2af593300): its helper releases a consumed write when the outer authority check rejects. Its existing regression covers that boundary; this PR does not duplicate the repair.

Evidence

  • Focused file-lock suite: 16/16 passed, including real sidecar removal and immediate reacquisition after rejected handoff (68.35 seconds including runner startup on the loaded development host).
  • The same file-lock tests on base e78a253059eb fail only the new rejected-handoff regression: the lock sidecar remains present when cleanup should have removed it. The 15 existing tests pass (194.35 seconds command wall time on the loaded host).
  • New preflight regression exercises external Doctor contract captures through real Doctor/startup operations, successful disposal, and rejected startup: all 3 passed locally (356.98 seconds including transforms on the loaded development host; test bodies 77.82/16.21/10.51 seconds). The fixture retires its caller-owned invocation cache separately from the fresh inspection caches under test.
  • On the unchanged base, startup and rejected startup both fail at the capture-directory removal assertion: the directories still exist. The Doctor baseline case hit its 120-second timeout and is not counted as direct negative proof. The baseline command took 920.98 seconds including cold worker compilation; candidate Doctor/startup cases all pass locally and in CI.
  • All six changed test files (66 cases), including the renamed-export mock consumer, pass on final head c558b50e53d1 in PR CI. The lifecycle/startup batch passed 49 tests in 31.24 seconds; CLI guard batch passed 35 tests in 13.96 seconds; Doctor persistence batch passed 87 tests in 105.42 seconds; file-lock passed 16 tests in 1.64 seconds. CLI guard regression covers terminal retirement and preservation after Gateway adoption.
  • Independent Codex autoreview: scoped-clean, no actionable findings (two rounds).
  • Basic lint, hosted type-aware lint, production/test types, and source contracts passed. SDK API diff reports no entrypoint or export changes; SDK surface budget and runtime API guardrails passed (plugin contract suite: 23 files, 251 tests, 32.69 seconds). Final-head T1 and dialect ratchets passed: repository T1 stays 455→455; touched-owner T1 stays 0→0.
  • Published-driver × candidate update cell passed: published 2026.10.2 updated to 0661bbc2831e, returned readyz=200, verified the running version and preserved durable/incognito sessions. The only later commit corrects tests, so this is the final production implementation. CI supplied this proof; no remote lease or local Docker was needed.
  • Madge on final head reports 0 cycles. The initial dependency scan's nine Knip findings match scheduled main CI exactly in untouched files; main repaired them in fix(ci): repair worker entry roots and retired exports #170499 (12be6f68b5e1), whose dependency check passed.
  • Production diff: +115/−38 (153 changed lines), below the revised 400-line budget.

One frozen shared-harness v2.1 pair compared base e78a253059eb with final head c558b50e53d1, using Node 24.21.0 and SQLite 3.53.4. Both complete workloads passed all 13 turns plus control-plane, cron, compaction, and shutdown checks. Distributions below cover the ten warmed turns; one pair follows the current relaxed testing policy.

Metric Base Candidate
Direct Gateway T1 call sites in touched owners 0 0
Warmed causal all-thread statements/turn, median [min–max] 170 [170–217] 170 [170–171]
Warmed causal logical requests/turn, median [min–max] 41 [41–43] 41 [41–42]
Warmed causal MAIN statements/turn, median [min–max] 0 [0–0] 0 [0–0]
Warmed causal statements/turn, mean 174.9 170.1
Warmed causal requests/turn, mean 41.4 41.1
Legacy window statements/turn, mean 219.6 212.8
Background statements/minute 888.0 678.3
Whole-workload statements 6,715 6,798
Whole-workload requests 1,244 1,270
Shared SELECT family, per warmed turn Base Candidate
Exact-entry facts 4.0 4.0
Actor hydration 1.2 1.0
Entry-cache snapshot loads 0 0
Row facts 0 0
Watermark reads 1.0 1.0

Families use recorded SQL stack attribution and may overlap. Changed owners contribute zero warmed statements and requests on both heads. Cold stack matches decrease for startup preflight (27→26) and config guard (23→22); those counts overlap and are not summed.

The whole-workload increase is 83 statements (+1.24%) and 26 requests (+2.09%). Turn-caused statements decrease 2,946→2,915 while background statements increase 3,769→3,883. The largest background request increases are memory retrieval (+13), agent publication (+7), and transcript reads (+4), with no increase attributed to the changed owners or shared warmed read families. This is background workload variation under the attribution policy, not a claimed saving from the lifecycle fix.

The candidate recorded one failed background audit-prune BEGIN IMMEDIATE site (database is locked); the complete workload still passed and there was no changed-owner or foreground failure. This observation is disclosed separately from the successful workload assertions. The 32-core host's one-minute load was 105.5→83.5 during baseline and 122.8→66.6 during candidate. Counts are reported; latency is unmeasured. No SQL-saving or latency-improvement claim is made.

@clawsweeper

clawsweeper Bot commented Oct 13, 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 cli CLI command changes commands Command implementations size: M labels Oct 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 13, 2026
@clawsweeper

clawsweeper Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR disposes Doctor and startup inspection caches and releases acquired file locks when their handoff guard rejects ownership.

Example: Acquiring /tmp/rejected-handoff succeeds, then the resource-borrow guard throws.

  • Before: The acquisition rejects while rejected-handoff.lock remains held.
  • After: The acquired handle releases before rejection, allowing immediate reacquisition.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused repair has useful production-owner regressions and no identified defect, but supplied validation does not yet include the required update scenario.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; the body now reports successful Doctor/startup capture cleanup and real lock reacquisition regressions, addressing the earlier lifecycle-validation gap, while the repository-required published-driver × candidate update cell remains pending.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Repeated Doctor or startup inspections retain plugin source directories, and a rejected lock acquisition can block later operations.
Reason: The maintainer-authored direction fixes concrete ownership gaps without new settings, persisted formats, or competing lifecycle owners.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs resource leaks still present on current main, preserves existing custody boundaries, and has no concrete introduced defect.

Priority: P2
Reviewed head: c558b50e53d183dbd0883c4d57faa2cd3b95f10e

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The published v2026.10.2 updater × this candidate remains unverified, and no base-fail/head-pass result is supplied for the new preflight lifecycle regression.
Agent review details

How this fits together

Doctor and CLI startup consume configuration and plugin metadata, producing validated snapshots whose inspection resources must survive until disposal or Gateway adoption.

flowchart TD
A[Doctor or CLI startup] --> B[Preflight snapshot reader]
B --> C[Owned inspection caches]
C --> D[Doctor disposable stack]
C --> E[Gateway process cache]
C --> F[Inspection cleanup]
A --> G[Shared file lock adapter]
G --> H[Identity checked sidecar release]
Loading

Technical review

Best possible solution:

Land the focused lifecycle repair while preserving borrowed-cache ownership and guarded release of delivered lock handles.

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

Current-main source exposes both leak paths, and the added regressions exercise capture cleanup and rejected-handoff reacquisition; this read-only review did not execute them.

Is this the best way to solve the issue?

The patch repairs lifetimes at the existing owners, migrates internal snapshot-reader callers together, and preserves Doctor finalization and borrowed resources.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Preflight snapshot ownership keeps the original intent (2a1402c: Separate ordinary startup readiness from Doctor-owned legacy repair while preserving admission and metadata contracts.)
  • Doctor finalization lifetime keeps the original intent (310bce6: Keep plugin callbacks alive through later Doctor contributions and service finalization.)
  • Rejected lock handoff changes intended behavior with a stated reason (000af98: Prevent source mutations and delivered-handle release while native resource custody remains borrowed.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned patch and current-main comparison: The introduced diff adds explicit cache retirement and rejected-handoff cleanup; fetched main still creates unowned fresh inspection caches and throws after lock acquisition without releasing the handle. (src/commands/config-preflight-snapshot.ts:47, c558b50e53d1)
  • Complete lifecycle ownership: The reader owns fresh caches, retires superseded caches, and transfers only its selected cache; Doctor adds it to the existing movable disposable stack, ordinary CLI validation disposes it, and Gateway startup adopts it. (src/commands/doctor-config-flow.ts:111, c558b50e53d1)
  • Preserved finalization intent: The earlier lifecycle repair deliberately retained Doctor callbacks through later contributions and service finalization; this PR attaches cache ownership to that same lifetime. (src/commands/doctor-config-flow.ts:640, 310bce6a7517)
  • Distinct deferred follow-up: fix: release retained resources after completed and failed operations #170439 explicitly deferred these cache and lock ownership repairs; its merged transcript-fallback cleanup is separate. (efd2af593300)
  • Required dependency release contract: The changed adapter imports @openclaw/fs-safe/file-lock, pinned to 0.26.2, establishing the dependency boundary. Its repository policy was applied; release checks the held entry, decrements reentrant references, and removes only the unchanged sidecar. (src/sidecar-lock.ts, d88b6803617f)
  • Validation and accepted SDK repair direction: The maintainer-authored body explains the failed-handoff custody distinction, preserves guarded public release and SDK signatures, and reports passing lock and preflight lifecycle regressions; the published-driver update cell remains pending. (src/plugin-sdk/file-lock.ts:212, c558b50e53d1)

Likely related people:

  • Peter Steinberger: Raw commit 310bce6 adds src/commands/doctor-config-flow.ts:634 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 310bce6a7517; files: src/commands/doctor-config-flow.ts)

PR surface

Source +77, Tests +153. Total +230 across 13 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 7 115 38 +77
Tests 6 161 8 +153
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 276 46 +230

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +115/−38; tests +161/−8 Production growth establishes acquisition, disposal, and transfer ownership; regressions cover capture removal, lock reacquisition, and Gateway retention.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Repeated inspections retain resources, and rejected lock acquisition can obstruct subsequent operations, without evidence of an immediate core-runtime outage.
  • merge-risk: 🚨 compatibility: The public SDK lock helper changes failed-acquisition cleanup behavior; the maintainer-authored repair explicitly accepts that distinction while retaining signatures and guarded public release.
  • 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-13T02:25:31.795Z sha 0661bbc :: needs maintainer review before merge. :: none

Reviewed October 12, 2026, 10:47 PM ET / October 13, 2026, 02:47 UTC (Revision 2).

@steipete
steipete merged commit 33a438a into main Oct 13, 2026
142 checks passed
@steipete
steipete deleted the dbasync/retainleak2 branch October 13, 2026 03:55
steipete added a commit that referenced this pull request Oct 13, 2026
## What Problem This Solves

After #169484 delivered worker final replies before workspace reconciliation, session subscribers could observe reconciliation in progress without receiving its later completion. The claim owner installed internal row-change facts on completion, but that notification does not reach the existing WebSocket lifecycle bridge.

## Change

Publish the existing placement lifecycle event after an owned closure commits with both the turn claim and pending workspace result cleared. Subscribers receive the settled placement after its facts are installed. Retained recovery fences stay pending; ordinary local-turn receipts are excluded.

Production LOC: +9, a bounded correctness fix. Three files change; the archive assertion now includes its response for diagnostics without changing the expected result. The existing owner boundary test proves acceptance stays silent and completion publishes already-cleared claim and result authority. No new RPC, lifecycle state, timer, or polling.

## Evidence

Changed-file formatting, type-aware lint, and independent review passed with no actionable P0/P1 findings. `pnpm test src/gateway/worker-environments/placement-store.turn-claim-closure.test.ts --maxWorkers=1` was not run locally under the CI-only host constraint; local test wall time is unavailable. The integrated [CI run 38340516247](https://github.com/openclaw/openclaw/actions/runs/38340516247) at 7be861c selected and passed all four affected E2Es with both production fixes: native-slot 36.141 test seconds, upgrade-wire 158.587, same-session 82.785, and skill-library 41.308. Native A/B claims clear, and all four same-session pairs publish the settled placement. This PR runs the focused owner regression and required static gates independently. The four E2E contract updates are tracked separately in #170537.

Release-note context: session subscriptions publish worker workspace settlement after an early final reply.

Focused CI run 38341715059 passed all 42 tests in the owner group (21.40 seconds), including the new completion-publication assertion (665 ms), abort and lifecycle closure cases. All selected static gates passed. The prior head had a separate orphaned-provisioning archive failure. Current main passed all 10 archive tests in [probe CI](https://github.com/openclaw/openclaw/actions/runs/38343515030/job/115119831896), so no inherited-failure exception is claimed. This branch is refreshed against that main baseline, and the archive assertion now reports the response if it fails again.

Final head 38916dd: [CI 38344022221](https://github.com/openclaw/openclaw/actions/runs/38344022221) passes the archive cases (successful orphan cleanup 2.261s, failing cleanup 2.280s) and all 42 owner-group tests (24.55s, new publication assertion 650ms). The earlier archive failure did not recur after main integration; it is not claimed as inherited proof.

The sole remaining static failure is inherited from main #170530: `src/commands/config-preflight-snapshot.test.ts:41` imports `readConfigPreflightSnapshot`, which that main commit made private. The CI checkout is merge 137ab4a7c73d03c5d5cb1f2713e68b966cb3614c (main 33a438a plus this head); neither config file is changed here. Both files are identical to current main: implementation blob afc97b5, test blob b85a1d9. [Exact TS2724 job](https://github.com/openclaw/openclaw/actions/runs/38344022221/job/115121788481). This is recorded for the config owner; landing uses the authorized inherited-static-failure exception. No behavioral failure is waived.
steipete added a commit that referenced this pull request Oct 13, 2026
## What Problem This Solves

Three selectively run node-worker E2Es assert ordering that #169484 intentionally retired by delivering the durable reply before workspace reconciliation. The skill-library E2E also exposed a retained-transcript regression during its sequential worker flow; its original assertions did not explicitly equate a final reply with settlement.

## User Impact

The final diff is test-only. It verifies early replies while preserving claim release, workspace settlement, upgrade recovery, retained-session continuation, and skill-library behavior.

## Change

- Native-slot waits on the existing session-change signal, then asserts that the claim and pending result are gone before proving physical-slot reuse.
- Upgrade-wire checks its attempted upload after the existing durable recovery observation.
- Required-native receives A's final while quiescence is held, preserves the queued-follow-up proof, and waits for B's settled placement.
- Skill-library joins workspace settlement before sequential turns; its wire fixture exposes existing events.

The updated waits uncovered two production defects: #169622 tied retained transcript facts to a writer that early final releases, and successful claim closure did not reach the existing lifecycle/WebSocket bridge. Those fixes landed separately in #170556 and #170575. Main is now integrated at 38033f1, and the final diff contains only the five test/fixture files. Production LOC: 0. No timers, polling, retries, budgets, or assertion weakening were added.

## Evidence

[Integrated CI 38340516247](https://github.com/openclaw/openclaw/actions/runs/38340516247) at 7be861c passed all four E2Es and the required CI gate:

| File | Test seconds | Runner seconds |
| --- | ---: | ---: |
| native-worker-slot | 36.141 | 45.72 |
| paired-node-worker-upgrade-wire | 158.587 | 168.53 |
| required-native-same-session | 82.785 | 94.17 |
| skill-library-worker-wire | 41.308 | 67.21 |

[Native/upgrade/same-session log](https://github.com/openclaw/openclaw/actions/runs/38340516247/job/115110480812) shows A and B claims clearing and all four same-session pairs settling on their retained environments. [Skill log](https://github.com/openclaw/openclaw/actions/runs/38340516247/job/115110480823) shows eight remote placements move from reconciling to clear; the complete authoring, continuation, cancellation, and reclaim flow passes.

The [unchanged-main probe](https://github.com/openclaw/openclaw/actions/runs/38331787910/job/115083216251) reproduced the original four failures. [Control CI 38339534658](https://github.com/openclaw/openclaw/actions/runs/38339534658/job/115107577910), with only the test alignment and the extra active-run condition removed, still reached a reconciling placement twice and received no further event before the 300-second watchdog. No E2E artifacts were uploaded; the retained Vitest resource was watchdog cleanup evidence, not proof of a product child leak.

Changed-file formatting, type-aware lint, and independent review pass with no actionable P0/P1 findings. Local diagnostic command `pnpm test:e2e:gateway test/e2e/qa-lab/runtime/native-worker-slot.e2e.test.ts --maxWorkers=1` took 179.68 seconds before test execution and refused to proceed because artifact separation could not be verified. The guard was preserved; subsequent proof used GitHub CI only, with no leases.

The earlier skill local-first rejection with an unsettled database writer remains recorded for the session-actor campaign; this change does not alter that guard. Related credential-diagnostics PR: #170257.

Final-head CI 38344788931 has the same inherited main-only TS2724 error as #170575: config-preflight-snapshot.test.ts:41 imports the function made private by main #170530. CI checkout 1e93e8ab merges this head into main 88e5ae8; this test-only PR does not change either config file. [Exact static failure](https://github.com/openclaw/openclaw/actions/runs/38344788931/job/115124083706). The config owner follow-up is recorded; no worker behavior failure is waived.

Final test-only head 38033f1 passes all four selected E2Es in CI 38344788931: native-slot 45.28s Vitest / 46.69s runner; upgrade-wire 166.37s / 167.94s; required same-session 100.49s / 102.91s; skill-library 64.35s / 66.24s. Final diff is exactly five test/fixture files and zero production LOC. The only remaining failure is the documented inherited main TS2724 check; landing uses that scoped static-failure exception.
steipete added a commit that referenced this pull request Oct 13, 2026
Complete the preflight reader migration in `config-preflight-snapshot.test.ts`. Commit 33a438a (#170530) intentionally made `readConfigPreflightSnapshot` private and moved reads behind `createConfigPreflightSnapshotReader`, which owns and disposes executable inspection caches. The remaining direct test import caused TS2724 in the commands test type project. The diagnostic was observed in run 38344022221/job 115121788481 on PR #170575's synthetic merge; source inspection confirms the same stale caller on main at fcb89a3.

Use the existing factory with `await using` in the Doctor test branch and call its `read` method. All snapshot options and behavioral assertions stay unchanged. Disposal completes before the final config, backup, and SQLite-family byte-preservation assertions. The private helper stays private, with no compatibility wrapper or test-only production export.

[Exact candidate proof](https://github.com/openclaw/openclaw/actions/runs/38345114058/job/115124606937) checked out `573774fd5d001f19983da243bf241df0bceb6530` and passed the complete `src/commands/config-preflight-snapshot.test.ts`: **19/19, no skips**, 103.81s Vitest / 108.07s runner wall. It also passed the exact failing commands TypeScript leaf: `node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.commands.json --incremental`.

The [independent baseline job](https://github.com/openclaw/openclaw/actions/runs/38345114058/job/115124606702) checked out actual main `fcb89a331a1f59eedde59c4b3a338febdb199cb7` with the same setup and naturally reproduced `config-preflight-snapshot.test.ts:41` TS2724 (exit 2). The overall proof workflow is red because that separate baseline fails; the independent candidate test and type steps both pass. No failure was suppressed.

[Ordinary CI](https://github.com/openclaw/openclaw/actions/runs/38345111705) completed successfully: **18 jobs passed, 29 skipped**, including the aggregate. Selected test types, lint, source contracts, and boundaries pass; Madge reports zero cycles. T1 live stays 455→455, compatibility stays 9→9, and dialect stays 0→0. Knip, build, update, and SDK-diff jobs were unselected and are not claimed as fresh passes. Scoped formatting, basic lint with warnings denied, whitespace checks, and native hooks passed. One isolated Codex P2 review completed scoped-clean with zero findings. No local suite was run.

Scope: one test file, +3/-2 lines; no production, schema, update, or runtime behavior changes. SQL/T1 measurements and published-driver update proof do not apply to this test caller migration. No assertions or safety checks were removed.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
Give fresh Doctor/startup inspection caches an explicit operation owner, retiring failed and superseded reads and transferring the final cache only after cleanup succeeds. Carry that ownership through Doctor and CLI validation, with Gateway startup adopting its process cache.

Release an acquired filesystem lock before rethrowing a rejected ownership handoff. Preserve the public SDK signature and guarded release behavior.

Add lifecycle regressions for external Doctor source captures, CLI cache retirement/adoption, and rejected lock reacquisition.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…170575)

## What Problem This Solves

After openclaw#169484 delivered worker final replies before workspace reconciliation, session subscribers could observe reconciliation in progress without receiving its later completion. The claim owner installed internal row-change facts on completion, but that notification does not reach the existing WebSocket lifecycle bridge.

## Change

Publish the existing placement lifecycle event after an owned closure commits with both the turn claim and pending workspace result cleared. Subscribers receive the settled placement after its facts are installed. Retained recovery fences stay pending; ordinary local-turn receipts are excluded.

Production LOC: +9, a bounded correctness fix. Three files change; the archive assertion now includes its response for diagnostics without changing the expected result. The existing owner boundary test proves acceptance stays silent and completion publishes already-cleared claim and result authority. No new RPC, lifecycle state, timer, or polling.

## Evidence

Changed-file formatting, type-aware lint, and independent review passed with no actionable P0/P1 findings. `pnpm test src/gateway/worker-environments/placement-store.turn-claim-closure.test.ts --maxWorkers=1` was not run locally under the CI-only host constraint; local test wall time is unavailable. The integrated [CI run 38340516247](https://github.com/openclaw/openclaw/actions/runs/38340516247) at 7be861c selected and passed all four affected E2Es with both production fixes: native-slot 36.141 test seconds, upgrade-wire 158.587, same-session 82.785, and skill-library 41.308. Native A/B claims clear, and all four same-session pairs publish the settled placement. This PR runs the focused owner regression and required static gates independently. The four E2E contract updates are tracked separately in openclaw#170537.

Release-note context: session subscriptions publish worker workspace settlement after an early final reply.

Focused CI run 38341715059 passed all 42 tests in the owner group (21.40 seconds), including the new completion-publication assertion (665 ms), abort and lifecycle closure cases. All selected static gates passed. The prior head had a separate orphaned-provisioning archive failure. Current main passed all 10 archive tests in [probe CI](https://github.com/openclaw/openclaw/actions/runs/38343515030/job/115119831896), so no inherited-failure exception is claimed. This branch is refreshed against that main baseline, and the archive assertion now reports the response if it fails again.

Final head 38916dd: [CI 38344022221](https://github.com/openclaw/openclaw/actions/runs/38344022221) passes the archive cases (successful orphan cleanup 2.261s, failing cleanup 2.280s) and all 42 owner-group tests (24.55s, new publication assertion 650ms). The earlier archive failure did not recur after main integration; it is not claimed as inherited proof.

The sole remaining static failure is inherited from main openclaw#170530: `src/commands/config-preflight-snapshot.test.ts:41` imports `readConfigPreflightSnapshot`, which that main commit made private. The CI checkout is merge 137ab4a7c73d03c5d5cb1f2713e68b966cb3614c (main 33cbbd1 plus this head); neither config file is changed here. Both files are identical to current main: implementation blob afc97b5, test blob b85a1d9. [Exact TS2724 job](https://github.com/openclaw/openclaw/actions/runs/38344022221/job/115121788481). This is recorded for the config owner; landing uses the authorized inherited-static-failure exception. No behavioral failure is waived.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
## What Problem This Solves

Three selectively run node-worker E2Es assert ordering that openclaw#169484 intentionally retired by delivering the durable reply before workspace reconciliation. The skill-library E2E also exposed a retained-transcript regression during its sequential worker flow; its original assertions did not explicitly equate a final reply with settlement.

## User Impact

The final diff is test-only. It verifies early replies while preserving claim release, workspace settlement, upgrade recovery, retained-session continuation, and skill-library behavior.

## Change

- Native-slot waits on the existing session-change signal, then asserts that the claim and pending result are gone before proving physical-slot reuse.
- Upgrade-wire checks its attempted upload after the existing durable recovery observation.
- Required-native receives A's final while quiescence is held, preserves the queued-follow-up proof, and waits for B's settled placement.
- Skill-library joins workspace settlement before sequential turns; its wire fixture exposes existing events.

The updated waits uncovered two production defects: openclaw#169622 tied retained transcript facts to a writer that early final releases, and successful claim closure did not reach the existing lifecycle/WebSocket bridge. Those fixes landed separately in openclaw#170556 and openclaw#170575. Main is now integrated at 38033f1, and the final diff contains only the five test/fixture files. Production LOC: 0. No timers, polling, retries, budgets, or assertion weakening were added.

## Evidence

[Integrated CI 38340516247](https://github.com/openclaw/openclaw/actions/runs/38340516247) at 7be861c passed all four E2Es and the required CI gate:

| File | Test seconds | Runner seconds |
| --- | ---: | ---: |
| native-worker-slot | 36.141 | 45.72 |
| paired-node-worker-upgrade-wire | 158.587 | 168.53 |
| required-native-same-session | 82.785 | 94.17 |
| skill-library-worker-wire | 41.308 | 67.21 |

[Native/upgrade/same-session log](https://github.com/openclaw/openclaw/actions/runs/38340516247/job/115110480812) shows A and B claims clearing and all four same-session pairs settling on their retained environments. [Skill log](https://github.com/openclaw/openclaw/actions/runs/38340516247/job/115110480823) shows eight remote placements move from reconciling to clear; the complete authoring, continuation, cancellation, and reclaim flow passes.

The [unchanged-main probe](https://github.com/openclaw/openclaw/actions/runs/38331787910/job/115083216251) reproduced the original four failures. [Control CI 38339534658](https://github.com/openclaw/openclaw/actions/runs/38339534658/job/115107577910), with only the test alignment and the extra active-run condition removed, still reached a reconciling placement twice and received no further event before the 300-second watchdog. No E2E artifacts were uploaded; the retained Vitest resource was watchdog cleanup evidence, not proof of a product child leak.

Changed-file formatting, type-aware lint, and independent review pass with no actionable P0/P1 findings. Local diagnostic command `pnpm test:e2e:gateway test/e2e/qa-lab/runtime/native-worker-slot.e2e.test.ts --maxWorkers=1` took 179.68 seconds before test execution and refused to proceed because artifact separation could not be verified. The guard was preserved; subsequent proof used GitHub CI only, with no leases.

The earlier skill local-first rejection with an unsettled database writer remains recorded for the session-actor campaign; this change does not alter that guard. Related credential-diagnostics PR: openclaw#170257.

Final-head CI 38344788931 has the same inherited main-only TS2724 error as openclaw#170575: config-preflight-snapshot.test.ts:41 imports the function made private by main openclaw#170530. CI checkout 1e93e8ab merges this head into main 8526c5b; this test-only PR does not change either config file. [Exact static failure](https://github.com/openclaw/openclaw/actions/runs/38344788931/job/115124083706). The config owner follow-up is recorded; no worker behavior failure is waived.

Final test-only head 38033f1 passes all four selected E2Es in CI 38344788931: native-slot 45.28s Vitest / 46.69s runner; upgrade-wire 166.37s / 167.94s; required same-session 100.49s / 102.91s; skill-library 64.35s / 66.24s. Final diff is exactly five test/fixture files and zero production LOC. The only remaining failure is the documented inherited main TS2724 check; landing uses that scoped static-failure exception.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…w#170619)

Complete the preflight reader migration in `config-preflight-snapshot.test.ts`. Commit 33cbbd1 (openclaw#170530) intentionally made `readConfigPreflightSnapshot` private and moved reads behind `createConfigPreflightSnapshotReader`, which owns and disposes executable inspection caches. The remaining direct test import caused TS2724 in the commands test type project. The diagnostic was observed in run 38344022221/job 115121788481 on PR openclaw#170575's synthetic merge; source inspection confirms the same stale caller on main at 54a9df0.

Use the existing factory with `await using` in the Doctor test branch and call its `read` method. All snapshot options and behavioral assertions stay unchanged. Disposal completes before the final config, backup, and SQLite-family byte-preservation assertions. The private helper stays private, with no compatibility wrapper or test-only production export.

[Exact candidate proof](https://github.com/openclaw/openclaw/actions/runs/38345114058/job/115124606937) checked out `573774fd5d001f19983da243bf241df0bceb6530` and passed the complete `src/commands/config-preflight-snapshot.test.ts`: **19/19, no skips**, 103.81s Vitest / 108.07s runner wall. It also passed the exact failing commands TypeScript leaf: `node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.commands.json --incremental`.

The [independent baseline job](https://github.com/openclaw/openclaw/actions/runs/38345114058/job/115124606702) checked out actual main `54a9df02cc64f5f466490dc7b76ae6bc7f2b2690` with the same setup and naturally reproduced `config-preflight-snapshot.test.ts:41` TS2724 (exit 2). The overall proof workflow is red because that separate baseline fails; the independent candidate test and type steps both pass. No failure was suppressed.

[Ordinary CI](https://github.com/openclaw/openclaw/actions/runs/38345111705) completed successfully: **18 jobs passed, 29 skipped**, including the aggregate. Selected test types, lint, source contracts, and boundaries pass; Madge reports zero cycles. T1 live stays 455→455, compatibility stays 9→9, and dialect stays 0→0. Knip, build, update, and SDK-diff jobs were unselected and are not claimed as fresh passes. Scoped formatting, basic lint with warnings denied, whitespace checks, and native hooks passed. One isolated Codex P2 review completed scoped-clean with zero findings. No local suite was run.

Scope: one test file, +3/-2 lines; no production, schema, update, or runtime behavior changes. SQL/T1 measurements and published-driver update proof do not apply to this test caller migration. No assertions or safety checks were removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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