Context
src/apm_cli/commands/install.py is at ~1700 LOC and is guarded by an architecture-invariant test (tests/unit/install/test_architecture_invariants.py::test_install_py_under_legacy_budget) with a legacy budget of 1680 LOC.
PR #803 (Codex project-scoped MCP, fixes #502) needs to thread scope context (project_root, user_scope, explicit_target) through install orchestration, which pushes the file to 1701 LOC and trips the invariant. Rather than block the Codex PR on a large refactor, we're raising the budget in-line there and tracking the extraction here.
Why this matters
The invariant test message says it explicitly:
Do NOT trim cosmetically -- engage the python-architecture skill (.github/skills/python-architecture/SKILL.md) and propose an extraction into apm_cli/install/.
install.py is a well-known God-module candidate. Every cross-cutting change (scope, targets, MCP, hooks, lockfile) adds pressure on it, and silent budget bumps would defeat the guard.
Proposed direction
Extract cohesive helpers into a new apm_cli/install/ package, keeping commands/install.py as the thin CLI entrypoint. Likely candidates:
- Scope/target resolution helpers (
project_root, user_scope, explicit_target plumbing).
- MCP integration orchestration (dep collection, conflict detection, stale cleanup glue).
- Dependency/runtime detection and filtering.
- Post-install reporting / diagnostics assembly.
Engage the python-architecture skill before cutting module boundaries -- the goal is cohesion by responsibility, not file-size juggling.
Acceptance
Related
Context
src/apm_cli/commands/install.pyis at ~1700 LOC and is guarded by an architecture-invariant test (tests/unit/install/test_architecture_invariants.py::test_install_py_under_legacy_budget) with a legacy budget of 1680 LOC.PR #803 (Codex project-scoped MCP, fixes #502) needs to thread scope context (
project_root,user_scope,explicit_target) through install orchestration, which pushes the file to 1701 LOC and trips the invariant. Rather than block the Codex PR on a large refactor, we're raising the budget in-line there and tracking the extraction here.Why this matters
The invariant test message says it explicitly:
install.pyis a well-known God-module candidate. Every cross-cutting change (scope, targets, MCP, hooks, lockfile) adds pressure on it, and silent budget bumps would defeat the guard.Proposed direction
Extract cohesive helpers into a new
apm_cli/install/package, keepingcommands/install.pyas the thin CLI entrypoint. Likely candidates:project_root,user_scope,explicit_targetplumbing).Engage the python-architecture skill before cutting module boundaries -- the goal is cohesion by responsibility, not file-size juggling.
Acceptance
commands/install.pyback under a tight budget (target: 1200 LOC or lower).apm_cli/install/package with clear module boundaries and its own tests.Related