Skip to content

[Architecture] Decompose CLI workflow composition root #42

Description

@orenlab

[Architecture] Decompose CLI workflow composition root

Labels: enhancement, architecture, cli
Priority: P2 (architecture triage)
Subject: codeclone/surfaces/cli/workflow.py
Signal: responsibility_overload
Triage run: e28867ed (health 91/A)

Summary

codeclone/surfaces/cli/workflow.py is the CLI composition root that combines pipeline orchestration, gating, controller queries, and subsystem dispatch (memory, analytics, observability) in one overloaded module.

Environment

  • Product/Service: CodeClone
  • Version: 2.1.0a1 (run e28867ed)
  • Area: CLI (codeclone.surfaces.cli)

Current State

  1. Fan-out 29, overloaded score 0.950, unwind: chain_bottleneck, high_instability.
  2. _main_impl spans lines 424–760 and imports core pipeline, cache, baseline, HTML, observability, audit, blast-radius, patch-verify.
  3. Dispatches memory/analytics/observability subcommands inline (lines 810–818).
  4. Impact blast: high (entry via codeclone/main.py).

Expected Behavior

workflow.py should orchestrate CLI lifecycle only. Controller query routing, subsystem CLIs, and analysis staging should live in dedicated modules with narrow imports — matching the thin main.py entry pattern described in AGENTS.md.

Actual Behavior

One module owns bootstrap → analysis → gating → report writes → controller terminal queries → subsystem CLI delegation. UX, controller flags, and pipeline bootstrap evolve on different cadences but share a single bottleneck.

Impact

Medium — CLI remains functional; change risk and review surface are high for any controller or subsystem CLI work touching the main path.

Proposed Direction

  • Peel --blast-radius, --patch-verify, --session-stats, --audit routing into existing or new surfaces/cli/* orchestrators.
  • Keep _main_impl focused on parse → bootstrap → pipeline → reports → exit routing.
  • Avoid duplicating core semantics; delegate to codeclone.core, codeclone.analysis, and controller helpers as blast-radius CLI already does.

Additional Context

  • Architecture triage score: C+D+E → 30 (P2).
  • Related hotspots: duplicated branch findings at workflow.py:810–818 (production triage).
  • Tests: tests/test_cli_inprocess.py, tests/test_cli_unit.py, tests/test_observability_cli_pipeline.py.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions