Plan: validate In-Network Runner (Issue #339)

Status

Step Description Status

1

New Dockerfile xtask/Dockerfile.validate-runner building a small Rust + cargo + sqlx-cli image. Multi-stage build matching the existing Dockerfile pattern at Dockerfile:1-69 for size. Includes the cargo xtask binary path and any system packages the validate path requires (postgresql-client for sqlx, git, etc.).

Done (2026-05-10)

2

New xtask command xtask/src/cmd/validate_in_network.rs. Builds the validate-runner image (cached locally), spins it up on the canopy-net Docker network (created by cargo xtask dev start), mounts the workspace via -v ${PWD}:/work -w /work, runs cargo xtask validate inside the container. Optional flag --with-devstack boots devstack first if not already up. Detects whether devstack is running by querying the existing devstack-guard helpers.

Done (2026-05-10)

3

CI wiring. Add an opt-in CI job in .gitlab-ci.yml that runs cargo xtask validate-in-network instead of validate on a runner with Docker daemon access. The job is manual: for now (developer-triggered) — making it a default gate is a follow-up issue once it’s been exercised in real conditions.

Done (2026-05-10)

4

Docs. New docs/modules/ROOT/pages/contributors/validate-in-network.adoc covering when to use it, prerequisites (Docker daemon, devstack profile selection), and trade-offs vs. host-validate. Update docs/modules/ROOT/pages/local-dev.adoc with a pointer. CHANGELOG entry under === Added. Plan moves to plans/archive/ post-merge.

Done (2026-05-10)

Issue: #339
Branch: feat/validate-in-network-runner
Labels: type::chore, priority::medium, service::xtask, program::infrastructure, workflow::ready

Context

ADR-015 specifies that integration tests requiring PostgreSQL run inside the docker network where canopy-net already routes traffic between services. Today cargo xtask validate runs on the host; PG-touching tests need a host-local postgres reachable on localhost:5432. Contributors without host postgres get spurious failures on tests that the devstack postgres would happily serve. ADR-015’s resolution path was the in-network runner — never built.

This plan ships it as an opt-in (cargo xtask validate-in-network) so the pre-push hook stays fast on contributors who do have host postgres while contributors who don’t get a path that just works.

Code references

  • xtask/src/cmd/validate.rs — host-side validate that this plan wraps in a container.

  • Dockerfile:1-69 — build pattern precedent.

  • docker-compose.yml — canopy-net network definition.

  • xtask/src/devstack_guard.rs — devstack health-check helpers.

  • ADR-015 — Containerized integration tests

Scope

In scope:

  • Dockerfile.validate-runner image build.

  • cargo xtask validate-in-network subcommand.

  • Optional --with-devstack boot helper.

  • Manual GitLab CI job exercising the path.

  • Contributor docs.

Out of scope:

  • Replacing the host-side cargo xtask validate as the pre-push gate. This plan is additive; default flow is unchanged.

  • Fully cached image distribution (e.g., publishing to a registry) — image builds on demand from the local Dockerfile.validate-runner. Caching is up to Docker’s local layer cache.

  • Cross-platform support beyond Linux + macOS. Windows is out of scope until a contributor surfaces a need.

Dependencies

  • devstack health-check helpers (xtask/src/devstack_guard.rs) already exist.

  • canopy-net network already exists.

  • No prerequisite plans.

Design

xtask/src/cmd/validate_in_network.rs sketch:

pub async fn run(opts: ValidateInNetworkOpts) -> Result<()> {
    if opts.with_devstack {
        ensure_devstack_up().await?;
    } else {
        check_devstack_running()?;
    }

    let image = build_runner_image()?;
    let workspace = std::env::current_dir()?;

    let status = std::process::Command::new("docker")
        .args([
            "run", "--rm",
            "--network", "canopy-net",
            "-v", &format!("{}:/work", workspace.display()),
            "-w", "/work",
            "-e", "CANOPY_TEST_DATABASE_URL=postgres://canopy:canopy@postgres:5432/canopy_test",
            // …pass-through any other env the validate path needs…
            &image,
            "cargo", "xtask", "validate",
        ])
        .status()?;

    if !status.success() {
        anyhow::bail!("in-network validate failed");
    }
    Ok(())
}

Dockerfile.validate-runner:

FROM rust:1-bookworm

RUN apt-get update && apt-get install -y --no-install-recommends \
    postgresql-client git pkg-config libssl-dev \
    && rm -rf /var/lib/apt/lists/*

RUN cargo install sqlx-cli --no-default-features --features postgres,rustls

WORKDIR /work
ENTRYPOINT ["cargo"]

Image build is on-demand; first run is slow, subsequent runs hit the local Docker layer cache.

Files Touched

File Change

xtask/Dockerfile.validate-runner

New file

xtask/src/cmd/validate_in_network.rs

New file

xtask/src/cmd/mod.rs

Register the new command

xtask/src/main.rs

Add the CLI subcommand wiring

.gitlab-ci.yml

Optional manual job calling cargo xtask validate-in-network

docs/modules/ROOT/pages/contributors/validate-in-network.adoc

New contributor doc

docs/modules/ROOT/pages/local-dev.adoc

Cross-link

CHANGELOG.adoc

=== Added entry

Verification

  1. cargo xtask validate-in-network --with-devstack on a host with no local postgres → command succeeds.

  2. cargo xtask validate-in-network on a host with devstack already up → command succeeds without rebooting devstack.

  3. cargo xtask validate-in-network on a host with devstack down → command exits with a clear message pointing at --with-devstack.

  4. CI manual job, when triggered, completes green on a known-good commit.

  5. cargo xtask validate (the host path) still works exactly as before.

Documentation Updates

  • docs/modules/ROOT/pages/contributors/validate-in-network.adoc — new page

  • docs/modules/ROOT/pages/local-dev.adoc — cross-link

  • CHANGELOG.adoc — entry under == Unreleased / === Added

  • Plan archive: move to plans/archive/ post-merge

Edit this page · default