Repository navigation
feat(memory): index and publish memory on PostgreSQL - #174183
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: f15737feec
ℹ️ 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 (bindingStageId === command.input.stageId) { | ||
| retainState = false; | ||
| } |
There was a problem hiding this comment.
Reset the dropped spool before returning it to normal use
After a full PostgreSQL reindex is published, the long-lived published backend has bindingStageId set to this stage, so this branch runs after dropping the retained temp table but leaves the closure's created flag true. The next streamed source or embedding-cache write calls stage.start; ensureSpool() then skips recreating the table and the following DELETE FROM memory_stage_* fails because that table was dropped. Reset the current binding's spool state (and preferably its binding ID) when discarding it so post-reindex publications continue working.
Useful? React with 👍 / 👎.
|
Codex review: needs changes before merge. What this changesThis PR adds PostgreSQL memory indexing and atomic publication through the existing agent database worker. Example: Index memory/orchid.md into a fresh PostgreSQL agent store.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open as a useful, maintainer-directed PostgreSQL publication foundation; no definite introduced production defect was established. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherMemory Core prepares source chunks and embeddings, then the agent database worker stages and commits them to canonical tables and engine-owned search projections. flowchart TD
A[Memory files and sessions] --> B[Memory Core indexing]
B --> C[Agent database worker]
C --> D[PostgreSQL temporary staging]
D --> E[Atomic publication]
E --> F[Canonical memory tables]
F --> G[Text and vector projections]
Technical reviewBest possible solution: Land the publication foundation once CI failures are classified, retaining the public-search refusal until the coordinated lifecycle implementation is ready. Do we have a high-confidence way to reproduce the issue? This is a foundation feature; current-main source confirms the missing PostgreSQL publication path, and no target code was executed during this review. Is this the best way to solve the issue? The implementation fits the existing agent worker and engine-owned projections, with connection-local staging instead of a competing persistent publication owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ce9d859d68ab. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +640, Tests +1073, Docs +7, Other +14. Total +1734 across 30 files. Added test files: 4. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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, 8:25 AM ET / 12:25 UTC. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 886c78d4b0
ℹ️ 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 (command.type === "vector.ensure") { | ||
| admitSearch({ "memory.vector": memoryVectorSearchSchema(command.input.dimensions) }); |
There was a problem hiding this comment.
Handle changed PostgreSQL search definitions during reindex
After a PostgreSQL index admits one embedding dimension, changing to a provider with different dimensions makes this call present a different definition under the existing memory.vector name. admitStoreSearchExtension rejects that with SearchExtensionDefinitionChangedError, while this handler ignores currentDimensions, so the full-reindex path cannot perform the required derived-index replacement and every subsequent indexing attempt fails. Add an owner-controlled replacement/rebuild path for changed dimensions; the same issue applies to changed FTS tokenizer definitions.
AGENTS.md reference: AGENTS.md:L65-L65
Useful? React with 👍 / 👎.
| }, | ||
| }, | ||
| ); | ||
| return { ok: true, value, facts: rebuilding ?? readMemoryDatabaseFacts(db) }; |
There was a problem hiding this comment.
Skip canonical fact reads for spool-only writes
For an ordinary streamed publication, stage.start and every stage.append invoke write(), but their handlers discard the returned facts. This line nevertheless runs readMemoryDatabaseFacts(db) after every 512 KiB transfer batch, including its table-existence/catalog check and several canonical-state queries, before the actual source replacement occurs. Large sources therefore incur redundant synchronous database work proportional to transfer batches; only compute facts for commands whose callers install or return them.
AGENTS.md reference: AGENTS.md:L72-L72
Useful? React with 👍 / 👎.
|
Merged via squash.
|
* feat(memory): index and publish memory on PostgreSQL * fix(memory): route PostgreSQL indexing reads through publication * test(memory): preserve PostgreSQL fixture command types * fix(memory): satisfy publication gates and order fixture writes
- Resolved by taking main's version of every file this branch touched; main's cache owner (openclaw#174183, openclaw#175224, openclaw#175566) replaced the helper the branch edited. - The eviction preference is re-applied on top in the next commit.
What Problem This Solves
PostgreSQL agent stores can admit search extensions, but memory publication still depends on SQLite shadow files and native vector writes.
User Impact
This adds the PostgreSQL memory indexing/publication foundation. Public memory search on PostgreSQL remains refused until the search and forget/status lifecycle is enabled together. SQLite statements, bindings, and results remain unchanged.
Why This Change Was Made
The agent owner admits memory's prepared text/vector definitions with the configured embedding dimensions. PostgreSQL stages bounded transfer fragments on the existing worker connection, releases the writer queue between batches, and publishes canonical rows plus engine-owned vector/text projections in one transaction. Revision and commit-authority checks preserve the previous index on failure. Internal indexing reads also use the publication worker, without enabling the public retrieval path. No PostgreSQL shadow file or ATTACH is used.
Embedding-cache inserts retain the 128-row batches (896 binds), and vector reuse retains bounded IN-lists. PostgreSQL eviction uses the canonical composite cache key; SQLite keeps its existing statements.
This is the first publication stage after #174085; search and lifecycle activation remain separate changes. No agent schema or Doctor import changes are included.
Evidence
ff0bd32e4451425028caba7ec84b9b55dffac030181b46a1ac2cae817af598ad.pnpm build strictSmoke, formatting, diff checks, and changed-file line-cap, dialect, worker, and Kysely checks passed. The worker ratchet remains 222 → 222 live main-thread calls.The whole-tree maximum-lines suppression check reports three unchanged files already present at the branch base:
ui/src/pages/chat/components/chat-message.test.tsx,ui/src/pages/config/config-page-state.ts, andui/src/pages/sessions/sessions-page-state.ts. This change adds no suppression or baseline entry.Size against the branch base: +641 net production lines, +1,075 test lines, +22 tooling/docs lines across 31 files. The retained growth is the PostgreSQL publication adapter and its conformance proof.
CI repair: added the four required cast invariants without changing runtime behavior. The gateway lookup fixture now queues its deliberate malformed-row write through agent write admission; CI had hit
database is lockedbefore the intended rejection assertion. The same assertion passes locally after the repair (one selected case, 7.2 seconds; 244 seconds including worker compilation). No retries or weakened assertions were added.Final head
886c78d4b058bdb0faa003d75a8125597588ae2a: CI run 38900610159 passed, including PostgreSQL conformance (15m10s), baseline ratchets, the repaired gateway shard, and the overall CI gate. Applicable security review requirements passed. The PR is ready and remains unmerged.