Repository navigation
Description
Problem
The runner Job template (k8s/devops/cronjob-runner.yaml) has one container, runner, with the App private key and the model key. #3702 adds the phases prepare, agent and publish, but this template runs them as --phase all in one container. So the App key and the agent still share one process tree (#2695).
Three parts stop a three-container Job now:
- The admission policy (
k8s/devops/roadmap-service/admissionpolicy.yaml) refuses each init container. Its per-container rules read onlyspec.containers. - The Service reads the Job log and the end of the pod with no container name (
log_tailandpod_endinsrc/devops_cli/k8s/cluster_job_api.py). During the agent phase, that read fails. So the deadline does not extend, and the Job stops at the first deadline. build_jobandtemplate_container(src/devops_cli/k8s/cluster_job.py) look only for the containerrunner.
Expected
The CronJob devops-cli-runner runs three containers, one after the other:
| Container | Kind | Secret key | Volumes |
|---|---|---|---|
prepare |
initContainers[0] |
App private key | run at /run/roadmap (read-write), state at /run/roadmap/state (read-write), its own prepare-tmp at /tmp and prepare-home, config (read-only) |
agent |
initContainers[1] |
DEVOPS_CLI_AI_API_KEY |
run at /run/roadmap (read-write), its own agent-tmp at /tmp and agent-home, config (read-only); no state |
publish |
containers[0] |
App private key | run and state (read-only), its own publish-tmp at /tmp and publish-home, config (read-only) |
The run root /run/roadmap holds state/, work/ and out/ (RunFolders). out/ cannot be a mount point of its own, because make_out refuses an out/ that is there before the outputs (src/devops_cli/roadmap/phases/files.py). prepare records the absolute path of the clone, so prepare and agent mount run at the same path. So state is a second volume on top of the run root, which agent does not mount.
Each container starts with args and its --phase. The pod keeps restartPolicy: Never, activeDeadlineSeconds, uid 1000, readOnlyRootFilesystem, drop ALL and no ServiceAccount token. The agent container takes a row of RUNNER_SIZES. prepare and publish take one small fixed row. Kubernetes sizes the pod by the largest init container or by the sum of the app containers, so the small rows add no capacity.
The policy admits only this layout, and it pins the keys and the mounts per container. The Service and devops k8s run-job read each container by its name.
Acceptance criteria
Service readers
-
log_tailtakes a container name. The deadline extension (implement_deadline.py) reads the container that runs:prepare, thenagent, thenpublish. A test shows that a log change in the containeragentextends the deadline. -
pod_endreadsinitContainerStatusesbeforecontainerStatuses. So an OOM kill ofagentkeeps the classoom. - Each other reader of the Job log or of a container status reads by container name. These readers are
_outcomeoffix_checks_row,_reportofimplement_submit,stage_submitandfollow_live. The Service reads the count line of feat(roadmap): run implement and fix-checks as prepare/agent/publish phases #3702 from the containeragent. -
devops k8s run-jobfollows each container in turn, and reads the exit status of each container by its name. -
build_jobandtemplate_containeraccept the old one-container template and the new template.build_jobsets the args, the env and the size per container. The three containers get the sameTRACEPARENT. - The readers are in a Service release before the cluster gets the new template. The PR states how it keeps this order. If one PR cannot keep the order, the template change moves to a new item that waits for that release.
Template
- The CronJob has the init containers
prepareandagentand the containerpublish, with the volumes and the keys of the table.
Admission policy
- One CEL variable holds
containersandinitContainers. Each per-container rule uses it: the image,envFrom,valueFrom,commandand the sizes. - The policy admits a runner Job only with the init containers [
prepare,agent] and the containers [publish]. - The App key
secretKeyRefis allowed only onprepareandpublish.DEVOPS_CLI_AI_API_KEYis allowed only onagent. - The policy refuses
shareProcessNamespace: true. It refusesrestartPolicyandrestartPolicyRuleson each container, init containers included. A restartedpublishpushes and comments twice, and a native sidecar runs at the same time aspublish. -
agentdoes not mountstateor a home ofprepareorpublish.publishmountsrunandstateread-only. - On UPDATE, the policy also admits the old one-container shape during the switch. The Service patches the deadline of a Job that runs.
- The cluster gets the policy before the template, for example through an Argo CD sync wave.
-
tests/gate/k8s_checks/job_admission_policy.pyhas a case for each new refusal:- a key on the wrong container
stateinagentshareProcessNamespace: true- a
restartPolicyon an init container and on the app container - a third init container
- an init container with another image or with
command
Live check and documents
- One live implement Job and one live fix-checks Job run the three phases. The PR gives the result.
- The bullets Template, Admission policy and Guarantees of
k8s/README.mdstate the new layout. The Guarantees bullet states what the containers share: the network, the IPC namespace and the kernel.
Existing tool considered
Kubernetes gives the order and a Secret per container through init containers. A ValidatingAdmissionPolicy with CEL pins the layout. This item builds nothing new for these.
Order
Merge this item only after a runner image release holds #3702, because the new template runs --phase. Key question 1 of #2695 (where the implement Job ends) needs an answer before this item makes the split live.
Dependencies
Related
- feat(roadmap): run the implement agent shell in a real sandbox #2695 is the parent. It holds the design, the key questions and the cost.
- feat(k8s): an admission policy pins the Jobs the roadmap Service may create #2696 added the admission policy.
- refactor(roadmap): run stage on Coder in the runner image #6528 moves stage to the runner image and to the same phases.
Source: #2695
Alternatives check of 2026-11-18: none.
Tool: none found.
Reason: Searches found no open tool for the two-container layout or the safe import; the parent's alternatives check names kubernetes-sigs/agent-sandbox for #3694's command server only, with no Job template, admission policy or import.
Proposed design
Problem statement
The runner CronJob still runs prepare, agent and publish in one container, so the App private key and the agent share one process tree. The Service readers read the Job log with no container name, so the deadline does not extend during the agent phase. This change makes the Service readers and the Job builder ready for three containers. The template switch, the admission policy, the live check and the documents move to a deferred issue that waits for a Service release with these readers and a runner image release that holds #3702. The interim git controls move to a second deferred issue.
Acceptance criteria
Requirement: Container-aware log tail
log_tail SHALL accept a container name and SHALL request the log of that container only.
Scenario: Agent log read
- WHEN The unit test calls
log_tailwith the container nameagentand a fake Kubernetes client. - THEN The test asserts that the client request names
agentand returns the log of that container.
Requirement: Deadline follows the running container
The deadline extension in implement_deadline.py SHALL read the log of the container that runs: prepare, then agent, then publish.
Scenario: Agent log change extends the deadline
- WHEN The deadline test gives pod status with
agentrunning and a changedagentlog. - THEN The test asserts that the deadline extends from the
agentlog and not from a pod log read with no container name.
Requirement: Pod end reads init statuses first
pod_end MUST read initContainerStatuses before containerStatuses.
Scenario: Agent OOM keeps class oom
- WHEN The pod status test sets an OOM kill in
initContainerStatusesforagentand a runningpublishincontainerStatuses. - THEN The test asserts that
pod_endreturns theagentexit status 137 with the reasonOOMKilled, and the failure class isoom.
Requirement: Readers name their container
Each reader of the Job log or of a container status SHALL pass a container name.
Scenario: Readers pass the agent name
- WHEN The unit tests run
_outcomeoffix_checks_row,_log_ofand_pod_end_ofofimplement_submit,_failure_ofand_recoverofstage_submit, andlive_linesoffollow_liveagainst a pod whose init containeragentruns. - THEN The tests assert that each reader requests the
agentlog or status by name.
Requirement: Count line comes from agent
The Service SHALL read the count line of #3702 from the container agent.
Scenario: Agent count line wins
- WHEN The unit test gives an
agentlog with the count line and apublishlog with a different count. - THEN The test asserts that the Service reads the count line from
agent.
Requirement: run-job follows each container
devops k8s run-job SHALL follow each container in turn and SHALL read the exit status of each container by its name.
Scenario: run-job reads three exit statuses
- WHEN The run-job test builds a Job with
prepare,agentandpublishand runs the follow loop. - THEN The test asserts that the loop follows the three names in order and reads each exit status by name.
Requirement: Job builder keeps the one-container template
build_job and template_container SHALL accept the one-container runner template.
Scenario: Old runner template builds
- WHEN The
cluster_jobtest builds a Job from the current one-container CronJob template. - THEN The test asserts that
template_containerreturns the containerrunnerand thatbuild_jobsets its args, env and size.
Requirement: Template container selects by name
template_container SHALL take a container name and SHALL return the container with that name from the Job template.
Scenario: Agent container is selected
- WHEN The
cluster_jobtest callstemplate_containerwith the nameagenton a three-container fixture. - THEN The test asserts that the returned container has the name
agent.
Requirement: Job builder sets each of three containers
build_job SHALL set the args, the env and the size of each named container and SHALL give the three containers the same TRACEPARENT.
Scenario: Three containers get one trace parent
- WHEN The
cluster_jobtest builds a Job from a three-container template fixture. - THEN The test asserts that each named container gets its args, env and size and that all three containers get the same
TRACEPARENT.
Existing Tool Considered
The alternatives check of 2026-11-18 in the issue body records the verdict none: it found no third-party tool for the two-container layout or the safe import. The open, maintained tools that cover this need are Kubernetes itself (Apache-2.0, maintained) and its Python client kubernetes-client/python (Apache-2.0, maintained): init containers run in order before the app container, a ValidatingAdmissionPolicy with CEL pins the pod layout, and read_namespaced_pod_log reads one container by name. They lack the project's three-container template, the per-container policy rules and the container-aware Service readers, which this change writes. The written cost from the design in #2695 is about 30k to 60k tokens to build, 10k to 20k tokens a year to keep and fix, and 2 engineer-days.
Key questions
- How does the Service read the log of the container that runs?: Add a required
containerparameter tolog_tailand pass the running container name from the pod status.implement_deadlinereadsprepare, thenagent, thenpublish. The Kubernetes Python client'sread_namespaced_pod_logtakes the container name, andread_pod_log_textalready forwards keyword arguments to it. (best practice) [sources: src/devops_cli/k8s/cluster_job_api.py:290, src/devops_cli/k8s/service.py:97, src/devops_cli/roadmap/implement/implement_deadline.py:73, src/devops_cli/roadmap/implement/implement_deadline.py:77]- Chosen: Pass the container name from the pod status. The Kubernetes log API reads one container by name, and the pod status names the running container.
- Rejected: Read the pod log with no container name. A multi-container pod refuses a log read with no container name.
- Rejected: Always read the container agent. The prepare and publish phases then get no deadline extension.
- Which container order does the three-container template use?:
prepareisinitContainers[0],agentisinitContainers[1], andpublishiscontainers[0]. The ADR records that the three phases run one after the other, and Kubernetes runs init containers in order before the app container. (best practice) [sources: docs/adr/0030-roadmap-steps-run-their-agent-apart-from-the-app-key.md:23, docs/adr/0030-roadmap-steps-run-their-agent-apart-from-the-app-key.md:29, k8s/devops/cronjob-runner.yaml:41, k8s/devops/roadmap-service/admissionpolicy.yaml:61]- Chosen: Two init containers and one app container. Kubernetes runs init containers in order before the app container, so the phases run one after the other.
- Rejected: Three app containers. App containers run at the same time, so the phases would overlap.
- Rejected: One container with --phase all. The App key and the agent then share one process tree, which is the problem.
- How does
build_jobset values per container?:template_containertakes a container name and returns that container fromcontainersorinitContainers.build_jobsets args, env and size on each named container and copies the sameTRACEPARENTto all three. (best practice) [sources: src/devops_cli/k8s/cluster_job.py:206, src/devops_cli/k8s/cluster_job.py:228, k8s/devops/cronjob-runner.yaml:51]- Chosen: Change each container by name. The command has a value for each phase, and the old one-container template still works.
- Rejected: Change only the container runner. The new template has no runner container, so the command would change nothing.
- Rejected: Change every container the same way. The three phases need different args and sizes.
- Should the template change ship in the same pull request as the Service readers?: No. Defer the template, the admission policy, the gate tests, the live check and the documents to a new issue. That issue waits for a Service release with these readers and a runner image release that holds feat(roadmap): run implement and fix-checks as prepare/agent/publish phases #3702. (best practice) [sources: k8s/devops/cronjob-runner.yaml:25, src/devops_cli/k8s/cluster_job_api.py:290, docs/adr/0030-roadmap-steps-run-their-agent-apart-from-the-app-key.md:29]
- Chosen: Defer the template and policy. Argo CD applies the template at the merge commit, before the Service release that holds the readers, so the old readers would fail during the agent phase.
- Rejected: Ship both in one pull request. The pull request cannot order the Service release before the manifest sync.
- Which interim git controls does the owner remove after this item?: Delete
OriginGitand its ref copying. Delete the git argument parser of_github_pin, but keep the in-process mint and renewal of the token. Delete the process sweeps andadopt_orphans, the privateGH_CONFIG_DIR, the origin URL pin, and the symlink stop ofimplement_step.pyand its tests. Do this in one PR after the agent runs in its own container. The ADR records that no new git hardening comes before feat(roadmap): add the three-container runner Job, policy and log reads #3700. (best practice) [sources: src/devops_cli/roadmap/implement/git_isolation.py, src/devops_cli/core/process.py:616, src/devops_cli/core/process_hardening.py:80, src/devops_cli/roadmap/implement/implement_step.py, docs/adr/0030-roadmap-steps-run-their-agent-apart-from-the-app-key.md:33]- Chosen: Delete after the three-container template is live. The controls protect nothing when the agent has no App key, no token and no mount of the state folder.
- Rejected: Delete now. The agent still shares a container with the state folder and the App key in the current template.
- Does this item depend on feat(roadmap): run implement and fix-checks as prepare/agent/publish phases #3702?: Yes. The ADR records that the implement Job follows feat(roadmap): run implement and fix-checks as prepare/agent/publish phases #3702 part C and that feat(roadmap): add the three-container runner Job, policy and log reads #3700 runs each phase in its own container, and the owner decision of 2026-11-21 puts this item directly after feat(roadmap): run implement and fix-checks as prepare/agent/publish phases #3702 part C. Keep feat(roadmap): run implement and fix-checks as prepare/agent/publish phases #3702 as the dependency. [sources: docs/adr/0030-roadmap-steps-run-their-agent-apart-from-the-app-key.md:29, docs/adr/0030-roadmap-steps-run-their-agent-apart-from-the-app-key.md:33, docs/adr/0030-roadmap-steps-run-their-agent-apart-from-the-app-key.md:49]
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 5, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(roadmap)scope of the title gives the scope.It closes a named security gap (#2695) but is a planned feature, not an active exploit or outage.It separates the agent shell from the session token, removing a direct token-exposure path for every implement run.It requires a new container, a file-import function, admission-policy edits, real-UID tests, and resolution of four open points.Both touch the admission policy for runner Jobs, but #2696 created the policy while this item modifies it to admit a two-container layout.devops-cli-service commentedon Nov 7, 2026
Refine cannot set this item to Ready at 72c52c6 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.
devops-cli-service commentedon Nov 8, 2026
Alternatives check: none
Reason: The searches returned nothing relevant to a safe import of files from one container's directory into another container's checkout, and the only tool the issue names as considered, vstorm-co/pydantic-ai-backend, is a sandbox-backend library with no artifact import, so it covers neither the import nor the two-container pod layout. The boundary itself comes from Kubernetes primitives (a second container,
runAsUser, a sharedemptyDirwith per-directory modes, and a ValidatingAdmissionPolicy), which are wiring the project must write, not an open tool that covers the need.Tool: none found
Lacks:
Tools considered:
Searches run:
Sources:
Checked on 2026-11-08. A person decides what this means for the item. The check changes no label and closes no issue.
[-]feat(roadmap): add the two-container runner Job and file import[/-][+]feat(roadmap): add the three-container runner Job, policy and log reads[/+]devops-cli-service commentedon Nov 20, 2026
Owner question: See Suspected block in the section Proposed design of the body.
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
dan-petty commentedon Nov 21, 2026
A layout fact from part B of #3702 (PR #6609), for the three-container template:
<data folder>/roadmap/fix-checks-runs/<run>/, withstate/,work/andout/. The clone ofprepareis inwork/.work/, becauseadd_worktreeholds the take-over check of the branch.publishreads onlyout/(with a safe read) and a fresh clone that it fetches itself. It never reads the worktree of the agent.So the agent container needs
work/,out/and the agent worktree folder of the data folder. The publish container needs onlystate/(read) andout/(read), and it must not mount the agent worktree folder.27 remaining items
docs(roadmap): state the three containers in the texts of #3700
chore(main): release 0.194.0 (#6764)
devops-cli-service commentedon Nov 22, 2026
Released in v0.194.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.194.0
devops-cli-service commentedon Nov 22, 2026
Live since 2026-11-22 13:47 UTC
dan-petty commentedon Nov 22, 2026
The live check of the three-container runner Job passed. #6745 merged first and #6732 merged at 13:22 UTC. CronJob
devops-cli-runnerholds the init containersprepareandagentand the containerpublish. Its runner image is 0.194.1 (sha256:f10c82dd…), which holds #6745.Both Jobs below were made by the Service, so the policy
roadmap-service-jobsadmitted each CREATE.devops-cli-fix-checks-devops-cli-6338-c100b846d3)repaired: publish pushed b83d45d "make check Tests & Coverage (shard 5 of 5) pass"; the PR then mergeddevops-cli-implement-devops-cli-4244-5e0764)drafted: draft PR #6779 at 697e37f; the Service recordedimplement.result=drafted,implement.pr=6779and the runner digestNext: #6691 deletes the interim git controls.
refactor(roadmap): delete the interim git controls of the Jobs
refactor(roadmap): delete the interim git controls of the Jobs
refactor(roadmap): delete the interim git controls of the Jobs
refactor(roadmap): delete the interim git controls of the Jobs (#6790)