Skip to content

fix: surface unreadable files as estimated tokens instead of 0 - #39

Merged
royalpinto007 merged 2 commits into
AgentPostmortem:mainfrom
sharadvc:fix/surface-unreadable-files
Sep 18, 2026
Merged

royalpinto007 merged 2 commits into
AgentPostmortem:mainfrom
sharadvc:fix/surface-unreadable-files

Conversation

@sharadvc

Copy link
Copy Markdown
Contributor

What does this PR do?

Closes #11. An unreadable file (e.g. EACCES / mode-000) was silently reported as a clean 0-token source because readFileSync throws and the catch returned { tokens: 0, sample: "" }. That hid real content from classification and totals. Now a 200 KB unreadable file is estimated from its known size (size/4) and flows through classification (→ "large" → trim) instead of reading as clean.

Checklist

  • Tests pass (node --test) — 18 passed / 0 failed
  • Diff is minimal: src/scan.js (read-catch returns estimated tokens) + regression test
  • No README change needed (behavior fix)
  • Followed existing code style
  • Added a CHANGELOG.md entry

Notes

Test-first: the new test failed (got 0) before the fix, then passed. CI smoke (node bin/ctxtrim.js test/fixtures/sample-repo --format json) OK. Authored with AI assistance; change reviewed and verified locally (commit c1b9860, matches prior teammate report).

@sharadvc
sharadvc force-pushed the fix/surface-unreadable-files branch from d8dbe24 to 70a1b2f Compare September 17, 2026 02:50
@royalpinto007
royalpinto007 merged commit 6ad06e7 into AgentPostmortem:main Sep 18, 2026
1 check passed
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.

Unreadable files silently reported as clean 0-token source

2 participants