Repository navigation
feat(team-reports): PostgreSQL support - #172855
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: blocked before merge. What this changesThis PR adds PostgreSQL storage, database porting, and backup/restore support for Team Reports. Example: Save the daily Team Reports report for 2026-08-20 with PostgreSQL selected.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR open: it delivers a useful maintainer-directed feature, but adding Team Reports strands previously valid mixed-engine installations without a working port command. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe Team Reports plugin sends storage operations to its database worker, which uses shared engine admission and transactions; offline port and backup operations discover the plugin through the database-family registry. flowchart TD
A[Team Reports plugin] --> B[Database worker]
B --> C[Shared engine owner]
C --> D[SQLite store or anchor]
C --> E[PostgreSQL reports]
F[Offline port and backup CLI] --> G[Database family registry]
G --> C
Technical reviewBest possible solution: Extend the existing offline port owner to migrate recognized mixed-engine installations while preserving reports, existing PostgreSQL stores, configuration, and recovery guarantees. Do we have a high-confidence way to reproduce the issue? Source establishes the failure: start with database.engine=postgres, a PostgreSQL Workboard anchor, and existing SQLite Team Reports data; runtime refuses the reports database, while either port direction fails the physical/config engine comparison. Is this the best way to solve the issue? Reusing shared engine, admission, and family-provider contracts is appropriate, but adoption must include the mixed-engine migration path rather than assuming every newly registered family already matches the global engine. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4d60655c338b. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +332, Tests +574, Docs +14, Config +4, Generated +286, Other +41. Total +1251 across 40 files. Added test files: 4. 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, 2:55 AM ET / 06:55 UTC. |
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. |
fd9d6df to
17061d8
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 17061d89fa
ℹ️ 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".
|
|
||
| export type DatabasePortProvider = { | ||
| id: string; | ||
| minimumPostgresVersion: number; |
There was a problem hiding this comment.
Populate the PostgreSQL floor for every provider
Adding this required field without updating logbookPortProvider leaves one registered provider's value undefined; consequently, the preflight calculation Math.max(...databasePortProviders.map(...)) returns NaN, and readPostgresPortCapabilities no longer rejects unsupported PostgreSQL versions for any database port operation. Add Logbook's minimum version when migrating the provider contract.
AGENTS.md reference: AGENTS.md:L48-L53
Useful? React with 👍 / 👎.
Preserve the existing PostgreSQL 16 floor when Team Reports adds the provider-level preflight contract. Keep the merged generator imports formatted.
|
Merged via squash.
|
* feat(team-reports): support PostgreSQL storage * fix(team-reports): inline schema in compiled runtimes * fix(team-reports): align descriptor and read-budget probes * fix(database): preserve SQLite artifacts during port lookup * test(database): retain Logbook in provider expectation * fix(database): declare Logbook PostgreSQL preflight minimum Preserve the existing PostgreSQL 16 floor when Team Reports adds the provider-level preflight contract. Keep the merged generator imports formatted.
What Problem This Solves
Team Reports could not use the experimental PostgreSQL backend for its saved reports or participate in database port and backup operations.
User Impact
Team Reports now supports experimental PostgreSQL runtime storage, bidirectional
openclaw database port, and matched anchor plus logical database backup/restore. Saved reports, person-day counts, and run history are durable. Collected activity remains session-local TEMP scratch and is excluded from port and backup.Why This Change Was Made
The existing database worker opens the engine store under admission, uses generated PostgreSQL DDL/port metadata, and delegates its eight JSON projections to the shared engine helper. PostgreSQL writes use the existing transaction/admission envelope. SQLite schema version 1 stays unchanged; the PostgreSQL format is unshipped and needs no migration.
Team Reports is separately installed (
bundledDist: false), so offline operations load its selected installed owner's public port API through the existing owner-aware loader. Preflight reads static provider requirements without loading absent optional plugins. Workboard keeps its existing descriptor path without plugin-metadata discovery. Team Reports resolves its selected installation under artifact-preserving state reads, so offline backup cannot mutate shared SQLite sidecars.Compiled workers and npm packages inline canonical schema SQL through the existing schema inliner. A focused packaging regression loads the built schema export; an isolated build of the actual plugin also passed public-API admission against both SQLite and PostgreSQL.
The approved additive
jsonPathValueexport uses the existing experimentalopenclaw/plugin-sdk/database-engine-worker-runtimeentrypoint. There is no new SDK subpath and the plugin imports no core internals. SDK export inventories were regenerated/checked, the current declaration baseline was rendered, and the surface budgets account for exactly one additional export/callable. The historical shipped SDK inventory is unchanged.Evidence
SQLite statement capture
A representative fixture covers 23 operations before/after: results are identical and all 76 existing statements retain identical bytes. No existing statement changed. Cold initialization adds the following four inspections, each twice (84 statements total):
PRAGMA schema_versionPRAGMA user_versionPRAGMA encodingSELECT type, name, tbl_name, sql FROM main.sqlite_schema WHERE type IN ('table', 'view', 'index', 'trigger')The second inspection follows schema creation invalidating the first snapshot. The warm-reopen test verifies zero repeated schema introspection while admission remains live.
Runtime, port, and backup proof
PostgreSQL 17 conformance runs in process with one fixture per suite, without launching compiled workers. It covers all 23 operation outputs, all eight numeric JSON projections, rollback, independent-session scratch isolation, scratch discard after close/reopen, every canonical table through SQLite → PostgreSQL → SQLite, exact backup/restore fingerprints, and the selected installed plugin owner with bundled artifacts absent. A separate real host-to-worker smoke passed configuration selection, writes, duplicate-finish refusal, and reopen. Existing worker-backed SQLite tests pass unchanged.
The isolated feature review and focused CI-correction review both completed with no actionable P0–P2 findings.
Measured commands use
pnpm test <file> --maxWorkers=1; PG cases use the existing PostgreSQL preload. Wall times include wrapper and compiler preparation on the contended local host. CI seconds below are from final headfd9d6dfe592331f4f2eae7d1ad7eb2c8c5d2deda.extensions/team-reports/src/store.conformance.test.tsextensions/team-reports/src/store-read-budget.test.tsextensions/team-reports/src/postgres-store.test.tssrc/infra/database-engine/team-reports-port.postgres.test.tssrc/infra/database-engine/port-command.postgres.test.tsextensions/team-reports/src/store.test.tsextensions/team-reports/index.test.tssrc/infra/database-engine/backup.test.ts(correction)test/plugin-npm-runtime-build.test.ts(focused packaging regression)The existing backup file reuses its compiled snapshot-worker boundary to prove capture, exact restore, and custody; no in-process helper test proves that path. Its three cases took 58.557 CI seconds. The port-command file exceeds 30 seconds because its existing cases exercise real offline copy/commit, recovery, and custody checks; this change extends those family expectations. The full port-command run passed five cases and exposed one stale family-prefix expectation; its corrected targeted replay passed. Initial CI exposed a duplicate descriptor-export name and HTTP/scheduler read-budget spies on the bypassed worker facade. The descriptor now has a family-specific name, and the spies wrap the real engine operation without weakening their assertions. Registry/provider/import tests also passed (per-file wall times 93.24s, 82.51s, and 78.69s).
341 net handwritten production lines, excluding generated files, docs, and tests. Generated PostgreSQL outputs come from
pnpm db:postgres:gen;pnpm db:postgres:checkpassed. SDK inventories/baseline, formatting, import guards, wrapper inventory/shadowing, Kysely, and dialect/line-cap/assertion-safety checks passed. The full-tree database-worker ratchet passed locally (223 → 223 main-thread calls; 12 → 12 deprecated compatibility calls). The full runtime build completed in 291.3 seconds.Pre-rebase CI
CI run 38704506995 passed on the final head: 63 jobs succeeded and 22 were skipped. The complete PR rollup has 94 successful checks, 49 skips, and one neutral CodeQL result, with no failing or pending checks.
The PostgreSQL job's existing 33-case port-command integration suite accounts for 932.622 test seconds; the two new Team Reports PG suites account for 3.085 test seconds combined.
The completed Knip production scan reports six exports in untouched GitHub/channel/UI files; the full-tree scan reports three untouched exports/types. Neither reports a task-file export. The environment-count gate reports 455 versus its 454 budget; this PR adds no environment names in counted production paths. These unrelated findings are recorded rather than masked with budget or ignore changes.
The preceding head passed 92 CI checks. Its PostgreSQL job exposed a new updater-backup regression: descriptor resolution unnecessarily loaded plugin metadata for Workboard after shared-SQLite fingerprints were captured, changing a
-shmfile. The correction skips discovery for providers that do not need an installed owner and uses artifact-preserving reads for Team Reports. The existing exact updater-backup test is the primary regression; the same updater test now also checks unchanged shared database/sidecar bytes and metadata through the real Team Reports resolver. The in-process port suite is unchanged; the new cold-lookup assertion reuses the updater test’s existing snapshot-worker boundary. The unwrapped negative control failed at the new sidecar assertion (28.070s test time, 654.54s wall, including 266.370s worker preparation). The initial fixed updater replay reached PostgreSQL export and SQLite snapshots, then hit its existing 120s test timeout on this contended host (683.61s wall, 121.186s test time). No timeout was increased. The fixed full-file replay took 634.49s: the updater passed in 71.185s, user export passed in 68.182s, and the unchanged Git-backup case failed in 34.979s at the external-volume ancestor permission check. Its permissions were not changed. The corrective review completed scoped-clean after its launcher’s shared-temp-directory preflight was resolved with a private task directory. Formatting passed; another lint attempt stopped before analysis at the existing 300s SDK declaration timeout, and the queued typecheck was stopped. Final-head CI passed all three backup cases, including the local Git-backup case blocked by the host path gate. It also passed lint and production/test types, covering the local declaration-preparation limitation.Landing rebase
Rebased onto main after Logbook landed and GitHub reported conflicts. The mechanical resolution preserves both families in the schema generator, runtime schema inliner, conformance targets, provider registry, import-closure coverage, and documentation. The provider-error expectation includes Workboard, Logbook, and Team Reports; the preflight test also preserves main's SecretRef-redaction assertion. This was the single landing fix push, at
17061d89fa0b252a8655e8f63496886ef6f8cd22.PostgreSQL generation/check passed (19 generator tests); SDK export and plugin inventories were regenerated without tracked changes. Registry/provider tests passed. The import-closure test initially encountered a native compiler crash with pre-rebase dependencies; after installing the rebased lockfile, it passed. The port-command file passed four cases and skipped its two PostgreSQL-dependent cases locally. The one-line expectation correction passed isolated review. Final-head CI is required before merge; the API-baseline render was stopped after CI exposed the missing Logbook provider field.
Landing follow-up
Rebased-head CI run 38718030583 on
17061d89fa0b252a8655e8f63496886ef6f8cd22found two PR-caused integration defects:minimumPostgresVersion. Its generated descriptor already specifies 16. Omitting it also makes the real preflight registry computeNaN; declaring 16 restores the expected floor.The coordinator-approved two-file integration correction is pushed at
174439b548b85914672e237c3b05f4215fea1f8c. It passed isolated review, and its real registry probe returns 16 for all three families and the combined preflight floor. Required CI passed on this new exact head before landing. The preceding failures are PR-caused integration fallout, not inherited exceptions.Final landing CI
CI run 38720659699 passed on
174439b548b85914672e237c3b05f4215fea1f8c: 64 jobs succeeded, 22 were skipped, and none failed. Required build, SDK boundaries/API checks, production/test types, docs, lint, ratchets, andopenclaw/ci-gatepassed. PostgreSQL conformance passed for Workboard, Logbook, and Team Reports, including Team Reports bidirectional port, installed-owner resolution, and backup/restore. The two preceding rebase integration failures are corrected; no inherited-failure exception is used.