Repository navigation
feat(cli): let boss mcp ledger verify detect records removed from the end - #998
Closed
Antriksh1984 wants to merge 1 commit into
Closed
Antriksh1984 wants to merge 1 commit into
Antriksh1984 wants to merge 1 commit into
Conversation
kshivang
force-pushed
the
dev
branch
3 times, most recently
from
September 22, 2026 04:42
bdcf620 to
bc9aa3b
Compare
… end The MCP ledger's hash chain links each record to the one before it, so an edit to a retained record or a broken link between two retained records was already detectable. Deleting records off the tail of the file was not: the chain still looked intact because nothing recorded how many records the file was supposed to hold. McpOperationLedger now writes a periodic anchor (record count plus the running hash) alongside the ledger, and boss mcp ledger verify --anchor compares the file against it, reporting a truncation the hash chain alone cannot see.
Antriksh1984
force-pushed
the
feat/mcp-ledger-truncation-anchor
branch
from
September 22, 2026 10:03
0375297 to
6fb6874
Compare
Contributor
Author
Collaborator
|
Thanks so much for this contribution, @Antriksh1984 - the work here is genuinely appreciated, and it's clear real care went into it. This overlaps with #1001 ("fix(cli): neutralise plugin manifest text in boss plugin validate and link"), which is further along in review and will carry this change forward. To keep review attention focused, I'm closing this one in favor of #1001 - please do review and follow that PR, and you're very welcome to pick up any part of it that still needs help or take on another open issue. Your contribution credit is noted here, and anything unique in this branch that #1001 misses is still welcome as a follow-up. Thanks again for contributing to BossConsole! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #995 (the diff below also shows its commits until it lands; this PR is the last commit).
The gap
The MCP operation ledger is hash-chained, and
boss mcp ledger verifywalks the chain. That proves no record was edited, inserted or removed from the middle. It cannot prove the ledger has not been cut short: a chain with its newest records deleted is still a perfectly valid chain, so deleting the tail of the audit trail (the records documenting what an agent just did) verifies asintact. So does replacing the whole history with a fresh chain of records that never happened.docs/CLI.mdalready says so: removing only the newest tail "cannot be distinguished from normal retained history without an external checkpoint". This PR is that checkpoint.The gap is pinned by a test (
truncating the end of the ledger still verifies as intact without an anchor), so the anchor tests are known to close something real.What changes
verifynow prints the head hash (Head: <sha256> (record N of M)) and includesheadHash/headRecordIndexin--json. That is the value an operator writes down somewhere outside the ledger's directory.verify --anchor <hash>fails (exit 1, verdictanchor-missing) when the chain no longer contains that record, and otherwise reports where it sits and how many verified records were written since.broken, thenincomplete, thenanchor-missing: a broken chain is reported as broken and an anchor cannot rescue it, and a ledger with a hole in its rotated history is not called truncated when the anchor may simply be in the missing file.Decisions worth a look
tailprints a 12-character prefix for reading, which is deliberately not accepted here.) Uppercase is accepted and normalised.McpLedgerVerificationgains defaulted fields,verifyChaingains a defaulted parameter, and existing output only gains theHead:line.Tests
McpLedgerAnchorTest(10): head hash in text and JSON; an anchor in the chain is found with the count since; truncation passes plain verify but fails with the anchor; full-history replacement fails the anchor; an anchor in a rotated backup is found; an anchor cannot rescue a broken chain (reported as broken, anchor "not checked"); full uppercase hash accepted and short/long/non-hex/empty values refused; JSON carriesanchorHash,anchorRecordIndexand theanchor-missingverdict.McpLedgerCliTest18/18,McpLedgerChainTest17/17,McpOperationLedgerTest13/13 unchanged and green.ktlintCheckanddetektclean.docs/CLI.mdupdated.