Repository navigation
fix(sessions): await agent schema preparation before discovery - #173196
Conversation
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bd8d8c2e4b
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (const physicalPath of admissionPaths) { | ||
| const preparation = getPendingOpenClawAgentDatabasePreparation(physicalPath); | ||
| if (preparation) { | ||
| await racePromiseWithAbortSignal(preparation, signal, (aborted) => aborted.reason); |
There was a problem hiding this comment.
Recheck all candidates after preparation waits
When discovery has multiple exact candidates, this loop checks and awaits them sequentially. If candidate A has no preparation when checked, candidate B causes an await, and A's cold preparation admits its empty catalog during that wait, A is never checked again; the subsequent admission turn can then skip A because it appears admitted and dispatch discovery before A's schema DDL commits, reproducing the schema-missing failure. Multi-candidate batches are produced for shared/fixed stores by captureSessionStoreCandidateInventory, so the preparation snapshots should be collected together and all paths rescanned after any await before dispatch.
Useful? React with 👍 / 👎.
|
Codex review: needs changes before merge. What this changesSession discovery waits for active agent database schema preparation before inspecting the catalog. Example: Create agent:firstbirth-new:dashboard:first-birth while its empty database is initializing.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR open: it addresses a current first-session failure through the correct owner, but federated discovery can still bypass pending preparation after awaiting another store. Priority: P1 Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway session requests resolve physical stores through discovery workers; the agent execution owner prepares their SQLite schemas and publishes readiness before readers consume them. flowchart TD
A[Gateway session request] --> B[Capture store candidates]
B --> C[Observe agent preparation]
C --> D[Agent execution owner]
D --> E[SQLite schema preparation]
C --> F[Discovery worker]
F --> G[Resolved session store]
Technical reviewBest possible solution: Join preparation across all captured exact candidates and rescan after waits before discovery dispatch, retaining cancellation and existing unavailable-store handling. Do we have a high-confidence way to reproduce the issue? The reported baseline boot trace and deterministic RPC regression establish the catalog-before-schema failure path; source inspection confirms current main retains it, but this review executed no target code. Is this the best way to solve the issue? Using the existing execution owner is the right repair and preserves lazy stores, but sequential observation must account for preparation that starts on an earlier candidate during another candidate's wait. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 824fde2bfab6. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +49, Tests +217, Docs +6. Total +272 across 8 files. Added test files: 1. View PR surface stats
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 Reviewed October 15, 2026, 10:39 AM ET / 14:39 UTC. |
|
Follow-up from automated review: in multi-candidate discovery, a new cold preparation can start on an already-inspected path while another candidate is awaited. The accepted recoverable outcome is temporary store unavailability for that discovery. This fix joins already-active preparation through its owner; repeated cross-candidate readiness rescans are deferred. The deterministic first-birth regression covers the reported single-agent flow and cancellation of an overlapping preparer. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a88eacd54
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| getPendingPreparation() { | ||
| return generation?.getPendingPreparation(); |
There was a problem hiding this comment.
Track preparation before writer-queue admission
When two cold prepare() calls for the same store originate from independent async contexts, runOpenClawAgentWorkerWrite serializes them in the writer queue, but this getter exposes only the native generation's set, which is populated after a caller reaches current.run. If the active attempt aborts or fails after catalog admission, its deferred resolves before the outer queue admits the next live preparer; a discovery already awaiting that deferred can therefore observe no pending preparation and dispatch against the still-empty catalog, reproducing schema-missing even for a single candidate. Track pending preparation at the file-owner/admission level so queued attempts remain visible.
AGENTS.md reference: AGENTS.md:L7-L8
Useful? React with 👍 / 👎.
…law#173196) Fresh installations could accept a Gateway connection and reject the first explicit-key sessions.create with schema-missing while the agent owner was still creating its schema. Join active first preparation through the existing agent execution owner before inspecting its admitted catalog. Settle preparation before caller dispatch and let discovery cancellation end only its own wait. The deterministic RPC regression fails with the original ordering and passes for both new and interrupted-empty stores. The live authcold-timed baseline failed on boot 5; all 50 candidate boots passed. Baseline and candidate fixture storage differed, so those samples are not a controlled failure-rate estimate. Warm-path SQL and worker requests are unchanged; changed-module T1 remains zero. The separate 300-second startup timeout is not claimed fixed. Final-head CI passed. Detailed proof, inherited static findings, and accepted P2 follow-ups are recorded in the PR.
Fresh installations can accept a signed Gateway connection and then reject the first explicit-key
sessions.createwithSessionStoreUnavailableError(schema-missing). The agent owner has admitted the empty SQLite catalog, but its canonical schema creation is still pending. Session discovery treated that catalog admission as completed preparation.This makes session target discovery join active first preparation through the existing per-agent execution owner before reading the catalog. Preparation settles before caller operations run, so discovery cannot wait on its own operation. Cancellation stops an individual discovery wait without canceling schema creation. Concurrent cold callers retain their own preparation completion until each settles. No retries, timeout increases, new schema, or second admission owner are added. Gateway readiness continues to permit lazy agent stores.
Reproduction and behavior proof
Baseline build:
a46ecb4350fc3230331ec5ac7c1def9ea9ba383a. Initial candidate base:45d8782918d5b458b0dead5820e6efde87687bf0. Integrated main93e4b56350e(including shared-state engine selection) into measured candidate703a6331a89259cb35536701daf42bebb31c4a27without conflicts; the fix and regression test are unchanged. The intervening change in this path adds cancellation forwarding; it leaves the catalog/schema ordering unchanged.Baseline live fixture state was on external storage. Candidate live fixture state is on internal storage following host storage-fault guidance; the before/after samples are not a controlled failure-rate estimate. The deterministic regression isolates the ordering change.
The natural failing boot returned
schema-missing71 ms before schema DDL began and 523 ms before schema transaction commit. Teardown began after the client received the error. The deterministic RPC regression pauses initialization between catalog admission and canonical schema birth, covering both a new database and an interrupted empty file, plus cancellation of a concurrent preparer. It fails with the original ordering and checks the resulting persisted session after release.SQL and thread scope
There is no warmed SQL reduction claim. The new warm-path lookup is an in-process owner lookup. No SQL implementation, schema, boot/service lifecycle, Doctor, update, plugin loading, or public SDK surface changes; no update cell applies.
No paranoid checks are removed in this reliability lane. Accepted edges: a preparation failure remains with its initiating caller and discovery reports normal availability afterward; failed creation is not retried. A genuinely empty database without active preparation retains existing availability handling. P2 follow-ups retained after the two review rounds: preparation starting on an earlier candidate while discovery awaits another can still report temporary unavailability. If an active cold preparation fails or is canceled after catalog admission, discovery can also finish before an independent queued preparer enters the native generation. These recoverable failed/canceled or multi-candidate edges are not the reproduced fresh-boot path; no repeated rescans or broader queue coordination are added.
Validation
Passed: deterministic Gateway RPC regression (both cases, including concurrent cancellation), plus six idle-owner tests; changed-file formatting, type-aware lint, and diff whitespace check; independent Codex review of the fix with no actionable P0–P2 findings, plus a clean P0/P1 review of the test-only CI correction. Runtime build at
703a6331a89passed, including 97 plugins and the CLI import-boundary guard.CI before the static-repair integration passed: 44 successful jobs, 25 skipped. The initial PR run exposed a test-only union-Promise inference error; the correction discards an unused fixture return value without changing completion or error propagation. Integrated-head attempt 1 passed all five test-type graphs, then hit the job deadline in the root-test partition. Rerunning only that cancelled job and its dependent gate passed without a code change.
The fixed 50-boot candidate sample completed with no failures at
703a6331a89. Integrated main's static repair through486f5b5181fbinto final head3a88eacd54c0236ddf17267d17aee6452173a39ewithout changing any firstbirth production or regression file. Final-head CI passed with 46 successful jobs and 25 skipped, including the aggregate gate, types, lint, source contracts, worker/dialect ratchets, PostgreSQL conformance, and Madge (zero cycles).Canonical production/full-tree/script Knip scans completed on Blacksmith Testbox, lease
tbx_01m50eejz48avq4ebknvvzf1hq, after verifying the selected source hashes. Command:node --import ./scripts/tsx.mjs scripts/check-deadcode-exports.mts. Exit 1 contains only these five inherited findings, exactly matching scheduled main at the incorporated base:src/gateway/operator-approval-store.ts: expireDueOperatorApprovals;ui/src/components/scroll-state.ts: scrollState.src/skills/lifecycle/clawhub.test-support.ts: expectInvalidSlug;ui/src/e2e/login-gate-e2e.test-support.ts: mountLoginGate.scripts/watch-pr-ci.mts: classifyAttachedCiRun.No changed file is flagged. The Testbox was granted immediately (requested 16-class, observed four CPUs). Local canonical scans had hit their unchanged 600-second limits; those timeouts are not counted as passes. Node compile cache was disabled for all SSD builds and tests. Host load makes these reliability counts, not latency claims. The separate reported pre-readiness 300-second timeout remains unproven and is not claimed fixed.
LOC: +319 / −45 overall; production net +49, tests net +219, documentation +6. Most of the native-owner diff moves existing preparation into a
try/finallythat publishes completion before operation dispatch.