From a76ebcab36fdc78f2824fc59dceaabbeda8189ba Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 19 Oct 2026 18:58:31 +1100 Subject: [PATCH] Prove exact R437 checkpoint work and lifetime backing envelope Add source-bound codec invoices, weighted-stack high water, preparation scan charges and chronological Program contribution. Retain complete producer and stock obligations. --- research/r437-resource-envelope/PROOF.md | 329 +++++++ research/r437-resource-envelope/README.md | 83 ++ research/r437-resource-envelope/REPLAY.log | 7 + research/r437-resource-envelope/RESULT.json | 815 ++++++++++++++++++ research/r437-resource-envelope/SOURCES.json | 102 +++ research/r437-resource-envelope/TASK.json | 89 ++ .../r437-resource-envelope/VALIDATION.json | 39 + research/r437-resource-envelope/VERIFY.json | 52 ++ .../r437-resource-envelope/test_export.py | 57 ++ research/r437-resource-envelope/verify.py | 416 +++++++++ 10 files changed, 1989 insertions(+) create mode 100644 research/r437-resource-envelope/PROOF.md create mode 100644 research/r437-resource-envelope/README.md create mode 100644 research/r437-resource-envelope/REPLAY.log create mode 100644 research/r437-resource-envelope/RESULT.json create mode 100644 research/r437-resource-envelope/SOURCES.json create mode 100644 research/r437-resource-envelope/TASK.json create mode 100644 research/r437-resource-envelope/VALIDATION.json create mode 100644 research/r437-resource-envelope/VERIFY.json create mode 100644 research/r437-resource-envelope/test_export.py create mode 100644 research/r437-resource-envelope/verify.py diff --git a/research/r437-resource-envelope/PROOF.md b/research/r437-resource-envelope/PROOF.md new file mode 100644 index 0000000000..e1f3fdd9e8 --- /dev/null +++ b/research/r437-resource-envelope/PROOF.md @@ -0,0 +1,329 @@ +# Exact checkpoint work and lifetime backing for the R437 caller codecs + +Chris R / Clear1nsight, with substantial OpenAI Codex assistance. Apache-2.0. + +## 1. Boundary and claim + +The primary method is amortized tape complexity. The contrasting method is a +weighted depth-first pebble schedule: an ancestor's saved state remains a +weighted pebble until its child returns; a later sibling reuses the same backing +interval. This distinguishes cumulative work, current live storage, and the +union of every visited cell. No information-theoretic lower bound against other +encodings or schedules is asserted. + +We analyze the **unchanged executable** `RoleParking` and `BankParking`, their +unchanged Tape/Word operations, and ywz65's unchanged parking transition table. +The source pins are the canonical files in SOURCES.json at main +`20ecf2891d80b5acf18d980b2164fb44ea7faa90`. This is the codec used by +`Machine.call` / `Machine.complete_return`. The current R437/OQ4 connection is +PR3967, commit `32af060614fefa9729c86370524c2e72265acd76`, using source +`a24f9ff95c12fd0b6792e3f710569237efd72db2`. Its reported inventory is 28416 +families, 660 staged roles and the 21 names in `macro_machine.NAMES`: R=29097. +We use that inventory as an explicitly attributed parameter, not a fresh replay +of the R437 compiler. The component theorem holds for every finite R. + +Assume a finite, complete, well-bracketed sequence of calls. Every call first +parks exactly R distinct canonical dense roles, including empty roles, then +parks the ungranted live numerical words. It restores in the opposite order. +Bodies use the retained 12-symbol BODY alphabet, begin at position 1 after +LEFT, and have no internal BLANK or LEFT. Two numerical banks have fixed +capacities C_0,C_1 and fixed widths b_0,b_1 >= 2. Child grants are separate from +saved parent words and are cleared before restore. At cuts there are no live +scratch leases. Only these codecs access the shared stack and port; child +computation may use the same codecs recursively. Invalid or interrupted +command sequences are outside the completed-run theorem. + +The theorem covers the checkpoint component, **not** functional refinement of +the residual, whole-word execution, root validity, production of descriptors or +directories, native transport, original-width stock admission, or a whole-caller +constant. Section 6 gives the exact missing join instead of assigning it zero. + +## 2. Exact complete stream invoice + +For one matched outer stream frame let L be the total body-symbol count and R +the number of roles. Both count empty role records. The exact sequential API +invoice, including role scans, encoding/decoding, port scans, table transitions, +all four empty-port checks, and BEGIN/END, is + +| Operation | Exact count | +| --- | ---: | +| reads | 61 L + 23 R + 14 | +| writes | 26 L + 6 R + 2 | +| unit moves | 52 L + 20 R + 10 | + +These are API operations, not Python wall time or a fully expanded multitape +transition count. Add `2R+2` for the same auxiliary command-dispatch convention +as PR2769. The resulting auxiliary action total is **139L+51R+28**. Fixed +finite-control role-loop bookkeeping beyond this explicitly defined measure +is not included in that exact coefficient. + +Derivation, for a role of length l: its complete park/restore non-table scans +cost `(21l+9, 10l+2, 20l+12)` reads/writes/moves. In particular, park erases the +source body, restore writes the body back, and each rewind reaches LEFT. The +four-bit record has s=4l. The retained PUSH/POP table adds +`(10s+14, 4s+4, 8s+8)`. The frame's four empty-port checks contribute `(8,0,8)`; +BEGIN/END contribute `(6,2,2)`. Summing yields the displayed coefficients. +This derivation uses only a symbol loop and its boundaries, so applies to all +finite l; the finite checks do not establish it by extrapolation. + +For the numerical frame, retain PR2769's proven invoice. Let p be the number +of parked (ungranted) words; B their total word-bit count; +`ell_i=max(1,ceil(log2 C_i))`; and + + S = sum over parked words in bank i of (1 + ell_i + b_i). + +Its read/write/move counts are respectively + + 14S+10B+32p+15, 6S+3B+8p+2, 12S+10B+30p+12. + +Including one per inventory slot test and command dispatch gives +`32S+23B+72p+C_0+C_1+31`. Hence one complete paired checkpoint contributes + + checkpoint = 139L + 51R + 32S + 23B + 72p + C_0+C_1 + 59. (1) + +The numerical result is predecessor work, independently exercised here in the +combined stack. Formula (1) is additive over **every call occurrence**. A word +or parent body parked for the next sibling is paid again. The number of calls +cannot be replaced by maximum depth in a time bound. + +With R=29097, even L=p=0 has a checkpoint auxiliary cost +`1484006+C_0+C_1`. This is a component calibration, not a legal zero-body +production R437 packet. At the original capacity `C_0=C_1=2^24`, the expression +is 35038438. The executable empty-body calibration uses capacity one per bank; +it does not allocate 2^25 test slots. A q-dependent constant is still real work +that must be absorbed by a valid packet-domain argument. + +## 3. Weighted stack potential and exact lifetime high water + +For a call v define + + A_v = 2 + R + 4L_v + p_v + S_v. (2) + +The two F cells start the stream/numerical frames; every stream role has one R +record delimiter and 4l bits; every numerical record has one R delimiter and +s bits. At the completed park cut the parking head has advanced exactly A_v. +The code does not decode A_v into control. It is an external proof quantity. + +Let `P(t)` be the sum of A_v over active parked ancestors at a completed cut. +BEGIN/PUSH only extend the current top, and POP/END only contract it. A complete +paired park increases P by A_v and matching restore decreases it by A_v. +During either operation no head exceeds the corresponding completed park top +or descends below its frame origin. The finite transition table verifies these +four local monotonicity/range statements directly. Induction over the properly +nested call word proves the invariant for arbitrary finite depth and any number +of sequential siblings. + +For a nonempty complete run beginning with stack head zero, write + + P_max = max over active paths pi of sum_(v in pi) A_v, + s_max = max(0, all stream lengths 4l, all numerical record lengths s). + +The set of visited parking positions is **exactly** `[0,P_max]`; the shared +packet-port positions are **exactly** `[0,s_max+1]`. Thus their lifetime backing +requirement in tape cells is + + checkpoint backing = P_max + s_max + 3. (3) + +We count positions reached by head movement, including the blank cell at the +stack top. The table reaches that top and the later matched restore scans it. +Each completed record also scans its port terminator and LEFT marker. Hence +these intervals have no gaps; the upper bound is attained. If the run has no +call, its supplied initialization must be counted separately. A pre-existing +opaque stack prefix is outside the owned origin and must be added separately. + +After complete return the parking map is empty, but equation (3) remains +unchanged. Removing a pebble releases occupancy; it does not undo previously +visited backing. Conversely, distinct siblings reuse the same interval: their +weights contribute a maximum in (3) and a sum in (1). The 64-sibling test +separates these two aggregations, with exact primitive metering. + +For a reusable dense stream role k, let m_k be its largest body length during +the **whole** run, including primitives and preparation, not just CALL cuts. +If its operations stay inside the dense prefix and adjacent blank, that role's +lifetime span is at most m_k+2 cells. Summing `m_k+2` over every permanent role +is valid even when different maxima occur at different times. Neither the +maximum live-symbol total nor the final nonblank count is automatically that +sum. The source's fixed-tape design makes the inventory finite; it does not +identify the maxima for free. Numerical banks/templates contribute at most + + (C_0+1)(b_0+2) + (C_1+1)(b_1+2), (4) + +including erased slots. This is the retained PR2769 span bound. + +A full caller certificate may therefore add (3), (4), all `m_k+2` for canonical, +scratch, handoff and protected-output tapes, borrowed input extents, and any +charged finite source tables. The machine inventory is +`R+(q^2+128)+8+1` such owned stream tapes. This is an exact interface for a +whole-caller reserve proof; it does not by itself prove a bound on their m_k. + +## 4. Exact elementary preparation and return scans + +The inherited `prepare_child` first computes projected extents, reads a prefix, +and produces the extended Program. It then copies eight complete capsule +bodies and copies three numerical grants. `call` transfers those bodies into +the cleared canonical roles. The following source-bound scan costs make a +specific part of preparation explicit. They exclude producing the copied data. +All source/target heads enter at position 1; the copied target is empty. + +| Literal operation | reads | writes | moves | +| --- | ---: | ---: | ---: | +| capsule empty check, append_tape of l symbols, target rewind | 5l+5 | l | 4l+6 | +| transfer l symbols over an old target of length m | 5l+2m+7 | 2l+m | 4l+2m+10 | +| Arena.copy of a b-bit word | 8b+9 | 2b+1 | 8b+12 | +| header write/read/clear, H finite bits | 6H+9 | 2H | 6H+12 | + +The code performs each rewind and target erasure included here. For example, +`transfer` first clears all m old target symbols, consumes all l source symbols, +and rewinds both roles. It cannot be charged only l writes. H is the sum of +fixed finite field widths, so it depends on compiled program and bank capacities, +not the runtime program-history length. + +If T is the sum of the eight capsule-body lengths and the three grant widths +are b_0,b_1,b_1, the raw read/write/move action sum for these copies, subsequent +empty-target adoption, numerical grant copies, and finite-header cycle is + + 21T + 18(b_0+2b_1) + 14H + 311. (5) + +This is a distinct count convention from (1): no extra command-dispatch or +inventory-test charge occurs in these elementary primitives. It can be added +to (1) if those auxiliary charges are desired. Formula (5) includes the Program +and directory bodies **at their actual serialized lengths**. For a protected +result of length o overwriting a parent current role of length m, add +`11o+5m+17` for the actual `complete_return` transfer. + +These identities follow by summing the literal Tape loops. The verifier +extracts the authenticated `append_tape` AST, whose sole external value is +BLANK; it runs the full retained implementations for transfer, Word.copy and +FiniteFields. The extraction does not execute the directory producer and is +not claimed to do so. + +## 5. Chronological history is real parked and copied data + +The `Program` grammar gives, including LEFT, + + P_h = 2I + L + 6 + h c, c = Q + 2I + 90. + +Here I and L are fixed index/residue widths, Q is the compiled source-code +width, and h is the number of chronological STEP records. This length identity +is predecessor work. The actual `children.extend` body rebuilds the fixed-width +ROOT, copies every old STEP byte and appends one new STEP. It does this for good, +pair and unit children, including half-width units; history is not reset by a +unit child. Therefore the produced child has exactly P_(h+1) symbols, with the +parent's body restored. The verifier executes this authenticated function body +in 20 fixture contexts, with actual Word arithmetic. Its incoming fields are +fixture objects; it does not execute Callback acceptance or validate a production +source specification. The length proof follows the literal grammar for every +admitted extension, independently of those acceptance tests. + +Each canonical parent Program is among the parked roles. Along d nested calls +whose incoming history is h_0 and whose widths and vocabulary stay fixed, the +Program alone contributes exactly + + 4 d (2I+L+5) + 4c [d h_0 + d(d-1)/2] (5a) + +to the peak parking **body bits**. Its record delimiters and all other bodies +are additional. This follows by summing `4(P_(h_0+j)-1)` for j=0,...,d-1. +Hence replacing history at every level by its initial h_0 omits the quadratic +term `2c d(d-1)`. This is a lower bound on this particular codec's full parked +stack, not a universal storage lower bound or an objection to the admitted +geometric-volume absorption. + +Likewise, the extended Program's capsule copy and adoption alone contribute +`21(P_(h+1)-1)` variable read/write/move actions to (5). Repeated siblings copy +and park their chronological Programs again. The root-coupled history premise +is thus needed for an actual named source term, not merely a loose big-O symbol. +The original program identity/ordinal and accepted-source contracts remain +necessary; this length calculation cannot authenticate an arbitrary history. + +## 6. The remaining gamma and stock join + +For a call occurrence, a transparent ledger is + + gamma_v = checkpoint_v + elementary_preparation_v + + result_transfer_v + Pi_v. (6) + +Pi_v is the as-yet uninstantiated cost of source-code and prefix validation, +`layout.child_extents`, `read_prefix`, `binding.child_program`, temporary-data +cleanup, closing geometry, context creation/restoration/closure, remaining +canonical/scratch boundary scans, and any producer work charged to this boundary. +The adopted child's **whole** residual computation belongs to its recursive +bill, separately. No term in Pi_v is declared zero or inferred from (1). +In particular, PARK does not produce a directory, evaluate a historical +coefficient, establish volume validity, or check original-width stock. + +The retained logical ledger is + + M_j = 8 V_j + 32 Delta_j + E(V_j,h_j,L,I,Q). + +Its bound `M_j < (10+2^-125)V_j` assumes minimal widths, coupled chronology, +admitted q, canonical complete directories, correct stock and the actual source +lifetime inventory. Its geometric identity `V_j=V_root/(WN)^j` also requires +complete physical prefix multiplicities and the fresh-row quotient. We retain +these premises and David Arias's credit. We do not infer their hypotheses from +our small bodies or this codec test. + +A sufficient closing certificate would supply: (i) a local bound +`A_v <= a_q M_j` for each current-source call at level j; (ii) per-role bounds +`m_k <= c_(q,k) max_j M_j` including every preparation/primitive phase; and +(iii) an upper bound on Pi_v and the actual capsule lengths T. Equations (3) +and (4) then give a uniform visited-cell reserve with explicit constants; (1), +(5), (6), and the actual number of calls give its complete boundary-time charge. +This avoids both summing every sibling's storage and charging only one sibling's +work. For example, the retained good/fallback bounds of one/49911 child calls +are multiplicities for time, never additional simultaneous parked ancestors. + +One contrasting encoding has a quick stop test. Suppose a replacement omits +empty roles and instead prefixes each of K nonempty records with a fixed-width +role label of g=ceil(log2 R) bits, retaining the same four-bit body encoding +and one record delimiter. Its record overhead is K(g+1), versus R here. At +R=29097, g=15, it saves this storage only for K<=1818 (strictly K<29097/16). +A production cut retaining all W=28416 nonempty family roles cannot meet that +condition: this replacement pays at least 454656 overhead cells versus 29097. +This rejects only that straightforward indexed-record design at such cuts; +bitmap, compressed-label or changed-ownership encodings need their own complete +codec proofs. No further search or new mechanism is asserted. + +Until that certificate is bound to the production source, the sharp physical +reserve coefficient and complete gamma remain open. Passing the component +checks does not authorize the historical logical coefficient 11 as a physical +visited-cell coefficient. It also does not make PR3967's 46-bit controlled +packet a volume-valid `660*3^4096`-bit root. No stock-margin arithmetic or new +frontier parameter is asserted. + +## 7. Evidence and attribution + +The verifier authenticates all declared live source bytes, loads the five +retained component modules directly, and supplies an inert `loader.activate` +shim only to avoid activating the unrelated full compiler. No tested codec +body, table, Tape operation or Word operation is replaced. Observer subclasses +record positions but do not select controller transitions. In particular, +`parking_machine.Machine.visited` alone omits direct codec accesses; our observer +records both paths. No bytecode cache is trusted by the registered runner. + +The committed receipt covers 32 deterministic randomized forests (397 complete +paired calls), 65 calls with 64 siblings, the R=29097 empty-role calibration, +18 copy/transfer length pairs, four grant widths, three header schemas, a three-grant checkpoint, and 20 literal history extensions. +All three operation counts equal the symbolic formulas; every visited set equals +the claimed interval; parent word aliases and the empty stack boundary restore. +Controls distinguish live-only storage, cumulative sibling storage and empty +role overhead, and reject an interior marker. The tests are component evidence +for the derivations, not a whole multiplier proof or independent human review. + +Credit Jose Manuel / jmbarrancoml for the fixed-role physical caller and PR2769 +numerical codec/invoice; ywz65 / PR2635 for the parking transition table; +David Arias / PR2753 for the logical source, inventory and conditional reserve; +Nick Petalas and retained continuation/Word/record authors. R437 applicability +retains ai-nanachi / PR3647, zxv / PR3690, Ali Romman / PR1043, Sagar Thakrar / +PR3700 and the credited selected/native lineage. PR3936, PR3950 and PR3967 are +the immediate stream audits. We add the full stream invoice, combined lifetime +high-water law, elementary preparation accounting and precise producer join. + +Complementary reserve results are Nick Petalas / PR2708's route nonblank-volume +bound, Ross Richardson / PR2874's packet prefix-return backing identity, and +Kumagi / PR2882's complete packet-loop named-array maximum/private-action +interface. Live GitHub reads during this session confirmed their exact heads +2982489cc00a17bd1c7ee1e206e975eda9bcb64d, +08dd02bd8d8b1fadc5fe8589c2d2875d21fe5fce, and +02483f1b4414286b86d807bf2e8a8b9ddc7cd487 respectively. They explicitly leave +physical reuse/whole-reserve joins open. We do not reprove or import their bounds +as a completed physical m_k inventory. They are useful inputs to that next join. diff --git a/research/r437-resource-envelope/README.md b/research/r437-resource-envelope/README.md new file mode 100644 index 0000000000..fdc3da1266 --- /dev/null +++ b/research/r437-resource-envelope/README.md @@ -0,0 +1,83 @@ +# R437 checkpoint resource envelope + +This package proves an exact checkpoint-component cost and lifetime visited-cell +law for the unchanged physical caller codecs used by the R437/OQ4 adapter. It +also prices the elementary capsule/grant/header scans. The complete production +preparation and full caller reserve remain open. + +The useful distinction is between **sum over call occurrences** for time and +**maximum weighted active path** for parking backing. Empty final storage does +not erase visited cells; repeated siblings reuse backing but repeat scans. +The proof pairs amortized complexity with a weighted depth-first pebble schedule. + +For one stream frame with R canonical roles and L body symbols, the complete +read/write/move invoice is `(61L+23R+14, 26L+6R+2, 52L+20R+10)`. +After adding the retained numerical codec, the auxiliary checkpoint action +count is `139L+51R+32S+23B+72p+C_0+C_1+59`. Every call occurrence pays it. + +A call stores `A=2+R+4L+p+S` parking cells. Across an arbitrary finite completed +call forest, parking plus shared-port backing is exactly +`max_active_path sum A + max_record_bits + 3`, including erased visited cells. +[PROOF.md](PROOF.md) states all boundary premises, derives the counts, includes +complete capsule-copy/adoption, grant and header scan costs, and isolates the +remaining production term Pi instead of treating it as free. + +PR3967 at `32af060614fefa9729c86370524c2e72265acd76` reports 29097 canonical +roles for R437 source `a24f9ff95c12fd0b6792e3f710569237efd72db2`. Our empty-body +calibration executes that many actual codec records. It is explicitly a +parameter calibration, not a new R437 catalogue reconstruction or valid +full-volume residual. The theorem applies to any finite R. At depth d, chronological Program bodies alone contribute the explicit quadratic term derived in PROOF.md; the admitted root/history absorption remains a separate premise. + +## Reproduce + +```sh +python3 -B scripts/research_package.py --package research/r437-resource-envelope +``` + +Python 3.12 and the standard library suffice. The registered commands check +pinned canonical inputs, exact receipts, optimized execution and Git-free +source-corruption controls. The narrow loader runs unchanged component code; +it deliberately does not initialize the complete selected compiler. The +append_tape and history-extend primitives are extracted from authenticated ASTs. + +[RESULT.json](RESULT.json) records 397 random complete calls in 32 forests, +65 calls in the sibling fixture, the 29097-role empty calibration and primitive +scan checks, a three-grant checkpoint and 20 literal history extensions. The proof is a source-bound mathematical derivation; finite checks +are evidence, not formal-kernel verification. No whole GL64 payload, production +ordinary/native/router cohort, selected cold replay, Lean or Docker was run. + +## Coordination and scope + +Explicit donor assignment refines `selected-stock-envelope`: one actual physical +caller component is bounded, rather than rerunning selected cutoff arithmetic. +Main `20ecf2891d80b5acf18d980b2164fb44ea7faa90`, priority revision 6, is the frozen +base. The shared investigation claim is +[PR3967 comment](https://github.com/CrocSwap/integer-mult-bounds/pull/3967#issuecomment-6262146714). +The local overlap helper found related PR2753/2769/physical caller work; remote +coverage failed because gh is unavailable. Live GitHub search and the parent's +Discussion1166/2319 and R437 checks supply partial overlap coverage. Existing +PR2769's numerical invoice is credited and retained; the new result is the +stream invoice, paired lifetime maximum and actual preparation-scan join. + +## Open next questions + +- Bind each canonical, scratch, handoff and output role's maximum extent to the + complete current-source producer. Start at `prepare_child`, then cover each + atomic primitive between cuts. This is needed for a whole-caller visited-cell + coefficient; the existing conditional logical ledger does not instantiate + those maxima by itself. +- Bound Pi in equation (6), including directory/program production and full + root-coupled history evaluation. Start with one source-bound child constructor + and retain original-width stock and prefix multiplicity. Another controlled + returned payload will not close this obligation. +- Review whether a cheaper equivalent codec can reduce empty-role overhead + without introducing unbounded role maps or changing restoration identity. + Start with the fixed R delimiter term and a complete alternate invoice. + This is an optional future mechanism, not part of the present proof. + +Credit Jose Manuel / jmbarrancoml, ywz65, David Arias, Nick Petalas and retained +Word/record/continuation authors; ai-nanachi, zxv, Ali Romman, Sagar Thakrar and +R437/native/selected lineage. Immediate predecessors: PR3936/3950/3967. Complementary logical-backing results by Ross Richardson / PR2874, Kumagi / PR2882 and Nick Petalas / PR2708 are credited without importing them as a whole physical reserve. +Detailed provenance and precise reuse are in PROOF.md and SOURCES.json. +New work by Chris R / Clear1nsight with substantial OpenAI Codex assistance. +Apache-2.0; no source or frontier record is changed. diff --git a/research/r437-resource-envelope/REPLAY.log b/research/r437-resource-envelope/REPLAY.log new file mode 100644 index 0000000000..4861d9d5c6 --- /dev/null +++ b/research/r437-resource-envelope/REPLAY.log @@ -0,0 +1,7 @@ +CHECK Exact unchanged-codec invoices, weighted lifetime spans, primitive copy/grant/header scans and committed receipt. +PASS exact stream/numerical invoice and lifetime high water: 32 forests, 397 random calls +CHECK Same mathematical checks remain active under optimization. +PASS exact stream/numerical invoice and lifetime high water: 32 forests, 397 random calls +CHECK Actual Git-free optimized CLI positive plus every live source corruption and receipt corruption rejects. +PASS Git-free optimized positive; 14 source mutations and changed receipt reject +PASS_REGISTERED_RESEARCH_PACKAGE research/r437-resource-envelope outcome=partial diff --git a/research/r437-resource-envelope/RESULT.json b/research/r437-resource-envelope/RESULT.json new file mode 100644 index 0000000000..46aec78fba --- /dev/null +++ b/research/r437-resource-envelope/RESULT.json @@ -0,0 +1,815 @@ +{ + "actual_role_count_empty_body": { + "api_invoice": { + "moves": 581962, + "reads": 669260, + "writes": 174586 + }, + "calls": 1, + "canonical_visited": 58194, + "command_dispatches": 58198, + "maximum_active_weight": 29099, + "parking_visited": 29100, + "port_visited": 2, + "record_max_bits": 0, + "roles": 29097, + "rows": [ + { + "roles": 29097, + "serialized_word_bits": 0, + "stack_weight": 29099, + "symbols": 0, + "word_bits": 0, + "word_records": 0 + } + ], + "slot_tests": 2, + "sum_all_call_weights": 29099 + }, + "controls": [ + "empty final stack does not imply zero visited backing", + "siblings add work but reuse backing", + "empty canonical roles retain delimiter cost", + "interior LEFT rejects" + ], + "history": { + "literal_extensions": [ + { + "I": 14, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 164, + "half": false, + "history": 0, + "kind": "good", + "parent_symbols_including_LEFT": 39 + }, + { + "I": 14, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 164, + "half": false, + "history": 0, + "kind": "pair", + "parent_symbols_including_LEFT": 39 + }, + { + "I": 14, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 164, + "half": false, + "history": 0, + "kind": "unit", + "parent_symbols_including_LEFT": 39 + }, + { + "I": 14, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 164, + "half": true, + "history": 0, + "kind": "unit", + "parent_symbols_including_LEFT": 39 + }, + { + "I": 20, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 325, + "half": false, + "history": 1, + "kind": "good", + "parent_symbols_including_LEFT": 188 + }, + { + "I": 20, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 325, + "half": false, + "history": 1, + "kind": "pair", + "parent_symbols_including_LEFT": 188 + }, + { + "I": 20, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 325, + "half": false, + "history": 1, + "kind": "unit", + "parent_symbols_including_LEFT": 188 + }, + { + "I": 20, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 325, + "half": true, + "history": 1, + "kind": "unit", + "parent_symbols_including_LEFT": 188 + }, + { + "I": 26, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 510, + "half": false, + "history": 2, + "kind": "good", + "parent_symbols_including_LEFT": 361 + }, + { + "I": 26, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 510, + "half": false, + "history": 2, + "kind": "pair", + "parent_symbols_including_LEFT": 361 + }, + { + "I": 26, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 510, + "half": false, + "history": 2, + "kind": "unit", + "parent_symbols_including_LEFT": 361 + }, + { + "I": 26, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 510, + "half": true, + "history": 2, + "kind": "unit", + "parent_symbols_including_LEFT": 361 + }, + { + "I": 38, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 952, + "half": false, + "history": 4, + "kind": "good", + "parent_symbols_including_LEFT": 779 + }, + { + "I": 38, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 952, + "half": false, + "history": 4, + "kind": "pair", + "parent_symbols_including_LEFT": 779 + }, + { + "I": 38, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 952, + "half": false, + "history": 4, + "kind": "unit", + "parent_symbols_including_LEFT": 779 + }, + { + "I": 38, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 952, + "half": true, + "history": 4, + "kind": "unit", + "parent_symbols_including_LEFT": 779 + }, + { + "I": 62, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 2124, + "half": false, + "history": 8, + "kind": "good", + "parent_symbols_including_LEFT": 1903 + }, + { + "I": 62, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 2124, + "half": false, + "history": 8, + "kind": "pair", + "parent_symbols_including_LEFT": 1903 + }, + { + "I": 62, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 2124, + "half": false, + "history": 8, + "kind": "unit", + "parent_symbols_including_LEFT": 1903 + }, + { + "I": 62, + "L": 5, + "Q": 7, + "child_symbols_including_LEFT": 2124, + "half": true, + "history": 8, + "kind": "unit", + "parent_symbols_including_LEFT": 1903 + } + ], + "scope": "Actual extend body with fixture incoming fields; Callback/source acceptance not executed" + }, + "indexed_role_candidate": { + "R": 29097, + "full_family_K": 28416, + "indexed_overhead": 454656, + "label_bits": 15, + "last_saving_K": 1818, + "original_overhead": 29097, + "scope": "this fixed-width indexed-record design only" + }, + "nonempty_grants": { + "api_invoice": { + "moves": 870, + "reads": 978, + "writes": 361 + }, + "grants": 3, + "parked_parent_words": 3, + "record_bits": 31, + "word_bits": 19 + }, + "preparation_components": { + "copy_transfer_length_pairs": 18, + "grant_widths": [ + 2, + 5, + 13, + 31 + ], + "header_schemas": 3, + "scope": "exact component scans, excluded production of capsule data" + }, + "random_cases": 32, + "random_completed_calls": 397, + "random_max_depth_at_most": 4, + "random_seed": 4373967, + "scope": "unchanged component codecs; no full production caller replay", + "siblings": { + "api_invoice": { + "moves": 23794, + "reads": 27156, + "writes": 9259 + }, + "calls": 65, + "canonical_visited": 31, + "command_dispatches": 914, + "maximum_active_weight": 150, + "parking_visited": 151, + "port_visited": 94, + "record_max_bits": 92, + "roles": 4, + "rows": [ + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 9, + "stack_weight": 20, + "symbols": 1, + "word_bits": 5, + "word_records": 1 + }, + { + "roles": 4, + "serialized_word_bits": 29, + "stack_weight": 130, + "symbols": 23, + "word_bits": 17, + "word_records": 3 + } + ], + "slot_tests": 910, + "sum_all_call_weights": 1410 + } +} diff --git a/research/r437-resource-envelope/SOURCES.json b/research/r437-resource-envelope/SOURCES.json new file mode 100644 index 0000000000..74da302159 --- /dev/null +++ b/research/r437-resource-envelope/SOURCES.json @@ -0,0 +1,102 @@ +{ + "schema_version": 1, + "base_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "b1fea0c94436b236cc2b7d41a7be032811b94c81", + "sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "67f085acd86acd7d4e03922d9cf4b26bca66fed5", + "sha256": "47b42433f5a85809a3aadd29c2c339da2c6ed728e4f7762df6b88bccb7874cf0" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/PROOF.md", + "usage": "input", + "git_blob": "1a08e57eac2a37764066d31baa3ecd3769759158", + "sha256": "552fa306d5cc228f4d8d8553f8ac5fc6a738ef2b66a2cb765ba0638cd229794d" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/records.py", + "usage": "input", + "git_blob": "4f00467a0ff580954ad2fd0c7380240c753ddef3", + "sha256": "0c9c4b23e998597fb877bb1a29da69ac869b68262abe635b162b4dba9c69b372" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/codec.py", + "usage": "input", + "git_blob": "9cd54d9417eb685dcd3f8293f01299ef9046ad31", + "sha256": "5b9fda8136f7e60bece54e3fcc74f4ea0bec7145fa60e1ae3a4d252741b81fd3" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/vendor/parking_machine.py", + "usage": "input", + "git_blob": "cafd614a3b7bc87b019361fcdf890ed976f26d19", + "sha256": "68134779debfb795468a1aaecbc2b9d321d7d4e451313ce7dc8fa7092561df4c" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/vendor/words.py", + "usage": "input", + "git_blob": "8d4ba37e2778acb35b34e0719df2caf138fbeb50", + "sha256": "5c37f57708ba3131bdcb03139f9dbc29886bee44569c09cbba51b68f75acd7f9" + }, + { + "path": "research/selected-bit-physical-caller/macro_machine.py", + "usage": "input", + "git_blob": "5a032e8923f7f8b22bb98f3e39b804beb9906c16", + "sha256": "7bc6e42072a09a08ac961e05c3da01cde012d740d4b4c605f298d994f2ad7c5a" + }, + { + "path": "research/selected-bit-physical-caller/role_parking.py", + "usage": "input", + "git_blob": "fc48c244eefdbaa3e320e86c75a7d187cb5765ef", + "sha256": "1884a3c260d81d5efbc0c33d86a810d6728e55e5764cfcd423f858cc685470f3" + }, + { + "path": "research/selected-bit-physical-caller/scratch_pool.py", + "usage": "input", + "git_blob": "0f22807c65d1bca374b905538512bf8c43702070", + "sha256": "41f1eb93652b7174c3b02f95f70e1a9ce2e2aed0a729e725167c8f226e65d8db" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/directory.py", + "usage": "input", + "git_blob": "c74cacf5ce809c0561d374f137a52df0992b4226", + "sha256": "4270e370b2bfe38ef73aadcd97d1b3496b56bd582115d74331eb9e5ceb90bec7" + }, + { + "path": "research/selected-bit-physical-caller/PROOF.md", + "usage": "input", + "git_blob": "548ecff3ef79a32c14bafc7f2309781181d3c23d", + "sha256": "e5a827e93fe313ba9bf4a2e300bae01b58b28004aa8a8ee119cf6d950edd9f93" + }, + { + "path": "research/selected-bit-physical-caller/README.md", + "usage": "input", + "git_blob": "abd0edba96101a025609d2840c3dbdf4d3e30aa8", + "sha256": "989ad891ce3f866c920a25e0cdd661815f982c4c854370f8c00668eaa15d770c" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/PROOF.md", + "usage": "input", + "git_blob": "7207ce7dec86694f01a3d9c049dcb87cc909e380", + "sha256": "fc9e7dcc5b385b6e508d6a6e9524b93059fa3e9fd5fcfb5eedbd85b3a54ba55e" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/children.py", + "usage": "input", + "git_blob": "ce4935f838516e2b08d13bec767cb803786fbc6b", + "sha256": "a78866939631214c1d1659203b2b5fc062e3c6255e9f11f975c310046b010bd6" + }, + { + "path": "research/selected-bit-physical-caller/macro_binding.py", + "usage": "input", + "git_blob": "c197eb6458be9374cb4684c654bfc99e619dcaf0", + "sha256": "9ef31765d03d2c54fad9296f2ff0707a190ce169e44de4f0f45214e3c410c01a" + } + ] +} diff --git a/research/r437-resource-envelope/TASK.json b/research/r437-resource-envelope/TASK.json new file mode 100644 index 0000000000..fa4344bb90 --- /dev/null +++ b/research/r437-resource-envelope/TASK.json @@ -0,0 +1,89 @@ +{ + "schema_version": 1, + "task_id": "selected-stock-envelope", + "priority_revision": 6, + "base_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "original_card": { + "id": "selected-stock-envelope", + "question": "What explicit uniform stock envelope does the actual selected stopped producer supply at one bootstrap stage?", + "starting_points": [ + "research/selected-bootstrap-stock-audit/README.md", + "research/bootstrap-cutoff-time-space-split/README.md", + "certificates/selected-result.json", + "docs/research/community-efficient1000-review.md", + "research/stock-margin-chain/README.md" + ], + "methods": [ + "Derive a source-bound reserve recurrence at the actual selected atom widths, separating parent stock from completed inner borrowing.", + "Find an exact missing implication or counterexample to a proposed selected-stage stock envelope." + ], + "acceptance_gate": "Bind every coefficient and depth factor to the selected producer and state the width domain. Compare a proved envelope with the sufficient cutoff guard; a large numerical headroom or a historical m=120 coefficient is not a selected m=73 proof.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read #2972 stock-margin chain and the selected stock audit. The new source archive reports the remaining cutoff comparisons, but leaves every actual stock coefficient unresolved; it is not an independently validated reserve envelope.", + "scope": "Source-bound orientation only. Read the named package and review before relying on its local evidence; this command is not its replay or supplier admission." + }, + "first_experiment": "Choose one actual selected producer/stage and derive its parent reserve and depth coefficient from source. Check whether newer handoffs already cover that exact obligation. Stop with the missing implementation lemma if it cannot be bounded; do not rerun #2972 cutoff/headroom arithmetic as a new contribution.", + "bottleneck_link": "This reduces a concrete inherited implementation obligation without confusing unchanged kappa arithmetic with a completed theorem.", + "allowed_variations": [ + "One stage or one explicit reserve/depth implication.", + "An independently checked same-domain proof repair, retaining all remaining assumptions." + ], + "scope_change_triggers": [ + "Importing the historical 57604 or 252 allowance without a selected-producer binding.", + "Calling a conditional fit lemma a full outer-proof adoption.", + "Replacing an actual selected stock coefficient with cutoff comparisons or a conditional fit inequality." + ], + "overlap_terms": [ + "selected stock", + "stock envelope", + "bootstrap cutoff", + "1956", + "1965", + "1990", + "2972", + "stock-margin-chain", + "actual_stock_coefficient" + ], + "existing_checks": [ + { + "scope": "Retained stock audit identifies missing actual selected-stage coefficients; later cutoff-chain arithmetic does not supply them.", + "evidence": "docs/research/research-family-status.md#revision-6-handoffs-source-archives-awaiting-independent-validation", + "remaining": "Derive one actual reserve/depth coefficient from the selected producer.", + "status": "reviewed", + "source_commit": "836b19bfa309ceafbc8ee32a15e8c4b10dde7e11", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "refined", + "actual_scope": "Exact current physical stream/numerical checkpoint invoice and lifetime high-water law; elementary preparation scans; explicit remaining producer join.", + "scope_change_reason": "Explicit donor R437/OQ4 assignment selects one actual caller resource component instead of selected cutoff arithmetic.", + "bottleneck_link": "Replaces unspecified checkpoint work/backing with source-bound coefficients and identifies the remaining whole-producer maxima and Pi obligations.", + "budget_minutes": 60, + "stop_rule": "Stop at the precise component-to-producer join if full preparation/history maxima cannot be source-bound in this session; no another controlled residual claimed as admission.", + "outcome": "partial", + "evidence": "PROOF.md; RESULT.json; registered normal/optimized and Git-free corruption checks.", + "author": "Chris R / Clear1nsight with OpenAI Codex", + "ai_assistance": "Substantial OpenAI Codex assistance for proof derivation, coding, source audit, verification and writing; parent-agent review is not independent human review.", + "open_questions": [ + { + "question": "What source-bound maximum extent does every permanent stream role reach during preparation and atomic primitives?", + "why_it_matters": "Needed to turn the exact lifetime backing functional into a complete physical reserve coefficient.", + "first_step": "Inventory prepare_child and each primitive between cuts against the explicit M ledger.", + "blocked_by": "Complete producer/refinement and admitted root/history/stock premises remain uninstantiated." + }, + { + "question": "What upper bound does the actual current-source constructor supply for Pi in gamma?", + "why_it_matters": "Checkpoint and elementary-copy costs do not price producing directories, histories or projected extents.", + "first_step": "Bind one current-source child constructor and its historical coefficient path with complete prefix multiplicity.", + "blocked_by": "Uniform source-bound data-production costs and original-width stock remain open." + } + ], + "coordination": "https://github.com/CrocSwap/integer-mult-bounds/pull/3967#issuecomment-6262146714" +} diff --git a/research/r437-resource-envelope/VALIDATION.json b/research/r437-resource-envelope/VALIDATION.json new file mode 100644 index 0000000000..945687ce88 --- /dev/null +++ b/research/r437-resource-envelope/VALIDATION.json @@ -0,0 +1,39 @@ +{ + "command": [ + "python3", + "-B", + "scripts/research_package.py", + "--package", + "research/r437-resource-envelope" + ], + "exit_code": 0, + "python": "3.12.3", + "started_utc": "2026-10-19T07:53:19.642544+00:00", + "elapsed_seconds": 70.40577662799842, + "source_and_package_bytes_unchanged": true, + "sha256": { + "research/r437-resource-envelope/PROOF.md": "ddf36ac12f6832dcc8b9928d7fc331dbbadc521d37aaf956398188ca0394d53d", + "research/r437-resource-envelope/README.md": "7919c33f9f1a7a2730f71d6c5067d404c4c9a1d3165c2f39edb8e5876644d4d3", + "research/r437-resource-envelope/RESULT.json": "f90b38402bb4ae72520f3830d5f3fccf3160e11bf6ba5aacdb3f85c6edbbcb06", + "research/r437-resource-envelope/SOURCES.json": "810a95c9ed7ad1a2ecf680b577d7477f1b8635b66a3fb9e952802b646564988b", + "research/r437-resource-envelope/TASK.json": "4480a162707840b85b773f868674667096037e44c71f36db8f06464dde6341dd", + "research/r437-resource-envelope/VERIFY.json": "8dd8d2da8b8981a8d2178b2db38f7cce4c1b5462dc32790b3e75e703ff004c85", + "research/r437-resource-envelope/test_export.py": "2d030eefc44cfee8d8823e2c77fe441d6362a19c2448df06c66293d1077a6d6e", + "research/r437-resource-envelope/verify.py": "047a965414faa2b4a8bda1658455cac7a5ed1947dc4e143fc06f02b9b1170676", + "research/selected-bit-physical-caller/PROOF.md": "e5a827e93fe313ba9bf4a2e300bae01b58b28004aa8a8ee119cf6d950edd9f93", + "research/selected-bit-physical-caller/README.md": "989ad891ce3f866c920a25e0cdd661815f982c4c854370f8c00668eaa15d770c", + "research/selected-bit-physical-caller/inputs/pr2753/PROOF.md": "552fa306d5cc228f4d8d8553f8ac5fc6a738ef2b66a2cb765ba0638cd229794d", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/children.py": "a78866939631214c1d1659203b2b5fc062e3c6255e9f11f975c310046b010bd6", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/directory.py": "4270e370b2bfe38ef73aadcd97d1b3496b56bd582115d74331eb9e5ceb90bec7", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/records.py": "0c9c4b23e998597fb877bb1a29da69ac869b68262abe635b162b4dba9c69b372", + "research/selected-bit-physical-caller/inputs/pr2769/PROOF.md": "fc9e7dcc5b385b6e508d6a6e9524b93059fa3e9fd5fcfb5eedbd85b3a54ba55e", + "research/selected-bit-physical-caller/inputs/pr2769/codec.py": "5b9fda8136f7e60bece54e3fcc74f4ea0bec7145fa60e1ae3a4d252741b81fd3", + "research/selected-bit-physical-caller/inputs/pr2769/vendor/parking_machine.py": "68134779debfb795468a1aaecbc2b9d321d7d4e451313ce7dc8fa7092561df4c", + "research/selected-bit-physical-caller/inputs/pr2769/vendor/words.py": "5c37f57708ba3131bdcb03139f9dbc29886bee44569c09cbba51b68f75acd7f9", + "research/selected-bit-physical-caller/macro_binding.py": "9ef31765d03d2c54fad9296f2ff0707a190ce169e44de4f0f45214e3c410c01a", + "research/selected-bit-physical-caller/macro_machine.py": "7bc6e42072a09a08ac961e05c3da01cde012d740d4b4c605f298d994f2ad7c5a", + "research/selected-bit-physical-caller/role_parking.py": "1884a3c260d81d5efbc0c33d86a810d6728e55e5764cfcd423f858cc685470f3", + "research/selected-bit-physical-caller/scratch_pool.py": "41f1eb93652b7174c3b02f95f70e1a9ce2e2aed0a729e725167c8f226e65d8db" + }, + "scope": "Three registered component commands; no complete production supplier replay" +} diff --git a/research/r437-resource-envelope/VERIFY.json b/research/r437-resource-envelope/VERIFY.json new file mode 100644 index 0000000000..775eee845a --- /dev/null +++ b/research/r437-resource-envelope/VERIFY.json @@ -0,0 +1,52 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/selected-bit-physical-caller/PROOF.md", + "research/selected-bit-physical-caller/README.md", + "research/selected-bit-physical-caller/inputs/pr2753/PROOF.md", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/children.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/directory.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/records.py", + "research/selected-bit-physical-caller/inputs/pr2769/PROOF.md", + "research/selected-bit-physical-caller/inputs/pr2769/codec.py", + "research/selected-bit-physical-caller/inputs/pr2769/vendor/parking_machine.py", + "research/selected-bit-physical-caller/inputs/pr2769/vendor/words.py", + "research/selected-bit-physical-caller/macro_binding.py", + "research/selected-bit-physical-caller/macro_machine.py", + "research/selected-bit-physical-caller/role_parking.py", + "research/selected-bit-physical-caller/scratch_pool.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Exact unchanged-codec invoices, weighted lifetime spans, primitive copy/grant/header scans and committed receipt." + }, + { + "argv": [ + "{python}", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Same mathematical checks remain active under optimization." + }, + { + "argv": [ + "{python}", + "-B", + "{package}/test_export.py" + ], + "timeout_seconds": 180, + "checks": "Actual Git-free optimized CLI positive plus every live source corruption and receipt corruption rejects." + } + ] +} diff --git a/research/r437-resource-envelope/test_export.py b/research/r437-resource-envelope/test_export.py new file mode 100644 index 0000000000..45601fb9c5 --- /dev/null +++ b/research/r437-resource-envelope/test_export.py @@ -0,0 +1,57 @@ +"""Git-free positive replay and exact-source/receipt rejection under -O.""" +from pathlib import Path +import json +import os +import shutil +import subprocess +import sys +import tempfile + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +PACKAGE = HERE.relative_to(ROOT) + + +def need(ok, message): + if not ok: raise ValueError(message) + + +def main(): + pins = [r for r in json.loads((HERE/'SOURCES.json').read_text())['files'] if r['usage']=='input'] + with tempfile.TemporaryDirectory(prefix='r437-resource-export-') as directory: + root = Path(directory) + package = root/PACKAGE + shutil.copytree(HERE, package, ignore=shutil.ignore_patterns('__pycache__', '*.pyc')) + for row in pins: + target = root/row['path'] + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(ROOT/row['path'], target) + env = dict(os.environ) + env.pop('PYTHONPATH', None) + env.pop('PYTHONOPTIMIZE', None) + def run(): + return subprocess.run([sys.executable,'-O','-B','-X',f'pycache_prefix={root}/private-cache',str(package/'verify.py')], + cwd=root, env=env, capture_output=True, text=True, timeout=60) + positive = run() + need(positive.returncode == 0, 'Git-free optimized positive: '+positive.stderr) + rejected = 0 + for row in pins: + target = root/row['path'] + before = target.read_bytes() + target.write_bytes(before+b'\n# intentional corruption control\n') + result = run() + need(result.returncode != 0 and 'changed source: '+row['path'] in result.stderr, + 'exact source mutation rejected before import: '+row['path']) + target.write_bytes(before) + rejected += 1 + receipt = package/'RESULT.json' + value = json.loads(receipt.read_text()) + value['random_completed_calls'] += 1 + receipt.write_text(json.dumps(value)) + result = run() + need(result.returncode != 0 and 'committed exact receipt' in result.stderr, + 'changed mathematical receipt rejects under optimization') + print('PASS Git-free optimized positive;', rejected, 'source mutations and changed receipt reject') + + +if __name__ == '__main__': main() diff --git a/research/r437-resource-envelope/verify.py b/research/r437-resource-envelope/verify.py new file mode 100644 index 0000000000..a7305e506e --- /dev/null +++ b/research/r437-resource-envelope/verify.py @@ -0,0 +1,416 @@ +"""Exact component invoice and lifetime high water for the retained physical codecs. + +The harness authenticates source before importing. The inert loader shim only +avoids loading the unrelated full selected compiler; the two tested codecs and +all record/Word/parking operations execute unchanged pinned source bodies. +""" +import ast +from hashlib import sha256 +import importlib.util +import json +from pathlib import Path +import random +import sys +import types + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +CALLER = ROOT / 'research/selected-bit-physical-caller' + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def authenticate(root=ROOT): + for row in json.loads((HERE / 'SOURCES.json').read_text())['files']: + if row['usage'] == 'input': + need(sha256((root / row['path']).read_bytes()).hexdigest() == row['sha256'], + 'changed source: ' + row['path']) + + +def module(name, path): + spec = importlib.util.spec_from_file_location(name, path) + result = importlib.util.module_from_spec(spec) + sys.modules[name] = result + spec.loader.exec_module(result) + return result + + +def load(): + authenticate() + words = module('words', CALLER / 'inputs/pr2769/vendor/words.py') + records = module('records', CALLER / 'inputs/pr2753/predecessor/vendor/records.py') + parking = module('parking_machine', CALLER / 'inputs/pr2769/vendor/parking_machine.py') + codec = module('bank_codec', CALLER / 'inputs/pr2769/codec.py') + shim = types.ModuleType('loader') + shim.activate = lambda: None + sys.modules['loader'] = shim + roles = module('role_parking', CALLER / 'role_parking.py') + return words, records, parking, codec, roles + + +WORDS, RECORDS, PARKING, CODEC, ROLES = load() + + +class ObservedMachine(PARKING.Machine): + def __init__(self): + super().__init__(packet={0: '^'}, heads=(0, 1)) + self.all_visited = [set(), set()] + + def observe(self): + for k, position in enumerate(self.heads): + self.all_visited[k].add(position) + + def step(self): + self.observe() + super().step() + self.observe() + + +class ObservedCodec(CODEC.BankParking): + def _read(self, tape): + self.machine.observe() + return super()._read(tape) + + def _write(self, tape, symbol): + self.machine.observe() + return super()._write(tape, symbol) + + def _move(self, tape, direction): + self.machine.observe() + super()._move(tape, direction) + self.machine.observe() + + +class ObservedTape(RECORDS.Tape): + def __init__(self): + super().__init__() + self.visited = {0, 1} + + def read(self): + self.visited.add(self.head) + return super().read() + + def write(self, symbol): + self.visited.add(self.head) + return super().write(symbol) + + def step(self, direction): + self.visited.add(self.head) + super().step(direction) + self.visited.add(self.head) + + +def stream_invoice(length, roles, frames=1): + return {'reads': 61*length+23*roles+14*frames, + 'writes': 26*length+6*roles+2*frames, + 'moves': 52*length+20*roles+10*frames} + + +def numeric_invoice(bits, word_bits, records, frames=1): + return {'reads': 14*bits+10*word_bits+32*records+15*frames, + 'writes': 6*bits+3*word_bits+8*records+2*frames, + 'moves': 12*bits+10*word_bits+30*records+12*frames} + + +def add(a, b): + return {k: a[k]+b[k] for k in a} + + +def subtract(a, b): + return {k: a[k]-b[k] for k in a} + + +def snapshot(codec, roles, arenas): + meters = [t.meter for t in roles] + [a.meter for a in arenas] + return {k: sum(getattr(m, k) for m in meters) + codec.codec_counts[k] + + codec.machine.counts[k] for k in ('reads', 'writes', 'moves')} + + +def exercise(role_count, forest, capacity=(8, 6), widths=(5, 7)): + arenas = tuple(WORDS.Arena(b, capacity=c) for b, c in zip(widths, capacity)) + roles = tuple(ObservedTape() for _ in range(role_count)) + machine = ObservedMachine() + codec = ObservedCodec(*arenas, machine=machine) + streams = ROLES.RoleParking(codec, roles) + expected = dict(reads=0, writes=0, moves=0) + observed = dict(expected) + active = maximum = record_max = total_weight = calls = 0 + peak_lengths = [0]*role_count + rows = [] + total_p = 0 + + def visit(node): + nonlocal expected, observed, active, maximum, record_max, total_weight, calls, total_p + lengths, counts, children = node + need(len(lengths) == role_count, 'fixture arity') + for i, (tape, length) in enumerate(zip(roles, lengths)): + tape.rewind() + need(tape.read() == WORDS.BLANK, 'empty reusable body') + for j in range(length): + tape.append(ROLES.BODY[(i+j) % len(ROLES.BODY)]) + tape.rewind() + peak_lengths[i] = max(peak_lengths[i], length) + saved = [] + for a, count in zip(arenas, counts): + saved.append([a.literal((i+1) % (1 << a.bits)) for i in range(count)]) + saved_bytes = [[bytes(w.cells) for w in slots] for slots in saved] + p = sum(counts) + total_p += p + B = sum(c*b for c, b in zip(counts, widths)) + S = sum(c*(1+ell+b) for c, ell, b in zip(counts, codec.slot_bits, widths)) + L = sum(lengths) + A = 2 + role_count + 4*L + p + S + active += A + total_weight += A + maximum = max(maximum, active) + record_max = max(record_max, max((4*x for x in lengths), default=0), + max((1+ell+b for c, ell, b in zip(counts, codec.slot_bits, widths) if c), default=0)) + before = snapshot(codec, roles, arenas) + streams.park() + codec.park() + observed = add(observed, subtract(snapshot(codec, roles, arenas), before)) + need(machine.heads[0] == active, 'weighted active stack equals actual physical head') + for child in children: + visit(child) + before = snapshot(codec, roles, arenas) + codec.restore() + streams.restore() + observed = add(observed, subtract(snapshot(codec, roles, arenas), before)) + active -= A + calls += 1 + need(machine.heads[0] == active, 'matched return restores weighted stack origin') + for i, (tape, length) in enumerate(zip(roles, lengths)): + expected_body = bytes(ROLES.BODY[(i+j) % len(ROLES.BODY)] for j in range(length)) + need(tape.head == 1 and bytes(tape.cells[1:length+1]) == expected_body + and all(x == WORDS.BLANK for x in tape.cells[length+1:]), 'exact body and head restored') + tape.clear() # Caller-owned work, deliberately outside codec invoice. + for a, slots, values in zip(arenas, saved, saved_bytes): + need(all(a.words[w.slot] is w and w.slot in a.live for w in slots), 'original aliases restored') + for w, value in zip(slots, values): + need(bytes(w.cells) == value and w.head == 1, 'exact parent word bytes and head') + a.free(w) # Caller-owned cleanup outside invoice. + expected = add(expected, add(stream_invoice(L, role_count), numeric_invoice(S, B, p))) + rows.append({'roles': role_count, 'symbols': L, 'word_records': p, + 'word_bits': B, 'serialized_word_bits': S, 'stack_weight': A}) + + for root in forest: + visit(root) + need(calls > 0, 'nonempty complete call forest') + need(observed == expected, 'exact complete stream plus numerical scan invoice') + need(codec.codec_counts['slot_tests'] == sum(capacity)*calls, 'fixed inventory scan multiplicity') + need(codec.codec_counts['commands'] == (2*role_count+4)*calls+2*total_p, 'complete command dispatch count') + need(machine.tapes == [{}, {0: '^'}] and machine.heads == [0, 1], 'complete blank stack return') + need(machine.all_visited[0] == set(range(maximum+1)), 'exact lifetime parking span') + need(machine.all_visited[1] == set(range(record_max+2)), 'exact lifetime shared-port span') + need(all(t.visited == set(range(m+2)) for t, m in zip(roles, peak_lengths)), 'per-role maximum backing spans') + # A final empty backing map has forgotten every formerly parked cell. + need(len(machine.tapes[0]) < len(machine.all_visited[0]), 'live-only reserve rejected') + return {'calls': calls, 'roles': role_count, 'api_invoice': observed, + 'slot_tests': codec.codec_counts['slot_tests'], 'command_dispatches': codec.codec_counts['commands'], + 'maximum_active_weight': maximum, 'sum_all_call_weights': total_weight, + 'parking_visited': len(machine.all_visited[0]), + 'port_visited': len(machine.all_visited[1]), + 'canonical_visited': sum(map(len, (t.visited for t in roles))), + 'record_max_bits': record_max, 'rows': rows} + + +def preparation_checks(): + # This exact, hash-authenticated function needs only BLANK. Extracting its + # AST isolates its tape scans; it is not a full directory-module replay. + path = CALLER / 'inputs/pr2753/predecessor/vendor/directory.py' + function = next(x for x in ast.parse(path.read_text()).body + if isinstance(x, ast.FunctionDef) and x.name == 'append_tape') + namespace = {'BLANK': WORDS.BLANK} + exec(compile(ast.Module(body=[function], type_ignores=[]), str(path), 'exec'), namespace) + append_tape = namespace['append_tape'] + samples = 0 + for length in (0, 1, 2, 7, 23, 127): + source, target = ObservedTape(), ObservedTape() + for i in range(length): + source.append(ROLES.BODY[i % len(ROLES.BODY)]) + source.rewind() + def total(ts): + return {k: sum(getattr(t.meter, k) for t in ts) for k in ('reads', 'writes', 'moves')} + before = total((source, target)) + need(target.read() == WORDS.BLANK, 'literal capsule empty guard') + append_tape(source, target) + target.rewind() + need(subtract(total((source, target)), before) == + {'reads': 5*length+5, 'writes': length, 'moves': 4*length+6}, + 'capsule copy including empty check and destination rewind') + for old_length in (0, 1, 19): + out = ObservedTape() + for _ in range(old_length): out.append(1) + out.rewind() + before = total((target, out)) + ROLES.transfer(target, out) + need(subtract(total((target, out)), before) == + {'reads': 5*length+2*old_length+7, 'writes': 2*length+old_length, + 'moves': 4*length+2*old_length+10}, 'exact result/adoption transfer') + # Restore fixture data; this work is excluded from the invoice. + append_tape(source, target); target.rewind() + samples += 1 + for width in (2, 5, 13, 31): + arena = WORDS.Arena(width, capacity=4) + source = arena.literal(1) + before = {k: getattr(arena.meter, k) for k in ('reads', 'writes', 'moves')} + result = arena.copy(source) + after = {k: getattr(arena.meter, k) for k in before} + need(subtract(after, before) == {'reads': 8*width+9, 'writes': 2*width+1, + 'moves': 8*width+12}, 'exact grant copy') + arena.free(result); arena.free(source) + for bounds in ((2,), (2, 2, 8, 16, 16, 16, 8, 8), (2, 3, 100, 2**24, 2**24, 2**24, 2**24, 2**24)): + schema = ROLES.FiniteFields(bounds) + tape = ObservedTape() + H = sum(schema.widths) + before = {k: getattr(tape.meter, k) for k in ('reads', 'writes', 'moves')} + schema.write(tape, [x-1 for x in bounds]) + need(schema.read(tape) == tuple(x-1 for x in bounds), 'finite header round trip') + tape.clear() + after = {k: getattr(tape.meter, k) for k in before} + need(subtract(after, before) == {'reads': 6*H+9, 'writes': 2*H, + 'moves': 6*H+12}, 'exact header write/read/clear') + return {'copy_transfer_length_pairs': samples, 'grant_widths': [2, 5, 13, 31], + 'header_schemas': 3, 'scope': 'exact component scans, excluded production of capsule data'} + + +def grant_check(): + arenas = (WORDS.Arena(7, capacity=8), WORDS.Arena(5, capacity=8)) + roles = (ObservedTape(), ObservedTape()) + for i in range(3): roles[0].append(i % 2) + roles[0].rewind() + parents = ([arenas[0].literal(3), arenas[0].literal(5)], [arenas[1].literal(4)]) + originals = [[bytes(w.cells) for w in slots] for slots in parents] + grants = ([arenas[0].literal(7)], [arenas[1].literal(2), arenas[1].literal(3)]) + machine = ObservedMachine() + codec = ObservedCodec(*arenas, machine=machine) + streams = ROLES.RoleParking(codec, roles) + before = snapshot(codec, roles, arenas) + streams.park() + codec.park(tuple(frozenset(w.slot for w in slots) for slots in grants)) + charged = subtract(snapshot(codec, roles, arenas), before) + need(tuple(a.live for a in arenas) == tuple({w.slot for w in slots} for slots in grants), + 'only owned grants remain live while parent is parked') + for a, slots in zip(arenas, grants): + for w in slots: a.free(w) # Child-owned closure, excluded from checkpoint. + before = snapshot(codec, roles, arenas) + codec.restore(); streams.restore() + charged = add(charged, subtract(snapshot(codec, roles, arenas), before)) + B, S, p = 19, 31, 3 + need(charged == add(stream_invoice(3, 2), numeric_invoice(S, B, p)), 'ungranted-word invoice') + need(len(machine.all_visited[0]) == 2+2+12+p+S+1, 'granted words absent from parent stack') + for a, slots, values in zip(arenas, parents, originals): + for w, value in zip(slots, values): + need(a.words[w.slot] is w and bytes(w.cells) == value and w.head == 1, 'grant case parent restores') + a.free(w) + return {'grants': 3, 'parked_parent_words': p, 'word_bits': B, 'record_bits': S, 'api_invoice': charged} + + +def history_checks(): + path = CALLER/'inputs/pr2753/predecessor/vendor/children.py' + function = next(x for x in ast.parse(path.read_text()).body + if isinstance(x, ast.FunctionDef) and x.name == 'extend') + namespace = dict(vars(RECORDS)); namespace['need'] = WORDS.need + exec(compile(ast.Module(body=[function], type_ignores=[]), str(path), 'exec'), namespace) + extend = namespace['extend'] + results = [] + for h in (0, 1, 2, 4, 8): + I, L, Q = 6*(h+2)+2, 5, 7 + for kind, half in (('good',False), ('pair',False), ('unit',False), ('unit',True)): + index, residue = WORDS.Arena(I, capacity=128), WORDS.Arena(L, capacity=16) + root_size = 64**(h+2) + parent = RECORDS.Program.fixture(index,residue,root_size,2,[(2,19,1,0,0,0)]*h,code_bits=Q) + before = bytes(parent.tape.cells) + P = 2*I+L+6+h*(Q+2*I+90) + need(len(before) == P, 'exact parent grammar length including LEFT') + raw = WORDS.Unsigned(index) + def plus(a,b): + value, carry = raw.add(a,b) + need(not carry,'fixture index margin');return value + incoming = types.SimpleNamespace(program=parent,index=index,residue=residue, + current_code=19,specifications={19:types.SimpleNamespace(template=types.SimpleNamespace(rank=7))}, + raw=raw,final_size=index.literal(4096),sixty_four=index.literal(64),two_index=index.literal(2), + depth=index.literal(h),one_index=index.literal(1),root_size=index.literal(root_size), + root_unit=residue.literal(2),plus=plus) + coordinate=index.zero() + request=types.SimpleNamespace(child_kind=kind,half=half,coordinate=coordinate,field=0,reverse=False) + child=extend(incoming,request) + expected=P+Q+2*I+90 + need(len(child.tape.cells)==expected, 'literal extend appends one STEP with fixed root extent') + need(bytes(parent.tape.cells)==before and parent.tape.head==child.tape.head==1, + 'literal extension preserves parent bytes and both heads') + old_root=2*I+L+6 + need(bytes(child.tape.cells[old_root:P])==before[old_root:], 'all chronological STEP bytes copied') + results.append({'history':h,'kind':kind,'half':half,'I':I,'L':L,'Q':Q, + 'parent_symbols_including_LEFT':P,'child_symbols_including_LEFT':expected}) + for d in range(1,20): + for h in range(5): + I,L,Q=59,7,31 + exact=sum(4*(2*I+L+5+(h+j)*(Q+2*I+90)) for j in range(d)) + closed=4*d*(2*I+L+5)+4*(Q+2*I+90)*(d*h+d*(d-1)//2) + need(exact==closed, 'weighted path history contribution') + return {'literal_extensions':results,'scope':'Actual extend body with fixture incoming fields; Callback/source acceptance not executed'} + + +def main(): + rng = random.Random(4373967) + def node(r, depth): + lengths = [rng.randrange(0, 19) for _ in range(r)] + counts = (rng.randrange(4), rng.randrange(4)) + children = [node(r, depth-1) for _ in range(rng.randrange(3))] if depth else [] + return lengths, counts, children + cases = [] + for r in (0, 1, 4, 9): + for _ in range(8): + cases.append(exercise(r, [node(r, 3) for _ in range(3)])) + # A wide root followed by many narrow siblings distinguishes max active + # depth from cumulative traffic, with the exact same permanent tape bank. + leaf = ([1, 0, 0, 0], (1, 0), []) + siblings = exercise(4, [([23, 0, 0, 0], (2, 1), [leaf]*64)]) + need(siblings['maximum_active_weight'] < siblings['sum_all_call_weights'], + 'cumulative sibling storage is a strict overcount') + # Actual current-source role inventory from PR3967, parameter-only: no + # full-volume R437 packet or semantic child is represented by empty bodies. + actual = exercise(29097, [([0]*29097, (0, 0), [])], capacity=(1, 1), widths=(2, 2)) + need(actual['maximum_active_weight'] == 29099, 'empty roles still pay physical frame cells') + # Four-bit alphabets are finite-control assumptions, not arbitrary bytes. + a, b = WORDS.Arena(2, capacity=1), WORDS.Arena(2, capacity=1) + t = ObservedTape() + t.append(2) # LEFT inside a role body is invalid. + t.rewind() + # rewind would stop at the interior LEFT; restore the legal cut explicitly + # in the rejection fixture, never as a production operation. + t.head = 1 + try: + ROLES.RoleParking(ObservedCodec(a, b, machine=ObservedMachine()), [t]).park() + except ValueError: + pass + else: + raise ValueError('interior marker admitted') + result = {'scope': 'unchanged component codecs; no full production caller replay', + 'preparation_components': preparation_checks(), 'nonempty_grants': grant_check(), 'history': history_checks(), + 'random_seed': 4373967, 'random_cases': len(cases), + 'random_completed_calls': sum(x['calls'] for x in cases), + 'random_max_depth_at_most': 4, 'siblings': siblings, + 'actual_role_count_empty_body': actual, + 'indexed_role_candidate': {'R':29097,'label_bits':(29097-1).bit_length(), + 'last_saving_K':(29097-1)//(1+(29097-1).bit_length()), + 'full_family_K':28416,'indexed_overhead':28416*(1+(29097-1).bit_length()), + 'original_overhead':29097,'scope':'this fixed-width indexed-record design only'}, + 'controls': ['empty final stack does not imply zero visited backing', + 'siblings add work but reuse backing', + 'empty canonical roles retain delimiter cost', + 'interior LEFT rejects']} + output = json.dumps(result, indent=2, sort_keys=True) + '\n' + if '--write' in sys.argv: + (HERE / 'RESULT.json').write_text(output) + else: + need(json.loads((HERE / 'RESULT.json').read_text()) == result, 'committed exact receipt') + print('PASS exact stream/numerical invoice and lifetime high water:', len(cases), 'forests,', result['random_completed_calls'], 'random calls') + + +if __name__ == '__main__': + main()