Skip to content

test(roadmap): proof tests for planner sandboxed run job isolation controls #4007

Closed

Description

@dan-petty

Problem or Motivation

ADR 0018 (docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md, #3242) defines seven isolation controls to ensure commands run by the planner cannot write to the repository, access secrets, or contact the network. Proof tests must verify that these controls hold.

Proposed Solution & Architectural Design

Add offline and live proof tests in tests/roadmap/test_roadmap_run_job.py:

  1. Implement offline invariant tests verifying the Job spec rendered via build_job:
    • test_a_write_outside_the_read_only_copy_fails: verifies readOnly: true on the repo mount and ensures only the two emptyDir volumes are writable.
    • test_a_read_of_a_credential_and_of_the_service_account_token_finds_no_file: verifies automountServiceAccountToken: false, no secret envFrom, and credential-free ConfigMap volume.
    • test_an_outbound_connection_fails: verifies NetworkPolicy selects Job pod labels and denies all egress and DNS.
  2. Implement live cluster verification test:
    • test_the_run_job_holds_the_three_controls: executes write attempt, credential read attempt, and outbound network attempt in the real cluster pod.
    • Mark live test with k8s marker and declare marker in pyproject.toml.

Depends on: #3242 (ADR 0018).

Target Subsystem

SDLC, Git & PR Governance

Existing Tool Considered

Pytest with existing test fixtures and Kubernetes job templates covers offline assertions. The cluster test uses the existing k8s marker pattern. Implementing these test suites costs approximately 10,000 tokens and 0.5 elapsed days.

Alternatives check of 2026-11-09: not-applicable.
Class: test, no search.
Tool: none found.

Proposed design

Problem statement

ADR 0018 defines seven isolation controls for the planner run Job. The repository has no proof tests for these controls. This item adds offline tests that read the run Job and its NetworkPolicy. It also adds one live test. The live test tries a write, a credential read and an outbound connection. The run Job manifest and its NetworkPolicy arrive with #4003. The tests wait for that merge.

Acceptance criteria

Requirement: Offline write test reads the read-only repository mount

The test test_a_write_outside_the_read_only_copy_fails SHALL assert that the run Job mounts the staged commit read-only and that only the home and tmp emptyDir volumes are writable.

Scenario: A run Job is built from the planner run CronJob

  • WHEN The test calls build_job with the devops-cli-planner-run CronJob and the planner template.
  • THEN The repository mount has readOnly: true, and the only writable volumes are home and tmp.

Requirement: Offline credential test reads no secret and no token

The test test_a_read_of_a_credential_and_of_the_service_account_token_finds_no_file SHALL assert that the run Job has no Secret envFrom, a credential-free config volume, and automountServiceAccountToken: false.

Scenario: A run Job is built from the planner run CronJob

  • WHEN The test reads the container envFrom, the config volume, and the pod automountServiceAccountToken.
  • THEN No envFrom names Secret devops-cli, the config volume comes from the credential-free ConfigMap, and automountServiceAccountToken is false.

Requirement: Offline network test reads a deny-all egress policy

The test test_an_outbound_connection_fails SHALL assert that the devops-cli-planner-run NetworkPolicy selects the run Job pod labels and admits no egress and no DNS.

Scenario: The planner run NetworkPolicy is read

  • WHEN The test reads the podSelector, policyTypes, and egress rules of the NetworkPolicy.
  • THEN The selector matches the run Job pod labels, policyTypes includes Egress, and no egress rule admits traffic or DNS.

Requirement: The live test carries the k8s marker

The live test test_the_run_job_holds_the_three_controls SHALL carry the k8s marker, and pyproject.toml SHALL declare that marker.

Scenario: The test suite collects the live test

  • WHEN pytest collects tests/roadmap/test_roadmap_run_job.py without -m k8s.
  • THEN The live test is skipped, and the k8s marker is declared in pyproject.toml.

Requirement: The live test holds the three attempts

The live test SHALL attempt a write, a credential read, and a public connection in the run Job pod, and SHALL assert that each fails.

Scenario: The live test source is read

  • WHEN A test reads tests/roadmap/test_roadmap_run_job.py.
  • THEN The file contains the three attempts in the run Job pod and asserts that each fails.

Requirement: The proof tests live in one module

The change SHALL add the three offline tests and the live test to tests/roadmap/test_roadmap_run_job.py.

Scenario: The test module is collected

  • WHEN pytest collects the tests/roadmap folder.
  • THEN The module tests/roadmap/test_roadmap_run_job.py holds the three offline tests and the live test.

Existing Tool Considered

The alternatives check returned not-applicable for this test item and named no tool. Pytest, already a dev dependency, covers the offline test harness. It lacks the devops-cli-planner-run CronJob and NetworkPolicy, which #4003 adds, and a cluster for the live test. The test suite costs about 10,000 tokens and 0.5 elapsed days.

Key questions

  • Which CronJob does the proof test read to render the run Job?: The suspended CronJob devops-cli-planner-run, which PLANNER_TEMPLATE names in src/devops_cli/k8s/cluster_job.py. feat(k8s): manifest and admission policy for planner sandboxed run job #4003 adds its manifest. [sources: src/devops_cli/k8s/cluster_job.py, docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md]
  • Which pytest marker selects the live cluster test?: k8s. The change adds the marker to pyproject.toml, and only -m k8s selects the live test. (best practice) [sources: docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md, pyproject.toml]
    • Chosen: k8s. ADR 0018 names k8s for the live proof test, and pyproject.toml declares no k8s marker today.
    • Rejected: live. live selects local tool binaries, not a cluster test.
    • Rejected: bwrap. bwrap selects bubblewrap sandbox tests, not Kubernetes.
  • Is the k8s marker already declared in pyproject.toml?: No. pyproject.toml declares the markers bwrap, live and unreachable only. The change adds k8s. [sources: pyproject.toml]
  • Does the live test run in CI by default?: No. The k8s marker excludes it unless a person runs pytest -m k8s. [sources: pyproject.toml, docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md]
  • Should the live test be deferred to a new issue?: No. The test is written in the module and marked k8s; a person runs it with a cluster. The offline tests carry the CI proof. (best practice) [sources: docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md]
    • Chosen: Keep the live test in the module. ADR 0018 names one live test in this module, and the test blocks no merge.
    • Rejected: Defer the live test to a new issue. The test can be written with the offline tests, and the ADR names it here.
  • What does the offline write test assert about the repository mount?: It asserts readOnly: true on the repository mount and that only the home and tmp emptyDir volumes are writable. [sources: docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md]
  • What does the offline credential test assert?: It asserts no envFrom of Secret devops-cli, a config volume from the credential-free ConfigMap, and automountServiceAccountToken: false. [sources: docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md]
  • What does the offline network test assert?: It asserts that a NetworkPolicy selects the run Job pod labels, that policyTypes includes Egress, and that no egress rule admits traffic or DNS. [sources: docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md]
  • Which issue must merge before the proof tests can read the run Job and NetworkPolicy?: feat(k8s): manifest and admission policy for planner sandboxed run job #4003, which adds the devops-cli-planner-run CronJob and its NetworkPolicy. The draft pull request feat(k8s): Add the planner sandboxed run Job #5754 is not merged. [sources: docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4003

Activity

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

    @devops-cli-service
    Contributor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Priority: P2-Medium. The tests confirm security controls, but the work depends on the manifest and the ADR.
    • Value: Medium. The tests show that the sandbox controls hold and prevent a regression.
    • Effort: Low. The candidate estimates 10,000 tokens and 0.5 elapsed days for two test suites.
    • Related: feat(k8s): manifest and admission policy for planner sandboxed run job #4003, which asks for a different change. Both items cover the same seven isolation controls. Item 4003 adds the manifest and the policy, and this item adds the proof tests.
  4. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 1f03ee3 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • the run Job CronJob manifest of ADR 0018 follow-up 1 is not in the repository
  5. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Class: test. The check makes no search and no model call for an item of this class.

    Tool: none found

    Checked on 2026-11-09. A person decides what this means for the item. The check changes no label and closes no issue.

  6. dan-petty commented on Nov 14, 2026

    @dan-petty
    OwnerAuthor

    The item waits on #4003, whose manifest is a draft pull request (#5754) and not on main. The refine block records the same block: "the run Job CronJob manifest of ADR 0018 follow-up 1 is not in the repository".

    • The offline tests render the Job from CronJob devops-cli-planner-run and NetworkPolicy devops-cli-planner-run, and neither file is on main today.
    • The live test writes, reads the token and opens a connection in a pod of the CronJob. It needs the manifest on main, a cluster with the devops stack, and the gVisor node.
    • The k8s marker is already declared in pyproject.toml, so the live test adds no marker change.

    No test is written before the manifest lands. Once #4003 merges, this item can add tests/roadmap/test_roadmap_run_job.py and run the offline tests. The live test stays a person step with a cluster.

  7. added
    status/ready
    and removed
    status/new
    on Nov 15, 2026
  8. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 46c62f3 (see proposed design in issue body).

  9. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 15, 2026
  10. removed
    status/in-review
    on Nov 15, 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/lowpriority/p2-mediumscope/roadmapsource/agenttype/testvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions