Skip to content

Commit f26fe4e

Browse files
committed
Reuse the pinned historical replay repair
The guide already includes the CrocSwap#7000/CrocSwap#7001 navigation from CrocSwap#7147/CrocSwap#7156. Reuse d2e54af from CrocSwap#7257, also verified in CrocSwap#7339, to run the historical audit at its inspected snapshot. Credit to unpaidmoon for the audit, Dennis for the historical gate, and Matarener for the pinned snapshot precedent.
1 parent f44e016 commit f26fe4e

4 files changed

Lines changed: 82 additions & 78 deletions

File tree

‎research/historical-selected-replay-gap/README.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ python3 -B scripts/research_package.py --package research/historical-selected-re
6969

7070
The direct command prints `PASS_HISTORICAL_SELECTED_REPLAY_GAP`. A registered
7171
replay prints `PASS_REGISTERED_RESEARCH_PACKAGE`. Both require Git history
72-
containing the two inspected commits.
72+
containing the two inspected commits and the source and manifest objects at
73+
`2485805a6d47f36ea83ddde6327d453ac82d44dc`. The verifier uses a temporary
74+
sparse checkout of that commit, checks the declared source digests there, and
75+
uses its planner and manifest inventory. The recorded rejections and selection
76+
therefore remain reproducible after later changes to the live Makefile or CI guide.
7377

7478
## Open next questions
7579

‎research/historical-selected-replay-gap/SOURCES.json‎

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"files": [
55
{
66
"path": "Makefile",
7-
"usage": "input",
7+
"usage": "provenance",
88
"git_blob": "0d683a06b9e7ee162496108ce9a7c5d2ee94fccf",
99
"sha256": "4f2d4f2dcd15139ec82658a975f85ed300897385f85799218539f4c8d60567da"
1010
},
1111
{
1212
"path": "certificates/partial-swap-network.json",
13-
"usage": "input",
13+
"usage": "provenance",
1414
"git_blob": "eccafa830c16170c36faf93045ddf1f638f7bcd4",
1515
"sha256": "4c0b9d37e1034b2076e30a70f8e514416298c462d9ee98bc87fe6556b14df786"
1616
},
@@ -22,7 +22,7 @@
2222
},
2323
{
2424
"path": "docs/ci-verification.md",
25-
"usage": "input",
25+
"usage": "provenance",
2626
"git_blob": "63ba3e9aa8bdc5e942b56e34244b92b16f854085",
2727
"sha256": "c7d3027e9ad8bcbff68f07aa9576b30fb2f3c76c44d876d40c7fdbf4a3e2228a"
2828
},
@@ -34,163 +34,163 @@
3434
},
3535
{
3636
"path": "research/clifford-state-performance/SOURCE.json",
37-
"usage": "input",
37+
"usage": "provenance",
3838
"git_blob": "6f98a0061a5104dfab82c9e806f819b41811f684",
3939
"sha256": "396d0f08df24952248140d5c65c51b8c902ef1c580892ff7ea182890530f67ee"
4040
},
4141
{
4242
"path": "research/community-batch1047-audit/CONTENT-COVERAGE.json",
43-
"usage": "input",
43+
"usage": "provenance",
4444
"git_blob": "5e0f92af463ec12c5e1dcc3effd44081a88af647",
4545
"sha256": "07a9daeaf2bda308a92e9a4684f13d5fc766c7772d74801fceb7f4599fdab226"
4646
},
4747
{
4848
"path": "research/community-batch1099-audit/CONTENT-COVERAGE.json",
49-
"usage": "input",
49+
"usage": "provenance",
5050
"git_blob": "9e13266bf85e627f1b7dc225e9530ea69fd2c7f0",
5151
"sha256": "421e1211fb1897c45621dc6801c276e53f2e6f335583c9c9049e535f87c0a3b1"
5252
},
5353
{
5454
"path": "research/community-batch932-audit/CONTENT-COVERAGE.json",
55-
"usage": "input",
55+
"usage": "provenance",
5656
"git_blob": "cc4d03eb59b9ab3f952735f7e88ff18c2d15d7af",
5757
"sha256": "184629cac91a5cfaca50330a88596008b824221433867dcf8117539c913c284a"
5858
},
5959
{
6060
"path": "research/community-batch970-audit/CONTENT-COVERAGE.json",
61-
"usage": "input",
61+
"usage": "provenance",
6262
"git_blob": "8b9f4111badf7de5d97684799560b55110e9da79",
6363
"sha256": "23188ed920e38a54006cb883e181585620821c63bf7e8b5e05d32719417cc37e"
6464
},
6565
{
6666
"path": "research/community-frontier741-audit/CONTENT-COVERAGE.json",
67-
"usage": "input",
67+
"usage": "provenance",
6868
"git_blob": "a5300d4e7a5381a3f443fc54c768ca6f0f236d68",
6969
"sha256": "3c820fb30e1b4d9bcfc6a7ab524375e5b2abd66b940af2c509146104f0bcd79c"
7070
},
7171
{
7272
"path": "research/community-frontier890-audit/CONTENT-COVERAGE.json",
73-
"usage": "input",
73+
"usage": "provenance",
7474
"git_blob": "d7ff6d777b01d69b6ce84caf25d3b7e4a4d2f211",
7575
"sha256": "6b185a9902652f893f3ebd8ada92d2f11b6de6533a9a4d11718a8a4496101128"
7676
},
7777
{
7878
"path": "research/community-hyperplane599-audit/SOURCE.json",
79-
"usage": "input",
79+
"usage": "provenance",
8080
"git_blob": "546f37d326d10a99910ae8f908e71ef768524d98",
8181
"sha256": "65099d764bfcc39bda5e4d9966783611b094c3522dbdd1435cd498d657a8ef8e"
8282
},
8383
{
8484
"path": "research/community-k492-audit/SOURCE.json",
85-
"usage": "input",
85+
"usage": "provenance",
8686
"git_blob": "e538481e4cb16ed936d3195f2dfb5b5a9ca0a76b",
8787
"sha256": "2c0f4fa5bc150d05658af2e7c54c4d2c337dd52b7efd3d69530ae73bcbdf452a"
8888
},
8989
{
9090
"path": "research/community-reconciliation92-audit/MANIFEST.json",
91-
"usage": "input",
91+
"usage": "provenance",
9292
"git_blob": "2a2e93685173d5f13cbb5abe740f5d90352e0228",
9393
"sha256": "5f501f3c118131e7d069f30ad77186eb2ad6961f9680a0ef105f4514ed41808a"
9494
},
9595
{
9696
"path": "research/partial-swap-digest/baseline.py",
97-
"usage": "input",
97+
"usage": "provenance",
9898
"git_blob": "a2f0190704db83bd8ef48e46e723c49b925804fe",
9999
"sha256": "81e9af92cdf38243a540cdcff2062778e449467848d444da37a9553c12ca4c34"
100100
},
101101
{
102102
"path": "research/r420-two-sided-basis/SOURCES.json",
103-
"usage": "input",
103+
"usage": "provenance",
104104
"git_blob": "5d718e11e62f4bcadecf1e02d6b61f87dbe190b0",
105105
"sha256": "d9810b0d139c5a1211fd2c1f0d142187cc1fca30026e1e7bc4f9ecfacf1596d1"
106106
},
107107
{
108108
"path": "research/skip-clones/SOURCE.json",
109-
"usage": "input",
109+
"usage": "provenance",
110110
"git_blob": "8d1bb3b9c8189e35e5d8bfdfa632d7473e8be0d5",
111111
"sha256": "0b68e63e35a97ce6b0cdb6e291b88ebaa8f2dd4afb70b2498f10ee89428258dc"
112112
},
113113
{
114114
"path": "research/split-skip/SOURCE.json",
115-
"usage": "input",
115+
"usage": "provenance",
116116
"git_blob": "2ab610b6ea2edd2865fda793ef2168b0c76afb4f",
117117
"sha256": "7c2b4646a3ecfef6f881da5c43e4bd0fa9a4d1b00548b8ab458d897e16735134"
118118
},
119119
{
120120
"path": "scripts/historical-ci-inputs/Makefile",
121-
"usage": "input",
121+
"usage": "provenance",
122122
"git_blob": "aff68409021c9d401a6f8013b9dfd7dbcc30f2a8",
123123
"sha256": "ea8830dd79da493e2d75baf753d733ff7efbcf2b4794afe41fae0ac8f3055646"
124124
},
125125
{
126126
"path": "scripts/historical-ci-inputs/ledger-batch932-run_isolated_tests.py",
127-
"usage": "input",
127+
"usage": "provenance",
128128
"git_blob": "65db599ab0b1dea0312c4ca048e0bd0f44c3736f",
129129
"sha256": "96ea543e6c707424afe247e77bd86c82152f90fc76a0773c4232145da5cdf8d1"
130130
},
131131
{
132132
"path": "scripts/historical-ci-inputs/ledger-batch932-test_isolated_test_runner.py",
133-
"usage": "input",
133+
"usage": "provenance",
134134
"git_blob": "34820a8f24678f918f4d0e7a35380d8013fc3495",
135135
"sha256": "628391b6abfbc8674ceec1751867a4392f2cc0b5b66886243e139af86cf355ac"
136136
},
137137
{
138138
"path": "scripts/historical-ci-inputs/ledger-batch970-verify_selected_result.py",
139-
"usage": "input",
139+
"usage": "provenance",
140140
"git_blob": "c755b76e0d44ba4917aa94440ebe54daefce5b2a",
141141
"sha256": "d7fd929726b326aeeaf0a3996475adec88eee9aac09ae0bebeeaa0bc1fc8f199"
142142
},
143143
{
144144
"path": "scripts/historical-ci-inputs/ledger-frontier741-ci-verification.md",
145-
"usage": "input",
145+
"usage": "provenance",
146146
"git_blob": "7f3c012504187917a728b9fe87043f0fc8cd006a",
147147
"sha256": "a854022e0e1d5d4db4d60e586be3ea56005013ef14a1fc06d02bc06e8529c4b0"
148148
},
149149
{
150150
"path": "scripts/historical-ci-inputs/partial-swap-context.json",
151-
"usage": "input",
151+
"usage": "provenance",
152152
"git_blob": "ad65114886bf34a4fd27e79f3be502389e689faa",
153153
"sha256": "833a9642f33aeab2ffea17ec9c6b82e0a953f90192b2c82e10bef21538dccba9"
154154
},
155155
{
156156
"path": "scripts/historical-ci-inputs/partial-swap-network.json",
157-
"usage": "input",
157+
"usage": "provenance",
158158
"git_blob": "52075f2463f60af5e16571347f24274fce73a1ea",
159159
"sha256": "f3c4be597b2f2136da4ae2cc80c7454f63c90aa01f84e5b8131cee4dd55de815"
160160
},
161161
{
162162
"path": "scripts/partial_swap/shared.py",
163-
"usage": "input",
163+
"usage": "provenance",
164164
"git_blob": "44a0e454c70f9c4b98e258b8443612e6a119904b",
165165
"sha256": "5a0646a50b9f3e8ea55168620a78e8853b0ab810517cefc8cfb8696aedee278a"
166166
},
167167
{
168168
"path": "scripts/replay_historical_check.py",
169-
"usage": "input",
169+
"usage": "provenance",
170170
"git_blob": "1e92fff2782970ef71378f594f2350d245a4db26",
171171
"sha256": "5467619c78183d3adc82b0cb55af28e5c1a01fca2b0588677816244b53e2bafd"
172172
},
173173
{
174174
"path": "scripts/research_package.py",
175-
"usage": "input",
175+
"usage": "provenance",
176176
"git_blob": "091b4c8f58bac9a9580d76025b887dc5c873d05f",
177177
"sha256": "e1256016e7f51827d04fa2179255989f639ae1d97afaa9c16265f85a0c6abd70"
178178
},
179179
{
180180
"path": "scripts/run_isolated_tests.py",
181-
"usage": "input",
181+
"usage": "provenance",
182182
"git_blob": "a96ab35b315ce492e7fbbfd6c5ae211aa066b541",
183183
"sha256": "49eb56dd0fc0d8d8ffdb209970a7adf2176223580646f575d5c22e59543b381c"
184184
},
185185
{
186186
"path": "scripts/verify_selected_result.py",
187-
"usage": "input",
187+
"usage": "provenance",
188188
"git_blob": "6882a4700e410dec569b51ae2eaf1a19cc019195",
189189
"sha256": "d6b305eac5b9bdb8172c469ad30a1655a60fa0aceac8b1bf610e1b73f51babd8"
190190
},
191191
{
192192
"path": "tests/test_isolated_test_runner.py",
193-
"usage": "input",
193+
"usage": "provenance",
194194
"git_blob": "343b24abf6719b81805eba5a84c74e57634c8288",
195195
"sha256": "3a5470d0b139828b90e19bf9583ddeafcd69f8e34f2824664eb3a2958a52e34d"
196196
}

‎research/historical-selected-replay-gap/VERIFY.json‎

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,7 @@
44
"python": "3.12",
55
"requirements": [],
66
"inputs": [
7-
"Makefile",
8-
"certificates/partial-swap-network.json",
9-
"docs/ci-verification.md",
10-
"research/clifford-state-performance/SOURCE.json",
11-
"research/community-batch1047-audit/CONTENT-COVERAGE.json",
12-
"research/community-batch1099-audit/CONTENT-COVERAGE.json",
13-
"research/community-batch932-audit/CONTENT-COVERAGE.json",
14-
"research/community-batch970-audit/CONTENT-COVERAGE.json",
15-
"research/community-frontier741-audit/CONTENT-COVERAGE.json",
16-
"research/community-frontier890-audit/CONTENT-COVERAGE.json",
17-
"research/community-hyperplane599-audit/SOURCE.json",
18-
"research/community-k492-audit/SOURCE.json",
19-
"research/community-reconciliation92-audit/MANIFEST.json",
20-
"research/partial-swap-digest/baseline.py",
21-
"research/r420-two-sided-basis/SOURCES.json",
22-
"research/skip-clones/SOURCE.json",
23-
"research/split-skip/SOURCE.json",
24-
"scripts/historical-ci-inputs/Makefile",
25-
"scripts/historical-ci-inputs/ledger-batch932-run_isolated_tests.py",
26-
"scripts/historical-ci-inputs/ledger-batch932-test_isolated_test_runner.py",
27-
"scripts/historical-ci-inputs/ledger-batch970-verify_selected_result.py",
28-
"scripts/historical-ci-inputs/ledger-frontier741-ci-verification.md",
29-
"scripts/historical-ci-inputs/partial-swap-context.json",
30-
"scripts/historical-ci-inputs/partial-swap-network.json",
31-
"scripts/partial_swap/shared.py",
32-
"scripts/replay_historical_check.py",
33-
"scripts/research_package.py",
34-
"scripts/run_isolated_tests.py",
35-
"scripts/verify_selected_result.py",
36-
"tests/test_isolated_test_runner.py"
7+
"scripts/research_package.py"
378
],
389
"commands": [
3910
{

‎research/historical-selected-replay-gap/verify.py‎

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
"""
77
import hashlib
88
import importlib.util
9+
import json
910
import subprocess
1011
import sys
12+
import tempfile
1113
from pathlib import Path
1214

1315
ROOT = Path(__file__).resolve().parents[2]
@@ -61,31 +63,47 @@ def require(ok, message):
6163
raise SystemExit(message)
6264

6365

64-
def load_checker():
65-
path = ROOT / "scripts/replay_historical_check.py"
66-
spec = importlib.util.spec_from_file_location("historical_selected_replay_gap_checker", path)
66+
def load_module(path):
67+
spec = importlib.util.spec_from_file_location(path.stem, path)
6768
module = importlib.util.module_from_spec(spec)
6869
spec.loader.exec_module(module)
6970
return module
7071

7172

73+
def checkout_snapshot(snapshot, sources, runner, env):
74+
paths = [runner.canonical_relative_path(row["path"]) for row in sources["files"]]
75+
git = ["git", "-c", "maintenance.auto=false", "-c", "gc.auto=0",
76+
"-c", "core.autocrlf=false"]
77+
subprocess.run([*git, "clone", "--quiet", "--shared", "--no-tags", "--no-checkout",
78+
"--", str(ROOT), str(snapshot)], cwd=ROOT, env=env, check=True)
79+
subprocess.run([*git, "update-ref", "--no-deref", "HEAD", INSPECTED],
80+
cwd=snapshot, env=env, check=True)
81+
# The pinned planner reads omitted manifests from the sparse HEAD/index.
82+
patterns = "".join(f"/{path.as_posix()}\n" for path in paths)
83+
subprocess.run([*git, "sparse-checkout", "set", "--no-cone", "--stdin"],
84+
cwd=snapshot, env=env, input=patterns.encode("utf-8"), check=True)
85+
subprocess.run([*git, "read-tree", "-mu", "HEAD"], cwd=snapshot, env=env, check=True)
86+
for path, row in zip(paths, sources["files"], strict=True):
87+
require(hashlib.sha256((snapshot / path).read_bytes()).hexdigest() == row["sha256"],
88+
"historical checkout source digest changed: " + path.as_posix())
89+
90+
7291
def entries(checker):
7392
for name, config in checker.CONFIG.items():
7493
for entry in [config, *config.get("additional_inputs", [])]:
7594
yield name, entry
7695

7796

78-
def reject(checker, entry):
97+
def reject(root, checker, entry):
7998
try:
80-
checker.authenticated_input(ROOT, entry)
99+
checker.authenticated_input(root, entry)
81100
except ValueError as exc:
82101
return str(exc)
83102
raise SystemExit("historical input was admitted: " + entry["path"])
84103

85104

86-
def main():
87-
require(not sys.flags.optimize, "assertions must stay enabled")
88-
checker = load_checker()
105+
def check_snapshot(root, env):
106+
checker = load_module(root / "scripts/replay_historical_check.py")
89107
selected = [entry for name, entry in entries(checker)
90108
if name == "tooling-ledger" and entry["path"] == SELECTED_PATH]
91109
require(len(selected) == 1, "selected-result checker overlay is not unique")
@@ -94,44 +112,55 @@ def main():
94112
require(entry["accepted_live_sha256"] == [SELECTED_ACCEPTED],
95113
"accepted selected-checker successors changed")
96114
frozen = (checker.INPUTS / entry["input"]).read_bytes()
97-
live = (ROOT / SELECTED_PATH).read_bytes()
115+
live = (root / SELECTED_PATH).read_bytes()
98116
require(hashlib.sha256(frozen).hexdigest() == SELECTED_PIN, "frozen selected checker bytes changed")
99117
require(hashlib.sha256(live).hexdigest() == SELECTED_LIVE, "live selected checker digest changed")
100118
require(SELECTED_LIVE not in (SELECTED_PIN, SELECTED_ACCEPTED), "live checker was already admitted")
101119
# The recorded pin would pass the same membership test. The failure is the
102120
# live successor, not a broken comparison.
103121
require(SELECTED_PIN in (SELECTED_PIN, *entry["accepted_live_sha256"]),
104122
"pin membership control failed")
105-
require(reject(checker, entry) == REJECTIONS[SELECTED_PATH][1],
123+
require(reject(root, checker, entry) == REJECTIONS[SELECTED_PATH][1],
106124
"selected checker rejection text changed")
107125

108126
counts = {path: 0 for path in REJECTIONS}
109127
messages = {}
110128
for _name, item in entries(checker):
111129
if item["path"] not in REJECTIONS:
112130
continue
113-
message = reject(checker, item)
131+
message = reject(root, checker, item)
114132
counts[item["path"]] += 1
115133
messages.setdefault(item["path"], message)
116134
for path, (count, message) in REJECTIONS.items():
117135
require(counts[path] == count, "rejection count changed for " + path)
118136
require(messages[path] == message, "rejection text changed for " + path)
119137
require(sum(counts.values()) == 19, "rejection total changed")
120138
ci = [item for _name, item in entries(checker) if item["path"] == CI_PATH]
121-
require(len(ci) == 1 and hashlib.sha256((ROOT / CI_PATH).read_bytes()).hexdigest() == CI_LIVE,
139+
require(len(ci) == 1 and hashlib.sha256((root / CI_PATH).read_bytes()).hexdigest() == CI_LIVE,
122140
"selected CI note digest changed")
123141

124142
diff = subprocess.check_output(
125-
["git", "diff", "--name-only", PARENT, INSPECTED], cwd=ROOT, text=True)
143+
["git", "diff", "--name-only", PARENT, INSPECTED], cwd=root, env=env, text=True)
126144
changed = sorted(name for name in diff.splitlines() if name)
127145
require(changed == CHANGED, "inspected commit diff changed")
128-
sys.path.insert(0, str(ROOT / "scripts"))
129-
from research_package import plan_details
130-
details = plan_details(ROOT, set(changed))
146+
planner = load_module(root / "scripts/research_package.py")
147+
details = planner.plan_details(root, set(changed))
131148
require([row["package"] for row in details] == PLAN_PACKAGES, "helper plan selection changed")
132149
matched = {name for row in details for names in row["causes"].values() for name in names}
133150
require(sorted(set(changed) - matched) == UNMATCHED, "unmatched plan paths changed")
134-
require(plan_details(ROOT, set()) == [], "empty change set selected a package")
151+
require(planner.plan_details(root, set()) == [], "empty change set selected a package")
152+
153+
154+
def main():
155+
require(not sys.flags.optimize, "assertions must stay enabled")
156+
sources = json.loads(Path(__file__).with_name("SOURCES.json").read_bytes())
157+
require(sources["base_commit"] == INSPECTED, "historical checkout base changed")
158+
runner = load_module(ROOT / "scripts/research_package.py")
159+
env = runner.git_source_env()
160+
with tempfile.TemporaryDirectory(prefix="historical-selected-replay-") as temporary:
161+
snapshot = Path(temporary) / "snapshot"
162+
checkout_snapshot(snapshot, sources, runner, env)
163+
check_snapshot(snapshot, env)
135164
print("PASS_HISTORICAL_SELECTED_REPLAY_GAP")
136165
print("selected_checker_live=" + SELECTED_LIVE)
137166
print("rejections=19 distinct_paths=7 plan_packages=9")

0 commit comments

Comments
 (0)