import io

p = r'C:\Users\decid\Documents\projects\spt-claude-code\traceable-reqs.toml'
s = io.open(p, encoding='utf-8').read()
NL = chr(10)
Q = chr(34)

compliance_title = (
 "claude-spt DECLARES `[io] compliance = true` and DELETES its own `@<...@>` parser in the SAME "
 "release, so spt-core becomes the single parser of this adapter's ingest. The published ordering "
 "rule is the whole design: 'an adapter that ships its own tag parser today keeps being the only "
 "parser until its own release deletes that parser and declares compliance in the same change - so "
 "no version exists in which both parse the same text and send it twice. Declare compliance in the "
 "release that removes your local parser, not before.' WHAT CORE NOW PARSES: the payloads this "
 "adapter reports at its ingest edges - USER_INPUT on `state busy` (REQ-IO-USER-INPUT-PAYLOAD), the "
 "turn's closing AGENT_OUTPUT on `state idle` (REQ-IO-AGENT-OUTPUT-PAYLOAD), and the MID-TURN "
 "AGENT_OUTPUT spans shipped in Release A (REQ-IO-MIDTURN-SPAN-REPORT). It never parses a RECEIVED "
 "message body: 'a peer can write a tag at you all day; it is text. Nothing you receive can make you "
 "send.' RELEASE A IS THE PRECONDITION, not a convenience. Before spans existed a tag written "
 "mid-turn reached no ingest edge at all, so declaring compliance would have silently dropped 12.5% "
 "of dispatches (measured); and before the disjointness fix (REQ-HAZARD-IO-SPAN-OVERLAP) an "
 "overlapping payload would have re-dispatched a tag to targets the author addressed once. Both were "
 "shipped and FIELD-VERIFIED through `spt api io-events` (2 spans, 3 closers, 0 duplicate payloads) "
 "before this flip, which is exactly what the two-release split bought. WHAT IS DELETED, and it must "
 "be the whole parser rather than a convenient half: `tag_scan`'s peer-dispatch grammar "
 "(`TagSection`, `parse_tag_sections`, `push_section`, `code_ranges`, `in_code`, `Dispatch.sends`) "
 "and, in `hook.rs`, the `spt send` fan-out, the outcome tallies and their classifications, the "
 "stamp probe, the outcome ledger, the QUEUED tripwire, and the whole shortform-confirm surface "
 "(`ScanConfirm`, `park_turn_end_confirm`, `tag_confirm_rel`, `parked_confirm_block`, and the "
 "UserPromptSubmit / PreToolUse sites that surfaced a parked confirm). A SPLIT PARSER IS FORBIDDEN - "
 "keeping ours for any case reopens the double-send window the gate exists to close, and a disabled "
 "parser is still a parser one edit away from firing. WHAT SURVIVES, deliberately: the commune "
 "shortcut (`>>commune<<`, REQ-COMMUNE-OUTPUT-SHORTCUT) is ours and core knows nothing of it; the "
 "transcript primitives `assistant_texts_from_jsonl` and `complete_line_prefix`, which the io "
 "payload legs depend on; the byte cursor and its first-run narrowing (REQ-HAZARD-TAG-FIRST-RUN-"
 "DROP), whose consumer moved from the dispatch to the payload; and the Stop settle "
 "(REQ-HAZARD-TAG-STOP-SCAN-EARLY), which Release A repointed at the payload read. `shortform = "
 "false` IS NOT DECLARED: it is the exotic-harness opt-out, and declaring it would turn core's reader "
 "off while ours is already gone, leaving NO parser rather than one. OUTCOMES MOVE TO "
 "DISPATCH_RESULTS, core's now-signal category, which is documented as 'the only channel, by design - "
 "a dispatch does not echo into your output, does not reply to you, and does not print a confirmation "
 "line, because a second channel is how an author ends up trusting whichever one they happened to "
 "notice.' Our own confirm surface was richer, and it is retired rather than kept beside it for "
 "exactly that stated reason."
)
compliance_stages = (
 'required_stages = ["impl", "unit"]  # MINTED + ACTIVATED 2026-08-29 with the implementing commit '
 '(Release B). impl: adapter/claude-spt.toml `[io] compliance = true`, plus the deletions in '
 'tools/claude-spt/src/tag_scan.rs and tools/claude-spt/src/hook.rs. unit: hook.rs + tag_scan.rs - a '
 '`@<...@>` in agent output produces NO send call from this adapter at all (asserted rather than '
 'assumed: a surviving dispatch path is silent here and visible only as a peer receiving everything '
 'twice) while the tag still reaches core verbatim inside the span; a commune body still routes to '
 'the commune file; the byte cursor and its first-run narrowing still hold. No "int": the parse and '
 'the dispatch are core-side once declared.'
)

quiet_title = (
 "A turn inside the ACROSS-CLEAR QUIET WINDOW still reports its authored text, so a shortform tag "
 "written in that turn is still dispatched. THE INVARIANT IS OLDER THAN THIS RELEASE and was stated "
 "at the very call site about to break it: 'The dispatch above already ran - outbound is never "
 "suppressed.' Under our own parser that held for free, because `scan_and_dispatch` dispatched "
 "BEFORE `handle_stop` reached the quiet-window return. Under `[io] compliance` the dispatch is "
 "core's, and core only sees what we REPORT - so the quiet window, which returns before the idle "
 "payload report and skips the PreToolUse span leg, would silently stop dispatching every tag in the "
 "turn that arms a commune-across. That is the worst turn in the system to lose one on: it is the "
 "turn an agent writes its handoff in, the session is about to be rebuilt, and nothing downstream "
 "would record that the message was never sent. THE GENERAL RULE THIS INSTANCE TEACHES: when a "
 "capability moves from the adapter to core, every path that SKIPS REPORTING silently becomes a path "
 "that SKIPS THE CAPABILITY. An early return that was previously about one concern inherits every "
 "concern that now rides the report, and the compiler cannot find them because nothing about them "
 "changed. Re-walk the early returns whenever you hand something over. THE FIX RIDES THE BUSY ARM, "
 "which is what makes it compatible with the window rather than a hole in it. The window exists to "
 "keep the endpoint BUSY across the `/clear` boundary so inbound spools for the post-clear session, "
 "and marking IDLE is the thing it must not do; `state busy --payload-stdin --mid` marks busy "
 "(idempotent - it already is) and publishes the batch as a mid-turn AGENT_OUTPUT span, which core "
 "parses. So the text reaches the parser, the endpoint stays ACTIVE, and the window keeps doing its "
 "job. The span is the same cursor-guarded batch every other leg reads, so exactly-once still holds "
 "(REQ-HAZARD-IO-SPAN-OVERLAP). ACCEPTED AND NAMED: a BARE (odd, unpaired) `;;` seal marker in that "
 "turn is refused as SEAL_BARE_MIDTURN, because 'through the end of your output' names text core has "
 "not been given yet and a short seal looks exactly like a correct one. Seal PAIRS mint normally, and "
 "a bare marker is the one construction an across-clear turn loses. Recorded rather than worked "
 "around: closing the pair is the author's fix, and a short seal that looked correct would be worse "
 "than a named refusal."
)
quiet_stages = (
 'required_stages = ["doc", "impl", "unit"]  # MINTED + ACTIVATED 2026-08-29 with the implementing '
 'commit (Release B). doc: docs/KNOWN-HAZARDS.md. impl: tools/claude-spt/src/hook.rs - the quiet-'
 'window arm of handle_stop reports the batch as a `--mid` span before returning. unit: hook.rs - a '
 'Stop inside the quiet window publishes its authored text as a span and NEVER marks idle; an empty '
 'batch in the window reports nothing at all. Mutation-verified: removing the span call, and adding '
 'an idle mark beside it, each fail the intended test.'
)

block = (
    NL + "[[requirements]]" + NL + 'id = "REQ-IO-COMPLIANCE-DECLARED"' + NL
    + 'title = "' + compliance_title + '"' + NL + compliance_stages + NL
    + NL + "[[requirements]]" + NL + 'id = "REQ-HAZARD-ACROSS-CLEAR-DISPATCH-DROP"' + NL
    + 'title = "' + quiet_title + '"' + NL + quiet_stages + NL
)

for t in (compliance_title, quiet_title):
    assert Q not in t, 'bare quote in title'
assert 'REQ-IO-COMPLIANCE-DECLARED' not in s
assert 'REQ-HAZARD-ACROSS-CLEAR-DISPATCH-DROP' not in s
s = s.rstrip(NL) + NL + block
io.open(p, 'w', encoding='utf-8', newline=NL).write(s)
print('minted 2 new requirements')
