Skip to content

fix(control): no missing-plan retry while a replan is pending - #1882

Merged
frahlg merged 1 commit into
masterfrom
a10-no-retry-while-replan-pending
Oct 27, 2026
Merged

frahlg merged 1 commit into
masterfrom
a10-no-retry-while-replan-pending

Conversation

@frahlg

@frahlg frahlg commented Oct 27, 2026

Copy link
Copy Markdown
Member

Item A10 of the stable plan.

Problem

After a restart the box has no plan, and the control tick fires missing_plan_retry every 5 s (main.go:3266-3270). It never checks whether a replan is already running. Each new request cancels the one in flight (service.go:1436-1438), and the cancelled result is dropped at publish. PlanStale stays true, so the retry keeps firing.

Scenario: a site whose solve takes 6 s, such as an Energyplan site with an hourly import cap, demand charges or many slot-assets (5 s budget, plus input load and the caution pass). Every solve gets cancelled at 5 s. No plan lands until something stops the retry. In the scaled test (tick 20 ms, cooldown 100 ms, solve 120 ms), master started 20 solves in 2 s and published none.

Change

Skip the retry while mpcSvc.PlanSnapshot().Pending is true. The check moves into a small helper, missingPlanRetryDue, in a new file so a test can call it. The 5 s cooldown is unchanged. A failed solve clears Pending, so the retry still fires after a failure.

Tests

  • go test ./cmd/ftw/ -run TestMissingPlanRetry -count=1 with the guard removed: FAIL, "no plan published after 2 s; 20 solves started".
  • Same test with the guard: PASS (also with -race -count=3).
  • go test -race ./cmd/ftw/... ./internal/mpc/... -count=1: ok.
  • go vet ./... and go build ./...: clean.

The test comes from the audit repro (caa-45). It now drives the real helper instead of a copy of the main.go condition.

Risk

Low. If a solve hangs and ignores cancel, the retry no longer starts a new one on top of it. Before, the new one could not finish either, since it would be cancelled 5 s later. The worker transports keep their own timeouts (energyplan 7 s, external optimizer cfg.Timeout).

🤖 Generated with Claude Code

The 5 s missing-plan retry cancelled any solve that took longer, so on
a slow box no plan ever landed. Skip the retry while
PlanSnapshot().Pending is true.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T13:13:38.648172Z 588dab5 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@frahlg
frahlg merged commit 3ef88a3 into master Oct 27, 2026
23 checks passed
@frahlg
frahlg deleted the a10-no-retry-while-replan-pending branch November 11, 2026 09:12
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