Skip to content

Run command decomposition #46

@bradjin8

Description

@bradjin8

Repository: local-ci-test-system
Severity: High

Problem

The eval identifies Local CI's dominant issue as a "Silent Failure Chain" whose root is structural: broad catch-all Exception handlers in cli/localci/cli/main.py reduce structured errors to string messages, orchestrator listener errors are logged but not re-raised, and container cleanup after a run is optional rather than guaranteed in cli/localci/core/orchestrator.py. The run() function in cli/localci/cli/run.py spans ~275 lines (lines 126–401 of the 679-line file) and mixes CLI argument parsing, configuration resolution, dependency injection, queue building, preflight checks, orchestrator execution, and result serialization into a single unit. The remaining ~280 lines of the file are two helper functions: _print_execution_plan (dry-run table output, ~30 lines) and _write_patched_workflow (a 237-line regex-based YAML patcher that injects container overrides, cache mounts, b2 bootstrap skipping, and Codecov patches). The run() function's monolithic structure makes it impossible to test the orchestration logic independently, impossible to inject mocks for the image-matching system or act executor, and impossible for new contributors to understand the flow. The eval's "Verification Vacuum" finding compounds this: no CI configuration exists to exercise the 12 test files with YAML fixtures in cli/tests/. Decomposing the run command into entry point, DI container, and testable orchestration function is the prerequisite for breaking the silent failure chain — it provides the test surface that currently does not exist.

Acceptance Criteria

  • CLI entry point reduced to argument parsing + delegation (≤50 lines)
  • Dependency injection container/factory extracted
  • Orchestration logic in a testable function accepting injected deps
  • Existing behavior preserved (same CLI interface)
  • At least one new test exercising the orchestration function directly

Implementation Notes

  • The run() function is ~275 lines (lines 126–401), not the full file; the file total (679 lines) includes _print_execution_plan and _write_patched_workflow
  • This is a partial decomposition (5pt); full extraction is 8pt+ and deferred to horizon
  • Target: split into cli.py (entry), container.py (DI), orchestrator.py (logic)
  • The 237-line _write_patched_workflow regex patcher remains untouched this week (separate horizon item)
  • Brad has reviewed local-ci PRs and understands the architecture

References

  • cli/localci/cli/run.py:126–401run() function (~275 LOC)
  • cli/localci/cli/run.py:442–678_write_patched_workflow() helper (~237 LOC)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions