Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ba04aea
feat(mining): P3-15'-c-ii — the criterion (c) synteny predicate, its …
bioedcam Aug 7, 2026
4b49352
fix(mining): P3-15'-c-ii review round 1 — the tandem carve-out now re…
bioedcam Aug 7, 2026
b61fd3a
fix(mining): P3-15'-c-ii review round 2 — the 5'UTR false-pass arm co…
bioedcam Aug 7, 2026
c7beb0a
fix(mining): P3-15'-c-ii review round 3 — a filtered subset that outn…
bioedcam Aug 7, 2026
b6234ec
fix(mining): P3-15'-c-ii review round 4 — "the same windows, filtered…
bioedcam Aug 7, 2026
b9aefb4
test(mining): P3-15'-c-ii review round 5 — assert object identity, no…
bioedcam Aug 7, 2026
1f9e3ab
fix(mining): P3-15'-c-ii review round 6 — the sub-threshold test used…
bioedcam Aug 7, 2026
3991fa2
fix(mining): P3-15'-c-ii review round 7 — ProducerError was not the f…
bioedcam Aug 7, 2026
a5b1fd0
fix(mining): P3-15'-c-ii review round 8 — duplicate-key collapse on t…
bioedcam Aug 7, 2026
cd3c01d
fix(mining): P3-15'-c-ii review round 9 — the false-pass rate divided…
bioedcam Aug 7, 2026
2f9563d
fix(mining): P3-15'-c-ii review round 10 — the positive control publi…
bioedcam Aug 7, 2026
bd493ba
fix(mining): P3-15'-c-ii review round 11 — a bare gene symbol suppres…
bioedcam Aug 7, 2026
24fa382
fix(mining): P3-15'-c-ii review round 12 — one bad GFF among 339 woul…
bioedcam Aug 7, 2026
9069d95
fix(mining): P3-15'-c-ii review round 13 — round 11's guard keyed on …
bioedcam Aug 7, 2026
ee9108c
test(mining): P3-15'-c-ii review round 14 — a one-class assertion gua…
bioedcam Aug 7, 2026
65f64af
fix(mining): P3-15'-c-ii review round 15 — a required parameter that …
bioedcam Aug 7, 2026
9b7a4e9
fix(mining): P3-15'-c-ii review round 16 — round 12 guarded one of tw…
bioedcam Aug 7, 2026
14a66b7
docs(dev-log): correct the round-16 pass count — 4,683, not 4,687
bioedcam Aug 7, 2026
bb76e3a
fix(mining): P3-15'-c-ii review round 17 — strided sharding defeated …
bioedcam Aug 7, 2026
231ffde
docs(dev-log): add the round-17 stanza dropped by a short-circuited c…
bioedcam Aug 7, 2026
3cf5e7b
test(mining): P3-15'-c-ii review round 18 — three instances of "fixed…
bioedcam Aug 7, 2026
be43605
docs(dev-log): P3-15'-c-ii review round 19 — no new findings, the gat…
bioedcam Aug 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 198 additions & 0 deletions analyses/phase3_log.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -3941,3 +3941,201 @@ shared predicate, since breaking only the predicate would leave a per-clause rep
Full unit+golden **4,490 passed / 15 failed** vs the matched baseline at `2be5ff4`
(**4,240 / 15**) — failure sets identical, `comm` empty both ways. Counts across nine rounds:
**9, 2, 4, 5, 5, 5, 1, 2, 1**.

## Step P3-15′-c-ii — 2026-08-07: the criterion (c) predicate, its per-candidate producer, and D4's two symmetric diagnostics

**Inputs.** `data/processed/mining/round0_fp_manifest.json` (941 candidates / 76 hosts);
`data/interim/production_annotations/*.gff.gz` (339, md5-verified at `-c-i`);
`data/interim/production_genomes/*.fna` (the contig-id bridge);
`data/processed/mining/production_genomes_v0.parquet` (GTDB clade);
`data/processed/negatives/{decoys,mining_pool}_v0.parquet` (the §9.1 arm).
**Process.** `mining/synteny.py` implements ADR-0006 D4's frozen `criterion_c` verbatim plus
the downstream walk, the tandem carve-out and the gene-identity vocabulary D4 delegates here;
`mining/synteny_producer.py` writes `$ROUND_DIR/synteny_status.json` (`candidate_id → status`,
the (a)-producer's shape) and the two committed diagnostic reports. `SYNTENY_SUPPLY_AVAILABLE`
was added beside `MSA_SUPPLY_AVAILABLE`, `candidate_evidence` / `remine_candidate_evidence`
gained the synteny status map with the same fail-closed absent-id rule, and `--synteny-available`
was promoted from a one-way `store_true` to the two-way pair with an exit-4 unevidenced preflight.
**Outputs.** `src/tbox_finder/mining/{synteny,synteny_producer}.py`;
`reports/p3/synteny_false_pass.json`; `reports/p3/synteny_exclusion_diagnostic.json`;
`tests/unit/test_synteny{,_producer}.py` (+112 tests).
**Validation.** 941/941 statuses (541 passed / 101 failed / 299 unavailable); the false-pass
control is **powered** (margin 0.975 ≥ 0.20); full unit+golden **4,604 passed / 13 failed**
against a matched baseline worktree at `95d0149` (**4,492 / 13**) — failure sets identical,
`comm` empty both ways; **19 sabotages / 19 RED against their named test**.
**Decisions.** ADR-0006 D4 (vocabulary delegated here, §10.1-verified); ADR-0005 D14 (fail-closed
`unavailable` ⇒ spared), D15 (both-strand carry-through).
**Commit.** see below.

**The criterion discriminates, and by a wide margin.** Candidates pass at **57.5 %** against a
clade-matched random-leader background of **1.67 %** and a §9.1 5′UTR-decoy background of
**4.52 %** — a 13–34× enrichment, with a positive-context arm at **99.20 %** proving the control
is powered rather than merely quiet. The reading is not that the criterion is loose: the
round-0 pool is Stage-1 *false positives* drawn from a masked negative substrate, and a 96-nt
element scoring 0.9977 that sits 19 bp upstream of an `alanine--tRNA ligase` is most plausibly
an uncatalogued T-box. ADR-0005 D14's spare rule exists precisely so those are spared rather
than trained against, and 541 of them now are.

**⚠ THE BIGGEST DEFECT WAS FOUND BY DISBELIEVING A NUMBER, NOT BY A TEST.** The first run
returned **541 of 941 passing** and the per-CDS background density of D4's four classes is
**4.14 %** — an irreconcilable gap. The cause was that the downstream walk bounded the distance
only from above: a bacterial genome is ~88 % coding, so a window buried inside a long gene found
that gene as its "downstream" gene and inherited its identity. D4's class-II case genuinely
needs a *negative* distance (a translational T-box abuts/overlaps the start codon), so the fix
could not be "reject overlap"; it is that the CDS start must lie at or after the **element's own
5′ end**, which pins no new number. The corpus-level counts barely moved because Stage-1
candidates land in leader regions rather than inside genes — so the number that exposed the bug
was not the number the bug corrupted.

**⚠ TWO DEFECTS THE DIAGNOSTIC FOUND IN ITSELF, AND BOTH WERE SILENT ZEROS.** (1) The pseudogene
diagnostic reported **0** pseudogenized first-downstream ORFs corpus-wide, because the tandem
carve-out hops exactly the population the diagnostic exists to size; the counts now accumulate
across the whole walk (15 pseudogenized, 88 unjudgeable). (2) D4's hypothetical/pseudogene route
was **entirely unreachable**: `gff3.gene_identity_text` collects `Dbxref`/`Name` as well as
`product`, and on NCBI CDS those are accessions (`Dbxref` is present on 29,852 of 30,273
measured CDS), so every `hypothetical protein` still had non-empty "identity text", never
resolved to unjudgeable, and was scored a *decided* `failed` instead of being routed to the
fallback. Identifier-shaped values are now filtered, with a positive control asserting the
filter removes identifiers rather than removing judgement.

**⚠ THE VOCABULARY IS PRECISION-FIRST BECAUSE THE PERMISSIVE VERSION WAS MEASURED FIRST.** An
"amino-acid word + enzyme word" rule looks reasonable and swallows `HAMP domain-containing
histidine kinase` (38 CDS over 12 hosts, two-component signalling), `serine/threonine protein
kinase`, `glutamine amidotransferase` (purine/His/Trp — **not** tRNA-dependent transamidation),
`methylated-DNA--[protein]-cysteine S-methyltransferase` (DNA repair) and `peptide-methionine
(S)-S-oxide reductase` (protein repair). Every `EXCLUSIONS` entry was observed on this corpus
before it was written down, exclusions are applied **before** every include rule, and the
transamidation rules all require the literal `tRNA`. Two ordering corrections came out of the
audit: the curated product name outranks the gene symbol (`hisJ` is the histidine transporter's
binding protein in the enterics and **histidinol phosphatase** in Firmicutes), and the symbol
route fires only when the product name says nothing at all — consulting it otherwise put `PTS
galactitol transporter subunit IIB` into the transamidation class via `gatB`, `cytochrome C-552`
into transport via `cycA`, and `homocitrate synthase` into aaRS via `lysS`. 24 of 4,991 matches
came from that route and 3 of the 24 were wrong.

**⚠ THE CONTIG BRIDGE IS BY IDENTITY, AND AN INDEX JOIN WOULD HAVE BEEN WRONG ON HALF THE
CORPUS.** A candidate's contig is `:c<ci>`, an index into the genomic FASTA's record order; a
GFF's `seqid` is the NCBI contig accession. **23 of the 48** candidate-carrying annotated hosts
serve their GFF seqids in a different order than their FASTA records, so `records[ci]` ↔
`seqids[ci]` would silently read the wrong contig on ~48 % of hosts. The id join resolves
**134 of 134** needed (host, contig) pairs.

**Three gaps reported rather than papered over.** (1) The **shipped §9.1 decoy rows carry
coordinates on 0 annotated production hosts** — `decoys_v0`'s three non-structured pools have no
accession at all, its 2,999 `structured_rna` accessions are Rfam source contigs, and
`mining_pool_v0`'s 45,988 leader/trail windows sit on the TBDB source genomes — so that arm is
`available: false` **with its counts**, and the §9.1 leader class is re-instantiated inside the
annotated corpus instead (5′UTR and tRNA-adjacent windows). (2) The **false-FAIL arm has almost
no positive denominator**: only **2 TBDB records on 1 assembly** intersect the 339, because the
production substrate is by construction a negative one. (3) The **joint a ∧ b ∧ c arm is
structurally unavailable** — (b) has no backend until P3-15′-d — and is withheld, never computed
from two unavailable disjuncts.

**Per-clade exclusion is the clade-structured cap D4 commissioned, and it is large.** 31.8 %
of candidates are `unavailable` (286 host-unannotated, 11 unjudgeable, 2 contig-absent), with
five phyla at **100 %** exclusion (Chloroflexota, Desulfobacterota, Fibrobacterota, Thermotogota,
Bdellovibrionota_C), Bacillota at 38.5 %, and Atribacterota / Sysuimicrobiota / Fusobacteriota at
0 %. That is the recall cap the commissioned bakta/prokka arm exists to lift. Empirical passing
distances: p50 117 bp, p95 269 bp, p99 364 bp, max 454 bp — all inside D4's 500 bp pad, which is
the sensitivity check D4 asks for.

**⚠ `n_mined` IS STILL STRUCTURALLY 0.** Sparing is a disjunction so mining is a conjunction:
`relaxed_architecture` remains the one unavailable backend, so `max_possible_yield` still caps
the round at 0 until P3-15′-d lands. This step removes one of the two blockers, not both.

**Review round 1 — 20 findings (app 5, CLI 15), all real, 8 major; only one in common.** The app
and the CLI overlapped on exactly the CLI-wiring finding, so running both was worth it rather
than redundant, as it was at `-c-i`.

**⚠ THE MAJOR ONE: THE TANDEM CARVE-OUT REACHED THE SEARCH BUT NOT THE DECISION.**
`resolve_downstream_gene` selected its target with the **re-anchored** window and then returned
that target's **element-relative** distance, which `synteny_status` judged against the 500 bp
pad — so the carve-out fired only where it was not needed, and turned exactly the tandem loci D4
built it for into **false FAILs**. `DownstreamGene` now carries both distances and `criterion_c`
sees `decision_distance_bp`. **Five candidates move `failed` → `passed`** (541 → 546), and the
decision-distance series is now p50 117 / p95 266 / p99 356 / **max 454 bp**, entirely inside the
pad, with the element-relative max of 1,652 bp explained by `n_passed_via_tandem_carve_out: 5`.
⚠ **My own test could not see this**: it asserted the walk reached the right *gene*, which was
always true. The search was never wrong; the decision was.

**⚠ A NUMBER I REPORTED WAS FROM A SUPERSEDED RUN.** The PR body, commit message, dev-log and
`TODO.md` all quoted "p95 269 / p99 364 / max 454, n 549" while the committed artifact said
"p95 272 / p99 389 / **max 1652**, n 554" — I read the field before the identifier-filter fix and
never re-read it after regenerating. The gap was also the symptom of the real bug: the statistic
collected every strand detail whose *class* was passing without checking its *status*, so
out-of-window hits that FAILED were counted (554 entries against 541 passed candidates). It now
filters on the detail's own status and reports both series.

**⚠ TWO ARTIFACT-PINNING TESTS WENT GREEN UNDER SABOTAGE, AND THAT IS THE CAMPAIGN'S BEST
OUTPUT.** `test_the_distance_statistic_counts_only_passed_evaluations` and
`test_provenance_never_records_an_absolute_local_path` both read the **committed report**, which
was generated by the fixed code — so breaking the source could not reach them. They still earn
their place as guards on the committed evidence, but `TestDiagnosticsComputedNotJustCommitted`
now calls the report builders directly so the *rule* is under test, not one frozen output of it.
Both new tests bite.

**⚠ A TEST THAT COULD NOT CATCH THE TRAP IT NAMED.** `test_no_clause_reads_dvc_tracked_data`
derived against `REPO_ROOT` — so on any laptop that has run `dvc pull`, a DVC-path clause would
read True and the test would still pass. It now derives against a `tmp_path` root holding only
the `SUPPLY_CLAUSES` files and asserts `n_annotated_hosts_on_disk == 0`, which is the environment
the clause set actually has to survive.

**⚠ THE PRODUCED TABLE WAS NEVER READ BY EITHER ROUND.** Both reviewers found it independently:
`candidate_evidence` accepted a synteny map but no CLI leg supplied one, so declaring the backend
available would have left every candidate `unavailable` — spared, with a zero yield
indistinguishable from an honest one. `--synteny-status` is wired into **both**
`apply-spare-rule` legs, and declaring the backend without a table (or supplying one without
declaring it) now raises rather than proceeding — the same answer this function's `probe_set`
parameter already got for the same reason.

**Also fixed.** A committed provenance record named an absolute `/home/<user>/…` path (out-of-repo
inputs are now hashed and recorded as `{name, sha256}`, which is *more* traceable than the path);
the unavailability reason scanned both strands under a single-strand policy; `merge_status_tables`
passed two inputs through unvalidated and accepted a shard contributing no rows; `_upstream_window`
bounded the plus arm but not the minus; `combine_strand_statuses` raised a bare `KeyError`;
`load_contig_ids` raised `IndexError` on a bare `>` header; `synteny._gene_symbols` was private
while the producer's control arm depended on it (now `synteny.gene_symbols`); the
`candidate_evidence` docstring still said no synteny backend exists.

**Validation (round 1).** Full unit+golden **4,621 passed / 13 failed** vs the matched baseline at
`95d0149` (**4,492 / 13**) — failure sets identical, `comm` empty both ways. **28 sabotages / 28
RED against their named test.** Both reports re-derive byte-identically from the final code apart
from `provenance`. ruff 0.15.15 + black 25.11.0 clean.

**Review round 2 — 7 findings (app 1, CLI 6), all real, 5 major.** Counts across two rounds:
**20, 7**.

**⚠ THE FALSE-PASS ARM THAT CONTAINED ITS OWN POSITIVE CLASS, AND THE NUMBER THAT CHANGED BY AN
ORDER OF MAGNITUDE.** The §9.1 5′UTR arm sampled *every* CDS, including the aaRS /
amino-acid-biosynthesis genes the positive-context arm is built from — and a 5′UTR sitting
upstream of an aaRS in a real genome may itself **be** a T-box leader, so counting it as a
*false* pass inflates the rate. Reporting one reading only would have been a choice disguised as
a measurement, so both now ship: drawn over all CDS the arm reads **5.28 %**; drawn over the CDS
naming none of D4's four classes — where every pass is unambiguously false — it reads **0.35 %**.
The gap *is* the ambiguity, and resolving it is not this step's to do.

**⚠ THE SUB-THRESHOLD HOP COULD SKIP A CDS THAT ALREADY SATISFIED THE CRITERION.** The docstring
already claimed the carve-out fires only on an ORF *"that cannot carry the criterion either
way"*; the length branch did not enforce it, so a short CDS naming a D4 class would be hopped in
favour of whatever sat further downstream. **No candidate verdict changed on this corpus** — the
case does not occur here — so this is latent correctness the new test pins rather than a numbers
movement, and it is recorded as such rather than dressed up as a fix that moved something.

**⚠ MY CLI-REACHABILITY TEST WAS VACUOUS, AND `argparse` IS WHY.** It probed the P2 leg by
parsing `[..., "--synteny-status", "t.json", "--help"]` and asserting exit 0 — but argparse
handles `--help` **before** it rejects an unknown option, so that exits 0 even for a flag the
parser has never heard of (verified by execution against a parser carrying no such option). The
test passed whether or not the option existed. `mine_round.build_parser` was extracted so the
assertion can be structural, and a negative control now checks the option set can answer False.

**Two more integrity findings.** `exclusion_reason_totals` fell back to `""` while the per-clade
breakdown fell back to `host_unannotated` for the **same row**, so one row was counted under two
keys and the closed `EXCLUSION_REASONS` vocabulary held in one place and not the other — both now
read one derivation, which *raises* on an unknown reason. And `merge_status_tables` wrote
`config.as_dict()`, which re-reads the **live** `HMM_FALLBACK_AVAILABLE`, so a merge on a checkout
where the flag had flipped would silently rewrite what the shards actually ran under; the
shard-recorded value now wins.

**Validation (round 2).** Full unit+golden **4,627 passed / 13 failed** vs the matched baseline at
`95d0149` (**4,492 / 13**) — failure sets identical, `comm` empty both ways. **32 sabotages / 32
RED against their named test.** ruff + black clean.
Loading
Loading