Skip to content

fix(github): distinguish publication locks from unavailable storage - #152437

Merged
steipete merged 18 commits into
mainfrom
upd/flake113-session-publication-exclusion
Sep 20, 2026
Merged

steipete merged 18 commits into
mainfrom
upd/flake113-session-publication-exclusion

Conversation

@steipete

@steipete steipete commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Related: #152387, #153068, #153355

What Problem This Solves

Publication clients need to distinguish a recorded lease holder from unavailable storage. A caller-canceled acquisition must also be reported as a non-outcome rather than a thrown Doctor health-check failure.

User Impact

Publication and confirmation return a closed leaseAcquisition outcome: held is FORBIDDEN with the holder and grant epoch; store-unavailable is retryable UNAVAILABLE with a native-derived reason code; aborted is non-retryable UNAVAILABLE with the caller-signal reason and recorded elapsed time. Actual workspace/turn/reconciliation contention remains retryable UNAVAILABLE.

Doctor reports that inspection was not performed when acquisition is canceled before grant. Its original 250 ms signal stays unchanged, source state remains untouched, and successful JSON retains findings: [] while reporting the non-outcome through warnings. Cancellation after a durable grant remains an operation error. Retired Gateway reservation closures cannot authorize further work.

No new configuration, CLI options, environment variables, schemas, dependencies, or wait limits are introduced. Existing-schema maintenance remains non-migrating.

Why This Change Was Made

The landed publication fix addressed the symptom with a 100 ms storage-retry policy but used the same STATE_LEASE_BUSY outcome for an occupied lease and a failed acquisition write. This PR replaces that inference with facts recorded by the shared lease owner. SQLite's existing worker admission and native busy handling own the bounded write; publication does not add a separate retry loop.

Area Reconciliation
100 ms policy and waitForLease Removed the reservation-selected retry policy, obsolete option/refusal helper, and STATE_LEASE_BUSY mapping. The shared owner records the lease row or the store's own failure signal.
RPC classification Replaced lease-busy inference with held, store-unavailable, and aborted; retained the separate workspace-busy response and callback failure identity. The closed storage reason is sqlite-busy, lifecycle-busy, or storage-error; arbitrary exception text is not serialized.
Correctness and fixtures Kept warn-mode maintenance for manual RPC fixtures, cold-reset preparation, the original three restart cases, no callback replay, and reuse of the same confirmation after writer release. The restart fixture now actually ends the placement-owner epoch.
Duplicate/obsolete coverage Main already provides the 98-line restart extraction, so that duplicate branch change disappears. Retired the nine-mode waitForLease policy matrix; acquisition, contention, and registered-RPC regressions assert the replacement facts and ownership guarantees.
Worker lifecycle Preserved main's direct idle inspection, generation/availability checks, deferred retirement, completed-outcome handling, and receiveSqliteWorkerReply integration. Detached cache creation retains explicit live authority and maintenance ownership.
Heartbeat handoff Incorporated #152681 unchanged. Its worker-retention fixture now warms the shared acquisition worker only in the heartbeat-specific case, so the existing observer identifies the heartbeat worker. The separate cold-acquisition GC case and terminated-thread assertion remain intact.
Caller transactions Review exposed a worker-created lease hidden by an active caller read transaction. Admission now rejects that state before writing, for both cached and supplied handles; healthy supplied handles remain supported.

Pending write-capable work still joins native settlement before cleanup. A signal records cancellation when it fires; later held/busy replies cannot replace that recorded outcome. Other storage/cleanup failures and post-grant cancellation remain errors. Caller authority refusals retain their original identity instead of being relabeled as unavailable storage.

Evidence

Gateway inventory ordering correction

Candidate: b8c69cee4cb4a3ff95b2ac54e48a495be327dbb2.

Tooling jobs 106011069200 and 106011069195 exposed the same ordering error in the hand-maintained gatewayDatabaseWorkerTestFiles owner (test/vitest/vitest.gateway-server-paths.mjs). The previous insertion placed local-workspace-projection.test.ts after prepared-pool-local-project.test.ts, while both discovery consumers return sorted arrays:

- "src/gateway/worker-environments/prepared-pool-local-project.test.ts",
  "src/gateway/worker-environments/local-workspace-projection.test.ts",
+ "src/gateway/worker-environments/prepared-pool-local-project.test.ts",

The owner now retains canonical order. All 104 unique members and their broker-backed lane remain unchanged. The expected values import this owner directly; no generated expected fixture, assertion, baseline, or wrapper input was changed.

Both targeted regressions failed before the repair with this exact diff. The complete test/vitest-cli-ownership.test.ts and test/scripts/ci-node-test-plan.test.ts then passed 202/202 tests. node scripts/check-changed.mjs --base 0b9190261065a70a7be0ac6c5b27f406efe11aae validated this one-file correction. Fresh Codex P1 autoreview: scoped-clean, 0.99. Delta: zero production LOC; test configuration +1/-1, net zero.

Prior rebase and validation

Candidate: 0b9190261065a70a7be0ac6c5b27f406efe11aae. Merge base moved from ce5322924b7c967a83b6ad72ffa4e78ff387495d to d3f7ab7bb356df93ac0f34f47fd5d1fe989e42e4.

Read the complete overlapping changes in #153150 (d22782a7f09, shared agent-database worker lifecycle) and #153158 (084dfeccb6e, worker-side Cron recovery observations). Their broker, cleanup, and recovery behavior remains intact. The broker's pre-factory refusal records a different fact from a lease holder, unavailable storage, or caller cancellation; neither path replaces or duplicates the other.

Resolved file Resolution
openclaw-state-worker-contract.ts Retain main's cleanup operations and backend alias alongside the recorded lease-acquisition contract.
openclaw-state-worker-runtime.ts Retain main's agent cleanup and Cron recovery dispatch. Lease acquisition stays excluded from this application runtime.
openclaw-state-worker-store.ts Reuse main's hoisted worker URL and retained cleanup opener; preserve the existing detached opening and explicit admission checks.
openclaw-state.worker.ts Use main's backend alias while retaining lease dispatch after the closed guard and without application-runtime preparation.

The conflict resolutions are mechanical. The combined store then exceeded the 700-line cap, so its existing host-only operation-options type moved to the existing worker contract and a redundant existingOnly: true overload was removed. True/boolean calls retain Promise<T | undefined>; false/default calls retain Promise<T>. This adds no runtime edge or behavior, and the size gate passes. Production change this round: +12/-12, net zero. Fresh Codex P1 review: scoped-clean, 0.99.

A further reset timeout reproduced on pristine main. Temporary phase tracing measured 105.8 seconds inside the embedded-agent import during the unchanged 120-second test; admission drain and hooks took less than one millisecond. The existing reset preload omitted that deferred cleanup dependency. The one-line test preparation correction is separately published in #153355 and included here. Pristine-main full restart proof passed 5/5, with reset taking 33.3 seconds; its scoped checks and P1 review passed. No deadline, assertion, mock, retry, or production path changed. Test delta this round: +1 line.

  • 1,649 passing cases across 30 focused files, combining completed local and Linux file proofs; one existing Podman-dependent projection case remains skipped. This covers the five previously red files, lease acquisition/error transport/diagnostics, worker ownership and settlement, updater authority callers, both wrapper closure files, and the sibling Cron recovery cases.

  • Publication restart: 7/7 passed on the final source. Doctor: 239 passed on Linux plus both platform-root-alias cases passed on macOS, completing all 241 cases. The earlier local Doctor invocation was deliberately stopped after six passing cases because this loaded host took 27–80 seconds per case; Linux ran the same cases in roughly 1.6–1.8 seconds. Final consumer Testbox proof, command exit 0, owned lease stopped.

  • Projection: 27 passed / 1 existing Podman skip on Linux. Its two macOS EILSEQ fixture failures occur when creating invalid-UTF-8 paths; the test is byte-identical to the previously compared pristine-main version. Projection Testbox proof, command exit 0, owned lease stopped.

  • The complete changed-check plan is accounted for. All typechecks, formatting, ratchets, dead-export scans, script lint, schema/storage guards, and boundary guards passed locally; import-cycle count is 0. The local core-lint shard hit its unchanged 900-second limit with no lint diagnostic (exit 124). The repository's complete core-lint gate then passed all five existing CI stripes on Linux, with zero errors and unchanged timeouts. Core-lint Testbox proof, command exit 0, owned lease stopped. The staged source for all three final changed files was compared byte-for-byte with the working tree before commit, and the committed patch matches the proof snapshot.

  • Extension declaration preparation encountered the documented ancestor-install artifact. The authorized direct lint of the two changed extension-facing contracts passed, with a temporary canary proving the rule remained active:

    canary: eslint(no-debugger), exit=1
    real files: exit=0
    

    The canary was removed. No checkout switch, baseline edit, suppression, or dependency change was used for this fallback.

  • Full PR delta against the new base: production +568/-341 (net +227); tests/support +1855/-1001 (net +854); tooling +5; docs +8. The remaining production growth records closed outcomes/native provenance and carries them through admission, publication, and Doctor consumers. This rebase round adds no runtime behavior.

Native attachment precheck confirmed pull-request CI run 35485470334 on 0b9190261065a70a7be0ac6c5b27f406efe11aae and was stopped immediately after attachment. REST verified the exact head, open/non-draft, mergeable: true, mergeable_state: blocked. CI completion was not awaited. No landing was attempted.

Earlier repair evidence

Previously published head: 6360383014be7635848db62d10cdda79761e84c2, based on ce5322924b7c967a83b6ad72ffa4e78ff387495d. The recorded lease outcomes, caller-refusal identity, and reconciliation with #152387 remain intact.

Five-shard attribution

All five failing files were run on the rebased branch before repair and on pristine main pinned to 5ca92f8dd27a576d7d3ec0206153f4ecbb782c02. The failed CI run used merge 2b3614911ab94f4a2d94a269ace773e95a296eac (head 098a3f64f6be173ae11539cce51ed4bf0f102230 into main 4f1d0b5270204e4056fca962264027608655b033). P/F/S denote complete-file pass/fail/skip counts.

Shard / file Branch before fix Pristine main Cause and canonical fix
small-46: test/scripts/test-projects.test.ts 1097P / 4F 959P PR integration: two exact dispatch expectations omitted the newly routed file; the rebase also retained ten duplicate broker inventory rows already supplied by main. Complete both expectations and retain each route once. No assertions weakened.
large-13: src/gateway/worker-environments/local-workspace-projection.test.ts 27F / 1S macOS 25P / 2F / 1S; Linux 27P / 1S PR acquisition now requires the host broker, but this real database consumer remained in threads. Route it through the existing Gateway database-worker owner. Main's two macOS failures are EILSEQ when creating deliberately invalid UTF-8 filenames; Linux confirms all applicable baseline cases pass.
small-15: src/infra/state-migrations.media-persistence.test.ts 13P / 1F 14P PR authority-preservation path treated a native open refusal as an arbitrary caller error, losing acquisition context and SQLITE_IOERR in the diagnostic cause. Record native-open provenance at the effect and consume it at the lease owner. Original consumer assertions unchanged.
small-11: src/commands/doctor-session-sqlite.test.ts 239P / 2F 241P Same owner defect: the uncoded loader error escaped as node:sqlite unavailable, and typed maintenance diagnostics lost the nested native cause. The shared owner repair preserves the cause and acquisition context.
large-3: src/agents/worktrees/service.source-only-filters.test.ts 8F 8P The real database consumer lacked the host broker. Route it through the existing database-worker core owner; filter/security assertions stay unchanged.

