p = 'CONTEXT.md'
s = open(p, encoding='utf-8').read()
pairs = [
# 155: the window is the BUSY window, keyed on the activity sentinel.
('''While the endpoint is **active**, the message spools for the receiver's own hook-poll to drain (non-disruptive — the *active window*).''',
 '''While the endpoint is **busy**, the message spools for the receiver's own hook-poll to drain (non-disruptive — the *busy window*).'''),
# 158: busy-only replaces active-only.
('''· **active-only** (active window only — the receiver's hook-poll; never wakes an idle agent). *active-only* is the renamed legacy **deferred** (the `deferred=1` spool column + `api poll --include-deferred` are its internal/adapter-facing names). Mutually exclusive.''',
 '''· **busy-only** (busy window only — the receiver's hook-poll; never wakes an idle agent). *busy-only* is the renamed legacy **deferred** (the `deferred=1` spool column + `api poll --include-deferred` are its internal/adapter-facing names, kept as spelled: the column is storage and the poll flag is adapter-facing). Mutually exclusive. The window is decided by the receiver's **activity** sentinel alone (busy|idle) — see *delivery window vs instance state* below. _Avoid_: the spelling *active-only* — it borrowed a word from the instance-state vocabulary, which is what made a cross-axis gate look reasonable to write (releases#256).'''),
# 161: the composition example.
('''(e.g. `force-native` + `active-only` = the binary injects during the active window, never idle;''',
 '''(e.g. `force-native` + `busy-only` = the binary injects during the busy window, never idle;'''),
# 669: notify kind rides the busy window.
('''**Delivery window (ruled 2026-07-21): the notify kind rides `active_only` unconditionally — spool-only, never a live-PTY interrupt — for every producer including rollback.**''',
 '''**Delivery window (ruled 2026-07-21): the notify kind rides the busy window unconditionally (busy-only) — spool-only, never a live-PTY interrupt — for every producer including rollback.**'''),
# 832: the gate clause, replaced by the positive statement.
('''**deferred-message gate:** deferred (spool-only, hook-consumer) messages are **not** delivered to a dormant or suspended instance — they hold until it is active again. (Extends the deferred-row semantics, KNOWN-HAZARDS 1.4/4.4, with an instance-state gate.)''',
 '''<!-- [doc->REQ-DELIVERY-WINDOW-IS-ACTIVITY-AXIS-ONLY] -->
**delivery window vs instance state (operator-ruled 2026-09-24, releases#341):** a busy-window (deferred, spool-only, hook-consumer) message is delivered on the receiving endpoint's own next hook-poll, **whatever its instance state**. Two unrelated axes both use the word *active*, so keep them apart: **activity** is busy|idle — the two states an adapter reports through its sentinel — and it is the **only** input to a delivery window; **instance state** is active|dormant|suspended|offline, and it selects **which instance** a bare id resolves to and may require a **wake** first. So a warm, undriven (**dormant**) endpoint drains its busy-window messages on its own next poll — being unwatched is not being unable to work, and an unwatched autonomous agent is the one that most needs its peer traffic — and a **suspended** endpoint receives them on the first poll after it wakes, because that is simply when its harness next polls. The away/return notice pair is the canonical case: it reaches the agent **while** it is away, in order. An instance-axis hold is not forbidden, only unbuilt: if one is ever wanted it arrives as its own flag on its own axis. _Avoid_: a gate that reads the rest record to answer a delivery question — the rest state machine's events (Detach / AttentionShift / Suspend / Wake / AutoSuspendTick) carry no activity input, so no reading of it can decide a window.'''),
# rest-state section: name dormant's two arms side by side + the axis sentence.
('''- **dormant** (default, *warm*): a live, state-preserved seat whose harness session stays running → instant re-activation. The default resting state.''',
 '''- **dormant** (default, *warm*): a live, state-preserved seat whose harness session stays running → instant re-activation. The default resting state. It has **two arms**, and a dormant instance may be either: **the driver detached** (nobody is watching — the agent may still be working) **or a sibling took attention** (another instance of the id is the active one). Neither arm means the instance cannot work, and **no instance state gates a delivery window** (see *delivery window vs instance state*).'''),
]
for a, b in pairs:
    n = s.count(a)
    assert n == 1, (n, a[:80])
    s = s.replace(a, b)
open(p, 'w', encoding='utf-8', newline='\n').write(s)
print('ok')
