Repository navigation
feat(cli): rank first-test candidates by direct symbol evidence (#444) - #465
Merged
Merged
Conversation
Add rankFirstTests(root, files, opts) in packages/cli/src/commands/test-rank.ts. Tests that import the seed's exported symbols by name (through re-exports or the seed's package name) rank first by reference count, then direct importers, then capped transitive importers with the rest collapsed. Each candidate has a reason and a ready-to-run vitest command; `unknown` is set when direct evidence runs out. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
rankFirstTests(root, files, opts)inpackages/cli/src/commands/test-rank.ts, which answers "what test should I run first?" for a seed file. It ranks by direct symbol evidence instead of import distance:import * as nscount too) from a module that reaches the seed, including through re-exports, or from the seed's own package name (@stackbilt/adf). Ordered by reference count. A test that imports the same name from an unrelated module does not count.collapsed: { count, maxDepth, note }.Each candidate has
{ file, rank, tier, reason, refs?, depth, command }, wherecommandispnpm exec vitest run <repo-relative path>. If the seed is itself a test file, it ranks first.unknownisnullwhen there is a direct answer. Otherwise it says what's missing: "only transitive candidates", "evidence ran out", or "seed file not found".opts.symbolslimits the evidence to the named symbols, andopts.graphreuses a blast graph that's already built.This is a new file. It reuses
buildGraphandresolveSpecifierfrom@stackbilt/blast, which is unchanged and has no new dependencies. It changes no existing CLI output, JSON output or exit codes. Hooking it into preflight is left to the integration PR.For seed
packages/adf/src/manifest.tson this repo,bundler.test.tsranks first with "calls parseManifest (16), resolveModules (7)". Withsymbols: ['resolveModules']the reason is "calls resolveModules (7)".Verified
pnpm exec tsc --build tsconfig.build.json: cleanpnpm exec tsc --noEmit -p tsconfig.json: cleanpnpm exec vitest run packages/cli/src/__tests__/test-rank.test.ts: 9/9 pass. The fixture covers re-export, alias, namespace, bare package, name collision, the transitive cap,unknownand seed-is-test. Two tests run on this repo's real files and cover the acceptance criteria: bundler.test.ts ranks first, and no transitive candidate ranks above a direct one.pnpm exec vitest run(run 1, machine loaded by parallel worktrees): the failures were the known Windows ones (bootstrap bootstrap: phases 6/7 collect warnings without printing them; absoluteAiDirArg misses Windows paths on POSIX #307, context-refresh, serve-context, github-commit-range), plus 5s timeouts in adf-vendor-doctor-score, adf-vendor-legacy, generated-context and integration/bootstrap-reset-cli. I re-ran those four files on their own and all 148 tests passed. A second full run had not finished when this PR was opened.node packages/cli/dist/bin.js adf evidence --auto-measure --ci --format text: PASS. adf_migrate_loc is at 792/792 (already the case on main). The pre-commit hook passed.Not done
import()with destructuring andrequirebindings fall back to import distance.Closes #444
Part of #437
🤖 Generated with Claude Code