Repository navigation
fix(mpc): reject ambiguous EV deadlines - #902
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a605222896
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if loadpoint.TargetSoCPct > 0 && loadpoint.TargetSlotIdx < 0 { | ||
| return fmt.Errorf("%s.target_slot_idx must be non-negative when target_soc_pct is set", field) |
There was a problem hiding this comment.
Do not reject deadlines that expire during probe construction
When a real deadline passes between the future-time gate in go/cmd/ftw/main.go:1236-1238 and the later time.Until calculation at main.go:1277-1282, the probe emits a positive target with TargetSlotIdx == -1. This new check then rejects the entire replan and retains the previous whole-site plan, even though the input was a normal deadline rather than malformed caller data. Use one captured timestamp throughout probe construction or omit the loadpoint when the deadline has elapsed before applying this validation.
Useful? React with 👍 / 👎.
What changed
0is the first real deadline and that only a zero target disables the deadline.Why
Core sent the same invalid input to two planners with different results. With
TargetSoCPct=40andTargetSlotIdx=-1, Go-DP treated the target as having no deadline and planned0 Win slot 0. Python/HiGHS clamped-1to slot 0 and planned2500 W.The service physics gate now rejects that input before either planner runs. It keeps the last accepted plan and does not allocate a new decision ID or diagnostic.
Compatibility stays explicit:
TargetSoCPct == 0: no target; the slot value is ignored.TargetSlotIdx == 0: target due at the end of the first slot.This advances #885. It does not touch
external_optimizer.go, which is owned by open stacked work.Validation
go test ./internal/mpc, full MPC race suite andgo vet ./internal/mpcpassed.make verify-allpassed, including 134 Python tests, all Go packages, Core to Optimizer contracts, full stack, Compose migration, vet/build, and Linux arm64/amd64 plus Windows amd64 cross-builds.