Skip to content

feat(roadmap): run each refine item in its own pod #4568

Open

Description

@dan-petty

Problem or Motivation

Refine runs 390 s at p50 and 2,060 s at p99 on this repository, longer than the drain of 120 s. A rollout of the roadmap Service loses the item in progress. #3793 tries to prove refine writes across live rollouts; this item makes that case moot.

Proposed Solution & Architectural Design

  • WorkflowTemplate roadmap-refine runs the refine selection narrowed to one item (the option that the stage Job added, for refine). Template-level mutex refine-<owner>.<name>-<n>. Semaphore agent. Deadline 3,600 s on the template. Requests 200m and 768Mi, limits 1 CPU and 1.5Gi. Blobless clone.
  • No DAG chain: when refine sets an item Ready, the unit sets roadmap:v1:due:<owner>/<name>:stage, and the next round creates the stage unit.
  • The refine row becomes a submit, as stage did.
  • Keep the refine edit checks (_body_unchanged_since_read, src/devops_cli/roadmap/refine/refine.py:2798).
  • Keep the spend telemetry of refine that the in-flight stage and refine spend work adds.

Removes: the in-pod body of _run_refine_adapter (src/devops_cli/roadmap/run.py:568-589), refine's use of model-clone.

When this item merges, close #3793 as superseded, with the evidence.

Target Subsystem

SDLC, Git & PR Governance (roadmap refine).

Existing Tool Considered

Argo Workflows mutex and semaphore, on the path of the stage unit. Cost: about 90,000 tokens and 4 hours to build, about 8,000 tokens a month to keep, about 15,000 tokens to fix.

Acceptance Criteria

  • Live: a refine pod finishes while the Service rolls out.
  • An item set Ready gets its stage unit within one round.
  • A second refine unit of the same item does not start while one runs.
  • Measure: refine rounds killed by a shutdown, 0 in 7 days.

Dependencies

Source: #4517

Alternatives check of 2026-12-01: in-use.
The repository already uses this tool.
Tool: Argo Workflows (https://github.com/argoproj/argo-workflows), Apache-2.0, last activity 2026-12-01, maintained.
Reason: The search and the repository show that Argo Workflows runs one pod for each refine item from a WorkflowTemplate. It gives the mutex, the semaphore and the workflow deadline that the issue names. The project already runs it, so the remaining work is repository code.

Covers:

  • One pod for each refine item from a WorkflowTemplate
  • Template mutex and semaphore serialize units
  • Workflow-level timeout holds the 3,600-second deadline

Lacks:

  • The roadmap-refine template and its submit row
  • The refine entrypoint narrowed to one item
  • The edit checks and the spend telemetry of refine

Owner decision 2026-11-13

The approved pipeline split (tracker #5482, Phase 4) removes the due marks of refine: delete the stage_due stamp and the key roadmap:v1:due:*:stage. Stage derives Ready from the labels. Refine is due by its predicate in due_jobs, with the research barrier of #5513 when that ships. Semaphore agent.

Proposed design

Problem statement

Refine runs 390 s at p50 and 2,060 s at p99. That is longer than the 120 s drain. A rollout of the roadmap Service kills the refine round in progress.

This change runs each refine item in its own Argo Workflow pod from a roadmap-refine template. The refine row submits a unit. The edit checks and the spend telemetry stay. The stage due mark goes, per the owner decision of 2026-11-13. The live proof runs after the merge and the release.

Acceptance criteria

Requirement: Refine template passes the manifest checks

The roadmap-refine WorkflowTemplate SHALL pass the Kubernetes manifest checks of the repository.

Scenario: Manifest check of the refine template

  • WHEN uv run devops ci --check --only k8s runs on the branch that adds the template.
  • THEN The command exits 0 and reports no error for the manifests under k8s/devops/roadmap-service/.

Requirement: Refine template holds its deadline, locks and budgets

The roadmap-refine WorkflowTemplate SHALL set the deadline, the mutex, the semaphore, the requests and the limits that the issue names.

Scenario: Rendered refine template

  • WHEN kubectl get workflowtemplate roadmap-refine -n devops -o json runs after the apply.
  • THEN The output shows activeDeadlineSeconds 3600, the mutex refine-<owner>.<name>-<n>, the semaphore agent, the requests 200m and 768Mi, and the limits 1 CPU and 1.5Gi.

Requirement: Blobless clone in the refine template

The roadmap-refine WorkflowTemplate MUST NOT run model-clone and SHALL clone the repository with git clone --filter=blob:none.

Scenario: Rendered refine clone

  • WHEN kubectl get workflowtemplate roadmap-refine -n devops -o yaml runs after the apply.
  • THEN The output holds git clone --filter=blob:none and holds no model-clone.

Requirement: Two-container refine unit

The roadmap-refine WorkflowTemplate SHALL run each unit in the two-container template that #5506 adds.

Scenario: Rendered refine template names

Requirement: Refine row submits a unit

The refine row SHALL create one Workflow from roadmap-refine for one due item and MUST NOT run a refine round in the Service process.

Scenario: Refine row runs for a due item

  • WHEN The refine row runs in a test for one due item that has no live unit.
  • THEN The Workflow client records one create call for that item and the test sees no call to _run_refine_adapter.

Requirement: No owner reference to the Service

The refine Workflow MUST carry no owner reference to the Service Deployment, so a rollout of the Service does not end the unit.

Scenario: Create body of the refine unit

  • WHEN The refine row builds the Workflow for a due item in a test.
  • THEN metadata.ownerReferences of the create body is empty.

Requirement: Fixed refine unit name

The refine row SHALL name each unit from the repository reference, the refine row and the item, so a second create gets a conflict.

Scenario: Second create of the same item

  • WHEN The refine row builds the unit for item 42 of dan-petty/devops-cli two times in a test.
  • THEN Both Workflow names are equal and the fake Workflow client returns a conflict for the second create.

Requirement: Refine unit narrows the selection

The refine unit SHALL run the refine selection for the one item that its Workflow names and MUST NOT write another item.

Scenario: Unit refines only its item

  • WHEN The refine entrypoint runs in a test with --item 42 and two open New items, 42 and 43.
  • THEN The refine plan holds item 42 and not item 43.

Requirement: No stage due mark

The refine writer SHALL write no stage_due field and no roadmap:v1:due:<owner>/<name>:stage key when it sets an item Ready.

Scenario: Ready item writes no stage due mark

  • WHEN The refine writer sets an item Ready in a test with a fake store.
  • THEN The fake store records no write of roadmap:v1:due:dan-petty/devops-cli:stage and the issue body holds no stage_due field.

Requirement: Refine unit starts no stage unit

The refine unit MUST NOT create a stage Workflow when it sets an item Ready.

Scenario: Ready item starts no stage unit

  • WHEN The refine unit sets an item Ready in a test with a fake Workflow client.
  • THEN The fake Workflow client records no create call for a stage Workflow.

Requirement: Stage selects a Ready item from its label

The stage selection SHALL take a Ready item from its status/ready label and MUST NOT read a stage due mark.

Scenario: Stage selects a Ready item with no due key

  • WHEN The stage row selects items in a test whose store holds one Ready item with status/ready and no stage due key.
  • THEN The selection holds that item in that round and the stage row creates one stage unit for it.

Requirement: Edit checks kept

The refine pod SHALL call _body_unchanged_since_read and _outside_unchanged_since_read before its writes and MUST refuse a write whose body changed since the read.

Scenario: Body changed during the round

  • WHEN The body hash at write time differs from the hash at read time in a test.
  • THEN The write is refused, a warning names the item, and the fake store records no write.

Requirement: Refine spend telemetry kept

The refine unit SHALL record one spend row for each model request of the unit.

Scenario: A refine model request is recorded

  • WHEN The refine investigation makes one model request in a test with a fake spend store.
  • THEN The fake spend store holds one row for that request.

Requirement: Pending a person after the merge

After the merge and the release, a person MUST confirm that refine runs as the App in its own pod on the next due items.

Scenario: Live refine run after the release

  • WHEN A person reads the next due refine units in the cluster after the release.
  • THEN A comment on the issue gives the result lines and shows 2 or fewer refine runs for each research result set.

Existing Tool Considered

Argo Workflows (argoproj/argo-workflows), verdict in-use. The alternatives check of 2026-11-26 in the issue body gives what the tool covers and lacks. The repository already runs Argo Workflows, so this change adopts no new tool. This proposal adds the repository code that the check lists as lacking: the roadmap-refine WorkflowTemplate and its submit row, the pod entrypoint for one item, the edit checks and the spend telemetry. Written cost for that repository code: about 90,000 tokens and 4 hours to build, about 8,000 tokens a month to keep, and about 15,000 tokens to fix.

Key questions

  • What does the owner decision of 2026-11-13 require?: It removes the due marks of refine. The refine writer writes no stage_due field and no roadmap:v1:due:<owner>/<name>:stage key. Stage derives Ready from its labels. Refine is due by its predicate in the due jobs, with the research barrier of feat(roadmap): one research unit runs its steps just in time #5513 when that ships. The unit holds the semaphore agent. After feat(roadmap): the model container of a unit holds no credential #5506 merges, the unit uses the two-container template. The live proof runs after the merge and the release. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md, src/devops_cli/roadmap/run.py:594, src/devops_cli/roadmap/refine/refine.py]
    • Chosen: Follow the owner decision: delete the stage due mark, use the due predicate, the agent semaphore and the two-container template after feat(roadmap): the model container of a unit holds no credential #5506. The owner decision of 2026-11-13 records the pipeline split and names these parts.
    • Rejected: Keep the stage_due mark and the stage due key. The owner decision deletes the mark and the key.
    • Rejected: Chain refine to stage in one DAG. ADR 0021 says only the router and the sweep create units, and no DAG chain links two jobs.
  • Which code runs the refine round in the Service process today?: The refine row calls _run_refine_adapter at src/devops_cli/roadmap/run.py:855. That adapter builds RefineWriter at src/devops_cli/roadmap/refine/refine.py:4958 and runs the round in the Service process. The body cites src/devops_cli/roadmap/run.py:568-589, but that range does not hold the adapter. The change deletes the in-pod body and makes the row submit a unit. [sources: src/devops_cli/roadmap/run.py:855, src/devops_cli/roadmap/refine/refine.py:4958, tests/roadmap/test_roadmap_run_adapter_imports.py, tests/roadmap/refine/test_roadmap_refine_round.py]
  • How does the refine row submit one unit for one due item?: The refine row builds one Workflow from roadmap-refine for one due item. It creates the Workflow with the fixed unit name. The create body carries no owner reference to the Service Deployment, so a rollout does not end the pod. The pod clones the repository itself. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md, src/devops_cli/roadmap/run.py:855]
    • Chosen: Submit one Workflow for each due item from the refine row. ADR 0021 says only the router and the sweep create units, and a pod outlives a Service rollout.
    • Rejected: Keep the refine round in the Service process. A rollout kills the round in progress, which is the problem of this item.
    • Rejected: Submit one Workflow for all due items. ADR 0021 narrows a unit to one item, and a long batch passes the 3,600-second deadline.
  • How does the refine unit narrow the selection to one item?: The Workflow passes the item number to the pod. The refine entrypoint runs the refine selection with --item for that number, so every selection rule of the job applies. The unit writes no other item. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md, src/devops_cli/roadmap/refine/refine.py]
    • Chosen: Pass the item number as a Workflow parameter and run the selection with --item. ADR 0021 keeps the --item option, and the row knows the item when it creates the unit.
    • Rejected: Let the pod read the due items and pick one. Two pods can pick the same item, and the mutex then serialises them for no gain.
  • How does a second refine unit of the same item stay out?: The unit name is fixed by the repository reference, the refine row and the item, so a second create gets 409. The template also sets the mutex refine-<owner>.<name>-<n>, and Argo Workflows holds it for the life of the pod. The semaphore agent keeps the cluster-wide model limit. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md, src/devops_cli/roadmap/run.py:855]
    • Chosen: Use a fixed unit name plus a template-level mutex. ADR 0021 records both the fixed name and the template-level mutex, and the repository reference gives the name form.
    • Rejected: Use one global mutex. It serialises every item, so a refine unit waits behind an unrelated item.
    • Rejected: Use an in-process lock in the Service. No refine round runs in the Service after this change.
  • Are the body and outside edit checks kept, and where do they run?: Yes. _body_unchanged_since_read is at src/devops_cli/roadmap/refine/refine.py:4586 and _outside_unchanged_since_read is at src/devops_cli/roadmap/refine/refine.py:4596. RefineWriter at src/devops_cli/roadmap/refine/refine.py:4958 runs them before its writes. The body cites src/devops_cli/roadmap/refine/refine.py:2798, which is not the function. [sources: src/devops_cli/roadmap/refine/refine.py:4586, src/devops_cli/roadmap/refine/refine.py:4596, src/devops_cli/roadmap/refine/refine.py:4958]
  • What makes refine due after the owner decision?: The refine row keeps its cadence and its predicate in the due jobs. It also passes _refine_cross_job at src/devops_cli/roadmap/run.py:594. The unit writes no stage due mark. The research barrier of feat(roadmap): one research unit runs its steps just in time #5513 joins the predicate when it ships. (best practice) [sources: src/devops_cli/roadmap/run.py:594, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md]
    • Chosen: Use the existing due predicate. The row already passes _refine_cross_job and keeps its cadence.
    • Rejected: Keep the stage due mark as the refine trigger. The owner decision deletes the mark and the key.
    • Rejected: Add the feat(roadmap): one research unit runs its steps just in time #5513 research barrier now. The owner decision makes the barrier conditional on when it ships.
  • Which issues must be done before this item?: feat(roadmap): keep plan records and record locks in Valkey #4564 and feat(roadmap): keep schedules, intake and ledgers in Valkey #4565, the two Valkey steps that the body names by title, come first. feat(k8s): let Argo Workflows run roadmap pods in devops #4566, the engine step, comes first per ADR 0021 section 7. feat(roadmap): the model container of a unit holds no credential #5506, the two-container template, comes first per the owner decision. feat(k8s): let roadmap-service create Argo Workflows #6592, which lets roadmap-service create Argo Workflows, comes first per the body. feat(roadmap): one research unit runs its steps just in time #5513 is no dependency; its research barrier joins the refine due predicate when it ships. [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md, k8s/devops/roadmap-service/role.yaml, k8s/devops/roadmap-service/admissionpolicy.yaml]
  • Which template does the refine unit use after feat(roadmap): the model container of a unit holds no credential #5506 merges?: The two-container template that feat(roadmap): the model container of a unit holds no credential #5506 adds: one job container and one model container that holds no credential. The admission policy at k8s/devops/roadmap-service/admissionpolicy.yaml admits a stage Job with one container and no init container today, and feat(roadmap): the model container of a unit holds no credential #5506 changes the policy for the model container. (best practice) [sources: k8s/devops/roadmap-service/admissionpolicy.yaml, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md]
  • Does the item close test(roadmap): verify refine writes across three live rollouts #3793 when it merges?: Yes. The pull request body holds Closes #3793 and the structural evidence: the rendered roadmap-refine settings and an empty ownerReferences on the Workflow. The live proof stays a criterion of this item and names a person after the merge. (best practice) [sources: src/devops_cli/roadmap/run.py:855, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4564, #4565, #4566, #5506, #6592

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/roadmap
    status/new
    value/high
    effort/high
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 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: P2-Medium. It removes a class of data loss during rollouts but depends on three other items and is not blocking a release.
    • Value: High. It eliminates item loss during Service rollouts and removes the need for the #3793 test.
    • Effort: High. It adds Argo Workflows templates, mutex, semaphore, removes existing code, and depends on three other items.
    • Related: test(roadmap): verify refine writes across three live rollouts #3793, which asks for a different change. Both address refine surviving Service rollouts, but #3793 adds a verification test while this candidate changes the architecture to run each item in its own pod.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 4330ee4 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 12, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches were thin on alternatives, but the repository facts show Argo Workflows is an open, actively maintained engine (Apache-2.0, latest release v4.1.6, not archived), and the issue itself records that its synchronization.mutex, synchronization.semaphore and activeDeadlineSeconds already give the per-item lock, the cluster-wide agent limit and the 3,600-second deadline, while its templates already run the stage unit as a pod. What is left is repository-specific code (the roadmap-refine template, the submit row, the pod entrypoint and the due mark), not a missing tool capability, so the tool covers the need and the issue already names it as the engine the project uses.

    The item already names this tool.

    Tool: argoproj/argo-workflows (https://github.com/argoproj/argo-workflows)

    • License: Apache-2.0
    • Last activity: 2026-11-12
    • Maintained: yes

    Covers:

    • Runs each roadmap item as a pod of a Workflow that carries no owner reference to the Service, so a Service rollout does not end the pod
    • Template-level synchronization.mutex gives the per-item lock named refine-<owner>.<name>-<n>
    • synchronization.semaphore gives the cluster-wide agent concurrency limit
    • activeDeadlineSeconds on a template gives the 3,600-second deadline
    • WorkflowTemplate steps can render the blobless clone, the resource requests and limits, and the one-item refine entrypoint

    Lacks:

    • No roadmap-refine WorkflowTemplate exists in the repository yet; the project must write it
    • No submit row that replaces the in-process refine round, and no pod entrypoint that narrows the selection to one item
    • No due mark roadmap:v1:due:<owner>/<name>:stage written when refine sets an item Ready
    • Does not itself keep the _body_unchanged_since_read and _outside_unchanged_since_read edit checks; the refine code must carry them

    Tools considered:

    Searches run:

    • Argo Workflows template-level mutex semaphore synchronization, results: 5
    • argo-workflows docs synchronization mutex semaphore activeDeadlineSeconds WorkflowTemplate, results: 5
    • Argo Workflows synchronization mutex documentation argo-workflows.readthedocs.io, results: 5
    • Kubernetes workflow engine per-item mutex lock deadline pod, results: 5
    • argo workflows "synchronization" "mutex" workflow template example, results: 5
    • argoproj argo-workflows github workflow engine kubernetes, results: 5

    Sources:

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

  7. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 3d6cae6 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.

  8. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

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

  9. 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.

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/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