Repository navigation
Plans tell the truth: task state follows runs and pull requests - #800
Merged
Merged
Conversation
A task's state is derived from the runs of its ticket and their pull requests (common::plan_state), never from filing the ticket, and a plan is Done only when every task merged or was dropped. common::plan_sync links each run to its plan and task, writes missing ticket links, and writes the derived states; it runs on run status events, pull request events, approvals, the plan page, and from the plans list for plans written before it (the backfill). Approving one task keeps the plan open, every start route checks the run budget, tasks are queued before the message that starts them, and filing failures keep their reason. The plan API returns tasks with runs, pull request chips, needs, drift and covered criteria, plus criteria with evidence and the start estimate; the list returns counts by state, cost and the needs-you count. Incident case pl_plan_follows_the_work replays the stranded plan and the false-Done plan.
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.
Summary
A plan now tells the truth about its work. A task's state is derived from the runs of its ticket and their pull requests, never from filing the ticket, and a plan is Done only when every task merged or was dropped. Every run started from a plan task names its plan and task, plans made before this are linked to their runs and read again (the backfill), approving one task never ends the plan, and every route that starts work checks the run budget.
Before: the worker marked a task
donethe moment its ticket was filed and the plandoneonce no task waited on another. Nothing wrote runs or pull requests back to tasks, so plans read Done with most of their pull requests open, closed unmerged or failing, and approving one task from its row stranded the other drafts.Changes
common::plan_state(new, pure): the task states (Draft, Queued with what it waits on, Working, Needs you with the exact ask, Failed with its reason, In review, Merged, Dropped) derived from the task row and its runs; the plan states (Drafting, Running, Needs you, Done, Stalled after 3 days of silence); pull request chips coloured by checks and review with their size; the Needs you list; drift marks (tasks added, changed or dropped after approval, pull requests that change files outside the paths the task names, scope ledger items moved into scope, with who made each change); success criteria with evidence from each task's newest criteria trace (Code map kept current, criteria traced to proof, non-functional checks in plans #780); the count line; cost and attempts per task and per plan.common::plan_sync(new): finds each task's runs through its ticket (Jira key, orGH-<n>in the issue's repository), stamps runs that lack it withplan_idandplan_task_id, writes a missing ticket link so later runs carry the plan from their first write, derives the states and writes the derived fields on the task and plan rows only when they changed. Idempotent. Also the start estimate (runs and cost range from the team's recent runs).filed(a fact) and refreshes the plan; it never writesdone. Filing failures store their reason. Runs carryplan_task_idfrom their first write. Every run status event (emit_run) refreshes the run's plan.GET /api/plans/:idderives the plan live and returns tasks with runs, pull request chips, needs, drift and covered criteria, pluscriteriawith evidence,needsand the startestimate.GET /api/plansreturns per-plan state, count line, counts by state, needs count, cost and attempts, and refreshes plans written before this (up to 8 per page) or open plans last derived over 10 minutes ago: this is the backfill. Pull request opened, reviewed, checked, merged and closed events refresh the plan of the run they belong to and keep the pull request's size and a person's review verdict on the run.approve-and-execute,execute, single approve andforce-runall check the run budget, and tasks are marked queued before the message that starts them (the old order could writequeuedover a task the worker had already filed), with a rollback to approved when the message can't be sent. Plans acceptsuccess_criteria, tasks acceptcovers, and task edits record who made them.pl_plan_follows_the_workwith its page: replays the stranded plan and the false-Done plan.Other open work: this touches
github_webhook.rsonly indispatch(one call after the event is routed) and makeslookup_run_item_by_prvisible toplans.rs; none of the reward paths. It touches no file of #796.Verification
cargo fmt --all --check,rustfmt --check --edition 2021 worker/src/passes/incidents/*.rs,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace.plan_state, and the incident case readingplan_execute.rs); state follows run and pull request events; one approved task leaves the plan open with the drafts asked for; every start route checks the run budget before starting and queues before sending (main: single approve, approve-all and force-run had no budget check, approve-all queued after sending); backfill links runs and recomputes, idempotently; drift marks; list counts and the list refresh rule.