Skip to content

feat(k8s): submit a RAG ingest run on a default-branch push #3950

Open

Description

@devops-cli-service

Split from #1653.

Problem

Proposed design

Problem statement

A managed repository changes when its default branch receives a push. No process starts a RAG ingest run for that change, so the index becomes stale. The Service must submit one ingest run for the new commit and must not submit runs for other branches.

Acceptance criteria

Requirement: Default-branch push submits one ingest Job

The Service SHALL create exactly one RAG ingest Job for a valid push to the default branch of a managed repository.

Scenario: Push to the default branch

  • WHEN A signed push webhook for a managed repository has ref equal to refs/heads/<repository.default_branch>.
  • THEN The Service creates one Job from CronJob devops-cli with the args ai rag ingest --repo <repository.full_name> and records the after commit SHA.

Requirement: Non-default refs are ignored

The Service SHALL ignore push events that do not target the repository default branch.

Scenario: Push to a feature branch

  • WHEN A valid push webhook has ref equal to refs/heads/feature.
  • THEN The Service creates no ingest Job.

Requirement: Duplicate commits are coalesced

The Service SHALL not create a second ingest Job while a Job for the same repository and commit SHA is running or has succeeded.

Scenario: Repeated push of the same commit

  • WHEN Two valid push webhooks carry the same repository full name and after commit SHA, and the first ingest Job is running.
  • THEN The Service creates one ingest Job, and the second event records the existing Job name as a duplicate.

Requirement: Ingest run records its source

The Service SHALL record the repository full name, the after commit SHA, the Job name and the submission time for each ingest run.

Scenario: Run record after submission

  • WHEN The Service creates an ingest Job for a default-branch push.
  • THEN The run record contains the repository full name, the after commit SHA, the Job name and a submission timestamp.

Requirement: Failed ingest Job is recorded

The Service SHALL record the final failure of an ingest Job and keep the commit eligible for a later retry.

Scenario: Ingest Job fails

  • WHEN An ingest Job has a Failed condition and no Complete condition.
  • THEN The Service records the failure with the repository full name and commit SHA, and a later push or manual request creates a new ingest Job for the same commit.

Existing Tool Considered

Argo Events (GitHub EventSource + Sensor) is the open, maintained tool that covers the webhook filter and the trigger of a Workflow or Job. It lacks the project's per-repository serialization and run record, and ADR 0008 rejected it for adding NATS without serialization or a hold; the project already has create_webhook_router (src/devops_cli/server/routes/webhooks.py) and the CronJob-template Job creator (src/devops_cli/k8s/cluster_job.py). The change builds a push consumer and a Job submitter instead: about 400 to 600 lines of code and tests, about 40k to 60k tokens to build, about 10k tokens to keep and fix, and 1 to 2 engineer-days.

