Skip to content

refactor(impact): split five modes into impact/ submodules + fixture-based unit tests#648

Merged
coseto6125 merged 2 commits into
mainfrom
chore/impact-split
Jul 22, 2026
Merged

refactor(impact): split five modes into impact/ submodules + fixture-based unit tests#648
coseto6125 merged 2 commits into
mainfrom
chore/impact-split

Conversation

@coseto6125

Copy link
Copy Markdown
Owner

What

Splits crates/ecp-cli/src/commands/impact.rs (2143 lines — the hottest file in the repo, 23 changes across 300 commits) into commands/impact/{mod,bfs,symbol,baseline,literal,coverage}.rs, mirroring the existing commands/{admin,dev,group}/ submodule convention. Adds the first non-subprocess unit tests for the mode logic.

Why

The file flat-packed five independent "impact" sub-modes (symbol lookup, git-baseline diff, path-literal search, literal-coherence split-brain detection, test-coverage gap analysis) sharing one BFS kernel. High edit frequency + high line count made every change here carry unnecessary review surface and merge-conflict risk.

C1 — pure code motion

  • mod.rs: run() dispatch, ImpactArgs, Direction, shared helpers (resolve_min_conf, direction_str, attach_hidden_edges, attach_heuristic_fields, tag_heuristic, emit_hidden_edges_footer, parse_csv_lower), and pub use re-exports so every external call site (main.rs, group/impact.rs, peers_plan.rs, review/aggregate.rs) keeps compiling unchanged.
  • bfs.rs: the shared run_bfs kernel plus MergedNodeMeta/MergedEdgeRef merged-space helpers — both symbol.rs and baseline.rs depend on it.
  • symbol.rs: impact_by_name, LocalImpact, run_for_symbol, collect_blind_spots.
  • baseline.rs: impact_with_baseline, hash_node_lines, head_blob_at.
  • literal.rs: build_literal_payload, build_literal_coherence_payload, and the literal-similarity helpers, plus the existing literal_coherence_tests module.
  • coverage.rs: classify_symbol, coverage_analyses, build_coverage_json.

Verified pure motion by sorting and diffing the original file's stripped body against the concatenated new modules — every line delta is accounted for by visibility keyword additions (pub(super)), module-qualified call paths, and rustfmt re-wrapping; zero logic drift.

C2 — fixture-based unit tests

Every existing impact_*.rs test spawns the built ecp binary + git init + ecp admin index subprocess. build_payload and run_for_symbol are pub fns taking &Engine, so they're directly unit-testable: serialize a synthetic ZeroCopyGraph to a tempdir graph.bin and Engine::load it — no subprocess, no CLI binary spawn, no .sample_repo or ~/.ecp touch.

New file crates/ecp-cli/tests/impact_fixture_unit.rs covers:

  • symbol-mode payload shape on a caller chain (depth/filePath/name fields present)
  • ambiguous-name error when two same-named symbols exist with no --file/--kind disambiguator
  • --file disambiguator resolving the same ambiguous pair
  • direction up vs down producing different, correct result sets
  • depth limit stopping BFS before the full chain is traversed
  • run_for_symbol wrapping build_payload correctly (direct_symbol_uids/direct_count consistency)

All 6 new tests run in ~0ms total, vs the 200-700ms+ per-test subprocess cost of the existing suite.

Verification

  • cargo test -p egent-code-plexus --tests — full suite green (all pre-existing impact_*.rs files pass unchanged, plus the 6 new fixture tests)
  • cargo clippy -p egent-code-plexus --tests — clean, no new warnings
  • rustfmt --edition 2021 on every touched file — no-op (already formatted)

impact.rs was the hottest file in the repo (23 changes in 300 commits)
because it flat-packed five independent impact sub-modes (symbol,
baseline, literal, literal-coherence, coverage) into one 2143-line file
sharing a single BFS kernel. Splits into commands/impact/{mod,bfs,
symbol,baseline,literal,coverage}.rs, mirroring the existing
commands/{admin,dev,group}/ submodule convention.

Pure code motion: mod.rs keeps run() dispatch, ImpactArgs, and the
shared attach_*/resolve_min_conf/direction_str helpers plus pub
re-exports so every external call site (main.rs, group/impact.rs,
peers_plan.rs, review/aggregate.rs) keeps compiling unchanged. bfs.rs
holds run_bfs and the MergedNodeMeta/MergedEdgeRef merged-space
helpers; symbol.rs and baseline.rs both depend on it.
…symbol

Every existing impact_*.rs test spawns the ecp binary + git init +
ecp admin index subprocess. build_payload and run_for_symbol are pub
fns taking &Engine, so they're unit-testable directly: serialize a
synthetic ZeroCopyGraph to a tempdir graph.bin and Engine::load it,
mirroring the fixture pattern in impact_heuristic_filter.rs and
ecp_core::cypher::executor's build_two_node/build_three_chain helpers.

Covers symbol-mode payload shape on a caller chain, the ambiguous-name
error path (two same-named defs, no --file/--kind), direction up vs
down producing different result sets, and depth-limit enforcement.
Runs in milliseconds with zero subprocess/binary/git overhead.
@coseto6125
coseto6125 enabled auto-merge (squash) July 22, 2026 17:29
@coseto6125 coseto6125 added the merge-queue Opt-in to Mergify merge queue label Jul 22, 2026
@coseto6125
coseto6125 disabled auto-merge July 22, 2026 17:35
@github-actions

Copy link
Copy Markdown
Contributor
ecp impact cache (0 symbols) — internal, used by ecp dev pr-analyze

[]

@github-actions github-actions Bot added the ecp:risk-low ecp signal label Jul 22, 2026
@coseto6125
coseto6125 enabled auto-merge (squash) July 22, 2026 17:53
@coseto6125
coseto6125 merged commit 690d3cb into main Jul 22, 2026
18 checks passed
@coseto6125
coseto6125 deleted the chore/impact-split branch July 22, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ecp:risk-low ecp signal merge-queue Opt-in to Mergify merge queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant