Skip to content

refactor(operator-trend): extract _build_resolution_trend payload assembly (T3-2 phase 8b)#95

Merged
saagpatel merged 2 commits into
refactor/resolution-trend-godfn-decomposefrom
refactor/resolution-trend-extract-payload
Jun 20, 2026
Merged

refactor(operator-trend): extract _build_resolution_trend payload assembly (T3-2 phase 8b)#95
saagpatel merged 2 commits into
refactor/resolution-trend-godfn-decomposefrom
refactor/resolution-trend-extract-payload

Conversation

@saagpatel

Copy link
Copy Markdown
Owner

What

Extracts the 1,676-line payload.update({...}) out of _build_resolution_trend into a new module, src/operator_trend_resolution_payload.py (build_resolution_trend_payload). The god-function drops 1,852 → 157 lines.

How (verbatim relocation, byte-identical)

  • The payload-assembly block moves byte-for-byte — only its container changed. The helper re-derives its 31 locals from the same source assignments (apply_chain[...] / summary_context[...]) and takes the three in-module summary renderers (_class_transition_health_summary, _class_transition_resolution_summary, _closure_forecast_hysteresis_summary) as injected callables — the established no-circular-import pattern the already-extracted stages (run-context, apply-chain, summary-context, topline-payload) use.
  • The 29 now-dead apply-chain unpacks are removed from the god-function; the 6 still fed to the topline-payload helper stay.
  • The god-function now reads as a clear pipeline: run-context → targets → apply-chain → summary-context → topline payload → recovery-tier payload update → return.

Proof

  • Characterization net (tests/test_resolution_trend_golden_contract.py, added in the base PR) stays byte-identical green — the relocation is provably faithful.
  • uv run pytest -q2541 passed, 2 skipped
  • uv run ruff check src/ tests/ → clean (no F841 from the dropped unpacks; no F821)
  • uv run mypy on both files → clean

Note

Stacked on #94 (the characterization net). Merge #94 first, then this. This is the first seam; collapsing the 8 repeated per-tier payload blocks onto a parametrized base is the next seam under the same net.

…embly to its own module (T3-2 phase 8b)

The 1,676-line payload.update({...}) that assembled the 320+ resolution-trend
payload keys moves verbatim into operator_trend_resolution_payload.build_resolution_trend_payload.
The god-function drops 1,852 -> 157 lines: it now reads as a clear pipeline
(run-context -> targets -> apply-chain -> summary-context -> topline payload ->
recovery-tier payload update). The helper re-derives its locals from the
apply-chain / summary-context dicts and takes the three in-module summary
renderers as injected callables (the established no-circular-import pattern;
matches the already-extracted run-context / apply-chain / summary-context /
topline-payload stages).

Pure relocation, proven byte-identical by the characterization net
(tests/test_resolution_trend_golden_contract.py) plus the full suite.

Verify: ruff clean; mypy clean on both files; 2541 passed, 2 skipped.
…r, dict]

Match the original god-function's annotation (review nit): _decision_memory_map
returns dict[str, dict] and _resolution_targets takes it as dict[str, dict]; the
extracted helper should not widen it to dict[str, Any].
@saagpatel saagpatel merged commit 6eccae4 into refactor/resolution-trend-godfn-decompose Jun 20, 2026
@saagpatel saagpatel deleted the refactor/resolution-trend-extract-payload branch June 20, 2026 11:40
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