diff --git a/research/selected-itinerary-compression/MEASUREMENTS.json b/research/selected-itinerary-compression/MEASUREMENTS.json new file mode 100644 index 0000000000..e5210519bd --- /dev/null +++ b/research/selected-itinerary-compression/MEASUREMENTS.json @@ -0,0 +1,35 @@ +{ + "python": "3.12.2 (main, Feb 10 2024, 11:33:20) [Clang 15.0.0 (clang-1500.1.0.2.5)]", + "platform": "macOS-27.0-arm64-arm-64bit", + "replicas": 64, + "measurement": "tracemalloc includes compile only, after coefficient plans and adapter construction", + "records": [ + { + "kind": "original", + "seconds": 0.061647666967473924, + "retained_bytes": 4344080, + "peak_bytes": 4591352, + "instructions": 30723, + "records": 30723 + }, + { + "kind": "compact", + "seconds": 0.6333393339300528, + "retained_bytes": 1986984, + "peak_bytes": 2055080, + "instructions": 30723, + "records": { + "instructions": 30723, + "retained_records": 3843, + "block_instructions": 27648, + "block_runs": 768, + "plan_indexes": 12, + "plan_prefix_entries": 186 + } + } + ], + "recursive_seconds": { + "original": 12.527206416940317, + "compact": 12.890516584040597 + } +} diff --git a/research/selected-itinerary-compression/README.md b/research/selected-itinerary-compression/README.md new file mode 100644 index 0000000000..6870808644 --- /dev/null +++ b/research/selected-itinerary-compression/README.md @@ -0,0 +1,194 @@ +# Compact residual itineraries with unchanged physical continuation PCs + +The authenticated physical compiler can retain one descriptor per complete +residual block run instead of every block tuple, while its original `Machine` +continues to fetch by the same `(mode, pc)`. This package implements that scoped +refinement, preserves every original `Residual` identity, and checks complete +recursive return, payload and cleanup on a bounded source fixture. It does not +claim faster compilation: validation makes the measured compact compile slower. + +The predecessor [wrapper sharing](../selected-wrapper-sharing/README.md), PR +#4758, operates after a full operations tuple already exists. This sink operates +*during* the original append stream and keeps the original wrappers. All frozen +sources remain unchanged; the new adapter is opt-in and is not selected adoption. + +## Exact adapter and observer contract + +`itinerary.compiler` authenticates the complete `macro_code.py` bytes against +SOURCES.json. It requires exactly one of each original construction/finalization +boundary, substitutes a sink there, extracts only `compile_node`, and compiles +that function in a private copy of the authenticated module namespace. Original +`Cursor`, factory, routing and schedule calls retain their order and arguments. +No original function or module global is patched by the compiler adapter. The +replay importer authenticates each imported byte stream using the predecessor +source bridge. As in that bridge, it initializes its loader directly: this is +not a cold selected-loader admission test. + +The accepted source is the pinned emitter and its good/fallback/axis grammar. +Plans and all nested plan fields must be frozen dataclasses, tuples or typed +immutable scalar leaves; mutable fields and unknown fallback commands reject. +The full plan snapshot includes reductions, permutation and sign, not just a +command count. Reuse is by **plan object identity**, with a snapshot consistency +check, never by equal-looking residual keys. Modes are compiled separately. +Every segment stores its exact original `Residual`; each emitted block and end +must refer to that same object, with the same role and expected block label. +The sink rejects missing/extra/reordered/foreign blocks and interrupted segments. + +Plans, Residual fields and binding-provided data are immutable for the simulation +statement. Every reconstructed block fetch checks that the definition still +owns the same plan and axis and that its complete plan snapshot is unchanged. +This catches illicit `object.__setattr__` plan mutation, even though frozen +Python dataclasses can otherwise be bypassed. It is not a claim to make arbitrary +concurrent Python mutation safe, or to reject all mutation before any earlier +non-block instruction executes. Source factory call order, arguments and returned objects are retained within +a stable source namespace. Replacing emitter globals during compilation, Python +frame/stack tracing, and container/type/allocation identity observers are outside +the contract. A binding that rewrites `macro_code.Cursor` mid-call is not covered +by the private-namespace simulation. The +original block tuple itself is reconstructed and need not have the same `id`; +the original Residual **does** have the same `id`. + +The physical caller has only two operations consumers: header sizing with +`len`, and indexed instruction fetch. Its checker receipts use `len`. Nearby +visitation/lifetime/sharing audits iterate the word. The sequence supports all +of these, Python integer-index conversion (including negative indices), bounds, +and tuple-valued slices; slices intentionally materialize their requested word. +It does not claim tuple type, tuple hashing, tuple concatenation, pickling, or +container-identity compatibility with arbitrary external extensions. + +## Pointwise word refinement and continuation proof + +Write the original word as retained non-block instructions and maximal block +runs. For a run with fallback commands `c_0,...,c_(C-1)`, give command `i` weight +3 if it is `child`, and 1 otherwise, and let `e_i` be cumulative weight, with `e_-1=0`. The +least `i` with `e_i > k` gives the command of local block offset `k`. A child +returns `("pair", i, k-e_(i-1))`; another command returns `("sweep", i, 0)`. +This is exactly the original Cursor's stage advance, including all three child +stages. A good plan gives the three fixed forward/good/backward blocks; an axis +run gives its single fixed axis block. + +Induct over source appends. Before a residual, the sink has the same word +prefix. Each original block is checked against the formula before being +released; the descriptor reserves the whole run span, and later block appends +check the remaining offsets. The provisional sink is not published as a Code +until `finish` confirms that every reserved run is complete. End requires the exact run length +and original identity. All other tuples are retained unchanged. Empty fallback +runs contribute zero blocks. At finish, prefix ends therefore partition exactly +the original PC interval. Binary search followed by the formula returns the +same operation fields and original Residual at **every** original index. Length +is bounded by `sys.maxsize`, matching the original Python tuple/`len` domain. + +The Machine's step at an equal mode/PC consequently dispatches an equal +operation. Its residual geometry owner test sees the original same object. +A child call saves `pc+1` with the original finite header; the same length gives +the same header schema. The unchanged park/restore restores the same mode/PC, +and fetching there gives the same successor. Induction on physical steps, +including nested call/return, yields the same payload and observable runtime +trace under the immutability and finite termination premises. This is a written +simulation argument plus finite checks, not a formal theorem about all selected +GL64 execution or a full multiplication theorem. + +## Retained allocation and lookup costs + +Let `A` be non-block tuples, `B` block instructions, `S` nonempty residual runs, +and `P` the total structural size of distinct plan objects. The old operations +container retains `A+B` tuples (plus its list-to-tuple peak); the new container +retains `A+S` entries and prefix ends, with O(P) immutable snapshots/command +prefixes. Original Residual objects, routing tuples and binding data remain. +The comparison is O(A+S+P), not O(S) total memory. Plans are already source inputs; +the **new** snapshot/index allocation is included in the measured compile peak. + +For `R=A+S`, block lookup costs O(log R + log C + P_current): the structural +mutation check walks the entire current plan on every block fetch and allocates +a temporary snapshot. Good and axis blocks still pay that validation cost. +Non-block lookup costs O(log R). Compile continues to enumerate every original +Cursor block, allocates its temporary tuple, validates it, and discards it. +There is no asymptotic source-enumeration time saving. The sink's plan checks and +rank lookup add work; it is not a compiler-speed optimization. + +MEASUREMENTS.json records one local CPython 3.12.2 / macOS 27 arm64 run. Compile +measurement uses mode 0 and 64 replicas of the real GL2 source schedule with precompiled +coefficient plans; tracemalloc starts after plans and adapter construction and +includes all sink metadata. It is a host-dependent observation, not a golden +receipt or selected asymptotic estimate. The original word has 30,723 tuples; +the compact word has 3,843 retained entries, including 768 run descriptors for +27,648 block instructions, plus 12 plan indexes / 186 command-prefix entries. +In this run, traced retained/peak bytes were 4,344,080 / 4,591,352 for the +original and 1,986,984 / 2,055,080 for the compact compile. Compile times were +0.062 / 0.633 seconds respectively; the complete recursive fixture took 12.53 / +12.89 seconds. These are single observations with no statistical speed claim. +The axis-only mode keeps the same entry count and adds metadata, so even the +retention saving is not uniform across modes. +The smaller representation trades compile work and lookup validation for lower +retention; use the exact measured bytes and times rather than extrapolating a +whole-program speed or memory ratio. + +## Independent finite validation and reproduction + +RESULT.json is deterministic. The checks cover: + +- Original Cursor enumeration of all length-0..4 command-kind strings, plus a + good plan: 122 cases, 713 labels. This is independent of the rank formula. +- Complete two-replica GL2 words in both modes: 963 and 123 instructions. A tee + observes the actual source append tuples and checks exact Residual identities; + a separate unmodified emitter call checks the complete ordered values. +- An actual recursive physical Machine with q=2, dimension/cutoff 2, the first + **two** GL2 low classes, four root rows, and all 256 addresses per row (1,024 + payload bits). Both original and compact words execute four calls/returns, + 20 residuals and 675 macros. The unchanged codec parks and restores parents + at nonzero PCs 4, 7, 14 and 17 in mode 1. It is not the predecessor's full + six-low/9,216-bit fixture, which is deliberately not replayed here. +- Independent address-permutation output, identical parking/codec counters, + restored PCs, borrowed tapes/heads/counts, numerical/geometry cleanup and + complete physical work erasure. Logical `Invocation` construction and host + numeric decode are forbidden during execution. +- Destructive controls for wrong block order/identity, missing blocks, wrong + end roles, interrupted/unterminated segments, mutable fields, illicit plan + mutation, changed source bytes and unsupported source shape. At an actual + restored parent, the checker corrupts `pc` by -1, requires the continuation + guard to reject, then restores it before dispatch; the complete run still + finishes. Tuple index bounds and type behavior are checked separately. + +```sh +python3.12 -B scripts/research_package.py --package research/selected-itinerary-compression +``` + +Both normal and `-O` commands are registered, 180 seconds each, using only the +standard library. All invariants use explicit checks that remain active under +`-O`. Verification is read-only. `verify.py --write --measure` explicitly +regenerates the deterministic receipt and optional local measurements. No Lean, +Docker, historical suite, selected GL64 expansion or selected source admission +is run. No stock coefficient, native tariff or kappa changes. + +## Coordination and credit + +Task `selected-stock-envelope`, priority revision 7, **changed scope** to the +concrete compiler representation/continuation handoff left by PR #4758; this +reduces a separate implementation obligation, not the card's reserve recurrence. +Base: `624de9dc66858af0945e5f8a0942488d62280d43`. +Canonical claim: https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-19131513 +Entry overlap covered 299 open PRs, 3695 Discussion records and all 6319 local +notes. Scoped terms found the wrapper-sharing follow-up and distinct residual/ +CALL refinement. Closed histories, all diffs and unpublished work were not +exhaustively searched; absence of a matching implementation is not novelty proof. + +Jose Manuel/jmbarrancoml supplied the physical emitter, caller, Cursor and toy +fixtures; Kewin Talaga/PellaML supplied the authenticated source importer and +visitation/identity audits. Nick Petalas and the residual/CALL refinement +contributors supplied the continuation audit lineage. David Arias, ywz65 and +all retained source notices retain their credits. The new adapter, proof and +checks were prepared by JoyboyBrian with substantial OpenAI Codex assistance; +Apache-2.0. Frozen predecessors and LICENSE/NOTICE remain unchanged. + +## Open next questions + +- Can immutable ownership be enforced cheaply enough to remove the full-plan + snapshot on each block fetch? First specify mutation/extension observers; a + frozen dataclass alone does not prevent `object.__setattr__`. +- Can a source-authenticated regional emitter skip enumeration of already + formula-addressable blocks, while preserving factory and binding observers? + This sink still visits every block; use its exact PC refinement as the starting + obligation, not a claim that GL64 compilation is now practical. +- Can the same contract be admitted through the selected loader and all actual + production bindings? This reduced same-byte runtime replay does not establish + provider admission, uniform stock/time budgets, or the full outer theorem. diff --git a/research/selected-itinerary-compression/RESULT.json b/research/selected-itinerary-compression/RESULT.json new file mode 100644 index 0000000000..7144dd2bab --- /dev/null +++ b/research/selected-itinerary-compression/RESULT.json @@ -0,0 +1,89 @@ +{ + "controls": { + "cursor_blocks": 713, + "cursor_cases": 122, + "index_boundary_controls": 4, + "rejecting_controls": 10 + }, + "full_word": [ + { + "block_instructions": 864, + "block_runs": 24, + "instructions": 963, + "plan_indexes": 12, + "plan_prefix_entries": 186, + "retained_records": 123 + }, + { + "block_instructions": 24, + "block_runs": 24, + "instructions": 123, + "plan_indexes": 24, + "plan_prefix_entries": 0, + "retained_records": 123 + } + ], + "imported_sources": 51, + "recursive": { + "codec": { + "commands": 248, + "moves": 271092, + "reads": 287802, + "slot_tests": 4096, + "writes": 135489 + }, + "counts": { + "calls": 4, + "macros": 675, + "residuals": 20, + "returns": 4 + }, + "instructions": [ + 163, + 23 + ], + "parking": { + "moves": 541968, + "reads": 677952, + "steps": 338976, + "writes": 270992 + }, + "payload_sha256": "52ab99ed3fbdb5f1a855afcdfe4d95f591d5a3804acf8d913822b097745cd812", + "restored": [ + [ + 1, + 4 + ], + [ + 1, + 7 + ], + [ + 1, + 14 + ], + [ + 1, + 17 + ] + ], + "saved": [ + [ + 1, + 4 + ], + [ + 1, + 7 + ], + [ + 1, + 14 + ], + [ + 1, + 17 + ] + ] + } +} diff --git a/research/selected-itinerary-compression/SOURCES.json b/research/selected-itinerary-compression/SOURCES.json new file mode 100644 index 0000000000..90c09eb973 --- /dev/null +++ b/research/selected-itinerary-compression/SOURCES.json @@ -0,0 +1,582 @@ +{ + "schema_version": 1, + "base_commit": "624de9dc66858af0945e5f8a0942488d62280d43", + "files": [ + { + "path": "LICENSE", + "usage": "input", + "git_blob": "261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" + }, + { + "path": "NOTICE", + "usage": "input", + "git_blob": "59d8e0cf3102e15bd11db430838365531e2d7f18", + "sha256": "b49022cb4104d90b182e4c335f670faf45529025b15db77bf0291835083c28bd" + }, + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "c35482cd9035843b15a634cc8276a7e1e40e8395", + "sha256": "6fe0a099b89aa2aed796a13c3a21dafc63f3388ebf397464e44e0451893b9375" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "f126dd2e2dad2b669e75d1d0d0bd05c600725602", + "sha256": "f7a48bfa2659b88378282a8eee7d9fe52cdf505594124c4d1686b58510fffd72" + }, + { + "path": "research/residual-call-refinement/README.md", + "usage": "input", + "git_blob": "4e7cf60a4627c46d9aa1a03198ac3fa2f5fee30d", + "sha256": "8cdaea2958d03909d5c27396dda089e2ce868cc704c3e4d669e1de4d830a0e2f" + }, + { + "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/continuation_checks.py", + "usage": "input", + "git_blob": "f2be8aad16e279c0d1467e21d79d2dd81dcae8d8", + "sha256": "c6ef8fa86a7099af0eb6763a3f5bd43f8f94e1e176cfba38c0077b3e0f5fda48" + }, + { + "path": "research/selected-bit-physical-caller/frame_checks.py", + "usage": "input", + "git_blob": "4b992ffcb0a613da54ca24e31d25e61445799e10", + "sha256": "ced41d9244afcb5275ad5c46dc0f60265afc1e6422d29b277364e945825c4dd8" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/bootstrap.py", + "usage": "input", + "git_blob": "448c9b3a86eedb84220646ab27ff089a32ad5b9b", + "sha256": "eef1c418e8edbdf317d159683e30beaecd971c77cf41d6b09708576405e2141e" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/check_layout.py", + "usage": "input", + "git_blob": "be59d614d25961f891e1640bf85cf5e2f474a059", + "sha256": "454b1587d1ed5ccaea19b621a67e2ceba999d7ede61188125faa41c4dd2ab2b1" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/check_nested_model.py", + "usage": "input", + "git_blob": "20fed6bd389cb53fc52d0ad8389e9e7704c90265", + "sha256": "b1941b882b0659722c3c41994c82f020c1f7ab320dc28c43c2758029ef8a48b7" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/check_recursion.py", + "usage": "input", + "git_blob": "8f36c88e196cf5afc0d6e227ba8568a10bb23c6a", + "sha256": "dde82badf043e553bc635a34295e2b5505d84d6dfbaf96e0cfccb8a8c3dbb158" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/check_runtime.py", + "usage": "input", + "git_blob": "fe355a703475325bca4807b8ffedfa9f6edb74f5", + "sha256": "9fcf0c9a3c84a17446fafe8da50b63db296ba9465d48ddb6fdeac8742dfc98b1" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/check_sign.py", + "usage": "input", + "git_blob": "50669949a1325e8c49aa0ff714c40a50077b5eb8", + "sha256": "ee4fd34acd49962a18d268aefeb20aa3c2673a10e7a43eee3e51a9bd3cf9106a" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/check_sources.py", + "usage": "input", + "git_blob": "5c09a13943070a3bb3c0da06fd19fbc6916d1743", + "sha256": "1c49984ae6ee7f8a44cde16b51e486f0b3ba4ee5c973389ac8d58a82d0a0aa3b" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/consumer.py", + "usage": "input", + "git_blob": "a66d9276f829ce2c619871866816649d5f3687fd", + "sha256": "2f2a8604c23fb2c81f24320c71ed0142118d98dde3be6086adad28e89954a777" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/control_checks.py", + "usage": "input", + "git_blob": "11daa0b2221c5870d19ba2eaf411a6bff3a0398d", + "sha256": "c09d33327932b4ffbb8acb26c8a6bb621bcca542157d22f1edf72679a9359981" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/driver.py", + "usage": "input", + "git_blob": "5b7846a70aada53d87480b337e1c04217118771b", + "sha256": "ceaf8f75de9810a05ebf8f65780b6f8bd7599a5768401d5e4386182afe615cdf" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/layout.py", + "usage": "input", + "git_blob": "aa554b14fe0f6b308d9fba0a2afc92e5a28e20cb", + "sha256": "3beef6534b02c3b011b741f957a7d9fb05a9ac0bba1fed53b2c71834e4ea6bc1" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/linear_sign.py", + "usage": "input", + "git_blob": "6a6e5c02f299fad8c4f7ab724fc36e14a22ab13c", + "sha256": "73e895fc701a4145cbe89d60f5775128354e7f08d0a45eacf22f423913f54e67" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/node.py", + "usage": "input", + "git_blob": "28c98a3573b458f7a055678d70b602b80e6e959e", + "sha256": "0bd4f640cafb5c8f070c161d86445910f77578a672bf5886936ed89e7f6bd21b" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/packet_engine.py", + "usage": "input", + "git_blob": "72543f684f38fefeacc2ee66d81661f1a2439cf7", + "sha256": "c80fc3aa9092f91cc309b2fb2dbc3618bf96bdb9b8498503993ea161f0ae2134" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/peel.py", + "usage": "input", + "git_blob": "38502515afc928082c849cd2cda8578d33a5050a", + "sha256": "8b20888f74b4cd814a97b42ec72528fbfb6d2e936c5022df726f0785d0d01a2e" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/cardinal_counts.py", + "usage": "input", + "git_blob": "6a14feac45094ae9156e8c2c982d6727544f180e", + "sha256": "59ddeac102a0cc51fa49b15aae6aeb68cd68ed217fa974ce916372a177d2ec8f" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/catalogue.py", + "usage": "input", + "git_blob": "0efc0575a7623ac41c094d2e8772beda5a9fdc29", + "sha256": "83ea88f82d4a83c5f889774bfe3519b7ebaa24b6a0e2a969dafff012107a89bf" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/check_headers.py", + "usage": "input", + "git_blob": "1c372b19e19b838a89c0e64daeda15ec6b49f079", + "sha256": "a41dab0c487c341eb32b34a03af74454e15e9e61e7386a1ca426d83f3b68b1ca" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/check_layout.py", + "usage": "input", + "git_blob": "174d843716a684145f934cb55a612bca85aad725", + "sha256": "8f776a21dc0e31f9738d822cfda38db92f1e3672afb880d4246ec5e084a50a41" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/check_runtime.py", + "usage": "input", + "git_blob": "5647693b3a5c1555b65e281c6609f98b92d45542", + "sha256": "5357e4ff255f17c4209aaf71a3413a4148475f11180c4f829e8f0ebacd2877cb" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/check_sources.py", + "usage": "input", + "git_blob": "9219cdf863d9f060d6e38a4f2f4760fd227af003", + "sha256": "6463c2724e04a313181b78e90a17cd62ee42465754902cca3e9a65c6140a15a1" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/consumer.py", + "usage": "input", + "git_blob": "24b53521fce94d3349072cf47d70e62195f4d541", + "sha256": "b28ec97b0873ff2be25aff4bdde268247ffcec0d21279d0ada196de19a0bdc66" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/control.py", + "usage": "input", + "git_blob": "4f6ac09bffab43dbccc470bd0bde2ffbe969a8b2", + "sha256": "d3a93e54bb7d333b73917586407d11674d38b5c3fda4fbdc436fb5293ae7786a" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/control_checks.py", + "usage": "input", + "git_blob": "712cfddc4caaad9e788d97b0e1e3f623172c43ed", + "sha256": "5ea6ded8c2508fbb00d93655affdfe7907ffb60916389e0736249c003a7a5148" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/driver.py", + "usage": "input", + "git_blob": "0bdee4c9e348259b470a636a98e7657770f97fae", + "sha256": "ee9e42fe95ab28fdd5e927c2d46fd480305aaad610eb2ca7ae514a5d22d9f0ac" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/fresh_rows.py", + "usage": "input", + "git_blob": "aa3a327604308d3a5c7a27b65f5e631d430ab093", + "sha256": "e4ae08fbd658add630eb7754ebe0cbcb42c6f39cf4128f9cb92e27fcf5213a7d" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/layout.py", + "usage": "input", + "git_blob": "267d5ab98cd013ee82ba75e6d41609f1778af25f", + "sha256": "7534b0166805f2ae8d11495c811d2bd272cea89c89b6bb5251fd411c89245a20" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/model.py", + "usage": "input", + "git_blob": "9fb82fa57d29cdf8402f91534dffed8f586ced6c", + "sha256": "c937ae8e46162f88fc1cd7646d3b22c99273029ad0f0e3131f46ddec230676cb" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/node.py", + "usage": "input", + "git_blob": "13badda6f059da2132cbe325c071307e5191baa3", + "sha256": "b88fc9ac0b22d939311ff4f7aff788e8c87a64fd5e866498e59bd27940ee3f28" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/packet_engine.py", + "usage": "input", + "git_blob": "27a0dbf82e78252beede56ff86f5933c93eb55c1", + "sha256": "ce7f132a6a69c802406f07c4a2119ef921e8978520ff58d5eeaeedb982c257f2" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/peel.py", + "usage": "input", + "git_blob": "2ae1769a9726ab738d3981891d0b76beccac2d99", + "sha256": "3de018e68601566c364c7568b110f60c1bf34941b846cdffb94401bb799f85e3" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/topology.py", + "usage": "input", + "git_blob": "39a2916c207d04be5efc44750d8606f5da0c2990", + "sha256": "384d456ddba76de137a63b50019d5bba2e9f6daa4177c91643e0565d4cf1d44b" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/binding.py", + "usage": "input", + "git_blob": "21a5a21220a18ab62a19ac403a9944bc3a8665c8", + "sha256": "20169a8af6ed2b34069fd353a2bc1c42335ab686c58de8479baef33dd3fb493b" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/bitstream.py", + "usage": "input", + "git_blob": "4d1fd4abb0f2aabe833e5cbc9efb51039739e7ca", + "sha256": "f78bac9641007dbd8824984edcac057274fe016ce78bd9cb512d0c0913274783" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/cardinality.py", + "usage": "input", + "git_blob": "b8ba857e32c5903408e1e61ff916300848b4a208", + "sha256": "505d5e560c5a507e6184edcc19a87cf1fed243eb34a5cb21fbe1e4fe017e7f22" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/check_support.py", + "usage": "input", + "git_blob": "e1f961df9fa3a441fc5b600d1288a8d038eca51e", + "sha256": "d9977e87ddc5acdb836b8e4a4e3942da17a05b04ce67c04547d17b986b518964" + }, + { + "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/inputs/pr2753/predecessor/vendor/controller.py", + "usage": "input", + "git_blob": "c631a9e77fbcccf0e8f448adc22978728aed7b60", + "sha256": "fa09146991f6c04e6f4b6eb9bf0c8e103e70e90a0e402ff3d69814e6aac8ff8c" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/counts.py", + "usage": "input", + "git_blob": "81b48940ce222290a40d4fb349ce827f4788469d", + "sha256": "00b476dbda0e8cc99886bf794439e1cb9e775f435f599a3557e99321fe084069" + }, + { + "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/inputs/pr2753/predecessor/vendor/episode.py", + "usage": "input", + "git_blob": "30d11ff4f333813855d36da3eb5a1ab0e154bafe", + "sha256": "38f79cb2a370548471063952d5f7c74bd795a2a8496fdcf3ce0996d79e3adaff" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/forms.py", + "usage": "input", + "git_blob": "6667c0b772a63f0059c7caffec63e0d919a92398", + "sha256": "1fdf9d31b7eb107c396e33f94dad61c9d3f2c709cae61178268a44ca80dbc0b4" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/low_codes.py", + "usage": "input", + "git_blob": "737edfc4a10f4b7b3b97a7cef4b40864efd806e6", + "sha256": "f657e17f6088c840e3f7783e662257630f6d2c1e71c217721ffbca4d6ac93e87" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/matrices.py", + "usage": "input", + "git_blob": "5d497353efbb9eeaaf4facd96ab40ffb0f3aa20d", + "sha256": "00b687434039b54529ee092e34f9435cfcd66e0816eb3bd2a6688c73f4e01459" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/numeric.py", + "usage": "input", + "git_blob": "6d4ebca8398008375b8f4762d1a9f1514e8c2611", + "sha256": "7327b05c4ec3e0f6d9c352cc7de85bfd4ebe940482553e77c59a773a8c09c514" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/oracle.py", + "usage": "input", + "git_blob": "244f131466698a3ace10b657242fe1f65c07fd1f", + "sha256": "7bd18089e32ce48085b5e3a75159f6a82cdb2649ec682c53db05e399d97aef67" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/packet.py", + "usage": "input", + "git_blob": "ebc9b616514412b80c56d523776e6ba5d6766453", + "sha256": "970e7fe0719e3dfe122b248941e6f21cd90d7dd62089fa6acbd0e5412ce083a5" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/plan.py", + "usage": "input", + "git_blob": "48255d5454308c07635fae4e7eb4873b0bd2a4f8", + "sha256": "d9c8dc93762db4d3a449814aa51e2211460648694469854d89cb48cb04188cf3" + }, + { + "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/pr2753/predecessor/vendor/residual.py", + "usage": "input", + "git_blob": "3d070d2539a529f3b14ecb086a92a3db056229fe", + "sha256": "8fd24747cae498dfb2ba333e7f8a68d7315ae4c2d7530d8ca145aab95ede21df" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/routes.py", + "usage": "input", + "git_blob": "35531201dc349a811dfabc6f1f6e64697d665194", + "sha256": "ed7dc3679451696ab1dd841146b215c9515a3eec5e4ff3763f33c315f1696ada" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/selection.py", + "usage": "input", + "git_blob": "2c28f1aaec104a75c4e6c170b3e6a60300ee6700", + "sha256": "bc8e371fb1fa0b41fb05ef0b34d0f4c317b2396f9833d91f44f95c2b54b4052b" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/sources.py", + "usage": "input", + "git_blob": "16d5e7e6a28018f1e2d76d61efe2d54f6a6941d4", + "sha256": "f102edc7816d742bd89db8097254c19b843d0ef5cf6758ad42e93bcc0b214c62" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/stream.py", + "usage": "input", + "git_blob": "5e5a4bb0f98971447043e25d4dd6991bfc070389", + "sha256": "c7dc7da5b00f27016982ada4c0416f8328568b00df16d97012f33d4b372d79b5" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/stream_runner.py", + "usage": "input", + "git_blob": "efff281d4c4be5c1378e31404fbcc634fe4ade59", + "sha256": "751c5023ca0e477369e448583961ace6a76db2723bb6c26f81203def539f1249" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/trace.py", + "usage": "input", + "git_blob": "bb845a90f5bcf006e683e581e385936208f6a1f4", + "sha256": "c71ba11d793dde2ac6e4cdcf468482872975c34589bf1167f2a460cb8a74e984" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/words.py", + "usage": "input", + "git_blob": "8d4ba37e2778acb35b34e0719df2caf138fbeb50", + "sha256": "5c37f57708ba3131bdcb03139f9dbc29886bee44569c09cbba51b68f75acd7f9" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/verify.py", + "usage": "input", + "git_blob": "121acc1ff15ec85a8011e96eda2eb587608413b9", + "sha256": "cd83797d1f420f7e5de61c1a693110b4ee0c80bac0adae4699599046b7f76f8a" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/recursive_call.py", + "usage": "input", + "git_blob": "6d33224145aa04f7fbaf7b6cda7c9c164311a402", + "sha256": "157deaa5972557893d43494a81151483bdc46373448ec677cb6a738c9b7e6f1e" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/scheduler.py", + "usage": "input", + "git_blob": "60c2b6d065eba91dd5e0edb7a77fc087971eca3f", + "sha256": "0d96f7fbd6f90416167c5a52c0e3de942d1a0cae3d2968831932a9576701699f" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/stream_runner.py", + "usage": "input", + "git_blob": "6ba5df130bb4a0fcb06b6c630830ae3a6922921b", + "sha256": "b255feaf6cc6e40413ae73fe302bf8f290bf4dd89f4128b23a91cc9860601801" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/trace.py", + "usage": "input", + "git_blob": "4b002201ce54cdecec9acf4e874b7f71cd75fe71", + "sha256": "3a664224c558244f606b603cad816d75e94a17c9b2620a06a1530e893dfceac2" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/verify.py", + "usage": "input", + "git_blob": "96be8f5859a3f3799344d46dec1ee68170d96bfa", + "sha256": "65126e788eeea10e830fc583cf4afe0bfc4d67495cbf8ac21de3507dbe624d56" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/checks.py", + "usage": "input", + "git_blob": "46630a7648b1c93530e9253872a19cce338929ff", + "sha256": "98ffbd58881aa138b8dbae4d5722855ece2a5fdf7585e53978069ae9b064eb09" + }, + { + "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/pr2753_recursive_call.py", + "usage": "input", + "git_blob": "6d33224145aa04f7fbaf7b6cda7c9c164311a402", + "sha256": "157deaa5972557893d43494a81151483bdc46373448ec677cb6a738c9b7e6f1e" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/vendor/words.py", + "usage": "input", + "git_blob": "8d4ba37e2778acb35b34e0719df2caf138fbeb50", + "sha256": "5c37f57708ba3131bdcb03139f9dbc29886bee44569c09cbba51b68f75acd7f9" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/verify.py", + "usage": "input", + "git_blob": "6be4f94eda9c96f4e7265a294f63e39309dcb0c6", + "sha256": "37f9e51e6c038a2493b4550e3cf0bd52621b6c20e115f0886406fc9909a82120" + }, + { + "path": "research/selected-bit-physical-caller/loader.py", + "usage": "input", + "git_blob": "4a0326c9af88626938645f288e559b5b97cb1787", + "sha256": "4d8647f520b2967a0ca7dcadeb39d6ebabbce44df4193f609fef22911d0ae67b" + }, + { + "path": "research/selected-bit-physical-caller/macro_binding.py", + "usage": "input", + "git_blob": "c197eb6458be9374cb4684c654bfc99e619dcaf0", + "sha256": "9ef31765d03d2c54fad9296f2ff0707a190ce169e44de4f0f45214e3c410c01a" + }, + { + "path": "research/selected-bit-physical-caller/macro_checks.py", + "usage": "input", + "git_blob": "6a9226a647d095419840fd9d6696ffcef9827b0b", + "sha256": "0631b4d6b547a76d8ea4babd3465908b9efaa058503f8330140bcc8eb22a51cb" + }, + { + "path": "research/selected-bit-physical-caller/macro_code.py", + "usage": "input", + "git_blob": "2f5f8ecfac6457171707b1b5ff02b5071954fcb7", + "sha256": "f626b018124747a5f17c1603bea36cd74c00a69a0647fd7b10e9c4e2964caea8" + }, + { + "path": "research/selected-bit-physical-caller/macro_controls.py", + "usage": "input", + "git_blob": "b7c1d28dd47ff463df02ea97b5907a041c05bdde", + "sha256": "a5343faffadfdd9ea0e52d4c7c4ef24ba5e8d2dee86c8af27c094ad78944b845" + }, + { + "path": "research/selected-bit-physical-caller/macro_local_checks.py", + "usage": "input", + "git_blob": "421f9030f91f3ab309a9873928c09ba8a2ade580", + "sha256": "a9be60378d1282184632066b87cb044a8510b6623acf0df4dbf2f1bcd35cb830" + }, + { + "path": "research/selected-bit-physical-caller/macro_machine.py", + "usage": "input", + "git_blob": "5a032e8923f7f8b22bb98f3e39b804beb9906c16", + "sha256": "7bc6e42072a09a08ac961e05c3da01cde012d740d4b4c605f298d994f2ad7c5a" + }, + { + "path": "research/selected-bit-physical-caller/macro_selected_checks.py", + "usage": "input", + "git_blob": "14f224e975fdd1a580088baf26e23ca44091a2f7", + "sha256": "080e147837a4983a73e598af0cc97333e2cfb1d328f5190c9d4447a8bdbb4668" + }, + { + "path": "research/selected-bit-physical-caller/nested_bank_checks.py", + "usage": "input", + "git_blob": "c48f87429773e3b80719c209b4ad3f3977e3c41e", + "sha256": "4c225e7d91c767b4cedcf9f9b5222875be948bf8b4ef03cedc4f46f1d570e9bb" + }, + { + "path": "research/selected-bit-physical-caller/numerical_frame.py", + "usage": "input", + "git_blob": "dc92611dd5f131718806fa96470b8f3494e15e2a", + "sha256": "3fd62eda5d0b48bf31ea244708a77afdc6d16cf4fc9439d140ef422a38c7406c" + }, + { + "path": "research/selected-bit-physical-caller/residual_blocks.py", + "usage": "input", + "git_blob": "fba75e7649cf77e352a75324495191bbd7853c22", + "sha256": "ab7f3df8906decd2efecfb138eac1456c106bb520b2598761f699f80680d8331" + }, + { + "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/verify.py", + "usage": "input", + "git_blob": "fbdc87b9f98dc7722db45a42a742c5569089eeeb", + "sha256": "bfba14c842ea4d97bf160588abc061553d3e4eab66cd5f32b903e1a67e661aec" + }, + { + "path": "research/selected-compiler-source-bridge/README.md", + "usage": "input", + "git_blob": "06fa567a17fe1d2bef373b63ec1a1b1bc737f0de", + "sha256": "d2d1c89168e2279799ada6a270267bcadc2db03a2b7f82d618ea49f575230ef9" + }, + { + "path": "research/selected-compiler-source-bridge/independent_lifetime.py", + "usage": "input", + "git_blob": "212728570a7f9b7da6c0ceb27330b2a4f87e134d", + "sha256": "d8bcc190a59defbd6e96f6cbd769ffad53214deccb73b5228c9fe3cac4f7c83f" + }, + { + "path": "research/selected-compiler-visitation-audit/README.md", + "usage": "input", + "git_blob": "0e38b7d90af06186c8c55aad1286068cd5eab210", + "sha256": "a205a33577bc60628f82606c47d3ee471e6e107db552e45e5c4e9466b4863f31" + }, + { + "path": "research/selected-wrapper-sharing/README.md", + "usage": "input", + "git_blob": "ce07f93198d9719ecd76da9e05a82e32f83c0d42", + "sha256": "a29e5e791419af964f57e82f3a0c859ddb01b7321827dc88a6400c426e7046bc" + } + ] +} diff --git a/research/selected-itinerary-compression/TASK.json b/research/selected-itinerary-compression/TASK.json new file mode 100644 index 0000000000..79f7ce680a --- /dev/null +++ b/research/selected-itinerary-compression/TASK.json @@ -0,0 +1,88 @@ +{ + "schema_version": 1, + "task_id": "selected-stock-envelope", + "priority_revision": 7, + "base_commit": "624de9dc66858af0945e5f8a0942488d62280d43", + "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": "changed", + "actual_scope": "Source-authenticated compact residual block itinerary preserving original Residual identity and unchanged physical Machine indexed PC and recursive-return semantics.", + "scope_change_reason": "PR4758 explicitly leaves peak operations retention and suspended continuation fetch open; the stock coefficient and four-provider admission obligations have newer coverage and are not repeated.", + "bottleneck_link": "Reduces a real finite compiler representation obligation without asserting a stock coefficient, selected GL64 expansion or new kappa.", + "budget_minutes": 60, + "stop_rule": "Stop with a scoped obstruction if indexed fetch, original identity, immutability or the actual recursive fixture cannot be validated within the session.", + "outcome": "completed", + "evidence": "README.md, itinerary.py, verify.py, RESULT.json and optional host-specific MEASUREMENTS.json; canonical claim discussioncomment-19131513.", + "author": "JoyboyBrian", + "ai_assistance": "Prepared by JoyboyBrian with substantial OpenAI Codex assistance; parallel source and code review, no independent human or formal acceptance claimed.", + "open_questions": [ + { + "question": "Can enforced immutable ownership remove the complete plan snapshot at every block fetch?", + "why_it_matters": "Current validation is O(plan structural size) and may dominate fetch cost.", + "first_step": "Specify and enforce all mutation/extension observers before weakening the guard.", + "blocked_by": "No enforced ownership contract for arbitrary Python extensions." + }, + { + "question": "Can a regional emitter avoid original per-block enumeration?", + "why_it_matters": "This sink lowers retention but continues all original emission work.", + "first_step": "Prove factory/observer-equivalent skipping against the pointwise PC refinement.", + "blocked_by": "Exact source observer preservation and selected binding admission remain open." + } + ] +} diff --git a/research/selected-itinerary-compression/VERIFY.json b/research/selected-itinerary-compression/VERIFY.json new file mode 100644 index 0000000000..6c890cce79 --- /dev/null +++ b/research/selected-itinerary-compression/VERIFY.json @@ -0,0 +1,123 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "LICENSE", + "NOTICE", + "research/residual-call-refinement/README.md", + "research/selected-bit-physical-caller/PROOF.md", + "research/selected-bit-physical-caller/README.md", + "research/selected-bit-physical-caller/continuation_checks.py", + "research/selected-bit-physical-caller/frame_checks.py", + "research/selected-bit-physical-caller/inputs/pr2753/bootstrap.py", + "research/selected-bit-physical-caller/inputs/pr2753/check_layout.py", + "research/selected-bit-physical-caller/inputs/pr2753/check_nested_model.py", + "research/selected-bit-physical-caller/inputs/pr2753/check_recursion.py", + "research/selected-bit-physical-caller/inputs/pr2753/check_runtime.py", + "research/selected-bit-physical-caller/inputs/pr2753/check_sign.py", + "research/selected-bit-physical-caller/inputs/pr2753/check_sources.py", + "research/selected-bit-physical-caller/inputs/pr2753/consumer.py", + "research/selected-bit-physical-caller/inputs/pr2753/control_checks.py", + "research/selected-bit-physical-caller/inputs/pr2753/driver.py", + "research/selected-bit-physical-caller/inputs/pr2753/layout.py", + "research/selected-bit-physical-caller/inputs/pr2753/linear_sign.py", + "research/selected-bit-physical-caller/inputs/pr2753/node.py", + "research/selected-bit-physical-caller/inputs/pr2753/packet_engine.py", + "research/selected-bit-physical-caller/inputs/pr2753/peel.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/cardinal_counts.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/catalogue.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/check_headers.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/check_layout.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/check_runtime.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/check_sources.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/consumer.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/control.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/control_checks.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/driver.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/fresh_rows.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/layout.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/model.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/node.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/packet_engine.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/peel.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/topology.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/binding.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/bitstream.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/cardinality.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/check_support.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/children.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/controller.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/counts.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/directory.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/episode.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/forms.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/low_codes.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/matrices.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/numeric.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/oracle.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/packet.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/plan.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/records.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/residual.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/routes.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/selection.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/sources.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/stream.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/stream_runner.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/trace.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/words.py", + "research/selected-bit-physical-caller/inputs/pr2753/predecessor/verify.py", + "research/selected-bit-physical-caller/inputs/pr2753/recursive_call.py", + "research/selected-bit-physical-caller/inputs/pr2753/scheduler.py", + "research/selected-bit-physical-caller/inputs/pr2753/stream_runner.py", + "research/selected-bit-physical-caller/inputs/pr2753/trace.py", + "research/selected-bit-physical-caller/inputs/pr2753/verify.py", + "research/selected-bit-physical-caller/inputs/pr2769/checks.py", + "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/pr2753_recursive_call.py", + "research/selected-bit-physical-caller/inputs/pr2769/vendor/words.py", + "research/selected-bit-physical-caller/inputs/pr2769/verify.py", + "research/selected-bit-physical-caller/loader.py", + "research/selected-bit-physical-caller/macro_binding.py", + "research/selected-bit-physical-caller/macro_checks.py", + "research/selected-bit-physical-caller/macro_code.py", + "research/selected-bit-physical-caller/macro_controls.py", + "research/selected-bit-physical-caller/macro_local_checks.py", + "research/selected-bit-physical-caller/macro_machine.py", + "research/selected-bit-physical-caller/macro_selected_checks.py", + "research/selected-bit-physical-caller/nested_bank_checks.py", + "research/selected-bit-physical-caller/numerical_frame.py", + "research/selected-bit-physical-caller/residual_blocks.py", + "research/selected-bit-physical-caller/role_parking.py", + "research/selected-bit-physical-caller/scratch_pool.py", + "research/selected-bit-physical-caller/verify.py", + "research/selected-compiler-source-bridge/README.md", + "research/selected-compiler-source-bridge/independent_lifetime.py", + "research/selected-compiler-visitation-audit/README.md", + "research/selected-wrapper-sharing/README.md" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Source identity, independent Cursor and exact source word, real recursive before/after and destructive controls" + }, + { + "argv": [ + "{python}", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Same explicit invariants with assertions disabled" + } + ] +} diff --git a/research/selected-itinerary-compression/itinerary.py b/research/selected-itinerary-compression/itinerary.py new file mode 100644 index 0000000000..2ab3f704b3 --- /dev/null +++ b/research/selected-itinerary-compression/itinerary.py @@ -0,0 +1,180 @@ +"""Source-bound streaming sink: retain residual identities and original PCs.""" +from bisect import bisect_right +from dataclasses import dataclass, fields, is_dataclass +from hashlib import sha256 +from operator import index +import sys + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def frozen(value): + """Typed structural snapshot; mutable nested fields are inadmissible.""" + if type(value) in (int, bool, str, type(None)): + return type(value).__name__, value + if type(value) is tuple: + return ('tuple', tuple(frozen(x) for x in value)) + if is_dataclass(value) and value.__dataclass_params__.frozen: + return (type(value).__module__, type(value).__qualname__, + tuple((f.name, frozen(getattr(value, f.name))) for f in fields(value))) + raise ValueError('mutable plan field') + + +@dataclass(frozen=True) +class PlanIndex: + plan: object + snapshot: tuple + ends: tuple + count: int + + @classmethod + def build(cls, plan): + snapshot = frozen(plan) + ends = [] + if not plan.good: + for command in plan.commands: + need(command.kind in ('add', 'sign', 'child'), 'unsupported command') + ends.append((ends[-1] if ends else 0) + (3 if command.kind == 'child' else 1)) + return cls(plan, snapshot, tuple(ends), 3 if plan.good else (ends[-1] if ends else 0)) + + def validate(self): + need(frozen(self.plan) == self.snapshot, 'plan mutation') + + def at(self, offset): + need(0 <= offset < self.count, 'block offset') + if self.plan.good: + return ('forward', 'good', 'backward')[offset], offset, 0 + position = bisect_right(self.ends, offset) + start = self.ends[position - 1] if position else 0 + command = self.plan.commands[position] + return ('pair', position, offset - start) if command.kind == 'child' else ('sweep', position, 0) + + +@dataclass(frozen=True) +class BlockRun: + definition: object + plan: PlanIndex + axis: object + + @property + def count(self): + return 1 if self.axis is not None else self.plan.count + + def at(self, offset, validate=True): + if validate: + need(self.definition.plan is self.plan.plan and frozen(self.definition.axis) == frozen(self.axis), + 'definition mutation') + self.plan.validate() + block = ('axis', self.axis, 0) if self.axis is not None else self.plan.at(offset) + return 'block', self.definition, block + + +@dataclass(frozen=True) +class Word: + entries: tuple + ends: tuple + + def __len__(self): + return self.ends[-1] if self.ends else 0 + + def __getitem__(self, key): + # Tuple-compatible integer indexing. Slices deliberately materialize. + if isinstance(key, slice): + return tuple(self[i] for i in range(*key.indices(len(self)))) + offset = index(key) + if offset < 0: + offset += len(self) + if not 0 <= offset < len(self): + raise IndexError('instruction index out of range') + region = bisect_right(self.ends, offset) + entry = self.entries[region] + if isinstance(entry, BlockRun): + start = self.ends[region - 1] if region else 0 + return entry.at(offset - start) + return entry + + def census(self): + runs = [e for e in self.entries if isinstance(e, BlockRun)] + return dict(instructions=len(self), retained_records=len(self.entries), + block_instructions=sum(r.count for r in runs), block_runs=len(runs), + plan_indexes=len({id(r.plan) for r in runs}), + plan_prefix_entries=sum(len(p.ends) for p in {id(r.plan): r.plan for r in runs}.values())) + + +class Sink: + """Validate each source append before discarding only its block tuple.""" + def __init__(self, initial, observer=None): + self.entries, self.ends, self.plans = [], [], {} + self.active = None + self.observer = observer + for operation in initial: + self.append(operation) + + def retain(self, entry, count=1): + self.entries.append(entry) + self.ends.append((self.ends[-1] if self.ends else 0) + count) + need(self.ends[-1] <= sys.maxsize, 'finite Python PC bound') + + def append(self, operation): + if self.observer is not None: + self.observer(operation) + kind = operation[0] + if kind == 'residual_begin': + need(self.active is None, 'nested residual') + _, role, definition = operation + plan = self.plans.get(id(definition.plan)) + if plan is None: + plan = PlanIndex.build(definition.plan) + self.plans[id(definition.plan)] = plan + plan.validate() + run = BlockRun(definition, plan, definition.axis) + self.active = role, run, 0 + self.retain(operation) + elif kind == 'block': + need(self.active is not None, 'block outside residual') + role, run, offset = self.active + need(offset < run.count, 'extra block') + need(operation[1] is run.definition and operation[2] == run.at(offset, False)[2], + 'source block mismatch') + if offset == 0: + self.retain(run, run.count) + self.active = role, run, offset + 1 + elif kind == 'residual_end': + need(self.active is not None, 'end outside residual') + role, run, offset = self.active + need(operation[1] == role and operation[2] is run.definition, 'end identity') + need(offset == run.count, 'missing block') + run.plan.validate() + self.active = None + self.retain(operation) + else: + need(self.active is None, 'operation inside residual') + self.retain(operation) + + def finish(self): + need(self.active is None, 'unterminated residual') + return Word(tuple(self.entries), tuple(self.ends)) + + +def compiler(module, source, digest, observer=None): + """Compile checked bytes in a PRIVATE namespace; never patch source globals.""" + need(sha256(source).hexdigest() == digest, 'emitter source hash') + text = source.decode() + old = ('operations = [("node",)]', 'Code(tuple(operations), staged)') + new = ('operations = _itinerary_sink([("node",)])', 'Code(operations.finish(), staged)') + for before, after in zip(old, new): + need(text.count(before) == 1, 'unsupported emitter shape') + text = text.replace(before, after) + namespace = dict(module.__dict__) + # Execute only the compile_node definition. Its authenticated body and all + # original namespace objects are unchanged except the two sink boundaries. + import ast + tree = ast.parse(text) + functions = [n for n in tree.body if isinstance(n, ast.FunctionDef) and n.name == 'compile_node'] + need(len(functions) == 1, 'unsupported emitter function') + namespace['_itinerary_sink'] = lambda initial: Sink(initial, observer) + exec(compile(ast.Module(body=functions, type_ignores=[]), '', 'exec'), namespace) + return namespace['compile_node'] diff --git a/research/selected-itinerary-compression/verify.py b/research/selected-itinerary-compression/verify.py new file mode 100644 index 0000000000..8fd8a3b4a6 --- /dev/null +++ b/research/selected-itinerary-compression/verify.py @@ -0,0 +1,262 @@ +"""Independent source Cursor, full emitted word, and physical recursive replay.""" +import argparse +from contextlib import contextmanager +from dataclasses import replace +from hashlib import sha256 +import importlib +import importlib.util +import json +from pathlib import Path +import sys +import time +from unittest.mock import patch + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +PHYSICAL = 'research/selected-bit-physical-caller' +sys.path.insert(0, str(HERE)) +from itinerary import need, frozen, compiler, Sink, PlanIndex + +def authenticate(): + rows = json.loads((HERE/'SOURCES.json').read_text())['files'] + pins = {r['path']: r['sha256'] for r in rows if r['usage']=='input'} + for name, digest in pins.items(): + need(sha256((ROOT/name).read_bytes()).hexdigest()==digest, 'source hash mismatch: '+name) + return pins + + +@contextmanager +def original_modules(pins): + # Reuse the predecessor's same-byte hash/compile importer; loader admission + # is intentionally outside this reduced-source runtime experiment. + path = ROOT/'research/selected-compiler-source-bridge/independent_lifetime.py' + spec=importlib.util.spec_from_file_location('sharing_source_importer',path) + prior=importlib.util.module_from_spec(spec);sys.modules[spec.name]=prior;spec.loader.exec_module(prior) + records={} + with prior.SourceFinder(ROOT,records,{p:h for p,h in pins.items() if p.startswith(PHYSICAL+'/') and p.endswith('.py')}) as finder: + loader=importlib.import_module('loader') + importlib.import_module('sources').ROOT=ROOT + codec_spec=finder.spec('bank_codec',ROOT/PHYSICAL/'inputs/pr2769/codec.py') + codec=importlib.util.module_from_spec(codec_spec);sys.modules['bank_codec']=codec;codec_spec.loader.exec_module(codec) + loader._active=True + yield records + + + +def rejected(function, message): + try: function() + except ValueError as error: + need(message in str(error), 'wrong rejection: '+str(error)) + return + raise ValueError('control accepted: '+message) + + +def controls(source, digest): + import macro_code + from macro_code import Residual + from plan import Plan, Command, Reference + from residual_blocks import Cursor + from itertools import product + # Enumerate independently using the original Cursor, not our rank formula. + cases = blocks = 0 + for width in range(5): + for kinds in product(('add','sign','child'), repeat=width): + plan=Plan(2,1,False,tuple(Command(k,0,1,Reference('unit')) for k in kinds)) + cursor=Cursor(plan); expected=[] + while not cursor.done: expected.append(cursor.take()) + indexed=PlanIndex.build(plan) + need([indexed.at(i) for i in range(indexed.count)]==expected, 'independent Cursor enumeration') + cases+=1; blocks+=len(expected) + plan=Plan(2,1,True,()); cursor=Cursor(plan) + need([PlanIndex.build(plan).at(i) for i in range(3)]==[cursor.take() for _ in range(3)],'good Cursor') + definition=Residual(0,plan,0,True,((1,0),(0,1))) + def sink(): + result=Sink([('node',)]);result.append(('residual_begin','idle',definition));return result + bad=sink();rejected(lambda:bad.append(('block',replace(definition),('forward',0,0))),'source block mismatch') + bad=sink();rejected(lambda:bad.append(('block',definition,('good',1,0))),'source block mismatch') + bad=sink();rejected(lambda:bad.append(('residual_end','idle',definition)),'missing block') + bad=sink();rejected(lambda:bad.append(('residual_end','other',definition)),'end identity') + bad=sink();rejected(lambda:bad.append(('return',)),'operation inside residual') + rejected(lambda:sink().finish(),'unterminated residual') + rejected(lambda:PlanIndex.build(replace(plan,commands=[])),'mutable plan field') + good=sink() + for i in range(3):good.append(('block',definition,PlanIndex.build(plan).at(i))) + good.append(('residual_end','idle',definition));word=good.finish() + object.__setattr__(plan,'rank',0) + rejected(lambda:word[2],'plan mutation') + object.__setattr__(plan,'rank',1) + changed=source.replace(b'operations = [("node",)]',b'operations = list((("node",),))') + rejected(lambda:compiler(macro_code,changed,digest),'emitter source hash') + rejected(lambda:compiler(macro_code,changed,sha256(changed).hexdigest()),'unsupported emitter shape') + for key in (-len(word)-1,len(word)): + try: word[key] + except IndexError: pass + else: raise ValueError('out-of-range accepted') + try: word[1.2] + except TypeError: pass + else: raise ValueError('non-index accepted') + need(word[-1]==word[len(word)-1] and word[::-1]==tuple(word)[::-1] and word[True]==word[1], 'tuple index behavior') + return dict(cursor_cases=cases+1,cursor_blocks=blocks+3,rejecting_controls=10,index_boundary_controls=4) + + +@contextmanager +def fixture(single=False, replicas=1): + import check_nested_model as model + from macro_binding import ToyBinding + from cardinal_counts import Count + from directory import Context + from words import Arena, Ring + catalogue=model.Catalogue() + if single: + class SingleCodes(model.ToyCodes): + def __init__(self): + super().__init__();self.size,self.limit,self.bits=2,8,3 + catalogue.codes=SingleCodes() + catalogue.low_classes=lambda: (catalogue.codes.unrank(i) for i in range(2)) + class Topology(model.Topology): + def call(self,stage,replica): + base=super().call(stage,0) + return replace(base,owners=tuple(replace(owner,family=replica) for owner in base.owners)) + topology=Topology(catalogue);topology.families=topology.replicas=replicas + arena,indices=Arena(3),Arena(8) + modulus=arena.input(2);ring=Ring(modulus);context=Context(ring,catalogue.codes) + plans=model.compile_coefficients(catalogue,context,indices,model.UnitIncoming(context)) + class Binding(ToyBinding): + def check_stock(self,runtime): + expected=Count.literal((2 if runtime.root else 1) if single else (6 if runtime.root else 1)) + try:need(expected.equals(runtime.count('unused')),'fixture independent fresh stock') + finally:expected.close() + binding=Binding(catalogue,plans) + context.close();ring.close() + try:yield topology,binding,arena,indices,modulus + finally: + arena.free(modulus) + need(not arena.live and not indices.live,'closed fixture banks') + + +def full_word(source,digest): + import macro_code + receipts=[] + with fixture(replicas=2) as (topology,binding,*_): + for mode in (0,1): + emitted=[] + compact=compiler(macro_code,source,digest,emitted.append)(topology,binding,mode) + need(len(compact.operations)==len(emitted),'same complete PC domain') + # This tee captures the ORIGINAL emitted tuples with identical wrappers. + for pc,old in enumerate(emitted): + got=compact.operations[pc] + need(got==old,'full word equality') + if old[0]=='block':need(got[1] is old[1],'original block identity') + if old[0] in ('residual_begin','residual_end'):need(got[2] is old[2],'original boundary identity') + # A separate unmodified emitter call checks values/order and source globals. + before=macro_code.compile_node(topology,binding,mode) + # Residual constants are immutable mapping proxies, outside frozen(plan). + def semantic(operation): + result=[] + for x in operation: + if hasattr(x,'plan'): + result.append((x.code,frozen(x.plan),x.identifier,x.common,x.low,x.axis,tuple(sorted((repr(k),v) for k,v in x.constants.items())))) + else:result.append(x) + return tuple(result) + need([semantic(x) for x in before.operations]==[semantic(x) for x in compact.operations],'independent whole original emitter') + receipts.append(compact.operations.census()) + return receipts + + +def recursive(compact,source,digest): + import macro_code + from macro_machine import Machine + from cardinal_counts import Count + from records import Tape + from words import Arena, BLANK + from check_runtime import destination + from check_support import no_decode + import scheduler + def body(tape):return bytes(tape.cells[1:]).rstrip(bytes([BLANK])) + with fixture(single=True) as (topology,binding,arena,indices,modulus): + emit=compiler(macro_code,source,digest) if compact else macro_code.compile_node + programs=tuple(emit(topology,binding,mode) for mode in (0,1)) + size,depth=indices.input(4),indices.input(0) + source_tape,directory,program=Tape(),Tape(),Tape() + for i in range(1024):source_tape.append(((i*13)^(i>>3)^(i>>7)^0x53)&1) + source_tape.rewind();original=body(source_tape) + counts=[Count.literal(v) for v in (1,4,1,1,1)] + count_inputs=[(body(c.tape),c.tape.head) for c in counts] + runtime=Machine(binding,topology,programs,Arena(3,512),Arena(8,512)) + saved=[];returns=[];pending=[] + call=Machine.call;complete=Machine.complete_return + def traced_call(self,grants): + continuation=(self.mode,self.pc+1) + pending.append(continuation);saved.append(continuation) + return call(self,grants) + corruptions=[] + def continuation(self,expected): + need((self.mode,self.pc)==expected,'actual physical restored PC') + def traced_return(self): + root=self.root;answer=complete(self) + if not root: + actual=(self.mode,self.pc);expected=pending.pop() + continuation(self,expected) + if compact and not corruptions: + self.pc-=1 + rejected(lambda:continuation(self,expected),'actual physical restored PC') + corruptions.append((self.mode,self.pc));self.pc+=1 + returns.append(actual) + return answer + def forbidden(*args,**kwargs):raise ValueError('logical Invocation forbidden') + with no_decode(),patch.object(scheduler.Invocation,'__init__',forbidden),patch.object(Machine,'call',traced_call),patch.object(Machine,'complete_return',traced_return): + output=runtime.run(source_tape,directory,program,modulus,size,depth,*counts,mode=1) + actual=body(output);expected=bytearray(1024) + for row in range(4): + for address in range(256):expected[row*256+destination(address,4,2,(1,1,1,1))]=original[row*256+address] + need(actual==expected,'independent complete recursive endpoint') + need(saved and len(saved)==len(returns) and all(pc>0 for _,pc in returns) and not pending,'nonzero continuations') + need(body(source_tape)==original and not body(directory) and not body(program),'borrowed root streams') + need(all(t.head==1 for t in (source_tape,directory,program,output)),'borrowed root heads') + need([(body(c.tape),c.tape.head) for c in counts]==count_inputs,'borrowed Count values and heads') + need(runtime.closed and not runtime.arena.live and not runtime.indices.live and runtime.geometry_state is None,'closed numerical and geometry state') + need(runtime.numerical.machine.tapes==[{},{}] and all(all(x==BLANK for x in t.cells) for t in (*runtime.roles.values(),*runtime.handoff.values(),*runtime.pool.tapes)),'complete physical erasure') + result=dict(payload_sha256=sha256(actual).hexdigest(),instructions=[len(p.operations) for p in programs],counts=runtime.counts,saved=saved,restored=returns,parking=runtime.numerical.machine.counts,codec=runtime.numerical.codec_counts) + for t in (source_tape,directory,program,output):t.clear() + for c in counts:c.close() + indices.free_many(size,depth) + return result + + +def measurement(source,digest): + import gc,time,tracemalloc,platform + import macro_code + records=[] + with fixture(replicas=64) as (topology,binding,*_): + compact=compiler(macro_code,source,digest) + for name,emit in (('original',macro_code.compile_node),('compact',compact)): + gc.collect();tracemalloc.start();start=time.perf_counter() + code=emit(topology,binding,0) + elapsed=time.perf_counter()-start;current,peak=tracemalloc.get_traced_memory();tracemalloc.stop() + records.append(dict(kind=name,seconds=elapsed,retained_bytes=current,peak_bytes=peak,instructions=len(code.operations),records=(len(code.operations) if name=='original' else code.operations.census()))) + del code + return dict(python=sys.version,platform=platform.platform(),replicas=64,measurement='tracemalloc includes compile only, after coefficient plans and adapter construction',records=records) + + +def run(measure=False): + pins=authenticate();source=(ROOT/PHYSICAL/'macro_code.py').read_bytes();digest=pins[PHYSICAL+'/macro_code.py'] + with original_modules(pins) as imports: + result=dict(controls=controls(source,digest),full_word=full_word(source,digest)) + start=time.perf_counter();before=recursive(False,source,digest);original_seconds=time.perf_counter()-start + start=time.perf_counter();after=recursive(True,source,digest);compact_seconds=time.perf_counter()-start + need(before==after,'complete recursive before/after equality') + result['recursive']=after;result['imported_sources']=len(imports) + if measure: + metrics=measurement(source,digest);metrics['recursive_seconds']={'original':original_seconds,'compact':compact_seconds} + (HERE/'MEASUREMENTS.json').write_text(json.dumps(metrics,indent=2)+'\n') + authenticate();return result + + +def main(): + parser=argparse.ArgumentParser();parser.add_argument('--write',action='store_true');parser.add_argument('--measure',action='store_true');args=parser.parse_args() + result=run(args.measure) + if args.write:(HERE/'RESULT.json').write_text(json.dumps(result,sort_keys=True,indent=2)+'\n') + else:need(json.dumps(result,sort_keys=True)==json.dumps(json.loads((HERE/'RESULT.json').read_text()),sort_keys=True),'deterministic receipt') + print(json.dumps(result,sort_keys=True,indent=2)) + +if __name__=='__main__':main()