The avatar constants and plugin SDK imports are not implicated in these five failures. SDK surface checks pass, and the constants remain defined once.

Native-open provenance is recorded only around the actual native calls in the coordinator, tracked handle, and ownership probes; authority callbacks remain outside that boundary. The lease owner consumes the recorded fact through its existing store-unavailable outcome. Review also identified worker startup before the acquisition wrapper: the existing closed error codec now carries this fact across that boundary, preserving error class, code, and causes without classifying lookalike authority errors. No retry, longer timeout, new option, SQLite schema, or dependency is added.

The final rebase is mechanical: its only conflict preserves both sets of broker-test registrations. The six native-error repair files are byte-identical across it. Main's earlier config-reload watcher helper is reused, removing a byte-identical duplicate while preserving lifecycle and environment isolation.

Main then added audit/delivery commands whose application-runtime closure would require 801 more files in the wrapper. The canonical fix is to dispatch stateLease.acquire in the existing lightweight worker bootstrap, beside metadata/idle control operations. It calls the same grant helper with the same lazy open callback after the closed guard. Native transaction/commit admission, existing-schema behavior, settlement and close are unchanged. The old application-runtime acquisition branch is removed, and that runtime's command type excludes it.

The wrapper now preserves every main archive input plus five actual bootstrap inputs, removing 232 obsolete application-runtime-only entries. Strict closure assertions remain exact. A new executable regression materializes that production archive without the application runtime, acquires and verifies two successive leases, and checks zero durable rows afterward. It fails before the cutover with ERR_MODULE_NOT_FOUND for the application runtime and passes afterward. No bulk allowlist, duplicated dispatcher, or test-only guard was added.

Prior validation

  • Final bootstrap proof: 1249 passing tests across 13 files: 1230 lifecycle/authority/publication/routing tests across ten files, all 18 executable/static wrapper tests, and the targeted Doctor cancellation case. The other 19 Doctor-isolation cases were unselected in that final targeted invocation; the complete 20-case file passed in the preceding cohort.

  • Native-provenance repair proof before the late rebase: 394 tests across nine complete files passed, including the complete 241-case Doctor session-maintenance file, 53 error-codec cases, both updater authority files, and the unchanged 250 ms Doctor signal. The native-error implementation was byte-identical across the subsequent rebase and bootstrap cutover.

  • New provenance regressions failed before their respective fixes: two direct native-open cases failed while two authority controls passed; two transport cases failed while the unmarked lookalike control passed. The extracted-wrapper lease test failed before the bootstrap cutover with a missing application-runtime module and passed afterward with real acquisition, ownership checks, reacquisition and zero remaining lease rows.

  • Linux proof: 1398 passed / 3 existing skips across six files, covering all five reported failing files plus acquisition. This proof used the native-provenance/routing repair before the later additive codec and bootstrap corrections, which received the final local proof above. The exact synchronized manifest was checked before execution. Provider: blacksmith-testbox, lease tbx_01m2xttd26zes3r234sgfy5qs9; proof run. Native command recorded FIXED_SUITES_EXIT 0; owned lease stopped. The skipped cases require Podman or a platform root alias.

  • Fresh API-route Codex P1 scoped-clean reviews: native error provenance/transport 0.90; final bootstrap cutover 0.94. No accepted/actionable findings.

  • SDK surface check passed on the final base. node scripts/check-changed.mjs completed successfully for the final bootstrap scope against the final base, including core/core-test/root-test typing, full core/script lint, dead exports, schema/storage/auth guards, and zero runtime import cycles. The earlier complete changed-set plan passed all other steps with the authorized nested-checkout extension-lint substitution below.

    extensions/l800-five-shards-lint-canary.ts:1:1: error eslint(no-debugger)
    canary exit=1
    real files exit=0
    

    The canary was removed. The direct fallback checked the two changed extension-facing contracts with test/tsconfig/tsconfig.extensions.test.json; CI's full extension lint remains authoritative.

This round before the bootstrap absorption: production +58/-13, net +45 and tests/support +107/-11, net +96. The bootstrap cutover then removes 2 net production lines and 232 archive entries, adding 56 net test lines. Combined round delta: production +43, tests/support +152, tooling -227. Against the final main base, production is +227 net (+557/-330), tests/support +853 net (+1854/-1001), tooling +5, and docs +8; remaining growth records the closed outcomes and native provenance and carries them through admission/RPC/Doctor consumers. The net-zero production target was not reached; the bootstrap cutover itself shrinks production and removes the broad archive dependency.

Additional local validation caveat

The broader local cohort recorded 1077 passed / 1 failed / 1 platform skip across 21 files before the final codec correction. The failure was src/state/openclaw-state-db.test.ts → “recovers a hot rollback journal privately before writable recovery”: its runHotRollbackJournalRecoveryProbe child hit the unchanged 30-second execFileSync deadline with ETIMEDOUT. At that comparison, this file was byte-identical to pinned main 5ca92f8dd27a576d7d3ec0206153f4ecbb782c02; the case originated in #113580.

