fix(octopus): compare a dispatch's real start, not its rounded settlement block, for 'already underway' - #4811
Merged
springfall2008 merged 1 commit intoAug 29, 2026
Conversation
…ment block, for "already underway" rate_add_io_slots()'s exemption from the #4482 future-need check compared the 30-min-rounded slot_start against a similarly rounded current_block, so a dispatch starting partway through the current settlement period (e.g. 10:20, checked at 10:05) read as already-underway from the top of that period (10:00), before it had actually started. Captures the dispatch's real, unrounded start separately and compares that against minutes_now instead - current_block is no longer needed and is removed. #4808, review follow-up on #4483 from Speshman. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Dispatch seconds are still truncated, allowing starts later in the current minute to be trusted prematurely.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes premature “already underway” classification for Intelligent Octopus dispatches.
Changes:
- Preserves the dispatch start before settlement-block rounding.
- Adds a regression test for future mid-period dispatches.
File summaries
| File | Description |
|---|---|
apps/predbat/octopus.py |
Compares dispatch start with current time. |
apps/predbat/tests/test_rate_add_io_slots.py |
Tests a future mid-period dispatch. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # start_minutes below - used only for the "already underway" check (#4808) so a | ||
| # dispatch starting partway through the current settlement period isn't treated as | ||
| # already started from the top of that period. | ||
| raw_start_minutes = start_minutes |
springfall2008
merged commit Aug 29, 2026
cdc9e16
into
fix/rate-io-slot-kwh-valid-scoping
3 checks passed
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.
Stacked on #4810 (which is stacked on #4483) - fixes #4808.
rate_add_io_slots()'s exemption from the #4482 future-need check compared the 30-min-roundedslot_startagainst a similarly roundedcurrent_block, so a dispatch starting partway through the current settlement period (e.g. 10:20, checked at 10:05) read as already-underway from the top of that period (10:00), before it had actually started.This captures the dispatch's real, unrounded start separately (
raw_start_minutes) and compares that againstminutes_nowinstead.current_blockis no longer needed and is removed.Test plan
test21b_mid_period_future_dispatch_not_yet_underway) for a dispatch starting later in the current settlement period - fails without this commit, passes with it. Built relative tomy_predbat.minutes_nowat test time rather than a hardcoded wall-clock value, so it stays correct under the pre-existing test-clock drift betweennow_utc/midnight_utcthat surfaces when the full suite runs in registry order (not something this PR introduces or fixes)./run_all --quickfull suite passesrun_pre_commitclean