Skip to content

feat(roadmap): build the command gate facts from the manifests and a probe #5203

Not planned

Description

@dan-petty

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_RDONLY of /);
  • 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

  1. 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.
  2. tests/roadmap/test_roadmap_environment_facts.py: a fake probe that finds a writable root file system gives read_only_root false and jev_allowed false. A fake service account mount gives kubernetes_access true and jev_allowed false. A fake added capability gives jev_allowed false.
  3. 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.
  4. Real Job, before the merge: the static facts of implement_shell are 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.
  5. uv run devops ci test tests/roadmap/test_roadmap_environment_facts.py passes.

Dependencies

Related

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.py builds 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 k8s runs the environment facts check over src/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.py gives the check a tree whose k8s/devops/networkpolicy.yaml sets the Qdrant egress port to 6334
  • THEN the check raises an error whose text names the profile implement_shell and the key egress

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.py gives the check a tree whose k8s/devops/cronjob-stage.yaml sets the home sizeLimit to 5Gi
  • THEN the check raises an error whose text names the profile stage_run and the key writable

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 k8s runs 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 k8s renders each profile through mask_secrets and mask_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.py gives runtime_probe() a fake os.statvfs of / whose f_flag holds no ST_RDONLY
  • THEN the facts hold read_only_root false and jev_allowed false

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.py gives the probe a fake mount of the service account token
  • THEN the facts hold kubernetes_access true and jev_allowed false

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.py gives the probe a fake CapEff of CAP_NET_RAW
  • THEN the facts hold capabilities of CAP_NET_RAW and jev_allowed false

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.py gives the probe an environment with DEVOPS_CLI_CONFIG=/config/devops-cli.yaml
  • THEN the facts hold DEVOPS_CLI_CONFIG and 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.py runs the probe for implement_shell with 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.py runs 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 json reads 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 k8s row of devops ci, as tests/gate/k8s_checks/environment_facts.py. Its logic test is tests/roadmap/test_roadmap_environment_facts.py. The proof command is uv 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 k8s row check with a logic test in tests/roadmap/. A check of committed files is a devops ci row. 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 the k8s row, 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.
  • 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?: git holds the git access of the profile. For implement_shell and implement_verify, it says the shell has no GitHub credential and can only use the local worktree. For stage_run and service, 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. git is 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_access key. The body fixes the key set and the bound. A new key spends the bound on a fact that git holds.
    • Rejected: Leave the permissions out. The body names src/devops_cli/config/constants.py as a prose source. A fact that it holds must reach the model.
  • 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_allowed to 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 CapEff from /proc/self/status and 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 CapEff from /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.
  • Where does runtime_probe() run?: It runs at the start of each Job in implement_run.py and at the start of each step in implement_step.py. It returns the facts and one log line. It sets jev_allowed to 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_secrets masks the secrets of a text. mask_private_hosts replaces each private host name or address with <masked-host>. Both are in src/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 activeDeadlineSeconds from CronJob devops-cli-runner. The Service sets the implement deadline from roadmap.implement.deadline_extension_seconds and caps it at roadmap.implement.deadline_ceiling_seconds. The admission policy refuses a deadline above CONST_ROADMAP_IMPLEMENT_DEADLINE_CAP_SECONDS. A stage Job has its own activeDeadlineSeconds. [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.yaml holds them. CronJob devops-cli-runner runs as a non-root user. It sets automountServiceAccountToken: false, a read-only root file system and capabilities.drop: [ALL]. It mounts tmp, home and a read-only config, and it sets the limits and activeDeadlineSeconds. [sources: k8s/devops/cronjob-runner.yaml]
  • Where do the facts of the stage pod come from?: k8s/devops/cronjob-stage.yaml holds them. CronJob roadmap-stage has a read-only root, dropped capabilities and its own limits. It reads the App private key and the gateway key through secretKeyRef. 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.yaml holds them. Deployment roadmap-service has a read-only root and capabilities.drop: [ALL]. It mounts a projected service-account token, so kubernetes_access is true for this profile. It reads the LLM key and the App keys through secretKeyRef. [sources: k8s/devops/roadmap-service/deployment.yaml]
  • Where does the egress of the runner come from?: k8s/devops/networkpolicy.yaml holds 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() in src/devops_cli/roadmap/implement/implement_step.py builds it. It sets HOME, XDG_CONFIG_HOME, GIT_CONFIG_NOSYSTEM, GIT_TERMINAL_PROMPT, UV_CACHE_DIR and AI_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_verify profile from implement_shell?: Both profiles run in the runner pod. implement_verify runs a verification command as a list of words with no shell. Its access is the class of each program that SHELL_PROGRAMS in implement_shell_policy.py lists: read, write or network. [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.yaml holds ValidatingAdmissionPolicy roadmap-service-jobs and its binding. It refuses a CREATE or UPDATE of a Job by system:serviceaccount:devops:roadmap-service unless 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.

Dependencies

#6521, #5201

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 12, 2026
  3. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
    • Related: feat(roadmap): the implement Job gates before its PR #4719, which asks for a different change. 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.
  4. added
    priority/p2-medium
    on Nov 12, 2026
  5. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    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.

  6. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    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:

    • amicontained container capabilities seccomp user id runtime probe tool, results: 5
    • open source tool summarize Kubernetes pod security context capabilities egress into structured facts, results: 5
    • kubescape controls read-only root filesystem capabilities service account token, results: 5
    • kube-score Kubernetes object analysis checks security context network policy, results: 5
    • kubescape, results: 5
    • kube-score, results: 5
    • kube-linter stackrox, results: 5
    • kube-score zegl, results: 5
    • amicontained, results: 5
    • kubernetes manifest linter kube-linter checks read-only root filesystem, results: 5

    Sources:

  7. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor

    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.

  8. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    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.

  9. devops-cli-service commented on Nov 21, 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.

  10. dan-petty commented on Nov 30, 2026

    @dan-petty
    OwnerAuthor

    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.

  11. removed
    status/new
    on Nov 30, 2026
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/roadmapsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions