Skip to content

fix(octopus): compare a dispatch's real start, not its rounded settlement block, for 'already underway' - #4811

Merged
springfall2008 merged 1 commit into
fix/rate-io-slot-kwh-valid-scopingfrom
fix/rate-io-slot-underway-real-start
Aug 29, 2026
Merged

fix(octopus): compare a dispatch's real start, not its rounded settlement block, for 'already underway'#4811
springfall2008 merged 1 commit into
fix/rate-io-slot-kwh-valid-scopingfrom
fix/rate-io-slot-underway-real-start

Conversation

@chalfontchubby

Copy link
Copy Markdown
Collaborator

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-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.

This captures the dispatch's real, unrounded start separately (raw_start_minutes) and compares that against minutes_now instead. current_block is no longer needed and is removed.

Test plan

  • New test (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 to my_predbat.minutes_now at test time rather than a hardcoded wall-clock value, so it stays correct under the pre-existing test-clock drift between now_utc/midnight_utc that surfaces when the full suite runs in registry order (not something this PR introduces or fixes)
  • ./run_all --quick full suite passes
  • run_pre_commit clean

…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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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.

Comment thread apps/predbat/octopus.py
# 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
springfall2008 merged commit cdc9e16 into fix/rate-io-slot-kwh-valid-scoping Aug 29, 2026
3 checks passed
@springfall2008
springfall2008 deleted the fix/rate-io-slot-underway-real-start branch August 29, 2026 13:00
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.

3 participants