Skip to content

fix(roadmap): Keep the fix-checks Job queue bounded and safe #6018

Closed

Description

@dan-petty

Problem

A review after the merge of PR #6009 (#5027, the fix-checks Jobs) found these defects. Write safety holds (bot pull requests only, lease on the judged head, no push to main), but the Job queue can waste or block the model places that implement and stage share (roadmap.model_jobs).

  1. The retry cap resets each day. fix_checks_row.py (about lines 284-285) reads the attempt count and the backoff only from Job objects, and cronjob-runner.yaml deletes ended Jobs after 24 hours (ttlSecondsAfterFinished: 86400). Then _next_attempt([]) gives attempt 1 again: a pull request that still fails on the same head and check starts a full chain each day (up to 5 Jobs of about 3.5 hours for outcome none; a known error runs again).
  2. Two fix Jobs can work one head at once. The unit key holds the check (steps/watch.py, about line 190; watch_row.py, about line 354), and FAILED comes while other checks still run: lint fails first and starts Job (head, lint); a test shard fails 30 minutes later and starts Job (head, shard). The lease stops the second push, but both model places can be in use for up to 3.5 hours.
  3. A waiting (suspended) fix Job can hold a place for all time. model_slots (job_launcher.py, about line 157) counts each suspended fix Job in the cluster, but only the watch row of its own repository resumes it, and a suspended Job has no deadline and no TTL. If a repository leaves service.repos or its watch row keeps failing, two such Jobs stop all implement and stage work in every repository.
  4. The watch row fails on each Kubernetes error. watch_row.py (about line 659) calls the fix-checks round with no guard and lists Jobs each round, so a ClusterJobError or ConfigurationError fails the whole row and counts toward the suspension of the row.
  5. A Job that its deadline killed is tried again as outcome none, so a step that is always slow runs up to 4 more times.
  6. The docstring of fix_checks_row.py (about lines 36-37) says that the Service writes nothing to GitHub, but in mode on _ready_after_fix (watch_row.py, about line 397) runs the step in the Service pod: it can mark a pull request ready or post a comment, and when a check fails between the two reads it raises RoadmapImplementError because no repair is given.
  7. The new dashboard panel (sum by (result)) can show about 13 series; the dashboard rule allows 3 series and Other.

Expected behavior

  • The attempt count, the outcome and the next allowed time of each unit live in the item record (FixChecksRecordKey, keyed by the unit), so a Job TTL does not reset them.
  • One fix unit for each pull request head (<pr>:<head>), or no new unit while a fix Job of the same pull request runs or waits.
  • A waiting fix Job counts against the places only while its repository is in service.repos, and a waiting Job older than a limit is deleted with a log line.
  • The fix-checks round of the watch row catches a Kubernetes error, logs it and counts it, and the rest of the row goes on.
  • A Job that ended with DeadlineExceeded is not tried again; it counts as its own outcome.
  • The docstring says what the Service writes, and _ready_after_fix handles a check that fails between the reads.
  • The panel shows at most 3 results and Other.
  • A test for each item fails on the base.

Related

Proposed design

Problem statement

A review after the merge of PR #6009 found defects in the fix-checks Jobs of the roadmap. The Job queue can waste or block the model places that implement and stage share: a daily Job TTL resets the retry cap, two Jobs can work one head, a suspended Job can hold a place for all time, a cluster error fails the whole watch row, and a Job that its deadline killed is tried again. The docstring of the row is wrong, _ready_after_fix raises on a check that fails between its reads, and the dashboard panel shows about 13 series where the chart rule allows 3 and Other.

Acceptance criteria

Requirement: Attempt state persists in the item record

The fix-checks round SHALL read and write the attempt count, the outcome and the next allowed time of each fix unit in the item record under FixChecksRecordKey, keyed by the unit key.

Scenario: A Job TTL does not reset the retry cap

  • WHEN the ended Jobs of a unit are deleted after their TTL, and the round judges the unit again
  • THEN the round takes the stored attempt count, the stored outcome and the stored next allowed time, and starts no Job before that time

Requirement: One fix unit for each pull request head

The unit key of a fix unit MUST be <pr>:<head>, so a second failing check on one head starts no second Job.

Scenario: Two checks fail on one head

  • WHEN lint fails and a test shard fails later on the same pull request head
  • THEN the round starts one fix Job for the head and writes one unit

Requirement: A waiting fix Job counts only while its repository is managed

A suspended fix Job SHALL count against the model places only while its repository is in service.repos, and the Service MUST delete a waiting Job older than the limit and write one log line.

Scenario: A waiting Job is older than the limit

  • WHEN a suspended fix Job is older than the limit, or its repository left service.repos
  • THEN the Service deletes the Job, writes one log line, and the Job no longer counts against the model places

Requirement: The watch row survives a Kubernetes error in the fix-checks round

The fix-checks round of the watch row MUST catch ClusterJobError and ConfigurationError, log the error, count it, and let the rest of the row continue.

Scenario: The Job list raises ClusterJobError

  • WHEN the fix-checks round lists the Jobs and the cluster raises ClusterJobError
  • THEN the row logs the error, counts it, and the other work of the row still runs

Requirement: A Job that its deadline killed is not tried again

The fix-checks round SHALL record DeadlineExceeded as its own outcome and MUST NOT start another Job for that unit.

Scenario: A fix Job ends with DeadlineExceeded

  • WHEN the fix Job of a unit ends with the reason DeadlineExceeded
  • THEN the round stores the outcome deadline_exceeded and starts no further Job for the unit

Requirement: The docstring and the ready step state what the Service writes

The docstring of fix_checks_row.py SHALL name each GitHub write that the Service makes in mode on, and _ready_after_fix MUST handle a check that fails between its two reads.

Scenario: A check fails between the two reads of the ready step

  • WHEN _ready_after_fix reads the checks, and a check fails before the second read
  • THEN _ready_after_fix handles the failure and raises no RoadmapImplementError

Requirement: The fix-checks panel shows at most three results and Other

The fix-checks dashboard panel in k8s/devops/dashboards/roadmap-service-telemetry.json MUST show at most 3 results and Other.

Scenario: More than three results exist

  • WHEN the panel query finds more than three distinct results
  • THEN the panel shows the three largest results and one Other series

Requirement: A regression test for each defect

The change MUST add one test for each defect of this issue that fails on the base revision and passes with the change.

Scenario: The new tests run on the base revision

  • WHEN the new tests run against the base revision
  • THEN each new test fails

Existing Tool Considered

No alternatives check has run (alternatives is null). The need is a fix inside devops-cli's own fix-checks Job queue: the attempt state, the unit key, the reaping of a suspended Job, the error handling of the watch row, the deadline outcome and the row docstring are roadmap-specific, and no open, maintained tool or library covers them (a web search for an open Kubernetes job-queue controller returned no covering project). The change edits existing modules (fix_checks_row.py, watch_row.py, job_launcher.py, steps/fix_checks.py, stores/store.py) and the dashboard JSON, and adds one test for each defect. Written cost: about 40,000 tokens to build, keep and fix the change, and about one working day of elapsed time.

Key questions

  • Where do the attempt count, the outcome and the next allowed time of a fix unit live?: In the item record, under FixChecksRecordKey, keyed by the unit key <pr>:<head>. The record outlives the Job, so a Job TTL resets nothing. (best practice) [sources: src/devops_cli/roadmap/stores/store.py:347, src/devops_cli/roadmap/steps/fix_checks.py:350, src/devops_cli/roadmap/steps/fix_checks.py:411]
    • Chosen: The item record (FixChecksRecordKey). The store already holds FixChecksRecordKey, and fix_checks.py already reads it, so the state outlives the Job TTL.
    • Rejected: Kubernetes Job annotations. cronjob-runner.yaml deletes ended Jobs after 24 hours, so the state dies with the Job.
    • Rejected: A Valkey key. A Valkey entry has a TTL and is derived state. The item record is the durable copy of a unit.
  • What is the unit key of a fix unit?: <pr>:<head>. One unit covers one pull request head, so two failing checks start one Job. (best practice) [sources: src/devops_cli/roadmap/watch_row.py:354, src/devops_cli/roadmap/steps/fix_checks.py:351]
    • Chosen: <pr>:<head>. One head gets one unit, so a second failing check starts no second Job and spends no second model place.
    • Rejected: <head>:<check>. The current form. FAILED arrives while other checks run, so a second check starts a second Job for the same head.
    • Rejected: <pr> alone. A new head after a push needs its own unit. One key for the pull request would block the new head.
  • What limit ends a waiting fix Job, and where does the setting live?: A new setting roadmap.fix_checks.suspended_max_seconds, default 14400. The Service deletes a suspended Job older than the limit and writes one log line. (best practice) [sources: docs/CLUSTER.md:73, src/devops_cli/roadmap/job_launcher.py:157]
    • Chosen: A new bounded setting roadmap.fix_checks.suspended_max_seconds. A suspended Job has no deadline and no TTL, so the Service needs its own bounded wait. The settings parser validates it.
    • Rejected: Reuse roadmap.implement.deadline_ceiling_seconds. That setting bounds an implement Job, not a waiting fix Job. One setting would then hold two meanings.
    • Rejected: Rely on the Job TTL. A suspended Job has no TTL, so it holds a model place for all time.
  • How does the fix-checks round of the watch row handle a Kubernetes error?: It catches ClusterJobError and ConfigurationError, logs the error, counts it, and lets the rest of the row continue. (best practice) [sources: src/devops_cli/roadmap/watch_row.py:659, docs/ERRORS.md:43, docs/ERRORS.md:47]
    • Chosen: Catch, log, count and continue. The row fails on each cluster error now, and each failure counts toward the suspension of the row.
    • Rejected: Let the round raise. One cluster error then fails the whole row and stops its other work.
    • Rejected: Retry the round inside the row. The sweep runs the row again on its interval. An inner retry holds the lane.
  • What outcome does a Job that ended with DeadlineExceeded get, and is it tried again?: Its own outcome deadline_exceeded. The round starts no further Job for the unit. (best practice) [sources: src/devops_cli/k8s/cluster_job_api.py, src/devops_cli/roadmap/fix_checks_row.py:291]
    • Chosen: Its own outcome, no retry. A step that is always slow would run up to 4 more times as outcome none.
    • Rejected: Outcome none with a retry. The current behavior. It spends up to 4 more model places on a step that cannot finish.
    • Rejected: Outcome error. It is not a provider or code error, and it would get the wait of the wrong class.
  • What does _ready_after_fix do when a check fails between its two reads?: It treats the pull request as not ready, logs the failed check and returns without raising RoadmapImplementError. (best practice) [sources: src/devops_cli/roadmap/watch_row.py:397, src/devops_cli/roadmap/steps/ready.py, src/devops_cli/exceptions/roadmap.py:61]
    • Chosen: Re-read the checks and skip the ready step. The fix place is already spent. A raised error fails the row and gives no repair.
    • Rejected: Pass the failure as a repair to the fix round. It spends a second model place on one check.
    • Rejected: Raise RoadmapImplementError. The current behavior. It fails the watch row on a check that failed between the reads.
  • What does the docstring of fix_checks_row.py say about the GitHub writes of the Service?: It must name each write that the Service makes in mode on: _ready_after_fix runs the ready step in the Service pod, so the Service can mark a pull request ready and post a comment. The current docstring at fix_checks_row.py:36-37 says that the Service writes nothing to GitHub, and that claim is false. (best practice) [sources: src/devops_cli/roadmap/fix_checks_row.py:36, src/devops_cli/roadmap/watch_row.py:397, src/devops_cli/roadmap/steps/ready.py]
    • Chosen: Name each write of mode on. _ready_after_fix runs the ready step in the Service pod, so the Service writes to GitHub.
    • Rejected: Keep the current docstring. It says the Service writes nothing to GitHub, and a reader takes that as a safety claim.
  • Where does the dashboard rule that allows 3 series and Other live, and what is its text?: The rule is C7 of docs/DESIGN.md: 'At most 3 colored series (chart.max-series), in the order cat.1 to cat.3, plus "Other" in color.data.neutral. Color follows the entity.' The token chart.max-series is 3 in src/devops_cli/design/tokens-base.json (and --chart-max-series: 3 in src/devops_cli/design/tokens-base.css). The offending panel is 'Service Fix-Checks Jobs by Result' in k8s/devops/dashboards/roadmap-service-telemetry.json, whose query sum by (result) (increase(devops_cli_service_fix_checks_jobs_total{job=~"$job",repo=~"$repo"}[1h])) returns one series for each result value. [sources: docs/DESIGN.md:110, docs/DESIGN.md:225, src/devops_cli/design/tokens-base.json:49, k8s/devops/dashboards/roadmap-service-telemetry.json:862]
  • How does the fix-checks panel query keep at most 3 results and Other?: Keep sum by (result) and bound it in the query: take the three largest results with topk(3, ...) and add one Other series as the total minus those three, so the panel has at most 4 series, per C7 of docs/DESIGN.md. (best practice) [sources: docs/DESIGN.md:225, src/devops_cli/design/tokens-base.json:49, k8s/devops/dashboards/roadmap-service-telemetry.json:862]
    • Chosen: topk(3, ...) plus a computed Other series. C7 allows 3 colored series plus Other; the query itself bounds the series count and the test at tests/grafana/test_grafana_dashboards.py:999 reads the panel query.
    • Rejected: A Grafana transform on the current query. The panel has no transform today, and the rule is stated on the query, which the dashboard test reads.
    • Rejected: Keep sum by (result) and let the legend list every result. That is the current defect: about 13 series against chart.max-series = 3.
  • Do the cited lines hold the code that the issue names?: Yes. fix_checks_row.py:284-285 returns attempt 1 when no Job exists (_next_attempt([])), watch_row.py:353-354 builds the fix unit from the check of the head, watch_row.py:659 calls run_fix_checks_round with no guard, job_launcher.py:157-168 counts each suspended fix Job in the cluster, and the docstring at fix_checks_row.py:36-37 says that the Service writes nothing to GitHub. [sources: src/devops_cli/roadmap/fix_checks_row.py:284, src/devops_cli/roadmap/watch_row.py:353, src/devops_cli/roadmap/watch_row.py:659, src/devops_cli/roadmap/job_launcher.py:157, src/devops_cli/roadmap/fix_checks_row.py:36]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    source/agent
    scope/roadmap
    status/new
    effort/high
    on Nov 16, 2026
  2. dan-petty commented on Nov 16, 2026

    @dan-petty
    OwnerAuthor
    • Priority: P1-High. The retry cap resets daily and suspended Jobs can block all implement and stage work, causing active resource waste and potential total blockage.
    • Related: fix(roadmap): Guard fix-checks against a live Job and a repeated failure #5983, which asks for a different change. Both guard fix-checks Jobs against concurrent or repeated work, but #5983 covers two specific gaps while the candidate fixes seven defects including queue bounds, suspension, and error handling.
  3. added
    value/high
    priority/p1-high
    owner/agent
    status/in-progress
    and removed
    status/new
    on Nov 16, 2026
  4. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

  5. added
    status/in-review
    and removed
    status/in-progress
    on Nov 16, 2026
  6. removed
    status/in-review
    owner/agent
    on Nov 16, 2026
  7. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-16 21:30 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/highpriority/p1-highscope/roadmapsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions