Skip to content

build(runner): bootstrap the dev env with uv in each Job #6517

Description

@dan-petty

Problem

The runner image of the stage, implement and fix-checks Jobs installs the whole dev dependency group of uv.lock into /app/.venv, and /app/.venv/bin is first on PATH. So the checks of a Job (ruff, mypy, pytest, pre-commit) can run from the image venv and not from the checkout the agent changes. The checkout gets its own environment only by accident: the first uv run of the Job (uv run pre-commit install-hooks) builds it. src/devops_cli/roadmap/runner_tools.py lists the dev tools (_dev(...), for example ruff and mypy) as tools of the image, and the runner smoke test checks them on PATH.

Owner direction (2026-11-20): "actually I don't think the dev dependencies should be in the image, there should be a uv command to bootstrap the coder environment". The plan/implement image is the devtools image plus the devops-cli runtime only (#4361, PR #6513).

Change

  • The runner image installs only the runtime dependencies of devops-cli (and the review extra) into /app/.venv: no dev group.
  • Each Job bootstraps the coder environment in its checkout with one explicit command before the agent starts: uv sync --locked with the dev group, as the devcontainer post-create does (docs/DEVCONTAINER_USAGE.md).
  • Every check a Job runs (ruff, mypy, pytest, pre-commit, devops ci) uses the checkout environment, never /app/.venv.
  • runner_tools.py moves the dev tools from "in the image" to "in the checkout environment after the bootstrap"; the runner smoke test proves the image and the bootstrap together.

Proof

  • A test (written first) shows that the Job runs the bootstrap command in the checkout before the first agent step, and that a check runs the checkout's tools.
  • The runner smoke step runs the bootstrap on a checkout inside the image and then uv run ruff --version, uv run pytest --version and uv run mypy --version from it.
  • docker run --rm <runner> sh -c 'ls /app/.venv/bin' shows no ruff, mypy or pytest.

Depends on: #4361 (PR #6513).

Proposed design

Problem statement

The runner image installs the full dev dependency group, so Job checks can run from /app/.venv instead of the checkout. Each stage, implement and fix-checks Job must bootstrap its checkout with uv sync --locked and run every check from that environment.

Acceptance criteria

Requirement: Runner image has no dev tools

The runner image SHALL install only the runtime dependencies of devops-cli and the review extra into /app/.venv.

Scenario: The image venv has no dev tool

  • WHEN the runner image is built and docker run --rm "$RUNNER_IMAGE" sh -c 'ls /app/.venv/bin' runs
  • THEN the output lists no ruff, mypy, pytest or pre-commit executable

Requirement: Checkout bootstrap command

Each stage, implement and fix-checks Job MUST run uv sync --locked in its checkout before the first agent step.

Scenario: A job bootstraps before the agent

  • WHEN a job test records the setup commands of the stage, implement or fix-checks Job
  • THEN the setup runs uv sync --locked in the checkout before the first agent step

Requirement: Shared bootstrap function

The runner code SHALL expose one bootstrap function in src/devops_cli/roadmap/runner_tools.py that the stage, implement and fix-checks Jobs call.

Scenario: All jobs call the shared bootstrap

  • WHEN a test inspects the setup of the stage, implement and fix-checks Jobs
  • THEN each job calls the same bootstrap function and passes its checkout path

Requirement: Checks use the checkout environment

Every check that a Job runs MUST resolve ruff, mypy, pytest, pre-commit and devops from the checkout environment.

Scenario: A check uses the checkout tools

  • WHEN a job test runs a check after the bootstrap
  • THEN the check resolves each tool under <checkout>/.venv/bin and not under /app/.venv/bin

Requirement: Dev tools move to the checkout inventory

runner_tools.py SHALL report ruff, mypy, pytest and pre-commit as tools of the checkout environment after bootstrap, not tools of the image.

Scenario: The tool inventory names the checkout

  • WHEN a test reads the tool inventory from src/devops_cli/roadmap/runner_tools.py
  • THEN each dev tool has the checkout source and no dev tool has the image source

Requirement: Runner smoke proves the bootstrap

The runner smoke step MUST run the checkout bootstrap inside the image and then run the dev tools from that checkout.

Scenario: The smoke step prints dev tool versions

  • WHEN the runner smoke step runs uv run ruff --version, uv run pytest --version and uv run mypy --version in a checkout inside the image
  • THEN each command exits 0 and prints the version from the checkout environment

Existing Tool Considered

No alternatives check has run. uv (https://docs.astral.sh/uv/) is the open, maintained tool that covers the need: uv sync --locked builds the checkout environment from uv.lock, including the default dev group. The change writes no new tool code.

Key questions

  • Which command bootstraps the checkout environment in each Job?: Use uv sync --locked in the checkout. The command installs the default dev group, as the devcontainer post-create does. (best practice) [sources: docs/DEVCONTAINER_USAGE.md, uv.lock]
    • Chosen: uv sync --locked. It uses the existing lock and the documented devcontainer command.
    • Rejected: uv sync --locked --no-dev. It leaves out the dev tools that the checks need.
    • Rejected: pip install -e .[dev]. It adds a second resolver and does not use uv.lock.
  • Which dependencies stay in the runner image?: Install the runtime dependencies of devops-cli and the review extra only. Install no dev group. The owner direction in the issue removes the dev group from the image. (best practice) [sources: pyproject.toml, uv.lock]
    • Chosen: runtime and review extra. The runner needs devops-cli and the review extra at runtime.
    • Rejected: full dev group. The owner direction removes the dev group from the image.
    • Rejected: runtime only. The runner needs the review extra.
  • Where does the shared checkout bootstrap live?: Put one bootstrap function in src/devops_cli/roadmap/runner_tools.py and call it from the stage, implement and fix-checks Job setup before the agent step. (best practice) [sources: src/devops_cli/roadmap/runner_tools.py]
    • Chosen: shared function in runner_tools.py. The module already holds the runner tool inventory, so one place owns the bootstrap and the tool list.
    • Rejected: copy the command into each Job. Three copies can drift.
    • Rejected: bootstrap in the image entrypoint. The checkout does not exist when the image starts.
  • How do the checks select the checkout environment?: Prepend <checkout>/.venv/bin to PATH after the bootstrap and run checks with uv run from the checkout. Never resolve a check from /app/.venv. (best practice) [sources: src/devops_cli/roadmap/runner_tools.py, docs/DEVCONTAINER_USAGE.md]
    • Chosen: prepend checkout venv and use uv run. The checkout venv is the environment that the bootstrap fills.
    • Rejected: remove /app/.venv from PATH only. The checks then have no dev tools.
    • Rejected: call tools by absolute path. The paths differ from the documented uv run workflow.
  • What does the runner smoke step prove?: Run uv sync --locked in a checkout inside the image, then run uv run ruff --version, uv run pytest --version and uv run mypy --version from that checkout. (best practice) [sources: docs/DEVCONTAINER_USAGE.md, uv.lock]
    • Chosen: bootstrap then uv run versions. It proves the image and the bootstrap together.
    • Rejected: check tools on PATH only. It can pass on the old image venv and prove nothing about the checkout.
    • Rejected: check the image venv only. It cannot show that the checkout has the dev tools.
  • Which tools are dev tools in runner_tools.py now?: ruff, mypy, pytest and pre-commit are dev tools. [sources: src/devops_cli/roadmap/runner_tools.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4361

Alternatives check of 2026-11-20: in-use.
The repository already uses this tool.
Tool: astral-sh/uv (https://github.com/astral-sh/uv), Apache-2.0, last activity 2026-11-20, maintained.
Reason: Searches and the uv docs show uv sync --locked fills a checkout .venv from uv.lock with the dev group, and uv run resolves ruff, mypy and pytest from it, so uv covers the bootstrap whole.

Covers:

  • One uv sync --locked fills the checkout .venv from uv.lock
  • uv run resolves ruff, mypy, pytest and pre-commit from that checkout venv
  • Runs offline from a copied uv seed cache, as the reply asks

Lacks:

  • No Job orchestration: the runner must run the bootstrap before the first agent step
  • No PATH or venv selection; the runner must prepend <checkout>/.venv/bin
  • No image change: dropping the dev group from /app/.venv stays with this item
  • The reply's --group dev and offline form is not in the body's command

Activity

  1. added
    type/infra
    source/agent
    status/new
    value/medium
    effort/medium
    on Nov 20, 2026
  2. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor
    • Scope: none. The title has the scope runner, and .github/labels.yml declares no scope/runner label. Add the label to the file to give the scope to this item.
    • Related: build(docker): build the runner image FROM devtools with no tool install #4361, which asks for a different change. Both change the runner image, but #4361 restructures the Dockerfile build (FROM devtools, no tool-install RUN steps) while the candidate changes the venv content and adds a per-Job bootstrap command.
  3. added
    priority/p2-medium
    on Nov 20, 2026
  4. devops-cli-service commented on Nov 20, 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.

  5. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor

    The bootstrap of this item uses the uv-seed image volume when it is present (decision on #4814, 2026-11-20): copy /opt/uv-seed/cache into the home emptyDir, then one uv sync --locked --group dev --offline when seed.json matches the clone, else the online uv sync --locked --group dev with UV_HTTP_RETRIES=5. Also set UV_COMPILE_BYTECODE=0 in the runner final stage (the image ENV sets 1 today, and #4814 measured 71 s of 110 s of the Job bootstrap as bytecode compile). Build after #6513 merges.

  6. devops-cli-service commented on Nov 20, 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 (4)

    Tools considered:

    Searches run:

    • uv sync --locked install dev dependency group from lockfile, results: 5
    • Python tool bootstrap reproducible dev environment from lockfile per CI job, results: 5
    • uv sync --group dev offline seed cache CI bootstrap, results: 5
    • astral uv Python package manager uv sync lockfile, results: 5

    Sources:

  7. added
    owner/agent
    status/in-progress
    and removed
    status/new
    on Nov 20, 2026
  8. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor

    The stage part of this item waits for the move of the stage Job to the runner image (#6417, #6528). PR #6537 bootstraps only the implement Job and the model fix of the fix-checks Job.

    Evidence:

    • k8s/devops/cronjob-stage.yaml runs the stage Job in ghcr.io/dan-petty/devops-cli/service; only k8s/devops/cronjob-runner.yaml uses ghcr.io/dan-petty/devops-cli/runner.
    • The smoke test of the Service image in ci.yml fails when command -v uv finds uv, and the image holds no npm.
    • The admission policy admits only the Service image for a stage Job.

    So uv sync in the stage Job would exit 127 on each repository with uv.lock, the Job would end as ci_infra, and it would run again each hour with the same result. The pull request adds no check whether uv is present. When the stage Job runs in the runner image, it can call bootstrap_checkout on its clone before plan_stage.

  9. removed
    status/in-progress
    owner/agent
    on Nov 20, 2026
  10. added a commit that references this issue on Nov 20, 2026
  11. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-20 20:21 UTC

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-mediumsource/agenttype/infravalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions