Skip to content

feat(roadmap): the poll frees the check-out of a gone job #5524

Open

Description

@dan-petty

Problem or Motivation

Owner request, 2026-11-13: "service jobs should check issues in and out when they are being worked on, polling looks at jobs that are checked out and the job is missing/failed".

Today a Service job claims an item through marks in its record block, such as stage.pending, implement.job and fix_plan.at. When the unit of the job ends with no check-in, the claim stays: a failed Job, an evicted pod, a lost Job or a Service restart. No job frees it, and other jobs skip the item.

Occurrence on 2026-11-13: the record of #1928 holds implement.job=devops-cli-runner-20261112-163430-77e5, implement.job_state=failed and implement.pr=5140. Pull request #5140 is a closed plan, and the Job is not in the cluster (kubectl get job gives NotFound). The implement row reported the Job (implement_submit.py records failed or gone), but it does not clear implement.job. Two rows skip any item that holds implement.job:

Agents that fix Service branches directly also need one place that tells whether a job works the item now.

Proposed Solution & Architectural Design

  • One check-out record for each item: the job name, the unit name (Job or Workflow), the start time and the deadline. The job writes it before work starts and clears it at its last write (check-in), with the result.
  • The poll lists the checked-out items and compares them with the unit list. For a unit that is missing, failed or past its deadline plus a margin, it records the class (gone, failed, deadline), frees the check-out and makes the next job due. A person or agent claim beats the Service.
  • The first case: an implement.job whose implement.job_state is failed or gone frees the check-out, so stage_ready and the fix-plan filter read the item again.
  • This is the claim protocol of the approved pipeline split (feat(roadmap): track the roadmap pipeline split into jobs #5482: Start, One writer, End, Free a stuck claim), applied to every job. It relates to fix(roadmap): repair a job record mark that a parallel write lost #4555 (lost record marks) and feat(roadmap): the phase of each item drives the stuck-item alert #5495 (stuck-item phase).

Target Subsystem

roadmap

Existing Tool Considered

Kubernetes Lease objects and Job owner references hold a claim on the server; #4564 plans record locks in Valkey. The check-out uses the unit list of the Kubernetes API, which the implement row reads today.

Source: #5422 (comment)

Owner decision 2026-11-13: every job

The owner decision of 2026-11-13 applies this protocol to every job of the pipeline split (tracker #5482). This item builds the shared part and connects the jobs that run today. Each item that moves a job to its own unit keeps the check-out and names the new unit.

Job map: the issue that writes the check-out and the check-in of each job. The recovery is this item for every job.

Job Check-out and check-in
stage #5483 (the Job side and the check-in marks stage.job*) and #4559 part 2 (the submit writes the check-out)
scaffold Runs inside the stage unit (#5499) and the tests unit (#5518, #5520), under the check-out of that unit
implement This item (the first case: implement.job with implement.job_state failed or gone). #4713, #5029 and #3105 keep it
refine, refine_judge This item for the row today. #4568 keeps it in its own pod. refine_judge runs inside refine, under the refine check-out
intake, retitle, premise This item for the rows and steps today. #4567 (triage unit), #5507 and #5508 keep it
alternatives This item for the row today. #4573 and #5513 (research unit) keep it
fix_plan This item for the row today. #5412 (fix-plan Jobs) keeps it. #5493 reads the class
fix-checks, fix-conflict #5027 and #5028 (the Job launcher)
tests, review #5520, #5521
incident, supervise #5477. Supervise reads a passed deadline, and this item frees it
group, split, inherit, related, resolve, watch, cleanup Not a row today. The item that builds the job writes them: #4813, #4819 and #4821 (group, split), #5510 (inherit), #5515 (related), #4805 and #4809 (resolve), #5024 (watch), #5026 (cleanup)
open A step inside the unit that opens the PR (stage, and implement after #4713), under the check-out of that unit. #5020 builds the step
candidates and judge #5533: each candidate step has its own check-out entry
  • Test first: for each class (gone, evicted, failed, deadline), the poll frees the check-out, records the class and makes the next job due. The test fails on the base.
  • A test: the poll does not free a person or agent claim, or the check-out of a unit that runs within its deadline.
  • A test: each job that runs today (stage, implement, refine, refine_judge, intake, alternatives, fix_plan, retitle) writes the check-out before its first write of work and checks in at its end write.
  • A test: a check-in that finds another unit name in <job>.job clears nothing.
  • A test: --dry-run sends 0 requests.
  • Live proof: after the merge and the release, the poll frees the check-out of refactor(ai): rank the benchmark with numpy and pytrec-eval #1928, or of another live item with a gone unit, as the App. stage_ready and the fix-plan filter then read the item again. A comment gives the result lines.
  • If the estimate goes above 1 day, move the connection of each job to a sub-issue (delivery rule of feat(roadmap): track the roadmap pipeline split into jobs #5482).

Alternatives check of 2026-12-01: in-use.
The repository already uses this tool.
Tool: Kubernetes (https://github.com/kubernetes/kubernetes), Apache-2.0, last activity 2026-11-27, maintained.
Reason: The searches found no tool that keeps a check-out in the item record and frees it. The Kubernetes API gives the Job, pod and deadline facts that the poll reads, so it covers the detection only.

Covers:

  • Job status: failed, gone and past deadline
  • Pod status: evicted and OOM
  • One list of Jobs and pods to compare

Lacks:

  • Check-out marks in the item record block
  • Check-in that clears only the own unit
  • Class record, due-job handoff and dry-run count

Proposed design

Problem statement

A Service job claims an item with record marks. If its unit ends without a check-in, the claim stays and other jobs skip the item. This change adds one check-out record for each job and a poll step that frees a gone, failed, evicted, OOM or overdue unit. The step keeps a person or agent claim and connects the jobs that run today. The live proof stays a post-release check.

Acceptance criteria

Requirement: Check-out before work

A job SHALL write its check-out record before its first write of work.

Scenario: Job starts with no check-out

  • WHEN a job starts work on an item with no check-out record
  • THEN the job writes <job>.job, <job>.job_at and <job>.job_deadline to the item record before any work mark.

Requirement: Check-in only for own unit

A check-in SHALL clear the check-out only when <job>.job names the job's own unit.

Scenario: Check-in with another unit

  • WHEN a job reaches its end write and <job>.job names a different unit
  • THEN the end write records <job>.job_result and leaves the check-out unchanged.

Requirement: Poll frees a gone unit

The poll SHALL free a check-out whose unit is gone.

Scenario: Gone unit

  • WHEN the poll reads a checked-out item and the Kubernetes API has no Job or pod for its unit
  • THEN the poll records class gone, clears the check-out and makes the next job due.

Requirement: Poll frees a failed unit

The poll SHALL free a check-out whose Job failed.

Scenario: Failed Job

  • WHEN the poll reads a checked-out item whose Job has failed
  • THEN the poll records class failed, clears the check-out and makes the next job due.

Requirement: Poll frees a unit past its deadline

The poll SHALL free a check-out whose deadline plus 5 minutes has passed.

Scenario: Deadline passed

  • WHEN the poll reads a checked-out item whose deadline plus 5 minutes has passed
  • THEN the poll records class deadline, clears the check-out and makes the next job due.

Requirement: Poll frees an evicted pod

The poll SHALL free a check-out whose pod status reports eviction.

Scenario: Evicted pod

  • WHEN the poll reads a checked-out item whose pod status reports eviction
  • THEN the poll records class evicted, clears the check-out and makes the next job due.

Requirement: Poll frees an OOM pod

The poll SHALL free a check-out whose pod status reports OOM.

Scenario: OOM pod

  • WHEN the poll reads a checked-out item whose pod status reports OOM
  • THEN the poll records class oom, clears the check-out and makes the next job due.

Requirement: Poll keeps a retried evicted Job

The poll SHALL keep the check-out of a Job that runs its evicted pod again.

Scenario: Evicted pod retried

  • WHEN the poll reads a checked-out item whose Job runs a new pod after an eviction
  • THEN the poll leaves the check-out unchanged.

Requirement: Poll keeps a running unit

The poll SHALL keep the check-out of a unit that runs within its deadline.

Scenario: Running unit

  • WHEN the poll reads a checked-out item whose Job runs and whose deadline has not passed
  • THEN the poll leaves the check-out and the due jobs unchanged.

Requirement: Poll keeps a person claim

The poll SHALL NOT free a check-out that a person claims.

Scenario: Person claim

  • WHEN the poll reads a checked-out item with owner/human
  • THEN the poll leaves the check-out and the claim unchanged.

Requirement: Poll keeps an agent claim

The poll SHALL NOT free a check-out that an agent claims.

Scenario: Agent claim

  • WHEN the poll reads a checked-out item with owner/agent
  • THEN the poll leaves the check-out and the claim unchanged.

Requirement: Implement first case

The poll SHALL free implement.job when implement.job_state is failed or gone.

Scenario: Implement row state

  • WHEN the record holds implement.job and implement.job_state is failed or gone
  • THEN the poll clears the check-out, _recorded_pull returns the recorded pull and the fix-plan filter no longer reports fix_plan_left_runner.

Requirement: Dry run sends no request

The poll SHALL send 0 requests with --dry-run.

Scenario: Dry run

  • WHEN the poll runs with --dry-run
  • THEN it sends 0 HTTP requests and writes no record.

Requirement: Current jobs check out and in

Each job that runs today SHALL write the check-out before its first work write and check in at its end write.

Scenario: Current jobs

  • WHEN the test runs stage, implement, refine, intake, alternatives, fix_plan and retitle against a fake record store
  • THEN each job writes the check-out before its first work write and clears it at its end write.

Requirement: Refine judge uses refine check-out

refine_judge SHALL run under the refine check-out and SHALL write no check-out of its own.

Scenario: Refine judge under refine

  • WHEN refine starts refine_judge
  • THEN refine_judge writes no <job>.job mark and the refine check-out stays in place.

Requirement: Pending a person after the merge

A person SHALL run the live proof after the merge and the release.

Scenario: Live proof after release

  • WHEN after the merge and the release, a person runs the poll on a live item with a gone unit
  • THEN the poll frees the check-out, stage_ready and the fix-plan filter read the item again, and a comment gives the result lines.

Existing Tool Considered

The alternatives check in the issue body records verdict rejected for kubernetes/kubernetes, rejected by ADR 0021. The proposal uses the item's GitHub record block for the check-out and reads the Kubernetes Job and pod status for the classes that the tool lacks.

Key questions

  • Which jobs does the check-out protocol cover?: The owner decision of 2026-11-13 applies the check-out protocol to every job of the pipeline split. This item builds the shared part and connects implement, refine, intake, retitle, alternatives and fix_plan. Stage uses feat(roadmap): add the stage Job template and one-item entry point #5483 and feat(roadmap): run each stage item in its own Job #4559 part 2, and refine_judge runs under the refine check-out. (best practice) [sources: CONTEXT.md, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md]
    • Chosen: Every job, with this item connecting the jobs that run today. The owner decision of 2026-11-13 applies the protocol to every job.
    • Rejected: Only implement. It leaves other jobs with stuck claims.
    • Rejected: Only long rows. It leaves short rows with stuck claims.
  • Where does a job store its check-out?: In the item's GitHub record block, with <job>.job, <job>.job_at, <job>.job_deadline and <job>.job_result. (best practice) [sources: docs/adr/0001-github-is-the-roadmap-source.md, CONTEXT.md]
    • Chosen: GitHub record block. The issue body is the job record, so no extra store is needed.
    • Rejected: Kubernetes Lease. ADR 0021 rejects per-lock Leases, and a Lease holds no record mark or due handoff.
    • Rejected: Valkey lock. It adds a second store and no record mark, and feat(roadmap): keep plan records and record locks in Valkey #4564 owns that path.
  • Which unit list does the poll compare with the check-out?: The poll reads Kubernetes Jobs and pods today. It reads Workflows after feat(k8s): let Argo Workflows run roadmap pods in devops #4566. (best practice) [sources: src/devops_cli/roadmap/implement/implement_submit.py:289, src/devops_cli/roadmap/implement/implement_submit.py:375, CONTEXT.md]
    • Chosen: Kubernetes Job and pod list. The implement row already reads this list and the pod status.
    • Rejected: Kubernetes Lease list. ADR 0021 rejects the Lease path and a Lease is no unit.
    • Rejected: GitHub check runs. A check run is no unit and does not name a Job or pod.
  • How does the poll classify a stale unit?: It records gone, failed, deadline, evicted or oom from the unit and pod status. A Job that runs its evicted pod again stays checked out. (best practice) [sources: src/devops_cli/roadmap/implement/implement_submit.py:289, src/devops_cli/roadmap/implement/implement_submit.py:375, CONTEXT.md]
  • What margin applies to a passed deadline?: The poll adds 5 minutes to the deadline before it frees the check-out. (best practice) [sources: CONTEXT.md]
    • Chosen: 5 minutes. The sweep runs every 5 minutes, so the margin matches one poll interval.
    • Rejected: No margin. A poll at the deadline can race the check-in.
    • Rejected: 15 minutes. It delays recovery for no gain.
  • Does the poll free a person or agent claim?: No. The poll frees only a Service check-out and leaves owner/human and owner/agent alone. (best practice) [sources: CONTEXT.md]
    • Chosen: Keep person and agent claims. CONTEXT.md says no job removes such a claim.
    • Rejected: Free all claims after a timeout. It breaks the claim rule and can stop a person's work.
    • Rejected: Free only agent claims. It breaks the same rule for agents.
  • Where does the recovery run today?: The poll of the Service runs the recovery now. After feat(roadmap): run the reconcile sweep on a cluster schedule #4574, the same step runs in the sweep. (best practice) [sources: CONTEXT.md]
  • Does a checked-out item appear as a due job?: No. due_jobs reads a check-out as a running unit, so the item has no other due job. (best practice) [sources: src/devops_cli/roadmap/fix_checks_row.py:5, CONTEXT.md]
    • Chosen: Check-out blocks due jobs. It prevents a second job on the same item.
    • Rejected: Check-out does not block due jobs. It lets two jobs work the same item.
    • Rejected: Due jobs ignore check-out. It gives the same double work.
  • When does a check-in clear the check-out?: Only when <job>.job names the job's own unit. The end write records <job>.job_result and clears the check-out in one write. (best practice) [sources: CONTEXT.md, docs/adr/0001-github-is-the-roadmap-source.md]
    • Chosen: Clear only own unit. CONTEXT.md says an item never gets a second unit, so another name is a stale or foreign claim.
    • Rejected: Clear any unit. It removes another job's check-out.
    • Rejected: Clear after result. A failed result leaves the check-out in place.
  • How does the poll treat an implement job with failed or gone state?: It frees implement.job and makes the next job due. stage_ready and the fix-plan filter then read the item. (best practice) [sources: src/devops_cli/roadmap/stage/stage_ready.py:103, src/devops_cli/roadmap/steps/fix_plan.py:432, src/devops_cli/roadmap/implement/implement_submit.py:289]
    • Chosen: Free on failed or gone state. The implement row records the state and the two readers skip the item while implement.job stays.
    • Rejected: Wait for a person retry. The issue exists because no job frees the claim.
    • Rejected: Free on any state. A running Job must keep its check-out.
  • Does refine_judge write its own check-out?: No. refine_judge runs inside refine, under the refine check-out, and writes no check-out of its own. (best practice) [sources: CONTEXT.md]
    • Chosen: Under the refine check-out. The job map says refine_judge runs inside refine.
    • Rejected: Its own check-out. It adds a second unit for work that refine already holds.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4555, #4559, #5483, #5504

Activity

  1. added
    source/agent
    type/feature
    scope/roadmap
    status/new
    value/high
    effort/medium
    on Nov 13, 2026
  2. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 13, 2026
  4. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Alternatives check: rejected

    Reason: Searches surfaced no dedicated stale-claim tool; Kubernetes Lease objects hold a holder, start time and expiry, but leave the GitHub record marks, unit-status classes and due-jobs step to the project, and ADR 0021 rejected per-lock Leases.

    Rejected by ADR 0021. A newer fact can change an ADR.

    Tool: kubernetes/kubernetes (https://github.com/kubernetes/kubernetes), Apache-2.0, last activity 2026-11-17, maintained.

    Covers:

    • Holder identity, acquire time and lease duration on the server
    • Expiry after a duration, so a stale holder is detectable
    • Read and written through the Kubernetes Python client

    Lacks:

    • No check-out marks in the item's GitHub record block
    • No gone, failed, evicted or deadline class from Job and pod status
    • No person-versus-agent claim rule and no due-jobs handoff
    • Each renewal is an API write, and agent pods hold no API token
    Searches (9)

    Tools considered:

    Searches run:

    • Kubernetes Lease object stale holder detection job check-out expire, results: 5
    • distributed lock library stale lock expiration python redis valkey, results: 5
    • github lease-based distributed lock python kubernetes lease library, results: 5
    • "lease" library github stale worker job claim expiry reaper, results: 5
    • redlock-py github distributed lock redis, results: 5
    • kubernetes lease coordination.k8s.io holderIdentity leaseDurationSeconds, results: 5
    • kubernetes python client coordination v1 lease example, results: 5
    • pottery python redis lock pypi, results: 5
    • Kubernetes Lease object documentation coordination API, results: 5

    Sources:

    A person decides what this check of 2026-11-17 means for the item.

  5. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 86358b6 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

  6. devops-cli-service commented on Nov 27, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  7. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: rejected, tool https://github.com/kubernetes/kubernetes. A person decides what the new result means for the item.

    Searches (8)

    Tools considered:

    Searches run:

    • Kubernetes Job status failed detect stale job and free lock automatically, results: 5
    • kubernetes job cleaner operator delete finished jobs ttl-after-finished, results: 5
    • kubernetes Job conditions Complete Failed pod failure policy documentation, results: 5
    • open source stale job lock recovery heartbeat expiry library, results: 5
    • Kubernetes Lease object heartbeat detect dead holder leader election, results: 5
    • kubernetes.io docs jobs activeDeadlineSeconds backoffLimit job status conditions, results: 5
    • Temporal activity heartbeat timeout detect dead worker reclaim task, results: 5
    • github kubernetes job reaper detect failed jobs cleanup controller, results: 5

    Sources:

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/mediumpriority/p2-mediumscope/roadmapsource/agentstatus/newtype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions