Fix parser import edge cases #19

Closed
codex wants to merge 1 commit from codex/prewave-parser-bugs-v0 into codex/prewave-governance-bootstrap
Collaborator

Canary Context Pack

Product story

Wave 1 should not lock incorrect parser behavior into golden output. Issue #17 verified four v0 parser bugs that affect agent-readable import evidence.

What changed

  • Added regression tests for single-quoted side-effect imports.
  • Added regression tests for multiline imports.
  • Added regression tests for import-looking text inside template literals and block comments.
  • Masked template literals and comments before import parsing.
  • Split side-effect imports from from imports to avoid multiline overmatching.
  • Documented the remaining regex-first limitation around template interpolation.

Why it changed

The current parser emitted false positives and false negatives on common JS/TS source forms. That would make Wave 1 contract goldens canonicalize known-bad behavior.

Files touched

  • src/analyze.ts
  • tests/analyze.test.mjs
  • README.md

Relevant context

  • Refs #17
  • Stacked on PR #18 (codex/prewave-governance-bootstrap)

Runtime evidence

Verified red:

  • npm test failed before the parser fix on the new B1, B2, and B3/B4 regression tests.

Verified green:

  • npm run build
  • npm test
  • node dist/cli.js analyze --root . --format json --output /tmp/fallow-ts-report.json
  • git diff --check

Known constraints

The parser remains regex-first. Comments and template literals are masked, which prevents phantom imports but also means code inside template interpolation is not analyzed yet.

Explicit out-of-scope

  • Full TypeScript AST parsing.
  • Resolver behavior.
  • New analyzer finding categories.
  • Wave 1 fixtures beyond the bug regressions.

Requested decision

Approve and merge after PR #18.

Merge blockers

Regression tests missing the verified cases from #17, parser overclaiming AST-level accuracy, or output false positives from comments/templates.

## Canary Context Pack ### Product story Wave 1 should not lock incorrect parser behavior into golden output. Issue #17 verified four v0 parser bugs that affect agent-readable import evidence. ### What changed - Added regression tests for single-quoted side-effect imports. - Added regression tests for multiline imports. - Added regression tests for import-looking text inside template literals and block comments. - Masked template literals and comments before import parsing. - Split side-effect imports from `from` imports to avoid multiline overmatching. - Documented the remaining regex-first limitation around template interpolation. ### Why it changed The current parser emitted false positives and false negatives on common JS/TS source forms. That would make Wave 1 contract goldens canonicalize known-bad behavior. ### Files touched - `src/analyze.ts` - `tests/analyze.test.mjs` - `README.md` ### Relevant context - Refs #17 - Stacked on PR #18 (`codex/prewave-governance-bootstrap`) ### Runtime evidence Verified red: - `npm test` failed before the parser fix on the new B1, B2, and B3/B4 regression tests. Verified green: - `npm run build` - `npm test` - `node dist/cli.js analyze --root . --format json --output /tmp/fallow-ts-report.json` - `git diff --check` ### Known constraints The parser remains regex-first. Comments and template literals are masked, which prevents phantom imports but also means code inside template interpolation is not analyzed yet. ### Explicit out-of-scope - Full TypeScript AST parsing. - Resolver behavior. - New analyzer finding categories. - Wave 1 fixtures beyond the bug regressions. ### Requested decision Approve and merge after PR #18. ### Merge blockers Regression tests missing the verified cases from #17, parser overclaiming AST-level accuracy, or output false positives from comments/templates.
Fix parser import edge cases
All checks were successful
CI / test (push) Successful in 14s
CI / test (pull_request) Successful in 13s
b5971470fc
Add regression coverage for issue #17 parser bugs: single-quoted side-effect imports, multiline imports, and import-looking text in template literals or block comments. Keep the v0 parser regex-first but mask comments/templates before matching.

Refs #17.

Verified red:

- npm test failed before the parser fix on the new B1, B2, and B3/B4 regression tests

Verified green:

- npm run build

- npm test

- node dist/cli.js analyze --root . --format json --output /tmp/fallow-ts-report.json

- git diff --check
codex closed this pull request 2026-05-17 01:17:25 +02:00
All checks were successful
CI / test (push) Successful in 14s
CI / test (pull_request) Successful in 13s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pdurlej/fallow-ts!19
No description provided.