Skip to content

ACTCLI-28: Refactor run_sync_with_probe: break up 555-line god function into phases#742

Draft
poiley wants to merge 1 commit into
mainfrom
factory/actcli-28
Draft

ACTCLI-28: Refactor run_sync_with_probe: break up 555-line god function into phases#742
poiley wants to merge 1 commit into
mainfrom
factory/actcli-28

Conversation

@poiley

@poiley poiley commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Resolves ACTCLI-28.

  • Extracted the 626-line run_sync_with_probe god function into 6 independently-testable phase functions: run_environment_phase, run_analysis_phase, run_fetch_phase, run_tailor_phase, run_write_phase, run_telemetry
  • Added EnvironmentPhaseResult, FetchPhaseResult, and TailorPhaseResult structs with clear input/output contracts for each phase
  • Reduced run_sync_with_probe to a ~15-line coordinator that calls the phases in sequence
  • Added 7 unit tests covering each extracted phase function directly (environment probe failure/success, analysis force mode, analysis filter no-match, fetch success, tailor no-tailor flag, write phase dry run)
  • Removed #[allow(clippy::too_many_arguments)] from all extracted functions (each has ≤7 params); kept it only on run_sync_with_probe which retains its 8-param public API

Test plan

  • All 320 sync pipeline tests pass
  • cargo fmt --check passes
  • cargo clippy -- -D warnings passes
  • cargo build --release succeeds
  • PR is MERGEABLE (no conflicts)

🤖 Generated with Claude Code

@linear

linear Bot commented Mar 16, 2026

Copy link
Copy Markdown

@poiley poiley force-pushed the factory/actcli-28 branch 2 times, most recently from 76bef3b to f7d8a43 Compare March 18, 2026 22:33
@poiley poiley force-pushed the factory/actcli-28 branch from f7d8a43 to 970bd40 Compare March 30, 2026 23:11
… phase functions

Extract the 626-line god function into focused phases:
- run_environment_phase: git detection, config display, runner probe
- run_analysis_phase: analysis, filtering, auto-select, confirmation
- run_fetch_phase: config reload, API fetch, rejection filtering
- run_tailor_phase: cache, ADR partitioning, tailoring, V2 governance
- run_write_phase: thin wrapper around confirm_and_write
- run_telemetry: fire-and-forget metrics (cfg feature)

Add EnvironmentPhaseResult, FetchPhaseResult, TailorPhaseResult structs.
run_sync_with_probe reduced to ~15-line coordinator.
Add 7 unit tests covering each extracted phase function.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@poiley poiley force-pushed the factory/actcli-28 branch from 970bd40 to 1bf3721 Compare March 31, 2026 03:11
@poiley poiley marked this pull request as draft March 31, 2026 04:58
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