Skip to content

fix(memory): make auto-prune observable and age-safe - #121

Merged
Grivn merged 1 commit into
masterfrom
codex/issue-83-autoprune-audit
Aug 30, 2026
Merged

fix(memory): make auto-prune observable and age-safe#121
Grivn merged 1 commit into
masterfrom
codex/issue-83-autoprune-audit

Conversation

@Grivn

@Grivn Grivn commented Aug 30, 2026

Copy link
Copy Markdown
Member

Summary

  • add a configurable auto-prune grace period with a safe 24-hour default
  • base grace on physical local insertion time (stored_at), not historical created_at
  • return exact auto_pruned_ids from remember/import operations
  • make prune audit records, edge cleanup, soft deletion, and the triggering write atomic
  • include the trigger insight, active count, limit, and minimum age in audit detail
  • document the behavior and configuration in English and Chinese

MNEMON_AUTO_PRUNE_MIN_AGE accepts a Go duration, an integer number of days, or 0 to disable the grace period. Invalid and negative values fall back safely to the default.

The nullable stored_at migration includes a backfill, an index, and a trigger for legacy/external writers. This protects newly imported historical records: an old event timestamp no longer makes a row immediately eligible for pruning after it first enters the local store.

Relationship to existing work

This is a broader independent solution than #108. Both address the newborn-insight grace period, but this PR additionally handles historical imports through stored_at, exposes exact pruned IDs, and makes audit/write behavior transactional. It preserves the existing prune operation name introduced by #96 and the configurable insight ceiling already on master from #109.

If maintainers prefer #108's opt-in/default-off policy, the default and environment naming can be adjusted without changing the transaction or stored_at design.

Verification

  • focused migration, legacy-writer, historical-import, grace-period, and audit-rollback tests
  • make test
  • 152/152 CLI E2E assertions
  • go test -race ./internal/memory/store ./cmd/memory
  • the external mnemon-sync convergence harness passes against the migrated schema
  • git diff --check

Closes #83.

Protect newly stored insights with a configurable grace period based on physical insertion time, including historical imports and legacy writers. Return pruned IDs and atomically record each deletion so audit failures roll back the triggering write.
@Grivn
Grivn force-pushed the codex/issue-83-autoprune-audit branch from c364c93 to 71c067a Compare August 30, 2026 19:59
@Grivn
Grivn merged commit 708ab61 into master Aug 30, 2026
2 checks passed
@Grivn
Grivn deleted the codex/issue-83-autoprune-audit branch August 30, 2026 20:00
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.

AutoPrune deletions are invisible: no oplog record, no config knob, and same-second reaping of newborn insights

1 participant