Repository navigation
fix: preserve database admission for post-restart turns - #166867
Conversation
Extend the checked TEMP tracking owner introduced in #166698 to the fixed transcript-index status table, pending queue, index and enqueue triggers. Installing these connection-local objects must not revoke the agent database's main-schema admission receipt. Ordinary DDL, unexpected object shapes, reentrant mutations and partial installation failures still revoke it. Move the existing SQL into the typed builder and migrate both tracking callers to its shared operation. Preserve local read revisions, rollback staging and INSERT OR REPLACE behavior. No persisted schema, stored bytes, migration, public SDK contract, retry or timeout changes. The existing status-owner regression fails on the parent at first tracker installation. All six owner cases pass after the repair (1.78s invocation), including drift, rollback, foreign writes and bounded cleanup. P2 review is clean. The broader restart investigation and Linux gates remain recorded in the task evidence; this commit alone is not a claim that the QA race is fixed.
A startup reader can publish canonical proof before native admission starts. A concurrent fully checked host open then registered the same database by revoking that proof, rejecting the pending native receipt and failing the post-restart turn before a provider request could begin. Publish the checked opener's registration through the validation owner and promote live proof without retiring its pending handoff. Keep physical-file replacement and explicit lifecycle revocation strict. Reject stale required schema receipts before they can replace newer facts, and retain the shared schema revocation cell for matching live schemas. Accepted schema changes and schema-optional revocation reports retire the displaced borrowers. Regressions cover canonical and empty promotion, physical replacement, revocation, delayed publication, and borrowed-schema retirement. All 36 receipt-owner cases pass (30.60s Vitest, 34.03s wrapper); the corresponding negative controls failed before their repairs. P2 review is clean. Linux pressure, owner-suite, and static gates are tracked separately before landing. No stored data, schema version, public SDK, retry, or timeout changes.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. Reviewed October 7, 2026, 9:33 PM ET / October 8, 2026, 01:33 UTC. ClawSweeper reviewWhat this changesThe branch preserves database admission during transcript tracker installation and concurrent successful database opens. Example: A user starts a subagent turn after a Gateway restart
Warning SQLite table change This PR modifies persisted SQLite tables in Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 3 items remain This PR addresses a demonstrated restart failure, but its receipt acceptance path introduces a blocking schema-revocation gap. Priority: P1 Before merge
Findings
Tests
Agent review detailsHow this fits togetherOpenClaw validates each agent’s SQLite database before processing turns. Shared admission receipts let host and worker connections reuse those checks, while revocation tells them when validation must run again. flowchart TD
A[Post-restart turn] --> B[Host and worker database opens]
B --> C[Database validation owner]
C --> D[Shared admission receipts]
D --> E[Schema change or lifecycle revocation]
E --> F[Readmission before subsequent work]
D --> G[Agent turn processing]
Technical reviewBest possible solution: Keep successful admission promotion, but ensure every accepted host and worker receipt participates in the same revocation lifecycle before subsequent database work. Do we have a high-confidence way to reproduce the issue? Yes: the supplied Linux restart scenario establishes the original failure, and source establishes the introduced independent-cell revocation failure. This read-only review executed neither scenario. Is this the best way to solve the issue? No: extending the existing admission owners is appropriate, but accepting equal schema markers does not establish shared revocation between independently opened connections. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c2827be879b9. Provenance checked
TestingProof path: shipped entry point. Added test files: 2. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +120, Tests +140, Docs +8. Total +268 across 10 files. View PR surface stats
Stored data modelPersistent data-model change detected: LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment |
|
Merged at the pinned head 5b0a3c1 despite one red check, because that red is inherited from main and unrelated to this change.
The change fixes a production admission race: a concurrent checked database open revoked a healthy pending receipt, and transcript TEMP setup invalidated admission. Together these could drop the first post-restart reply before model dispatch. |
) * fix(sqlite): preserve admission during transcript tracker setup Extend the checked TEMP tracking owner introduced in openclaw#166698 to the fixed transcript-index status table, pending queue, index and enqueue triggers. Installing these connection-local objects must not revoke the agent database's main-schema admission receipt. Ordinary DDL, unexpected object shapes, reentrant mutations and partial installation failures still revoke it. Move the existing SQL into the typed builder and migrate both tracking callers to its shared operation. Preserve local read revisions, rollback staging and INSERT OR REPLACE behavior. No persisted schema, stored bytes, migration, public SDK contract, retry or timeout changes. The existing status-owner regression fails on the parent at first tracker installation. All six owner cases pass after the repair (1.78s invocation), including drift, rollback, foreign writes and bounded cleanup. P2 review is clean. The broader restart investigation and Linux gates remain recorded in the task evidence; this commit alone is not a claim that the QA race is fixed. * fix(state): retain valid admission across concurrent opens A startup reader can publish canonical proof before native admission starts. A concurrent fully checked host open then registered the same database by revoking that proof, rejecting the pending native receipt and failing the post-restart turn before a provider request could begin. Publish the checked opener's registration through the validation owner and promote live proof without retiring its pending handoff. Keep physical-file replacement and explicit lifecycle revocation strict. Reject stale required schema receipts before they can replace newer facts, and retain the shared schema revocation cell for matching live schemas. Accepted schema changes and schema-optional revocation reports retire the displaced borrowers. Regressions cover canonical and empty promotion, physical replacement, revocation, delayed publication, and borrowed-schema retirement. All 36 receipt-owner cases pass (30.60s Vitest, 34.03s wrapper); the corresponding negative controls failed before their repairs. P2 review is clean. Linux pressure, owner-suite, and static gates are tracked separately before landing. No stored data, schema version, public SDK, retry, or timeout changes.
What Problem This Solves
Fixes intermittent first-turn failures after a Gateway restart when concurrent opens revoke otherwise valid agent-database admission. QA Smoke's
subagent-completion-direct-fallbackscenario then waits for a reply that never starts.User Impact
A healthy database remains admitted while startup readers and the checked host opener converge on the same physical store. In the captured failure, the post-restart turn failed before provider dispatch; all five earlier child replies had already been delivered. This is an availability defect, not demonstrated loss of a completed reply.
No persisted schema, stored bytes, migration, public SDK contract, retry, or timeout changes. Replacement, explicit revocation, schema drift, and failed installation still invalidate admission.
Why This Change Was Made
Two owners incorrectly treated successful local setup as revocation. Extend the checked TEMP installer from #166698 to the existing transcript-index tracking objects, then promote a live canonical-only validation entry when the full opener completes. Preserve matching live shared-schema revocation cells so delayed healthy receipts do not detach existing borrowers; reject stale required-schema receipts before mutating the cache.
The trace records a pending native receipt with valid integrity and schema bits being refused solely because a concurrent checked host open replaced the captured cache entry. The fix keeps that entry alive while retaining physical-file and lifecycle fences.
Evidence
The broad Linux proof used base
06a1b56f5c9bplus the exact candidate. Rebase ontob27f3f32eb9dpreserves the authored implementation; the additional owner-file run checks its integration with upstream schema-marker reuse. Completed predecessor proof is not represented as an exact-head whole-suite run.Direct-push proof remains incomplete. Native Testbox timed out after 15 minutes; AWS fallback supplied the results above, but the whole infra run reached its lease cap before a terminal summary. This PR uses the authorized fallback; it has not been directly landed or armed for auto-merge.
Broader failures and remaining uncertainty
check-changedand full Knip report the inherited unusedreadRecommendedModelsexport. The remaining static commands passed independently./tmpis below the worktree reserve; focused disk-backed comparisons also found auth logout at 1,040 ms against 1,000 ms and a forced-abandonment authorization wait failure. A matched diagnostic reproduces forced abandonment on both untouched base and candidate under identical CPU pressure: the first cold read remains pending until teardown at 1,046/1,053 ms, before any drain operation runs. Both unloaded controls close authorization at approximately 611 ms. Plugin/config lease contention also reproduces on base, but the full failure mix is not conclusively attributed.killedstatus independently reproduce on untouched base: the same 20 failures. Two files fail because the required sandbox Docker image is absent. Ten failing files remain unclassified, including runtime-artifact publication refusals, recovery authority, and timing.No assertions, retries, timeout budgets, suppressions, inventories, dependencies, or unrelated product paths were changed to conceal these results.