Skip to content

v0.2.0 — Write audit hook & token accounting

Choose a tag to compare

@theBeautifulIce theBeautifulIce released this 06 Nov 05:15
· 44 commits to main since this release

dsh-Immunity-memory 0.2.0

本版新增写入审计 Hook、待确认候选队列与审计 token 账本。

This release adds a write-audit gate for memory mutations, a reviewable candidate queue, and per-run audit token accounting, together with entity keys, provenance, and supersedes.

Highlights

  • Write-audit hook (hook.*, default off): every memory_write / memory_update is reviewed by a tool-less isolated subagent against the user's turn, with enforce vs shadow mode, a confidence threshold, and fail-open behavior on timeout, missing services, or audit-storage errors.
  • Candidate queue: low-confidence and needs_user decisions wait in the audit tab. Approving a pending candidate applies the exact reviewed payload; rejecting it leaves the existing memory untouched.
  • Token accounting: input, output, cache-read, cache-write, and total tokens are recorded per run and aggregated on the audit page, including the session-persistence fallback for real subagent activations.
  • Entity keys, provenance, and supersedes: same-key writes update in place, quote keeps the user's exact wording, turn records where it came from, and supersedes archives older versions without injecting them again.
  • Hardened approval path: concurrent decisions are serialized, a crash-recovered candidate is adopted instead of duplicated, long candidate content survives approval intact, and rejecting an update candidate no longer archives the untouched target.

Upgrade notes

  • Existing SQLite databases migrate automatically; no manual step is required.
  • The hook stays disabled by default. Enable it in Settings → Write audit, then choose enforce or shadow mode.
  • ttlDays is still mandatory for every mutable write and update; this release does not weaken the hard TTL rule.
  • The technical plugin id is still dsh-memory-plugin; existing installs and tool names are unchanged.

Verification