Skip to content

fix(database): Team Reports fails to port to PostgreSQL after a successful dry run - #190124

Merged
VACInc merged 6 commits into
mainfrom
openclaw/pg-team-reports-port-namespace
Nov 18, 2026
Merged

VACInc merged 6 commits into
mainfrom
openclaw/pg-team-reports-port-namespace

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

High Level TLDR

Backups and database port now accept the PostgreSQL schema name that Team Reports already uses. The schema name and its stored data stay in place.

What Problem This Solves

A Team Reports SQLite-to-PostgreSQL dry run can succeed, then the actual port fails before staging. Once Team Reports is on PostgreSQL, archive and Git backup also reject its SQLite anchor.

User Impact

Team Reports can keep its existing PostgreSQL schema when making backups, resuming a port, or porting back to SQLite.

Why This Change Was Made

Root Cause

The namespace builder includes the store ID team-reports in the schema name. PostgreSQL accepts it as a quoted identifier. The anchor and recovery manifest validators excluded its hyphen, and the local-companion backup manifest had the same restriction. PostgreSQL also includes quotes when it deparses these schema references, so the port catalog check removes that quoting when comparing with its reference schema.

The validators retain their original rules for the first character and letter case. The port and backup round trips preserve the name. Original investigation and patch by etzelm.

Evidence

Real behavior proof

On the base, the Team Reports dry run found the store. The real port then failed at Database port capture originals. The local-companion backup case failed with Backup manifest contains an invalid PostgreSQL anchor.

On disposable PostgreSQL 16, the focused round-trip test returned 1 passed. It ran dry run, interrupted publication, resumed against the same quoted schema, and returned to SQLite with the original 64-bit value and unchanged neighboring store.

Reproduce the PostgreSQL proof
node scripts/test-database-conformance.mjs --engine postgres --connection "$TEST_POSTGRES_URL" -- src/infra/database-engine/port-command.mixed.integration.test.ts --maxWorkers=1 -t 'resumes and reverses Team Reports'

Verification

The focused TypeScript, lint, formatting, and whitespace checks passed. Local recovery, update-capture and backup tests passed, including offline verification and restore of an anchor containing a hyphen.

The five local suites passed all 156 tests on PostgreSQL 16.16 with the same database extensions as CI. The earlier local OWNER_UNAVAILABLE failure also reproduced on main. The test database lacked the unaccent extension. After provisioning the test database with the CI extensions, all eight mixed-family port cases passed.

The first CI run caught an older backup test that used a hyphen as its invalid character. The follow-up changes that fixture to a dot. All 12 tests in src/snapshot/database-backup.test.ts passed locally after that change.

What was not tested

The Git backup and Gateway lock recovery call paths were traced to the shared anchor reader. They were not exercised end to end for this change.

roboclaw-bot and others added 3 commits November 1, 2026 06:01
…ssful dry run

Worked on by:
- @etzelm

Co-authored-by: etzelm <[email protected]>
OpenClaw-Publication: 3a013d3e-391a-435f-97ed-7eb6d08ccf92
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review blocked

Automated review did not run, so no review verdict was produced.

Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here.

Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update.

Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it.

View the workflow run.

@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. labels Nov 1, 2026
Worked on by:
- @etzelm

Co-authored-by: etzelm <[email protected]>
OpenClaw-Publication: 2d03c461-6f96-4e07-900e-48b00d89efcb
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Nov 1, 2026
@etzelm

etzelm commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper's input-safety hold on this PR comes from a pre-existing synthetic fixture on main, not from this change.

  • Match: TruffleHog 3.99.4, Postgres detector, result unknown (the host is the reserved example.invalid, so verification cannot resolve it), at src/infra/database-engine/port-command.integration.test-support.ts:22.
  • That line is identical on main (546523f) and at this head (1ee44e4). This PR touches the file only at line 89 (the dropPortSchemas cleanup regex now allows -), which brings the file's base blob into scan scope.
  • The value is a deliberate redaction fixture: it is the fallback DB URL at :110 and is asserted absent from errors at :180.
  • The PR body, title, comments and all 4 commit messages scan clean with the same pinned scanner and flags (filesystem --results=verified,unknown --fail). A local split of the line-22 literal ("postgres:" + "//...", value byte-identical) in both blobs scans clean.
  • Editing line 22 inside this PR cannot clear the hold, because the base blob stays in scope.

Could a maintainer either qualify this fixture in clawsweeper REVIEWED_FIXTURES (Postgres detector, both blob roles for this path, like the existing src/logging/redact.test.ts entries), or land the string split of line 22 on main? After that a fresh @clawsweeper re-review can run.

Items worth covering in the evidence once review runs:

  1. A short redacted CLI transcript (base: dry-run exit 0, port exit 1 in capture-originals; head: forward and reverse exit 0), and the PostgreSQL conformance job line showing the new Team Reports test ran (it is describe.skipIf(!fixtures.connection)).
  2. The shared postgresNamespacePattern ([a-zA-Z_][a-zA-Z0-9_-]*) now also lets the recovery manifest accept uppercase, which it rejected before ([a-z_][a-z0-9_]*). Worth stating whether that is intended.
  3. Evidence that every SQL site interpolating namespace quotes it, since a hyphenated name is only safe quoted.
  4. catalogEvidence now mutates facts in place; worth noting that facts is a fresh local array with no other consumer.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Merge current main into the existing PR branch and resolve the moved anchor
reader. Preserve each validator's case policy and accept the hyphen in
local-companion backup verification. Retain the PostgreSQL port round trip
and quoted catalog normalization.

Co-authored-by: etzelm <[email protected]>
@VACInc VACInc reopened this Nov 18, 2026
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations and removed scripts Repository scripts labels Nov 18, 2026
@VACInc VACInc self-assigned this Nov 18, 2026
@VACInc

VACInc commented Nov 18, 2026

Copy link
Copy Markdown
Member

Reopened because the Team Reports schema name still breaks PostgreSQL archive and Git backups and stops database port after a successful dry run. The refresh follows the moved anchor reader, accepts the same name in local-companion backup verification, and keeps the PostgreSQL port and resume regression.

Use a dot in the malformed namespace fixture now that PostgreSQL store
anchors accept the hyphen in Team Reports namespaces.
@VACInc
VACInc merged commit ced77ff into main Nov 18, 2026
136 of 137 checks passed
@VACInc
VACInc deleted the openclaw/pg-team-reports-port-namespace branch November 18, 2026 21:36
@VACInc

VACInc commented Nov 18, 2026

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 19, 2026
…ssful dry run (openclaw#190124)

* Save workspace before refreshing its selected base

Co-authored-by: etzelm <[email protected]>

* fix(database): Team Reports fails to port to PostgreSQL after a successful dry run

Worked on by:
- @etzelm

Co-authored-by: etzelm <[email protected]>
OpenClaw-Publication: 3a013d3e-391a-435f-97ed-7eb6d08ccf92

* Publish openclaw/pg-team-reports-port-namespace

Worked on by:
- @etzelm

Co-authored-by: etzelm <[email protected]>
OpenClaw-Publication: 2d03c461-6f96-4e07-900e-48b00d89efcb

* test(database): keep the backup anchor refusal case invalid

Use a dot in the malformed namespace fixture now that PostgreSQL store
anchors accept the hyphen in Team Reports namespaces.

---------

Co-authored-by: etzelm <[email protected]>
Co-authored-by: VACInc <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 19, 2026
…ssful dry run (#190124)

* Save workspace before refreshing its selected base

Co-authored-by: etzelm <[email protected]>

* fix(database): Team Reports fails to port to PostgreSQL after a successful dry run

Worked on by:
- @etzelm

Co-authored-by: etzelm <[email protected]>
OpenClaw-Publication: 3a013d3e-391a-435f-97ed-7eb6d08ccf92

* Publish openclaw/pg-team-reports-port-namespace

Worked on by:
- @etzelm

Co-authored-by: etzelm <[email protected]>
OpenClaw-Publication: 2d03c461-6f96-4e07-900e-48b00d89efcb

* test(database): keep the backup anchor refusal case invalid

Use a dot in the malformed namespace fixture now that PostgreSQL store
anchors accept the hyphen in Team Reports namespaces.

---------

Co-authored-by: etzelm <[email protected]>
Co-authored-by: VACInc <[email protected]>

(cherry picked from commit ced77ff)

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
…ssful dry run (openclaw#190124)

* Save workspace before refreshing its selected base

Co-authored-by: etzelm <[email protected]>

* fix(database): Team Reports fails to port to PostgreSQL after a successful dry run

Worked on by:
- @etzelm

Co-authored-by: etzelm <[email protected]>
OpenClaw-Publication: 3a013d3e-391a-435f-97ed-7eb6d08ccf92

* Publish openclaw/pg-team-reports-port-namespace

Worked on by:
- @etzelm

Co-authored-by: etzelm <[email protected]>
OpenClaw-Publication: 2d03c461-6f96-4e07-900e-48b00d89efcb

* test(database): keep the backup anchor refusal case invalid

Use a dot in the malformed namespace fixture now that PostgreSQL store
anchors accept the hyphen in Team Reports namespaces.

---------

Co-authored-by: etzelm <[email protected]>
Co-authored-by: VACInc <[email protected]>

(cherry picked from commit ced77ff)

Release adaptation: Port existing physical anchor/recovery namespace validation and quoted catalog normalization. Exclude local-companion manifest parser and its tests because baseline lacks that feature; audit corrected on actual application. Existing backup/port regressions retained; no DDL.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…ssful dry run (#190124)

Baseline adaptation: Normalize quoted PostgreSQL catalog qualifiers and admit the Team Reports namespace at the branch-local backup anchor and port recovery readers; retain generated port_ destinations and the baseline catalog fact filter.

(cherry picked from commit ced77ff)

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. commands Command implementations size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants