Repository navigation
fix(doctor): PostgreSQL maintenance custody - #173683
Conversation
Inspect PostgreSQL Gateway leases through admitted state readers and preserve case-sensitive lease aliases. Keep SQLite maintenance snapshots and statements unchanged. Data-only migrations retain existing writer advisory transactions; schema migrations report the missing PostgreSQL state-family backup support.
|
🦞👀 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: 90c825a832
ℹ️ 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".
| try { | ||
| authority.assertCurrent(); | ||
| if (schemaMaintenance) { | ||
| if (schemaMaintenance && !isStatePostgres()) { |
There was a problem hiding this comment.
Hold PostgreSQL maintenance custody across the workflow
When Doctor uses anchor A and a Gateway starts afterward through anchor B for the same PostgreSQL store, this branch has performed only a point-in-time lease inspection and publishes no PostgreSQL-visible maintenance ownership. The Gateway can therefore acquire its own lease while Doctor remains active; the per-transaction advisory lock only serializes individual writes, allowing the Gateway to observe or interleave intermediate migration state. The new conformance test covers only Gateway-before-Doctor, so PostgreSQL custody needs to remain visible until maintenance releases it.
AGENTS.md reference: AGENTS.md:L70-L70
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. What this changesThis PR enables PostgreSQL maintenance lease inspection, preserves lease aliases, and explicitly refuses unsupported schema backups. Example: Doctor inspects a PostgreSQL store containing a Gateway lease on port 19483.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 4 items remain Keep open: this maintainer-authored PR addresses a real PostgreSQL limitation, but maintenance custody does not exclude a later Gateway using another anchor. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherDoctor acquires lifecycle custody before migrations; worker lease inspection reads the selected state engine and determines whether maintenance may proceed. flowchart TD
Doctor[Doctor migrations] --> Custody[Lifecycle custody owner]
Custody --> Anchor[Anchor-local ownership lock]
Custody --> Reader[State lease read worker]
Reader --> Postgres[PostgreSQL shared state]
Gateway[Gateway through another anchor] --> Postgres
Doctor --> Writer[State write transactions]
Writer --> Postgres
Technical reviewBest possible solution: Extend the existing custody owner to exclude all anchors for the PostgreSQL store throughout maintenance while retaining SQLite behavior and unsupported-backup refusal. Do we have a high-confidence way to reproduce the issue? Source establishes the failure sequence: Doctor acquires anchor A, then a Gateway using anchor B sees no maintenance lease and can acquire the same PostgreSQL store; no target code was executed. Is this the best way to solve the issue? The admitted-reader and typed-alias changes fit the existing owners, but enabling maintenance requires store-wide exclusion beyond individual write transactions. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cf7311c10482. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +27, Tests +264, Docs +8. Total +299 across 8 files. Added test files: 1. View PR surface stats
Review metrics
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, 11:18 PM ET / October 16, 2026, 03:18 UTC. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Inspect PostgreSQL Gateway leases through admitted state readers and preserve case-sensitive lease aliases. Keep SQLite maintenance snapshots and statements unchanged. Data-only migrations retain existing writer advisory transactions; schema migrations report the missing PostgreSQL state-family backup support.
What Problem This Solves
Doctor cannot acquire maintenance custody on PostgreSQL shared state because lease inspection takes a SQLite repair snapshot and rejects the PostgreSQL reader. Populated PostgreSQL leases also lose their camel-case column aliases, preventing owner identity decoding.
User Impact
Doctor can acquire and release offline PostgreSQL custody and run data-only legacy state migrations. A live Gateway still blocks maintenance, including through another anchor for the same PostgreSQL store.
Schema migrations remain blocked with an actionable error until their state-family backup path is available. The remaining work is tracked separately: the PG schema-migration end-to-end proof follows R13 (state family registration).
Why This Change Was Made
Reuse the admitted PostgreSQL state reader and existing owner-lease checks, with typed PostgreSQL lease selection. Keep SQLite's private snapshot and damaged-index-safe query byte-for-byte. Writes retain the existing PostgreSQL advisory transaction lock; no new lock protocol or shared-admission revision changes.
The schema runner is unchanged. Its backup dependency now reports the missing PostgreSQL state-family support and directs the operator to keep the database and retry with a supporting version.
Evidence
config-machine-stateno-op step runs through the migration runner, followed by a synthetic committed state write. Custody releases/reacquires; a real Gateway lease blocks a second anchor; schema backup refusal names the next step.NOT INDEXEDlease scan.ui/src/pages/chat/components/chat-message.test.tswhile the unchanged file is now.tsx; Knip reports the unchanged, unusedui/src/components/loading-skeleton.ts. No UI files or baseline exceptions are changed here.Conformance timing: 25.79 seconds in Vitest (about 2 seconds executing the four cases); 128 seconds for the wrapper including cold worker compilation. The initial live-lease test exposed PostgreSQL alias folding and passed after the typed-query fix. A first SQLite backup test attempt was rejected because source changed during worker compilation; the final frozen-source rerun passed.
Draft CI observation for
90c825a832ac5117536859cd217e971987198269: all 12 checks that ran passed (including TypeScript contracts, Rust workspace, actionlint, PR context/evidence, and Socket). Full CI andopenclaw/ci-gatewere skipped while the PR was draft; this is not full-CI proof.Landing validation
Final-head CI: run 38843454803, attempt 1, head
90c825a832ac5117536859cd217e971987198269. PostgreSQL conformance passed, including all four maintenance-custody cases; all typechecks, baseline ratchets, and the other selected test jobs passed. No failed/cancelled-job rerun or fix push was needed.The native admin exception is limited to this unrelated failure and its downstream aggregate:
checks-node-changed-compact-large-18-2:src/state/openclaw-agent-db.test.ts/serializes concurrent ownership claims for one unowned databasesrc/state/openclaw-agent-db-schema.ts, are unchanged; the case invokesensureOpenClawAgentDatabaseSchemaon SQLite and does not call the changed PostgreSQL maintenance-custody path. The failed job's executed test-file set is disjoint from this PR's changed files.openclaw/ci-gatesecurity-fastpassed independently.The earlier local UI gate failures are also present on main and remain outside this PR: Knip reports unused
ui/src/components/loading-skeleton.tsin scheduled main run 38841437948; main6ce4fb7f39ca751db358b0da9f50f7552b0e8ef3retainsui/src/pages/chat/components/chat-message.test.tsinconfig/max-lines-baseline.txtwhile the actual file is.tsx. Neither UI file nor the baseline is changed here. The final-head CI baseline-ratchet job passed.