Refactor sync_run.py from a hard-wired composition root (imports 7 sibling modules, constructs everything inline) into an injectable pipeline where key collaborators are accepted as optional parameters with real-construction defaults. This turns hypothetical seams into real ones — tests can pass fakes instead of patching fully-qualified import names.
Key collaborators to inject: session, history, reporter, download_all_fn. When None (default), construct as today. Extract the verbose-logging block and history-path-resolution logic into small helpers to reduce the main function's cognitive load.
This is the highest-leverage refactor in PRD-003 but also the highest scope.
When parameters are None, the function constructs real collaborators (backward-compatible default)
Tests for sync_run pass fakes via parameters instead of (or in addition to) mock.patch
Verbose config block extracted to a helper function
History path resolution logic deduplicated with config.py's existing resolution utility
Full test suite passes (all 43 existing sync_run tests + new injection-path tests)
The _make_download_fn() closure captures fewer variables from enclosing scope
Blocked by
#37, #38, #39, #40, #41, #42, #43 — All other slices should complete first. This refactor touches the composition root and will interact cleanly only after downstream modules have stabilized.
Deferred per PRD-003 Decision: High value but high scope. Better done when sync_run is next opened for feature work. Recording as known opportunity.
## Parent
#36 — PRD-003: Deepen Codebase Architecture
## What to build
Refactor `sync_run.py` from a hard-wired composition root (imports 7 sibling modules, constructs everything inline) into an injectable pipeline where key collaborators are accepted as optional parameters with real-construction defaults. This turns hypothetical seams into real ones — tests can pass fakes instead of patching fully-qualified import names.
Key collaborators to inject: session, history, reporter, download_all_fn. When None (default), construct as today. Extract the verbose-logging block and history-path-resolution logic into small helpers to reduce the main function's cognitive load.
**This is the highest-leverage refactor in PRD-003 but also the highest scope.**
## Acceptance criteria
- [ ] `sync_run()` accepts optional `session`, `history`, `reporter`, `download_all_fn` parameters
- [ ] When parameters are None, the function constructs real collaborators (backward-compatible default)
- [ ] Tests for sync_run pass fakes via parameters instead of (or in addition to) mock.patch
- [ ] Verbose config block extracted to a helper function
- [ ] History path resolution logic deduplicated with config.py's existing resolution utility
- [ ] Full test suite passes (all 43 existing sync_run tests + new injection-path tests)
- [ ] The _make_download_fn() closure captures fewer variables from enclosing scope
## Blocked by
#37, #38, #39, #40, #41, #42, #43 — All other slices should complete first. This refactor touches the composition root and will interact cleanly only after downstream modules have stabilized.
> **Deferred per PRD-003 Decision:** High value but high scope. Better done when sync_run is next opened for feature work. Recording as known opportunity.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Parent
#36 — PRD-003: Deepen Codebase Architecture
What to build
Refactor
sync_run.pyfrom a hard-wired composition root (imports 7 sibling modules, constructs everything inline) into an injectable pipeline where key collaborators are accepted as optional parameters with real-construction defaults. This turns hypothetical seams into real ones — tests can pass fakes instead of patching fully-qualified import names.Key collaborators to inject: session, history, reporter, download_all_fn. When None (default), construct as today. Extract the verbose-logging block and history-path-resolution logic into small helpers to reduce the main function's cognitive load.
This is the highest-leverage refactor in PRD-003 but also the highest scope.
Acceptance criteria
sync_run()accepts optionalsession,history,reporter,download_all_fnparametersBlocked by
#37, #38, #39, #40, #41, #42, #43 — All other slices should complete first. This refactor touches the composition root and will interact cleanly only after downstream modules have stabilized.
Completed in
5cc3fce. All 7 AC met: 4 DI seams, 2 helper extractions, closure simplification. 172/172 tests pass (+10 new).