Refactor impact analysis module boundaries#27
Merged
Conversation
Document scoped implementation tasks for impact workflow, cache lifecycle, test recommendation, graph edge semantics, and CLI execution refactors.
Split impact selection orchestration into focused internal modules for changed-file handling, graph preparation, and test selection. Preserves public command behavior while improving locality around the analysis pipeline. Verification: - pnpm test - pnpm lint - pnpm benchmark Benchmark: - shared-root [1441 files]: 66.8710 hz, mean 14.9542 ms - deep-branch [1441 files]: 96.4631 hz, mean 10.3667 ms - deep-branch 1.44x faster than shared-root
Move cache scan reuse, metadata staging, metrics, and save policy into a dedicated impact cache lifecycle module. This keeps graph workflow focused on orchestration while preserving cache format, diagnostics, and failure-tolerant cache writes. Verification: - pnpm test - pnpm lint - pnpm benchmark Benchmark: - shared-root [1441 files]: 65.4058 hz, mean 15.2892 ms - deep-branch [1441 files]: 88.3971 hz, mean 11.3126 ms - deep-branch 1.35x faster than shared-root
Move run-all, shared-target, dependency, containment, de-duplication, and reason ordering policy into a dedicated recommendation module. Keeps output reason shapes and legacy matching imports compatible while giving recommendation behavior a direct test surface. Verification: - pnpm test - pnpm lint - pnpm benchmark Benchmark: - shared-root [1441 files]: 72.6239 hz, mean 13.7696 ms - deep-branch [1441 files]: 103.07 hz, mean 9.7024 ms - deep-branch 1.42x faster than shared-root
Centralize resolved edge creation, cached edge normalization, synthetic containment expansion, traversal classification, and deterministic sorting. This keeps buildGraph focused on orchestration while preserving graph shape, traversal behavior, and cache compatibility. Verification: - pnpm test - pnpm lint - pnpm benchmark Benchmark: - first run had noisy deep-branch outlier: shared-root mean 16.1344 ms, deep-branch mean 15.5197 ms - rerun: shared-root [1441 files]: 66.8837 hz, mean 14.9513 ms - rerun: deep-branch [1441 files]: 99.5613 hz, mean 10.0441 ms - rerun deep-branch 1.49x faster than shared-root
Extract shared CLI diagnostics, status tracking, error reporting, and flush behavior into a dedicated execution wrapper. This removes duplicated impact/run action boilerplate while preserving validation, output, exit-code, and diagnostics behavior. Verification: - pnpm test - pnpm lint Benchmark skipped because this only changes CLI execution plumbing, not impact analysis, graph, scanner, resolver, cache, or test matching behavior.
Remove task brief files from the PR and rename new impact helper modules/tests to shorter names within their existing folders. Verification: - pnpm test - pnpm lint
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.
What is this?
This PR deepens the internal architecture around Sniffler's impact analysis pipeline. The previous implementation kept many policies in a few broad orchestration files, especially impact selection and graph building, which made cache behavior, test recommendation rules, graph edge semantics, and CLI execution flow harder to reason about independently.
This change keeps the public CLI and output behavior intact while moving those policies behind focused internal modules with direct test coverage.
How does it work?
The impact command now coordinates smaller internal modules for changed-file handling, graph preparation, cache lifecycle, and test selection. Cache scan reuse and save policy live in
src/impact/cache-lifecycle.ts, while test recommendation rules move into a dedicated recommendation module that owns run-all reasons, shared targets, containment reasons, de-duplication, and reason ordering.Graph edge construction and traversal participation rules are centralized in a graph edge semantics module, so import, re-export, export-all, synthetic containment, cached edge normalization, and deterministic sorting logic live together. CLI command actions now share a wrapper for diagnostics setup, status tracking, error reporting, and flushing.
Why is this useful?
This makes future changes to Sniffler easier to review and safer to test. Each policy area now has better locality, so fixes to cache behavior, recommendation rules, edge semantics, or CLI diagnostics no longer require working through the full impact command implementation.
The new seams also give tests more natural surfaces: cache lifecycle, recommendation policy, graph edge semantics, and CLI execution can be verified directly. That should reduce accidental regressions while preserving the existing behavior expected by CLI users and integrations.