import io, sys

P = 'd2-integration-receipt.md'
s = io.open(P, encoding='utf-8').read()
old = "## 6. Six defects the control caught"
n = s.count(old)
if n != 1:
    sys.exit('anchor matched %d times' % n)

new = """## 5c. The integration-control pass -- duration baseline recorded BEFORE dispatch

doyle authorized one integration-control pass on frozen `f7b7773f` covering the **non-residual**
scenarios and the validator's own arms, and required the measured duration of comparable prior runs
to be recorded **before** dispatch rather than reconstructed afterwards. Each figure below is the
run root's own UTC stamp subtracted from the output file's completion time -- the runs' own record,
not an estimate:

| prior run | driver | tallies | duration | per tally |
| --- | --- | --- | --- | --- |
| `all-run-1541dac6.txt` (superseded full suite) | `2bd12fc8` | 12 | 624 s | 52 s |
| `all-run.txt` (full suite, Sec. 5) | `2bd12fc8` | 13 | 644 s | 49 s |
| `residual-run.txt` (focused, Sec. 5a) | `f7b7773f` | 10 | 716 s | 71 s |
| `r8-run.txt` | `81dc4fe8` | 1 | 86 s | 86 s |
| `r7-run.txt` / `r9-rerun.txt` / `r10-rerun.txt` (Sec. 5b) | `f7b7773f` | 1 each | 81 / 84 / 75 s | 80 s mean |

The residual arms cost more per tally (71 s) than the full suite's mixed average (49 s) because each
drives a process model through capture and re-query. This pass runs **12 tallies** -- A, B, C, D, E,
F, G, H1, H2, I, L and the validator arms K -- so the comparable prediction is **600-900 s**,
dispatched under a 1800 s bound. The ten residual arms are deliberately NOT repeated: they are
already measured on this same driver, their receipts stand on their own, and repeating them would
buy one aggregate tally and nothing else.

The runner gained a `core` mode for exactly this set; it takes a **fresh isolated output root**
(`rig-d2/work/<UTC stamp>-<pid>/`) like every other invocation, so no earlier control can reach this
run's evidence.

## 6. Six defects the control caught"""

io.open(P, 'w', encoding='utf-8', newline='\n').write(s.replace(old, new))
print('Sec.5c inserted')
