Skip to content

fix(store): record an oplog entry for every auto-pruned insight - #96

Merged
Grivn merged 1 commit into
mnemon-dev:masterfrom
audreyt:fix/prune-audit-log
Aug 12, 2026
Merged

fix(store): record an oplog entry for every auto-pruned insight#96
Grivn merged 1 commit into
mnemon-dev:masterfrom
audreyt:fix/prune-audit-log

Conversation

@audreyt

@audreyt audreyt commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Auto-prune soft-deletes insights and hard-deletes their edges, but is the only mutation path that writes nothing to the oplog. Every other mutation — remember, forget, link, diff-replace, diff-skip, embed — records one, so the oplog reads as a complete history when it isn't.

This is easy to hit. AutoPrune runs on every remember once the active count exceeds MaxInsights (default 1000), pruning up to PruneBatchSize per call. A store that has been over capacity for a while can quietly shed thousands of insights, and the only visible symptom is a count that stopped growing. There is currently no way to discover which ones went, when, or why.

Log one entry per pruned id, with the active count and the cap that triggered it, so the oplog can serve as a recovery index.

Blast radius: none beyond the added log line. No change to what gets pruned or when.

Test: TestAutoPrune_RecordsOplogEntryPerPrunedInsight — fails without the change with want 2 prune oplog entries, got 0. It also asserts every id the oplog names is genuinely soft-deleted, so the log can be trusted as an index.

Copilot AI lite review requested due to automatic review settings August 12, 2026 02:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes auto-pruning observable by recording an oplog entry for each insight that AutoPrune soft-deletes, closing a gap where this destructive mutation path previously left no audit/history trail.

Changes:

  • Add db.LogOp("prune", ...) per successfully pruned insight during autoPrune.
  • Add a regression test to assert that each auto-pruned insight produces a corresponding prune oplog entry and that the logged IDs reflect pruned insights.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
internal/memory/store/node.go Writes an oplog entry for each insight pruned by auto-prune, including capacity context in detail.
internal/memory/store/store_test.go Adds a regression test covering per-pruned-ID oplog logging behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/memory/store/store_test.go
Comment thread internal/memory/store/node.go
Auto-prune soft-deletes insights and hard-deletes their edges, but was
the only mutation path that wrote nothing to the oplog. Every other
mutation (remember, forget, link, diff-replace, diff-skip, embed)
records one, so the oplog reads as a complete history when it is not:
a store that has shed insights offers no way to discover which ones,
when, or why.

This is easy to hit. AutoPrune runs on every remember once the active
count exceeds MaxInsights (default 1000), pruning up to PruneBatchSize
per call. A store that has been over capacity for a while can quietly
lose thousands of insights, and the loss is only visible as a count
that stopped growing.

Log one entry per pruned id, with the active count and the cap that
triggered it, so the oplog can be used as a recovery index.

No behavior change beyond the added log line.
@audreyt
audreyt force-pushed the fix/prune-audit-log branch from b4fa165 to a4faa72 Compare August 12, 2026 03:06

@Grivn Grivn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — thanks for closing this audit gap!

@Grivn
Grivn merged commit 0604e52 into mnemon-dev:master Aug 12, 2026
1 check passed
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.

3 participants