A pristine-main focused run passed the case in 20.4 seconds (1 passed, 243 unselected). Phase-instrumented probes with the same 30-second limit passed on both main (20.125 seconds) and candidate (20.705 seconds), preserving 256 committed rows, zero uncommitted rows in the read-only view, the journal through read-only inspection, and integrity ok. The original timed-out phase was not captured; the cause remains unattributed. This is not claimed as a fixed flake or a reproduced main regression. No retry, longer deadline, weaker assertion, or speculative separate PR was added. The pristine checkout is retained locally for follow-up.

Previous candidate attribution and proof

Current head: 098a3f64f6be173ae11539cce51ed4bf0f102230, mechanically rebased onto 11741283eb04dbf1f8678b162e89d23c35032470, then repaired at the import and test lifecycle owners. The recorded lease outcomes, original caller-refusal identity, and reconciliation with #152387 remain intact.

Seven-shard attribution

Each complete failing file was compared on the rebased branch before repair and in a pristine detached checkout of the pinned main commit. CI had tested synthetic merge 9e279ecd (afff6a132 into d1609f8a), which included main's avatar-owner extraction and new managed-workspace dispatch case. Counts below are local complete-file results (P=passed, F=failed, S=skipped).

Shard / failing file Branch before repair Pristine main Cause and repair
small-50: pr-wrapper-source-closure.test.ts 1F / 5P 3P PR merge integration: #152670 moved real runtime avatar constants into the new profile types module, outside this PR's materialized worker closure. Move the constants to the existing src/shared/avatar-limits.ts owner and make all remaining profile-types imports type-only. No inventory or baseline expansion.
small-45: pr-operation-lock.test.ts 2F / 140P / 1S 2F / 140P / 1S PR failures were the same missing module before the expected fetch refusal. Main's failures were distinct timing failures listed below. The import-owner repair fixes both reported PR cases.
small-43: pr-main-refresh.test.ts 7F / 64P 71P Same missing module prevented cold provisioning; all seven reported cases pass after the import repair.
small-32: pr-worktree-provision.test.ts 18F / 1S 17P / 1F / 1S Same missing module and downstream absent-checkout assertions. Main's separate failure was the Darwin-only multi-checkout deadline below. All 17 selected applicable provisioning cases pass after repair.
small-46: eager-import-closure.test.ts 1F / 10P 11P Extracted wrapper could not resolve user-profiles.types.js; the type-only cutover removes that runtime edge.
large-15: run-attempt-dispatch.owner.test.ts 1F / 10P 11P PR acquisition now requires the host broker. A temporary diagnostic recorded Shared-state admission requires the host broker; the test was still in threads. Route it through the existing database-worker fork owner and assert the actual backend refusal. Diagnostic removed.
small-23: server.mcp-auth-login.test.ts 1F / 47P 48P PR worker acquisition exposed a fixture assumption: cancellation acknowledgement and callback retirement precede asynchronous credential cleanup. Capture the admitted wizard, preserve immediate callback rejection, then await its existing settlement promise before checking verifier deletion.

The runtime constants move preserves the separate 512 KiB PNG/JPEG/WebP profile and 2 MiB general-avatar contracts. The eight repaired files are src/shared/avatar-limits.ts, the four src/state/user-profiles{,-internal,-tailscale-avatar,.types}.ts consumers/type owner, both runtime test files above, and test/vitest/vitest.database-worker-core-paths.mjs.

Additional failures reproduced on pristine main, with no bounded root-cause repair established:

  • pr-operation-lock.test.ts: review-init requires fresh main before replacing PR artifacts (healthy, existing=false) exceeded 30,000 ms.
  • Same file, (first, existing=true): git worktree add hit the fixture helper's 5,000 ms ETIMEDOUT.
  • pr-worktree-provision.test.ts: materializes full cold/warm PR siblings, then preserves native sparse transitions took 126,698 ms against 120,000 ms on Darwin. It runs six sequential real checkouts; synchronous subprocesses delay reporter/timer delivery. The slow stage remains unidentified.

These main-side timing failures need a separate tooling lane. No speculative separate PR, retry, longer timeout, or weaker assertion was added. The known Darwin case was excluded from the targeted repair rerun; its complete-file failure is retained above.

Current-head proof

  • 272/272 tests across 19 files passed: original 16-file set, both updater authority suites, and MCP auth. Held/store-unavailable/aborted outcomes, original refusal identity, restart fencing, real publication handoff, worker cleanup, existing-schema behavior, and Doctor's unchanged 250 ms cancellation remain covered.

  • 81/81 owner tests across four files passed: wrapper/extracted closure, real dispatch, and user profiles, including the unchanged avatar size/MIME boundaries.

  • 26/26 targeted provisioning cases passed: 2 operation-lock, 7 main-refresh, and 17 worktree-provisioning cases. 338/338 selected routing checks across three files passed.

  • node scripts/check-changed.mjs --base 11741283eb04dbf1f8678b162e89d23c35032470: every planned step passed using the authorized nested-checkout extension-lint substitution. All typechecks, core/script lint, dead-export scans, and ten trailing guards passed. The temporary canary was removed.

    extensions/l800-seven-shard-lint-canary.ts:1:1: error eslint(no-debugger)
    canary exit=1
    real files exit=0
    
  • Fresh API-route Codex P1 review of the eight-file repair is scoped-clean. No accepted/actionable findings.

  • CI run 35467834981 attached to this head. The native watcher was stopped immediately after ATTACHED; CI completion was not awaited. REST reported open, ready, mergeable: true, mergeable_state: blocked. No landing performed.

This round: production +15/-15, net 0; tests/routing +7/-0. Total against the pinned base: production +502/-318, net +184; tests/support +1737/-1032, net +705; tooling +232; docs +8. Remaining production growth belongs to the existing closed lease outcomes and their admission/RPC/Doctor consumers; this round adds no production LOC or new configuration, environment, schema, or dependency surface.

