Repository navigation
feat(u4): add embedded cap clamp - #140
Conversation
|
Review: changes required before merge. The vector result reverses the documented input order. The loop consumes the bottom input first using OP_ROLL, then restores staged results in reverse order. On input [1,2,3] bottom-to-top, the threshold(2), equality(1), trichotomy(2), and clamp(2) cases fail their documented ordered output checks and succeed with the reversed expected vectors. Preserve the documented order and add asymmetric input/output vectors, including preserved main/alt-stack state. Evidence: Reviewed commit: |
fbaa771 to
ba5b56c
Compare
|
Updated in commit
Checks passed: focused clamp tests, all 34 non-ignored |
|
Review of Processing the top input before altstack staging addresses the previously reversed output schedule. Preserve asymmetric ordering and the exact preserved-state stack frontier when rebasing; run the clamp library/metric checks and KB validation. Current integration conflicts: Validation scope: source/diff and existing CI review; no new full-repository or field-arithmetic test run was requested. |
Resolve the six integration conflicts Robin listed (catalog, arithmetic comparison, primitive index, u4 README, u4 mod.rs, primitive_metrics) as a union: every origin/main record, row, module, and metric test is kept unchanged, and the clamp record/row/module/metric is added once. The merged tree differs from origin/main by exactly the PR's original diff. Catalog: 101 main records / 256 configurations plus the clamp record and its configuration = 102 / 257, no duplicate ids, main records byte-equal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add two regressions requested in review: - keeps_asymmetric_witness_order_with_preserved_state: twelve distinct runtime witness nibbles under cap 9 with two distinct preserved main and two distinct alt items; the full final stack must match the documented order. The original bottom-first OP_ROLL schedule returns the exact reversed output vector and fails this test. - preserved_state_stack_frontier_is_exact: for batches 1, 16, 997, 998, exactly `998 - nibble_count` preserved items (main, alt, or split) succeed with a 1,000-item combined peak and intact state; one more item fails with StackSize. Raising U4_CLAMP_MAX_BATCH by one fails it. Consistency fixes: the catalog configuration still quoted the pre-fix script_bytes of 298 (the reversed ROLL schedule) while per_use and the README metric are 270; set it to 270. Measure the previously unchecked u4_clamp_16_witness_items marker (16) and add an explicit u4_clamp_16_hints marker (0). Metric values are otherwise unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed in
Validation, run on the committed HEAD
No field-arithmetic tests and no full-repository test run. Evidence is This head was subsequently integrated into |
Summary\n- add a range-checked u4 batch primitive that saturates each nibble to an embedded public cap\n- use bottom-to-top OP_ROLL scheduling so the capped outputs preserve original order and surrounding state\n- document the intentional information loss, canonical-byte boundary, catalog record, comparison, and exact metrics\n\n## Evidence\n- focused unit tests: cargo test --locked arithmetic::u4::clamp::tests --lib\n- exact metric fixture: cargo test --locked --test primitive_metrics u4_clamp_metrics_are_current -- --exact\n- knowledge validation: python3 tools/kb.py validate\n- formatting, JSON, and diff checks pass\n- representative 16-nibble fragment: 298 script bytes, 33 witness bytes, 18 strict peak stack items, 221 static non-push opcodes\n- execution class remains unclassified; no Bitcoin Core consensus or relay-policy validation is claimed\n\nThe full repository test suite was skipped intentionally.