refactor(REF-003): extract status panel + parameter controls from app.py#99
Conversation
Third app.py slimming pass (after REF-001/REF-002). Moves the pre-run
system-status card and the sidebar parameter-override plumbing into
dedicated ui/ modules, verbatim except for one rider:
- ui/status_panel.py: show_status_panel, render_universe_table, and their
30s @st.cache_data helpers (cache_summary, _universe_mtime,
_cached_universe_status, _cached_all_universe_statuses).
- ui/parameter_controls.py: _param_state_key, _render_parameter_overrides,
_apply_param_overrides.
- Rider: cache_summary's `cache_dir: Path = DAILY_CACHE_DIR` default bound
the config path at import time; now `Path | None` resolved in the body so
a repointed cache dir is honored per call (locked by a test that fails
against the old signature).
app.py re-exports every moved helper, so `app.<name>` imports and the
monkeypatch seams in test_app_orchestration.py keep working; function
identity is preserved, so refresh_universes_and_invalidate() still clears
the same cache objects (asserted by new identity checks). The universe-table
laziness test now patches ui.status_panel per the house pattern ("patch the
module that actually reads st").
New render tests for both modules (100% coverage each; lesson from #97's
untested-extraction coverage dip). Docs: app-orchestration LLD updated.
Gates: 1,404 passed, coverage 88.21% (floor 87); pre-commit validate,
compileall, ruff, mypy (121 files), bandit, pip-audit all clean.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
DoRmAmMu1997
left a comment
There was a problem hiding this comment.
Self-review (posted as COMMENT — the bot runs as the PR author and cannot APPROVE). Verdict: Approve.
Diff-level checks against the seams this extraction must not break:
- Verbatim move —
git diffon the moved bodies confirms only thecache_summarysignature/body rider differs; docstrings, comments, and widget-dispatch order (boolchecked beforeint— bool is an int subclass) are byte-identical. The rider is pinned bytest_cache_summary_default_resolves_current_daily_cache_dir, which fails against the old import-time-bound default. - Re-export identity — nine new assertions in
test_app_reexports_helpers_from_extracted_ui_modulesproveapp.<name> is ui.<module>.<name>. This matters doubly here:refresh_universes_and_invalidate()clears caches through theappbindings, which only works because they are the same function objects. - Monkeypatch seams —
main()still calls the four moved renderers via app module globals, so the:870-871patches in the orchestration suite work untouched. The single test that exercised a moved body directly (universe-table laziness) now patchesui.status_panelper the house pattern; no other test patched the moved names (verified by repo-wide grep). - Import removals safe —
pd,datetime,DAILY_CACHE_DIR,all_universe_statuses,universe_file_path,universe_statushad no remaining app.py consumers; full suite + ruff + mypy (121 files) clean. st.cache_datahygiene in new tests — every test that runs a real cached helper (cache_summary,_universe_mtime,_cached_universe_status,_cached_all_universe_statuses) clears before and infinally, so no state leaks into other suites (same discipline as TEST-007).- Layering —
ui/importsbackendonly (rule §4);backend/untouched; no ui module importsapp.
Gates: 1,404 passed + 1 skipped, coverage 88.21% (floor 87), both new modules 100%; ruff/mypy/bandit/pip-audit/pre-commit/compileall clean; constraints/pyproject diff vs main empty. app.py: 1,127 → 822 lines.
|
Codex review plan: I found no actionable standalone code issue in REF-003. I will rerun the focused extraction tests and verify the status panel, parameter override/reset, universe details, and cache invalidation flows on desktop and mobile. I’ll post a no-findings verdict with the evidence; no branch change is planned unless verification uncovers a regression. |
Completion verdictComplete — no findings. This is a completion comment, not an approval. No follow-up code changes were required. Verification covered 51 focused tests plus desktop and mobile browser QA for the status panel, parameter controls, universe handling, and cache invalidation. No actionable quality, behavior, or security findings remained. |
Ticket scope (REF-003)
Goal: third
app.pyslimming pass (after REF-001's page extraction and REF-002's #97 scan-view/fundamentals extraction).app.pydrops from 1,127 → 822 lines and is now orchestration-only.In scope
show_status_panel,render_universe_table) and its four 30-second@st.cache_datahelpers (cache_summary,_universe_mtime,_cached_universe_status,_cached_all_universe_statuses) → newui/status_panel.py._param_state_key,_render_parameter_overrides,_apply_param_overrides) → newui/parameter_controls.py.cache_summary(cache_dir: Path = DAILY_CACHE_DIR)froze the config path at import time; nowPath | None, resolved in the body per call. Locked by a test that fails against the old signature.app.pyre-exports every moved helper soapp.<name>imports and thetest_app_orchestration.pymonkeypatch seams keep working. Function identity is preserved, sorefresh_universes_and_invalidate()(stays inapp.py) still clears the same cache objects — new identity assertions lock this.ui.status_panel(house pattern: patch the module that actually readsst); update the app-orchestration LLD.Out of scope (deliberate)
main()/_execute_screenerdecomposition — those are genuinely orchestration and stay.main— no stacking; the branches touch disjoint files.This is ticket 2 of a 10-ticket second improvement wave (TEST-007 #98, REF-003, AI-006, IPO-006, TEST-006, PERF-002, DEPLOY-004, QUAL-006, QUAL-007, DOC-003), each shipped as its own PR off
main.Why the seams hold
main()callsshow_status_panel/render_universe_table/_render_parameter_overrides/_apply_param_overridesthrough app module globals, so existing monkeypatches ofapp.<name>are unaffected..clear()calls inrefresh_universes_and_invalidate()go through the re-exported bindings;from ui.status_panel import _universe_mtimebinds the same function object, so clearing throughappempties the cacheui.status_panelreads. The extended re-export identity test asserts this for all nine moved names.ui.status_panel.st— consistent with how REF-001 repointed the page-renderer tests.Gates (all green, local, Python 3.13)
pytest -q --cov=backend --cov=screeners --cov=ui --cov-fail-under=87pre_commit validate-configcompileallruff checkmypy(121 files)banditpip_audit -r constraints.txtconstraints.txt/pyproject.tomldiff vs main: empty (as required).Review
/code-review: Approve — verified the seven risk points (cache identity through re-exports,cache_summarycache-key change, laziness-test repointing, cache clears around real cached helpers, removed-import safety, bool-before-int widget dispatch, raisingrerunfake)./security-review: no findings (verbatim code move; no new injection/traversal/auth surface; the param-merge loop that keeps arbitrary session-state keys out of screener params is now test-locked).🤖 Generated with Claude Code