Skip to content

fix(fs): make expected ENOENT probes silent control flow - #92

Draft
robotlearning123 wants to merge 1 commit into
mainfrom
loop/20260928_040032-issue82
Draft

robotlearning123 wants to merge 1 commit into
mainfrom
loop/20260928_040032-issue82

Conversation

@robotlearning123

Copy link
Copy Markdown
Member

What

  • In src/utils/fs.ts, fileExists, readFile and directoryExists are used as existence probes on every scan. A missing path is expected control flow, not an error, but the catch blocks logged each ENOENT at debug level with the full err object, so every scan emitted pino records carrying complete stack traces plus absolute filesystem paths.
  • ENOENT is now logged at trace level without the err object (observable only with LOG_LEVEL=trace); non-ENOENT errors keep the existing debug record with the error attached.

Why

Test evidence

  • RED first: new test in test/utils.test.ts captures the pino debug records emitted by fileExists/readFile on a missing path and asserts no err.stack and no absolute path. On unmodified main @ e704b49 the suite fails 27/28 (the new test fails with a real captured stack).
  • GREEN after fix, default env, scan of test/fixtures/minimal-repo: grep -c '"stack"' = 0, grep -c '"path":"/' = 0 (baseline 67/67), check exits 0.
  • Behavior unchanged: stdout minus level-20 records is byte-identical before/after (diff empty).
  • LOG_LEVEL=trace still shows all 67 probes at level 10 with no stacks.
  • npx tsx --test test/utils.test.ts: 28/28; test/engine.test.ts + test/checker.test.ts: 20/20; tsc --noEmit clean.

Scope

fileExists, readFile, and directoryExists are used as existence probes
on every scan; a missing path is expected control flow, not an error.
Log ENOENT at trace level without the err object instead of emitting
debug records carrying full stacks and absolute paths. Non-ENOENT
errors keep the existing debug record.
@robotlearning123

Copy link
Copy Markdown
Member Author

Verification (cycle 20260928_040032, issue #82): premise reproduced on main — one fixture scan emitted 67 pino debug records each carrying full err.stack + absolute paths (fs.ts:15/:30 via context.ts:98 and project-type.ts). Two evidence corrections: pino writes to stdout (not stderr — the issue's stderr oracle passes vacuously today), and LOG_LEVEL is already honored (logger.ts:13) so the fix lives at the probe sites only. Fix at head 4dc9526 (src/utils/fs.ts + test/utils.test.ts only — no logger.ts, respecting sibling PR #89): ENOENT catches log logger.trace({path}) without err; non-ENOENT keeps debug+err. Session re-verified by execution in a fresh worktree: stack count 0 (was 67); scan report byte-identical before/after (level-20 records excluded); LOG_LEVEL=trace still shows probes (67 records, 0 stacks); test/utils.test.ts 28 pass / 0 fail; tsc clean. Independent review did NOT run (reviewer lane quota-blocked) — status: needs_work, review-gate only; zero code findings.

One-command resume when the reviewer lane recovers:
git -C /home/robot/workspace/agent-next/agent-ready fetch origin --prune && git -C /home/robot/workspace/agent-next/agent-ready worktree add /tmp/loop-wt-agent-next_agent-ready-issue82 loop/20260928_040032-issue82 2>/dev/null; timeout 540 grok --always-approve --cwd /tmp/loop-wt-agent-next_agent-ready-issue82 -p "REVIEW origin/main...loop/20260928_040032-issue82 on agent-next/agent-ready for correctness, test coverage, and scope creep. Read the actual diff (git diff). Judge against issue #82. Output exactly: VERDICT: SHIP or VERDICT: FIX-FIRST, then findings[] each with file:line + concrete failure scenario + severity, then checked_does_not_hold[]."

@robotlearning123

Copy link
Copy Markdown
Member Author

Reviewer lane recovered — grok review result: VERDICT SHIP. One minor: test/utils.test.ts:55 — the test stubs logger.debug but this branch's ENOENT probes log at trace, so its asserts never execute (debugRecords=0); reverting the directoryExists catch at src/utils/fs.ts:105 to debug would still pass that test. Checked-does-not-hold: no scope creep (diff is fs.ts + one test only), default-scan/Action path clean (0 stacks, 0 log lines on stdout), issue #82 oracle passes (exit 0, empty stderr), non-ENOENT errors correctly stay at debug, listDirectories ENOENT-at-debug has no callers, trace-level absolute paths unreachable under action.yml.

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.

expected-ENOENT probes log full stack traces + absolute paths on every scan

1 participant