Skip to content

fix(cli): analyze the baseline under the current checkout's config instead of re-loading it in the worktree - #400

Merged
oekazuma merged 1 commit into
mainfrom
advisor/046-baseline-config-once
Aug 8, 2026
Merged

oekazuma merged 1 commit into
mainfrom
advisor/046-baseline-config-once

Conversation

@oekazuma

@oekazuma oekazuma commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Summary

--baseline <ref> checks out <ref> into a worktree under os.tmpdir() and runs analyzeProject there — which re-loaded svelte-vitals.config.* from the worktree, a directory with no node_modules anywhere in its ancestry (git worktrees only contain tracked content). The install wizard's own .ts scaffold emits import { defineConfig } from 'svelte-vitals' (a runtime bare-specifier import), so for every project that took the wizard's default, the baseline-side config load threw ERR_MODULE_NOT_FOUND, the catch logged one stderr line, and all findings were reported as new — the PR gate exited 1 on unrelated changes. The tool's own scaffolder produced the config that disabled the tool's own baseline gate.

Second, quieter wrong: even when the worktree config did load, it was the ref's config, so the two sides of the comparison ran under different rule sets whenever the config changed between ref and HEAD — a config-only edit produced "introduced" findings.

Semantics

The current checkout's config now governs both sides of the comparison: a baseline run answers "which findings does my change introduce, under today's policy?" — policy is an input to the comparison, not part of the compared code.

Changes

  • AnalyzeOptions.loadedConfig?: LoadedConfigFile | null (additive, public API): reuse a prior loadConfigFile() result instead of loading from cwd; null means "no config file — don't look". AnalyzeResult.loadedConfig returns the load result so run() can thread it into the baseline call via analyzeOpts.
  • 2 regression tests running the real checkoutBaseline (real git repo + real git worktree add, config importing an untracked node_modules/fake-pkg): (1) the ERR_MODULE_NOT_FOUND shape — new finding reported, pre-existing finding filtered, no degradation message on stderr; (2) config-governs-both-sides — a config-only rule re-enable does not report the pre-existing finding as introduced. Both were shown to fail without the fix (via git stash of the src change).

Note for the action repo

svelte-vitals-action bundles applyScope directly; its baseline path keeps the old re-load-from-worktree behavior until it passes analyzeOpts.loadedConfig the same way run() now does. Small follow-up candidate there.

Verification

pnpm -r typecheck / pnpm test (core 1292, cli 824, vite 207) / pnpm lint all green; io-budget.test.ts untouched and passing (no new collector I/O).

🤖 Generated with Claude Code

…stead of re-loading it in the worktree

--baseline checks out the ref into a git worktree under os.tmpdir(), which
has no node_modules in its ancestry. analyzeProject re-loaded
svelte-vitals.config.* from that worktree cwd, so any config that imports a
runtime dependency (e.g. the install wizard's own .ts scaffold, which does
`import { defineConfig } from 'svelte-vitals'`) threw ERR_MODULE_NOT_FOUND,
silently degrading the baseline comparison to "report everything".

Add AnalyzeOptions.loadedConfig (LoadedConfigFile | null) so a caller can
hand analyzeProject an already-loaded config instead of loading one from its
cwd; null means "no config file, don't look for one" and is distinct from
undefined ("load normally"). run() now threads its own loadConfigFile()
result (surfaced via the new AnalyzeResult.loadedConfig) into the baseline
analyzeProject call, so both sides of the comparison run under the current
checkout's config. This also fixes a quieter bug: a config edit between the
baseline ref and HEAD no longer makes unrelated findings look "introduced".
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@oekazuma, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 19 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ef44ab48-937e-4b21-9252-0339958af11a

📥 Commits

Reviewing files that changed from the base of the PR and between 9e0cf9e and 076580e.

📒 Files selected for processing (3)
  • .changeset/baseline-config-once.md
  • packages/cli/src/index.ts
  • packages/cli/test/run-baseline.test.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@oekazuma
oekazuma merged commit 87d5d62 into main Aug 8, 2026
8 checks passed
@oekazuma
oekazuma deleted the advisor/046-baseline-config-once branch August 8, 2026 02:20
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.

1 participant