audit: stratum.audit/verify-chain + IAuditable#24
Merged
Conversation
New stratum.audit namespace mirrors datahike's audit shape so bridges can pass results through without translation: - IAuditable protocol: -merkle-root (cheap, may return nil; never throws) and -recompute-merkle-root (returns a result map: :ok/:mismatch/ :unsupported with :root and :errors). - verify-chain walks the dataset commit DAG from a branch HEAD, recomputes each dataset commit-id and each referenced index commit-id under :crypto-hash?, reports advisory for non-crypto-hashed indexes. - :deep? walks every reachable column's PSS tree directly from konserve (bypassing CachedStorage LRUs), recomputes each node's address via cached-storage/gen-address, and surfaces any leaf/branch whose bytes no longer hash back to its address. - IAuditable extended for live PersistentColumnIndex and StratumDataset values so callers can verify in-memory handles too. cached-storage: extracted attach-pss-handlers so audit (and any other caller that needs to deserialize PSS nodes from a raw konserve store without standing up a full CachedStorage) can wire the Fressian read handlers up cheaply. Tests cover clean walk, dataset-cid-recipe-coverage boundary, layer-1 mismatch on cid-bearing fields, layer-1 mismatch on index commits, deep-walk leaf tampering, advisory mode without :crypto-hash?, the verify-pss-tree-from-cold helper, and IAuditable on live values. Signed-off-by: Christian Weilbach <christian@weilbach.name>
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.
Summary
New
stratum.auditnamespace with the same protocol shape as datahike's audit, so bridges across repos pass results through without translation.IAuditableprotocol:-merkle-root(cheap, may return nil; never throws) and-recompute-merkle-root(returns a result map:{:status :ok|:mismatch|:unsupported, :root, :errors, :reason}).verify-chainwalks the dataset commit DAG from a branch HEAD, recomputes each dataset commit-id and each referenced index commit-id under:crypto-hash?, advisory-flags non-crypto-hashed indexes.:deep? truewalks every reachable column's PSS tree directly from konserve (bypassing CachedStorage LRUs), recomputes each node's address viacached-storage/gen-address, and surfaces any leaf/branch whose bytes no longer hash back to its address.IAuditableextended for livePersistentColumnIndexandStratumDatasetso callers can verify in-memory handles too.Supporting change
cached-storage/attach-pss-handlersextracted so audit (and any other caller that needs to deserialize PSS nodes from a raw konserve store without standing up a fullCachedStorage) can wire the Fressian read handlers up cheaply.Companion datahike work
The matching datahike branch (
feature/audit-chainon replikativ/datahike) lazily delegates its stratum-secondary-recompute-merkle-rootintostratum.audit/-recompute-merkle-rootwhen this lib is on the classpath; older stratum versions degrade to:unsupported :reason :stratum-audit-unavailable.Test plan
clojure -M:replthen runstratum.audit-test— 12 tests / 35 assertions pass:okdataset-cid-recipe-coveragedocuments the layer-1 boundary (only fields hashed into the cid recipe are caught):mismatch:mismatchwith the column flagged:deep?reports:mismatchwith:audit/merkle-mismatchat the right address:crypto-hash?→:advisoryverify-pss-tree-from-coldstandalone helper: clean + tamperedIAuditableon livePersistentColumnIndexandStratumDataset