Skip to content

test: empty _OWED_BOTH_ROOTS — all eleven gates now sweep both roots (#689) - #699

Merged
realmarcin merged 3 commits into
mainfrom
fix-689-owed-both-roots
Aug 28, 2026
Merged

test: empty _OWED_BOTH_ROOTS — all eleven gates now sweep both roots (#689)#699
realmarcin merged 3 commits into
mainfrom
fix-689-owed-both-roots

Conversation

@realmarcin

Copy link
Copy Markdown
Contributor

Closes #689.

The guard added in #692 recorded eleven test modules that swept
kb/communities where data/isolates holds the same content. This converts all
eleven and empties the list.

Checked before converting, not hoped for afterwards

probe result
truncation gate over isolate snippets 66 examined, 0 flagged
interaction participants outside taxonomy none
network auditor over data/isolates 0 issues of any kind

So this adds coverage rather than a defect backlog. The value is that a defect
arriving in an isolate tomorrow is visible to eleven gates that could not have
seen it.

The shared helper

communitymech.paths gains record_files() and record_path().
default_record_roots() answers which directories, and almost every caller
then wrote the same glob line — eleven skipped that step entirely and globbed one
root. One function, so a module cannot get half the corpus by writing slightly
less code than the module beside it.

Three needed more than a directory swap

  • test_ncbi_domain_scope and test_gtdb_near_tie_marker iterate
    document["taxonomy"], and a CommonTaxon in kb/taxa has no such key —
    exactly the trap taxon_blocks.iter_taxon_descriptors was written for in Six independent copies of 'where the records live', and they already disagree #656.
    They now use taxon_descriptor_roots() with that walker and reach 16 isolate
    and 2 kb/taxa descriptors
    that were previously invisible;
    gtdb_classification blocks seen 752 → 755.

  • test_network_auditor passed communities_dir= explicitly, silently
    replacing the auditor's own default_record_roots() default — the shape data/isolates/** now triggers validate-strict, but that job does not validate isolates #350
    fixed in the auditor and left standing in its test. The override is gone, so
    the default is under test as much as the corpus is, and an assertion now
    requires an isolate among the audited records.

  • test_snippet_rendering_artefacts monkeypatched the COMMUNITIES constant
    to drive its mutation check over one record. Sweeping both roots makes the walk
    a call rather than a directory, so the seam moves to a _record_files()
    indirection; the mutation check still fires.

The scanner guard is recalibrated, not lowered

It asserted len(found) >= 10. The population legitimately fell from 14 to 3
when the eleven were converted, so a fixed threshold would have had to be
lowered — and a threshold lowered to match reality measures nothing. It now
calibrates against _COMMUNITY_ONLY: the scanner must still see every module
classified as single-root, which is what the checks below it are about.

Verification

just lint                clean (black, ruff, mypy)
pytest tests/            2831 passed, 16 skipped

Proven non-vacuous by collection rather than by reading: the 4 isolate records
now appear as parametrised cases in test_snippet_truncation, which collected
only kb/communities before.

Known unrelated failure: test_no_snippet_stops_mid_word fails locally on
data/isolates/Methylobacterium_REE_Ewaste_Platform.yaml, driven by an untracked
local cache; it skips on a clean checkout.

realmarcin and others added 3 commits August 28, 2026 00:18
…#689)

The guard added in #692 recorded eleven test modules that swept kb/communities
where data/isolates holds the same content. This converts all eleven and empties
the list.

Checked BEFORE converting, not hoped for afterwards: the truncation gate
examined 66 isolate snippets and flagged 0, no isolate interaction participant
sits outside its taxonomy, and the auditor reports 0 issues of any kind across
the 4 records. So this adds coverage rather than a defect backlog -- the value
is that a defect arriving in an isolate tomorrow is visible to eleven gates that
could not have seen it.

`communitymech.paths` gains `record_files()` and `record_path()`.
`default_record_roots()` answers "which directories" and almost every caller
then wrote the same glob line; eleven skipped that step entirely and globbed one
root. One function, so a module cannot get half the corpus by writing slightly
less code than the module beside it.

Two of the eleven needed more than a directory. `test_ncbi_domain_scope` and
`test_gtdb_near_tie_marker` iterate `document["taxonomy"]`, and a CommonTaxon in
kb/taxa has no such key -- the trap `taxon_blocks.iter_taxon_descriptors` was
written for in #656. They now use `taxon_descriptor_roots()` with that walker,
and reach 16 isolate and 2 kb/taxa descriptors that were previously invisible;
gtdb_classification blocks seen: 752 -> 755.

`test_network_auditor` was the sharpest. It passed `communities_dir=`
explicitly, silently replacing the auditor's own `default_record_roots()`
default -- the shape #350 fixed IN the auditor and left standing in its test.
The override is gone, so the default is under test as much as the corpus is, and
an assertion now requires an isolate to be among the audited records.

`test_snippet_rendering_artefacts` monkeypatched the COMMUNITIES constant to
drive its mutation check over one record. Sweeping both roots makes the walk a
call rather than a directory, so the seam moves to a `_record_files()`
indirection; the mutation check still fires.

The scanner guard is recalibrated against `_COMMUNITY_ONLY` instead of a written
count. The population legitimately FELL from 14 to 3, so a fixed threshold would
have had to be lowered -- and a threshold lowered to match reality measures
nothing. What must stay true is that the scanner still sees the modules
classified as single-root.

Verified: 2831 passed, 16 skipped. Conversion proven non-vacuous by collection
-- the 4 isolate records now appear as parametrised cases in
test_snippet_truncation, which collected only kb/communities before.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Adversarial review of the previous commit. Four findings, all in my own work.

1. THE GUARD WAS WEAKER THAN IT LOOKED. `_sweeping_test_modules()` skipped any
   module mentioning `record_files`/`default_record_roots`, treating the
   presence of a NAME as proof of its USE. test_no_vacuous_go_annotations
   imported record_files, never called it -- its sweep read
   `(corpus or COMMUNITIES).glob(...)`, which the conversion's pattern did not
   match -- and ruff then deleted the now-unused import, leaving a module that
   looked converted, was not, and passed this scan twice over.

   Detection is now structural: a module that still globs a constant bound to
   kb/communities is flagged whatever else it says. A genuinely converted module
   cannot trip it, because it no longer has such a glob.

2. That stricter scan immediately surfaced two more, both previously hidden:
   test_gtdb_status_writer swept one root for curated GTDB pins, and
   test_ncbi_domain_scope had a SECOND sweep at line 134 that I missed while
   converting line 82 -- a module I had already claimed to convert.

3. test_interaction_participants_outside_taxonomy swept both roots but then
   constructed `NetworkIntegrityAuditor(COMMUNITIES)`, handing the auditor one
   root -- the same override I had just removed from test_network_auditor, one
   file away. Three modules had dead COMMUNITIES constants left behind.

4. The stricter scan then produced a FALSE positive:
   test_isolates_are_covered_by_id_checks was flagged for a docstring that
   DISCUSSES reverting a loop to `Path("kb/communities").glob("*.yaml")` -- it
   describes the defect it exists to prevent. The scan now strips docstrings and
   comments first; a guard that cannot tell code from commentary teaches people
   to reword their explanations.

Reindenting the status-writer sweep also moved its `assert curation_note`
outside the `if block.get("curated")`, so it briefly asserted a note on every
descriptor and reported a curated pin in a record containing zero occurrences of
`curated:`. Chased to the edit rather than "fixed" in the corpus, and
mutation-checked afterwards: blanking the note in the pinned record fails the
test, restoring it passes.

2833 passed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@realmarcin
realmarcin merged commit 2031b7e into main Aug 28, 2026
5 checks passed
@realmarcin
realmarcin deleted the fix-689-owed-both-roots branch August 28, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty _OWED_BOTH_ROOTS: 11 test modules sweep kb/communities where data/isolates holds the same content

1 participant