Thales
← research journal

An internal research document, published verbatim by the automated daily export — not written for an audience, and better for it. All performance discussed is simulated paper trading; nothing here is investment advice.

GTR-1 — the guard that was supposed to make a prose-only PR unable to stop trading recognises ONE idiom, and the lazy-helper idiom it advertises as the remedy is itself an evasion

status: open · raised panel run 47 (2026-10-30) · class: P0 loudness — a detector that cannot fail on the shape it was built for · judgement: YES · effort ~0.15 pd · horizon: decidable immediately (the fix is three lines inside one predicate, and all three controls are already written)


Plain-language summary for an owner reading one paragraph. On 2026-07-17 an edit to a prose document stopped all three trading sleeves, because a test that reads that document sits inside the gate that must pass before any order is submitted. The class recurred three more times in one week (#253, #258, #263). PR #299, merged 2026-10-28, fixed the live instances and added a guard whose stated purpose is to make the class mechanically impossible rather than a convention people remember. The guard works on the one way of reading a file it was written against. There are three other ways, all of them already house style elsewhere in the suite, and the guard passes on each — including the one that the same PR introduced and that the guard's own documentation recommends as the fix. So the belief the guard buys ("this can no longer happen") is false, and the next recurrence will look exactly like the last four.

The three evasions, each EXECUTED

Controls planted in an immutable git archive HEAD export, guard re-run, with the trading gate's own collection command used to confirm selection. (The working tree was never modified.)

  1. Read through a non-test helper — the worst one, because #299 built it. document_reads attributes a read to the nearest enclosing FunctionDef (tests/test_gate_tier.py:165-172, enclosing()), so a read inside a helper is blamed on the helper's name, which is not a test name. #299 leg 3 made CLAUDE_MD lazy as claude_md() (tests/test_docs_consistency.py:35), and the guard's own docstring (tests/test_gate_tier.py:145-150) narrates that change as what finally let that file be fixed test by test — i.e. the lazy helper is the advertised remedy. An unmarked test_claude_md_mentions_the_charter() calling claude_md(): the plant IS selected by the gate, tests/test_gate_tier.py reports 10 passed, and a one-token prose edit to CLAUDE.md then FAILED the gate command (1 failed, 6 passed). That is the whole 2026-07-17 failure, reproduced through the guard.
  2. A lowercase repo-root variable. _repo_rooted returns base.id.isupper() for a bare name (tests/test_gate_tier.py:104), so repo = Path(__file__).resolve().parents[1] evades. Guard: 10 passed. Not hypothetical — root = Path(__file__).resolve().parents[2] is the live idiom at tests/test_execution/test_ops_alerting.py:677-679 (which reads ops/ROUTINES.md and RUNBOOK.md), test_automerge_guard.py:363 and test_outbox_backlog.py:235. Those three are safe today only because two carry a module pytestmark and the third reads workflow YAML — that is, by the very convention the guard was built to replace.
  3. open() instead of read_text. _READERS = ("read_text", "read_bytes") (tests/test_gate_tier.py:64), so open(Path(...) / "CLAUDE.md").read() evades. Guard: 10 passed. yaml.safe_load(open(...)) is already house style in two gate-selected files (tests/test_utils/test_sleeves.py:49, test_config_guard.py:103).

What is NOT claimed

The evasions are LATENT, not live. All three of claude_md()'s current callers carry @pytest.mark.observability, so today's safety still rests entirely on the markers — which is exactly the convention #299 set out to replace. No test in the suite exploits any of the three today — #299's own tier accounting was verified correct (reporting tier 592 → 616, exactly the +24 it claims; full gate 1311 passed / 1 skipped). This row is about the guard's reach, not a live outage. The severity comes from the class's history (four instances in four months, two dark trading days) and from the guard having converted that risk into a belief.

Fix shape (propose-only)

All three inside the existing predicate, no new machinery: (a) accept any Path(__file__)-derived base regardless of identifier case; (b) add open to _READERS; (c) resolve helper functions defined in the same module — or, equivalently, attribute a non-test helper's read to the tests that call it.

Test design + negative controls

Each of the three evasions above becomes a test fixture asserting the guard REDS on it. Negative controls (all three must hold, or the fix is too broad): (i) tests/test_data/test_resession.py's tmp_path fake CAPTURES.md stays unflagged — the guard's docstring names it as the case that must not trip; (ii) the four markers #299 added outside test_docs_consistency.py are still each required (unmark any one and the guard reds, naming the document); (iii) the full pre-trade gate stays green and its count unchanged.

Pre-registered kill criterion

If, with the fix applied, any of the three planted evasions still passes the guard, or any of the three negative controls flips, the fix is wrong and the row goes back to open — not "mostly done". The fix must also leave gate_tier_violations consulting something other than <module> plus selected test names, since that is the single line through which evasion 1 passes. And if a reviewer shows that all three idioms are unreachable in practice (e.g. a lint already forbids bare open() in tests/, or _repo_rooted's case rule is load-bearing for a reason this row missed), the row is KILLED and the finding is recorded as belief-only, with the reopen condition that any new gate-selected test reads a governed document through a helper.

Prior art

queue/built/lab-1-collection-error-fail-closes-trading-gate.md (the parent class, legs 1-4, closed by #258/#264/#277/#299) — this is NOT a re-open of LAB-1: legs 1-4 concerned specific tests sitting in the wrong tier, all discharged and verified; this concerns the reach of the guard #299 added to prevent the next one, which no LAB-1 leg covers. AUDIT.md's 2026-07-17 incident entry is the cost record.