Skip to content

The record of a conflict and the recheck of conflicted behind Params::recheck_conflicted (for #47) - #72

Merged
Calgooon merged 9 commits into
betafrom
lane/trk-47-1
Nov 29, 2026
Merged

Calgooon merged 9 commits into
betafrom
lane/trk-47-1

Conversation

@Calgooon

@Calgooon Calgooon commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

A host can now turn on the recheck of conflicted: with Params::new(..).with_recheck_conflicted(true) a conflicted word whose every competitor has lost its root from the host's headers returns to the word held before the conflict (seen as announced), with Reask::CompetitorGone. The record behind it is public: State::rivals() (each Competitor with its own measured length, its checked proof and its mark) and State::prior(). With the flag off, the default, the machine is the latch, as before. For every host, a competitor's proof for the tracked txid itself is now refused (CheckError::TxidMismatch).

For #47. Lane 3 (trk-47-1) of the plan for #56 and #47; mirrored from bsv-stack-lean lean/Tracker.lean at a7ef91de (section "The recheck of conflicted").

What it builds

  • Competitor (re-exported), State::rivals, State::prior; on_competitor refuses the tracked txid, then the competitor's length, then the header check; on_verdict puts a node's competitors on the record with no proof; leave_word (Tracker.leaveWord).
  • Params::recheck_conflicted (false in Params::new) and Params::with_recheck_conflicted; State::step reads it: off is Tracker.step, on is Tracker.stepRecheck (recheckConflict, onChainConflict).
  • Tracker: two indexes for conflicted words (standing checked competitors' heights and headers) and, under the flag alone, their selection after the mined words.
  • The compact form fills the two fields version 2 already carries (the record, each competitor with its length as the plan's section 6.4 has it, and the prior word) and reads re-ask tag 8. No version 3: no published release reads version 2.
  • A competitor or a verdict that joins a conflicted word puts each id of the word's list with no entry on the record on it as named (name_the_unrecorded), so after any join the word's list and the record's standing ids are one set: a restored version 1 row's competitors stand as named ones and never leave by a chain event or a recheck. Ahead of onCompetitor and onVerdict (keptRivals) in lean/Tracker.lean at bsv-stack-lean 9a727a64, which keep the record of a state stored before the record existed as it was.
  • Evidence::Competitor's doc, README and docs/SPEC.md: the hash of the competitor's bytes is the crate's check; the spend of our input stays the host's.

The tests and what they pin

  • tests/transitions.rs: the latch leaves a conflicted word whole under every chain event and a recheck; a_competitor_proof_for_the_tracked_txid (refused in both modes; the latch's old answer, conflicted on itself, quoted as what it replaces); the record and the prior word; a competitor's length and the tracked measure kept apart (K4's scope); the door's rows over one state (return, bound, root that stands, fail closed, every word returned to, two competitors, a named one and an empty record never leave, fork then tip, invalidation, splits, hints and host acts).
  • tests/reorg_by_root.rs: the latch's outputs over a registry with conflicted words (the base commit pins them; they do not move, and are equal 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; each refusal of the record and the prior word as bytes; the round trip's generator feeds the door at random places.
  • tests/compact_golden.rs: the published conflicted row of record under the door (a checked competitor joins, its root then gone: the word stays conflicted on the row's competitors, no CompetitorGone), the same with the door off (the latch), and a row nothing joins (never leaves; its write-back bytes spelled as a literal). tests/compact.rs: a_conflicted_word_and_its_record_name_the_same_competitors, over the round trip's generator with every other case a restored version 1 row (129 rows, 46 joins on a row).
  • tests/labels.rs (competitor_gone), a unit test of leave_word, and handed_to_only_beside_handed tightened to conflicted whose prior word is handed, both ways.

Moved by the record (every name of the base is present and green): the golden conflicted_by_ids_and_text (a node's verdict now writes its two competitors on the record and the prior word unknown; its old ending is quoted); version_1_bytes_still_restore and version_2_is_version_1_with_four_empty_fields for that one state; handed_refusals and version_2_refusals lose their pins of a record "held empty in this release"; an_instance_beside_each_word_of_record. Every other golden string is byte-identical.

The proof (tails)

$ cargo fmt --all -- --check
exit 0
$ cargo clippy --locked --all-targets -- -D warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s
$ cargo test --locked
passed 262 failed 0   (the base 13f8d49: 241; 21 added; every base name present)
test result: ok. 17 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.32s
$ RUSTDOCFLAGS=-Dwarnings cargo doc --locked --no-deps
   Generated .../doc/bsv_tracker/index.html
$ cargo build --locked --target wasm32-unknown-unknown --features wasm
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.83s
$ cargo +1.88 check --locked --all-targets
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.30s
$ cargo deny --locked check bans licenses sources
bans ok, licenses ok, sources ok
$ git diff --stat origin/beta
 15 files changed, 2071 insertions(+), 148 deletions(-)

Rows left

  • The decoder accepts a record with no prior word. No run writes a record without prior; the decoder does not refuse it (the plan lists no such refusal). For lane 4 or the keeper.
  • The decoder accepts a conflicted word whose list differs from its standing competitors. The word's ids and the record's standing ids agree on every run; the bytes are not checked for it.
  • The rows file and the properties of the door. rows_of_record_recheck and tests/recheck_properties.rs are lane 4's (trk-47-2); the vectors job's count does not move here.
  • The golden count of the plan. Section 3 said BREAKING (the compact format): Conflicted keeps the competitor's checked proof and is rechecked on a reorg and an invalidation, as Mined is (ruling 28.3) #47's lane moves no golden; a verdict's record moves conflicted_by_ids_and_text. Lane 4's four goldens should be recorded against this layout.

The landing is the captain's.

🤖 Generated with Claude Code

Calgooon and others added 6 commits November 28, 2026 23:20
…to a competitor's proof of the tracked txid (for #47)

The tests that decide #47's lane, at its base: a registry holding a mined
word and two conflicted words (one on a competitor's checked proof, one
named by a node) under every chain event the feed carries, its updates
and states pinned; a conflicted state under every chain event and a
recheck, left whole; and a proof offered as a competitor's for the
tracked txid, which the latch at this commit writes as conflicted on
itself. The next commits keep the two of them unmoved with the mode off and
replace the third.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…al of a competitor that is the tracked transaction, and the mode's flag (for #47)

A conflicted word now keeps what the recheck of #47 reads, mirrored from
bsv-stack-lean lean/Tracker.lean (onCompetitor, onVerdict, keptRivals,
keptPrior, verdictRivals, verdictPrior, leaveWord):

- Competitor, re-exported at the root: its txid, its own measured length
  (Some for one entered by a proof, None for one a verdict named; never
  the tracked transaction's measure), its checked proof and its gone
  mark, with readers; State::rivals and State::prior.
- on_competitor refuses a proof whose txid is the tracked one
  (TxidMismatch, ProofFailed, nothing else moved) before the length's
  refusal and the header check; a checked competitor goes on the record
  at the front with its proof and length, and the word of the moment is
  kept as the prior word when the conflict begins. This moves for every
  host: the latch wrote conflicted on the tracked txid itself.
- on_verdict: a conflicted verdict puts its competitors on the record
  with no proof and keeps the prior word; rejected leaves both.
- Reask::CompetitorGone and its label; Params::recheck_conflicted, false
  in Params::new, with its builder (Params is non-exhaustive: no host
  breaks). Nothing reads the flag yet.
- The compact form fills the two fields version 2 carries (the record and
  the prior word) and reads re-ask tag 8, so a state with a record keeps
  round-tripping; the decoder's refusals follow the plan.

The tests the record moves, each pinned what this change fills: the
conflicted golden (a verdict's state now holds its record and the prior
word unknown; its old ending is quoted), the version 1 row's restore of
that state, the relation of the two versions for it, the refusals of a
record and a prior word "empty in this release", and the instance beside
a conflicted word (kept only when the conflict began from handed). The
self-competitor case of the base commit now reads the refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…check_conflicted (for #47)

With the flag on, State::step is the Lean's stepRecheck (bsv-stack-lean
lean/Tracker.lean: recheckConflict, onChainConflict, rivalAtOrAbove,
rivalCheckedAgainst, rootGone): a conflicted word meeting a chain event or
an executed recheck reads the host's header at each standing competitor's
height, one read each. Every competitor's root gone: the word returns to
the word held before the conflict through leave_word (seen as announced),
with Reask::CompetitorGone naming the word's competitors, the record kept
and marked, the mark cleared, the instances kept only for a return to
handed. A standing competitor unanswered: conflicted on the standing
ones, Reask::Recheck, and the fault of the one nearest the front. A
competitor a node named, and an empty record, never leave. With the flag
off, the default, every output is the latch's.

Tracker keeps two indexes for conflicted words (the heights of their
standing checked competitors and the headers those were checked against)
and, under the flag alone, 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. The crate's split and resolved split meet a
conflicted word as a fork and a tip of a marked word, as they meet a
mined one (the stack's ChainEvent has no split).

Tests: the door's rows over one state (the return, the bound, the root
that stands, fail closed, the words returned to, two competitors, a
named one, an empty record, fork then tip, invalidation, splits, hints
and host acts) and over a registry (the latch's outputs unchanged with
the flag named off, the selection under the door, one header read per
standing competitor with a proof).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s, a state with a record round-trips, and the list property tightened (for #47)

The record and the prior word ride version 2, which no published release
reads: the fields lane 1 of #56 wrote as zero counts now carry their
bodies, so no version 3 is needed. The module's table and the doc of
State::to_compact and State::from_compact now name them: each
competitor's txid, length, checked proof (read back as a record, never
checked against headers) and mark; the prior word as the word field
writes it; re-ask tag 8. A restored record comes back exactly, its
competitors not marked suspect.

Tests: a state with a record round-trips (a checked competitor with its
191-byte length, a named one beside it, the marks after a recheck, a
returned word with CompetitorGone); each refusal as bytes (the tracked
txid as a competitor, a proof of another txid, a checked proof with no
length, a length of 64, a record whose root does not hold, a named
competitor with a length or marked gone, a prior word mined or
conflicted, a bad flag, a count past the bytes); the round-trip
property's generator feeds the door at random places and reaches a
checked record, a mark and a return. handed_to_only_beside_handed is
tightened to conflicted whose prior word is handed, both ways, now that
the prior word exists.

Every golden string of tests/compact_golden.rs is the base's but the
conflicted state of record's tail, moved by the previous change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e door, and what a host must show about a competitor (for #47)

Under ## [Unreleased]: the Hosts paragraph (the latch is the default and
changes nothing; a competitor's proof for the tracked txid is refused for
every host; the hash of a competitor's bytes is the crate's check and
the spend of our input stays the host's; what a host that turns the door
on feeds), the Added entry for Competitor, the record, the prior word,
Params::recheck_conflicted, the door and Reask::CompetitorGone, and the
Changed entry for the refusal and the compact form's two fields, with
the tests that moved and why. README's hosts' lines and docs/SPEC.md's
paragraph on the competitor door say the same in their own words.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Calgooon

Copy link
Copy Markdown
Contributor Author

Held for a fix round, on the captain's ruling after two cold reads at da6dd782 (one said merge; one found a class).

With recheck_conflicted on, a version 1 conflicted row (what the published 0.9.0-beta.10 writes: a word with its list and no record) could leave by a recheck: a checked competitor that joined was put on the record alone, and when its root was gone the standing list came out empty while the row's own competitor still stood. The latch (the flag off, the default) is not touched.

The cure, ruled: when a competitor joins a conflicted word, every id of the word's list that has no entry on the record is put on the record as named, so the list and the record are the same set, and a named competitor never leaves. A version 1 row that nothing joins is untouched and is written back to the same bytes; that write-back is asserted again.

New commits on this branch: the tests that decide, then the cure. Nothing lands before its checks are green and the changed arm is read again. The reads' other rows go to the lane that follows and to the crate's issue 57.

Calgooon and others added 3 commits November 28, 2026 23:39
…s record as one set (for #47)

A version 1 `conflicted` row, as the published 0.9.0-beta.10 writes it,
restores with the word's list and an empty record. Under
`Params::recheck_conflicted` a checked competitor Z that joins went on the
record alone, so a reorg that removed Z's root returned the word to
`unknown` with `CompetitorGone` while the row's own competitors stood.

The tests that decide it: the reader's row (red here: the word becomes
`unknown`), the same row with the door off (the latch, green), a row that
nothing joins (never leaves, and its write-back bytes pinned as a literal:
green), and a property over the round trip's generator that a
`conflicted` word's list and its record's standing ids are one set unless
the record is empty (red here on a join to a restored row).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ecorded competitors (for #47)

The cure of the reader's row. When a checked competitor or a node's
verdict joins a `conflicted` word, each id of the word's list with no
entry on the record goes on it as named (no proof, never rechecked by a
root), after the entries the record holds. After any join the word's
list and the record's standing ids are one set. A restored version 1
row, whose record is empty, is the one state that lists such an id: its
competitors now stand as named ones, so a reorg that removes the joined
competitor's root leaves the word `conflicted` on them, never `unknown`
with `CompetitorGone`. A version 1 row nothing joins is untouched: its
record stays empty and it writes back the same bytes.

Ahead of the Lean: `Tracker.onCompetitor` and `Tracker.onVerdict` keep
the record of a state stored before the record existed as it was.

The property now also holds that a restored row's own competitors never
return; its one return over the generator is a later conflict, begun
after the subject's own proof ended the row's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r (for #47)

CHANGELOG's entry for the door says what a restored version 1
`conflicted` row's competitors are once a competitor or a verdict joins
it: named on the record, so the row never leaves by a chain event or a
recheck. VERIFICATION records the four tests of the round with their
answers before and after the cure, and where the crate builds ahead of
`lean/Tracker.lean` (`onCompetitor`, `onVerdict`, `keptRivals`) at
bsv-stack-lean `9a727a64`. No sentence of docs/SPEC.md describes the
record's join, and none there moves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Calgooon

Copy link
Copy Markdown
Contributor Author

The fix round (lane trk-47-1-fix1), three commits on this branch after da6dd782.

What the read found. A version 1 conflicted row, as the published 0.9.0-beta.10 writes it, restores with the word's list and an empty record; under recheck_conflicted(true) a checked competitor Z that joined went on the record alone, so the word listed [Z, the row's own] while the record held [Z]. A reorg that then removed Z's root left no standing competitor, and the word returned to unknown with CompetitorGone while the row's own competitors still stood.

The cure. 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 (name_the_unrecorded in src/state.rs), so after any join the word's list and the record's standing ids are one set, and a restored row's competitors never leave by a chain event or a recheck; a row nothing joins is not touched.

The Lean. lean/Tracker.lean at bsv-stack-lean 9a727a64 has the state (a State stored before the record existed reads with rivals := [], and recheckConflict leaves a word with no record as it is), and its onCompetitor and onVerdict join it with keptRivals, which keeps the record as it was: the Lean's join reaches the same return from such a state. The crate builds ahead of it there; the two tests are marked [AHEAD OF THE LEAN] in docs/VERIFICATION.md.

test at da6dd782 now
a_version_1_conflicted_row_keeps_its_competitors_under_the_door (the reader's row) red: the word Unknown, CompetitorGone { [Z, hash(8), "Not-An-Id"] }, one entry on the record green: conflicted on [hash(8), "Not-An-Id"], Z on the record marked gone, no re-ask
a_version_1_conflicted_row_is_latched_with_the_door_off green green
a_version_1_conflicted_row_nothing_joins_never_leaves_and_writes_back_whole green green: the write-back bytes pinned as a literal
a_conflicted_word_and_its_record_name_the_same_competitors (property, 256 cases) red green: 129 restored rows, 46 joins on a row, 1 return (a later conflict, after the subject's own proof ended the row's)

What the rule keeps of a gone Z: Z stays on the record marked gone and leaves the word's list (recheckConflict writes the standing ids), so the word is the row's own list.

$ cargo fmt --all -- --check
exit 0
$ cargo clippy --locked --all-targets -- -D warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s
$ cargo test --locked
passed 262 failed 0   (da6dd782: 258; 4 added)
$ RUSTDOCFLAGS=-Dwarnings cargo doc --locked --no-deps
   Generated .../doc/bsv_tracker/index.html
$ cargo build --locked --target wasm32-unknown-unknown --features wasm
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.79s
$ cargo +1.88 check --locked --all-targets
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.03s
$ cargo deny --locked check bans licenses sources
bans ok, licenses ok, sources ok
$ git diff --stat origin/beta
 15 files changed, 2071 insertions(+), 148 deletions(-)

For #47.

@Calgooon
Calgooon merged commit b2a22f7 into beta Nov 29, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant