Repository navigation
Cover data.state with integrity and bundle version 2 - #181
Merged
Merged
Conversation
data.state becomes an optional activity group: committed only on rows that have it and left out of the leaf, erased and stamped by scrub only there, counted in stamped_state_rows, listed in the erasure journal and re-applied by reapply_erasures. An export with a state row in scope is bundle version 2, decided by a pre-scan before header.json; every other bundle stays version 1. Lift the guard that refused record_state with integrity.
- Fail a sealed row whose data.state is present and null with COMMITMENT_MISMATCH (group state), in verify() and verify_bundle(). - Require an integer bundle_version in the header and the manifest. - A scrub record outside the scope that holds data.state now raises its own error naming the row; the "export again" guard covers only the rows the pre-scan reads. - Docs: upgrade every sealer and verifier to 0.8 before turning on record_state with integrity; the pre-scan is one extra pass over the activity rows in scope. - Tests for state tampering, the export guards and the 0.7 scrub record bytes.
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.
Closes #51
Integrity now covers
data.state(row state), andrecord_stateworks withAuditTrail(integrity=...).stateis an optional activity group: committed only on rows that have it, left out of the leaf (ERASABLE_DATA_KEYS).scrub()erases it likepayloadand stampsstateonly on rows that have the key; theaudit.scrubbedpayload getsstamped_state_rowsonly when nonzero.verify()checks the erased form and counts (absent means 0).state;reapply_erasures()erases and stamps it again.staterow in scope isbundle_version2 (header and manifest), decided by anEXISTSpre-scan per run of seal blocks beforeheader.json. The reader accepts 1 and 2; a version 1 bundle with astategroup or null key is malformed; a ledger bundle is always 1.data.state = null. The guard refusingrecord_statewith integrity is removed.canonical.md,bundle-v1.md), the integrity, privacy and models guides, and new vectors (astatecommitment, a leaf, a journal, five bundles).Compatibility
data.v, leaf and commit tags unchanged.git diff origin/main -- docs/spec/vectorsshows additions only; the existing bundle vectors regenerate byte for byte.bundle version 2 is not supported.verify()run against a database holding 0.8 state rows reportsROOT_MISMATCH/COMMITMENT_MISMATCH; upgrade every sealer and verifier to 0.8 before writing state with integrity (a 0.7 sealer does lasting damage; see below).Review follow-up
record_statewith integrity. A 0.7 sealer hashesdata.stateinto the leaf, so 0.8'sverify()fails those blocks withROOT_MISMATCHfor good, and once a scrub erases the state they can never verify. That cannot be undone; a 0.7 verifier is only a false alarm.statefails.check_groups(used byverify()andverify_bundle()) fails a sealed row whosedata.stateis present andnullwithCOMMITMENT_MISMATCH, groupstate, detailstored as null, before the salt/stamp checks. No writer stores it and a scrub erases a null to the mark, so it is never legitimate. I kept an existing failure kind instead of adding a new one: it is waivable like the others and needs no new report or CLI surface.canonical.mdand the bundle spec's group-check steps state the rule.payload/changesare unchanged. The Go verifier checks ledger bundles only (it refuses anybundle_versionbut 1 and never reads audit row groups), so it needs no change.data.stateraises its own error naming theaudit.scrubbedrow: no scrub writes a state, so the row was changed, and exporting again would not help. I chose this over widening the pre-scan: the scrub records are found only by the stamps read during the export, and finding them up front would need a scan of every activity row (there is noverbindex), while that tampered row is already averify()failure.EXISTSquery has no index to use: one extra pass over the activity rows in scope.bundle_versionmust be an integer (not a bool) in the header (both the audit and the ledger dispatch) and the manifest:true,2.0,1.0and"2"are refused as unsupported versions.verify()and through an exported bundle; the race guard (a state row after the pre-scan); a tampered scrub record outside the scope; and a 0.8audit.scrubbedpayload compared byte for byte with what 0.7.0 stores for the same scrub (checked against the 0.7.0 tag). Unit: non-integer versions, atruemanifest version, a null state in a version 2 bundle, andcheck_groupson a null state.