From 3109341caf9ffeb111a3a8cf5a7503e2325ebab4 Mon Sep 17 00:00:00 2001 From: John Calhoun Date: Sun, 29 Nov 2026 01:11:54 -0500 Subject: [PATCH 1/4] docs: the Word and CheckError docs name the published 0.9.0-beta.10 (for #56 and #47) The nine-word match and the five-fault match these doc comments quote are the published 0.9.0-beta.10's; 0.9.0-beta.11 is the unpublished release that carries Word::Handed and the new faults, so naming it was untrue. Two `///` lines, no code. Co-Authored-By: Claude Opus 5.5 --- src/evidence.rs | 2 +- src/state.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/evidence.rs b/src/evidence.rs index 04ccef2..face1c0 100644 --- a/src/evidence.rs +++ b/src/evidence.rs @@ -61,7 +61,7 @@ pub(crate) fn digest(tx_bytes: &[u8]) -> (TxId, u64) { /// outside this crate names the faults it reads and carries a wildcard arm. /// A fault a host does not name still means "not `mined`", so the wildcard /// arm is safe here, where [`Word`](crate::Word) stays exhaustive on purpose. -/// A match over the five faults of 0.9.0-beta.11 no longer compiles. +/// A match over the five faults of 0.9.0-beta.10 no longer compiles. /// /// ```compile_fail,E0004 /// use bsv_tracker::CheckError; diff --git a/src/state.rs b/src/state.rs index 9d35dc4..643c68e 100644 --- a/src/state.rs +++ b/src/state.rs @@ -40,7 +40,7 @@ impl Mined { /// `Word` is not `#[non_exhaustive]`, on purpose: a word is a decision each /// host makes about what it may do, so a new word breaks every exhaustive /// match on it outside this crate until the host names it. `Handed`, the -/// tenth, did so: a match over the nine words of 0.9.0-beta.11 no longer +/// tenth, did so: a match over the nine words of 0.9.0-beta.10 no longer /// compiles. /// /// ```compile_fail,E0004 From bcc91c0358e5494f92da51214809e8d79c108173 Mon Sep 17 00:00:00 2001 From: John Calhoun Date: Sun, 29 Nov 2026 01:11:54 -0500 Subject: [PATCH 2/4] docs: SPEC maps the tenth word, the record and the two machines (for #56 and #47) The pin of the stack moves to bsv-stack-lean a7ef91de (lean/Tracker.lean, blob c2a6045a), the commit the rows of record name, with the opening table re-cited at it. A new section maps every item of #56 and #47 to the Lean definition it mirrors, says the two machines (the latch by default, the door behind Params::recheck_conflicted), lists what the crate does that the stack's model does not mirror yet (the named join, leaf.4, the split under the door, the door's fault, theorem (iv) over the door), and gives a host the sentences issue 57 left for a page. Each sentence was read from src/ and the tests at the base. Co-Authored-By: Claude Opus 5.5 --- docs/SPEC.md | 93 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 16 deletions(-) diff --git a/docs/SPEC.md b/docs/SPEC.md index 6e7a83a..0d3e0fe 100644 --- a/docs/SPEC.md +++ b/docs/SPEC.md @@ -1,21 +1,22 @@ # Mapping to the executable charter -[SRC] All Lean citations on this page refer to `bsv-stack-lean@f95520fcd85e066ec341faffa9dd8f1f8f35a37e lean/Tracker.lean`, apart from the section "The length of a transaction", which names its own commit. The charter is `docs/charters/tracker.md` at the same pin. The Rust projection is an implementation under test, not a new node rule. +[SRC] All Lean citations on this page refer to `bsv-stack-lean@a7ef91de104944e3b02c920a935e8549c19dcc89 lean/Tracker.lean` (blob `c2a6045a`), apart from the section "The length of a transaction", which names its own commit. The charter is `docs/charters/tracker.md` at the same pin. The Rust projection is an implementation under test, not a new node rule. `tests/vectors/tracker/rows_of_record.json` names the same commit and blob as its source. | definition | Rust surface | reading | |---|---|---| -| `State.init` | `State::new` | private state prevents direct writes | -| `hintWord`, `agrees`, `onHint`, lines 252, 259, 270 | `State::on_hint` | three upward hint moves, newest received hint, agreeing hint keeps pending trigger | -| `onHost`, line 295 | `State::on_host` | build and abandon only in the host tier; spend and age produce triggers | -| `onProof`, line 306 | `State::on_proof`, `Headers::check` | reduce a real SDK path, bind the txid, match the active header, keep it | -| `onCompetitor`, line 320 | `State::on_competitor` | the host identifies a competing input spend; a mined word stands and re-asks | -| `recheck`, line 334 | `State::recheck` | matching root clears suspect and the completed trigger, mismatch makes stale, unavailable keeps word | -| `onReorg`, `onFork`, lines 346, 353 | `State::on_chain` | at-or-above comparison bounds the words; a reorg or an invalidation runs `recheck`, stale only when the stored root is not the active header's root (ruling (5), 2026-10-20 19:4xZ) | -| `onInvalidated`, line 361 | `State::on_chain` | match the checked header hash; keep the old evidence | -| `onChain`, line 370 | `State::on_chain`, `Tracker::on_chain` | tip touches suspect only; frozen and tipAge move no word | -| `onVerdict`, line 385 | `State::on_verdict` | mined proof outranks a node's mempool verdict; new competitors precede old ones | -| `step`, `run`, lines 398, 406 | `State::step`, sequential calls | headers are a snapshot per input, with no internal effect loop | -| `reorgReask`, line 705 | `Tracker` mined-height range index | exactly affected txids, bounded by what the host tracks | +| `State.init`, line 296 | `State::new` | private state prevents direct writes | +| `hintWord`, `agrees`, `onHint`, lines 312, 323, 338 | `State::on_hint` | upward hint moves only (`built` or `handed` to `announced` or `seen`, `announced` to `seen`), newest received hint, agreeing hint keeps pending trigger, a hint that moves the word empties the list of instances | +| `onHost`, line 432 | `State::on_host` | build, abandon, hand-over, discharge and the end of a hold only in the host tier; spend, age and the re-announce produce triggers | +| `onProof`, line 446 | `State::on_proof`, `Headers::check` | reduce a real SDK path, bind the txid, match the active header, keep it; a proof that writes `mined` empties the list of instances | +| `onCompetitor`, line 490 | `State::on_competitor` | the host identifies a competing input spend; the tracked txid itself is refused; a checked competitor goes on the record of the conflict; a mined word stands and re-asks | +| `recheck`, line 507 | `State::recheck` | matching root clears suspect and the completed trigger, mismatch makes stale, unavailable keeps word | +| `onReorg`, `onFork`, lines 528, 535 | `State::on_chain` | at-or-above comparison bounds the words; a reorg or an invalidation runs `recheck`, stale only when the stored root is not the active header's root (ruling (5), 2026-10-20 19:4xZ) | +| `onInvalidated`, line 545 | `State::on_chain` | match the checked header hash; keep the old evidence | +| `onChain`, line 553 | `State::on_chain`, `Tracker::on_chain` | tip touches suspect only; frozen and tipAge move no word | +| `onVerdict`, line 586 | `State::on_verdict` | mined proof outranks a node's mempool verdict; new competitors precede old ones and go on the record with no proof | +| `step`, `run`, lines 600, 608 | `State::step` with `Params::recheck_conflicted` off, sequential calls | headers are a snapshot per input, with no internal effect loop | +| `stepRecheck`, `runRecheck`, lines 2462, 2471 | `State::step` with `Params::recheck_conflicted` on | the machine with the door: see "The tenth word and the record of a conflict" | +| `reorgReask`, line 1215 | `Tracker` mined-height range index | exactly affected txids, bounded by what the host tracks | [D] Differences of representation: real owned BRC-74 paths replace Lean's reduced `(height, root)`; `Mined` wraps an immutable checked capability and derives its height; the capability and state's record share an allocation. Header and proof failures add a returned `CheckError` after the Lean-compatible re-ask update. Header freshness and tip coherence are host obligations; checking a proof above the host's tip fails closed. The retained depth is a snapshot annotation, not a Lean word field. Rust heights and times are finite. An overflowing age deadline remains not due, matching the natural-number comparison. Raw `Verdict` metadata is retained beside its reduced hint and never read by evidence transitions. @@ -23,19 +24,19 @@ [X] `cached_host_check_cannot_bypass_fail_closed_snapshot_lookup` exercises a host returning an old capability from its `check` override while current header lookups fault. Own and competitor proofs fail closed. Transitions wrap the host's snapshot methods and invoke the default `Headers::check`, preserving the single capability constructor and current-snapshot check. -`mined_implies_checked_proof` checks every prefix of randomized evidence, hint and host traces. A mined word's stored path is for its own txid and height, computes the retained header's merkle root, and has positive depth. The only writing transition constructs both the word and retained record from the same checked capability. This corresponds to the invariant at Lean lines 666-670. It does not establish that the host's header snapshot is the node's active chain. +`mined_implies_checked_proof` checks every prefix of randomized evidence, hint and host traces. A mined word's stored path is for its own txid and height, computes the retained header's merkle root, and has positive depth. The only writing transition constructs both the word and retained record from the same checked capability. This corresponds to the invariant `Evidenced` at Lean lines 617-619. It does not establish that the host's header snapshot is the node's active chain. `stale_iff_header_inactive` (0.7.0, in place of `reorg_reasks_at_or_above`; ruling (5) of 2026-10-20 19:4xZ) generates registries containing mined and unmined words at random heights and a new branch that moves the roots at a random subset of the heights at or above the fork. It compares the indexed result set to the exact at-or-above set, asserts stale plus the reorg trigger for every selected word whose root moved, full state equality for every selected word whose root holds, and full state equality for every other transaction. This exercises `reorg_spares_below`, `reorg_spares_unmined`, `reorgReask_only`, the bound and the stale-by-the-root rule. `hint_changes_no_chain_word` inserts random hints into random evidence and host traces. It compares chain words, retained evidence and suspect marks before and after each hint, and checks that any changed hint-tier word is one of the three allowed moves. This is the charter's theorem (iii), including the no-new-claim half. -`same_evidence_same_word` feeds two instances identical evidence and header snapshots but independently generated hints and host acts around each evidence input. It compares the chain words, evidence and suspect marks after every prefix. It intentionally does not compare `Announced` with `Seen`, matching `Word.chain` and theorem (iv). +`same_evidence_same_word` feeds two instances identical evidence and header snapshots but independently generated hints and host acts around each evidence input. It compares the chain words, evidence and suspect marks after every prefix. It intentionally does not compare `Announced` with `Seen`, matching `Word.chain` and theorem (iv). It runs over the latch alone: the Lean states theorem (iv) of `step`, and over the door two hosts agree on the word only where they hold the same record (`sameViewOtherRecord`, line 3365). `mined_implies_checked_proof`, `stale_iff_header_inactive` and `hint_changes_no_chain_word` run each trace under both machines. [X] Each property has 256 cases with an explicit deterministic ChaCha seed, failure persistence disabled, and random trace lengths up to 79 inputs. The full local results are in `VERIFICATION.md`. These Rust checks are not a formal Lean refinement proof or an execution of the Lean evaluator; that link remains unverified [D]. ## Landed recheck rule -[SRC] The earlier stack pin retained a successful recheck's trigger. At the final pin, `lean/Tracker.lean:340` clears `reask` along with `suspect`, matching the charter and scenario table. [X] The crate follows this rule; `successful_recheck_clears_completed_spend_and_fork_triggers` failed on the old Rust transition, then passed after the correction. Unavailable headers continue to keep the mined word and schedule `Recheck`. +[SRC] An earlier stack pin retained a successful recheck's trigger. At this page's pin, `lean/Tracker.lean:512` clears `reask` along with `suspect`, matching the charter and scenario table. [X] The crate follows this rule; `successful_recheck_clears_completed_spend_and_fork_triggers` failed on the old Rust transition, then passed after the correction. Unavailable headers continue to keep the mined word and schedule `Recheck`. [D] The new #31 spendability predicate and host confirmation-depth policy remain host adapter work under this lane's integration exclusion. `Params` holds the age threshold and, as the Lean's `Params.spendDepth`, the host's spend depth, which `doubts::spendable_eff` reads (for #51). @@ -43,6 +44,66 @@ [SRC] `bsv_tracker::doubts` mirrors `lean/Headers/Doubts.lean` and `lean/Headers/Host.lean` of the stack, not `lean/Tracker.lean`, and sits beside the reducer above, never inside it. Its page is [DOUBTS.md](DOUBTS.md): every public item beside the Lean name it mirrors at the stack's commit, the stored form, the printed line, the feed's named number and the snapshot, what is not mirrored, and the test of record. +## The tenth word and the record of a conflict (for #56 and #47) + +[SRC] Mirrored from `lean/Tracker.lean` at this page's pin: the section "The word `handed`" and the definitions it names, and the section "The recheck of `conflicted`" from line 2361 to `runRecheck`. The tests of record replay the namespaces `Tracker.HandedRows` and `Tracker.LeafRows` under the machine each row's source runs it in (`tests/tracker_rows.rs`), and the theorems of both sections are properties under their names (`tests/handed_properties.rs`, `tests/recheck_properties.rs`; `docs/VERIFICATION.md` records each beside its theorem). + +### The items + +| Lean | Rust surface | new or changed | what the crate answers | +|---|---|---|---| +| `Word.handed`, line 106 | `Word::Handed` | new (a break: `Word` is not `#[non_exhaustive]`) | the bytes left the host's hands for named instances and none has answered; `Word::chain` answers `None` | +| `State.handedTo`, line 283 | `State::handed_to() -> &[HandedTo]`; `HandedTo { instance, at }`, `#[non_exhaustive]`, `HandedTo::new`, a serde form | new | the instances handed the bytes and not discharged, each with its latest hand-over's time, in the order of each instance's earliest hand-over | +| `HostAction.handOver`, `onHandOver`, `renew`, `clearReannounce`, lines 392, 379, 385 | `HostAction::HandOver { instance, at }` | new | `unknown`, `built`, `handed`: `handed`, the instance added at the end or its time renewed in its place, a pending `Reask::Reannounce` cleared; `abandoned`: the state whole; any other word: only a pending `Reannounce` cleared | +| `HostAction.discharge`, `onDischarge`, line 402 | `HostAction::Discharge { instance }` | new | from `handed`, the instance leaves the list (compared with the hand-over's `instance`, never a hint's `source`), and the word is `built` when the list is empty; any other word untouched | +| `HostAction.endHold`, `onEndHold`, line 411 | `HostAction::EndHold` | new | `unknown`, `built`, `handed`: `abandoned`, the list emptied, a pending `Reannounce` cleared; any other word untouched. A received payment's act: the crate cannot see where a transaction came from | +| `abandonWord`, line 351 | `HostAction::Abandon` | unchanged | refused from `handed` | +| `oldestHandOver`, `handedDue`, `onTick`, lines 417, 421, 427 | `HostAction::Tick` | changed | the age re-ask as before; else `Reask::Reannounce` on `handed` when the oldest hand-over plus the age threshold is at most the tick's time (checked addition); never on `built` | +| `Reask.reannounce`, line 232 | `Reask::Reannounce`, label `reannounce`, compact re-ask tag `7` | new | post the bytes again to each instance on the list; never a proof request | +| `hintWord`, `onHint`, lines 312, 338 | `State::on_hint` | changed | `handed` to `announced` on an acceptance or a courier's mempool presence, to `seen` on a sighting; a hint that moves the word empties the list; no hint lowers `handed` | +| `onProof`, `verdictHanded`, lines 446, 580 | `Evidence::Proof`, `NodeVerdict` | changed | a proof that writes `mined` and a node's `rejected` empty the list; a node's `conflicted` and a competitor's proof keep it | +| `spendable`, line 1675 | `doubts::guard`'s rule arm | changed (one arm) | `handed` is spendable under a rule that allows it and under no other, and reads no header | +| `structure Competitor`, `Competitor.standing`, lines 271, 2380 | `Competitor`: private fields, readers `txid()`, `tx_len()`, `checked()`, `gone()`, `standing()`; no public constructor, no serde | new | a competitor on the record: its checked proof and header, or none for one a node named; whether a recheck found its root gone. `tx_len()` is the length section's (ahead of the Lean) | +| `State.rivals`, `State.prior`, line 283 | `State::rivals() -> &[Competitor]` (the newest at the front), `State::prior() -> Option<&Word>` | new | the record of the conflict, beside and never in the evidence, kept with its marks after the word leaves `conflicted`; the word held when the conflict began | +| `onCompetitor`, `conflictWord`, `keptRivals`, `keptPrior`, lines 490, 464, 470, 476 | `Evidence::Competitor` | changed | in order: the tracked txid itself is refused (`CheckError::TxidMismatch`, `Reask::ProofFailed`, the word and the record untouched; `competitor_is_another`, line 2963); a proof not built from the competitor's bytes is refused (`CheckError::Unmeasured`, the length section); then the header check. A checked competitor on a word that is not `mined` writes `conflicted` with itself at the front and goes on the record with its proof; a conflict that begins starts its own record and keeps the word of its moment as the prior word; a competitor that joins keeps both | +| `onVerdict`, `verdictRivals`, `verdictPrior`, lines 586, 569, 574 | `NodeVerdict::Conflicted`, `NodeVerdict::Rejected` | changed | `conflicted` puts its competitors at the front of the word and of the record, with no proof, and keeps the prior word as a competitor's proof does; `rejected` leaves the record and the prior word; a `mined` word only re-asks | +| `rootGone`, `unanswered`, `markGone`, lines 2384, 2393, 2399 | inside the recheck of the conflict | new | a competitor's root is gone exactly when a header is there at its proof's height with another root (`rootGone_iff`); no header and a headers fault are not gone | +| `leaveWord`, line 2407 | inside the recheck | new | `seen` returns as `announced`; `mined`, `conflicted` or no prior word read `unknown`; every other word as it was | +| `recheckConflict`, line 2419 | `Evidence::Recheck` and the chain events below, on a `conflicted` word, under the door | new | an empty record: nothing. Every competitor gone: `leave_word(prior)`, the record kept and marked, `Reask::CompetitorGone` naming the word's competitors, the suspect mark cleared, the list kept only when the word returned to is `handed`. A standing competitor unanswered: `conflicted` on the standing ones, `Reask::Recheck`, the mark as it was, and the fault of the unanswered competitor nearest the front. Else `conflicted` on the standing ones, the marks cleared | +| `rivalAtOrAbove`, `rivalCheckedAgainst`, `onChainConflict`, lines 2437, 2444, 2452 | `Evidence::Chain` on a `conflicted` word, under the door | new | a reorg at or below a standing competitor's height marks and rechecks; an invalidation of a standing competitor's checked header marks and rechecks; a fork at or below one marks it with `Reask::Fork`; a tip rechecks a marked word | +| `Reask.competitorGone`, line 232 | `Reask::CompetitorGone { competitors }`, label `competitor_gone`, compact re-ask tag `8` | new | fetch the tracked transaction's proof and the named competitors' again | +| `conflictedAtOrAbove`, `conflictReask`, `conflictReads`, lines 3120, 3125, 3129 | `Tracker::on_chain`, two indexes of the `conflicted` words (their standing checked competitors' heights and headers) | changed, under the door alone | the selection adds those words after the `mined` ones, no txid twice; one header read per standing competitor with a proof (`conflictReads_le`); with the door off the selection and every output are the latch's | +| (the choice of machine) | `Params::recheck_conflicted: bool`, `false` in `Params::new`; `Params::with_recheck_conflicted` | new (`Params` is `#[non_exhaustive]`) | which of `step` and `stepRecheck` the host runs | + +`State`'s equality compares the list of instances, the record and the prior word. The compact form carries all three (version 2; `src/compact.rs`'s module page is its table): a version 1 row reads as the same state with the list and the record empty and no prior word. + +### The two machines + +The Lean keeps two functions, `step` and `stepRecheck`, equal on every input but a chain event or an executed recheck that finds a `conflicted` word (`stepRecheck_eq_step`, line 2705). The crate is one `State::step` that reads `Params::recheck_conflicted`, so a host chooses once, in the parameters every entry point already carries (`State::step`, `Tracker::apply`, `Tracker::on_chain`). + +- **The latch**, the default (`false`, the Lean's `step`). A `conflicted` word stays `conflicted` under every chain event and recheck (`step_conflicted_latched`, line 2671). It leaves only by the transaction's own checked proof, which writes `mined` from any word (`returned_then_mined`), or by a node's `rejected`. +- **The door** (`true`, the Lean's `stepRecheck`). A `conflicted` word meeting `Evidence::Chain` or `Evidence::Recheck` goes through the recheck of the conflict; every other input is the latch's step. The recheck reads the host's header at each standing competitor's height that carries a proof, one read each, and nothing more: no depth, no doubt and no clock. What starts it is a row of the feed or the host's executed recheck, never a timer. + +Both machines answer the length rule, the refusal of the tracked txid as its own competitor, and every arm of the tenth word alike. A host turns the door on only when its own rules for a returned word are ready: a coin it released while the payment read `conflicted` is still released after the return unless the host locks it back. + +### What the crate does that the stack's model does not mirror yet + +- **The named join** `[AHEAD OF THE LEAN]`. When a competitor's proof or a node's `conflicted` verdict joins a `conflicted` word, each id of the word's list with no entry on the record goes on it as a named competitor, after the entries the record holds, before the joiner is entered (`name_the_unrecorded`). Only a row restored from version 1 bytes, whose record is empty, lists such an id; its competitors then stand as named ones, so under the door that row never leaves by a chain event or a recheck. `keptRivals` keeps the joining competitor alone and has no such step. Every transcribed row starts from the initial state, so none reaches it: the crate's own tests pin it (`docs/VERIFICATION.md`). +- **One row of `LeafRows` cannot be written in the crate's types** (`leaf.4`, "A competitor named C with X's proof", line 3104). `Evidence::Competitor(Proof)` names the competitor by the txid its proof is bound to, so a proof of another leaf cannot be offered for C. The replay lists it by name as not spelled. +- **The crate's split and resolved split under the door.** The stack's `ChainEvent` has no split. The crate's split meets a `conflicted` word as a fork, and its resolved split as the tip of a marked word at or below a standing competitor, as both meet a `mined` word. +- **The door's fault.** The Lean's machine answers no error. The crate writes the state and then answers `CheckError::Unavailable(h)` or `CheckError::Headers(e)` for the unanswered standing competitor nearest the front of the record, as its `recheck` does for a `mined` word. +- **A competitor's length** (`Competitor::tx_len`) and the competitor door's refusal of a proof not built from its bytes: the length section's, ahead of a Lean that holds no length. +- **Theorem (iv) over the door.** `same_evidence_same_word` is stated of `step`; over the door two states can agree on `view` and hold different records (`sameViewOtherRecord`), so the crate promises that two hosts agree on the word under the door only where they hold the same record. + +### What a host must know + +- **A repeated verdict grows the state.** A node's `conflicted` verdict puts its ids at the front of the word's list and of the record whether or not they are there already, as the Lean's `verdictWord` and `verdictRivals` do; a competitor's proof offered twice is entered twice. A host feeds a node's verdict once per verdict it obtained, not on every poll. +- **A `Reask::Reannounce` can outlive its word.** A hint that raises `handed` to `announced` or `seen` empties the list and keeps a pending re-ask, as the Lean's `onHint` does; the re-ask then names no instance to post to. The host posts nothing for it; the next hand-over, or any later re-ask, replaces it. +- **`HostAction::EndHold` is never fed for a transaction of the host's own.** The crate cannot tell, and moves `unknown`, `built` and `handed` to `abandoned` for whatever it is fed. +- **`Evidence::Competitor` takes what the host has shown.** The hash of the competitor's bytes is the crate's check; that those bytes spend an input of the tracked transaction is the host's, which the crate cannot see. A competitor known only by someone's word is a hint or a node's verdict. +- **An `Err` from `Tracker::restore` has two meanings**, and a host that overrides `Headers::check` takes over the refusal of a proof that carries no length: the length section says both. +- **A restore marks a `mined` word suspect and a `conflicted` one not.** A `conflicted` row restores exactly, its record and its stored mark as written. Under the door a host that wants it read against today's headers feeds it `Evidence::Recheck`. + ## The length of a transaction A transaction of exactly 64 bytes is never taken as proven by a merkle path (BRC-237's condition for an anchor; bsv-rs enforces it in its own verifier, its public advisory GHSA-jjhc-7hvh-c3hm). This crate holds a txid and a path and compares the root with the host's header itself, so no library it pins applies the rule here: the crate is told the transaction's length, measured from its bytes or stated by its host, and every door that takes a proof reads it. From 706ed18a15365a22bd8929dd82d0e991869a7d4c Mon Sep 17 00:00:00 2001 From: John Calhoun Date: Sun, 29 Nov 2026 01:11:54 -0500 Subject: [PATCH 3/4] docs: README, the hand-over and the door, with an example that runs (for #56 and #47) A host building on the next prerelease reads how to feed HandOver, Discharge and EndHold, what Reannounce asks, and what the door does beside the latch. The example is a doc test: it hands a payment to two instances, discharges one, re-announces, takes a hint, meets a checked competitor, and shows the latch keep conflicted where the door returns the payment to announced with CompetitorGone. Co-Authored-By: Claude Opus 5.5 --- README.md | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/README.md b/README.md index 3cc30e5..86d16ed 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,112 @@ Since 0.7.0 it moves `built` to `announced`, as an acceptance does: someone announced the transaction, and the same hint gives the same word whether or not this host did. It writes no chain word. +## The hand-over and the door + +A post that leaves the host and is never answered was invisible before the +tenth word. The host now says it: `HostAction::HandOver { instance, at }`, +fed and stored before the bytes leave, writes `Word::Handed` from `unknown`, +`built` or `handed`, with the instance on `State::handed_to()` (its time +renewed in its place when it is handed again). `HostAction::Discharge { +instance }` says that instance answered and keeps nothing: it leaves the +list, and the word returns to `built` when the list is empty. A tick one age +threshold after the oldest hand-over asks `Reask::Reannounce`: post the +bytes again to each instance on the list, never a proof request; the next +hand-over clears it. An acceptance or a courier's mempool presence raises +`handed` to `announced`, a sighting to `seen`, and either empties the list; +no hint lowers it, and `HostAction::Abandon` is refused once the bytes were +handed. `HostAction::EndHold` is a received payment's +act: it ends the hold on `unknown`, `built` or `handed` as `abandoned`. The +crate cannot see where a transaction came from, so a host never feeds it +for a transaction of its own. A host stores the list by `HandedTo`'s serde +form, `{"instance":"arcade","at":1700000000}`. + +A checked competitor's proof writes `conflicted`, puts the competitor on the +record of the conflict (`State::rivals()`, with its proof and its own +length) and keeps the word held when the conflict began (`State::prior()`); +a node's `conflicted` verdict puts its competitors on the record with no +proof. With `Params::recheck_conflicted` off, the default, `conflicted` is a +latch: it leaves only by the transaction's own checked proof or a node's +`rejected`. With it on (`Params::new(..).with_recheck_conflicted(true)`), a +reorg at or below a standing competitor's height, an invalidation of the +header one was checked against, a tip or a resolved split once a fork or a +split marked the word, and an executed `Evidence::Recheck` read the host's +header at each standing competitor's height; when every competitor's root is gone the word returns to the prior +word (`seen` as `announced`) with `Reask::CompetitorGone`, which asks the +host to fetch the transaction's proof and the named competitors' again. A +competitor a node named has no root to lose and never leaves this way. A +host turns the door on only when its own rules lock back a coin it released +while the payment read `conflicted`. + +```rust +use std::collections::BTreeMap; +use bsv_rs::transaction::{MerklePath, MerklePathLeaf}; +use bsv_tracker::{Evidence, HandedTo, Header, HeaderError, Headers, Height, Hint, HintStatus}; +use bsv_tracker::{HostAction, Input, Params, Proof, Reask, State, Word}; + +// The host's own verified headers, by height. +struct Verified(BTreeMap); +impl Headers for Verified { + fn header_at(&self, height: Height) -> Result, HeaderError> { + Ok(self.0.get(&height).cloned()) + } + fn tip_height(&self) -> Result { + Ok(self.0.keys().next_back().copied().unwrap_or(0)) + } +} + +fn main() -> Result<(), Box> { + let latch = Params::new(60, 1); + let door = Params::new(60, 1).with_recheck_conflicted(true); + let mut headers = Verified(BTreeMap::new()); + let hand = |instance: &str, at| Input::Host(HostAction::HandOver { instance: instance.into(), at }); + + // The payment is built, then handed to two instances before each post leaves. + let mut payment = State::measured(&[0x5a_u8; 191]); + payment.step(&latch, &headers, Input::Host(HostAction::Build))?; + payment.step(&latch, &headers, hand("arcade", 1_000))?; + payment.step(&latch, &headers, hand("taal", 1_005))?; + assert_eq!(payment.word(), &Word::Handed); + + // One answered and keeps nothing; the other never answers. + let taal = Input::Host(HostAction::Discharge { instance: "taal".into() }); + payment.step(&latch, &headers, taal)?; + assert_eq!(payment.handed_to(), [HandedTo::new("arcade", 1_000)]); + payment.step(&latch, &headers, Input::Host(HostAction::Tick(1_060)))?; + assert_eq!(payment.reask(), Some(&Reask::Reannounce)); // post again, fetch nothing + payment.step(&latch, &headers, hand("arcade", 1_061))?; + assert_eq!(payment.reask(), None); + + // The instance takes it: the word is `announced` and the list is empty. + let accepted = Hint::new("arcade", HintStatus::Accepted, 1_062); + payment.step(&latch, &headers, Input::Hint(accepted))?; + assert_eq!(payment.word(), &Word::Announced); + assert!(payment.handed_to().is_empty()); + + // A competitor spends one of its inputs and is mined at 100. The host has + // shown that these bytes spend our input; the crate checks their hash. + let rival_tx = [0x6b_u8; 191]; + let rival = State::measured(&rival_tx).txid().to_owned(); + let leaves = vec![MerklePathLeaf::new_txid(0, rival.clone()), MerklePathLeaf::new(1, "bb".repeat(32))]; + let proof = Proof::new(&rival_tx, MerklePath::new(100, vec![leaves])?)?; + headers.0.insert(100, Header { hash: "cc".repeat(32), merkle_root: proof.root()? }); + payment.step(&latch, &headers, Input::Evidence(Evidence::Competitor(proof)))?; + assert_eq!(payment.word(), &Word::Conflicted { competitors: vec![rival.clone()] }); + assert_eq!(payment.prior(), Some(&Word::Announced)); + + // The competitor's block leaves the active chain. + headers.0.insert(100, Header { hash: "dd".repeat(32), merkle_root: "ee".repeat(32) }); + let mut latched = payment.clone(); + latched.step(&latch, &headers, Input::Evidence(Evidence::Recheck))?; + assert_eq!(latched, payment); // the latch: `conflicted` stands + payment.step(&door, &headers, Input::Evidence(Evidence::Recheck))?; + assert_eq!(payment.word(), &Word::Announced); // the door: the word held before + assert_eq!(payment.reask(), Some(&Reask::CompetitorGone { competitors: vec![rival] })); + assert!(payment.rivals()[0].gone()); // the record is kept, marked + Ok(()) +} +``` + ## Kinds a later release adds `Word` is not `#[non_exhaustive]`: a new word is a decision for every host, so From 149a7063fd44f02002d9fba8ffab6a431119002e Mon Sep 17 00:00:00 2001 From: John Calhoun Date: Sun, 29 Nov 2026 01:11:54 -0500 Subject: [PATCH 4/4] changelog: one account of the line under Unreleased (for #56 and #47) The Unreleased section told the line eight times, one entry set per lane, each repeating the last. It is now one Hosts paragraph, for a host of the published 0.9.0-beta.10 (the word, Proof::new on bytes, CheckError, Params::new, Tracker::restore's Result, compact version 2 and what a version 1 row reads as, the door's flag, the competitor refusal), then Added, Changed, Tests and Documents, each fact said once. Every backticked item of the old section is kept but those that named states between lanes (an intermediate sha of the rows file, a renamed test, the step from three empty fields to four). Nothing folded, nothing bumped. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 239 ++++++++++++++++++++------------------------------- 1 file changed, 92 insertions(+), 147 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 675a973..95af04e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,62 +2,25 @@ ## [Unreleased] -### Hosts: what a host changes to take the record of a conflict and the recheck of `conflicted` (for #47) +Three rows of this line, each told once below: the tenth word `handed` with its acts and its re-ask (for #56); the record of a conflict, the word it began from and the recheck of `conflicted` behind `Params::recheck_conflicted` (for #47); and the transaction's measured length (GHSA-jjhc-7hvh-c3hm, BRC-237). The tenth word and the record mirror bsv-stack-lean's `lean/Tracker.lean` at `a7ef91de` (blob `c2a6045a`, the same file the lanes read at `08ce467d`, `901e9dfa` and `9a727a64`): the section "The word `handed`" with the definitions it names, and the section "The recheck of `conflicted`" (`onCompetitor`, `onVerdict`, `keptRivals`, `keptPrior`, `verdictRivals`, `verdictPrior`, `leaveWord`, `recheckConflict`, `onChainConflict`, `rivalAtOrAbove`, `rivalCheckedAgainst`, `stepRecheck`, `conflictReask`). The length is ahead of the Lean: `lean/Tracker.lean` at `9a727a64` holds no length (its name there will be `State.txLen`); the rule's words are the stack's `docs/DECISIONS-2026-10-19.md` 32.13. -**A host changes nothing to keep today's machine, and one answer moves for every host.** (1) The latch is the default: `Params::new` sets `Params::recheck_conflicted` to `false`, and with it off a `conflicted` word stays `conflicted` under every chain event and recheck, as before; it leaves only by its own checked proof or a node's `rejected`. (2) For every host, in either mode: a proof offered as a competitor's whose txid is the tracked transaction's is refused, `Err(CheckError::TxidMismatch)` with `Reask::ProofFailed` and nothing else moved, where the latch wrote `conflicted` on the tracked transaction from its own proof. A competitor is another transaction; such bytes go to `Evidence::Proof`. (3) What a host must have checked before it feeds `Evidence::Competitor`: the hash of the competitor's bytes is the crate's check (the proof is built with `Proof::new` from those bytes); that those bytes spend an input of the tracked transaction stays the host's, which the crate cannot see. A competitor known only by someone's word is a hint or a node's verdict. (4) A host that turns the door on, `Params::new(..).with_recheck_conflicted(true)`, feeds its header feed's rows as it does today (`Tracker::on_chain`, or `Evidence::Chain` and `Evidence::Recheck` on one state); after a restore it feeds `Evidence::Recheck` to a `conflicted` word it wants read against today's headers (a restored record is not marked suspect); and on `Reask::CompetitorGone` it fetches the tracked transaction's proof and the named competitors' again. It turns the door on only when its own rules for a returned word are ready: a coin it released when the payment read `conflicted` is still released after the return unless the host locks it back. (5) `State`'s equality compares the record and the prior word; a match on `Reask` outside the crate already carries a wildcard arm (`#[non_exhaustive]`), and `Reask::LABELS` appends `competitor_gone`. +### Hosts: what a host of the published 0.9.0-beta.10 changes to take this line (for #56, #47, GHSA-jjhc-7hvh-c3hm) -```rust -// The latch, today's machine: nothing to change. -let params = Params::new(3600, 1); -// The door, when the host's own rules lock back a returned payment's inputs. -let params = Params::new(3600, 1).with_recheck_conflicted(true); - -// Before: a competitor's proof for the tracked txid wrote conflicted [txid]. -// This line, for every host: refused; the proof door takes such a proof. -assert_eq!( - state.step(¶ms, &headers, Input::Evidence(Evidence::Competitor(own_proof))), - Err(CheckError::TxidMismatch) -); -``` - -### Added: the record of a conflict, the word it began from, and the door (for #47) - -Mirrored from bsv-stack-lean's `lean/Tracker.lean` at `a7ef91de` (section "The recheck of `conflicted`"; `onCompetitor`, `onVerdict`, `keptRivals`, `keptPrior`, `verdictRivals`, `verdictPrior`, `leaveWord`, `recheckConflict`, `onChainConflict`, `rivalAtOrAbove`, `rivalCheckedAgainst`, `stepRecheck`, `conflictReask`). - -- `Competitor`, re-exported at the crate root (`Tracker.Competitor`): a competitor on the record, with private fields and the readers `txid()`, `tx_len()`, `checked()`, `gone()` and `standing()`. `tx_len()` is the competitor's own measured length, `Some` for a competitor entered by a proof (never 64) and `None` for one a node's verdict named; it is never the tracked transaction's measure (ahead of the Lean, whose `Competitor` has no length yet). No public constructor and no serde form: a checked proof has neither. -- `State::rivals() -> &[Competitor]` (`State.rivals`), the newest at the front, and `State::prior() -> Option<&Word>` (`State.prior`), the word held when the conflict began. A checked competitor's proof puts the competitor on the record with its proof and length; a node's `conflicted` verdict puts its competitors on it with neither, so no root rechecks them; a conflict that begins starts its own record and keeps the word of its moment as the prior word; a later competitor joins it. A `rejected` verdict and a `mined` word's re-ask leave both. The record is kept, with its marks, after the word leaves `conflicted`. -- `Params::recheck_conflicted: bool`, `false` in `Params::new`, and `Params::with_recheck_conflicted` (`Params` is `#[non_exhaustive]`: no host breaks). `State::step` reads it: off, the latch (`Tracker.step`); on, the machine with the door (`Tracker.stepRecheck`), where a `conflicted` word meeting a chain event or an executed recheck goes through the recheck of the conflict and every other input is the latch's step. -- The recheck reads the host's header at each standing competitor's height that carries a proof, one read each. A header with another root marks the competitor gone; no header, or a headers fault, is not gone. Every competitor gone: the word returns to `leave_word(prior)` (`seen` returns as `announced`; `mined`, `conflicted` or none would read `unknown`; every other word as it was, `handed` with its instances), with `Reask::CompetitorGone { competitors }` naming the word's competitors, the record kept and marked, the suspect mark cleared. A standing competitor unanswered: `conflicted` on the standing competitors, `Reask::Recheck`, the mark as it was, and `Err(CheckError::Unavailable(h))` or `Err(CheckError::Headers(e))` for the unanswered competitor nearest the front. Else `conflicted` on the standing ones, the marks cleared. An empty record and a competitor a node named never leave this way. A restored version 1 `conflicted` row's competitors stand on the record as named ones once a competitor or a verdict joins the word (each id of the word's list with no entry on the record goes on it as named, ahead of `onCompetitor` and `onVerdict` in bsv-stack-lean's `lean/Tracker.lean` at `9a727a64`), so under the door such a row never leaves by a chain event or a recheck. -- The feed under the door, as for `mined`: a reorg at or below a standing competitor's height marks the word and rechecks; an invalidation of a standing competitor's checked header marks and rechecks; a fork at or below one marks it with `Reask::Fork`; a tip rechecks a marked word and reads nothing for an unmarked one. The crate's split meets a `conflicted` word as a fork, and its resolved split as the tip of a marked word at or below a standing competitor, as both meet a `mined` word (the stack's `ChainEvent` has no split). -- `Tracker` keeps two indexes for `conflicted` words: the heights of their standing checked competitors and the headers those were checked against. Under the flag alone, `Tracker::on_chain` adds the words they select to a reorg's, a fork's, a split's and an invalidation's targets, after the `mined` words and with no txid twice. With the flag off the selection and every output are the latch's. -- `Reask::CompetitorGone { competitors: Vec }`, label `competitor_gone`, compact re-ask tag `8`. -- `Evidence::Competitor`'s doc says what the host must have shown: the hash of the competitor's bytes is the crate's check, and the spend of our input stays the host's. - -### Changed: a competitor's proof for the tracked txid is refused, and the compact form carries the record (for #47) - -- `State::step` on `Evidence::Competitor`, in order: a proof whose txid is the tracked one is refused (`CheckError::TxidMismatch`, `Reask::ProofFailed`, the word and the record untouched; `Tracker.competitor_is_another`); then the competitor's own length (a proof not built from its bytes is `CheckError::Unmeasured`); then the header check. -- The compact form fills the two fields version 2 already carries, with no new version: no published release reads version 2. The record: a varint count, then each competitor's txid (an id), its length (`0`, or `1` and a varint), its checked proof (`0`, or `1` and the record as the evidence field writes it, read back as a record and never checked against headers) and its mark. The prior word: `0`, or `1` and a word as the word field writes it. Re-ask tag `8`, competitor gone, and its ids. A record restores exactly, its competitors not marked suspect; a version 1 row restores with an empty record and no prior word. -- Refused, through the variants `CompactError` has: re-ask tag `8` under version 1 (`Malformed("re-ask tag")`); a prior word `mined` or `conflicted` (`Malformed("prior word")`); a competitor's checked proof with no length (`Malformed("competitor's proof with no length")`); a length beside a competitor with no proof (`Malformed("named competitor with a length")`); a competitor with no proof marked gone (`Malformed("named competitor marked gone")`); a competitor that is the tracked transaction, or whose proof is another transaction's (`Evidence(CheckError::TxidMismatch)`); a competitor's length of 64 (`Evidence(CheckError::AmbiguousLength)`); a competitor's record that does not hold together (`Evidence(_)`). Instances now stand only beside `handed` and beside `conflicted` whose prior word is `handed` (`Malformed("instances beside a word that holds none")`). -- `tests/compact_golden.rs`: every golden string is byte-identical but `conflicted_by_ids_and_text`'s tail, where the node's verdict now writes its two competitors on the record and the prior word `unknown`; its old ending is quoted in its doc. `version_1_bytes_still_restore` and `version_2_is_version_1_with_four_empty_fields` read that one state's record apart; `handed_refusals` and `tests/compact.rs`'s `version_2_refusals` lose the refusals of a record "held empty in this release"; `an_instance_beside_each_word_of_record` reads the list kept beside `conflicted` only when its prior word is `handed`. -- Tests: `tests/transitions.rs` (the latch over a `conflicted` word under every chain event and a recheck; a competitor's proof for the tracked txid, refused in both modes, the latch's old answer quoted; the record and the prior word; a competitor's length and the tracked transaction's measure kept apart, the K4 scope of the crate's issue 57; the door's rows over one state), `tests/reorg_by_root.rs` (the latch's outputs over a registry with `conflicted` words, unchanged with the flag named off; the selection under the door; one header read per standing competitor with a proof), `tests/compact.rs` (a state with a record round-trips; the record's refusals; the round trip's generator feeds the door), `tests/labels.rs` (`competitor_gone`), a unit test of `leave_word`. `tests/handed_properties.rs`'s `handed_to_only_beside_handed` is tightened to `conflicted` whose prior word is `handed`, both ways. - -### Tests: the recheck of `conflicted`'s tests of record (for #47) - -Mirrored from bsv-stack-lean's `lean/Tracker.lean` at `a7ef91de` (blob `c2a6045a`): the rows of the namespace `Tracker.HandedRows` from "The competitor's proof goes on the record" to its end and the namespace `Tracker.LeafRows`, and the theorems of the section "The recheck of `conflicted`". The crate is one machine with a mode; its tests run the Lean's rows of both machines, each under its own. - -- `tests/vectors/tracker/rows_of_record.json` (sha256 `0e8f13056b9fd5dfd0785f870c0347f1565a918176216f87313c6ec9fec2d3e1`) gains the 47 rows of the record and the door and the 5 of `LeafRows`, one row one `#guard`, its text verbatim, and one row of the crate's own (`self_competitor_refused`, `Tracker.competitor_is_another` at a taken payment); every row names its group and its machine, and each input of a trace the machine the source passes it through (`run P` or `runR`). 99 rows: the 46 of the word under `step`; of the 53, 45 under the door and 8 under the latch. `LeafRows`' competitor named "C" offered X's proof is listed by name as not spelled: the crate names a competitor by its proof's own txid. -- `tests/tracker_rows.rs`, `rows_of_record_recheck` (new): every row of the 53 under its own machine, `0 divergences, 1 not spelled, 0 ahead of the Lean` (no row starts from a state stored before the record existed, so none meets the crate's named join); then the 54 rows of the latch a second time through the door wherever `stepRecheck_eq_step`'s premise holds at every step of the row's traces: 52 replayed, 1 not covered (`returned.5`, the latch's own reorg on `conflictedT`), 0 divergences. The `vectors` job runs it by name beside `rows_of_record_handed` and greps its three lines: 14 named passes. -- `tests/recheck_properties.rs` (new): 23 properties, each named for its Lean theorem (`step_conflicted_latched` to `conflictReask_only` and `conflictReads_le`), and 3 of the crate's own (`a_competitors_length_is_its_own`, the length rule's scope: a competitor's length never moves the tracked transaction's measure, 64 included; `no_run_lists_an_id_whose_only_entry_is_gone`; `conflicted_from_handed_keeps_its_list`). 256 cases each from the fixed ChaCha seed, no failure persistence; every trace runs under both machines, with two competitors whose proofs are built from their bytes, and each premise is met in some case. -- `tests/properties.rs`: `mined_implies_checked_proof`, `stale_iff_header_inactive` and `hint_changes_no_chain_word` run each trace under both machines with two competitors; `same_evidence_same_word` stays over the latch: two hosts agree on the word under the door only where they hold the same record. `tests/compact.rs`: the generator runs each step under either machine with two competitors; `a_conflicted_word_and_its_record_name_the_same_competitors` reads the row's conflict before the step, so a return by that very step is checked (it was not), and fails when the named join is removed. `tests/scenarios.rs`: the three scenarios of record run under both machines and give the same states step by step. -- `tests/compact_golden.rs`: four goldens with a record, each spelled field by field, each competitor's length beside the tracked transaction's own field: `conflicted_with_a_checked_competitor` (prior `announced`), `conflicted_from_handed` (the instance kept, the competitor's 191 beside the tracked transaction's 65), `conflicted_named_by_a_node` (no length, no proof), `returned_with_the_record_marked` (`announced`, `competitor_gone`, the mark); `record_refusals`, #47's refusals as bytes beside them; and `a_record_with_no_prior_word_is_written_by_a_run_and_restores` (a restored version 1 row that a competitor joined: read, not refused). -- Refused, in the compact form: `conflicted` whose prior word is `handed` with no instance (`Malformed("conflicted from handed with no instance")`), whose return would be `handed` with none; no run writes it. The named join and the door's selection keep the ids they hold in a set; behaviour unchanged. +**A host of 0.9.0-beta.10 changes each exhaustive match on `Word`, every call that builds a `Proof`, each exhaustive match on `CheckError`, each `Params` literal and each call of `Tracker::restore`; it may start feeding three acts and turning on one door; and one answer moves for every host.** Every break below stops compiling; none changes meaning in silence. -### Hosts: what a host of 0.9.0-beta.11 changes to take the tenth word (for #56) - -**A host of 0.9.0-beta.11 changes each exhaustive match on `Word`, and may start feeding three acts.** (1) `Word` has a tenth word, `Word::Handed`, and is still not `#[non_exhaustive]`, on purpose: every exhaustive match on `Word` outside the crate stops compiling (E0004) until it names the word, because each place that names words must decide what `handed` means for it. (2) A host that feeds no `HostAction::HandOver` never sees `Word::Handed`, and every word it sees is the word it saw at 0.9.0-beta.11: no other act, hint or evidence writes it (the Lean's `handedNamed_run` and the arms of `step` in `lean/Tracker.lean` at bsv-stack-lean `08ce467d`). Once a host feeds the act, a rule that reads a word by its text or through a wildcard arm reads `handed` as whatever that arm says, in silence; name each before feeding the act. (3) A re-ask of the new kind `Reask::Reannounce` asks the host to post the bytes again to each instance of `State::handed_to()`; it is never a proof request, so a host that fetches a proof for every due re-ask whatever its kind fetches the wrong thing for it. `Reask::LABELS` gains `"reannounce"` at its end. (4) `State::to_compact` writes version 2 of the compact form. Version 1 bytes a host stored still restore, as the same state with no instance; an older crate refuses version 2 bytes with `CompactError::UnknownVersion(2)` and restores nothing. +1. **The tenth word.** `Word::Handed`: the bytes left the host's hands for named instances and none has answered. `Word` is still not `#[non_exhaustive]`, on purpose: every exhaustive match on `Word` outside the crate stops compiling (E0004) until it names the word, because each place that names words must decide what `handed` means for it. A host that feeds no `HostAction::HandOver` never sees `Word::Handed`: no other act, hint or evidence writes it (the Lean's `handed_only_by_handOver` and `handedNamed_run`). Once a host feeds the act, a rule that reads a word by its text or through a wildcard arm reads `handed` as whatever that arm says, in silence: name each before feeding the act. +2. **The acts, when the host feeds them.** `HostAction::HandOver { instance, at }` before each post, fed and its result stored before the bytes leave, with the host's time of the post; `HostAction::Discharge { instance }` when that instance answered and keeps nothing; `HostAction::EndHold` for a received payment whose hold is spent, never for a transaction of the host's own (the crate cannot tell them apart). The list is `State::handed_to()`, stored by `HandedTo`'s serde form. A re-ask of the new kind `Reask::Reannounce` asks the host to post the bytes again to each instance on the list; it is never a proof request, so a host that fetches a proof for every due re-ask whatever its kind fetches the wrong thing for it. A hint that raises `handed` keeps a pending `Reannounce` and empties the list, so the re-ask can name no instance: the host posts nothing for it. +3. **`Proof::new` takes the transaction's bytes.** `Proof::new(&raw_tx, path)` hashes them to bind the txid and yields no proof for exactly 64 bytes (`CheckError::AmbiguousLength`): a transaction of 64 bytes is never taken as proven by a merkle path (BRC-237's condition for an anchor; bsv-rs enforces it in its own verifier, its public advisory GHSA-jjhc-7hvh-c3hm), and this crate compares the root itself, so it is told the length. A host with no bytes where it builds a proof calls `Proof::with_stated_len(txid, stated_len, path)`: the length is the host's word, which the crate cannot check, and a host with no length has no proof. A host hands the bytes where tracking begins (`Tracker::track_bytes(&raw)` or `State::measured(&raw)`), or later (`State::measure`); the state keeps the measure (`State::tx_len()`), a later proof is checked against it, and a restore brings it back. A state measured at 64 takes no proof, so the host asks none for it. A competitor's proof is built from the competitor's bytes, or it is refused (`CheckError::Unmeasured`). +4. **`CheckError` has three more values and is `#[non_exhaustive]`**: a match on it names them and carries a wildcard arm. A proof taken out of a state's record carries no length: a measured state takes it, and `Headers::check`, `doubts::may_enter` and an unmeasured state refuse it. A host that overrides `Headers::check` takes over that refusal; the crate's own doors never call a host's override. +5. **`Params` is built by `Params::new(age_threshold, spend_depth)`** and is `#[non_exhaustive]`: the literal of 0.9.0-beta.10 is refused (#51's paragraph under the 0.9.0-beta.11 heading below says it whole). +6. **`Tracker::restore` answers `Result, CheckError>`** where it answered `Option`. A host that matched the `Option` stops compiling, and a bare `tracker.restore(s);` compiles with a warning and the host never sees the fault, so read the `Result`. An `Err` has two meanings: `Err(AmbiguousLength)`, the tracker moved (the row is held, its proof unsaid, and the state it replaced is dropped); `Err(LengthMismatch { .. })`, nothing moved (the row passed in is dropped). A host that wants either value clones it before the call. +7. **The compact form's version 2.** `State::to_compact` writes version 2; 0.9.0-beta.10 wrote version 1 and refuses version 2 bytes with `CompactError::UnknownVersion(2)`, restoring nothing. A version 1 row a host stored still restores, as the state it restored to before, unmeasured, with no instance, an empty record and no prior word. A `mined` row restores `mined`, suspect, with `Reask::Recheck` due, as before; it was written before the crate measured a transaction, so a host that holds its bytes hands them to `State::measure` before it serves the inclusion (at 64 bytes the call answers `AmbiguousLength` and the proof is unsaid). A `conflicted` row restores with an empty record, so under the door it never leaves by a chain event or a recheck. No published release wrote version 2. +8. **The door, off by default.** `Params::new` sets `Params::recheck_conflicted` to `false`: the latch, today's machine, where a `conflicted` word stays `conflicted` under every chain event and recheck and leaves only by its own checked proof or a node's `rejected`. `Params::new(..).with_recheck_conflicted(true)` makes a `conflicted` word return to the word held before the conflict when every competitor on its record has lost its root from the host's headers, `seen` returning as `announced`, with `Reask::CompetitorGone`. A host that turns it on feeds its header feed's rows as it does today (`Tracker::on_chain`, or `Evidence::Chain` and `Evidence::Recheck` on one state); after a restore it feeds `Evidence::Recheck` to a `conflicted` word it wants read against today's headers (a restore does not mark it suspect); and on `Reask::CompetitorGone` it fetches the tracked transaction's proof and the named competitors' again. It turns the door on only when its own rules for a returned word are ready: a coin it released when the payment read `conflicted` is still released after the return unless the host locks it back. +9. **One answer moves for every host, latch or door.** A proof offered as a competitor's whose txid is the tracked transaction's is refused, `Err(CheckError::TxidMismatch)` with `Reask::ProofFailed` and nothing else moved, where 0.9.0-beta.10 wrote `conflicted` on the tracked transaction from its own proof. A competitor is another transaction; such bytes go to `Evidence::Proof`. Before it feeds `Evidence::Competitor` a host has shown that the competitor's bytes spend an input of the tracked transaction, which the crate cannot see; the hash of those bytes is the crate's check. A competitor known only by someone's word is a hint or a node's verdict. +10. **Equality and the labels.** `State`'s equality compares the measured length, the list of instances, the record and the prior word. A match on `Reask` already carries a wildcard arm (`#[non_exhaustive]`), and `Reask::LABELS` appends `reannounce` and `competitor_gone`: a host test that pins the list exactly goes red, which is its job. A node that repeats its `conflicted` verdict grows the word's list and the record each time, as the Lean's does: a host feeds each verdict it obtained once. ```rust -// 0.9.0-beta.11: nine arms, which no longer compile (E0004). +// 0.9.0-beta.10: nine arms, which no longer compile (E0004). fn label(word: &Word) -> &'static str { match word { Word::Unknown => "unknown", @@ -86,10 +49,8 @@ fn label(word: &Word) -> &'static str { Word::Abandoned => "abandoned", } } -``` -```rust -// 0.9.0-beta.11: a rule that compares a word as a string. Once the host +// 0.9.0-beta.10: a rule that compares a word as a string. Once the host // feeds HandOver, a "handed" row falls outside this list in silence: it is // never loaded and never re-announced. const PENDING: [&str; 5] = ["unknown", "built", "announced", "seen", "stale"]; @@ -97,54 +58,6 @@ const PENDING: [&str; 5] = ["unknown", "built", "announced", "seen", "stale"]; const PENDING: [&str; 6] = ["unknown", "built", "handed", "announced", "seen", "stale"]; ``` -```rust -// 0.9.0-beta.11: a stored compact row, version 1, restored. -let state = State::from_compact(&row)?; // row[0] == 1 -// This line: the same row restores to the same state, with no instance; -// what the host writes back is version 2. -let state = State::from_compact(&row)?; // row[0] == 1, still read -assert!(state.handed_to().is_empty()); -let row = state.to_compact(); // row[0] == 2 -``` - -```rust -// This line: a host that hands the bytes over says so before the post -// leaves, and says when an instance answered and keeps nothing. -state.step(¶ms, &headers, Input::Host(HostAction::HandOver { instance: "arcade".into(), at: now }))?; -state.step(¶ms, &headers, Input::Host(HostAction::Discharge { instance: "arcade".into() }))?; -``` - -### Added: the tenth word `handed`, its acts and its re-ask (for #56) - -- `Word::Handed`, mirrored from `Tracker.Word.handed` (`lean/Tracker.lean` at bsv-stack-lean `08ce467d`): the bytes left the host's hands for one or more named instances and none has answered. It claims nothing of the chain (`Word::chain` answers `None`). The doc of `Word` carries a `compile_fail,E0004` doctest of a nine-arm match. -- `State::handed_to() -> &[HandedTo]`, the Lean's `State.handedTo`: the instances handed the bytes and not discharged, each with the time of its hand-over, in the order of each instance's earliest hand-over. `HandedTo { instance, at }` is `#[non_exhaustive]`, built by `HandedTo::new`, re-exported at the crate root, and stored by its serde form (`{"instance":"arcade","at":1700000000}`). -- Three host acts (`HostAction` is `#[non_exhaustive]`, so they add without a break): `HostAction::HandOver { instance, at }` (`onHandOver`: `unknown`, `built` and `handed` read `handed`, the instance added or its time renewed in its place, a pending `reannounce` cleared; an `abandoned` state left whole; any other word keeps its word and only the pending `reannounce` is cleared), `HostAction::Discharge { instance }` (`onDischarge`: from `handed` the instance leaves the list, and the word returns to `built` when it is empty; every other word untouched) and `HostAction::EndHold` (`onEndHold`: `unknown`, `built` and `handed` read `abandoned`, the list emptied, a pending `reannounce` cleared; every other word untouched; a received payment's act, which the crate cannot tell from one of the host's own). -- `Reask::Reannounce`, label `reannounce`, compact re-ask tag `7` (`Tracker.Reask.reannounce`): a host tick on a `handed` word whose oldest hand-over plus the age threshold is at most the tick's time (`handedDue`, checked addition); never on `built`, and the age re-ask keeps its arm before it. -- The list in every other arm, as the Lean writes it: a hint raises `handed` to `announced` (an acceptance or a mempool presence) or `seen` (a sighting), and empties the list whenever it moves the word (`onHint`); no hint lowers `handed`. `abandon` stays refused on `handed`. A proof that writes `mined` empties the list (`onProof`); a node's `rejected` empties it and its `conflicted` keeps it (`verdictHanded`); a competitor's proof keeps it. -- `bsv_tracker::doubts`: the guard's rule arm names `Word::Handed`, as the Lean's `spendable` does: `handed` is spendable under a rule that allows it and under no other, and reads no header. Nothing else in the module moves. -- Tests: nine examples of the arms in `tests/transitions.rs`, one per row of the stack's `docs/p0/tracker-handed-proof-2026-11-27.md` section 3, and the stored form of `HandedTo`. `tests/labels.rs` names the new label. `src/tracker.rs` is untouched. - -### Changed: the compact form's version 2 (for #56) - -- `COMPACT_VERSION` is 2. Version 2 is version 1's layout with word tag `9` (handed), re-ask tag `7` (reannounce) and three fields after the re-ask: the instances (a varint count, each a string and a varint time), the record of a conflict's competitors and the word held when it began. The last two are held empty in this release (a count of `0` and a `0`), and the reader refuses any other value there. Version 1 still reads, as the same state with the three fields empty. -- Refused as `CompactError::Malformed`: word tag `9` and re-ask tag `7` under version 1, re-ask tag `8`, a `handed` word with no instance, an instance named twice, instances beside any word but `handed` and `conflicted` (a conflict that began from `handed` keeps its list), and a count of competitors or a prior word that is not `0`. `CompactError` gains no variant. -- `tests/compact_golden.rs`: the ten goldens re-recorded in a commit of their own, each moved only by its opening byte, `01` to `02`, and three bytes `000000` at its end; `version_1_bytes_still_restore` restores each of the ten version 1 strings, kept verbatim, to the state built today, and `version_2_is_version_1_with_three_empty_fields` pins the relation. `tests/compact.rs`: `version_2_refusals` pins each refusal and the bytes of a `handed` state; two tests that read version 1's layout move by their inputs and keep their answers (version 3 is the unread version; word tag `10` is the unknown tag; the hints count is six bytes from the end). - -### Tests: the word `handed`'s tests of record (for #56) - -Tests alone: no line of `src` moves. The Lean is bsv-stack-lean's `lean/Tracker.lean` at `a7ef91de`. - -- `tests/vectors/tracker/rows_of_record.json` (new, schema `bsv-tracker-rows/1`, sha256 `6c9169e2041ca60d437dbb239ea67d197b3dd970d25f218e3517b9e0f7fa4ff7`): the 46 rows of the word `handed` in the namespace `Tracker.HandedRows`, one row one `#guard`, its text verbatim, each naming the machine it runs under (all 46 under `step`, the machine without the recheck of `conflicted`). `tests/tracker_rows.rs` (new), `rows_of_record_handed`, replays them through the crate's public items, the tracked transaction's proof stated and a competitor's built from its bytes, and prints `46 rows under step, 0 divergences, 0 not spelled`; a row the crate cannot spell would be listed by name. The `vectors` job runs it by name: 13 named passes. -- `tests/handed_properties.rs` (new): 23 properties over 256 traces each, from the fixed ChaCha seed, 22 named for the Lean's theorems of the word (`handOver_writes_handed` through `onEvidence_word`, `handedNamed_run` among them) and one of the crate's own, `handed_to_only_beside_handed` (a list stands beside `handed`, or beside `conflicted`, which keeps it). -- The generators of `tests/properties.rs` and `tests/compact.rs` draw the hand-over, the discharge and the end of a hold (`hand_act` in `tests/common/mod.rs`); `hint_changes_no_chain_word` allows `handed` to `announced` or `seen` and reads the list; the compact round trip reads the list back and reaches `handed` and `conflicted` states that keep one. -- Three goldens in `tests/compact_golden.rs`, the length's byte at their end: `handed_to_one_with_reannounce`, `handed_to_two_one_renewed` and `built_after_discharge` (the bytes of a state only ever built). `handed_refusals` pins #56's refusals as bytes; `an_instance_beside_each_word_of_record` writes an instance into each of the ten states of record. W4 in `tests/scenarios.rs`, `abort_during_a_post_in_flight_is_refused`. -- `docs/VERIFICATION.md` records each property beside its theorem and sixteen faults planted in the word's arms, each failing some of these tests. -- In `tests/length_properties.rs`, the draw asserts that a proof it builds from bytes, or states, is never at 64 bytes. `docs/SPEC.md`: every door that takes a proof reads the length (the recheck compares a stored root without it). - -### Hosts: what a host of 0.9.0-beta.10 changes for the length of a transaction (GHSA-jjhc-7hvh-c3hm, BRC-237) - -**A host of the published 0.9.0-beta.10 changes every call that builds a `Proof`, each exhaustive match on `CheckError`, and each call of `Tracker::restore`.** A transaction of exactly 64 bytes is never taken as proven by a merkle path (BRC-237's condition for an anchor; bsv-rs enforces it in its own verifier, its public advisory GHSA-jjhc-7hvh-c3hm). This crate holds a txid and a path and compares the root itself, so it is now told the transaction's length. The three items are the same at 0.9.0-beta.10 and 0.9.0-beta.11. (1) `Proof::new` takes the transaction's serialized bytes in place of its txid: it hashes them to bind the txid and yields no proof for 64 bytes (`CheckError::AmbiguousLength`). Every old call stops compiling; none changes meaning in silence. (2) A host with no bytes where it builds a proof calls `Proof::with_stated_len(txid, stated_len, path)`: the length is the host's word, the crate cannot check it, and a host with no length has no proof. (3) Hand the bytes where tracking begins (`Tracker::track_bytes(&raw)` or `State::measured(&raw)`), or later (`State::measure`). The state keeps the measure (`State::tx_len()`), a later proof is checked against it, and a restore brings it back; a state measured at 64 refuses every proof, so ask none for it. (4) A competitor's proof is built from the competitor's bytes, or it is refused (`CheckError::Unmeasured`). (5) `CheckError` has three more values and is `#[non_exhaustive]`: a match on it names them and carries a wildcard arm. (6) A proof taken out of a state's record carries no length: a measured state takes it, and `Headers::check`, `doubts::may_enter` and an unmeasured state refuse it. (7) `Tracker::restore` answers `Result, CheckError>` where it answered `Option`: a host that matched the `Option` stops compiling, and a bare `tracker.restore(s);` compiles with a warning and the host never sees the fault, so read the `Result`. `Err(AmbiguousLength)` means the tracker moved (the row is held, its proof unsaid, and the state it replaced is dropped); `Err(LengthMismatch { .. })` means nothing moved (the row passed in is dropped); a host that wants either value clones it before the call. (8) The stored rows. 0.9.0-beta.10 writes compact version 1, and a version 1 row restores unmeasured, as the state it restored to before: a `mined` row restores `mined`, suspect, with `Reask::Recheck` due, and nothing more is asked of it; it was written before the crate measured a transaction, so a host that holds its bytes hands them to `State::measure` before it serves the inclusion (at 64 bytes the call answers `AmbiguousLength` and the proof is unsaid). No published release wrote version 2. A version 2 row reads its last field: a row measured at 64 with no stored proof restores measured at 64 and refuses every proof; a length of 64 beside a stored proof is refused, `CompactError::Evidence(CheckError::AmbiguousLength)`; and version 2 bytes that end before the field are `CompactError::Truncated`. - ```rust // 0.9.0-beta.10: a proof from a txid alone. No longer compiles. let proof = Proof::new(txid.clone(), path)?; @@ -153,9 +66,7 @@ let proof = Proof::new(&raw_tx, path)?; // Err(AmbiguousLength) at 64 bytes assert_eq!(proof.txid(), txid); // This line, where the host holds a txid and a length read from the bytes. let proof = Proof::with_stated_len(&txid, stored_len, path)?; -``` -```rust // 0.9.0-beta.10: the replaced state, or none. No longer compiles. if let Some(old) = tracker.restore(state) { /* ... */ } // This line: each road read. @@ -165,59 +76,93 @@ match tracker.restore(state) { Err(CheckError::LengthMismatch { measured, offered }) => { /* nothing moved */ } Err(fault) => { /* a fault a later release adds */ } } -``` -### Added: the transaction's measured length on the tracked state (GHSA-jjhc-7hvh-c3hm, BRC-237) +// A stored compact row of version 1 restores to the same state; what the +// host writes back is version 2. +let state = State::from_compact(&row)?; // row[0] == 1, still read +assert!(state.handed_to().is_empty()); +let row = state.to_compact(); // row[0] == 2 +``` -A transaction of exactly 64 bytes is never taken as proven by a merkle path (BRC-237's condition for an anchor; bsv-rs enforces it in its own verifier, its public advisory GHSA-jjhc-7hvh-c3hm). This crate's `Proof` holds a txid and the crate compares the root itself, so the crate measures the transaction. This entry is the measure on the tracked state and in the stored bytes; `Proof::new` is untouched by it. Every item is ahead of the Lean: bsv-stack-lean `lean/Tracker.lean` at `9a727a64` has no such field yet (its name there will be `State.txLen`); the rule's words are its `docs/DECISIONS-2026-10-19.md` 32.13. +```rust +// This line: a host that hands the bytes over says so before the post +// leaves, and says when an instance answered and keeps nothing. +state.step(¶ms, &headers, Input::Host(HostAction::HandOver { instance: "arcade".into(), at: now }))?; +state.step(¶ms, &headers, Input::Host(HostAction::Discharge { instance: "arcade".into() }))?; -- `AMBIGUOUS_TX_LEN: u64 = 64`, re-exported at the crate root: the one length the rule names. A host and a test read the constant, never the literal. -- `State::tx_len() -> Option`: the transaction's measured length in bytes, `None` where the host never handed the bytes. It is written only from bytes the crate hashed to the state's own txid, and once written it does not change. A length is a `u64`, never a `usize`, so the stored form does not depend on the host's word size. -- `State::measured(tx_bytes: &[u8]) -> State`: birth from the transaction's serialized bytes. The txid is their double SHA-256, reversed, as 64 lowercase hex digits; the word is `Unknown`. The bytes are hashed and counted, never decoded, and the call never fails: the host compares `State::txid()` with the txid it expects. `State::new(txid)` is unchanged: a state born from a txid is unmeasured. -- `State::measure(&mut self, tx_bytes: &[u8]) -> Result<(), CheckError>`: the bytes handed after birth. Bytes of another transaction are `CheckError::TxidMismatch`, the state left whole; the same length again is `Ok` and moves nothing; another length is `CheckError::LengthMismatch { measured, offered }`, the state left whole; an unmeasured state gains the length, and off 64 bytes nothing else moves, whatever the word. -- `Tracker::track_bytes(&mut self, tx_bytes: &[u8]) -> Result<&State, CheckError>`: a txid not tracked is born measured and no index moves; a tracked txid gains its measure as by `State::measure`, through the indexes. -- **A state measured at 64 takes no proof.** Its proof door answers every `Evidence::Proof` for its txid with `CheckError::AmbiguousLength` and leaves the state whole: no word, no record and no re-ask is written (a re-ask is an order to fetch, and no fetch helps). Such a state is tracked like any other and never reads `mined`; a host reads `state.tx_len() == Some(AMBIGUOUS_TX_LEN)` and asks no proof for it. -- **The fault road of `State::measure`.** When the measure taken is 64 bytes and the state held a proof (a state that took its proof unmeasured, or a row restored from version 1 bytes), the call unsays the proof AND returns the fault: the length is written, the stored record is dropped, a `Mined` or `Stale` word reads `Unknown` with the suspect mark and the re-ask cleared, any other word keeps its word and its re-ask, and the answer is `Err(CheckError::AmbiguousLength)`. `Tracker::track_bytes` returns the same fault with the indexes moved, and `Tracker::get` reads the state. This is a fault, never a transition a host may lean on: the Lean's machine has no such step. -- `CheckError::AmbiguousLength` and `CheckError::LengthMismatch { measured: u64, offered: u64 }`. -- Tests: `tests/measure.rs`, five tables. `births` (a birth from a txid and from bytes of 0, 63, 64, 65 and 191 bytes; the hash and its byte order against the txid of the chain's block 0 coinbase; `Tracker::track_bytes` on a new txid, on a tracked one, and repeated); `measure_after_birth` (bytes of another transaction, 64 bytes and 191 bytes on each of the ten words, and a record beside a word no proof writes); `a_state_measured_at_64_refuses_every_proof` (on five words, three proofs each, under headers that carry the root and under headers that cannot answer, and through `Tracker::apply` with no index moved); the fault road through the tracker; and a `mined` row of version 1 restored. `tx_length_field` in `tests/compact.rs`, and one unit test in `src/state.rs` of the second measure's refusal. +// The latch, today's machine: nothing to change. +let params = Params::new(3600, 1); +// The door, when the host's own rules lock back a returned payment's inputs. +let params = Params::new(3600, 1).with_recheck_conflicted(true); -### Changed: `CheckError` is `#[non_exhaustive]`, and version 2 of the compact form gains the length (GHSA-jjhc-7hvh-c3hm, BRC-237) +// 0.9.0-beta.10: a competitor's proof for the tracked txid wrote +// conflicted [txid]. This line, for every host: refused; the proof door +// takes such a proof. +assert_eq!( + state.step(¶ms, &headers, Input::Evidence(Evidence::Competitor(own_proof))), + Err(CheckError::TxidMismatch) +); +``` -- `CheckError` is `#[non_exhaustive]`: an exhaustive match on it outside the crate stops compiling (E0004) until it carries a wildcard arm. An error is never a word: a fault a host does not name still means "not `mined`". Its doc carries a `compile_fail,E0004` doctest of the five-arm match of 0.9.0-beta.11. -- Version 2 of the compact form gains one field, its last: `0` (the host never handed the bytes), or `1` and a varint, the measured length (`State::tx_len`). `COMPACT_VERSION` stays 2: no published release wrote version 2, so its layout takes the field. A length of zero is `01 00`, a measure and never absence. A version 1 row still restores, unmeasured; a `mined` row of version 1 restores `mined` as before, and nothing more is asked of it. -- Refused: a length of 64 beside a stored proof, as `CompactError::Evidence(CheckError::AmbiguousLength)`, which the encoder never writes; a flag that is not `0` or `1` (`Malformed("flag")`); a varint not in its shortest form; and bytes that end before the field (`Truncated`). A length of 64 with no stored proof is read: it is a state measured at 64. `CompactError` gains no variant. -- `State`'s equality compares the measured length: a measured state and an unmeasured one are not equal. -- `tests/compact_golden.rs`: the ten version 2 goldens re-recorded in a commit of their own, each gaining the byte `00` at its end and nothing else; the helper's string and the renamed test `version_2_is_version_1_with_four_empty_fields`; the ten version 1 strings byte-identical. `tests/compact.rs`: the four constants that count from the tail. +### Added -### Changed: a `Proof` is built on a length, and every door reads it (GHSA-jjhc-7hvh-c3hm, BRC-237) +- **`Word::Handed`** (`Tracker.Word.handed`): the bytes left the host's hands for one or more named instances and none has answered. It claims nothing of the chain (`Word::chain` answers `None`). The doc of `Word` carries a `compile_fail,E0004` doctest of a nine-arm match. +- **`State::handed_to() -> &[HandedTo]`** (`State.handedTo`): the instances handed the bytes and not discharged, each with the time of its latest hand-over, in the order of each instance's earliest hand-over. `HandedTo { instance, at }` is `#[non_exhaustive]`, built by `HandedTo::new`, re-exported at the crate root, and stored by its serde form (`{"instance":"arcade","at":1700000000}`). +- **Three host acts** (`HostAction` is `#[non_exhaustive]`, so they add without a break): `HostAction::HandOver { instance, at }` (`onHandOver`: `unknown`, `built` and `handed` read `handed`, the instance added or its time renewed in its place, a pending `reannounce` cleared; an `abandoned` state left whole; any other word keeps its word and only the pending `reannounce` is cleared), `HostAction::Discharge { instance }` (`onDischarge`: from `handed` the instance leaves the list, compared with the hand-over's `instance` and never with a hint's `source`, and the word returns to `built` when it is empty; every other word untouched) and `HostAction::EndHold` (`onEndHold`: `unknown`, `built` and `handed` read `abandoned`, the list emptied, a pending `reannounce` cleared; every other word untouched; a received payment's act, which the crate cannot tell from one of the host's own). +- **`Reask::Reannounce`**, label `reannounce`, compact re-ask tag `7` (`Tracker.Reask.reannounce`): a host tick on a `handed` word whose oldest hand-over plus the age threshold is at most the tick's time (`handedDue`, checked addition); never on `built`, and the age re-ask keeps its arm before it. +- **`Competitor`**, re-exported at the crate root (`Tracker.Competitor`): a competitor on the record, with private fields and the readers `txid()`, `tx_len()`, `checked()`, `gone()` and `standing()`. `tx_len()` is the competitor's own measured length, `Some` for a competitor entered by a proof (never 64) and `None` for one a node's verdict named; it is never the tracked transaction's measure (ahead of the Lean, whose `Competitor` has no length yet; its name there will be `Competitor.txLen`). No public constructor and no serde form: a checked proof has neither. +- **`State::rivals() -> &[Competitor]`** (`State.rivals`), the newest at the front, and **`State::prior() -> Option<&Word>`** (`State.prior`), the word held when the conflict began. A checked competitor's proof puts the competitor on the record with its proof and length; a node's `conflicted` verdict puts its competitors on it with neither, so no root rechecks them; a conflict that begins starts its own record and keeps the word of its moment as the prior word; a later competitor joins it. A `rejected` verdict and a `mined` word's re-ask leave both. The record is kept, with its marks, after the word leaves `conflicted`. +- **The named join** (ahead of `onCompetitor` and `onVerdict` in bsv-stack-lean's `lean/Tracker.lean` at `9a727a64`, and still at `a7ef91de`): when a competitor or a verdict joins a `conflicted` word, each id of the word's list with no entry on the record goes on it as named. Only a restored version 1 `conflicted` row lists such ids; its competitors then stand on the record as named ones, so under the door such a row never leaves by a chain event or a recheck. +- **`Params::recheck_conflicted: bool`**, `false` in `Params::new`, and `Params::with_recheck_conflicted` (`Params` is `#[non_exhaustive]`: no host breaks). `State::step` reads it: off, the latch (`Tracker.step`); on, the machine with the door (`Tracker.stepRecheck`), where a `conflicted` word meeting a chain event or an executed recheck goes through the recheck of the conflict and every other input is the latch's step. +- **The recheck of the conflict** reads the host's header at each standing competitor's height that carries a proof, one read each. A header with another root marks the competitor gone; no header, or a headers fault, is not gone. Every competitor gone: the word returns to `leave_word(prior)` (`seen` returns as `announced`; `mined`, `conflicted` or none would read `unknown`; every other word as it was, `handed` with its instances), with `Reask::CompetitorGone { competitors }` naming the word's competitors, the record kept and marked, the suspect mark cleared. A standing competitor unanswered: `conflicted` on the standing competitors, `Reask::Recheck`, the mark as it was, and `Err(CheckError::Unavailable(h))` or `Err(CheckError::Headers(e))` for the unanswered competitor nearest the front. Else `conflicted` on the standing ones, the marks cleared. An empty record and a competitor a node named never leave this way. +- **The feed under the door**, as for `mined`: a reorg at or below a standing competitor's height marks the word and rechecks; an invalidation of a standing competitor's checked header marks and rechecks; a fork at or below one marks it with `Reask::Fork`; a tip rechecks a marked word and reads nothing for an unmarked one. The crate's split meets a `conflicted` word as a fork, and its resolved split as the tip of a marked word at or below a standing competitor, as both meet a `mined` word (the stack's `ChainEvent` has no split). +- **Two indexes in `Tracker`** for `conflicted` words: the heights of their standing checked competitors and the headers those were checked against. Under the flag alone, `Tracker::on_chain` adds the words they select to a reorg's, a fork's, a split's and an invalidation's targets, after the `mined` words and with no txid twice. With the flag off the selection and every output are the latch's. +- **`Reask::CompetitorGone { competitors: Vec }`**, label `competitor_gone`, compact re-ask tag `8`. +- **The measured length.** `AMBIGUOUS_TX_LEN: u64 = 64`, re-exported at the crate root: the one length the rule names; a host and a test read the constant, never the literal. `State::tx_len() -> Option`: the transaction's measured length in bytes, `None` where the host never handed the bytes; it is written only from bytes the crate hashed to the state's own txid, and once written it does not change. A length is a `u64`, never a `usize`, so the stored form does not depend on the host's word size. +- **`State::measured(tx_bytes: &[u8]) -> State`**: birth from the transaction's serialized bytes. The txid is their double SHA-256, reversed, as 64 lowercase hex digits; the word is `Unknown`. The bytes are hashed and counted, never decoded, and the call never fails: the host compares `State::txid()` with the txid it expects. `State::new(txid)` is unchanged: a state born from a txid is unmeasured. +- **`State::measure(&mut self, tx_bytes: &[u8]) -> Result<(), CheckError>`**: the bytes handed after birth. Bytes of another transaction are `CheckError::TxidMismatch`, the state left whole; the same length again is `Ok` and moves nothing; another length is `CheckError::LengthMismatch { measured, offered }`, the state left whole; an unmeasured state gains the length, and off 64 bytes nothing else moves, whatever the word. +- **`Tracker::track_bytes(&mut self, tx_bytes: &[u8]) -> Result<&State, CheckError>`**: a txid not tracked is born measured and no index moves; a tracked txid gains its measure as by `State::measure`, through the indexes. +- **A state measured at 64 takes no proof.** Its proof door answers every `Evidence::Proof` for its txid with `CheckError::AmbiguousLength` and leaves the state whole: no word, no record and no re-ask is written (a re-ask is an order to fetch, and no fetch helps). Such a state is tracked like any other and never reads `mined`; a host reads `state.tx_len() == Some(AMBIGUOUS_TX_LEN)` and asks no proof for it. +- **The fault road of `State::measure`.** When the measure taken is 64 bytes and the state held a proof (a state that took its proof unmeasured, or a row restored from version 1 bytes), the call unsays the proof AND returns the fault: the length is written, the stored record is dropped, a `Mined` or `Stale` word reads `Unknown` with the suspect mark and the re-ask cleared, any other word keeps its word and its re-ask, and the answer is `Err(CheckError::AmbiguousLength)`. `Tracker::track_bytes` returns the same fault with the indexes moved, and `Tracker::get` reads the state. This is a fault, never a transition a host may lean on: the Lean's machine has no such step. +- **`Proof::with_stated_len(txid, stated_len: u64, path) -> Result`**: the road of a host with no bytes at the place where it builds the proof. The length is the host's word; the crate cannot check it, and a host with no length has no proof. A stated length of 64 is `CheckError::AmbiguousLength`, read before the txid and the path; no other number is refused. +- **`CheckError::AmbiguousLength`, `CheckError::LengthMismatch { measured: u64, offered: u64 }` and `CheckError::Unmeasured`.** `AmbiguousLength` is answered by both constructors, the proof door of a state measured at 64, the fault roads of `State::measure` and `Tracker::track_bytes`, and `Tracker::restore`'s fault road; `LengthMismatch` by `State::measure`, the proof door and `Tracker::restore`; `Unmeasured` by the proof door, the competitor door, `Headers::check` and `doubts::may_enter`. -A transaction of exactly 64 bytes is never taken as proven by a merkle path (BRC-237's condition for an anchor; bsv-rs enforces it in its own verifier, its public advisory GHSA-jjhc-7hvh-c3hm). This entry is the two constructors and the doors: the crate is told the length where a proof is built, and each door that compares a root reads it. Every item is ahead of the Lean (bsv-stack-lean `lean/Tracker.lean` at `9a727a64`; the rule's words are its `docs/DECISIONS-2026-10-19.md` 32.13). +### Changed -- **A break: `Proof::new(tx_bytes: &[u8], path: MerklePath) -> Result`** takes the transaction's serialized bytes in place of its txid. It hashes them to bind the txid (the double SHA-256, reversed, as 64 lowercase hex digits; the bytes are counted and never decoded) and yields no proof for exactly 64 bytes (`CheckError::AmbiguousLength`, before anything is hashed, whatever the path). Every old call stops compiling (E0308: a `String`, a `&String` and a `&str` are none of them a `&[u8]`); none changes meaning in silence. -- `Proof::with_stated_len(txid, stated_len: u64, path) -> Result`: the road of a host with no bytes at the place where it builds the proof. The length is the host's word; the crate cannot check it, and a host with no length has no proof. A stated length of 64 is `CheckError::AmbiguousLength`, read before the txid and the path; no other number is refused. +- **The list of instances in every other arm**, as the Lean writes it: a hint raises `handed` to `announced` (an acceptance or a mempool presence) or `seen` (a sighting), and empties the list whenever it moves the word (`onHint`); no hint lowers `handed`. `abandon` stays refused on `handed`. A proof that writes `mined` empties the list (`onProof`); a node's `rejected` empties it and its `conflicted` keeps it (`verdictHanded`); a competitor's proof keeps it. +- **`bsv_tracker::doubts`**: the guard's rule arm names `Word::Handed`, as the Lean's `spendable` does: `handed` is spendable under a rule that allows it and under no other, and reads no header. Nothing else in the module moves. +- **The competitor door**, in order: a proof whose txid is the tracked one is refused (`CheckError::TxidMismatch`, `Reask::ProofFailed`, the word and the record untouched; `Tracker.competitor_is_another`); then the competitor's own length (a proof not built from its bytes is `CheckError::Unmeasured`, the word kept, `Reask::ProofFailed` written); then the header check. The competitor is judged by its own length, never by the tracked transaction's measure: a state measured at 64 still takes a competitor's proof, and a `conflicted` word a competitor's proof wrote holds no proof of the tracked transaction, so a measure of 64 handed after it is no fault. `Evidence::Competitor`'s doc says what the host must have shown: the hash of the competitor's bytes is the crate's check, and the spend of our input stays the host's. +- **A break: `Proof::new(tx_bytes: &[u8], path: MerklePath) -> Result`** takes the transaction's serialized bytes in place of its txid. It hashes them to bind the txid (the double SHA-256, reversed, as 64 lowercase hex digits; the bytes are counted and never decoded) and yields no proof for exactly 64 bytes (`CheckError::AmbiguousLength`, before anything is hashed, whatever the path). Every old call stops compiling (E0308: a `String`, a `&String` and a `&str` are none of them a `&[u8]`). - **The proof door reads a length.** A state measured at another length than the proof's (built from bytes or stated) refuses it, `CheckError::LengthMismatch { measured, offered }`, the word and the record kept, `Reask::ProofFailed` written. A measured state takes a proof of its own length by either road, and a proof taken out of a record. An unmeasured state is measured by a proof built from bytes (before the header check, whatever it answers), takes a stated one on the host's word (`tx_len` stays `None`), and refuses a record's proof, `CheckError::Unmeasured`. -- **The competitor door** takes a proof built from the competitor's own bytes and refuses any other, `CheckError::Unmeasured`, the word kept, `Reask::ProofFailed` written. The competitor is judged by its own length, never by the tracked transaction's measure: a state measured at 64 still takes a competitor's proof, and a `conflicted` word a competitor's proof wrote holds no proof of the tracked transaction, so a measure of 64 handed after it is no fault. - **A record's proof carries no length.** The record a door builds keeps the proof with none, and a restore reads it back so: the state's measure, kept beside it, is the length. `Headers::check` (called by a host, with no state) and `doubts::may_enter` take a proof built by either constructor and refuse a record's proof, `CheckError::Unmeasured`. A transition never calls a host's override of `Headers::check`. -- **A break: `Tracker::restore(&mut self, state: State) -> Result, CheckError>`.** A measure the tracker holds is carried across the swap to a restored row that carries no length. When the held measure is 64 and the row holds a proof, the proof is unsaid AND the fault is returned, as `State::measure`'s fault road: the row is held with its record dropped and a `Mined` or `Stale` word read as `Unknown`, out of the suspect set, and the call answers `Err(CheckError::AmbiguousLength)`. A row that carries another measure than the held one is `Err(CheckError::LengthMismatch { measured, offered })`, nothing moved. `Ok` holds the replaced state as before. -- `CheckError::Unmeasured`. `CheckError::AmbiguousLength` is also answered by both constructors and by `Tracker::restore`'s fault road; `CheckError::LengthMismatch` by the proof door and `Tracker::restore`. -- `README.md`'s example builds its coin with `State::measured(&raw_tx)` and its proof with `Proof::new(&raw_tx, path)`. `ProofFetcher::fetch`'s doc names both constructors. -- Tests: `tests/proof_length.rs`, eight tables and the witness. `constructors_by_length` (63, 64 and 65 bytes by each road, a malformed path beside each); `bytes_that_do_not_hash_to_the_txid`; `the_proof_door_pairings` (seven pairings of the state's measure and the proof's length, the measure written whatever the header check answers, a mined word kept by a refusal, and a state measured at 64 against three proofs); `a_measured_state_against_a_stated_length_proof`; `the_competitor_door`; `the_competitor_is_judged_by_its_own_length`; `the_doors_with_no_state`; `restore_carries_the_held_measure` (six rows); and `brc237_t64_is_never_proven`, on BRC-237's own transaction of 64 bytes, `T64`, with its path and the header at its height, held in `tests/vectors/brc237/t64.json`. One unit test in `src/state.rs` for the proof from bytes of another length, which no public constructor reaches. The vectors job runs the witness by name. Every existing test keeps its name and its answer: the helper `proof(..)` of `tests/common/mod.rs` states a length of 191, and eight competitor proofs are built from bytes. No golden string moves. - -### Tests: the length rule as properties and goldens (GHSA-jjhc-7hvh-c3hm, BRC-237) - -A transaction of exactly 64 bytes is never taken as proven by a merkle path (BRC-237's condition for an anchor; bsv-rs enforces it in its own verifier, its public advisory GHSA-jjhc-7hvh-c3hm). This entry is tests alone: no line of `src` moves. Each statement is ahead of the Lean (bsv-stack-lean `lean/Tracker.lean` at `901e9dfa` has no measured length yet; the rule's words are its `docs/DECISIONS-2026-10-19.md` 32.13), and the theorem names are proposals. - -- `tests/length_properties.rs` (new), ten properties over 256 traces each, from the fixed ChaCha seed: a subject drawn as a txid alone or as bytes of 63, 64, 65 or 191, born measured or from its txid, held by a `Tracker`; its proofs by either constructor at a length that agrees or not and out of a record, a competitor's by each road, the measure, restores through both versions of the compact form and a hand-set length field, and every other input. Eight are named for the proposed theorems: `ambiguous_never_mined` (no road yields a state that reads `mined` and is measured at 64), `txLen_once`, `txLen_only_by_bytes`, `mined_read_a_length`, `mismatch_refused`, `competitor_needs_bytes`, `measure_moves_no_word` (with the measure's fault road: the fault returned AND the proof unsaid) and `record_carries_no_length`. Two read the tracker's indexes through its public doors: `restore_leaves_the_index_describing_the_held_state` (for every pair of a held state and a restored row, on `Ok` and on both faults) and `every_act_leaves_the_index_describing_the_state`. -- The generators of `tests/properties.rs` and `tests/compact.rs` draw the same subject, both constructors and the measure; the four properties and the compact round trip keep their names and also read the length; the prefix test runs over the generator. -- Three goldens in `tests/compact_golden.rs`: `measured_unknown` (`01bf01`), `measured_at_64` (built, `0140`) and `mined_measured_by_its_proof` (`01bf01`), each beside an unmeasured twin whose bytes differ in the last field alone. -- `docs/VERIFICATION.md` records each property beside its proposed name, the witness's two tails, and thirteen faults planted in the length arms, each failing some of these tests. - -### Added: the pages of the length rule (GHSA-jjhc-7hvh-c3hm, BRC-237) - -- `docs/SPEC.md`, a section "The length of a transaction": every item of the rule beside the Lean name it would mirror, each marked ahead of the Lean (bsv-stack-lean at `9a727a64`, `docs/DECISIONS-2026-10-19.md` 32.13); the proof door's pairings and the competitor door; the fault roads, which the Lean's machine has no step for; `Tracker::restore`'s two error roads, what each drops, and why one takes the row and the other moves nothing; and what the length rule does not close. -- `README.md`, "Evidence and host obligations": the host's duties under the rule, with an example that runs as a doc test. -- `docs/DOUBTS.md` and `docs/VERIFICATION.md`: a received coin's proven ancestor is `State::measured(bytes)` stepped with a proof built by `Proof::new(bytes, path)`, since the host holds the ancestor's bytes. `docs/VERIFICATION.md` says that a `compile_fail` block naming an error code is checked for that code on nightly alone. -- `Tracker::restore`'s doc says what each error road drops. No line of code moves. +- **A break: `Tracker::restore(&mut self, state: State) -> Result, CheckError>`.** A measure the tracker holds is carried across the swap to a restored row that carries no length. When the held measure is 64 and the row holds a proof, the proof is unsaid AND the fault is returned, as `State::measure`'s fault road: the row is held with its record dropped and a `Mined` or `Stale` word read as `Unknown`, out of the suspect set, and the call answers `Err(CheckError::AmbiguousLength)`. A row that carries another measure than the held one is `Err(CheckError::LengthMismatch { measured, offered })`, nothing moved. `Ok` holds the replaced state as before. Its doc says what each error road drops. +- **`CheckError` is `#[non_exhaustive]`**: an exhaustive match on it outside the crate stops compiling (E0004) until it carries a wildcard arm. An error is never a word: a fault a host does not name still means "not `mined`". Its doc carries a `compile_fail,E0004` doctest of the five-arm match of 0.9.0-beta.10. +- **`State`'s equality** compares the measured length (a measured state and an unmeasured one are not equal), the list of instances, the record and the prior word. +- **The compact form's version 2.** `COMPACT_VERSION` is 2. Version 2 is version 1's layout with word tag `9` (handed), re-ask tags `7` (reannounce) and `8` (competitor gone, and its ids), and four fields after the re-ask: the instances (a varint count, each a string and a varint time); the record (a varint count, then each competitor's txid (an id), its length (`0`, or `1` and a varint), its checked proof (`0`, or `1` and the record as the evidence field writes it, read back as a record and never checked against headers) and its mark); the prior word (`0`, or `1` and a word as the word field writes it); and the measured length, the last field (`0`, the host never handed the bytes, or `1` and a varint; a length of zero is `01 00`, a measure and never absence). A record restores exactly, its competitors not marked suspect. Version 1 still reads, as the same state with the four fields empty: unmeasured, no instance, an empty record, no prior word. +- **Refused in the compact form**, through the variants `CompactError` has (it gains none): under version 1, word tag `9` and re-ask tags `7` and `8` (`Malformed("word tag")`, `Malformed("re-ask tag")`); a `handed` word with no instance (`Malformed("handed word with no instance")`); an instance named twice (`Malformed("instance named twice")`); instances beside any word but `handed` and `conflicted` whose prior word is `handed` (`Malformed("instances beside a word that holds none")`); `conflicted` whose prior word is `handed` with no instance, whose return would be `handed` with none and which no run writes (`Malformed("conflicted from handed with no instance")`); a prior word `mined` or `conflicted` (`Malformed("prior word")`); a competitor's checked proof with no length (`Malformed("competitor's proof with no length")`); a length beside a competitor with no proof (`Malformed("named competitor with a length")`); a competitor with no proof marked gone (`Malformed("named competitor marked gone")`); a competitor that is the tracked transaction, or whose proof is another transaction's (`Evidence(CheckError::TxidMismatch)`); a competitor's length of 64 (`Evidence(CheckError::AmbiguousLength)`); a competitor's record that does not hold together (`Evidence(_)`); a length of 64 beside a stored proof (`Evidence(CheckError::AmbiguousLength)`, which the encoder never writes); a flag that is not `0` or `1` (`Malformed("flag")`); a varint not in its shortest form; and bytes that end before the length (`Truncated`). A length of 64 with no stored proof is read: it is a state measured at 64. The named join and the door's selection keep the ids they hold in a set. + +### Tests + +- **`tests/vectors/tracker/rows_of_record.json`** (new, schema `bsv-tracker-rows/1`, sha256 `0e8f13056b9fd5dfd0785f870c0347f1565a918176216f87313c6ec9fec2d3e1`): the 93 rows of the namespace `Tracker.HandedRows` and the 5 of `Tracker.LeafRows` at `a7ef91de`, one row one `#guard`, its text verbatim, and one row of the crate's own (`self_competitor_refused`, `Tracker.competitor_is_another` at a taken payment): 99 rows. Every row names its group and its machine, and each input of a trace the machine the source passes it through (`run P` or `runR`): the 46 of the word under `step`; of the 53, 45 under the door and 8 under the latch. `LeafRows`' competitor named "C" offered X's proof (`leaf.4`) is listed by name as not spelled: the crate names a competitor by its proof's own txid. +- **`tests/tracker_rows.rs`** (new) replays them through the crate's public items, the tracked transaction's proof stated and a competitor's built from its bytes. `rows_of_record_handed`: `46 rows under step, 0 divergences, 0 not spelled`. `rows_of_record_recheck`: every row of the 53 under its own machine, `0 divergences, 1 not spelled, 0 ahead of the Lean` (no row starts from a state stored before the record existed, so none meets the named join); then the 54 rows of the latch a second time through the door wherever `stepRecheck_eq_step`'s premise holds at every step of the row's traces: 52 replayed, 1 not covered (`returned.5`, the latch's own reorg on `conflictedT`), 0 divergences. The `vectors` job runs both by name and greps their three lines: 14 named passes. +- **`tests/handed_properties.rs`** (new): 23 properties, 22 named for the Lean's theorems of the word (`handOver_writes_handed` through `onEvidence_word`, `handedNamed_run` among them) and one of the crate's own, `handed_to_only_beside_handed` (a list stands beside `handed`, or beside `conflicted` whose prior word is `handed`, both ways). +- **`tests/recheck_properties.rs`** (new): 23 properties, each named for its Lean theorem (`step_conflicted_latched` to `conflictReask_only` and `conflictReads_le`), and 3 of the crate's own (`a_competitors_length_is_its_own`, the length rule's scope: a competitor's length never moves the tracked transaction's measure, 64 included; `no_run_lists_an_id_whose_only_entry_is_gone`; `conflicted_from_handed_keeps_its_list`). Every trace runs under both machines, with two competitors whose proofs are built from their bytes, and each premise is met in some case. +- **`tests/length_properties.rs`** (new), ten properties over a subject drawn as a txid alone or as bytes of 63, 64, 65 or 191, born measured or from its txid, held by a `Tracker`; its proofs by either constructor at a length that agrees or not and out of a record, a competitor's by each road, the measure, restores through both versions of the compact form and a hand-set length field, and every other input; the draw asserts that a proof it builds from bytes, or states, is never at 64 bytes. Eight are named for proposed theorems (each ahead of the Lean, at `901e9dfa` with no measured length): `ambiguous_never_mined` (no road yields a state that reads `mined` and is measured at 64), `txLen_once`, `txLen_only_by_bytes`, `mined_read_a_length`, `mismatch_refused`, `competitor_needs_bytes`, `measure_moves_no_word` (with the measure's fault road: the fault returned AND the proof unsaid) and `record_carries_no_length`. Two read the tracker's indexes through its public doors: `restore_leaves_the_index_describing_the_held_state` (for every pair of a held state and a restored row, on `Ok` and on both faults) and `every_act_leaves_the_index_describing_the_state`. +- Every property runs 256 cases from the fixed ChaCha seed with no failure persistence. +- **`tests/properties.rs`**: the generators draw the hand-over, the discharge and the end of a hold (`hand_act` in `tests/common/mod.rs`), the length's subject, both constructors and the measure, and two competitors; `mined_implies_checked_proof`, `stale_iff_header_inactive` and `hint_changes_no_chain_word` run each trace under both machines and read the length; `hint_changes_no_chain_word` allows `handed` to `announced` or `seen` and reads the list; `same_evidence_same_word` stays over the latch: two hosts agree on the word under the door only where they hold the same record. +- **`tests/compact.rs`**: the round trip's generator runs each step under either machine with two competitors and the length's draw, reads the list back and reaches `handed` and `conflicted` states that keep one; the prefix test runs over the generator. `a_conflicted_word_and_its_record_name_the_same_competitors` reads the row's conflict before the step, so a return by that very step is checked, and fails when the named join is removed. `version_2_refusals` pins each refusal and the bytes of a `handed` state; a state with a record round-trips; `tx_length_field`; tests that read version 1's layout move by their inputs and keep their answers (version 3 is the unread version; word tag `10` is the unknown tag; the constants that count from the tail). +- **`tests/compact_golden.rs`**: the ten goldens re-recorded in commits of their own, each its version 1 string, kept verbatim, with its opening byte `01` made `02` and the four empty fields `00000000` at its end, but `conflicted_by_ids_and_text`, where the node's verdict now writes its two competitors on the record and the prior word `unknown` (its old ending is quoted in its doc); `version_1_bytes_still_restore` restores each version 1 string to the state built today and `version_2_is_version_1_with_four_empty_fields` pins the relation, both reading that one state's record apart. New goldens, each spelled field by field: `handed_to_one_with_reannounce`, `handed_to_two_one_renewed` and `built_after_discharge` (the bytes of a state only ever built); `measured_unknown` (`01bf01`), `measured_at_64` (built, `0140`) and `mined_measured_by_its_proof` (`01bf01`), each beside an unmeasured twin whose bytes differ in the last field alone; `conflicted_with_a_checked_competitor` (prior `announced`), `conflicted_from_handed` (the instance kept, the competitor's 191 beside the tracked transaction's 65), `conflicted_named_by_a_node` (no length, no proof) and `returned_with_the_record_marked` (`announced`, `competitor_gone`, the mark). `handed_refusals` and `record_refusals` pin the refusals as bytes; `an_instance_beside_each_word_of_record` writes an instance into each of the ten states of record and reads the list kept beside `conflicted` only when its prior word is `handed`; `a_record_with_no_prior_word_is_written_by_a_run_and_restores` (a restored version 1 row that a competitor joined: read, not refused). +- **`tests/measure.rs`** (new), five tables: `births` (a birth from a txid and from bytes of 0, 63, 64, 65 and 191 bytes; the hash and its byte order against the txid of the chain's block 0 coinbase; `Tracker::track_bytes` on a new txid, on a tracked one, and repeated); `measure_after_birth` (bytes of another transaction, 64 bytes and 191 bytes on each of the ten words, and a record beside a word no proof writes); `a_state_measured_at_64_refuses_every_proof` (on five words, three proofs each, under headers that carry the root and under headers that cannot answer, and through `Tracker::apply` with no index moved); the fault road through the tracker; and a `mined` row of version 1 restored. +- **`tests/proof_length.rs`** (new), eight tables and the witness: `constructors_by_length` (63, 64 and 65 bytes by each road, a malformed path beside each); `bytes_that_do_not_hash_to_the_txid`; `the_proof_door_pairings` (seven pairings of the state's measure and the proof's length, the measure written whatever the header check answers, a mined word kept by a refusal, and a state measured at 64 against three proofs); `a_measured_state_against_a_stated_length_proof`; `the_competitor_door`; `the_competitor_is_judged_by_its_own_length`; `the_doors_with_no_state`; `restore_carries_the_held_measure` (six rows); and `brc237_t64_is_never_proven`, on BRC-237's own transaction of 64 bytes, `T64`, with its path and the header at its height, held in `tests/vectors/brc237/t64.json`, which the `vectors` job runs by name. The helper `proof(..)` of `tests/common/mod.rs` states a length of 191, and every competitor proof is built from bytes. +- **`tests/transitions.rs`**: nine examples of the word's arms, one per row of the stack's `docs/p0/tracker-handed-proof-2026-11-27.md` section 3, and the stored form of `HandedTo`; the latch over a `conflicted` word under every chain event and a recheck; a competitor's proof for the tracked txid, refused in both modes, the latch's old answer quoted; the record and the prior word; a competitor's length and the tracked transaction's measure kept apart (the K4 scope of the crate's issue 57); the door's rows over one state. **`tests/reorg_by_root.rs`**: the latch's outputs over a registry with `conflicted` words, unchanged with the flag named off; the selection under the door; one header read per standing competitor with a proof. **`tests/scenarios.rs`**: the three scenarios of record run under both machines and give the same states step by step, and W4, `abort_during_a_post_in_flight_is_refused`. **`tests/labels.rs`**: `reannounce` and `competitor_gone`. +- Unit tests in `src/state.rs`: `leave_word`, the second measure's refusal, and the proof from bytes of another length, which no public constructor reaches. + +### Documents + +- **`docs/SPEC.md`**: the pin of the stack moved to `a7ef91de` (`lean/Tracker.lean`, blob `c2a6045a`), with the opening table re-cited at it; a section "The tenth word and the record of a conflict": every item beside the Lean name it mirrors, the two machines, what the crate does that the stack's model does not mirror yet (the named join, `leaf.4`, the split under the door, the door's fault, a competitor's length, theorem (iv) over the door) and what a host must know; and a section "The length of a transaction", whose opening says every door that takes a proof reads the length (the recheck compares a stored root without it): every item of the rule beside the Lean name it would mirror, each marked ahead of the Lean (`9a727a64`); the proof door's pairings and the competitor door; the fault roads, which the Lean's machine has no step for; `Tracker::restore`'s two error roads, what each drops, and why one takes the row and the other moves nothing; and what the length rule does not close. +- **`README.md`**: "The hand-over and the door", the two rows for a host with an example that runs as a doc test; "Evidence and host obligations", the host's duties under the length rule with an example that runs as a doc test, and its example of the doubts building its coin with `State::measured(&raw_tx)` and its proof with `Proof::new(&raw_tx, path)`. `ProofFetcher::fetch`'s doc names both constructors. +- **`docs/VERIFICATION.md`** records each property beside its theorem (or its proposed name), the rows' replay, the witness's two tails, sixteen faults planted in the word's arms and thirteen in the length arms, each failing some of these tests, and the named join marked `[AHEAD OF THE LEAN]`. It says that a `compile_fail` block naming an error code is checked for that code on nightly alone. It and `docs/DOUBTS.md` say that a received coin's proven ancestor is `State::measured(bytes)` stepped with a proof built by `Proof::new(bytes, path)`, since the host holds the ancestor's bytes. +- The docs of `Word` and `CheckError` name 0.9.0-beta.10, the published release whose nine-word and five-fault matches no longer compile. ## [0.9.0-beta.11] - 2026-11-28