diff --git a/CHANGELOG.md b/CHANGELOG.md index 95af04e..3b4d5b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,22 +2,34 @@ ## [Unreleased] -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. +## [0.9.0-beta.11] - 2026-11-29 -### Hosts: what a host of the published 0.9.0-beta.10 changes to take this line (for #56, #47, GHSA-jjhc-7hvh-c3hm) +The prerelease of the rulings of the 0.9.0 line, on bsv-rs `=0.9.0-beta.12`, each told once below: the doubts and the effective depth (for #51); 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 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 the published 0.9.0-beta.10 changes to take this release (for #51, #56, #47, GHSA-jjhc-7hvh-c3hm) -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. +**A host of 0.9.0-beta.10 changes each `Params` literal, each exhaustive match on `Word`, every call that builds a `Proof`, each exhaustive match on `CheckError` and each call of `Tracker::restore`; it may start calling one module, feeding three acts and turning on one door; and one answer moves for every host.** Every compile break below is named by the host's compiler. Three items change an answer with no compile error, and a host reads its code for each of them, since no compiler names them: a wildcard arm, or a rule that reads a word by its text, reads `handed` as whatever it says once the host feeds `HostAction::HandOver` (items 3 and 4); a transaction offered as its own competitor is refused where 0.9.0-beta.10 wrote `conflicted` (item 10); and `State`'s equality compares the measured length, the list of instances, the record and the prior word (item 11). + +1. **`Params`** (for #51). `Params` is built by `Params::new(age_threshold, spend_depth)` and is `#[non_exhaustive]`. In 0.9.0-beta.10 it was a struct of one public field, `age_threshold`, with no constructor, no `Default` and no `#[non_exhaustive]`, built by literal, so every new field broke every host: the literal is refused once more (E0639), and a later field, which a later minor adds here with a default, breaks none. Its three new fields, each public to read and to assign, and their values when the host says nothing: `spend_depth: u64`, which has no default and is the constructor's second argument (the Lean's `Params.spendDepth` has none, and one host has one depth for an act; a host that reads no guard of `doubts` writes 1, the floor; the crate applies no floor, and a depth of 0 passes a `mined` word whose root the headers carry); `bound: Option`, the feed's named number, absent as `None`, which is no check and the host of today, row for row (it arrived with the keyed splits); and `versions: Vec`, the row versions the host's decoder reads, absent as `vec![1, 2]`, `Params::VERSIONS` (it arrived with the spend depth, by the table of the stack's cut 1g); `with_spend_depth`, `with_bound` and `with_versions` set one. +2. **The doubts, when the host calls them** (for #51). The new module `bsv_tracker::doubts`, nothing of it re-exported at the crate root: a host may start folding each feed row with `doubts::step` (`step_checked` under a number) before the tracker's own step, which takes the event by value; storing the doubts as their serde text, and reporting a text it cannot read as a fault, never a cold start; and reading `eff_depth` for the depth it may trust at a height, `spendable_eff` for the spend guard on it and `may_enter` for the builder's test. A host whose feed names a number sets `bound` from the service's contract, never from a snapshot or a row (a check against a number the checked party sends checks nothing), and treats `Checked::Out` as the feed out of its contract: it keeps the doubts it was given and reads no row; its depths are `eff_c`'s and its guard `spendable_c`'s, which pass no `mined` word under a spend depth of 1 or more (a word with no height passes as today, the row `outZero`); at each page read it makes one ask for a snapshot and nothing more, one start a page read at most and never a start that causes a start; it takes a snapshot through `accepts` or `start_from` alone, at its cursor or past it, and does not ask at its cursor alone, where an honest snapshot holds the count that tripped the check (the row `stuck_at_cursor`); a refused snapshot (`Refused::Overfull`, one that itself holds more open keys than `bound`, among them) builds no doubts, and the host holds every act, as it is still out, and asks again at its next page read, no faster than its page poll. The snapshot's wire is the header service's and the crate reads none: a host reads it into a `Served`. The page loop is the host's. `docs/DOUBTS.md` is the page of every item, beside the Lean name it mirrors at bsv-stack-lean `08ce467d`. The doubts move no answer a host already calls: outside their module they move only `Params` in `src/`, and the tracker's reducer reads none of its three new fields; they move no serde form of `State`, `Tracker`, `ChainEvent` or `decode_envelope`, and no compact byte (the compact form's version 2 is the tenth word's and the record's, item 8). bsv-wallet-cli builds `Params` by literal in `src/tracker_host.rs` (two sites); it pins `=0.9.0-beta.10` and does not move until its next pin. +3. **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. +4. **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. +5. **`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`). +6. **`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. +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`. 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. +8. **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. This release's reader refuses every version but 1 and 2 (`CompactError::UnknownVersion`), and in a row of either version each field that Changed lists under "Refused in the compact form". +9. **The door, off by default: the latch is the 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. +10. **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. +11. **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.10 +let params = Params { age_threshold: 60 }; +// this line: the same host, its spend depth said once +let params = Params::new(60, 1); +// a host whose feed names a number +let params = Params::new(60, 1).with_bound(Some(4)); +``` ```rust // 0.9.0-beta.10: nine arms, which no longer compile (E0004). @@ -106,6 +118,17 @@ assert_eq!( ### Added +- **The doubts (for #51).** `bsv_tracker::doubts`, a new public module beside the tracker's reducer: a host's doubts, folded from the header service's feed one row at a time. It mirrors `lean/Headers/Doubts.lean` of bsv-stack-lean at `7213ef4a` under the Lean's names. Nothing is re-exported at the crate root, and the module moves no existing serde form or compact byte: `State`, `Tracker`, `ChainEvent` and the decoder read nothing of it (`Params` is the one existing item it moves: Hosts, above), and a host changes nothing for it until it calls the module. +- `Rival` (`fork`, `tip`; `Rival::new`, `covers`, `merge`), `Doubts` (the kept rivals, the open splits (keyed by the fork point: Changed, below), the feed's tip and the summary of what the prune dropped; `Doubts::new`, `Doubts::cold`, the readers `rivals`, `splits`, `tip`, `gone`, and `held`) and `Bounds` (`settled`; `Bounds::new`, `Bounds::B400`, the feed's settled line). `Rival` and `Bounds` are `#[non_exhaustive]`; `Doubts` keeps its fields private. +- `raw(event, ds)` (the table of rows, no prune), `prune(bounds, ds)`, `step(bounds, event, ds)` (`raw`, then `prune`) and `run(bounds, ds, rows)` (`step` folded from the left). They take the decoded `ChainEvent` a host already holds, take and return values, and read a row's heights and a split row's key alone: no header, clock, root or chain work. The split arms are the keyed ones (Changed, below). +- The stored form of `Doubts`, its serde text, with the fields in the Lean's order and under the Lean's names: `{"rivals":[{"fork":101,"tip":101}],"splits":[],"tip":103,"gone":null}`. All four fields are required on read, `gone` included (`null` or a rival: a text without it is refused, never read as "nothing dropped"), and a field this reader does not know is refused. `Bounds` has no serde. The compact format stays one transaction's: the doubts are not in it. +- `Display` for `Doubts`: `tip=103 splits=[] rivals=[101:101] summary=-`, the lists in their order, the summary as `fork:tip` or `-`. +- **The feed's named number, checked after every row (the stack's cut 1g).** `Params::bound: Option`, the feed's named number: the most split keys the header service's contract says it can have open at once, as the host was told it. Its absent value, and where a host takes it from, are in Hosts, above. It mirrors `StartParams.bound` of `lean/Headers/Host.lean` section 12 at `656c502a`, the field of the table of `docs/p0/reorg-proof-cut2-2026-11-18.md`, "Cut 1g". +- `doubts::over(params, ds)` (the Lean's `over`: more open splits than the number; never with none), `doubts::step_checked(bounds, params, event, ds)` and `doubts::run_checked(bounds, params, ds, rows)` (the Lean's `trips` beside `run`), answering `doubts::Checked`: `Within(doubts)` or `Out(doubts)`, with `doubts`, `into_doubts` and `is_out`. The count is made after every row, not at a page's end: one row over the number answers `Out`, even when a later row brings the count back. The check drops no split and merges no key: the doubts in either answer are `step`'s or `run`'s, every row applied. The start itself is not counted (`trips` of no rows is false). What an out host does next is the host's (Hosts, above). +- **The effective depth, the guard, the builder's test, the out host and the snapshot.** In `bsv_tracker::doubts`, mirrors of bsv-stack-lean at `7e616ab3` under the Lean's names: `lead_tip(headers, ds)` and `eff_depth(headers, ds, x)` (`lean/Headers/Doubts.lean` section 2, `leadTip` and `effDepth`: nothing under an open split at or below `x`, else the lesser of the depth under the host's headers and the lead under the lesser of the feed's tip and the headers' tip over every held entry forking at or below `x`), `spendable_eff(params, headers, ds, rule, state)` (section 4, `spendableEff`) and `may_enter(headers, ds, proof)` (section 5, `mayEnter`: the path's root active at its height and that height's effective depth at least 2), with `AppRule` (`Tracker.AppRule`: a name and `allows: fn(&Word) -> bool`; `#[non_exhaustive]`, `AppRule::new`) and the private mirrors `depth`, `still_confirmed`, `root_checks` and `rule_allows` of `lean/Tracker.lean`. `spendable_eff` reads the spend depth from `Params::spend_depth`, as the Lean's reads `P.spendDepth`, and takes no depth argument: the host sets one depth when it builds its parameters, and the crate applies no floor, as the Lean's guard applies none (Hosts, above). +- The Lean's headers are total and the crate's can fail: a headers fault is an `Err(CheckError::Headers(_))` in each function that reads a header, never a pass. A depth is read before a header, so an open split at or below the height answers `Ok(0)` (and `may_enter` and `spendable_eff` `Ok(false)`) before any header is read, and a word that claims nothing of the chain reads no header; a height the headers carry no header for is `false`, never a pass and never a fault. +- The out host (`lean/Headers/Host.lean` section 12): `eff_c(headers, checked, x)` (nothing at any height while `Checked::Out`, no header read; else `eff_depth`) and `spendable_c(params, headers, checked, rule, state)` (the Lean's `effC` and `spendableC`). +- The snapshot: `Snapshot` (`rival`, `splits`, `tip`; section 6: `Snapshot::new`, `empty`, `least`, `doubts`, and section 12's `fold`, the service's fold), `Served` (the snapshot, its cursor, the row version of the decoder that folded it, the cursor through which every row was readable to that decoder, its tip's hash; `Served::new`), and `accepts(params, headers, cursor, served)` with `start_from`, which gives the doubts and the cursor of a taken snapshot. A snapshot is taken only at the host's cursor or past it; of a version `Params::versions` names; readable through its own cursor; holding at most `Params::bound` open splits; and with its tip, by height and by hash, the host's own verified header. Each refusal is a value of its own, `Refused::Behind`, `Version`, `Unreadable`, `Overfull`, `TipAbsent` and `TipOtherHash`, read in the Lean's order, with `Refused::Headers` for a fault; the four on the snapshot's own parts read no header. The tip's hash is compared in either case. After a start every later row's version is the decoder's to check, as before: the snapshot's version covers the rows to its cursor only. `Snapshot`, `Served` and `Refused` are `#[non_exhaustive]`. - **`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). @@ -126,9 +149,11 @@ assert_eq!( - **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`. +- **CI: the direction rule and its two checks.** The owner's ruling of 2026-11-18, as bsv-wallet-cli holds it: every change is born on `beta`, and `main` takes a `git cherry-pick -x` of a `beta` commit in six classes alone (`RELEASING.md`, "The direction rule"). `.github/workflows/lines.yml` runs `main-in-beta` on every pull request into `beta` and every push to `beta` (each commit of `main` after the merge base `86f193b8` is on `beta` by sha, patch or cherry-pick line, or is a hop commit, as the dependency bot's `Cargo.lock` moves are), `beta-born` on every pull request into `main`, and `lines-selftest`, the 26 planted cases of `.github/ci/test_lines.py`, on every event. No source line, test or public item of the crate changes. ### Changed +- **The pin of the key library, `bsv-rs = "=0.9.0-beta.12"`**, where 0.9.0-beta.10 pinned `=0.9.0-beta.10`. In its published words, cut short: 0.9.0-beta.11 carries the stable line's fixes of 0.8.15, among them that "a transaction that serializes to exactly 64 bytes is never taken as proven by its merkle path; every proof door judges it as an unproven transaction" (GHSA-jjhc-7hvh-c3hm), beside GHSA-f2rq-878r-pgxv, GHSA-pfv3-7r7f-mhgh and GHSA-mp9c-g2q9-q3qw, "Breaking since beta.10. None."; 0.9.0-beta.12 carries "the 64-byte merkle-proof residue": "a 64-byte entry whose named proof does not carry it at its lowest level, or names no bump, is refused again", and "the public words that describe an entry's proof answer through the rule" (GHSA-3h6g-mj4h-rw57), "Breaking since beta.11. None." Both release pages name GHSA-82g9-h6jw-r99f as open on the line, in `Transaction::from_ef` and `from_hex_ef`, which this crate does not call. No source line of this crate changes for the pin and no answer moves: it names `MerklePath` and `MerklePathLeaf` (it builds a path, computes its root and reads its height) and `sha256d`, and bsv-rs's `src/transaction/merkle_path.rs` and `src/primitives/hash.rs` are byte for byte the same in 0.9.0-beta.10 and 0.9.0-beta.12; it calls no BEEF reader, no `Transaction::verify` and no script parser, the doors the two prereleases changed. Every test keeps its name and its answer across the pin, the crate's own rule for a transaction of 64 bytes, which it measures itself, among them. The crate's consumers pin bsv-rs exactly and a build holds one bsv-rs, so they reach the patched prerelease only with a tracker that pins it. - **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. @@ -140,9 +165,22 @@ assert_eq!( - **`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. +- **The doubts' open splits keyed by the fork point (for #51, the stack's cut 1f).** An open split is a pair, its key and its fork height, and nothing more, under `lean/Headers/Doubts.lean` of bsv-stack-lean at `656c502a`, section 7d (`isOpen`, `openSplit`, `closeSplit`; the stack's `docs/DECISIONS-2026-10-19.md` 30.7). The key is the two branches' common ancestor's hash: the row's `key` with its `split:` prefix taken off. `Doubts::new` takes and `Doubts::splits` returns `(Hash, Height)` pairs, the newest key at the front. +- `raw`'s `split` arm: a key not open goes to the front with the row's fork height; a key already open keeps its place and takes the lower of its stored height and the row's, so a repeated `split` row adds nothing. The row's lower witness tip is added as a rival either way. `raw`'s `splitResolved` arm closes the pair of its key and no other, and reads no height; a key not open changes nothing. Two keys open at one height no longer close together. +- `Display` prints each open split as `key:height`: `tip=60 splits=[kb:50 ka:50] rivals=[50:54] summary=-`; an empty list prints `splits=[]` as before. +- The stored form holds each open split as `["", ]`: `"splits":[["k95",95]]`. No release carries the form of fork heights alone (`"splits":[95]`), so there is no reader of it to keep: this reader refuses it, as it refuses a pair without its height, with a third part, or with a key that is not text. +- **Fixed: a split's key in mixed case through `Doubts::new` and the stored form (for #51, #57).** A split's key is lower-cased where it is read from the wire, in `raw` and in `Snapshot::new` (with the snapshot, under Added): the decoder accepts a hash in either case and a key is compared as text, so a `split` row and its `splitResolved` row name one key in whatever case each is sent. `Doubts::new` and the stored form's reader did not lower-case it: a key that came in through either of those two in upper case stayed so, and a `splitResolved` row for it, read in lower case, never closed it. Both now lower-case each key, so a key is held in lower case whichever way it comes in, and the stored form refuses two spellings of one key as one key named twice. `Doubts::new` is no longer a `const fn` (no release carries the module). Test: `a_mixed_case_key_is_held_in_lower_case` in `tests/doubts_rows.rs`, which fails before the change. ### Tests +- `tests/vectors/doubts/rows_of_record.json` is at schema `bsv-tracker-doubts-rows/2`: a `split` row is `["split", k, fh, h1, h2]`, a `splitResolved` row `["resolved", k, fh]`, and a start's open split `[k, fh]`. The five cases holding a split are re-worked from the Lean's own rows at `656c502a` (`split_only`, `split_holds`, `two_splits`, `two_splits_one_resolved`, `split_above_tip`, under the Lean's keys `k0`, `k95`, `k5`, `k8`, `k20`); every other case is byte for byte as it was. +- `tests/doubts_rows.rs` `rows_of_record_asks`, every ask of the rows of record (`eff_depth` under headers carrying no header, and `lead_tip`), 184 counted; `stored_form_refuses` gains the key named twice. `tests/doubts_guard.rs`, 32 tests: appendix B's rows of the plan by the Lean's names (`oneBehind`, `feedAhead` three ways, `Builder.lean`'s `tieDs` and `rivalTwo`, `gapNoHeader`, `spendableEff_today`, `split_holds_coin` with `level_rival_holds_coin`, the guard's two lower arms, the headers fault, `emptyFork`, `emptySplit`, `lowestSplitOnly`, `oneKeyOfTwo`, `settledCut`, `Snapshot.doubts`), and the rows of record of cut 1g's table by name (`absent_today`, `over_then_back`, `extra_key_trips`, `out_zero`, `stuck_at_cursor`, `start_trip_loop`, `overfull_forever`, `covers_not_kept`, `resolve_unknown`, `least_commutes` (its three), `skipped_split`, `after_start`, `other_branch`, `hash_not_content`) over a local mirror of the Lean's `readC`, and every refusal by its value. `rows_of_record.json` gains three cases of the crate's own, worked from `raw` at `7e616ab3` and checked by the run: `rekey_all_order` (the direction of `rekeyAll`'s `foldr`: a front-to-back fold fails it), `reorg_rekey_visible` (a `run` case whose `reorg` rekeys a kept rival: reverting the rekey fails it) and `key_case` (a key in upper case closed in lower case: reading it as sent fails it); 80 cases, 184 asks, sha256 `1287ff6fa1699e673718a27a8e08846991a465f8084ca96af8535f1609c8e2c5`. The CI job `vectors` runs `rows_of_record_states` and `rows_of_record_asks` by name and counts two passes. +- `tests/vectors/doubts/rows_of_record.json` (53 cases taken from the `#guard` rows of `lean/Headers/Doubts.lean` section 8 and `lean/Headers/Host.lean` section 11 at `7213ef4a`; no journal row) and `tests/doubts_rows.rs`: `rows_of_record_states` (every case's printed state after its last row, 53 counted), `stored_form_round_trips` and `stored_form_refuses`. The file's `asks` are for the depth functions, read by `rows_of_record_asks` (the depth's entry above). The CI job `vectors` runs `rows_of_record_states` by name and counts its pass. +- `tests/vectors/doubts/split_cases.txt`, the stack's reducer's own run over twelve synthetic rows (open, lower, keep the lower, a second key at the same height, a resolve of a key never opened, a resolve that leaves the other, a split above the tip, the same split row twice), its opening line naming where it comes from, and `split_cases_oracle` in `tests/doubts_rows.rs`, which replays the rows through `step` from a cold start and compares each state line byte for byte (all twelve agree). `rows_of_record.json` gains 18 cases from the Lean's rows at `656c502a`: cut 1f's (`two_keys`, `closes_both`, `closes_both_then_kb`, the three cases of a key already open, `keep_stored`, two resolves of a key never opened, the three of a split above the tip, the two orders of K5 and the hold past the settled line of K6) and cut 1g's for the keys (`resolve_unknown`, `covers_not_kept_fold`, `covers_not_kept_kept`). The file's count and sha256 after every change of this line are in the depth's entry above (80 cases). +- The feed's named number: six cases of `rows_of_record.json` under the table's rows of record (`absent_today`, `over_then_back` under 1 and under 2, `extra_key_trips` for the started host and the kept one, and the trip of `stuck_at_cursor`), each naming its `bound` and whether it is `out`; every other `run` case is checked under no number and is within, its doubts `run`'s; and `bound_counts_after_rows` (more than the number is over and as many is within, the start is not counted, a row that opens no key still answers `Out` while the count stands over, and the same split row twice never trips it). +- `tests/doubts_properties.rs`, 31 randomized statements over `bsv_tracker::doubts`, each named for the theorem of bsv-stack-lean at `08ce467d` it mirrors (`lean/Headers/Doubts.lean`; `lean/Headers/Host.lean` sections 6 and 12), 256 cases each from the explicit ChaCha seed with no failure persistence, as `tests/properties.rs`: the six issue #51 names (`safe_either_lag`, `reorg_holds_until_headers`, `run_safe`, `run_exact`, `state_bound`, `lesser_cost_bound`), with `run_safe_from`, `no_feed_is_today`, `stale_feed_only_unseen`, `safety`, `coldFrom_safe`, `least_enough` and `least_fold_coversK`; the keyed split's laws of cut 1f (`split_row_holds`, `split_new_key`, `split_open_key`, `split_adds_rival`, `splitResolved_mem`, `splitResolved_unknown`, `splitResolved_reads_no_height`, `splitResolved_keeps_other`, `split_holds_until_resolved`, `splits_never_shrink`, `run_perm`); and cut 1g's bound, out host, snapshot and page loop (`trips_iff`, `trips_none`, `out_passes_nothing`, `effC_le`, `accepts_iff`, `starts_le_reads`). `registerAncestor_is_onProof` pins that the Lean's `registerAncestor` is the tracker's own proof step on a new state, no new item. `docs/VERIFICATION.md` lists each test beside its theorem. No source line changes. +- `tests/journal_states.rs`, `journals_reproduce_the_states_after_every_row`: the header service's two journals, folded from `Doubts::cold(0)` under `Bounds::new(400)` with the crate's own `decode_envelope` and `doubts::step`, reproduce the stack's journal driver's state after every row (bsv-stack-lean at `7213ef4a`, `tools/journal/JournalRun.lean`): each states line equal by the ruled comparison (the cursor, the tip, the splits, the rivals as a set, the summary) and byte for byte. The journals are private to the estate and read in place from `BSV_TRACKER_JOURNALS_DIR` and `BSV_TRACKER_JOURNAL_STATES_DIR`; nothing of them is committed, and a failure names a line's number and the fields that differ, never a value. With the variable unset (CI's run) the test prints a `SKIPPED` line and passes. The run of record: production 6,254 rows, 6,254 states lines equal and byte-equal; the beta 39,686 rows, 11 unreadable deliveries skipped as the driver skips them, 39,675 states lines equal and byte-equal (`docs/VERIFICATION.md`). +- `a_wrong_line_is_named_by_its_fields`: the comparison's witness on a hand-built `Doubts` and hand-written lines, run everywhere. No source line or public item changes. - **`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). @@ -153,7 +191,7 @@ assert_eq!( - **`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/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 the eight competitor proofs of the tests that came before the length rule are 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. @@ -163,76 +201,8 @@ assert_eq!( - **`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 - -### Hosts: what a host of 0.9.0-beta.10 changes to take this line (for #51) - -**A host of the published 0.9.0-beta.10 changes one thing, and may start calling one module.** (1) `Params` is built by `Params::new(age_threshold, spend_depth)` and is `#[non_exhaustive]`. In 0.9.0-beta.10 it was a struct of one public field, `age_threshold`, with no constructor, no `Default` and no `#[non_exhaustive]`, built by literal, so every new field broke every host: the literal is refused once more (E0639), and a later field, which a later minor adds here with a default, breaks none. (2) Its three new fields, each public to read and to assign, and their values when the host says nothing: `spend_depth: u64`, which has no default and is the constructor's second argument (the Lean's `Params.spendDepth` has none, and one host has one depth for an act; a host that reads no guard of `doubts` writes 1, the floor; the crate applies no floor, and a depth of 0 passes a `mined` word whose root the headers carry); `bound: Option`, the feed's named number, absent as `None`, which is no check and the host of today, row for row (it arrived with the keyed splits); and `versions: Vec`, the row versions the host's decoder reads, absent as `vec![1, 2]`, `Params::VERSIONS` (it arrived with the spend depth, by the table of the stack's cut 1g); `with_spend_depth`, `with_bound` and `with_versions` set one. (3) The new module `bsv_tracker::doubts`, nothing of it re-exported at the crate root: a host may start folding each feed row with `doubts::step` (`step_checked` under a number) before the tracker's own step, which takes the event by value; storing the doubts as their serde text, and reporting a text it cannot read as a fault, never a cold start; and reading `eff_depth` for the depth it may trust at a height, `spendable_eff` for the spend guard on it and `may_enter` for the builder's test. A host whose feed names a number sets `bound` from the service's contract, never from a snapshot or a row (a check against a number the checked party sends checks nothing), and treats `Checked::Out` as the feed out of its contract: it keeps the doubts it was given and reads no row; its depths are `eff_c`'s and its guard `spendable_c`'s, which pass no `mined` word under a spend depth of 1 or more (a word with no height passes as today, the row `outZero`); at each page read it makes one ask for a snapshot and nothing more, one start a page read at most and never a start that causes a start; it takes a snapshot through `accepts` or `start_from` alone, at its cursor or past it, and does not ask at its cursor alone, where an honest snapshot holds the count that tripped the check (the row `stuck_at_cursor`); a refused snapshot (`Refused::Overfull`, one that itself holds more open keys than `bound`, among them) builds no doubts, and the host holds every act, as it is still out, and asks again at its next page read, no faster than its page poll. The snapshot's wire is the header service's and the crate reads none: a host reads it into a `Served`. The page loop is the host's. `docs/DOUBTS.md` is the page of every item, beside the Lean name it mirrors at bsv-stack-lean `08ce467d`. (4) Nothing a host already calls has changed its answer: outside the new module only `Params` moves in `src/`, and the tracker's reducer reads none of its three new fields; `State`, `Tracker`, `ChainEvent`, `decode_envelope`, every serde form and the compact bytes are as at 0.9.0-beta.10 (`tests/compact_golden.rs` untouched). bsv-wallet-cli builds `Params` by literal in `src/tracker_host.rs` (two sites); it pins `=0.9.0-beta.10` and does not move until its next pin. - -```rust -// 0.9.0-beta.10 -let params = Params { age_threshold: 60 }; -// this line: the same host, its spend depth said once -let params = Params::new(60, 1); -// a host whose feed names a number -let params = Params::new(60, 1).with_bound(Some(4)); -``` - -### Added: the page of the doubts (for #51) - - `docs/DOUBTS.md`: what the doubts are for a host; every public item of `bsv_tracker::doubts`, and the fields of `Params` it reads, beside the Lean name it mirrors at bsv-stack-lean `08ce467d`, with one line of what it answers; the stored form and what it refuses; the printed line field by field; the feed's named number, the out host, and the snapshot's five conditions with the refusal each gives; what is not mirrored and where it belongs; the test of record and its variables. `docs/SPEC.md` points to it. `README.md` gains a section, "The doubts", whose example runs as a doc test: a host builds its `Params` with `Params::new`, folds a `split` row and its `splitResolved` row, and asks `spendable_eff` for a coin held by the split and then passed four blocks clear of the rival it left. Two doc comments are corrected: `Refused` has two values for the tip's condition, and `Params::spend_depth` is read by `spendable_c` as well. No line of code moves. -### Added: the doubts' theorems as properties (for #51) - -- `tests/doubts_properties.rs`, 31 randomized statements over `bsv_tracker::doubts`, each named for the theorem of bsv-stack-lean at `08ce467d` it mirrors (`lean/Headers/Doubts.lean`; `lean/Headers/Host.lean` sections 6 and 12), 256 cases each from the explicit ChaCha seed with no failure persistence, as `tests/properties.rs`: the six issue #51 names (`safe_either_lag`, `reorg_holds_until_headers`, `run_safe`, `run_exact`, `state_bound`, `lesser_cost_bound`), with `run_safe_from`, `no_feed_is_today`, `stale_feed_only_unseen`, `safety`, `coldFrom_safe`, `least_enough` and `least_fold_coversK`; the keyed split's laws of cut 1f (`split_row_holds`, `split_new_key`, `split_open_key`, `split_adds_rival`, `splitResolved_mem`, `splitResolved_unknown`, `splitResolved_reads_no_height`, `splitResolved_keeps_other`, `split_holds_until_resolved`, `splits_never_shrink`, `run_perm`); and cut 1g's bound, out host, snapshot and page loop (`trips_iff`, `trips_none`, `out_passes_nothing`, `effC_le`, `accepts_iff`, `starts_le_reads`). `registerAncestor_is_onProof` pins that the Lean's `registerAncestor` is the tracker's own proof step on a new state, no new item. `docs/VERIFICATION.md` lists each test beside its theorem. No source line changes. - -### Fixed: a split's key in mixed case through `Doubts::new` and the stored form (for #51, #57) - -- A split's key is lower-cased where it is read from the wire, in `raw` and in `Snapshot::new` (with the snapshot, above): the decoder accepts a hash in either case and a key is compared as text, so a `split` row and its `splitResolved` row name one key in whatever case each is sent. `Doubts::new` and the stored form's reader did not lower-case it: a key that came in through either of those two in upper case stayed so, and a `splitResolved` row for it, read in lower case, never closed it. Both now lower-case each key, so a key is held in lower case whichever way it comes in, and the stored form refuses two spellings of one key as one key named twice. `Doubts::new` is no longer a `const fn` (no release carries the module). Test: `a_mixed_case_key_is_held_in_lower_case` in `tests/doubts_rows.rs`, which fails before the change. - -### Added: the direction rule and its two checks - -- The owner's ruling of 2026-11-18, as bsv-wallet-cli holds it: every change is born on `beta`, and `main` takes a `git cherry-pick -x` of a `beta` commit in six classes alone (`RELEASING.md`, "The direction rule"). `.github/workflows/lines.yml` runs `main-in-beta` on every pull request into `beta` and every push to `beta` (each commit of `main` after the merge base `86f193b8` is on `beta` by sha, patch or cherry-pick line, or is a hop commit, as the dependency bot's `Cargo.lock` moves are), `beta-born` on every pull request into `main`, and `lines-selftest`, the 26 planted cases of `.github/ci/test_lines.py`, on every event. No source line, test or public item of the crate changes. - -### Added: the effective depth, the guard, the builder's test, the out host and the snapshot (for #51) - -- In `bsv_tracker::doubts`, mirrors of bsv-stack-lean at `7e616ab3` under the Lean's names: `lead_tip(headers, ds)` and `eff_depth(headers, ds, x)` (`lean/Headers/Doubts.lean` section 2, `leadTip` and `effDepth`: nothing under an open split at or below `x`, else the lesser of the depth under the host's headers and the lead under the lesser of the feed's tip and the headers' tip over every held entry forking at or below `x`), `spendable_eff(params, headers, ds, rule, state)` (section 4, `spendableEff`) and `may_enter(headers, ds, proof)` (section 5, `mayEnter`: the path's root active at its height and that height's effective depth at least 2), with `AppRule` (`Tracker.AppRule`: a name and `allows: fn(&Word) -> bool`; `#[non_exhaustive]`, `AppRule::new`) and the private mirrors `depth`, `still_confirmed`, `root_checks` and `rule_allows` of `lean/Tracker.lean`. `spendable_eff` reads the spend depth from `Params::spend_depth`, as the Lean's reads `P.spendDepth`, and takes no depth argument: the host sets one depth when it builds its parameters, and the crate applies no floor, as the Lean's guard applies none (Hosts, above). -- The Lean's headers are total and the crate's can fail: a headers fault is an `Err(CheckError::Headers(_))` in each function that reads a header, never a pass. A depth is read before a header, so an open split at or below the height answers `Ok(0)` (and `may_enter` and `spendable_eff` `Ok(false)`) before any header is read, and a word that claims nothing of the chain reads no header; a height the headers carry no header for is `false`, never a pass and never a fault. -- The out host (`lean/Headers/Host.lean` section 12): `eff_c(headers, checked, x)` (nothing at any height while `Checked::Out`, no header read; else `eff_depth`) and `spendable_c(params, headers, checked, rule, state)` (the Lean's `effC` and `spendableC`). -- The snapshot: `Snapshot` (`rival`, `splits`, `tip`; section 6: `Snapshot::new`, `empty`, `least`, `doubts`, and section 12's `fold`, the service's fold), `Served` (the snapshot, its cursor, the row version of the decoder that folded it, the cursor through which every row was readable to that decoder, its tip's hash; `Served::new`), and `accepts(params, headers, cursor, served)` with `start_from`, which gives the doubts and the cursor of a taken snapshot. A snapshot is taken only at the host's cursor or past it; of a version `Params::versions` names; readable through its own cursor; holding at most `Params::bound` open splits; and with its tip, by height and by hash, the host's own verified header. Each refusal is a value of its own, `Refused::Behind`, `Version`, `Unreadable`, `Overfull`, `TipAbsent` and `TipOtherHash`, read in the Lean's order, with `Refused::Headers` for a fault; the four on the snapshot's own parts read no header. The tip's hash is compared in either case. After a start every later row's version is the decoder's to check, as before: the snapshot's version covers the rows to its cursor only. `Snapshot`, `Served` and `Refused` are `#[non_exhaustive]`. -- Tests: `tests/doubts_rows.rs` `rows_of_record_asks`, every ask of the rows of record (`eff_depth` under headers carrying no header, and `lead_tip`), 184 counted; `stored_form_refuses` gains the key named twice. `tests/doubts_guard.rs`, 32 tests: appendix B's rows of the plan by the Lean's names (`oneBehind`, `feedAhead` three ways, `Builder.lean`'s `tieDs` and `rivalTwo`, `gapNoHeader`, `spendableEff_today`, `split_holds_coin` with `level_rival_holds_coin`, the guard's two lower arms, the headers fault, `emptyFork`, `emptySplit`, `lowestSplitOnly`, `oneKeyOfTwo`, `settledCut`, `Snapshot.doubts`), and the rows of record of cut 1g's table by name (`absent_today`, `over_then_back`, `extra_key_trips`, `out_zero`, `stuck_at_cursor`, `start_trip_loop`, `overfull_forever`, `covers_not_kept`, `resolve_unknown`, `least_commutes` (its three), `skipped_split`, `after_start`, `other_branch`, `hash_not_content`) over a local mirror of the Lean's `readC`, and every refusal by its value. `rows_of_record.json` gains three cases of the crate's own, worked from `raw` at `7e616ab3` and checked by the run: `rekey_all_order` (the direction of `rekeyAll`'s `foldr`: a front-to-back fold fails it), `reorg_rekey_visible` (a `run` case whose `reorg` rekeys a kept rival: reverting the rekey fails it) and `key_case` (a key in upper case closed in lower case: reading it as sent fails it); 80 cases, 184 asks, sha256 `1287ff6fa1699e673718a27a8e08846991a465f8084ca96af8535f1609c8e2c5`. The CI job `vectors` runs `rows_of_record_states` and `rows_of_record_asks` by name and counts two passes. - -### Changed: the doubts' open splits keyed by the fork point (for #51, the stack's cut 1f) - -- An open split is now a pair, its key and its fork height, and nothing more, under `lean/Headers/Doubts.lean` of bsv-stack-lean at `656c502a`, section 7d (`isOpen`, `openSplit`, `closeSplit`; the stack's `docs/DECISIONS-2026-10-19.md` 30.7). The key is the two branches' common ancestor's hash: the row's `key` with its `split:` prefix taken off. `Doubts::new` takes and `Doubts::splits` returns `(Hash, Height)` pairs, the newest key at the front. -- `raw`'s `split` arm: a key not open goes to the front with the row's fork height; a key already open keeps its place and takes the lower of its stored height and the row's, so a repeated `split` row adds nothing. The row's lower witness tip is added as a rival either way. `raw`'s `splitResolved` arm closes the pair of its key and no other, and reads no height; a key not open changes nothing. Two keys open at one height no longer close together. -- `Display` prints each open split as `key:height`: `tip=60 splits=[kb:50 ka:50] rivals=[50:54] summary=-`; an empty list prints `splits=[]` as before. -- The stored form holds each open split as `["", ]`: `"splits":[["k95",95]]`. No release carries the form of fork heights alone (`"splits":[95]`), so there is no reader of it to keep: this reader refuses it, as it refuses a pair without its height, with a third part, or with a key that is not text. -- `tests/vectors/doubts/rows_of_record.json` is at schema `bsv-tracker-doubts-rows/2`: a `split` row is `["split", k, fh, h1, h2]`, a `splitResolved` row `["resolved", k, fh]`, and a start's open split `[k, fh]`. The five cases holding a split are re-worked from the Lean's own rows at `656c502a` (`split_only`, `split_holds`, `two_splits`, `two_splits_one_resolved`, `split_above_tip`, under the Lean's keys `k0`, `k95`, `k5`, `k8`, `k20`); every other case is byte for byte as it was. - -- Tests: `tests/vectors/doubts/split_cases.txt`, the stack's reducer's own run over twelve synthetic rows (open, lower, keep the lower, a second key at the same height, a resolve of a key never opened, a resolve that leaves the other, a split above the tip, the same split row twice), its opening line naming where it comes from, and `split_cases_oracle` in `tests/doubts_rows.rs`, which replays the rows through `step` from a cold start and compares each state line byte for byte (all twelve agree). `rows_of_record.json` gains 18 cases from the Lean's rows at `656c502a`: cut 1f's (`two_keys`, `closes_both`, `closes_both_then_kb`, the three cases of a key already open, `keep_stored`, two resolves of a key never opened, the three of a split above the tip, the two orders of K5 and the hold past the settled line of K6) and cut 1g's for the keys (`resolve_unknown`, `covers_not_kept_fold`, `covers_not_kept_kept`). The file's count and sha256 after every change of this line are in the depth's entry above (80 cases). - -### Added: the feed's named number on `Params`, checked after every row (for #51, the stack's cut 1g) - -- `Params::bound: Option`, the feed's named number: the most split keys the header service's contract says it can have open at once, as the host was told it. Its absent value, and where a host takes it from, are in Hosts, above. It mirrors `StartParams.bound` of `lean/Headers/Host.lean` section 12 at `656c502a`, the field of the table of `docs/p0/reorg-proof-cut2-2026-11-18.md`, "Cut 1g". -- `doubts::over(params, ds)` (the Lean's `over`: more open splits than the number; never with none), `doubts::step_checked(bounds, params, event, ds)` and `doubts::run_checked(bounds, params, ds, rows)` (the Lean's `trips` beside `run`), answering `doubts::Checked`: `Within(doubts)` or `Out(doubts)`, with `doubts`, `into_doubts` and `is_out`. The count is made after every row, not at a page's end: one row over the number answers `Out`, even when a later row brings the count back. The check drops no split and merges no key: the doubts in either answer are `step`'s or `run`'s, every row applied. The start itself is not counted (`trips` of no rows is false). What an out host does next is the host's (Hosts, above). -- Tests: six cases of `rows_of_record.json` under the table's rows of record (`absent_today`, `over_then_back` under 1 and under 2, `extra_key_trips` for the started host and the kept one, and the trip of `stuck_at_cursor`), each naming its `bound` and whether it is `out`; every other `run` case is checked under no number and is within, its doubts `run`'s; and `bound_counts_after_rows` (more than the number is over and as many is within, the start is not counted, a row that opens no key still answers `Out` while the count stands over, and the same split row twice never trips it). - -### Added: the doubts' state and reducer (for #51) - -- `bsv_tracker::doubts`, a new public module beside the tracker's reducer: a host's doubts, folded from the header service's feed one row at a time. It mirrors `lean/Headers/Doubts.lean` of bsv-stack-lean at `7213ef4a` under the Lean's names. Nothing is re-exported at the crate root, and no existing item, serde form or compact byte moves: `State`, `Tracker`, `ChainEvent`, the decoder and `tests/compact_golden.rs` are untouched (`Params` is the one existing item that moves: Hosts, above), and a host changes nothing until it calls the module. -- `Rival` (`fork`, `tip`; `Rival::new`, `covers`, `merge`), `Doubts` (the kept rivals, the open splits (keyed above), the feed's tip and the summary of what the prune dropped; `Doubts::new`, `Doubts::cold`, the readers `rivals`, `splits`, `tip`, `gone`, and `held`) and `Bounds` (`settled`; `Bounds::new`, `Bounds::B400`, the feed's settled line). `Rival` and `Bounds` are `#[non_exhaustive]`; `Doubts` keeps its fields private. -- `raw(event, ds)` (the table of rows, no prune), `prune(bounds, ds)`, `step(bounds, event, ds)` (`raw`, then `prune`) and `run(bounds, ds, rows)` (`step` folded from the left). They take the decoded `ChainEvent` a host already holds, take and return values, and read a row's heights and a split row's key alone: no header, clock, root or chain work. The split arms are the keyed ones above. -- The stored form of `Doubts`, its serde text, with the fields in the Lean's order and under the Lean's names: `{"rivals":[{"fork":101,"tip":101}],"splits":[],"tip":103,"gone":null}`. All four fields are required on read, `gone` included (`null` or a rival: a text without it is refused, never read as "nothing dropped"), and a field this reader does not know is refused. `Bounds` has no serde. The compact format stays one transaction's and stays at version 1. -- `Display` for `Doubts`: `tip=103 splits=[] rivals=[101:101] summary=-`, the lists in their order, the summary as `fork:tip` or `-`. -- Tests: `tests/vectors/doubts/rows_of_record.json` (53 cases taken from the `#guard` rows of `lean/Headers/Doubts.lean` section 8 and `lean/Headers/Host.lean` section 11 at `7213ef4a`; no journal row) and `tests/doubts_rows.rs`: `rows_of_record_states` (every case's printed state after its last row, 53 counted), `stored_form_round_trips` and `stored_form_refuses`. The file's `asks` are for the depth functions, read by `rows_of_record_asks` (the depth's entry above). The CI job `vectors` runs `rows_of_record_states` by name and counts its pass. - -### Added: the doubts' test of record (for #51) - -- `tests/journal_states.rs`, `journals_reproduce_the_states_after_every_row`: the header service's two journals, folded from `Doubts::cold(0)` under `Bounds::new(400)` with the crate's own `decode_envelope` and `doubts::step`, reproduce the stack's journal driver's state after every row (bsv-stack-lean at `7213ef4a`, `tools/journal/JournalRun.lean`): each states line equal by the ruled comparison (the cursor, the tip, the splits, the rivals as a set, the summary) and byte for byte. The journals are private to the estate and read in place from `BSV_TRACKER_JOURNALS_DIR` and `BSV_TRACKER_JOURNAL_STATES_DIR`; nothing of them is committed, and a failure names a line's number and the fields that differ, never a value. With the variable unset (CI's run) the test prints a `SKIPPED` line and passes. The run of record: production 6,254 rows, 6,254 states lines equal and byte-equal; the beta 39,686 rows, 11 unreadable deliveries skipped as the driver skips them, 39,675 states lines equal and byte-equal (`docs/VERIFICATION.md`). -- `a_wrong_line_is_named_by_its_fields`: the comparison's witness on a hand-built `Doubts` and hand-written lines, run everywhere. No source line or public item changes. - ## [0.9.0-beta.10] - 2026-11-18 The pin to bsv-rs 0.9.0-beta.10, bsv-rs's security prerelease, so that the toolbox's and the CLI's beta lines can follow onto it through this crate. No behaviour moves and no public item changes: every test of the base keeps its name and its answer, the compact bytes are unchanged (`tests/compact_golden.rs`), and a host changes nothing at this prerelease. diff --git a/Cargo.lock b/Cargo.lock index 274b9a6..32cd9ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,9 +107,9 @@ dependencies = [ [[package]] name = "bsv-rs" -version = "0.9.0-beta.10" +version = "0.9.0-beta.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c56edf841f5a169a1671c893c32c4b886a24878bf09cee5e259ce0220e713a0" +checksum = "185a0622c7348c1842d2880ee7bfa43233cb4e47635eb78360a8dc3a7153ae20" dependencies = [ "aes", "aes-gcm", diff --git a/Cargo.toml b/Cargo.toml index 774e642..2ba5f7f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ default = [] wasm = ["bsv-rs/wasm"] [dependencies] -bsv-rs = { version = "=0.9.0-beta.10", default-features = false, features = ["transaction"] } +bsv-rs = { version = "=0.9.0-beta.12", default-features = false, features = ["transaction"] } serde = { version = "1", features = ["derive"] } serde_json = "1" diff --git a/README.md b/README.md index 86d16ed..17fd918 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # bsv-tracker **0.9.0-beta.11**, a transaction evidence state machine: a prerelease of the -`beta` line, on **bsv-rs =0.9.0-beta.10**. The stable line is `main`, whose +`beta` line, on **bsv-rs =0.9.0-beta.12**. The stable line is `main`, whose release 0.8.0 is on bsv-rs 0.8.0. crates.io carries both versions; the repository's Releases page has a Release for each tag. @@ -38,7 +38,7 @@ a restored `Word::Mined` comes back suspect with `Reask::Recheck` due, and a 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). The crate holds a txid and a path, +its public advisories GHSA-jjhc-7hvh-c3hm and GHSA-3h6g-mj4h-rw57). The crate holds a txid and a path, so the host tells it the length, and these are the host's duties: - Build a proof from the transaction's serialized bytes, `Proof::new(&raw_tx, diff --git a/docs/SPEC.md b/docs/SPEC.md index 0d3e0fe..085b870 100644 --- a/docs/SPEC.md +++ b/docs/SPEC.md @@ -79,7 +79,7 @@ ### 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 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 its `Params`: `State::step` takes them as its argument, and `Tracker::apply` and `Tracker::on_chain` take none, since the tracker holds the `Params` it was given by `Tracker::new`, which is where a host of the tracker picks the mode. - **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. @@ -106,7 +106,7 @@ Both machines answer the length rule, the refusal of the tracked txid as its own ## 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. +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 advisories GHSA-jjhc-7hvh-c3hm and GHSA-3h6g-mj4h-rw57). 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. [SRC] The rule's words are bsv-stack-lean's `docs/DECISIONS-2026-10-19.md` 32.13 at `9a727a64653b602377b6c3acad543e6997544bfb`. `lean/Tracker.lean` at that commit holds no length (no `txLen` in any Lean file): every item below but `State::new` is ahead of the Lean, marked `[AHEAD]`. The Lean names in the table are proposals for its mirror, apart from `State.txLen`, whose name is ruled. diff --git a/docs/VERIFICATION.md b/docs/VERIFICATION.md index b6ab7a7..9a8ba6f 100644 --- a/docs/VERIFICATION.md +++ b/docs/VERIFICATION.md @@ -1519,7 +1519,7 @@ Not mirrored here: `Host.lean`'s hosts over a journal (`host_is_run`, `two_hosts ## The length rule as properties and goldens (GHSA-jjhc-7hvh-c3hm, BRC-237, 2026-11-28) -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). The crate measures the transaction: `State::tx_len`, the two constructors of `Proof` and the doors that read a length. This section is the rule's randomized statements and its compact goldens; the tables and the witness are `tests/measure.rs` and `tests/proof_length.rs`. +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 advisories GHSA-jjhc-7hvh-c3hm and GHSA-3h6g-mj4h-rw57). The crate measures the transaction: `State::tx_len`, the two constructors of `Proof` and the doors that read a length. This section is the rule's randomized statements and its compact goldens; the tables and the witness are `tests/measure.rs` and `tests/proof_length.rs`. [SRC] The stack: bsv-stack-lean at `901e9dfa` (`901e9dfaac42b5dafdf5d5f2c552933dc1c28cd4`), `docs/DECISIONS-2026-10-19.md` 32.13 for the rule's words. `lean/Tracker.lean` there holds no measured length (no `txLen` in any Lean file): every name in the table below is ahead of the Lean and a proposal, apart from `txLen`, whose name is ruled. diff --git a/src/evidence.rs b/src/evidence.rs index face1c0..5605e5c 100644 --- a/src/evidence.rs +++ b/src/evidence.rs @@ -28,7 +28,7 @@ impl std::error::Error for HeaderError {} /// The one length, in bytes, at which a merkle path proves nothing: 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). +/// verifier, its public advisories GHSA-jjhc-7hvh-c3hm, GHSA-3h6g-mj4h-rw57). /// /// A host and a test read this constant, never the literal: a state whose /// [`State::tx_len`](crate::State::tx_len) is `Some(AMBIGUOUS_TX_LEN)` takes @@ -146,10 +146,10 @@ pub(crate) enum Len { /// /// 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). The crate holds the -/// path and the txid, so it is told the length at the constructor: from the -/// transaction's bytes ([`Proof::new`]), or as the host's word -/// ([`Proof::with_stated_len`]). Neither yields a proof at +/// verifier, its public advisories GHSA-jjhc-7hvh-c3hm, GHSA-3h6g-mj4h-rw57). +/// The crate holds the path and the txid, so it is told the length at the +/// constructor: from the transaction's bytes ([`Proof::new`]), or as the +/// host's word ([`Proof::with_stated_len`]). Neither yields a proof at /// [`AMBIGUOUS_TX_LEN`]. /// /// Two proofs are equal when their txid, height and path are: the length a diff --git a/src/hints.rs b/src/hints.rs index 99fb6bf..b2c28aa 100644 --- a/src/hints.rs +++ b/src/hints.rs @@ -4,7 +4,7 @@ use std::fmt; /// A broadcaster's claim reduced to the Lean hint vocabulary. /// -/// `#[non_exhaustive]` (the room made before 0.9.0, bsv-stack-lean +/// `#[non_exhaustive]` (the room made at 0.9.0-beta.9, bsv-stack-lean /// `docs/DECISIONS-2026-10-19.md` 28.8.1 (c)): a later minor may add a kind, /// so a host's match outside this crate carries a wildcard arm. A hint status /// is stored by its serde form and read back by it, never mapped by hand, and diff --git a/tests/compact_golden.rs b/tests/compact_golden.rs index 9445291..688927c 100644 --- a/tests/compact_golden.rs +++ b/tests/compact_golden.rs @@ -494,8 +494,8 @@ fn mined_measured_by_its_proof() { assert_eq!(restored.evidence(), s.evidence()); } -/// The ten states of record with the version 1 bytes each wrote up to -/// 0.9.0-beta.11, verbatim. They are the reader's record and never move: a +/// The ten states of record with the version 1 bytes each wrote up to and +/// including 0.9.0-beta.10, verbatim. They are the reader's record and never move: a /// version 1 row a host stored still restores. type Record = (&'static str, fn() -> State, &'static str); const VERSION_1: [Record; 10] = [