Skip to content

docs(openspec): plan #5562 Retry a stage attempt on a provider timeout - #5592

Merged
dan-petty merged 3 commits into
mainfrom
fix/5562-a-stage-job-retries-a-provider
Nov 14, 2026
Merged

dan-petty merged 3 commits into
mainfrom
fix/5562-a-stage-job-retries-a-provider

Conversation

@devops-cli-service

Copy link
Copy Markdown
Contributor

Plans #5562

This change makes a stage Job retry an attempt whose failure class has the action retry. A provider timeout, a clone failure, a timeout of the plan and a moved head exit 75, the one code that backoffLimit 2 and the pod failure policy of the stage Job retry. The pod writes the result line of the attempt with its class and infra=true, and leaves the check-out and the claim, so the next pod plans the same item. A class that a retry cannot help, such as plan_defect, keeps exit 1, and the deadline end keeps 143. No manifest changes: the policy already retries only exit 75, and a case of the k8s row of devops ci pins that rule. The gateway fallback for deepseek-v4.1-flash-1017 is a separate item.

Change: openspec/changes/5562-a-stage-job-retries-a-provider/

@devops-cli-service devops-cli-service Bot added type/docs Type docs: a change to the documents scope/openspec OpenSpec changes, specs and their checks labels Nov 14, 2026
@devops-cli-service
devops-cli-service Bot marked this pull request as ready for review November 14, 2026 01:50
@dan-petty

Copy link
Copy Markdown
Owner

An agent vetted this plan before a merge (shepherd, 2026-11-14). Verdict: needs fix. Each point below blocks a correct build.

  1. The retried pod plans nothing for the main case of the issue, a provider timeout. During plan_stage, StageWriter.settle -> _recording -> _record_failures (src/devops_cli/roadmap/stage/stage.py:3560, :3732) already writes stage.failed_at and stage.failed_class=provider on the item before run_stage_job sees the result. The stage Job selects with named=False (stage_job.py calls plan_stage(named=False); stage.py:588-591 adds _failed_lately), and RETRY_AFTER[provider] is 1 hour (failure.py). Thus the next pod leaves the item out in its failure wait. Proof by scratch test in a detached worktree (since removed): pod 1 with AIClientError(status=504) gives exit 1, stage.failed_at=NOW, stage.failed_class=provider. The record then got the state that the plan wants (stage.job kept, no stage.job_result). Pod 2 at NOW+30 s gave exit 0, result 'skipped', 0 model calls, no stage.pr, and it checked in, which cleared the check-out. The existing test test_a_failed_plan_exits_1_and_checks_in_with_the_failure already asserts that stage.failed_at is present after a failed plan. The design is wrong when it says that only a check-in writes FAILED_AT (design.md 'Write no check-in...'). Fix the plan: for an attempt that exits 75, clear the failure marks in stage_job.py, or skip them in the writer, or make _failed_lately pass when the check-out names the Job of the pod. Name the changed path (probably src/devops_cli/roadmap/stage/stage.py). Add a test that runs a second run_stage_job after the 504 and asserts that it plans and stages the item. Test 1.1 asserts only the check-out marks, so it passes while the retry does nothing. ci_infra from a failed write (applied.failed) has the same defect. head_moved (wait 0) and a clone failure that is raised (no marks written) work.

Paths that the change must touch and that the plan does not name: src/devops_cli/roadmap/stage/stage.py (_record_failures/StageWriter._recording or _failed_lately: the retry must not leave the item in its failure wait), docs/roadmap/stage.md (line 175 exit-code rule), src/devops_cli/lang/en/help.py (stage_job_item help, lines 1805-1808), docs/commands/roadmap.md (generated from help, line 133), k8s/devops/cronjob-stage.yaml (comment lines 32-36 only), k8s/devops/roadmap-service/admissionpolicy.yaml (comment lines 13 and 180 only), tests/gate/k8s_checks/stage_job.py (docstring line 80; existing check that group 2 repeats), src/devops_cli/roadmap/stage/stage_submit.py (recovery after backoff limit writes a second result line)

Points that do not block:

  • Group 2 repeats checks that exist. tests/gate/k8s_checks/stage_job.py:79 check_the_stage_job_runs_again_only_after_an_eviction_and_ends_by_its_deadline already pins backoffLimit 2 and the exact podFailurePolicy (Ignore DisruptionTarget, FailJob NotIn [75] for container stage). job_admission_policy.py:547 check_the_stage_job_from_the_template_passes_in_every_image_form already asserts no refusal for the template stage Job. The rule-break cases at :594-596 also exist. Better: update the docstring at stage_job.py:80 ('Exit 75 is the evicted exit... Any other exit fails the Job, so the Service decides each later attempt'), which the change makes wrong, and drop task 2.1. The verify command 'uv run devops ci --check --only k8s' is a real command form.
  • The plan does not name texts that the change makes wrong (AGENTS rule 8): docs/roadmap/stage.md:175 ('1 for a failure of the item, 75 for a SIGTERM before the time budget ends'); src/devops_cli/lang/en/help.py:1805-1808 (stage_job_item: '1 failure, 75 evicted') and the generated docs/commands/roadmap.md:133; the comment in k8s/devops/cronjob-stage.yaml:32-36 ('Any other exit ends the Job, and the Service decides each later attempt'); the comments in k8s/devops/roadmap-service/admissionpolicy.yaml:13 and :180 ('only after exit 75, the evicted exit'); the 'The result line' and 'Ends that fail' paragraphs of the stage_job.py module docstring (task 1.2 updates only the Ends list).
  • The plan does not state the end of a Job whose three pods all exit 75. The Job fails with its backoff limit, and stage_submit.py _recover/_end_of (FAILED) checks in with classify_failure of the log tail and writes one more result line. The last attempt then counts twice in the job grades, which goes against the rule 'each attempt counts once' (fix(roadmap): eval grades counts the result lines of Job pods #5556). Name the rule, for example: the recovery writes no line when the pod already wrote one.
  • proposal.md says 'Write the result line of that attempt with its class and infra=true'. For head_moved and timeout, the line computes infra=false (INFRA_CLASSES in job_result.py:125 holds provider, ci_infra, oom and limit_reached). design.md and the spec say this correctly. Correct the proposal sentence.
  • Plan PR docs(openspec): plan #3387 Re-stage an item whose draft plan fails #5581 (feat(roadmap): Stage items whose draft plan fails the check #3387) changes the selection in src/devops_cli/roadmap/stage/stage.py. The correct fix of the blocking point probably touches the same selection or writer, so put the two builds in order.
  • PR docs(openspec): plan #5562 Retry a stage attempt on a provider timeout #5592 is no longer a draft (draft=false). 'devops roadmap explain 5562' says 'Implement job: no. Its pull request docs(openspec): plan #5562 Retry a stage attempt on a provider timeout #5592 is not an open draft.' This is the expected state before the owner merges.
  • Prose is close to ASD-STE100, but many Feasibility bullets in proposal.md are long sentences (more than 25 words) with chained clauses. This is not a block.

@dan-petty dan-petty added the verdict/fix-plan Verdict Needs fix of a plan: an open finding keeps the plan in draft until a fix label Nov 14, 2026
@dan-petty
dan-petty force-pushed the fix/5562-a-stage-job-retries-a-provider branch from 80970f5 to 219697c Compare November 14, 2026 13:54
@dan-petty
dan-petty force-pushed the fix/5562-a-stage-job-retries-a-provider branch from 219697c to 0721fed Compare November 14, 2026 13:56
@dan-petty

Copy link
Copy Markdown
Owner

An agent vetted this plan before a merge (2026-11-14). Verdict: ready.

  • Updated plan to handle _failed_lately in src/devops_cli/roadmap/stage/stage.py so attempts retried under the same Job checkout are not skipped by the 1-hour failure wait.
  • Added test in tests/roadmap/stage/test_roadmap_stage_job_entry.py verifying that a retried attempt after an HTTP 504 successfully plans and stages the item.
  • Updated src/devops_cli/roadmap/stage/stage_submit.py to prevent duplicate result lines when recovering a Job whose pods already logged results.
  • Aligned ## Criteria exactly with the issue acceptance criteria.
  • Updated documentation and comments across docs/CLUSTER.md, docs/roadmap/stage.md, src/devops_cli/lang/en/help.py, docs/commands/roadmap.md, k8s/devops/cronjob-stage.yaml, k8s/devops/roadmap-service/admissionpolicy.yaml, and tests/gate/k8s_checks/stage_job.py.
  • Rebased on origin/main and verified with devops roadmap plan-check 5592 (all checks passed).

@dan-petty
dan-petty merged commit e37d1c3 into main Nov 14, 2026
22 checks passed
@dan-petty
dan-petty deleted the fix/5562-a-stage-job-retries-a-provider branch November 14, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/openspec OpenSpec changes, specs and their checks type/docs Type docs: a change to the documents verdict/fix-plan Verdict Needs fix of a plan: an open finding keeps the plan in draft until a fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant