Skip to content

coverage/*.html should be filtered by directory, not extension #870

Closed

Description

@akanoodles

coverage/*.html should be filtered by directory, not extension

Repo

safishamsi/graphify — https://github.com/safishamsi/graphify

Summary

The existing noise filter excludes the coverage/ directory at file-collection time, so .ts / .js source files inside coverage/ (rare, but they happen if someone ships a coverage-aware util there) get correctly skipped. However, the generated HTML files produced by Vitest / Istanbul / nyc — coverage/lcov-report/<source-path>.html — are categorised as document and sent to the semantic-extraction subagents. There's typically one HTML file per source file under the report tree, so a project with 800 source files generates ~828 noise documents.

Concrete numbers from one repo on 2026-05-14:

  • 1,277 documents detected in total
  • 828 of those (65%) were coverage/lcov-report/<x>.html
  • The 828 files are mechanically-generated, contain only the coverage report markup for an existing source file, and produce no useful semantic information when extracted

After manual filter:

  • Document count dropped from 1,277 → 449
  • Semantic subagent dispatch dropped from ~64 → 37
  • Net token saving on a single corpus build: ~27 subagents × ~100K tokens = ~2.7M tokens

Repro

Run /graphify . against any Vitest-based monorepo that has run tests recently (coverage/ directory present). Inspect .graphify_detect.json:

$(cat graphify-out/.graphify_python) -c "
import json
from pathlib import Path
d = json.loads(Path('graphify-out/.graphify_detect.json').read_text())
docs = d.get('files', {}).get('document', [])
in_coverage = sum(1 for f in docs if '/coverage/' in f or '/lcov-report/' in f)
print(f'{in_coverage} of {len(docs)} documents are in coverage/')
"

You'll see most of them are in coverage/.

Suggested fix

The detect step should apply the directory-noise filter to all file categories, not just code. Today's behaviour (inferred from observed results — I haven't read your detect.py) appears to be:

# Current behaviour (inferred)
if category == 'code' and any(noise_dir in path for noise_dir in NOISE_DIRS):
    skip

What it should be:

# Suggested
if any(noise_dir in path for noise_dir in NOISE_DIRS):
    skip   # regardless of category

This is a one-line conceptual fix though it may require adjusting the
detect() function's per-category collection logic.

Workaround (today)

Filter .graphify_detect.json between Step 2 (detect) and Step 3 (extract):

def is_noise(f: str) -> bool:
    return (
        '/coverage/' in f or '/lcov-report/' in f or
        '/__snapshots__/' in f or f.endswith('.snap') or
        '/node_modules/' in f or 'package-lock' in f or
        '/dist/' in f or '/dist-protected/' in f or '/build/' in f
    )

for cat, files in detect['files'].items():
    detect['files'][cat] = [f for f in files if not is_noise(f)]

Mechanical but every user has to know to do it.

Related

This is closely related to the visual-tests/ filter request (issue 1). Both share the same root cause: directory-level filtering is currently per-category instead of universal. A single fix covers both.

Activity

  1. safishamsi commented on May 14, 2026

    @safishamsi
    Member

    Fixed in commit 7c561e6 on v7. Added coverage and lcov-report to _SKIP_DIRS in detect.py. These Istanbul/nyc/Vitest HTML report directories are now pruned during os.walk so they never appear in the corpus. Regression tests added, 779 tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions