From a977fd1989c092d6946766fe0e66625935799058 Mon Sep 17 00:00:00 2001 From: Sagar Thakrar Date: Sat, 17 Oct 2026 02:24:15 +0530 Subject: [PATCH] Independently verify PR3015's R1 restore edit on PR2979's words (no kappa; no defect found) research/t74-3015-restore-edit-audit: standard-library audit of open PR #3015 (Jeremy Kothe, head e244296d) with code that imports or executes nothing of PR #3015, #2979, #3018 or #3021 (their files are pinned git data; this contributor's earlier checkers are vendored as byte-pinned copies). Checked: the declared hunk restore[178:180) -> 3 gates (own diff), the net operator, both edited words exact forward and dual through cleanup and the target endpoint (632 inputs), the frame recount in two implementations with the paid delta -2H1+H2 attributed to register 63's climbs 7->8->9 merging into 7->9, the literal cleanup, PR2979's allocation priced in two implementations under the new local profiles (271,728 roles; complete profile, physical stock 66813), the endpoint C = 0.001729150973534224428695 and kappa = C-1e-46-1e-70 with own and vendored enclosures, the exact gain over PR2979, a census of R1's rewrite class (122 rewrites recounted on the parent words: only the R1 pair improves; 108 on the edited words: none), PR3018's journal (profile and endpoint reproduced) and the PR3015+PR3018 composition (equal to PR3021's finite records). 117 negative controls rejected by their named rules (85 distinct), 8 positive controls, 7 vendor-pin controls, 23/23 checker mutations killed. Co-Authored-By: Claude Fable 5.1 --- .../t74-3015-restore-edit-audit/README.md | 255 + .../t74-3015-restore-edit-audit/RESULT.json | 8108 +++++++++++++++++ .../t74-3015-restore-edit-audit/SOURCES.json | 323 + .../t74-3015-restore-edit-audit/TASK.json | 91 + .../t74-3015-restore-edit-audit/VERIFY.json | 20 + .../audit_controls.py | 386 + .../t74-3015-restore-edit-audit/audit_edit.py | 405 + .../t74-3015-restore-edit-audit/audit_fill.py | 202 + .../audit_kappa.py | 202 + .../audit_words.py | 128 + .../vendor/NOTICE.md | 41 + .../vendor/pr2315/words_check.py | 1294 +++ .../vendor/pr2387/fill_check80.py | 1285 +++ .../vendor/pr2804/NOTICE.md | 33 + .../vendor/pr2804/audit_common.py | 216 + .../vendor/pr2804/check_accounting.py | 638 ++ .../vendor/pr2804/check_fill.py | 920 ++ .../vendor/pr2804/check_words.py | 1017 +++ .../vendor/pr2865/NOTICE-2865-vendor.md | 47 + .../vendor/pr2865/audit_lib.py | 396 + .../t74-3015-restore-edit-audit/verify.py | 674 ++ 21 files changed, 16681 insertions(+) create mode 100644 research/t74-3015-restore-edit-audit/README.md create mode 100644 research/t74-3015-restore-edit-audit/RESULT.json create mode 100644 research/t74-3015-restore-edit-audit/SOURCES.json create mode 100644 research/t74-3015-restore-edit-audit/TASK.json create mode 100644 research/t74-3015-restore-edit-audit/VERIFY.json create mode 100644 research/t74-3015-restore-edit-audit/audit_controls.py create mode 100644 research/t74-3015-restore-edit-audit/audit_edit.py create mode 100644 research/t74-3015-restore-edit-audit/audit_fill.py create mode 100644 research/t74-3015-restore-edit-audit/audit_kappa.py create mode 100644 research/t74-3015-restore-edit-audit/audit_words.py create mode 100644 research/t74-3015-restore-edit-audit/vendor/NOTICE.md create mode 100644 research/t74-3015-restore-edit-audit/vendor/pr2315/words_check.py create mode 100644 research/t74-3015-restore-edit-audit/vendor/pr2387/fill_check80.py create mode 100644 research/t74-3015-restore-edit-audit/vendor/pr2804/NOTICE.md create mode 100644 research/t74-3015-restore-edit-audit/vendor/pr2804/audit_common.py create mode 100644 research/t74-3015-restore-edit-audit/vendor/pr2804/check_accounting.py create mode 100644 research/t74-3015-restore-edit-audit/vendor/pr2804/check_fill.py create mode 100644 research/t74-3015-restore-edit-audit/vendor/pr2804/check_words.py create mode 100644 research/t74-3015-restore-edit-audit/vendor/pr2865/NOTICE-2865-vendor.md create mode 100644 research/t74-3015-restore-edit-audit/vendor/pr2865/audit_lib.py create mode 100644 research/t74-3015-restore-edit-audit/verify.py diff --git a/research/t74-3015-restore-edit-audit/README.md b/research/t74-3015-restore-edit-audit/README.md new file mode 100644 index 0000000000..412e927306 --- /dev/null +++ b/research/t74-3015-restore-edit-audit/README.md @@ -0,0 +1,255 @@ +# Independent verification of PR #3015: the R1 restore edit on PR #2979's words (no κ; no defect found) + +**Object.** Open [PR #3015](https://github.com/CrocSwap/integer-mult-bounds/pull/3015) (Jeremy Kothe, jeremykothe2; +head `e244296debb45fe6f4da84d29e4d64fbab55fda0`, package `research/rank7-joint-endframes-restore-edit`), which takes +[PR #2979](https://github.com/CrocSwap/integer-mult-bounds/pull/2979)'s words (Marius-Paul Dumitrean, mdumitrean; +head `be191346391661f4d35fc0d1508d0a6029572576`, merged, package `research/rank7-joint-endframes`) and PR #2979's +literal T74 allocation, and changes exactly one thing: the restore block `restore[178:180)` of both provider words. + +```text +Status / UTC update / priority revision: DONE (audit) · 2026-10-16 19:35 UTC · priority revision 6 · base main d8e0f83f +Concrete question and changed premise: is PR #3015's single declared restore edit R1 exact, legal in the inherited + frame model, and correctly priced through the complete T74 invoice to its claimed conditional κ? (No premise + of the construction is changed; this is an independent check with code that does not run either PR.) +Established result and evidence status: no defect found in the checked scope (independently checked, AI-assisted; + no human review). Both edited words are exact forward and dual through cleanup and the target endpoint over all + 632 independent inputs; the paid delta −2H1+H2 per call is exactly register 63's two rank-1 climbs merging into + one rank-2 climb; the unchanged allocation gives the claimed complete profile, physical stock 66,813 and + C = 0.001729150973534224428695 (κ = C − 1e-46 − 1e-70, +1.1699e-7 over PR #2979, both exact). Up to the choice + of carrier, R1 is the only improving rewrite of its class (adjacent same-target restore pairs, every legal third + frame) on PR #2979's words, and none remains in that class on the edited words. PR #3018's journal and PR #3021's + composition (R1 + journal) reproduce from the same inputs. +Public artifact URL + exact commit: this package (see the PR); RESULT.json is the recomputed receipt. +Next useful task, success/stop test and rough runtime: a frame re-solve of the edited words (Open next questions); + this package's replay takes about 3.5 minutes (`verify.py --fetch`). +Active claim / expiry, or released: released (no advance claim; bounded session). +``` + +## What this adds + +PR #2979's coordinated rank-7 lowering already had six independent audits when this session started (#2993 frame +paths and V45 subsets; #2987 and #3010 chronological packing; #3006 and #3008 V45 native endpoint and events; #3014 +frozen-owner invoice), one improving journal (#3018, an integrality exchange on the fill) and two live construction +claims. PR #3015, the newest conditional candidate on the same words, had no independent replay, frame recount or +endpoint check: its only new ingredient is R1; its own review (`edits/edits_review.py`) applies the author's pure +applier and runs the inherited #2833 auditor; PR #3021's finite checker (petalas) verifies R1's address and +preimage, its 3×3 rational scalar identity, the changed sections and the re-derived inverse cleanup of both edited +words, but takes the paid profile and its delta from the word report. This package checks R1 with code that imports +or executes nothing of PR #3015, PR #2979, PR #3018 or PR #3021: + +- **Scope A, the edit itself.** The candidate words equal PR #2979's words outside `restore`, `report` and + `cleanup`, and the restore sections differ by exactly the declared hunk (own diff, not the author's applier). The + three new gates equal the two old ones as a formal operator on registers 22, 61, 63. A fresh monotone frame-chain + implementation (second implementation next to this contributor's vendored recount) reproduces both paid profiles + and attributes the whole delta to **register 63**: its climbs `7→8` (at the old gate 179) and `8→9` (at the end) + become one climb `7→9` (at the new gate 180). Registers 22 and 61 keep their climb dimensions (61's `7→8` and + `8→9` only move to the new gates 179 and 180); the five other registers whose labels move are the restore gates + after the hunk, shifted by one index. +- **Scope A, a census of R1's class.** Every adjacent pair of restore gates `t += q1·s1; t += q2·s2` at one frame + F, rewritten either way round as `s += (q'/q)·s'; t += q·s; s −= (q'/q)·s'` with the first gate at the span of the + two current frames (the cheapest legal choice), the second at F and the third at **every** subspace between F and + the intersection of the two registers' next frames; every rewritten word is recounted (cleanup re-derived), + nothing is asserted. On PR #2979's words: 47 such pairs, 94 pair/carrier candidates, 122 rewrites recounted; + **exactly two candidates have an improving option, and they are the R1 pair in its two carrier orders** (both + −2H1+H2); 12 candidates have only losing options (+2H1−H2, or +4H1−2H2 at an intermediate third frame: the carrier's next + frame is above the absorbed register's, so a single rank-2 climb splits) and the rest are neutral. On the edited words: 44 pairs, + 88 candidates, 108 rewrites recounted, none improves. This is one class, not the author's search over all + 2–4-gate blocks (Scope limits); the second rewrite petalas reported at 19:40 UTC (a covector shared by two + non-adjacent consumers, below) is outside it. +- **Scope B, the words.** Both edited words through this contributor's lineage checks: parse with the 36 initial + corrections, warp algebra of the 72 records, frame recount against the word report and the declared profile and + inventory, forward and dual free-operator replays through the 5,208-item cleanup to the target endpoint (632 + independent inputs), the own exact tracker, the literal cleanup against an own inverse-reverse re-derivation (one + item more than PR #2979's, at FULL), and the 91 private buffers as exactly the `helper_final` endpoints. +- **Scope C, the invoice.** PR #2979's allocation (FILL, ORDER, DISPATCH byte-identical in PR #3015; the FILL's + SHA-256 is bound in both CLAIM files) priced with the recounted local profiles of the edited words in two + implementations (271,728 roles, rules R-a..R-e, the R-c recount): complete profile + `{1:1644348, 2:470862, 3:159468, 4:71928, 5:13716, 8:5328, 48:28190}` = PROFILE.json = CLAIM.json, rank mass + 4,816,512, complete delta 666 × (−2H1+H2) against PR #2979, idle remainders unchanged, physical stock + 66,304 + 408 + 8 + 91 + 2 = 66,813. +- **Scope D, the endpoint.** C = 0.001729150973534224428695 accepted (M(C) − 1 ≈ −5.9e-25) and C + 1e-24 rejected + (+2.3e-24) by an own rational-interval enclosure (ln by dyadic splitting and the atanh series, exp by Taylor with + tail bound, outward rounding at 1e-60; any rank) and by the vendored 640-bit enclosure of PR #2804 (width 3e-191); + κ = C − 1e-46 − 1e-70 equals the CLAIM; the gain over PR #2979, `58495443855455489/(5·10^23)` ≈ 1.1699e-7, is + exact; PR #2979's profile is rejected at C; the 24-digit endpoint predicted from the profile alone equals C. +- **Scope E, PR #3018 and the PR #3021 composition.** PR #3018's 103-row journal (44 role moves, 59 offset-only + compactions) applied to PR #2979's fill gives exactly PR #3018's RESULT profile + `{1:1645684, 2:470196, 3:159472, 4:71928, 5:13710, 8:5328, 14:1, 48:28190}` and the 24-digit endpoint one grid + step below its root bracket (the bracket lies in [C, C + 1e-24)). With R1's local profiles the composed profile is + `{1:1644352, 2:470862, 3:159472, 4:71928, 5:13710, 8:5328, 14:1, 48:28190}` and the endpoint is + **0.001729151203983018442998** (κ = endpoint − 1e-46 − 1e-70; +2.3045e-10 over PR #3015). This was computed here at + about 18:40 UTC without having read PR #3021 (Nick Petalas, head `217edac2`), which published the same composition + at 2026-10-16 18:21 UTC and has priority; it equals PR #3021's FINITE, OUTER-CLAIM and COMPOSITION records + (profile, idle, physical, roles, κ and gain equal; PR #3021's root bracket lies in [C, C + 1e-24)). PR #3021's + native/admission/outer release is author-run and not rerun here. + +## Findings for the author (non-blocking) + +1. **`TASK.json` is PR #2979's file, byte for byte** (git blob `cbc9bcc5b1d4a7ef69ae983ab0cba218cf6ef7d2` in both + packages): author "Marius-Paul Dumitrean", task `complex-new-helper-inventory`, priority revision 5, base + `484a8ade`, and an `actual_scope`, `evidence` and `open_questions` that describe PR #2979's three stages, not R1. + The README and CLAIM.json credit R1 correctly; the task card does not. (`VERIFY.json`, `SOURCES.json`, + `verify.py` and `producer.py` are also PR #2979's blobs; `run_registered.py` and `reproduce.py` differ.) +2. The README's status line is dated `2026-10-17`; the PR was opened on 2026-10-16 at 17:54 UTC. The head commit + is stamped `2026-10-17 04:26 +11:00`, so this is the author's local date; the field asks for UTC. +3. The mechanism of the saving is not stated in the README ("lowers the paid frame bill by 4925 units"); it is + register 63 alone (above). The unit price is not reproduced here; the exact κ gain is. +4. The class census above may be worth a sentence: on the edited words no further adjacent same-target rewrite of + R1's kind improves, consistent with R1 being the first edit of the author's search. + +## Existing checks and overlap (refreshed 2026-10-16 20:53 UTC) + +| Where | What it checks | Relation to this package | +|---|---|---| +| PR #3015 `edits/edits_review.py` (author) | the candidate equals the parent with the declared hunks (author's applier), the inherited #2833 auditor forward and dual, seven tamper controls per word | reproduced here with an own diff, own replays and tracker, and the frame delta attributed; the stale-cleanup case is shown to pass both replays and to be caught only by the literal cleanup check | +| #3021 `verify.py` `check_word` (petalas) | R1's address and preimage, the exact 3×3 rational scalar identity, only restore/report/cleanup change, the width inventory unchanged, the report's delta `{1:−2, 2:1}`, the literal inverse cleanup with 91 buffers (both edited words) | the closest existing check of R1; it does not replay the words, recount frames or price the profile (the delta is read from the report), which this package does | +| #2993 (petalas) | #2979's frame paths, five groups, 16 V45 subsets | different object (stage 1 of #2979); no word semantics, no R1 | +| #2987, #3010 (RossRichardson) | chronological packing of #2979's fill; the k = 940 frozen-fill boundary | the same fill is reused unchanged by #3015; this package re-prices it under the new local profiles | +| #3006, #3008, #3014 (petalas) | V45 native endpoint and events; frozen-owner invoice on #2942's assignment | different objects | +| #3018 (petalas) | integrality exchange on #2979's fill | its journal is applied and its profile and endpoint reproduced here (Scope E) | +| #3021 (petalas, 18:21 UTC) | composition of R1 with #3018's journal, author chain run | its finite records equal the composition computed here (without having read it; it has priority); its release is not rerun | +| #3022, #3024 (petalas) | T148 and T740 packings of #2979's fill | outside this package | +| #3028, #3030 (petalas, 19:08 and 19:18 UTC) | T148 and T740 releases with R1's words (T740 root ≈ 0.001729152756004331) | outside this package; they inherit R1 and are not checked here | +| #3042 (dcharb78, 20:15 UTC), #3050 (petalas, 20:44 UTC), #3051 (jeremydiviney, 20:52 UTC) | six restore carrier/pivot skips on PR #2979's words (the same restore region, register 22 among them; −12H1+6H2 per call), their independent audit, and a T740 release of them | alternative rewrites of PR #2979's words, not of PR #3015's; none audits R1 | +| #3044 (petalas, 20:22 UTC) and the 20:51 UTC claim (Discussion 2612, comment 18982803) | the shared restore covector R2 composed with R1 through a fresh T74 release; a proposed contraction of four ADDs in `restore[175:179]` (registers 22 and 230) to three | compose with or sit next to R1; not audits of R1 | +| petalas, active claim 19:40 UTC (Discussion 2612, comment 18981612; expiry 20:30 UTC; local-only) | a second restore rewrite on #2979's words: `restore[162:178]` reads the covector `X40 − 2·X54` into registers 18 and 22; formed once at their common rank-7 frame and undone at FULL, so X54 climbs 7→9; per-call −2H1+H2, composed with R1 to `{1:2441, 2:708, 3:232, 4:108, 5:18, 8:8}` | outside R1's class (two non-adjacent consumers, two targets); not an audit of R1; bears on Open next question 2 | + +No independent replay, frame recount or endpoint check of R1 existed on the board at 2026-10-16 20:53 UTC (PR #3015 had no +comments or reviews; PR #3021's `check_word` is the closest, above). The overlap helper (`scripts/find_overlap.py` +with a scratch cache outside the checkout, refreshed at 19:36 UTC: 276 open PRs and 1,756 discussion records, complete +pagination) and the PR comments of #3015, #2979, #3018 and #3021 were read. + +## Result + +| Check | Result | +|---|---| +| hunk | `restore[178:180)` → 3 gates in both words; words equal outside restore/report/cleanup; minimal hunk = declared hunk | +| net operator | old = new on {22, 61, 63}: `22 −= 61 + 63`, 61 and 63 unchanged | +| frames | all three new gates legal (monotone): `V45 ⊂ F8 ⊂ FULL`; V45 = E_7 ∩ E_42 ∩ E_45 (computed, rule `edit.v45`), the rank-7 subspace of #2979's stage 1 | +| local profile | `{1:2445, 2:706, 3:232, 4:108, 5:18, 8:8}` → `{1:2443, 2:707, 3:232, 4:108, 5:18, 8:8}` (two implementations); inventory `{4:26, 5:2, 6:16, 7:52, 8:99, 9:213}` and mass 5,139 unchanged | +| attribution | climb dimensions change for register 63 only: `[…, 4→7, 7→8, 8→9]` → `[…, 4→7, 7→9]` | +| words | forward and dual exact, 632 inputs, 36 corrections, 72 warps, 408 helpers, 91 buffers, cleanup 5,208 items = own re-derivation, all at FULL; own tracker: targets Y+X, restored registers own, buffers zero before cleanup, identity after | +| allocation | 271,728 roles pass R-a..R-e in both implementations; complete profile = PROFILE.json = CLAIM.json; mass 4,816,512; physical 66,813; idle `{1:17310, 3:4956, 5:1728, 48:28190}` and the delta `{1:−1332, 2:+666}` are the model's consequences of unchanged widths and fill, checked but not independent evidence | +| endpoint | C accepted, C + 1e-24 rejected (own and vendored enclosures agree); κ = C − 1e-46 − 1e-70; gain over #2979 exact; #2979's profile rejected at C; root 0.0017291509735342244286952066… | +| census | parent words: 47 pairs, 94 pair/carrier candidates, 122 rewrites recounted, 2 with an improving option (R1, both carriers), 12 with losing options only; edited words: 44 pairs, 88 candidates, 108 recounted, 0 improving | +| #3018 | journal applies (103 edits); profile and endpoint reproduced | +| #3021 | composed profile, idle, physical, roles, κ and gain equal; PR #3021's root bracket lies in [C, C + 1e-24) | +| controls | 117 negative controls rejected by their named rules (85 distinct; edit 44, words 20, fill rules 10, pricing 17, κ 21, journal 5), 8 positive controls, 7 vendor-pin controls; checker mutations: see below | + +### Checker mutations + +`verify.py --mutations` applies each of the 23 textual mutations of the local checkers (a disabled monotonicity +check, net-operator check, hunk checks, attribution and delta checks, two-implementation comparison, dual replay, +literal-cleanup check, declared-profile, count and tracker checks, profile/delta/idle/preimage comparisons, +accept/reject verdicts, κ and gain checks, the ln 2 constant) in a subprocess in `--fast` mode and counts a mutation +as killed only when the run ends with an audit rejection (a wrong answer or an accepted control; a crash does not +count): **23/23 killed, 0 survived** (local run, 2026-10-16 20:52 UTC, `--jobs 3`, about 14 minutes). A first sweep had three survivors (a disabled outside-hunk check masked by the length check, the +dual replay bypassed by a control that called it directly, a disabled enclosure-intersection check masked by the +verdict check); the controls were extended so that each is now killed. + +## The R1 edit, as checked + +```text +old (PR #2979, restore[178:180)): new (PR #3015, restore[178:181)): + add 22 ← −1·61 @ F8 add 61 ← +1·63 @ V45 (rank 7) + add 22 ← −1·63 @ F8 add 22 ← −1·61 @ F8 (rank 8) + add 61 ← −1·63 @ FULL (rank 9) +F8 = ⟨256,128,64,34,16,10,4,1⟩, V45 = ⟨256,128,64,35,16,11,5⟩ ⊂ F8 ⊂ FULL +``` + +Before the block both 61 and 63 are at V45. In the old block both must climb to F8 (one rank each) and later to +FULL (one rank each at the end). In the new block 63 is read at V45 and then at FULL only, so its two rank-1 climbs +become one rank-2 climb; 61 climbs as before. In the inherited pricing a rank-2 child costs less than two rank-1 +children, hence −2H1+H2 per call, 666 calls, and the exact κ gain above. The cleanup, which inverts the non-target +gates in reverse order, gains one item; the parent's cleanup would still make both replays pass (same net operator), +which is why the literal cleanup is checked against an own re-derivation. + +## Controls + +Every negative control mutates a word, a fill, a claim or an expectation and runs it through the function the main +check uses; `audit_lib.expect` counts the attempt before the mutant runs and records the control only after the +rejecting rule id (and replay stage, where named) was asserted, so attempted and rejected are counted separately +(117 = 117). Highlights: + +- a new gate dropped, a coefficient flipped, a ratio of 2: rejected by the own diff, the net-operator check, the + forward replay (before cleanup) and the own tracker; +- the old frame kept on the new gates, or the third gate at F8 instead of FULL: legal words with no saving, rejected + by the declared-profile check and by the attribution (no delta); +- one generator dropped from the first new frame: rejected by both frame implementations (non-nested climb); +- the parent's cleanup on the candidate: passes both replays (recorded) and is rejected by the literal cleanup check; +- a cleanup prepended with `helper += zero buffer`: passes the forward replay and the own tracker, rejected by the + dual replay (buffers after cleanup); +- the symmetric rewrite with 63 as carrier: same delta, rejected by the attribution (the saving moves to 61); +- fill mutants (a role dropped, an overlap, a non-prefix bin, a role outside its window, a role on the caller's + active pair), each rejected by its rule in both implementations; a legal re-hosting changes the profile and is + rejected against PROFILE.json and against #2979's idle remainders; the parent's recounts against #3015's claim; +- endpoints at C ± 1e-24 and at each enclosure's straddle point, κ ± 1e-70, the claimed gain ± 1e-24, the + improvement test with swapped roles, a shifted vendored enclosure, a prediction started above the root; +- PR #3018's journal with a wrong preimage, a repeated index, a changed helper, its last edit dropped (a non-prefix + bin), and a profile with the rank-14 child at rank 13. + +Positive controls: PR #2979's words through the same pipeline with their CLAIM profile; PR #2979's fill with the +parent recounts giving its PROFILE.json and CLAIM; PR #2979's endpoint; PR #3018's profile and endpoint; PR #3021's +composition; the R1 pair found by the census. + +## Reproduce + +```sh +# from the repository root; git >= 2.29 and network for --fetch (PR #3015, #3018 and #3021 heads into refs/audit/prN) +python3 -I -B research/t74-3015-restore-edit-audit/verify.py --fetch # ~3.5 min, compares with RESULT.json +python3 -I -B research/t74-3015-restore-edit-audit/verify.py --fetch --out # rewrites RESULT.json +python3 -I -B research/t74-3015-restore-edit-audit/verify.py --mutations --jobs 3 # ~15 min; every mutation must fail +python3.12 scripts/research_package.py --package research/t74-3015-restore-edit-audit # registered replay (VERIFY.json) +``` + +Standard library only (Python 3.8 syntax; run here with CPython 3.14.4 on Linux, 4 cores; the registered 3.12 replay +was not run locally because no 3.12 interpreter is available, the command it registers was run directly). The run +reads the PR files with `git show` at the pinned commits and checks every blob id and SHA-256 (`SOURCES.json`); +nothing is written to the repository except, with `--fetch`, the fetched objects and `refs/audit/pr3015`, +`refs/audit/pr3018`, `refs/audit/pr3021`. + +## Scope limits + +- PR #3015's exhaustive search over all 2–4-gate restore-phase blocks (its Stack2979 harness, not shipped) is not + reproduced; the census covers one class on both words. +- The three new frames are checked for legality and priced as given; a frame re-solve of the whole word is not done. +- The native chains, bootstrap, complete admission and outer release of PR #3015 and PR #3021 are author-run and not + rerun; κ is checked as arithmetic on the complete profile under the inherited moment model with the inherited + 24-digit grid and margins. +- The fixed-inventory fractional cap certificate (`certificates/RELAX-CAP.json`) is not re-derived. +- PR #3018's sign proof and its own geometry checker are not re-derived; its journal is applied and priced under + rules R-a..R-e. +- Window semantics and the free interleaving of independent replica controllers are inherited modelling assumptions. + +## Open next questions + +1. **Does a frame re-solve of the edited word beat `{1:2443, 2:707, 3:232, 4:108, 5:18, 8:8}`?** R1's frames came from + the author's certified frame pricer; this package prices the given frames. First step: a monotone, gate-coupled + frame optimizer over GF(2)^9 subspaces (shortest path per register with the gate constraints), run on the parent + and the edited words. Blocked by: that optimizer has to be written; none of this contributor's checkers has one. +2. **Which other 2–4-gate restore blocks re-synthesise with the same net operator and a lower profile?** The census + here finds R1 unique in its class and the class exhausted after it. First step: enumerate contiguous blocks and + their equivalent gate sequences (commutations, carrier changes) and price them with the own chain. Blocked by: the + allowed re-synthesis needs a specification; the author's harness is not shipped. +3. **Does PR #3021's release at 0.001729151203983018442998 survive an independent admission check?** The finite side + is reproduced here; the native/prefix/outer side is author-run. First step: an independent reading of the admission + receipts against the composed fill (as #2804's stock and prefix checks did for #2530). Blocked by: nothing but time. + +## Independence, conflicts and credits + +**Independence.** All code in this package and in `vendor/` is this contributor's (Sagar Thakrar, thakrarsagar; +substantial AI assistance from Claude Code, Anthropic). No file of PR #3015, #2979, #3018, #3021 or of the packages +they build on is imported or executed; their files are read as data at pinned commits. Two implementations are used +where the lineage's checks exist twice (frame recount, fill rules, moment enclosure). + +**Conflicts.** None known. Other sessions of this account run in parallel on other tasks; none audits PR #3015 on the +board as of 2026-10-16 20:53 UTC (the account's open PRs are #2215 and #2361). + +**Credits.** Jeremy Kothe (jeremykothe2) for PR #3015 (R1, the edit stage and its review), and for PR #2957/#2966's +rewrites in the words; Marius-Paul Dumitrean (mdumitrean) for PR #2979 (the words, the rank-7 overlay, the literal T74 +allocation, the cap machinery) and PR #2942/#2930; Nick Petalas (petalas) for PR #3018, PR #3021 and the V45/native +audits; Ross Richardson for PR #2987/#3010; Mason Hale (PR2917), Jeremy Diviney (PR2908), Yiyang Lu (Lyy-iiis), +Tekalign (tekuuu), Dugongue, philippeVV, themilkman216, icekylinx (credited in PR #2979's and PR #3015's packages) +and Zhihao Chen (jacklightChen) (two contributors; checker lineage, see `vendor/NOTICE.md`), and the retained T74 +lineage credited in PR #2979's and PR #3015's packages; Douglas Colkitt for the research framework. The vendored +checkers' own predecessor credits are in `vendor/NOTICE.md`. Apache-2.0. diff --git a/research/t74-3015-restore-edit-audit/RESULT.json b/research/t74-3015-restore-edit-audit/RESULT.json new file mode 100644 index 0000000000..bfca101ce6 --- /dev/null +++ b/research/t74-3015-restore-edit-audit/RESULT.json @@ -0,0 +1,8108 @@ +{ + "audit": "independent verification of PR #3015 head e244296debb45fe6f4da84d29e4d64fbab55fda0 (R1 restore edit on PR #2979 head be191346391661f4d35fc0d1508d0a6029572576)", + "census": { + "base": { + "candidate": { + "nonzero": [ + { + "absorbed": 232, + "best_F3": 7, + "carrier": 363, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 5, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 60, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 363, + 232, + -2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 532, + 363, + -1, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 363, + 232, + 2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 532 + }, + { + "absorbed": 363, + "best_F3": 7, + "carrier": 232, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 5, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 60, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 232, + 363, + -1, + 2, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 532, + 232, + 2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 232, + 363, + 1, + 2, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 532 + }, + { + "absorbed": 73, + "best_F3": 7, + "carrier": 7, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 5, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 62, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 7, + 73, + -1, + 2, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 533, + 7, + 2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 7, + 73, + 1, + 2, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 533 + }, + { + "absorbed": 7, + "best_F3": 7, + "carrier": 73, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 5, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 62, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 73, + 7, + -2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 533, + 73, + -1, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 73, + 7, + 2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 533 + }, + { + "absorbed": 395, + "best_F3": 7, + "carrier": 236, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 5, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 73, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 236, + 395, + -1, + 2, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 556, + 236, + 2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 236, + 395, + 1, + 2, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 556 + }, + { + "absorbed": 236, + "best_F3": 7, + "carrier": 395, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 5, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 73, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 395, + 236, + -2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 556, + 395, + -1, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 395, + 236, + 2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 556 + }, + { + "absorbed": 238, + "best_F3": 7, + "carrier": 5, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 5, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 75, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 5, + 238, + -2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 557, + 5, + -1, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 5, + 238, + 2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 557 + }, + { + "absorbed": 5, + "best_F3": 7, + "carrier": 238, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 5, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 75, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 238, + 5, + -1, + 2, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 557, + 238, + 2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 238, + 5, + 1, + 2, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 557 + }, + { + "absorbed": 72, + "best_F3": 7, + "carrier": 70, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 9, + "cur_a": 7, + "cur_b": 7, + "next_a": 9, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8, + 8, + 8, + 9 + ], + "frame_dim": 7, + "improves": false, + "index": 144, + "legal": true, + "legal_options": 5, + "loses_only": true, + "new_block": [ + [ + "add", + 70, + 72, + -1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 2, + 70, + -1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 70, + 72, + 1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + }, + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + }, + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + } + ], + "option_deltas": [ + "{\"1\":4,\"2\":-2}", + "{}" + ], + "option_verdicts": { + "{\"1\":4,\"2\":-2}": false + }, + "options": 5, + "order": "s1 absorbs s2", + "target": 2 + }, + { + "absorbed": 70, + "best_F3": 7, + "carrier": 72, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 9, + "cur_a": 7, + "cur_b": 7, + "next_a": 9, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8, + 8, + 8, + 9 + ], + "frame_dim": 7, + "improves": false, + "index": 144, + "legal": true, + "legal_options": 5, + "loses_only": true, + "new_block": [ + [ + "add", + 72, + 70, + -1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 2, + 72, + 1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 72, + 70, + 1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + }, + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + }, + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + } + ], + "option_deltas": [ + "{\"1\":4,\"2\":-2}", + "{}" + ], + "option_verdicts": { + "{\"1\":4,\"2\":-2}": false + }, + "options": 5, + "order": "s2 absorbs s1", + "target": 2 + } + ], + "summary": { + "adjacent_same_target_pairs": 44, + "candidates": 88, + "illegal_reasons": {}, + "legal": 88, + "option_deltas": { + "{\"1\":2,\"2\":-1}": 8, + "{\"1\":4,\"2\":-2}": 6 + }, + "records_with_a_nonzero_option": 10, + "rewrites_recounted": 108 + } + }, + "parent": { + "nonzero": [ + { + "absorbed": 232, + "best_F3": 7, + "carrier": 363, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 5, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 60, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 363, + 232, + -2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 532, + 363, + -1, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 363, + 232, + 2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 532 + }, + { + "absorbed": 363, + "best_F3": 7, + "carrier": 232, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 5, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 60, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 232, + 363, + -1, + 2, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 532, + 232, + 2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 232, + 363, + 1, + 2, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 532 + }, + { + "absorbed": 73, + "best_F3": 7, + "carrier": 7, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 5, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 62, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 7, + 73, + -1, + 2, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 533, + 7, + 2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 7, + 73, + 1, + 2, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 533 + }, + { + "absorbed": 7, + "best_F3": 7, + "carrier": 73, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 5, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 62, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 73, + 7, + -2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 533, + 73, + -1, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 73, + 7, + 2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 533 + }, + { + "absorbed": 395, + "best_F3": 7, + "carrier": 236, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 5, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 73, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 236, + 395, + -1, + 2, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 556, + 236, + 2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 236, + 395, + 1, + 2, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 556 + }, + { + "absorbed": 236, + "best_F3": 7, + "carrier": 395, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 5, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 73, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 395, + 236, + -2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 556, + 395, + -1, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 395, + 236, + 2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 556 + }, + { + "absorbed": 238, + "best_F3": 7, + "carrier": 5, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 5, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 75, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 5, + 238, + -2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 557, + 5, + -1, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 5, + 238, + 2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 557 + }, + { + "absorbed": 5, + "best_F3": 7, + "carrier": 238, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 5, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 75, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 238, + 5, + -1, + 2, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 557, + 238, + 2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 238, + 5, + 1, + 2, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 557 + }, + { + "absorbed": 72, + "best_F3": 7, + "carrier": 70, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 9, + "cur_a": 7, + "cur_b": 7, + "next_a": 9, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8, + 8, + 8, + 9 + ], + "frame_dim": 7, + "improves": false, + "index": 144, + "legal": true, + "legal_options": 5, + "loses_only": true, + "new_block": [ + [ + "add", + 70, + 72, + -1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 2, + 70, + -1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 70, + 72, + 1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + }, + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + }, + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + } + ], + "option_deltas": [ + "{\"1\":4,\"2\":-2}", + "{}" + ], + "option_verdicts": { + "{\"1\":4,\"2\":-2}": false + }, + "options": 5, + "order": "s1 absorbs s2", + "target": 2 + }, + { + "absorbed": 70, + "best_F3": 7, + "carrier": 72, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 9, + "cur_a": 7, + "cur_b": 7, + "next_a": 9, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8, + 8, + 8, + 9 + ], + "frame_dim": 7, + "improves": false, + "index": 144, + "legal": true, + "legal_options": 5, + "loses_only": true, + "new_block": [ + [ + "add", + 72, + 70, + -1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 2, + 72, + 1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 72, + 70, + 1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + }, + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + }, + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + } + ], + "option_deltas": [ + "{\"1\":4,\"2\":-2}", + "{}" + ], + "option_verdicts": { + "{\"1\":4,\"2\":-2}": false + }, + "options": 5, + "order": "s2 absorbs s1", + "target": 2 + }, + { + "absorbed": 62, + "best_F3": 7, + "carrier": 61, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 153, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 61, + 62, + 2, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 2, + 61, + -1, + 2, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 61, + 62, + -2, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 2 + }, + { + "absorbed": 61, + "best_F3": 7, + "carrier": 62, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 7, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 153, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 62, + 61, + 1, + 2, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 2, + 62, + -1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 62, + 61, + -1, + 2, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 2 + }, + { + "absorbed": 63, + "best_F3": 9, + "carrier": 61, + "delta": { + "1": -2, + "2": 1 + }, + "dims": { + "F": 8, + "F1": 7, + "G": 9, + "cur_a": 7, + "cur_b": 7, + "next_a": 9, + "next_b": 9 + }, + "f3_dims": [ + 8, + 9 + ], + "frame_dim": 8, + "improves": true, + "index": 178, + "legal": true, + "legal_options": 2, + "loses_only": false, + "new_block": [ + [ + "add", + 61, + 63, + 1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 22, + 61, + -1, + 1, + [ + 256, + 128, + 64, + 34, + 16, + 10, + 4, + 1 + ] + ], + [ + "add", + 61, + 63, + -1, + 1, + [ + 256, + 128, + 64, + 32, + 16, + 8, + 4, + 2, + 1 + ] + ] + ], + "nonzero_options": [ + { + "F3": 9, + "delta": { + "1": -2, + "2": 1 + } + } + ], + "option_deltas": [ + "{\"1\":-2,\"2\":1}", + "{}" + ], + "option_verdicts": { + "{\"1\":-2,\"2\":1}": true + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 22 + }, + { + "absorbed": 61, + "best_F3": 9, + "carrier": 63, + "delta": { + "1": -2, + "2": 1 + }, + "dims": { + "F": 8, + "F1": 7, + "G": 9, + "cur_a": 7, + "cur_b": 7, + "next_a": 9, + "next_b": 9 + }, + "f3_dims": [ + 8, + 9 + ], + "frame_dim": 8, + "improves": true, + "index": 178, + "legal": true, + "legal_options": 2, + "loses_only": false, + "new_block": [ + [ + "add", + 63, + 61, + 1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 22, + 63, + -1, + 1, + [ + 256, + 128, + 64, + 34, + 16, + 10, + 4, + 1 + ] + ], + [ + "add", + 63, + 61, + -1, + 1, + [ + 256, + 128, + 64, + 32, + 16, + 8, + 4, + 2, + 1 + ] + ] + ], + "nonzero_options": [ + { + "F3": 9, + "delta": { + "1": -2, + "2": 1 + } + } + ], + "option_deltas": [ + "{\"1\":-2,\"2\":1}", + "{}" + ], + "option_verdicts": { + "{\"1\":-2,\"2\":1}": true + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 22 + } + ], + "summary": { + "adjacent_same_target_pairs": 47, + "candidates": 94, + "illegal_reasons": {}, + "legal": 94, + "option_deltas": { + "{\"1\":-2,\"2\":1}": 2, + "{\"1\":2,\"2\":-1}": 10, + "{\"1\":4,\"2\":-2}": 6 + }, + "records_with_a_nonzero_option": 14, + "rewrites_recounted": 122 + } + } + }, + "extra": { + "candidate": { + "nonzero": [ + { + "absorbed": 232, + "best_F3": 7, + "carrier": 363, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 5, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 60, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 363, + 232, + -2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 532, + 363, + -1, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 363, + 232, + 2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 532 + }, + { + "absorbed": 363, + "best_F3": 7, + "carrier": 232, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 5, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 60, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 232, + 363, + -1, + 2, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 532, + 232, + 2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 232, + 363, + 1, + 2, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 532 + }, + { + "absorbed": 73, + "best_F3": 7, + "carrier": 7, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 5, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 62, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 7, + 73, + -1, + 2, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 533, + 7, + 2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 7, + 73, + 1, + 2, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 533 + }, + { + "absorbed": 7, + "best_F3": 7, + "carrier": 73, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 5, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 62, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 73, + 7, + -2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 533, + 73, + -1, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 73, + 7, + 2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 533 + }, + { + "absorbed": 395, + "best_F3": 7, + "carrier": 236, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 5, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 73, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 236, + 395, + -1, + 2, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 556, + 236, + 2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 236, + 395, + 1, + 2, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 556 + }, + { + "absorbed": 236, + "best_F3": 7, + "carrier": 395, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 5, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 73, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 395, + 236, + -2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 556, + 395, + -1, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 395, + 236, + 2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 556 + }, + { + "absorbed": 238, + "best_F3": 7, + "carrier": 5, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 5, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 75, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 5, + 238, + -2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 557, + 5, + -1, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 5, + 238, + 2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 557 + }, + { + "absorbed": 5, + "best_F3": 7, + "carrier": 238, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 5, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 75, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 238, + 5, + -1, + 2, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 557, + 238, + 2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 238, + 5, + 1, + 2, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 557 + }, + { + "absorbed": 72, + "best_F3": 7, + "carrier": 70, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 9, + "cur_a": 7, + "cur_b": 7, + "next_a": 9, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8, + 8, + 8, + 9 + ], + "frame_dim": 7, + "improves": false, + "index": 144, + "legal": true, + "legal_options": 5, + "loses_only": true, + "new_block": [ + [ + "add", + 70, + 72, + -1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 2, + 70, + -1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 70, + 72, + 1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + }, + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + }, + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + } + ], + "option_deltas": [ + "{\"1\":4,\"2\":-2}", + "{}" + ], + "option_verdicts": { + "{\"1\":4,\"2\":-2}": false + }, + "options": 5, + "order": "s1 absorbs s2", + "target": 2 + }, + { + "absorbed": 70, + "best_F3": 7, + "carrier": 72, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 9, + "cur_a": 7, + "cur_b": 7, + "next_a": 9, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8, + 8, + 8, + 9 + ], + "frame_dim": 7, + "improves": false, + "index": 144, + "legal": true, + "legal_options": 5, + "loses_only": true, + "new_block": [ + [ + "add", + 72, + 70, + -1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 2, + 72, + 1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 72, + 70, + 1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + }, + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + }, + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + } + ], + "option_deltas": [ + "{\"1\":4,\"2\":-2}", + "{}" + ], + "option_verdicts": { + "{\"1\":4,\"2\":-2}": false + }, + "options": 5, + "order": "s2 absorbs s1", + "target": 2 + } + ], + "summary": { + "adjacent_same_target_pairs": 44, + "candidates": 88, + "illegal_reasons": {}, + "legal": 88, + "option_deltas": { + "{\"1\":2,\"2\":-1}": 8, + "{\"1\":4,\"2\":-2}": 6 + }, + "records_with_a_nonzero_option": 10, + "rewrites_recounted": 108 + } + }, + "parent": { + "nonzero": [ + { + "absorbed": 232, + "best_F3": 7, + "carrier": 363, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 5, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 60, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 363, + 232, + -2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 532, + 363, + -1, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 363, + 232, + 2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 532 + }, + { + "absorbed": 363, + "best_F3": 7, + "carrier": 232, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 5, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 60, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 232, + 363, + -1, + 2, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 532, + 232, + 2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 232, + 363, + 1, + 2, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 532 + }, + { + "absorbed": 73, + "best_F3": 7, + "carrier": 7, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 5, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 62, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 7, + 73, + -1, + 2, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 533, + 7, + 2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 7, + 73, + 1, + 2, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 533 + }, + { + "absorbed": 7, + "best_F3": 7, + "carrier": 73, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 5, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 62, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 73, + 7, + -2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 533, + 73, + -1, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ], + [ + "add", + 73, + 7, + 2, + 1, + [ + 256, + 128, + 64, + 32, + 19, + 11, + 6 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 533 + }, + { + "absorbed": 395, + "best_F3": 7, + "carrier": 236, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 5, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 73, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 236, + 395, + -1, + 2, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 556, + 236, + 2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 236, + 395, + 1, + 2, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 556 + }, + { + "absorbed": 236, + "best_F3": 7, + "carrier": 395, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 5, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 73, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 395, + 236, + -2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 556, + 395, + -1, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 395, + 236, + 2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 556 + }, + { + "absorbed": 238, + "best_F3": 7, + "carrier": 5, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 5, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 75, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 5, + 238, + -2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 557, + 5, + -1, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 5, + 238, + 2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 557 + }, + { + "absorbed": 5, + "best_F3": 7, + "carrier": 238, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 5, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 75, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 238, + 5, + -1, + 2, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 557, + 238, + 2, + 1, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ], + [ + "add", + 238, + 5, + 1, + 2, + [ + 256, + 128, + 64, + 37, + 21, + 8, + 3 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 557 + }, + { + "absorbed": 72, + "best_F3": 7, + "carrier": 70, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 9, + "cur_a": 7, + "cur_b": 7, + "next_a": 9, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8, + 8, + 8, + 9 + ], + "frame_dim": 7, + "improves": false, + "index": 144, + "legal": true, + "legal_options": 5, + "loses_only": true, + "new_block": [ + [ + "add", + 70, + 72, + -1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 2, + 70, + -1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 70, + 72, + 1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + }, + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + }, + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + } + ], + "option_deltas": [ + "{\"1\":4,\"2\":-2}", + "{}" + ], + "option_verdicts": { + "{\"1\":4,\"2\":-2}": false + }, + "options": 5, + "order": "s1 absorbs s2", + "target": 2 + }, + { + "absorbed": 70, + "best_F3": 7, + "carrier": 72, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 9, + "cur_a": 7, + "cur_b": 7, + "next_a": 9, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8, + 8, + 8, + 9 + ], + "frame_dim": 7, + "improves": false, + "index": 144, + "legal": true, + "legal_options": 5, + "loses_only": true, + "new_block": [ + [ + "add", + 72, + 70, + -1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 2, + 72, + 1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 72, + 70, + 1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + }, + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + }, + { + "F3": 8, + "delta": { + "1": 4, + "2": -2 + } + } + ], + "option_deltas": [ + "{\"1\":4,\"2\":-2}", + "{}" + ], + "option_verdicts": { + "{\"1\":4,\"2\":-2}": false + }, + "options": 5, + "order": "s2 absorbs s1", + "target": 2 + }, + { + "absorbed": 62, + "best_F3": 7, + "carrier": 61, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 7, + "next_a": 8, + "next_b": 9 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 153, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 61, + 62, + 2, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 2, + 61, + -1, + 2, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 61, + 62, + -2, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 2 + }, + { + "absorbed": 61, + "best_F3": 7, + "carrier": 62, + "delta": {}, + "dims": { + "F": 7, + "F1": 7, + "G": 8, + "cur_a": 7, + "cur_b": 7, + "next_a": 9, + "next_b": 8 + }, + "f3_dims": [ + 7, + 8 + ], + "frame_dim": 7, + "improves": false, + "index": 153, + "legal": true, + "legal_options": 2, + "loses_only": true, + "new_block": [ + [ + "add", + 62, + 61, + 1, + 2, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 2, + 62, + -1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 62, + 61, + -1, + 2, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ] + ], + "nonzero_options": [ + { + "F3": 8, + "delta": { + "1": 2, + "2": -1 + } + } + ], + "option_deltas": [ + "{\"1\":2,\"2\":-1}", + "{}" + ], + "option_verdicts": { + "{\"1\":2,\"2\":-1}": false + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 2 + }, + { + "absorbed": 63, + "best_F3": 9, + "carrier": 61, + "delta": { + "1": -2, + "2": 1 + }, + "dims": { + "F": 8, + "F1": 7, + "G": 9, + "cur_a": 7, + "cur_b": 7, + "next_a": 9, + "next_b": 9 + }, + "f3_dims": [ + 8, + 9 + ], + "frame_dim": 8, + "improves": true, + "index": 178, + "legal": true, + "legal_options": 2, + "loses_only": false, + "new_block": [ + [ + "add", + 61, + 63, + 1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 22, + 61, + -1, + 1, + [ + 256, + 128, + 64, + 34, + 16, + 10, + 4, + 1 + ] + ], + [ + "add", + 61, + 63, + -1, + 1, + [ + 256, + 128, + 64, + 32, + 16, + 8, + 4, + 2, + 1 + ] + ] + ], + "nonzero_options": [ + { + "F3": 9, + "delta": { + "1": -2, + "2": 1 + } + } + ], + "option_deltas": [ + "{\"1\":-2,\"2\":1}", + "{}" + ], + "option_verdicts": { + "{\"1\":-2,\"2\":1}": true + }, + "options": 2, + "order": "s1 absorbs s2", + "target": 22 + }, + { + "absorbed": 61, + "best_F3": 9, + "carrier": 63, + "delta": { + "1": -2, + "2": 1 + }, + "dims": { + "F": 8, + "F1": 7, + "G": 9, + "cur_a": 7, + "cur_b": 7, + "next_a": 9, + "next_b": 9 + }, + "f3_dims": [ + 8, + 9 + ], + "frame_dim": 8, + "improves": true, + "index": 178, + "legal": true, + "legal_options": 2, + "loses_only": false, + "new_block": [ + [ + "add", + 63, + 61, + 1, + 1, + [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + ], + [ + "add", + 22, + 63, + -1, + 1, + [ + 256, + 128, + 64, + 34, + 16, + 10, + 4, + 1 + ] + ], + [ + "add", + 63, + 61, + -1, + 1, + [ + 256, + 128, + 64, + 32, + 16, + 8, + 4, + 2, + 1 + ] + ] + ], + "nonzero_options": [ + { + "F3": 9, + "delta": { + "1": -2, + "2": 1 + } + } + ], + "option_deltas": [ + "{\"1\":-2,\"2\":1}", + "{}" + ], + "option_verdicts": { + "{\"1\":-2,\"2\":1}": true + }, + "options": 2, + "order": "s2 absorbs s1", + "target": 22 + } + ], + "summary": { + "adjacent_same_target_pairs": 47, + "candidates": 94, + "illegal_reasons": {}, + "legal": 94, + "option_deltas": { + "{\"1\":-2,\"2\":1}": 2, + "{\"1\":2,\"2\":-1}": 10, + "{\"1\":4,\"2\":-2}": 6 + }, + "records_with_a_nonzero_option": 14, + "rewrites_recounted": 122 + } + } + } + }, + "commits": { + "2269": "b479fc5567bc09ab9185bffe89b62594f36d74e5", + "2979": "be191346391661f4d35fc0d1508d0a6029572576", + "3015": "e244296debb45fe6f4da84d29e4d64fbab55fda0", + "3018": "ca7113157d7c959fdfa9d7cd17ef92d3877070d0", + "3021": "217edac2ebfa6250536bd6df153de14901a69395" + }, + "controls": { + "edit": [ + { + "control": "[base] new gate 2 dropped: own diff", + "expected": "edit.hunk", + "message": "edit.hunk: candidate[178:181] is not the declared new block", + "rejected_by": "edit.hunk" + }, + { + "control": "[base] new gate 2 dropped, report forged, cleanup re-derived: forward replay", + "expected": "wc.replay", + "message": "restored cold register 230 is not its own input", + "rejected_by": "wc.replay", + "stage": "forward replay, before cleanup" + }, + { + "control": "[base] new gate 1 coefficient flipped: net operator", + "expected": "edit.net_operator", + "message": "edit.net_operator: the new block is not the old block as an operator", + "rejected_by": "edit.net_operator" + }, + { + "control": "[base] new gate 1 coefficient flipped, cleanup re-derived: forward replay", + "expected": "wc.replay", + "message": "restored cold register 230 is not its own input", + "rejected_by": "wc.replay", + "stage": "forward replay, before cleanup" + }, + { + "control": "[base] new gate 1 coefficient flipped, cleanup re-derived: own tracker", + "expected": "words.tracker", + "message": "words.tracker: pre-cleanup state {'targets_final': True, 'restored_own': False, 'buffers_zero': True}", + "rejected_by": "words.tracker" + }, + { + "control": "[base] old frame kept on the three new gates: declared profile", + "expected": "words.declared", + "message": "words.declared: recount {1: 2445, 2: 706, 3: 232, 4: 108, 5: 18, 8: 8} {4: 26, 5: 2, 6: 16, 7: 52, 8: 99, 9: 213} != declared {1: 2443, 2: 707, 3: 232, 4: 108, ", + "rejected_by": "words.declared" + }, + { + "control": "[base] old frame kept on the three new gates: attribution (no delta)", + "expected": "edit.delta", + "message": "edit.delta: paid delta {} != {1: -2, 2: 1}", + "rejected_by": "edit.delta" + }, + { + "control": "[base] new gate 1 frame with one generator dropped: vendored recount", + "expected": "wc.frame", + "message": "non-nested climb of 61 at post[178]", + "rejected_by": "wc.frame" + }, + { + "control": "[base] new gate 1 frame with one generator dropped: own chain", + "expected": "chain.monotone", + "message": "chain.monotone: post[178] climbs 61 from dim 7 to a frame of dim 6 not containing it", + "rejected_by": "chain.monotone" + }, + { + "control": "[base] new gate 3 at the old rank-8 frame instead of FULL: declared profile", + "expected": "words.declared", + "message": "words.declared: recount {1: 2445, 2: 706, 3: 232, 4: 108, 5: 18, 8: 8} {4: 26, 5: 2, 6: 16, 7: 52, 8: 99, 9: 213} != declared {1: 2443, 2: 707, 3: 232, 4: 108, ", + "rejected_by": "words.declared" + }, + { + "control": "[base] candidate with the parent restore section: own diff", + "expected": "edit.hunk", + "message": "edit.hunk: the restore sections are identical", + "rejected_by": "edit.hunk" + }, + { + "control": "[base] declared hunk shifted by one gate: own diff", + "expected": "edit.hunk", + "message": "edit.hunk: parent[177:179] is not the declared old block", + "rejected_by": "edit.hunk" + }, + { + "control": "[base] new block with ratio 2 (61 += 2*63 ... 61 -= 2*63): net operator", + "expected": "edit.net_operator", + "message": "edit.net_operator: the new block is not the old block as an operator", + "rejected_by": "edit.net_operator" + }, + { + "control": "[base] new block with ratio 2, cleanup re-derived: forward replay", + "expected": "wc.replay", + "message": "restored cold register 230 is not its own input", + "rejected_by": "wc.replay", + "stage": "forward replay, before cleanup" + }, + { + "control": "[base] parent cleanup on the candidate (passes both replays): literal cleanup check", + "expected": "words.cleanup", + "message": "words.cleanup: the literal cleanup is not the own inverse-reverse re-derivation", + "rejected_by": "words.cleanup", + "replays_accept": true + }, + { + "control": "[base] one A gate frame changed as well: own diff", + "expected": "edit.sections", + "message": "edit.sections: sections differing beyond ('restore', 'report', 'cleanup'): ['A', 'cleanup', 'report', 'restore']", + "rejected_by": "edit.sections" + }, + { + "control": "[base] a copy of new gate 3 appended to restore: own diff", + "expected": "edit.hunk", + "message": "edit.hunk: restore length", + "rejected_by": "edit.hunk" + }, + { + "control": "[base] restore gate 100 (outside the hunk) coefficient flipped, same length: own diff", + "expected": "edit.hunk", + "message": "edit.hunk: minimal hunk [100, 180) outside the declared [178, 180)", + "rejected_by": "edit.hunk" + }, + { + "control": "[base] declared old block with a flipped coefficient: own diff", + "expected": "edit.hunk", + "message": "edit.hunk: parent[178:180] is not the declared old block", + "rejected_by": "edit.hunk" + }, + { + "control": "[base] symmetric rewrite (63 as carrier): attribution names 61, not 63", + "expected": "edit.attribution", + "message": "edit.attribution: climb dimensions changed for [61], expected [63]", + "rejected_by": "edit.attribution" + }, + { + "control": "[base] parent against itself: attribution (no delta)", + "expected": "edit.delta", + "message": "edit.delta: paid delta {} != {1: -2, 2: 1}", + "rejected_by": "edit.delta" + }, + { + "control": "[base] two implementations: vendored recount with one more rank-1 child", + "expected": "edit.two_impl", + "message": "edit.two_impl: own chain {1: 2445, 2: 706, 3: 232, 4: 108, 5: 18, 8: 8} != vendored recount {1: 2446, 2: 706, 3: 232, 4: 108, 5: 18, 8: 8}", + "rejected_by": "edit.two_impl" + }, + { + "control": "[extra] new gate 2 dropped: own diff", + "expected": "edit.hunk", + "message": "edit.hunk: candidate[178:181] is not the declared new block", + "rejected_by": "edit.hunk" + }, + { + "control": "[extra] new gate 2 dropped, report forged, cleanup re-derived: forward replay", + "expected": "wc.replay", + "message": "restored cold register 230 is not its own input", + "rejected_by": "wc.replay", + "stage": "forward replay, before cleanup" + }, + { + "control": "[extra] new gate 1 coefficient flipped: net operator", + "expected": "edit.net_operator", + "message": "edit.net_operator: the new block is not the old block as an operator", + "rejected_by": "edit.net_operator" + }, + { + "control": "[extra] new gate 1 coefficient flipped, cleanup re-derived: forward replay", + "expected": "wc.replay", + "message": "restored cold register 230 is not its own input", + "rejected_by": "wc.replay", + "stage": "forward replay, before cleanup" + }, + { + "control": "[extra] new gate 1 coefficient flipped, cleanup re-derived: own tracker", + "expected": "words.tracker", + "message": "words.tracker: pre-cleanup state {'targets_final': True, 'restored_own': False, 'buffers_zero': True}", + "rejected_by": "words.tracker" + }, + { + "control": "[extra] old frame kept on the three new gates: declared profile", + "expected": "words.declared", + "message": "words.declared: recount {1: 2445, 2: 706, 3: 232, 4: 108, 5: 18, 8: 8} {4: 26, 5: 2, 6: 16, 7: 52, 8: 99, 9: 213} != declared {1: 2443, 2: 707, 3: 232, 4: 108, ", + "rejected_by": "words.declared" + }, + { + "control": "[extra] old frame kept on the three new gates: attribution (no delta)", + "expected": "edit.delta", + "message": "edit.delta: paid delta {} != {1: -2, 2: 1}", + "rejected_by": "edit.delta" + }, + { + "control": "[extra] new gate 1 frame with one generator dropped: vendored recount", + "expected": "wc.frame", + "message": "non-nested climb of 61 at post[178]", + "rejected_by": "wc.frame" + }, + { + "control": "[extra] new gate 1 frame with one generator dropped: own chain", + "expected": "chain.monotone", + "message": "chain.monotone: post[178] climbs 61 from dim 7 to a frame of dim 6 not containing it", + "rejected_by": "chain.monotone" + }, + { + "control": "[extra] new gate 3 at the old rank-8 frame instead of FULL: declared profile", + "expected": "words.declared", + "message": "words.declared: recount {1: 2445, 2: 706, 3: 232, 4: 108, 5: 18, 8: 8} {4: 26, 5: 2, 6: 16, 7: 52, 8: 99, 9: 213} != declared {1: 2443, 2: 707, 3: 232, 4: 108, ", + "rejected_by": "words.declared" + }, + { + "control": "[extra] candidate with the parent restore section: own diff", + "expected": "edit.hunk", + "message": "edit.hunk: the restore sections are identical", + "rejected_by": "edit.hunk" + }, + { + "control": "[extra] declared hunk shifted by one gate: own diff", + "expected": "edit.hunk", + "message": "edit.hunk: parent[177:179] is not the declared old block", + "rejected_by": "edit.hunk" + }, + { + "control": "[extra] new block with ratio 2 (61 += 2*63 ... 61 -= 2*63): net operator", + "expected": "edit.net_operator", + "message": "edit.net_operator: the new block is not the old block as an operator", + "rejected_by": "edit.net_operator" + }, + { + "control": "[extra] new block with ratio 2, cleanup re-derived: forward replay", + "expected": "wc.replay", + "message": "restored cold register 230 is not its own input", + "rejected_by": "wc.replay", + "stage": "forward replay, before cleanup" + }, + { + "control": "[extra] parent cleanup on the candidate (passes both replays): literal cleanup check", + "expected": "words.cleanup", + "message": "words.cleanup: the literal cleanup is not the own inverse-reverse re-derivation", + "rejected_by": "words.cleanup", + "replays_accept": true + }, + { + "control": "[extra] one A gate frame changed as well: own diff", + "expected": "edit.sections", + "message": "edit.sections: sections differing beyond ('restore', 'report', 'cleanup'): ['A', 'cleanup', 'report', 'restore']", + "rejected_by": "edit.sections" + }, + { + "control": "[extra] a copy of new gate 3 appended to restore: own diff", + "expected": "edit.hunk", + "message": "edit.hunk: restore length", + "rejected_by": "edit.hunk" + }, + { + "control": "[extra] restore gate 100 (outside the hunk) coefficient flipped, same length: own diff", + "expected": "edit.hunk", + "message": "edit.hunk: minimal hunk [100, 180) outside the declared [178, 180)", + "rejected_by": "edit.hunk" + }, + { + "control": "[extra] declared old block with a flipped coefficient: own diff", + "expected": "edit.hunk", + "message": "edit.hunk: parent[178:180] is not the declared old block", + "rejected_by": "edit.hunk" + }, + { + "control": "[extra] symmetric rewrite (63 as carrier): attribution names 61, not 63", + "expected": "edit.attribution", + "message": "edit.attribution: climb dimensions changed for [61], expected [63]", + "rejected_by": "edit.attribution" + }, + { + "control": "[extra] parent against itself: attribution (no delta)", + "expected": "edit.delta", + "message": "edit.delta: paid delta {} != {1: -2, 2: 1}", + "rejected_by": "edit.delta" + }, + { + "control": "[extra] two implementations: vendored recount with one more rank-1 child", + "expected": "edit.two_impl", + "message": "edit.two_impl: own chain {1: 2445, 2: 706, 3: 232, 4: 108, 5: 18, 8: 8} != vendored recount {1: 2446, 2: 706, 3: 232, 4: 108, 5: 18, 8: 8}", + "rejected_by": "edit.two_impl" + } + ], + "fill_rules": [ + { + "control": "last fill role dropped (own check_rows)", + "expected": "R-a.count", + "message": "R-a.count: 271727 roles != 666 calls x 408 helpers", + "rejected_by": "R-a.count" + }, + { + "control": "last fill role dropped (vendored fill_check80)", + "expected": "R-a.count", + "message": "R-a.count: 271727 roles, expected 666 calls x 408 helpers", + "rejected_by": "R-a.count" + }, + { + "control": "fill role 4487 moved onto the offset of role 1223 in bin (0, 0, 0) (own check_rows)", + "expected": "R-b.overlap", + "message": "R-b.overlap: overlap in bin (0, 0, 0)", + "rejected_by": "R-b.overlap" + }, + { + "control": "fill role 4487 moved onto the offset of role 1223 in bin (0, 0, 0) (vendored fill_check80)", + "expected": "R-b.overlap", + "message": "R-b.overlap: overlapping slices in bin (0, 0, 0)", + "rejected_by": "R-b.overlap" + }, + { + "control": "top slice of bin (0, 4, 0) lifted by one cell (gap below it) (own check_rows)", + "expected": "R-b.prefix", + "message": "R-b.prefix: occupied cells of bin (0, 4, 0) are not a prefix", + "rejected_by": "R-b.prefix" + }, + { + "control": "top slice of bin (0, 4, 0) lifted by one cell (gap below it) (vendored fill_check80)", + "expected": "R-b.prefix", + "message": "R-b.prefix: occupied cells of bin (0, 4, 0) are not a prefix", + "rejected_by": "R-b.prefix" + }, + { + "control": "fill role 4490 re-hosted at owner 0 outside its window (own check_rows)", + "expected": "R-d.window", + "message": "R-d.window: role (t=11,h=2) outside window (-1,10] of owner 0 child 0", + "rejected_by": "R-d.window" + }, + { + "control": "fill role 4490 re-hosted at owner 0 outside its window (vendored fill_check80)", + "expected": "R-d.window", + "message": "R-d.window: role outside window of owner 0 child 0", + "rejected_by": "R-d.window" + }, + { + "control": "fill role 0 re-hosted on its caller's active pair (owner 0, child 12) (own check_rows)", + "expected": "R-e.active_pair", + "message": "R-e.active_pair: helper 0 of call 0 hosted on the caller active pair (child 12)", + "rejected_by": "R-e.active_pair" + }, + { + "control": "fill role 0 re-hosted on its caller's active pair (owner 0, child 12) (vendored fill_check80)", + "expected": "R-e.active_pair", + "message": "R-e.active_pair: helper hosted on the caller active pair", + "rejected_by": "R-e.active_pair" + } + ], + "journal": [ + { + "control": "journal edit 0 with its preimage offset raised by one", + "expected": "journal.preimage", + "message": "journal.preimage: edit 0: row 0 is [0, 0, 13, 0, 41, 0], not [0, 0, 13, 0, 41, 1]", + "rejected_by": "journal.preimage" + }, + { + "control": "journal with its first edit repeated", + "expected": "journal.index", + "message": "journal.index: edit 103 index 0", + "rejected_by": "journal.index" + }, + { + "control": "journal edit 0 whose new row changes the helper", + "expected": "journal.row", + "message": "journal.row: edit 0 keeps call and helper", + "rejected_by": "journal.row" + }, + { + "control": "journaled profile against PR3018's RESULT profile with its rank-14 child at rank 13", + "expected": "journal.profile", + "message": "journal.profile: complete profile {'1': 1645684, '2': 470196, '3': 159472, '4': 71928, '5': 13710, '8': 5328, '13': 1, '48': 28190} != {'1': 1645684, '2': 47019", + "rejected_by": "journal.profile" + }, + { + "control": "journal with its last edit dropped: the fill priced", + "expected": "R-b.prefix", + "message": "R-b.prefix: occupied cells of bin (60, 13, 111) are not a prefix", + "rejected_by": "R-b.prefix" + } + ], + "kappa": [ + { + "control": "endpoint claimed at C + 1e-24 (own enclosure)", + "expected": "kappa.endpoint_accept", + "message": "kappa.endpoint_accept: M(C) enclosure [2.252e-24, 2.252e-24] - 1 not below 0", + "rejected_by": "kappa.endpoint_accept" + }, + { + "control": "endpoint claimed at the straddle point S (enclosure contains 1) (own enclosure)", + "expected": "kappa.endpoint_accept", + "message": "kappa.endpoint_accept: M(C) enclosure [-1.000e-60, 1.000e-60] - 1 not below 0", + "rejected_by": "kappa.endpoint_accept" + }, + { + "control": "endpoint claimed at C - 1e-24 (own enclosure)", + "expected": "kappa.endpoint_reject", + "message": "kappa.endpoint_reject: M(C + 1e-24) enclosure [-5.865e-25, -5.865e-25] - 1 not above 0", + "rejected_by": "kappa.endpoint_reject" + }, + { + "control": "endpoint claimed at S - 1e-24 (so that S must be rejected) (own enclosure)", + "expected": "kappa.endpoint_reject", + "message": "kappa.endpoint_reject: M(C + 1e-24) enclosure [-1.000e-60, 1.000e-60] - 1 not above 0", + "rejected_by": "kappa.endpoint_reject" + }, + { + "control": "endpoint claimed at C + 1e-24 (vendored enclosure)", + "expected": "kappa.endpoint_accept", + "message": "kappa.endpoint_accept: M(C) enclosure [2.252e-24, 2.252e-24] - 1 not below 0", + "rejected_by": "kappa.endpoint_accept" + }, + { + "control": "endpoint claimed at the straddle point S (enclosure contains 1) (vendored enclosure)", + "expected": "kappa.endpoint_accept", + "message": "kappa.endpoint_accept: M(C) enclosure [-1.463e-191, 1.198e-191] - 1 not below 0", + "rejected_by": "kappa.endpoint_accept" + }, + { + "control": "endpoint claimed at C - 1e-24 (vendored enclosure)", + "expected": "kappa.endpoint_reject", + "message": "kappa.endpoint_reject: M(C + 1e-24) enclosure [-5.865e-25, -5.865e-25] - 1 not above 0", + "rejected_by": "kappa.endpoint_reject" + }, + { + "control": "endpoint claimed at S - 1e-24 (so that S must be rejected) (vendored enclosure)", + "expected": "kappa.endpoint_reject", + "message": "kappa.endpoint_reject: M(C + 1e-24) enclosure [-1.463e-191, 1.198e-191] - 1 not above 0", + "rejected_by": "kappa.endpoint_reject" + }, + { + "control": "C with 25 digits", + "expected": "kappa.endpoint_format", + "message": "kappa.endpoint_format: C is not a positive 24-digit decimal", + "rejected_by": "kappa.endpoint_format" + }, + { + "control": "C = 0", + "expected": "kappa.endpoint_format", + "message": "kappa.endpoint_format: C is not a positive 24-digit decimal", + "rejected_by": "kappa.endpoint_format" + }, + { + "control": "CLAIM kappa + 1e-70", + "expected": "kappa.kappa", + "message": "kappa.kappa: CLAIM kappa != C - 1e-46 - 1e-70", + "rejected_by": "kappa.kappa" + }, + { + "control": "kappa against C + 1e-70", + "expected": "kappa.kappa", + "message": "kappa.kappa: CLAIM kappa != C - 1e-46 - 1e-70", + "rejected_by": "kappa.kappa" + }, + { + "control": "claimed gain + 1e-24", + "expected": "kappa.gain", + "message": "kappa.gain: kappa gain 58495443855455489/500000000000000000000000 != claimed 116990887710910979/1000000000000000000000000", + "rejected_by": "kappa.gain" + }, + { + "control": "gain of PR2979 over itself", + "expected": "kappa.gain", + "message": "kappa.gain: kappa gain 0 != claimed 0", + "rejected_by": "kappa.gain" + }, + { + "control": "improvement with the new profile in place of the old one", + "expected": "kappa.improvement", + "message": "kappa.improvement: the old profile is not rejected at the new C (or the new profile not accepted at the old C)", + "rejected_by": "kappa.improvement" + }, + { + "control": "improvement with the roles of the two claims swapped", + "expected": "kappa.improvement", + "message": "kappa.improvement: the old profile is not rejected at the new C (or the new profile not accepted at the old C)", + "rejected_by": "kappa.improvement" + }, + { + "control": "vendored enclosure shifted by 1e-20 (disjoint from the own one, verdict changes)", + "expected": "kappa.two_impl", + "message": "kappa.two_impl: enclosures (Fraction(999999999999999999999999413486757355975699865734602616151727, 1000000000000000000000000000000000000000000000000000000000000", + "rejected_by": "kappa.two_impl" + }, + { + "control": "vendored enclosure shifted by -1e-50 (disjoint from the own one, same verdict)", + "expected": "kappa.two_impl", + "message": "kappa.two_impl: enclosures (Fraction(999999999999999999999999413486757355975699865734602616151727, 1000000000000000000000000000000000000000000000000000000000000", + "rejected_by": "kappa.two_impl" + }, + { + "control": "prediction started from a C above the root", + "expected": "kappa.predict", + "message": "kappa.predict: initial bracket", + "rejected_by": "kappa.predict" + }, + { + "control": "profile with a negative count", + "expected": "kappa.profile", + "message": "kappa.profile: rank 1 count -1", + "rejected_by": "kappa.profile" + }, + { + "control": "profile with a rank-73 child", + "expected": "kappa.profile", + "message": "kappa.profile: rank 73 count 1", + "rejected_by": "kappa.profile" + } + ], + "pricing": [ + { + "control": "fill with one legal re-hosting (top slice of bin (1, 13, 110) (width 9) moved to the empty bin (1, 13, 0); R-a..R-e pass in both implementations): PROFILE.json", + "expected": "fill.profile_file", + "legal_fill_rules_passed": true, + "message": "fill.profile_file: complete profile {'1': 1644348, '2': 470862, '3': 159467, '4': 71928, '5': 13716, '8': 5328, '12': 1, '39': 1, '48': 28189} != {'1': 1644348,", + "rejected_by": "fill.profile_file" + }, + { + "control": "fill with one legal re-hosting: idle remainders against PR2979", + "expected": "fill.idle", + "message": "fill.idle: idle remainders differ", + "rejected_by": "fill.idle" + }, + { + "control": "fill_check80 result of the re-hosted fill against check_rows of the published fill", + "expected": "fill.two_impl", + "message": "fill.two_impl: fill_check80 idle/profile/mass != check_rows", + "rejected_by": "fill.two_impl" + }, + { + "control": "the fill priced with the parent words' recounts against PR3015's CLAIM profile", + "expected": "fill.profile_claim", + "message": "fill.profile_claim: complete profile {'1': 1645680, '2': 470196, '3': 159468, '4': 71928, '5': 13716, '8': 5328, '48': 28190} != {'1': 1644348, '2': 470862, '3'", + "rejected_by": "fill.profile_claim" + }, + { + "control": "PROFILE.json with one more rank-48 child", + "expected": "fill.profile_file", + "message": "fill.profile_file: complete profile {'1': 1644348, '2': 470862, '3': 159468, '4': 71928, '5': 13716, '8': 5328, '48': 28190} != {'1': 1644348, '2': 470862, '3':", + "rejected_by": "fill.profile_file" + }, + { + "control": "complete profile with one more rank-1 child: rank mass", + "expected": "fill.mass", + "message": "fill.mass: rank mass 4816513 != 72W + 64N", + "rejected_by": "fill.mass" + }, + { + "control": "parent against parent with the R1 local delta: complete delta", + "expected": "fill.delta", + "message": "fill.delta: complete delta {} != 666 x {1: -2, 2: 1}", + "rejected_by": "fill.delta" + }, + { + "control": "complete delta against the local delta with the wrong sign", + "expected": "fill.delta", + "message": "fill.delta: complete delta {1: -1332, 2: 666} != 666 x {1: 2, 2: -1}", + "rejected_by": "fill.delta" + }, + { + "control": "CLAIM with 90 private buffers and the stock lowered by one", + "expected": "fill.physical", + "message": "fill.physical: own 66813 = {'live': 66304, 'helpers': 408, 'centres': 8, 'private_buffers': 91, 'coefficient': 2} != CLAIM {'live_families': 66304, 'helpers': 4", + "rejected_by": "fill.physical" + }, + { + "control": "physical stock from one private buffer fewer than the CLAIM", + "expected": "fill.physical", + "message": "fill.physical: own 66812 = {'live': 66304, 'helpers': 408, 'centres': 8, 'private_buffers': 90, 'coefficient': 2} != CLAIM {'live_families': 66304, 'helpers': 4", + "rejected_by": "fill.physical" + }, + { + "control": "dispatch with its last entry dropped", + "expected": "fill.dispatch", + "message": "fill.dispatch: dispatch does not cover the 666 calls once with known providers", + "rejected_by": "fill.dispatch" + }, + { + "control": "recount with the first helper width raised by one against the word", + "expected": "fill.widths", + "message": "fill.widths: word widths != recount (gauge44)", + "rejected_by": "fill.widths" + }, + { + "control": "vendored implementation's profile given one more rank-1 child before the comparison", + "expected": "fill.two_impl", + "message": "fill.two_impl: fill_check80 idle/profile/mass != check_rows", + "rejected_by": "fill.two_impl" + }, + { + "control": "FILL with its columns reordered", + "expected": "fill.format", + "message": "fill.format: columns/overrides", + "rejected_by": "fill.format" + }, + { + "control": "per-replica stage inversion (replica 5)", + "expected": "order.projection", + "message": "order.projection: stage order of replica 5", + "rejected_by": "order.projection" + }, + { + "control": "block-rule windows of the order against the event-rule windows of the order swapped at 9", + "expected": "windows.block_vs_event", + "message": "windows.block_vs_event: block rule != fill_check80 event-position rule", + "rejected_by": "windows.block_vs_event" + }, + { + "control": "template bridge event 3 given a cross-replica field", + "expected": "template.cross_replica_field", + "message": "template.cross_replica_field: per-replica event 'bridge' names a replica", + "rejected_by": "template.cross_replica_field" + } + ], + "vendor_pins": [ + { + "control": "vendored vendor/pr2315/words_check.py with one comment line appended (in memory)", + "expected": "VendorPinMismatch", + "message": "vendored file does not match its pin: vendor/pr2315/words_check.py (git blob a4f1fde4b5633a0c2f0131e2cf9575373659e8ea, s", + "rejected_by": "VendorPinMismatch" + }, + { + "control": "vendored vendor/pr2387/fill_check80.py with one comment line appended (in memory)", + "expected": "VendorPinMismatch", + "message": "vendored file does not match its pin: vendor/pr2387/fill_check80.py (git blob 8762dfc22294f5498afd5d9b149c1e9586d626f3, ", + "rejected_by": "VendorPinMismatch" + }, + { + "control": "vendored vendor/pr2804/audit_common.py with one comment line appended (in memory)", + "expected": "VendorPinMismatch", + "message": "vendored file does not match its pin: vendor/pr2804/audit_common.py (git blob 22e606201e8d29a25ee2cfaeb158334f8352ad41, ", + "rejected_by": "VendorPinMismatch" + }, + { + "control": "vendored vendor/pr2804/check_accounting.py with one comment line appended (in memory)", + "expected": "VendorPinMismatch", + "message": "vendored file does not match its pin: vendor/pr2804/check_accounting.py (git blob a5bd280ce36a751c8644dc382542963d6565b7", + "rejected_by": "VendorPinMismatch" + }, + { + "control": "vendored vendor/pr2804/check_fill.py with one comment line appended (in memory)", + "expected": "VendorPinMismatch", + "message": "vendored file does not match its pin: vendor/pr2804/check_fill.py (git blob 9fcacf6f80a8669a9ab9ca7b4f6b485067698bdf, sh", + "rejected_by": "VendorPinMismatch" + }, + { + "control": "vendored vendor/pr2804/check_words.py with one comment line appended (in memory)", + "expected": "VendorPinMismatch", + "message": "vendored file does not match its pin: vendor/pr2804/check_words.py (git blob a2dd2c810ffa75b86587ae10e3e79facbb88db1e, s", + "rejected_by": "VendorPinMismatch" + }, + { + "control": "vendored vendor/pr2865/audit_lib.py with one comment line appended (in memory)", + "expected": "VendorPinMismatch", + "message": "vendored file does not match its pin: vendor/pr2865/audit_lib.py (git blob 0870c6eeb15ca6be0f6b9564a20dbdc2967791c5, sha", + "rejected_by": "VendorPinMismatch" + } + ], + "words": [ + { + "control": "[base] cleanup prepended with helper 224 += zero buffer 930 (forward replay and own tracker accept): word pipeline, rejected by the dual replay", + "expected": "wc.replay", + "forward_and_tracker_accept": true, + "message": "a zero buffer is not returned to zero", + "rejected_by": "wc.replay", + "stage": "dual replay, buffers after cleanup" + }, + { + "control": "[base] report local_profile with one more rank-1 child", + "expected": "words.report_fields", + "message": "words.report_fields: report {1: 2444, 2: 707, 3: 232, 4: 108, 5: 18, 8: 8} {4: 26, 5: 2, 6: 16, 7: 52, 8: 99, 9: 213} != recount {1: 2443, 2: 707, 3: 232, 4: 10", + "rejected_by": "words.report_fields" + }, + { + "control": "[base] report width_inventory with one width-9 helper counted as width 8", + "expected": "words.report_fields", + "message": "words.report_fields: report {1: 2443, 2: 707, 3: 232, 4: 108, 5: 18, 8: 8} {4: 26, 5: 2, 6: 16, 7: 52, 8: 100, 9: 212} != recount {1: 2443, 2: 707, 3: 232, 4: 1", + "rejected_by": "words.report_fields" + }, + { + "control": "[base] candidate recount against the parent's declared profile", + "expected": "words.declared", + "message": "words.declared: recount {1: 2443, 2: 707, 3: 232, 4: 108, 5: 18, 8: 8} {4: 26, 5: 2, 6: 16, 7: 52, 8: 99, 9: 213} != declared {1: 2445, 2: 706, 3: 232, 4: 108, ", + "rejected_by": "words.declared" + }, + { + "control": "[base] restore gate 100 dropped, report forged, cleanup re-derived: forward replay", + "expected": "wc.replay", + "message": "restored inputs still read by [416]", + "rejected_by": "wc.replay", + "stage": "forward replay, before cleanup" + }, + { + "control": "[base] restore gate 100 dropped, report forged, cleanup re-derived: own tracker", + "expected": "words.tracker", + "message": "words.tracker: final identity after cleanup", + "rejected_by": "words.tracker" + }, + { + "control": "[base] first cleanup item at a rank-8 frame", + "expected": "words.cleanup", + "message": "words.cleanup: an item is not at FULL", + "rejected_by": "words.cleanup" + }, + { + "control": "[base] first cleanup item dropped: literal cleanup check", + "expected": "words.cleanup", + "message": "words.cleanup: the literal cleanup is not the own inverse-reverse re-derivation", + "rejected_by": "words.cleanup" + }, + { + "control": "[base] helper_final endpoint 226 removed, cleanup kept (its buffer is no longer declared)", + "expected": "wc.frame", + "message": "cleanup touches non-FULL 930", + "rejected_by": "wc.frame", + "stage": "frame recount" + }, + { + "control": "[base] expected helper count 409", + "expected": "words.counts", + "message": "words.counts: {'live': 632, 'helpers': 408, 'buffers': 91, 'warps': 72, 'corrections': 36} != {'live': 632, 'helpers': 409, 'buffers': 91, 'warps': 72, 'correct", + "rejected_by": "words.counts" + }, + { + "control": "[extra] cleanup prepended with helper 224 += zero buffer 930 (forward replay and own tracker accept): word pipeline, rejected by the dual replay", + "expected": "wc.replay", + "forward_and_tracker_accept": true, + "message": "a zero buffer is not returned to zero", + "rejected_by": "wc.replay", + "stage": "dual replay, buffers after cleanup" + }, + { + "control": "[extra] report local_profile with one more rank-1 child", + "expected": "words.report_fields", + "message": "words.report_fields: report {1: 2444, 2: 707, 3: 232, 4: 108, 5: 18, 8: 8} {4: 26, 5: 2, 6: 16, 7: 52, 8: 99, 9: 213} != recount {1: 2443, 2: 707, 3: 232, 4: 10", + "rejected_by": "words.report_fields" + }, + { + "control": "[extra] report width_inventory with one width-9 helper counted as width 8", + "expected": "words.report_fields", + "message": "words.report_fields: report {1: 2443, 2: 707, 3: 232, 4: 108, 5: 18, 8: 8} {4: 26, 5: 2, 6: 16, 7: 52, 8: 100, 9: 212} != recount {1: 2443, 2: 707, 3: 232, 4: 1", + "rejected_by": "words.report_fields" + }, + { + "control": "[extra] candidate recount against the parent's declared profile", + "expected": "words.declared", + "message": "words.declared: recount {1: 2443, 2: 707, 3: 232, 4: 108, 5: 18, 8: 8} {4: 26, 5: 2, 6: 16, 7: 52, 8: 99, 9: 213} != declared {1: 2445, 2: 706, 3: 232, 4: 108, ", + "rejected_by": "words.declared" + }, + { + "control": "[extra] restore gate 100 dropped, report forged, cleanup re-derived: forward replay", + "expected": "wc.replay", + "message": "restored inputs still read by [416]", + "rejected_by": "wc.replay", + "stage": "forward replay, before cleanup" + }, + { + "control": "[extra] restore gate 100 dropped, report forged, cleanup re-derived: own tracker", + "expected": "words.tracker", + "message": "words.tracker: final identity after cleanup", + "rejected_by": "words.tracker" + }, + { + "control": "[extra] first cleanup item at a rank-8 frame", + "expected": "words.cleanup", + "message": "words.cleanup: an item is not at FULL", + "rejected_by": "words.cleanup" + }, + { + "control": "[extra] first cleanup item dropped: literal cleanup check", + "expected": "words.cleanup", + "message": "words.cleanup: the literal cleanup is not the own inverse-reverse re-derivation", + "rejected_by": "words.cleanup" + }, + { + "control": "[extra] helper_final endpoint 226 removed, cleanup kept (its buffer is no longer declared)", + "expected": "wc.frame", + "message": "cleanup touches non-FULL 930", + "rejected_by": "wc.frame", + "stage": "frame recount" + }, + { + "control": "[extra] expected helper count 409", + "expected": "words.counts", + "message": "words.counts: {'live': 632, 'helpers': 408, 'buffers': 91, 'warps': 72, 'corrections': 36} != {'live': 632, 'helpers': 409, 'buffers': 91, 'warps': 72, 'correct", + "rejected_by": "words.counts" + } + ] + }, + "facts": { + "pr2979_template_equals_t37_inputs_template": true, + "pr3015_parent_words_equal_pr2979": true + }, + "git_env": { + "policy": "GIT_CONFIG* removed from the process environment before the first git call; every git subprocess runs without the repository-redirecting GIT_* variables and with GIT_NO_REPLACE_OBJECTS=1 and GIT_NO_LAZY_FETCH=1; the only write is --fetch into refs/audit/prN (audit_common)", + "selftest": { + "kept_in_selftest": [ + "GIT_NO_REPLACE_OBJECTS", + "HOME", + "PATH" + ], + "removed_in_selftest": [ + "GIT_CONFIG", + "GIT_CONFIG_COUNT", + "GIT_CONFIG_GLOBAL", + "GIT_CONFIG_KEY_0", + "GIT_CONFIG_NOSYSTEM", + "GIT_CONFIG_PARAMETERS", + "GIT_CONFIG_SYSTEM", + "GIT_CONFIG_VALUE_0" + ] + } + }, + "harness_selftest": { + "accepted_raises": true, + "wrong_attrs_raises": true, + "wrong_rule_raises": true + }, + "inputs": { + "claim2979": { + "bytes": 5750, + "commit": "be191346391661f4d35fc0d1508d0a6029572576", + "git_blob": "8ec2ce4e440c0b584ee982c551e526a011c9324c", + "path": "research/rank7-joint-endframes/CLAIM.json", + "pr": 2979, + "sha256": "436e0d297cbdf195445d3697d496ac675e95210b79e70ce602a6a6667a4c6ce9" + }, + "claim3015": { + "bytes": 7138, + "commit": "e244296debb45fe6f4da84d29e4d64fbab55fda0", + "git_blob": "70813f559e2878f0c5403c0b859eefe602f70abc", + "path": "research/rank7-joint-endframes-restore-edit/CLAIM.json", + "pr": 3015, + "sha256": "f9b9fbaaac794c0ce279c238a33a2f34f8c91a34d97ccdeb5ec98b7b8ba56d73" + }, + "claim3021": { + "bytes": 2141, + "commit": "217edac2ebfa6250536bd6df153de14901a69395", + "git_blob": "a8d657563624b98d8bb238878a6c20fa74a1f593", + "path": "research/rank7-restore-packing-composition/evidence/OUTER-CLAIM.json", + "pr": 3021, + "sha256": "8beb062c36169728a8f82a5eda6638c2a83125f16e7e5de56f3a13d9cba5e1f5" + }, + "composition3021": { + "bytes": 3481, + "commit": "217edac2ebfa6250536bd6df153de14901a69395", + "git_blob": "399bcc26f0684cced978e3a4c90f834551f62dd7", + "path": "research/rank7-restore-packing-composition/evidence/COMPOSITION-RESULT.json", + "pr": 3021, + "sha256": "cdc4874dcb17714fbe10f003a4a4516b80a9ddccfc7199278a53baa13c5d3a04" + }, + "dispatch2979": { + "bytes": 10401, + "commit": "be191346391661f4d35fc0d1508d0a6029572576", + "git_blob": "9544fee4e6ee1f202cee22bfaeaf229ee3b2515e", + "path": "research/rank7-joint-endframes/allocation/DISPATCH.json", + "pr": 2979, + "sha256": "65e435bd68e97243c003677271b88485a29d4d0fae2dff1354100404a145e74c" + }, + "edits3015": { + "bytes": 2429, + "commit": "e244296debb45fe6f4da84d29e4d64fbab55fda0", + "git_blob": "90894fc6592951eaa3b4e25467d3a85c36b2d988", + "path": "research/rank7-joint-endframes-restore-edit/edits/EDITS.json", + "pr": 3015, + "sha256": "c9c68660d07bfd12ed20fd8cbfe3d36301ceb2d7bb9b4ea11350cc399b19e0b1" + }, + "exchange3018": { + "bytes": 6637, + "commit": "ca7113157d7c959fdfa9d7cd17ef92d3877070d0", + "git_blob": "1260c8d95f573a574e007038263adf883b5ecbd2", + "path": "research/rank7-integrality-exchange/EXCHANGE.json", + "pr": 3018, + "sha256": "8a103f643ad12d8074972f41e4359d9487eb8b96fc6849e1a178adb61b36578b" + }, + "fill2979": { + "bytes": 1347458, + "commit": "be191346391661f4d35fc0d1508d0a6029572576", + "git_blob": "8d4fd644d60ba2c98106dc770803b647afdf0963", + "path": "research/rank7-joint-endframes/allocation/FILL.json.gz", + "pr": 2979, + "sha256": "c2136be9434cda511a1a8a44d98f9f72ea5376830a8426674253b4ee351c4c39" + }, + "finite3021": { + "bytes": 4124, + "commit": "217edac2ebfa6250536bd6df153de14901a69395", + "git_blob": "6f73992ff764a3d527d4fd551057dc6fa254127e", + "path": "research/rank7-restore-packing-composition/evidence/FINITE.json", + "pr": 3021, + "sha256": "f7f6aca1e2596d7049ff2bc69c523013324f568f86fd31b1f29899b96b2617eb" + }, + "order2979": { + "bytes": 4573, + "commit": "be191346391661f4d35fc0d1508d0a6029572576", + "git_blob": "7409c4df1092241729739596c7648bda504e6aad", + "path": "research/rank7-joint-endframes/allocation/ORDER.json", + "pr": 2979, + "sha256": "519d1d5dbb997a219fcfcad34c0b03e7838bef24199784d7e964fa10090f66e1" + }, + "profile2979": { + "bytes": 104, + "commit": "be191346391661f4d35fc0d1508d0a6029572576", + "git_blob": "46a83eeda67ab67cccbffe8b7ad8e44368b40ea7", + "path": "research/rank7-joint-endframes/allocation/PROFILE.json", + "pr": 2979, + "sha256": "94a819747f3ced41f1544ada0036c983fc0c92847b9644380f877a06cd7931cf" + }, + "profile3015": { + "bytes": 104, + "commit": "e244296debb45fe6f4da84d29e4d64fbab55fda0", + "git_blob": "05766f448600d2f94699f42818aa8150f49fd934", + "path": "research/rank7-joint-endframes-restore-edit/allocation/PROFILE.json", + "pr": 3015, + "sha256": "5626c44edd6d5b209cd4e2d2a824e07bfba696e0856f3964b81fcb01c78eaad8" + }, + "pw3015_base": { + "bytes": 71422, + "commit": "e244296debb45fe6f4da84d29e4d64fbab55fda0", + "git_blob": "d9aa96a93fea5f7395e7783aef0bc117c0a0ae89", + "path": "research/rank7-joint-endframes-restore-edit/data/WORD-base.json.gz", + "pr": 3015, + "sha256": "abaf67bfcb257528658c906b612f57025617592bd7889828f92b97a5f4f4300d" + }, + "pw3015_extra": { + "bytes": 71419, + "commit": "e244296debb45fe6f4da84d29e4d64fbab55fda0", + "git_blob": "74f6cb64595c21f7726ae77e69437868620bdcee", + "path": "research/rank7-joint-endframes-restore-edit/data/WORD-extra.json.gz", + "pr": 3015, + "sha256": "e0eaf64c4d5d324693d43889bce1b9e53e8da00402105c8c978fd102f208bed7" + }, + "result3018": { + "bytes": 4381, + "commit": "ca7113157d7c959fdfa9d7cd17ef92d3877070d0", + "git_blob": "b5b527781e2c1e03e11648727d930ab7cb5f8fa8", + "path": "research/rank7-integrality-exchange/RESULT.json", + "pr": 3018, + "sha256": "a9191f711b50476312c222a47f33d7b72a4ac26fdd190ec58b38889986f39b24" + }, + "t37_2269": { + "bytes": 1124331, + "commit": "b479fc5567bc09ab9185bffe89b62594f36d74e5", + "git_blob": "114808c32b1799da53524bdc25cea67efb60009e", + "path": "research/gmx-t74-borrow43/inputs/GLOBAL-TEMPLATE.json.gz", + "pr": 2269, + "sha256": "21297b20f1f2dc76eb9dd8124416068c3cb096bab9df17fa4da19bc68dfe082e" + }, + "template2979": { + "bytes": 1124331, + "commit": "be191346391661f4d35fc0d1508d0a6029572576", + "git_blob": "114808c32b1799da53524bdc25cea67efb60009e", + "path": "research/rank7-joint-endframes/allocation/vendor/TEMPLATE.json.gz", + "pr": 2979, + "sha256": "21297b20f1f2dc76eb9dd8124416068c3cb096bab9df17fa4da19bc68dfe082e" + }, + "tpl2269": { + "bytes": 2055625, + "commit": "b479fc5567bc09ab9185bffe89b62594f36d74e5", + "git_blob": "5327fc2f4e8ea82ed356c94ff040d23fc73c731f", + "path": "research/gmx-t74-borrow43/GLOBAL-TEMPLATE.json.gz", + "pr": 2269, + "sha256": "1d31424c4e27e26a35a9932ca778e43f1f3577589275422cc642aa68b31112db" + }, + "w2979_base": { + "bytes": 71422, + "commit": "be191346391661f4d35fc0d1508d0a6029572576", + "git_blob": "d9aa96a93fea5f7395e7783aef0bc117c0a0ae89", + "path": "research/rank7-joint-endframes/data/WORD-base.json.gz", + "pr": 2979, + "sha256": "abaf67bfcb257528658c906b612f57025617592bd7889828f92b97a5f4f4300d" + }, + "w2979_extra": { + "bytes": 71419, + "commit": "be191346391661f4d35fc0d1508d0a6029572576", + "git_blob": "74f6cb64595c21f7726ae77e69437868620bdcee", + "path": "research/rank7-joint-endframes/data/WORD-extra.json.gz", + "pr": 2979, + "sha256": "e0eaf64c4d5d324693d43889bce1b9e53e8da00402105c8c978fd102f208bed7" + }, + "w3015_base": { + "bytes": 71434, + "commit": "e244296debb45fe6f4da84d29e4d64fbab55fda0", + "git_blob": "4f0483657396a7f735873e1b252482c53dfb2eb6", + "path": "research/rank7-joint-endframes-restore-edit/edits/FINAL-WORD-base.json.gz", + "pr": 3015, + "sha256": "77d9be7ac47347894e034d8b67bf07ff8a5e1c317923ed5dd9257c492187dcf5" + }, + "w3015_extra": { + "bytes": 71430, + "commit": "e244296debb45fe6f4da84d29e4d64fbab55fda0", + "git_blob": "81f95e21ede115e8bdb6bd522c641b37b740bdf7", + "path": "research/rank7-joint-endframes-restore-edit/edits/FINAL-WORD-extra.json.gz", + "pr": 3015, + "sha256": "18d9c448ce892aa19f162e214760d0bd4ecb09f814b9b859dbf11f3ca637e9ea" + } + }, + "journal": { + "composed_endpoint_predicted": "0.001729151203983018442998", + "composed_gain_over_pr3015": "2.3045e-10", + "composed_gain_over_pr3018": "1.1699e-07", + "composed_kappa_predicted": "0.0017291512039830184429979999999999999999999998999999999999999999999999", + "composed_profile": { + "1": 1644352, + "14": 1, + "2": 470862, + "3": 159472, + "4": 71928, + "48": 28190, + "5": 13710, + "8": 5328 + }, + "journal": { + "edits": 103, + "location_changes": 44, + "offset_only_changes": 59, + "rows_changed": 103 + }, + "pr3018_delta_vs_pr2979": { + "1": 4, + "14": 1, + "3": 4, + "5": -6 + }, + "pr3018_endpoint_predicted": "0.001729034213064256309510", + "pr3018_kappa_predicted": "0.0017290342130642563095099999999999999999999998999999999999999999999999", + "pr3018_new_root_bracket": [ + "0.0017290342130642563095108", + "0.0017290342130642563095109" + ], + "pr3018_profile": { + "1": 1645684, + "14": 1, + "2": 470196, + "3": 159472, + "4": 71928, + "48": 28190, + "5": 13710, + "8": 5328 + }, + "pr3021": { + "gain_over_pr3015": "230448794014303/1000000000000000000000000", + "head": "217edac2ebfa6250536bd6df153de14901a69395", + "idle_physical_roles_equal": true, + "kappa": "0.0017291512039830184429979999999999999999999998999999999999999999999999", + "new_root": [ + "0.0017291512039830184429986", + "0.0017291512039830184429987" + ], + "profile_equal": true + }, + "status": "The composition of PR3015's words with PR3018's journal was computed here as a prediction (about 2026-10-16 18:40 UTC, before this package had read PR3021, which was published at 18:21 UTC and has priority) and equals PR3021's published finite records (profile, idle, physical, roles, kappa, gain; its root bracket lies in [C, C + 1e-24)); PR3021's native/admission/outer release is author-run and not rerun here." + }, + "kappa": { + "C": "0.001729150973534224428695", + "C_pr2979": "0.001729033982646513517717", + "census_improving": { + "base": { + "candidate": [], + "parent": [ + [ + 178, + 61, + 63 + ], + [ + 178, + 63, + 61 + ] + ] + }, + "extra": { + "candidate": [], + "parent": [ + [ + 178, + 61, + 63 + ], + [ + 178, + 63, + 61 + ] + ] + } + }, + "census_losing_only": { + "base": { + "candidate": 10, + "parent": 12 + }, + "extra": { + "candidate": 10, + "parent": 12 + } + }, + "census_prices_per_call_delta": { + "{\"1\":-2,\"2\":1}": [ + "-3.3209e-07", + "-3.3209e-07", + true + ], + "{\"1\":2,\"2\":-1}": [ + "3.3209e-07", + "3.3209e-07", + false + ], + "{\"1\":4,\"2\":-2}": [ + "6.6419e-07", + "6.6419e-07", + false + ] + }, + "endpoint_own": { + "C_enclosure_width": "2.00e-60", + "C_moment_minus_1": [ + "-5.865132426e-25", + "-5.865132426e-25" + ], + "C_plus_1e24_moment_minus_1": [ + "2.251929986e-24", + "2.251929986e-24" + ] + }, + "endpoint_predicted_from_profile": "0.001729150973534224428695", + "endpoint_vendored": { + "C_enclosure_width": "2.66e-191", + "C_moment_minus_1": [ + "-5.865132426e-25", + "-5.865132426e-25" + ], + "C_plus_1e24_moment_minus_1": [ + "2.251929986e-24", + "2.251929986e-24" + ] + }, + "gain_over_pr2979": { + "gain": "58495443855455489/500000000000000000000000", + "gain_float": "1.169909e-07" + }, + "kappa": "17291509735342244286949999999999999999999998999999999999999999999999/10000000000000000000000000000000000000000000000000000000000000000000000", + "kappa_decimal_70": "0.0017291509735342244286949999999999999999999998999999999999999999999999", + "passed": [ + "kappa.endpoint_format", + "kappa.endpoint_accept", + "kappa.endpoint_reject", + "kappa.two_impl", + "kappa.kappa", + "kappa.gain", + "kappa.improvement", + "kappa.root_bracket", + "kappa.predict" + ], + "root_bracket": { + "lower": "0.001729150973534224428695206632014575010163935", + "upper": "0.001729150973534224428695206632014575010163935", + "width": "3.01e-60" + }, + "root_bracket_vendored": { + "lower": "0.001729150973534224428695206632014575010163935122054509638034", + "upper": "0.001729150973534224428695206632014575010163935122054509638034", + "width": "3.39e-191" + }, + "two_implementations": { + "at_C": { + "intersect": true, + "own": [ + "-5.865e-25", + "-5.865e-25" + ], + "vendored": [ + "-5.865e-25", + "-5.865e-25" + ] + }, + "at_C_plus": { + "intersect": true, + "own": [ + "2.252e-24", + "2.252e-24" + ], + "vendored": [ + "2.252e-24", + "2.252e-24" + ] + } + } + }, + "positive_controls": [ + "PR2979 base word through the word pipeline with its CLAIM local profile", + "the census on the parent word finds the R1 pair with the delta -2H1+H2 (both carriers)", + "PR2979 extra word through the word pipeline with its CLAIM local profile", + "PR2979 fill with the parent recounts gives PR2979's PROFILE.json and CLAIM profile", + "PR2979's C accepted and C + 1e-24 rejected on its profile (own and vendored enclosures)", + "PR3018's journal on PR2979's fill gives PR3018's RESULT profile (two implementations)", + "the 24-digit endpoint predicted from the journaled profile is the grid point below PR3018's new_root bracket (bracket in [C, C + 1e-24))", + "the composed profile, endpoint, kappa and gain computed here equal PR3021's published FINITE/OUTER-CLAIM/COMPOSITION records" + ], + "pricing": { + "complete_delta_vs_pr2979": { + "1": -1332, + "2": 666 + }, + "dispatch": { + "extra": 416, + "gauge44": 250 + }, + "idle_identical_to_pr2979": true, + "physical": { + "physical": 66813, + "terms": { + "centres": 8, + "coefficient": 2, + "helpers": 408, + "live": 66304, + "private_buffers": 91 + } + }, + "pr2979": { + "bins": 149184, + "capacity": 3580416, + "cross_replica_roles": 251358, + "deficit": 23680, + "helpers": 408, + "hosted_width": 2186478, + "idle": { + "1": 17310, + "3": 4956, + "48": 28190, + "5": 1728 + }, + "occupied_bins": 120994, + "private_buffers": 91, + "profile": { + "1": 1645680, + "2": 470196, + "3": 159468, + "4": 71928, + "48": 28190, + "5": 13716, + "8": 5328 + }, + "rank_mass": 4816512, + "roles": 271728, + "two_impl": { + "idle_equal": true, + "profile_equal": true, + "rank_mass_equal": true, + "roles": 271728 + }, + "vendored_fill_check80": { + "idle": { + "1": 17310, + "3": 4956, + "48": 28190, + "5": 1728 + }, + "profile": { + "1": 1645680, + "2": 470196, + "3": 159468, + "4": 71928, + "48": 28190, + "5": 13716, + "8": 5328 + }, + "rank_mass": 4816512, + "roles": 271728 + } + }, + "pr3015": { + "bins": 149184, + "capacity": 3580416, + "cross_replica_roles": 251358, + "deficit": 23680, + "helpers": 408, + "hosted_width": 2186478, + "idle": { + "1": 17310, + "3": 4956, + "48": 28190, + "5": 1728 + }, + "occupied_bins": 120994, + "private_buffers": 91, + "profile": { + "1": 1644348, + "2": 470862, + "3": 159468, + "4": 71928, + "48": 28190, + "5": 13716, + "8": 5328 + }, + "rank_mass": 4816512, + "roles": 271728, + "two_impl": { + "idle_equal": true, + "profile_equal": true, + "rank_mass_equal": true, + "roles": 271728 + }, + "vendored_fill_check80": { + "idle": { + "1": 17310, + "3": 4956, + "48": 28190, + "5": 1728 + }, + "profile": { + "1": 1644348, + "2": 470862, + "3": 159468, + "4": 71928, + "48": 28190, + "5": 13716, + "8": 5328 + }, + "rank_mass": 4816512, + "roles": 271728 + } + }, + "rank_mass": 4816512, + "schedule": { + "calls": 666, + "child_ranks": { + "16": 4, + "32": 4, + "48": 4, + "8": 6 + }, + "per_replica_events": 30, + "t37_events_recipe_ranks_equal": true, + "windows": 1332, + "windows_sha256": "5c004fdb309cae5b62cf79cba6326bca22f5a5aaf2bb578273fc16b32fbf7ee4" + } + }, + "schema": 1, + "scope_a": { + "base": { + "attribution": { + "climbs": { + "230": { + "candidate": [ + [ + "A", + 1879, + 0, + 1 + ], + [ + "A", + 1921, + 1, + 2 + ], + [ + "A", + 1931, + 2, + 3 + ], + [ + "B", + 608, + 3, + 5 + ], + [ + "B", + 1291, + 5, + 6 + ], + [ + "post", + 24, + 6, + 7 + ], + [ + "post", + 184, + 7, + 8 + ] + ], + "parent": [ + [ + "A", + 1879, + 0, + 1 + ], + [ + "A", + 1921, + 1, + 2 + ], + [ + "A", + 1931, + 2, + 3 + ], + [ + "B", + 608, + 3, + 5 + ], + [ + "B", + 1291, + 5, + 6 + ], + [ + "post", + 24, + 6, + 7 + ], + [ + "post", + 183, + 7, + 8 + ] + ] + }, + "363": { + "candidate": [ + [ + "A", + 3118, + 0, + 1 + ], + [ + "A", + 3161, + 1, + 2 + ], + [ + "B", + 671, + 2, + 3 + ], + [ + "B", + 799, + 3, + 4 + ], + [ + "B", + 823, + 4, + 5 + ], + [ + "post", + 60, + 5, + 7 + ], + [ + "post", + 192, + 7, + 8 + ] + ], + "parent": [ + [ + "A", + 3118, + 0, + 1 + ], + [ + "A", + 3161, + 1, + 2 + ], + [ + "B", + 671, + 2, + 3 + ], + [ + "B", + 799, + 3, + 4 + ], + [ + "B", + 823, + 4, + 5 + ], + [ + "post", + 60, + 5, + 7 + ], + [ + "post", + 191, + 7, + 8 + ] + ] + }, + "395": { + "candidate": [ + [ + "A", + 3426, + 0, + 1 + ], + [ + "A", + 3469, + 1, + 2 + ], + [ + "B", + 723, + 2, + 3 + ], + [ + "B", + 809, + 3, + 4 + ], + [ + "B", + 825, + 4, + 5 + ], + [ + "post", + 74, + 5, + 7 + ], + [ + "post", + 198, + 7, + 8 + ] + ], + "parent": [ + [ + "A", + 3426, + 0, + 1 + ], + [ + "A", + 3469, + 1, + 2 + ], + [ + "B", + 723, + 2, + 3 + ], + [ + "B", + 809, + 3, + 4 + ], + [ + "B", + 825, + 4, + 5 + ], + [ + "post", + 74, + 5, + 7 + ], + [ + "post", + 197, + 7, + 8 + ] + ] + }, + "5": { + "candidate": [ + [ + "A", + 3453, + 1, + 2 + ], + [ + "B", + 726, + 2, + 3 + ], + [ + "B", + 810, + 3, + 4 + ], + [ + "B", + 826, + 4, + 5 + ], + [ + "post", + 75, + 5, + 7 + ], + [ + "post", + 197, + 7, + 8 + ], + [ + "end", + 0, + 8, + 9 + ] + ], + "parent": [ + [ + "A", + 3453, + 1, + 2 + ], + [ + "B", + 726, + 2, + 3 + ], + [ + "B", + 810, + 3, + 4 + ], + [ + "B", + 826, + 4, + 5 + ], + [ + "post", + 75, + 5, + 7 + ], + [ + "post", + 196, + 7, + 8 + ], + [ + "end", + 0, + 8, + 9 + ] + ] + }, + "61": { + "candidate": [ + [ + "A", + 2221, + 1, + 2 + ], + [ + "A", + 2243, + 2, + 3 + ], + [ + "A", + 2245, + 3, + 4 + ], + [ + "A", + 2334, + 4, + 7 + ], + [ + "post", + 179, + 7, + 8 + ], + [ + "post", + 180, + 8, + 9 + ] + ], + "parent": [ + [ + "A", + 2221, + 1, + 2 + ], + [ + "A", + 2243, + 2, + 3 + ], + [ + "A", + 2245, + 3, + 4 + ], + [ + "A", + 2334, + 4, + 7 + ], + [ + "post", + 178, + 7, + 8 + ], + [ + "end", + 0, + 8, + 9 + ] + ] + }, + "63": { + "candidate": [ + [ + "A", + 2067, + 1, + 2 + ], + [ + "A", + 2089, + 2, + 3 + ], + [ + "A", + 2091, + 3, + 4 + ], + [ + "A", + 2180, + 4, + 7 + ], + [ + "post", + 180, + 7, + 9 + ] + ], + "parent": [ + [ + "A", + 2067, + 1, + 2 + ], + [ + "A", + 2089, + 2, + 3 + ], + [ + "A", + 2091, + 3, + 4 + ], + [ + "A", + 2180, + 4, + 7 + ], + [ + "post", + 179, + 7, + 8 + ], + [ + "end", + 0, + 8, + 9 + ] + ] + }, + "73": { + "candidate": [ + [ + "A", + 3145, + 1, + 2 + ], + [ + "B", + 674, + 2, + 3 + ], + [ + "B", + 800, + 3, + 4 + ], + [ + "B", + 824, + 4, + 5 + ], + [ + "post", + 63, + 5, + 7 + ], + [ + "post", + 191, + 7, + 8 + ], + [ + "end", + 0, + 8, + 9 + ] + ], + "parent": [ + [ + "A", + 3145, + 1, + 2 + ], + [ + "B", + 674, + 2, + 3 + ], + [ + "B", + 800, + 3, + 4 + ], + [ + "B", + 824, + 4, + 5 + ], + [ + "post", + 63, + 5, + 7 + ], + [ + "post", + 190, + 7, + 8 + ], + [ + "end", + 0, + 8, + 9 + ] + ] + } + }, + "dimensions_changed": [ + 63 + ], + "labels_only_moved": [ + 5, + 61, + 73, + 230, + 363, + 395 + ], + "paid_delta": { + "1": -2, + "2": 1 + } + }, + "diff": { + "cleanup_lengths": { + "candidate": 5208, + "parent": 5207 + }, + "declared": { + "new_gates": 3, + "old_gates": 2, + "section": "restore", + "start": 178, + "stop": 180 + }, + "minimal_hunk": { + "candidate": [ + 178, + 181 + ], + "parent": [ + 178, + 180 + ] + }, + "restore_lengths": { + "candidate": 204, + "parent": 203 + }, + "sections_differing": [ + "cleanup", + "report", + "restore" + ], + "touched_registers": [ + 22, + 61, + 63 + ] + }, + "first_new_frame": { + "dim": 7, + "equals_E7_E42_E45": true, + "frame": [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + }, + "net_operator": { + "operator": { + "22": { + "22": "1", + "61": "-1", + "63": "-1" + }, + "61": { + "61": "1" + }, + "63": { + "63": "1" + } + }, + "registers": [ + 22, + 61, + 63 + ] + }, + "two_implementations": { + "candidate": { + "inventory_equal": true, + "mass": 5139, + "paid_equal": true + }, + "parent": { + "inventory_equal": true, + "mass": 5139, + "paid_equal": true + } + } + }, + "extra": { + "attribution": { + "climbs": { + "230": { + "candidate": [ + [ + "A", + 1879, + 0, + 1 + ], + [ + "A", + 1921, + 1, + 2 + ], + [ + "A", + 1931, + 2, + 3 + ], + [ + "B", + 608, + 3, + 5 + ], + [ + "B", + 1291, + 5, + 6 + ], + [ + "post", + 24, + 6, + 7 + ], + [ + "post", + 184, + 7, + 8 + ] + ], + "parent": [ + [ + "A", + 1879, + 0, + 1 + ], + [ + "A", + 1921, + 1, + 2 + ], + [ + "A", + 1931, + 2, + 3 + ], + [ + "B", + 608, + 3, + 5 + ], + [ + "B", + 1291, + 5, + 6 + ], + [ + "post", + 24, + 6, + 7 + ], + [ + "post", + 183, + 7, + 8 + ] + ] + }, + "363": { + "candidate": [ + [ + "A", + 3118, + 0, + 1 + ], + [ + "A", + 3161, + 1, + 2 + ], + [ + "B", + 671, + 2, + 3 + ], + [ + "B", + 799, + 3, + 4 + ], + [ + "B", + 823, + 4, + 5 + ], + [ + "post", + 60, + 5, + 7 + ], + [ + "post", + 192, + 7, + 8 + ] + ], + "parent": [ + [ + "A", + 3118, + 0, + 1 + ], + [ + "A", + 3161, + 1, + 2 + ], + [ + "B", + 671, + 2, + 3 + ], + [ + "B", + 799, + 3, + 4 + ], + [ + "B", + 823, + 4, + 5 + ], + [ + "post", + 60, + 5, + 7 + ], + [ + "post", + 191, + 7, + 8 + ] + ] + }, + "395": { + "candidate": [ + [ + "A", + 3426, + 0, + 1 + ], + [ + "A", + 3469, + 1, + 2 + ], + [ + "B", + 723, + 2, + 3 + ], + [ + "B", + 809, + 3, + 4 + ], + [ + "B", + 825, + 4, + 5 + ], + [ + "post", + 74, + 5, + 7 + ], + [ + "post", + 198, + 7, + 8 + ] + ], + "parent": [ + [ + "A", + 3426, + 0, + 1 + ], + [ + "A", + 3469, + 1, + 2 + ], + [ + "B", + 723, + 2, + 3 + ], + [ + "B", + 809, + 3, + 4 + ], + [ + "B", + 825, + 4, + 5 + ], + [ + "post", + 74, + 5, + 7 + ], + [ + "post", + 197, + 7, + 8 + ] + ] + }, + "5": { + "candidate": [ + [ + "A", + 3453, + 1, + 2 + ], + [ + "B", + 726, + 2, + 3 + ], + [ + "B", + 810, + 3, + 4 + ], + [ + "B", + 826, + 4, + 5 + ], + [ + "post", + 75, + 5, + 7 + ], + [ + "post", + 197, + 7, + 8 + ], + [ + "end", + 0, + 8, + 9 + ] + ], + "parent": [ + [ + "A", + 3453, + 1, + 2 + ], + [ + "B", + 726, + 2, + 3 + ], + [ + "B", + 810, + 3, + 4 + ], + [ + "B", + 826, + 4, + 5 + ], + [ + "post", + 75, + 5, + 7 + ], + [ + "post", + 196, + 7, + 8 + ], + [ + "end", + 0, + 8, + 9 + ] + ] + }, + "61": { + "candidate": [ + [ + "A", + 2221, + 1, + 2 + ], + [ + "A", + 2243, + 2, + 3 + ], + [ + "A", + 2245, + 3, + 4 + ], + [ + "A", + 2334, + 4, + 7 + ], + [ + "post", + 179, + 7, + 8 + ], + [ + "post", + 180, + 8, + 9 + ] + ], + "parent": [ + [ + "A", + 2221, + 1, + 2 + ], + [ + "A", + 2243, + 2, + 3 + ], + [ + "A", + 2245, + 3, + 4 + ], + [ + "A", + 2334, + 4, + 7 + ], + [ + "post", + 178, + 7, + 8 + ], + [ + "end", + 0, + 8, + 9 + ] + ] + }, + "63": { + "candidate": [ + [ + "A", + 2067, + 1, + 2 + ], + [ + "A", + 2089, + 2, + 3 + ], + [ + "A", + 2091, + 3, + 4 + ], + [ + "A", + 2180, + 4, + 7 + ], + [ + "post", + 180, + 7, + 9 + ] + ], + "parent": [ + [ + "A", + 2067, + 1, + 2 + ], + [ + "A", + 2089, + 2, + 3 + ], + [ + "A", + 2091, + 3, + 4 + ], + [ + "A", + 2180, + 4, + 7 + ], + [ + "post", + 179, + 7, + 8 + ], + [ + "end", + 0, + 8, + 9 + ] + ] + }, + "73": { + "candidate": [ + [ + "A", + 3145, + 1, + 2 + ], + [ + "B", + 674, + 2, + 3 + ], + [ + "B", + 800, + 3, + 4 + ], + [ + "B", + 824, + 4, + 5 + ], + [ + "post", + 63, + 5, + 7 + ], + [ + "post", + 191, + 7, + 8 + ], + [ + "end", + 0, + 8, + 9 + ] + ], + "parent": [ + [ + "A", + 3145, + 1, + 2 + ], + [ + "B", + 674, + 2, + 3 + ], + [ + "B", + 800, + 3, + 4 + ], + [ + "B", + 824, + 4, + 5 + ], + [ + "post", + 63, + 5, + 7 + ], + [ + "post", + 190, + 7, + 8 + ], + [ + "end", + 0, + 8, + 9 + ] + ] + } + }, + "dimensions_changed": [ + 63 + ], + "labels_only_moved": [ + 5, + 61, + 73, + 230, + 363, + 395 + ], + "paid_delta": { + "1": -2, + "2": 1 + } + }, + "diff": { + "cleanup_lengths": { + "candidate": 5208, + "parent": 5207 + }, + "declared": { + "new_gates": 3, + "old_gates": 2, + "section": "restore", + "start": 178, + "stop": 180 + }, + "minimal_hunk": { + "candidate": [ + 178, + 181 + ], + "parent": [ + 178, + 180 + ] + }, + "restore_lengths": { + "candidate": 204, + "parent": 203 + }, + "sections_differing": [ + "cleanup", + "report", + "restore" + ], + "touched_registers": [ + 22, + 61, + 63 + ] + }, + "first_new_frame": { + "dim": 7, + "equals_E7_E42_E45": true, + "frame": [ + 256, + 128, + 64, + 35, + 16, + 11, + 5 + ] + }, + "net_operator": { + "operator": { + "22": { + "22": "1", + "61": "-1", + "63": "-1" + }, + "61": { + "61": "1" + }, + "63": { + "63": "1" + } + }, + "registers": [ + 22, + 61, + 63 + ] + }, + "two_implementations": { + "candidate": { + "inventory_equal": true, + "mass": 5139, + "paid_equal": true + }, + "parent": { + "inventory_equal": true, + "mass": 5139, + "paid_equal": true + } + } + } + }, + "scope_b": { + "base": { + "candidate": { + "buffers": { + "offset": 704, + "private_buffers": 91 + }, + "centre_copy_children": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "cleanup": { + "all_at_full": true, + "items": 5208, + "literal_equal": true + }, + "counts": { + "a_prelude_events": 84, + "buffers": 91, + "corrections": 36, + "helpers": 408, + "live": 632, + "sections": { + "A": 4079, + "B": 1874, + "cleanup": 5208, + "compensation": 5736, + "cut": 176, + "precondition": 192, + "restore": 204 + }, + "warps": 72 + }, + "helper_widths_sha256": "9e39591791752111d0b50d9186854bab1d3c9b9a3c86ca00ee43724a40ea6080", + "independent_inputs": 632, + "inventory": { + "4": 26, + "5": 2, + "6": 16, + "7": 52, + "8": 99, + "9": 213 + }, + "mass": 5139, + "profile": { + "1": 2443, + "2": 707, + "3": 232, + "4": 108, + "5": 18, + "8": 8 + }, + "replay_dual": { + "buffer_nonzero_window": [ + 0, + 5200 + ], + "buffers": 91, + "buffers_ever_nonzero": 71, + "cleanup_adds_reading_a_zero_buffer": 417, + "independent_inputs": 632, + "max_overlap_of_buffer_lifetimes": 62, + "orientation": "dual", + "peak_nonzero_buffers": 62 + }, + "replay_forward": { + "buffer_nonzero_window": [ + 2, + 5206 + ], + "buffers": 91, + "buffers_ever_nonzero": 91, + "cleanup_adds_reading_a_zero_buffer": 306, + "independent_inputs": 632, + "max_overlap_of_buffer_lifetimes": 65, + "orientation": "forward", + "peak_nonzero_buffers": 65, + "rows_with_operator_words_before_cleanup": 118 + }, + "tracker": { + "buffers": 91, + "buffers_zero": true, + "buffers_zero_after": true, + "cleanup_items": 5208, + "final_identity": true, + "live": 632, + "restored_own": true, + "rows_with_operator_words": 118, + "targets_final": true + }, + "warp_records": 72 + }, + "parent": { + "buffers": { + "offset": 704, + "private_buffers": 91 + }, + "centre_copy_children": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "cleanup": { + "all_at_full": true, + "items": 5207, + "literal_equal": true + }, + "counts": { + "a_prelude_events": 84, + "buffers": 91, + "corrections": 36, + "helpers": 408, + "live": 632, + "sections": { + "A": 4079, + "B": 1874, + "cleanup": 5207, + "compensation": 5736, + "cut": 176, + "precondition": 192, + "restore": 203 + }, + "warps": 72 + }, + "helper_widths_sha256": "9e39591791752111d0b50d9186854bab1d3c9b9a3c86ca00ee43724a40ea6080", + "independent_inputs": 632, + "inventory": { + "4": 26, + "5": 2, + "6": 16, + "7": 52, + "8": 99, + "9": 213 + }, + "mass": 5139, + "profile": { + "1": 2445, + "2": 706, + "3": 232, + "4": 108, + "5": 18, + "8": 8 + }, + "replay_dual": { + "buffer_nonzero_window": [ + 0, + 5199 + ], + "buffers": 91, + "buffers_ever_nonzero": 71, + "cleanup_adds_reading_a_zero_buffer": 417, + "independent_inputs": 632, + "max_overlap_of_buffer_lifetimes": 62, + "orientation": "dual", + "peak_nonzero_buffers": 62 + }, + "replay_forward": { + "buffer_nonzero_window": [ + 2, + 5205 + ], + "buffers": 91, + "buffers_ever_nonzero": 91, + "cleanup_adds_reading_a_zero_buffer": 306, + "independent_inputs": 632, + "max_overlap_of_buffer_lifetimes": 65, + "orientation": "forward", + "peak_nonzero_buffers": 65, + "rows_with_operator_words_before_cleanup": 118 + }, + "tracker": { + "buffers": 91, + "buffers_zero": true, + "buffers_zero_after": true, + "cleanup_items": 5207, + "final_identity": true, + "live": 632, + "restored_own": true, + "rows_with_operator_words": 118, + "targets_final": true + }, + "warp_records": 72 + } + }, + "extra": { + "candidate": { + "buffers": { + "offset": 704, + "private_buffers": 91 + }, + "centre_copy_children": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "cleanup": { + "all_at_full": true, + "items": 5208, + "literal_equal": true + }, + "counts": { + "a_prelude_events": 84, + "buffers": 91, + "corrections": 36, + "helpers": 408, + "live": 632, + "sections": { + "A": 4079, + "B": 1874, + "cleanup": 5208, + "compensation": 5736, + "cut": 176, + "precondition": 192, + "restore": 204 + }, + "warps": 72 + }, + "helper_widths_sha256": "9e39591791752111d0b50d9186854bab1d3c9b9a3c86ca00ee43724a40ea6080", + "independent_inputs": 632, + "inventory": { + "4": 26, + "5": 2, + "6": 16, + "7": 52, + "8": 99, + "9": 213 + }, + "mass": 5139, + "profile": { + "1": 2443, + "2": 707, + "3": 232, + "4": 108, + "5": 18, + "8": 8 + }, + "replay_dual": { + "buffer_nonzero_window": [ + 0, + 5200 + ], + "buffers": 91, + "buffers_ever_nonzero": 71, + "cleanup_adds_reading_a_zero_buffer": 417, + "independent_inputs": 632, + "max_overlap_of_buffer_lifetimes": 62, + "orientation": "dual", + "peak_nonzero_buffers": 62 + }, + "replay_forward": { + "buffer_nonzero_window": [ + 2, + 5206 + ], + "buffers": 91, + "buffers_ever_nonzero": 91, + "cleanup_adds_reading_a_zero_buffer": 306, + "independent_inputs": 632, + "max_overlap_of_buffer_lifetimes": 65, + "orientation": "forward", + "peak_nonzero_buffers": 65, + "rows_with_operator_words_before_cleanup": 118 + }, + "tracker": { + "buffers": 91, + "buffers_zero": true, + "buffers_zero_after": true, + "cleanup_items": 5208, + "final_identity": true, + "live": 632, + "restored_own": true, + "rows_with_operator_words": 118, + "targets_final": true + }, + "warp_records": 72 + }, + "parent": { + "buffers": { + "offset": 704, + "private_buffers": 91 + }, + "centre_copy_children": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "cleanup": { + "all_at_full": true, + "items": 5207, + "literal_equal": true + }, + "counts": { + "a_prelude_events": 84, + "buffers": 91, + "corrections": 36, + "helpers": 408, + "live": 632, + "sections": { + "A": 4079, + "B": 1874, + "cleanup": 5207, + "compensation": 5736, + "cut": 176, + "precondition": 192, + "restore": 203 + }, + "warps": 72 + }, + "helper_widths_sha256": "9e39591791752111d0b50d9186854bab1d3c9b9a3c86ca00ee43724a40ea6080", + "independent_inputs": 632, + "inventory": { + "4": 26, + "5": 2, + "6": 16, + "7": 52, + "8": 99, + "9": 213 + }, + "mass": 5139, + "profile": { + "1": 2445, + "2": 706, + "3": 232, + "4": 108, + "5": 18, + "8": 8 + }, + "replay_dual": { + "buffer_nonzero_window": [ + 0, + 5199 + ], + "buffers": 91, + "buffers_ever_nonzero": 71, + "cleanup_adds_reading_a_zero_buffer": 417, + "independent_inputs": 632, + "max_overlap_of_buffer_lifetimes": 62, + "orientation": "dual", + "peak_nonzero_buffers": 62 + }, + "replay_forward": { + "buffer_nonzero_window": [ + 2, + 5205 + ], + "buffers": 91, + "buffers_ever_nonzero": 91, + "cleanup_adds_reading_a_zero_buffer": 306, + "independent_inputs": 632, + "max_overlap_of_buffer_lifetimes": 65, + "orientation": "forward", + "peak_nonzero_buffers": 65, + "rows_with_operator_words_before_cleanup": 118 + }, + "tracker": { + "buffers": 91, + "buffers_zero": true, + "buffers_zero_after": true, + "cleanup_items": 5207, + "final_identity": true, + "live": 632, + "restored_own": true, + "rows_with_operator_words": 118, + "targets_final": true + }, + "warp_records": 72 + } + } + }, + "scope_limits": [ + "PR3015's exhaustive search over all 2-4-gate restore-phase blocks (its Stack2979 harness) is not reproduced; the census here covers one class (adjacent same-target pairs rewritten in R1's way with the three frames chosen as described) on both words.", + "The frames of the three new gates are checked for legality and priced as given; whether a different frame assignment of the whole word gives a lower paid profile (a frame re-solve) is not decided here.", + "The native chains, the bootstrap, the complete admission and the outer release of PR3015 (author-run, evidence/ in its package) are not rerun; kappa is checked as arithmetic on the complete profile under the inherited moment model (M(b) = sum n_r r (73/r)^b / (73 W)), with the inherited 24-digit grid and the -1e-46-1e-70 margins.", + "The fixed-inventory fractional cap certificate (RELAX-CAP.json) is not re-derived.", + "PR3018's journal is applied and priced; its sign proof, its own geometry checker and its physical legality claims beyond rules R-a..R-e are not re-derived. The composed endpoint was computed here (about 18:40 UTC) without having read PR3021, which published the same composition at 2026-10-16 18:21 UTC and has priority; it is checked against PR3021's finite records; PR3021's fresh native/admission/outer release is author-run and not rerun here.", + "The window semantics and the free interleaving of independent replica controllers are inherited modelling assumptions (as in PR2804/PR2865)." + ], + "self_checks_ran": { + "fill.sha256_bound": 1, + "wiring.edits_equal": 1, + "wiring.providers_agree": 1 + }, + "summary": { + "C": "0.001729150973534224428695", + "census": { + "base": { + "candidate": { + "adjacent_same_target_pairs": 44, + "candidates": 88, + "illegal_reasons": {}, + "improving": [], + "legal": 88, + "losing_only": 10, + "option_deltas": { + "{\"1\":2,\"2\":-1}": 8, + "{\"1\":4,\"2\":-2}": 6 + }, + "records_with_a_nonzero_option": 10, + "rewrites_recounted": 108 + }, + "parent": { + "adjacent_same_target_pairs": 47, + "candidates": 94, + "illegal_reasons": {}, + "improving": [ + [ + 178, + 61, + 63 + ], + [ + 178, + 63, + 61 + ] + ], + "legal": 94, + "losing_only": 12, + "option_deltas": { + "{\"1\":-2,\"2\":1}": 2, + "{\"1\":2,\"2\":-1}": 10, + "{\"1\":4,\"2\":-2}": 6 + }, + "records_with_a_nonzero_option": 14, + "rewrites_recounted": 122 + } + }, + "extra": { + "candidate": { + "adjacent_same_target_pairs": 44, + "candidates": 88, + "illegal_reasons": {}, + "improving": [], + "legal": 88, + "losing_only": 10, + "option_deltas": { + "{\"1\":2,\"2\":-1}": 8, + "{\"1\":4,\"2\":-2}": 6 + }, + "records_with_a_nonzero_option": 10, + "rewrites_recounted": 108 + }, + "parent": { + "adjacent_same_target_pairs": 47, + "candidates": 94, + "illegal_reasons": {}, + "improving": [ + [ + 178, + 61, + 63 + ], + [ + 178, + 63, + 61 + ] + ], + "legal": 94, + "losing_only": 12, + "option_deltas": { + "{\"1\":-2,\"2\":1}": 2, + "{\"1\":2,\"2\":-1}": 10, + "{\"1\":4,\"2\":-2}": 6 + }, + "records_with_a_nonzero_option": 14, + "rewrites_recounted": 122 + } + } + }, + "complete_delta_vs_pr2979": { + "1": -1332, + "2": 666 + }, + "complete_profile": { + "1": 1644348, + "2": 470862, + "3": 159468, + "4": 71928, + "48": 28190, + "5": 13716, + "8": 5328 + }, + "composed_endpoint_predicted": "0.001729151203983018442998", + "counting": "negative_controls_attempted: controls run (audit_common.attempt; vendor-pin controls excluded); negative_controls_rejected: control records written after the rejecting rule id was asserted (a mutation of each provider counts once per provider); distinct_controls: distinct (group, control) pairs with the provider tag removed", + "distinct_controls": 85, + "fast": false, + "gain_over_pr2979": "1.169909e-07", + "hunk": "restore[178:180) -> 3 gates", + "local_profile": { + "1": 2443, + "2": 707, + "3": 232, + "4": 108, + "5": 18, + "8": 8 + }, + "local_profile_parent": { + "1": 2445, + "2": 706, + "3": 232, + "4": 108, + "5": 18, + "8": 8 + }, + "negative_controls_attempted": 117, + "negative_controls_by_group": { + "edit": 44, + "fill_rules": 10, + "journal": 5, + "kappa": 21, + "pricing": 17, + "words": 20 + }, + "negative_controls_rejected": 117, + "paid_delta": { + "1": -2, + "2": 1 + }, + "physical": 66813, + "pinned_inputs": 22, + "plumbing_controls": 7, + "positive_controls": 8, + "positive_controls_executed": [ + "pr2979_words_base", + "r1_census_pair_found", + "pr2979_words_extra", + "pr2979_complete_profile", + "pr2979_endpoint", + "pr3018_journal_profile", + "pr3018_endpoint", + "pr3021_composition" + ], + "pr3018_endpoint_predicted": "0.001729034213064256309510", + "pr3018_profile_reproduced": true, + "pr3021_composition_equal": true, + "registers_with_changed_climbs": [ + 63 + ], + "replay_orientations": [ + "forward", + "dual" + ], + "roles": 271728, + "width_inventory": { + "4": 26, + "5": 2, + "6": 16, + "7": 52, + "8": 99, + "9": 213 + }, + "words_independent_inputs": 632 + }, + "vendor": { + "vendor/pr2315/words_check.py": { + "bytes": 66439, + "computed_from": "the loaded bytes (vendor_pin)", + "git_blob": "0b646b9d5583c75a78e0c2dd7e9cfffa02055058", + "sha256": "b66414a39f5ac7b9cd32284027e13a550734901aca5f4457085a034689bc3ce6" + }, + "vendor/pr2387/fill_check80.py": { + "bytes": 73478, + "computed_from": "the loaded bytes (vendor_pin)", + "git_blob": "557e0732bfe4c030436a11f5433143c10fa07821", + "sha256": "1c4d30591969c6502605f239f40505261e99d025aa3b576a804332a6bc479b06" + }, + "vendor/pr2804/audit_common.py": { + "bytes": 10853, + "computed_from": "the loaded bytes (vendor_pin)", + "git_blob": "17c4064f01b110012b54c05e64bdee8ae498e0b2", + "sha256": "7ced740252ac8d8a8c66ef3cc825008e0aacf080494d0e983fb322d7dcddbf42" + }, + "vendor/pr2804/check_accounting.py": { + "bytes": 39529, + "computed_from": "the loaded bytes (vendor_pin)", + "git_blob": "e749057dd838b715d0630de618f32d66a38da931", + "sha256": "fb6aef50da586f15cd60762edc074c20e300d65f1378a80160b3d4b840762548" + }, + "vendor/pr2804/check_fill.py": { + "bytes": 57380, + "computed_from": "the loaded bytes (vendor_pin)", + "git_blob": "85d1f807c62e4ac3b5f5ec7a809333ca05d5a951", + "sha256": "6abf2a574de50c71b46b502d322deab841cbaa0080e326262f346a96992878fb" + }, + "vendor/pr2804/check_words.py": { + "bytes": 57868, + "computed_from": "the loaded bytes (vendor_pin)", + "git_blob": "451dbb82f147ef446a1819b1ed595b4bf5547583", + "sha256": "5996e804fa006906abff63a982c272588a44c35dfc932fdf687ef98dd3e0905f" + }, + "vendor/pr2865/audit_lib.py": { + "bytes": 16379, + "computed_from": "the loaded bytes (vendor_pin)", + "git_blob": "e8e847cc89dae6bb4e90e2c3dbebc30f615b698f", + "sha256": "e0cf84dd959d39e3f299c1e171753c29465fd5b4457561f4ab9ec0675d8e9dc1" + } + } +} diff --git a/research/t74-3015-restore-edit-audit/SOURCES.json b/research/t74-3015-restore-edit-audit/SOURCES.json new file mode 100644 index 0000000000..d2494495da --- /dev/null +++ b/research/t74-3015-restore-edit-audit/SOURCES.json @@ -0,0 +1,323 @@ +{ + "schema_version": 1, + "base_commit": "d8e0f83f00191df62174b641e9fff055c357f641", + "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" + } + ], + "remote_sources": [ + { + "key": "claim2979", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 2979, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2979", + "commit": "be191346391661f4d35fc0d1508d0a6029572576", + "path": "research/rank7-joint-endframes/CLAIM.json", + "git_blob": "8ec2ce4e440c0b584ee982c551e526a011c9324c", + "sha256": "436e0d297cbdf195445d3697d496ac675e95210b79e70ce602a6a6667a4c6ce9", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "claim3015", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 3015, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/3015", + "commit": "e244296debb45fe6f4da84d29e4d64fbab55fda0", + "path": "research/rank7-joint-endframes-restore-edit/CLAIM.json", + "git_blob": "70813f559e2878f0c5403c0b859eefe602f70abc", + "sha256": "f9b9fbaaac794c0ce279c238a33a2f34f8c91a34d97ccdeb5ec98b7b8ba56d73", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "claim3021", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 3021, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/3021", + "commit": "217edac2ebfa6250536bd6df153de14901a69395", + "path": "research/rank7-restore-packing-composition/evidence/OUTER-CLAIM.json", + "git_blob": "a8d657563624b98d8bb238878a6c20fa74a1f593", + "sha256": "8beb062c36169728a8f82a5eda6638c2a83125f16e7e5de56f3a13d9cba5e1f5", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "composition3021", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 3021, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/3021", + "commit": "217edac2ebfa6250536bd6df153de14901a69395", + "path": "research/rank7-restore-packing-composition/evidence/COMPOSITION-RESULT.json", + "git_blob": "399bcc26f0684cced978e3a4c90f834551f62dd7", + "sha256": "cdc4874dcb17714fbe10f003a4a4516b80a9ddccfc7199278a53baa13c5d3a04", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "dispatch2979", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 2979, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2979", + "commit": "be191346391661f4d35fc0d1508d0a6029572576", + "path": "research/rank7-joint-endframes/allocation/DISPATCH.json", + "git_blob": "9544fee4e6ee1f202cee22bfaeaf229ee3b2515e", + "sha256": "65e435bd68e97243c003677271b88485a29d4d0fae2dff1354100404a145e74c", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "edits3015", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 3015, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/3015", + "commit": "e244296debb45fe6f4da84d29e4d64fbab55fda0", + "path": "research/rank7-joint-endframes-restore-edit/edits/EDITS.json", + "git_blob": "90894fc6592951eaa3b4e25467d3a85c36b2d988", + "sha256": "c9c68660d07bfd12ed20fd8cbfe3d36301ceb2d7bb9b4ea11350cc399b19e0b1", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "exchange3018", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 3018, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/3018", + "commit": "ca7113157d7c959fdfa9d7cd17ef92d3877070d0", + "path": "research/rank7-integrality-exchange/EXCHANGE.json", + "git_blob": "1260c8d95f573a574e007038263adf883b5ecbd2", + "sha256": "8a103f643ad12d8074972f41e4359d9487eb8b96fc6849e1a178adb61b36578b", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "fill2979", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 2979, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2979", + "commit": "be191346391661f4d35fc0d1508d0a6029572576", + "path": "research/rank7-joint-endframes/allocation/FILL.json.gz", + "git_blob": "8d4fd644d60ba2c98106dc770803b647afdf0963", + "sha256": "c2136be9434cda511a1a8a44d98f9f72ea5376830a8426674253b4ee351c4c39", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "finite3021", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 3021, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/3021", + "commit": "217edac2ebfa6250536bd6df153de14901a69395", + "path": "research/rank7-restore-packing-composition/evidence/FINITE.json", + "git_blob": "6f73992ff764a3d527d4fd551057dc6fa254127e", + "sha256": "f7f6aca1e2596d7049ff2bc69c523013324f568f86fd31b1f29899b96b2617eb", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "order2979", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 2979, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2979", + "commit": "be191346391661f4d35fc0d1508d0a6029572576", + "path": "research/rank7-joint-endframes/allocation/ORDER.json", + "git_blob": "7409c4df1092241729739596c7648bda504e6aad", + "sha256": "519d1d5dbb997a219fcfcad34c0b03e7838bef24199784d7e964fa10090f66e1", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "profile2979", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 2979, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2979", + "commit": "be191346391661f4d35fc0d1508d0a6029572576", + "path": "research/rank7-joint-endframes/allocation/PROFILE.json", + "git_blob": "46a83eeda67ab67cccbffe8b7ad8e44368b40ea7", + "sha256": "94a819747f3ced41f1544ada0036c983fc0c92847b9644380f877a06cd7931cf", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "profile3015", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 3015, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/3015", + "commit": "e244296debb45fe6f4da84d29e4d64fbab55fda0", + "path": "research/rank7-joint-endframes-restore-edit/allocation/PROFILE.json", + "git_blob": "05766f448600d2f94699f42818aa8150f49fd934", + "sha256": "5626c44edd6d5b209cd4e2d2a824e07bfba696e0856f3964b81fcb01c78eaad8", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "pw3015_base", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 3015, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/3015", + "commit": "e244296debb45fe6f4da84d29e4d64fbab55fda0", + "path": "research/rank7-joint-endframes-restore-edit/data/WORD-base.json.gz", + "git_blob": "d9aa96a93fea5f7395e7783aef0bc117c0a0ae89", + "sha256": "abaf67bfcb257528658c906b612f57025617592bd7889828f92b97a5f4f4300d", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "pw3015_extra", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 3015, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/3015", + "commit": "e244296debb45fe6f4da84d29e4d64fbab55fda0", + "path": "research/rank7-joint-endframes-restore-edit/data/WORD-extra.json.gz", + "git_blob": "74f6cb64595c21f7726ae77e69437868620bdcee", + "sha256": "e0eaf64c4d5d324693d43889bce1b9e53e8da00402105c8c978fd102f208bed7", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "result3018", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 3018, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/3018", + "commit": "ca7113157d7c959fdfa9d7cd17ef92d3877070d0", + "path": "research/rank7-integrality-exchange/RESULT.json", + "git_blob": "b5b527781e2c1e03e11648727d930ab7cb5f8fa8", + "sha256": "a9191f711b50476312c222a47f33d7b72a4ac26fdd190ec58b38889986f39b24", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "t37_2269", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 2269, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2269", + "commit": "b479fc5567bc09ab9185bffe89b62594f36d74e5", + "path": "research/gmx-t74-borrow43/inputs/GLOBAL-TEMPLATE.json.gz", + "git_blob": "114808c32b1799da53524bdc25cea67efb60009e", + "sha256": "21297b20f1f2dc76eb9dd8124416068c3cb096bab9df17fa4da19bc68dfe082e", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "template2979", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 2979, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2979", + "commit": "be191346391661f4d35fc0d1508d0a6029572576", + "path": "research/rank7-joint-endframes/allocation/vendor/TEMPLATE.json.gz", + "git_blob": "114808c32b1799da53524bdc25cea67efb60009e", + "sha256": "21297b20f1f2dc76eb9dd8124416068c3cb096bab9df17fa4da19bc68dfe082e", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "tpl2269", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 2269, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2269", + "commit": "b479fc5567bc09ab9185bffe89b62594f36d74e5", + "path": "research/gmx-t74-borrow43/GLOBAL-TEMPLATE.json.gz", + "git_blob": "5327fc2f4e8ea82ed356c94ff040d23fc73c731f", + "sha256": "1d31424c4e27e26a35a9932ca778e43f1f3577589275422cc642aa68b31112db", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "w2979_base", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 2979, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2979", + "commit": "be191346391661f4d35fc0d1508d0a6029572576", + "path": "research/rank7-joint-endframes/data/WORD-base.json.gz", + "git_blob": "d9aa96a93fea5f7395e7783aef0bc117c0a0ae89", + "sha256": "abaf67bfcb257528658c906b612f57025617592bd7889828f92b97a5f4f4300d", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "w2979_extra", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 2979, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2979", + "commit": "be191346391661f4d35fc0d1508d0a6029572576", + "path": "research/rank7-joint-endframes/data/WORD-extra.json.gz", + "git_blob": "74f6cb64595c21f7726ae77e69437868620bdcee", + "sha256": "e0eaf64c4d5d324693d43889bce1b9e53e8da00402105c8c978fd102f208bed7", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "w3015_base", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 3015, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/3015", + "commit": "e244296debb45fe6f4da84d29e4d64fbab55fda0", + "path": "research/rank7-joint-endframes-restore-edit/edits/FINAL-WORD-base.json.gz", + "git_blob": "4f0483657396a7f735873e1b252482c53dfb2eb6", + "sha256": "77d9be7ac47347894e034d8b67bf07ff8a5e1c317923ed5dd9257c492187dcf5", + "usage": "data input, read with git show :; never executed" + }, + { + "key": "w3015_extra", + "repository": "CrocSwap/integer-mult-bounds", + "pr": 3015, + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/3015", + "commit": "e244296debb45fe6f4da84d29e4d64fbab55fda0", + "path": "research/rank7-joint-endframes-restore-edit/edits/FINAL-WORD-extra.json.gz", + "git_blob": "81f95e21ede115e8bdb6bd522c641b37b740bdf7", + "sha256": "18d9c448ce892aa19f162e214760d0bd4ecb09f814b9b859dbf11f3ca637e9ea", + "usage": "data input, read with git show :; never executed" + } + ], + "vendored": [ + { + "path": "research/t74-3015-restore-edit-audit/vendor/pr2315/words_check.py", + "module": "words_check", + "git_blob": "0b646b9d5583c75a78e0c2dd7e9cfffa02055058", + "sha256": "b66414a39f5ac7b9cd32284027e13a550734901aca5f4457085a034689bc3ce6", + "usage": "vendored library of this contributor (byte copy, pinned and executed from the verified bytes; see vendor/NOTICE.md)" + }, + { + "path": "research/t74-3015-restore-edit-audit/vendor/pr2387/fill_check80.py", + "module": "fill_check80", + "git_blob": "557e0732bfe4c030436a11f5433143c10fa07821", + "sha256": "1c4d30591969c6502605f239f40505261e99d025aa3b576a804332a6bc479b06", + "usage": "vendored library of this contributor (byte copy, pinned and executed from the verified bytes; see vendor/NOTICE.md)" + }, + { + "path": "research/t74-3015-restore-edit-audit/vendor/pr2804/audit_common.py", + "module": "audit_common", + "git_blob": "17c4064f01b110012b54c05e64bdee8ae498e0b2", + "sha256": "7ced740252ac8d8a8c66ef3cc825008e0aacf080494d0e983fb322d7dcddbf42", + "usage": "vendored library of this contributor (byte copy, pinned and executed from the verified bytes; see vendor/NOTICE.md)" + }, + { + "path": "research/t74-3015-restore-edit-audit/vendor/pr2804/check_accounting.py", + "module": "check_accounting", + "git_blob": "e749057dd838b715d0630de618f32d66a38da931", + "sha256": "fb6aef50da586f15cd60762edc074c20e300d65f1378a80160b3d4b840762548", + "usage": "vendored library of this contributor (byte copy, pinned and executed from the verified bytes; see vendor/NOTICE.md)" + }, + { + "path": "research/t74-3015-restore-edit-audit/vendor/pr2804/check_fill.py", + "module": "check_fill", + "git_blob": "85d1f807c62e4ac3b5f5ec7a809333ca05d5a951", + "sha256": "6abf2a574de50c71b46b502d322deab841cbaa0080e326262f346a96992878fb", + "usage": "vendored library of this contributor (byte copy, pinned and executed from the verified bytes; see vendor/NOTICE.md)" + }, + { + "path": "research/t74-3015-restore-edit-audit/vendor/pr2804/check_words.py", + "module": "check_words", + "git_blob": "451dbb82f147ef446a1819b1ed595b4bf5547583", + "sha256": "5996e804fa006906abff63a982c272588a44c35dfc932fdf687ef98dd3e0905f", + "usage": "vendored library of this contributor (byte copy, pinned and executed from the verified bytes; see vendor/NOTICE.md)" + }, + { + "path": "research/t74-3015-restore-edit-audit/vendor/pr2865/audit_lib.py", + "module": "audit_lib", + "git_blob": "e8e847cc89dae6bb4e90e2c3dbebc30f615b698f", + "sha256": "e0cf84dd959d39e3f299c1e171753c29465fd5b4457561f4ab9ec0675d8e9dc1", + "usage": "vendored library of this contributor (byte copy, pinned and executed from the verified bytes; see vendor/NOTICE.md)" + } + ], + "commits": { + "3015": "e244296debb45fe6f4da84d29e4d64fbab55fda0", + "2979": "be191346391661f4d35fc0d1508d0a6029572576", + "3018": "ca7113157d7c959fdfa9d7cd17ef92d3877070d0", + "2269": "b479fc5567bc09ab9185bffe89b62594f36d74e5", + "3021": "217edac2ebfa6250536bd6df153de14901a69395" + }, + "notes": [ + "PR #2979 (head be191346) and PR #2269 (b479fc55) are reachable from main; PR #3015, PR #3018 and PR #3021 are open and are fetched by --fetch into refs/audit/pr3015, refs/audit/pr3018 and refs/audit/pr3021." + ] +} diff --git a/research/t74-3015-restore-edit-audit/TASK.json b/research/t74-3015-restore-edit-audit/TASK.json new file mode 100644 index 0000000000..522d0e0eed --- /dev/null +++ b/research/t74-3015-restore-edit-audit/TASK.json @@ -0,0 +1,91 @@ +{ + "schema_version": 1, + "task_id": "independent-moment", + "priority_revision": 6, + "base_commit": "d8e0f83f00191df62174b641e9fff055c357f641", + "scope_key": "pr3015-r1-restore-edit-independent-audit", + "original_card": { + "id": "independent-moment", + "question": "Does one changed supplier or assembly claim lack a source-bound independent check of a specific new implication?", + "starting_points": [ + "certificates/selected-result.json", + "research/rank7-joint-endframes/README.md", + "docs/research/research-family-status.md" + ], + "methods": [ + "Independently reconstruct a coordinated frame/circuit change and its single-change control, then derive the complete rank and physical ledger.", + "Implement certified moment inequalities through a different exact enclosure method." + ], + "acceptance_gate": "Demonstrate independence, source binding, positive cases and semantic failure controls. Name the existing checks and the missing coverage. More digits or another equivalent evaluation of an unchanged root is not by itself new verification coverage.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read #2979 joint rank-7 end-frame proposal and the revision-6 evidence status. Its claimed kappa is not selected. Compare coordinated changes with the losing single-change controls and locate the complete physical ledger; an aggregate moment alone does not validate the mechanism.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Prioritize a bounded independent audit of #2979: reconstruct one joint group and its single-lowering control, check the declared frames/chronology, then trace changed children, idle widths and cleanup buffers into the complete invoice and both supplier caps. Choose one still-missing implication after checking existing audits. Stop with exact unresolved dependencies if full admission exceeds the session; do not launch a new lowering census on an unvalidated premise or substitute extra root digits for mechanism checking.", + "bottleneck_link": "Independent pricing prevents unsupported frontier claims and can reveal genuine accounting slack.", + "allowed_variations": [ + "Reconstruct either a source ledger or a numeric enclosure with a different method." + ], + "scope_change_triggers": [ + "Importing the primary function and calling its output independent verification.", + "Promoting #2979 from merged source archive to validated supplier solely from author PASS receipts or aggregate pricing." + ], + "overlap_terms": [ + "independent moment", + "rank histogram", + "exact enclosure", + "2979", + "rank7 joint endframes", + "paired extraction", + "joint lowering" + ] + }, + "scope_status": "refined", + "actual_scope": "Independent verification of open PR #3015 (Jeremy Kothe, head e244296debb45fe6f4da84d29e4d64fbab55fda0): the declared restore edit R1 on PR #2979's words (merged, head be191346391661f4d35fc0d1508d0a6029572576) with PR #2979's literal T74 allocation. Checked with code independent of both PRs: the hunk (own diff), the net operator, both edited words exact forward and dual through cleanup and endpoint (632 inputs, 36 initial corrections), the frame recount in two implementations with the paid delta -2H1+H2 attributed to register 63's merged climbs, the literal cleanup against an own re-derivation, the allocation priced in two implementations (271,728 roles) under the new local profiles (complete profile, delta, idle, physical stock 66813), the endpoint C and kappa with own and vendored rational enclosures, the exact gain over PR #2979, a census of R1's rewrite class on the parent and on the edited words, and PR #3018's journal applied to the same fill (its profile and endpoint reproduced), with the PR3015+PR3018 composition computed here (without having read PR #3021, which published it 19 minutes earlier) and equal to PR #3021's published finite records (profile, idle, kappa, gain).", + "scope_change_reason": "The card's lead object (#2979's coordinated lowerings) already had six independent audits (#2993, #2987, #3006, #3008, #3010, #3014) and one improving journal (#3018) and two live claims at entry; PR #3015, the newest conditional candidate on the same words, had none. The audit follows the card's method (independent recheck of a changed cost through the complete invoice) on the changed object; the census extends the check to the uniqueness of R1 within its rewrite class, which the author's unshipped search claims.", + "declared_milestone": "audit", + "budget_minutes": 240, + "stop_rule": "Stop after the independent checks and controls pass or a defect is found; no frame re-solve, no reproduction of the author's 2-4-gate block search, no native/admission/outer replay.", + "outcome": "completed", + "started_utc": "2026-10-16T18:12:00Z", + "author": "Sagar Thakrar (thakrarsagar)", + "ai_assistance": "Substantial AI assistance (Claude Code, Anthropic) for implementation, checks and writing; no independent human review is claimed.", + "existing_checks_consulted": [ + "#2993 (petalas): frame paths and V45 subsets of #2979, not word semantics or the R1 edit", + "#2987/#3010 (RossRichardson): chronological packing of #2979's fill; the fill is reused unchanged by #3015", + "#3006/#3008/#3014 (petalas): V45 native endpoint/events and frozen-owner invoice of #2979", + "#3018 (petalas): an integrality exchange on #2979's fill; its journal is applied here and its profile and endpoint reproduced", + "#3021 (petalas, published 2026-10-16 18:21 UTC): composition of R1 with #3018's journal, author chain run; its finite records equal the composition computed here; its verify.py check_word verifies R1's preimage, 3x3 scalar identity, changed sections and re-derived cleanup, reading the profile delta from the report", + "PR #3015's own edits_review.py (author-run, uses the inherited #2833 auditor); not imported or executed here", + "petalas, Discussion 2612 comment 18981612 (19:40 UTC, local-only claim): a second restore rewrite (restore[162:178], shared covector X40 - 2 X54 across two non-adjacent consumers), outside the class censused here" + ], + "open_questions": [ + { + "question": "Does a frame re-solve of the whole edited word (all gate frames free, monotone, same gates) give a paid profile below {1:2443, 2:707, 3:232, 4:108, 5:18, 8:8}?", + "why_it_matters": "R1's frames were re-solved by the author's certified frame pricer, which is not shipped; this audit checks the given frames for legality and prices them, not their optimality.", + "first_step": "Formulate the frame assignment as a shortest-path problem per register on the lattice of subspaces with the gate constraints (a gate's registers share its frame) and solve it exactly on the parent and edited words.", + "blocked_by": "A monotone, gate-coupled frame optimizer over GF(2)^9 subspaces has to be written; none of this contributor's checkers contains one." + }, + { + "question": "Beyond R1's class, which 2-4-gate restore blocks of the edited words can be re-synthesised with the same net operator and a lower paid profile?", + "why_it_matters": "PR #3015 reports R1 as the first edit of an exhaustive search over all 2-4-gate restore-phase blocks; the census here covers one class (adjacent same-target pairs, three-gate rewrite) and finds no further gain in it.", + "first_step": "Enumerate contiguous blocks of 2-4 restore gates, the finite set of equivalent gate sequences (commutations, carrier changes), and price each with the own chain.", + "blocked_by": "The equivalence class enumeration needs a specification of the allowed re-synthesis; the author's harness is not shipped." + }, + { + "question": "Does PR #3021's release at 0.001729151203983018442998 survive an independent admission check?", + "why_it_matters": "The finite side (profile, idle, endpoint, kappa, gain) is reproduced here and equals PR #3021's published records; the native/prefix/outer side is author-run.", + "first_step": "Read PR #3021's admission receipts against the composed fill, as #2804's stock and prefix checks did for #2530.", + "blocked_by": "Nothing but time." + } + ], + "family_expansion_decision": "None proposed. This audit admits nothing; it reports no defect in PR #3015's finite claims within the checked scope and leaves the author-run native/admission/outer evidence as stated by the author.", + "bottleneck_link": "PR #3015 is the newest conditional candidate of the complex T74 line (kappa 0.00172915 against the selected 0.00167266); an independent check of its only new ingredient (the R1 restore edit and its re-derived paid profile) and of the composed PR3015+PR3018 endpoint is the missing coverage before any of these claims can be treated as more than author-checked. No kappa or supplier change is claimed here.", + "evidence": "verify.py (RESULT.json): both edited words exact forward and dual through cleanup and the target endpoint (632 inputs, 36 initial corrections, 72 warps, 408 helpers, 91 buffers); the hunk restore[178:180) -> 3 gates reproduced by an own diff and equal to the old block as an operator; two frame-chain implementations give {1:2445,2:706,3:232,4:108,5:18,8:8} -> {1:2443,2:707,3:232,4:108,5:18,8:8} with the delta -2H1+H2 attributed to register 63's climbs 7->8->9 merging into 7->9; PR #2979's allocation priced in two implementations under the new local profiles gives the complete profile {1:1644348,2:470862,3:159468,4:71928,5:13716,8:5328,48:28190} = PROFILE.json = CLAIM.json, delta 666 x (-2H1+H2), idle unchanged, physical 66813; C = 0.001729150973534224428695 accepted and C + 1e-24 rejected by an own rational enclosure and by the vendored PR2804 enclosure, kappa = C - 1e-46 - 1e-70, gain over PR #2979 exact; census (adjacent same-target restore pairs, every legal third frame, 122 rewrites recounted on the parent words and 108 on the edited words): the R1 pair is the only candidate with an improving option (both carrier orders), none on the edited words; PR #3018's journal reproduces its profile and endpoint; the composed PR3015+PR3018 endpoint 0.001729151203983018442998 equals PR #3021's finite records. 117 negative controls rejected by their named rules (85 distinct), 8 positive controls, 7 vendor-pin controls; checker mutations in --mutations (see README). No defect found in the checked scope." +} diff --git a/research/t74-3015-restore-edit-audit/VERIFY.json b/research/t74-3015-restore-edit-audit/VERIFY.json new file mode 100644 index 0000000000..8904a0f735 --- /dev/null +++ b/research/t74-3015-restore-edit-audit/VERIFY.json @@ -0,0 +1,20 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "--fetch" + ], + "timeout_seconds": 600, + "checks": "Independent verification of open PR #3015 head e244296d (R1 restore edit on PR #2979 head be191346), in standard-library code that reads PR files only as pinned git data (git blob id and sha256) and never imports or runs PR code; GIT_CONFIG* variables are removed before the first git call; --fetch (git >= 2.29, network) writes only the fetched objects and refs/audit/pr3015, refs/audit/pr3018, refs/audit/pr3021. It checks the declared hunk restore[178:180) -> 3 gates by an own diff, the net operator, both edited words exact forward and dual through cleanup and the target endpoint (632 inputs, 36 initial corrections emulated), the frame recount in two implementations with the paid delta -2H1+H2 attributed to register 63, the literal cleanup, the 91 private buffers, PR #2979's allocation (byte-identical in PR #3015) priced in two implementations under the new local profiles (271,728 roles; complete profile, PROFILE.json, CLAIM.json, rank mass, delta 666 x (-2H1+H2), idle, physical stock 66813), the endpoint C = 0.001729150973534224428695 accepted and C + 1e-24 rejected by an own rational enclosure and by the vendored one, kappa = C - 1e-46 - 1e-70, the exact gain over PR #2979, a census of R1's rewrite class on the parent and edited words (R1 unique, class exhausted after the edit), PR #3018's journal reproducing its profile and endpoint on the same fill, and the endpoint of the PR3015+PR3018 composition computed here and equal to PR #3021's published finite records; it requires every negative control to be rejected by its named rule, the positive controls to pass, and the result to equal RESULT.json. See README.md." + } + ] +} diff --git a/research/t74-3015-restore-edit-audit/audit_controls.py b/research/t74-3015-restore-edit-audit/audit_controls.py new file mode 100644 index 0000000000..a1f5719e4d --- /dev/null +++ b/research/t74-3015-restore-edit-audit/audit_controls.py @@ -0,0 +1,386 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Negative controls of the PR #3015 audit. Every control mutates a word, a fill, a claim or an expectation and +runs it through the function the main check uses; it must be rejected by exactly the named rule id (audit_lib.expect +counts the attempt before the mutant runs and records the control only after the rejecting rule was asserted). +Standard library only; Python 3.8-compatible syntax. +""" +import copy +from fractions import Fraction as Q + +import audit_edit as AE +import audit_fill as AF +import audit_kappa as AK +import audit_lib as AL +import audit_words as AW +import check_fill as CF +import check_words as CW +import fill_check80 as FC +import words_check as WC +from audit_common import AuditFail, need + +expect = AL.expect +V = AL.V +FULL = [1 << b for b in range(9)][::-1] +STAGE_FWD = 'forward replay, before cleanup' +STAGE_DUAL_BUF = 'dual replay, buffers after cleanup' + + +def tagged(tag, name): + return '[%s] %s' % (tag, name) + + +def forge(m): + """Report fields made equal to the own recount, so only the independent checks can reject.""" + AL.forge(m) + return m + + +# ---------------------------------------------------------------------------------------------- scope A/B --- +def edit_controls(tag, wp, wc, edit, declared, expect_counts, Pp, chp, frp, out, replay_stage=None): + a, old, new = edit['start'], edit['old'], edit['new'] + nn = len(new) + T = lambda n: tagged(tag, n) # noqa: E731 + pipeline = lambda m: AW.word_pipeline(m, declared, expect_counts) # noqa: E731 + + def chain_of(m): + return AE.own_chain(AL.parse_word(m)) + + # 1-2 dropped new gate: diff, then replay (report forged so that only the replay can reject) + m = AL.mutant(wc) + del m['restore'][a + 1] + expect(out, T('new gate 2 dropped: own diff'), 'edit.hunk', lambda: AE.own_diff(wp, m, edit)) + m2 = forge(AL.mutant(m)) + m2['cleanup'] = AL.rederive_cleanup(m2) + expect(out, T('new gate 2 dropped, report forged, cleanup re-derived: forward replay'), 'wc.replay', + lambda: AL.replay(AL.parse_word(m2), False), stage=STAGE_FWD) + # 3 flipped coefficient of new gate 1: net operator, replay, own tracker + flipped = copy.deepcopy(new) + flipped[0][3] = -flipped[0][3] + expect(out, T('new gate 1 coefficient flipped: net operator'), 'edit.net_operator', + lambda: AE.net_operator(old, flipped)) + m = forge(AL.mutant(wc)) + m['restore'][a][3] = -m['restore'][a][3] + m['cleanup'] = AL.rederive_cleanup(m) + expect(out, T('new gate 1 coefficient flipped, cleanup re-derived: forward replay'), 'wc.replay', + lambda: AL.replay(AL.parse_word(m), False), stage=STAGE_FWD) + expect(out, T('new gate 1 coefficient flipped, cleanup re-derived: own tracker'), 'words.tracker', + lambda: AW.tracker_check(AW.track(m))) + # 4 frames not re-solved: the old frame on all three new gates (legal word, no saving) + m = AL.mutant(wc) + for j in range(a, a + nn): + m['restore'][j][-1] = copy.deepcopy(old[0][-1]) + expect(out, T('old frame kept on the three new gates: declared profile'), 'words.declared', + lambda: AW.check_declared(CW.frame_recount(AL.parse_word(m)), declared)) + expect(out, T('old frame kept on the three new gates: attribution (no delta)'), 'edit.delta', + lambda: AE.attribution(chp, chain_of(m), {1: -2, 2: 1}, [63])) + # 5 gate-1 frame below the current frames of its registers (both implementations) + m = AL.mutant(wc) + m['restore'][a][-1] = m['restore'][a][-1][:-1] + expect(out, T('new gate 1 frame with one generator dropped: vendored recount'), 'wc.frame', + lambda: CW.frame_recount(AL.parse_word(m))) + expect(out, T('new gate 1 frame with one generator dropped: own chain'), 'chain.monotone', lambda: chain_of(m)) + # 6 gate-3 frame = the old frame instead of FULL (legal, no saving) + m = AL.mutant(wc) + m['restore'][a + 2][-1] = copy.deepcopy(old[0][-1]) + expect(out, T('new gate 3 at the old rank-8 frame instead of FULL: declared profile'), 'words.declared', + lambda: AW.check_declared(CW.frame_recount(AL.parse_word(m)), declared)) + # 7 parent restore kept + m = AL.mutant(wp) + m['report'] = copy.deepcopy(wc['report']) + expect(out, T('candidate with the parent restore section: own diff'), 'edit.hunk', lambda: AE.own_diff(wp, m, edit)) + # 8 declared address shifted + expect(out, T('declared hunk shifted by one gate: own diff'), 'edit.hunk', + lambda: AE.own_diff(wp, wc, dict(edit, start=a - 1, stop=a + 1))) + # 9 ratio 2 in the new block + two = copy.deepcopy(new) + two[0][3], two[2][3] = 2 * two[0][3], 2 * two[2][3] + expect(out, T('new block with ratio 2 (61 += 2*63 ... 61 -= 2*63): net operator'), 'edit.net_operator', + lambda: AE.net_operator(old, two)) + m = forge(AL.mutant(wc)) + m['restore'][a][3], m['restore'][a + 2][3] = 2 * m['restore'][a][3], 2 * m['restore'][a + 2][3] + m['cleanup'] = AL.rederive_cleanup(m) + expect(out, T('new block with ratio 2, cleanup re-derived: forward replay'), 'wc.replay', + lambda: AL.replay(AL.parse_word(m), False), stage=STAGE_FWD) + # 10 stale cleanup: accepted by both replays (same net operator), rejected by the literal re-derivation + m = AL.mutant(wc) + m['cleanup'] = copy.deepcopy(wp['cleanup']) + P = AL.parse_word(m) + fwd_ok = AL.replay(P, False) is not None + dual_ok = AL.replay(P, True) is not None + need(fwd_ok and dual_ok, 'control: the stale cleanup must pass both replays (same net operator)') + expect(out, T('parent cleanup on the candidate (passes both replays): literal cleanup check'), 'words.cleanup', + lambda: AW.check_cleanup(m), replays_accept=True) + # 11 edit outside the allowed sections + m = AL.mutant(wc) + m['A'][m['prelude_events'] + 5][-1] = list(FULL) + expect(out, T('one A gate frame changed as well: own diff'), 'edit.sections', lambda: AE.own_diff(wp, m, edit)) + # 12 extra gate elsewhere in restore (length changes), and a same-length change outside the hunk + m = AL.mutant(wc) + m['restore'].append(copy.deepcopy(new[2])) + expect(out, T('a copy of new gate 3 appended to restore: own diff'), 'edit.hunk', lambda: AE.own_diff(wp, m, edit)) + m = AL.mutant(wc) + m['restore'][100][3] = -m['restore'][100][3] + expect(out, T('restore gate 100 (outside the hunk) coefficient flipped, same length: own diff'), 'edit.hunk', + lambda: AE.own_diff(wp, m, edit)) + # 13 declared old block tampered + bad_old = copy.deepcopy(old) + bad_old[1][3] = -bad_old[1][3] + expect(out, T('declared old block with a flipped coefficient: own diff'), 'edit.hunk', + lambda: AE.own_diff(wp, wc, dict(edit, old=bad_old))) + # 14 attribution: the symmetric rewrite (63 as carrier) moves the saving to register 61 + F1, F, F3 = AE.ech(new[0][-1]), AE.ech(old[0][-1]), AE.ech(new[2][-1]) + sym, _ = AE.rewrite(wp, a, old[1][2], old[0][2], F1, F, F3, Q(old[1][3], old[1][4]), + Q(old[0][3], old[0][4]) / Q(old[1][3], old[1][4])) + forge(sym) + expect(out, T('symmetric rewrite (63 as carrier): attribution names 61, not 63'), 'edit.attribution', + lambda: AE.attribution(chp, chain_of(sym), {1: -2, 2: 1}, [63])) + expect(out, T('parent against itself: attribution (no delta)'), 'edit.delta', + lambda: AE.attribution(chp, chp, {1: -2, 2: 1}, [63])) + # 15 own chain against a recount with one more rank-1 child + fr2 = dict(frp, paid=dict(frp['paid'])) + fr2['paid'][1] += 1 + expect(out, T('two implementations: vendored recount with one more rank-1 child'), 'edit.two_impl', + lambda: AE.two_impl(chp, fr2)) + + +def word_controls(tag, wc, wp, declared, expect_counts, out): + T = lambda n: tagged(tag, n) # noqa: E731 + n = 2 * V + wc['report']['R'] + restored = set(int(k) for k in wc['helper_final']) + helper = next(r for r in range(2 * V, n) if r not in set(wc['removed']) and r not in restored) + buf = n + min(restored) + # 16 dual-only cleanup mutant: forward and the own tracker accept, the dual replay rejects + m = AL.mutant(wc) + m['cleanup'].insert(0, ['add', helper, buf, 1, 1, list(FULL)]) + P = AL.parse_word(m) + need(AL.replay(P, False) is not None, 'control: the dual-only mutant must pass the forward replay') + AW.tracker_check(AW.track(m)) + expect(out, T('cleanup prepended with helper %d += zero buffer %d (forward replay and own tracker accept): word ' + 'pipeline, rejected by the dual replay' % (helper, buf)), 'wc.replay', + lambda: AW.word_pipeline(m, declared, expect_counts), stage=STAGE_DUAL_BUF, forward_and_tracker_accept=True) + # 17-18 report fields + m = AL.mutant(wc) + m['report']['local_profile']['1'] += 1 + expect(out, T('report local_profile with one more rank-1 child'), 'words.report_fields', + lambda: AW.check_report(AL.parse_word(m), CW.frame_recount(AL.parse_word(m)))) + m = AL.mutant(wc) + m['report']['width_inventory']['9'] -= 1 + m['report']['width_inventory']['8'] += 1 + expect(out, T('report width_inventory with one width-9 helper counted as width 8'), 'words.report_fields', + lambda: AW.check_report(AL.parse_word(m), CW.frame_recount(AL.parse_word(m)))) + # 19 declared profile of the parent given for the candidate + parent_declared = dict(local_profile=wp['report']['local_profile'], width_inventory=wp['report']['width_inventory']) + expect(out, T('candidate recount against the parent\'s declared profile'), 'words.declared', + lambda: AW.check_declared(CW.frame_recount(AL.parse_word(wc)), parent_declared)) + # 20 a restore gate outside the hunk dropped (report forged, cleanup re-derived): replay and tracker + m = forge(AL.mutant(wc)) + del m['restore'][100] + m['cleanup'] = AL.rederive_cleanup(m) + expect(out, T('restore gate 100 dropped, report forged, cleanup re-derived: forward replay'), 'wc.replay', + lambda: AL.replay(AL.parse_word(m), False), stage=STAGE_FWD) + expect(out, T('restore gate 100 dropped, report forged, cleanup re-derived: own tracker'), 'words.tracker', + lambda: AW.tracker_check(AW.track(m))) + # 21 cleanup item moved below FULL + m = AL.mutant(wc) + m['cleanup'][0][-1] = list(FULL[:-1]) + expect(out, T('first cleanup item at a rank-8 frame'), 'words.cleanup', lambda: AW.check_cleanup(m)) + # 22 cleanup with its first item dropped + m = AL.mutant(wc) + del m['cleanup'][0] + expect(out, T('first cleanup item dropped: literal cleanup check'), 'words.cleanup', lambda: AW.check_cleanup(m)) + # 23 buffers: a helper_final endpoint removed (its buffer stays in the cleanup) + m = AL.mutant(wc) + del m['helper_final'][str(min(restored))] + expect(out, T('helper_final endpoint %d removed, cleanup kept (its buffer is no longer declared)' % min(restored)), + 'wc.frame', lambda: AW.word_pipeline(m, declared, expect_counts), stage='frame recount') + # 24 counts + expect(out, T('expected helper count 409'), 'words.counts', + lambda: AW.check_counts(AW.counts(AL.parse_word(wc), wc), dict(expect_counts, helpers=409))) + + +# ------------------------------------------------------------------------------------------------ scope C --- +def fill_controls(ctx, out): + rows, drows, order, disp, widths, local, sc, R = (ctx[k] for k in ('rows', 'drows', 'order', 'disp', 'widths', + 'local', 'sc', 'helpers')) + fam, fam_at, bins, top, wd = AF.fill_index(rows, order, disp, widths, sc) + + def both(name, rule, rr, changes): + dr = list(drows) + for q in changes: + dr[q] = CF.fc_row(rr[q], order, disp, widths, sc['pair_of'], sc['side_of']) + if len(rr) < len(drows): + dr = dr[:len(rr)] + expect(out, name + ' (own check_rows)', rule, lambda: AF.own_rows(rr, order, disp, widths, local, sc, R)) + expect(out, name + ' (vendored fill_check80)', rule, lambda: AF.vendored_rows(dr, order, disp, widths, local, + sc, R)) + both('last fill role dropped', 'R-a.count', rows[:-1], []) + b = next(b for b in sorted(bins) if len(bins[b]) >= 2) + q1, q2 = sorted(bins[b], key=lambda k: rows[k][5])[:2] + rr = list(rows) + rr[q2] = rows[q2][:5] + [rows[q1][5]] + both('fill role %d moved onto the offset of role %d in bin %r' % (q2, q1, b), 'R-b.overlap', rr, [q2]) + b = next(b for b in sorted(bins) if top[b][1] + 1 <= sc['rank'][b[1]] and len(bins[b]) >= 2) + q = top[b][0] + rr = list(rows) + rr[q] = rows[q][:5] + [rows[q][5] + 1] + both('top slice of bin %r lifted by one cell (gap below it)' % (b,), 'R-b.prefix', rr, [q]) + found = None + for q, (t, h, o, c, p, off) in enumerate(rows): + s, r = order[t] + for o2 in range(AF.T): + lo, hi = sc['win'][o2, c] + if o2 != o and not lo < t <= hi and (t, fam(o2, c, p)) not in fam_at and not ( + o2 == r and sc['pair_of'][c] == sc['stage_pair'][s]): + found = (q, o2) + break + if found: + break + q, o2 = found + rr = list(rows) + rr[q] = [rows[q][0], rows[q][1], o2] + rows[q][3:] + both('fill role %d re-hosted at owner %d outside its window' % (q, o2), 'R-d.window', rr, [q]) + found = None + for q, (t, h, o, c, p, off) in enumerate(rows): + s, r = order[t] + c2 = next((c2 for c2 in sorted(sc['rank']) if sc['pair_of'][c2] == sc['stage_pair'][s] + and (t, fam(r, c2, p)) not in fam_at), None) + if c2 is not None: + found = (q, r, c2) + break + q, r, c2 = found + rr = list(rows) + rr[q] = [rows[q][0], rows[q][1], r, c2] + rows[q][4:] + both('fill role %d re-hosted on its caller\'s active pair (owner %d, child %d)' % (q, r, c2), 'R-e.active_pair', + rr, [q]) + + +def pricing_controls(ctx, out): + pc, pp = ctx['pc'], ctx['pp'] + order, disp, sc, fill = ctx['order'], ctx['disp'], ctx['sc'], ctx['fill'] + profile15, claim15 = ctx['profile15'], ctx['claim15'] + rr, q, desc = AF.legal_move(fill['rows'], order, disp, pc['widths'], sc) + pm = AF.price(dict(fill, rows=rr), order, disp, ctx['words_c'], ctx['rec_c'], sc) + need(pm['own']['profile'] != pc['own']['profile'], 'control: the legal move does not change the profile') + expect(out, 'fill with one legal re-hosting (%s; R-a..R-e pass in both implementations): PROFILE.json' % desc, + 'fill.profile_file', lambda: AF.check_profile(pm['own']['profile'], profile15, 'fill.profile_file'), + legal_fill_rules_passed=True) + expect(out, 'fill with one legal re-hosting: idle remainders against PR2979', 'fill.idle', + lambda: AF.check_idle(pm['own'], pp['own'])) + expect(out, 'fill_check80 result of the re-hosted fill against check_rows of the published fill', 'fill.two_impl', + lambda: AF.compare_impl(pc['own'], pm['fc'])) + del pm + expect(out, 'the fill priced with the parent words\' recounts against PR3015\'s CLAIM profile', + 'fill.profile_claim', lambda: AF.check_profile(pp['own']['profile'], claim15['profile'], 'fill.profile_claim')) + p = dict(profile15, **{'48': profile15['48'] + 1}) + expect(out, 'PROFILE.json with one more rank-48 child', 'fill.profile_file', + lambda: AF.check_profile(pc['own']['profile'], p, 'fill.profile_file')) + prof = dict(pc['own']['profile']) + prof[1] += 1 + expect(out, 'complete profile with one more rank-1 child: rank mass', 'fill.mass', lambda: AF.check_mass(prof)) + expect(out, 'parent against parent with the R1 local delta: complete delta', 'fill.delta', + lambda: AF.check_delta(pp['own']['profile'], pp['own']['profile'], {1: -2, 2: 1})) + expect(out, 'complete delta against the local delta with the wrong sign', 'fill.delta', + lambda: AF.check_delta(pc['own']['profile'], pp['own']['profile'], {1: 2, 2: -1})) + c = dict(claim15, zero_buffers=90, physical_families=claim15['physical_families'] - 1) + expect(out, 'CLAIM with 90 private buffers and the stock lowered by one', 'fill.physical', + lambda: AF.physical(pc['helpers'], pc['buffers'], c)) + expect(out, 'physical stock from one private buffer fewer than the CLAIM', 'fill.physical', + lambda: AF.physical(pc['helpers'], pc['buffers'] - 1, claim15)) + expect(out, 'dispatch with its last entry dropped', 'fill.dispatch', + lambda: AF.dispatch_map(ctx['dispatch_list'][:-1], order)) + rec_bad = dict(ctx['rec_c']) + rec_bad['gauge44'] = dict(rec_bad['gauge44'], helper_widths=[rec_bad['gauge44']['helper_widths'][0] + 1] + + list(rec_bad['gauge44']['helper_widths'][1:])) + expect(out, 'recount with the first helper width raised by one against the word', 'fill.widths', + lambda: AF.price(fill, order, disp, ctx['words_c'], rec_bad, sc)) + + def disagree(fc): + return dict(fc, profile=dict(fc['profile'], **{'1': fc['profile']['1'] + 1})) + expect(out, 'vendored implementation\'s profile given one more rank-1 child before the comparison', + 'fill.two_impl', lambda: AF.price(fill, order, disp, ctx['words_c'], ctx['rec_c'], sc, fc_hook=disagree)) + expect(out, 'FILL with its columns reordered', 'fill.format', + lambda: AF.price(dict(fill, columns=list(reversed(fill['columns']))), order, disp, ctx['words_c'], + ctx['rec_c'], sc)) + inv = list(order) + i, j = inv.index((0, 5)), inv.index((1, 5)) + inv[i], inv[j] = inv[j], inv[i] + expect(out, 'per-replica stage inversion (replica 5)', 'order.projection', + lambda: AF.schedule(ctx['tpl'], ctx['t37'], inv)) + k = next(k for k in range(len(order) - 1) if order[k][1] != order[k + 1][1] and + CF.block_windows(ctx['tpl'], order[:k] + [order[k + 1], order[k]] + order[k + 2:], sc['stage_pair'], + sc['rank'])[0] != sc['win']) + o2 = order[:k] + [order[k + 1], order[k]] + order[k + 2:] + sched2 = FC.derive_schedule(AF.T, ctx['tpl'], o2) + expect(out, 'block-rule windows of the order against the event-rule windows of the order swapped at %d' % k, + 'windows.block_vs_event', lambda: CF.windows_agree(sc['win'], sched2)) + src = ctx['tpl']['execution_schedule'] + q = next(q for q, e in enumerate(src[:30]) if e['kind'] == 'bridge') + tpl_bad = dict(ctx['tpl'], execution_schedule=src[:q] + [dict(src[q], dst_replica=1)] + src[q + 1:]) + expect(out, 'template bridge event %d given a cross-replica field' % q, 'template.cross_replica_field', + lambda: AF.schedule(tpl_bad, ctx['t37'], order)) + + +# ------------------------------------------------------------------------------------------------ scope D --- +def kappa_controls(ctx, out): + prof, prof_p = ctx['profile_c'], ctx['profile_p'] + C, C79 = ctx['C'], ctx['C79'] + CA = ctx['CA'] + # each enclosure has its own straddle point (the vendored one is far tighter than the own one) + for label, mom, S in (('own enclosure', AK.moment, ctx['straddle']), ('vendored enclosure', CA.moment, ctx['straddle_vendored'])): + for name, a, rule in (('C + 1e-24', C + AK.E24, 'kappa.endpoint_accept'), + ('the straddle point S (enclosure contains 1)', S, 'kappa.endpoint_accept'), + ('C - 1e-24', C - AK.E24, 'kappa.endpoint_reject'), + ('S - 1e-24 (so that S must be rejected)', S - AK.E24, 'kappa.endpoint_reject')): + expect(out, 'endpoint claimed at %s (%s)' % (name, label), rule, lambda a=a, mom=mom: AK.endpoint_check(prof, a, mom=mom)) + expect(out, 'C with 25 digits', 'kappa.endpoint_format', lambda: AK.endpoint_format(C + Q(1, 10 ** 25))) + expect(out, 'C = 0', 'kappa.endpoint_format', lambda: AK.endpoint_format(Q(0))) + k = ctx['kappa'] + expect(out, 'CLAIM kappa + 1e-70', 'kappa.kappa', lambda: AK.kappa_check(k + AK.KAPPA_TERMS[1], C)) + expect(out, 'kappa against C + 1e-70', 'kappa.kappa', lambda: AK.kappa_check(k, C + AK.KAPPA_TERMS[1])) + gain = ctx['claimed_gain'] + expect(out, 'claimed gain + 1e-24', 'kappa.gain', lambda: AK.gain_check(k, ctx['kappa79'], gain + AK.E24)) + expect(out, 'gain of PR2979 over itself', 'kappa.gain', lambda: AK.gain_check(ctx['kappa79'], ctx['kappa79'], Q(0))) + expect(out, 'improvement with the new profile in place of the old one', 'kappa.improvement', + lambda: AK.improvement(prof, prof, C, C79)) + expect(out, 'improvement with the roles of the two claims swapped', 'kappa.improvement', + lambda: AK.improvement(prof, prof_p, C79, C)) + + def shifted(p, a): + lo, hi = CA.moment(p, a) + return lo + Q(1, 10 ** 20), hi + Q(1, 10 ** 20) + expect(out, 'vendored enclosure shifted by 1e-20 (disjoint from the own one, verdict changes)', 'kappa.two_impl', + lambda: AK.two_impl(prof, C, shifted)) + + def shifted_down(p, a): + lo, hi = CA.moment(p, a) + return lo - Q(1, 10 ** 50), hi - Q(1, 10 ** 50) + expect(out, 'vendored enclosure shifted by -1e-50 (disjoint from the own one, same verdict)', 'kappa.two_impl', + lambda: AK.two_impl(prof, C, shifted_down)) + expect(out, 'prediction started from a C above the root', 'kappa.predict', + lambda: AK.predict_endpoint(prof, C + AK.E24)) + bad = dict(prof) + bad[1] = -1 + expect(out, 'profile with a negative count', 'kappa.profile', lambda: AK.moment(bad, C)) + expect(out, 'profile with a rank-73 child', 'kappa.profile', lambda: AK.moment(dict(list(prof.items()) + [(73, 1)]), C)) + + +# ------------------------------------------------------------------------------------------------ scope E --- +def journal_controls(ctx, out): + fill, edits = ctx['fill'], ctx['edits'] + e = copy.deepcopy(edits) + e[0][1][5] += 1 + expect(out, 'journal edit 0 with its preimage offset raised by one', 'journal.preimage', + lambda: AF.apply_journal(fill, e)) + e = copy.deepcopy(edits) + e.append(copy.deepcopy(edits[0])) + expect(out, 'journal with its first edit repeated', 'journal.index', lambda: AF.apply_journal(fill, e)) + e = copy.deepcopy(edits) + e[0][2][1] += 1 + expect(out, 'journal edit 0 whose new row changes the helper', 'journal.row', lambda: AF.apply_journal(fill, e)) + prof = dict(ctx['profile_j']) + prof[13] = prof.pop(14) + expect(out, 'journaled profile against PR3018\'s RESULT profile with its rank-14 child at rank 13', + 'journal.profile', lambda: AF.check_profile(prof, ctx['result18']['profile'], 'journal.profile')) + fj, _ = AF.apply_journal(fill, edits[:-1]) + expect(out, 'journal with its last edit dropped: the fill priced', ctx['last_edit_dropped_rule'], + lambda: AF.price(fj, ctx['order'], ctx['disp'], ctx['words_p'], ctx['rec_p'], ctx['sc'])) diff --git a/research/t74-3015-restore-edit-audit/audit_edit.py b/research/t74-3015-restore-edit-audit/audit_edit.py new file mode 100644 index 0000000000..44df8effcf --- /dev/null +++ b/research/t74-3015-restore-edit-audit/audit_edit.py @@ -0,0 +1,405 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Scope A: PR #3015's declared restore edit R1 as a literal change of PR #2979's words, with code that does not +import or run either PR. + +own_diff() the candidate word equals the parent word outside the sections 'restore', 'report' and 'cleanup' + (rule edit.sections); the restore section differs by exactly the declared hunk: parent[start:stop] + is the declared old block, candidate[start:start+len(new)] the declared new block, the lengths + agree, and the minimal common-prefix/suffix hunk lies inside the declared one, i.e. both words + agree before and after it (edit.hunk). +net_operator() the new block equals the old block as a formal operator on the registers it touches (frames ignored, + exact Fractions; edit.net_operator). +own_chain() a fresh implementation of the lineage's monotone frame chain (precondition and compensation at frame + 0 on targets, A and B gates climb their registers to the gate frame, A and B warps need the lender at + U and set E at rank zero, the cut's COPY children per distinct served level, restore gates climb, + every live register climbs to its end frame, cleanup at FULL). It returns the paid profile, the + climb list of every register (section, index, from-dimension, to-dimension) and, for the census, the + frame of every register before each restore gate and the next frame each register must reach after + it (snapshots of all registers). Its paid profile must equal the vendored + check_words.frame_recount (edit.two_impl). +attribution() the registers whose climb dimensions differ between parent and candidate, and the paid delta. +r1_class_census() every adjacent pair of restore gates t += q1*s1; t += q2*s2 at one frame F, rewritten either way + round as s += (q'/q) s'; t += q s; s -= (q'/q) s' with the first gate at the span of the two + current frames (the cheapest legal choice), the second at F and the third at EVERY subspace F3 + with F <= F3 <= G, G = the intersection of the next frames s and s' must reach (F3 = F is always + legal; a larger F3 can merge a later climb). Every candidate word (cleanup re-derived) is + recounted with the vendored frame recount, nothing is asserted without a recount; the record of a + pair/order keeps its best (lowest-mass-weighted) delta and every option. Pricing (sign of the + moment change at the root) is done in audit_kappa. +Standard library only; Python 3.8-compatible syntax. +""" +import copy +import math +from collections import Counter +from fractions import Fraction + +import audit_lib as AL +import check_words as CW +import words_check as WC +from audit_common import AuditFail, need + +V = AL.V +H = 9 +ALLOWED_DIFF = ('restore', 'report', 'cleanup') + + +# ------------------------------------------------------------------------------------- GF(2) linear algebra --- +def ech(vectors): + """Reduced echelon basis (tuple, descending pivots) of the span of integer bit-vectors.""" + piv = {} + for a in vectors: + a = int(a) + while a: + b = a.bit_length() - 1 + if b in piv: + a ^= piv[b] + else: + piv[b] = a + break + for b in sorted(piv): + for c in list(piv): + if c > b and (piv[c] >> b) & 1: + piv[c] ^= piv[b] + return tuple(piv[b] for b in sorted(piv, reverse=True)) + + +def inside(a, b): + """Every vector of a lies in the span of b.""" + pb = dict((x.bit_length() - 1, x) for x in ech(b)) + for a0 in a: + x = int(a0) + while x: + t = x.bit_length() - 1 + if t not in pb: + return False + x ^= pb[t] + return True + + +def regs(g): + return (g[1], g[2]) if g[0] == 'add' else (g[1],) + + +# ------------------------------------------------------------------------------------------------- own diff --- +def own_diff(parent, cand, declared_edit): + """See the module docstring. Returns the record of the hunk.""" + keys = set(parent) | set(cand) + diff = sorted(k for k in keys if parent.get(k) != cand.get(k)) + need(set(diff) <= set(ALLOWED_DIFF), 'edit.sections: sections differing beyond %r: %r' % (ALLOWED_DIFF, diff)) + need('restore' in diff, 'edit.hunk: the restore sections are identical') + e = declared_edit + need(e['section'] == 'restore', 'edit.hunk: declared section %r' % e['section']) + a, b, old, new = e['start'], e['stop'], e['old'], e['new'] + po, cn = parent['restore'], cand['restore'] + need(0 <= a <= b <= len(po) and po[a:b] == old, 'edit.hunk: parent[%d:%d] is not the declared old block' % (a, b)) + need(cn[a:a + len(new)] == new, 'edit.hunk: candidate[%d:%d] is not the declared new block' % (a, a + len(new))) + need(len(cn) == len(po) - len(old) + len(new), 'edit.hunk: restore length') + # minimal hunk by common prefix / suffix: it must lie inside the declared one, which is exactly the statement + # that the words agree outside the declared hunk (a difference before it lowers p, one after it lowers s) + p = 0 + while p < min(len(po), len(cn)) and po[p] == cn[p]: + p += 1 + s = 0 + while s < min(len(po), len(cn)) - p and po[len(po) - 1 - s] == cn[len(cn) - 1 - s]: + s += 1 + need(a <= p and len(po) - s <= b, 'edit.hunk: minimal hunk [%d, %d) outside the declared [%d, %d)' + % (p, len(po) - s, a, b)) + return dict(sections_differing=diff, declared=dict(section='restore', start=a, stop=b, old_gates=len(old), + new_gates=len(new)), + minimal_hunk=dict(parent=[p, len(po) - s], candidate=[p, len(cn) - s]), + restore_lengths=dict(parent=len(po), candidate=len(cn)), + cleanup_lengths=dict(parent=len(parent['cleanup']), candidate=len(cand['cleanup'])), + touched_registers=sorted(set(r for g in old + new for r in regs(g)))) + + +# --------------------------------------------------------------------------------------------- net operator --- +def apply_formal(rows, g): + if g[0] == 'add': + t, s, q = g[1], g[2], Fraction(g[3], g[4]) + need(t != s, 'edit.net_operator: self add') + dst = rows[t] + for k, v in list(rows[s].items()): + nv = dst.get(k, 0) + q * v + if nv: + dst[k] = nv + else: + dst.pop(k, None) + elif g[0] == 'scale': + q = Fraction(g[2], g[3]) + rows[g[1]] = dict((k, v * q) for k, v in rows[g[1]].items()) + else: + raise AuditFail('edit.net_operator: unknown gate %r' % (g[0],)) + + +def net_operator(old, new): + """Both blocks as formal operators on the union of their registers (identity start); must be equal.""" + touched = sorted(set(r for g in old + new for r in regs(g))) + states = [] + for block in (old, new): + rows = dict((r, {r: Fraction(1)}) for r in touched) + for g in block: + need(all(r in rows for r in regs(g)), 'edit.net_operator: register outside the block') + apply_formal(rows, g) + states.append(rows) + need(states[0] == states[1], 'edit.net_operator: the new block is not the old block as an operator') + return dict(registers=touched, + operator=dict((str(r), dict((str(k), str(v)) for k, v in sorted(states[0][r].items()))) + for r in touched)) + + +# -------------------------------------------------------------------------------------------- own frame chain --- +def own_chain(P): + """See the module docstring. P is the vendored parse (audit_lib.parse_word).""" + v, full = P['v'], ech(P['full']) + cur = dict((r, ech(P['start'][r])) for r in P['live']) + paid, climbs = Counter(), dict((r, []) for r in P['live']) + before_post, next_post = {}, {} + + def istarget(r): + return v <= r < 2 * v + + def climb(r, F, sec, i): + F = ech(F) + need(r in cur, 'chain.live: register %d not live at %s[%d]' % (r, sec, i)) + need(inside(cur[r], F), 'chain.monotone: %s[%d] climbs %d from dim %d to a frame of dim %d not containing it' + % (sec, i, r, len(cur[r]), len(F))) + d = len(F) - len(cur[r]) + if d: + paid[d] += 1 + climbs[r].append((sec, i, len(cur[r]), len(F))) + cur[r] = F + + for i, g in enumerate(P['pre']): + need(g[-1] == () and istarget(g[1]), 'chain.pre: item %d not a frame-0 target gate' % i) + for r in WC.regs_of(g): + climb(r, (), 'pre', i) + for i, g in enumerate(P['A']): + if g[0] == 'warp': + reg, U, E = g[1], ech(g[3]), ech(g[4]) + need(reg in cur and not istarget(reg) and cur[reg] == U, 'chain.awarp: A warp %d lender frame != U' % i) + cur[reg] = E + continue + need(g[-1] is not None, 'chain.A: unframed A gate %d' % i) + for r in WC.regs_of(g): + climb(r, g[-1], 'A', i) + for t in range(v): + need(cur[v + t] == ech(P['target_levels'].get(t, ())), 'chain.levels: target %d off its level after A' % t) + served = dict((q, set()) for q in P['centers']) + for q, U in zip(P['centers'], P['center_frames']): + need(cur[q] == ech(U), 'chain.centre: centre %d frame' % q) + for i, g in enumerate(P['cut']): + need(g[0] == 'add' and g[-1] is None and istarget(g[1]) and g[2] in served, 'chain.cut: item %d' % i) + served[g[2]].add(cur[g[1]]) + copy_children = [] + for q, U in zip(P['centers'], P['center_frames']): + prev = ech(U) + for T in sorted(served[q], key=lambda S: (-len(S), S)): + need(inside(T, prev), 'chain.copy: served levels of centre %d not nested' % q) + if T != prev: + paid[len(prev) - len(T)] += 1 + copy_children.append(len(prev) - len(T)) + prev = T + for i, it in enumerate(P['B_items']): + if it[0] == 'warp': + L, U, E = it[1], ech(it[3]), ech(it[4]) + need(L in cur and not istarget(L) and cur[L] == U, 'chain.bwarp: B warp %d lender frame != U' % i) + cur[L] = E + else: + need(it[-1] is not None, 'chain.B: unframed B gate %d' % i) + for r in WC.regs_of(it): + climb(r, it[-1], 'B', i) + post = list(P['post']) + # next frame each register must reach after restore gate i: the frame of the next restore gate touching it, + # else its end frame (sources and R helpers: FULL; targets: hyperplane; restored helpers: helper_final) + nxt = dict((r, ech(P['end'][r])) for r in P['live']) + for i in range(len(post) - 1, -1, -1): + g = post[i] + next_post[i] = dict(nxt) # the next frame every register must reach after restore gate i + for r in WC.regs_of(g): + nxt[r] = ech(g[-1]) + for i, g in enumerate(post): + before_post[i] = dict(cur) # the frame of every register before restore gate i + for r in WC.regs_of(g): + climb(r, g[-1], 'post', i) + for r in P['live']: + climb(r, P['end'][r], 'end', 0) + for i, it in enumerate(P['cleanup']): + need(ech(it[-1]) == full, 'chain.cleanup: item %d not at FULL' % i) + for r in ((it[1],) if it[0] == 'warp' else WC.regs_of(it)): + need(r in P['buffers'] or cur.get(r) == full, 'chain.cleanup: item %d touches a non-FULL register %d' + % (i, r)) + for r in P['live']: + need(sum(c[3] - c[2] for c in climbs[r]) == len(ech(P['end'][r])) - len(ech(P['start'][r])), + 'chain.width: charge of %d != its width' % r) + helpers = [r for r in P['live'] if r >= 2 * v] + return dict(paid=dict(sorted(paid.items())), climbs=climbs, before_post=before_post, next_post=next_post, + copy_children=copy_children, + inventory=dict(sorted(Counter(len(ech(P['end'][r])) - len(ech(P['start'][r])) + for r in helpers).items())), + mass=sum(k * c for k, c in paid.items())) + + +def two_impl(chain, fr): + """edit.two_impl: the own chain and the vendored recount give the same paid profile, inventory and mass.""" + need(chain['paid'] == dict(fr['paid']) and chain['inventory'] == dict(fr['inventory']) and chain['mass'] == fr['mass'], + 'edit.two_impl: own chain %r != vendored recount %r' % (chain['paid'], fr['paid'])) + return dict(paid_equal=True, inventory_equal=True, mass=chain['mass']) + + +# ---------------------------------------------------------------------------------------------- attribution --- +def dims(lst): + return [(c[2], c[3]) for c in lst] + + +def attribution(chain_p, chain_c, expected_delta, expected_regs): + """The paid delta (edit.delta: exactly expected_delta, checked first), the registers whose climb dimensions + differ (edit.attribution: exactly expected_regs) and the registers whose climb labels only move (reported).""" + changed, moved = [], [] + for r in sorted(set(chain_p['climbs']) | set(chain_c['climbs'])): + a, b = chain_p['climbs'].get(r, []), chain_c['climbs'].get(r, []) + if dims(a) != dims(b): + changed.append(r) + elif a != b: + moved.append(r) + delta = AL.counter_delta(chain_c['paid'], chain_p['paid']) + need(delta == dict(expected_delta), 'edit.delta: paid delta %r != %r' % (delta, dict(expected_delta))) + need(changed == sorted(expected_regs), 'edit.attribution: climb dimensions changed for %r, expected %r' + % (changed, sorted(expected_regs))) + detail = {} + for r in changed + moved: + detail[str(r)] = dict(parent=[list(c) for c in chain_p['climbs'].get(r, [])], + candidate=[list(c) for c in chain_c['climbs'].get(r, [])]) + return dict(dimensions_changed=changed, labels_only_moved=moved, paid_delta=AL.hist(delta), climbs=detail) + + +# --------------------------------------------------------------------------------------------------- census --- +def dyadic(q): + return q != 0 and q.denominator & (q.denominator - 1) == 0 + + +def intersect(A, B): + """Basis of span(A) ∩ span(B) over GF(2) (brute force over the 512 vectors of GF(2)^9).""" + def member(x, S): + return inside((x,), S) + return ech([x for x in range(1, 1 << H) if member(x, A) and member(x, B)]) + + +def between(F, G): + """Every subspace F3 with span(F) <= F3 <= span(G), as echelon bases (brute force over the quotient).""" + F, G = ech(F), ech(G) + need(inside(F, G), 'census.between: F not inside G') + extra = [x for x in range(1, 1 << H) if inside((x,), G) and not inside((x,), F)] + out = set([F]) + frontier = [F] + while frontier: + nxt = [] + for S in frontier: + for x in extra: + if not inside((x,), S): + T = ech(S + (x,)) + if T not in out: + out.add(T) + nxt.append(T) + frontier = nxt + return sorted(out, key=lambda S: (len(S), S)) + + +def hyperplane(p): + """E_p = {x : = 0 mod 2}, as in the lineage's parsers.""" + return ech([x for x in range(1, 1 << H) if bin(x & p).count('1') % 2 == 0]) + + +def v45_identity(frame): + """The rank-7 frame of R1's first gate is E_7 ∩ E_42 ∩ E_45 (rule edit.v45).""" + want = intersect(intersect(hyperplane(7), hyperplane(42)), hyperplane(45)) + need(ech(frame) == want and len(want) == 7, 'edit.v45: the first new frame is not E_7 ∩ E_42 ∩ E_45') + return dict(frame=list(ech(frame)), equals_E7_E42_E45=True, dim=len(want)) + + +def rewrite(w, i, a, b, F1, F, F3, q_a, ratio): + """The word with restore[i:i+2] replaced by the R1-class block with carrier a absorbing b (cleanup re-derived; + the report fields are left as they are, the recount does not read them).""" + m = copy.deepcopy(w) + new = [['add', a, b, ratio.numerator, ratio.denominator, list(F1)], + ['add', w['restore'][i][1], a, q_a.numerator, q_a.denominator, list(F)], + ['add', a, b, -ratio.numerator, ratio.denominator, list(F3)]] + m['restore'][i:i + 2] = new + m['cleanup'] = AL.rederive_cleanup(m) + return m, new + + +def r1_class_census(w, P, chain, parent_paid): + """See the module docstring. Returns (records, summary).""" + post = w['restore'] + records = [] + for i in range(len(post) - 1): + g1, g2 = post[i], post[i + 1] + if g1[0] != 'add' or g2[0] != 'add' or g1[1] != g2[1] or g1[-1] is None or g2[-1] is None: + continue + if ech(g1[-1]) != ech(g2[-1]): + continue + t, s1, s2 = g1[1], g1[2], g2[2] + if s1 == s2 or t in (s1, s2): + continue + F = ech(g1[-1]) + for (a, b, ga, gb) in ((s1, s2, g1, g2), (s2, s1, g2, g1)): + q_a, q_b = Fraction(ga[3], ga[4]), Fraction(gb[3], gb[4]) + ratio = q_b / q_a + rec = dict(index=i, target=t, carrier=a, absorbed=b, order=('s1 absorbs s2' if a == s1 else 's2 absorbs s1'), + frame_dim=len(F)) + if not dyadic(ratio): + rec.update(legal=False, why='non-dyadic ratio') + records.append(rec) + continue + cur_a, cur_b = chain['before_post'][i][a], chain['before_post'][i][b] + F1 = ech(cur_a + cur_b) + nxt_a, nxt_b = chain['next_post'][i + 1][a], chain['next_post'][i + 1][b] + G = intersect(nxt_a, nxt_b) + rec.update(dims=dict(cur_a=len(cur_a), cur_b=len(cur_b), F1=len(F1), F=len(F), next_a=len(nxt_a), + next_b=len(nxt_b), G=len(G))) + if not inside(F1, F): + rec.update(legal=False, why='span of the current frames not inside F') + records.append(rec) + continue + if not inside(F, G): + rec.update(legal=False, why='F not inside the intersection of the next frames') + records.append(rec) + continue + options = [] + for F3 in between(F, G): + m, new = rewrite(w, i, a, b, F1, F, F3, q_a, ratio) + try: + fr = CW.frame_recount(AL.parse_word(m)) + except WC.Reject as err: + options.append(dict(F3=len(F3), legal=False, + why='vendored recount: %s %s' % (err.check, ' '.join(str(err.msg).split())[:100]))) + continue + delta = AL.counter_delta(fr['paid'], parent_paid) + options.append(dict(F3=len(F3), legal=True, delta=AL.hist(delta), mass=sum(k * v for k, v in delta.items()), + new_block=new)) + legal_opts = [o for o in options if o['legal']] + need(legal_opts and all(o['delta'] == {} for o in legal_opts if o['F3'] == len(F)), + 'census.f3: the third gate at F must be legal with delta zero at restore[%d]' % i) + # every legal option's delta is kept; which of them improve is decided by the exact pricing (audit_kappa); + # 'delta' is only a display choice: the lowest proxy price (rank mass first, then the concave correction) + best = min(legal_opts, key=lambda o: proxy(o['delta'])) + rec.update(legal=True, options=len(options), legal_options=len(legal_opts), f3_dims=[o['F3'] for o in legal_opts], + option_deltas=sorted(set(AL.canon(o['delta']) for o in legal_opts)), + delta=best['delta'], best_F3=best['F3'], new_block=best['new_block'], + nonzero_options=[dict(F3=o['F3'], delta=o['delta']) for o in legal_opts if o['delta']]) + records.append(rec) + legal = [r for r in records if r['legal']] + summary = dict(adjacent_same_target_pairs=len(set(r['index'] for r in records)), candidates=len(records), + legal=len(legal), illegal_reasons=dict(Counter(r['why'].split(':')[0] for r in records + if not r['legal'])), + rewrites_recounted=sum(r['options'] for r in legal), + records_with_a_nonzero_option=sum(1 for r in legal if r['nonzero_options']), + option_deltas=dict(Counter(AL.canon(o['delta']) for r in legal for o in r['nonzero_options']))) + return records, summary + + +def proxy(delta): + """Display-only ordering of a per-call profile delta: rank mass first, then the first-order concave correction + -sum d_r r ln r (the sign of the moment change of a mass-zero delta).""" + d = AL.intkeys(delta) + return (sum(v * r for r, v in d.items()), -sum(v * r * math.log(r) for r, v in d.items())) diff --git a/research/t74-3015-restore-edit-audit/audit_fill.py b/research/t74-3015-restore-edit-audit/audit_fill.py new file mode 100644 index 0000000000..fd2dc5f38e --- /dev/null +++ b/research/t74-3015-restore-edit-audit/audit_fill.py @@ -0,0 +1,202 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Scope C: PR #3015's literal T74 allocation (FILL/ORDER/DISPATCH byte-identical to PR #2979's) priced with the +recounted local profiles of the edited words, in two implementations (this contributor's own check_rows of PR2804 +and the vendored fill_check80 of PR2387), and scope E's journal application for PR #3018. + +schedule() the T74 template (PR2269's GLOBAL-TEMPLATE, read at b479fc55) and the T37 inputs template (equal to + PR2979's allocation/vendor/TEMPLATE.json.gz), the order's per-replica projection, the block-level + windows against the event-position windows of the vendored derive_schedule. +price() every fill row against rules R-a..R-e in both implementations, the R-c recount (idle remainders, + complete profile), with the helper widths and local profiles taken from the frame recounts of the + words given (not from the words' reports), and the two-implementation comparison (fill.two_impl). +check_*() the complete profile against PROFILE.json and CLAIM.json (fill.profile_file, fill.profile_claim), + the rank-mass identity (fill.mass), the complete delta against PR2979 = 666 x the local delta + (fill.delta), the unchanged idle remainders (fill.idle), the physical stock W + helpers + 8 + buffers + + 2 against CLAIM.json (fill.physical). +apply_journal() PR3018's EXCHANGE.json edits [row index, old row, new row] applied to PR2979's rows; every preimage + must match (journal.preimage) and every index be distinct (journal.index). +Standard library only; Python 3.8-compatible syntax. +""" +import hashlib +from collections import Counter, defaultdict + +import audit_lib as AL +import check_fill as CF +import fill_check80 as FC +from audit_common import need + +V, M, T, STAGES = 112, 73, 74, 9 +FPR = 2 * 4 * V +W = FPR * T +CALLS = STAGES * T +FILL_COLUMNS = ['time', 'helper', 'owner_replica', 'child', 'port', 'offset'] +PROVIDER_OF = (('gauge44', 'base'), ('extra', 'extra')) + + +# ------------------------------------------------------------------------------------------------ schedule --- +def schedule(tpl, t37, order): + stage_pair, rank, info = CF.template_structure(tpl, t37) + CF.order_projection(order) + win, pair_of, side_of = CF.block_windows(tpl, order, stage_pair, rank) + sched = FC.derive_schedule(T, tpl, order) + wt = CF.windows_agree(win, sched) + return dict(stage_pair=stage_pair, rank=rank, win=win, pair_of=pair_of, side_of=side_of, sched=sched, + info=dict(calls=info['calls'], per_replica_events=info['per_replica_events'], + t37_events_recipe_ranks_equal=info['t37_events_recipe_ranks_equal'], + child_ranks=dict((str(k), v) for k, v in sorted(Counter(rank.values()).items())), + windows=len(win), windows_sha256=AL.sha(sorted([list(k), v] for k, v in wt.items())))) + + +def dispatch_map(dispatch_list, order): + disp = dict(((s, r), p) for s, r, p in dispatch_list) + need(len(disp) == len(dispatch_list) == len(order) == CALLS and sorted(disp) == sorted(order) + and set(disp.values()) <= set(p for p, _ in PROVIDER_OF), + 'fill.dispatch: dispatch does not cover the %d calls once with known providers' % CALLS) + return disp + + +# ---------------------------------------------------------------------------------------------------- fill --- +def own_rows(rows, order, disp, widths, local, sc, helpers, skip=()): + saved = CF.CLAIM['helpers'] + CF.CLAIM['helpers'] = helpers + try: + return CF.check_rows(rows, order, disp, widths, local, sc['rank'], sc['win'], sc['pair_of'], sc['side_of'], + sc['stage_pair'], skip) + finally: + CF.CLAIM['helpers'] = saved + + +def fc_rows(rows, order, disp, widths, sc): + return [CF.fc_row(z, order, disp, widths, sc['pair_of'], sc['side_of']) for z in rows] + + +def vendored_rows(drows, order, disp, widths, local, sc, helpers): + ctx = dict(T=T, R=helpers, W=W, order=order, dispatch=disp, widths=widths, local_profiles=local) + return FC.check_roles(ctx, sc['sched'], drows) + + +def compare_impl(own, fc): + need(fc['idle'] == AL.hist(own['idle']) and fc['profile'] == AL.hist(own['profile']) + and fc['rank_mass'] == own['rank_mass'], + 'fill.two_impl: fill_check80 idle/profile/mass != check_rows') + return dict(idle_equal=True, profile_equal=True, rank_mass_equal=True, roles=own['roles']) + + +def price(fill, order, disp, words, recounts, sc, keep_drows=False, fc_hook=None): + """words: {'gauge44': base word, 'extra': extra word}; recounts: the same keys -> frame recounts (scope B). + fc_hook (negative controls only): applied to the vendored implementation's result before the comparison.""" + need(fill['columns'] == FILL_COLUMNS and fill['dispatch_overrides'] == [], 'fill.format: columns/overrides') + widths, local, ended = {}, {}, {} + for pid in words: + widths[pid], ended[pid] = CF.word_widths(words[pid]) + need(widths[pid] == recounts[pid]['helper_widths'], 'fill.widths: word widths != recount (%s)' % pid) + local[pid] = Counter(recounts[pid]['paid']) + helpers = len(widths['gauge44']) + need(all(len(x) == helpers for x in widths.values()), 'fill.widths: helper count differs between providers') + rows = fill['rows'] + own = own_rows(rows, order, disp, widths, local, sc, helpers) + drows = fc_rows(rows, order, disp, widths, sc) + fc = vendored_rows(drows, order, disp, widths, local, sc, helpers) + if fc_hook is not None: + fc = fc_hook(fc) + two = compare_impl(own, fc) + return dict(own=own, fc=fc, two_impl=two, widths=widths, local=local, helpers=helpers, buffers=len(ended['gauge44']), + buffers_by_provider=dict((p, len(e)) for p, e in ended.items()), drows=drows if keep_drows else None) + + +def summary(pr): + own = pr['own'] + return dict(roles=own['roles'], idle=AL.hist(own['idle']), profile=AL.hist(own['profile']), + rank_mass=own['rank_mass'], deficit=own['deficit'], hosted_width=own['hosted_width'], + capacity=own['capacity'], cross_replica_roles=own['cross_replica_roles'], + occupied_bins=own['occupied_bins'], bins=own['bins'], helpers=pr['helpers'], + private_buffers=pr['buffers'], two_impl=pr['two_impl'], + vendored_fill_check80=dict(roles=pr['fc']['roles'], idle=pr['fc']['idle'], profile=pr['fc']['profile'], + rank_mass=pr['fc']['rank_mass'])) + + +# -------------------------------------------------------------------------------------------------- checks --- +def check_profile(prof, claimed, rule): + need(prof == AL.intkeys(claimed), '%s: complete profile %r != %r' % (rule, AL.hist(prof), claimed)) + + +def check_mass(prof): + mass = sum(r * n for r, n in prof.items()) + need(mass == (M - 1) * W + 64 * CALLS, 'fill.mass: rank mass %d != 72W + 64N' % mass) + return mass + + +def check_delta(prof_new, prof_old, local_delta): + delta = AL.counter_delta(prof_new, prof_old) + want = dict((k, CALLS * v) for k, v in local_delta.items()) + need(delta == want, 'fill.delta: complete delta %r != 666 x %r' % (delta, local_delta)) + return delta + + +def check_idle(own_new, own_old): + need(own_new['idle'] == own_old['idle'], 'fill.idle: idle remainders differ') + + +def physical(helpers, buffers, claim): + terms = dict(live=W, helpers=helpers, centres=8, private_buffers=buffers, coefficient=2) + got = sum(terms.values()) + need(claim['live_families'] == W and claim['helpers'] == helpers and claim['zero_buffers'] == buffers + and claim['physical_families'] == got, + 'fill.physical: own %d = %r != CLAIM %r' % (got, terms, dict((k, claim[k]) for k in + ('live_families', 'helpers', 'zero_buffers', + 'physical_families')))) + return dict(physical=got, terms=terms) + + +def fill_sha256(raw): + return hashlib.sha256(raw).hexdigest() + + +# ------------------------------------------------------------------------------------------------ journal --- +def apply_journal(fill, edits): + rows = list(fill['rows']) + seen = set() + for k, (idx, old, new) in enumerate(edits): + need(isinstance(idx, int) and 0 <= idx < len(rows) and idx not in seen, 'journal.index: edit %d index %r' % (k, idx)) + seen.add(idx) + need(rows[idx] == old, 'journal.preimage: edit %d: row %d is %r, not %r' % (k, idx, rows[idx], old)) + need(isinstance(new, list) and len(new) == 6 and new[:2] == old[:2], 'journal.row: edit %d keeps call and helper' % k) + rows[idx] = list(new) + return dict(fill, rows=rows), dict(edits=len(edits), rows_changed=len(seen), + location_changes=sum(1 for _, o, n in edits if o[2:5] != n[2:5]), + offset_only_changes=sum(1 for _, o, n in edits if o[2:5] == n[2:5])) + + +# --------------------------------------------------------------------------------------- control helpers --- +def fill_index(rows, order, disp, widths, sc): + def fam(o, c, p): + return o * FPR + (2 * sc['pair_of'][c] + sc['side_of'][c]) * V + p + fam_at, bins = {}, defaultdict(list) + for q, (t, h, o, c, p, off) in enumerate(rows): + fam_at[t, fam(o, c, p)] = q + bins[o, c, p].append(q) + + def wd(z): + return widths[disp[order[z[0]]]][z[1]] + top = {} + for b, members in bins.items(): + q = max(members, key=lambda k: rows[k][5]) + top[b] = (q, rows[q][5] + wd(rows[q])) + return fam, fam_at, bins, top, wd + + +def legal_move(rows, order, disp, widths, sc): + """A fill that still satisfies R-a..R-e but has a different idle histogram.""" + fam, fam_at, bins, top, wd = fill_index(rows, order, disp, widths, sc) + for b in sorted(bins): + if len(bins[b]) < 2: + continue + q = top[b][0] + t, h, o, c, p, off = rows[q] + w = wd(rows[q]) + for p2 in range(V): + if (o, c, p2) not in bins and (t, fam(o, c, p2)) not in fam_at and w <= sc['rank'][c]: + rr = list(rows) + rr[q] = [t, h, o, c, p2, 0] + return rr, q, 'top slice of bin %r (width %d) moved to the empty bin %r' % (b, w, (o, c, p2)) + raise AL.AuditFail('control: no legal move found') diff --git a/research/t74-3015-restore-edit-audit/audit_kappa.py b/research/t74-3015-restore-edit-audit/audit_kappa.py new file mode 100644 index 0000000000..6e935547c9 --- /dev/null +++ b/research/t74-3015-restore-edit-audit/audit_kappa.py @@ -0,0 +1,202 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Scope D: the complex endpoint and kappa of PR #3015 from its complete profile, with an own rational-interval +moment enclosure for every rank (cross-checked against the vendored check_accounting.moment of PR2804 on the ranks +that one tabulates), the exact gain over PR #2979, the improvement test, the pricing of profile deltas (census), and +the PR #3018 composition prediction. + +M(a) = (1/(73 W)) sum_r n_r r (73/r)^a = sum_r n_r r exp(a (ln 73 - ln r)) / (73 W), increasing in a; the complex +endpoint C is the largest 24-digit decimal with M(C) < 1 (and M(C + 1e-24) > 1); kappa = C - 1e-46 - 1e-70. +ln r (r >= 1): r = 2^k x with 1 <= x < 2, ln x = 2 atanh((x-1)/(x+1)) by its series with the geometric tail, ln 2 = +2 atanh(1/3); exp(y) for 0 <= y < 1 by its Taylor series with the tail bound 2 y^N / N!; every bound is rounded +outward to the grid 10^-60. Standard library only; Python 3.8-compatible syntax. +""" +from fractions import Fraction as Q + +import audit_lib as AL +from audit_common import need + +M = 73 +W = 66304 +CALLS = 666 +E24 = Q(1, 10 ** 24) +KAPPA_TERMS = (Q(1, 10 ** 46), Q(1, 10 ** 70)) +GRID = 10 ** 60 +_LN = {} + + +def floor_g(x): + return Q((x * GRID).__floor__(), GRID) + + +def ceil_g(x): + return Q(-((-x * GRID).__floor__()), GRID) + + +def atanh_iv(z, N=80): + """0 <= z < 1: (partial sum, partial sum + tail) of atanh(z) = sum z^(2j+1)/(2j+1).""" + need(0 <= z < 1, 'kappa.ln: atanh argument') + s, zp, z2 = Q(0), z, z * z + for j in range(N): + s += zp / (2 * j + 1) + zp *= z2 + return s, s + zp / (2 * N + 1) / (1 - z2) + + +def ln_interval(r): + """Enclosure of ln r for an integer r >= 1 (cached).""" + if r in _LN: + return _LN[r] + need(isinstance(r, int) and r >= 1, 'kappa.ln: rank') + k, x = 0, Q(r) + while x >= 2: + x /= 2 + k += 1 + l2 = atanh_iv(Q(1, 3)) + lx = atanh_iv((x - 1) / (x + 1)) + lo = floor_g(2 * (k * l2[0] + lx[0])) + hi = ceil_g(2 * (k * l2[1] + lx[1])) + _LN[r] = (lo, hi) + return _LN[r] + + +def exp_interval(y_lo, y_hi, N=40): + """Enclosure of exp over [y_lo, y_hi], 0 <= y_lo <= y_hi < 1.""" + need(0 <= y_lo <= y_hi < 1, 'kappa.exp: argument outside [0, 1)') + out = [] + for y, up in ((y_lo, False), (y_hi, True)): + t = s = Q(1) + for j in range(1, N): + t = t * y / j + s += t + if up: + s += 2 * t * y / N # tail bound sum_{j>=N} y^j/j! <= 2 y^N/N! for y <= (N+1)/2 + out.append(ceil_g(s)) + else: + out.append(floor_g(s)) + return out[0], out[1] + + +def H(r, a): + """Enclosure of r (73/r)^a.""" + l73, lr = ln_interval(M), ln_interval(r) + L_lo, L_hi = l73[0] - lr[1], l73[1] - lr[0] + need(L_lo > 0, 'kappa.rank: rank %d not below 73' % r) + e_lo, e_hi = exp_interval(a * L_lo, a * L_hi) + return r * e_lo, r * e_hi + + +def moment(profile, a, live=W): + """Enclosure of M(a) for a complete profile {rank: count} (counts >= 0).""" + lo = hi = Q(0) + for r, n in profile.items(): + if n == 0: + continue + need(n > 0 and 0 < int(r) < M, 'kappa.profile: rank %r count %r' % (r, n)) + h_lo, h_hi = H(int(r), a) + lo += n * h_lo + hi += n * h_hi + return floor_g(lo / (M * live)), ceil_g(hi / (M * live)) + + +def accepts(enc): + return enc[1] < 1 + + +def rejects(enc): + return enc[0] > 1 + + +def endpoint_format(C): + need((C * 10 ** 24).denominator == 1 and C > 0, 'kappa.endpoint_format: C is not a positive 24-digit decimal') + + +def endpoint_check(prof, C, mom=moment): + """C accepted (upper end of the enclosure of M(C) below 1) and C + 1e-24 rejected (lower end above 1).""" + lo, hi = mom(prof, C) + need(accepts((lo, hi)), 'kappa.endpoint_accept: M(C) enclosure [%.3e, %.3e] - 1 not below 0' + % (float(lo - 1), float(hi - 1))) + lo2, hi2 = mom(prof, C + E24) + need(rejects((lo2, hi2)), 'kappa.endpoint_reject: M(C + 1e-24) enclosure [%.3e, %.3e] - 1 not above 0' + % (float(lo2 - 1), float(hi2 - 1))) + return dict(C_moment_minus_1=['%.9e' % float(lo - 1), '%.9e' % float(hi - 1)], + C_plus_1e24_moment_minus_1=['%.9e' % float(lo2 - 1), '%.9e' % float(hi2 - 1)], + C_enclosure_width='%.2e' % float(hi - lo)) + + +def two_impl(prof, a, vendored_moment): + """kappa.two_impl: the own enclosure and the vendored one (PR2804's check_accounting.moment) at a intersect, and + neither accepts what the other rejects.""" + own, ven = moment(prof, a), vendored_moment(prof, a) + need(max(own[0], ven[0]) <= min(own[1], ven[1]), 'kappa.two_impl: enclosures %r and %r are disjoint' % (own, ven)) + need(accepts(own) == accepts(ven) and rejects(own) == rejects(ven), 'kappa.two_impl: verdicts differ at %s' % a) + return dict(own=['%.3e' % float(own[0] - 1), '%.3e' % float(own[1] - 1)], + vendored=['%.3e' % float(ven[0] - 1), '%.3e' % float(ven[1] - 1)], intersect=True) + + +def kappa_check(kappa, C): + need(kappa == C - KAPPA_TERMS[0] - KAPPA_TERMS[1], 'kappa.kappa: CLAIM kappa != C - 1e-46 - 1e-70') + + +def gain_check(kappa_new, kappa_old, claimed_gain): + gain = kappa_new - kappa_old + need(gain > 0 and gain == claimed_gain, 'kappa.gain: kappa gain %s != claimed %s' % (gain, claimed_gain)) + return dict(gain=str(gain), gain_float='%.6e' % float(gain)) + + +def improvement(prof_old, prof_new, C_new, C_old): + need(rejects(moment(prof_old, C_new)) and accepts(moment(prof_new, C_old)), + 'kappa.improvement: the old profile is not rejected at the new C (or the new profile not accepted at the old C)') + + +def straddle(prof, C, mom=moment): + """Bisection on [C, C + 1e-24] until the enclosure of M straddles 1: (lo_a accepted, hi_a rejected, S).""" + lo_a, hi_a = C, C + E24 + for _ in range(1200): # the vendored enclosure is ~1e-191 wide: about 560 halvings + mid = (lo_a + hi_a) / 2 + e = mom(prof, mid) + if accepts(e): + lo_a = mid + elif rejects(e): + hi_a = mid + else: + return lo_a, hi_a, mid + raise AL.AuditFail('kappa.root_bracket: no straddle point found') + + +def predict_endpoint(prof, C_start, span=Q(1, 10 ** 6)): + """The 24-digit endpoint of a complete profile by bisection on the 24-digit grid from an accepted C_start: + returns (C, kappa) with M(C) accepted and M(C + 1e-24) rejected.""" + lo = (C_start * 10 ** 24).__floor__() + hi = ((C_start + span) * 10 ** 24).__floor__() + need(accepts(moment(prof, Q(lo, 10 ** 24))) and rejects(moment(prof, Q(hi, 10 ** 24))), + 'kappa.predict: initial bracket') + while hi - lo > 1: + mid = (lo + hi) // 2 + e = moment(prof, Q(mid, 10 ** 24)) + if accepts(e): + lo = mid + elif rejects(e): + hi = mid + else: + raise AL.AuditFail('kappa.predict: the grid point %d straddles 1' % mid) + C = Q(lo, 10 ** 24) + return C, C - KAPPA_TERMS[0] - KAPPA_TERMS[1] + + +def price_delta(delta_per_call, a, calls=CALLS, live=W): + """Enclosure of the change of M(a) when every call's local profile changes by delta_per_call {rank: change}.""" + lo = hi = Q(0) + for r, d in delta_per_call.items(): + h_lo, h_hi = H(int(r), a) + if d >= 0: + lo += d * h_lo + hi += d * h_hi + else: + lo += d * h_hi + hi += d * h_lo + return calls * lo / (M * live), calls * hi / (M * live) + + +def dec(q, digits): + s = (q * 10 ** digits).__floor__() + return '%d.%0*d' % (s // 10 ** digits, digits, s % 10 ** digits) diff --git a/research/t74-3015-restore-edit-audit/audit_words.py b/research/t74-3015-restore-edit-audit/audit_words.py new file mode 100644 index 0000000000..6368333e16 --- /dev/null +++ b/research/t74-3015-restore-edit-audit/audit_words.py @@ -0,0 +1,128 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Scope B: PR #3015's two final words (and PR #2979's parent words as positive controls) through this contributor's +lineage checks, with the vendored byte-pinned modules as libraries and no code of either PR. + +word_pipeline(w, declared, expect) runs, in this order (each step raises with its own rule id): + parse (vendored parser + validated initial corrections; wc.format / words.corrections) + -> warp algebra of every B record (wc.warp) + -> literal frame recount (wc.frame): paid local profile, width inventory, helper widths + -> words.counts (live inputs, helpers, private buffers, warp records, initial corrections = expect) + -> words.report_fields (the word's own report equals the recount) + -> words.declared (the recount equals the declared local profile and inventory of EDITS.json / CLAIM.json) + -> forward replay and dual replay of all live inputs in the free-operator model through cleanup and the target + endpoint (wc.replay, orientation recorded) + -> the own exact tracker through restore and cleanup (words.tracker: targets Y_t + X_t, restored registers their own + input and every private buffer zero before cleanup; the final identity and zero buffers after cleanup) + -> words.cleanup (the literal cleanup equals the own inverse-reverse re-derivation, frames aside, every item at FULL) + -> words.buffers (the cleanup's private buffers are exactly the helper_final endpoints, one each). +Standard library only; Python 3.8-compatible syntax. +""" +from collections import Counter + +import audit_lib as AL +import check_words as CW +import words_check as WC +from audit_common import need + +V = AL.V + + +def counts(P, w): + return dict(live=len(P['live']), helpers=len([r for r in P['live'] if r >= 2 * V]), buffers=len(P['buffers']), + warps=len(w['warps']), corrections=len(w.get('initial_corrections', [])), + a_prelude_events=w['prelude_events'], + sections=dict((k, len(w[k])) for k in ('A', 'B', 'restore', 'cut', 'precondition', 'compensation', + 'cleanup'))) + + +def check_counts(c, expect): + got = dict((k, c[k]) for k in expect) + need(got == dict(expect), 'words.counts: %r != %r' % (got, dict(expect))) + + +def check_report(P, fr): + need(fr['paid'] == P['claimed_profile'] and fr['inventory'] == P['claimed_inventory'], + 'words.report_fields: report %r %r != recount %r %r' % (P['claimed_profile'], P['claimed_inventory'], + fr['paid'], fr['inventory'])) + + +def check_declared(fr, declared): + prof = AL.intkeys(declared['local_profile']) + inv = AL.intkeys(declared['width_inventory']) + need(fr['paid'] == prof and fr['inventory'] == inv, + 'words.declared: recount %r %r != declared %r %r' % (fr['paid'], fr['inventory'], prof, inv)) + + +def check_cleanup(w): + mine = AL.rederive_cleanup(w) + need([g[:-1] for g in mine] == [g[:-1] for g in w['cleanup']], + 'words.cleanup: the literal cleanup is not the own inverse-reverse re-derivation') + full = WC.span([1 << b for b in range(9)]) + need(all(WC.span(g[-1]) == full for g in w['cleanup']), 'words.cleanup: an item is not at FULL') + return dict(items=len(mine), literal_equal=True, all_at_full=True) + + +def check_buffers(w, P): + n = 2 * V + w['report']['R'] + touched = set() + for g in w['cleanup']: + for r in ((g[1],) if g[0] == 'warp' else ((g[1], g[2]) if g[0] == 'add' else (g[1],))): + if r >= n: + touched.add(r) + ends = set(int(k) + n for k in w['helper_final']) + need(touched == ends == set(P['buffers']), 'words.buffers: cleanup buffers %d != helper_final endpoints %d' + % (len(touched), len(ends))) + return dict(private_buffers=len(ends), offset=n) + + +def track(w): + """One exact forward pass of the own tracker (audit_lib rows: every live register its own symbol, private buffers + zero, warp letters as formal words) through corrections, precondition, compensation, A, cut, B with its warps, + restore and cleanup. Returns the pre-cleanup and final conditions (rule words.tracker, see tracker_check).""" + rows = AL.init_rows(w) + n = AL.nregs(w) + removed = set(w['removed']) + restored = set(int(k) for k in w['helper_final']) + live = [r for r in range(n) if r not in removed] + pre = None + for sec, i, g in AL.events(w, cleanup=True): + if sec == 'cleanup' and pre is None: + pre = dict(targets_final=all(rows[V + t] == AL.target_final(t) for t in range(V)), + restored_own=all(rows[r] == AL.own_symbol(r) for r in restored), + buffers_zero=all(not rows[b + n] for b in restored), + rows_with_operator_words=sum(1 for r in live if any(wd for _, wd in rows[r]))) + AL.apply(rows, g) + need(pre is not None, 'words.tracker: empty cleanup') + final = all(rows[r] == (AL.target_final(r - V) if V <= r < 2 * V else AL.own_symbol(r)) for r in live) + return dict(pre, final_identity=final, buffers_zero_after=all(not rows[b + n] for b in restored), + live=len(live), buffers=len(restored), cleanup_items=len(w['cleanup'])) + + +def tracker_check(check): + need(check['targets_final'] and check['restored_own'] and check['buffers_zero'], + 'words.tracker: pre-cleanup state %r' % dict((k, check[k]) for k in ('targets_final', 'restored_own', + 'buffers_zero'))) + need(check['final_identity'] and check['buffers_zero_after'], 'words.tracker: final identity after cleanup') + + +def word_pipeline(w, declared, expect): + P = AL.parse_word(w) + warps = WC.check_all_warps(P) + fr = CW.frame_recount(P) + c = counts(P, w) + check_counts(c, expect) + check_report(P, fr) + if declared is not None: + check_declared(fr, declared) + fwd = AL.replay(P, False) + dual = AL.replay(P, True) + check = track(w) + tracker_check(check) + cl = check_cleanup(w) + bf = check_buffers(w, P) + rec = dict(counts=c, profile=AL.hist(fr['paid']), inventory=AL.hist(fr['inventory']), mass=fr['mass'], + helper_widths_sha256=AL.sha(fr['helper_widths']), warp_records=len(warps), + centre_copy_children=sorted(sum(1 for d in c_['children']) for c_ in fr['copy_paths']), + replay_forward=fwd, replay_dual=dual, tracker=check, cleanup=cl, buffers=bf, + independent_inputs=fwd['independent_inputs']) + return rec, P, fr diff --git a/research/t74-3015-restore-edit-audit/vendor/NOTICE.md b/research/t74-3015-restore-edit-audit/vendor/NOTICE.md new file mode 100644 index 0000000000..31f634d173 --- /dev/null +++ b/research/t74-3015-restore-edit-audit/vendor/NOTICE.md @@ -0,0 +1,41 @@ +# Vendored files + +Every file below is an earlier independent checker by the author of this package (Sagar Thakrar / thakrarsagar), +Apache-2.0, prepared with substantial AI assistance (Claude Code, Anthropic). They are byte-for-byte copies of the +files integrated into main (`d8e0f83f00191df62174b641e9fff055c357f641`, package +`research/t74-2751-joint-twelve-audit/`, PR #2865, whose own `vendor/` carried the PR2315/PR2387/PR2804 copies). +`verify.py` checks each file's git blob id and SHA-256 and executes exactly the verified bytes as the module (no +import machinery, so no cached `.pyc` can stand in). No code of PR #3015, #2979, #3018 or of any PR they build on +is vendored, imported or executed. + +| File | Module | Git blob | SHA-256 | Origin | +| --- | --- | --- | --- | --- | +| `pr2315/words_check.py` | `words_check` | `0b646b9d5583c75a78e0c2dd7e9cfffa02055058` | `b66414a39f5ac7b9cd32284027e13a550734901aca5f4457085a034689bc3ce6` | PR #2315 (merged), `research/t74-borrow43-independent-check/words_check.py`; this copy keeps the pinned bytes, whose docstring credit was corrected on main (see below) | +| `pr2387/fill_check80.py` | `fill_check80` | `557e0732bfe4c030436a11f5433143c10fa07821` | `1c4d30591969c6502605f239f40505261e99d025aa3b576a804332a6bc479b06` | PR #2387 (merged), `research/t74-80alias-owner-fill/fill_check80.py` | +| `pr2804/audit_common.py` | `audit_common` | `17c4064f01b110012b54c05e64bdee8ae498e0b2` | `7ced740252ac8d8a8c66ef3cc825008e0aacf080494d0e983fb322d7dcddbf42` | PR #2804 (merged), `research/t74-2530-source-partner-audit/audit_common.py` | +| `pr2804/check_accounting.py` | `check_accounting` | `e749057dd838b715d0630de618f32d66a38da931` | `fb6aef50da586f15cd60762edc074c20e300d65f1378a80160b3d4b840762548` | PR #2804, `.../check_accounting.py` (rigorous moment enclosure, 640-bit fixed point) | +| `pr2804/check_fill.py` | `check_fill` | `85d1f807c62e4ac3b5f5ec7a809333ca05d5a951` | `6abf2a574de50c71b46b502d322deab841cbaa0080e326262f346a96992878fb` | PR #2804, `.../check_fill.py` (own owner-fill rules R-a..R-e, windows, template) | +| `pr2804/check_words.py` | `check_words` | `451dbb82f147ef446a1819b1ed595b4bf5547583` | `5996e804fa006906abff63a982c272588a44c35dfc932fdf687ef98dd3e0905f` | PR #2804, `.../check_words.py` (extended parser, frame recount, replays, cleanup re-derivation) | +| `pr2865/audit_lib.py` | `audit_lib` | `e8e847cc89dae6bb4e90e2c3dbebc30f615b698f` | `e0cf84dd959d39e3f299c1e171753c29465fd5b4457561f4ab9ec0675d8e9dc1` | PR #2865 (merged), `research/t74-2751-joint-twelve-audit/audit_lib.py` (parse with initial corrections, own tracker, control bookkeeping) | + +`pr2804/NOTICE.md` and `pr2865/NOTICE-2865-vendor.md` are the predecessor packages' own vendor notices, retained +verbatim for the credit chain. + +## Predecessor credits + +Carried over from the files' docstrings and the retained notices: + +- `words_check.py`: PR2269 (Jeremy Kothe, jeremykothe2): the borrow43 package and words; PR2226 (Cinna Davis / + 1337isnot1337, with OpenAI Codex): anticipatory dirty borrowing, the alias rule, K_G reference changes and the + free-operator replay idea; PR2260 (Dugongue); the T74 lineage PR1319/PR1297 (Rohan Arun) and PR1625 (mdumitrean); + **icekylinx and Zhihao Chen (jacklightChen)** (two contributors): Clifford-frame normal forms and the local-word + checker lineage. The pinned bytes of `words_check.py` and `fill_check80.py` still carry the conflated form + "icekylinx (Zhihao Chen)" in their docstrings, which the maintainer corrected on main when integrating PR #2315; + the correct attribution is the one here. +- `fill_check80.py`: PR2269 (Jeremy Kothe): the T74 template, windows, dispatch and owner-row format; PR2322 + (Vlado Vojdanovski): the private-namespace statement; PR2226 (Cinna Davis); the PR858 / + complex-double-replica-owners hosting rules (Hao Yan); the T16 owner audit (Josie Elliston; icekylinx and Zhihao + Chen (jacklightChen) checker lineage). +- `check_accounting.py`, `check_fill.py`, `check_words.py`, `audit_common.py` (PR #2804) and `audit_lib.py` + (PR #2865): this contributor's own, built on the above and on the PR2462/PR2530/PR2733/PR2751 words they audited + (tekuuu, jeremydiviney, mdumitrean, petalas and the retained lineage credited in those packages' READMEs). diff --git a/research/t74-3015-restore-edit-audit/vendor/pr2315/words_check.py b/research/t74-3015-restore-edit-audit/vendor/pr2315/words_check.py new file mode 100644 index 0000000000..0b646b9d55 --- /dev/null +++ b/research/t74-3015-restore-edit-audit/vendor/pr2315/words_check.py @@ -0,0 +1,1294 @@ +#!/usr/bin/env python3 +"""Independent check (task A) of the two borrowed T74 local words of PR #2269. + +Object: CrocSwap/integer-mult-bounds PR #2269 (jeremykothe2), head +b479fc5567bc09ab9185bffe89b62594f36d74e5, package research/gmx-t74-borrow43/: +new/borrow/words/BORROW-WORD-43{base,extra}.json.gz and their inputs +new/borrow/inputs/* (canonical unborrowed words, block certificate, witnesses). + +Credit: PR2269 (jeremykothe2) for the borrow43 package and words; PR2226 +(Cinna Davis / 1337isnot1337, with OpenAI Codex) for anticipatory dirty +borrowing, the alias rule, the K_G reference changes and the free-operator +replay idea; PR2260 (Dugongue) for concurrent application of PR2226; the T74 +lineage PR1319/PR1297 (Rohan Arun), PR1625 (mdumitrean) and the pivot-554 +kernel; icekylinx (Zhihao Chen) for the Clifford-frame normal forms +(notes/general-clifford-frames.tex) and the local-word checker lineage. + +This file shares no code with those packages. It was written from their +written specification (PR2226 README/PROOF, notes/general-clifford-frames.tex, +the PR2269 README and the JSON field layout); no package code is imported or +executed. Inputs are read as git blobs at the pinned commit (or from +--blob-dir) and are pinned by sha256 and git blob id. + +Prepared with substantial AI assistance (Claude Code, Anthropic); Apache-2.0. + +Usage: python3 -I -B words_check.py [--repo PATH | --blob-dir DIR] [--out RECEIPT.json] +The receipt (if requested) must be written next to this script. The final +stdout line is PASS_T74_BORROW43_WORDS_INDEPENDENT or FAIL_T74_BORROW43_WORDS_INDEPENDENT. + +MODEL (stated precisely; see also the receipt field "model"). + * Registers 0..v-1 are X (sources), v..2v-1 are Y (targets), 2v..2v+R-1 + helpers; n = 2v+R. Removed helpers do not exist. A buffer register b = r+n + exists only for r in helper_final (restored cold helpers) and only in cleanup. + * Frame = GF(2)-subspace of F_2^h (h = 9), given by a list of bit-mask + vectors; compared as spans (reduced echelon form). Start: X_i = span(port_i), + Y = 0, helper = start_extra[r] or 0. End: X = FULL, Y_i = port_i^perp, + helper = helper_final[r] or FULL. + * Every framed gate (add t s c F | scale t c F) climbs each incident register + from its current frame S to F; legal only if S <= F; a strict climb pays one + child of rank dim F - dim S. precondition/compensation are at frame 0. + * After A every target sits at its level (target_levels, here all 0) and + every centre at its centre frame. cut gates (frame null) add c*centre into + a target at its level; each centre pays one COPY child of rank + dim(centre frame) - dim(level) per distinct served level (nested chain). + * warp [pos, L, G, U, E] is inserted before B[pos] (list order inside a + position): requires cur[L] == span U exactly, sets cur[L] = span E, pays + nothing (rank-zero reference change K_G); logically L <- K_G L. + * After B and restore every live register climbs to its end frame (paid). + * cleanup items must all be at FULL, may touch only live registers whose + current frame is FULL, or buffers; they pay nothing. + * Logic: exact replay over Q (rationals x free group on K_1..K_43): + every live register starts as an independent symbol (arbitrary dirty + content), buffers start at 0; add t+=c*s, scale t*=c, warp left-multiplies + by K_k^{+-1} with free-group cancellation. Accept iff after cleanup + Y_i = Y_i + X_i, every other live register is its own input, and every + buffer is 0. The dual orientation replays g^{-T} for every item + (add -> s -= c t, scale -> 1/c, K -> K^{-T} as new free letters) and expects + X_i = X_i - Y_i. + * Warp algebra over GF(2): G (columns = images of unit vectors) invertible, + dim U = dim E, G span U = span E, M = [[G,0],[G+G^-T,G^-T]] symplectic for + w((x,z),(x',z')) = x.z' + z.x', M L_0 = L_0, M L_FULL = L_FULL, + M L_U = L_E where L_W = {(u, u+p): u in W, p in W^perp}, and the Fourier + rank h - dim(L_E cap M L_U) of R_in = T_E K_G T_U^-1 is 0; G^-T U^perp = E^perp. + Exact Clifford phases / Gaussian monomial lifts are NOT checked here. +""" + +import argparse +import copy +import gzip +import hashlib +import json +import os +import subprocess +import sys +import time +from collections import Counter +from fractions import Fraction + +PASS_LINE = 'PASS_T74_BORROW43_WORDS_INDEPENDENT' +FAIL_LINE = 'FAIL_T74_BORROW43_WORDS_INDEPENDENT' +COMMIT = 'b479fc5567bc09ab9185bffe89b62594f36d74e5' +PKG = 'research/gmx-t74-borrow43/' +DEFAULT_REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) # repository root + +# path (relative to PKG) -> (git blob id, sha256 of blob bytes) +PINS = { + 'word_base': ('new/borrow/words/BORROW-WORD-43base.json.gz', + '448dd795adba29392a90b34aa3f1b1b796c7e0bd', + '9492a5537fb87d9ca98dffcd0230f7625b3789744fa94e2f18acf23d91d998b5'), + 'word_extra': ('new/borrow/words/BORROW-WORD-43extra.json.gz', + '2b51ba96256283bbc5578f99b694c50edd8a0e35', + '87d51f5298101d5947f45c43ee02f0ec45d6acbddabb808d0d02db1eaf063734'), + 'canon_base': ('new/borrow/inputs/gauge44.canonical.json.gz', + '4abb6e28f02c95b41ed345d4e4401d16d58ae791', + '65c6d17ffee2eacf27bff438f37fc549c9ed0c909cbc7a52976cc75cf2d15b91'), + 'canon_extra': ('new/borrow/inputs/extra.canonical.json.gz', + 'e0d670d4351229ce6921ecfbecf180070b17616b', + 'd7e48dcbafa236a2e1e41f7958244211506f7c7630fe6a2d43d2bdf17b7ae015'), + 'blocks': ('new/borrow/inputs/blocks.json', + 'c683574b3861678081fd5c5944dbd7a47309f6fd', + 'ddfac1dae1fe7cc0a91e7c7205c6d9d0c07c682880aa34eed83bf4ad7384da9f'), + 'witness_base': ('new/borrow/inputs/witness_43_base.json', + '9f4b93f3bc52d4f4ffaa128cfd7ae574fd36c462', + '67ffb66d94067f6e53aee9118fe90e14a57f497fc8b3f708b6dac3de2e58ff28'), + 'witness_extra': ('new/borrow/inputs/witness_43_extra.json', + '864ba533f50c2f1f639a6a3559b185bd321b923a', + 'd46449c6dbf4477f260cf5baea9bbb570a66ee0b6db81f4a220b9e3086ae9e46'), + 'providers': ('new/BORROW-PROVIDERS.json', + '42563d218a5c7321f686c1cf9b98e75883d85abc', + '8324fcf5fd652af9793c1acbc5f5099ee0d2f1eefa0adfbb8335f3d31d891da2'), + 'word566_base': ('new/gauge44-word-566.json.gz', + '76c01583a0286cddb0f71e0cb13077e4317104f6', + 'eeb6a236ed0ea8873b8800947d0cd19c36a6fcfdf857fc42913cb45cd984f219'), + 'word566_extra': ('new/extra-word-566.json.gz', + 'e86142b352466f54a3da38c96a6e1484145c3b5c', + 'cd417b904408c221d9840d08faff8af040cc4207f9804284f2f5375d21298a62'), +} + +# Claims under test (PR2269 README / scout notes), written here independently of the files. +CLAIMS = { + 'base': dict(profile={1: 2351, 2: 501, 3: 414, 4: 129, 5: 42, 8: 8}, + old_profile={1: 2348, 2: 500, 3: 416, 4: 130, 5: 82, 8: 8}, + providers_key='gauge44', base_tag='eeb6a236'), + 'extra': dict(profile={1: 2339, 2: 509, 3: 418, 4: 125, 5: 42, 8: 8}, + old_profile={1: 2340, 2: 508, 3: 420, 4: 126, 5: 82, 8: 8}, + providers_key='extra', base_tag='cd417b90'), + 'width_inventory': {4: 36, 5: 9, 7: 36, 8: 116, 9: 240}, + 'helpers_before': 480, 'helpers_after': 437, 'warps': 43, 'mass': 5385, + # README: "43 high helpers (8 width-4, 35 width-5)". This holds for the base (gauge44) word; the + # extra word's 43 removed helpers have canonical widths 4 x 4 + 39 x 5 (recorded, see receipt). + 'removed_old_widths': {'base': {4: 8, 5: 35}, 'extra': {4: 4, 5: 39}}, +} + + +class Reject(Exception): + """A failed check; .check names the check family that rejected.""" + + def __init__(self, check, msg): + Exception.__init__(self, '[%s] %s' % (check, msg)) + self.check = check + self.msg = msg + + +def need(cond, check, msg): + if not cond: + raise Reject(check, msg) + + +# ---------------------------------------------------------------------------- +# Input loading and pinning +# ---------------------------------------------------------------------------- + +def git_blob_id(data): + h = hashlib.sha1() + h.update(b'blob %d\0' % len(data)) + h.update(data) + return h.hexdigest() + + +def verify_pin(key, data): + rel, blob, sha = PINS[key] + need(git_blob_id(data) == blob, 'pin', 'git blob id mismatch for %s' % rel) + need(hashlib.sha256(data).hexdigest() == sha, 'pin', 'sha256 mismatch for %s' % rel) + + +def load_inputs(repo, blob_dir): + raw = {} + pins = {} + for key in sorted(PINS): + rel, blob, sha = PINS[key] + path = PKG + rel + if blob_dir is None: + got = subprocess.run(['git', '-C', repo, 'rev-parse', COMMIT + ':' + path], + capture_output=True, text=True) + need(got.returncode == 0, 'pin', 'cannot resolve %s at %s' % (path, COMMIT)) + need(got.stdout.strip() == blob, 'pin', 'path %s does not resolve to pinned blob' % path) + got = subprocess.run(['git', '-C', repo, 'cat-file', 'blob', blob], capture_output=True) + need(got.returncode == 0, 'pin', 'cannot read blob %s' % blob) + data = got.stdout + else: + # Layouts: DIR/ (a `git archive` export of the package, as + # check_all.py uses) or DIR/. Either way the bytes must match both pins. + cands = [os.path.join(blob_dir, rel), os.path.join(blob_dir, os.path.basename(rel))] + src = next((c for c in cands if os.path.isfile(c)), None) + need(src is not None, 'pin', 'blob for %s not found in --blob-dir (tried %s)' % (rel, ', '.join(cands))) + with open(src, 'rb') as fh: + data = fh.read() + verify_pin(key, data) + raw[key] = data + pins[key] = dict(path=path, git_blob=blob, sha256=sha, bytes=len(data)) + js = {} + for key, data in raw.items(): + if PINS[key][0].endswith('.gz'): + data = gzip.decompress(data) + js[key] = json.loads(data.decode('utf-8')) + return js, pins, raw + + +# ---------------------------------------------------------------------------- +# GF(2) linear algebra on integer bit vectors +# ---------------------------------------------------------------------------- + +def parity(x): + return bin(x).count('1') & 1 + + +def echelon(vectors): + """Fully reduced echelon basis {pivot bit: vector} of the span of the vectors.""" + piv = {} + for x in vectors: + x = int(x) + for b in list(piv): + if (x >> b) & 1: + x ^= piv[b] + if x: + lead = x.bit_length() - 1 + for b in list(piv): + if (piv[b] >> lead) & 1: + piv[b] ^= x + piv[lead] = x + return piv + + +def span(vectors): + """Canonical key of a subspace: its reduced echelon basis, sorted decreasingly.""" + return tuple(sorted(echelon(vectors).values(), reverse=True)) + + +def reduce_by(x, piv): + for b, vec in piv.items(): + if (x >> b) & 1: + x ^= vec + return x + + +def contains(small, big): + piv = echelon(big) + return all(reduce_by(x, piv) == 0 for x in small) + + +def dim_sum(a, b): + return len(span(list(a) + list(b))) + + +def perp(sub, h): + return span([x for x in range(1, 1 << h) if all(parity(x & u) == 0 for u in sub)]) + + +def mat_apply(cols, x): + y = 0 + i = 0 + while x: + if x & 1: + y ^= cols[i] + x >>= 1 + i += 1 + return y + + +def mat_inverse(cols, h): + """Columns of G^{-1}, or None if G is singular over GF(2).""" + piv = {} + for i in range(h): + a, b = cols[i], 1 << i # invariant: G(b) = a + for p in list(piv): + pa, pb = piv[p] + if (a >> p) & 1: + a ^= pa + b ^= pb + if a == 0: + return None + lead = a.bit_length() - 1 + for p in list(piv): + pa, pb = piv[p] + if (pa >> lead) & 1: + piv[p] = (pa ^ a, pb ^ b) + piv[lead] = (a, b) + inv = [0] * h + for p, (a, b) in piv.items(): + if a != (1 << p): + return None + inv[p] = b + return inv + + +def mat_transpose(cols, h): + return [sum(((cols[r] >> j) & 1) << r for r in range(h)) for j in range(h)] + + +def lagrangian(sub, h): + """L_W = {(u, u+p): u in W, p in W^perp} encoded as x | z << h.""" + return span([u | (u << h) for u in sub] + [p << h for p in perp(sub, h)]) + + +def symp(a, b, h): + mask = (1 << h) - 1 + return parity((a & mask) & (b >> h)) ^ parity((a >> h) & (b & mask)) + + +# ---------------------------------------------------------------------------- +# Parsing (borrow word and canonical word) into one internal program shape +# ---------------------------------------------------------------------------- + +def is_int(x): + return isinstance(x, int) and not isinstance(x, bool) + + +def dyadic(q): + return q.denominator & (q.denominator - 1) == 0 + + +def unit(q): + a = abs(q.numerator) + return a > 0 and a & (a - 1) == 0 and dyadic(q) + + +def regs_of(item): + if item[0] == 'add': + return (item[1], item[2]) + return (item[1],) + + +def conv_gate(g, frame_of, where, allow_warp=False): + need(isinstance(g, list) and g, 'format', 'gate is not a list at %s' % where) + op = g[0] + if op == 'add': + need(len(g) == 6 and all(is_int(x) for x in g[1:5]), 'format', 'bad add at %s' % where) + need(g[4] > 0 and g[3] != 0, 'format', 'bad add coefficient at %s' % where) + q = Fraction(g[3], g[4]) + need(dyadic(q), 'format', 'non-dyadic coefficient at %s' % where) + need(g[1] != g[2], 'format', 'self add at %s' % where) + return ('add', g[1], g[2], q, frame_of(g[5])) + if op == 'scale': + need(len(g) == 5 and all(is_int(x) for x in g[1:4]), 'format', 'bad scale at %s' % where) + need(g[3] != 0 and g[2] != 0, 'format', 'zero scale at %s' % where) + q = Fraction(g[2], g[3]) + need(unit(q), 'format', 'scale is not a dyadic unit at %s' % where) + return ('scale', g[1], q, frame_of(g[4])) + if op == 'warp' and allow_warp: + need(len(g) == 4 and is_int(g[1]) and is_int(g[2]) and g[2] != 0, 'format', 'bad warp item at %s' % where) + return ('warp', g[1], g[2], frame_of(g[3])) + raise Reject('format', 'unknown primitive %r at %s' % (op, where)) + + +def parse_borrow(w): + need(w.get('kind') == 'BORROW-WORD', 'format', 'not a BORROW-WORD') + rep = w['report'] + v, h, R = rep['v'], rep['h'], rep['R'] + need((v, h, R) == (112, 9, 480), 'format', 'unexpected geometry') + n = 2 * v + R + full = span([1 << i for i in range(h)]) + + def frame_lit(F): + if F is None: + return None + need(isinstance(F, list) and all(is_int(x) and 0 < x < (1 << h) for x in F), 'format', 'bad frame literal') + return span(F) + + ports = w['ports'] + need(len(ports) == v and all(is_int(p) and 0 < p < (1 << h) for p in ports), 'format', 'ports') + removed = w['removed'] + need(len(set(removed)) == len(removed) and all(2 * v <= r < n for r in removed), 'format', 'removed helpers') + removed = set(removed) + live = [r for r in range(n) if r not in removed] + start, end = {}, {} + for i in range(v): + start[i] = span([ports[i]]) + end[i] = full + start[v + i] = () + end[v + i] = perp(span([ports[i]]), h) + for r in live: + if r >= 2 * v: + start[r] = () + end[r] = full + for k, F in w['start_extra'].items(): + r = int(k) + need(r in start and r >= 2 * v, 'format', 'start_extra names a non-live/non-helper register %s' % k) + start[r] = frame_lit(F) + restored = set() + for k, F in w['helper_final'].items(): + r = int(k) + need(r in end and r >= 2 * v, 'format', 'helper_final names a non-live/non-helper register %s' % k) + end[r] = frame_lit(F) + restored.add(r) + need(w.get('initial_corrections') == [], 'anticipatory', + 'initial (anticipatory) corrections present; this checker covers the zero-correction case only') + sec = {} + for name in ('precondition', 'compensation', 'A', 'cut', 'B', 'restore'): + sec[name] = [conv_gate(g, frame_lit, '%s[%d]' % (name, i)) for i, g in enumerate(w[name])] + cleanup = [conv_gate(g, frame_lit, 'cleanup[%d]' % i, allow_warp=True) for i, g in enumerate(w['cleanup'])] + warps = [] + for k, rec in enumerate(w['warps'], 1): + need(isinstance(rec, list) and len(rec) == 5, 'format', 'warp record %d shape' % k) + pos, L, cols, U, E = rec + need(is_int(pos) and 0 <= pos <= len(sec['B']), 'format', 'warp %d position' % k) + need(is_int(L), 'format', 'warp %d lender' % k) + need(isinstance(cols, list) and len(cols) == h and all(is_int(c) and 0 <= c < (1 << h) for c in cols), + 'format', 'warp %d G columns' % k) + need(isinstance(U, list) and isinstance(E, list) and all(is_int(x) and 0 < x < (1 << h) for x in U + E), + 'format', 'warp %d frames' % k) + warps.append(dict(op=k, pos=pos, lender=L, G=list(cols), U_list=list(U), E_list=list(E), + U=span(U), E=span(E))) + by_pos = {} + for wr in warps: + by_pos.setdefault(wr['pos'], []).append(wr) + items = [] + for p in range(len(sec['B']) + 1): + for wr in by_pos.get(p, []): + items.append(('warp', wr['lender'], wr['op'], wr['U'], wr['E'])) + if p < len(sec['B']): + items.append(sec['B'][p]) + return dict(kind='borrow', v=v, h=h, R=R, n=n, full=full, ports=ports, live=live, removed=removed, + start=start, end=end, restored=restored, buffers=set(r + n for r in restored), + centers=list(w['centers']), center_frames=[frame_lit(F) for F in w['center_frames']], + target_levels={int(k): frame_lit(F) for k, F in w['target_levels'].items()}, + pre=sec['precondition'] + sec['compensation'], n_pre=len(sec['precondition']), + A=sec['A'], cut=sec['cut'], B_items=items, post=sec['restore'], cleanup=cleanup, + warps=warps, sections=sec, + claimed_profile={int(k): c for k, c in rep['local_profile'].items()}, + claimed_inventory={int(k): c for k, c in rep['width_inventory'].items()}) + + +def parse_canonical(c): + v, h, R = c['v'], c['h'], c['R'] + need((v, h, R) == (112, 9, 480), 'format', 'unexpected canonical geometry') + n = 2 * v + R + full = span([1 << i for i in range(h)]) + frames = [] + for F in c['frames']: + need(isinstance(F, list) and all(is_int(x) and 0 < x < (1 << h) for x in F), 'format', 'canonical frame') + need(len(span(F)) == len(F), 'format', 'canonical frame basis is dependent') + frames.append(span(F)) + + def frame_idx(F): + if F is None: + return None + need(is_int(F) and 0 <= F < len(frames), 'format', 'canonical frame index') + return frames[F] + + ports = c['ports'] + need(len(c['start']) == n and len(c['final']) == n, 'format', 'canonical start/final length') + start = {r: frames[c['start'][r]] for r in range(n)} + end = {r: frames[c['final'][r]] for r in range(n)} + for i in range(v): + need(start[i] == span([ports[i]]), 'format', 'canonical X start is not its port line') + need(end[i] == full, 'format', 'canonical X end is not FULL') + need(start[v + i] == (), 'format', 'canonical Y start is not 0') + need(end[v + i] == perp(span([ports[i]]), h), 'format', 'canonical Y end is not port-perp') + sec = {} + for name in ('precondition', 'compensation', 'A', 'cut', 'B', 'tail', 'cleanup'): + sec[name] = [conv_gate(g, frame_idx, 'canon %s[%d]' % (name, i)) for i, g in enumerate(c[name])] + return dict(kind='canonical', v=v, h=h, R=R, n=n, full=full, ports=ports, live=list(range(n)), + removed=set(), start=start, end=end, restored=set(), buffers=set(), + centers=list(c['centers']), center_frames=[frames[i] for i in c['center_frames']], + target_levels={int(k): frame_idx(F) for k, F in c['target_levels'].items()}, + pre=sec['precondition'] + sec['compensation'], n_pre=len(sec['precondition']), + A=sec['A'], cut=sec['cut'], B_items=list(sec['B']), post=sec['tail'], cleanup=sec['cleanup'], + warps=[], sections=sec, frames=frames, + claimed_profile={int(k): x for k, x in c['local_profile'].items()}, claimed_inventory=None) + + +# ---------------------------------------------------------------------------- +# Check 1: warp algebra +# ---------------------------------------------------------------------------- + +def check_warp(wr, h, live, v): + k = wr['op'] + cols = wr['G'] + inv = mat_inverse(cols, h) + need(inv is not None, 'warp', 'warp %d: G is singular over GF(2)' % k) + need(all(mat_apply(cols, inv[t]) == 1 << t and mat_apply(inv, cols[t]) == 1 << t for t in range(h)), + 'warp', 'warp %d: inverse witness' % k) + U, E = wr['U'], wr['E'] + need(len(U) == len(wr['U_list']) and len(E) == len(wr['E_list']), 'warp', + 'warp %d: U or E list is linearly dependent' % k) + need(len(U) == len(E), 'warp', 'warp %d: dim U != dim E' % k) + need(span([mat_apply(cols, u) for u in U]) == E, 'warp', 'warp %d: G span U != span E' % k) + git = mat_transpose(inv, h) # G^{-T} + mask = (1 << h) - 1 + + def M(vec): + x, z = vec & mask, vec >> h + gx = mat_apply(cols, x) + return gx | ((gx ^ mat_apply(git, x) ^ mat_apply(git, z)) << h) + + gens = [1 << i for i in range(2 * h)] + imgs = [M(g) for g in gens] + need(len(span(imgs)) == 2 * h, 'warp', 'warp %d: K_G singular' % k) + for a in range(2 * h): + for b in range(a + 1, 2 * h): + need(symp(imgs[a], imgs[b], h) == symp(gens[a], gens[b], h), 'warp', 'warp %d: K_G not symplectic' % k) + full = span([1 << i for i in range(h)]) + L0, LF, LU, LE = lagrangian((), h), lagrangian(full, h), lagrangian(U, h), lagrangian(E, h) + need(len(L0) == len(LF) == len(LU) == len(LE) == h, 'warp', 'warp %d: Lagrangian dimension' % k) + need(span([M(x) for x in L0]) == L0, 'warp', 'warp %d: K_G does not fix L_0' % k) + need(span([M(x) for x in LF]) == LF, 'warp', 'warp %d: K_G does not fix L_FULL' % k) + MLU = span([M(x) for x in LU]) + rank_in = h - (len(LE) + len(MLU) - dim_sum(LE, MLU)) + need(MLU == LE and rank_in == 0, 'warp', 'warp %d: K_G L_U != L_E (Fourier rank %d)' % (k, rank_in)) + need(span([mat_apply(git, p) for p in perp(U, h)]) == perp(E, h), 'warp', 'warp %d: G^-T U^perp != E^perp' % k) + need(wr['lender'] in live and not (v <= wr['lender'] < 2 * v), 'warp', + 'warp %d: lender must be a live non-target register' % k) + # Fourier distance of a plain frame change U -> E (what the transition would cost without K_G) + plain = h - (2 * h - dim_sum(LU, LE)) + by_formula = len(U) + len(E) - 2 * (len(U) + len(E) - dim_sum(U, E)) + need(plain == by_formula, 'warp', 'warp %d: Lagrangian distance lemma inconsistency' % k) + return dict(op=k, pos=wr['pos'], lender=wr['lender'], dim=len(U), plain_fourier_distance=plain, + U_eq_E=(U == E), U_in_E=contains(U, E)) + + +def check_all_warps(P): + out = [check_warp(wr, P['h'], set(P['live']), P['v']) for wr in P['warps']] + lenders = [wr['lender'] for wr in P['warps']] + need(len(set(lenders)) == len(lenders), 'warp', 'a register lends twice') + return out + + +# ---------------------------------------------------------------------------- +# Check 2: frame legality and paid-profile recount +# ---------------------------------------------------------------------------- + +def frame_check(P, charge_warps=False, warp_as_climb=()): + v, full = P['v'], P['full'] + cur = {r: P['start'][r] for r in P['live']} + paid, climbs, copies, warp_charge = Counter(), Counter(), Counter(), Counter() + per_reg = Counter() + istarget = lambda r: v <= r < 2 * v + + def climb(r, F, where): + need(r in cur, 'frame', 'register %d is not live (%s)' % (r, where)) + old = cur[r] + need(contains(old, F), 'frame', 'non-nested climb of %d at %s: %r -> %r' % (r, where, old, F)) + d = len(F) - len(old) + if d: + paid[d] += 1 + climbs[d] += 1 + per_reg[r] += d + cur[r] = F + + for i, g in enumerate(P['pre']): + need(g[-1] == (), 'frame', 'precondition/compensation gate %d not at frame 0' % i) + need(istarget(g[1]), 'frame', 'precondition/compensation gate %d writes a non-target' % i) + for r in regs_of(g): + climb(r, (), 'pre[%d]' % i) + for i, g in enumerate(list(P['A']) + [it for it in P['B_items'] if it[0] != 'warp'] + list(P['post'])): + need(not (g[0] == 'add' and not istarget(g[1]) and istarget(g[2])), 'frame', + 'a non-target register reads a target (item %d of A+B+post)' % i) + for i, g in enumerate(P['A']): + need(g[-1] is not None, 'frame', 'unframed gate in A') + for r in regs_of(g): + climb(r, g[-1], 'A[%d]' % i) + for t in range(v): + need(cur[v + t] == P['target_levels'].get(t, ()), 'frame', 'target %d not at its level after A' % t) + need(len(set(P['centers'])) == len(P['centers']) == len(P['center_frames']), 'frame', 'centres') + for q, U in zip(P['centers'], P['center_frames']): + need(q in cur and cur[q] == U, 'frame', 'centre %d not at its centre frame after A' % q) + served = dict((q, set()) for q in P['centers']) + for i, g in enumerate(P['cut']): + need(g[0] == 'add' and g[-1] is None, 'frame', 'cut[%d] is not an unframed add' % i) + t, s = g[1], g[2] + need(istarget(t) and s in served, 'frame', 'cut[%d] must add a centre into a target' % i) + need(cur[t] == P['target_levels'].get(t - v, ()), 'frame', 'cut[%d] target off its level' % i) + served[s].add(cur[t]) + for q, U in zip(P['centers'], P['center_frames']): + prev = U + for T in sorted(served[q], key=lambda S: (-len(S), S)): + need(contains(T, prev), 'frame', 'centre %d copy levels not nested' % q) + if T != prev: + paid[len(prev) - len(T)] += 1 + copies[len(prev) - len(T)] += 1 + prev = T + for i, it in enumerate(P['B_items']): + if it[0] == 'warp': + _, L, k, U, E = it + need(L in cur and not istarget(L), 'frame', 'warp %d lender %d not a live non-target' % (k, L)) + if k in warp_as_climb: + climb(L, E, 'warp %d treated as an ordinary climb' % k) + continue + need(cur[L] == U, 'frame', 'warp %d: lender %d frame %r != U %r' % (k, L, cur[L], U)) + if charge_warps: + d = len(U) + len(E) - 2 * (len(U) + len(E) - dim_sum(U, E)) + if d: + paid[d] += 1 + warp_charge[d] += 1 + cur[L] = E + else: + need(it[-1] is not None, 'frame', 'unframed gate in B') + for r in regs_of(it): + climb(r, it[-1], 'B item %d' % i) + for i, g in enumerate(P['post']): + need(g[-1] is not None, 'frame', 'unframed gate after B') + for r in regs_of(g): + climb(r, g[-1], 'post-B[%d]' % i) + for r in P['live']: + climb(r, P['end'][r], 'end frame') + for i, it in enumerate(P['cleanup']): + need(it[-1] == full, 'frame', 'cleanup item %d not at FULL' % i) + rr = (it[1],) if it[0] == 'warp' else regs_of(it) + for r in rr: + if r in P['buffers']: + continue + need(r in cur and cur[r] == full, 'frame', + 'cleanup item %d touches register %d whose frame is not FULL' % (i, r)) + for r in P['live']: + need(per_reg[r] == len(P['end'][r]) - len(P['start'][r]), 'frame', 'per-register charge != width for %d' % r) + helpers = [r for r in P['live'] if r >= 2 * v] + inventory = Counter(len(P['end'][r]) - len(P['start'][r]) for r in helpers) + return dict(paid=paid, climbs=climbs, copies=copies, warp_charge=warp_charge, inventory=inventory, + helpers=len(helpers), widths=[len(P['end'][r]) - len(P['start'][r]) for r in sorted(helpers)], + mass=sum(k * c for k, c in paid.items())) + + +# ---------------------------------------------------------------------------- +# Check 3: exact replay over the free-group algebra Q +# ---------------------------------------------------------------------------- + +ONE = Fraction(1) + + +def replay(P, dual=False): + v, n = P['v'], P['n'] + rows = {} + for r in P['live']: + rows[r] = {(r, ()): ONE} + for b in P['buffers']: + rows[b] = {} + istarget = lambda r: v <= r < 2 * v + + def row(r): + need(r in rows, 'replay', 'unknown register %d' % r) + return rows[r] + + def do(it): + kind = it[0] + if kind == 'add': + t, s, c = it[1], it[2], it[3] + if dual: + t, s, c = s, t, -c + src, dst = row(s), row(t) + for key, val in src.items(): + nv = dst.get(key, 0) + c * val + if nv: + dst[key] = nv + else: + del dst[key] + elif kind == 'scale': + t, c = it[1], it[2] + if dual: + c = 1 / c + rr = row(t) + for key in rr: + rr[key] = rr[key] * c + elif kind == 'warp': + reg, k = it[1], it[2] + letter = (abs(k), 1 if dual else 0, 1 if k > 0 else -1) + inverse = (letter[0], letter[1], -letter[2]) + old = row(reg) + new = {} + for (var, word), val in old.items(): + nw = word[1:] if (word and word[0] == inverse) else (letter,) + word + new[(var, nw)] = val + rows[reg] = new + else: + raise Reject('replay', 'unknown item') + + before = list(P['pre']) + list(P['A']) + list(P['cut']) + for it in before: + do(it) + for it in P['B_items']: + if it[0] == 'warp': + do(('warp', it[1], it[2])) + else: + do(it) + for it in P['post']: + do(it) + diag = {} + need(all(not rows[b] for b in P['buffers']), 'replay', 'a buffer is non-zero before cleanup') + if not dual: + for t in range(v): + need(rows[v + t] == {(v + t, ()): ONE, (t, ()): ONE}, 'replay', 'target %d not final before cleanup' % t) + for r in P['restored']: + need(rows[r] == {(r, ()): ONE}, 'replay', 'restored cold register %d is not its own input' % r) + readers = [r for r in P['live'] if r not in P['restored'] and not istarget(r) + and any(var in P['restored'] for var, _ in rows[r])] + need(not readers, 'replay', 'restored inputs still read by %r' % readers[:5]) + diag['rows_with_operator_words_before_cleanup'] = sum( + 1 for r in P['live'] if any(word for _, word in rows[r])) + peak = 0 + first_live = last_live = None + span_of = {} + noop_buffer_reads = 0 + for i, it in enumerate(P['cleanup']): + if it[0] == 'add': + src = it[2] if not dual else it[1] + if src in P['buffers'] and not rows[src]: + noop_buffer_reads += 1 + do(it) + live_buffers = 0 + for b in P['buffers']: + if rows[b]: + live_buffers += 1 + lo, hi = span_of.get(b, (i, i)) + span_of[b] = (min(lo, i), i) + if live_buffers: + first_live = i if first_live is None else first_live + last_live = i + peak = max(peak, live_buffers) + events = sorted([(lo, 1) for lo, hi in span_of.values()] + [(hi + 1, -1) for lo, hi in span_of.values()]) + overlap = best = 0 + for _, d in events: + overlap += d + best = max(best, overlap) + diag['buffers_ever_nonzero'] = len(span_of) + diag['max_overlap_of_buffer_lifetimes'] = best + diag['cleanup_adds_reading_a_zero_buffer'] = noop_buffer_reads + for r in P['live']: + if dual: + exp = {(r, ()): ONE, (r + v, ()): -ONE} if r < v else {(r, ()): ONE} + else: + exp = {(r, ()): ONE, (r - v, ()): ONE} if istarget(r) else {(r, ()): ONE} + need(rows[r] == exp, 'replay', 'final map wrong on register %d (%s)' % (r, 'dual' if dual else 'forward')) + need(all(not rows[b] for b in P['buffers']), 'replay', 'a zero buffer is not returned to zero') + diag.update(peak_nonzero_buffers=peak, buffer_nonzero_window=[first_live, last_live], + buffers=len(P['buffers']), independent_inputs=len(P['live'])) + return diag + + +# ---------------------------------------------------------------------------- +# Links between the borrowed word, its canonical base, witness, providers, 566 word +# ---------------------------------------------------------------------------- + +def coef(g): + return g[3] if g[0] == 'add' else g[2] + + +def norm(g): + return (g[0],) + tuple(regs_of(g)) + (coef(g), g[-1]) + + +def link_checks(tag, P, C, wit, blocks, providers, fr): + out = {} + need(P['ports'] == C['ports'] and P['centers'] == C['centers'], 'link', 'ports/centres differ from canonical') + need(P['center_frames'] == C['center_frames'], 'link', 'centre frames differ from canonical') + removed = P['removed'] + touches = lambda g: any(r in removed for r in regs_of(g)) + need(not any(touches(g) for g in C['sections']['compensation']), 'link', + 'canonical compensation reads a removed helper (a removed helper has non-zero response)') + for name in ('precondition', 'compensation', 'A', 'cut'): + kept = [norm(g) for g in C['sections'][name] if not touches(g)] + need([norm(g) for g in P['sections'][name]] == kept, 'link', 'section %s != canonical minus removed' % name) + out['canonical_%s_gates_dropped' % name] = len(C['sections'][name]) - len(kept) + v, n, h = P['v'], P['n'], P['h'] + for r in P['live']: + if r >= 2 * v: + need(P['start'][r] == C['start'][r], 'link', 'start frame of %d differs from canonical' % r) + for r in P['restored']: + need(P['end'][r] == C['end'][r], 'link', 'cold end frame of %d differs from canonical' % r) + canon_cold = [r for r in range(2 * v, n) if len(C['end'][r]) < h] + out['canonical_cold_helpers'] = len(canon_cold) + out['canonical_cold_helpers_ending_FULL_after_borrowing'] = sorted( + r for r in canon_cold if r not in removed and r not in P['restored']) + # exact mass bookkeeping: local mass = sum of all register widths + COPY mass, so the saving must equal + # (canonical widths of removed helpers) - (width added to canonical cold helpers that now end at FULL) + grown = sum(len(P['end'][r]) - len(C['end'][r]) for r in out['canonical_cold_helpers_ending_FULL_after_borrowing']) + removed_widths = sum(len(C['end'][r]) - len(C['start'][r]) for r in removed) + others_same = all(P['start'][r] == C['start'][r] and P['end'][r] == C['end'][r] for r in P['live'] + if r not in out['canonical_cold_helpers_ending_FULL_after_borrowing']) + need(others_same, 'link', 'some other register changed its start/end frame') + out['mass_identity'] = dict(removed_widths=removed_widths, width_added_to_cold_now_FULL=grown, + predicted_saving=removed_widths - grown) + high = set() + low = set() + for bl in blocks['sources'][0]['blocks']: + high |= set(bl['high']) + low |= set(bl['low']) + need(removed <= high and not (removed & low), 'link', 'removed helpers are not all high helpers') + out['high_helpers_in_blocks'] = len(high) + old_w = Counter(len(C['end'][r]) - len(C['start'][r]) for r in removed) + out['removed_old_widths'] = dict(sorted(old_w.items())) + need(dict(old_w) == CLAIMS['removed_old_widths'][tag], 'link', 'removed helper canonical widths %r' % dict(old_w)) + # witness: pairs <-> warp records + need(wit['initial_corrections'] == [], 'link', 'witness has initial corrections') + pairs = wit['pairs'] + need(len(pairs) == len(P['warps']), 'link', 'witness pair count') + gauss = dict((g['operator'], g['G_columns']) for g in wit['gaussian']['records']) + for wr, pr in zip(P['warps'], pairs): + k = wr['op'] + need(pr['borrow_from'] == wr['lender'], 'link', 'warp %d lender != witness borrow_from' % k) + need(gauss.get(k) == wr['G'], 'link', 'warp %d G != witness Gaussian record' % k) + need(span(pr['retirement_basis']) == wr['U'], 'link', 'warp %d U != witness retirement basis' % k) + need(span(pr['handoff_basis']) == wr['E'], 'link', 'warp %d E != witness handoff basis' % k) + need(pr['anticipate'] is False and pr['low'] is False and pr['handoff_paid_rank'] == 0, 'link', + 'warp %d witness flags' % k) + need(set(p['register'] for p in pairs) == removed, 'link', 'witness registers != removed set') + # B multiset: canonical B plus the 48 moved tail gates, with each removed helper renamed to its lender + rename = dict((p['register'], p['borrow_from']) for p in pairs) + def ren(g): + if g[0] == 'add': + return ('add', rename.get(g[1], g[1]), rename.get(g[2], g[2]), g[3], g[4]) + return ('scale', rename.get(g[1], g[1]), g[2], g[3]) + moved = [C['sections']['tail'][e['old_tail_index']] for e in wit['early_tail_events']] + lhs = Counter(norm(ren(g)) for g in list(C['sections']['B']) + moved) + rhs = Counter(norm(it) for it in P['B_items'] if it[0] != 'warp') + out['B_multiset_equals_canonical_B_plus_moved_tail_renamed'] = (lhs == rhs) + need(lhs == rhs, 'link', 'B multiset != canonical B + moved tail (renamed)') + out['moved_tail_gates'] = len(moved) + # providers (interface to the owner fill) + need(providers['widths'] == fr['widths'], 'link', 'BORROW-PROVIDERS widths != recount') + need(dict((int(k), c) for k, c in providers['actual_paid_profile'].items()) == dict(fr['paid']), 'link', + 'BORROW-PROVIDERS paid profile != recount') + out['providers_widths_match'] = True + return out + + +def link_566(C, o): + """Canonical word == predecessor 566 word up to a register permutation and a linear frame map.""" + h = C['h'] + pi = {} + pairs = {} + + def lit(F): + return None if F is None else span(F) + + def add_pair(a, b, where): + need((a is None) == (b is None), 'link566', 'frame presence differs at %s' % where) + if a is not None: + need(pairs.setdefault(a, b) == b, 'link566', 'inconsistent frame pair at %s' % where) + + def align(cg, og, where): + need(cg[0] == og[0], 'link566', 'op differs at %s' % where) + oc = conv_gate(og, lit, where) + need(coef(cg) == coef(oc), 'link566', 'coefficient differs at %s' % where) + for x, y in zip(regs_of(cg), regs_of(oc)): + need(pi.setdefault(x, y) == y, 'link566', 'register map conflict at %s' % where) + add_pair(cg[-1], oc[-1], where) + + for name in ('precondition', 'A', 'cut', 'B'): + need(len(C['sections'][name]) == len(o[name]), 'link566', 'length of %s' % name) + for i, (cg, og) in enumerate(zip(C['sections'][name], o[name])): + align(cg, og, '%s[%d]' % (name, i)) + early = o['early_cleanup'] + eidx = [e[0] for e in early] + need(len(set(eidx)) == len(eidx) == len(C['sections']['tail']), 'link566', 'early cleanup count') + rest = [g for i, g in enumerate(o['cleanup']) if i not in set(eidx)] + need(len(rest) == len(C['sections']['cleanup']), 'link566', 'cleanup length') + for i, (cg, og) in enumerate(zip(C['sections']['cleanup'], rest)): + align(cg, og, 'cleanup[%d]' % i) + for i, (cg, (j, F)) in enumerate(zip(C['sections']['tail'], early)): + og = list(o['cleanup'][j][:-1]) + [F] + align(cg, og, 'tail[%d]' % i) + need(len(pi) == C['n'] and len(set(pi.values())) == C['n'], 'link566', 'register map is not a bijection') + v = C['v'] + need(all((x < v) == (y < v) and (x < 2 * v) == (y < 2 * v) for x, y in pi.items()), 'link566', 'roles not preserved') + need(all(x == y for x, y in pi.items() if x >= 2 * v), 'link566', 'helpers renumbered') + # linear frame map tau from 1-dim pairs, then verified on every frame + ones = [(a[0], b[0]) for a, b in pairs.items() if len(a) == 1 and b is not None and len(b) == 1] + piv = {} + for a, b in ones: + x, y = a, b + for p in list(piv): + pa, pb = piv[p] + if (x >> p) & 1: + x ^= pa + y ^= pb + if x: + lead = x.bit_length() - 1 + for p in list(piv): + pa, pb = piv[p] + if (pa >> lead) & 1: + piv[p] = (pa ^ x, pb ^ y) + piv[lead] = (x, y) + need(len(piv) == h, 'link566', 'one-dimensional frame pairs do not span F_2^h') + tau = [0] * h + for p, (a, b) in piv.items(): + need(a == 1 << p, 'link566', 'tau construction') + tau[p] = b + need(mat_inverse(tau, h) is not None, 'link566', 'tau singular') + tmap = lambda S: span([mat_apply(tau, x) for x in S]) + for a, b in pairs.items(): + need(tmap(a) == b, 'link566', 'frame pair not induced by the linear map tau') + for i in range(v): + need(mat_apply(tau, C['ports'][i]) == o['ports'][pi[i]], 'link566', 'port %d' % i) + need([pi[q] for q in C['centers']] == o['centers'], 'link566', 'centres') + need([tmap(F) for F in C['center_frames']] == [span(F) for F in o['center_frames']], 'link566', 'centre frames') + full = C['full'] + for r in range(2 * v, C['n']): + os_ = span(o['start_extra'][str(r)]) if str(r) in o['start_extra'] else () + oe = span(o['helper_final'][str(r)]) if str(r) in o['helper_final'] else full + need(tmap(C['start'][r]) == os_, 'link566', 'helper start %d' % r) + need(tmap(C['end'][r]) == oe, 'link566', 'helper end %d' % r) + need(dict((int(k), c) for k, c in o['report']['local_profile'].items()) == C['claimed_profile'], 'link566', + 'canonical local_profile != 566 report local_profile') + return dict(register_permutation_nonidentity=sum(1 for x, y in pi.items() if x != y), + frame_map_tau_columns=tau, aligned_frame_pairs=len(pairs)) + + +# ---------------------------------------------------------------------------- +# Driver +# ---------------------------------------------------------------------------- + +def dsort(c): + return dict((str(k), c[k]) for k in sorted(c)) + + +def expect_reject(name, target, fn, results, also=None): + """Run fn (which must raise Reject from check family `target`).""" + entry = dict(control=name, target_check=target) + try: + fn() + entry.update(rejected=False) + except Reject as e: + entry.update(rejected=True, by=e.check, reason=e.msg[:200]) + entry['ok'] = bool(entry['rejected'] and entry.get('by') == target) + if also is not None: + info = {} + for label, g in also: + try: + g() + info[label] = 'accepted' + except Reject as e: + info[label] = 'rejected[%s]' % e.check + entry['other_checks'] = info + results.append(entry) + print(' control %-58s target=%-8s %s' % (name, target, 'REJECTED-OK' if entry['ok'] else 'NOT-OK ' + str(entry)), flush=True) + return entry['ok'] + + +def mutate_P(P): + Q = dict(P) + for key in ('pre', 'A', 'cut', 'B_items', 'post', 'cleanup'): + Q[key] = list(P[key]) + Q['warps'] = [dict(w) for w in P['warps']] + return Q + + +def profile_check(P, fr, claim): + need(dict(fr['paid']) == P['claimed_profile'], 'profile', 'recount %r != word report %r' % (dsort(fr['paid']), P['claimed_profile'])) + need(dict(fr['paid']) == claim, 'profile', 'recount != claimed profile') + + +def controls_for(tag, P, claim, results): + ok = True + v = P['v'] + warps = P['warps'] + # pick a warp with U != E and its B-item index + k0 = next(w['op'] for w in warps if w['U'] != w['E']) + # 1. drop one warp from the forward word (cleanup keeps its inverse) + Q = mutate_P(P) + Q['B_items'] = [it for it in P['B_items'] if not (it[0] == 'warp' and it[2] == k0)] + ok &= expect_reject('drop forward warp %d' % k0, 'replay', lambda: replay(Q), results, + also=[('frame', lambda: frame_check(Q))]) + # 2. drop one inverse warp in cleanup + Q2 = mutate_P(P) + j = next(i for i, it in enumerate(P['cleanup']) if it[0] == 'warp' and it[2] == -k0) + del Q2['cleanup'][j] + ok &= expect_reject('drop inverse warp %d in cleanup' % k0, 'replay', lambda: replay(Q2), results, + also=[('frame', lambda: frame_check(Q2))]) + # 3. perturb one coefficient (one dyadic step: c -> 2c) in B after the first warp, in compensation, in cleanup + lender = next(w['lender'] for w in warps if w['op'] == k0) + wi = next(i for i, it in enumerate(P['B_items']) if it[0] == 'warp' and it[2] == k0) + bi = next(i for i in range(wi + 1, len(P['B_items'])) if P['B_items'][i][0] == 'add' and lender in regs_of(P['B_items'][i])) + for label, key, idx in (('B item %d (lender %d after its warp)' % (bi, lender), 'B_items', bi), + ('compensation gate 0', 'pre', P['n_pre']), + ('first cleanup add between live registers', 'cleanup', + next(i for i, it in enumerate(P['cleanup']) + if it[0] == 'add' and it[1] not in P['buffers'] and it[2] not in P['buffers']))): + Q3 = mutate_P(P) + g = list(Q3[key][idx]) + g[3] = g[3] * 2 + Q3[key][idx] = tuple(g) + ok &= expect_reject('perturb coefficient x2: %s' % label, 'replay', lambda: replay(Q3), results, + also=[('frame', lambda: frame_check(Q3))]) + # 4a. treat the warp frame change as an ordinary climb (no K_G) + ok &= expect_reject('warp %d as an ordinary climb U->E' % k0, 'frame', + lambda: frame_check(P, warp_as_climb=(k0,)), results) + # 4b. charge every warp its plain Fourier distance d(L_U, L_E) + def charged(): + fr = frame_check(P, charge_warps=True) + profile_check(P, fr, claim) + ok &= expect_reject('charge every warp as a climb of rank d(L_U,L_E)', 'profile', charged, results) + # 5. swap two warp lenders (warps at one position with different U) + pair = None + for a in warps: + for b in warps: + if a['op'] < b['op'] and a['pos'] == b['pos'] and a['U'] != b['U']: + pair = (a['op'], b['op']) + break + if pair: + break + need(pair is not None, 'control', 'no swappable warp pair') + la = next(w['lender'] for w in warps if w['op'] == pair[0]) + lb = next(w['lender'] for w in warps if w['op'] == pair[1]) + Q5 = mutate_P(P) + Q5['B_items'] = [(it[0], lb if it[1] == la else la, it[2], it[3], it[4]) + if it[0] == 'warp' and it[2] in pair else it for it in P['B_items']] + ok &= expect_reject('swap lenders of warps %d,%d' % pair, 'frame', lambda: frame_check(Q5), results, + also=[('replay', lambda: replay(Q5))]) + # 6. warp algebra: singular G, invertible G with G U != E, dimension mismatch + def warp_mut(fn): + wr = dict(warps[0]) + fn(wr) + return lambda: check_warp(wr, P['h'], set(P['live']), v) + + def singular(wr): + wr['G'] = list(wr['G']) + wr['G'][1] = wr['G'][0] + ok &= expect_reject('warp 1: singular G', 'warp', warp_mut(singular), results) + + def wrong_image(wr): + h = P['h'] + for j in range(h): + for i in range(h): + if i == j: + continue + G = list(wr['G']) + G[j] ^= G[i] + if mat_inverse(G, h) is not None and span([mat_apply(G, u) for u in wr['U']]) != wr['E']: + wr['G'] = G + return + raise Reject('control', 'no wrong-image G found') + ok &= expect_reject('warp 1: invertible G with G span U != span E', 'warp', warp_mut(wrong_image), results) + + def dim_drop(wr): + wr['E_list'] = wr['E_list'][:-1] + wr['E'] = span(wr['E_list']) + ok &= expect_reject('warp 1: dim E != dim U', 'warp', warp_mut(dim_drop), results) + # 7. cleanup reads a restored register directly instead of its zero buffer + Q7 = mutate_P(P) + j = next(i for i, it in enumerate(P['cleanup']) if it[0] == 'add' and (it[1] in P['buffers'] or it[2] in P['buffers'])) + it = list(P['cleanup'][j]) + if it[1] in P['buffers']: + it[1] -= P['n'] + else: + it[2] -= P['n'] + Q7['cleanup'][j] = tuple(it) + ok &= expect_reject('cleanup item %d uses the restored register, not its buffer' % j, 'frame', + lambda: frame_check(Q7), results) + # 8. delete one restore gate + Q8 = mutate_P(P) + del Q8['post'][0] + ok &= expect_reject('delete restore gate 0', 'replay', lambda: replay(Q8), results) + # 9. delete one T74 compensation gate (dirty helper inputs are live symbols) + Q9 = mutate_P(P) + del Q9['pre'][P['n_pre']] + ok &= expect_reject('delete compensation gate 0', 'replay', lambda: replay(Q9), results) + # 10. drop the cleanup adds that read a never-yet-written buffer: no-ops in the forward replay, but in the + # dual (s -= c t) they write the buffer, so only the dual replay can reject this + Q10 = mutate_P(P) + written, keep = set(), [] + for it in P['cleanup']: + if it[0] == 'add' and it[2] in P['buffers'] and it[2] not in written: + continue + if it[0] == 'add' and it[1] in P['buffers']: + written.add(it[1]) + keep.append(it) + Q10['cleanup'] = keep + ok &= expect_reject('drop %d forward-no-op cleanup adds (dual replay)' % (len(P['cleanup']) - len(keep)), 'replay', + lambda: replay(Q10, dual=True), results, also=[('forward replay', lambda: replay(Q10))]) + ok &= results[-1]['other_checks']['forward replay'] == 'accepted' # they really are forward no-ops + # positive mutation: re-express U and E of every warp in another basis of the same span + Qp = mutate_P(P) + rebased = [] + for wr in warps: + w2 = dict(wr) + if len(w2['U_list']) > 1: + w2['U_list'] = [w2['U_list'][0] ^ w2['U_list'][1]] + w2['U_list'][1:] + w2['E_list'] = w2['E_list'][1:] + [w2['E_list'][0] ^ w2['E_list'][-1]] + w2['U'], w2['E'] = span(w2['U_list']), span(w2['E_list']) + rebased.append(w2) + entry = dict(control='positive: rebased warp U/E lists (same spans) accepted', target_check='warp+frame') + try: + for w2 in rebased: + check_warp(w2, P['h'], set(P['live']), v) + Qp['warps'] = rebased + frp = frame_check(Qp) + profile_check(Qp, frp, claim) + entry.update(accepted=True, ok=True) + except Reject as e: + entry.update(accepted=False, ok=False, reason=str(e)) + print(' control %-58s %s' % (entry['control'], 'ACCEPTED-OK' if entry['ok'] else 'NOT-OK'), flush=True) + results.append(entry) + ok &= entry['ok'] + return ok + + +def main(): + ap = argparse.ArgumentParser(description='Independent check of PR2269 BORROW-WORD-43{base,extra}') + ap.add_argument('--repo', default=DEFAULT_REPO, help='git checkout containing commit %s' % COMMIT) + ap.add_argument('--blob-dir', default=None, help='directory with exported blobs (basename of each path)') + ap.add_argument('--out', default=None, help='JSON receipt path (must be next to this script)') + ap.add_argument('--skip-controls', action='store_true', help='skip negative controls (not a PASS run)') + args = ap.parse_args() + if sys.flags.optimize: + print('refusing to run under -O') + print(FAIL_LINE) + return 2 + here = os.path.dirname(os.path.abspath(__file__)) + if args.out is not None: + if os.path.dirname(os.path.abspath(args.out)) != here: + print('--out must name a file next to this script (%s)' % here) + print(FAIL_LINE) + return 2 + t0 = time.time() + receipt = dict(checker='words_check.py', object=dict(pr=2269, commit=COMMIT, package=PKG), + python=sys.version.split()[0], scope='task A: BORROW-WORD-43{base,extra} and new/borrow/inputs') + ok = True + try: + js, pins, raw = load_inputs(args.repo, args.blob_dir) + receipt['pins'] = pins + print('pins: %d input blobs verified (sha256 + git blob id)' % len(pins), flush=True) + words = {} + for tag in ('base', 'extra'): + claim = CLAIMS[tag] + print('== word 43%s' % tag, flush=True) + w = js['word_' + tag] + res = dict(base_tag=w.get('base')) + need(w.get('base') == claim['base_tag'], 'link', 'base tag') + need(PINS['word566_' + tag][2].startswith(w['base']), 'link', 'base tag is not the 566 word sha256 prefix') + P = parse_borrow(w) + C = parse_canonical(js['canon_' + tag]) + # 1. warps + wres = check_all_warps(P) + res['warps'] = dict(count=len(wres), dims=dsort(Counter(x['dim'] for x in wres)), + positions=[x['pos'] for x in wres], lenders=[x['lender'] for x in wres], + lenders_that_are_X=[x['lender'] for x in wres if x['lender'] < P['v']], + lenders_that_are_restored_cold=[x['lender'] for x in wres if x['lender'] in P['restored']], + U_equal_E=sum(1 for x in wres if x['U_eq_E']), + U_inside_E=sum(1 for x in wres if x['U_in_E']), + plain_fourier_distance=dsort(Counter(x['plain_fourier_distance'] for x in wres)), + anticipatory_terms=len(w['initial_corrections'])) + need(len(wres) == CLAIMS['warps'], 'warp', 'warp count') + print(' warps: %d PASS (dims %s); anticipatory terms %d' % (len(wres), res['warps']['dims'], len(w['initial_corrections'])), flush=True) + # 2. frames + profile + fr = frame_check(P) + profile_check(P, fr, claim['profile']) + need(dict(fr['inventory']) == CLAIMS['width_inventory'] == P['claimed_inventory'], 'profile', 'width inventory') + need(fr['helpers'] == CLAIMS['helpers_after'] == P['R'] - len(P['removed']), 'profile', 'helper count') + need(fr['mass'] == CLAIMS['mass'], 'profile', 'local mass') + frc = frame_check(P, charge_warps=True) + res['frames'] = dict(model_ok=True, paid_profile=dsort(fr['paid']), climbs=dsort(fr['climbs']), + copy_charges=dsort(fr['copies']), local_mass=fr['mass'], + width_inventory=dsort(fr['inventory']), helpers=fr['helpers'], + if_warps_charged_profile=dsort(frc['paid']), if_warps_charged_mass=frc['mass']) + print(' frames: PASS; paid %s (climbs %s + COPY %s), mass %d, helpers %d, inventory %s' % ( + res['frames']['paid_profile'], res['frames']['climbs'], res['frames']['copy_charges'], fr['mass'], + fr['helpers'], res['frames']['width_inventory']), flush=True) + # 3. replay + rf = replay(P) + rd = replay(P, dual=True) + res['replay'] = dict(forward=rf, dual=rd) + print(' replay: forward PASS %s; dual PASS' % rf, flush=True) + # links + res['links'] = link_checks(tag, P, C, js['witness_' + tag], js['blocks'], + js['providers'][claim['providers_key']], fr) + print(' links: PASS %s' % {k: v for k, v in res['links'].items() if k != 'canonical_cold_helpers_ending_FULL_after_borrowing'}, flush=True) + # 5. positive control: canonical words + frC = frame_check(C) + need(dict(frC['paid']) == C['claimed_profile'] == claim['old_profile'], 'canonical', + 'canonical profile not reproduced: %r' % dsort(frC['paid'])) + rC = replay(C) + l566 = link_566(C, js['word566_' + tag]) + res['canonical'] = dict(paid_profile=dsort(frC['paid']), climbs=dsort(frC['climbs']), + copy_charges=dsort(frC['copies']), local_mass=frC['mass'], + width_inventory=dsort(frC['inventory']), helpers=frC['helpers'], replay=rC, + link_566=l566) + print(' canonical positive control: profile %s mass %d reproduced, replay PASS, 566-link PASS' % ( + res['canonical']['paid_profile'], frC['mass']), flush=True) + res['saving'] = dict(mass_before=frC['mass'], mass_after=fr['mass'], helpers_before=frC['helpers'], + helpers_after=fr['helpers']) + need(frC['mass'] - fr['mass'] == res['links']['mass_identity']['predicted_saving'] and + frC['copies'] == fr['copies'], 'profile', 'saving does not match the width bookkeeping') + if not args.skip_controls: + results = [] + cok = controls_for(tag, P, claim['profile'], results) + # canonical negative controls + CQ = mutate_P(C) + del CQ['pre'][C['n_pre']] + cok &= expect_reject('canonical: delete compensation gate 0', 'replay', lambda: replay(CQ), results) + CF = mutate_P(C) + CF['post'] = list(C['post']) + j = next(i for i, g in enumerate(C['post']) if g[-1] != C['full']) + g = list(C['post'][j]) + g[-1] = C['full'] + CF['post'][j] = tuple(g) + cok &= expect_reject('canonical: tail gate %d lifted to FULL (cold end violated)' % j, 'frame', + lambda: frame_check(CF), results) + o_mut = copy.deepcopy(js['word566_' + tag]) + o_mut['B'][0][-1] = o_mut['B'][1][-1] if span(o_mut['B'][1][-1]) != span(o_mut['B'][0][-1]) else [1] + cok &= expect_reject('566 link: one 566 B-gate frame changed', 'link566', + lambda: link_566(C, o_mut), results) + bad = bytearray(raw['word_' + tag]) + bad[len(bad) // 2] ^= 1 + cok &= expect_reject('pin: one flipped bit in the word blob', 'pin', + lambda: verify_pin('word_' + tag, bytes(bad)), results) + res['controls'] = results + res['controls_ok'] = bool(cok) + ok &= bool(cok) + words[tag] = res + receipt['words'] = words + fb, fe = words['base'], words['extra'] + bf = fb['replay']['forward'] + # the summary below speaks for both words: assert that the shared facts really are shared + for key in ('dims', 'lenders', 'lenders_that_are_X', 'plain_fourier_distance', 'anticipatory_terms'): + need(fb['warps'][key] == fe['warps'][key], 'summary', 'warp fact %s differs between words' % key) + need(fb['replay']['forward'] == fe['replay']['forward'] and fb['replay']['dual'] == fe['replay']['dual'], + 'summary', 'buffer diagnostics differ between words') + bd = fb['replay']['dual'] + need(fb['frames']['local_mass'] == fe['frames']['local_mass'] and + fb['frames']['if_warps_charged_mass'] == fe['frames']['if_warps_charged_mass'], 'summary', 'mass differs') + need(fb['links']['canonical_cold_helpers_ending_FULL_after_borrowing'] == + fe['links']['canonical_cold_helpers_ending_FULL_after_borrowing'], 'summary', 'cold-to-FULL list differs') + need(fb['canonical']['helpers'] == fe['canonical']['helpers'] == CLAIMS['helpers_before'], 'summary', + 'unborrowed helper count') + cold_full = fb['links']['canonical_cold_helpers_ending_FULL_after_borrowing'] + cold_lenders = sorted(set(cold_full) & set(fb['warps']['lenders'])) + ncomp = len(js['canon_base']['compensation']) + receipt['findings'] = [ + 'Both words: 43 warps pass the GF(2) checks (G invertible, dim U = dim E, G span U = span E, ' + 'K_G symplectic, fixes L_0 and L_FULL, K_G L_U = L_E, Fourier rank 0); handoff dims %s; ' + '%d anticipatory/initial correction terms; the %d-gate T74 compensation is the canonical one ' + 'unchanged (%d + %d gates dropped, i.e. none reads a removed helper).' % ( + fb['warps']['dims'], fb['warps']['anticipatory_terms'], ncomp, + fb['links']['canonical_compensation_gates_dropped'], fe['links']['canonical_compensation_gates_dropped']), + 'Paid profiles recounted exactly: base %s, extra %s (climbs + COPY %s); mass %d both; ' + '%d helpers (from %d); width inventory %s.' % ( + fb['frames']['paid_profile'], fe['frames']['paid_profile'], fb['frames']['copy_charges'], + fb['frames']['local_mass'], fb['frames']['helpers'], fb['canonical']['helpers'], + fb['frames']['width_inventory']), + 'Exact replay over Q in both orientations: Y_i <- Y_i + X_i, all other %d non-target registers (X and live helpers) restored, ' + '%d zero buffers returned to zero.' % (bf['independent_inputs'] - 112, bf['buffers']), + 'Canonical inputs reproduce the old profiles (base %s mass %d; extra %s mass %d), replay exactly, ' + 'and equal the pinned 566 predecessor words up to a role-preserving register permutation and a ' + 'linear frame map.' % (fb['canonical']['paid_profile'], fb['canonical']['local_mass'], + fe['canonical']['paid_profile'], fe['canonical']['local_mass']), + 'README imprecision: "8 width-4, 35 width-5" holds for the base word; the extra word removes ' + 'helpers of canonical widths %s.' % fe['links']['removed_old_widths'], + 'Canonical cold helpers %s end at FULL after borrowing (of these, %s also lend); with the removed ' + 'widths this gives the exact mass savings %d (base) and %d (extra).' % ( + cold_full, cold_lenders, + fb['canonical']['local_mass'] - fb['frames']['local_mass'], + fe['canonical']['local_mass'] - fe['frames']['local_mass']), + 'Lenders that are source registers X: %s; lenders that are restored cold helpers: %s.' % ( + fb['warps']['lenders_that_are_X'], fb['warps']['lenders_that_are_restored_cold']), + 'Cleanup uses %d private zero buffers outside the helper inventory. Forward orientation: at most %d are ' + 'non-zero simultaneously (max overlap of lifetimes %d); %d cleanup adds read a still-zero buffer (no-ops ' + 'in the forward replay only: in the dual such an add writes the buffer, and dropping those that read a ' + 'never-written buffer is rejected by the dual replay, see the controls). Dual orientation: at most %d ' + 'non-zero simultaneously (%d ever non-zero). No paid child runs in ' + 'cleanup. Peak helper-like fields during cleanup are %d+%d = %d (lazy, forward), %d+%d = %d (lazy, dual) ' + 'or %d+%d = %d (eager); the unborrowed word uses %d. Whether the global accounting must host them is a ' + 'global-model question that is not decided here.' % ( + bf['buffers'], bf['peak_nonzero_buffers'], bf['max_overlap_of_buffer_lifetimes'], + bf['cleanup_adds_reading_a_zero_buffer'], bd['peak_nonzero_buffers'], bd['buffers_ever_nonzero'], + fb['frames']['helpers'], bf['peak_nonzero_buffers'], + fb['frames']['helpers'] + bf['peak_nonzero_buffers'], fb['frames']['helpers'], + bd['peak_nonzero_buffers'], fb['frames']['helpers'] + bd['peak_nonzero_buffers'], + fb['frames']['helpers'], bf['buffers'], fb['frames']['helpers'] + bf['buffers'], + fb['canonical']['helpers']), + 'Charging each warp as a plain frame change (rank d(L_U,L_E), distances %s) would raise the local mass ' + 'from %d to %d; the saving depends on rank-zero K_G handoffs, checked here only at the binary ' + 'symplectic level.' % (fb['warps']['plain_fourier_distance'], fb['frames']['local_mass'], + fb['frames']['if_warps_charged_mass']), + ] + receipt['not_checked'] = [ + 'Exact Clifford (Gaussian-dyadic, unit quadratic phase) lifts of K_G and their native lowering; only the ' + 'binary symplectic image is checked (it determines the Fourier rank by notes/general-clifford-frames.tex).', + 'Native word lowering, both hosted orientations at the native level, owner/window hosting of the 437 ' + 'helpers and the 76 buffers, precision/tape, global profile, kappa and outer assembly.', + 'Provenance of the 566 predecessor words beyond their pinned blobs (they are taken as the old record inputs).', + ] + receipt['buffers_note'] = ( + 'Each borrowed word uses %d private zero buffers (one per restored cold helper) only inside the ' + 'FULL-frame cleanup; they are not among the 437 helpers of the width inventory. No paid child occurs ' + 'in cleanup (all items at FULL).' % words['base']['replay']['forward']['buffers']) + for line in receipt['findings']: + print('FINDING: ' + line) + except Reject as e: + ok = False + receipt['failure'] = str(e) + print('FAILED: %s' % e, flush=True) + receipt['skip_controls'] = bool(args.skip_controls) + receipt['result'] = PASS_LINE if (ok and not args.skip_controls) else FAIL_LINE + receipt['model'] = __doc__.split('MODEL (stated precisely; see also the receipt field "model").')[1].strip() + print('elapsed %.1f s' % (time.time() - t0)) + if args.out is not None: + with open(args.out, 'w') as fh: + json.dump(receipt, fh, indent=1, sort_keys=True) + fh.write('\n') + print('receipt written: %s' % args.out) + print(receipt['result']) + return 0 if receipt['result'] == PASS_LINE else 1 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/research/t74-3015-restore-edit-audit/vendor/pr2387/fill_check80.py b/research/t74-3015-restore-edit-audit/vendor/pr2387/fill_check80.py new file mode 100644 index 0000000000..557e0732bf --- /dev/null +++ b/research/t74-3015-restore-edit-audit/vendor/pr2387/fill_check80.py @@ -0,0 +1,1285 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""Standalone independent recount of the 80-alias T74 whole-helper owner fill (OWNERS-80.json.gz). + +Object: OWNERS-80.json.gz of this package (research/t74-80alias-owner-fill/, sha256 pinned below): 266,400 +literal roles hosting the 400 live helpers of the two 80-alias T74 borrow words of PR #2339 +(BORROW-WORD-80base = provider gauge44, BORROW-WORD-80extra = provider extra; commit bf1742ae) in the idle +children of PR #2269's unchanged T74 template (head b479fc55: 74 replicas, nine stages, 666 calls). + +This file is an adaptation of our own iteration-3 independent checker (fill_check.py and the frame recount of +words_check.py, research/t74-borrow43-independent-check/ at commit 4a2f20ea, Apache-2.0, same author). It is +standalone: standard library only, it imports no module of this package (not build_fill.py, not +check_fill.py, not vendor/), and no code of PR #2269 / #2322 / #2339 is imported or run. Every input is a git +blob read with `git cat-file` at a pinned commit and is pinned by git blob id *and* sha256. The PR #2339 files +are read from commit bf1742ae when it is present; otherwise from the byte-identical copies in inputs/, which +must match the same blob ids and sha256 pins. The recount does not read PROFILE-80.json or BUILD-RECEIPT.json; +those, and the builder's reported numbers (CLAIMS below), are only compared with the recount at the end. +All accepted facts are integer or GF(2) facts. The script refuses `python -O`. + +Hosting rules (PR858 / complex-double-replica-owners PROOF.md lineage; T16 owner audit rules R1-R7/X1): + R-a one role per (call, live helper): 666 calls x 400 helpers; helper i = i-th live helper register of the + word (224..703 minus the 80 `removed`, increasing); width = dim(final frame) - dim(start frame) over + GF(2), re-derived from both words (they have equal live registers and ordered widths, asserted). + R-e family = owner*896 + (2*pair(child)+side(child))*112 + port, copy = 112*owner + port; family inside the + data namespace [0, W), W = 896*74 = 66304; not the caller's active pair; at most one helper per family + per call. + R-d the call lies strictly inside the owner's actual window, rebuilt from the template's 30 per-replica + source events expanded in ORDER (bridge-aware). X1: rebuilt windows == PR #2269 new/PLAN.json windows. + R-b slices [offset, offset+width) lie in [0, rank(child)), are disjoint per bin (owner, child, port) and + form an occupied prefix. + R-c idle remainders (rank - occupied, per bin) and the global profile sum_calls P_provider + idle are + recounted here; P_provider is recounted from the word by the frame-climb rule (nested climbs + COPY + charges) and compared with the word report and PR #2339's AUDIT receipts; rank-mass, deficit, capacity + and halving identities. + R-f private namespace, stated as PR #2322 does (README "complete physical stock" and + evidence/PRIVATE-NAMESPACE-INJECTION.json): physical = W + 8 centres + R reserved tableau + 2 + coefficient work; centres [W, W+8), reserved tableau [W+8, W+8+R), coefficient [P-2, P); the NZ + private cleanup zero buffers (buffer register r + 704 for every hyperplane-ended live helper r) are + injected in increasing order into [W+8, W+8+NZ), which must lie inside the reserved tableau (NZ <= R); + every hosted helper family is a live data family (< W), hence disjoint from all private names. + The same rule applied to (R, NZ) = (434, 78) must reproduce PR #2322's stated geometry exactly. + R-g X2 and 73-column charts (rule of PR #2269 independent_core.py check_pending_axes / check_roles, Hao Yan + checker lineage): DATA-PHASES.json is read at the PR #2269 commit (blob pinned; its sha256 must equal the + template's exact_data_phase_recipe_sha256) and its 112 port vectors must equal both words' ports. Per + port, the owner 73-frame is orthonormal; every ranked child's pending orthogonal axes are rank-many, + distinct and in that frame, and children sharing a family (pair, side) have disjoint axes (X2). Every + role's slice binds pending[offset:offset+width] to a residual/spectator permutation of the 73 columns; + the distinct charts are counted (positive control: PR #2269's fill gives its SPEC actual_73column_sigmas). + +Positive control: the same pipeline on PR #2269's own fill (OWNERS.json.gz, 437 helpers of the 43-alias +words), including the PLAN per_call_widths comparison, must reproduce its idle {1:23976,3:8673,5:813,7:150, +48:24479} and its global profile. For the 80-alias fill the PLAN per_call_widths comparison (437-helper +lists) is replaced by the word-derived widths; everything else of the static checks, including X1, is kept. +Negative controls: each mutation must be rejected by the check it targets. + +Credits: PR2339 (this author: the 80-alias words); PR2269 Jeremy Kothe (jeremykothe2; T74 template, +windows, dispatch, owner-row format); PR2322 Vlado Vojdanovski (owner exchanges; the private-namespace +statement followed here); PR2312/PR2302 jeremykothe2; PR2226 Cinna Davis (anticipatory dirty borrowing); +PR1319/PR1297 T74 lineage (Rohan Arun et al.); hosting rules of Hao Yan's PR858 / complex-double-replica-owners +PROOF.md and the T16 owner audit (Josie Elliston; icekylinx / Zhihao Chen checker lineage). +Prepared with substantial AI assistance (Claude Code, Anthropic); Apache-2.0. + +Usage: python3 -I -B fill_check80.py [--repo PATH] [--words-from-inputs] [--skip-positive-control] [--out] +The final stdout line starts with PASS_T74_80ALIAS_FILL_INDEPENDENT or FAIL_T74_80ALIAS_FILL_INDEPENDENT. +""" + +import argparse +import bisect +import gzip +import hashlib +import json +import os +import subprocess +import sys +import time +from collections import Counter +from fractions import Fraction + +if not __debug__: + sys.stdout.write('FAIL_T74_80ALIAS_FILL_INDEPENDENT refusing to run under python -O\n') + sys.exit(2) + +HERE = os.path.dirname(os.path.abspath(__file__)) +REPO_DEFAULT = os.path.dirname(os.path.dirname(HERE)) +RECEIPT_NAME = 'fill_check80.receipt.json' +PASS_LINE = 'PASS_T74_80ALIAS_FILL_INDEPENDENT' +FAIL_LINE = 'FAIL_T74_80ALIAS_FILL_INDEPENDENT' + +HEAD_2269 = 'b479fc5567bc09ab9185bffe89b62594f36d74e5' +PKG_2269 = 'research/gmx-t74-borrow43' +HEAD_2322 = '002304ef01c4416a127916169ae6d94c1bee052b' +PKG_2322 = 'research/t74-joint-owner-hillclimb' +HEAD_2339 = 'bf1742aee4d855efb8bbd44a8419eddb33a679e5' +PKG_2339 = 'research/t74-low-alias-borrowing' + +# package-relative path -> (git blob id, sha256) +PINS_2269 = { + 'OWNERS.json.gz': ('fc874cb553af5b984e34c1d8696d2213d7458f8f', '5a8c9a18c21f635563c9a6b6a433bcb1e804175ef23d677459033344aa2bd4e6'), + 'new/PROFILE.json': ('3e103605dd46c8754028056eb9dde9a73b9bfdca', '50fcc0960a47f6d35064d3b55ea6dcb4cebbd305aec215c8034f626718595538'), + 'new/SPEC.json': ('2431d1cebbb2e155356d2da160d60808498bc33d', 'bd091ed9e7f4939d06abb467d0d2c56ce0f34ba800d74132669f7b667e125d2d'), + 'new/PLAN.json': ('7cacd857edd0f29be5bd2ca9590a17fed4da17ba', 'bf1abd33c8ba946371cae37e021747343ef6603a31297bcc962197cc23f535e2'), + 'CONSTRUCTION.json': ('034ec6c6309bd1279661918f2a8706268f9a1200', '37b8605607b2877d82b8403d509f5cd224240064c93fa67ce89a8894acc6b460'), + 'GLOBAL-TEMPLATE.json.gz': ('5327fc2f4e8ea82ed356c94ff040d23fc73c731f', '1d31424c4e27e26a35a9932ca778e43f1f3577589275422cc642aa68b31112db'), + 'ORDER.json': ('7409c4df1092241729739596c7648bda504e6aad', '519d1d5dbb997a219fcfcad34c0b03e7838bef24199784d7e964fa10090f66e1'), + 'DISPATCH.json': ('20807cc27c82db1f8f9cd47c79713e066d6ad816', '6aad7f628f4c9b510a95c5b34357736303069ecf92a551659900b1ba540bc7e0'), + 'new/borrow/words/BORROW-WORD-43base.json.gz': ('448dd795adba29392a90b34aa3f1b1b796c7e0bd', '9492a5537fb87d9ca98dffcd0230f7625b3789744fa94e2f18acf23d91d998b5'), + 'new/borrow/words/BORROW-WORD-43extra.json.gz': ('2b51ba96256283bbc5578f99b694c50edd8a0e35', '87d51f5298101d5947f45c43ee02f0ec45d6acbddabb808d0d02db1eaf063734'), + 'new/borrow/receipts/AUDIT-43base.json': ('65728eff3ef61c275c873b58f0f8cebc095ef6f9', '9af87b149b8efa58e2454541dd1c5aef86d893c71ec488ae69fb8680c2f7936e'), + 'new/borrow/receipts/AUDIT-43extra.json': ('f9c2401401612b3b0b6e652e142e65bceadc1170', '849fbe9b9267180ba914237d751b118b4539731249c4482e6264d4772932fd2d'), + 'evidence/INDEPENDENT.json': ('16bb558f2472df730076a8163454c6f70b9e9fe3', '78cd00f832ed3c0a4b0e0d202095f7beb6111eaeb4457849d5bb920e983098a0'), +} +# DATA-PHASES.json of the template (outside the PR2269 package dir, present in the b479fc55 tree and on main). +PKG_PHASES = 'research/community-cold617-audit/pr600/replay/mixed-global/base/work/complex-nine-native' +PINS_PHASES = { + 'DATA-PHASES.json': ('d9a4f84211182ca200c081ea061d724c8a2cfb70', 'c5916ff312678f12aba403847643fbbc29f643acec60bdf836fa56cd3e8251fa'), +} +PINS_2322 = { + 'evidence/PRIVATE-NAMESPACE-INJECTION.json': ('3588cb8991177c10059ce99bd3949220bbe52580', 'fad0f68aa273e39f63904462b7ade93c7c50c29d7278d0c37eee2139bbdcad65'), + 'CLAIM.json': ('e10747182e8bdfa2fea1c8631bf738c15619eccb', '439ded151e7897b8e7d5ef9ad47f3cd8d1daf0b69219ef507a922519c7003530'), +} +# PR #2339 files; inputs/ is a byte-identical copy used when commit bf1742ae is absent. +PINS_2339 = { + 'words/BORROW-WORD-80base.json.gz': ('c5953dfdb0ee9ac0c2c73eb29e320582b4569d2b', '61290abffd8c8225e0abb3958c1506674e256de688fc4cdf358bbe7c981df493'), + 'words/BORROW-WORD-80extra.json.gz': ('852868543ed36efa799b3ed6dd76a0442b0d6ff1', '1dd2d6f2ae5b5a27b5f89fb830203f0cca7a78d0323a7845e85e1e80f8f6d1a5'), + 'receipts/AUDIT-80base.json': ('fc16634cfd3a9c5190e5b97b93cb29ddbd1547ca', 'd65a79658cba82932a9abd2c9af5dd345527141b098130b98850572420166cdd'), + 'receipts/AUDIT-80extra.json': ('b1b0c4d69e4c1a5edc3e9dd968f6f58b5eb8aaf0', '6d05abbc122d72b1eec05e7654a118dd492e55db34b30b718603521231094099'), +} +# The object under test (this package, untracked build output of build_fill.py). +OWNERS_80 = ('OWNERS-80.json.gz', 'b79d678dc8ae685fdecedca994e41b41c8a2930564ec0c58c707d7d13a3870a5') + +# Builder's reported numbers (claims under test, written here from the build report; compared at the end only). +CLAIMS_80 = dict( + roles=266400, cross_replica=251101, idle_remainders=69734, + idle={1: 2644, 3: 10310, 5: 27847, 7: 6114, 41: 33, 48: 22786}, + profile={1: 1529770, 2: 354318, 3: 267386, 4: 83250, 5: 52489, 7: 6114, 8: 5328, 41: 33, 48: 22786}, + local={'gauge44': {1: 2303, 2: 527, 3: 386, 4: 125, 5: 37, 8: 8}, + 'extra': {1: 2287, 2: 535, 3: 386, 4: 125, 5: 37, 8: 8}}, + inventory={4: 4, 5: 4, 7: 36, 8: 84, 9: 272}, zero_buffers=44) +CLAIMS_2269 = dict(idle={1: 23976, 3: 8673, 5: 813, 7: 150, 48: 24479}) + +# Geometry of the nine-stage, four-pair, 112-port controller (template/PLAN): +V = 112 # data ports per (pair, side) +H = 9 # local frame dimension +M = 73 # global dimension m +STAGES = 9 +PAIRS = 4 +FAMILIES_PER_REPLICA = 2 * PAIRS * V # 896 +CENTRES, COEFFICIENT_WORK = 8, 2 +REGISTERS = 2 * V + 480 # n = 704: X, Y and helper registers of a word +ROW_LIMIT = 20161 +ROW_CONSTANTS = 9909 + 252 # retained row formula 2*stock + 9909 + 252 + 2*payload +TAIL_KINDS = ('bank_padding_cover_sweep', 'translate_every_live_family') +ROLE_KEYS = ('child', 'copy', 'family', 'helper', 'offset', 'owner_replica', + 'port', 'replica', 'stage', 'time', 'width') + + +class CheckFailure(Exception): + def __init__(self, check, detail): + Exception.__init__(self, check + ': ' + detail) + self.check = check + self.detail = detail + + +def need(condition, check, detail): + if not condition: + raise CheckFailure(check, detail) + + +# ---------------------------------------------------------------- inputs --- + +def git(repo, *args): + proc = subprocess.run(['git', '-C', repo] + list(args), stdout=subprocess.PIPE, + stderr=subprocess.PIPE, check=False) + need(proc.returncode == 0, 'input.git', 'git ' + ' '.join(args) + ' failed: ' + + proc.stderr.decode('utf-8', 'replace').strip()) + return proc.stdout + + +def commit_present(repo, commit): + proc = subprocess.run(['git', '-C', repo, 'cat-file', '-e', commit + '^{commit}'], + stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False) + return proc.returncode == 0 + + +def blob_id(data): + return hashlib.sha1(('blob %d' % len(data)).encode() + b'\0' + data).hexdigest() + + +def verify(data, oid, sha, what): + need(blob_id(data) == oid, 'input.pin', 'git blob id of ' + what) + need(hashlib.sha256(data).hexdigest() == sha, 'input.pin', 'sha256 of ' + what) + + +def read_pinned(repo, commit, pkg, pins, label): + need(commit_present(repo, commit), 'input.pin', '%s commit %s missing from %s (run run_all.py --fetch)' + % (label, commit, repo)) + blobs, record = {}, {} + for rel in sorted(pins): + oid, sha = pins[rel] + path = pkg + '/' + rel + got = git(repo, 'rev-parse', '--verify', commit + ':' + path).decode().strip() + need(got == oid, 'input.pin', path + ' resolves to ' + got + ', pinned ' + oid) + data = git(repo, 'cat-file', 'blob', oid) + verify(data, oid, sha, path) + blobs[rel] = data + record['%s:%s' % (commit[:12], path)] = dict(git_blob=oid, sha256=sha, bytes=len(data)) + return blobs, record + + +def read_2339(repo, force_inputs=False): + """PR #2339 words/receipts: git blobs at bf1742ae if present (inputs/ copies must then be identical), + else the inputs/ copies (same pins).""" + use_git = commit_present(repo, HEAD_2339) and not force_inputs + blobs, record = {}, {} + for rel in sorted(PINS_2339): + oid, sha = PINS_2339[rel] + copy = os.path.join(HERE, 'inputs', os.path.basename(rel)) + path = PKG_2339 + '/' + rel + if use_git: + got = git(repo, 'rev-parse', '--verify', HEAD_2339 + ':' + path).decode().strip() + need(got == oid, 'input.pin', path + ' resolves to ' + got + ', pinned ' + oid) + data = git(repo, 'cat-file', 'blob', oid) + if os.path.isfile(copy): + with open(copy, 'rb') as handle: + need(handle.read() == data, 'input.pin', 'inputs copy differs from the git blob: ' + copy) + source = 'git %s:%s' % (HEAD_2339[:12], path) + else: + need(os.path.isfile(copy), 'input.pin', 'commit %s absent and inputs copy missing: %s' % (HEAD_2339, copy)) + with open(copy, 'rb') as handle: + data = handle.read() + source = 'inputs/' + os.path.basename(rel) + verify(data, oid, sha, path) + blobs[rel] = data + record['%s:%s' % (HEAD_2339[:12], path)] = dict(git_blob=oid, sha256=sha, bytes=len(data), read_from=source) + return blobs, record, ('git' if use_git else 'inputs') + + +def parse_bytes(data, gz): + if gz: + data = gzip.decompress(data) + return json.loads(data.decode('utf-8'), parse_float=Fraction) + + +def parse(blobs, rel): + return parse_bytes(blobs[rel], rel.endswith('.gz')) + + +def as_profile(mapping, check, what): + out = Counter() + for key, value in mapping.items(): + need(type(value) is int and value >= 0 and str(int(key)) == str(key), check, what + ' profile entry') + if value: + out[int(key)] = value + return out + + +def plain(counter): + return {str(k): counter[k] for k in sorted(counter) if counter[k]} + + +def mass(counter): + return sum(r * n for r, n in counter.items()) + + +# ------------------------------------------------- GF(2) frames and widths --- +# (from our iteration-3 fill_check.py / words_check.py) + +FULL = [1 << i for i in range(H)] + + +def gf2_rank(vectors, check): + pivots = {} + for x in vectors: + need(type(x) is int and 0 <= x < 1 << H, check, 'frame vector outside GF(2)^9') + while x: + top = x.bit_length() - 1 + if top in pivots: + x ^= pivots[top] + else: + pivots[top] = x + break + return len(pivots) + + +def parity(x): + return bin(x).count('1') & 1 + + +def echelon(vectors): + piv = {} + for x in vectors: + x = int(x) + for b in list(piv): + if (x >> b) & 1: + x ^= piv[b] + if x: + lead = x.bit_length() - 1 + for b in list(piv): + if (piv[b] >> lead) & 1: + piv[b] ^= x + piv[lead] = x + return piv + + +def span(vectors): + """Canonical key of a subspace: its reduced echelon basis, sorted decreasingly.""" + return tuple(sorted(echelon(vectors).values(), reverse=True)) + + +def contains(small, big): + piv = echelon(big) + for x in small: + for b, vec in piv.items(): + if (x >> b) & 1: + x ^= vec + if x: + return False + return True + + +def perp(sub, h): + return span([x for x in range(1, 1 << h) if all(parity(x & u) == 0 for u in sub)]) + + +def word_helpers(word, label, removed_count): + """Live helper registers, their residual widths and the hyperplane-ended set (R-a).""" + check = 'R-a.word' + report = word['report'] + need((report.get('v'), report.get('h'), report.get('R')) == (V, H, 480), check, label + ' dimensions') + need(len(word['ports']) == V, check, label + ' port count') + first, end = 2 * V, 2 * V + 480 + removed = list(word.get('removed', [])) + need(all(type(r) is int and first <= r < end for r in removed) and len(set(removed)) == len(removed), + check, label + ' removed registers') + need(len(removed) == removed_count, check, label + ' removed register count') + removed_set = set(removed) + for table in ('helper_final', 'start_extra'): + for key in word[table]: + need(first <= int(key) < end and int(key) not in removed_set, check, + label + ' ' + table + ' names a non-live register ' + key) + live = [r for r in range(first, end) if r not in removed_set] + widths, ended = [], [] + for r in live: + final = word['helper_final'].get(str(r)) + if final is None: + final = FULL + else: + ended.append(r) + start = word['start_extra'].get(str(r), []) + rank_final, rank_start = gf2_rank(final, check), gf2_rank(start, check) + need(rank_final == len(final) and rank_start == len(start), check, label + ' dependent frame list at %d' % r) + need(gf2_rank(list(final) + list(start), check) == rank_final, check, + label + ' start frame not inside final frame at %d' % r) + widths.append(rank_final - rank_start) + return dict(live=live, removed=sorted(removed), widths=widths, hyperplane_ended=ended) + + +# ------------------------------------------------- local paid-profile recount --- +# Frame-climb rule of our iteration-3 words_check.py (frame_check), extended to the anticipatory initial +# corrections of PR2226/PR2339: they run first, at frame 0, and pay nothing. + +def _dyadic(q): + return q.denominator & (q.denominator - 1) == 0 + + +def _gate(g, frame_of, where, allow_warp=False): + check = 'R-c.local_format' + need(isinstance(g, list) and g, check, 'gate is not a list at %s' % where) + op = g[0] + if op == 'add': + need(len(g) == 6 and all(type(x) is int for x in g[1:5]) and g[4] > 0 and g[3] != 0 and g[1] != g[2], + check, 'bad add at %s' % where) + need(_dyadic(Fraction(g[3], g[4])), check, 'non-dyadic coefficient at %s' % where) + return ('add', g[1], g[2], frame_of(g[5])) + if op == 'scale': + need(len(g) == 5 and all(type(x) is int for x in g[1:4]) and g[2] != 0 and g[3] != 0, check, + 'bad scale at %s' % where) + q = Fraction(g[2], g[3]) + need(_dyadic(q) and abs(q.numerator) & (abs(q.numerator) - 1) == 0, check, 'scale not a dyadic unit at %s' % where) + return ('scale', g[1], frame_of(g[4])) + if op == 'warp' and allow_warp: + need(len(g) == 4 and type(g[1]) is int and type(g[2]) is int and g[2] != 0, check, 'bad warp at %s' % where) + return ('warp', g[1], frame_of(g[3])) + raise CheckFailure(check, 'unknown primitive %r at %s' % (op, where)) + + +def _regs(item): + return (item[1], item[2]) if item[0] == 'add' else (item[1],) + + +def local_recount(w, label): + """Paid local profile, helper widths and private zero buffers of one BORROW-WORD, recounted.""" + check = 'R-c.local' + need(w.get('kind') == 'BORROW-WORD', check, label + ' not a BORROW-WORD') + v, h, n = V, H, REGISTERS + full = span(FULL) + + def frame_lit(F): + if F is None: + return None + need(isinstance(F, list) and all(type(x) is int and 0 < x < (1 << h) for x in F), check, 'frame literal') + return span(F) + + ports = w['ports'] + removed = set(w['removed']) + live = [r for r in range(n) if r not in removed] + start, end = {}, {} + for i in range(v): + start[i], end[i] = span([ports[i]]), full + start[v + i], end[v + i] = (), perp(span([ports[i]]), h) + for r in live: + if r >= 2 * v: + start[r], end[r] = (), full + for k, F in w['start_extra'].items(): + need(int(k) in start and int(k) >= 2 * v, check, label + ' start_extra register') + start[int(k)] = frame_lit(F) + restored = set() + for k, F in w['helper_final'].items(): + need(int(k) in end and int(k) >= 2 * v, check, label + ' helper_final register') + end[int(k)] = frame_lit(F) + restored.add(int(k)) + buffers = set(r + n for r in restored) + sec = {name: [_gate(g, frame_lit, '%s[%d]' % (name, i)) for i, g in enumerate(w[name])] + for name in ('precondition', 'compensation', 'A', 'cut', 'B', 'restore')} + cleanup = [_gate(g, frame_lit, 'cleanup[%d]' % i, allow_warp=True) for i, g in enumerate(w['cleanup'])] + warps = {} + by_pos = {} + for k, rec in enumerate(w['warps'], 1): + need(isinstance(rec, list) and len(rec) == 5, check, 'warp record shape') + pos, lender, _cols, U, E = rec + need(type(pos) is int and 0 <= pos <= len(sec['B']) and lender in start and not (v <= lender < 2 * v), check, + 'warp %d position/lender' % k) + warps[k] = dict(lender=lender, U=span(U), E=span(E)) + need(len(warps[k]['U']) == len(U) == len(E) == len(warps[k]['E']), check, 'warp %d frame dimensions' % k) + by_pos.setdefault(pos, []).append(k) + need(len(set(x['lender'] for x in warps.values())) == len(warps), check, 'a register lends twice') + cur = {r: start[r] for r in live} + paid, copies, per_reg = Counter(), Counter(), Counter() + istarget = lambda r: v <= r < 2 * v + + def climb(r, F, where): + need(r in cur, check, 'register %d is not live (%s)' % (r, where)) + need(contains(cur[r], F), check, 'non-nested climb of %d at %s' % (r, where)) + d = len(F) - len(cur[r]) + if d: + paid[d] += 1 + per_reg[r] += d + cur[r] = F + + # initial (anticipatory) corrections: t += c K_k s, both at frame 0, k a warp lent by s; pay nothing. + for i, c in enumerate(w['initial_corrections']): + t, s, word_k = c['target'], c['source'], c['operator_word'] + q = Fraction(c['coefficient']) + need(istarget(t) and s in cur and not istarget(s) and cur[t] == () and cur[s] == (), check, + 'initial correction %d: target/source not at frame 0' % i) + need(isinstance(word_k, list) and len(word_k) == 1 and word_k[0] in warps and warps[word_k[0]]['lender'] == s + and q != 0 and _dyadic(q), check, 'initial correction %d: operator/coefficient' % i) + for i, g in enumerate(sec['precondition'] + sec['compensation']): + need(g[-1] == () and istarget(g[1]), check, 'precondition/compensation gate %d' % i) + for r in _regs(g): + climb(r, (), 'pre[%d]' % i) + items = [] + for p in range(len(sec['B']) + 1): + items.extend(('warp', k) for k in by_pos.get(p, [])) + if p < len(sec['B']): + items.append(sec['B'][p]) + for i, g in enumerate(list(sec['A']) + [it for it in items if it[0] != 'warp'] + list(sec['restore'])): + need(not (g[0] == 'add' and not istarget(g[1]) and istarget(g[2])), check, + 'a non-target register reads a target (item %d of A+B+restore)' % i) + for i, g in enumerate(sec['A']): + need(g[-1] is not None, check, 'unframed gate in A') + for r in _regs(g): + climb(r, g[-1], 'A[%d]' % i) + levels = {int(k): frame_lit(F) for k, F in w['target_levels'].items()} + for t in range(v): + need(cur[v + t] == levels.get(t, ()), check, 'target %d not at its level after A' % t) + centers, cframes = list(w['centers']), [frame_lit(F) for F in w['center_frames']] + need(len(set(centers)) == len(centers) == len(cframes), check, 'centres') + for q, U in zip(centers, cframes): + need(q in cur and cur[q] == U, check, 'centre %d not at its centre frame after A' % q) + served = {q: set() for q in centers} + for i, g in enumerate(sec['cut']): + need(g[0] == 'add' and g[-1] is None and istarget(g[1]) and g[2] in served, check, 'cut[%d]' % i) + need(cur[g[1]] == levels.get(g[1] - v, ()), check, 'cut[%d] target off its level' % i) + served[g[2]].add(cur[g[1]]) + for q, U in zip(centers, cframes): + prev = U + for T in sorted(served[q], key=lambda S: (-len(S), S)): + need(contains(T, prev), check, 'centre %d copy levels not nested' % q) + if T != prev: + paid[len(prev) - len(T)] += 1 + copies[len(prev) - len(T)] += 1 + prev = T + for i, it in enumerate(items): + if it[0] == 'warp': + wr = warps[it[1]] + need(cur[wr['lender']] == wr['U'], check, 'warp %d: lender frame != U' % it[1]) + cur[wr['lender']] = wr['E'] + else: + need(it[-1] is not None, check, 'unframed gate in B') + for r in _regs(it): + climb(r, it[-1], 'B item %d' % i) + for i, g in enumerate(sec['restore']): + need(g[-1] is not None, check, 'unframed gate after B') + for r in _regs(g): + climb(r, g[-1], 'restore[%d]' % i) + for r in live: + climb(r, end[r], 'end frame') + touched_buffers = set() + for i, it in enumerate(cleanup): + need(it[-1] == full, check, 'cleanup item %d not at FULL' % i) + for r in ((it[1],) if it[0] == 'warp' else _regs(it)): + if r in buffers: + touched_buffers.add(r) + continue + need(r in cur and cur[r] == full, check, 'cleanup item %d touches %d not at FULL / not a buffer' % (i, r)) + need(touched_buffers == buffers, check, label + ' cleanup does not use exactly the declared zero buffers') + for r in live: + need(per_reg[r] == len(end[r]) - len(start[r]), check, 'per-register charge != width for %d' % r) + helpers = [r for r in live if r >= 2 * v] + return dict(paid=+paid, copies=+copies, widths=[len(end[r]) - len(start[r]) for r in helpers], live_helpers=helpers, + buffers=sorted(buffers), mass=mass(paid), corrections=len(w['initial_corrections']), + warps=len(warps)) + + +def load_word(blobs, rel, audit_rel, label, removed_count, claimed_local=None, claimed_inventory=None): + word = parse(blobs, rel) + audit = parse(blobs, audit_rel) if audit_rel else None + info = word_helpers(word, label, removed_count) + rec = local_recount(word, label) + need(rec['live_helpers'] == info['live'] and rec['widths'] == info['widths'], 'R-a.word', + label + ' frame-recount widths != GF(2) rank widths') + inventory = Counter(info['widths']) + need(inventory == as_profile(word['report']['width_inventory'], 'R-a.word', label), 'R-a.word', + label + ' width inventory vs word report') + local = rec['paid'] + need(local == as_profile(word['report']['local_profile'], 'R-c.local', label), 'R-c.local', + label + ' recounted local profile %s != word report %s' % (plain(local), word['report']['local_profile'])) + need(rec['copies'] == Counter({8: 8}), 'R-c.local', label + ' COPY children') + need(rec['buffers'] == sorted(r + REGISTERS for r in info['hyperplane_ended']), 'R-f.zero_buffers', + label + ' buffers = r + 704 for the hyperplane-ended live helpers') + if audit is not None: + need(as_profile(audit['local_profile'], 'R-c.local', 'audit') == local and + as_profile(audit['width_inventory'], 'R-a.word', 'audit') == inventory and + audit['zero_buffers'] == audit['restored_cold'] == len(rec['buffers']), 'R-c.local', + label + ' vs AUDIT receipt') + if claimed_local is not None: + need(local == Counter(claimed_local), 'R-c.local', label + ' local profile vs build report') + if claimed_inventory is not None: + need(inventory == Counter(claimed_inventory), 'R-a.word', label + ' inventory vs build report') + return dict(widths=info['widths'], live=info['live'], removed=info['removed'], local=local, inventory=inventory, + buffers=rec['buffers'], local_mass=rec['mass'], width_sum=sum(info['widths']), + corrections=rec['corrections'], warps=rec['warps']) + + +# --------------------------------------------------------------- context --- + +def derive_schedule(T, template, order): + """Expand the 30 per-replica source events in call order; rebuild windows (verbatim iteration-3 rule).""" + src = template['execution_schedule'] + need([i for i, e in enumerate(src) if e['kind'] in TAIL_KINDS] == [len(src) - 2, len(src) - 1], + 'R-d.schedule', 'global tail events') + per_replica = [i for i, e in enumerate(src) if e['kind'] not in TAIL_KINDS] + need(per_replica == list(range(30)), 'R-d.schedule', 'thirty per-replica source events') + stage_pair = {} + for e in template['recipe']: + if e['kind'] == 'local': + need(e['stage'] not in stage_pair and 0 <= e['pair'] < PAIRS, 'R-d.schedule', 'recipe stage/pair') + stage_pair[e['stage']] = e['pair'] + need(set(stage_pair) == set(range(STAGES)), 'R-d.schedule', 'recipe stages') + blocks, stage = {}, None + for i in per_replica: + e = src[i] + if e['kind'] == 'local_cover_sweep': + stage = e['stage'] + need(stage not in blocks and e['replicas'] == list(range(T)), 'R-d.schedule', 'local sweep block') + blocks[stage] = [] + need(stage is not None, 'R-d.schedule', 'event before first local sweep') + need(e['kind'] in ('local_cover_sweep', 'idle_cover_sweep', 'bridge', 'terminal_Y_translations', 'terminal'), + 'R-d.schedule', 'unknown source event kind ' + str(e['kind'])) + blocks[stage].append((i, e)) + need(set(blocks) == set(range(STAGES)), 'R-d.schedule', 'stage blocks') + rank = {} + for c in template['idle_children']: + need(c['replicas'] == T and 0 <= c['port'] < V and type(c['rank']) is int and c['rank'] > 0, + 'R-d.schedule', 'idle child record') + need(rank.setdefault(c['child'], c['rank']) == c['rank'], 'R-d.schedule', 'child rank depends on port') + need(len(template['idle_children']) == V * len(rank), 'R-d.schedule', 'idle children per port') + seen = Counter((c['child'], c['port']) for c in template['idle_children']) + need(all(n == 1 for n in seen.values()), 'R-d.schedule', 'duplicate idle child record') + events = [] + for t, (s, r) in enumerate(order): + for i, e in blocks[s]: + events.append((i, e, r, t)) + projection = {} + for i, e, r, t in events: + projection.setdefault(r, []).append(i) + need(set(projection) == set(range(T)) and all(p == per_replica for p in projection.values()), + 'R-d.schedule', 'per-replica source-event projection') + last, windows, callpos, child_pair, child_side = {}, {}, {}, {}, {} + rankless = set() + bridges = 0 + for pos, (i, e, r, t) in enumerate(events): + kind = e['kind'] + if kind == 'local_cover_sweep': + callpos[t] = pos + last[r, stage_pair[e['stage']]] = pos + elif kind == 'bridge': + bridges += 1 + last[r, e['src']] = pos + last[r, e['dst']] = pos + elif kind == 'idle_cover_sweep': + for side, child in enumerate(e['child_indices']): + if child not in rank: + rankless.add(child) # a swept child without an idle_children record has no capacity + continue + need((r, child) not in windows, 'R-d.schedule', 'idle sweep child') + need(child_pair.setdefault(child, e['pair']) == e['pair'] and + child_side.setdefault(child, side) == side, 'R-d.schedule', 'child pair/side') + windows[r, child] = (last.get((r, e['pair']), -1), pos) + else: # terminal events touch every pair; they follow every idle sweep of the replica + for p in range(PAIRS): + last[r, p] = pos + need(len(windows) == T * len(rank) and set(callpos) == set(range(len(order))), 'R-d.schedule', 'window inventory') + positions = [callpos[t] for t in range(len(order))] + need(all(a < b for a, b in zip(positions, positions[1:])), 'R-d.schedule', 'call positions increase') + times = {} + for key, (lo, hi) in windows.items(): + times[key] = list(range(bisect.bisect_right(positions, lo), bisect.bisect_left(positions, hi))) + return dict(stage_pair=stage_pair, rank=rank, windows=windows, callpos=positions, child_pair=child_pair, + child_side=child_side, window_times=times, bridges=bridges, events=len(events), + rankless_children=sorted(rankless)) + + +def check_static(ctx, sched): + """Order, dispatch, (optionally) PLAN per-call widths, and X1 (PLAN windows == rebuilt windows).""" + T, order, plan = ctx['T'], ctx['order'], ctx['plan'] + need(len(order) == STAGES * T and set(order) == {(s, r) for s in range(STAGES) for r in range(T)}, + 'R-0.order', 'call inventory') + need(plan['order'] == [list(x) for x in order], 'R-0.order', 'PLAN order') + need(set(ctx['dispatch']) == set(order), 'R-0.dispatch', 'dispatch inventory') + need(len(plan['provider_calls']) == len(order), 'R-0.dispatch', 'PLAN call records') + for t, (s, r) in enumerate(order): + pc = plan['provider_calls'][t] + need((pc['stage'], pc['replica']) == (s, r) and pc.get('time', t) == t and + pc['provider'] == ctx['dispatch'][s, r], 'R-0.dispatch', 'PLAN provider call %d' % t) + if ctx['plan_widths']: + pw = plan['per_call_widths'][t] + need((pw['stage'], pw['replica']) == (s, r) and pw.get('time', t) == t, 'R-0.widths', 'PLAN width call %d' % t) + need(pw['widths'] == ctx['widths'][ctx['dispatch'][s, r]], 'R-0.widths', 'PLAN per-call widths at %d' % t) + pw = plan['windows'] + need(len(pw) == len(sched['windows']), 'R-d.plan_windows', 'window count') + for (r, c), times in sched['window_times'].items(): + key = '%d,%d' % (r, c) + need(key in pw and pw[key] == [sched['rank'][c], times], 'R-d.plan_windows', 'PLAN window ' + key) + + +def check_roles(ctx, sched, rows): + """R-a, R-e, R-d, R-b on the literal roles and the R-c recount (no claim is read here).""" + T, R, W, order = ctx['T'], ctx['R'], ctx['W'], ctx['order'] + at = {key: t for t, key in enumerate(order)} + provider = [ctx['dispatch'][key] for key in order] + # ---- R-a: one role per (call, live helper) at the helper's width + need(len(rows) == len(order) * R, 'R-a.count', '%d roles, expected %d calls x %d helpers' % (len(rows), len(order), R)) + have = [0] * len(order) + seen_helper = set() + for z in rows: + need(type(z) is dict and tuple(sorted(z)) == ROLE_KEYS and all(type(z[k]) is int for k in ROLE_KEYS), + 'R-a.schema', 'role fields') + t = at.get((z['stage'], z['replica'])) + need(t is not None and z['time'] == t, 'R-a.call', 'role call/time') + need(0 <= z['helper'] < R, 'R-a.helper_range', 'helper index') + key = (t, z['helper']) + need(key not in seen_helper, 'R-a.duplicate_helper', 'helper %d twice in call %d' % (z['helper'], t)) + seen_helper.add(key) + need(z['width'] == ctx['widths'][provider[t]][z['helper']], 'R-a.width', 'width of helper %d in call %d' % (z['helper'], t)) + have[t] += 1 + need(all(n == R for n in have), 'R-a.complete', 'per-call helper inventory') + # ---- R-e: physical family identity, namespace, active pair, one helper per family per call + rank, pair, side, stage_pair = sched['rank'], sched['child_pair'], sched['child_side'], sched['stage_pair'] + seen_family = set() + cross = 0 + for z in rows: + need(0 <= z['owner_replica'] < T and z['child'] in rank and 0 <= z['port'] < V, 'R-e.coords', 'owner coordinates') + need(0 <= z['family'] < W, 'R-e.namespace', 'family %d outside data namespace [0,%d)' % (z['family'], W)) + expect = z['owner_replica'] * FAMILIES_PER_REPLICA + (2 * pair[z['child']] + side[z['child']]) * V + z['port'] + need(z['family'] == expect and z['copy'] == V * z['owner_replica'] + z['port'], 'R-e.family_identity', + 'family/copy identity') + need(not (z['owner_replica'] == z['replica'] and pair[z['child']] == stage_pair[z['stage']]), + 'R-e.active_pair', 'helper hosted on the caller active pair') + key = (z['time'], z['family']) + need(key not in seen_family, 'R-e.family_unique_per_call', 'two helpers on family %d in call %d' % key[::-1]) + seen_family.add(key) + cross += z['owner_replica'] != z['replica'] + # ---- R-d: strictly inside the owner's actual (bridge-aware) window + callpos, windows = sched['callpos'], sched['windows'] + for z in rows: + lo, hi = windows[z['owner_replica'], z['child']] + need(lo < callpos[z['time']] < hi, 'R-d.window', 'role outside window of owner %d child %d' % (z['owner_replica'], z['child'])) + # ---- R-b: capacity, disjoint slices per bin, occupied prefix + used = {} + for z in rows: + need(z['offset'] >= 0 and z['width'] >= 1 and z['offset'] + z['width'] <= rank[z['child']], 'R-b.capacity', + 'slice outside child capacity') + b = (z['owner_replica'], z['child'], z['port']) + cells = ((1 << z['width']) - 1) << z['offset'] + old = used.get(b, 0) + need(not old & cells, 'R-b.overlap', 'overlapping slices in bin %s' % (b,)) + used[b] = old | cells + for b, cells in used.items(): + need(cells & (cells + 1) == 0, 'R-b.prefix', 'occupied cells of bin %s are not a prefix' % (b,)) + # ---- R-c: recount idle remainders and the global profile; pure identities + idle = Counter() + for (owner, child) in windows: + for port in range(V): + left = rank[child] - bin(used.get((owner, child, port), 0)).count('1') + if left: + idle[left] += 1 + local = Counter() + for p in provider: + local.update(ctx['local_profiles'][p]) + profile = local + idle + total = mass(profile) + need(M * W - total == 320 * T, 'R-c.mass', 'deficit identity m*W - mass = 320*T') + need(total == (M - 1) * W + 64 * len(order), 'R-c.mass', 'mass = (m-1)W + 64 calls') + capacity = T * V * sum(rank.values()) + hosted_width = sum(z['width'] for z in rows) + need(mass(idle) == capacity - hosted_width, 'R-c.mass', 'idle mass = capacity - hosted width') + need(total == mass(local) + capacity - hosted_width, 'R-c.mass', 'mass decomposition') + need(M * M > 2 * max(profile) ** 2, 'R-c.mass', 'halving guard m^2 > 2*maxchild^2') + family_children = {} + for z in rows: + family_children.setdefault(z['family'], set()).add(z['child']) + return dict(roles=len(rows), calls=len(order), helpers_per_call=R, bins=T * V * len(rank), + occupied_bins=len(used), cross_replica_roles=cross, idle=plain(idle), + hosted_families=len(family_children), max_hosted_family=max(family_children), + idle_remainders=sum(idle.values()), profile=plain(profile), rank_mass=total, + deficit=M * W - total, live=W, idle_capacity=capacity, hosted_width=hosted_width, + idle_mass=mass(idle), local_mass=mass(local), max_child=max(profile), + provider_counts=dict(Counter(provider))) + + +def compare_claims(ctx, rec): + """Compare the recount with the claims (only after the recount).""" + claims = ctx['claims'] + idle = as_profile(rec['idle'], 'R-c.idle', 'recount') + profile = as_profile(rec['profile'], 'R-c.profile', 'recount') + for source, claimed in claims['idle']: + need(idle == claimed, 'R-c.idle', 'recounted idle %s differs from %s %s' % (rec['idle'], source, plain(claimed))) + for source, claimed in claims['profile']: + need(profile == claimed, 'R-c.profile', 'recounted global profile differs from ' + source) + for key, source, value in claims.get('scalars', []): + need(rec[key] == value, 'R-c.counts', '%s %r differs from %s %r' % (key, rec[key], source, value)) + + +def run_pipeline(ctx, sched, rows): + check_static(ctx, sched) + rec = check_roles(ctx, sched, rows) + compare_claims(ctx, rec) + return rec + + +def dispatch_map(records, check): + out = {} + for s, r, p in records: + need((s, r) not in out, check, 'duplicate dispatch') + out[s, r] = p + return out + + +# ------------------------------------------------------------ case setup --- + +def template_2269(blobs): + plan = parse(blobs, 'new/PLAN.json') + spec = parse(blobs, 'new/SPEC.json') + template = parse(blobs, 'GLOBAL-TEMPLATE.json.gz') + order = [tuple(x) for x in parse(blobs, 'ORDER.json')] + dispatch = dispatch_map(parse(blobs, 'DISPATCH.json'), 'R-0.dispatch') + construction = parse(blobs, 'CONSTRUCTION.json') + T = plan['T'] + need(T == 74 and (plan['K'], plan['L'], plan['M']) == (PAIRS, STAGES, M), 'R-0.plan', 'PLAN geometry') + need(order == [tuple(x) for x in plan['order']] == [tuple(x) for x in spec['call_order']], 'R-0.order', + 'ORDER.json = PLAN order = SPEC call_order') + need(dispatch == dispatch_map(spec['dispatch'], 'R-0.dispatch'), 'R-0.dispatch', 'DISPATCH.json = SPEC dispatch') + need(Counter(dispatch.values()) == Counter({'gauge44': 249, 'extra': 417}) == + Counter(construction['dispatch']), 'R-0.dispatch', 'provider call counts 249 gauge44 + 417 extra') + need(spec['expected']['live'] == plan['live'] == FAMILIES_PER_REPLICA * T, 'R-0.plan', 'live data families') + return dict(T=T, plan=plan, spec=spec, template=template, order=order, dispatch=dispatch, construction=construction) + + +def context(name, tpl, helpers, widths, local_profiles, claims, plan_widths): + return dict(name=name, T=tpl['T'], R=helpers, W=FAMILIES_PER_REPLICA * tpl['T'], order=tpl['order'], + dispatch=tpl['dispatch'], widths=widths, local_profiles=local_profiles, plan=tpl['plan'], + claims=claims, plan_widths=plan_widths) + + +def words_80(b2339): + out = {} + for pid, tag in (('gauge44', 'base'), ('extra', 'extra')): + out[pid] = load_word(b2339, 'words/BORROW-WORD-80%s.json.gz' % tag, 'receipts/AUDIT-80%s.json' % tag, + '80' + tag, 80, CLAIMS_80['local'][pid], CLAIMS_80['inventory']) + need(len(out[pid]['live']) == 400 and len(out[pid]['buffers']) == CLAIMS_80['zero_buffers'], 'R-a.word', + pid + ' 400 live helpers / 44 zero buffers') + need(out[pid]['local_mass'] == 1856 + out[pid]['width_sum'], 'R-c.local', pid + ' local mass = 1856 + widths') + need(out['gauge44']['live'] == out['extra']['live'] and out['gauge44']['widths'] == out['extra']['widths'], + 'R-a.word', 'helper map is provider independent (same live registers and ordered widths)') + need(out['gauge44']['removed'] == out['extra']['removed'], 'R-a.word', 'both words remove the same registers') + return out + + +def load_owners80(): + path = os.path.join(HERE, OWNERS_80[0]) + with open(path, 'rb') as handle: + raw = handle.read() + need(hashlib.sha256(raw).hexdigest() == OWNERS_80[1], 'input.pin', 'sha256 of ' + OWNERS_80[0]) + return json.loads(gzip.decompress(raw).decode('utf-8')), raw + + +def claim_files_80(): + """PROFILE-80.json and BUILD-RECEIPT.json (builder outputs): claims only, compared after the recount.""" + out, record = {}, {} + for name in ('PROFILE-80.json', 'BUILD-RECEIPT.json'): + path = os.path.join(HERE, name) + if os.path.isfile(path): + with open(path, 'rb') as handle: + data = handle.read() + out[name] = json.loads(data.decode('utf-8')) + record[name] = hashlib.sha256(data).hexdigest() + return out, record + + +def case_80(repo, force_inputs): + b2269, rec2269 = read_pinned(repo, HEAD_2269, PKG_2269, PINS_2269, 'PR2269') + b2339, rec2339, mode = read_2339(repo, force_inputs) + tpl = template_2269(b2269) + words = words_80(b2339) + rows, raw = load_owners80() + files, file_record = claim_files_80() + claims = dict(idle=[('build report (hard-coded)', Counter(CLAIMS_80['idle']))], + profile=[('build report (hard-coded)', Counter(CLAIMS_80['profile']))], + scalars=[('roles', 'build report', CLAIMS_80['roles']), + ('cross_replica_roles', 'build report', CLAIMS_80['cross_replica']), + ('idle_remainders', 'build report', CLAIMS_80['idle_remainders'])]) + if 'PROFILE-80.json' in files: + claims['profile'].append(('PROFILE-80.json', as_profile(files['PROFILE-80.json'], 'R-c.profile', 'PROFILE-80'))) + if 'BUILD-RECEIPT.json' in files: + b = files['BUILD-RECEIPT.json'] + claims['idle'].append(('BUILD-RECEIPT.json idle', as_profile(b['idle'], 'R-c.idle', 'receipt'))) + claims['profile'].append(('BUILD-RECEIPT.json profile', as_profile(b['profile'], 'R-c.profile', 'receipt'))) + claims['scalars'] += [(k, 'BUILD-RECEIPT.json', b[k]) for k in + ('roles', 'cross_replica_roles', 'idle_remainders', 'rank_mass', 'hosted_width', + 'idle_mass', 'idle_capacity')] + need(b['owners_sha256'] == OWNERS_80[1], 'R-0.pins', 'BUILD-RECEIPT owners sha256') + ctx = context('ext80-T74', tpl, 400, {p: words[p]['widths'] for p in words}, + {p: words[p]['local'] for p in words}, claims, plan_widths=False) + record = dict(rec2269) + record.update(rec2339) + record['package:' + OWNERS_80[0]] = dict(sha256=OWNERS_80[1], git_blob=blob_id(raw), bytes=len(raw)) + return ctx, rows, tpl, words, b2269, dict(inputs=record, pr2339_source=mode, claim_files_sha256=file_record) + + +def case_2269(b2269, tpl): + """Positive control: PR #2269's own 437-helper fill on the same template, PLAN widths included.""" + words = {} + for pid, tag in (('gauge44', 'base'), ('extra', 'extra')): + words[pid] = load_word(b2269, 'new/borrow/words/BORROW-WORD-43%s.json.gz' % tag, + 'new/borrow/receipts/AUDIT-43%s.json' % tag, '43' + tag, 43) + spec, construction = tpl['spec'], tpl['construction'] + exp = spec['expected'] + claims = dict(idle=[('hard-coded #2269 idle', Counter(CLAIMS_2269['idle'])), + ('CONSTRUCTION.json idle', as_profile(construction['idle'], 'R-c.idle', 'construction')), + ('new/SPEC.json idle_remainder_profile', as_profile(exp['idle_remainder_profile'], 'R-c.idle', 's'))], + profile=[('new/PROFILE.json', as_profile(parse(b2269, 'new/PROFILE.json'), 'R-c.profile', 'p')), + ('new/SPEC.json global_profile', as_profile(exp['global_profile'], 'R-c.profile', 's'))], + scalars=[('roles', 'new/SPEC.json hosted_residuals', exp['hosted_residuals']), + ('cross_replica_roles', 'new/SPEC.json', exp['cross_replica_helper_roles']), + ('idle_remainders', 'new/SPEC.json', exp['idle_remainders']), + ('rank_mass', 'new/SPEC.json', exp['rank_mass'])]) + ctx = context('pr2269-borrow43-T74', tpl, 437, {p: words[p]['widths'] for p in words}, + {p: words[p]['local'] for p in words}, claims, plan_widths=True) + return ctx, parse(b2269, 'OWNERS.json.gz'), words + + +# ------------------------------------------------------- R-f: private namespace --- + +def private_namespace(W, R, buffers, hosted_max): + """Rule as stated by PR #2322: physical = W + 8 + R + 2; centres [W, W+8), reserved tableau [W+8, W+8+R), + coefficient [P-2, P); zero buffers injected in increasing order into [W+8, W+8+NZ); NZ <= R; every hosted + family is live (< W). Returns the geometry in PR #2322's PRIVATE-NAMESPACE-INJECTION field names.""" + check = 'R-f.namespace' + NZ = len(buffers) + P = W + CENTRES + R + COEFFICIENT_WORK + need(0 < NZ <= R, check, '%d zero buffers do not fit the %d-field reserved tableau' % (NZ, R)) + zp = {z: W + CENTRES + j for j, z in enumerate(sorted(buffers))} + centres = set(range(W, W + CENTRES)) + work = {P - 2, P - 1} + aux = set(zp.values()) | centres | work + need(len(aux) == NZ + CENTRES + COEFFICIENT_WORK and min(aux) == W and max(aux) == P - 1, check, 'private names') + need(max(zp.values()) < W + CENTRES + R and not set(zp.values()) & (work | centres), check, + 'buffer fields outside the reserved tableau') + need(hosted_max < W, check, 'a hosted helper family is not a live data family') + return dict(live=W, centers=[W, W + CENTRES], reserved_tableau=[W + CENTRES, W + CENTRES + R], + coefficient=[P - 2, P], physical=P, buffer_fields=[W + CENTRES, W + CENTRES + NZ], + remaining_reserve=R - NZ, native_helpers=R, zero_buffers=NZ) + + +def stock_group(): + """The retained 73-dimensional group factor 2^(36*36) * prod_{i=1}^{36} (2^(2i) - 1).""" + g = 2 ** (36 * 36) + for i in range(1, 37): + g *= 2 ** (2 * i) - 1 + return g + + +def physical_rows(b2269, W, calls, physicals): + """Stock bits and row coefficient (iteration-3 R-f formula, re-derived against PR #2269 INDEPENDENT.json).""" + independent = parse(b2269, 'evidence/INDEPENDENT.json') + g = stock_group() + payload = 1 << (192 + (M + 1) // 2 + 2 * calls + 4).bit_length() + + def charge(physical): + bits = (g * physical).bit_length() + return dict(physical=physical, stock_bits=bits, row_coefficient=2 * bits + ROW_CONSTANTS + 2 * payload) + + ref = charge(independent['physical']) + need((ref['stock_bits'], ref['row_coefficient'], independent['charged_prefix_bits']) == + (independent['physical_stock_bits'], independent['physical_row_coefficient'], payload), + 'R-f.formula', 'stock/row formula does not reproduce PR2269 evidence/INDEPENDENT.json') + rows = {name: charge(p) for name, p in physicals.items()} + for name, row in rows.items(): + need(row['row_coefficient'] < ROW_LIMIT, 'R-f.row', name + ' row coefficient') + return dict(payload_bits=payload, row_limit=ROW_LIMIT, rows=rows, + formula_reproduces=dict(physical=independent['physical'], stock_bits=ref['stock_bits'], + row=ref['row_coefficient'])) + + +# ------------------------------------------- R-g: X2 pending axes and 73-column charts --- + +def load_phases(repo, template, port_lists): + """DATA-PHASES.json at the PR2269 commit, bound to the template's data-phase pin and to the word ports.""" + blobs, record = read_pinned(repo, HEAD_2269, PKG_PHASES, PINS_PHASES, 'PR2269 tree') + need(PINS_PHASES['DATA-PHASES.json'][1] == template['exact_data_phase_recipe_sha256'], 'R-g.phases', + 'DATA-PHASES sha256 != GLOBAL-TEMPLATE exact_data_phase_recipe_sha256') + phases = parse(blobs, 'DATA-PHASES.json') + ports = [x['q'] for x in phases['recipes']] + need(phases['ports'] == V and [x['port'] for x in phases['recipes']] == list(range(V)), 'R-g.phases', 'port records') + need(all(p == ports for p in port_lists), 'R-g.phases', 'DATA-PHASES port vectors != word ports') + return phases, ports, record + + +def owner_bases(ports): + """Orthonormal 73-column owner frame per port (PR2269 independent_core.py make_context, verbatim rule).""" + bases = [] + for q in ports: + zero = next(i for i in range(H) if not (q >> i & 1)) + correction = q ^ (1 << zero) + axes = list(range(H)) + axes[0], axes[zero] = axes[zero], axes[0] + frame = [(1 << i) ^ (correction if correction >> i & 1 else 0) for i in axes] + [1 << i for i in range(H, M)] + need(all(bin(x & y).count('1') % 2 == int(i == j) for i, x in enumerate(frame) for j, y in enumerate(frame)), + 'R-g.pending_axes', 'non-orthonormal owner basis') + bases.append(frame) + return bases + + +def pending_axes_and_charts(sched, phases, bases, rows): + """X2 (disjoint pending axes of children sharing a family) and one 73-column chart per role slice.""" + rank, pair, side = sched['rank'], sched['child_pair'], sched['child_side'] + checked = 0 + for port, frame in enumerate(bases): + used, fset = {}, set(frame) + for child in sorted(rank): + axes = [int(x) for x in phases['recipes'][port]['idle_children'][child]['orthogonal_axes']] + need(len(axes) == rank[child] == len(set(axes)) and set(axes) <= fset, 'R-g.pending_axes', + 'pending axes of child %d at port %d' % (child, port)) + fam = used.setdefault((pair[child], side[child]), set()) + need(not fam & set(axes), 'R-g.pending_axes', 'overlapping pending children on one family (X2)') + fam.update(axes) + checked += 1 + charts, cache = set(), {} + for z in rows: + key = (z['port'], z['child'], z['offset'], z['width']) + if key not in cache: + frame = bases[z['port']] + pending = [int(x) for x in phases['recipes'][z['port']]['idle_children'][z['child']]['orthogonal_axes']] + need(z['offset'] + z['width'] <= len(pending) and z['width'] <= H, 'R-g.chart', 'slice beyond pending axes') + occupied = [frame.index(x) for x in pending[z['offset']:z['offset'] + z['width']]] + spectators = [i for i in range(M) if i not in occupied][:H - z['width']] + perm = occupied + spectators + [i for i in range(M) if i not in occupied and i not in spectators] + need(len(set(occupied + spectators)) == H and sorted(perm) == list(range(M)) and + [frame[i] for i in perm[:z['width']]] == pending[z['offset']:z['offset'] + z['width']], + 'R-g.chart', 'residual/spectator permutation') + cache[key] = tuple(frame[i] for i in perm) + charts.add(cache[key]) + return dict(pending_axis_checks=checked, chart_keys=len(cache), actual_73column_charts=len(charts)) + + +# ------------------------------------------------------- negative controls --- + +def controls(ctx, sched, rows, words, b2339, phases=None, bases=None): + T, W, order = ctx['T'], ctx['W'], ctx['order'] + pair, side, stage_pair, rank = sched['child_pair'], sched['child_side'], sched['stage_pair'], sched['rank'] + by_call = {} + for i, z in enumerate(rows): + by_call.setdefault(z['time'], []).append(i) + family_index = {(z['time'], z['family']): i for i, z in enumerate(rows)} + helper_index = {(z['time'], z['helper']): i for i, z in enumerate(rows)} + out = [] + + def replaced(changes): + new = list(rows) + for i, z in changes.items(): + new[i] = z + return new + + def expect(name, expected, fn): + try: + fn() + except CheckFailure as exc: + need(exc.check == expected, 'control', name + ' rejected by ' + exc.check + ' (' + exc.detail + + '), expected ' + expected) + out.append(dict(name=name, rejected_by=exc.check, detail=exc.detail[:200])) + return + raise CheckFailure('control', 'negative control accepted: ' + name) + + def run(name, expected, mutant_rows, mutant_ctx=None): + expect(name, expected, lambda: run_pipeline(mutant_ctx or ctx, sched, mutant_rows)) + + call0 = by_call[0] + a, b = next((i, j) for i in call0 for j in call0 if i < j and rows[i]['width'] == rows[j]['width']) + run('duplicate_role (helper twice in one call)', 'R-a.duplicate_helper', + replaced({b: dict(rows[b], helper=rows[a]['helper'])})) + run('dropped_role', 'R-a.count', rows[1:]) + i = next(k for k, z in enumerate(rows) if z['width'] > 1) + run('narrowed_width', 'R-a.width', replaced({i: dict(rows[i], width=rows[i]['width'] - 1)})) + run('family_in_private_namespace', 'R-e.namespace', replaced({0: dict(rows[0], family=W + CENTRES)})) + z = rows[0] + active = stage_pair[z['stage']] + child = next(c for c in sorted(rank) if pair[c] == active) + fam = z['replica'] * FAMILIES_PER_REPLICA + (2 * active + side[child]) * V + z['port'] + run('caller_active_pair', 'R-e.active_pair', replaced({0: dict(z, owner_replica=z['replica'], child=child, offset=0, + family=fam, copy=V * z['replica'] + z['port'])})) + a, b = call0[0], call0[1] + host = {k: rows[a][k] for k in ('owner_replica', 'child', 'port', 'family', 'copy', 'offset')} + run('two_helpers_one_family', 'R-e.family_unique_per_call', replaced({b: dict(rows[b], **host)})) + # role moved outside its owner's window: swap the hosts of one helper between two calls (R-a/R-e still hold) + swap = None + for i, z in enumerate(rows): + lo, hi = sched['windows'][z['owner_replica'], z['child']] + for t2 in range(len(order) - 1, -1, -1): + if lo < sched['callpos'][t2] < hi: + continue + j = helper_index[t2, z['helper']] + y = rows[j] + s2, r2 = order[t2] + zz = dict(z, stage=s2, replica=r2, time=t2) + yy = dict(y, stage=z['stage'], replica=z['replica'], time=z['time']) + if ctx['widths'][ctx['dispatch'][s2, r2]][z['helper']] != z['width']: + continue + if ctx['widths'][ctx['dispatch'][z['stage'], z['replica']]][y['helper']] != y['width']: + continue + if family_index.get((t2, z['family']), j) != j or family_index.get((z['time'], y['family']), i) != i: + continue + if (zz['owner_replica'] == r2 and pair[zz['child']] == stage_pair[s2]) or \ + (yy['owner_replica'] == z['replica'] and pair[yy['child']] == stage_pair[z['stage']]): + continue + swap = {i: zz, j: yy} + break + if swap: + break + need(swap is not None, 'control', 'no window control could be built') + run('out_of_window_role', 'R-d.window', replaced(swap)) + bins = {} + for k, z in enumerate(rows): + bins.setdefault((z['owner_replica'], z['child'], z['port']), []).append(k) + pick = None + for bkey, members in sorted(bins.items()): + if len(members) >= 2: + members = sorted(members, key=lambda k: rows[k]['offset']) + if rows[members[0]]['offset'] + rows[members[1]]['width'] <= rank[bkey[1]]: + pick = (members[0], members[1]) + break + need(pick is not None, 'control', 'no overlap control could be built') + run('overlapping_slices', 'R-b.overlap', replaced({pick[1]: dict(rows[pick[1]], offset=rows[pick[0]]['offset'])})) + gap = None + for bkey, members in sorted(bins.items()): + last = max(members, key=lambda k: rows[k]['offset']) + if rows[last]['offset'] + rows[last]['width'] + 1 <= rank[bkey[1]]: + gap = last + break + need(gap is not None, 'control', 'no prefix control could be built') + run('gap_in_prefix', 'R-b.prefix', replaced({gap: dict(rows[gap], offset=rows[gap]['offset'] + 1)})) + over = next(k for k, z in enumerate(rows) if z['offset'] + z['width'] == rank[z['child']]) + run('slice_beyond_child_capacity', 'R-b.capacity', replaced({over: dict(rows[over], offset=rows[over]['offset'] + 1)})) + claims = dict(ctx['claims']) + src, claimed = claims['idle'][0] + tampered = Counter(claimed) + tampered[48] -= 1 + tampered[47] += 1 + claims['idle'] = [(src, +tampered)] + claims['idle'][1:] + run('tampered_idle (one 48 claimed as 47)', 'R-c.idle', rows, dict(ctx, claims=claims)) + claims = dict(ctx['claims']) + src, claimed = claims['profile'][-1] + tampered = Counter(claimed) + tampered[1] += 1 + claims['profile'] = claims['profile'][:-1] + [(src, tampered)] + run('tampered_global_profile (%s)' % src, 'R-c.profile', rows, dict(ctx, claims=claims)) + plan = dict(ctx['plan']) + windows = dict(plan['windows']) + key = next(k for k in sorted(windows) if windows[k][1]) + windows[key] = [windows[key][0], windows[key][1][:-1]] + plan['windows'] = windows + run('truncated_plan_window (X1)', 'R-d.plan_windows', rows, dict(ctx, plan=plan)) + # namespace: one more zero buffer than reserved-tableau fields + expect('zero_buffers_exceed_reserve (NZ = R + 1)', 'R-f.namespace', + lambda: private_namespace(W, ctx['R'], list(range(ctx['R'] + 1)), 0)) + # local profile: the word report claims one rank-1 child moved to rank 2 + word = parse(b2339, 'words/BORROW-WORD-80base.json.gz') + lp = dict(word['report']['local_profile']) + lp['1'] -= 1 + lp['2'] += 1 + word['report'] = dict(word['report'], local_profile=lp) + mutant = dict(b2339) + mutant['words/BORROW-WORD-80base.json.gz'] = gzip.compress(json.dumps(word).encode()) + expect('tampered_word_local_profile', 'R-c.local', + lambda: load_word(mutant, 'words/BORROW-WORD-80base.json.gz', None, '80base-mutant', 80)) + if phases is not None: + # X2: one pending axis of a child copied into another child of the same family (PR2269 control) + bad = json.loads(json.dumps(phases)) + a, b = next((a, b) for a in sorted(rank) for b in sorted(rank) + if a < b and (pair[a], side[a]) == (pair[b], side[b])) + kids = bad['recipes'][0]['idle_children'] + kids[b]['orthogonal_axes'][0] = kids[a]['orthogonal_axes'][0] + expect('cross_child_pending_axis_alias (X2)', 'R-g.pending_axes', + lambda: pending_axes_and_charts(sched, bad, bases, [])) + return out + + +# -------------------------------------------------------------------- API --- + +def recount(repo=REPO_DEFAULT, force_inputs=False): + """Main recount only (no controls): used by price80.py.""" + ctx, rows, tpl, words, b2269, meta = case_80(repo, force_inputs) + sched = derive_schedule(ctx['T'], tpl['template'], ctx['order']) + rec = run_pipeline(ctx, sched, rows) + return dict(recount=rec, ctx=ctx, words=words, meta=meta, sched=sched, rows=rows, tpl=tpl, b2269=b2269) + + +# -------------------------------------------------------------------- main --- + +def main(): + ap = argparse.ArgumentParser(description=__doc__.split('\n')[0]) + ap.add_argument('--repo', default=REPO_DEFAULT) + ap.add_argument('--words-from-inputs', action='store_true', + help='read the PR2339 files from inputs/ even if commit bf1742ae is present') + ap.add_argument('--skip-positive-control', action='store_true') + ap.add_argument('--out', action='store_true', help='write ' + RECEIPT_NAME + ' next to this script') + args = ap.parse_args() + started = time.time() + try: + R = recount(args.repo, args.words_from_inputs) + ctx, rec, words, sched, rows = R['ctx'], R['recount'], R['words'], R['sched'], R['rows'] + print('windows: %d rebuilt from %d expanded events (%d bridges) = PR2269 new/PLAN.json windows (X1)' % ( + len(sched['windows']), sched['events'], sched['bridges']), flush=True) + print('R-a..R-e PASS: roles=%d = %d x %d; cross-replica %d; occupied bins %d of %d' % ( + rec['roles'], rec['calls'], rec['helpers_per_call'], rec['cross_replica_roles'], rec['occupied_bins'], + rec['bins']), flush=True) + print('R-c recount: idle=%s' % rec['idle'], flush=True) + print('R-c recount: profile=%s mass=%d deficit=%d' % (rec['profile'], rec['rank_mass'], rec['deficit']), flush=True) + # ---- R-f: private namespace (rule as PR2322 states it) + its positive control on PR2322's numbers + b2322, rec2322 = read_pinned(args.repo, HEAD_2322, PKG_2322, PINS_2322, 'PR2322') + inj = parse(b2322, 'evidence/PRIVATE-NAMESPACE-INJECTION.json') + claim2322 = parse(b2322, 'CLAIM.json') + geo2322 = private_namespace(inj['geometry']['live'], claim2322['native_helpers'], + list(range(inj['geometry']['zero_buffers'])), 0) + need(all(inj['geometry'][k] == geo2322[k] for k in geo2322), 'R-f.namespace', + 'rule does not reproduce PR2322 PRIVATE-NAMESPACE-INJECTION.json geometry') + need(words['gauge44']['buffers'] == words['extra']['buffers'], 'R-f.zero_buffers', + 'both words use the same buffer registers') + geo = private_namespace(ctx['W'], ctx['R'], words['gauge44']['buffers'], rec['max_hosted_family']) + need(geo['physical'] == 66714 and geo['buffer_fields'] == [66312, 66356] and geo['remaining_reserve'] == 356, + 'R-f.namespace', 'expected geometry 66714 = 66304 + 400 + 8 + 2') + phys = physical_rows(R['b2269'], ctx['W'], rec['calls'], + {'ext80_this_fill': geo['physical'], + 'pr2269_43alias': ctx['W'] + CENTRES + 437 + COEFFICIENT_WORK, + 'pr2322': geo2322['physical']}) + print('R-f namespace: physical %d = %d + %d + 8 + 2; centres %s, reserved tableau %s, %d zero buffers -> %s, ' + 'coefficient %s; remaining reserve %d (PR2322 rule reproduces its own geometry %d)' % ( + geo['physical'], ctx['W'], ctx['R'], geo['centers'], geo['reserved_tableau'], geo['zero_buffers'], + geo['buffer_fields'], geo['coefficient'], geo['remaining_reserve'], geo2322['physical']), flush=True) + print('R-f stock bits: %s' % {k: v['stock_bits'] for k, v in phys['rows'].items()}, flush=True) + # ---- R-g: X2 pending-axis disjointness and 73-column charts (template DATA-PHASES) + b2339, _rec, _mode = read_2339(args.repo, args.words_from_inputs) + word_ports = [parse(b2339, 'words/BORROW-WORD-80%s.json.gz' % t)['ports'] for t in ('base', 'extra')] + phases, pports, recph = load_phases(args.repo, R['tpl']['template'], word_ports) + bases = owner_bases(pports) + xg = pending_axes_and_charts(sched, phases, bases, rows) + print('R-g X2: %d (port, child) pending-axis sets disjoint per family; %d distinct 73-column charts ' + '(%d slice keys)' % (xg['pending_axis_checks'], xg['actual_73column_charts'], xg['chart_keys']), flush=True) + # ---- negative controls + rejected = controls(ctx, sched, rows, words, b2339, phases, bases) + print('negative controls rejected: %d (%s)' % (len(rejected), ', '.join( + c['name'].split(' ')[0] + '->' + c['rejected_by'] for c in rejected)), flush=True) + # ---- positive control: PR2269's own fill + presult = None + if not args.skip_positive_control: + pctx, prows, pwords = case_2269(R['b2269'], R['tpl']) + presult = run_pipeline(pctx, sched, prows) + pxg = pending_axes_and_charts(sched, phases, bases, prows) + need(pxg['actual_73column_charts'] == R['tpl']['spec']['expected']['actual_73column_sigmas'], 'R-g.chart', + 'positive control: PR2269 chart count != its SPEC actual_73column_sigmas') + presult['pending_axes_and_charts'] = pxg + print('positive control PR2269 fill: roles=%d idle=%s (PLAN per_call_widths checked); charts %d = SPEC ' + 'actual_73column_sigmas' % (presult['roles'], presult['idle'], pxg['actual_73column_charts']), + flush=True) + except CheckFailure as exc: + print('%s %s' % (FAIL_LINE, exc)) + return 1 + except Exception as exc: # malformed input: report, never pass + print('%s unexpected %s: %s' % (FAIL_LINE, type(exc).__name__, exc)) + return 1 + meta = R['meta'] + meta['inputs'].update(rec2322) + meta['inputs'].update(recph) + receipt = dict( + status=PASS_LINE, + object=dict(owners=OWNERS_80[0], sha256=OWNERS_80[1], template='PR2269 head %s %s' % (HEAD_2269, PKG_2269), + words='PR2339 commit %s %s/words' % (HEAD_2339, PKG_2339)), + inputs=meta['inputs'], pr2339_files_read_from=meta['pr2339_source'], + claim_files_sha256=meta['claim_files_sha256'], + windows=dict(rebuilt=len(sched['windows']), equal_to_pr2269_plan=True, expanded_events=sched['events'], + bridges=sched['bridges'], child_ranks={str(c): sched['rank'][c] for c in sorted(sched['rank'])}, + swept_children_without_capacity=sched['rankless_children']), + words={pid: dict(removed_registers=w['removed'], width_inventory=plain(w['inventory']), + width_per_call=w['width_sum'], local_profile_recount=plain(w['local']), + local_mass=w['local_mass'], zero_buffers=len(w['buffers']), + buffer_registers=w['buffers'], initial_corrections=w['corrections'], warps=w['warps']) + for pid, w in words.items()}, + recount=rec, + claims_compared=dict(idle=[s for s, _ in ctx['claims']['idle']], profile=[s for s, _ in ctx['claims']['profile']], + scalars=[(k, s) for k, s, _ in ctx['claims']['scalars']], all_equal=True), + private_namespace=dict( + rule='As PR2322 states it (README "complete physical stock"; evidence/PRIVATE-NAMESPACE-INJECTION.json): ' + 'physical = W + 8 centres + R reserved tableau + 2 coefficient work; centres [W,W+8), reserved ' + 'tableau [W+8,W+8+R), coefficient [P-2,P); the NZ zero buffers (r + 704 for each hyperplane-ended ' + 'live helper r) are injected in increasing order into [W+8,W+8+NZ) and must fit (NZ <= R); all ' + 'hosted helper families are live (< W). Calls are serial and every buffer is allocated and freed ' + 'inside one call, so the same NZ fields serve every call.', + this_fill=geo, pr2322_reproduced=geo2322, stock=phys), + pending_axes_and_charts=dict( + rule='R-g: PR2269 independent_core.py check_pending_axes (X2) and the per-role 73-column chart binding, on ' + 'DATA-PHASES.json read at the PR2269 commit (sha256 = GLOBAL-TEMPLATE exact_data_phase_recipe_sha256)', + this_fill=xg), + controls_rejected=rejected, + positive_control=None if presult is None else dict( + object='PR2269 OWNERS.json.gz (437 helpers, 43-alias words) on the same template; PLAN per_call_widths ' + 'compared; claims of new/SPEC.json, CONSTRUCTION.json and new/PROFILE.json reproduced', **presult), + adaptation='For the 400-helper fill the PR2269 PLAN per_call_widths (437-helper lists) are not compared; ' + 'per-call widths come from the 80-alias words (positive control checks the PLAN widths for 437).', + not_checked=['warp algebra and exact free-operator replay of the 80-alias words (PR2339 check_ext.py)', + 'native lowering in both orientations of the 64 anticipatory initial corrections (the 43-alias ' + 'words have none) and the 37 new warps (80 lenders: 74 hosted helpers, 6 X fields)', + 'X-field lender ownership and frame-zero read lifetimes of hosted correction sources in the ' + 'whole-call map; physical lowering of the 44 zero buffers (R-f only follows PR2322 statement)', + 'native local prefix bits (needed for prefix < payload), controller emission, physical Clifford ' + 'phases, invoice; PLAN/SPEC refreeze for 400 helpers; assembly and outer ledger'], + scope='Finite recount of OWNERS-80.json.gz under the stated hosting rules on PR2269\'s unchanged template; ' + 'not a kappa claim.', + credits='PR2339 (this author); PR2269 Jeremy Kothe; PR2322 Vlado Vojdanovski; PR2312/PR2302 jeremykothe2; ' + 'PR2226 Cinna Davis; PR1319/PR1297 T74 lineage (Rohan Arun et al.); PR858 / T16 owner-audit rules. ' + 'Adapted from our iteration-3 fill_check.py/words_check.py (commit 4a2f20ea). Prepared with ' + 'substantial AI assistance (Claude Code, Anthropic); Apache-2.0.', + python=sys.version.split()[0]) + if args.out: + with open(os.path.join(HERE, RECEIPT_NAME), 'w', encoding='utf-8') as handle: + handle.write(json.dumps(receipt, indent=1, sort_keys=True) + '\n') + print('runtime_s=%.1f' % (time.time() - started)) + print('%s roles=%d idle=%s physical=%d buffers=%d/%d charts=%d controls=%d positive_control=%s' % ( + PASS_LINE, rec['roles'], json.dumps(rec['idle'], separators=(',', ':')), geo['physical'], geo['zero_buffers'], + ctx['R'], xg['actual_73column_charts'], len(rejected), 'PASS' if presult is not None else 'skipped')) + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/research/t74-3015-restore-edit-audit/vendor/pr2804/NOTICE.md b/research/t74-3015-restore-edit-audit/vendor/pr2804/NOTICE.md new file mode 100644 index 0000000000..88bbd7cf04 --- /dev/null +++ b/research/t74-3015-restore-edit-audit/vendor/pr2804/NOTICE.md @@ -0,0 +1,33 @@ +# Reused modules (PR #2804) + +The four files in this directory are this contributor's own checkers (Sagar Thakrar / thakrarsagar), Apache-2.0, +prepared with substantial AI assistance (Claude Code, Anthropic). They are byte-for-byte copies of the PR #2804 +package `research/t74-2530-source-partner-audit/` at commit `feb727ba471b5dc3f057f867804aa70ae58b2e71` (fork branch +`research/t74-2530-source-partner-audit`), copied with `git show` and not modified. `verify.py` checks each file's git +blob id and SHA256 (table `VENDOR`) and executes exactly the verified bytes. + +| File | Git blob | SHA256 | +| --- | --- | --- | +| `audit_common.py` | `17c4064f01b110012b54c05e64bdee8ae498e0b2` | `7ced740252ac8d8a8c66ef3cc825008e0aacf080494d0e983fb322d7dcddbf42` | +| `check_accounting.py` | `e749057dd838b715d0630de618f32d66a38da931` | `fb6aef50da586f15cd60762edc074c20e300d65f1378a80160b3d4b840762548` | +| `check_fill.py` | `85d1f807c62e4ac3b5f5ec7a809333ca05d5a951` | `6abf2a574de50c71b46b502d322deab841cbaa0080e326262f346a96992878fb` | +| `check_words.py` | `451dbb82f147ef446a1819b1ed595b4bf5547583` | `5996e804fa006906abff63a982c272588a44c35dfc932fdf687ef98dd3e0905f` | + +What this package uses from them: + +- `audit_common.py`: the failure type, the control counters, `git_env` (GIT_* redirection and config-injection + variables removed, `GIT_NO_REPLACE_OBJECTS=1`, `GIT_NO_LAZY_FETCH=1`), `ensure_commits` (the only writing call: + `--fetch` into `refs/audit/prN` with `--no-write-fetch-head`, `-c gc.auto=0 -c maintenance.auto=false`) and + `PinnedInputs` (every PR file read with `git show :` and checked against its git blob id and SHA256). +- `check_words.py`: `parse_ext` (A-phase warp items), `frame_recount` (literal climb chain and COPY paths), + `a_warp_algebra`, `run_replay`, `rederive_cleanup`, `inserted_gate_label`, `label_formula`, `reject_stage` and + `climb_split_mutant` (for a control). Its PR2530-specific constants are not used. +- `check_fill.py`: `template_structure`, `order_projection`, `block_windows`, `windows_agree`, `word_widths`, + `check_rows` (rules R-a..R-e and the R-c recount) and `fc_row`. `check_rows` reads its helper count from the + module-level `CLAIM['helpers']`; `audit_pricing.own_rows` sets that value to the recounted helper count (415) for + the duration of each call and restores it afterwards. The file bytes are unchanged. +- `check_accounting.py`: `moment` (exact atanh logarithms and a 2^-640 fixed-point directed-rounding exponential), + `accepts`, `rejects` and `dec`. + +The credits of the PR #2804 package and of the vendored PR #2315 and PR #2387 checkers (see `../NOTICE.md`) apply. +No code of PR #2751, #2733, #2720, #2696, #2269, #2766 or #2767 is vendored, imported or executed by this package. diff --git a/research/t74-3015-restore-edit-audit/vendor/pr2804/audit_common.py b/research/t74-3015-restore-edit-audit/vendor/pr2804/audit_common.py new file mode 100644 index 0000000000..17c4064f01 --- /dev/null +++ b/research/t74-3015-restore-edit-audit/vendor/pr2804/audit_common.py @@ -0,0 +1,216 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Shared helpers for the PR #2530 audit: one failure type and the pinned-input reader. + +Every PR input is read with `git -C show :` at a pinned commit and must match a pinned git +blob id (and, where listed, a sha256) before it is parsed; a pinned tree is listed by reading and re-hashing every +tree object below it (`git cat-file tree`, recursively), so a listing is accepted only if it hashes to the pinned +tree id. PR content is data only: it is decoded as JSON, gzip, tar or text and never imported or executed. + +Git environment (git_env): the repository-redirecting variables (GIT_DIR, GIT_WORK_TREE, GIT_INDEX_FILE, +GIT_OBJECT_DIRECTORY, GIT_ALTERNATE_OBJECT_DIRECTORIES, GIT_NAMESPACE, GIT_CEILING_DIRECTORIES, GIT_COMMON_DIR) and +the command-line config injections (GIT_CONFIG_PARAMETERS, GIT_CONFIG_COUNT, GIT_CONFIG_KEY_*, GIT_CONFIG_VALUE_*) +are removed, GIT_NO_REPLACE_OBJECTS=1 is set, so every git call reads exactly the --repo repository's own objects, +and GIT_NO_LAZY_FETCH=1 is set, so that in a partial clone `git show` fails on a missing object instead of fetching +it (honoured by recent git; older git ignores it). The reader is read-only. The only write is the documented --fetch (ensure_commits), which runs +`git fetch` with --no-write-fetch-head, --no-tags, --no-recurse-submodules, --no-prune, an empty --refmap and +-c gc.auto=0 -c maintenance.auto=false -c fetch.writeCommitGraph=false -c core.logAllRefUpdates=false +-c core.hooksPath=/dev/null, so it writes only the fetched objects and the namespaced ref refs/audit/pr (no +FETCH_HEAD, no other ref, no reflog, no commit-graph, no gc or maintenance, no hook); it needs git >= 2.29 +(--no-write-fetch-head); a failed fetch is reported with git's own error message. + +Control bookkeeping: every negative-control helper of the scopes calls attempt() before it runs its mutant, and every +positive control calls positive() after it has passed, so verify.py prints attempted and rejected negative +controls from separate counters and the positive controls actually executed. +Standard library only; Python 3.8-compatible syntax. +""" +import gzip +import hashlib +import json +import os +import subprocess + + +class AuditFail(Exception): + """A failed audit check (the message names the check).""" + + +def need(ok, msg): + if not ok: + raise AuditFail(msg) + + +# Negative controls attempted (names, in order) and positive controls executed (ids, in order); see reset_controls. +ATTEMPTED, POSITIVES = [], [] + + +def reset_controls(): + del ATTEMPTED[:] + del POSITIVES[:] + + +def attempt(name): + """Called by every negative-control helper before it runs its mutant.""" + ATTEMPTED.append(name) + + +def positive(pid): + """Called after a positive control has passed.""" + POSITIVES.append(pid) + + +def git_blob_id(data): + return hashlib.sha1(b'blob %d\0' % len(data) + data).hexdigest() + + +def sha256(data): + return hashlib.sha256(data).hexdigest() + + +# Environment variables that would make git read or write a repository other than `git -C `. +GIT_REDIRECT_VARS = ('GIT_DIR', 'GIT_WORK_TREE', 'GIT_INDEX_FILE', 'GIT_OBJECT_DIRECTORY', + 'GIT_ALTERNATE_OBJECT_DIRECTORIES', 'GIT_NAMESPACE', 'GIT_CEILING_DIRECTORIES', 'GIT_COMMON_DIR') +# Environment variables that inject configuration as if given with `git -c` (prefixes end with '_'). +GIT_CONFIG_INJECTION_VARS = ('GIT_CONFIG_PARAMETERS', 'GIT_CONFIG_COUNT') +GIT_CONFIG_INJECTION_PREFIXES = ('GIT_CONFIG_KEY_', 'GIT_CONFIG_VALUE_') +# `git -c` settings and options of the one writing call (--fetch): objects and refs/audit/pr only. +FETCH_CONFIG = ('gc.auto=0', 'maintenance.auto=false', 'fetch.writeCommitGraph=false', 'core.logAllRefUpdates=false', + 'core.hooksPath=/dev/null') +FETCH_OPTIONS = ('-q', '--no-tags', '--no-write-fetch-head', '--no-recurse-submodules', '--no-prune', '--refmap=') + + +def git_env(): + """A copy of os.environ without GIT_REDIRECT_VARS and the config-injection variables, with + GIT_NO_REPLACE_OBJECTS=1 (refs/replace is ignored) and GIT_NO_LAZY_FETCH=1 (no on-demand fetch of missing + objects in a partial clone).""" + env = dict(os.environ) + for name in list(env): + if name in GIT_REDIRECT_VARS or name in GIT_CONFIG_INJECTION_VARS or name.startswith(GIT_CONFIG_INJECTION_PREFIXES): + del env[name] + env['GIT_NO_REPLACE_OBJECTS'] = '1' + env['GIT_NO_LAZY_FETCH'] = '1' + return env + + +def _git(repo, args, config=()): + cmd = ['git'] + for kv in config: + cmd += ['-c', kv] + return subprocess.run(cmd + ['-C', repo] + list(args), stdout=subprocess.PIPE, stderr=subprocess.PIPE, + env=git_env()) + + +def commit_present(repo, commit): + return _git(repo, ['cat-file', '-e', commit + '^{commit}']).returncode == 0 + + +def audit_ref(pr): + return 'refs/audit/pr%d' % pr + + +def anchored(repo, commit, ref): + """commit is present and reachable from ref (so git gc keeps it).""" + return commit_present(repo, commit) and _git(repo, ['merge-base', '--is-ancestor', commit, ref]).returncode == 0 + + +def ensure_commits(repo, commits, fetch, remote): + """commits: {pr_number: sha}. Without fetch a missing commit is an error and nothing is written. With fetch, + a missing commit is fetched from the remote's refs/pull/N/head and, if the PR head has moved past it, by its + sha, each time into the namespaced ref refs/audit/prN of the target repository (forced update), so that the + fetched commit stays reachable from a ref and survives git gc; it must then be present and reachable from + refs/audit/prN. The fetch writes the fetched objects and refs/audit/prN only (FETCH_CONFIG, FETCH_OPTIONS; + git >= 2.29). If the commit is still missing, the failure message carries the last fetch's exit code and stderr + (for example an unknown option on older git, or a network error). Returns the PR numbers fetched.""" + need(_git(repo, ['rev-parse', '--git-dir']).returncode == 0, '%s is not a git repository (use --repo)' % repo) + fetched = [] + for pr in sorted(commits): + sha = commits[pr] + if commit_present(repo, sha): + continue + need(fetch, 'commit %s of PR #%d is absent from %s; rerun with --fetch' % (sha[:12], pr, repo)) + ref = audit_ref(pr) + last = None + for src in ('refs/pull/%d/head' % pr, sha): + last = _git(repo, ['fetch'] + list(FETCH_OPTIONS) + [remote, '+%s:%s' % (src, ref)], FETCH_CONFIG) + if anchored(repo, sha, ref): + fetched.append(pr) + break + need(anchored(repo, sha, ref), 'could not fetch commit %s of PR #%d from %s into %s (last git fetch: exit %d, ' + 'stderr %r)' % (sha[:12], pr, remote, ref, last.returncode, last.stderr.decode('utf-8', 'replace')[-400:])) + return fetched + + +class PinnedInputs(object): + """Reader for the pinned input table {key: (pr, commit, path, git_blob, sha256 or None)}. + + raw() returns the verified bytes; json() the parsed JSON (gunzipped for *.gz). Parsed objects are cached and + shared, so callers must treat them as read-only (controls deep-copy before mutating).""" + + def __init__(self, repo, table): + self.repo, self.table = repo, table + self._raw, self._json, self.used = {}, {}, {} + + def raw(self, key): + if key not in self._raw: + pr, commit, path, blob, sha = self.table[key] + p = _git(self.repo, ['rev-parse', '--verify', '-q', commit + ':' + path]) + need(p.returncode == 0, 'input %s: %s:%s not found' % (key, commit[:12], path)) + need(p.stdout.decode().strip() == blob, 'input %s: tree entry is not the pinned blob %s' % (key, blob)) + p = _git(self.repo, ['show', commit + ':' + path]) + need(p.returncode == 0, 'input %s: git show failed: %s' % (key, p.stderr.decode()[:200])) + data = p.stdout + need(git_blob_id(data) == blob, 'input %s: git blob id mismatch' % key) + digest = sha256(data) + need(sha is None or digest == sha, 'input %s: sha256 mismatch' % key) + self._raw[key] = data + self.used[key] = dict(pr=pr, commit=commit, path=path, git_blob=blob, sha256=digest, bytes=len(data)) + return self._raw[key] + + def json(self, key): + if key not in self._json: + data = self.raw(key) + if self.table[key][2].endswith('.gz'): + data = gzip.decompress(data) + self._json[key] = json.loads(data.decode('utf-8')) + return self._json[key] + + def text(self, key): + return self.raw(key).decode('utf-8') + + def show_blob(self, commit, path, blob): + """Bytes of commit:path for a file listed by tree(); the blob id is re-verified.""" + p = _git(self.repo, ['show', commit + ':' + path]) + need(p.returncode == 0 and git_blob_id(p.stdout) == blob, 'git show %s:%s is not blob %s' % (commit[:12], path, blob)) + return p.stdout + + def _tree_object(self, tree_id): + """Raw content of a tree object, re-hashed against its id (fail-closed listing).""" + p = _git(self.repo, ['cat-file', 'tree', tree_id]) + need(p.returncode == 0, 'git cat-file tree %s failed' % tree_id) + data = p.stdout + need(hashlib.sha1(b'tree %d\0' % len(data) + data).hexdigest() == tree_id, 'tree object %s does not hash to its id' + % tree_id) + return data + + def _tree_files(self, tree_id, prefix, out, key): + data, i = self._tree_object(tree_id), 0 + while i < len(data): + sp, nul = data.index(b' ', i), data.index(b'\0', i) + mode, name, oid = data[i:sp].decode(), data[sp + 1:nul].decode('utf-8'), data[nul + 1:nul + 21].hex() + i = nul + 21 + if mode == '40000': + self._tree_files(oid, prefix + name + '/', out, key) + else: + need(mode in ('100644', '100755'), 'tree %s: non-regular entry %r (mode %s)' % (key, prefix + name, mode)) + out[prefix + name] = oid + return out + + def tree(self, key): + """A pinned tree entry {key: (pr, commit, path, tree_id, None)}: returns {relative path: blob id} of every + regular file below it, after checking that commit:path is the pinned tree object; every tree object read is + re-hashed against its id.""" + pr, commit, path, tree_id, _ = self.table[key] + p = _git(self.repo, ['rev-parse', '--verify', '-q', commit + ':' + path]) + need(p.returncode == 0 and p.stdout.decode().strip() == tree_id, 'tree %s is not the pinned tree %s' % (key, tree_id)) + out = self._tree_files(tree_id, '', {}, key) + self.used[key] = dict(pr=pr, commit=commit, path=path, git_tree=tree_id, files=len(out)) + return out diff --git a/research/t74-3015-restore-edit-audit/vendor/pr2804/check_accounting.py b/research/t74-3015-restore-edit-audit/vendor/pr2804/check_accounting.py new file mode 100644 index 0000000000..e749057dd8 --- /dev/null +++ b/research/t74-3015-restore-edit-audit/vendor/pr2804/check_accounting.py @@ -0,0 +1,638 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Scope C and provenance: verifier overrides, recovered source, stock/precision accounting, endpoint, kappa, PR2474. + +What is proved: + * overrides: OVERRIDES.json's old hashes are PR2462's independent_core.py and new/rebind.py (rebind also equals + PR2435's); the new hashes are PR #2530's files; ignoring CRLF, independent_core.py changes exactly two exact- + equality pins (independent_core_change) and rebind.py exactly one expression, physical += zero buffers + (rebind_change). The pins, parsed as literals (never executed), equal what the words give: 16 line-[30] lifted + targets and centre children {1:8, 7:8} (old pins = PR2462's words). No other .py file of the PR2462 package + carries the old pins (old_pin_files); all three checks are functions of the file bytes; + * recovered source: PR #2530's source-pr2435.tar.gz (438 members) equals the PR2435 package tree (438 files) and, + with pr2462-overlay.tar.gz (40 members) applied, equals the PR2462 package tree (443 files), including the + overlay words (reconstruct; recon.pr2435_tree, recon.pr2462_tree, recon.overlay_words); archives are read in + memory as data and nothing in them is executed or written to disk; + * stock: physical = W + 8 + R + Z + 2 gives 66814 (R=422, Z=78 counted from the words) and reproduces PR2462's + SPEC 66822 (R=430) and PR2435's SPEC 66826 (R=434); local mass falls 5315 -> 5251 = 8 x 8; + * precision arithmetic: receipt prefix_l1 values give 62/69 bits (valid upper bounds); the global prefix computed + from them, 69+37+666+666+4 = 1442, equals receipts/INDEPENDENT-GLOBAL.json prefix_bits and fits the payload 2048 + (= its charged_prefix_bits) (global_prefix); the row coefficient is the receipt's 19545 for every physical stock + 66736..66830; the receipt values are recorded next to the own ones; + * endpoint: a rigorous integer fixed-point enclosure (2^-640, directed rounding, atanh/exp series with tail + bounds) of M(a) = (1/W) sum n_r (r/73)^(1-a) on PROFILE.json; an endpoint is accepted only if the upper end of + the enclosure is below 1 (accepts) and rejected only if the lower end is above 1 (rejects). C = + 0.001713737921547504346752 is accepted and C + 1e-24 rejected; bisection brackets the root, so C is its + 24-digit floor; the conservative endpoint is likewise accepted/rejected; the ledger's two 2^-527 native moments + bracket the enclosure at b; + * kappa = C - 10^-70 - 10^-46 with the ledger's b = C - r0, q = C - 2 r0, delta = (1025/1024) r0, and the + DIG = 24 instance of PR2462's grid-maximum rule (outer_grid, rule outer.grid): C*F integer, 0 < C - eps*q + (= 2.0017e-104, recorded) < 1/F, floor(F eps q)/F - B = kappa (floor(F eps q) = C*F - 1, recorded); + * PR2474 comparison: the pinned OUTER-CLAIM equals the file at the PR2474 commit; the gain computed from the two + kappas equals CLAIM's latest_claim_gain exactly (latest_gain, rule pr2474.gain) and the percentage string is its + 100-digit truncation; + * enclosure soundness guards: every exp series argument lies in [0, 1) in fixed point (the precondition of the + "2 x next term" tail bound) and every lower end is <= its upper end; + * positive control: the same moment checker's enclosure [lo, hi] at PR2462's certified 3000-digit endpoint + C2462 (where 1 - 1e-2999 < M <= 1) satisfies lo <= 1 and hi >= 1 - 1e-2990, so an upper end that falls below + the true moment by more than about 1e-2990 (an unsound exp upper rounding) is caught; C2462 - 1e-150 is + accepted and C2462 + 1e-150 rejected; + * negative controls, each asserting its rule (and, where one rule has several conditions, the condition) and each + run through the function the main check uses. accounting (8): the acceptance check fails at C + 1e-24, at the + conservative C' + 1e-24 and at C2462 + 1e-150; at C2462 the enclosure straddles 1 (lo < 1 < hi), so the + acceptance check must fail at C2462 + 1e-3000 and the rejection check at C2462 (a predicate on the wrong end of + the enclosure would pass either); a wrong target pin; a reconstruction that keeps PR2435's base word; and the + stock rule without the zero-buffer term (the pre-PR2530 rebind formula, 66736 != 66814). outer_grid (3): + kappa + 1e-70 (floor equality), q - 2e-70 (C - eps*q > 1/F) and q = C/eps (C - eps*q = 0). overrides_diff + (5): independent_core.py with one more line (a require) commented out, rebind.py with one more line (an assert) + commented out, each once before and once after the allowed lines, and an extra .py file carrying the old target + pin. provenance_accounting (6): the source archive with one extra and with one missing member + (recon.pr2435_tree), the overlay with one extra member and missing one of the files it adds (recon.pr2462_tree), + CLAIM's gain + 1e-40 (pr2474.gain), and the global prefix from the largest receipt prefix_l1 doubled + (precision.global_prefix). +Scope limits: the 63 outer inequalities are not re-derived; prefix_l1 is taken from the PR's receipts (only its +bit arithmetic is checked); the ledger was not regenerated here (PR2462's outer code is not run by this package). +""" +import ast +import io +import posixpath +import re +import tarfile +from collections import Counter +from fractions import Fraction as Q + +import fill_check80 as FC +from audit_common import AuditFail, attempt, git_blob_id, need, positive, sha256 + +V, M, W, T, CALLS = 112, 73, 66304, 74, 666 +PKG_HANDOFF = 'research/gmx-t74-borrow43-handoff/' +IC_PIN_LINES = (72, 93) # 1-based lines of independent_core.py that may change +REBIND_LINE = 52 +REBIND_SUFFIX = " + max(len(rd(d / 'CANONICAL-WORD.json.gz').get('zero_buffers', [])) for d in locs.values()))" +OLD_PIN_PATTERNS = (r'23,\s*34,\s*50,\s*108', r'1:\s*4,\s*7:\s*4,\s*8:\s*4') + + +def dec(q, digits): + """Truncated decimal string of a non-negative Fraction.""" + n = q.numerator * 10 ** digits // q.denominator + s = str(n).rjust(digits + 1, '0') + return s[:-digits] + '.' + s[-digits:] + + +# ------------------------------------------------------------------------------------------ overrides --- +def _lines(raw): + return raw.decode('utf-8').replace('\r\n', '\n').split('\n') + + +def changed_lines(old_raw, new_raw): + old, new = _lines(old_raw), _lines(new_raw) + need(len(old) == len(new), 'overrides: line count changed') + return [(i + 1, old[i].strip(), new[i].strip()) for i in range(len(old)) if old[i] != new[i]] + + +def pin_literals(ic_text_lines): + """Parse (never execute) the two pins of independent_core.py as Python literals.""" + targets = re.search(r'set\(levels\) == (\{[0-9, ]*\})', ic_text_lines[0]) + children = re.search(r'forward\) == (\{[0-9:, ]*\})', ic_text_lines[1]) + need(targets is not None and children is not None, 'overrides: pin lines not recognised') + return sorted(ast.literal_eval(targets.group(1))), dict(ast.literal_eval(children.group(1))) + + +def pins_match_words(ic_new_line_pair, ic_old_line_pair, words): + """New pins must equal the PR2530 words (both providers), old pins the PR2462 words.""" + for tag in ('base', 'extra'): + for lines, key in ((ic_new_line_pair, 'pr2530'), (ic_old_line_pair, 'pr2462')): + targets, children = pin_literals(lines) + wsum = words[tag][key] + need(targets == wsum['lifted_targets'], 'overrides: %s target pin != %s %s words' % (key, key, tag)) + need(Counter(children) == Counter(d for _, ch in wsum['copy_paths'] for d in ch), + 'overrides: %s centre-child pin != %s %s words' % (key, key, tag)) + + +def independent_core_change(old_raw, new_raw): + """independent_core.py (bytes, CRLF ignored) changes exactly the lines IC_PIN_LINES; returns the changes.""" + ic = changed_lines(old_raw, new_raw) + need([c[0] for c in ic] == list(IC_PIN_LINES), 'overrides: independent_core changed lines %r' % [c[0] for c in ic]) + return ic + + +def rebind_change(old_raw, new_raw): + """rebind.py (bytes, CRLF ignored) changes exactly line REBIND_LINE, by appending the zero-buffer term to the + physical stock expression; returns the change.""" + rb = changed_lines(old_raw, new_raw) + need([c[0] for c in rb] == [REBIND_LINE] and rb[0][1].endswith('+ 8 + R + 2)') + and rb[0][2] == rb[0][1][:-1] + REBIND_SUFFIX, 'overrides: rebind change %r' % [c[0] for c in rb]) + return rb + + +def old_pin_files(py_files, listing): + """py_files: {relative path: bytes} of the .py files of the PR2462 package; listing: the .py paths of the pinned + tree, which the scan must cover exactly. Only independent_core.py may carry the old pins (any other file would + also have needed editing); returns the files that carry them.""" + need(sorted(py_files) == sorted(listing), 'overrides: old-pin scan covers %d of %d .py files' % (len(py_files), len(listing))) + hits = sorted(rel for rel, data in py_files.items() + if any(re.search(p, data.decode('utf-8', 'replace')) for p in OLD_PIN_PATTERNS)) + need(hits == ['independent_core.py'], 'overrides: old pins also in %r' % hits) + return hits + + +def overrides(inp, words): + ov = inp.json('overrides2530') + need(sorted(ov) == ['independent_core.py', 'new/rebind.py'], 'overrides: entries') + need(ov['independent_core.py']['old_sha256'] == sha256(inp.raw('ic2462')), 'overrides: independent_core old hash != PR2462 file') + need(ov['independent_core.py']['new_sha256'] == sha256(inp.raw('ic2530')), 'overrides: independent_core new hash') + need(ov['new/rebind.py']['old_sha256'] == sha256(inp.raw('rebind2462')) == sha256(inp.raw('rebind2435')), + 'overrides: rebind old hash != PR2462 (= PR2435) file') + need(ov['new/rebind.py']['new_sha256'] == sha256(inp.raw('rebind2530')), 'overrides: rebind new hash') + ic = independent_core_change(inp.raw('ic2462'), inp.raw('ic2530')) + pins_match_words([c[2] for c in ic], [c[1] for c in ic], words) + rb = rebind_change(inp.raw('rebind2462'), inp.raw('rebind2530')) + # no other .py file of the PR2462 package carries the old pins (they would also have needed editing) + tree = inp.tree('tree2462') + py_files = dict((rel, inp.show_blob(inp.table['tree2462'][1], PKG_HANDOFF + rel, tree[rel])) + for rel in sorted(tree) if rel.endswith('.py')) + hits = old_pin_files(py_files, [rel for rel in tree if rel.endswith('.py')]) + return dict(independent_core_changed=[list(c) for c in ic], rebind_changed=[list(c) for c in rb], + old_files_crlf=b'\r\n' in inp.raw('ic2462') and b'\r\n' in inp.raw('rebind2462'), + new_files_crlf=b'\r\n' in inp.raw('ic2530') or b'\r\n' in inp.raw('rebind2530'), + py_files_scanned_for_old_pins=len(py_files), files_with_old_pins=hits), ic, py_files + + +# ------------------------------------------------------------------------------- source reconstruction --- +def tar_blobs(raw, prefix=''): + """{path relative to prefix: git blob id} of the regular files of a .tar.gz, read in memory (data only).""" + out = {} + with tarfile.open(fileobj=io.BytesIO(raw), mode='r:gz') as tf: + for m in tf.getmembers(): + name = m.name + if m.isdir(): + continue + need(not name.startswith('/') and '..' not in name.split('/') and posixpath.normpath(name) == name, + 'tar: unsafe member name %r' % name) + need(m.isfile(), 'tar: non-regular member %r' % name) + need(name.startswith(prefix), 'tar: member outside %s: %r' % (prefix, name)) + rel = name[len(prefix):] + need(rel not in out, 'tar: duplicate member %r' % name) + out[rel] = git_blob_id(tf.extractfile(m).read()) + return out + + +def same_tree(got, want, label): + """Two {path: git blob id} maps are equal: no missing, no extra and no differing file ('