feat(memory): append WARD-C6 CompactionLedger events on warded-surface compaction#393
Conversation
Record WARD-C6 compaction_ledger audit rows for each ward_manifest surface when the Coven store is compacted, carrying pre/post commitments in the single daemon-owned ward_audit table. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
✅ Nova sign-off — WARD-C6 CompactionLedger Reviewed against the Pre/post commitment pair — ✅ Three decision states — ✅
All three are meaningful audit events. Missing-post is the critical one — it's the proof that an implementation can't silently drop a warded surface during vacuum. Non-warded stores skip ledger — ✅ Channel = Append-only enforced — ✅ CI: Rust checks (ubuntu + windows), CodeQL all ✅. One note: Merging. |
There was a problem hiding this comment.
Pull request overview
This PR wires the SQLite store vacuum/compaction entry point (vacuum_store_path, used by coven vacuum and POST /store/vacuum) to emit WARD-C6 compaction_ledger audit rows into the daemon-owned ward_audit table for each warded surface present in ward_manifest at compaction time.
Changes:
- Capture pre-compaction
ward_manifestentry hashes and appendcompaction_ledgerrows toward_auditafter vacuuming. - Add helpers to load warded surface commitments pre/post compaction and compute a compaction decision tag.
- Add tests covering ledger emission for warded stores, no-op behavior for non-warded stores, and
ward_auditappend-only enforcement.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| conn.execute_batch("PRAGMA optimize; VACUUM;") | ||
| .context("failed to vacuum Coven store")?; | ||
| let _ = conn.execute_batch("PRAGMA wal_checkpoint(TRUNCATE);"); | ||
| let integrity_check = pragma_integrity_check(&conn)?; | ||
| append_compaction_ledger_events(&conn, &pre_compaction)?; |
| let format = time::format_description::well_known::Rfc3339; | ||
| let now = time::OffsetDateTime::now_utc().format(&format)?; | ||
| for pre in pre_compaction { | ||
| let post = load_warded_surface_commitment(conn, &pre.familiar_id, &pre.surface)?; | ||
| let decision = match post.as_deref() { |
Summary
Implements bead
threads-2q5: wires the daemon store compaction entry point (vacuum_store_path, reached bycoven vacuumandPOST /store/vacuum) to append WARD-C6compaction_ledgerevents into the existing daemon-ownedward_audittable.Per grimoire §9 C6 / the two-compaction contract, each warded surface present in
ward_manifestat compaction time gets one audit row carrying:ward_hashdiff_hashfiles_touchedforcedchannel and a compacted decision tagNon-warded stores append no compaction ledger rows.
Validation
cargo fmt --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspace --lockedpython scripts/check-secrets.py