Skip to content

fix: qualify PostgreSQL majors and repair stable adoption - #178005

Merged
steipete merged 6 commits into
mainfrom
pgprep/pgqual-majors
Oct 20, 2026
Merged

steipete merged 6 commits into
mainfrom
pgprep/pgqual-majors

Conversation

@steipete

@steipete steipete commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes the published-stable SQLite → current → PostgreSQL adoption path, which could duplicate aliased stores, silently omit the port source, reject a valid lazy journal column, or leave local credentials bound to the old database. Qualifies PostgreSQL 16–18 with recorded full conformance runs.

User Impact

Existing 2026.10.5 users can update through their installed updater, port their populated stores to PostgreSQL, and start the Gateway with their agents, sessions, memory, and local credentials intact. The docs state the tested scope: foreground macOS acceptance, no live inference without provider keys, and service activation covered separately by the signed-Mac/Parallels lane. Published 2026.10.5 has no PostgreSQL configuration schema, so a native stable-PG upgrade is not applicable.

Why This Change Was Made

Use physical identity to deduplicate supplemental updater discovery while preserving explicit registry spellings. Take the port's canonical state root from its existing owner. Complete the lazy deletion-journal column only in the private migration copy. Capture credential receipt metadata with the existing port artifacts and rebind it through the credential owner after durable port completion, preserving the local credential rows and provenance. No new schema, migration protocol, or readiness bypass. The simplification pass retained the existing owners and removed duplicate alias discovery. Delta: +249/−29 production lines, +326/−17 test lines, +128/−50 documentation lines.

PostgreSQL 18 rejects malformed JSON before its CHECK constraint in one catalog probe; accept either rejection while retaining strict row-rejection assertions. No CI matrix was added. A weekly sequential PG16/PG18 conformance job is recommended to catch future major-version differences without adding per-PR cost.

Evidence

  • Final-head CI run 39366445588: all three PostgreSQL conformance shards and openclaw/ci-gate passed on 50e01a442f95b9c75baca485e4b352d7b2427079.

  • PGQUAL-MAJORS-UPGRADE, local Homebrew PostgreSQL 16.15_1 / 17.11_1 / 18.6_1, unaccent 1.1, pg_trgm 1.6, pgvector 0.8.7. Full unsharded CI entry point on 16 and 18. Counts, source heads, bottle/source SHA256s, lock sizing, and the retained initial failures are in the qualification record.

  • PG16 full: 948 passed / 2 failed / 37 skipped; the three affected files passed once on PG16 and PG17 (10 tests each). PG18 full: 947 passed / 3 failed / 37 skipped; failed files passed on PG17 (9 tests) and PG18 with port/recovery (43 tests). Further PG18 journal regression: 25/25. Initial timeout/cleanup failures are not represented as clean full runs.

  • Published stable installed-updater run d3b04126-11d3-4f28-9dd0-146f9fe914b5: exited 0 and activated the exact packed build b1d415c2448f. PostgreSQL port aae1aaff-ec7e-4dac-afe6-7b46f8589867: two populated stores, retained SQLite captures, foreground Gateway readiness, agent/session/memory continuity, Doctor/status. Unreachable-DSN Doctor returned exit 2 and ok: false. Matching pre-upgrade backup + exact stable package rollback passed the same continuity checks. Cell table.

  • Regressions reproduced before their fixes. Final PG17 credential/port/recovery/restore run: 46/46. Final PG18 credential/port/recovery run on integrated head 50e01a442f95: 40/40, including all five credential cases. Core and scripts typechecks, targeted infrastructure/updater test typechecks, lint/format, docs checks, and independent P0–P2 review recorded locally. Full test-graph selection encountered pre-existing 725/726-root budgets in unchanged Gateway/plugin shards; all 29 compiler graphs passed, and the targeted graphs passed independently.

Main integration changed only the generated config fingerprint conflict; the runtime patch remained unchanged.

The queued Testbox lease was canceled; no remote workload or local Docker ran. Temporary Gateways use isolated state and foreground processes, with no LaunchAgent or Keychain changes. Local clusters and task-owned large artifacts are cleaned up after validation; installed Homebrew formulas and external-volume worktrees are retained.

@clawsweeper

clawsweeper Bot commented Oct 20, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts commands Command implementations labels Oct 20, 2026
@steipete
steipete force-pushed the pgprep/pgqual-majors branch from c981595 to 50e01a4 Compare October 20, 2026 03:50
@steipete
steipete marked this pull request as ready for review October 20, 2026 03:51
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 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-20T03:56:56.574269Z 50e01a4 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.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 50e01a442f95b9c75baca485e4b352d7b2427079
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/infra/client-credential-restore.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 50e01a442f

ℹ️ 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".

if (!target || !input) {
refuse(ctx, "credential binding without shared target", "captured shared store");
}
rebindPortedClientCredentials({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep startup blocked until credential rebinding is durable

If the process exits after the manifest revision is durably marked complete but before this rebinding commits, assertDatabasePortStartupAllowed permits the next Gateway startup even though the canonical credential receipt still references the pre-port shared-store inode. assertClientCredentialStoreReady then rejects that receipt, leaving local credentials unusable until the operator discovers and manually resumes the port. Keep the manifest startup-blocking until the receipt update is durable, while still preventing rollback once rebinding begins.

AGENTS.md reference: AGENTS.md:L9-L11

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

Repairs stable SQLite-to-PostgreSQL adoption and documents qualification for PostgreSQL 16–18.

Example: An OpenClaw 2026.10.5 installation updates and ports populated stores to PostgreSQL 17.

  • Before: Aliased paths, a lazy journal column, or stale credential bindings can prevent successful adoption.
  • After: Discovery preserves store identities, migration completes the private copy, and port finalization rebinds local credentials.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Detailed upgrade acceptance records and focused production-path regressions support the repair, but interrupted credential finalization still needs correction.
Proof confidence 🐚 platinum hermit (4/6) Maintainer authorship exempts this PR from the ordinary contributor proof gate; the supplied qualification record reports the installed updater, populated PostgreSQL port, Gateway continuity, and matched stable rollback, with live-turn and service limitations explicit.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Existing SQLite users can fail to adopt PostgreSQL while preserving populated stores and usable local credentials.
Reason: The repair serves a documented migration flow, and its direction is already approved through maintainer authorship.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this maintainer-authored PR repairs a concrete PostgreSQL adoption path, but credential finalization leaves an interrupted port incorrectly marked ready for startup.

Priority: P2
Reviewed head: 50e01a442f95b9c75baca485e4b352d7b2427079

Before merge

  • Keep unfinished credential rebinding behind the startup recovery guard (P2) - When the new receipt write fails, or the process exits before it commits, finalize has already durably marked the manifest complete. assertDatabasePortStartupAllowed then permits startup, but credential admission rejects the receipt because it still names the pre-port shared-store inode. The added receipt-failure test constructs this state and resumes it without checking startup first. Keep an active credential-bearing manifest startup-blocking until rebinding finishes, while retaining the completed-state rollback prohibition; requiring successful archival before startup is one small solution using the existing recovery owner.

Findings

  • [P2] Keep unfinished credential rebinding behind the startup recovery guard — src/commands/doctor-database-port-context.ts:254-262

Tests

  • Missing end-to-end proof: The interrupted receipt-write case needs to assert startup remains blocked before resume and becomes admissible after successful recovery.
Agent review details

How this fits together

The installed updater inventories and captures existing databases; the offline port command migrates verified copies, publishes stores and configuration, and updates the local credential receipt used by subsequent client admission.

flowchart TD
  A[Installed updater] --> B[Database inventory and captures]
  B --> C[Offline port owner]
  C --> D[Private migration copy]
  D --> E[Published database stores]
  C --> F[Local credential owner]
  E --> G[Gateway and client startup]
  F --> G
Loading

Technical review

Best possible solution:

Keep credential-bearing port manifests startup-blocking until rebinding and archival finish, while preserving the existing prohibition on rollback after completion.

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

Source and the added failure-injection case establish the trigger: a receipt-write failure leaves a complete manifest and an old shared-file binding; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The alias, canonical-root, private journal migration, and credential-owner changes address the reported causes without parallel ownership; the remaining correction belongs in the existing port startup/recovery contract.

Full review comments:

  • [P2] Keep unfinished credential rebinding behind the startup recovery guard — src/commands/doctor-database-port-context.ts:254-262
    When the new receipt write fails, or the process exits before it commits, finalize has already durably marked the manifest complete. assertDatabasePortStartupAllowed then permits startup, but credential admission rejects the receipt because it still names the pre-port shared-store inode. The added receipt-failure test constructs this state and resumes it without checking startup first. Keep an active credential-bearing manifest startup-blocking until rebinding finishes, while retaining the completed-state rollback prohibition; requiring successful archival before startup is one small solution using the existing recovery owner.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit ec56c59 adds src/infra/client-credential-restore.ts:26 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ec56c5956825; files: src/infra/client-credential-restore.ts)

PR surface

Source +209, Tests +309, Docs +78, Generated 0, Other +11. Total +607 across 15 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 8 235 26 +209
Tests 3 326 17 +309
Docs 2 126 48 +78
Config 0 0 0 0
Generated 1 2 2 0
Other 1 14 3 +11
Total 15 703 96 +607

Labels

Label changes:

  • add P2: A focused adoption repair with a recoverable interrupted-finalization defect in an advanced database administration flow.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit 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: A focused adoption repair with a recoverable interrupted-finalization defect in an advanced database administration flow.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit 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 20, 2026, 12:08 AM ET / 04:08 UTC.

@steipete
steipete merged commit 63b8eec into main Oct 20, 2026
253 of 254 checks passed
@steipete
steipete deleted the pgprep/pgqual-majors branch October 20, 2026 04:15
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
…78005)

