import io, sys

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

TABLE = io.open('rig-d2/core-results-table.md', encoding='utf-8').read().rstrip('\n')

new = """## 5d. The integration-control pass -- 85 pass / 0 fail, and full suite coverage on `f7b7773f`

Dispatched 03:03:21Z, ended 03:15:52Z: **751 s**, against the 600-900 s predicted in Sec. 5c before
any result existed. Driver hashed `f7b7773f...fde0` immediately before dispatch and again after it
ended, unchanged. Fresh isolated output root `20260913T030322Z-3754`.

""" + TABLE + """

**Every arm is identical to the same arm on `2bd12fc8`** -- not merely green, but the same count:
A 16, B 6, C 6, D 6, E 5, F 5, G 6, H1 8, H2 4, I 8, L 6, K 9. Twelve of twelve identical, zero
changed, and 85 + J's 7 reproduces the old suite's 92 exactly. The capture-integrity gate and the
calendar parse did not disturb the non-residual behaviour.

### Coverage: every scenario now measured on the current driver

Assembled from four runs rather than one aggregate, per doyle's ruling that completed arms are not
re-run merely to obtain a single tally. Every row is bound to its subject **by bytes**, recovered
from that run's own per-case artifacts (Sec. 5c), not by a filename:

| scenarios | driver, recovered from the run's own artifacts | receipt | result |
| --- | --- | --- | --- |
| A B C D E F G H1 H2 I L K | `f7b7773f` | `rig-d2/core-run.txt`, Sec. 5d | 85 / 0 |
| J R2 R3 R4 R5 R6 R8 | `f7b7773f` | `rig-d2/residual-run.txt`, Sec. 5a | 46 / 0 |
| R7 | `f7b7773f` | `rig-d2/r7-run.txt`, Sec. 5b | 7 / 0 |
| R9 | `f7b7773f` | `rig-d2/r9-rerun.txt`, Sec. 5b | 4 / 0 |
| R10 | `f7b7773f` | `rig-d2/r10-rerun.txt`, Sec. 5b | 5 / 0 |
| | | **all 22 scenarios** | **147 / 0** |

The three superseded results are NOT counted above and are not withdrawn either: R7's 4/1, R9's
contaminated 4/0 and R10's void 3/2 stand in Sec. 5a as run, with their classifications.

### A behavioural change the arms do not assert, found by comparing exits

**Case L's driver exit moved from 0 to 6 between `2bd12fc8` and `f7b7773f`**, while its assertion
count stayed 6/0 -- because case L never asserted its exit. The cause is not a regression; it is the
capture-integrity ruling reaching a path no arm was written for:

| | `2bd12fc8` | `f7b7773f` |
| --- | --- | --- |
| `residual_state` | `CLEAR` | `UNREADABLE` |
| cleanup | `CLEANUP=VERIFIED residue=0` | `CLEANUP=PENDING residue=UNMEASURED` |
| driver exit | 0 | 6 |

Case L is the REFUSED setup. Nothing runs, so there is no identity capture at all -- and the old
driver called the box **CLEAR and VERIFIED on the strength of no measurement whatsoever**. That is a
false-clean of precisely the class this whole effort exists to stop, it survived a 92/0 suite, and
it was invisible because the arm read only the refusal and never the verdict. The current driver
refuses instead: no capture means UNREADABLE, never CLEAR.

**Proposed, not made:** case L should assert its exit and its cleanup verdict, so that this path is
covered by an arm rather than by someone diffing two tables. Rig-side, no driver change.

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

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