refactor(operator-trend): extract _build_resolution_trend payload assembly (T3-2 phase 8b)#95
Merged
saagpatel merged 2 commits intoJun 20, 2026
Conversation
…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].
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Extracts the 1,676-line
payload.update({...})out of_build_resolution_trendinto 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)
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.Proof
tests/test_resolution_trend_golden_contract.py, added in the base PR) stays byte-identical green — the relocation is provably faithful.uv run pytest -q→ 2541 passed, 2 skippeduv run ruff check src/ tests/→ clean (no F841 from the dropped unpacks; no F821)uv run mypyon both files → cleanNote
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.