Skip to content

EpubTextPreprocessorTest fuzz-recall check is vacuous for 2 of 9 clutter injections (trailing-newline marker + final trim()) #504

Open

Description

@github-actions

Where

feature/reader/src/test/kotlin/xyz/libravault/feature/reader/epub/EpubTextPreprocessorTest.kt, added in PR #501 — the new every clutter injection is removed (recall) while base prose survives (precision), across all base passages fuzz test and its clutterInjections matrix.

What's broken

Two of the nine ClutterInjection entries use a marker string that requires a newline on both sides:

ClutterInjection("standalone page number", { base -> "$base\n47\n" }, "\n47\n"),
...
ClutterInjection("roman numeral page", { base -> "$base\nxiv\n" }, "\nxiv\n"),

Both injectors append their clutter at the very end of the base passage, with a trailing \n. EpubTextPreprocessor.clean()'s last stage, normalizeWhitespace(), unconditionally calls .trim() on the whole string. When the injected text is the last thing in the string, that final .trim() strips the trailing \n regardless of whether the actual clutter-removal regex upstream (removeStandalonePageNumbers / removeRomanNumeralPageNumbers) did its job — which removes the second \n the marker string needs, so cleaned.contains(marker) is false either way.

Verified

Confirmed directly against the real (unmodified) EpubTextPreprocessor.clean() via a standalone kotlinc run, then again with removeStandalonePageNumbers patched to a no-op (this // BUG: no-op) to simulate a total regression:

removeStandalonePageNumbers working completely disabled (simulated regression)
cleaned tail ...foolishness. ...foolishness.\n47
47 actually present in output no yes
cleaned.contains("\n47\n") (the test's assertion) false (correctly passes) false (incorrectly still passes)

Same result for removeRomanNumeralPageNumbers / the "\nxiv\n" marker.

So for these 2 of 9 injection types (6 of the 27 matrix cells, once crossed with the 3 base passages), the recall assertion is vacuously true — it would not catch removeStandalonePageNumbers or removeRomanNumeralPageNumbers being deleted entirely, let alone a narrower regression. The lostWords precision assertion in the same test doesn't cover this either, since digits aren't "significant words" ([A-Za-z]{3,}).

This is exactly the trap AGENTS.md's "Prove a new test can fail" section calls out by name (deliberately break the code path and confirm red before trusting a test). The PR's own verification checklist only describes cross-checking the logic against a Python port, not proving each new assertion can go red — which is how this specific gap made it through.

Why it matters

Not a functional bug in EpubTextPreprocessor itself (production code is untouched by PR #501) — the bug is that two of the new fuzz assertions silently don't test what they claim to test, undermining the reliability claims the PR is making the tests for.

Suggested fix

Use a marker that doesn't depend on trailing-newline structure being preserved by the final .trim() — e.g. check for the literal digits/numeral ("47", "xiv") with word-boundary-safe containment against the pre-trim structure, or place these two injections mid-passage (like "labelled page number" already does) rather than appended at the very end.

Filed per PR #501's principal review (risk:low, but this CONFIRMED finding forces status:needs-human-merge regardless of risk tier).

Activity

  1. libravault-xyz commented on Aug 26, 2026

    @libravault-xyz
    Collaborator

    Automated pipeline health check: This issue (filed by github-actions[bot], CONTRIBUTOR association) has received zero dev-agent.yml runs and zero explanatory comment of any kind since it was filed.

    Same author-association trust-gate-skip signature already tracked on #469/#475/#479/#388/#408/#433/#437/#441/#544/#558/#582 — but unlike that earlier batch, this issue never got even the explain-trust-gate-skip job's own skip-reason comment, consistent with the regression confirmed on #437/#441 (that job's gh issue comment step has no actions/checkout/--repo, so it fails before posting: fatal: not a git repository).

    Not self-healing: no status label to toggle, and .github/workflows/dev-agent.yml is a sensitive path this routine won't edit.

    This now makes at least 13 open issues sitting with zero pipeline engagement: #469, #475, #479, #487, #504, #523, #534, #556, #557, #559, #561, #581, #589, #611, #626, #639. A tracked issue for the underlying explain-trust-gate-skip checkout/--repo bug has been recommended across at least two prior automated runs (2026-08-23 on #469, 2026-08-24 on #437/#441) but doesn't appear to have been filed yet.

    Action needed: someone with write access can workflow_dispatch triage this issue manually, and/or fix explain-trust-gate-skip's gh issue comment step (add actions/checkout or --repo ${{ github.repository }}) so future instances self-report instead of going silent.


    Generated by Claude Code

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