Repository navigation
fix: preserve agent database ownership during concurrent initialization - #174251
Conversation
Read the authoritative owner, schema version and migration state inside the schema write transaction instead of retaining observations made before BEGIN. Invalidate only schema facts so physical integrity proof and clean-close seals remain available. No schema or storage-format changes. The deterministic native-handle regression fails on main in 3/3 CPU-pressure runs; focused ownership, migration, deletion and seal suites pass 113 tests. Core/test types, targeted lint/format and independent P2 review pass.
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR reads agent ownership, schema version, and migration eligibility after acquiring the database write lock. Example: worker-b initializes shared.sqlite while worker-a is preparing its first claim.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR repairs a concrete ownership regression still present on current main; no introduced correctness defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherAgent database admission accepts a SQLite connection and agent identity, validates ownership and migration eligibility, then initializes or upgrades the store and registers its owner. flowchart TD
A[Agent database opener] --> B[Integrity admission]
B --> C[Acquire write transaction]
C --> D[Read owner and schema]
D --> E[Refuse competing agent]
D --> F[Initialize or migrate]
F --> G[Publish facts and register]
Technical reviewBest possible solution: Retain the existing schema owner and make its ownership and migration decisions from current facts inside the write transaction. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the stale pre-lock observation and subsequent metadata upsert; the added deterministic regression targets that sequence, with baseline failures reported by the author but no execution performed during this review. Is this the best way to solve the issue? The repair addresses the owning invariant with the existing transaction and invalidation mechanisms, preserving migration authority checks and avoiding a parallel ownership protocol. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 88ef99e66fc9. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +2, Tests +44, Docs +2. Total +48 across 3 files. Added test files: 0. 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 16, 2026, 9:40 AM ET / 13:40 UTC. |
|
Merged via squash.
|
…ion (openclaw#174251) Read the authoritative owner, schema version and migration state inside the schema write transaction instead of retaining observations made before BEGIN. Invalidate only schema facts so physical integrity proof and clean-close seals remain available. No schema or storage-format changes. The deterministic native-handle regression fails on main in 3/3 CPU-pressure runs; focused ownership, migration, deletion and seal suites pass 113 tests. Core/test types, targeted lint/format and independent P2 review pass.
…ion (#174251) Read the authoritative owner, schema version and migration state inside the schema write transaction instead of retaining observations made before BEGIN. Invalidate only schema facts so physical integrity proof and clean-close seals remain available. No schema or storage-format changes. The deterministic native-handle regression fails on main in 3/3 CPU-pressure runs; focused ownership, migration, deletion and seal suites pass 113 tests. Core/test types, targeted lint/format and independent P2 review pass. (cherry picked from commit 2ce7c92)
What Problem This Solves
Two concurrent initializers can both report success for one unowned agent database, letting the later initializer replace the first agent's ownership metadata. This fixes the ownership failure in main CI.
User Impact
The first successful claim remains authoritative; a competing agent is refused. Existing schema, migration, deletion-fence, and clean-close guarantees remain intact. No storage format or operator action changes.
Why This Change Was Made
#172373 removed transaction-local checks under the assumption that “synchronous preparation remains under Gateway or exclusive maintenance custody; unsupported writes between preparation and the transaction are not polled for.” The initializer nevertheless accepts competing first claims before either has established ownership. Its saved empty-file observation can outlive a lock wait, and the metadata upsert then overwrites the winner.
Move the existing owner/version/migration decisions into the synchronous schema write transaction. Refresh only schema facts there, preserving the independent physical-integrity proof used by clean-close seals. This adds no retry, timer, or ownership protocol.
Evidence
--maxWorkers=1; one existing platform-specific skip is unchanged. This includes creation/query-count, migration rollback, deletion fencing, and all clean-close/seal cases.88ef99e66fc9when its file runs in order (31 passed, one failed); it observes an internal file-watcher helper as the first spawn. Its isolated case passes. No update-wizard assertion was changed.openclaw/ci-gate; no CI dispatch or rerun was requested.The first local repair invalidated physical-integrity facts too broadly and failed eight existing seal tests. Narrowing invalidation to schema facts fixes those failures; no assertion was changed.