Skip to content

bug(score): directory-tree code blocks in README produce broken-reference false positives #293

Closed

Description

@stackbilt-admin

Problem

charter score on a Vite/TypeScript app reports 118 broken path references, dragging Grounding to 11/20. Nearly all of them are bare filenames listed inside a fenced directory tree block in the README, and every one of those files exists in the repo at its real path.

README (abridged):

src/
  terminal/       terminal.types.ts (event protocol), terminalEngine.ts (playback),
                  terminalEvents.ts (builders), terminalEffects.ts, inputHistory.ts
  simulation/     random.ts (seeded RNG), eventQueue.ts, clock.ts

Reported as broken: terminalEvents.ts, simulation/random.ts, escalation.ts, ...

Actual locations:

src/terminal/terminalEvents.ts
src/simulation/random.ts
src/games/globalThermonuclearWar/escalation.ts

Why the existing filters don't catch it

This is a different class from #164 (URLs, env vars, HTTP routes; closed) and #163 (monorepo/absolute paths). #164's fix keeps any token with a file extension, which is exactly what a directory tree is full of. The tokens are real filenames; only the prefix is missing, because a tree diagram expresses the prefix structurally through indentation rather than inline.

Impact

  • 118 false positives against ~0 real ones here, so the number carries no signal.
  • Grounding is the one category a well-documented repo can't win: the more thorough the README's structure section, the worse the score.
  • It pushes authors toward deleting useful documentation, or rewriting trees as fully-qualified path lists, to satisfy the metric.

Suggested fix

Any of these would resolve it:

  1. Skip fenced blocks that look like directory trees — a block whose lines are dominated by indentation plus ├ └ │ / or dir/ headers is a diagram, not a reference list.
  2. Resolve by basename before declaring a reference broken — if exactly one file in the repo matches the basename, count it as resolved. Ambiguous matches could stay unresolved or warn once.
  3. Only validate tokens that look like paths relative to the repo — i.e. containing a / and resolving from root, and treat bare name.ext tokens in prose as prose.

Option 2 also helps #163, since it doesn't depend on the reference being written relative to the repo root.

Repro

Any repo with a README directory-tree section. Observed with @stackbilt/[email protected], charter score, Node 22.14, WSL2.

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