import io, os
os.chdir(r"C:/Users/decid/Documents/projects/spt-core/.worktrees/hertz-inbound-probe")
P = "docs/INFRA-REGISTER.md"
s = io.open(P, encoding="utf-8", newline="").read()
CR, LF = chr(13), chr(10)
CRLF = s.count(CR + LF) > s.count(LF) // 2
def term(t):
    return t.replace(CR + LF, LF).replace(LF, CR + LF) if CRLF else t.replace(CR + LF, LF)
anchor = "- **FIELD PROOF, 2026-09-09, and it is the ONLY proof this guard has:**"
add = (
    "  5. **ONE ACK IS NOT ENOUGH — the same split verdict arrives by packet loss** (doyle, review of
"
    "     the built lane). A acking ONCE and breaking means B’s red rests on a single unrepeated UDP
"
    "     datagram: lose it and A prints INBOUND OK while B reds INBOUND_BLOCKED, blaming a firewall for
"
    "     ordinary loss. A now keeps draining for a short window after its verdict is already decided and
"
    "     acks EVERY probe in it, while B stops on the first ack. The A-side assertion is unchanged — it
"
    "     was settled by the first datagram.
"
    "  6. **THE PROBE STEPS CARRY THEIR OWN BUDGET, 300 s, set EXPLICITLY beside ceremony steps that say
"
    "     900.** The probe budget bounds RENDEZVOUS skew, not pairing, so a blocked link costs 300 s once
"
    "     rather than 900 per cell per half; left unset it would have been `from_env`’s invisible default
"
    "     next to a visible 900 on the step below — a number a reader would have inferred wrongly.
"
)
a = term(anchor)
assert s.count(a) == 1
io.open(P, "w", encoding="utf-8", newline="").write(s.replace(a, term(add) + a))
print("IR-89 amendment: corrections 5 and 6 added")
