Skip to content

fix(scripts): a test file is source — the Bun-only rule stops skipping it - #382

Merged
sebyx07 merged 1 commit into
mainfrom
fix/a-test-file-is-source
Aug 27, 2026
Merged

fix(scripts): a test file is source — the Bun-only rule stops skipping it#382
sebyx07 merged 1 commit into
mainfrom
fix/a-test-file-is-source

Conversation

@sebyx07

@sebyx07 sebyx07 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Closes #365. The test-file half of the sweep whose scanner-correctness half merged as #381.

The rule read every test file and threw the answer away

checkNodeImports opened with if (isTestPath(file.path)) continue at both of its walks, from the day it landed. The scanner worked fine; the ratchet dropped its findings. Measured: 404 unexplained node: imports across 164 test files, under a green bun run node-imports, while node-import-pins.ts said 146.

The hole was asserted as correct by a test named "a test file is a test — its imports are the harness, not the shipped surface". That is how it survived a year of edits: the rule that would have caught it had a unit test saying it should not.

CLAUDE.md's non-negotiable exempts nothing — and it already records this exact mechanism happening once before:

In tests too, As of 2026-08checkErrorFixes skips test files, so the rule was prose there and 422 sites accumulated under a green gate.

storage is the proof it mattered in practice: review flagged two of its test files on #364 for exactly this, and storage had no row in the pin table at all.

A fixture is exempt, and both carriers are

maskLiterals blanks string contents and comment text, preserving every offset — so a match survives it exactly when the process would really evaluate the import. It is the mask render-modes, frozen-records, secret-compare and proto-index already read, so no second tokenizer enters the tree.

The old test was a line prefix (// or * at the start), which misses:

  • a specifier inside a template literalpackages/cli/src/templates/ emits app source the CLI writes and never runs
  • a specifier inside a trailing or block commentasync-context-guard.test.ts:106 explains its shape by quoting it

Two rows therefore fell as the rest rose: cli lost 4 template sites, scripts lost 25 fixtures. Both are the mask, not a sweep.

Swept 545 → 209

Nine sites converted rather than annotatedBun.file(p).exists(), Bun.file(p).text() and Bun.write() (which creates intermediate directories, so it is mkdir -p too) retired seven whole node:fs imports.

The rest carry the sentence, because Bun 1.4 genuinely has no replacement: no tmpdir(), no mkdtemp, no recursive remove, and no path API at all. Object.keys(Bun) has file, write, Glob, pathToFileURL and fileURLToPath — nothing that joins a path or makes a directory. node:path is 0-of-127 convertible today, which is the honest reason cli still holds 95 and scripts 28: those are shipped source, and both packages' test-file sites are now entirely answered (336 of them).

before after
cli 360 95
scripts 99 28
every other package 86 86
total 545 209

The one time a pin may rise

It rose because the rule started reading files it was always written to read — not because anything regressed. scripts/node-imports.test.ts holds the 2026-08-26 ceiling and refuses a raise past it, so the ratchet only falls from here.

Verified

  • bun run verify — 14 of 20 passed, 6 skipped (drift, contract-diff, budgets, seo, i18n, policy), the documented root baseline
  • bun run scripts/reference-app-gate.ts — every pin holds: examples/dummy 18/20 (2 pinned), dummy/social-media-clone 18/20 (2 pinned)
  • bun run node-imports --json re-derives the table; CLAUDE.md and wiki/Error-Codes.md are updated to say what it now measures, and to say --json is what to read

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

…g it

`checkNodeImports` opened with `if (isTestPath(file.path)) continue` at
both of its walks, from the day it landed. So the SCANNER read every test
file and the RATCHET dropped every finding: **404 unexplained `node:`
imports across 164 test files**, under a green `bun run node-imports`,
while the pin table said 146.

The hole was ASSERTED AS CORRECT by a test named *"a test file is a test
— its imports are the harness, not the shipped surface"*, which is how it
survived. `CLAUDE.md`'s non-negotiable exempts nothing, and it already
records this exact mechanism happening once before: "`checkErrorFixes`
skips test files, so the rule was prose there and 422 sites accumulated
under a green gate". `storage` is the proof it mattered — review flagged
two of its test files on #364 and `storage` had no row in the pin table
at all.

A FIXTURE IS EXEMPT, and both carriers are. `maskLiterals` blanks string
contents and comment text alike while preserving every offset, so a match
survives it exactly when the process would really evaluate the import.
The old line-prefix test (`//` or `*` at the start) missed a specifier
inside a template literal — `packages/cli/src/templates/` emits app source
the CLI writes and never runs — and `async-context-guard.test.ts:106`
explains its shape by quoting it. Two rows FELL as the rest rose: `cli`
lost 4 template sites, `scripts` lost 25 fixtures.

Swept 545 -> 209. Nine sites were CONVERTED rather than annotated —
`Bun.file(p).exists()`, `Bun.file(p).text()` and `Bun.write()` (which
creates intermediate directories) retired seven whole `node:fs` imports.
The rest carry the sentence, because Bun 1.4 has no `tmpdir()`, no
`mkdtemp`, no recursive remove and **no path API at all**: `Object.keys(Bun)`
has `file`, `write`, `Glob`, `pathToFileURL`, `fileURLToPath`, and nothing
that joins a path or makes a directory.

This is the one time a number in `node-import-pins.ts` may rise, and it
rose because the rule started reading files it was always written to read.
`scripts/node-imports.test.ts` holds the 2026-08-26 ceiling and refuses a
raise past it.

Fixes #365

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

On-demand reviews are free for the next 25 days. After that, they cost $0.25 per reviewed file.

Or wait 27 minutes for your next included review.

View limit details

Limit details: You’ve used the included review currently available. Your 76 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Run ID: aba8a4a9-2cf7-4684-b4b7-ef5cfa26ab02

📥 Commits

Reviewing files that changed from the base of the PR and between c928163 and c978c2f.

📒 Files selected for processing (139)
  • CLAUDE.md
  • packages/cli/e2e/registry-boot.e2e.test.ts
  • packages/cli/src/app-agents-md.test.ts
  • packages/cli/src/app-auth.test.ts
  • packages/cli/src/app-boundaries.test.ts
  • packages/cli/src/app-entities.test.ts
  • packages/cli/src/app-env.test.ts
  • packages/cli/src/app-evals.test.ts
  • packages/cli/src/app-load.test.ts
  • packages/cli/src/app-manifest.test.ts
  • packages/cli/src/budgets.test.ts
  • packages/cli/src/caught-value-reads.test.ts
  • packages/cli/src/cmd-affected.test.ts
  • packages/cli/src/cmd-build.test.ts
  • packages/cli/src/cmd-db-backfill.test.ts
  • packages/cli/src/cmd-db-branch.test.ts
  • packages/cli/src/cmd-db.test.ts
  • packages/cli/src/cmd-deploy.test.ts
  • packages/cli/src/cmd-dev.live.test.ts
  • packages/cli/src/cmd-dev.test.ts
  • packages/cli/src/cmd-docs.test.ts
  • packages/cli/src/cmd-doctor.test.ts
  • packages/cli/src/cmd-env.test.ts
  • packages/cli/src/cmd-fix.test.ts
  • packages/cli/src/cmd-generate-i18n.test.ts
  • packages/cli/src/cmd-generate.test.ts
  • packages/cli/src/cmd-i18n.test.ts
  • packages/cli/src/cmd-jobs.test.ts
  • packages/cli/src/cmd-manifest.test.ts
  • packages/cli/src/cmd-mcp.test.ts
  • packages/cli/src/cmd-new-git.test.ts
  • packages/cli/src/cmd-new.test.ts
  • packages/cli/src/cmd-policy.test.ts
  • packages/cli/src/cmd-registries.test.ts
  • packages/cli/src/cmd-routes.test.ts
  • packages/cli/src/cmd-secrets.test.ts
  • packages/cli/src/cmd-shot.test.ts
  • packages/cli/src/cmd-tasks.test.ts
  • packages/cli/src/cmd-test.test.ts
  • packages/cli/src/cmd-verify.test.ts
  • packages/cli/src/compile-externals.test.ts
  • packages/cli/src/db-branch.test.ts
  • packages/cli/src/db-destructive.test.ts
  • packages/cli/src/db-generate.test.ts
  • packages/cli/src/db-seed.test.ts
  • packages/cli/src/db-snapshot.test.ts
  • packages/cli/src/db-ungeneratable.test.ts
  • packages/cli/src/dev-assets.test.ts
  • packages/cli/src/dev-cache.test.ts
  • packages/cli/src/dev-dashboard.test.ts
  • packages/cli/src/dev-lock.test.ts
  • packages/cli/src/dev-purge.live.test.ts
  • packages/cli/src/dev-queue.test.ts
  • packages/cli/src/dev-roles-csp.test.ts
  • packages/cli/src/dev-roles-error-page.test.ts
  • packages/cli/src/dev-roles-http-config.test.ts
  • packages/cli/src/dev-roles-identity.test.ts
  • packages/cli/src/dev-roles.live.test.ts
  • packages/cli/src/dev-roles.test.ts
  • packages/cli/src/dev-runtime-storage.test.ts
  • packages/cli/src/dev-runtime.live.test.ts
  • packages/cli/src/dev-runtime.test.ts
  • packages/cli/src/dev-services.test.ts
  • packages/cli/src/dev-storage.test.ts
  • packages/cli/src/dispatch.test.ts
  • packages/cli/src/drift.test.ts
  • packages/cli/src/error-catalog.test.ts
  • packages/cli/src/error-contract-codes.test.ts
  • packages/cli/src/error-contract-paths.test.ts
  • packages/cli/src/error-contract.test.ts
  • packages/cli/src/error-fixes.test.ts
  • packages/cli/src/error-pages.test.ts
  • packages/cli/src/favicon.test.ts
  • packages/cli/src/fix-imports.test.ts
  • packages/cli/src/flag-reads.test.ts
  • packages/cli/src/framework-scope.test.ts
  • packages/cli/src/generate-format.test.ts
  • packages/cli/src/guards.test.ts
  • packages/cli/src/i18n-audit.test.ts
  • packages/cli/src/i18n-index.test.ts
  • packages/cli/src/island-bundle.test.ts
  • packages/cli/src/island-routes.test.ts
  • packages/cli/src/island-shot.test.ts
  • packages/cli/src/island-states-load.test.ts
  • packages/cli/src/island-styles.test.ts
  • packages/cli/src/jobs-driver.test.ts
  • packages/cli/src/live-routes.test.ts
  • packages/cli/src/mcp-host-tools.test.ts
  • packages/cli/src/migrations.test.ts
  • packages/cli/src/prerender.test.ts
  • packages/cli/src/schema-drift.test.ts
  • packages/cli/src/serve.live.test.ts
  • packages/cli/src/source-files.test.ts
  • packages/cli/src/static-report.test.ts
  • packages/cli/src/storage-surfaces.test.ts
  • packages/cli/src/templates/emitted-contract.test.ts
  • packages/cli/src/templates/scaffold-guards.test.ts
  • packages/cli/src/test-select.test.ts
  • packages/cli/src/tsconfig-references.test.ts
  • packages/cli/src/verify-floor.test.ts
  • packages/cli/src/verify-run.test.ts
  • packages/cli/src/verify-tests.test.ts
  • packages/cli/src/version-loader.test.ts
  • packages/cli/src/workspace-checks.test.ts
  • packages/cli/src/workspace-graph.test.ts
  • packages/cli/src/write-line.test.ts
  • scripts/async-context-guard.test.ts
  • scripts/bench-claims.test.ts
  • scripts/browser-barrel.test.ts
  • scripts/bun-pin.test.ts
  • scripts/catch-render.test.ts
  • scripts/chart-version.test.ts
  • scripts/compose-parity.test.ts
  • scripts/config-readers.test.ts
  • scripts/image-contract.test.ts
  • scripts/lib/browser-barrel-set.test.ts
  • scripts/lib/gated-apps.test.ts
  • scripts/lib/node-import-pins.ts
  • scripts/lib/unpin.test.ts
  • scripts/lib/workspaces.test.ts
  • scripts/lockfile-pins.test.ts
  • scripts/manifest.test.ts
  • scripts/node-imports.test.ts
  • scripts/node-imports.ts
  • scripts/package-map-graph.test.ts
  • scripts/reference-app-gate-build-graph.test.ts
  • scripts/reference-app-gate-floor.test.ts
  • scripts/reference-app-gate-unpin.test.ts
  • scripts/release-workflow.test.ts
  • scripts/roadmap.test.ts
  • scripts/scaffold-smoke-overrides.test.ts
  • scripts/secret-compare.test.ts
  • scripts/side-effects.test.ts
  • scripts/stdout-truncation.test.ts
  • scripts/test-typecheck-gate.test.ts
  • scripts/tier-table-drift.test.ts
  • scripts/verify.test.ts
  • scripts/version-stamps.test.ts
  • wiki/Error-Codes.md

Comment @coderabbitai help to get the list of available commands.

@developerz-ai

developerz-ai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Looks good — CI is green, this is a patch-level bug fix to the node-imports rule, and no risk signals apply. Ready for merge when you're ready. Feel free to tag with ready-to-merge if you'd like this lane to handle it.

🤖 Posted by developerz.ai — the maintainer agent, not a human.

@sebyx07

sebyx07 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@sebyx07

sebyx07 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Merging without a CodeRabbit review, and recording why. Its included-review allowance is exhausted (76 attempts over 7 days → 1 review/hour), and both an automatic pass and an explicit @coderabbitai review came back Review rate limited.

What stands in its place:

  • 38 CI checks: 37 pass, 1 skip. The full gate, both tracked apps' gate, the scaffold smoke test, the container build, and every package tested alone.
  • bun run verify — 14 of 20, 6 skipped (drift, contract-diff, budgets, seo, i18n, policy), the documented root baseline.
  • bun run scripts/reference-app-gate.ts — every pin holds.
  • The substantive half was reviewed. fix(scripts,cli): a mask that desyncs on one emoji, and a rule spelled by name #381 carried the scanner-correctness changes and took a CodeRabbit finding on screeningCallPattern (a \b boundary matching property-qualified callees), fixed with regression tests before merge. What is here is that work's sweep: one scanner change reusing the same maskLiterals seam four other rules already read, plus 137 one-line why: annotations.

Nothing here is unreviewable-and-unverified; it is reviewed-by-machine-gate and unreviewed-by-CodeRabbit, which is a different claim and the accurate one.

@sebyx07
sebyx07 merged commit 70c3787 into main Aug 27, 2026
38 checks passed
@sebyx07
sebyx07 deleted the fix/a-test-file-is-source branch August 27, 2026 02:18
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@sebyx07 The merge record is clear.

The CodeRabbit review did not run because of the documented rate limit. The PR has independent verification from the CI checks, bun run verify, and bun run scripts/reference-app-gate.ts. The scanner-correctness change also received review and regression coverage in #381.

The statement correctly distinguishes verified changes from an executed CodeRabbit review.

You are interacting with an AI system.

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.

node-imports: the Bun-only rule stops at the test boundary, and 443 imports have accumulated behind it

1 participant