Skip to content

fix(cars): keep a one-off goal's deadline when a profile target applies - #1887

Merged
frahlg merged 1 commit into
masterfrom
d4-profile-target-keeps-deadline
Oct 27, 2026
Merged

frahlg merged 1 commit into
masterfrom
d4-profile-target-keeps-deadline

Conversation

@frahlg

@frahlg frahlg commented Oct 27, 2026

Copy link
Copy Markdown
Member

Item D4 of the stable plan.

Problem

A car with a vehicles[] profile target_soc loses a one-off goal's ready-by time at plug-in.

Scenario: profile target_soc: 0.9; the owner sets a one-off goal of 80 % by 07:00, then plugs in. At the session seed, cars/tick.go calls lps.SetTarget(id, 0.9, time.Time{}). SetTarget sets the target to 0.9 and clears targetTime. RollSchedules seeds a one-off schedule only once (lastRolledFor is already set), so the deadline never returns. The stored goal still says 80 % by 07:00, but the planner and the deadline reserve read 90 % with no deadline for the rest of the session. A recurring goal recovers on the next roll; a one-off goal does not.

Change

Apply the profile target at the session seed only when the car has no goal (!goal.HasTarget()). One condition in syncLocked.

The plan said to delete the call, on the grounds that migration had already folded the profile target into the car. It had not: ProfileTarget is stored apart from Goal and this call is its only reader. Deleting it would make target_soc a dead setting. The guard is the fallback the audit proposed, and it keeps the setting working for cars without a goal.

Tests

  • TestProfileTargetKeepsOneOffDeadline (the audit's repro, renamed): fails on master with after 0.90 by 0001-01-01, passes with this change.
  • TestProfileTargetAppliesWithoutGoal: a car with no goal still gets 0.9 at plug-in.
  • cd go && go test -race ./internal/cars/...: ok
  • go vet ./... and go build ./...: clean

Risk

Low. User-intent bookkeeping only; the dispatch and fuse paths are unchanged.

🤖 Generated with Claude Code

The session seed called SetTarget with the vehicles[] profile target,
which clears targetTime. A one-off goal is not re-rolled, so the car lost
its ready-by time for the whole session. Apply the profile target only
when the car has no goal.

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:19:01.980884Z 047a14d 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 c33e87d into master Oct 27, 2026
22 checks passed
@frahlg
frahlg deleted the d4-profile-target-keeps-deadline branch November 11, 2026 09:16
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