Skip to content

fix(jobs,ui): reach model_exogenous + block empty assumption dates in the planner#236

Merged
w7-mgfcode merged 2 commits into
devfrom
fix/planner-model-exogenous-and-empty-dates
May 19, 2026
Merged

fix(jobs,ui): reach model_exogenous + block empty assumption dates in the planner#236
w7-mgfcode merged 2 commits into
devfrom
fix/planner-model-exogenous-and-empty-dates

Conversation

@w7-mgfcode
Copy link
Copy Markdown
Owner

Summary

Two related What-If Planner bug fixes (/visualize/planner), landed on one branch per PRPs/planner-model-exogenous-and-empty-dates.md.

#229model_exogenous reachable from the UI

The headline PRP-27 capability (a genuine model-driven re-forecast of a regression baseline) was reachable only via raw API calls or agent tools. Root cause: the planner picked a predict job and read params.run_id, but regression is rejected by POST /forecasting/predict, so no completed regression predict job can ever exist.

  • Backend — added a regression branch to JobService._execute_train, so a train job can train a regression model and complete with result.run_id set.
  • UI — switched the planner baseline picker to train jobs and read the artifact key from job.result.run_id. A regression train job now routes POST /scenarios/simulate down the model_exogenous re-forecast branch.

#228 — empty assumption dates blocked

Enabling Price/Promotion without filling both From/To dates submitted empty strings → backend RFC 7807 422. Added a pure, unit-tested assumptionDateErrors() helper; the planner now disables Run simulation + Save as plan and shows inline Required hints while any enabled assumption has a blank date. The empty-date 422 is now structurally unreachable from the form.

Testing

  • ruff check + ruff format --check — clean
  • mypy app/ + pyright app/ — 0 errors
  • pytest -m "not integration" — 1290 passed (2 new jobs tests)
  • frontend lint + tsc --noEmit + test --run — 109 passed (5 new scenario-utils tests)
  • Level 3 manual — regression train job completes with run_id; that baseline → simulate returns method="model_exogenous"; naive baseline still returns method="heuristic"; blank dates show Required + disable Run/Save (browser-verified)

Notes

Resolves #229 and #228.

Follow-up (out of scope here): the model_exogenous re-forecast is reachable but returns a 0.0 units/revenue delta for a price assumption regardless of magnitude — pre-existing PRP-27 behaviour in scenarios/feature_frame.py / _simulate_model_exogenous. A separate issue will track it.

Add a regression branch to JobService._execute_train so a train job can
train a regression model and complete with result.run_id set. Rewire the
What-If Planner baseline picker to train jobs and read the artifact key
from job.result.run_id, making the model_exogenous re-forecast path
reachable from the browser.
Add a pure assumptionDateErrors helper (unit-tested) and use it in the
What-If Planner to disable Run simulation and Save as plan while any
enabled Price/Promotion assumption has a blank date, with inline Required
hints. The empty-string-date 422 is now structurally unreachable from the
form.
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @w7-mgfcode, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 34113ffc-510d-452c-abbb-051c1b774bf3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/planner-model-exogenous-and-empty-dates

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@w7-mgfcode w7-mgfcode merged commit f09dec0 into dev May 19, 2026
8 checks passed
@w7-mgfcode w7-mgfcode deleted the fix/planner-model-exogenous-and-empty-dates branch May 20, 2026 03:26
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