Files
ruflo/v3/@claude-flow/security/__tests__
ruv f090628452 fix(policy): anchor the decision ledger head so truncation fails verification (#3568)
The ADR-324 decision ledger is a hash chain, which rejects a modified or
deleted-middle receipt but not a deleted tail: a prefix of a valid chain is
itself a valid chain. Deleting the most recent receipts, or all of them, from
.claude-flow/policy/state.json still verified as valid: true.

- PolicyState gains ledgerHead/ledgerLength, updated in the same state write
  as every receipt append.
- verifyLedger fails with policy-ledger-truncated (or
  policy-ledger-anchor-mismatch) when the chain disagrees with its anchor, and
  answers an empty ledger distinctly (state: 'empty').
- appendReceipt refuses to extend a chain that no longer matches its anchor,
  so a new decision cannot re-anchor a truncated ledger and erase the evidence.
- Ledgers written before the anchor existed verify as valid and are anchored
  once (anchor: 'established-now'); truncation before that point is not
  detectable and is not claimed to be.
- verifyPolicyLedger is now a locked read instead of a write transaction, whose
  own post-operation check turned every failure into a generic
  policy-ledger-verification-failed. `policy verify` exits 1 when invalid.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 17:58:52 -04:00
..
2026-01-04 17:40:48 +00:00