Key questions

  • Which event starts a RAG ingest run?: A GitHub push webhook starts the run when ref is refs/heads/<default_branch>. Polling reconciles a missed delivery, and the router's consumer subscription is the extension point. (best practice) [sources: docs/adr/0009-one-webhook-router-delivers-each-event-to-the-consumers-subscribed-to-it.md, docs/adr/0003-polling-is-how-the-roadmap-sees-changes.md, src/devops_cli/server/routes/webhooks.py:141-153]
    • Chosen: Push webhook. It starts the run at once, and ADR 0003 keeps polling as the fallback.
    • Rejected: Poll only. It delays the run until the next tick.
    • Rejected: Scheduled cron. It leaves the index stale between runs.
  • How does the Service identify the default branch?: The Service compares ref with refs/heads/{repository.default_branch} from the push payload's repository object and falls back to GET /repos/{owner}/{repo} (_repository_default_branch) when the field is absent. (best practice) [sources: src/devops_cli/commands/pr.py:995-1004, src/devops_cli/models/webhooks.py:8-13, src/devops_cli/ai/rag/ingest.py:93-94]
    • Chosen: Payload default branch with API fallback. A managed repository can use a branch name other than main, and the payload's repository object carries the field; the API read covers a payload that omits it.
    • Rejected: Hard-coded main. It misses repositories whose default branch has another name.
    • Rejected: API read on every push. It costs a request per push when the payload already carries the repository object.
  • What executes the RAG ingest run?: The Service creates one Kubernetes Job from suspended CronJob devops-cli, the template of every cluster job, with the args ai rag ingest --repo <full_name>. The Job carries the repository and commit labels. Argo Workflows is not used because ADR 0008's measured go has not been recorded. (best practice) [sources: src/devops_cli/k8s/cluster_job.py:1-8, src/devops_cli/k8s/cluster_job.py:122-156, k8s/devops/cronjob.yaml:1-3, docs/adr/0008-argo-workflows-run-the-roadmap-jobs-after-a-measured-go.md, docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md:45]
    • Chosen: Kubernetes Job. It uses the cluster's existing CronJob template and keeps cluster credentials out of GitHub Actions.
    • Rejected: Argo Workflow. ADR 0008's measured go is not recorded, and no roadmap job runs on it yet.
    • Rejected: GitHub Actions workflow. It runs outside the cluster and needs a second credential path.
    • Rejected: Long-running worker. It adds a service to keep and scale.
  • How does the Service prevent duplicate runs for one commit?: The Service labels each ingest Job with a digest of the repository full name and a digest of the commit SHA, then lists the Jobs by those labels. It creates no Job when a listed Job is RUNNING or SUCCEEDED; a FAILED Job does not block a new run. The Kubernetes API is the lock, as it is for the implement runner, so a restart loses nothing. (best practice) [sources: src/devops_cli/k8s/cluster_job.py:60-65, src/devops_cli/k8s/cluster_job_api.py:74-80, src/devops_cli/k8s/cluster_job_api.py:164-174, k8s/README.md:668]
    • Chosen: Label and state check. The Kubernetes API is the lock, so a restart loses nothing and a failed Job does not block a retry.
    • Rejected: Deterministic Job name. A deterministic name blocks a retry of a failed commit until the old Job is deleted.
    • Rejected: In-memory delivery cache. It drops only a repeated delivery id and loses its state on restart.
    • Rejected: No deduplication. Repeated deliveries waste work and can race the index.
  • How does the Service handle a failed ingest Job?: The Job inherits backoffLimit: 0 from CronJob devops-cli, so Kubernetes marks it Failed on the first pod failure. The Service records the Failed condition with the repository and commit SHA and leaves the commit eligible for a new Job on a later push or a manual request. (best practice) [sources: k8s/devops/cronjob.yaml:17-20, k8s/README.md:643, k8s/README.md:668, src/devops_cli/k8s/cluster_job_api.py:74-80]
    • Chosen: Template's backoffLimit: 0 and Service resubmit. The template documents that a Job never retries, and the Service's new Job is the project's retry path.
    • Rejected: Bounded backoffLimit above zero. It overrides the template's documented no-retry rule and duplicates the Service's retry path.
    • Rejected: No failure record. The index stays stale with no record of the failed commit.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/feature
    scope/k8s
    status/new
    value/medium
    effort/medium
    on Nov 7, 2026
  2. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    ContributorAuthor

    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/k8s. The (k8s) scope of the title gives the scope.
    • Priority: P2-Medium. The trigger keeps the index fresh after each merge, but it waits on the #1653 workflow.
    • Value: Medium. A push trigger keeps RAG search results current after each default-branch merge.
    • Effort: Medium. It adds one push trigger, but it depends on the #1653 workflow and its cluster setup.
    • Related: feat(k8s): Add an Argo workflow to keep the RAG index current #1653, which asks for a different change. Both add Argo RAG ingest; #1653 asks for the full workflow and the candidate asks only for the default-branch push trigger.
  3. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    ContributorAuthor

    Refine cannot set this item to Ready at 7935fba. A bot opened the item, so a review of the issue and of the proposal must approve it first. The review found the defects below. A person edits the body to answer them. The next refine round looks at the item again only after a body edit.

    • missing_path at key_questions: The plan names this file as a source. The input files has no entry for the file. Evidence: "src/devops_cli/commands/pr.py:995-1004"
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/k8ssource/agentstatus/newtype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions