Skip to content

fix(state): retain schema and disposal refusals during cold admission - #175295

Merged
steipete merged 1 commit into
mainfrom
fix/state-admission-cluster-20261017
Oct 17, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/state-admission-cluster-20261017

Conversation

@steipete

@steipete steipete commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes incorrect database admission after a schema-owner handoff and loss of the original disposal refusal during deferred session preparation. Both appeared in main hourly 39010956087.

User Impact

A cold write refuses a database upgraded by a newer owner before its callback can mutate it. Disposal during session preparation reports the original lifecycle refusal, while rejected work remains uncommitted and a later operation can recover. No migration or operator action is required.

Why This Change Was Made

Evidence

Before on 363f07d8be98: all three reported failures reproduced, 35 passed / 3 failed, 128.76 s native command wall. Existing regressions remain intact apart from the registry-required fixture input.

After: 38/38 passed, 211.93 s command wall including worker rebuild. File timings: state transactions 10/10 in 92.46 s, placement evidence 12/12 in 54.14 s, entry admission 16/16 in 49.98 s.

Thirteen sibling files: 93 passed; the pre-existing Linux-only killed-owner case is gated on macOS and remains for PR CI. Coverage includes cache retention and close custody, worker reply cleanup/native settlement, shared integrity preparation and schema admission, and registry-target inventory/deduplication.

State/SQLite, agent/session and Gateway-server test typegraphs pass. Type-aware and boundary lint, formatting and whitespace pass. Independent P2 review is scoped-clean. All test commands use the repository's native wrapper with --maxWorkers=1; PR CI provides broad and Linux proof. No skips, assertion weakening, retries or timeout changes were added.

CI follow-up: the five changed-compact failures are inherited

CI run 39013823977 tested merge 1457cda7 of this head into 4c15811faab4. Its “unknown” classifications reflect unmatched changed-job names, so each failing file was run through the native wrapper on current main 8c4ea360522c and PR head 6fa2a3a05cbc. All five test-file blobs are identical between those trees.

Failed job / file Current main PR head Attribution
large-19-3: reply-turn-admission.worker.test.ts Synthetic cancelled reply Same failure Inherited cancellation-result failure
large-9-1: server.sessions.reclamation-admission.test.ts Exit codes [] versus [1] Same failure Inherited native-exit expectation
large-17: doctor-session-sqlite.targets.test.ts (pinned Bun) Unavailable shared-state import resolves Same failure Inherited Doctor refusal failure
large-18-2: update-command-doctor-child.test.ts Both exit-code cases fail to throw newer-schema refusal Same failures Inherited Doctor readmission failure
large-18-1: server.agent-database-recreation-product-proof.test.ts Missing memory-core/worker-api.js, then worker exit 1 Both cases pass Main's later #175157 adds a worker to a fixture that disables bundled plugins

The Memory failure occurs at public-surface resolution before SQL: the Gateway fixture disables bundled plugins but directly imports the real Memory runtime; the new worker inherits the disabled environment without the fixture's imported runtime. Those owners are unchanged between the CI merge parent and tested current main. This PR does not modify Memory worker entry, environment, artifact resolution or that fixture.

Paired proof: current main has 6 failures / 16 passes; PR head has 5 failures / 17 passes. Four Node files took 255.66 s on main and 143.17 s on the head; the pinned-Bun file took 144.13 s and 50.37 s, including native worker preparation.

Fresh P2 review of the unchanged commit is scoped-clean. Original focused types/lint/test proof remains valid. No source changes, additional push or CI rerun were made for these five inherited failures. CI remains red; other failed jobs are outside this five-job attribution.

Reopen cold state handles after an observed schema-owner handoff so a
newer schema is refused before the first write callback. Keep warm
schema admission cached as intended by #175077.

Retain exact execute-refusal provenance through worker retirement and
deliver the original host lifecycle error. Preserve shared preparation
from #175008, native-exit joining and unknown execute settlement.

Exercise registry error handling with a custom store that requires the
registry after #175129. Keep every existing assertion.

Before: three deterministic main failures,35passes,128.76s wall.
After: all38tests pass,211.93s wall including worker rebuild; files took
92.46s/54.14s/49.98s through native --maxWorkers=1 wrapper.
Targeted types/lint/format pass; P2 review scoped-clean.
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

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

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 17, 2026 07:29
@chatgpt-codex-connector

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

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T07:32:07.825347Z 6fa2a3a Draft marked ready
ℹ️ About Codex in GitHub

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

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

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Oct 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR refreshes cold schema admission after an ownership handoff and preserves original worker disposal refusals.

Example: Another schema owner changes a database to user_version 999999 between cold opening and the first write.

  • Before: The write callback can run using the previously admitted schema.
  • After: The handle reopens through ordinary admission and rejects the newer schema before the callback runs.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The narrow repair has meaningful owner-level regression evidence and no code findings, but one PostgreSQL failure remains unattributed.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate does not apply to this maintainer-authored PR; its body reports before/after owner regressions and sibling coverage.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A cold write can accept a database upgraded during admission, and interrupted session preparation can obscure the original disposal refusal.
Reason: The maintainer-authored repair restores documented admission behavior while respecting the accepted warm-cache and shared-preparation decisions.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this maintainer-authored PR narrowly repairs evidenced admission failures still present on main, with no actionable code findings.

Priority: P2
Reviewed head: 6fa2a3a05cbcff390b6c917ff58e051e34fbe02f

Before merge

  • Complete next step - Classify the unexpected rhododendron-map.md result in PostgreSQL conformance job 117342087283 against base evidence, and repair it if the diff causes it.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence exercises real database and worker owners in tests, without a shipped CLI or Gateway demonstration of the changed scenarios.
Agent review details

How this fits together

Shared-state transactions and session preparation use database admission and SQLite workers; callers receive committed results or lifecycle errors after native settlement.

flowchart TD
  A[State or session operation] --> B[Database admission]
  B --> C[Schema owner handoff]
  C --> D[Reopen and validate]
  B --> E[SQLite worker]
  E --> F[Broker retirement and settlement]
  D --> G[Result or original refusal]
  F --> G
Loading

Technical review

Best possible solution:

Preserve first-admission schema validation and original lifecycle refusals through the existing database and worker owners.

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

Existing regressions exercise a future-schema handoff and disposal during deferred session preparation, and scheduled main independently fails those cases; no tests were run during this read-only review.

Is this the best way to solve the issue?

The patch repairs the existing admission boundaries without restoring intentional warm revalidation, duplicating lifecycle ownership, or weakening native settlement.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Cold state admission keeps the original intent (8b16e53: Use SQLite transaction exclusion while retaining bounded cold-admission waiting and preventing replay after callback entry.)
  • Worker refusal and retirement keeps the original intent (d22782a: Share physical worker lifetime while retaining committed outcomes and native cleanup custody; later reply-recovery work preserves original admission errors.)
  • Registry warning fixture keeps the original intent (7e48efb: Prepare session facts asynchronously while preserving visible resolver failures; canonical stores subsequently stopped requiring registry reads.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +9, Tests 0. Total +9 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 14 5 +9
Tests 1 2 2 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 16 7 +9

Review metrics

Metric Value Why it matters
Production versus test LOC Production +14/-5; tests +2/-2 The small production increase refreshes cold admission through existing owners; the fixture change retains every assertion.

Labels

Label changes:

  • add P2: Repairs a bounded cold schema-handoff failure and incorrect disposal error propagation, with direct source and main-CI evidence.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Repairs a bounded cold schema-handoff failure and incorrect disposal error propagation, with direct source and main-CI evidence.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

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

Reviewed October 17, 2026, 3:46 AM ET / 07:46 UTC.

@steipete
steipete merged commit e877929 into main Oct 17, 2026
249 of 259 checks passed
@steipete
steipete deleted the fix/state-admission-cluster-20261017 branch October 17, 2026 08:12
steipete added a commit that referenced this pull request Oct 17, 2026
Require one current follower for shared integrity/schema effects. Settle request-owned native opening before a healthy successor reuses or replaces the generation; keep the full shared preparation joinable.

Both hourly 39010956087 regressions came from #175008. Preserve the existing reclamation assertions while checking the missing index before incidental worker termination. Initial native admission and first-use creation retain original caller authority.

Focused six-file proof plus final three-case integration cover 74 distinct passing cases; the existing Linux-only killed-owner case remains for CI. Targeted types, type-aware lint, docs, formatting and P2 review pass. Integrates with prerequisite #175295, which owns refusal propagation; no duplicate broker or worker changes.
steipete added a commit that referenced this pull request Oct 17, 2026
Require one current follower for shared integrity/schema effects. Settle request-owned native opening before a healthy successor reuses or replaces the generation; keep the full shared preparation joinable.

Both hourly 39010956087 regressions came from #175008. Preserve the existing reclamation assertions while checking the missing index before incidental worker termination. Initial native admission and first-use creation retain original caller authority.

Focused six-file proof plus final three-case integration cover 74 distinct passing cases; the existing Linux-only killed-owner case remains for CI. Targeted types, type-aware lint, docs, formatting and P2 review pass. Integrates with prerequisite #175295, which owns refusal propagation; no duplicate broker or worker changes.
steipete added a commit that referenced this pull request Oct 17, 2026
The fault worker delegated iteration with yield*, which does not close the
native iterator when next() throws. Its completed wrapper then hid the
native return() from Kysely cleanup. On Node 24.19 the cached statement
reported the old injected error on its next use after faults were disabled.

Explicitly close the native iterator before restoring the TEMP triggers.
Production queue and database behavior is unchanged. Preserve every
committed-prefix, pending-input and exactly-once assertion.

The scalar INSERT ... RETURNING path added by #175193 exposed this latent
fixture defect. #174897 did not remove a required predecessor, and #175295
is not the cause. Reproduced the same failure on hourly ab37bc6 and
current main 9c12710 using CI's Node 24.19.0; Node 24.22 used all()
and passed without the change.

Focused full-file proof: 5/5 pass in normal order with --maxWorkers=1,
28.45 s Vitest / 49.62 s command wall. Independent P2 review is clean.
All 22 affected consumer files pass: 337 tests using Node 24.19 and
--maxWorkers=1. The other 21 files take 509.14 s wall across five native
configs. Owning test-helper types, boundary lint, syntax, formatting and
whitespace checks pass. Root-test type-aware lint reports the same
pre-existing no-map-spread violation at this file's unchanged line 22 on
both base and candidate; no new diagnostic or suppression is introduced.
No CI dispatch or rerun.
steipete added a commit that referenced this pull request Oct 17, 2026
…e preparation (#175307)

* fix(state): retain caller authority during shared database preparation

Require one current follower for shared integrity/schema effects. Settle request-owned native opening before a healthy successor reuses or replaces the generation; keep the full shared preparation joinable.

Both hourly 39010956087 regressions came from #175008. Preserve the existing reclamation assertions while checking the missing index before incidental worker termination. Initial native admission and first-use creation retain original caller authority.

Focused six-file proof plus final three-case integration cover 74 distinct passing cases; the existing Linux-only killed-owner case remains for CI. Targeted types, type-aware lint, docs, formatting and P2 review pass. Integrates with prerequisite #175295, which owns refusal propagation; no duplicate broker or worker changes.

* fix(state): preserve borrowers after known promotion refusals

Capture shared promotion admission as well as initial native admission, preserving logical borrowers only for known, uncommitted refusals. Protocol faults, unknown outcomes and cleanup failures retain their terminal handling.

The new retained-borrower regression failed before this correction and passes with it. Also seed transcript data in the reclamation concurrency fixture: #175091 intentionally avoids reclamation workers for eventless deletes. Keep all original assertions and deadlines.

Rebased focused proof covers 75 cases including both hourly 39013936147 reds; all 8 final error-path cases pass. Targeted types, lint, format, docs and independent P2 review pass.

* test(state): complete idle generation fixture contract

Return no pending native open from the timer-only generation stub, matching
the required contract introduced by #175307. The production factory already
supplies this method; wrappers retain the real generation. Keep every idle
expiry, reborrow, creation, alias, cleanup and restart assertion unchanged.

Before: four idle lifecycle cases fail with getPendingNativeOpen missing,
and the state-logging test graph reports TS2345.
After: all eight openclaw-agent-execution test files pass (91 tests, one
existing Linux-only skip; 125.20 seconds including worker preparation).
State-logging test types, targeted lint, formatting and P2 review pass.

* test(state): follow physical admission in refusal fixture

Main b499c60 moved existing-file opening off caller admission. Observe
the real physical open so the refusal fixture still starts concurrent
survivor reads, and remove its obsolete caller callback. Keep all refusal,
liveness, exact-result and cleanup assertions. Clarify the shared native
opening wording after integrating the peer cancellation fix.

The requested ten-file proof passed 99 cases and exposed this stale trigger.
The corrected close-wedge file passes all 7 cases (17.37 seconds), bringing
combined coverage to 100 distinct passes and one existing Linux-only skip.
Gateway reclamation is 2/2; reply admission, state-logging types, targeted
lint and formatting pass. No CI reruns.

Independent P2 review is scoped-clean for the rebased candidate and this fixture follow-up.
steipete added a commit that referenced this pull request Oct 17, 2026
Existing-only opens validate the immutable anchor without BEGIN IMMEDIATE. Creation retains its transaction and all identity, schema, and admission refusals remain.

A real two-handle cold-admission regression fails before the fix even with #175295 reversed. Native PostgreSQL schema and Gateway tests pass 18/18 on the refreshed base (187.50s command wall; regression 344ms), plus retained opener proof 4/4. Targeted types, core/boundary lint, format, and P2 review pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…nclaw#175295)

Reopen cold state handles after an observed schema-owner handoff so a
newer schema is refused before the first write callback. Keep warm
schema admission cached as intended by openclaw#175077.

Retain exact execute-refusal provenance through worker retirement and
deliver the original host lifecycle error. Preserve shared preparation
from openclaw#175008, native-exit joining and unknown execute settlement.

Exercise registry error handling with a custom store that requires the
registry after openclaw#175129. Keep every existing assertion.

Before: three deterministic main failures,35passes,128.76s wall.
After: all38tests pass,211.93s wall including worker rebuild; files took
92.46s/54.14s/49.98s through native --maxWorkers=1 wrapper.
Targeted types/lint/format pass; P2 review scoped-clean.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
The fault worker delegated iteration with yield*, which does not close the
native iterator when next() throws. Its completed wrapper then hid the
native return() from Kysely cleanup. On Node 24.19 the cached statement
reported the old injected error on its next use after faults were disabled.

Explicitly close the native iterator before restoring the TEMP triggers.
Production queue and database behavior is unchanged. Preserve every
committed-prefix, pending-input and exactly-once assertion.

The scalar INSERT ... RETURNING path added by openclaw#175193 exposed this latent
fixture defect. openclaw#174897 did not remove a required predecessor, and openclaw#175295
is not the cause. Reproduced the same failure on hourly ea5c031 and
current main 6b9b192 using CI's Node 24.19.0; Node 24.22 used all()
and passed without the change.

Focused full-file proof: 5/5 pass in normal order with --maxWorkers=1,
28.45 s Vitest / 49.62 s command wall. Independent P2 review is clean.
All 22 affected consumer files pass: 337 tests using Node 24.19 and
--maxWorkers=1. The other 21 files take 509.14 s wall across five native
configs. Owning test-helper types, boundary lint, syntax, formatting and
whitespace checks pass. Root-test type-aware lint reports the same
pre-existing no-map-spread violation at this file's unchanged line 22 on
both base and candidate; no new diagnostic or suppression is introduced.
No CI dispatch or rerun.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…e preparation (openclaw#175307)

* fix(state): retain caller authority during shared database preparation

Require one current follower for shared integrity/schema effects. Settle request-owned native opening before a healthy successor reuses or replaces the generation; keep the full shared preparation joinable.

Both hourly 39010956087 regressions came from openclaw#175008. Preserve the existing reclamation assertions while checking the missing index before incidental worker termination. Initial native admission and first-use creation retain original caller authority.

Focused six-file proof plus final three-case integration cover 74 distinct passing cases; the existing Linux-only killed-owner case remains for CI. Targeted types, type-aware lint, docs, formatting and P2 review pass. Integrates with prerequisite openclaw#175295, which owns refusal propagation; no duplicate broker or worker changes.

* fix(state): preserve borrowers after known promotion refusals

Capture shared promotion admission as well as initial native admission, preserving logical borrowers only for known, uncommitted refusals. Protocol faults, unknown outcomes and cleanup failures retain their terminal handling.

The new retained-borrower regression failed before this correction and passes with it. Also seed transcript data in the reclamation concurrency fixture: openclaw#175091 intentionally avoids reclamation workers for eventless deletes. Keep all original assertions and deadlines.

Rebased focused proof covers 75 cases including both hourly 39013936147 reds; all 8 final error-path cases pass. Targeted types, lint, format, docs and independent P2 review pass.

* test(state): complete idle generation fixture contract

Return no pending native open from the timer-only generation stub, matching
the required contract introduced by openclaw#175307. The production factory already
supplies this method; wrappers retain the real generation. Keep every idle
expiry, reborrow, creation, alias, cleanup and restart assertion unchanged.

Before: four idle lifecycle cases fail with getPendingNativeOpen missing,
and the state-logging test graph reports TS2345.
After: all eight openclaw-agent-execution test files pass (91 tests, one
existing Linux-only skip; 125.20 seconds including worker preparation).
State-logging test types, targeted lint, formatting and P2 review pass.

* test(state): follow physical admission in refusal fixture

Main 0f21575 moved existing-file opening off caller admission. Observe
the real physical open so the refusal fixture still starts concurrent
survivor reads, and remove its obsolete caller callback. Keep all refusal,
liveness, exact-result and cleanup assertions. Clarify the shared native
opening wording after integrating the peer cancellation fix.

The requested ten-file proof passed 99 cases and exposed this stale trigger.
The corrected close-wedge file passes all 7 cases (17.37 seconds), bringing
combined coverage to 100 distinct passes and one existing Linux-only skip.
Gateway reclamation is 2/2; reply admission, state-logging types, targeted
lint and formatting pass. No CI reruns.

Independent P2 review is scoped-clean for the rebased candidate and this fixture follow-up.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…175389)

Existing-only opens validate the immutable anchor without BEGIN IMMEDIATE. Creation retains its transaction and all identity, schema, and admission refusals remain.

A real two-handle cold-admission regression fails before the fix even with openclaw#175295 reversed. Native PostgreSQL schema and Gateway tests pass 18/18 on the refreshed base (187.50s command wall; regression 344ms), plus retained opener proof 4/4. Targeted types, core/boundary lint, format, and P2 review pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. gateway Gateway runtime size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant