Skip to content

feat(ci): devops ci --remote runs the gate in the cluster #4698

Open

Description

@dan-petty

Problem or Motivation

Agents iterate through GitHub CI. In the census week (2026-11-04 to 2026-11-11), a workstation pull request got 1.63 CI runs. One round takes about 30 min: a median of 4.6 min in the queue and 25.5 min of wall clock. 119 of 851 pull request CI runs (14 %) failed. The owner decided on 2026-11-11 that every push to GitHub follows a passing gate (OD6 a).

Proposed Solution & Architectural Design

devops ci --remote is one thin adapter to the gate template of #4691:

  1. Fetch origin/main and run git merge-tree. A conflict stops the command, and the agent rebases locally.
  2. Make a synthetic squash commit on origin/main and a git bundle of it. Put the bundle in a ConfigMap. Over 900 KB, the lane is unavailable.
  3. Create the Workflow devops-cli-ci-gate-<patchid12>-<base7>. A 409 attaches to the existing Workflow. Stop an older gate of the same branch.
  4. Delete a gate that is still Pending after 900 s (unavailable, reason queue).
  5. Read the result from the Workflow phase. Print at most 50 lines from the devops ci --report JSON.
  6. Write a record keyed by the git patch-id of git diff -U0. A local devops ci --check writes the same record.
  7. Add the settings ci.remote.* and ci.check_timeout_seconds, and the override DEVOPS_CLI_CI_REMOTE_ENABLED.
  8. --dry-run makes 0 requests and prints the would-be requests.
  9. Emit bounded metrics: gate runs, queue time, fallbacks by reason and a disagreement counter against GitHub.

When the cluster is down, the record says unavailable, and work goes the GitHub-only way, as today. The transport is a seam, so a Gitea branch can replace the bundle later.

Measured: the thin packs of 581 main commits have a p99 of 112 KB and a maximum of 819 KB, under the 1 MiB ConfigMap limit. An anonymous base fetch took 3.5 s.

Target Subsystem

SDLC, Git & PR Governance (src/devops_cli/commands/ci.py, src/devops_cli/argo/).

Existing Tool Considered

The Argo Workflows API through the existing ArgoCRDService.submit_workflow and await_workflow, git (bundle, merge-tree, patch-id) and the devops ci --report JSON cover the parts. No tool sends a local change to an Argo Workflow and reads the result back, so one thin adapter joins them. The workstation submits with its kubeconfig. A narrow kube identity follows after #4566 (OD7). Cost (estimate): about 400,000 tokens and 6 hours to build, about 15,000 tokens a month to keep, about 50,000 tokens to fix.

Acceptance Criteria

  • Tests use doubles at the process and API edges.
  • Each fallback reason has a test.
  • --dry-run makes no request.
  • One live gate on main passes.
  • The opt-in week shows at least 95 % agreement with the GitHub required checks and a queue p90 of at most 10 min.

Dependencies

#4691.

Source: #4667

Alternatives check of 2026-11-26: in-use.
The repository already uses this tool.
Tool: argoproj/argo-workflows (https://github.com/argoproj/argo-workflows), Apache-2.0, last activity 2026-11-26, maintained.
Reason: Searches found no tool that carries a local working-tree change into a cluster gate and returns its verdict. Argo Workflows covers the submit, wait and attach in the cluster, so the local git, record and fallback parts stay in a thin adapter.

Covers:

  • Submits a Workflow to the cluster and waits on its phase
  • Returns an existing Workflow on a name conflict
  • Runs the gate template with ConfigMap inputs and no artifact store

Lacks:

  • No local git merge-tree conflict check before submit
  • No git bundle packing into a ConfigMap with a size fallback
  • No patch-id keyed local gate record or dry-run request plan

Proposed design

Problem statement

Agents wait about 30 minutes for GitHub CI. In the census week, 14% of pull request CI runs failed. The owner decided on 2026-11-11 that every push to GitHub follows a passing gate. This issue adds devops ci --remote, one thin adapter that runs the gate template of #4691 in the cluster. The adapter records the result by patch-id. It falls back to the GitHub-only path when the cluster is down.

Acceptance criteria

Requirement: Remote gate submit and wait

The command SHALL submit one gate Workflow through ArgoCRDService.submit_workflow in attach mode and wait through await_workflow.

Scenario: Submit and wait

  • WHEN the remote lane is enabled and the Argo service double records calls
  • THEN the command submits one Workflow in attach mode and waits for it once.

Requirement: Conflict stops before submit

The command SHALL stop before any Workflow request when git merge-tree reports a conflict.

Scenario: Merge conflict

  • WHEN the base and the synthetic squash commit conflict
  • THEN the command exits non-zero, reports the conflict, and submits no Workflow.

Requirement: Synthetic squash commit bundle

The command SHALL fetch origin/main, make a synthetic squash commit on it, put its git bundle in a ConfigMap, and submit the gate Workflow.

Scenario: Bundle from squash commit

  • WHEN the command runs with no conflict
  • THEN the process double records a fetch of origin/main and the test double receives a git bundle made from a squash commit on origin/main.

Requirement: Bundle size fallback

The command SHALL record unavailable with reason bundle-size and submit no Workflow when the git bundle is larger than 900 KB.

Scenario: Oversized bundle

  • WHEN the test double makes a bundle larger than 900 KB
  • THEN the record says unavailable with reason bundle-size and the Argo service receives no submit.

Requirement: Workflow name and 409 attach

The command SHALL name the Workflow devops-cli-ci-gate-<patchid12>-<base7> and SHALL attach to the existing Workflow on a 409 response without patching it.

Scenario: 409 attaches

  • WHEN the Argo API returns 409 for the Workflow name
  • THEN the command reads and waits on the existing Workflow and creates no second Workflow.

Requirement: Older gate stopped

The command SHALL delete an older running gate Workflow of the same branch with background propagation before it waits on the new gate.

Scenario: Older gate

  • WHEN the test double holds an older running gate for the same branch
  • THEN the command deletes the older gate and waits on the new gate.

Requirement: Pending queue timeout

The command SHALL delete a gate that is still Pending after 900 s and record unavailable with reason queue.

Scenario: Pending timeout

  • WHEN the clock passes 900 s while the Workflow is Pending
  • THEN the command deletes the Workflow and writes the queue fallback record.

Requirement: Report output cap

The command SHALL read the Workflow phase and print at most 50 lines of the gate template's report JSON.

Scenario: Long report

  • WHEN the Workflow succeeds and its report has more than 50 lines
  • THEN the command prints no more than 50 report lines and exits with the gate result.

Requirement: Patch-id record

The command SHALL write a gate record keyed by the git patch-id of git diff -U0, and a local devops ci --check SHALL write the same key for the same patch.

Scenario: Same patch key

  • WHEN the remote gate and devops ci --check run on the same diff
  • THEN both write a record under the same patch-id key.

Requirement: Settings and override

The command SHALL read ci.remote.*, including ci.remote.queue_timeout_seconds, and DEVOPS_CLI_CI_REMOTE_ENABLED SHALL override the remote setting.

Scenario: Override disables remote

  • WHEN the setting enables remote and DEVOPS_CLI_CI_REMOTE_ENABLED=false is set
  • THEN the command makes no remote request and uses the GitHub-only path.

Requirement: Dry run makes no request

--dry-run SHALL make zero requests and print the requests that it would make.

Scenario: Dry run

  • WHEN the command runs with --dry-run and a fake Argo service
  • THEN the fake records no call and the output lists the planned requests.

Requirement: Fallback reasons

Each fallback reason SHALL write an unavailable record with that reason and SHALL leave the local gate on the GitHub-only path.

Scenario: Fallback reason table

  • WHEN the test double raises each fallback condition
  • THEN the command writes the matching reason and exits as the GitHub-only path.

Requirement: Bounded metrics

The command SHALL emit bounded metrics for gate runs, queue time, fallbacks by reason and disagreements with GitHub.

Scenario: Metrics labels

  • WHEN a gate run, a fallback and a disagreement occur in a test
  • THEN the telemetry double receives one bounded sample for each metric.

Requirement: Offline doubles

The tests of the remote gate SHALL use doubles at the process and API edges and SHALL need no cluster or network.

Scenario: Offline test run

  • WHEN the remote gate test suite runs with no cluster and no network
  • THEN the suite passes and the doubles record the process and API calls.

Existing Tool Considered

Argo Workflows (argoproj/argo-workflows, Apache-2.0, maintained) is in use. The alternatives check in the issue body lists what it covers and lacks. The thin adapter supplies the missing local parts. Cost (estimate): about 400,000 tokens and 6 hours to build, about 15,000 tokens a month to keep, about 50,000 tokens to fix.

Key questions

  • Which open tool should the remote gate use for cluster submit and wait?: Use Argo Workflows through the existing ArgoCRDService.submit_workflow and await_workflow. Hera only builds and submits Workflows. A new client duplicates the service. (best practice) [sources: src/devops_cli/argo/crd.py, src/devops_cli/argo/workflows.py, src/devops_cli/commands/argo.py, AGENTS.md]
    • Chosen: Existing ArgoCRDService. The repository already uses it for submit and await, so the adapter adds no client.
    • Rejected: Hera Python SDK. It builds and submits Workflows only and adds no local git or record logic.
    • Rejected: New Argo client. It duplicates the existing service and increases maintenance.
  • How should the command carry the local squash commit to the gate?: Use a git bundle in a ConfigMap. Stop with unavailable reason bundle-size when the bundle is larger than 900 KB. The Argo install keeps no archive and configures no artifact repository. The measured bundles of main commits stay under the 1 MiB ConfigMap limit. (best practice) [sources: k8s/argo-workflows/values.yaml, docs/guidelines/kubernetes.md]
    • Chosen: ConfigMap with 900 KB cap. It uses the cluster object that the gate template reads, needs no artifact store or credentials, and the measured bundle sizes stay under the 1 MiB limit.
    • Rejected: Argo artifact repository. Argo needs a configured artifact repository and credentials for artifacts, and this install has neither.
    • Rejected: Git push to a temporary branch. It writes to the remote and needs a server-side branch that the gate does not require.
  • What should the command do when a Workflow with the same name exists, and what about an older gate of the same branch?: Name the Workflow from the patch-id and the base. A repeated event then gets 409. Add an attach mode to ArgoCRDService.submit_workflow. On 409 it reads the existing Workflow. It does not use apply_resource's patch-in-place, which changes a running Workflow's spec. Delete an older running gate of the same branch with background propagation before the wait. (best practice) [sources: docs/guidelines/agentic-jobs.md, docs/guidelines/kubernetes.md, src/devops_cli/argo/crd.py, src/devops_cli/k8s/cluster_job_api.py]
    • Chosen: Attach on 409 in a create mode and delete the older gate. The name makes a repeated event hit AlreadyExists, the attach reads the existing Workflow without patching a running spec, and the delete frees the branch's queue slot without a second gate.
    • Rejected: Use apply_resource's patch-in-place. It changes the spec of a running Workflow and does not attach to it.
    • Rejected: Fail on 409. It makes a retry fail after a partial submit.
    • Rejected: Create a second Workflow. It runs duplicate gates for the same patch and leaves the older gate in the queue.
  • What should the command do with a gate that stays Pending?: Wait on the clock seam with ci.remote.queue_timeout_seconds (900 s). On the timeout, read the Workflow. If it is Pending, delete it and record unavailable with reason queue. If it is Running, keep waiting to the gate timeout. (best practice) [sources: src/devops_cli/argo/workflows.py, src/devops_cli/config/defaults.py, src/devops_cli/config/constants.py, src/devops_cli/k8s/cluster_job_api.py]
    • Chosen: Delete after 900 s. It bounds the queue wait on the clock seam and lets the agent use the GitHub-only path.
    • Rejected: Wait until the gate ends. It can hold the agent for an unbounded time.
    • Rejected: Leave it Pending. It keeps a stale gate in the cluster.
  • Which key identifies a gate record?: Use the git patch-id of git diff -U0. The remote gate and devops ci --check then share a key for the same patch. (best practice) [sources: openspec/changes/archive/2026-11-12-4674-devops-pr-update-acts-only-on/proposal.md]
    • Chosen: Patch-id of git diff -U0. It stays the same when the commit changes but the patch does not, as the archived proposal records for a rebase.
    • Rejected: Commit SHA. A rebase changes it for the same patch.
    • Rejected: Branch name. It changes with each pull request and does not identify the patch.
  • How should the command read its settings and handle a dry run?: Add ci.remote.* under CIConfig, including ci.remote.queue_timeout_seconds (default 900). Let DEVOPS_CLI_CI_REMOTE_ENABLED override the remote setting. Make no request with --dry-run. Do not add ci.check_timeout_seconds. feat(ci): devops ci ends each row at a time limit #4775 removed the need for it, because timeout stops the gate rows. (best practice) [sources: src/devops_cli/config/settings.py:643, src/devops_cli/commands/ci.py, ARCHITECTURE.md, openspec/changes/archive/2026-11-12-4775-devops-ci-ends-each-row-at/proposal.md]
    • Chosen: Settings plus environment override and dry-run plan. It follows the existing CIConfig and dry-run patterns, and it leaves out the setting that feat(ci): devops ci ends each row at a time limit #4775 rejected.
    • Rejected: Environment only. It gives no persistent project setting.
    • Rejected: No dry-run plan. It breaks the request-plan contract of devops ci.
  • Which metrics should the remote gate emit?: Emit bounded counters and timers for gate runs, queue time, fallbacks by reason and disagreements with GitHub. (best practice) [sources: src/devops_cli/telemetry/instruments.py, docs/TELEMETRY.md, src/devops_cli/commands/ci.py]
    • Chosen: Bounded metrics for the four signals. They measure the gate without an unbounded label.
    • Rejected: No metrics. The opt-in week cannot measure agreement or queue time.
    • Rejected: Free-text labels. They grow without bound and are not safe metrics.
  • How should the tests isolate the remote gate?: Use doubles at the process and API edges. The tests need no cluster and no network. (best practice) [sources: tests/argo/test_workflows.py, src/devops_cli/argo/workflows.py, docs/TESTING.md, AGENTS.md]
    • Chosen: Process and API doubles. They check each fallback and request offline.
    • Rejected: Live cluster test. It is not repeatable and needs credentials.
    • Rejected: Mock only the CLI. It leaves the Argo and git edges untested.
  • Should the live gate and opt-in week stay in this issue?: No. Defer them. They need a cluster run and a week of real use. (best practice) [sources: docs/roadmap/refine.md]
    • Chosen: Defer live validation. The implementation and offline tests can reach Ready without a cluster run or a week of use.
    • Rejected: Keep live validation in this issue. It blocks Ready on a cluster run and an outside event.
  • Does devops ci provide the --report JSON that the gate reads?: No. The devops ci callback has --check and no --report option at this commit. The report JSON must come from the gate template of feat(k8s): add the CI gate WorkflowTemplate #4691, which this issue depends on. [sources: src/devops_cli/commands/ci.py, docs/commands/ci.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4691

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/ci
    status/new
    value/high
    effort/medium
    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/ci. The (ci) scope of the title gives the scope.
    • Priority: P2-Medium. It addresses a real 30-minute CI round pain point but depends on #4691 and is an opt-in feature, not a blocker.
    • Value: High. It cuts the 30-minute agent iteration loop and supports the owner decision that every push follows a passing gate.
    • Effort: Medium. The body estimates about 6 hours to build a thin adapter with multiple fallback paths and tests.
    • Related: refactor(ci): github ci runs the gate through devops ci from one check table #843, which asks for a different change. Both items change how CI runs the gate, but #843 unifies check definitions while the candidate adds a remote Argo Workflow execution path.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: Searches found Argo Workflows, the engine the issue already reaches through ArgoCRDService.submit_workflow and await_workflow, plus the Hera Python SDK for constructing and submitting Workflows. They cover the cluster-side submit/await/phase part, but no tool turns a local git change into a bundle and ConfigMap, applies the fallback/queue rules or writes the patch-id record, so the proposed thin adapter is still needed.

    The repository already uses this tool.

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

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

    Covers:

    • Submits a Workflow to the cluster and waits for it (already wrapped by ArgoCRDService.submit_workflow and await_workflow)
    • Reports the Workflow phase and result, which the command can read and print
    • Runs the gate template of feat(k8s): add the CI gate WorkflowTemplate #4691 in the cluster

    Lacks:

    • No local git side: fetch origin/main, merge-tree conflict check, synthetic squash commit and git bundle
    • No ConfigMap size check or unavailable lane above 900 KB
    • No 409 attach, older-gate stop, Pending-after-900s delete or fallback reasons
    • No patch-id keyed record shared with devops ci --check, ci.remote.* settings, DEVOPS_CLI_CI_REMOTE_ENABLED override or --dry-run
    • No bounded metrics (gate runs, queue time, fallbacks, GitHub disagreement)
    • Hera, the Python SDK found, only builds and submits Workflows; it does not handle the local change or records either

    Tools considered:

    Searches run:

    • Python SDK submit Argo Workflows workflow and wait for result Hera, results: 5
    • submit Argo Workflow from local git commit and read result CLI tool, results: 5
    • Hera Argo Workflows Python SDK submit workflow wait, results: 5
    • Argo Workflows CLI argo submit wait git bundle ConfigMap, results: 5
    • hera python argo workflows github repository, results: 5
    • "argo submit" CLI wait workflow result command, results: 5
    • Hera Argo Workflows SDK, results: 5
    • Argo Workflows, results: 5
    • Actions Runner Controller run GitHub Actions workflows Kubernetes, results: 5
    • run CI gate in Kubernetes cluster from local uncommitted changes tool, results: 5

    Sources:

    Checked on 2026-11-14. 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 15, 2026

    @devops-cli-service
    Contributor

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

  7. devops-cli-service commented on Nov 26, 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/mediumpriority/p2-mediumscope/cisource/agentstatus/newtype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions