Repository navigation
Description
Problem or Motivation
The Jev question of the command gate needs the constraints of the Job environment and its access. Today these facts are only prose, in several places:
k8s/devops/cronjob-runner.yaml:4-6, 24-125: the pod, its security context, volumes and limits.k8s/devops/networkpolicy.yaml:26-72: the egress.src/devops_cli/config/constants.py:1502-1510: the permissions of the GitHub App installation.src/devops_cli/config/defaults.py:942-952: the time limits.src/devops_cli/roadmap/implement/implement_step.py:537-556: the shell env.
Prose can be wrong, and two reviews of 2026-11-12 gave wrong facts about the pod. No check measures the facts in a live Job.
Proposed Solution & Architectural Design
Add src/devops_cli/roadmap/environment_facts.py with an EnvironmentFacts model. Its keys are fixed: runs_in, user, kubernetes_access, secrets_in_pod (names only), shell_environment, output_goes_to, egress (by purpose), writable (with sizes), discardable_paths, git, main_branch and limits. The rendered JSON is at most 1,500 characters. It holds no address, no host name and no value.
There is one object for each profile: implement_shell, implement_verify, stage_run and service. The static part is committed as src/devops_cli/roadmap/environment_facts.json. A test makes it again from the k8s manifests (the YAML of cronjob-runner.yaml, networkpolicy.yaml and admissionpolicy.yaml) and the constants. The test fails on drift and names the key.
runtime_probe() runs at the start of each Job (in implement_run.py) and at the start of each step. It reads:
- the uid;
- whether the root file system is read-only (statvfs
ST_RDONLYof/); - the effective capabilities;
- whether a Kubernetes service account is mounted;
- the variable names of the shell env (names only).
It logs one line: Command gate facts: profile implement_shell, uid <n>, read_only_root <bool>, capabilities <list>, kubernetes_access <bool>. A runtime fact that is worse than the static fact sets jev_allowed=false for the Job. Then the Jev tier of the gate refuses the rest as mode off does.
Files: src/devops_cli/roadmap/environment_facts.py, src/devops_cli/roadmap/environment_facts.json, src/devops_cli/roadmap/implement/implement_run.py, src/devops_cli/lang/en/messages.py, tests/roadmap/test_roadmap_environment_facts.py.
Target Subsystem
SDLC, Git & PR Governance (src/devops_cli/roadmap/, the implement runner) and Kubernetes & Minikube Automation (the runner manifests).
Existing Tool Considered
No open tool turns Kubernetes manifests into a short statement of the limits of a pod. The probe uses the stdlib (os.statvfs, os.getuid). The build is about 220 lines. Cost: about 0.5M tokens and half a day.
Acceptance Criteria
tests/roadmap/test_roadmap_environment_facts.py: a copy of networkpolicy.yaml with a changed egress port makes the drift test fail, and the error names the key.tests/roadmap/test_roadmap_environment_facts.py: a fake probe that finds a writable root file system givesread_only_root falseandjev_allowed false. A fake service account mount giveskubernetes_access trueandjev_allowed false. A fake added capability givesjev_allowed false.tests/roadmap/test_roadmap_environment_facts.py: the rendered facts of each profile are at most 1,500 characters, and mask_secrets and mask_private_hosts leave the text unchanged.- Real Job, before the merge: the static facts of
implement_shellare equal to the spec of the newest implement Job (kubectl -n devops get job <name> -o json, read-only: security context, volumes, limits, deadline). The pull request comment shows the comparison. The shadow report item of tracker feat(roadmap): track the shared command gate #5199 checks the probe line in a live Job after the deploy. uv run devops ci test tests/roadmap/test_roadmap_environment_facts.pypasses.
Dependencies
-
chore(roadmap): hold incremental stage and implement work #6521 (hold: incremental work on the stage, implement and fix-checks jobs waits for the re-architecture)
-
A private security fix (owner).
-
feat(roadmap): check shell commands with a parser and configured lists #5201: the gate package and its profile table.
Related
- Tracker: feat(roadmap): track the shared command gate #5199.
- The Jev item of tracker feat(roadmap): track the shared command gate #5199 reads these facts.
Source: #5199
Alternatives check of 2026-11-28: partly.
Tool: kubescape/kubescape (https://github.com/kubescape/kubescape), Apache-2.0, last activity 2026-11-28, maintained.
Reason: The searches surfaced only manifest policy scanners. kubescape reads Kubernetes manifests and live workloads and reports pod security context facts in JSON, but it gives control results, not the fixed-key facts, drift check or in-pod probe that the issue needs.
Covers:
- Parses Kubernetes manifests and live workloads for pod settings
- Reports privileged mode, added capabilities, host mounts and token exposure
- Machine-readable JSON results that a check can compare
Lacks:
- No fixed-key compact environment facts with egress by purpose
- No committed-file drift check that names the profile and key
- No in-process probe of uid, read-only root and capabilities at step start
Proposed design
Problem statement
The command gate needs the facts of the Job environment and its access to answer its Jev question. Today these facts are only prose in the manifests, the constants, the defaults and the shell environment builder. Two reviews of 2026-11-12 gave wrong facts about the pod. No check measures the facts in a live Job. This change adds a fixed-key model. It adds a committed JSON of static facts for four profiles. It adds a drift check in the k8s row. It adds a runtime probe that refuses the Jev tier when a runtime fact is worse.
Acceptance criteria
Requirement: The model holds the fixed keys
The EnvironmentFacts model MUST hold the fixed keys runs_in, user, kubernetes_access, secrets_in_pod, shell_environment, output_goes_to, egress, writable, discardable_paths, git, main_branch and limits.
Scenario: The keys of the model
- WHEN
uv run devops ci test tests/roadmap/test_roadmap_environment_facts.pybuilds the model from an in-memory mapping of the fixed keys - THEN the model holds exactly those keys
Requirement: The committed facts hold four profiles
The committed facts file MUST hold one object for each profile implement_shell, implement_verify, stage_run and service.
Scenario: The profile keys of the committed file
- WHEN
uv run devops ci --check --only k8sruns the environment facts check oversrc/devops_cli/roadmap/environment_facts.json - THEN the check exits 0 and reports the four profiles
Requirement: A changed egress port names the key
The environment facts check SHALL name the profile and the key whose value differs from the manifests.
Scenario: A changed Qdrant egress port
- WHEN
uv run devops ci test tests/roadmap/test_roadmap_environment_facts.pygives the check a tree whosek8s/devops/networkpolicy.yamlsets the Qdrant egress port to 6334 - THEN the check raises an error whose text names the profile
implement_shelland the keyegress
Requirement: A changed stage volume names the key
The environment facts check SHALL build each profile from the manifest of its own pod and name the profile and the key that differ.
Scenario: A changed stage home size
- WHEN
uv run devops ci test tests/roadmap/test_roadmap_environment_facts.pygives the check a tree whosek8s/devops/cronjob-stage.yamlsets thehomesizeLimit to 5Gi - THEN the check raises an error whose text names the profile
stage_runand the keywritable
Requirement: Each profile fits the bound
The rendered facts of each profile SHALL be at most 1,500 characters.
Scenario: The size of the four profiles
- WHEN
uv run devops ci --check --only k8sruns the environment facts check over the four profiles - THEN the check exits 0 and reports each profile at or below 1,500 characters
Requirement: No secret or private host in the facts
The rendered facts of each profile MUST be unchanged by mask_secrets and mask_private_hosts.
Scenario: The two maskers leave the text alone
- WHEN
uv run devops ci --check --only k8srenders each profile throughmask_secretsandmask_private_hosts - THEN the check exits 0 and reports no change from either masker
Requirement: A writable root refuses the tier
The probe SHALL set jev_allowed to false when the root file system is writable.
Scenario: A writable root
- WHEN
uv run devops ci test tests/roadmap/test_roadmap_environment_facts.pygivesruntime_probe()a fakeos.statvfsof/whosef_flagholds noST_RDONLY - THEN the facts hold
read_only_rootfalse andjev_allowedfalse
Requirement: A mounted token refuses the tier
The probe SHALL set jev_allowed to false when a Kubernetes service account token is mounted.
Scenario: A mounted token
- WHEN
uv run devops ci test tests/roadmap/test_roadmap_environment_facts.pygives the probe a fake mount of the service account token - THEN the facts hold
kubernetes_accesstrue andjev_allowedfalse
Requirement: An added capability refuses the tier
The probe SHALL set jev_allowed to false when the process holds a capability that the static facts do not list.
Scenario: An added capability
- WHEN
uv run devops ci test tests/roadmap/test_roadmap_environment_facts.pygives the probe a fakeCapEffofCAP_NET_RAW - THEN the facts hold
capabilitiesofCAP_NET_RAWandjev_allowedfalse
Requirement: The shell environment gives names only
The probe MUST report the names of the shell environment variables and no value.
Scenario: A value stays out
- WHEN
uv run devops ci test tests/roadmap/test_roadmap_environment_facts.pygives the probe an environment withDEVOPS_CLI_CONFIG=/config/devops-cli.yaml - THEN the facts hold
DEVOPS_CLI_CONFIGand not/config/devops-cli.yaml
Requirement: The probe logs one line
The probe SHALL log one line that names the profile, the uid, read_only_root, capabilities and kubernetes_access.
Scenario: The line of the implement shell
- WHEN
uv run devops ci test tests/roadmap/test_roadmap_environment_facts.pyruns the probe forimplement_shellwith uid 1000, a read-only root, no capability and no token - THEN the log holds the line
Command gate facts: profile implement_shell, uid 1000, read_only_root true, capabilities [], kubernetes_access false.
Requirement: The probe runs at the Job start and at each step start
The implement runner SHALL call runtime_probe() at the start of each Job and at the start of each step.
Scenario: The two call sites
- WHEN
uv run devops ci test tests/roadmap/test_roadmap_environment_facts.pyruns the implement runner with a fake probe - THEN the fake probe records one call at the Job start and one call at each step start
Requirement: Pending a person after the merge
A person MUST compare the static facts of implement_shell with the security context, volumes, limits and deadline of the newest implement Job after the merge.
Scenario: The newest implement Job after the merge
- WHEN
kubectl -n devops get job <name> -o jsonreads the newest implement Job - THEN the person confirms that the security context, volumes, limits and deadline equal the static facts of
implement_shell
Existing Tool Considered
The alternatives check in the issue body gives kubescape/kubescape the verdict partly. The block lists what the tool covers and lacks. This change adds the compact fixed-key JSON. It adds the egress by purpose and the writable sizes. It adds the deadlines. It adds the drift check. It adds the in-process probe that feeds jev_allowed. The block says the tool lacks each of these. The change builds its own code of about 220 lines. It uses the standard library (os.statvfs, os.getuid, /proc/self/status) and the yaml loader that the gate checks already use. The written cost is about 0.5M tokens to build, keep and fix that code, and about half a day of elapsed time.
Key questions
- Where does the drift check live?: It lives in the
k8srow ofdevops ci, astests/gate/k8s_checks/environment_facts.py. Its logic test istests/roadmap/test_roadmap_environment_facts.py. The proof command isuv run devops ci --check --only k8s. (best practice) [sources: tests/gate/k8s_checks/job_admission_policy.py, src/devops_cli/config/constants.py]- Chosen: A
k8srow check with a logic test intests/roadmap/. A check of committed files is adevops cirow. The test of a check's logic gives it a small tree. - Rejected: A pytest test under
tests/roadmap/that reads the manifests and the JSON. A drift check of committed files belongs to thek8srow, not to a test that reads the files. - Rejected: Build the JSON at run time from the manifests. The body fixes a committed JSON. A Job must read the same facts with no cluster read.
- Chosen: A
- How does the drift check report a difference?: It builds each profile from the manifest of its own pod and the constants. It compares the result with the committed file key by key. The error names the profile and the first key that differs. (best practice) [sources: k8s/devops/cronjob-runner.yaml, k8s/devops/networkpolicy.yaml]
- Chosen: Compare key by key and name the profile and the key. The acceptance criterion requires the error to name the key. A reader must know which pod drifted.
- Rejected: Compare the rendered text. A text diff names no key, so a reader cannot tell the fact that drifted.
- Which key holds the git access and the permissions of the GitHub App installation token?:
githolds the git access of the profile. Forimplement_shellandimplement_verify, it says the shell has no GitHub credential and can only use the local worktree. Forstage_runandservice, it names the App permission names and levels. It holds no token value. (best practice) [sources: src/devops_cli/config/constants.py, docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md, src/devops_cli/roadmap/implement/implement_run.py]- Chosen: Put the git access under
git.gitis the only fixed key that covers the GitHub side of a step. The body lists the installation permissions among the prose facts to replace. - Rejected: Add a
github_accesskey. The body fixes the key set and the bound. A new key spends the bound on a fact thatgitholds. - Rejected: Leave the permissions out. The body names
src/devops_cli/config/constants.pyas a prose source. A fact that it holds must reach the model.
- Chosen: Put the git access under
- Which runtime facts does the probe compare with the static facts?: It compares the four facts that it can observe: the uid, the read-only root, the effective capabilities and the service-account mount. A value that is worse than the static fact sets
jev_allowedto false. (best practice) [sources: k8s/devops/cronjob-runner.yaml, src/devops_cli/roadmap/implement/implement_run.py]- Chosen: Compare the four observable facts. The probe reads the uid, the root file system, the capabilities and the token mount. A test can show each one.
- Rejected: Compare every key of the model. The probe cannot observe the egress, the volumes or the deadline. It would report a false drift.
- How does the probe read the effective capabilities?: It reads
CapEfffrom/proc/self/statusand decodes the hexadecimal bitmask against a fixed table of capability numbers and names. The probe adds no dependency and starts no program. (best practice) [sources: k8s/devops/cronjob-runner.yaml, src/devops_cli/roadmap/implement/implement_run.py]- Chosen: Read
CapEfffrom/proc/self/status. The standard library exposes no capability call. One file read gives the effective set. - Rejected: Add a capability library. A dependency for one read reaches the runner image. The probe runs in every Job.
- Rejected: Run
capsh --print. It adds a system program and a child process. A file read answers the same.
- Chosen: Read
- Where does
runtime_probe()run?: It runs at the start of each Job inimplement_run.pyand at the start of each step inimplement_step.py. It returns the facts and one log line. It setsjev_allowedto false when a runtime fact is worse than the static fact. The profile table of feat(roadmap): check shell commands with a parser and configured lists #5201 reads the field. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py, src/devops_cli/roadmap/implement/implement_step.py]- Chosen: Probe at the Job start and at each step start. The body fixes both call sites. The line of each step shows which step saw a worse fact.
- Rejected: Probe only at the Job start. It hides a step that changes the environment after the Job start.
- Which maskers does the repository hold?:
mask_secretsmasks the secrets of a text.mask_private_hostsreplaces each private host name or address with<masked-host>. Both are insrc/devops_cli/security/sanitizer.py. [sources: src/devops_cli/security/sanitizer.py, src/devops_cli/roadmap/implement/implement_run.py] - Which time limit bounds each profile?: A runner Job keeps
activeDeadlineSecondsfrom CronJobdevops-cli-runner. The Service sets the implement deadline fromroadmap.implement.deadline_extension_secondsand caps it atroadmap.implement.deadline_ceiling_seconds. The admission policy refuses a deadline aboveCONST_ROADMAP_IMPLEMENT_DEADLINE_CAP_SECONDS. A stage Job has its ownactiveDeadlineSeconds. [sources: k8s/devops/cronjob-runner.yaml, src/devops_cli/config/defaults.py, src/devops_cli/config/constants.py, k8s/devops/roadmap-service/admissionpolicy.yaml, k8s/devops/cronjob-stage.yaml] - Where do the facts of the runner pod come from?:
k8s/devops/cronjob-runner.yamlholds them. CronJobdevops-cli-runnerruns as a non-root user. It setsautomountServiceAccountToken: false, a read-only root file system andcapabilities.drop: [ALL]. It mountstmp,homeand a read-onlyconfig, and it sets the limits andactiveDeadlineSeconds. [sources: k8s/devops/cronjob-runner.yaml] - Where do the facts of the stage pod come from?:
k8s/devops/cronjob-stage.yamlholds them. CronJobroadmap-stagehas a read-only root, dropped capabilities and its own limits. It reads the App private key and the gateway key throughsecretKeyRef. Its egress is the perimeter policy. [sources: k8s/devops/cronjob-stage.yaml, k8s/devops/networkpolicy.yaml] - Where do the facts of the Service pod come from?:
k8s/devops/roadmap-service/deployment.yamlholds them. Deploymentroadmap-servicehas a read-only root andcapabilities.drop: [ALL]. It mounts a projected service-account token, sokubernetes_accessis true for this profile. It reads the LLM key and the App keys throughsecretKeyRef. [sources: k8s/devops/roadmap-service/deployment.yaml] - Where does the egress of the runner come from?:
k8s/devops/networkpolicy.yamlholds it. The policy admits DNS on port 53, the gateway on 4000 and Valkey on 6379, Qdrant on 6333 and OTLP/HTTP on 4318. It admits public HTTPS on 443 only, with the private, shared, link-local, metadata and benchmarking ranges removed. [sources: k8s/devops/networkpolicy.yaml] - Where is the shell environment of a step built?:
shell_environment()insrc/devops_cli/roadmap/implement/implement_step.pybuilds it. It setsHOME,XDG_CONFIG_HOME,GIT_CONFIG_NOSYSTEM,GIT_TERMINAL_PROMPT,UV_CACHE_DIRandAI_AGENT. The CronJob sets the other variables. [sources: src/devops_cli/roadmap/implement/implement_step.py, k8s/devops/cronjob-runner.yaml] - What distinguishes the
implement_verifyprofile fromimplement_shell?: Both profiles run in the runner pod.implement_verifyruns a verification command as a list of words with no shell. Its access is the class of each program thatSHELL_PROGRAMSinimplement_shell_policy.pylists:read,writeornetwork. [sources: src/devops_cli/roadmap/implement/implement_step.py] - Where does the output of a step go?: The step writes to the stdout log of the pod. The Service reads that log in each round to find progress. The implement job comments the outcome of each step on the pull request and sets its title and body. [sources: src/devops_cli/roadmap/implement/implement_run.py]
- Which file holds the admission policy that bounds a Job of the Service?:
k8s/devops/roadmap-service/admissionpolicy.yamlholds ValidatingAdmissionPolicyroadmap-service-jobsand its binding. It refuses aCREATEorUPDATEof a Job bysystem:serviceaccount:devops:roadmap-serviceunless the Job matches the runner or stage shape. It never changes a Job. [sources: k8s/devops/roadmap-service/admissionpolicy.yaml]
Fit
Fits in one pull request.
Suspected block
A private security fix that the owner holds, with no issue number.
Activity
dan-petty commentedon Nov 12, 2026
Both work on the command gate for the implement Job, but #4719 delivers the gate running full checks while this delivers the structured EnvironmentFacts model and runtime probe that inform gate decisions.devops-cli-service commentedon Nov 17, 2026
Refine cannot set this item to Ready at 8ccd95a 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 19, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (10)
Tools considered:
Searches run:
Sources:
dan-petty commentedon Nov 20, 2026
Frozen on 2026-11-20. The stage, implement and fix-checks jobs grade under 60%, so the owner rule asks for a re-architecture before more fixes inside the current design (tracker #6519). This item is incremental work on those jobs, so its Dependencies section now names #6521 first. Stage and implement leave this item while #6521 is open. When the experiments of #6519 decide, a person closes #6521 (this item can then continue) or closes this item as not planned.
devops-cli-service commentedon Nov 21, 2026
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.
devops-cli-service commentedon Nov 21, 2026
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.
dan-petty commentedon Nov 30, 2026
Triage under #6519 (owner instruction of 2026-11-30), before the hold #6521 closes. This item adds or extends a gate, refusal, screen, cap, limit, retry, result line, shell allowlist, tool catalog or plan-shape rule of the stage, implement or fix-checks job. #6519 found that 263 of about 900 issues in four weeks added such rules and none replaced the engine. Stage now runs on stock Coder (grade 60 on 30 graded attempts), where the agent reads the repository, runs the checks in its loop and has a real shell; implement follows (#6527). The code paths that this item names have also moved. If the failure class still shows in graded attempts, file a new item from that evidence. Closed as not planned; a person may reopen it.