diff --git a/research/p112-reader-memo-seed92/BENCHMARK.json b/research/p112-reader-memo-seed92/BENCHMARK.json new file mode 100644 index 0000000000..83b81680df --- /dev/null +++ b/research/p112-reader-memo-seed92/BENCHMARK.json @@ -0,0 +1,158 @@ +{ + "base_commit": "9ef085e6c07c8590329ad00b7eac382aef06124c", + "certificate_sha256": "d1140c3af508b420ab63b1de5fb29af9ed47631492ab1eb7d5b19b06a7d83646", + "conflicting_kernels": 128, + "environment": { + "implementation": "CPython", + "machine": "arm64", + "python": "3.12.13", + "system": "Darwin" + }, + "excluded_runs": "Scalar-cache prototype and earlier table-preparation pilots are not benchmark evidence. The preceding five-pair run overlapped an untimed counting replay and is excluded.", + "fixture": "Entire unchanged PR845 run() and its committed RESULTS.json; no sampled sign cases.", + "inherited_controls": 9, + "measurement_protocol": "Five pairs alternate reference/memo and memo/reference. Each engine gets a fresh interpreter and cache; no other agent-launched CPU workload ran concurrently. Filesystem caches were not flushed. No process affinity or resource limits beyond the 120-second worker timeout. Ratios are descriptive, never a mathematical pass gate.", + "median_process_seconds": { + "memo": 1.4025932499789633, + "ratio": 1.401297976445339, + "reference": 1.9654510829714127 + }, + "median_run_seconds": { + "memo": 1.3471562499762513, + "ratio": 1.4191348442594394, + "reference": 1.9117963750031777 + }, + "package_controls": [ + "ordered basis permutation", + "in-place basis mutation", + "in-place label mutation", + "uncached X coordinate mutation", + "uncached coefficient mutation", + "integer-equal float basis still rejects", + "integer-equal float label still rejects", + "bounded eviction and recomputation", + "omitted constraint row", + "exchanged sign-row order", + "erased reader values", + "type-sensitive rank receipt", + "omitted live source pin" + ], + "pairs": [ + { + "memo": { + "cache": { + "currsize": 1, + "hits": 3272, + "maxsize": 4, + "misses": 1 + }, + "process_seconds": 1.3969656249973923, + "run_seconds": 1.3417054579476826 + }, + "order": [ + "reference", + "memo" + ], + "reference": { + "cache": null, + "process_seconds": 1.9654510829714127, + "run_seconds": 1.9117963750031777 + } + }, + { + "memo": { + "cache": { + "currsize": 1, + "hits": 3272, + "maxsize": 4, + "misses": 1 + }, + "process_seconds": 1.4423786249826662, + "run_seconds": 1.3871181670110673 + }, + "order": [ + "memo", + "reference" + ], + "reference": { + "cache": null, + "process_seconds": 1.9578862090129405, + "run_seconds": 1.9031278339680284 + } + }, + { + "memo": { + "cache": { + "currsize": 1, + "hits": 3272, + "maxsize": 4, + "misses": 1 + }, + "process_seconds": 1.4025932499789633, + "run_seconds": 1.3471562499762513 + }, + "order": [ + "reference", + "memo" + ], + "reference": { + "cache": null, + "process_seconds": 1.9603819170151837, + "run_seconds": 1.90456820797408 + } + }, + { + "memo": { + "cache": { + "currsize": 1, + "hits": 3272, + "maxsize": 4, + "misses": 1 + }, + "process_seconds": 1.430742874974385, + "run_seconds": 1.376137999992352 + }, + "order": [ + "memo", + "reference" + ], + "reference": { + "cache": null, + "process_seconds": 1.9686416669865139, + "run_seconds": 1.9120537909911945 + } + }, + { + "memo": { + "cache": { + "currsize": 1, + "hits": 3272, + "maxsize": 4, + "misses": 1 + }, + "process_seconds": 1.3938636250095442, + "run_seconds": 1.3381605410249904 + }, + "order": [ + "reference", + "memo" + ], + "reference": { + "cache": null, + "process_seconds": 2.002653875038959, + "run_seconds": 1.9471341249882244 + } + } + ], + "sign_cases": 3272, + "source_pr845_head": "125ce25bdae421627b56077adc14940c2d0aa52f", + "status": "PASS_P112_READER_MEMO", + "support_certificates": 511, + "targeted_exact_evaluations": { + "memo": 896, + "method": "Untimed instrumented full source-bound replays, both compared against the complete committed certificate.", + "reference": 979776 + }, + "timing_scope": "process_seconds: fresh admitted worker from process launch through exit, including source admission, imports, complete run, complete-certificate comparison and output writing. Excludes parent control suite and parent child-output decoding/comparison. run_seconds: complete source run() boundary.", + "verify_py_sha256": "9fb00f9b71243cafbf35c7cc78f9de8213a15a99ac0dadc23e4227a7385bd3f0" +} diff --git a/research/p112-reader-memo-seed92/CLAIM.md b/research/p112-reader-memo-seed92/CLAIM.md new file mode 100644 index 0000000000..343d0c28cd --- /dev/null +++ b/research/p112-reader-memo-seed92/CLAIM.md @@ -0,0 +1,7 @@ +CLAIM — verification engineering, OS assignment seed **92**. Base `9ef085e6c07c8590329ad00b7eac382aef06124c`. + +Exact object: Mihir Srivastava's incorporated PR845 `research/p112-single-lift/verify.py`, specifically repeated binary reader-form evaluations in its complete 3,272-sign-case constraint stream. Method: source-pinned opt-in memoization keyed by the complete ordered reader basis and label, with bounded in-process storage; alternate fresh-process baseline/candidate pairs, compare every field of the original certificate and retain all original controls. Add changed-label/basis and collision controls. No new mathematics or kappa; frozen sources and selected frontier unchanged. + +Three candidates screened: exact moment kernels (overlaps retained exact-exp tooling), registered source-pin batching (overlaps #1452/#1595), and this PR845 reader-form kernel. Seed `92 mod 3 = 2` selects the third, after checking live bodies/Discussion claims. #1144 accelerates a different free-sink determinant audit; #1584 accelerates the finite-bit edge scorer; the active selected phase-replay claim is distinct. + +Expected deliverable: one opt-in verifier package with a full-certificate comparison, paired timings, meaningful fault controls, exact pins and a bounded replay hook. Expected finish **2026-10-14 05:53 UTC**; expires **06:10 UTC**. No pinned sprint issue exists; this claim will also be retained locally. Prepared for Charan (@theon199) with substantial OpenAI Codex assistance. diff --git a/research/p112-reader-memo-seed92/README.md b/research/p112-reader-memo-seed92/README.md new file mode 100644 index 0000000000..4084d0aaba --- /dev/null +++ b/research/p112-reader-memo-seed92/README.md @@ -0,0 +1,130 @@ +# Exact compiled reader tables for the PR845 replay + +**Verification tooling; no new mathematics or κ.** The opt-in compiled-table +engine runs Mihir Srivastava's complete P112 single-lift verifier about **1.40× +faster** in five alternating fresh-process pairs on macOS arm64 / CPython +3.12.13. Both engines reproduce every field of its committed certificate: +511 support certificates, 3,272 sign cases, 128 conflicting kernels and all +nine inherited controls. The original package is unchanged. + +## What changes + +PR845's `constraint_rows` repeatedly evaluates the same reader bases against +the same live labels. `ConstraintMemo` in [verify.py](verify.py) computes the +eight-by-112 table with the **original exact evaluator**, then builds every +original ordered constraint row. An instrumented complete replay counts +979,776 targeted evaluations in the reference and 896 in the candidate. + +The cache key contains all ordered basis entries and all labels. Each call +snapshots their current values; it caches neither coefficients nor X. The LRU +holds at most four tables of 896 integers. Only the fixed-size built-in integer +list/tuple domain uses this path. Other inputs retain the original builder, +including its failure behavior. There is no cross-process cache or persisted +reuse receipt. + +Every other predecessor check runs unchanged. Acceptance compares the whole +certificate using canonical, type-sensitive JSON, including ordered row hashes, +original-row support minors, exact kernels, conflict ports and control outputs. +Rank or histogram agreement alone is insufficient. Live inputs are admitted +by exact SHA256 before import; an omitted source pin fails. + +## Reproduce + +From the repository root, using Python 3.12 and the standard library: + +```sh +python3.12 -B scripts/research_package.py --package research/p112-reader-memo-seed92 +``` + +Expected final marker: +`PASS_REGISTERED_RESEARCH_PACKAGE research/p112-reader-memo-seed92 outcome=completed`. +The registered replay compares both full engines, runs five focused test groups +under optimization, and invokes PR845's unchanged independent checker. + +For a single faster, source-bound complete replay, create a fresh output: + +```sh +reader_work=$(mktemp -d) +python3.12 -I -B research/p112-reader-memo-seed92/verify.py \ + --engine memo --output "$reader_work/REPLAY.json" +``` + +Expected: `PASS_P112_READER_MEMO_ENGINE engine=memo`. The output contains the +entire predecessor certificate and cache statistics. Existing files are never +overwritten. The default engine is `compare`, which deliberately runs both +full replays and therefore takes longer than either single engine. + +To repeat the paired benchmark: + +```sh +reader_work=$(mktemp -d) +python3.12 -I -B research/p112-reader-memo-seed92/verify.py \ + --pairs 5 --report "$reader_work/BENCHMARK.json" +``` + +Expected: `PASS_P112_READER_MEMO` with `supports=511 signs=3272 +conflicting_kernels=128 inherited_controls=9 controls=13 pairs=5`, and complete +certificate digest +`d1140c3af508b420ab63b1de5fb29af9ed47631492ab1eb7d5b19b06a7d83646`. +Timing ratios are reported and never used as a mathematical pass threshold. + +## Evidence and limits + +[BENCHMARK.json](BENCHMARK.json) records all five pairs and their environment. +Median complete worker-process time is **1.965451 s → 1.402593 s** (1.4013×). +This includes source admission, imports, the complete verifier, full-certificate +comparison and output writing. It excludes the parent driver's controls and +comparison of child outputs. Median time inside the unchanged `run()` boundary +is **1.911796 s → 1.347156 s** (1.4191×). These are local workload measurements, +not a hardware-independent, selected cold-replay or multiplication speed claim. + +Thirteen additional controls cover ordered and mutated bases, mutated labels, +uncached X/coefficients, integer-equal float failures, eviction/recomputation, +erased reader values, omitted/reordered constraints, a type-altered rank receipt, +and a missing source pin. Five tests additionally cover every proof section, +lazy/fallback inputs, source drift, duplicate pins/JSON, actual optimized +workers, read-only relocation in a path with spaces and preserving output after +failure. PR845's separate integer-minor/set-elimination checker also passes; +that implementation and its independent-method credit belong to its predecessor. + +This contributes finite replay equivalence and tooling. It does not prove the +all-real-parameter theorem anew, admit a physical supplier or audit the full +multiplication theorem. Selected cold replay, native/Lean builds and hosted CI +are not claimed. All-size/compiler, realization, hosting, precision/tape, +analytic transfer and bit H1–H5 obligations remain separate. + +## Sources, assignment and attribution + +Exact research base: **`9ef085e6c07c8590329ad00b7eac382aef06124c`**. +[SOURCES.json](SOURCES.json) pins all eight live inputs with Git blob IDs and +SHA256, plus historical provenance. The reviewed PR845 head is +`125ce25bdae421627b56077adc14940c2d0aa52f`. The selected record at this base is +PR1094, conditional κ = `836330098538459/500000000000000000`, reviewed in +`docs/research/community-batch1099-review.md`; its complete command is +`make frontier1094-verify`. That selected replay was not run for this isolated +tooling contribution. + +OS seed **92**, verification engineering, selected this object after screening +three narrow candidates. [TASK.json](TASK.json) and [CLAIM.md](CLAIM.md) record +the selection, bounds and [sprint claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-18915419). +The final overlap coverage and limitations are recorded in TASK.json. +#1144 accelerates a different P112 free-sink determinant checker; #1584 the +finite-bit edge scorer; #1452/#1595 source-pin reads. The active cold phase +replay claim concerns different inputs and kernels. No pending code is imported. + +Credit **Mihir Srivastava / @mihir-s-05 (PR845)** for the theorem, geometry, +certificate and both original checkers; **DreamingOfClouds (PR717/PR446)** for +geometry and the inherited physical interpretation; **Joel Pulikkan / +GamingPuzzled (PR620)** for the coordinate cost 64 and retained lineage. +Prepared for **Charan (@theon199)** with substantial **OpenAI Codex assistance** +in profiling, implementation, verification and writing. No subagents or +independent human review. New material is Apache-2.0; predecessor sources and +notices, `upstream/` and the selected frontier remain unchanged. + +## Open next questions + +Maintainers can review whether to adopt this table preparation in PR845's +frozen package. Start with the registered replay and paired benchmark, then +migrate source pins deliberately if approved. That review and pin migration +block adoption; this package remains opt-in. No additional mathematical search +is justified by the verifier speedup. diff --git a/research/p112-reader-memo-seed92/SOURCES.json b/research/p112-reader-memo-seed92/SOURCES.json new file mode 100644 index 0000000000..e2c5bb527b --- /dev/null +++ b/research/p112-reader-memo-seed92/SOURCES.json @@ -0,0 +1,92 @@ +{ + "schema_version": 1, + "base_commit": "9ef085e6c07c8590329ad00b7eac382aef06124c", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "06c96f5579bb67ed1b86d334e78fbed7da6945f1", + "sha256": "6686ad58f1fbdbc87134a78901b60fd53a20d3984355e91defbbebc9e9fa8075" + }, + { + "path": "research/p112-single-lift/RESULTS.json", + "usage": "input", + "git_blob": "be204ad0bb27dda715acc3e01fbe7ad6ddc1e010", + "sha256": "0947e7380f931dc8e447751b9b33d531a1ced92a6b94225be7ea29ea57497c05" + }, + { + "path": "research/p112-single-lift/SOURCES.json", + "usage": "input", + "git_blob": "a36ad2fa75d5f2bbce60997a4caa21b0f12786c3", + "sha256": "3895e1e5d97987d760fca7ef124cccabcfe5a675ce2928c1c9b2de1f48bb7667" + }, + { + "path": "research/p112-single-lift/geometry.py", + "usage": "input", + "git_blob": "34c1abf059d7be5fe5e5044cf01a09b843071c68", + "sha256": "3857c11ec731a602b8059d85d58fbb3b641bab687bb33016a0e54f7567752c8a" + }, + { + "path": "research/p112-single-lift/independent_check.py", + "usage": "input", + "git_blob": "dec55ff6c048c8aa2e4c9bc274345c56d8c016d6", + "sha256": "9d74b6fde539f82c31fda88074c7c2dd0465f9892ed61b8d13b5dae0fbf5d29b" + }, + { + "path": "research/p112-single-lift/reference-geometry.json", + "usage": "input", + "git_blob": "d862663d3c0ffe3c72df510e89997beb85cef640", + "sha256": "4f44af368e046002553d632ee90c6470990827cea3fae41f0f54018522d7a080" + }, + { + "path": "research/p112-single-lift/reference/PR717-NOTICE.md", + "usage": "input", + "git_blob": "481f6bf99bb19c7f2f73b0991a751b6b9187b16c", + "sha256": "7809c20cd037dcc29edb5207cbc333bed7b2bd1026cb4f1137f150de90d6866d" + }, + { + "path": "research/p112-single-lift/reference/pr717_e8model.py", + "usage": "input", + "git_blob": "489a3e2c12e58c0e824eb6c49f5168ddc6756085", + "sha256": "7255d13ef349e7a549c0f26addf35ef72d28c72343f3abfcbab2f5eba74834a5" + }, + { + "path": "research/p112-single-lift/verify.py", + "usage": "input", + "git_blob": "b7a81ad2f5beb21cd5595b93c0c07b467a3a9715", + "sha256": "8da963c33c5d09f1f23437cd89cb9c05f397ac1cddae49d3dc47b2d719555546" + }, + { + "path": "research/p112-single-lift/PROOF.md", + "usage": "provenance", + "git_blob": "609a2b1f83f17523a570a1a2e1731817c87a587a", + "sha256": "02147aa2a93a449dcbd15886b42d993bd0dbb554d7c15d347a9567fbe2a442e1" + }, + { + "path": "research/p112-single-lift/README.md", + "usage": "provenance", + "git_blob": "41ee5713cd31f82b3a2882a178b03ed8fbede436", + "sha256": "b0aa432b38e6317661d4edfe5fa37c377cff937a527fe83a55261e7202ce2442" + }, + { + "path": "research/p112-single-lift/NOTICE.md", + "usage": "provenance", + "git_blob": "eb811ef7e601441f07c996fa3a265639b354eb8f", + "sha256": "54fcd00460fed3afecad295c0e8310cc1f44d00a21c9ac2872be8c4e3ca26dbe" + }, + { + "path": "docs/research/community-batch952-review.md", + "usage": "provenance", + "git_blob": "512ce9f18b32007bea71452eb5f3eb85c4d577ad", + "sha256": "04db59dfc2c31453229b6061bbf59547e71ce3abdc0ce0f6779144bb0dde127b" + } + ], + "predecessor_head": "125ce25bdae421627b56077adc14940c2d0aa52f", + "attribution": "Mihir Srivastava PR845; DreamingOfClouds PR717 geometry and PR446 physical interpretation; Joel Pulikkan/GamingPuzzled PR620 coordinate cost. Original sources remain in place and unchanged." +} diff --git a/research/p112-reader-memo-seed92/TASK.json b/research/p112-reader-memo-seed92/TASK.json new file mode 100644 index 0000000000..be1ff0ffa7 --- /dev/null +++ b/research/p112-reader-memo-seed92/TASK.json @@ -0,0 +1,271 @@ +{ + "schema_version": 1, + "task_id": "replay-runtime", + "priority_revision": 3, + "base_commit": "9ef085e6c07c8590329ad00b7eac382aef06124c", + "original_card": { + "id": "replay-runtime", + "question": "Can one measured replay bottleneck be sped up without dropping coverage?", + "starting_points": [ + "scripts/run_isolated_tests.py", + "scripts/verify_replay_coverage.py", + "certificates/selected-result.json" + ], + "methods": [ + "Profile one isolated replay and optimize the measured bottleneck.", + "Design source-bound reuse with explicit dependency invalidation and negative controls." + ], + "acceptance_gate": "Report before/after wall time on the same fixture, retained checks and invalidation behavior.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read the selected reproduction command and choose a single replay stage for profiling.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Measure one unchanged fixture, preserve check coverage, and test one optimization with invalidation controls.", + "bottleneck_link": "Faster trustworthy replays increase review throughput and let mechanism candidates be checked sooner.", + "allowed_variations": [ + "Profile one stage or design one source-bound cache boundary." + ], + "scope_change_triggers": [ + "Skipping coverage or comparing different fixtures to claim speedup." + ], + "overlap_terms": [ + "replay runtime", + "cache invalidation", + "isolated tests" + ] + }, + "scope_status": "refined", + "actual_scope": "Memoize the complete ordered PR845 reader-form table, retaining every row and every full-certificate obligation of the 3272-sign replay.", + "scope_change_reason": "The donor assigned seed 92 to verification engineering. The replay-runtime card is refined to the incorporated PR845 P112 single-lift constraint builder; no source, theorem or selected-supplier change.", + "bottleneck_link": "Speeds a complete reviewed structural-decoder replay and its failure controls; this improves review throughput, not the multiplication exponent.", + "budget_minutes": 60, + "stop_rule": "One 60-minute session, orientation ended after about seven minutes. Stop after exact full-certificate equality, one measured optimization, five alternating fresh-process timing pairs, fault controls and packaging; no search for a new supplier or kappa.", + "outcome": "completed", + "evidence": "verify.py compares the full committed PR845 certificate for both engines. BENCHMARK.json records five alternating fresh-process pairs. test_verify.py covers source drift, omitted/duplicated pins, certificate-field corruption, fallback, optimized workers and read-only relocation.", + "author": "Charan (@theon199), with substantial OpenAI Codex assistance", + "ai_assistance": "Substantial OpenAI Codex assistance in task selection, profiling, implementation, tests, analysis and writing; no subagents, independent human review or proof-assistant verification.", + "open_questions": [ + { + "question": "Should the source-bound compiled reader table be adopted in the frozen PR845 package?", + "why_it_matters": "The opt-in engine reduces replay time while preserving the original mathematical certificate and all inherited controls.", + "first_step": "Review ConstraintMemo and run the registered package and five-pair benchmark; migrate predecessor source pins explicitly if adopted.", + "blocked_by": "Maintainer review and deliberate source-pin migration; this contribution does not modify the frozen package." + } + ], + "assignment_seed": 92, + "assignment_seed_source": "Python secrets.randbelow(100), using OS randomness; one draw.", + "track": "verification-engineering", + "predecessor": { + "pr": 845, + "reviewed_head": "125ce25bdae421627b56077adc14940c2d0aa52f", + "author": "Mihir Srivastava (@mihir-s-05)", + "review": "docs/research/community-batch952-review.md" + }, + "claim": { + "pinned_coordination_issue": null, + "local_record": "CLAIM.md", + "url": "https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-18915419", + "expected_finish_utc": "2026-10-14 05:53 UTC" + }, + "candidates": [ + { + "object": "Exact moment exponential kernels", + "decision": "deferred", + "reason": "Retained exact-exp-performance and adjacent endpoint-engine work already cover these kernels." + }, + { + "object": "Registered source-pin reads", + "decision": "deferred", + "reason": "Current PR1452 and PR1595 already cover Git process batching and registered input reads." + }, + { + "object": "PR845 repeated reader-form evaluations", + "decision": "selected", + "reason": "Seed 92 modulo 3 selects this third candidate; current PR bodies and Discussion claims did not identify the same kernel." + } + ], + "overlap_refresh": { + "checked_at_utc": "2026-10-14 05:25 UTC", + "refreshed_main": "3d161fdcdf9b49812efe3546e0ac5bff63f4de46", + "live_inputs_unchanged": true, + "open_prs_count": 531, + "discussion_count": 108, + "pr_pagination_complete": true, + "discussion_pagination_complete": true, + "comment_page_limit": 50, + "reply_page_limit": 20, + "truncated_comment_or_reply_threads": [], + "terms": [ + "p112-single-lift", + "constraint_rows", + "reader memo", + "reader-form", + "reader form", + "3272", + "3,272", + "pr845", + "pr #845" + ], + "matching_prs": [ + { + "number": 1626, + "title": "docs: map complex decoder bounds and restore PR968 replay route", + "head": "46849a15a2812d3e0a9f0d2c4a9b86382d6cfe4e" + }, + { + "number": 1591, + "title": "Research: sharp COPY64 floor for all nine-factor singleton P112 completions", + "head": "264b8dcfc56584797ebf36d69ee35de18313fd27" + }, + { + "number": 1473, + "title": "Scoped negative result: two-anchor span preservation for P112 decoders", + "head": "ea2f6bf0940580dfaeb393ec0786abc8f7bbb7b4" + }, + { + "number": 1468, + "title": "Research: independent COPY floor for arbitrary one-column P112 corrections", + "head": "5e2d8ec8ebff17c85e813ef1bd6f06312c1fe16a" + }, + { + "number": 1460, + "title": "Scoped negative result: arbitrary free rectangles retain COPY64 for P112 pair (4,6)", + "head": "8d53667d9bb09d9b1ffb0f865b5c8dc230eb02f6" + }, + { + "number": 1432, + "title": "Scoped negative result: fixed P112 24-row boundary retains COPY64", + "head": "4bcc49e3f4041018b0607da46a87d8928a6e0fd0" + }, + { + "number": 1375, + "title": "Research: COPY floor 64 for two-coordinate P112 mixing with small free rectangles (no new kappa)", + "head": "4a533aff2a7a87c9b36e077a31774b332a7f64bd" + }, + { + "number": 1373, + "title": "Scoped negative result: P112 GL3 COPY floor with three active projections", + "head": "3eaef3e4427068b33847dc1147c8a2e5709a970e" + }, + { + "number": 1331, + "title": "Scoped obstruction: one free P112 rectangle cannot improve one coordinate COPY", + "head": "f08b698cc2bd74e2425486728a008e531fc35f0e" + }, + { + "number": 1327, + "title": "Scoped negative result: copy-rank floor for two-sided P112 parity lifts", + "head": "0462379659388acdb271f2e769986475d8a0646c" + }, + { + "number": 1325, + "title": "Research: classify P112 sparse-lift equality and sharp all-active cost 65", + "head": "ba2d1cae64738891dd530b3526fb8ae3b25541aa" + }, + { + "number": 1212, + "title": "Research: rank-8 complex decoders are gauge-rigid; E-graph eight-term floor (no new kappa)", + "head": "57099cb5684f38877f31d149d598801671a633db" + }, + { + "number": 885, + "title": "[Lean] Prove the selected PR799 native Real moment bound", + "head": "0181d0f2e00278535f435968f000d7e2ec4b93aa" + }, + { + "number": 487, + "title": "[Lean] Verification of selected 1320-port bijection, \u03ba=0.000661885549259598", + "head": "a9d9fd5196311a0ecf91a6b021879f2bacc0ee68" + } + ], + "matching_discussions": [ + { + "number": 1166, + "title": "Handoffs and requests for independent checks", + "updated_at": "2026-10-14T05:23:26Z" + }, + { + "number": 1639, + "title": "DONE: uniform P112 odd-column COPY64 and nine-mixed COPY71 (PR1652)", + "updated_at": "2026-10-14T05:20:08Z" + }, + { + "number": 1645, + "title": "CLAIM: one extra mixed total at the selected k8 centre cut", + "updated_at": "2026-10-14T05:04:12Z" + }, + { + "number": 1621, + "title": "CLAIM: scope map for retained complex E8 decoder lower bounds", + "updated_at": "2026-10-14T04:19:18Z" + }, + { + "number": 1360, + "title": "CLAIM: sharp copy floor for all rank-nine factorizations of a single odd-entry P112 completion", + "updated_at": "2026-10-14T03:39:44Z" + }, + { + "number": 1434, + "title": "Two-coordinate COPY floor for arbitrary one-column free corrections", + "updated_at": "2026-10-14T01:14:59Z" + }, + { + "number": 1316, + "title": "CLAIM: one free odd rectangle mixed with one P112 coordinate term", + "updated_at": "2026-10-14T01:00:03Z" + } + ], + "scope_comparison": "No same PR845 compiled-reader-table optimization identified in retrieved bodies/claims. PR1144 is a distinct signed determinant checker, PR1584 a finite-bit edge scorer, PR1452/1595 source reads. Discussion1621/PR1626 consolidate existing decoder claims, not this kernel. No pending code imported. Claims in Discussion1166 concern selected phase, packing and different decoder subjects.", + "limitations": "Bodies and retrieved comments/replies only; not a proof of novelty, no complete diff or closed-PR survey. Historical closed work is represented by the base ledger and retained package notes.", + "nearest_tooling_and_navigation": [ + { + "pr": 1144, + "head": "3a4da02f15d702f1900d15d55a675afc8d033e9b", + "title": "Verification engineering: preserve exact signed P112 audit with bounded modular recovery", + "present_in_final_open_snapshot": false + }, + { + "pr": 1584, + "head": "dddaa467d2bbbcf45bcc6b2cf92a78e8d1c4ccad", + "title": "Tooling: 1.22x faster exact finite-bit block-core checks", + "present_in_final_open_snapshot": true + }, + { + "pr": 1452, + "head": "f785c7a847a396d1947bb9fdf3a936af487a70ab", + "title": "Performance: stream research provenance through one Git process", + "present_in_final_open_snapshot": true + }, + { + "pr": 1595, + "head": "2c2b583848ffe3c169b3ce18b7e6a982b4281aa4", + "title": "Tooling: batch registered research source-pin reads", + "present_in_final_open_snapshot": true + }, + { + "pr": 1626, + "head": "46849a15a2812d3e0a9f0d2c4a9b86382d6cfe4e", + "title": "docs: map complex decoder bounds and restore PR968 replay route", + "present_in_final_open_snapshot": true + } + ] + }, + "validation": { + "python_312": "3.12.13", + "python_additional": "3.14.5", + "registered_replay": "PASS", + "package_tests": "5 passed on both interpreters, optimized child execution included", + "research_workflow_tests": "20 passed on Python 3.12.13", + "selected_record_integrity": "PASS", + "predecessor_independent_check": "PASS", + "full_selected_replay": "not run", + "native_or_lean": "not run", + "hosted_ci": "not yet run" + } +} diff --git a/research/p112-reader-memo-seed92/VERIFY.json b/research/p112-reader-memo-seed92/VERIFY.json new file mode 100644 index 0000000000..342e8a9889 --- /dev/null +++ b/research/p112-reader-memo-seed92/VERIFY.json @@ -0,0 +1,49 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/p112-single-lift/RESULTS.json", + "research/p112-single-lift/SOURCES.json", + "research/p112-single-lift/geometry.py", + "research/p112-single-lift/independent_check.py", + "research/p112-single-lift/reference-geometry.json", + "research/p112-single-lift/reference/PR717-NOTICE.md", + "research/p112-single-lift/reference/pr717_e8model.py", + "research/p112-single-lift/verify.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Both unchanged-reference and compiled-table workers reproduce all fields of PR845 RESULTS.json; thirteen mathematical, cache and source-inventory controls." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/test_verify.py" + ], + "timeout_seconds": 120, + "checks": "Five focused test groups: proof-section corruption, mutation/fallback, source pins/duplicates, read-only relocation, actual optimized worker and preservation of output after failed source admission." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "research/p112-single-lift/independent_check.py" + ], + "timeout_seconds": 120, + "checks": "Unchanged predecessor independent set-elimination/integer-minor audit of all 511 support minors, 3272 sign cases and 128 conflict kernels." + } + ] +} diff --git a/research/p112-reader-memo-seed92/test_verify.py b/research/p112-reader-memo-seed92/test_verify.py new file mode 100644 index 0000000000..110b6328f9 --- /dev/null +++ b/research/p112-reader-memo-seed92/test_verify.py @@ -0,0 +1,155 @@ +#!/usr/bin/env python3 +"""Failure-detection, fallback, relocation and optimized-execution controls. + +Charan (@theon199), with substantial OpenAI Codex assistance. Apache-2.0. +""" + +import copy +import importlib.util +import json +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile +import unittest + +HERE = Path(__file__).resolve().parent +spec = importlib.util.spec_from_file_location('reader_memo_package', HERE / 'verify.py') +v = importlib.util.module_from_spec(spec) +spec.loader.exec_module(v) + + +def export(root): + package = root / 'research/p112-reader-memo-seed92' + package.mkdir(parents=True) + for name in ('verify.py', 'SOURCES.json'): + shutil.copyfile(HERE / name, package / name) + for name in v.LIVE_INPUTS: + destination = root / name + destination.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(v.ROOT / name, destination) + return package + + +class ReaderMemoTests(unittest.TestCase): + def test_mathematical_fault_and_mutation_controls(self): + controls = v.controls(v.ROOT) + self.assertEqual(len(controls), 13) + self.assertEqual(len(set(controls)), 13) + + def test_outside_envelope_retains_source_behavior(self): + module = v.subject(v.ROOT) + memo = v.ConstraintMemo(module.constraint_rows, module.evaluate) + # A small arbitrary state uses the exact original builder, including + # duplicated readers, signed labels and coefficient magnitudes != 1. + data = {'X': [[1, -1], [0, 1], [-1, 0]], 'labels': [1, 2, -3]} + for coefficients in ((1, 1), (2, -1), (0, 0)): + spaces = [[1, 1], [2, 3]] + self.assertEqual(memo(coefficients, data, spaces), + module.constraint_rows(coefficients, data, spaces)) + spaces = [[1, 1], [2, 3]] + expected = module.constraint_rows((1, 1), data, spaces) + lazy = {**data, 'labels': iter(data['labels'])} + self.assertEqual(memo((1, 1), lazy, spaces), expected) + # A malformed form is irrelevant when no reader is active; caching + # must not turn the source's successful zero map into a type failure. + data = module.build() + spaces = [[1.0] * 8 for _ in range(8)] + self.assertEqual(memo((0,) * 8, data, spaces), [0] * 224) + + def test_every_proof_section_is_compared(self): + expected = v.read_json(v.ROOT / v.SUBJECT / 'RESULTS.json') + mutations = [] + for field, value in (('geometry_sha256', '0' * 64), + ('reader_spaces', expected['reader_spaces'][::-1])): + wrong = copy.deepcopy(expected) + wrong[field] = value + mutations.append(wrong) + wrong = copy.deepcopy(expected) + wrong['support_certificates'][0]['basis_ports'][0] = -1 + mutations.append(wrong) + wrong = copy.deepcopy(expected) + wrong['cases'][0]['rows_sha256'] = '0' * 64 + mutations.append(wrong) + wrong = copy.deepcopy(expected) + full = next(case for case in wrong['cases'] if 'kernel' in case) + full['kernel'] = '0x0' + mutations.append(wrong) + wrong = copy.deepcopy(expected) + full = next(case for case in wrong['cases'] if 'conflict_ports' in case) + full['conflict_ports'].pop() + mutations.append(wrong) + wrong = copy.deepcopy(expected) + wrong['controls']['rejected'].pop() + mutations.append(wrong) + for wrong in mutations: + with self.assertRaisesRegex(ValueError, 'complete certificate mismatch'): + v.compare(wrong, expected, 'mutated proof section') + + def test_source_drift_inventory_and_duplicate_json(self): + manifest = v.read_json(HERE / 'SOURCES.json') + with tempfile.TemporaryDirectory(prefix='reader source controls ') as temporary: + root = Path(temporary) + export(root) + v.source_admission(root) + source = root / v.SUBJECT / 'geometry.py' + source.write_bytes(source.read_bytes() + b'\n# deliberate source mutation\n') + with self.assertRaisesRegex(ValueError, 'source drift'): + v.source_admission(root) + duplicate = copy.deepcopy(manifest) + duplicate['files'].append(next(p for p in duplicate['files'] + if p['usage'] == 'input')) + with self.assertRaisesRegex(ValueError, 'complete live input inventory'): + v.source_admission(root, duplicate) + path = root / 'duplicate.json' + path.write_text('{"rank":63,"rank":64}', encoding='utf-8') + with self.assertRaisesRegex(ValueError, 'duplicate JSON key'): + v.read_json(path) + + def test_optimized_read_only_relocation_and_preserved_output(self): + with tempfile.TemporaryDirectory(prefix='reader relocation with spaces ') as temporary: + outside = Path(temporary) + root = outside / 'read only checkout' + package = export(root) + paths = list(root.rglob('*')) + [root] + for path in paths: + path.chmod(0o555 if path.is_dir() else 0o444) + try: + report = outside / 'report.json' + completed = subprocess.run( + [sys.executable, '-I', '-O', '-B', str(package / 'verify.py'), + '--report', str(report)], text=True, capture_output=True, timeout=120) + self.assertEqual(completed.returncode, 0, completed.stdout + completed.stderr) + self.assertIn('PASS_P112_READER_MEMO', completed.stdout) + result = v.read_json(report) + self.assertEqual(result['sign_cases'], 3272) + self.assertEqual(len(result['package_controls']), 13) + # An actually optimized candidate worker executes the full + # predecessor replay, not just an optimized parent driver. + worker = outside / 'optimized-worker.json' + completed = subprocess.run( + [sys.executable, '-I', '-O', '-B', str(package / 'verify.py'), + '--engine', 'memo', '--output', str(worker)], + text=True, capture_output=True, timeout=120) + self.assertEqual(completed.returncode, 0, completed.stdout + completed.stderr) + v.compare(v.read_json(worker)['certificate'], + v.read_json(root / v.SUBJECT / 'RESULTS.json'), 'optimized worker') + saved = report.read_bytes() + source = root / v.SUBJECT / 'geometry.py' + source.chmod(0o644) + source.write_bytes(source.read_bytes() + b'\n# deliberate failure\n') + source.chmod(0o444) + failed = subprocess.run( + [sys.executable, '-I', '-O', '-B', str(package / 'verify.py'), + '--report', str(report)], text=True, capture_output=True, timeout=120) + self.assertNotEqual(failed.returncode, 0) + self.assertIn('source drift', failed.stderr) + self.assertEqual(report.read_bytes(), saved) + finally: + for path in paths: + path.chmod(0o755 if path.is_dir() else 0o644) + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/research/p112-reader-memo-seed92/verify.py b/research/p112-reader-memo-seed92/verify.py new file mode 100644 index 0000000000..e185f87036 --- /dev/null +++ b/research/p112-reader-memo-seed92/verify.py @@ -0,0 +1,340 @@ +#!/usr/bin/env python3 +"""Opt-in exact reader-form memoization for Mihir Srivastava's PR845 replay. + +Charan (@theon199), with substantial OpenAI Codex assistance. Apache-2.0. +The frozen predecessor is imported unchanged only after live source admission. +""" + +import argparse +from functools import lru_cache +import hashlib +import importlib.util +import json +from pathlib import Path +import platform +import statistics +import subprocess +import sys +import tempfile +import time + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +SUBJECT = 'research/p112-single-lift' +LIVE_INPUTS = { + SUBJECT + '/' + name for name in ( + 'verify.py', 'geometry.py', 'RESULTS.json', 'SOURCES.json', + 'reference-geometry.json', 'reference/pr717_e8model.py', + 'reference/PR717-NOTICE.md', 'independent_check.py', + ) +} + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def encoded(value): + """Type-sensitive equality for every field, including booleans and numbers.""" + return json.dumps(value, sort_keys=True, separators=(',', ':'), + allow_nan=False).encode('utf-8') + + +def no_duplicates(pairs): + out = {} + for key, value in pairs: + require(key not in out, 'duplicate JSON key: ' + key) + out[key] = value + return out + + +def read_json(path): + return json.loads(path.read_text(encoding='utf-8'), + object_pairs_hook=no_duplicates) + + +def source_admission(root, manifest=None): + manifest = read_json(HERE / 'SOURCES.json') if manifest is None else manifest + inputs = [p for p in manifest['files'] if p['usage'] == 'input'] + require(len(inputs) == len(LIVE_INPUTS) + and {p['path'] for p in inputs} == LIVE_INPUTS, + 'complete live input inventory') + root = root.resolve() + for pin in inputs: + path = (root / pin['path']).resolve() + require(path.is_relative_to(root) and path.is_file(), + 'missing or escaped source: ' + pin['path']) + require(hashlib.sha256(path.read_bytes()).hexdigest() == pin['sha256'], + 'source drift: ' + pin['path']) + return inputs + + +def load_module(name, path): + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + sys.modules[name] = module + spec.loader.exec_module(module) + return module + + +def subject(root): + source_admission(root) + directory = root / SUBJECT + # The original verifier uses `from geometry import ...`. Bind that import + # to its admitted file even under -I or in a relocated checkout. + load_module('geometry', directory / 'geometry.py') + return load_module('pr845_reader_memo_subject', directory / 'verify.py') + + +class ConstraintMemo: + """Compile exact reader values once, then build every original constraint. + + Snapshot all ordered bases and labels on each call. The fixed-size built-in + integer envelope avoids bool/float cache aliases and bounds each table to + 896 integers; other inputs use the original constraint builder. Coefficients + and X are never cached. Mutating either immediately changes the generated + rows. A four-table LRU bound limits storage without dropping any constraint. + """ + + def __init__(self, original, evaluate, maxsize=4): + require(type(maxsize) is int and maxsize > 0, 'positive integer cache bound') + self.original = original + + @lru_cache(maxsize=maxsize) + def prepare(spaces, labels): + return tuple(tuple(evaluate(space, label) for space in spaces) + for label in labels) + + self.cached = prepare + + def __call__(self, coefficients, data, spaces): + # Do not consume generators or custom containers that the original + # builder may read lazily. Optimize the admitted JSON/list domain only. + if (type(spaces) not in (list, tuple) + or any(type(space) not in (list, tuple) for space in spaces) + or type(data['labels']) not in (list, tuple) + or type(coefficients) not in (list, tuple)): + return self.original(coefficients, data, spaces) + bases = tuple(tuple(space) for space in spaces) + labels = tuple(data['labels']) + if (len(bases) != 8 or any(len(basis) != 8 for basis in bases) + or len(labels) != 112 or len(coefficients) != 8 + or any(type(q) is not int for basis in bases for q in basis) + or any(type(label) is not int for label in labels)): + return self.original(coefficients, data, spaces) + values_by_port = self.cached(bases, labels) + active = [j for j, value in enumerate(coefficients) if value] + rows = [] + for values, evaluations in zip(data['X'], values_by_port): + for sign in (-1, 1): + row = 0 + for block, j in enumerate(active): + if values[j] * coefficients[j] == sign: + row |= evaluations[j] << (8 * block) + rows.append(row) + return rows + + +def compare(actual, expected, context): + require(encoded(actual) == encoded(expected), 'complete certificate mismatch: ' + context) + + +def controls(root): + """Exercise cache invalidation and fault detection outside the timed runs.""" + module = subject(root) + data = module.build() + spaces = [module.reader_space([r[j] for r in data['X']], data['duals']) + for j in range(8)] + original = module.constraint_rows + memo = ConstraintMemo(original, module.evaluate) + signs = (1,) * 8 + baseline = original(signs, data, spaces) + require(memo(signs, data, spaces) == baseline, 'initial compiled rows') + passed = [] + + def changed_rows(name, changed_data, changed_spaces, changed_signs=signs): + expected = original(changed_signs, changed_data, changed_spaces) + require(expected != baseline, 'ineffective control: ' + name) + require(memo(changed_signs, changed_data, changed_spaces) == expected, + 'stale compiled table: ' + name) + require(memo(signs, data, spaces) == baseline, 'restore after ' + name) + passed.append(name) + + changed_spaces = [list(space) for space in spaces] + changed_spaces[0].reverse() + changed_rows('ordered basis permutation', data, changed_spaces) + # Mutate the SAME list objects after warming them, then restore them. + memo(signs, data, changed_spaces) + changed_spaces[0][0] ^= 1 + changed_rows('in-place basis mutation', data, changed_spaces) + changed_data = {**data, 'labels': list(data['labels'])} + changed_data['labels'][0] ^= 1 + changed_rows('in-place label mutation', changed_data, spaces) + changed_data = {**data, 'X': [list(row) for row in data['X']]} + column = next(j for j, value in enumerate(changed_data['X'][0]) if value) + changed_data['X'][0][column] = 0 + changed_rows('uncached X coordinate mutation', changed_data, spaces) + changed_rows('uncached coefficient mutation', data, spaces, (-1,) + signs[1:]) + + def must_fail(name, operation, error=ValueError): + try: + operation() + except error: + passed.append(name) + else: + raise ValueError('accepted fault: ' + name) + + changed_spaces = [list(space) for space in spaces] + changed_spaces[0][0] = float(changed_spaces[0][0]) + must_fail('integer-equal float basis still rejects', + lambda: memo(signs, data, changed_spaces), TypeError) + changed_data = {**data, 'labels': list(data['labels'])} + changed_data['labels'][0] = float(changed_data['labels'][0]) + must_fail('integer-equal float label still rejects', + lambda: memo(signs, changed_data, spaces), TypeError) + + # Table eviction affects only recomputation. Use the real source builder. + small = ConstraintMemo(original, module.evaluate, maxsize=1) + small(signs, data, spaces) + alternate = [list(reversed(space)) for space in spaces] + require(small(signs, data, alternate) == original(signs, data, alternate), + 'evicted alternate input') + require(small(signs, data, spaces) == baseline + and small.cached.cache_info().misses == 3, 'exact eviction/recomputation') + passed.append('bounded eviction and recomputation') + + # These faults can preserve ranks. The complete row-stream digest detects + # them rather than accepting a rank-only or histogram-only comparison. + correct = module.case_certificate(signs, data, spaces) + for name, corrupt in ( + ('omitted constraint row', lambda rows: rows[1:]), + ('exchanged sign-row order', lambda rows: [r for i in range(0, len(rows), 2) + for r in (rows[i+1], rows[i])]), + ): + module.constraint_rows = lambda c, d, s, f=corrupt: f(original(c, d, s)) + must_fail(name, lambda: compare(module.case_certificate(signs, data, spaces), + correct, name)) + module.constraint_rows = lambda c, d, s: [0] * len(original(c, d, s)) + must_fail('erased reader values', lambda: module.case_certificate(signs, data, spaces)) + module.constraint_rows = original + false = {**correct, 'rank': 63.0} + must_fail('type-sensitive rank receipt', lambda: compare(false, correct, 'rank type')) + manifest = read_json(HERE / 'SOURCES.json') + incomplete = {**manifest, 'files': [p for p in manifest['files'] + if p['path'] != SUBJECT + '/geometry.py']} + must_fail('omitted live source pin', lambda: source_admission(root, incomplete)) + return passed + + +def worker(root, engine, output): + module = subject(root) + memo = None + if engine == 'memo': + memo = ConstraintMemo(module.constraint_rows, module.evaluate) + module.constraint_rows = memo + started = time.perf_counter() + result = module.run() + seconds = time.perf_counter() - started + expected = read_json(root / SUBJECT / 'RESULTS.json') + compare(result, expected, engine) + stats = memo.cached.cache_info()._asdict() if memo is not None else None + payload = {'engine': engine, 'run_seconds': seconds, 'cache': stats, + 'certificate_sha256': hashlib.sha256(encoded(result)).hexdigest(), + 'certificate': result} + # Never truncate an existing output, including when a caller repeats a run. + with output.open('x', encoding='utf-8') as stream: + json.dump(payload, stream, sort_keys=True) + stream.write('\n') + print('PASS_P112_READER_MEMO_ENGINE engine=' + engine) + + +def run_worker(root, engine, output, optimized=False): + argv = [sys.executable, '-I', '-B'] + if optimized: + argv.append('-O') + argv += [str(HERE / 'verify.py'), '--engine', engine, + '--root', str(root), '--output', str(output)] + started = time.perf_counter() + completed = subprocess.run(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + text=True, timeout=120) + elapsed = time.perf_counter() - started + require(completed.returncode == 0, + engine + ' worker failed: ' + completed.stdout + completed.stderr) + payload = read_json(output) + require(payload['engine'] == engine, 'worker engine binding') + return payload, elapsed + + +def audit(root, pairs): + require(type(pairs) is int and 1 <= pairs <= 9, 'pairs must be in 1..9') + source_admission(root) + expected = read_json(root / SUBJECT / 'RESULTS.json') + certificate_digest = hashlib.sha256(encoded(expected)).hexdigest() + passed_controls = controls(root) + samples = [] + with tempfile.TemporaryDirectory(prefix='p112 reader memo ') as directory: + work = Path(directory) + for pair in range(pairs): + order = ['reference', 'memo'] if pair % 2 == 0 else ['memo', 'reference'] + sample = {'order': order} + for engine in order: + payload, seconds = run_worker(root, engine, work / f'{pair}-{engine}.json') + compare(payload['certificate'], expected, engine + ' full replay') + sample[engine] = {'process_seconds': seconds, + 'run_seconds': payload['run_seconds'], + 'cache': payload['cache']} + if engine == 'memo': + stats = payload['cache'] + require(stats['hits'] > 0 and 0 < stats['currsize'] <= 4, + 'memo path actually exercised with bounded storage') + samples.append(sample) + result = {'status': 'PASS_P112_READER_MEMO', 'certificate_sha256': certificate_digest, + 'support_certificates': len(expected['support_certificates']), + 'sign_cases': len(expected['cases']), 'conflicting_kernels': 128, + 'inherited_controls': len(expected['controls']['rejected']), + 'package_controls': passed_controls, 'pairs': samples, + 'environment': {'python': platform.python_version(), + 'implementation': platform.python_implementation(), + 'system': platform.system(), 'machine': platform.machine()}} + for field in ('process_seconds', 'run_seconds'): + baseline = statistics.median(s['reference'][field] for s in samples) + candidate = statistics.median(s['memo'][field] for s in samples) + result['median_' + field] = {'reference': baseline, 'memo': candidate, + 'ratio': baseline / candidate} + return result + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--root', type=Path, default=ROOT) + parser.add_argument('--pairs', type=int, default=1, + help='1..9 alternating fresh-process pairs; timings are not a pass gate') + parser.add_argument('--report', type=Path, help='create a new timing report after all checks') + parser.add_argument('--engine', choices=('compare', 'reference', 'memo'), default='compare', + help='compare both engines, or run one complete admitted replay') + parser.add_argument('--output', type=Path, help='create a new full-certificate file for one engine') + args = parser.parse_args() + root = args.root.resolve() + if args.engine != 'compare': + require(args.output is not None and args.report is None, + 'single engine requires --output and excludes --report') + worker(root, args.engine, args.output) + return + require(args.output is None, '--output requires a single engine') + result = audit(root, args.pairs) + if args.report is not None: + with args.report.open('x', encoding='utf-8') as stream: + json.dump(result, stream, sort_keys=True, indent=2) + stream.write('\n') + print('PASS_P112_READER_MEMO supports=511 signs=3272 conflicting_kernels=128 ' + f'inherited_controls=9 controls={len(result["package_controls"])} ' + f'pairs={args.pairs} complete_certificate={result["certificate_sha256"]}') + + +if __name__ == '__main__': + try: + main() + except (ValueError, OSError, KeyError, TypeError, subprocess.TimeoutExpired) as error: + print('FAIL_P112_READER_MEMO: ' + str(error), file=sys.stderr) + raise SystemExit(1)