Repository navigation
feat(database): agent family port and backup on PostgreSQL - #174080
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 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: a3b6e45b0c
ℹ️ 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".
| ...metadata.tables.map(({ name, identities }) => ({ | ||
| name, | ||
| identities, | ||
| columns: columns | ||
| .filter((fact) => fact.table === name) |
There was a problem hiding this comment.
Accept agent stores with absent lazy tables
When a current-version agent database legitimately lacks a lazy feature table such as session_goal_operations or memory_entry_origins, inspectSqliteSource accepts it through AGENT_SCHEMA_COMPATIBILITY.allowedMissingTables and does not necessarily request migration. This unconditional expansion nevertheless makes inspectSqlitePortSchema inspect the absent table and reject it because it has no columns, so openclaw database port fails for valid existing agent stores before copying any data. Model these optional durable tables as source-selected fragments while still copying them whenever present.
Useful? React with 👍 / 👎.
| const events = ( | ||
| await target.db.query<{ event_json: string; seq: string; created_at: string }>( | ||
| "SELECT event_json, seq, created_at FROM transcript_events WHERE session_id = $1 ORDER BY seq", | ||
| [sessionId], | ||
| ) |
There was a problem hiding this comment.
Stream transcript rows while rebuilding projections
When porting or restoring a large agent database into PostgreSQL, this unbounded query materializes every full event_json for a session, after which the rows are copied into normalized objects, indexed in a Map, and expanded into active/FTS arrays before output begins. Long-lived transcripts can therefore exhaust the port worker heap and prevent publication; use bounded cursor reads or another streaming owner primitive instead.
Useful? React with 👍 / 👎.
| Existing agent stores support bidirectional ports and matched backups, including | ||
| retained registry paths and explicit session or agent directories. Older SQLite | ||
| schemas migrate only in the port's private copy. Compressed transcript events | ||
| become plain JSON on PostgreSQL; transcript search is rebuilt before publication. |
There was a problem hiding this comment.
Remove the stale prohibition on agent porting
This new guidance says existing agent stores support bidirectional ports, but the same page still says at lines 123–127 that the port command excludes agents and that agent porting is unavailable. Operators following the latter instructions will avoid the newly supported migration path or leave agent stores behind, so the stale limitation needs to be updated together with this feature.
Useful? React with 👍 / 👎.
|
Codex review: blocked before merge. What this changesAdds agent databases to bidirectional SQLite/PostgreSQL porting and matched backup and restore. Example: Move the main agent’s existing openclaw-agent.sqlite to PostgreSQL.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 7 items remain Keep this PR open: it supplies a useful, maintainer-directed capability missing from current main, but port admission, transcript rebuilding, and affected CI fixtures need repairs. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe offline database coordinator discovers stores and holds maintenance custody; family providers supply schemas, conversion rules, admission, and projection rebuilding before verified stores and configuration are published. flowchart TD
A[Database port command] --> B[Offline maintenance owner]
B --> C[Agent family provider]
C --> D[Private source capture]
D --> E[Verified materializer]
E --> F[Transcript projection owner]
F --> G[Store and config publication]
C --> H[Matched backup and restore]
Technical reviewBest possible solution: Complete the existing family-provider integration with valid lazy-schema admission, bounded transcript rebuilding, and preserved upgrade and backup behavior. Do we have a high-confidence way to reproduce the issue? Current source establishes the admission and rebuild failures, and exact-head CI supplies traces for the fixture failures; no target code was executed during this review. Is this the best way to solve the issue? Reusing the existing family registry and canonical owners is appropriate, but the new adapter must preserve their optional-schema and bounded-publication contracts. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e8cc6196dc80. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +6873, Tests +455, Docs +13, Other +37. Total +7378 across 23 files. Added test files: 3. 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, 6:14 AM ET / 10:14 UTC. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5d60cf7394
ℹ️ 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".
| version !== OPENCLAW_AGENT_SCHEMA_VERSION || | ||
| needsIndexRepair || | ||
| hasPendingCurrentVersionAgentDatabaseMigration(db), | ||
| pendingColumns: {}, |
There was a problem hiding this comment.
Normalize absent lazy columns before port inspection
When a current-version database predates first-use columns such as session_nodes.owner_actor_type or session_key_contract.canonical_ready, assertOpenClawAgentSchemaContains accepts the shape via allowedMissingColumns, while hasPendingCurrentVersionAgentDatabaseMigration does not request migration for those feature-local columns. Returning no pending columns then makes the full descriptor scan reject the otherwise valid store (and it could not select the absent columns anyway), so the private migration must materialize these nullable columns or the descriptor must model their absence before copying.
AGENTS.md reference: AGENTS.md:L65-L65
Useful? React with 👍 / 👎.
|
e9d12a5 to
b2bdeb2
Compare
e1ddc9b to
4b244d0
Compare
…174080) Add the canonical agent-family PostgreSQL port and matched-backup provider, including retained registry paths and R14 capture/rollback. Preserve mixed-engine refusal, canonical identities, FIFO, sequence high-watermarks, and SQLite byte identity. Validation: exact-head PostgreSQL conformance 589 passed; Doctor PostgreSQL, R14 recovery, import guard and 2,588-file wrapper closure passed. Types, lint and security review passed. Land with Peter-authorized inherited/causal-path CI exception: Cloudflare package exclusion, CLI inspectionErrors fixture, and two unchanged Codex fixture failures. Knip exports match scheduled main exactly. Evidence is recorded in PR openclaw#174080. Rebased onto current main without conflicts; no additional source fix.
Problem and impact
Agent databases supported PostgreSQL but lacked the port and matched-backup provider needed by update capture and rollback. This adds that agent-family provider, preserves retained external registry paths, and includes PostgreSQL agents in R14 recovery. Mixed-engine and explicit family-override update refusals remain intact.
The descriptor consumes canonical generated agent DDL and catalog metadata. SQLite sources migrate in a private copy. Ports preserve compressed transcript content, canonical identities, outbox FIFO, sequence high-watermarks, cold archives, and exact/user backup admission. Memory projection handling uses the shared memory owner.
Validation
Rebased without conflicts onto main
d8faf8876126ad19a2c497b19aa0b538a9592b1c, including the landed memory PostgreSQL work. Current head:4b244d01084773c4afb99620e6a12d39b3138e28. This landing made one rebase push and no additional source fix.Exact-head CI: PostgreSQL conformance passed 589 tests, 37 skipped, including agent port/matched backup, R14 capture/rollback (5/5), Doctor PostgreSQL (3/3), and port recovery (12/12). The package harness, Gateway pressure shard, lint, production/test types, architecture guards, and security-fast passed. Prior coordinator proof includes SQLite capture/restore byte identity and a clean independent review.
Post-rebase PostgreSQL generation/checks passed without a generated delta. The port-provider import guard and PR wrapper inventory/eager import closure passed (2,588 files). No local Docker, Testbox, changelog edit, or additional local test suite was used for landing.
Knip completed: production reports
packages/ai/src/transports/transport-utils.ts: redactSensitiveTextandui/src/i18n/lib/lit-controller.ts: I18nController; full-tree reports onlyredactSensitiveText; script scan passes. These are exactly the exports reported by scheduled main. No Knip exception was introduced by this PR.Authorized inherited-failure exception
The aggregate CI gate remains failed. Peter authorized native admin admission for matching-main and causally unrelated failures. The four nonaggregate failures are:
collectPublishablePluginPackages > keeps publishable plugin dist trees out of the core npm package unless bundled: Cloudflare exclusion assertion matches main's exact case.cli json stdout contract > keeps update status --json stdout parseable even with legacy doctor preflight inputs: the one-second status fixture rejects the existing optionalinspectionErrorskey. Its test/status owner are identical between the CI main parent, merge checkout and inspected current main. The failed status/timeout expectation is outside R15's port/backup effects.Codex app-server startup retry > preserves the shared client and binding on an overloaded resume with a sibling lease: undefined test binding instead ofthread-recovered. The Map-backed fixture and startup/binding path are unchanged by R15. Newer main changes this fixture to enable tools.Codex migration discovery deadline with real request owner > keeps request allowances within the 30s discovery budget after a 120s rewind: observes a 630000 ms timer. The fixture mocks database/credential dependencies and exercises the unchanged request deadline path. Newer main inspects request timeout allowances directly.Both Codex fixture changes are in main commit 8114ddb5ce6207. This is causal-path attribution for the CLI and Codex cases, not a claim of a same-case main runtime replay. All named failure inputs are byte-identical between CI's main parent
a09c26b193b44610fbb565478963bceca30fe951and its tested merge0930a09cd1e8184988beb3863ecbfade568fe3e3.Reported scope remains +657 production lines and +6,428 generated lines; generated DDL/catalog and family descriptor were reviewed by the coordinator. No schema version, dependency, or protocol bump.