Skip to content

refactor(healer): split data_gap_adapters.py by role (Wave 7b) - #539

Merged
moremeds merged 1 commit into
mainfrom
chore/healer-adapters-split
Oct 5, 2026
Merged

moremeds merged 1 commit into
mainfrom
chore/healer-adapters-split

Conversation

@moremeds

@moremeds moremeds commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

What

This PR splits worker/jobs/data_gap_adapters.py (1,154 lines) into four modules by role. Imports run one way: context ← runners ← adapters ← executor. There is no re-export shim.

Module Lines Holds
data_gap_heal_context.py 160 RequestBudget, HealContext, HealSpec, _beat
data_gap_heal_runners.py 516 the _run_* writers, _recorder_hook, _uw_alpha_repo, _eventlog_heal, _replay_run_single_stock
data_gap_adapters.py 296 HEAL_SPECS, run_refresh_adapters
data_gap_executor.py 265 _verify_covered, the dispatchers, _verify_and_mark, execute_run
  • Function bodies are unchanged. An AST comparison of all 50 top-level names in main's file against the four new modules found 0 missing and 0 changed.
  • All 33 HEAL_SPECS entries still point at the same functions, which now live in data_gap_heal_runners.
  • Every importer in src/ and tests/ now names the new home. worker/scheduler.py and worker/schedule/** do not import this module and are untouched.
  • The CLAUDE.md "Data gap healer" row, the runbook code path, the data_gap_telemetry.py docstring and the CHANGELOG [Unreleased] entry are updated.
  • data_gap_heal_runners.py is 16 lines over the 500-line target.

Monkeypatch targets

Each patch now goes on the module whose globals look the name up.

Test Old target New target
tests/integration/worker/test_caveat_never_aborts_heal.py data_gap_adapters._verify_covered data_gap_executor._verify_covered (_verify_and_mark calls it there)
tests/integration/worker/test_data_gap_adapters_replay.py data_gap_adapters._replay_run_single_stock data_gap_heal_runners._replay_run_single_stock (_run_pipeline_replay calls it there)

How the patches were verified:

  • Each name is defined in exactly one module. monkeypatch.setattr defaults to raising=True, so a patch on the wrong module raises instead of passing silently.
  • Mutation check: I disabled each monkeypatch.setattr line in turn and re-ran its test file. Both files fail without the patch (2 failed, and 2 failed + 1 passed), so each patch takes effect.

Verification

  • Healer test set: 110 passed on baseline 521c4309 and 110 passed on this branch. The set covers 13 integration files (tests/integration/worker/test_data_gap*, caveat, gold-posture, uw-alpha, freshness-autoheal, CLI) plus test_no_dead_adapters.py, test_data_gap_healer_specs.py and test_source_telemetry_wiring.py.
  • uv run pytest tests/unit/: 3160 passed.
  • uv run ruff check src/ tests/ scripts/: clean.
  • Format: no format commit was needed. The touched files pass ruff format --check, except tests/integration/worker/test_data_gap_telemetry.py, which already fails it on main for an unrelated line. I left that file as it is.

🤖 Generated with Claude Code

…dapters, executor (Wave 7b)

data_gap_adapters.py was 1,154 lines. It now splits by role, with imports
one way (context <- runners <- adapters <- executor) and no re-export shim:

- data_gap_heal_context.py: RequestBudget, HealContext, HealSpec, _beat
- data_gap_heal_runners.py: the _run_* writers, _eventlog_heal,
  _replay_run_single_stock
- data_gap_adapters.py: HEAL_SPECS, run_refresh_adapters
- data_gap_executor.py: _verify_covered, dispatchers, _verify_and_mark,
  execute_run

Function bodies move unchanged. Every importer names the new home. The two
test monkeypatches follow the module that looks the name up:
_verify_covered on data_gap_executor, _replay_run_single_stock on
data_gap_heal_runners.
@moremeds
moremeds merged commit f44e2c6 into main Oct 5, 2026
7 checks passed
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