Repository navigation
perf(sqlite): reuse generated memory schema facts - #174141
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. |
|
Codex review: blocked before merge. What this changesThis PR replaces memory schema scratch databases with generated catalogs and skips redundant STRICT schema installation. Example: Reopen a memory index using the custom cache table embedding_cache.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep open: this maintainer-authored PR provides a useful, focused optimization, and source review found no discrete introduced correctness or security defect. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherMemory index initialization supplies schema definitions and existing SQLite state to shared admission and migration helpers, which return admitted tables and search availability. flowchart TD
A[Memory index initialization] --> B[Storage shape admission]
C[Generated SQLite catalogs] --> B
B --> D[Legacy storage migration]
D --> E[Shared STRICT migration]
C --> E
E --> F[Search schema admission]
Technical reviewBest possible solution: Complete the existing generated-catalog cutover while preserving custom identifiers, generic repair behavior, and stored memory data. Do we have a high-confidence way to reproduce the issue? Current-main source reconstructs canonical STRICT tables in a scratch database and separately constructs dynamic memory catalogs; no target code was run. Is this the best way to solve the issue? Reusing the existing generator is a coherent solution that removes the superseded memory-only owner while retaining native discovery for unregistered custom SQL. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7bb0840c04cb. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +581, Tests +89, Other +48. Total +718 across 19 files. Added test files: 0. 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, 7:48 AM ET / 11:48 UTC. |
PR #174141 intentionally moved static memory admission to the shared build-generated SQLite catalog registry. The service anchor's lineage writer retains that registry, including its lazy memory-catalog reader and JSON URL, in its emitted runtime code. The asset is therefore part of the runtime closure, not an unused transform emission. Update the exact artifact inventory while preserving the two-JavaScript- file boundary and unresolved-import assertions. No runtime change. On current main the file reproduced the six-versus-five failure with 56 tests passing. After this change all 57 pass with --maxWorkers=1. Targeted typecheck, lint, format, and independent P2 review pass.
Use the shared schema fingerprint generator for static memory storage and STRICT admission. Consume generated expected facts instead of rebuilding scratch catalogs and replaying already-current DDL. Preserve migration validation, rollback, row identities and generic custom-SQL admission. Remove the redundant in-transaction storage-shape read under the single-owner contract. Unsupported external schema changes between preflight and transaction are no longer rechecked. No schema-version, PostgreSQL DDL or search-semantic changes. Engine search admission and computed vector facts remain outside this static slice.
PR openclaw#174141 intentionally moved static memory admission to the shared build-generated SQLite catalog registry. The service anchor's lineage writer retains that registry, including its lazy memory-catalog reader and JSON URL, in its emitted runtime code. The asset is therefore part of the runtime closure, not an unused transform emission. Update the exact artifact inventory while preserving the two-JavaScript- file boundary and unresolved-import assertions. No runtime change. On current main the file reproduced the six-versus-five failure with 56 tests passing. After this change all 57 pass with --maxWorkers=1. Targeted typecheck, lint, format, and independent P2 review pass.
What Problem This Solves
Memory admission reconstructs known schemas in scratch SQLite databases and reapplies already-created STRICT DDL when an index is first opened. This performs unnecessary SQL during first-use and restart preparation.
User Impact
Reduces static memory-schema admission work while preserving stored data, migrations, row identities, custom cache names, and search results. There is no schema-version change or operator action.
Why This Change Was Made
Memory's static storage fragments now use the shared build-generated SQLite fingerprint catalogs. STRICT migration consumes generated native facts and skips scratch reconstruction and DDL replay when its caller already owns creation and all required tables are STRICT. Ordinary generic callers retain index/trigger repair, and unregistered public custom SQL retains its existing native discovery contract. The old memory-only scratch-catalog implementation is deleted.
Only the static slice is included. FTS/tokenizer selection, vec0 dimensions, rebuild-on-mismatch, engine search admission, and PostgreSQL memory support are unchanged. The files named
sqlite-memory-catalogs.{json,ts}inpostgres-schema.generated/are SQLite catalog artifacts from the shared generator; PostgreSQL memory schema remains owned by the separate memory-on-PostgreSQL work.Removed check: the second storage-shape read inside the synchronous migration transaction. Accepted edge case: an unsupported external writer changing schema between preflight and transaction is no longer rechecked under the single-owner contract. Migration data validation, rollback, and actual write authority remain.
Evidence
The 23 STRICT regressions pass, including rowid/AUTOINCREMENT preservation, rollback, missing-table handling, and ordinary caller index repair. All 43 focused memory/facade tests pass. Final catalog equivalence passes 143 cases; catalog contracts pass 24 cases with one runtime-dependent diagnostic skip. Changed-file type-aware lint, formatting and diff checks pass. Two isolated Codex review rounds are complete (implementation through P2, small lint/test repair through P1), both scoped-clean. Knip has no PR-caused findings after removing the now-unused catalog-reader export; the unchanged media and UI findings are reproduced on main.
pnpm db:postgres:genandpnpm db:postgres:checkpass, with a clean regeneration diff. There are no PostgreSQL DDL changes. The new memory artifacts are SQLite catalogs only; PostgreSQL memory schema belongs to the separate memory-on-PostgreSQL work.Final-head CI 38893856140 completed: production and selected test types, lint, source contracts/export collisions, PostgreSQL conformance, and architecture checks pass. Madge reports zero cycles. T1 is 0 → 0 in touched runtime owners and 222 → 222 globally; the dialect categories remain 1/18/16 → 1/18/16. The assertion-safety shrink check fails only on untouched
src/media/media-facts.ts(14 < 16), whose source, scanner and baseline row match main; its dependent CI gate is also red. The failure is inherited from the tested main base; current main has since corrected that row from 16 to 14, and the conflict-free final merge includes the correction. The inherited-only landing exception applies to the prior CI result. Knip's remaining unused exports (readRuntimePromptImageOrderand UIrenderActivityGroup) are also demonstrated on main; no new export finding remains.The required published-driver update cell passed at the original static candidate. Later commits only repair lint/test coverage and remove an unused export, without changing runtime SQL or migration behavior. The separate npm-install acceptance job failed its installed-tree budget (47,651 entries > 47,500); package integrity passed. The overall workflow is not claimed green.
The public SDK comparison covers 155 modules and 3,773 exports: no entry point, exported name, kind, or direct declaration changed. Its 157 reachable-closure deltas all reflect the removal of the unused internal
readSqliteSchemaCatalogexport from one conservatively included module declaration. That difference is reviewed and accepted.The P3 search capture preserves all 44 output phases, search SQL, the 10 vector-edge records, and dense-NUL subprocess output byte-for-byte. Its full main stream changes from 968 to 849 execution records: 122 removed schema-admission records and three newly observed records from the existing SQLite runtime/iterator probe. Removing scratch opens delays that probe into the capture's unfiltered publication-open phase; it adds no search work. The admission differences are reviewed separately; full SQL-stream identity is not claimed. The historical 970-record capture used an older base, and its execution-record units differ from harness statement/request counts. Two external capture-audit adaptations account for the current point-delete implementation and that exact runtime probe; negative probes retain the search, vector, output, and runtime gates. Product source and the shared harness were unchanged by those adaptations.
Three alternating harness-v3 pairs completed in M/C/M/C/M/C order on base
186a4ed9808bf5a9cf9d51d5385f2a498de1b640and candidate2170eb39241d73735192d56658768e33bdfaccdb, with pinned Node 24.22.0 / SQLite 3.54.0 and unchanged workload/native-image hashes. All six workloads passed 14 turns, cron, compaction, same-state restart, both shutdowns, and cleanup, with zero native SQL/prepare errors or missing causal request coverage. Counts are measured on a busy host; no latency claim.Memory rows are identical in all three runs per arm. Other rows report median [min–max]; warm rows pool 30 turns per arm. Memory rows count complete worker request envelopes, so they are directly comparable across dispatch timing.
The attributable first-use saving is exactly 118 SQL statements (43.2%) with no request change in every pair: 72 scratch STRICT-schema statements, 32 expected-storage construction/catalog statements, and 14 already-STRICT DDL replays. The
ensureMemoryIndexSchemasubset falls 250 → 132 SQL. Restart admission stays 13 SQL / 1 request and never rebuilds the schema; this static slice claims no additional restart saving. Warm causal statement/request vectors are byte-for-byte equal across all six runs, and both pooled raw medians are unchanged.Raw restart SQL rises 762 → 798 (+36) while causal restart-turn work stays exactly 149 SQL / 49 requests / 0 MAIN and memory admission stays 13 SQL / 1 request. In C2/C3, one background transcript-projection publication request falls inside restart: 34 SQL (status tracking/index maintenance, transaction setup, busy-timeout and catalog inspection). The remaining median difference is one primary-key-column read and one legacy ambient-watch sentinel read. These owners are unchanged by this PR. The traces do not establish why projection maintenance falls in that window, so this is disclosed as a timing/trigger attribution limit, not claimed as a restart improvement. Whole-workload SQL and requests both fall. All five tracked shared read families—exact-entry facts, actor hydration, entry-cache snapshots, row facts and watermarks—remain zero during warm turns on both arms; lifecycle counts are retained in the detailed ledger. All 69 observed warm-background source files are byte-identical between base and candidate.
Total diff: +905/−187 lines, including +460/−2 generated catalog output, +139/−50 tests, +50/−2 tooling and +256/−133 production code. The static slice is complete; engine search-admission and computed vec0 work remain held for the PostgreSQL memory integration.