Previous candidate evidence

Previous candidate: afff6a132f1a6458eae4b807fab29af7a9b3c4fb, rebased onto 847fdb9ea859c8db6cc836ef300ed1b47297c768.

  • 224 tests across 18 files passed on Node 26.8.2: the original 16-file proof set plus both update-cli authority suites. This includes all seven publication restart cases, real Gateway handoff, held/busy/aborted acquisition outcomes, caller-refusal identity, worker cleanup and retirement, existing-schema maintenance, wrapper extraction, and Doctor's unchanged 250 ms cancellation/source-isolation checks.

  • The updater authority suites initially reproduced 10 failed / 3 passed because their threaded CLI lane lacked the newly required host broker. Both now use the existing broker-backed lane, with original assertions unchanged. The added lease-boundary regression independently failed before the owner preserved typed caller refusals.

  • The large-result cleanup failure was attributed separately: pristine main f2dff0dcf9cca6e11aba8cbdf35a3005027894d3 on Node 24.21.0 produced 4 passes / 1 failure in five complete file runs. A controlled slow-commit probe recorded the native writer's legitimate 5-second coordinator refusal before the 65 MiB mutation settled. The separately published fixture repair starts the framed-result probe at the first result continuation; all payload, grant, cleanup, exit, follower, persistence, and deadline assertions remain. Five fixed runs passed on Node 24, and all seven cases passed in this candidate's Node 26 cohort. Temporary probes and injected delay are removed.

  • The latest rebase preserves all twelve preceding commits' patches in range-diff; the additional commit is the separately reviewed fixture repair. Main's opening-admission checks, native retirement behavior, and both wrapper inventories are retained. The wrapper inventory also includes main's two newly required upload-store modules.

  • Fresh API-route P1 reviews of caller-refusal preservation, wrapper inventory reconciliation, and the cleanup fixture are scoped-clean.

  • All planned changed checks passed with the authorized nested-checkout extension-lint substitution. Full typechecking, core lint, unused-export scans, and all ten trailing guards passed. The temporary canary was removed.

    extensions/l800-final-lint-canary.ts:1:1: error eslint(no-debugger)
    canary exit=1
    real files exit=0
    
  • CI run 35459733029 subsequently failed on seven shards. The new attribution and repair above supersede that earlier registration-only observation.

Previous candidate diff against its stated base: production +487/-303, net +184; tests/support +1730/-1032, net +698; tooling/inventories +232; docs +8. The fixture repair itself changes no production code and is +8/-4 test lines. Remaining production growth records closed outcomes, carries them through worker admission and RPC/Doctor consumers, and joins lifecycle cleanup; the superseded timeout/busy adapter is removed.

Published-updater × candidate upgrade proof was not rerun in this authoring round. The existing-schema, Doctor, worker, and focused RPC proofs do not claim to replace that scenario. CI's full extension-lint job remains authoritative for the documented local host substitution.

Earlier proof and reviewed reconciliation
  • Against exact rebased-main production (be33ad451fa83365176c7ffd53f2fdda1d36e6dd, including the landed retry policy), all five targeted regressions fail for their intended assertions: held exclusion reports retryable UNAVAILABLE without holder facts; store contention lacks the closed cause; a retired coordinator still publishes; caller abort lacks its reason/elapsed outcome; Doctor reports health check threw instead of a non-outcome. The comparison verifies all 29 candidate production paths are byte-identical to that base while retaining the regression harness.
  • Reconciled candidate: 197 tests across 16 files pass, including all seven publication restart cases, the real Gateway handoff, lease/store contention, Doctor's unchanged 250 ms cancellation, worker admission/idle/retirement, existing-schema behavior, error transport, and native wrapper source closure.
  • The two active-transaction regressions fail before the review correction with LEASE_LOST and a stranded lease. After the correction, 42 acquisition/contention/existing-schema tests pass, including valid supplied-handle acquisition and cleanup.
  • The CI-discovered stale-probe routing omission reproduced as 2 failed / 4 passed; routing the file through the existing broker-backed lane passes 47 worktree tests across 3 files. No assertion or timeout changed.
  • The incoming heartbeat-retention fixture reproduced threadId 1 !== -1 before correction. On the heartbeat-reconciliation base fba076b49e53ad7eed5475525da89c34c269d66c, 85 tests across 7 files pass: publication restart, lease acquisition/heartbeat/retention/existing-schema, Doctor isolation, and native-wrapper packaging.
  • The next CI run exposed two managed-reloader tests draining fake timers across native worker acquisition. The focused pre-fix replay also failed after draining 10,000 timers. Both cases now await their existing outcome promises with real time; all assertions and deadlines are unchanged, and the complete 269-case reload-handler file passes.
  • A later exact-head CI run stalled twice for 300 seconds in the 70-second admitted-write fixture. Local replay and temporary phase diagnostics reproduced the stall after the intended drain error: lease release waited on a fake timer while SQLite cleanup was native. The fixture now records the inner outcome, finishes its simulated drain phase, restores real timers, and then joins native lease cleanup. Exact deadlines, held-call assertions, and release/reacquisition checks remain; 186 plugin/reload tests across 3 files pass. All temporary diagnostics are removed.
  • Rebased again onto c5f60118cf50552dae9726b16c6a4ab0fee3f899 after main moved. The only conflict was four upstream database-worker inventory additions; the final inventory is the exact duplicate-free union. All other 77 candidate files are byte-identical across that rebase. 1,173 routing/config tests across 3 files pass on the rebased head.
  • Main then added theme-related wrapper inputs. Rebased onto 68e23ccf848c25b678218521b6be5e1d94f92476, retained both inventories, and preserved its theme documentation. The wrapper closure check caught one newly eager typeface schema dependency; adding that existing file fixes the observed 1/5 failure. All 5 wrapper-closure tests pass, and this one-line packaging correction passed fresh API-route P1 review plus its selected changed checks. Production and test implementations are unchanged by this rebase.
  • Fresh full-candidate API-route Codex review on the heartbeat-reconciliation base: five passes, scoped-clean at P1. Both final test-only clock corrections passed fresh API-route P1 reviews and all their selected changed checks.
  • All selected changed checks pass with the documented extension-lint host substitution. Full core lint, all typecheck lanes, all unused-export scans, and the ten remaining planned guards passed. Head: 95931bd891d872732aaaabfd57fac9535c7848a3; exact-head CI completed successfully (157 completed jobs, zero failures; native watcher GREEN). The exact-head Security Review reevaluation also passed after CI completed.

Earlier proof remains recorded: 835 reload cases, 454 integration cases, and two hosted peer-composition iterations of 100 files / 1,589 tests each. The hosted proof predates this rebase; the new 197-case suite exercises the changed worker-settlement context. Hosted iterations. GitHub effects are synthetic; SQLite contention, worker lifetimes, and CLI execution are real.

Production changed from +218 net against the previous base to +175 net against final base 68e23ccf848c25b678218521b6be5e1d94f92476 (+477/-302). The reconciliation was +166 before the nine-line transaction-admission correction. Remaining growth records outcomes and carries them through worker admission, RPC/Doctor consumers, and joined lifecycle cleanup; the duplicate timeout/busy adapter is removed. Tests/support: +518 net (+1546/-1028). Tooling/inventories: +370; docs: +8. The comparisons use their stated bases, and the net-zero target was not reached.

The nested-checkout extension-lint guard uses the authorized direct fallback with test/tsconfig/tsconfig.extensions.test.json on the changed extension-facing contracts. No extension implementation file changed. The canary and real-file results are:

extensions/l800-lint-canary.ts:1:1: error eslint(no-debugger)
canary exit=1
real files exit=0

The temporary canary is removed. Every other selected check passed; CI's full extension-lint job is authoritative. The earlier Testbox fs-safe directory-mode defect belongs to #152717 and is untouched here: node-workspace-transfer-credential.test.ts, “fences the real credential deletion before tunnel stop (upload pending: true)”, reports FsSafeError: temp workspace directory is group/world writable without sticky protection under umask 0002. The outer fixture is worker-environments/service.test-support.ts; ensureContainedDirectory in node-worker-workspace-identity.ts created the session directory without an explicit mode.

Earlier-head CI also exposed two incoming-main failures outside this diff: #152563’s Windows refresh.missing-root.integration.test.ts intermediate-ancestor case timed out at 120,000 ms; #152120’s service-definition-backup.test.ts original-byte replacement case resolved instead of rejecting. Their source provenance is established; their exact runtime causes are not. Neither owner is modified here.

Current handoff

The earlier landing disposition below applies to its named 95931bd891d872732aaaabfd57fac9535c7848a3 head. This authoring round did not land or wait for CI; earlier-head green checks are not current-head CI proof.

Historical maintainer landing disposition

ClawSweeper's September 19 12:33 UTC review of 95931bd891d872732aaaabfd57fac9535c7848a3 found no actionable code or security findings. Its single Rank-up move requests published-updater × candidate proof on copied existing state, including Doctor maintenance completion and healthy Gateway restart. Skipped for this landing under the maintainer's bounded landing instruction. That end-to-end upgrade scenario remains a validation gap; the existing-schema, Doctor isolation, native worker, and exact-head CI results above do not claim to replace it. The related compatibility-proof requests have the same disposition.

The reviewed source remains unchanged. Landing reuses the scoped-clean Codex review of record and the successful exact-head CI and Security Review results above. The reconciliation with #152387 preserves its contention repair while replacing the duplicate publication retry policy with acquisition facts recorded by the shared lease owner.

Maintainer landing disposition for the current candidate

Candidate: b8c69cee4cb4a3ff95b2ac54e48a495be327dbb2.

ClawSweeper's September 20 04:24 UTC review examined this exact head and established no actionable correctness or security finding. Its sole Rank-up move asks for published-updater validation or renewed acceptance of the bounded validation gap. The bounded waiver is renewed for this candidate under the maintainer's explicit instruction to land this reviewed head and record Rank-up dispositions. Published-updater × candidate execution against copied existing state through Doctor completion and healthy Gateway restart is skipped for this landing and remains an end-to-end validation gap. Native SQLite, worker, Doctor, and RPC boundary results above do not replace that scenario. The related compatibility-proof and maintainer-decision requests have this same disposition.

Compatibility scope: no new configuration, CLI options, environment variables, SQLite schemas, dependencies, or wait limits are introduced. Existing-schema maintenance remains non-migrating. The shared lease owner replaces the publication-specific retry inference with recorded acquisition outcomes and preserves caller authority and settlement.

The scoped-clean Codex review of record is accepted by the maintainer for this exact candidate. The exact-head openclaw/ci-gate completed successfully in CI run 35488776731. The landing runner makes no semantic source changes and uses the native review, preparation, and merge gates.

@clawsweeper

clawsweeper Bot commented Sep 19, 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 gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Sep 19, 2026
@steipete
steipete force-pushed the upd/flake113-session-publication-exclusion branch from 2ac61e5 to 05e30d9 Compare September 19, 2026 03:47
@steipete
steipete marked this pull request as ready for review September 19, 2026 03:50
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 19, 2026
@clawsweeper

clawsweeper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 20, 2026, 1:02 AM ET / 05:02 UTC (Revision 22).

ClawSweeper review

What this changes

The PR distinguishes occupied publication locks, unavailable storage, and canceled acquisition through the shared SQLite lease owner, and updates Doctor diagnostics and worker lifecycle integration.

Merge readiness

⛔ Blocked before merge - 2 items remain

The PR remains useful and has no actionable correctness findings. The exact-head maintainer disposition resolves the previous upgrade-proof blocker; the bounded validation gap remains explicitly accepted.

Priority: P2
Reviewed head: b8c69cee4cb4a3ff95b2ac54e48a495be327dbb2

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent owner-level repair with substantial boundary validation and no actionable findings; the remaining upgrade uncertainty has an explicit disposition.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): Retained native SQLite, worker, extracted-wrapper, and Doctor execution evidence covers acquisition outcomes, cancellation, cleanup, and recovery through production boundaries; publication RPC proof uses synthetic GitHub effects. The separate upgrade exception does not claim that scenario passed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): Retained native SQLite, worker, extracted-wrapper, and Doctor execution evidence covers acquisition outcomes, cancellation, cleanup, and recovery through production boundaries; publication RPC proof uses synthetic GitHub effects. The separate upgrade exception does not claim that scenario passed.
Evidence reviewed 9 items Pinned introduction and clean checkout: Reviewed the merge-base d3f7ab7 to pinned-head delta. Endpoint drift was not treated as PR ownership, and the stale test merge was not used to claim removal of main behavior. Whitespace validation passed and the checkout remained clean.
Previous blocker explicitly dispositioned: The fetched complete PR body matched the supplied SHA-256 9b31a838096be3078b52618638de0408c5fd9e0b933a98f14fee6824ec71fed6. Its final section renews the bounded published-updater validation waiver for this exact head and explicitly covers the prior rank-up, compatibility-proof, and maintainer-decision requests. This is captured discussion evidence, not an instruction to perform a merge.
Distinct work remains on main: Fetched main still uses OPENCLAW_STATE_LEASE_TIMEOUT/STATE_LEASE_BUSY and the publication-specific 100 ms retry adapter. The merged contention repair at #152387 therefore overlaps this work but does not implement its recorded holder, storage-cause, and cancellation outcomes.
Findings None None.
Security None None.

How this fits together

GitHub publication uses shared SQLite leases to exclude conflicting workspace operations before publishing an accepted checkpoint. The same lease infrastructure supports Doctor and plugin lifecycle operations, whose callers need accurate acquisition outcomes and safe cleanup.

flowchart TD
  A[Publication or Doctor request] --> B[Shared lease owner]
  B --> C[SQLite worker admission]
  C --> D{Acquisition outcome}
  D -->|Acquired| E[Revalidate authority and perform work]
  D -->|Held or unavailable| F[Typed caller response]
  D -->|Canceled| G[Recorded non-outcome]
  E --> H[Join settlement and release]
Loading

Before merge

  • Resolve merge risk (P1) - Accepted for this exact candidate: published-updater execution against copied existing state through Doctor completion and healthy Gateway restart remains unverified, leaving end-to-end upgrade interaction uncertainty.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production versus validation growth Production +227 net; tests/support +854 net Production growth is explained by recorded acquisition outcomes, native-error provenance, and lifecycle integration; most growth supports validation.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/flows/doctor-lint-flow.ts, unknown-truncated-pull-files. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Merge-risk options

Maintainer options:

  1. Honor the recorded upgrade exception (recommended)
    Proceed under the maintainer's exact-head waiver while retaining the published-updater validation gap in the landing record.

Technical review

Best possible solution:

Keep acquisition facts and write admission in the shared lease owner, preserving checkpoint identity, live authority, and joined cleanup across all callers.

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

Yes: main's shared busy classification and the recorded native-SQLite contention cases establish the failure path. This read-only review did not execute the tests.

Is this the best way to solve the issue?

Yes. Recording outcomes at the shared lease owner removes the publication-specific inference while preserving authority checks and avoiding another retry policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded publication and maintenance reliability improvement without evidence of an urgent widespread outage.
  • merge-risk: 🚨 compatibility: Shared lease admission and Doctor retirement affect existing installations, and the full upgrade scenario remains an explicitly accepted validation gap.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): Retained native SQLite, worker, extracted-wrapper, and Doctor execution evidence covers acquisition outcomes, cancellation, cleanup, and recovery through production boundaries; publication RPC proof uses synthetic GitHub effects. The separate upgrade exception does not claim that scenario passed.
  • proof: sufficient: Contributor real behavior proof is sufficient. Retained native SQLite, worker, extracted-wrapper, and Doctor execution evidence covers acquisition outcomes, cancellation, cleanup, and recovery through production boundaries; publication RPC proof uses synthetic GitHub effects. The separate upgrade exception does not claim that scenario passed.

Evidence

What I checked:

  • Pinned introduction and clean checkout: Reviewed the merge-base d3f7ab7 to pinned-head delta. Endpoint drift was not treated as PR ownership, and the stale test merge was not used to claim removal of main behavior. Whitespace validation passed and the checkout remained clean. (b8c69cee4cb4)
  • Previous blocker explicitly dispositioned: The fetched complete PR body matched the supplied SHA-256 9b31a838096be3078b52618638de0408c5fd9e0b933a98f14fee6824ec71fed6. Its final section renews the bounded published-updater validation waiver for this exact head and explicitly covers the prior rank-up, compatibility-proof, and maintainer-decision requests. This is captured discussion evidence, not an instruction to perform a merge. (b8c69cee4cb4)
  • Distinct work remains on main: Fetched main still uses OPENCLAW_STATE_LEASE_TIMEOUT/STATE_LEASE_BUSY and the publication-specific 100 ms retry adapter. The merged contention repair at fix(gateway): retry publication during brief database contention #152387 therefore overlaps this work but does not implement its recorded holder, storage-cause, and cancellation outcomes. (src/gateway/worker-environments/placement-workspace-reservation.ts:94, e7f5b8f57a9b)
  • Latest release comparison: The v2026.9.5 source retains the earlier lease-timeout error contract. A failed local historical-blob lookup was recovered through GitHub's contents API; no release implementation of the new outcomes was established. (src/state/openclaw-state-lease-error.ts:1, ec9c1a13db89)
  • Current authority and settlement: Worker acquisition requests host admission after transaction entry and immediately before commit. The host composes current database admission, caller cancellation, and active-transaction refusal; detached worker creation retains explicit admission and maintenance ownership. Publication reservations capture the Gateway restart signal and remain part of the downstream effect guard. (src/state/openclaw-state-lease-worker.ts:75, b8c69cee4cb4)
  • Behavioral coverage and retained proof: The inspected restart harness exercises registered publication RPCs with real SQLite contention, held rows, and retired Gateway owners. It checks unchanged receipts and effects on refusal, then successful reuse of the original confirmation after writer release. The captured body reports 7/7 final-source restart cases, native worker and extracted-wrapper execution, and Doctor cancellation/source-isolation results. GitHub effects are synthetic. A direct hosted-log download was blocked by the review proxy, so those logs were not independently inspected or rerun. (src/gateway/github-repository-publication-restart.test.ts:53, b8c69cee4cb4)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

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

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

Workflow

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

History

Review history (21 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-19T14:28:22.694Z sha 9f2baa5 :: blocked before merge. :: none
  • reviewed 2026-09-19T16:08:27.829Z sha cc0cd17 :: blocked before merge. :: none
  • reviewed 2026-09-19T18:07:35.902Z sha afff6a1 :: blocked before merge. :: none
  • reviewed 2026-09-19T20:46:03.126Z sha 098a3f6 :: blocked before merge. :: none
  • reviewed 2026-09-20T01:00:37.749Z sha 6360383 :: blocked before merge. :: none
  • reviewed 2026-09-20T01:42:51.154Z sha 6360383 :: blocked before merge. :: none
  • reviewed 2026-09-20T03:11:52.528Z sha 0b91902 :: blocked before merge. :: none
  • reviewed 2026-09-20T04:24:36.758Z sha b8c69ce :: blocked before merge. :: none

@steipete
steipete force-pushed the upd/flake113-session-publication-exclusion branch from 05e30d9 to fb729ea Compare September 19, 2026 04:03
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling size: XL and removed size: L labels Sep 19, 2026
@steipete steipete changed the title fix(github): distinguish busy storage from publication locks fix(github): report retryable publication failures when storage is busy Sep 19, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 19, 2026
@steipete
steipete force-pushed the upd/flake113-session-publication-exclusion branch from dc39f81 to e04ce15 Compare September 19, 2026 09:23
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 19, 2026
Distinguish caller cancellation from held leases and unavailable storage without changing caller deadlines. Preserve operation errors after durable grants and report cancelled Doctor inspection as a recorded non-outcome.

Complete native-worker fixture routing, awaited teardown, and reload receipt synchronization after the acquisition cutover.
Replace the overlapping publication retry policy from #152387 with the shared held, store-unavailable, and aborted outcomes. Preserve workspace-busy responses, callback failure identity, restart preparation, confirmation reuse, and main's worker-retirement fixes.

Reject active caller transactions at worker admission before they can hide or strand a newly acquired lease. Keep healthy supplied handles supported and document the closed RPC reason codes.
@steipete
steipete force-pushed the upd/flake113-session-publication-exclusion branch from 6360383 to 0b91902 Compare September 20, 2026 03:00
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 20, 2026
)

Start the competing native-writer probe at the first framed-result request, after the 65 MiB mutation settles. This keeps cleanup validation from consuming the writer's admission budget during unrelated mutation work while preserving every result, retirement, authority, recovery, and persistence assertion.

No production behavior, timeout, retry policy, payload size, or deadline changes. The smaller cases retain transaction and commit-admission coverage.

Validation: controlled slow-commit reproduction before and after the trigger change; five complete final fixture runs passed (35 cases); changed-file checks passed; scoped-clean autoreview and exact-head hosted CI.

Related: openclaw#152437, openclaw#152377.
@steipete
steipete merged commit 44b0127 into main Sep 20, 2026
214 checks passed
@steipete
steipete deleted the upd/flake113-session-publication-exclusion branch September 20, 2026 05:14
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
…penclaw#152437)

Publication and confirmation now distinguish held workspace leases from unavailable storage and caller-canceled acquisition. The shared SQLite lease owner records these outcomes, replacing the publication-specific retry inference while preserving caller authority, native settlement, and retired-owner fencing.

Doctor records pre-grant cancellation as a visible inspection warning without changing its signal budget or mutating source state. No new configuration, CLI options, schemas, dependencies, or wait limits are introduced.

Validation: scoped-clean Codex review; native SQLite/worker, registered publication RPC, Doctor, updater-authority, and wrapper-boundary proof; exact-head CI gate success. The current candidate's published-updater through healthy Gateway restart scenario remains an explicitly accepted, bounded validation gap recorded in the PR body.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR 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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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