## What Problem This Solves

Fixes the published-stable SQLite → current → PostgreSQL adoption path, which could duplicate aliased stores, silently omit the port source, reject a valid lazy journal column, or leave local credentials bound to the old database. Qualifies PostgreSQL 16–18 with recorded full conformance runs.

## User Impact

Existing 2026.10.5 users can update through their installed updater, port their populated stores to PostgreSQL, and start the Gateway with their agents, sessions, memory, and local credentials intact. The docs state the tested scope: foreground macOS acceptance, no live inference without provider keys, and service activation covered separately by the signed-Mac/Parallels lane. Published 2026.10.5 has no PostgreSQL configuration schema, so a native stable-PG upgrade is not applicable.

## Why This Change Was Made

Use physical identity to deduplicate supplemental updater discovery while preserving explicit registry spellings. Take the port's canonical state root from its existing owner. Complete the lazy deletion-journal column only in the private migration copy. Capture credential receipt metadata with the existing port artifacts and rebind it through the credential owner after durable port completion, preserving the local credential rows and provenance. No new schema, migration protocol, or readiness bypass. The simplification pass retained the existing owners and removed duplicate alias discovery. Delta: +249/−29 production lines, +326/−17 test lines, +128/−50 documentation lines.

PostgreSQL 18 rejects malformed JSON before its CHECK constraint in one catalog probe; accept either rejection while retaining strict row-rejection assertions. No CI matrix was added. A weekly sequential PG16/PG18 conformance job is recommended to catch future major-version differences without adding per-PR cost.

## Evidence

- Final-head [CI run 39366445588](https://github.com/openclaw/openclaw/actions/runs/39366445588): all three PostgreSQL conformance shards and `openclaw/ci-gate` passed on `50e01a442f95b9c75baca485e4b352d7b2427079`.

- `PGQUAL-MAJORS-UPGRADE`, local Homebrew PostgreSQL 16.15_1 / 17.11_1 / 18.6_1, unaccent 1.1, pg_trgm 1.6, pgvector 0.8.7. Full unsharded CI entry point on 16 and 18. Counts, source heads, bottle/source SHA256s, lock sizing, and the retained initial failures are in [the qualification record](docs/gateway/postgresql.md#server-major-qualification).
- PG16 full: 948 passed / 2 failed / 37 skipped; the three affected files passed once on PG16 and PG17 (10 tests each). PG18 full: 947 passed / 3 failed / 37 skipped; failed files passed on PG17 (9 tests) and PG18 with port/recovery (43 tests). Further PG18 journal regression: 25/25. Initial timeout/cleanup failures are not represented as clean full runs.
- Published stable installed-updater run `d3b04126-11d3-4f28-9dd0-146f9fe914b5`: exited 0 and activated the exact packed build `b1d415c2448f`. PostgreSQL port `aae1aaff-ec7e-4dac-afe6-7b46f8589867`: two populated stores, retained SQLite captures, foreground Gateway readiness, agent/session/memory continuity, Doctor/status. Unreachable-DSN Doctor returned exit 2 and `ok: false`. Matching pre-upgrade backup + exact stable package rollback passed the same continuity checks. [Cell table](docs/gateway/postgresql.md#published-stable-upgrade-qualification).
- Regressions reproduced before their fixes. Final PG17 credential/port/recovery/restore run: 46/46. Final PG18 credential/port/recovery run on integrated head `50e01a442f95`: 40/40, including all five credential cases. Core and scripts typechecks, targeted infrastructure/updater test typechecks, lint/format, docs checks, and independent P0–P2 review recorded locally. Full test-graph selection encountered pre-existing 725/726-root budgets in unchanged Gateway/plugin shards; all 29 compiler graphs passed, and the targeted graphs passed independently.

Main integration changed only the generated config fingerprint conflict; the runtime patch remained unchanged.

The queued Testbox lease was canceled; no remote workload or local Docker ran. Temporary Gateways use isolated state and foreground processes, with no LaunchAgent or Keychain changes. Local clusters and task-owned large artifacts are cleaned up after validation; installed Homebrew formulas and external-volume worktrees are retained.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts security-sensitive-changed size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant