Skip to content

feat(roadmap): durable runs: a step survives an eviction, an OOM or a restart #3062

Closed

Description

@dan-petty

What happened

A runner Job that the kernel kills (OOM at 4 Gi), a pod that is evicted, or a Service restart ends the run. The next round records a stop, and a person or a new image digest must clear it. The Job deadline is a fixed 7200 s.

What should happen

  • Checkpoints (D2) plus a run state in the job record let a new Job continue a run: the Service finds a Job that ended without a report and starts a continuation Job, bounded by a count per item.
  • Heartbeats from the runner (a field of the job record, updated at each tool or model call) tell the Service that a run lives; a silent run is ended and continued.

Acceptance criteria

  • A replay that kills the runner after step 2 of 4 ends with a continuation Job that runs steps 3 and 4.
  • The Service distinguishes a slow run from a dead one by the heartbeat age (a setting).
  • Continuations per item are bounded, and the comment says how many were used.
  • The run state holds no secret.

Related: tracker for this set (filed with it), #2908 (issue workflow), #2867 (draft PR evaluator), #3005 (task kind), #3010 to #3015 (plan gates), #2919 (stuck-item metrics), #2953 (Ollama parser).

Alternatives check of 2026-11-04: covers.
Tool: temporalio/temporal (https://github.com/temporalio/temporal), MIT, last activity 2026-11-04, maintained.

Proposed design

Problem statement

A runner Job can end by OOM, eviction or a Service restart. The Service records a stop, and only a person or a new image digest clears it. This change adds a bounded continuation for a retry-class stop. The Service starts a new Job when continuations remain. It keeps the existing silent-run decision and stores only a count. The per-group checkpoint on origin is deferred to a new issue.

Acceptance criteria

Requirement: retry_stop_gets_continuation

The Service SHALL start a continuation for a retry-class implement stop when the item has continuations left.

Scenario: Retry-class stop starts a continuation

  • WHEN An implement Job sets implement.stopped=job with a retry-class failure, and implement.continuations is below the setting.
  • THEN The Service clears the stop with a continuation Job and increments implement.continuations by one.

Requirement: continuation_uses_no_digest_clear

The continuation rule SHALL run before the digest rule and SHALL NOT spend a digest clear.

Scenario: Continuation wins over digest clear

  • WHEN A retry-class stop and a new image digest are both present.
  • THEN The Service records a continuation and leaves the digest clear count unchanged.

Requirement: continuation_limit_keeps_blocked

The Service SHALL stop at the configured limit and leave the item Blocked.

Scenario: Third stop after two continuations

  • WHEN The setting is 2, the item has used 2 continuations, and a retry-class stop occurs.
  • THEN The Service leaves the item Blocked and comments No continuation is left.

Requirement: continuation_comment_reports_count

The Service SHALL comment the continuation number and the limit when it starts a continuation.

Scenario: First continuation comment

  • WHEN The Service starts continuation 1 of 2.
  • THEN The comment says continuation 1 of 2.

Requirement: continuation_record_has_no_secret

The job record SHALL hold only the continuation count and no secret.

Scenario: Record after a continuation

  • WHEN The Service records a continuation.
  • THEN The record key implement.continuations is an integer and the record holds no token or credential.

Requirement: zero_disables_continuation

A setting value of 0 SHALL disable continuation and keep the current Blocked behavior.

Scenario: Zero setting keeps Blocked

  • WHEN The setting is 0 and a retry-class stop occurs.
  • THEN The item stays Blocked and the Service starts no continuation Job.

Requirement: killed_run_resumes_from_origin

The Service SHALL continue a killed run from the work that is on origin through wip: commits.

Scenario: Kill after step 2 of 4

  • WHEN A replay kills the runner after step 2 of 4, and steps 1 and 2 are on origin.
  • THEN A continuation Job starts and runs steps 3 and 4.

Requirement: silent_run_uses_existing_setting

The Service SHALL use the existing roadmap.implement.deadline_stall_seconds decision to mark a run silent.

Scenario: Fresh log is not ended

  • WHEN The Job log digest is unchanged for less than the setting.
  • THEN The Service does not end the Job and starts no continuation.

Existing Tool Considered

temporalio/temporal (MIT, maintained, last activity 2026-11-04) covers durable run state, heartbeats, resume from heartbeat details and bounded retries. It lacks a Kubernetes continuation Job and a read of the hidden job record. The runner becomes a Temporal worker, and the Service must run or connect to a Temporal server. It has no built-in GitHub comment for continuations. Its event history is not secret-free by construction. It replaces the fixed 7200 s Job deadline with per-activity timeouts.

Key questions

  • The alternatives check found that https://github.com/temporalio/temporal covers this item. Adopt the tool, or keep the item and give the reason.: Keep the item. Do not adopt Temporal. ADR 0008 rejects the new Postgres and 3 to 6 pods. The git checkpoint and the feat(roadmap): long-running tasks: progress-based deadlines instead of a fixed two hours #3063 liveness signal already exist. Temporal also lacks a Kubernetes continuation Job and a secret-free history. (best practice) [sources: CONTEXT.md]
    • Rejected: Adopt temporalio/temporal. It adds a Temporal server, a new Postgres and 3 to 6 pods. ADR 0008 rejects this. It does not create the Kubernetes continuation Job.
    • Chosen: Keep the item and add a Service continuation rule. The Service already records the stop and reads the liveness signal. A small rule reuses them and adds no infrastructure.
    • Rejected: Use Argo Workflows retryStrategy. It re-runs a step and has no checkpoint. The runner is not on Argo yet.
  • What does the Service do when an implement Job stops today?: _report in implement_submit.py sets Blocked and implement.stopped=job. Only a person's implement: retry or a new image digest clears that stop. [sources: src/devops_cli/roadmap/implement_submit.py, src/devops_cli/roadmap/stop_clear.py]
  • Is a heartbeat field needed to tell a slow run from a dead run?: feat(roadmap): long-running tasks: progress-based deadlines instead of a fixed two hours #3063 reads the Job log digest and ends a silent Job after roadmap.implement.deadline_stall_seconds. A heartbeat field would cost one GitHub write per tool call, so feat(roadmap): long-running tasks: progress-based deadlines instead of a fixed two hours #3063 rejected it. [sources: src/devops_cli/roadmap/implement_deadline.py]
  • Where does the continuation rule run?: In stop_clear.py, as rule continue, before the digest rule. It applies to implement.stopped=job with a failure class whose action is retry, and it spends no digest clear. (best practice) [sources: src/devops_cli/roadmap/stop_clear.py, src/devops_cli/roadmap/implement_submit.py]
  • How are continuations bounded and recorded?: Use roadmap.implement.continuations_per_item, default 2. A value of 0 turns continuation off. The record key implement.continuations holds only the count. (best practice) [sources: src/devops_cli/roadmap/store.py]
    • Chosen: Default 2, setting 0 disables. It bounds the loop and gives two recovery attempts. An operator can turn it off.
    • Rejected: No bound. A dead Job could loop forever.
    • Rejected: Default 1. One attempt does not survive a second eviction.
  • Why does a one-task group lose its passed work on a kill?: _groups in implement_run.py records a passed group but does not push. A wip: push occurs only while tasks of a group are unticked. So a one-task group has no checkpoint on origin, and groups 1 and 2 are lost. [sources: src/devops_cli/roadmap/implement_run.py]
  • Do we add per-group checkpoint pushes in this issue?: No. Defer it. A push conflicts with feat(roadmap): an item has one owner, service, agent or human, and the jobs skip a claimed item #2910, feat(roadmap): the implement job runs the scoped CI before it pushes and repairs failures #3043 and the false-premise return. The owner must choose the item branch or a hidden ref. (best practice) [sources: src/devops_cli/roadmap/implement_run.py, src/devops_cli/roadmap/stop_clear.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

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

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P1-High. OOM and eviction are observed in production and each kills a full run, requiring manual clearing.
    • Value: High. Eliminates total work loss and manual intervention on every transient runner failure.
    • Effort: High. Requires checkpoint state, heartbeat protocol, Service-side liveness detection, continuation Job creation, and bounded retry logic.
    • Related: feat(roadmap): a stopped step keeps its work and the next attempt resumes from it #3054, which asks for a different change. Both items address resuming work after a stop, but #3054 preserves step-level work on a ref while this candidate adds Service-level run detection, heartbeat liveness, and continuation Job creation.
  3. added
    priority/p1-high
    on Nov 1, 2026
  4. devops-cli-service commented on Nov 1, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 2ae3772 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • What does the reference 'D2' (checkpoints) point to? (missing verified source)
  5. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Alternatives check: covers

    Tool: temporalio/temporal (https://github.com/temporalio/temporal)

    • License: MIT
    • Last activity: 2026-11-04
    • Maintained: yes

    Covers:

    • Durable run state: the workflow event history survives a worker crash, a pod eviction or a restart, and the run continues on a new worker instead of ending.
    • Runner heartbeats: an activity sends heartbeats, and a configurable heartbeat timeout marks a silent run as failed (the slow-versus-dead distinction).
    • Resume from the last checkpoint: heartbeat details are persisted and handed to the retry attempt, so a run killed after step 2 of 4 resumes at step 3 on a new worker.
    • Bounded continuations: a RetryPolicy maximum_attempts caps the attempts for an activity, and the attempt number is available to the activity.
    • Python SDK (temporalio) that fits the project's runner code.

    Lacks:

    • Does not create a Kubernetes continuation Job or read the hidden job record; the runner becomes a Temporal worker/activity, and the Service must run or connect to a Temporal server (a new infrastructure dependency).
    • No built-in GitHub comment reporting how many continuations were used; the Service must read the attempt count and write the comment itself.
    • The heartbeat details and event history are not secret-free by construction; the runner must keep tokens and credentials out of the checkpoint payload, or add payload encryption.
    • The fixed 7200 s Job deadline is replaced by per-activity timeouts, so the existing deadline has to be re-expressed rather than reused.

    Searches run:

    • durable execution framework checkpoint resume heartbeat timeout bounded retries
    • Temporal activity heartbeat timeout retry policy max attempts durable workflow
    • Temporal heartbeat details available on retry resume activity progress checkpoint

    Sources:

    Checked on 2026-11-04. A person decides what this means for the item. The check changes no label and closes no issue.

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

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 0e3427f until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • The alternatives check found that https://github.com/temporalio/temporal covers this item. Adopt the tool, or keep the item and give the reason. (a person decides)
  7. dan-petty commented on Nov 5, 2026

    @dan-petty
    OwnerAuthor

    This item cannot be built as written. Evidence follows.

    PREMISE CHECK (origin/main 66a8a63)

    1. D2 is feat(roadmap): a stopped step keeps its work and the next attempt resumes from it #3054 (merged as PR feat(roadmap): a stopped step keeps its work and a new Job resumes #3560, archived change 2026-11-05-3054). The refine bot asked what D2 means. The tracker feat(roadmap): an enterprise-grade plan and implement pipeline (tracker) #3027 lists D2 as "checkpoints".

    2. The heartbeat criterion is already met by feat(roadmap): long-running tasks: progress-based deadlines instead of a fixed two hours #3063. The Service reads the Job log, compares its digest, and ends a silent Job after the setting roadmap.implement.deadline_stall_seconds (src/devops_cli/roadmap/implement_deadline.py). A heartbeat field in the job record would cost one GitHub write per tool call, so feat(roadmap): long-running tasks: progress-based deadlines instead of a fixed two hours #3063 rejected it.

    3. The continuation Job is missing. _report in implement_submit.py sets Blocked and implement.stopped=job. Only a person's implement: retry or a new image digest clears that stop (stop_clear.py, fix(roadmap): a new runner image clears only a stop that it can fix #3481).

    4. The first criterion (kill after step 2 of 4, then a continuation Job runs steps 3 and 4) FAILS on main for groups that have one task. I wrote a replay test: 4 groups with one task each, and a runner killed by a BaseException in group 3. On main, origin holds 1 commit (the plan), not 3. Groups 1 and 2 are lost.

    5. Open tools:

    6. CONFLICT that needs an owner decision. I pushed each passed group to the item branch (about 10 lines in _groups) and ran tests/roadmap. At least 10 tests failed. They check these requirements:

      • feat(roadmap): an item has one owner, service, agent or human, and the jobs skip a claimed item #2910: a claim ends the Job with no push and no pull request. Tests: 4 in test_roadmap_implement_job.py, plus test_a_planned_item_that_a_person_claims_gets_no_branch_and_no_pull_request.
      • feat(roadmap): the implement job runs the scoped CI before it pushes and repairs failures #3043: the scoped-check stops push nothing. 3 tests in test_roadmap_implement_job_scoped.py.
      • Spec requirement "A false premise returns the item to New": it pushes nothing and leaves the old tip. Test: test_false_premise_on_staged_item_after_group_1_leaves_old_tip_and_clears_group. For a Planned item, a pushed branch would also hold the item back (issue_holder).
      • The push-count test in test_roadmap_implement_job.py.
        Making the push safe needs compensating code (undo the push on a premise return) or a new hidden-ref mechanism with its own resume and cleanup. The issue names neither. I reverted the change. Saved aside: .data/agent/3062-checkpoint-push.patch and .data/agent/scratch/test_roadmap_implement_checkpoint.py (the fail-to-pass test).

    RE-SCOPE PROPOSAL

    ON DISK (not pushed, not committed)

    • Worktree: /workspaces/devops-cli/.claude/worktrees/wf_1dd0e72e-d13-2, branch feat/3062-durable-runs (from origin/main 66a8a63).
    • Part A edits: src/devops_cli/roadmap/stop_clear.py (ClearLimits replaces DigestLimits; rule continue), store.py, config/defaults.py, config/settings.py, lang/en/messages.py, and the test files test_roadmap_stop_clear.py, test_roadmap_digest_clears.py, test_roadmap_limit_classes.py, test_roadmap_implement_project_steps.py and tests/security/test_config_declarations.py.
    • No OpenSpec change folder was written.

    A local draft of Part A exists in a worktree of the agent that checked this item. It is not pushed. It is kept only until a person decides the re-scope.

  8. added
    status/ready
    and removed
    status/new
    on Nov 5, 2026
  9. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at f6d57ec (see proposed design in issue body).

    Moved to new items: #3677.

  10. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    The continuation part of this item is delivered. PR #3731 (issue #3721) merged. The Service now clears a stop job with a retry class by the rule continue, and starts a new Job. The limit is the setting roadmap.implement.continuations_per_item (default 2, 0 turns it off). The count is in implement.continuations.

    Refine moved the checkpoint of each passed group to #3677. That part needs an owner decision, because a push of each group conflicts with the recorded requirements of #2910 (a claim ends the Job with no push), #3043 (a scoped-check stop pushes nothing) and the premise return. See the evidence comment of 2026-11-05 above.

    What is left in this item: the scenario "kill after step 2 of 4 resumes at step 3" holds only for work that a wip: push kept. A passed group of one task runs again until #3677 lands. Do not build the continuation again. If the owner agrees, close this item as completed by #3731 and #3677, or keep it as the tracker of #3677.

  11. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    Closed as completed. The continuation Job is delivered by PR #3731 (issue #3721). The checkpoint of each passed group is tracked in #3677, which holds the evidence and two designs for the owner decision. The out-of-memory read is tracked in #3727. The details are in the comment above.

  12. removed
    status/ready
    on Nov 6, 2026
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/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions