Skip to content

Commit eedf6d3

Browse files
committed
record(perf): step 5 — the owner's ratified design constants
Records the five design constants the owner chose, bound to the step 4 identity, and records nothing else. q 19/20 committed as [19, 20] M 2 committed as [2, 1] R_runs 5 N_ladder [5, 15, 45], the last rung being the mandatory stop G 1/10 committed as [1, 10] bound policy digest c3068ed7fa880a7083866ead25fe8bf65c87889d242d8af1f7eee01582cd5cbf bound harness digest 562a7f7232dad2f4c79c6adfe0e1e7e25680b4b6f3444d54824bf0405e3c14b3 Rationals are reduced integer pairs and counts are plain integers, so no reader has to decide whether 15 means the integer or the pair. There is no N_max: a second field holding 45 would be a duplicate free to drift. Deliberately absent: A_abs, R_rel, a selected N, any measurement output. Those are fitted rather than chosen, no admissible fitting corpus exists, and no measurement is authorised. The schema is enumerated by a control, so there is no key for one to arrive under. Four controls, both platforms: constants-artifact-shape the permitted schema and nothing else; bool excluded explicitly, since in Python a bool is an int constants-accepted-by-policy the frozen DesignConstants.from_committed() accepts them and as_committed() round-trips exactly. The ranges are NOT re-stated here: a second copy of them would only prove the two copies agree, so the implementation under freeze is the judge of its own constants constants-bound-to-freeze both digests equal what step 4 froze, and the harness digest equals the live one constants-no-empirical a second net whose forbidden names are derived from what Envelope serialises. No mutation isolates it, because the schema refuses every route one check earlier, and that is recorded rather than counted as coverage Fifteen mutations, each declaring in advance which control must catch it, scored only on a FAIL line from that control. The count is not the claim. ratified_by records "owner" and the repository cannot check that. It is an attribution, not a proof, in the same sense the Round 7 reading's withdrawn "checkable" claim was not. What is established is the binding: these constants are recorded against an implementation whose bytes are frozen and independently recomputable. No policy code change, no harness change, no measurement. The step 4 freeze artifact is untouched and the harness digest is unmoved. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CYLNQy6tLXqsV1CbuNqsSb
1 parent 2a037b8 commit eedf6d3

4 files changed

Lines changed: 353 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,6 +2954,11 @@ jobs:
29542954
# artifact outright if it ever grows a field that is not identity.
29552955
- name: Calibration policy freeze controls (step 4 digest identity)
29562956
run: python tests/test_calibration_freeze.py
2957+
# Step 5 records the five constants the owner chose, bound to the step 4
2958+
# identity. The frozen implementation is the judge of its own ranges, so
2959+
# these controls hand it the committed pairs rather than re-stating them.
2960+
- name: Calibration design constants controls (step 5 ratified values)
2961+
run: python tests/test_calibration_constants.py
29572962
# Plan mode builds the arms, preflights THOSE bytes, freezes their
29582963
# identities and fixes the execution order — then returns before the
29592964
# timing function is reachable. Linux only: the arms are ELF binaries.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"artifact": "p022-263a-calibration-design-constants",
3+
"bound_measurement_harness_digest": "562a7f7232dad2f4c79c6adfe0e1e7e25680b4b6f3444d54824bf0405e3c14b3",
4+
"bound_policy_implementation_digest": "c3068ed7fa880a7083866ead25fe8bf65c87889d242d8af1f7eee01582cd5cbf",
5+
"constants": {
6+
"G": [
7+
1,
8+
10
9+
],
10+
"M": [
11+
2,
12+
1
13+
],
14+
"N_ladder": [
15+
5,
16+
15,
17+
45
18+
],
19+
"R_runs": 5,
20+
"q": [
21+
19,
22+
20
23+
]
24+
},
25+
"ratified_by": "owner"
26+
}

docs/notes/p022-263a-calibration-policy-proposal.md

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
Status:
55
MECHANISM RATIFIED.
66
STEPS 1-3 COMPLETE.
7-
STEP 4 DIGEST FREEZE TAKEN, PENDING OWNER ACCEPTANCE.
8-
NO DESIGN CONSTANT VALUES RATIFIED.
7+
STEP 4 DIGEST FREEZE ACCEPTED.
8+
STEP 5 DESIGN CONSTANTS RATIFIED BY THE OWNER AND RECORDED.
9+
NO EMPIRICAL CONSTANT IS FITTED.
910
NO NUMERIC FITTING CORPUS EXISTS.
1011
NO TRAINING OR VALIDATION MEASUREMENT AUTHORISED.
1112
```
@@ -26,7 +27,7 @@ where the value was chosen by whoever was holding the pen.
2627

2728
No clock authority is claimed or implied. No measurement is proposed here.
2829

29-
## Step 4 — the digest freeze, taken
30+
## Step 4 — the digest freeze, accepted
3031

3132
`docs/evidence/calibration/p022-263a-policy-freeze.json` records **which bytes the
3233
policy is**, and nothing else. It carries no design constant, no fitted constant
@@ -102,6 +103,71 @@ now reads the objects themselves, and the one claim shallowness genuinely blocks
102103
ancestry — says so in its own message instead of reading as a provenance break.
103104
The CI job that runs these controls therefore checks out with full history.
104105

106+
## Step 5 — the design constants, chosen by the owner
107+
108+
`docs/evidence/calibration/p022-263a-design-constants.json` records the five
109+
constants and nothing else. They were **chosen by the owner**, which is the whole
110+
point of the step: a constant this repository picked for itself would be a knob
111+
wearing a ratification.
112+
113+
| constant | committed form | value |
114+
|---|---|---|
115+
| `q` | `[19, 20]` | 19/20 |
116+
| `M` | `[2, 1]` | 2 |
117+
| `R_runs` | `5` | 5 |
118+
| `N_ladder` | `[5, 15, 45]` | rungs 5, 15, 45, stopping at 45 |
119+
| `G` | `[1, 10]` | 1/10 |
120+
121+
Rationals are committed as reduced integer pairs and counts as plain integers,
122+
which is the separation revision 4 introduced so that no reader has to decide
123+
whether `15` means the integer or the pair. There is no `N_max`: the ladder's last
124+
rung **is** the mandatory stop, and a second field holding 45 would be a duplicate
125+
free to drift.
126+
127+
The artifact binds both identities: `policy_implementation_digest c3068ed7fa88…`
128+
and `measurement_harness_digest 562a7f7232da…`. Constants bound to an
129+
implementation other than the frozen one are constants for a policy nobody
130+
reviewed.
131+
132+
**What is deliberately absent.** No `A_abs`, no `R_rel`, no selected `N`, no
133+
measurement output. Those are fitted rather than chosen, no admissible fitting
134+
corpus exists, and no measurement is authorised. The artifact's schema is
135+
enumerated by a control, so there is no key for one to arrive under.
136+
137+
**A provenance limit, stated rather than implied.** `ratified_by` records `owner`,
138+
and the repository **cannot check that**. It is an attribution, not a proof, in
139+
exactly the sense the Round 7 reading's withdrawn "checkable" claim was not. What
140+
the repository does establish is the binding: these constants are recorded against
141+
a policy implementation whose bytes are frozen and independently recomputable, so
142+
whatever is later fitted is fitted under constants that were fixed first.
143+
144+
### The controls
145+
146+
`tests/test_calibration_constants.py` runs four on every CI run, both platforms:
147+
148+
- **`constants-artifact-shape`** enumerates the permitted schema, requires rationals
149+
as reduced integer pairs and counts as exact integers, and excludes `bool`
150+
explicitly, since in Python a `bool` is an `int`.
151+
- **`constants-accepted-by-policy`** hands the committed pairs to the frozen
152+
`DesignConstants.from_committed()` and requires an exact round trip through
153+
`as_committed()`. It deliberately does **not** re-state the ranges — `0 < q < 1`,
154+
`M > 1`, `G >= 0`, `R_runs >= 2`, a strictly increasing ladder — because a second
155+
copy of those rules would only prove the two copies agree. The implementation
156+
under freeze is the judge of its own constants.
157+
- **`constants-bound-to-freeze`** requires both recorded digests to equal what step
158+
4 froze, and the harness digest to equal the live one.
159+
- **`constants-no-empirical`** is a second net whose forbidden names are *derived*
160+
from what `Envelope` serialises, so it grows if the policy grows another
161+
empirical field. **No mutation isolates it**, because the exact schema refuses
162+
every smuggling route one check earlier, and that is recorded rather than
163+
counted as coverage.
164+
165+
Fifteen mutations, each declaring in advance which control must catch it and
166+
scored only on a `FAIL` line from that control. The count is not the claim: the
167+
claim is that every mutation has a named expected catcher and is scored by output
168+
rather than by a non-zero exit code, so the campaign can grow without the
169+
guarantee changing shape.
170+
105171
## Revision 5 — what the owner's fourth review changed
106172

107173
Revision 4 was ruled **CHANGES REQUIRED before the step 4 freeze**, on one P0 in
Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
#!/usr/bin/env python3
2+
"""#263-A calibration policy — step 5, the ratified design constants.
3+
4+
Step 5 records the five constants the owner chose, bound to the step 4 identity.
5+
It records nothing else. No `A_abs`, no `R_rel`, no selected `N`, no measurement
6+
output: those are empirical, they do not exist yet, and an artifact that made
7+
room for them would be step 7 arriving with step 5's paperwork.
8+
9+
constants-artifact-shape the artifact is five design constants and two bindings
10+
constants-accepted-by-policy the frozen implementation accepts them and round-trips
11+
constants-bound-to-freeze the bindings are the step 4 digests, not lookalikes
12+
constants-no-empirical no name the policy uses for a fitted quantity appears
13+
14+
`constants-accepted-by-policy` is the one that matters. It does not re-implement
15+
the ranges — `0 < q < 1`, `M > 1`, `G >= 0`, `R_runs >= 2`, a strictly increasing
16+
ladder — because a second copy of those rules would only ever prove the two copies
17+
agree. It hands the committed pairs to the frozen `DesignConstants.from_committed()`
18+
and lets the implementation under freeze be the judge.
19+
20+
Failures print `FAIL[<check>]: <detail>`; nothing stops at the first one.
21+
22+
Run: python tests/test_calibration_constants.py
23+
"""
24+
25+
from __future__ import annotations
26+
27+
import json
28+
import sys
29+
from fractions import Fraction
30+
from pathlib import Path
31+
32+
ROOT = Path(__file__).resolve().parent.parent
33+
sys.path.insert(0, str(ROOT / "scripts"))
34+
sys.path.insert(0, str(ROOT / "scripts" / "calibration"))
35+
36+
import perf_baseline as pb # noqa: E402
37+
import policy as pol # noqa: E402
38+
39+
CONSTANTS_ARTIFACT = ROOT / "docs" / "evidence" / "calibration" / "p022-263a-design-constants.json"
40+
FREEZE_ARTIFACT = ROOT / "docs" / "evidence" / "calibration" / "p022-263a-policy-freeze.json"
41+
42+
ARTIFACT_NAME = "p022-263a-calibration-design-constants"
43+
RATIONALS = ("q", "M", "G")
44+
COUNTS = ("R_runs",)
45+
LADDERS = ("N_ladder",)
46+
47+
_FAILURES: list[tuple[str, str]] = []
48+
_PASSES: list[str] = []
49+
50+
51+
def fail(check: str, detail: str) -> None:
52+
_FAILURES.append((check, detail))
53+
print(f"FAIL[{check}]: {detail}")
54+
55+
56+
def ok(check: str, detail: str = "") -> None:
57+
_PASSES.append(check)
58+
print(f"ok[{check}]: {detail}" if detail else f"ok[{check}]")
59+
60+
61+
def _exact_int(value: object) -> bool:
62+
"""`bool` is excluded: in Python a bool IS an int, and round 9 was lost to that."""
63+
return isinstance(value, int) and not isinstance(value, bool)
64+
65+
66+
def _load(path: Path, check: str) -> dict[str, object] | None:
67+
if not path.exists():
68+
fail(check, f"{path.relative_to(ROOT).as_posix()} does not exist")
69+
return None
70+
try:
71+
loaded = json.loads(path.read_text(encoding="utf-8"))
72+
except (OSError, ValueError) as exc:
73+
fail(check, f"{path.name} could not be read as JSON: {exc}")
74+
return None
75+
if not isinstance(loaded, dict):
76+
fail(check, f"{path.name} is a {type(loaded).__name__}, not an object")
77+
return None
78+
return loaded
79+
80+
81+
def control_artifact_shape(art: dict[str, object]) -> None:
82+
permitted = {"artifact", "bound_measurement_harness_digest",
83+
"bound_policy_implementation_digest", "constants", "ratified_by"}
84+
problems: list[str] = []
85+
86+
unexpected = sorted(set(art) - permitted)
87+
missing = sorted(permitted - set(art))
88+
if unexpected:
89+
problems.append(f"keys step 5 does not permit: {unexpected}; the empirical "
90+
"constants are fitted, not chosen, and have no home here")
91+
if missing:
92+
problems.append(f"keys step 5 requires: {missing}")
93+
if art.get("artifact") != ARTIFACT_NAME:
94+
problems.append("artifact is not the frozen literal")
95+
if art.get("ratified_by") != "owner":
96+
problems.append("ratified_by is not 'owner'; a constant this repository chose "
97+
"for itself is the one thing step 5 must never record")
98+
for key in ("bound_policy_implementation_digest", "bound_measurement_harness_digest"):
99+
value = art.get(key)
100+
if not (isinstance(value, str) and len(value) == 64
101+
and all(ch in "0123456789abcdef" for ch in value)):
102+
problems.append(f"{key} is not 64 lowercase hex characters")
103+
104+
constants = art.get("constants")
105+
if not isinstance(constants, dict):
106+
problems.append("constants is not an object")
107+
else:
108+
expected = set(RATIONALS) | set(COUNTS) | set(LADDERS)
109+
if set(constants) != expected:
110+
problems.append(f"constants names {sorted(constants)}, not {sorted(expected)}")
111+
for name in RATIONALS:
112+
pair = constants.get(name)
113+
if not (isinstance(pair, list) and len(pair) == 2 and all(_exact_int(v) for v in pair)):
114+
problems.append(f"{name} is not a pair of exact integers; a rational is "
115+
"committed as a reduced pair, never as a float or a "
116+
"decimal string")
117+
for name in COUNTS:
118+
if not _exact_int(constants.get(name)):
119+
problems.append(f"{name} is not an exact integer count")
120+
for name in LADDERS:
121+
ladder = constants.get(name)
122+
if not (isinstance(ladder, list) and ladder and all(_exact_int(v) for v in ladder)):
123+
problems.append(f"{name} is not a non-empty list of exact integers")
124+
125+
if problems:
126+
fail("constants-artifact-shape", "; ".join(problems))
127+
else:
128+
ok("constants-artifact-shape",
129+
f"{len(permitted)} permitted keys and no others; {len(RATIONALS)} rationals as "
130+
f"reduced pairs, {len(COUNTS)} count and {len(LADDERS)} ladder as exact integers")
131+
132+
133+
def control_accepted_by_policy(art: dict[str, object]) -> None:
134+
"""The frozen implementation is the judge of its own constants."""
135+
constants = art.get("constants")
136+
if not isinstance(constants, dict):
137+
fail("constants-accepted-by-policy", "there are no constants to hand to the policy")
138+
return
139+
try:
140+
built = pol.DesignConstants.from_committed(
141+
q=tuple(constants["q"]), m=tuple(constants["M"]), # type: ignore[arg-type]
142+
r_runs=constants["R_runs"], n_ladder=constants["N_ladder"], # type: ignore[arg-type]
143+
g=tuple(constants["G"])) # type: ignore[arg-type]
144+
except (pol.PolicyRefused, KeyError, TypeError, ValueError) as exc:
145+
fail("constants-accepted-by-policy",
146+
f"the frozen policy refuses the committed constants: {exc}")
147+
return
148+
149+
round_trip = json.loads(json.dumps(built.as_committed()))
150+
committed = json.loads(json.dumps(constants))
151+
if round_trip != committed:
152+
fail("constants-accepted-by-policy",
153+
f"the policy reads the constants back as {round_trip}, not as the committed "
154+
f"{committed}; a form that does not survive the round trip is not canonical")
155+
return
156+
if not all(isinstance(v, Fraction) for v in (built.q, built.m, built.g)):
157+
fail("constants-accepted-by-policy", "a rational came back as something other "
158+
"than Fraction")
159+
return
160+
ok("constants-accepted-by-policy",
161+
f"q={built.q}, M={built.m}, R_runs={built.r_runs}, ladder={list(built.n_ladder)} "
162+
f"stopping at {built.n_ladder[-1]}, G={built.g}; accepted by the frozen "
163+
"implementation and byte-identical on the round trip")
164+
165+
166+
def control_bound_to_freeze(art: dict[str, object]) -> None:
167+
freeze = _load(FREEZE_ARTIFACT, "constants-bound-to-freeze")
168+
if freeze is None:
169+
return
170+
problems: list[str] = []
171+
pairs = (("bound_policy_implementation_digest", "policy_implementation_digest"),
172+
("bound_measurement_harness_digest", "measurement_harness_digest"))
173+
for here, there in pairs:
174+
if art.get(here) != freeze.get(there):
175+
problems.append(f"{here} is {str(art.get(here))[:12]} but step 4 froze "
176+
f"{str(freeze.get(there))[:12]}")
177+
live = pb.harness_digest()
178+
if art.get("bound_measurement_harness_digest") != live:
179+
problems.append(f"the bound harness digest is not the live one, {live[:12]}")
180+
if problems:
181+
fail("constants-bound-to-freeze", "; ".join(problems)
182+
+ "; constants bound to an implementation other than the frozen one are "
183+
"constants for a policy nobody reviewed")
184+
else:
185+
ok("constants-bound-to-freeze",
186+
f"bound to policy {str(art.get('bound_policy_implementation_digest'))[:12]}… and "
187+
f"harness {live[:12]}…, both equal to what step 4 froze")
188+
189+
190+
def control_no_empirical(art: dict[str, object]) -> None:
191+
"""No name the policy itself uses for a fitted quantity may appear here.
192+
193+
The exact schema above is the primary guarantee. This is a second net, and it
194+
is DERIVED from the module rather than hand-listed: the forbidden names are
195+
whatever `Envelope` serialises as, so if the policy ever grows another
196+
empirical field the net grows with it instead of going quietly out of date.
197+
198+
NO MUTATION ISOLATES THIS CONTROL, and that is recorded rather than papered
199+
over. Every way of smuggling an empirical name in today is refused one check
200+
earlier by the exact schema, so the mutation campaign scores those against
201+
`constants-artifact-shape`. This is defence in depth, which is worth having and
202+
is not the same thing as tested coverage. Counting it as covered would be the
203+
defect this PR exists to remove, one level up.
204+
"""
205+
sample = pol.Envelope(n=1, a_abs=Fraction(0), r_rel=Fraction(0))
206+
empirical = set(sample.as_committed()) - {"n"}
207+
empirical |= {"selected_N", "measurements", "elapsed_ns"}
208+
209+
def names(node: object) -> list[str]:
210+
if isinstance(node, dict):
211+
return list(node) + [n for v in node.values() for n in names(v)]
212+
if isinstance(node, list):
213+
return [n for item in node for n in names(item)]
214+
return []
215+
216+
def floats(node: object) -> list[object]:
217+
if isinstance(node, dict):
218+
return [f for v in node.values() for f in floats(v)]
219+
if isinstance(node, list):
220+
return [f for item in node for f in floats(item)]
221+
return [node] if isinstance(node, float) else []
222+
223+
problems: list[str] = []
224+
present = sorted(set(names(art)) & empirical)
225+
if present:
226+
problems.append(f"names the policy uses for fitted quantities: {present}; those "
227+
"are measured, not chosen, and no measurement is authorised")
228+
stray = floats(art)
229+
if stray:
230+
problems.append(f"floating-point values: {stray}; the policy computes in exact "
231+
"rationals and a committed decimal is a float to one reader and "
232+
"a rational to another")
233+
if problems:
234+
fail("constants-no-empirical", "; ".join(problems))
235+
else:
236+
ok("constants-no-empirical",
237+
f"none of {sorted(empirical)} appears, and no value is a float")
238+
239+
240+
def run() -> int:
241+
art = _load(CONSTANTS_ARTIFACT, "constants-artifact-shape")
242+
if art is not None:
243+
control_artifact_shape(art)
244+
control_accepted_by_policy(art)
245+
control_bound_to_freeze(art)
246+
control_no_empirical(art)
247+
print()
248+
print(f"calibration constants controls: {len(_PASSES)} passed, {len(_FAILURES)} failed")
249+
return 1 if _FAILURES else 0
250+
251+
252+
if __name__ == "__main__":
253+
sys.exit(run())

0 commit comments

Comments
 (0)