---
name: scripted-edit-zero-match-refusal
description: "scripted inserts convert \\n escapes to real linebreaks (mixed-EOL landmine units can't see); anchor-count refusal on zero/non-unique matches is the guard that catches it"
metadata: 
  node_type: memory
  type: feedback
  originSessionId: bcaec1f3-343d-4719-aa9d-1e1cb82b0e58
  modified: 2026-08-03T13:08:22.863Z
---

DOORBELL W2 leg 1 (todlando, 3ab9fe9): a scripted insertion converted intended `\n` escapes into REAL line breaks inside string literals. Correct only by luck — those source lines happened to end LF in an otherwise-CRLF file; any EOL normalization would push a stray `\r` into every rendered output on every platform, with units still green (`contains()` and `lines()` both tolerate either ending).

**Why:** it surfaced ONLY because a mutation anchor written against the intended escape matched zero times and the script refuses to mutate on a non-unique/zero count. A scripted replace reporting success on zero matches hides this class entirely.

**How to apply:** any scripted edit/mutation tooling must hard-fail on zero or non-unique anchor matches — the refusal is the detector, not an inconvenience. After scripted inserts into Rust string literals, verify escapes survived (grep for literal newline inside the quoted region or render-compare). Related: [[sweep-dispatch-site-counts]], [[render-not-read-pipefail]].

⭐⭐ **AMENDED 2026-08-03 (#115 mutation battery): the refusal only works if you count the string you actually REPLACE.** I asserted a SHORT anchor (`unknown => eprintln!(`, count 1 → passed) and then `.replace()`d a LONGER block that matched nothing. Silent no-op; the test went green; I read that green as "the mutation SURVIVED, my probe is blind" and wrote it up as a finding. **No mutation had been applied — a green from unmutated code.** Assert on the *replacement's own* anchor, and assert `after != before` as a second belt. This is [[a-predicate-without-its-tool-is-not-evidence]] wearing a guard's uniform: the count I ran was real, it just answered a different question.

⭐ **Cause of the zero-match, worth its own line:** a **non-ASCII char (em-dash) in a heredoc did not survive the shell into python**, so the literal never matched the file's bytes. On this box, match anchors in scripted mutations must be **ASCII-only** — prefer a regex spanning from an ASCII prefix to an ASCII suffix (`re.S`) over pasting a block that contains prose punctuation.

⚠ **A mutation loop ending in `git checkout -- <file>` destroys UNCOMMITTED repairs to the very probe you are testing.** Mine did, so three variants silently re-ran against the OLD probe. Commit a probe fix BEFORE running the battery over it — see [[restore-step-presumes-committed-baseline]]. (The accident was informative rather than fatal, but that was luck.)

⭐⭐ **A `BTreeMap` fixture can mask a mis-seed by key ORDER.** Probing "an unknown key seeds no latch" with key `future_slot` alongside a legitimate `turn` entry: the seeder walks sorted, the mis-seed into `latch_turn` landed first and the legitimate `turn` **overwrote it**, so the final state was identical to correct. Name the adversarial key so it sorts **last** (`zz_…`), and assert the **whole state snapshot** against a hand-built expectation instead of naming latches one at a time. The variant the weak probe missed was the one a careless fix would actually produce; the two it caught seeded a slot the fixture never fills.
