Skip to content

feat: mirror reflection slice rows into the daily memory journal#943

Draft
gorkem2020 wants to merge 4 commits into
CortexReach:masterfrom
gorkem2020:feat/mirror-reflection-slices
Draft

feat: mirror reflection slice rows into the daily memory journal#943
gorkem2020 wants to merge 4 commits into
CortexReach:masterfrom
gorkem2020:feat/mirror-reflection-slices

Conversation

@gorkem2020

Copy link
Copy Markdown
Contributor

The mdMirror daily journal (memory/<date>.md) mirrors writer-1 reflection mapped rows, smart-extraction rows, and manual memory_store rows, but not the reflection writer-2 slice rows (storeReflectionToLanceDB's event / invariant / derived rows). Those rows entered the database invisibly; the daily file only got the "Reflection generated: <path>" pointer line. This PR closes that gap so every row that enters the database is observable in the daily file without CLI tools.

  • storeReflectionToLanceDB (src/reflection-store.ts) gains an optional onPersisted(entry, kind) hook, fired after each event / item-invariant / item-derived row is stored. The combined-legacy row is intentionally excluded since it is out of scope for this change (it is a distinct legacy row type, not one of the writer-2 slice rows this PR targets).
  • Callback failures are swallowed with a try/catch so a mirror bug can never abort reflection persistence, matching the existing SmartExtractor.notifyPersisted convention for the same kind of hook.
  • index.ts wires mdMirror through this hook with source labels reflection-slice:event, reflection-slice:invariant, and reflection-slice:derived.
  • The event row's text is a multi-line key=value block. It renders as one line for free, because createMdMirrorWriter's existing line formatter already replaces \n with a space before appending to the daily file - no changes were needed there.

Test plan

  • Red-first: added tests to test/memory-reflection.test.mjs asserting onPersisted fires for event/invariant/derived rows, is skipped for the legacy row, does not break storage when absent, does not abort remaining stores if it throws, and that the event row's multi-line text collapses to one line under the existing mirror formatting contract. All five failed before the implementation and pass after.
  • npm run build (tsc) clean.
  • Full local npm test chain green (one test skipped: a known host-side port 11434 conflict unrelated to this change).

Notes for reviewers

While working on this I found that test/memory-reflection.test.mjs itself (the file with the most direct coverage of storeReflectionToLanceDB) is not wired into either package.json's test script or scripts/ci-test-manifest.mjs on master, and separately has four pre-existing failing tests unrelated to this change. Both are out of scope here and are called out separately rather than folded into this PR.

…Mirror

storeReflectionToLanceDB gains an optional onPersisted(entry, kind) hook,
fired after each event/item-invariant/item-derived row is stored (the
combined-legacy row is intentionally excluded, matching the task's scoped
target types). Failures in the callback are swallowed so a mirror bug can
never abort reflection persistence, matching the existing SmartExtractor
onPersisted convention.

index.ts wires mdMirror through this hook with source labels
reflection-slice:event / :invariant / :derived. The event row's multi-line
key=value text collapses to one line for free via createMdMirrorWriter's
existing newline-to-space formatting, so no changes were needed there.
@gorkem2020
gorkem2020 force-pushed the feat/mirror-reflection-slices branch from 9563030 to 0a511d1 Compare July 18, 2026 15:53
…irror

The memory-reflection-event row is bookkeeping (its text is a kv stamp);
the daily journal already records each run via its 'Reflection generated'
line, so mirroring the stamp only produced content-less journal entries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant