Skip to content

Refactor impact analysis module boundaries#27

Merged
V3RON merged 7 commits into
masterfrom
refactor/deepen-analysis-modules
Jul 1, 2026
Merged

Refactor impact analysis module boundaries#27
V3RON merged 7 commits into
masterfrom
refactor/deepen-analysis-modules

Conversation

@V3RON

@V3RON V3RON commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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.

V3RON added 7 commits July 1, 2026 10:04
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
@V3RON V3RON merged commit df76dbf into master Jul 1, 2026
6 checks passed
@V3RON V3RON deleted the refactor/deepen-analysis-modules branch July 1, 2026 09:53
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