Make the Supply run from the plan revision Push to Calendar pushed
A plan edit landing between a successful Push and the Generate that followed it made the Supply run from the newer plan while the push answer reported supply_run generated, so the list could hold a dinner Calendar never showed (MQ-133-01). Push now returns the revision it pushed, and the push hook calls shopping.GeneratePushed, which checks inside its transaction that the week's plan is still at that revision (week_plans.revision, as the draft path does) and otherwise fails with ErrPlanChanged, leaving the Supply run as it was. The push answer then reports supply_run failed with error plan_changed (retryable: push again), logged as a warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+12
-8
@@ -739,14 +739,18 @@ Runs are recorded in `schedule_runs` and executed through `jobs`.
|
||||
has no plan, 400 `invalid_week`. The push holds the account lock
|
||||
across its Google requests and its record, like listing and choosing.
|
||||
- The week's Supply run (Feature 17) is made from a pushed plan: after
|
||||
a successful `Push`, the handler runs `shopping.Generate` for the week
|
||||
and the 200 answer carries `supply_run: {status, error}`. `status` is
|
||||
`generated`; `archived` when the week's Supply run is in the Supply
|
||||
archive and was left as it was; or `failed` (error
|
||||
`supply_run_failed`, retryable, logged as an error) when it could not
|
||||
be made. Generation never fails or undoes the push — Calendar already
|
||||
shows the plan — and `POST /api/v1/shopping/{weekStart}/generate`
|
||||
makes it again.
|
||||
a successful `Push`, the handler runs `shopping.GeneratePushed` for
|
||||
the week at the plan revision `Push` pushed, and the 200 answer
|
||||
carries `supply_run: {status, error}`. `status` is `generated`;
|
||||
`archived` when the week's Supply run is in the Supply archive and was
|
||||
left as it was; or `failed` — error `plan_changed` (retryable, logged
|
||||
as a warning) when the plan was edited between the push and
|
||||
generation, so no Supply run is made from a plan Calendar does not
|
||||
show and pushing again makes it; or error `supply_run_failed`
|
||||
(retryable, logged as an error) when it could not be made, and
|
||||
`POST /api/v1/shopping/{weekStart}/generate` makes it again.
|
||||
Generation checks the revision inside its own transaction, and never
|
||||
fails or undoes the push — Calendar already shows the plan.
|
||||
|
||||
## Supply run API (Feature 17)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user