feat(memory): add holographic fact store and MCP tools - #11
Conversation
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 487f76fa08
ℹ️ 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".
…phic-memory-core # Conflicts: # src/hooks.rs
Eliminate the per-id N+1 round-trips in the holographic search/probe/reason paths by adding batched MemoryStore::get_facts and fact_vectors (chunked at 256 to stay under SQLite's 999-parameter limit). search now hydrates missing candidates and preloads candidate vectors in single batched queries, and holographic scoring becomes a pure helper fed those preloaded vectors; results_for_fact_ids does one batched fetch while iterating the original id order so probe/reason ordering is preserved. Worst case drops from ~1,100 round-trips to ~6. Also bind the user-derived strings in reason and entity_candidates as anonymous ? placeholders instead of interpolating string literals (escape_like still governs LIKE wildcards, now bound rather than inlined), and factor the repeated BEGIN IMMEDIATE/COMMIT/ROLLBACK boilerplate in add_fact, update_fact, remove_fact, and record_feedback_event into a with_immediate_tx combinator. Behavior is unchanged; all memory tests pass.
Cursor transcript ingestion previously re-read the whole transcript and re-upserted every message on every beforeSubmitPrompt, which is O(n^2) over a session under the 5s hook budget. Make ingestion incremental: resume from the byte offset tracked in the project session DB's parse_offsets table (mirroring the Claude accounting parser), seek + stream only newly-appended lines, and upsert just those. Handle truncation/rewrite (restart at offset 0) and a partial final line at EOF (defer until newline-terminated). Session start time and title are preserved across appends; ended_at advances to the latest message. Move the bulk catch-up off the hot path: register a Cursor stop hook (end-of-turn, generous timeout) as the primary ingest point and also ingest on sessionStart for resumed sessions. beforeSubmitPrompt now does at most a small tail read, bounded by a byte cap and wrapped in tokio::time::timeout so it fails open and can never exceed the prompt budget; the ingest runs inline (not a detached task) since CLI hook processes exit immediately. Upserts stay idempotent via INSERT ... ON CONFLICT, so concurrent short-lived hooks converge to the same rows. Behavioral change: re-ingesting an unchanged transcript is now a no-op, and the message ordinal/fallback id derives from the line's byte offset rather than a dense line index. Tests updated/added for the no-op, incremental append, and partial-line cases, plus the new stop-hook registration.
Introduce a shared TranscriptSource driver that persists ByteOffset, ContentHash, and RowCursor progress through the existing parse_offsets table, then refactor Cursor ingestion onto it without changing its hook behavior. The driver centralizes idempotent session/message upserts, source offsets, partial-line handling, full-rewrite content hashes, and row-cursor support. Add serve-side catch-up ingestion for hookless, path-discoverable adapters and implement the feasible sources verified in this pass: Claude Code JSONL, Codex rollout JSONL, Mistral Vibe messages.jsonl, and the Cline/Roo/Kilo full-rewrite task-history stores. Gemini transcript ingestion is intentionally omitted per user request; Hermes remains excluded. Add focused fixture tests for every integrated adapter plus framework tests for ByteOffset, ContentHash, and RowCursor cursor behavior.
Ensure Cline-family transcript fixtures are written under the same OS-specific VS Code data root that the provider scans, so macOS CI exercises the intended ingest path.
Align message-search providers with ingested session sources, bound transcript storage and catch-up reads, and ensure memory transactions roll back when COMMIT fails.
Summary
Test plan
Stacked on #10.