feat: scenario simulation what-if planning full version (#223)#227
Conversation
There was a problem hiding this comment.
Sorry @w7-mgfcode, your pull request is larger than the review limit of 150000 diff characters
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Implements PRP-27 — Scenario Simulation / What-If Planning (Full Version) (#223), the 4-phase increment on the shipped scenarios MVP. Delivered as one branch, phase-ordered commits:
feature_frame.py: a leakage-safe future feature-frame (X_future) generator — long-lag (shift ≥ horizon), calendar, and exogenous columns.RegressionForecaster(wrapsHistGradientBoostingRegressor) + aregressiontraining path;POST /scenarios/simulateroutes a regression baseline to a genuine re-forecast (method="model_exogenous").tags,cloned_from) +POST /scenarios/compare(rank 2-5 saved plans, merged multi-series chart) + the planner UI multi-scenario comparison view.propose_scenarioand mutating, HITL-gatedsave_scenario; provenance/audit columns onscenario_plan.Required call-outs (per PRP)
service.pyimport (DECISIONS LOCKED ci: add GitHub Actions workflows for phase-1 readiness #3). The scenarios slice still imports onlyload_model_bundle;agent_tools.pyis the agent-integration seam —agents/imports that module, neverscenarios/service.py.app/features/scenarios/tests/test_future_frame_leakage.pyis its load-bearing spec (long-lag only, future-points-only) — never weaken it.scenarios+forecastingslices (no new slice). 2) PRP-27 / Scenario Simulation / What-If Planning — Full Version #223 describe it. 3) Time-safety preserved — new leakage spec added. 4) Three forward-only Alembic migrations ship. 5) Runs viadocker-compose up. 6) Passes ruff + mypy --strict + pyright --strict + pytest.model_exogenouspath is additive — every non-regression baseline still uses the deterministicheuristicmultiplier; themethodCHECK was widened, not replaced.save_scenariolets the experiment agent persist ascenario_planrow — a new mutation surface. PerAGENTS.md§ Safety, it is added toagent_require_approval(["create_alias","archive_run","save_scenario"]) so every agent save pauses for explicit HITL approval and records a full provenance/audit trail (source,agent_session_id,approved_by,approved_at,approval_decision). PRP-27 (maintainer-approved) is that approval.Validation
ruff check/ruff format --check— cleanmypy app/+pyright app/(--strict) — 0 errorspytest -m "not integration"— 1224 passedpytest -m integration(scenarios + agents) — 37 passedtsc --noEmit+lint+test— clean, 97 passedregressionbaseline on seeded data, confirmedPOST /scenarios/simulatereturnsmethod="model_exogenous", saved/tagged/listed/compared plans through the running API. (Note: the seeded sales are price-invariant, so the model's price response is legitimately flat — the mechanism is exercised by the synthetic-coefficient integration fixture.)Closes #223.