Skip to content

feat(roadmap): run the implement job as a cluster Job - #2698

Merged
dan-petty merged 18 commits into
mainfrom
feat/2667-implement-runner-job
Oct 29, 2026
Merged

dan-petty merged 18 commits into
mainfrom
feat/2667-implement-runner-job

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

What

The implement job now runs as a Kubernetes Job in a runner pod, not in the Service pod.

  • Image: a runner stage in Dockerfile with git and the dev tools. release.yml and ci.yml build, test, scan and publish it. The stage sets UV_PYTHON, so uv run finds an interpreter.
  • Template: a suspended CronJob devops-cli-runner. devops k8s run-job --template runner --repo owner/name makes a Job from it.
  • Service: the row implement makes one Job for each repository at a time, and reports each Job that ended on its item. It runs no step. A narrow Role, a ServiceAccount with a one-hour token, and one egress rule to the API server let it do this.
  • Token: a Job gets an installation token for one repository. The job runs no step unless its token names the repository of its plan.
  • Process: the job clears its dumpable flag, adopts orphans, and ends every process of a step before it runs git or gh with the token.
  • Limits: the Job has size limits for /tmp and ephemeral storage, and the public-HTTPS egress rule excludes more non-public ranges.

Why

The step of the agent needs tests, ruff, mypy and OpenSpec. The Service image has none of them, and the Service pod has no way to create a Job. The pod of the runner Job is the sandbox, because the shell policy of a step is no security boundary.

Known limits are in k8s/README.md (Runner Jobs, Guarantees). A hook that a step writes can still run with the token. A sandbox for the shell is planned in #2695. An admission policy for the Jobs of the Service is planned in #2696.

Closes #2667

…ce (#2667)

The model lane gets an implement row. A round reports the runner Jobs that ended, waits while a Job of the repository runs, and else creates one Job for the first Staged item. A Job that leaves its item eligible stops the item. The Kubernetes fake takes equality label selectors.
k8s/README.md and docs/ROUTINE_TASKS.md describe the runner image, the template, the Role, the network rule and what the sandbox does and does not guarantee. CONTEXT.md names the runner exactly. The generated documents follow the new option, setting and variable.
…gMap (#2667)

The ConfigMap of the Service must not name one repository for its tokens, because the Service works for every repository in service.repos. The tests that counted the devops manifests, the rendered section and the variables of the GitHub App now include the new items.
)

The runner stage forbids a Python download, and the .python-version of a checkout names a patch release that the pinned base image can lack. So uv run found no interpreter in the Job. The stage now sets UV_PYTHON to the image interpreter, the step shell gets it, and the CI smoke test runs uv run in a copy of the checkout.
…pository (#2667)

The one-repository token scope was fail-open: a Job made by devops k8s run-job set no token repository, so it got a token for every repository of the installation. The implement job now runs no step unless it acts as the GitHub App and service.github_app.token_repository equals the repository of the plan. run-job needs --repo for the runner template and sets the variable.
…gh with the token (#2667)

A git or gh child of the job holds the session token in its environment, which a process of the same user can read through /proc. The agent shell can leave such a process behind. A pod cannot hide the token from it: a user namespace for the shell needs unshare, which the RuntimeDefault seccomp profile refuses. So the job now adopts orphans, and ends every descendant when a step ends, before it runs any program with the token. A survivor stops the item.
…t a Job with no log (#2667)

A round recorded the Job after it created it. If the record failed and the Job died early, its item stayed eligible and every round made another Job. The record now comes first, and a refused create takes it back. A log that the API refuses no longer blocks the report of an ended Job. A test shows that apply_implement itself refuses when the kernel refuses to clear the dumpable flag.
…usions (#2667)

A step could write without limit into /tmp and fill the disk of its node. The tmp volume now has a size limit, and the container has ephemeral-storage requests and limits that cover both volumes. The public-HTTPS rule of the default perimeter now also excludes the shared address space, the link-local range and the IETF protocol and benchmarking ranges.
…2667)

Describe the order that keeps a step process away from the token, the open hook risk with its follow-ups, the runner Job name, the storage limits and the required --repo of run-job. Re-wrap two module docstrings to 100 columns. Regenerate the command reference.
…2667)

Fix the spec, design, proposal and tasks of the archived change for the findings of the review: the interpreter of uv in the image, the token scope, the order that keeps a step process away from the token, the Job record before the create, the storage limits and the egress exclusions. Name the follow-up issues for the shell sandbox and the admission policy.
@dan-petty

Copy link
Copy Markdown
Owner Author

Test results: uv run devops ci passed on the head of this branch before the push. The test check took 3 min 11 s. The whole run took 3 min 19 s.

Review findings fixed, each test first:

  • B1 uv run failed in the runner image: the base image has Python 3.14.8 and .python-version names 3.14.10, and the stage forbids a download. The stage sets UV_PYTHON, the step shell gets it, an invariant test checks it, and the CI smoke test runs uv run --locked ruff --version in a copy of the checkout. I built the image and ran that command on a read-only root: it printed ruff 0.16.8.
  • S1 The token scope was fail-open. The job now runs no step unless it acts as the App and service.github_app.token_repository equals its repository. run-job --template runner needs --repo, and sets the variable.
  • S2 A leftover process of the shell could read the environment of a git or gh child. I checked two ways to close it. A file or a pipe does not hide the token from the same user. A user namespace fails: in a container with user 1000, all capabilities dropped and the default seccomp profile, unshare --user --pid --fork id ended with "Operation not permitted". It worked only with seccomp=unconfined, which Pod Security restricted forbids. So the job now adopts orphans and kills every descendant of a step, also a daemon in its own session, before it runs git or gh. A real daemon proves it in the tests. A hook that a step writes can still run with the token. This is written in design.md and k8s/README.md. The sandbox is follow-up feat(roadmap): run the implement agent shell in a real sandbox #2695.
  • M1 The Job is recorded on the item before it is created, and a refused create takes the record back.
  • M2 A log that the API refuses no longer blocks the report of an ended Job.
  • M3 The spec says "before the first step", and a test shows that apply_implement raises when prctl fails.
  • M4 /tmp has a 1 Gi limit, and the container has ephemeral-storage 2 Gi requested and 6 Gi at most.
  • M5 The public-HTTPS rule excludes 100.64.0.0/10, 169.254.0.0/16, 192.0.0.0/24 and 198.18.0.0/15 too.
  • M6 The admission policy is follow-up feat(k8s): an admission policy pins the Jobs the roadmap Service may create #2696. design.md Risks says the Role comment about secrets holds only while namespace devops holds only Secret devops-cli.
  • M7 tasks.md points at tests/test_k8s_run_job.py and tests/test_k8s_cluster_job_api.py.
  • M8 Both module docstrings are wrapped to 100 columns.
  • M9 k8s/README.md names the runner Job devops-cli-runner-<UTC time>-<hex>.

Declined:

  • M10 Fold of the fix commit e2a5b211 into 87106d4f: skipped. The pull request is squash-merged, and an interactive rebase is not available here.
  • The egress rule of roadmap-service-egress keeps its one exclusion. Its target is the API server on a node address, so it cannot exclude private ranges, and the Service pod runs no step.

New dependency: psutil (and types-psutil for mypy). It finds the descendants of the job process. uv run devops ci passed with it.

…r image (#2667)

The scan of the runner image reported HIGH findings in the npm that the builder bundles (undici, brace-expansion) and in the wheels that pip vendors (certifi, urllib3, msgpack). A Job installs no tool, so the runner stage deletes them, as the service stage deletes pip.
@dan-petty
dan-petty marked this pull request as ready for review October 29, 2026 22:09
@dan-petty

Copy link
Copy Markdown
Owner Author

Update after the first CI run: the check Runner Image failed at the Trivy scan, not at the smoke test. The scan found HIGH findings in the npm that the builder bundles (undici, brace-expansion) and in the wheels that pip vendors (certifi, urllib3, msgpack). A Job installs no tool, so the runner stage now deletes npm, pip and the uv cache of root, as the service stage deletes pip. I built the image and ran the same Trivy scan locally: it exits 0. All required checks pass on the new head. The Tests & Coverage check on GitHub took longer than 5 minutes to settle in this run; the local run of the same check took 3 min 11 s.

@dan-petty
dan-petty merged commit b4669f6 into main Oct 29, 2026
18 checks passed
@dan-petty
dan-petty deleted the feat/2667-implement-runner-job branch October 29, 2026 22:16
dan-petty pushed a commit that referenced this pull request Oct 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.20.0](v0.19.0...v0.20.0)
(2026-10-29)


### Features

* **roadmap:** run the implement job as a cluster Job
([#2698](#2698))
([b4669f6](b4669f6)),
closes [#2667](#2667)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(k8s): the implement job runs as a cluster Job on a runner image with uv, the dev dependencies and the pinned tools, submitted by the Service

1 participant