Yang–Mills: the 2026 Lean construction, rerun and read; the mass gap still open
OpenAI's 2026 Lean construction of 4D Yang–Mills as the expert group keeps it: settle what it proves, rerun it, read it; uniqueness and the mass gap are open, and Clay's problem unsolved

chore: independently audit V-1 package hashes and submission (#7)
Browse files+1 −0 routes/beamnxw-v1-package-audit/.gitignore added View file
| @@ -0,0 +1 @@ | ||
| 1 | +__pycache__/ | |
+53 −4 routes/beamnxw-v1-package-audit/README.md View file
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | --- |
| 2 | 2 | issue: 7 |
| 3 | -status: working | |
| 3 | +status: done | |
| 4 | 4 | --- |
| 5 | 5 | # V-1: independent package hash audit |
| 6 | 6 | |
| @@ -22,6 +22,55 @@ and matching report; this route does not manufacture that second review. | ||
| 22 | 22 | |
| 23 | 23 | ## Next |
| 24 | 24 | |
| 25 | -Bind this session to issue #7, reread the authenticated brief, post the starting | |
| 26 | -report, then test the independent auditor against small known fixtures before | |
| 27 | -running it on the pinned package. Report Shoal verdicts separately from our audit. | |
| 25 | +Second party: reproduce the primary 9,746 assertions with your own code and | |
| 26 | +compare the per-file results, then review PR #56. Issue #7 is not declared closed | |
| 27 | +by this route. The route's implementation/run is complete, not independently | |
| 28 | +accepted. Maintainer replay and any final adoption remain outside this run. | |
| 29 | + | |
| 30 | +## Result | |
| 31 | + | |
| 32 | +`audit-result.json` records 9,784 local assertions over 9,703 unique paths, | |
| 33 | +0 mismatches and 0 missing files. Its three primary manifests give 9,746 | |
| 34 | +assertions; the extra 38 are explicitly counted provenance/bridge assertions. | |
| 35 | +All 9,508 submission files are present at the recorded Shoal base: 9,507 are | |
| 36 | +byte-identical and only `README.md` differs. `UPSTREAM.md` is a separate Shoal-only | |
| 37 | +document, not counted as a byte-identical file; 42 Shoal-only paths are inventoried. | |
| 38 | +See `RERUN.md` for commands, exact output and what remains unverified. | |
| 39 | + | |
| 40 | +## Reproduce | |
| 41 | + | |
| 42 | +Python 3.11+ and Git; no third-party Python packages, Lean, or upstream scripts. | |
| 43 | +Clone upstream at the pin above with byte-preserving checkout (`core.autocrlf=false`). | |
| 44 | +From this route folder (the upstream clone is a sibling of the Shoal clone): | |
| 45 | + | |
| 46 | +```console | |
| 47 | +python -X utf8 -m unittest -v test_audit | |
| 48 | +python -X utf8 audit.py --upstream ../../../upstream-ym --shoal ../.. --shoal-commit e6cb83f2a074d48e31a67e57d4ecb15b85e7275d --output audit-result.json | |
| 49 | +``` | |
| 50 | + | |
| 51 | +The first three manifests are counted separately for comparison with the earlier | |
| 52 | +9,746-assertion record. All five provenance JSON manifests are parsed explicitly: | |
| 53 | + | |
| 54 | +- `october-import.json`: every `included[].path` / `sha256`. | |
| 55 | +- `package-files.json`: every path-to-SHA-256 entry. | |
| 56 | +- `review-imports.json` and `osreconstruction.json`: every `files[]` entry. | |
| 57 | +- `os-bridge-excerpts.json`: every `sources[]` entry and both hashes in every | |
| 58 | + `copies[]` entry. Historical absolute `source` paths are never opened: their | |
| 59 | + unique `source_path` suffix must map to a local provenance snapshot. `copy` is | |
| 60 | + relative to `checks/`. This checks bytes, not `declarations_unchanged` or the | |
| 61 | + asserted correctness of adaptations. | |
| 62 | + | |
| 63 | +Repeated assertions remain repeated in the hash count; `unique_files` counts | |
| 64 | +paths separately. No recorded expected count is used as a success condition. | |
| 65 | +Unknown/empty manifests, duplicate JSON keys, invalid hashes and unsafe paths | |
| 66 | +fail rather than silently shrink the scope. Files are hashed as raw bytes. | |
| 67 | + | |
| 68 | +The submission comparison reads **committed Git blobs at the recorded Shoal | |
| 69 | +base**, not the live `main` branch or this route's working tree. It enumerates | |
| 70 | +identical, changed, source-only and Shoal-only paths. Exit 0 means local hash | |
| 71 | +assertions match, **not** that the whole Shoal tree equals the submission. | |
| 72 | +Missing/hash-mismatched files give exit 1; input/format/Git-object errors give 2. | |
| 73 | + | |
| 74 | +The historical ZIP's standalone `archive_sha256` cannot be recomputed: that ZIP | |
| 75 | +is not in this clone. Local snapshots do not authenticate external original | |
| 76 | +repositories. No network requests are made by the auditor. | |
+104 −0 routes/beamnxw-v1-package-audit/RERUN.md added View file
| @@ -0,0 +1,104 @@ | ||
| 1 | +# Rerun record: V-1 / issue #7 | |
| 2 | + | |
| 3 | +## 2026-12-03 (Moscow; 2026-12-02 UTC): independent package audit, by beamnxw-codex-review (Codex) | |
| 4 | + | |
| 5 | +- Machine: owner's local Windows 10 Pro 10.0.19045, AMD Ryzen 5 5600X, | |
| 6 | + 6 physical / 12 logical cores, 33,475,644 KiB visible RAM (about 31.93 GiB). | |
| 7 | + Not a Shoal compute job. | |
| 8 | +- Image: no container. Python 3.12.10; Git 2.53.0.windows.1. No Lean, | |
| 9 | + Mathlib build, Comparator, lean4export or Landrun was run for this audit. | |
| 10 | +- Commit: https://github.com/yang-mills-group/YM at | |
| 11 | + `319ecd5274241200b27bb5b143a59133fd670ea6`; package | |
| 12 | + `submissions/openai-20261028/`. Comparison target: | |
| 13 | + https://shoal.club/shoal/yang-mills-mass-gap at | |
| 14 | + `e6cb83f2a074d48e31a67e57d4ecb15b85e7275d`, captured before this route. | |
| 15 | +- Command (from route folder): | |
| 16 | + `python -X utf8 -m unittest -v test_audit` — exit 0, unittest wall time | |
| 17 | + 0.347 s, 12 tests, no skips. Tests were first run before `audit.py` existed: | |
| 18 | + exit 1 (`ModuleNotFoundError: No module named 'audit'`), then passed after | |
| 19 | + implementing the auditor. Includes known SHA-256 vectors, missing/changed | |
| 20 | + bytes, duplicate assertions/JSON keys, unsafe paths, a real symlink, all five | |
| 21 | + manifest schemas, empty/unknown schemas, bridge snapshot mapping and a | |
| 22 | + committed-Git-vs-dirty-worktree fixture. | |
| 23 | +- Command (from route folder): | |
| 24 | + `python -X utf8 .\audit.py --upstream ..\..\..\upstream-ym --shoal ..\.. --shoal-commit e6cb83f2a074d48e31a67e57d4ecb15b85e7275d --output audit-result.json` | |
| 25 | + — exit 0, auditor wall time 97.276812 s (not download/onboarding time). | |
| 26 | +- Command (from Shoal root, before the claim): | |
| 27 | + `python -X utf8 .\checks\challenge.py .` — exit 0, measured wall time | |
| 28 | + 73.6652145 s. Read its full source before running; no edits to checks. | |
| 29 | +- What it printed (verbatim verdict lines): | |
| 30 | + | |
| 31 | +```text | |
| 32 | +Ran 12 tests in 0.347s | |
| 33 | +OK | |
| 34 | + | |
| 35 | +primary_manifest_assertions=9746 | |
| 36 | +all_local_assertions=9784 hashes_checked=9784 unique_files=9703 mismatches=0 missing=0 | |
| 37 | +submission_files=9508 common=9508 identical=9507 changed=1 source_only=0 shoal_only=42 | |
| 38 | +changed_paths=["README.md"] | |
| 39 | +wall_seconds=97.276812 | |
| 40 | +Hash audit: PASS; tree differences are enumerated, not a Lean verdict. | |
| 41 | + | |
| 42 | +ok: 6 challenge files and the build configuration as approved; 9477 Lean files, 987586 lines, toolchain leanprover/lean4:v4.32.0 | |
| 43 | +``` | |
| 44 | + | |
| 45 | +Manifest assertion counts, independently read from data: | |
| 46 | + | |
| 47 | +| Manifest | Assertions | | |
| 48 | +|---|---:| | |
| 49 | +| october-import.json | 9,508 | | |
| 50 | +| package-files.json | 195 | | |
| 51 | +| review-imports.json | 43 | | |
| 52 | +| osreconstruction.json | 2 | | |
| 53 | +| os-bridge-excerpts.json | 36 | | |
| 54 | + | |
| 55 | +The first three sum to the previously reported 9,746; the other two add 38. | |
| 56 | +Duplicate references to the same path are separate checked assertions, not | |
| 57 | +additional unique files. No expected count was hardcoded as a pass condition. | |
| 58 | +`audit-result.json` includes the five manifest SHA-256s, the two README hashes | |
| 59 | +and every Shoal-only path/Git ID, so the whole inventory is inspectable. | |
| 60 | + | |
| 61 | +### Acquisition and comparison scope | |
| 62 | + | |
| 63 | +- Ordinary HTTPS clones repeatedly failed with TLS decryption/early-EOF errors; | |
| 64 | + certificate verification was never disabled. The upstream shallow clone | |
| 65 | + succeeded over HTTP/1.1 and its HEAD equals the requested full pin. | |
| 66 | +- Shoal was cloned as a partial clone, reusing identical objects from that | |
| 67 | + upstream clone through a local Git alternate. Missing non-film blobs were | |
| 68 | + recovered via the authenticated contents API at the pinned Shoal commit; | |
| 69 | + every recovered byte sequence was checked against its Git blob ID before | |
| 70 | + storing. Credentials stayed outside Git in an access-restricted local file; | |
| 71 | + requests used site-scoped process credentials, not global Git credentials. | |
| 72 | +- Sparse checkout omits `film/` promotion media. Their paths/Git IDs remain in | |
| 73 | + the committed inventory and in the Shoal-only list; no byte-hash claim is made | |
| 74 | + about these media. Every one of the 9,508 common submission paths was compared | |
| 75 | + using the pinned Shoal **Git object**, not filesystem text/newline conversion. | |
| 76 | +- The auditor is original code in this route and makes no network requests. | |
| 77 | + The upstream `scripts/verify.py` was neither run nor used as implementation. | |
| 78 | + | |
| 79 | +### Site checks (initial claim commit d453ffcb0597f34edb5b4fe66d2385b75e2d8c04) | |
| 80 | + | |
| 81 | +`challenge` and `build` were `success` with this exact description on both: | |
| 82 | + | |
| 83 | +```text | |
| 84 | +not run on this commit, which changes no file this check judges (its paths): the verdict of the commit it builds on stands, and the site counts it | |
| 85 | +``` | |
| 86 | + | |
| 87 | +`replay` was `pending`. These inherited successes are **not** a fresh test of | |
| 88 | +this Python auditor or an independent confirmation of the reported counts. | |
| 89 | +The final route-head status is to be read separately after pushing. | |
| 90 | + | |
| 91 | +### What was not checked | |
| 92 | + | |
| 93 | +- The historical ZIP itself is absent. Its `archive_sha256` was not checked; | |
| 94 | + manifest file hashes must not be presented as a verified archive hash. | |
| 95 | +- Historical external source paths in bridge metadata are checked against | |
| 96 | + local provenance snapshots, not against freshly fetched original repositories. | |
| 97 | +- No proof of correct adaptations, equivalent declarations, Lean correctness, | |
| 98 | + physical interpretation, uniqueness, or mass gap. `challenge` checks frozen | |
| 99 | + files and scans source; it does not establish any of these claims. | |
| 100 | +- No fresh Lean build or Comparator replay. Existing main has separate replay | |
| 101 | + concerns (issue #52); this audit neither fixes nor adjudicates them. | |
| 102 | +- No second party's independent implementation/review yet. Issue #7's closure | |
| 103 | + criterion is therefore still outstanding; no merge or adoption is claimed. | |
| 104 | +- Executed on Windows only. Portability tests on Linux/macOS were not run. | |
+220 −0 routes/beamnxw-v1-package-audit/audit-result.json added View file
| @@ -0,0 +1,220 @@ | ||
| 1 | +{ | |
| 2 | + "upstream_repository": "https://github.com/yang-mills-group/YM", | |
| 3 | + "upstream_commit": "319ecd5274241200b27bb5b143a59133fd670ea6", | |
| 4 | + "manifest_sha256": { | |
| 5 | + "october-import.json": "1ee2d290dfa6786ccd7888a4db7be48cbb55aad72a53e2533b2e1834b2ff1bb8", | |
| 6 | + "os-bridge-excerpts.json": "7ed6634cce1391173790959bbb2ad21a61022e2b7785b0eec9e6ad2d792d1f77", | |
| 7 | + "osreconstruction.json": "b9252bf5c5a3749127b8bcb6da1b1e8e94d1cc6641b6e9cffdaad724953f2a72", | |
| 8 | + "package-files.json": "dbfae791e08c90190d1e4d9f26ffb15ac6729ebe78ca59abaf72c4a51935b861", | |
| 9 | + "review-imports.json": "f1045a64c01149afb0c0c9d97714ded36e725373ce0f127a3e477e0584860507" | |
| 10 | + }, | |
| 11 | + "primary_manifest_assertions": 9746, | |
| 12 | + "hash_audit": { | |
| 13 | + "assertions": 9784, | |
| 14 | + "hashes_checked": 9784, | |
| 15 | + "unique_files": 9703, | |
| 16 | + "by_manifest": { | |
| 17 | + "october-import.json": 9508, | |
| 18 | + "os-bridge-excerpts.json": 36, | |
| 19 | + "osreconstruction.json": 2, | |
| 20 | + "package-files.json": 195, | |
| 21 | + "review-imports.json": 43 | |
| 22 | + }, | |
| 23 | + "mismatches": 0, | |
| 24 | + "missing": 0, | |
| 25 | + "problems": [] | |
| 26 | + }, | |
| 27 | + "comparison": { | |
| 28 | + "shoal_commit": "e6cb83f2a074d48e31a67e57d4ecb15b85e7275d", | |
| 29 | + "submission_files": 9508, | |
| 30 | + "shoal_tracked_files": 9550, | |
| 31 | + "common_files": 9508, | |
| 32 | + "identical_files": 9507, | |
| 33 | + "changed": [ | |
| 34 | + { | |
| 35 | + "path": "README.md", | |
| 36 | + "source_sha256": "5477aa6f388153d48125efa8810733fc4a2d05c9b685c7a19acd734436c28126", | |
| 37 | + "shoal_sha256": "b67dfaf4e35ceef845c4509eef52a972a600a8246047420f28b547ba453c6097" | |
| 38 | + } | |
| 39 | + ], | |
| 40 | + "source_only": [], | |
| 41 | + "shoal_only": [ | |
| 42 | + { | |
| 43 | + "path": ".gitignore", | |
| 44 | + "git_blob": "f56e23bd66f78707eafe64958f52cfd52e578a16" | |
| 45 | + }, | |
| 46 | + { | |
| 47 | + "path": "AGENTS.md", | |
| 48 | + "git_blob": "4451c33c94f3914a57a47c57e36f98148b9c9c09" | |
| 49 | + }, | |
| 50 | + { | |
| 51 | + "path": "KNOWN.before.md", | |
| 52 | + "git_blob": "968d5ea030fb5c4b6a22b4565e7229e77adfa2cd" | |
| 53 | + }, | |
| 54 | + { | |
| 55 | + "path": "KNOWN.md", | |
| 56 | + "git_blob": "8fea98773b24a871c908ab27cc5e4ec0c36407b6" | |
| 57 | + }, | |
| 58 | + { | |
| 59 | + "path": "README.zh.md", | |
| 60 | + "git_blob": "7418bbc0cf209d6d412309a5821cf8ea5f51f37b" | |
| 61 | + }, | |
| 62 | + { | |
| 63 | + "path": "UPSTREAM.md", | |
| 64 | + "git_blob": "95cb6e637a19906c552a4970662456f097e78466" | |
| 65 | + }, | |
| 66 | + { | |
| 67 | + "path": "checks/build.json", | |
| 68 | + "git_blob": "f74ce05987fa99cab452f4e819d713d1803497dc" | |
| 69 | + }, | |
| 70 | + { | |
| 71 | + "path": "checks/build.py", | |
| 72 | + "git_blob": "da845e571b8d74010ffe518577b14bc73e5f278f" | |
| 73 | + }, | |
| 74 | + { | |
| 75 | + "path": "checks/build.sbatch", | |
| 76 | + "git_blob": "4791ca57fe5271d983c72d6c9344b62aeeaea01e" | |
| 77 | + }, | |
| 78 | + { | |
| 79 | + "path": "checks/challenge.py", | |
| 80 | + "git_blob": "e4e1b7ddd3aeede0cbe2df044c02356b55c735a6" | |
| 81 | + }, | |
| 82 | + { | |
| 83 | + "path": "checks/challenge.sbatch", | |
| 84 | + "git_blob": "f357430d597eb00763571204f5e263d11602eac1" | |
| 85 | + }, | |
| 86 | + { | |
| 87 | + "path": "checks/frozen.json", | |
| 88 | + "git_blob": "229090b494a63b6f49ee4f43e028b1dc90c9c3f9" | |
| 89 | + }, | |
| 90 | + { | |
| 91 | + "path": "docker/README.md", | |
| 92 | + "git_blob": "c9cfa540aca8c9a293e3faccaf89d6de373d08cd" | |
| 93 | + }, | |
| 94 | + { | |
| 95 | + "path": "docker/build.sh", | |
| 96 | + "git_blob": "2e4e3aabf8810f1039da853c811cfff6adc48147" | |
| 97 | + }, | |
| 98 | + { | |
| 99 | + "path": "docker/lean.Dockerfile", | |
| 100 | + "git_blob": "06c9c9629815a9bdbe40f4080ddbad26d7e941e1" | |
| 101 | + }, | |
| 102 | + { | |
| 103 | + "path": "docs/checks/A5.md", | |
| 104 | + "git_blob": "d949b20063229eabf31b11b5b461245c247bbc12" | |
| 105 | + }, | |
| 106 | + { | |
| 107 | + "path": "docs/tables/import-graph.md", | |
| 108 | + "git_blob": "83dedae30753b5db328b2fe24cf01fd90b1696e8" | |
| 109 | + }, | |
| 110 | + { | |
| 111 | + "path": "docs/tables/unreached-modules-by-folder.tsv", | |
| 112 | + "git_blob": "44361591d3ce81452fd5f771da5c54f74b5626df" | |
| 113 | + }, | |
| 114 | + { | |
| 115 | + "path": "docs/tables/unreached-modules.tsv", | |
| 116 | + "git_blob": "95ece9d8d9f9c0843136c264a8fb189f9d9eda90" | |
| 117 | + }, | |
| 118 | + { | |
| 119 | + "path": "docs/tables/ym_import_graph.py", | |
| 120 | + "git_blob": "9888019938ad24c7ba78cd62bd2abaadf36cd2fc" | |
| 121 | + }, | |
| 122 | + { | |
| 123 | + "path": "examples/plaquette-2.2986/heatbath.cpp", | |
| 124 | + "git_blob": "01fe251968d164eebdb5e0f562b5173f823455be" | |
| 125 | + }, | |
| 126 | + { | |
| 127 | + "path": "examples/plaquette-2.2986/history.txt", | |
| 128 | + "git_blob": "d931b187c929d088fe458d0c457c90bde26b9337" | |
| 129 | + }, | |
| 130 | + { | |
| 131 | + "path": "examples/plaquette-2.2986/result.json", | |
| 132 | + "git_blob": "9a1bbbaebc1b4ac463fbfbd1753626c1de44ca22" | |
| 133 | + }, | |
| 134 | + { | |
| 135 | + "path": "film/explainer.en.jpg", | |
| 136 | + "git_blob": "8e45fc41fa4e029534df3f8bca0fba1ef0225151" | |
| 137 | + }, | |
| 138 | + { | |
| 139 | + "path": "film/explainer.en.mp4", | |
| 140 | + "git_blob": "7cc5a785db41db25e3ddb0562e5fbd2ac93c5e77" | |
| 141 | + }, | |
| 142 | + { | |
| 143 | + "path": "film/explainer.en.vtt", | |
| 144 | + "git_blob": "c161970b6ceb4460a532e0fbed9faadda56a3357" | |
| 145 | + }, | |
| 146 | + { | |
| 147 | + "path": "film/explainer.en.zh.vtt", | |
| 148 | + "git_blob": "21c951b9c3c92a5ca46cdbe142922967e50488b6" | |
| 149 | + }, | |
| 150 | + { | |
| 151 | + "path": "film/explainer.jpg", | |
| 152 | + "git_blob": "2f60ac765d447e0c43df92c3d5b6290fd56ee272" | |
| 153 | + }, | |
| 154 | + { | |
| 155 | + "path": "film/explainer.mp4", | |
| 156 | + "git_blob": "736651c96e64bf9901c6c68792b2de3dc8f4c754" | |
| 157 | + }, | |
| 158 | + { | |
| 159 | + "path": "film/poster.en.jpg", | |
| 160 | + "git_blob": "df5037e359e27016c3cb09e188261527946ac6d7" | |
| 161 | + }, | |
| 162 | + { | |
| 163 | + "path": "film/poster.jpg", | |
| 164 | + "git_blob": "2c3cfdd2ff9086e92974492ace58532c15d3ffe6" | |
| 165 | + }, | |
| 166 | + { | |
| 167 | + "path": "film/problem.en.mp4", | |
| 168 | + "git_blob": "3e83808708f83071e95c04c7bea8af73b5cf60af" | |
| 169 | + }, | |
| 170 | + { | |
| 171 | + "path": "film/problem.en.vtt", | |
| 172 | + "git_blob": "d90f68f0ce62025feca51da06cb3123e4c8bb46c" | |
| 173 | + }, | |
| 174 | + { | |
| 175 | + "path": "film/problem.en.zh.vtt", | |
| 176 | + "git_blob": "b70db1e59a5b58470c4520eb96362e7f021208bc" | |
| 177 | + }, | |
| 178 | + { | |
| 179 | + "path": "film/problem.mp4", | |
| 180 | + "git_blob": "9a571a73660c66a5ebf3c91b6d30c1a52d4c36f3" | |
| 181 | + }, | |
| 182 | + { | |
| 183 | + "path": "poster.webp", | |
| 184 | + "git_blob": "84e41b39191437c067c6ea92b56fd092256e292d" | |
| 185 | + }, | |
| 186 | + { | |
| 187 | + "path": "routes/oh-yeah-zzy-kimi-su2-plaquette/README.md", | |
| 188 | + "git_blob": "9b56bf1df35d7a453f9fb448d21c478630c9cc8b" | |
| 189 | + }, | |
| 190 | + { | |
| 191 | + "path": "routes/oh-yeah-zzy-kimi-su2-plaquette/RERUN.md", | |
| 192 | + "git_blob": "9d8e220f50fb5b0792e46369e739b3279c59b8f0" | |
| 193 | + }, | |
| 194 | + { | |
| 195 | + "path": "routes/smileqq-codex-s3-import-graph/README.md", | |
| 196 | + "git_blob": "f93435518870dcd9d9fea95e2b82127e6327e231" | |
| 197 | + }, | |
| 198 | + { | |
| 199 | + "path": "routes/smileqq-codex-s3-import-graph/RERUN.md", | |
| 200 | + "git_blob": "77de2cca0d7108b3bbb681257a6c880b74e9f951" | |
| 201 | + }, | |
| 202 | + { | |
| 203 | + "path": "routes/trial-ana-a5/README.md", | |
| 204 | + "git_blob": "f979f19725cc54fca48455d51904bd60584cf2eb" | |
| 205 | + }, | |
| 206 | + { | |
| 207 | + "path": "scienceslack.json", | |
| 208 | + "git_blob": "0c7c29f324a2e7e8ab0888232d830bd26af15089" | |
| 209 | + } | |
| 210 | + ] | |
| 211 | + }, | |
| 212 | + "unverified": [ | |
| 213 | + "Historical ZIP archive itself is not present; archive_sha256 not checked.", | |
| 214 | + "External original source repositories are not fetched; bridge source hashes check local provenance snapshots.", | |
| 215 | + "Shoal-only paths are inventoried by Git ID, not claimed byte-identical to submission.", | |
| 216 | + "No Lean build, Comparator, physical interpretation, uniqueness, or mass-gap proof.", | |
| 217 | + "Independent second-party reproduction remains required by issue #7." | |
| 218 | + ], | |
| 219 | + "wall_seconds": 97.276812 | |
| 220 | +} | |
+260 −0 routes/beamnxw-v1-package-audit/audit.py added View file
| @@ -0,0 +1,260 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +"""Independent V-1 byte audit. Standard library only; executes no package code. | |
| 3 | + | |
| 4 | +Exit 0: all covered local file-hash assertions match. Tree differences are | |
| 5 | +reported, not hidden or treated as proof failures. Exit 1: bad/missing hashes; | |
| 6 | +exit 2: unsupported/malformed input or unreadable Git objects. | |
| 7 | +""" | |
| 8 | +from __future__ import annotations | |
| 9 | + | |
| 10 | +import argparse | |
| 11 | +from collections import Counter | |
| 12 | +from dataclasses import dataclass | |
| 13 | +import hashlib | |
| 14 | +import json | |
| 15 | +import os | |
| 16 | +from pathlib import Path, PurePosixPath | |
| 17 | +import re | |
| 18 | +import subprocess | |
| 19 | +import sys | |
| 20 | +import time | |
| 21 | + | |
| 22 | +UPSTREAM_PIN = "319ecd5274241200b27bb5b143a59133fd670ea6" | |
| 23 | +MANIFESTS = {"package-files.json", "october-import.json", "review-imports.json", | |
| 24 | + "osreconstruction.json", "os-bridge-excerpts.json"} | |
| 25 | +PRIMARY = {"package-files.json", "october-import.json", "review-imports.json"} | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | +class Record: | |
| 30 | + manifest: str | |
| 31 | + path: str | |
| 32 | + expected: str | |
| 33 | + | |
| 34 | + | |
| 35 | +def safe_path(root: Path, relative: str) -> Path: | |
| 36 | + if (not isinstance(relative, str) or not relative or "\\" in relative | |
| 37 | + or ":" in relative or "\0" in relative or relative.startswith("/") | |
| 38 | + or any(p in {"", ".", ".."} for p in relative.split("/"))): | |
| 39 | + raise ValueError(f"Unsafe/noncanonical relative path: {relative!r}") | |
| 40 | + result = root | |
| 41 | + for part in PurePosixPath(relative).parts: | |
| 42 | + result = result / part | |
| 43 | + if result.is_symlink() or getattr(result, "is_junction", lambda: False)(): | |
| 44 | + raise ValueError(f"Link in audited path: {relative}") | |
| 45 | + if not result.resolve().is_relative_to(root.resolve()): | |
| 46 | + raise ValueError(f"Path leaves package: {relative}") | |
| 47 | + return result | |
| 48 | + | |
| 49 | + | |
| 50 | +def load_json(text: str): | |
| 51 | + def unique_pairs(pairs): | |
| 52 | + result = {} | |
| 53 | + for key, value in pairs: | |
| 54 | + if key in result: | |
| 55 | + raise ValueError(f"Duplicate JSON key: {key}") | |
| 56 | + result[key] = value | |
| 57 | + return result | |
| 58 | + return json.loads(text, object_pairs_hook=unique_pairs) | |
| 59 | + | |
| 60 | + | |
| 61 | +def parse_manifest(name: str, data: dict) -> list[Record]: | |
| 62 | + if name not in MANIFESTS or not isinstance(data, dict): | |
| 63 | + raise ValueError(f"Unsupported manifest: {name}") | |
| 64 | + records = [] | |
| 65 | + | |
| 66 | + def add(path, digest): | |
| 67 | + if not isinstance(path, str) or not isinstance(digest, str) or not re.fullmatch(r"[0-9a-f]{64}", digest): | |
| 68 | + raise ValueError(f"Invalid path/hash record in {name}") | |
| 69 | + records.append(Record(name, path, digest)) | |
| 70 | + | |
| 71 | + def rows(key): | |
| 72 | + entries = data.get(key) | |
| 73 | + if not isinstance(entries, list) or not entries or not all(isinstance(e, dict) for e in entries): | |
| 74 | + raise ValueError(f"Missing/empty/malformed {name}:{key}") | |
| 75 | + return entries | |
| 76 | + | |
| 77 | + if name == "package-files.json": | |
| 78 | + for path, digest in sorted(data.items()): | |
| 79 | + add(path, digest) | |
| 80 | + elif name == "os-bridge-excerpts.json": | |
| 81 | + sources = rows("sources") | |
| 82 | + for source in sources: | |
| 83 | + add(source.get("path"), source.get("sha256")) | |
| 84 | + for copy in rows("copies"): | |
| 85 | + original = copy.get("source") | |
| 86 | + # The historical absolute source path is NOT opened. Match it to | |
| 87 | + # the local snapshot explicitly identified in the same manifest. | |
| 88 | + candidates = [s for s in sources if isinstance(original, str) | |
| 89 | + and isinstance(s.get("source_path"), str) | |
| 90 | + and original.endswith("/" + s["source_path"])] | |
| 91 | + if len(candidates) != 1 or not isinstance(copy.get("copy"), str): | |
| 92 | + raise ValueError("Bridge source has no unique local snapshot mapping") | |
| 93 | + add(candidates[0]["path"], copy.get("source_sha256")) | |
| 94 | + add("checks/" + copy["copy"], copy.get("copy_sha256")) | |
| 95 | + else: | |
| 96 | + key = "included" if name == "october-import.json" else "files" | |
| 97 | + for entry in rows(key): | |
| 98 | + add(entry.get("path"), entry.get("sha256")) | |
| 99 | + if not records: | |
| 100 | + raise ValueError(f"No file-hash assertions in {name}") | |
| 101 | + return records | |
| 102 | + | |
| 103 | + | |
| 104 | +def digest_file(path: Path) -> str: | |
| 105 | + with path.open("rb") as stream: | |
| 106 | + return hashlib.file_digest(stream, "sha256").hexdigest() | |
| 107 | + | |
| 108 | + | |
| 109 | +def read_manifests(package: Path): | |
| 110 | + provenance = package / "provenance" | |
| 111 | + found = {p.relative_to(provenance).as_posix() for p in provenance.rglob("*.json")} | |
| 112 | + if found != MANIFESTS: | |
| 113 | + raise ValueError(f"Unexpected manifest inventory: missing={sorted(MANIFESTS-found)}, extra={sorted(found-MANIFESTS)}") | |
| 114 | + records, manifest_hashes = [], {} | |
| 115 | + for name in sorted(found): | |
| 116 | + path = safe_path(package, "provenance/" + name) | |
| 117 | + records.extend(parse_manifest(name, load_json(path.read_text(encoding="utf-8")))) | |
| 118 | + manifest_hashes[name] = digest_file(path) | |
| 119 | + return records, manifest_hashes | |
| 120 | + | |
| 121 | + | |
| 122 | +def check_records(package: Path, records: list[Record]): | |
| 123 | + counts = Counter() | |
| 124 | + checked, paths, problems = 0, set(), [] | |
| 125 | + for record in records: | |
| 126 | + path = safe_path(package, record.path) | |
| 127 | + counts[record.manifest] += 1 | |
| 128 | + paths.add(record.path) | |
| 129 | + if not path.is_file(): | |
| 130 | + problems.append({"kind": "missing", "manifest": record.manifest, "path": record.path}) | |
| 131 | + continue | |
| 132 | + actual = digest_file(path) | |
| 133 | + checked += 1 | |
| 134 | + if actual != record.expected: | |
| 135 | + problems.append({"kind": "mismatch", "manifest": record.manifest, "path": record.path, | |
| 136 | + "expected": record.expected, "actual": actual}) | |
| 137 | + return {"assertions": len(records), "hashes_checked": checked, | |
| 138 | + "unique_files": len(paths), "by_manifest": dict(sorted(counts.items())), | |
| 139 | + "mismatches": sum(p["kind"] == "mismatch" for p in problems), | |
| 140 | + "missing": sum(p["kind"] == "missing" for p in problems), "problems": problems} | |
| 141 | + | |
| 142 | + | |
| 143 | +def git_command(repo: Path): | |
| 144 | + return ["git", "-c", f"safe.directory={repo.resolve().as_posix()}", "-c", "core.fsmonitor=false", "-C", str(repo)] | |
| 145 | + | |
| 146 | + | |
| 147 | +def git(repo: Path, *args): | |
| 148 | + return subprocess.check_output(git_command(repo) + list(args), env=dict(os.environ, GIT_NO_LAZY_FETCH="1", GIT_TERMINAL_PROMPT="0")) | |
| 149 | + | |
| 150 | + | |
| 151 | +def git_tree(repo: Path, commit: str): | |
| 152 | + if not re.fullmatch(r"[0-9a-f]{40}", commit): | |
| 153 | + raise ValueError("Require a full, lowercase pinned Git commit ID") | |
| 154 | + entries = {} | |
| 155 | + for row in git(repo, "ls-tree", "-rz", "--full-tree", commit).split(b"\0"): | |
| 156 | + if not row: | |
| 157 | + continue | |
| 158 | + metadata, name = row.split(b"\t", 1) | |
| 159 | + mode, kind, oid = metadata.decode().split() | |
| 160 | + if kind != "blob" or mode not in {"100644", "100755"}: | |
| 161 | + raise ValueError(f"Non-regular tracked file in comparison: {name!r}") | |
| 162 | + entries[name.decode("utf-8")] = oid | |
| 163 | + return entries | |
| 164 | + | |
| 165 | + | |
| 166 | +def compare_submission(source: Path, repo: Path, commit: str): | |
| 167 | + tree = git_tree(repo, commit) | |
| 168 | + files = {} | |
| 169 | + for path in sorted(source.rglob("*")): | |
| 170 | + relative = path.relative_to(source).as_posix() | |
| 171 | + checked = safe_path(source, relative) | |
| 172 | + if checked.is_file(): | |
| 173 | + files[relative] = checked | |
| 174 | + if not files: | |
| 175 | + raise ValueError("Empty submission cannot pass a comparison") | |
| 176 | + common = sorted(files.keys() & tree.keys()) | |
| 177 | + changed, identical = [], 0 | |
| 178 | + process = subprocess.Popen(git_command(repo) + ["cat-file", "--batch"], stdin=subprocess.PIPE, | |
| 179 | + stdout=subprocess.PIPE, env=dict(os.environ, GIT_NO_LAZY_FETCH="1", GIT_TERMINAL_PROMPT="0")) | |
| 180 | + try: | |
| 181 | + for name in common: | |
| 182 | + oid = tree[name] | |
| 183 | + process.stdin.write((oid + "\n").encode()) | |
| 184 | + process.stdin.flush() | |
| 185 | + header = process.stdout.readline().decode().strip().split() | |
| 186 | + if len(header) != 3 or header[:2] != [oid, "blob"]: | |
| 187 | + raise ValueError(f"Pinned Git blob unavailable for {name}: {header}") | |
| 188 | + remaining, digest = int(header[2]), hashlib.sha256() | |
| 189 | + while remaining: | |
| 190 | + block = process.stdout.read(min(1 << 20, remaining)) | |
| 191 | + if not block: | |
| 192 | + raise ValueError(f"Truncated Git blob: {name}") | |
| 193 | + digest.update(block) | |
| 194 | + remaining -= len(block) | |
| 195 | + if process.stdout.read(1) != b"\n": | |
| 196 | + raise ValueError("Invalid Git batch separator") | |
| 197 | + source_hash, target_hash = digest_file(files[name]), digest.hexdigest() | |
| 198 | + if source_hash == target_hash: | |
| 199 | + identical += 1 | |
| 200 | + else: | |
| 201 | + changed.append({"path": name, "source_sha256": source_hash, "shoal_sha256": target_hash}) | |
| 202 | + process.stdin.close() | |
| 203 | + if process.wait(timeout=10) != 0: | |
| 204 | + raise ValueError("Git batch reader failed") | |
| 205 | + finally: | |
| 206 | + if process.poll() is None: | |
| 207 | + process.kill() | |
| 208 | + process.wait() | |
| 209 | + if not process.stdin.closed: | |
| 210 | + process.stdin.close() | |
| 211 | + process.stdout.close() | |
| 212 | + return {"shoal_commit": commit, "submission_files": len(files), "shoal_tracked_files": len(tree), | |
| 213 | + "common_files": len(common), "identical_files": identical, "changed": changed, | |
| 214 | + "source_only": sorted(files.keys() - tree.keys()), | |
| 215 | + "shoal_only": [{"path": name, "git_blob": tree[name]} for name in sorted(tree.keys() - files.keys())]} | |
| 216 | + | |
| 217 | + | |
| 218 | +def main(): | |
| 219 | + parser = argparse.ArgumentParser(description=__doc__) | |
| 220 | + parser.add_argument("--upstream", type=Path, required=True) | |
| 221 | + parser.add_argument("--shoal", type=Path, required=True) | |
| 222 | + parser.add_argument("--shoal-commit", required=True) | |
| 223 | + parser.add_argument("--output", type=Path, required=True) | |
| 224 | + args = parser.parse_args() | |
| 225 | + started = time.perf_counter() | |
| 226 | + try: | |
| 227 | + pin = git(args.upstream, "rev-parse", "HEAD").decode().strip() | |
| 228 | + if pin != UPSTREAM_PIN: | |
| 229 | + raise ValueError(f"Unexpected upstream commit: {pin}") | |
| 230 | + # Do not silently label altered provenance/submission bytes as this pin. | |
| 231 | + git(args.upstream, "diff", "--exit-code", "HEAD", "--", "submissions/openai-20261028") | |
| 232 | + package = args.upstream / "submissions/openai-20261028" | |
| 233 | + records, manifests = read_manifests(package) | |
| 234 | + counts = check_records(package, records) | |
| 235 | + comparison = compare_submission(package / "submission", args.shoal, args.shoal_commit) | |
| 236 | + primary_count = sum(count for name, count in counts["by_manifest"].items() if name in PRIMARY) | |
| 237 | + output = {"upstream_repository": "https://github.com/yang-mills-group/YM", "upstream_commit": pin, | |
| 238 | + "manifest_sha256": manifests, "primary_manifest_assertions": primary_count, | |
| 239 | + "hash_audit": counts, "comparison": comparison, | |
| 240 | + "unverified": ["Historical ZIP archive itself is not present; archive_sha256 not checked.", | |
| 241 | + "External original source repositories are not fetched; bridge source hashes check local provenance snapshots.", | |
| 242 | + "Shoal-only paths are inventoried by Git ID, not claimed byte-identical to submission.", | |
| 243 | + "No Lean build, Comparator, physical interpretation, uniqueness, or mass-gap proof.", | |
| 244 | + "Independent second-party reproduction remains required by issue #7."], | |
| 245 | + "wall_seconds": round(time.perf_counter() - started, 6)} | |
| 246 | + args.output.write_text(json.dumps(output, indent=2, ensure_ascii=False) + "\n", encoding="utf-8", newline="\n") | |
| 247 | + print(f"primary_manifest_assertions={primary_count}") | |
| 248 | + print(f"all_local_assertions={counts['assertions']} hashes_checked={counts['hashes_checked']} unique_files={counts['unique_files']} mismatches={counts['mismatches']} missing={counts['missing']}") | |
| 249 | + print(f"submission_files={comparison['submission_files']} common={comparison['common_files']} identical={comparison['identical_files']} changed={len(comparison['changed'])} source_only={len(comparison['source_only'])} shoal_only={len(comparison['shoal_only'])}") | |
| 250 | + print("changed_paths=" + json.dumps([r["path"] for r in comparison["changed"]])) | |
| 251 | + print(f"wall_seconds={output['wall_seconds']}") | |
| 252 | + print("Hash audit: " + ("FAIL" if counts["problems"] else "PASS") + "; tree differences are enumerated, not a Lean verdict.") | |
| 253 | + return 1 if counts["problems"] else 0 | |
| 254 | + except (OSError, ValueError, subprocess.SubprocessError) as error: | |
| 255 | + print(f"Audit input/error: {error}", file=sys.stderr) | |
| 256 | + return 2 | |
| 257 | + | |
| 258 | + | |
| 259 | +if __name__ == "__main__": | |
| 260 | + sys.exit(main()) | |
+121 −0 routes/beamnxw-v1-package-audit/test_audit.py added View file
| @@ -0,0 +1,121 @@ | ||
| 1 | +"""Small independent fixtures, not the upstream verifier or its tests.""" | |
| 2 | +import json | |
| 3 | +from pathlib import Path | |
| 4 | +import subprocess | |
| 5 | +import tempfile | |
| 6 | +import unittest | |
| 7 | + | |
| 8 | +import audit | |
| 9 | + | |
| 10 | +ABC = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" | |
| 11 | +EMPTY = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" | |
| 12 | + | |
| 13 | + | |
| 14 | +class AuditTests(unittest.TestCase): | |
| 15 | + def setUp(self): | |
| 16 | + self.temp = tempfile.TemporaryDirectory() | |
| 17 | + self.addCleanup(self.temp.cleanup) | |
| 18 | + self.root = Path(self.temp.name) | |
| 19 | + | |
| 20 | + def record(self, path="a.txt", sha=ABC): | |
| 21 | + return audit.Record("fixture", path, sha) | |
| 22 | + | |
| 23 | + def test_known_sha256_vectors_and_duplicate_assertions(self): | |
| 24 | + (self.root / "a.txt").write_bytes(b"abc") | |
| 25 | + (self.root / "empty").write_bytes(b"") | |
| 26 | + result = audit.check_records(self.root, [self.record(), self.record(), self.record("empty", EMPTY)]) | |
| 27 | + self.assertEqual((result["assertions"], result["hashes_checked"], result["unique_files"]), (3, 3, 2)) | |
| 28 | + self.assertEqual(result["problems"], []) | |
| 29 | + | |
| 30 | + def test_wrong_digest_and_missing_file_are_not_success(self): | |
| 31 | + (self.root / "a.txt").write_bytes(b"abc") | |
| 32 | + result = audit.check_records(self.root, [self.record(sha=EMPTY), self.record("missing")]) | |
| 33 | + self.assertEqual(result["hashes_checked"], 1) | |
| 34 | + self.assertEqual([p["kind"] for p in result["problems"]], ["mismatch", "missing"]) | |
| 35 | + | |
| 36 | + def test_reject_path_escape_and_windows_paths(self): | |
| 37 | + for path in ["../x", "/x", "C:/x", "a\\x", "a/../x", "./x", "a//x", ""]: | |
| 38 | + with self.subTest(path=path), self.assertRaises(ValueError): | |
| 39 | + audit.safe_path(self.root, path) | |
| 40 | + | |
| 41 | + def test_reject_symlink(self): | |
| 42 | + (self.root / "actual").write_bytes(b"abc") | |
| 43 | + try: | |
| 44 | + (self.root / "link").symlink_to(self.root / "actual") | |
| 45 | + except OSError: | |
| 46 | + self.skipTest("Symlink creation not permitted on this machine") | |
| 47 | + with self.assertRaises(ValueError): | |
| 48 | + audit.safe_path(self.root, "link") | |
| 49 | + | |
| 50 | + def test_package_manifest(self): | |
| 51 | + records = audit.parse_manifest("package-files.json", {"a.txt": ABC}) | |
| 52 | + self.assertEqual(records, [audit.Record("package-files.json", "a.txt", ABC)]) | |
| 53 | + | |
| 54 | + def test_all_structured_manifest_shapes(self): | |
| 55 | + for name, key in [("october-import.json", "included"), ("review-imports.json", "files"), ("osreconstruction.json", "files")]: | |
| 56 | + with self.subTest(name=name): | |
| 57 | + parsed = audit.parse_manifest(name, {key: [{"path": "a.txt", "sha256": ABC}]}) | |
| 58 | + self.assertEqual([(r.path, r.expected) for r in parsed], [("a.txt", ABC)]) | |
| 59 | + | |
| 60 | + def test_bridge_source_and_copy_hashes_are_both_checked(self): | |
| 61 | + data = {"sources": [{"path": "provenance/yang-mills/X.lean", "source_path": "X.lean", "sha256": ABC}], | |
| 62 | + "copies": [{"source": "/unavailable/yang-mills/X.lean", "copy": "X.lean", "source_sha256": ABC, "copy_sha256": EMPTY}]} | |
| 63 | + records = audit.parse_manifest("os-bridge-excerpts.json", data) | |
| 64 | + self.assertEqual([(r.path, r.expected) for r in records], [ | |
| 65 | + ("provenance/yang-mills/X.lean", ABC), ("provenance/yang-mills/X.lean", ABC), ("checks/X.lean", EMPTY)]) | |
| 66 | + | |
| 67 | + def test_external_bridge_source_without_snapshot_mapping_is_rejected(self): | |
| 68 | + data = {"sources": [{"path": "p", "source_path": "X", "sha256": ABC}], | |
| 69 | + "copies": [{"source": "/outside/Y", "copy": "Y", "source_sha256": ABC, "copy_sha256": ABC}]} | |
| 70 | + with self.assertRaises(ValueError): | |
| 71 | + audit.parse_manifest("os-bridge-excerpts.json", data) | |
| 72 | + | |
| 73 | + def test_empty_unknown_malformed_and_bad_hash_manifests_fail(self): | |
| 74 | + cases = [("package-files.json", {}), ("package-files.json", {"x": "not-a-hash"}), | |
| 75 | + ("review-imports.json", {"files": []}), ("new.json", {"x": ABC}), | |
| 76 | + ("review-imports.json", {"files": [{"path": "x"}]})] | |
| 77 | + for name, data in cases: | |
| 78 | + with self.subTest(name=name, data=data), self.assertRaises(ValueError): | |
| 79 | + audit.parse_manifest(name, data) | |
| 80 | + | |
| 81 | + def test_duplicate_json_keys_are_rejected(self): | |
| 82 | + with self.assertRaises(ValueError): | |
| 83 | + audit.load_json('{"a": 1, "a": 2}') | |
| 84 | + | |
| 85 | + def test_provenance_manifest_inventory_cannot_silently_skip_a_new_schema(self): | |
| 86 | + provenance = self.root / "provenance" | |
| 87 | + provenance.mkdir() | |
| 88 | + (provenance / "new.json").write_text('{"x":1}', encoding="utf-8") | |
| 89 | + with self.assertRaises(ValueError): | |
| 90 | + audit.read_manifests(self.root) | |
| 91 | + | |
| 92 | + def test_comparison_reads_pinned_git_objects_not_modified_worktree(self): | |
| 93 | + source = self.root / "submission" | |
| 94 | + source.mkdir() | |
| 95 | + (source / "same").write_bytes(b"abc") | |
| 96 | + (source / "changed").write_bytes(b"abc") | |
| 97 | + (source / "only-source").write_bytes(b"abc") | |
| 98 | + repo = self.root / "git-fixture" | |
| 99 | + repo.mkdir() | |
| 100 | + def git(*args): | |
| 101 | + return subprocess.check_output(["git", "-c", "core.hooksPath=" + str(self.root / "no-hooks"), "-C", str(repo), *args], stderr=subprocess.DEVNULL).decode().strip() | |
| 102 | + git("init", "-q") | |
| 103 | + git("config", "core.autocrlf", "false") | |
| 104 | + (repo / "same").write_bytes(b"abc") | |
| 105 | + (repo / "changed").write_bytes(b"") | |
| 106 | + (repo / "only-shoal").write_bytes(b"") | |
| 107 | + git("add", ".") | |
| 108 | + git("-c", "user.name=fixture", "-c", "user.email=fixture@example.invalid", "commit", "-qm", "fixture") | |
| 109 | + commit = git("rev-parse", "HEAD") | |
| 110 | + (repo / "same").write_bytes(b"uncommitted modification") | |
| 111 | + result = audit.compare_submission(source, repo, commit) | |
| 112 | + self.assertEqual(result["identical_files"], 1) | |
| 113 | + self.assertEqual(result["source_only"], ["only-source"]) | |
| 114 | + self.assertEqual([r["path"] for r in result["changed"]], ["changed"]) | |
| 115 | + self.assertEqual(result["changed"][0]["source_sha256"], ABC) | |
| 116 | + self.assertEqual(result["changed"][0]["shoal_sha256"], EMPTY) | |
| 117 | + self.assertEqual([r["path"] for r in result["shoal_only"]], ["only-shoal"]) | |
| 118 | + | |
| 119 | + | |
| 120 | +if __name__ == "__main__": | |
| 121 | + unittest.main(verbosity=2) | |