Skip to content

Add stable selection of opaque stack items - #253

Merged
RobinLinus merged 2 commits into
solving-bitcoin:mainfrom
brenorb:codex/stable-stack-compaction
Oct 16, 2026
Merged

RobinLinus merged 2 commits into
solving-bitcoin:mainfrom
brenorb:codex/stable-stack-compaction

Conversation

@brenorb

@brenorb brenorb commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

support::selection::compact_selected_items(n) consumes opaque payload/binary-selector pairs and returns the retained payloads in original order plus their exact count, preserving both caller stacks. Consuming pairs backward avoids forward ROLL routing and a final reversal. At 32 all-retained one-byte pairs it costs 496 fragment / 596 checked-leaf bytes and peaks at 65 combined items, versus 970 / 1,070 / 66 for the matched native forward schedule, with the same 64 entry data items, zero hints and 129 serialized witness bytes.

The public contract requires native tapscript MINIMALIF for exact empty/01 flags. Payload content and selector meaning remain caller obligations. The API accepts 0..=499 pairs; 499 uses 998 entry items and peaks at 999, allowing exactly one caller item. Discarded payloads still count at entry. Explicit guarded comparison variants reach their frontier at 498 pairs. The existing numeric word selector retains its API; the shared audit only clarifies its four-byte numeric condition and lack of limb validation.

The deterministic 110-row report binds source/dependency hashes, execution options, final fragment/leaf hashes, witness/output hashes, typed failures and exact boundaries. Whole-leaf compilation is recorded independently: the 499-pair leaf checking 520-byte outputs is explicitly unoptimized NONE at 270,319 bytes, while its 8,339-byte selection fragment uses ALL. Local policy rejects oversized payloads even when discarded. All new configurations are locally-reproduced / unclassified; no complete Core spend, relay acceptance or cryptographic security claim is made. The KB includes matched comparisons, NR-078 and OP-036.

Validation at delivered commit 12d398f5fef3c287cf5348be954252e7bf05d530, with source artifacts pinned to 666643cf20198f4e831e66f705a7192a216b33b2:

  • Shared contracts: exhaustive small masks, asymmetric long vectors, opaque payloads, every malformed flag position, allowed numeric aliases, short inputs, preserved main/alt state, exact frontiers and count/output/order regressions. Compiled bypass mutants preserve valid controls and are caught by the same typed-error assertion with unchanged cleanup.
  • CARGO_PROFILE_TEST_OPT_LEVEL=1 cargo test --locked -- --skip fields:: on the clean delivered tree, including all active named metrics and artifact recomputation/source checks.
  • Report regenerated independently and compared byte-for-byte; KB validation, 50 Python tests and Rust formatting pass.
  • All 122 existing catalog records and envelope fields preserved semantically against current main; original dirty checkout preserved.

@RobinLinus
RobinLinus merged commit f392f37 into solving-bitcoin:main Oct 16, 2026
3 checks passed
@brenorb
brenorb deleted the codex/stable-stack-compaction branch October 28, 2026 02:57
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.

2 participants