Skip to content

fix(audit): make index_persist audit entries opt-in - #2

Merged
codeasier merged 1 commit into
v0.9.29-patchfrom
fix/audit-index-persist-optin
Sep 28, 2026
Merged

codeasier merged 1 commit into
v0.9.29-patchfrom
fix/audit-index-persist-optin

Conversation

@codeasier

Copy link
Copy Markdown
Owner

Summary

Ports upstream rohitg00#1182 (39658a9) onto the v0.9.29-patch line: index_persist audit rows become opt-in via AGENTMEMORY_AUDIT_INDEX_PERSIST=1 (default off). Follow-up to the retention PR (#1) — without this, the new AGENTMEMORY_AUDIT_MAX=5000 retention window is dominated by index-persistence rows within hours of sustained capture, evicting genuine deletion records.

Why

  • Index shard writes, manifest publishes, and generation reclaims record no user-data deletions — outside the audit policy stated at the top of src/functions/audit.ts.
  • Yet a single save() emits several index_persist rows; on a real store they reached 59876 of 84028 entries (71%) (figure from upstream's fix).
  • On this branch the interaction is worse: under sustained hook load the 5s-debounced index save writes ~4 rows ≈ 2880/hour, so the 5000-row audit window would be almost entirely index_persist noise and real delete/forget records get swept.

Changes (1917377)

  • src/state/index-persistence.ts — auditIndexPersistEnabled() gate + if (!auditIndexPersistEnabled()) return; at the top of auditIndexPersistence(), verbatim from upstream (direct process.env read is equivalent to getEnvVar here because hydrateProcessEnvFromFile() runs at boot in both cli.ts and index.ts; keeping the text identical minimises the future merge into main, where fix(audit): make index_persist audit entries opt-in rohitg00/agentmemory#1182 already landed).
  • test/index-persistence.test.ts — upstream's gating suite ported verbatim: default-off, affirmative vocabulary (1, 1, true, TRUE, true ), off vocabulary (0, false, yes, ", " ``), and persistence-unaffected. Env captured/restored per case (upstream's second commit).
  • plugin/skills/agentmemory-config/REFERENCE.md — regenerated: 51 → 52 recognized variables.
  • CHANGELOG.md — bullet under [Unreleased] → Fixed.

No REST endpoint / MCP tool / KV scope / audit-operation changes, so no count surfaces beyond the regenerated REFERENCE.md.

Test plan

  • npm test passes — 1756 passed / 1 skipped (base 1744 + 12 new gating tests; no regressions)
  • npm run build passes
  • npm run skills:check passes (17 skills)
  • npx tsc --noEmit — 30 pre-existing errors, byte-identical set to the merge base (no new type errors)
  • Diff vs upstream 39658a9 verified: src hunks identical except one patch-branch context line (DEFAULT_BOOT_RECLAIM_MAX_DELETES)

Port of upstream rohitg00#1182 (39658a9) onto the
v0.9.29-patch line, adapted only for this branch's ledger-era
index-persistence (same gate, same vocabulary, same tests).

Index shard writes, manifest publishes, and generation reclaims record
no user-data deletions, yet a single save() emits several index_persist
audit rows; on a real store they reached 59876 of 84028 entries (71%).
On this branch they would also dominate the new AGENTMEMORY_AUDIT_MAX
retention window within hours of sustained capture (~4 rows per 5s
debounced save) and evict genuine deletion records, so they are now
opt-in via AGENTMEMORY_AUDIT_INDEX_PERSIST=1 (trimmed, case-insensitive
1/true; 0/false/anything else stays off).

- src/state/index-persistence.ts: auditIndexPersistEnabled() gate,
  verbatim from upstream
- test/index-persistence.test.ts: gating suite ported verbatim
  (default-off, affirmative vocabulary, off vocabulary, persistence
  unaffected) — 12 new tests, suite now 1756 passing
- plugin/skills/agentmemory-config/REFERENCE.md: regenerated (52 vars)
- CHANGELOG.md: document the new default under [Unreleased]
@codeasier
codeasier merged commit 252fa25 into v0.9.29-patch Sep 28, 2026
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