Repository navigation
Chain the first event after a prune from the truncation anchor - #1831
Merged
Merged
Conversation
The contract says how the next event row is linked after a prune leaves the event table empty, and what the chain walk accepts after a truncation anchor. It adds no code. Refs #1811. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…genesis restart After a prune that leaves no row, the next event is linked to the hash of the last row the prune deleted (the truncation anchor), read in the same write transaction as the tail read, and to genesis only when there is no anchor either. The chain walk no longer accepts a first row that links to genesis after an anchor: that row reads as broken. The earlier test case that pinned the restart now pins the link to the anchor, and a new test file adds nine cases. Refs #1811. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds the progress and decisions entries for the change, marks the earlier decision about an emptied table as replaced by it, and regenerates the AD ledger. Refs #1811. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Nov 18, 2026
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.
Refs #1811
What changes
After a prune empties the event table, the next event no longer restarts the hash chain at genesis, and the chain walk no longer accepts a genesis restart after a truncation anchor.
EventLog._insert_chained_row(src/probos/substrate/event_log.py) started every append atGENESIS_HASHand replaced it only with the hash of a tail row. A prune whose age stage deletes every row records the last deleted row's hash inevents_truncation_anchor(BF-942), but the next append, finding no tail row, linked to genesis, andverify_chainthen accepted that genesis-linked first row after the anchor (BF-942's decision D4). Now:BEGIN IMMEDIATEtransaction as the tail read and chains from itsrow_hashverbatim (an empty hash included), and from genesis only when there is no anchor either. A tail row decides exactly as before. This is the rule the AD-1278AuditLog.appendalready follows.broken,(False, its id), withanchor_idset. Unanchored chains (unanchored,detached_at),wipe()(it deletes the anchor with the rows, so a wiped log starts at genesis),_compute_row_hash,prune,_delete_head, the schema andChainVerdictare unchanged.brokenat that row until its next prune that deletes a row moves the anchor (decision D3, case A7); no row is rewritten and no migration runs. The reach is the code from BF-942's merge (2026-11-09) to this change, an age prune that left no row, and an append after it. The Captain's vessel is not in that state: a copy of itsevents.db, read raw before any code opened it, has no anchor table (BF-942's schema creates the table at start-up, so BF-942's code has not run on that store), 0 of 1.tests/test_bf980_eventlog_anchor_restart.pyadds 9 cases (a realEventLogundertmp_path; each asserts the state it needs before its effect). The one BF-942 case that pinned the restart (test_after_a_prune_empties_the_table_the_next_row_links_to_the_anchor) now pins the link to the anchor, with its reason inline; that file stays at 22 cases.DECISIONS.md(the BF-980 entry; BF-942's D4 line points to it),PROGRESS.mdand the regenerated AD ledger pair. The rest of the diff is the contract (prompts/bf-980-eventlog-anchor-restart.md).Commits
ff2ea0981129872f41bc07a5Review and the broad gate
Review. Two passes by the
Diff Reviewerongpt-6.1-sol(the model read back from the session log's usage records, including the first dispatched model), both over the frozen candidate41bc07a5. Round 1 (the whole candidate, 16 minutes) found properties 1 to 7 and 9 holding, each executed on a realEventLog: the append's statement order isBEGIN, the tail read, the anchor read only when no tail row exists,INSERT,COMMIT(4 statements on a populated append, 5 on an empty-table append); an anchor-read failure rolls back and propagates; a prune and an append in two processes endtruncatedin both orders; the new file fails 6 of its 9 cases on the base code and the rewritten BF-942 case fails alone, each at its effect line; no other hunk touchesprune,_delete_head,wipe, the schema,ChainVerdictor the BF-873 code. Its verdict was NOT READY on one P3 that concerns the review input and not the candidate: my brief named the replay's working copy of the vessel'sevents.db, which the replay's own run had opened throughEventLog.start()(that creates an empty anchor table), so property 8's premise "no anchor table before start" could not be shown on that file; the behaviours property 8 asks for held on it. Round 1b (property 8 only, a fresh reviewer, 6 minutes, on the pristine copy of the vessel'sevents.db) held: head and base both readunanchored,(False, 415101)before and after an append, and after a prune that deleted all 1,796 rows the head's next row links to the anchor hash while the base's links to genesis (both readtruncated); nothing contradicts the claims inDECISIONS.mdandPROGRESS.mdabout the vessel's store. READY, 0 findings. Size findings: 0 in both passes. No repair followed either pass, so there is no delta to review again.Size findings: 0 (no size finding in either review pass).
The broad gate. One run of the canonical wrapper on the frozen head
41bc07a53079809572007521f22dee59ca4875ed(tree2937dd55b7f5c9e2afa5ea1416be328f6238ebdf), after the last review and with no change since:scripts/run_test_gate.py --label bf980 --receipt logs/gates/bf980.receipt.json, 3 workers, on a host with nothing else running. Result:54193 passed, 184 skipped, 246 warnings, 7 subtests passed in 1:42:51, exit 0. The receipt validates (54,377 tests collected and reported on 3 workers) and binds the committed tree; the live-data manifest taken before and after the run is identical (54,107 files, none added, removed or changed). The count is the previous gate's (bf938-1680b: 54184 passed, 184 skipped) plus the 9 cases of the new test file; the rewritten BF-942 case replaces one and adds none.origin/mainwas60e2c36bat the start of the run and at the push.Evidence
tests/test_bf980_eventlog_anchor_restart.pyfails 6 of its 9 cases (A1, A2, A4, A7, A8 and A9, each at the effect line the contract names; A3, A5 and A6 pass because they pin what must not change), and with the base code the rewritten BF-942 case alone fails (1 failed, 21 passed).test_ad490,test_bf873,test_database_retentionandtest_event_log) 81 passed; the 36 test files that import the event log or use it throughtests/bf934_world.py2,204 passed and 2 skipped (a POSIX-only symlink case);tests/test_ad1184_ad_ledger.py33 passed.scripts/gen_ad_ledger.py --check,check_architecture_principles.py --checkandcheck_store_registry.py --checkpass; the gate wrapper's preflight exits 0.GENESIS_HASHin the append fails A1, A4, A8, A9 and the rewritten BF-942 case; restoring the genesis exception in the walk fails A2 and A7; removing thewipeclearing of the anchor fails A5 and the BF-942 wipe case; the unanchored-path row fails the two BF-942 cases that guard it. Rows 3 and 4 fail more cases than the contract names (3 and 29 more), which is recorded and is not a defect.events.db(1,796 rows, ids 415101 to 416896, no anchor table, read raw before any code opened it; the pristine copy's hash was unchanged by the probes; two scratch copies were used): with an ordinary start the head and the base readunanchored,(False, 415101)before and after one append, and the new row links to the old tail; with an age prune that deletes all 1,796 rows (anchor id 416896) the head's next row links to the anchor hash and the base's to genesis, and both readtruncated. The live store was never opened (the live-data manifest before and after the broad gate is identical, see above).What this pull request does not do
brokenat that row until its next deleting prune (D3), and none is known.verify_chain(there is none insrc,scriptsorui/srcfor the event log), so no running code reads the changed verdict.events.dbcan do undetected: forge the anchor and a matching cut, rewrite rows and every later hash, or delete the newest rows or every row after the anchor (the next append then chains from the anchor, as after a prune). That is BF-942's limits L1 and L2; this change narrows only the genesis-restart half of BF942-F5 (Follow-up: residual findings from the #1722 / #1604 / #1723 / #1724 / #1736 / #1741 wave (reserves BF-954) #1754, noted there after this merges).wipe()reset in the chain (the function has no production caller).