Skip to content

feat: complete BEEF serialisation (BRC-62/95/96)#121

Merged
sgbett merged 5 commits intomasterfrom
feature/92-beef-serialisation
Mar 6, 2026
Merged

feat: complete BEEF serialisation (BRC-62/95/96)#121
sgbett merged 5 commits intomasterfrom
feature/92-beef-serialisation

Conversation

@sgbett
Copy link
Copy Markdown
Owner

@sgbett sgbett commented Mar 6, 2026

Summary

Completes the BEEF (Background Evaluation Extended Format) implementation for HLR #92:

986 lines added across 4 files. Full test suite: 1363 examples, 0 failures.

Closes #92, closes #116, closes #117, closes #118, closes #119, closes #120

Test plan

  • All 49 BEEF unit specs pass (beef_spec.rb)
  • All 24 BEEF conformance specs pass (conformance/beef_spec.rb)
  • Full suite: 1363 examples, 0 failures
  • RuboCop clean on all changed files

🤖 Generated with Claude Code

sgbett and others added 5 commits March 5, 2026 22:10
…hods

Add convenience methods on Transaction for BEEF serialisation:
- Transaction#to_beef / #to_beef_hex: build BEEF V2 from tx + ancestry
- Transaction.from_beef / .from_beef_hex: parse BEEF, return subject tx

Collects ancestor chain via source_transaction references and merkle
paths, producing a dependency-ordered BEEF bundle.

Implements sub-task #116 of HLR #92.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add merge methods to the Beef class:
- merge_bump: add/deduplicate BUMPs by block height and merkle root
- merge_transaction: recursively merge a tx and its ancestors
- merge_raw_tx: merge from raw transaction bytes
- merge: combine two BEEF bundles with BUMP index remapping
- make_txid_only: convert a transaction entry to TXID-only format

Implements sub-task #117 of HLR #92.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add structural validation and transaction ordering to Beef:
- valid?(allow_txid_only:): checks every tx is proven or has known ancestors
- sort_transactions!: topological sort via Kahn's algorithm

Validation iteratively resolves: proven txs (with BUMPs) are known,
then txs whose inputs all reference known txids become known. TXID-only
entries are invalid by default (opt-in via allow_txid_only: true).

Implements sub-task #118 of HLR #92.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add additional lookup and convenience methods to Beef:
- find_bump: find merkle path for a transaction by txid
- find_transaction_for_signing: return tx with wired source inputs
- find_atomic_transaction: recursive proof tree wiring for ancestors
- to_atomic_hex: hex convenience wrapper for to_atomic_binary

Implements sub-task #119 of HLR #92.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add conformance spec validating Ruby BEEF implementation against Go SDK
test vectors and expected values:

- BRC-62 (V1) format: version, BUMP count, tx count, merkle path wiring
- BRC-96 (V2) format: version (4022206466), 3 BUMPs, 3 txs, known txid
- BRC-95 (Atomic BEEF): magic prefix, subject txid, round-trip
- Empty BEEF: V1/V2 empty hex matches Go SDK expected output
- V1 → V2 upgrade: data preservation across format versions
- Merge conformance: deduplication, combination, post-merge validity
- Transaction convenience methods: from_beef/to_beef round-trips
- Validation: structural validity for all vectors, invalid magic rejection

Implements sub-task #120 of HLR #92.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 89.50617% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/bsv/transaction/beef.rb 89.60% 13 Missing ⚠️
lib/bsv/transaction/transaction.rb 89.18% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@sgbett sgbett merged commit 9fc9133 into master Mar 6, 2026
7 checks passed
@sgbett sgbett deleted the feature/92-beef-serialisation branch March 24, 2026 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment