Skip to content

feat(automations): add tags to automations #5643

feat(automations): add tags to automations

feat(automations): add tags to automations #5643

Workflow file for this run

name: CI
# The single CI workflow: Linux Rust + web/pnpm + macOS/VZ + the e2e
# stack all live here (the old ci-macos-vz.yml was folded in).
#
# Surfaces this workflow exercises:
# - lint: cargo fmt --check, cargo clippy -D warnings,
# cargo check workspace
# - test-linux: cargo nextest workspace tests, plus
# Postgres-gated ignored tests (ha_listener,
# snapshot_disk_manifest_persistence) against
# the postgres service container, plus the
# GCS-emulator round-trip via fake-gcs-server
# - cross-musl: cross-compile engram-agentd + the harness
# wrappers to x86_64-unknown-linux-musl
# (catches breakage of the FC image bake chain).
# engram-bootstrap was collapsed into
# engram-agentd by ADR 0015 M1 (`75ba2df`).
# - test-fc-*: every `#[ignore]`'d FC integration test under
# nested virt, split across four parallel KVM
# jobs (unprivileged / pooled host-agent /
# root / true-e2e) that share setup
# via .github/actions/fc-setup. See the block
# comment above the jobs for the batch split.
# - web: pnpm install + oxfmt + oxlint + tsc +
# vite build + vitest
# - bake-demo-image: push-to-main only. ADR 0080: a plain
# `docker build && docker push` of deploy/demo
# to `ghcr.io/cortexapps/engrams/demo:warm-<sha>`
# (+ :main / :latest aliases). The coordinator
# materializes the rootfs host-side at enable —
# no bake CLI, no agentd/ttyd injection.
# - artifacts-e2e-stack: release-builds engram-coordinator +
# engram-host-agent + musl engram-agentd ONCE
# and uploads as a workflow artifact. Consumed
# by `test-e2e-stack` so the e2e lane doesn't
# pay the compile cost again. The `engrams`
# CLI (crates/engram-cli) is built here too and
# the e2e job runs that binary.
# - test-e2e-stack: true end-to-end against the prod-shape
# stack: real coord HTTP API + real gRPC + real
# host-agent + real Firecracker + real chunked
# OCI via fake-gcs + real local registry +
# published Claude harness pack. Runs three
# flows: cold session with harness=none + exec
# ls; cold session with harness=claude + exec
# ls; cold session with harness=claude + bogus
# API key + prompt → assert auth failure event.
# Closes the gap that let prod session
# 8725648d's empty-Binary-frame bug ship (all
# existing FC tests bypass the coord HTTP path).
#
# All jobs run on Blacksmith Linux runners
# (https://docs.blacksmith.sh/blacksmith-runners/overview) — faster
# CPUs + nested-virt support across the whole matrix, not just the FC
# job. Tier sizing is per-job (2vcpu for cheap stuff, 4vcpu for
# Postgres/test runs and KVM workloads).
on:
push:
branches: [main]
# No base-branch filter: STACKED PRs (base = another feature branch)
# must run the same checks — with the old `branches: [main]` filter
# they triggered no run at all, leaving the ruleset's required
# contexts "waiting for status to be reported" until a base retarget
# (whose late-fired run then built a racy stale merge ref).
pull_request:
# GitHub Merge Queue fires `merge_group` events for the temporary
# ref it builds out of (current main + queued PRs combined). Branch
# protection blocks the queue from completing until every required
# check passes against THIS ref, which is what guarantees main's
# HEAD was CI'd against the exact tree being merged.
merge_group:
branches: [main]
workflow_dispatch: {}
# Cancel an in-progress PR run when a new push lands on the same
# branch — saves runner minutes during fix-and-rerun cycles. Pushes
# to `main` are *not* cancelled (we want a CI record per merged
# commit, even on rapid back-to-back merges).
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
# Default to read-only repo access. No job here writes to the repo
# (no GH releases, no commit-back, no PR comments), so least
# privilege. `packages: read` is load-bearing: the test-fc-* jobs
# oras-pull the forked firecracker artifact from GHCR — without
# it the pull is DENIED and every fork-gated FC test (the ADR 0045 R2
# stock<->fork compat gate, the substrate suites, vmstate_only)
# silently green-by-skips.
permissions:
contents: read
packages: read
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
SQLX_OFFLINE: "true"
# Single source of truth for the built-in claude harness artifact's
# tag (ADR 0062 — the artifact rides the host bundle stamp, not the
# image). Used by:
# - `bake-harness-claude-artifact` (publishes to GHCR on
# push-to-main; uploads as workflow artifact on every run)
# - `test-e2e-stack` (downloads the artifact, unpacks it into
# ENGRAM_HARNESS_CLAUDE_TREE for the bundle stamp)
HARNESS_VERSION: v0.1.0
HARNESS_PLATFORM: linux-x86_64
jobs:
# Change-detection for the expensive e2e lane. Reuses the
# same cargo-dep-closure detector as bake-images.yml so "any crate in
# the e2e binaries' release closure" is expressed precisely (a glob
# filter can't). The e2e jobs consume the aggregate gate plus a selective
# PR matrix; the other outputs are emitted for free. Push-to-main and
# merge_group always run the full matrix (see the job's `if:` and matrix).
detect:
name: detect changed lanes
runs-on: blacksmith-2vcpu-ubuntu-2404
outputs:
e2e: ${{ steps.lanes.outputs.e2e }}
e2e_matrix: ${{ steps.lanes.outputs.e2e_matrix }}
e2e_full_matrix: ${{ steps.lanes.outputs.e2e_full_matrix }}
# PR test lanes — each gates the matching job below. A CI-workflow or
# detector change sets all of these (see detect-rebake-lanes.py), so a
# change to how CI runs re-runs everything.
test_rust: ${{ steps.lanes.outputs.test_rust }}
test_cross: ${{ steps.lanes.outputs.test_cross }}
test_fc: ${{ steps.lanes.outputs.test_fc }}
test_web: ${{ steps.lanes.outputs.test_web }}
test_orchestrator: ${{ steps.lanes.outputs.test_orchestrator }}
test_cosim: ${{ steps.lanes.outputs.test_cosim }}
test_buf: ${{ steps.lanes.outputs.test_buf }}
test_integrations_cli: ${{ steps.lanes.outputs.test_integrations_cli }}
test_deploy: ${{ steps.lanes.outputs.test_deploy }}
test_site: ${{ steps.lanes.outputs.test_site }}
# The container-image lane. The detector has always computed these; until
# now nothing on a PR consumed them, so a Dockerfile-only change ran no
# lane at all and the gate passed on an unbuilt image.
images: ${{ steps.lanes.outputs.images }}
dockerfiles: ${{ steps.lanes.outputs.dockerfiles }}
images_matrix: ${{ steps.lanes.outputs.images_matrix }}
steps:
- uses: actions/checkout@v7
with:
# Full history so the PR base SHA is present for the diff.
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- name: Detect changed lanes
id: lanes
run: |
# PRs diff against the base SHA (an ancestor of the checked-out
# merge commit under fetch-depth:0). Other events (merge_group,
# push) fall back to HEAD^! — the squashed change set of the commit.
BASE=""
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE="${{ github.event.pull_request.base.sha }}"
fi
python3 .github/scripts/detect-rebake-lanes.py --base "$BASE" --head HEAD
# `build-images` is gated on `images`/`images_matrix`. If either output is
# renamed the job silently stops running and a Dockerfile change is
# unvalidated again — the exact hole this PR closes, reopened quietly.
#
# Assert the GITHUB_OUTPUT keys, NOT the human-readable stderr line. The
# detector emits the contract twice and the two forms differ: stderr
# prints the Python repr (`images=True`, `['web']`) while the real output
# is `images=true` and JSON `["web"]`. Grepping stderr would keep this
# step green through exactly the rename it exists to catch.
#
# GITHUB_OUTPUT is overridden for this one command so the job's own
# output file is untouched.
- name: Detector still emits the images lane contract
run: |
env GITHUB_OUTPUT=/tmp/lanes.env python3 \
.github/scripts/detect-rebake-lanes.py --stdin \
<<< 'docker/web.Dockerfile'
grep -qxF 'images=true' /tmp/lanes.env
grep -qxF 'dockerfiles=true' /tmp/lanes.env
grep -qxF 'images_matrix=["web"]' /tmp/lanes.env
# ...and a NON-Dockerfile change must not trigger the image build.
env GITHUB_OUTPUT=/tmp/lanes-rs.env python3 \
.github/scripts/detect-rebake-lanes.py --stdin <<< 'Cargo.lock'
grep -qxF 'dockerfiles=false' /tmp/lanes-rs.env
# The site lane fires on its own tree and stays quiet otherwise.
grep -qxF 'test_site=false' /tmp/lanes-rs.env
env GITHUB_OUTPUT=/tmp/lanes-site.env python3 \
.github/scripts/detect-rebake-lanes.py --stdin <<< 'site/package.json'
grep -qxF 'test_site=true' /tmp/lanes-site.env
grep -qxF 'test_web=false' /tmp/lanes-site.env
# ADR 0122: the deploy templates are user-facing product surface once
# the repo is open source — a broken chart or module is a broken
# install for someone we never meet. Lint + render every chart with
# every shipped overlay (REPLACE_* placeholders stubbed), and
# fmt/validate every terraform root. Path-gated on deploy/terraform +
# deploy/helm via the detector's test_deploy flag.
deploy-config:
name: terraform + helm
needs: detect
if: needs.detect.outputs.test_deploy == 'true'
runs-on: blacksmith-2vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v7
# The Blacksmith runner image ships helm but not terraform.
- uses: hashicorp/setup-terraform@v4
with:
terraform_wrapper: false
- name: Tool versions
run: |
helm version
terraform version
# The charts fail-fast on required deployment values by design
# (bucket, KMS resource, CA secret paths), so bare defaults never
# render. Each chart ships `ci/render-values.yaml` — the minimum
# stub set that satisfies its required-value guards — and every
# shipped overlay renders LAYERED on it, the way a user's
# filled-in copy sits on their base values.
- name: helm lint + template (ci render values)
run: |
set -euo pipefail
for chart in deploy/helm/*/; do
[ -f "$chart/Chart.yaml" ] || continue
echo "==> lint $chart"
helm lint "$chart" -f "$chart/ci/render-values.yaml"
echo "==> template $chart (ci render values)"
helm template test-release "$chart" \
-f "$chart/ci/render-values.yaml" > /dev/null
done
- name: helm template (every shipped overlay, placeholders stubbed)
run: |
set -euo pipefail
for chart in deploy/helm/*/; do
[ -f "$chart/Chart.yaml" ] || continue
for overlay in "$chart"values-*.yaml.example; do
[ -e "$overlay" ] || continue
stub="$(mktemp)"
# REPLACE_* placeholders become syntactically valid stub
# values so the overlay renders as a user's filled-in copy
# would. `stub` is safe for every current placeholder kind
# (bucket, project, region, domain, resource path, IP).
sed -E 's/REPLACE_[A-Z_]+/stub/g' "$overlay" > "$stub"
echo "==> template $chart with $(basename "$overlay")"
helm template test-release "$chart" \
-f "$chart/ci/render-values.yaml" -f "$stub" > /dev/null
done
done
# Node prep's disk scheduler script against constructed sysfs trees,
# and the chart default that turns it on.
- name: host-fleet io scheduler
run: |
set -euo pipefail
chart=deploy/helm/engram-host-fleet
sh "$chart/ci/io-scheduler-test.sh"
helm template test-release "$chart" -f "$chart/ci/render-values.yaml" \
| grep -q 'IO_SCHEDULER="none"'
if helm template test-release "$chart" -f "$chart/ci/render-values.yaml" \
--set storage.ioScheduler= | grep -q 'io-scheduler'; then
echo "storage.ioScheduler=\"\" still renders the io-scheduler step" >&2
exit 1
fi
- name: terraform fmt -check
run: terraform fmt -check -recursive -diff deploy/terraform
- name: terraform validate (every root)
run: |
set -euo pipefail
# Every directory holding .tf files validates standalone —
# modules included, since each is a BYO-cluster composition
# unit for OSS users, not just an internal include.
find deploy/terraform -name '*.tf' -not -path '*/.terraform/*' \
| xargs -n1 dirname | sort -u | while read -r dir; do
echo "==> validate $dir"
terraform -chdir="$dir" init -backend=false -input=false > /dev/null
terraform -chdir="$dir" validate -no-color
done
integrations-cli:
name: integrations CLI bundle
needs: detect
if: needs.detect.outputs.test_integrations_cli == 'true'
runs-on: blacksmith-2vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- name: Install build dependencies
run: sudo apt-get update -qq && sudo apt-get install -y -qq protobuf-compiler
- name: Build and start the bundle
run: |
python3 -m unittest discover \
-s deploy/bundles/integrations-cli/tests -p 'test_*.py'
deploy/bundles/integrations-cli/build.sh --stage var/integrations-cli
config_dir="$(mktemp -d)"
trap 'rm -rf "$config_dir"' EXIT
CLOUDSDK_CONFIG="$config_dir" var/integrations-cli/bin/gcloud --version
test "$(CLOUDSDK_CONFIG="$config_dir" var/integrations-cli/bin/gcloud \
config get core/custom_ca_certs_file)" = \
"/etc/ssl/certs/ca-certificates.crt"
- name: Verify metadata ADC with the bundled gcloud
run: |
export PATH="$PWD/var/integrations-cli/bin:$PATH"
cargo test -p engram-egress-proxy \
guest_gateway::tests::installed_gcloud_can_use_the_metadata_endpoint_as_adc \
-- --exact
lint:
name: fmt + clippy + check
needs: detect
if: needs.detect.outputs.test_rust == 'true'
runs-on: blacksmith-2vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
# ADR 0013: `engram-protocol/build.rs` invokes `protoc` to
# compile `proto/host_service.proto` into Rust bindings.
# `arduino/setup-protoc` pulls a recent protoc release from
# https://github.com/protocolbuffers/protobuf/releases and
# puts it on PATH. Cross-platform (Linux + macOS) so every
# workflow that touches Rust uses the same step.
# Install protoc via apt: arduino/setup-protoc@v3 with a pinned
# version *still* called the GH releases API to validate and
# 401'd with "Bad credentials" on a not-rare-enough fraction
# of runs. Ubuntu 24.04's protobuf-compiler ships 3.21.12,
# well above tonic-build/prost-build's minimum, and `apt`
# never hits the GH API — deterministic, ~2s.
- name: Install protoc
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq --no-install-recommends protobuf-compiler
protoc --version
# Parallel linker — installs a prebuilt mold release (~1–2s)
# and (with the action's default `make-default: true`) points
# /usr/bin/ld at it so cargo's default cc→ld chain picks it up
# transparently. Cuts incremental link time 3–10× on this
# multi-binary workspace, net positive after install overhead.
# Skipped on cross-musl-linux (musl-gcc has its own bundled
# ld) and on test-e2e-stack (downloads prebuilt binaries, no
# native link step happens).
- name: Setup mold linker
uses: rui314/setup-mold@v1
- uses: Swatinem/rust-cache@v2
with:
# Shared with test-linux + test-e2e-stack: all three build
# the workspace's debug profile, so cargo's `target/debug/`
# contents (deps + workspace artifacts) populate the same
# cache bucket and each subsequent job sees prior deps as
# already-compiled.
shared-key: workspace-debug
# Install cargo-hakari from a prebuilt release (~1s) so we can
# `cargo hakari generate --diff` below. The dev shell pulls this from
# nixpkgs; CI uses taiki-e/install-action to avoid a slow
# `cargo install` from source.
- name: Install cargo-hakari
uses: taiki-e/install-action@v2
with:
tool: cargo-hakari
# `if: always()` so each gate runs regardless of which earlier
# step failed — surfaces fmt + clippy + check failures together
# in one CI run instead of forcing a fix-and-rerun loop. The job
# still ends red if any step fails (the workflow conclusion is
# the worst step's conclusion).
- name: cargo fmt --all -- --check
if: always()
run: cargo fmt --all -- --check
- name: cargo clippy --workspace --all-targets -- -D warnings
if: always()
run: cargo clippy --workspace --all-targets -- -D warnings
- name: cargo check --workspace --all-targets
if: always()
run: cargo check --workspace --all-targets
# Catch dep additions that didn't regenerate workspace-hack, AND
# any hand edit to it. Run `just hakari` locally and commit
# `workspace-hack/Cargo.toml` if this fails.
#
# `generate --diff` rather than `verify`: verify only asks whether
# the pins are SUFFICIENT to unify features, so an edit that adds a
# version nothing consumes sails through it. That is not
# hypothetical — `workspace-hack/Cargo.toml` is a workspace member,
# so Dependabot reads it as a manifest and opens bumps against the
# generated pins. #1075 landed one (der 0.7.10 -> 0.8.1; der is not
# a direct dependency anywhere) and left main carrying an
# unconsumed der 0.8.1 + pem-rfc7468 1.0.0 in the lockfile with
# every lane green. `generate --diff` exits 1 unless the file is
# exactly what `cargo hakari generate` emits, which is the only
# correct content for a generated file — and it subsumes verify,
# since generate's own output always verifies.
- name: cargo hakari generate --diff
if: always()
run: cargo hakari generate --diff
# ADR 0122: the AWS SDK rides the workspace's single rustls
# CryptoProvider (ring). `aws-lc-rs` in the tree means some crate
# (re)enabled an SDK default HTTPS client — a second compiled
# provider that panics rustls at first TLS use and a cmake+nasm C
# build the musl cross lane cannot carry. Catch it as a
# deterministic lint failure instead of a runtime panic. Fix:
# `default-features = false` on the offending aws crate; TLS comes
# only from aws-smithy-http-client's `rustls-ring` (engram-aws).
- name: forbid aws-lc in the dependency tree
if: always()
run: |
if grep -q 'name = "aws-lc' Cargo.lock; then
echo '::error::aws-lc entered Cargo.lock — an aws-* crate enabled a default HTTPS client. See the aws sdk note in the root manifest.' >&2
grep -B1 -A2 'name = "aws-lc' Cargo.lock >&2
exit 1
fi
test-linux:
name: tests (linux)
needs: detect
if: needs.detect.outputs.test_rust == 'true'
runs-on: blacksmith-4vcpu-ubuntu-2404
env:
DATABASE_URL: postgres://postgres:engram@localhost:5432/engram_test
# Admin URL for the Postgres-gated `#[ignore]`'d tests. ADR 0099 H1:
# engram-testkit clones every test its OWN database off this URL
# (template-cloned, pre-migrated), so a bare Postgres is fine — the
# role just needs CREATEDB (the `postgres` superuser here).
ENGRAM_TEST_DATABASE_URL: postgres://postgres:engram@localhost:5432/engram_test
# ADR 0007: the GCS round-trip test in engram-storage-gcs is
# gated on these env vars (so it no-ops on hosts without the
# emulator). Setting them at the job level so every nextest
# invocation in this job exercises the real SDK→emulator path.
# The chunk store backs onto the same BlobStorage impl, so
# this also covers the chunked-storage primitive end-to-end.
STORAGE_EMULATOR_HOST: http://localhost:4443
ENGRAM_TEST_GCS_BUCKET: engram-snapshots-test
# ADR 0122: the S3 conformance + chunk-store e2e tests are gated
# the same way, against MinIO. Static credentials so the SDK's
# default chain never probes the IMDS address from CI.
ENGRAM_TEST_S3_ENDPOINT: http://localhost:9000
ENGRAM_TEST_S3_BUCKET: engram-snapshots-test
AWS_ACCESS_KEY_ID: minioadmin
AWS_SECRET_ACCESS_KEY: minioadmin
AWS_REGION: us-east-1
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
# Install protoc via apt: arduino/setup-protoc@v3 with a pinned
# version *still* called the GH releases API to validate and
# 401'd with "Bad credentials" on a not-rare-enough fraction
# of runs. Ubuntu 24.04's protobuf-compiler ships 3.21.12,
# well above tonic-build/prost-build's minimum, and `apt`
# never hits the GH API — deterministic, ~2s.
- name: Install protoc
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq --no-install-recommends protobuf-compiler
protoc --version
- name: Setup mold linker
uses: rui314/setup-mold@v1
- uses: Swatinem/rust-cache@v2
with:
# Shared with lint + test-e2e-stack — see lint's cache step
# for the rationale (debug-profile workspace dep graph).
shared-key: workspace-debug
- name: Install nextest
uses: taiki-e/install-action@nextest
# Postgres via plain `docker run` rather than `services:` for the
# same reason as fake-gcs-server below: service containers can't
# override the image's CMD, and the Postgres-gated lane runs deeply
# parallel (ADR 0099 H2) — each test's PostgresStore holds up to an
# 8-connection pool, so 16 concurrent tests need headroom over the
# stock max_connections=100.
- name: Start postgres
run: |
docker run -d --name engram-test-pg \
-e POSTGRES_PASSWORD=engram \
-e POSTGRES_DB=engram_test \
-p 5432:5432 \
postgres:16 \
-c max_connections=300
# -h 127.0.0.1 forces TCP: initdb's temporary bootstrap server
# listens on the unix socket only, so a socket-based pg_isready
# can report ready before the real server is up.
for _ in $(seq 1 30); do
docker exec engram-test-pg pg_isready -h 127.0.0.1 -U postgres && break
sleep 1
done
docker exec engram-test-pg pg_isready -h 127.0.0.1 -U postgres
# GCS emulator for the cold-tier round-trip test. We can't use
# `services:` here because github actions service containers
# don't let us override the image's CMD — fake-gcs-server's
# default uses HTTPS + a host we can't reach. Plain `docker run`
# gives us the full CLI surface; mirrors what
# `deploy/docker-compose.dev.yml` runs locally.
- name: Start fake-gcs-server
run: |
docker run -d --name fake-gcs-server \
-p 4443:4443 \
fsouza/fake-gcs-server:1.54.0 \
-scheme http -host 0.0.0.0 -port 4443 \
-public-host localhost:4443
# S3 emulator for the ADR 0122 conformance + chunk-store e2e
# tests. Same plain-`docker run` rationale as fake-gcs above;
# mirrors the `local-s3` profile in deploy/docker-compose.dev.yml.
- name: Start minio
run: |
docker run -d --name minio \
-p 9000:9000 \
minio/minio:RELEASE.2025-09-07T16-13-09Z server /data
# Wait for the emulators to come up + seed the test buckets
# (fake-gcs AND minio — the script covers both). Runs the same
# script as local dev so the two paths share one source of truth.
- name: Seed blob test buckets
run: bash deploy/dev/seed-buckets.sh
# ADR 0055 P2: mksquashfs for the engram-coordinator `skill_pack`
# determinism test (it self-skips without the tool — install it so
# the test actually RUNS in this lane). ADR 0093 retired the
# mke2fs/e2fsprogs setup that used to sit here: ext4 packing is
# pure Rust (mkext4).
- name: Install squashfs-tools
run: sudo apt-get install -y -qq --no-install-recommends squashfs-tools
# Default (non-ignored) tests across the entire workspace. Mirrors
# `just check`'s nextest pass — same speedup, same coverage. The
# GCS-emulator round-trip uses STORAGE_EMULATOR_HOST set above.
#
# `--no-fail-fast` reports every failing test instead of stopping
# at the first; `if: always()` keeps the ha_listener steps below
# running even if this one fails.
- name: cargo nextest run --workspace
if: always()
run: cargo nextest run --workspace --no-fail-fast
# Postgres-gated ignored tests — the FC `#[ignore]` set needs KVM
# so we don't try to run them here. Scoping by `--test` keeps us
# from accidentally tripping firecracker tests that share the
# `#[ignore]` bucket.
#
# ADR 0099 H2: every test clones its own database via
# engram-testkit (NOTIFY is per-database, so the old ha_listener
# cross-talk that forced `--test-threads=1` is structurally
# impossible). The tests are PG-IO-bound, so oversubscribe the
# 4 vcpus: 16 threads × worst-case ~17 connections per test
# (8-conn store pool + admin conn + a second pool in a few tests)
# stays under the max_connections=300 the `Start postgres` step
# provisions.
- name: Postgres-gated ignored tests
if: always()
run: |
cargo nextest run \
-p engram-coordinator \
--test ha_listener \
--test snapshot_disk_manifest_persistence \
--test chunk_gc_helpers_live_pg \
--test bundle_gc_live_pg \
--test snapshot_blob_gc_live_pg \
--test admin_chunk_gc_live_pg \
--test admin_evac_live_pg \
--test teleport_live_pg \
--test eviction_live_pg \
--test checkpoint_reconcile_live_pg \
--test enable_jobs_live_pg \
--test capture_jobs_live_pg \
--test claim_cold_base_live_pg \
--test enable_reuse_live_pg \
--test placement_reservation_live_pg \
--test host_register_live_pg \
--test host_status_transition_live_pg \
--test queue_scanner_live_pg \
--test binding_cas_live_pg \
--test sandbox_owner_live_pg \
--test outbox_live_pg \
--test session_ops_live_pg \
--test mount_catalog_live_pg \
--run-ignored ignored-only \
--no-fail-fast \
--test-threads=16
# ADR 0098 D4: the SimMetadataStore conformance suite's live-PG
# half. Every scenario runs against BOTH the in-memory sim store
# (normal workspace lane) and a real template-cloned database
# (here) — the defense against sim-fidelity drift. Same admin URL
# + per-test isolation as the step above.
- name: SimMetadataStore conformance (PG half)
if: always()
run: |
cargo nextest run \
-p engram-sim \
--run-ignored ignored-only \
--no-fail-fast \
--test-threads=16
# Relocated from the KVM lane (ADR 0098: keep the FC lane minimal —
# one test per kernel assumption). probe_sandbox_desync needs only
# `/proc` + the on-disk sandbox manifest: it constructs the
# map-vs-process desync with a plain process, no KVM, no firecracker
# binary (its module docs spell this out). Runs here so every
# Rust-touching PR exercises it, not just the FC dep closure.
- name: FC probe_sandbox desync tests (no KVM)
if: always()
run: |
cargo nextest run \
-p engram-sandbox-firecracker \
--test probe_sandbox_desync \
--run-ignored ignored-only \
--no-fail-fast
# Relocated from the KVM lane for the same reason: host_startup
# asserts iptables RULE ORDERING — it needs CAP_NET_ADMIN (sudo),
# not /dev/kvm. LAST in the job on purpose: it applies and removes
# real netfilter rules (each test brackets itself with cleanup()),
# and the docker-backed postgres/fake-gcs containers above ride
# this host's iptables — nothing else may run concurrently with it.
- name: FC host_startup iptables tests (root, no KVM)
if: always()
run: |
sudo -E env "PATH=$PATH" cargo nextest run \
-p engram-sandbox-firecracker \
--test host_startup \
--run-ignored ignored-only \
--no-fail-fast \
--test-threads=1
- name: Restore ownership after sudo tests
if: always()
run: |
sudo chown -R "$USER":"$USER" target/ ~/.cargo 2>/dev/null || true
cross-musl-linux:
name: cross-compile linux-musl artifacts
needs: detect
if: needs.detect.outputs.test_cross == 'true'
runs-on: blacksmith-2vcpu-ubuntu-2404
# Job-level (not step-scoped): any crate in this lane can pull in a
# transitive C dependency that needs the kernel UAPI headers against
# the musl sysroot (userfaultfd-sys's build-script shim #includes
# <linux/types.h>, absent from musl-gcc's own sysroot). ADR 0068 added
# `userfaultfd` to engram-host-agent too (ProbeSandbox's UFFD MINOR
# self-test) — step-scoping this only onto engram-uffd-handler left
# the host-agent musl build with CFLAGS=None and it failed the same
# way uffd-handler used to.
env:
CFLAGS_x86_64_unknown_linux_musl: "-idirafter /opt/uapi"
BINDGEN_EXTRA_CLANG_ARGS: "-idirafter /opt/uapi"
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-musl
# Install protoc via apt: arduino/setup-protoc@v3 with a pinned
# version *still* called the GH releases API to validate and
# 401'd with "Bad credentials" on a not-rare-enough fraction
# of runs. Ubuntu 24.04's protobuf-compiler ships 3.21.12,
# well above tonic-build/prost-build's minimum, and `apt`
# never hits the GH API — deterministic, ~2s.
- name: Install protoc
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq --no-install-recommends protobuf-compiler
protoc --version
- uses: Swatinem/rust-cache@v2
- name: Install musl-tools + kernel uapi headers
# linux-libc-dev: uffd-handler's transitive userfaultfd-sys build
# script compiles a C shim that #includes <linux/types.h>, absent
# from the musl cross-gcc sysroot.
run: |
sudo apt-get update && sudo apt-get install -y musl-tools linux-libc-dev
# Adversarial finding from the #663 rollout: injecting ALL of
# /usr/include poisons any real vendored-C build (zstd-sys) with
# glibc headers under a musl target. The shim only needs the
# KERNEL UAPI headers, which are libc-agnostic — stage exactly
# those in a scoped dir and reference it with -idirafter, so the
# musl sysroot's own headers always win and only genuinely
# missing ones (linux/*, asm*/*) fall through.
sudo mkdir -p /opt/uapi
sudo cp -r /usr/include/linux /usr/include/asm-generic /opt/uapi/
sudo cp -r /usr/include/x86_64-linux-gnu/asm /opt/uapi/asm
# Mirrors what `just bake-demo` produces on Linux. If any of these
# stop building the demo bake
# path is broken even when the host-target workspace check is
# green.
- name: build agentd (musl)
run: |
cargo build \
--target x86_64-unknown-linux-musl \
--release \
-p engram-agentd
- name: build harness wrappers (musl)
run: |
cargo build \
--target x86_64-unknown-linux-musl \
--release \
-p engram-harness-noop \
-p engram-harness-claude
# The FC host image bake (private deploy repo's
# bake-fc-host-image workflow) ships this binary into the GCE
# image. Without this lane, musl regressions in host-agent
# only surface during a bake, which is too late. `libc::Ioctl`
# has a different width on musl (`c_int`) vs glibc (`c_ulong`)
# so anything passing raw `u64` ioctl numbers won't catch this
# on the gnu workspace check.
- name: build engram-host-agent (musl)
run: |
cargo build \
--target x86_64-unknown-linux-musl \
--release \
-p engram-host-agent
# uffd-handler also ships into the FC host image (ADR 0020 Route B),
# so guard its musl build here too. userfaultfd-sys's C shim needs the
# kernel uapi headers pointed at via CFLAGS/bindgen (libc-agnostic, so
# safe to mix with the musl sysroot) — set at the job level above so
# every step in this lane gets it, not just this one.
- name: build engram-uffd-handler (musl)
run: |
cargo build \
--target x86_64-unknown-linux-musl \
--release \
-p engram-uffd-handler
web:
name: web (pnpm)
needs: detect
if: needs.detect.outputs.test_web == 'true'
runs-on: blacksmith-2vcpu-ubuntu-2404
defaults:
run:
working-directory: web
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
with:
version: 9
# Node 26 ("Lithium") is the newest Active LTS line: LTS since
# 2026-10-28, maintenance 2027-10-20, EOL 2029-04-30. Node 26 is the
# last release under the two-per-year model; from Node 27 every annual
# major becomes LTS (no odd/even distinction). Node 24 moved to
# Maintenance LTS on 2026-10-20.
#
# This major is pinned in FIVE places that must move together:
# - here (the web lane)
# - the site lane below (same `setup-node` version)
# - .github/workflows/site-deploy.yml
# - docker/web.Dockerfile (`FROM node:<major>-alpine`)
# - flake.nix (`nodejs_<major>`, the `nix develop` shell)
# They had drifted to 20 / 24 / 22 respectively; Node 20 went EOL
# 2026-04-30, so CI was building on an unsupported runtime.
- uses: actions/setup-node@v7
with:
node-version: 26
cache: pnpm
cache-dependency-path: web/pnpm-lock.yaml
- name: pnpm install
run: pnpm install --frozen-lockfile
- name: pnpm format check (oxfmt)
run: pnpm format:check
# oxlint over src/. Fast (Rust-based) static gate; runs before the
# build so lint failures surface without waiting on tsc + vite.
- name: pnpm lint (oxlint)
run: pnpm lint
# `pnpm build` runs `tsc -b && vite build` — gives us typecheck
# AND production bundle validation in one step.
- name: pnpm build (tsc -b + vite build)
run: pnpm build
# Vitest. Currently exercises TerminalPane mount/unmount/remount
# ordering against a mocked ghostty-web; expand as more components
# gain regression tests.
- name: pnpm test (vitest)
run: pnpm test
- name: Install Chromium for renderer policy test
run: pnpm exec playwright install chromium --with-deps
- name: D2 production CSP and renderer browser test
run: pnpm test:browser
# The public docs + landing site (site/: Astro + Starlight). Build-only —
# site-deploy.yml publishes it to GitHub Pages on push to main. The leak
# lint runs first: the site must never mention internal decision records,
# repos, or hosts, and its prose must pass the style denylist. Gated on the
# detector's test_site flag (site/ only).
site:
name: site (leak lint + astro build)
needs: detect
if: needs.detect.outputs.test_site == 'true'
runs-on: blacksmith-2vcpu-ubuntu-2404
defaults:
run:
working-directory: site
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
with:
version: 9
- uses: actions/setup-node@v7
with:
node-version: 26
cache: pnpm
cache-dependency-path: site/pnpm-lock.yaml
- name: pnpm install
run: pnpm install --frozen-lockfile
- name: pnpm lint (leak + style denylist)
run: pnpm lint
# astro check + astro build in the public project-page mode; the deploy
# workflow derives the real origin and base from actions/configure-pages,
# so this pair only needs to be *a* valid mode.
- name: pnpm build (astro check + astro build)
run: pnpm build
env:
SITE_URL: https://cortexapps.github.io
BASE_PATH: /engrams
# ADR 0051 Task 14: the orchestration tier (Bun/Hono). install + tsc
# --noEmit + bun test. A Postgres service backs (a) the live DB-gated tests
# (db.test.ts etc., which self-skip without a reachable ORCHESTRATOR_DATABASE_URL)
# and (b) the ADR 0060 DBOS engine — DBOS keeps its system tables in a `dbos`
# schema of this same database. The .live smoke test still self-skips without a
# live coordinator.
orchestrator:
name: orchestrator (bun)
needs: detect
if: needs.detect.outputs.test_orchestrator == 'true'
runs-on: blacksmith-2vcpu-ubuntu-2404
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: engram
POSTGRES_DB: engram_orchestrator_test
ports: ["5432:5432"]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
defaults:
run:
working-directory: orchestrator
env:
# Required by loadConfig(); tests override per-test via process.env
# assignments, but the module-level `config` singleton reads this at
# import time. A dummy value is fine for CI unit tests.
CONTROL_PLANE_BEARER: ci-test-token
# Reachable Postgres → the DB-gated tests + the DBOS smoke test run here
# (instead of self-skipping). `bun run migrate` below applies the Drizzle
# schema before the suite; DBOS creates its own `dbos` schema on launch.
ORCHESTRATOR_DATABASE_URL: postgres://postgres:engram@localhost:5432/engram_orchestrator_test
steps:
- uses: actions/checkout@v7
- uses: oven-sh/setup-bun@v2
with:
# `.bun-version` is the ONE place the runtime version lives; the
# orchestrator Dockerfile pins the same value and the drift guard
# below fails the build if they disagree. CI used to hardcode 1.3.14
# while the image floated on `oven/bun:1`, so prod ran a Bun the
# tests never saw — which is how a 1.4.0 change to native
# `server.upgrade()` broke every WebSocket with CI green.
#
# An exact version also bypasses setup-bun's GitHub tags API lookup,
# keeping CI alive during a degraded GitHub REST API.
bun-version-file: .bun-version
- name: Bun version matches the shipped image
# Both inputs are repo-root paths and this job defaults to
# `orchestrator/`, so it has to say so explicitly.
working-directory: ${{ github.workspace }}
run: |
# The image pins Bun explicitly; `.bun-version` is what CI installs.
# If they drift, the tests run on a different runtime than prod — the
# exact gap that let a Bun 1.4.0 change to native `server.upgrade()`
# break every WebSocket in the product with CI green.
version_file=".bun-version"
dockerfile="docker/orchestrator.Dockerfile"
for f in "$version_file" "$dockerfile"; do
if [ ! -f "$f" ]; then
echo "::error::Bun pin guard cannot read $f from $(pwd)."
exit 1
fi
done
want="$(tr -d '[:space:]' < "$version_file")"
# `|| true` so a Dockerfile with no FROM line reports as drift below
# rather than tripping pipefail with an opaque failure.
got="$(grep -oE 'FROM oven/bun:[^ ]+' "$dockerfile" \
| sed -E 's|FROM oven/bun:||; s|-alpine$||' | sort -u || true)"
# More than one distinct tag = the stages disagree with each other.
if [ -z "$got" ] || [ "$(printf '%s\n' "$got" | wc -l)" -ne 1 ] || [ "$got" != "$want" ]; then
echo "::error::Bun drift — $version_file is '$want', $dockerfile pins '$got'."
echo "Pin both to the same exact version (a floating tag such as 'oven/bun:1' is what caused this)."
exit 1
fi
echo "Bun pinned to $want in both."
- name: bun install
run: bun install --frozen-lockfile
- name: DBOS workflow hash warning (non-blocking, ADR 0104)
run: |
# The default checkout is depth-1; fetch main so the script's
# merge-base tier can annotate PRs that intentionally change a
# workflow hash. Best-effort: the script skips that tier cleanly
# when the ref is unavailable.
git fetch --no-tags --depth=50 origin main || true
NODE_ENV=test bun scripts/dbos-workflow-hashes.ts
- name: bun typecheck
run: bun run typecheck
- name: apply orchestrator migrations
run: bun run migrate
- name: bun test
run: bun test
# ADR 0051 §7: buf owns crates/engram-protocol/proto. Lint GATES style —
# legacy host_service.proto carries scoped exceptions in buf.yaml;
# everything new must be clean under full STANDARD, and a lint failure
# fails this job. Breaking-change detection is ADVISORY: it runs against
# the PR base, but a detected break does NOT fail the job — it surfaces
# as a `::warning::` plus a detailed PR comment so a reviewer can confirm
# the wire-compat impact is intended. Codegen-drift activates only once
# the generated TS bindings are committed (ADR 0051 Tasks 4-5) — until
# then this PR ships only the contract + Rust stubs.
buf:
name: buf (proto lint + breaking + codegen drift)
needs: detect
if: needs.detect.outputs.test_buf == 'true'
runs-on: blacksmith-2vcpu-ubuntu-2404
# The breaking step posts a PR comment via the action's pr_comment;
# that needs pull-requests: write (the workflow default is read-only).
# This job doesn't pull from GHCR, so it drops the top-level
# `packages: read` — job-level permissions replace, not merge.
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v7
# Lint (fatal). Split from breaking because a single buf-action run
# can't make one check fatal and another advisory.
- name: buf lint (fatal)
uses: bufbuild/buf-action@v1
with:
# Pin to the locally-verified buf CLI; bump deliberately. A new
# buf release can surface new lint rules (1.69.0 added
# ENUM_VALUE_PREFIX / ENUM_ZERO_VALUE_SUFFIX to STANDARD's
# findings on host_service.proto).
version: 1.69.0
input: crates/engram-protocol/proto
# host_service.proto predates `buf format`; don't gate on
# formatting (the action runs it by default on PRs).
format: false
# lint defaults to PR-events only — force it on so push-to-main
# + merge_group keep the gate.
lint: true
breaking: false
# The action's push step publishes to the BSR by default on push
# events — we don't use the BSR.
push: false
archive: false
pr_comment: false
# Breaking (advisory). PR-only: the comparison base and the PR comment
# only make sense on pull_request events. continue-on-error keeps a
# detected break from failing the job — buf-action posts the PR
# comment BEFORE it sets its failure status, so the comment still
# lands. The next step turns that swallowed failure into a warning.
- name: buf breaking (advisory — warns + comments, never fails)
id: breaking
if: github.event_name == 'pull_request'
continue-on-error: true
uses: bufbuild/buf-action@v1
with:
version: 1.69.0
input: crates/engram-protocol/proto
format: false
lint: false
breaking: true
push: false
archive: false
# Post/update a single comment keyed by <workflow>:<job> with the
# breaking-change details (needs pull-requests: write above;
# silently skipped on fork PRs where the token is read-only).
pr_comment: true
- name: Flag breaking changes as a warning
if: github.event_name == 'pull_request' && steps.breaking.outcome == 'failure'
run: |
echo "::warning title=Proto breaking change detected::buf found a wire-incompatible change to crates/engram-protocol/proto against the PR base. This is non-blocking — see the buf comment on the PR for details. Confirm the break is intended before merging."
# TS codegen drift check. Guarded on the committed output dir so it
# stays inert in this PR (protos + Rust stubs only) and activates
# once web/src/gen lands with the connect-es deps (ADR 0051 Task 4).
- name: Codegen drift check (buf generate)
run: |
if [ -d web/src/gen/engram/app ]; then
buf generate
# Assert porcelain-clean rather than `git diff --exit-code`:
# plain diff misses UNTRACKED new bindings, and `add -N` would
# stage (and so hide) DELETIONS that `clean: true` performs on
# proto removals — porcelain catches edits, adds, and deletes.
if [ -n "$(git status --porcelain -- web/src/gen orchestrator/src/gen)" ]; then
git status --porcelain -- web/src/gen orchestrator/src/gen
echo "generated bindings drifted — run 'just gen-proto' and commit the result"
exit 1
fi
else
echo "generated bindings not committed yet (ADR 0051 Tasks 4-5) — skipping codegen drift check"
fi
# ------------------------------------------------------------------
# The Firecracker KVM lane: every `#[ignore]`'d FC integration test
# under nested virt, split across four parallel jobs so the wall
# time is the longest batch (~5 min) instead of the sum (~14.5 min).
# Shared setup lives in .github/actions/fc-setup; each job runs one
# of the old serial batches. All four gate on the same `test_fc`
# detector flag (one lane parallelized, not four new lanes) and all
# four are in `ci-gate`'s needs — never required checks individually.
#
# Blacksmith exposes `/dev/kvm` via nested virtualization (see
# https://docs.blacksmith.sh/blacksmith-runners/overview). Mirrors
# the dev-vm bootstrap (engram-dev) — the canonical Linux + KVM
# env for Firecracker development. 4vCPU gives boot+lifecycle
# tests enough headroom to run microVMs without queuing.
# ------------------------------------------------------------------
test-fc-unprivileged:
name: tests (firecracker unprivileged, Linux + KVM)
needs: detect
if: needs.detect.outputs.test_fc == 'true'
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: ./.github/actions/fc-setup
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
rust-cache-shared-key: fc-unpriv
# Run the `#[ignore]`'d FC integration tests that don't need
# root. `--no-fail-fast` so a regression in one test doesn't
# hide regressions in others.
#
# We name the test binaries explicitly (rather than
# `--run-ignored ignored-only`) because the root-required
# tests (snapshot_net, proxy_e2e) live in the same crate and
# would otherwise be invoked here only to short-circuit via
# their `require_root()` SKIP path — leaving the gap silent.
- name: Firecracker `#[ignore]` tests (unprivileged)
run: |
# ADR 0021 P1.6: `baked_harness_loopback` replaced the
# retired `harness_loopback`. `restore_chain` and
# `option_d_latency_bench` were also deleted with the
# substrate subsystem; `restore_chain` came back (baked-in
# variant) in the P1.6 e2e resurrection.
#
# Runs in PARALLEL (--test-threads=4 ≈ runner vCPUs): these are
# unprivileged tests (net_pool=None — no TAP), so the only
# host-global resource they share is the vsock CID space, which
# FirecrackerBackend now partitions per nextest slot
# (NEXTEST_TEST_GLOBAL_SLOT → CID base offset). Jail/work dirs
# are per-process temp dirs and the substrate shm base is
# PID-keyed, so nothing else collides. ~4x faster than the old
# serial run. The 128-256 MiB test VMs keep 4 concurrent slots
# well within the runner's RAM.
cargo nextest run \
-p engram-sandbox-firecracker \
--test boot \
--test lifecycle \
--test reattach_detach \
--test snapshot \
--test exec \
--test exec_real_vm \
--test agentd_bundle_reexec \
--test materialize_boot \
--test baked_harness_loopback \
--test guest_clock_step \
--test forge_loopback \
--test upload_loopback \
--test proxy_port_loopback \
--test multi_restore \
--test cross_host_restore \
--test restore_chain \
--test aux_ro_drive \
--test diff_snapshot \
--test file_restore_shared_rss \
--test stock_fork_snapshot_compat \
--test pause_resume_vsock \
--test vmstate_only_snapshot \
--test substrate_kernel_capabilities \
--test substrate_uffd_base \
--run-ignored ignored-only \
--no-fail-fast \
--test-threads=4
test-fc-pooled:
name: tests (firecracker pooled host-agent, Linux + KVM)
needs: detect
if: needs.detect.outputs.test_fc == 'true'
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: ./.github/actions/fc-setup
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
rust-cache-shared-key: fc-pooled
# ADR 0028 Fix A: the checkpoint-chain pipeline test lives in
# engram-host-agent (it exercises PooledBackend), same gating
# as the unprivileged FC tests (KVM + musl agentd).
#
# `--test-threads=1` is load-bearing here: PooledBackend owns
# host-global resources (the vsock CID allocator restarting at 3,
# the shared chunk store, per-host work dirs), so concurrent
# tests collide. Production runs one backend per host, which is
# why this isn't an issue there — and why splitting this batch
# across CI *jobs* (= separate hosts) is legal while `-jN`
# within one job is not.
- name: Firecracker `#[ignore]` tests (PooledBackend host-agent)
run: |
cargo nextest run \
-p engram-host-agent \
--test checkpoint_chain \
--test warm_hook_capture \
--test cold_base_capture \
--test pagemap_scanner \
--test eviction_finalize_redrive \
--test chain_rehydrate \
--test egress_survives_roll \
--test rehome_retained_harness \
--run-ignored ignored-only \
--no-fail-fast \
--test-threads=1
test-fc-root:
name: tests (firecracker root, Linux + KVM)
needs: detect
if: needs.detect.outputs.test_fc == 'true'
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: ./.github/actions/fc-setup
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
rust-cache-shared-key: fc-root
# Root-only lanes: the pagemap and idle-page scans, the post-copy
# moves that use them, the dm-thin pool, and the TAP/netns tests.
# `sudo -E env "PATH=$PATH"` keeps the cargo env sudo scrubs.
- name: Idle-page tracking and advisory drain tests (root)
run: |
sudo -E env "PATH=$PATH" cargo nextest run \
-p engram-host-agent -p engram-uffd-handler --lib \
-E 'test(page_idle::tests::anonymous_mapping_accesses_clear_idle_bits) | test(peer_mode_drains_sealed_chunks_and_sweep_never_overwrites_them)'
# Post-copy moves: the capture seals the guest's dirty pages from
# its pagemap (root) and the disks move as session-volume
# checkpoints. Serial: one PooledBackend per host owns host-global
# resources (the vsock CID allocator, the chunk cache).
- name: Post-copy teleport tests (root)
run: |
sudo -E env "PATH=$PATH" cargo nextest run \
-p engram-host-agent \
--test migration_source \
--test two_host_live_teleport \
--test two_host_drain_wave \
--test postcopy_source_fresh_create \
--run-ignored ignored-only \
--no-fail-fast \
--test-threads=1
# ADR 0125: the session-disk pool, built by the same script
# node-prep runs in production. A runner that cannot build one
# fails the lane: the pool tests are the production disk path.
- name: Build the dm-thin pool
run: |
sudo apt-get install -y -qq --no-install-recommends thin-provisioning-tools
sudo env POOL_DIR=/var/lib/engram/thin POOL_DATA_SIZE=4G POOL_META_SIZE=128M \
sh deploy/helm/engram-host-fleet/files/thin-pool.sh
# Every state node prep can find: a used disk, a disk without room,
# a crash before the first activation, a restart.
- name: Node-prep pool states (root)
run: sudo sh scripts/thin-pool-states-test.sh
# The disk over the pool, then the session disk under a real guest
# over the same pool (`session_disk` reads ENGRAM_TEST_THIN_POOL).
# The ublk source's tests run in `test-ublk-root`: this runner's
# kernel has no ublk driver.
- name: dm-thin session-disk tests (root)
env:
ENGRAM_TEST_THIN_POOL: engram-pool
run: |
sudo -E env "PATH=$PATH" cargo nextest run \
-p engram-disk-thin \
--test thin_pool \
--test clone \
--run-ignored ignored-only \
--no-fail-fast \
--test-threads=1
sudo -E env "PATH=$PATH" cargo nextest run \
-p engram-host-agent \
--test session_disk \
--run-ignored ignored-only \
--no-fail-fast \
--test-threads=1
# Root-required tests: proxy_e2e provisions a TAP device and runs
# the full guest→TAP→REDIRECT→proxy→upstream chain, snapshot_net
# asserts that snapshot/restore re-provisions the per-VM TAP + /30
# under the original name (Gap 1 of the FC parity work). All need
# CAP_NET_ADMIN, which on Blacksmith runners means sudo.
# (host_startup — iptables ordering, root but no KVM — moved to the
# `tests (linux)` lane per ADR 0098's keep-the-FC-lane-minimal.) We `-E` to keep the cargo / rustc env (CARGO_HOME,
# RUSTUP_HOME, PATH) so the binary can be found, and chown back
# at the end so the rust-cache action can read /target without
# permission errors. Docker buildx scratchpad (~/.docker/buildx)
# also gets touched by proxy_e2e's image bake; cleanup includes
# it.
- name: Firecracker `#[ignore]` tests (root — snapshot_net, patch_drive_swap, netns_isolation, warm_proxy_chain, proxy_e2e)
run: |
# ADR 0021 P1.6: `proxy_e2e` came back in the e2e
# resurrection — baked-in harness path, CA delivered via
# the `SpawnHarness` vsock RPC (2026-07 core-ops fold: one
# first-contact call installs the CA and spawns) instead of
# the retired `.engram-host/ca.pem` substrate file.
# `option_d_warm_lease` stays deleted (it was specifically
# about option-D).
# `aux_ro_drive` is NOT in this list: it self-isolates (raw FC
# spawn, per-process tempdir + auto loop device, its own `sudo
# mount`) and already runs in the unprivileged `--test-threads=4`
# batch (test-fc-unprivileged), so listing it here too was pure
# duplication on the serial path (~4 tests x ~20s). Dropped;
# ADR 0027 coverage is unchanged (same tests, still run, once).
sudo -E env "PATH=$PATH" cargo nextest run \
-p engram-sandbox-firecracker \
--test snapshot_net \
--test patch_drive_swap \
--test netns_isolation \
--test warm_proxy_chain \
--test proxy_e2e \
--run-ignored ignored-only \
--no-fail-fast \
--test-threads=1
# Run after either success or failure so cache write doesn't
# trip on root-owned files.
- name: Restore ownership after sudo tests
if: always()
run: |
sudo chown -R "$USER":"$USER" target/ ~/.cargo ~/.docker 2>/dev/null || true
# ------------------------------------------------------------------
# The ublk source of a hydrating session volume (ADR 0125), as root
# over a dm-thin pool. No guest boots, so no KVM. It runs on a
# GitHub-hosted runner because the Blacksmith kernel is built without
# `CONFIG_BLK_DEV_UBLK`; Ubuntu's kernel has `ublk_drv` as a module,
# as the production node image does.
# ------------------------------------------------------------------
test-ublk-root:
name: tests (ublk source, root)
needs: detect
if: needs.detect.outputs.test_fc == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- name: Install protoc and the pool tools
run: |
install() {
sudo apt-get update -qq
sudo apt-get install -y -qq --no-install-recommends \
protobuf-compiler thin-provisioning-tools
}
# The hosted runner's resolver sometimes fails for the package
# hosts. Show its state, then try again with public resolvers.
if ! install; then
link="$(ip route show default | awk '{print $5; exit}')"
resolvectl status "$link" || true
getent hosts azure.archive.ubuntu.com archive.ubuntu.com github.com || true
sudo resolvectl dns "$link" 1.1.1.1 8.8.8.8
sudo resolvectl flush-caches
getent hosts azure.archive.ubuntu.com archive.ubuntu.com || true
install
fi
- uses: Swatinem/rust-cache@v2
with:
shared-key: ublk-root
- uses: taiki-e/install-action@nextest
- name: Build the dm-thin pool and load ublk
run: |
sudo env POOL_DIR=/var/lib/engram/thin POOL_DATA_SIZE=4G POOL_META_SIZE=128M \
sh deploy/helm/engram-host-fleet/files/thin-pool.sh
# Some Ubuntu kernels keep `ublk_drv` in a separate package.
if ! sudo modprobe ublk_drv; then
sudo apt-get install -y -qq --no-install-recommends "linux-modules-extra-$(uname -r)"
sudo modprobe ublk_drv
fi
test -e /dev/ublk-control
- name: ublk source and lazy restore tests (root)
env:
ENGRAM_TEST_THIN_POOL: engram-pool
ENGRAM_TEST_UBLK: "1"
run: |
sudo -E env "PATH=$PATH" cargo nextest run \
-p engram-host-agent \
--test blk_source \
--test lazy_restore \
--run-ignored ignored-only \
--no-fail-fast \
--test-threads=1 &
run=$!
# A thread blocked in the kernel on a ublk device cannot be
# killed, so a hung test never ends: show where it waits.
for _ in $(seq 1 120); do
kill -0 "$run" 2>/dev/null || break
sleep 5
done
if kill -0 "$run" 2>/dev/null; then
echo "::error::the ublk tests did not end in 10 minutes"
for exe in /proc/[0-9]*/exe; do
case "$(sudo readlink "$exe" 2>/dev/null)" in
*/blk_source-*|*/lazy_restore-*) ;;
*) continue ;;
esac
pid=${exe#/proc/}; pid=${pid%/exe}
for task in /proc/"$pid"/task/*; do
echo "== pid $pid task ${task##*/} $(cat "$task/comm") $(cut -d' ' -f3 "$task/stat")"
sudo cat "$task/stack" 2>/dev/null || true
done
done
for dev in /sys/block/ublkb*; do
[ -e "$dev" ] && echo "$dev inflight: $(cat "$dev/inflight") holders: $(ls "$dev/holders")"
done
sudo dmsetup ls || true
sudo dmesg | tail -60
exit 1
fi
wait "$run"
- name: Restore ownership after sudo tests
if: always()
run: |
sudo chown -R "$USER":"$USER" target/ ~/.cargo 2>/dev/null || true
test-fc-e2e:
name: tests (firecracker true-e2e, Linux + KVM)
needs: detect
if: needs.detect.outputs.test_fc == 'true'
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: ./.github/actions/fc-setup
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
rust-cache-shared-key: fc-e2e
# Cache the Claude Code CLI binary across CI runs. The
# e2e_harness tests download it from
# `downloads.claude.ai/claude-code-releases/latest`. Without
# caching every CI run pays a ~30s download + the upstream
# may rate-limit. Cache key is intentionally fuzzy (`latest`)
# since Anthropic's "latest" pointer floats; the test
# tolerates whatever version is in the cache and only
# re-downloads when the cache misses.
- name: Cache Claude Code CLI
uses: actions/cache@v6
with:
path: ~/.cache/engram-e2e-harness
# Refresh every ~week — gives some staleness so we
# eventually pick up new Claude CLI versions, but doesn't
# re-download on every run.
key: claude-code-cli-${{ github.run_id }}
restore-keys: |
claude-code-cli-
# ADR 0064: stage the `browser` squashfs bundle the e2e_vnc test
# mounts. `just bundles-squashfs` content-addresses every bundle
# (<sha>.squashfs + current.json) under the repo's var/shared/ — the
# same shape the FC-host image bake produces under /var/lib/engram/shared.
# e2e_vnc points FirecrackerConfig.bundle_dir at var/shared/ and reads
# the `browser` sha from current.json, so this MUST run before it.
# The browser build needs Docker (chromium + Xvfb + x11vnc, glibc-linked),
# which Blacksmith runners provide; the other bundles in the recipe
# degrade gracefully if their build skips (e2e_vnc only needs `browser`).
- name: Stage browser bundle for e2e_vnc (ADR 0064)
env:
# ADR 0080: `bundles-squashfs` also packs `bundle-agentd`; reuse the
# musl agentd this lane already built instead of a second compile.
ENGRAM_AGENTD_BIN: target/x86_64-unknown-linux-musl/release/engram-agentd
run: |
just bundles-squashfs
ls -l var/shared/
cat var/shared/current.json
# `bundles-squashfs` `|| continue`s past a failed bundle build, so it
# always exits 0. If the `browser` build failed, current.json has no
# `browser` key, e2e_vnc prints `SKIP:` and the lane stays GREEN — the
# VNC e2e never runs. Fail loud here so a broken browser bundle FAILS
# the job before the FC test invocation. (python3 is preinstalled on
# the ubuntu runner; jq is not.)
python3 -c 'import json,sys; d=json.load(open("var/shared/current.json")); sys.exit(0 if "browser" in d else 1)' || { echo "FATAL: browser bundle missing from current.json — e2e_vnc would silently skip" >&2; exit 1; }
# True-e2e tests (engram-host-agent crate): real bake + real
# FC microVM + PooledBackend + real proxy + (for harness)
# real Claude CLI + real api.anthropic.com 401 round-trip.
# These are the highest-fidelity tests we have for the
# cold-and-warm path the dashboard's SHELL tab + Claude
# harness use in prod.
# ADR 0062: the harness is a per-session bundle mounted on dyn_0
# (no longer baked into the rootfs); the CA rides the
# `SpawnHarness` vsock RPC (2026-07 core-ops fold).
- name: True-e2e tests (root — e2e_shell, e2e_harness, e2e_vnc, egress_stream_survives_roll)
run: |
# egress_stream_survives_roll (ADR 0121): a real guest's
# ESTABLISHED egress stream flows across a host-agent roll —
# incl. the successor's iptables purge+reapply (conntrack).
# Root: TAP + iptables, same as the shell/harness e2e.
sudo -E env "PATH=$PATH" cargo nextest run \
-p engram-host-agent \
--test e2e_shell \
--test e2e_harness \
--test e2e_vnc \
--test egress_stream_survives_roll \
--run-ignored ignored-only \
--no-fail-fast \
--test-threads=1
# Run after either success or failure so cache write doesn't
# trip on root-owned files.
- name: Restore ownership after sudo tests
if: always()
run: |
sudo chown -R "$USER":"$USER" target/ ~/.cargo ~/.docker 2>/dev/null || true
# ------------------------------------------------------------------
# ------------------------------------------------------------------
# Built-in Claude harness artifact bake (ADR 0021 P0).
#
# Folds the prior standalone `bake-harness-claude.yml` workflow
# into ci.yml so every PR + push-to-main produces the exact
# artifact it tests against — closing a structural catch-22 where
# a PR that bumps `HARNESS_VERSION` had no way to publish the new
# tag before its own e2e_stack lane consumed it.
#
# ADR 0062: the harness rides the fleet `current_bundles` stamp, NOT
# the image. Two consumers of this artifact:
# - **production hosts** (push-to-main only): node-assets stages
# `ghcr.io/cortexapps/engrams/harness-claude:<version>-<platform>`
# into each host's bundle stamp. This job publishes that tag on
# push-to-main and skips the push on PRs.
# - **`test-e2e-stack` (every PR + push)**: download the workflow
# artifact this job uploads, unpack it into ENGRAM_HARNESS_CLAUDE_TREE,
# and `just bundles-squashfs` packs it into the host stamp so the
# coordinator resolves the built-in `claude` from `current_bundles`.
#
# Why a workflow artifact (not "PR pushes to a per-PR GHCR tag"):
# workflow artifacts auto-expire, never write to a shared registry
# namespace, and can't accidentally leak a half-baked PR's binary
# into a tag prod's bake might pull. The trade-off (one extra
# ~30-60 s job per PR) is worth the elimination of all four
# failure modes the catch-22 created.
# ------------------------------------------------------------------
bake-harness-claude-artifact:
name: bake harness-claude artifact
# Consumed only by test-e2e-stack (downloads the workflow artifact) and
# bake-demo-image (push-to-main / dispatch) — so gate it on the union of
# their conditions. No point building the harness when nothing consumes it
# (e.g. a docs- or chart-only PR). Mirrors artifacts-e2e-stack's gating.
needs: detect
if: >-
needs.detect.outputs.e2e == 'true'
|| github.event_name == 'merge_group'
|| (github.event_name == 'push' && github.ref == 'refs/heads/main')
|| github.event_name == 'workflow_dispatch'
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30
permissions:
contents: read
# `packages: write` only used on push-to-main. The PR path
# uploads as a workflow artifact and never touches GHCR.
packages: write
steps:
- uses: actions/checkout@v7
- uses: actions-rust-lang/setup-rust-toolchain@v2
with:
rustflags: ''
target: x86_64-unknown-linux-musl
- name: Install protoc
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq --no-install-recommends protobuf-compiler
- name: Install musl-tools
run: sudo apt-get install -y -qq --no-install-recommends musl-tools
- name: Cache cargo build
uses: Swatinem/rust-cache@v2
with:
# Shares with bake-demo-image matrix (same musl + host
# release deps) so the second job warms instantly off the
# first's deps.
shared-key: release-musl-bake
- name: Build built-in harnesses (musl) + publisher (host)
run: |
cargo build --release --target x86_64-unknown-linux-musl \
-p engram-harness-claude -p engram-harness-codex
cargo build --release -p engram-publish-builtin-harness
- name: Download Claude Code CLI (Linux x64)
id: claude_cli
run: |
# PINNED, not floating `latest` (cortexapps/engrams#431): claude
# >=2.1.187 removed the AskUserQuestion + ExitPlanMode built-ins from
# headless `--print` mode, so questions and plan approval ride the
# injected MCP tools (ask_user_question / exit_plan_mode) instead of
# native bindings. Bump deliberately and re-verify BOTH spines
# against the new CLI: the deferred-tool spine (defer parks the turn
# with `terminal_reason: tool_deferred`, `--resume` re-fires
# id-stable, the MCP bridge serves the stashed result) and the
# steering behavior (`scripts/claude-steer-probe.py` must report
# STEER — ADR 0052 2026-08-20 update; needs model credentials, so
# it runs on the bumper's machine, not here). Keep in lockstep with
# the justfile and bake-images.yml.
CLAUDE_VERSION=2.1.285
curl -fsSL --retry 3 \
"https://downloads.claude.ai/claude-code-releases/${CLAUDE_VERSION}/linux-x64/claude" \
-o /tmp/claude
chmod +x /tmp/claude
# Anthropic's musl build — the shim picks claude-musl on
# Alpine-class guests (glibc CLI dies at the loader there).
curl -fsSL --retry 3 \
"https://downloads.claude.ai/claude-code-releases/${CLAUDE_VERSION}/linux-x64-musl/claude" \
-o /tmp/claude-musl
chmod +x /tmp/claude-musl
/tmp/claude --version || true
echo "version=$CLAUDE_VERSION" >> "$GITHUB_OUTPUT"
- name: Stage harness artifact contents
id: stage
env:
CLAUDE_VERSION: ${{ steps.claude_cli.outputs.version }}
run: |
# Stage into a known, repo-relative path so upload-artifact
# has a stable input. The staged directory is the harness pack:
# entry binary at `harness`, bundled `claude` CLI alongside, and
# the ADR 0063 `harness.toml` descriptor (read by RegisterHarness,
# which pulls this artifact + packs it into the catalog). The
# legacy `artifact.toml` is still staged transitionally until the
# bake-time injection path is removed (ADR 0062 A4b).
STAGE="$PWD/var/harness-claude-stage"
rm -rf "$STAGE"
mkdir -p "$STAGE"
cp -p target/x86_64-unknown-linux-musl/release/engram-harness-claude "$STAGE/harness"
cp -p /tmp/claude "$STAGE/claude"
cp -p /tmp/claude-musl "$STAGE/claude-musl"
# ADR 0062/0063: the canonical harness descriptor (committed, reviewed).
cp -p deploy/harness-claude/harness.toml "$STAGE/harness.toml"
cat > "$STAGE/artifact.toml" <<EOF
name = "claude"
version = "${HARNESS_VERSION}"
entry = "harness"
description = "Anthropic Claude Code, bundled with engram-harness-claude ${HARNESS_VERSION}. Built on top of claude CLI ${CLAUDE_VERSION}."
EOF
ls -la "$STAGE"
echo "dir=$STAGE" >> "$GITHUB_OUTPUT"
# PR + merge_group: upload as a workflow artifact for downstream
# consumers (test-e2e-stack downloads + re-publishes locally).
# Always runs so the artifact exists regardless of whether the
# GHCR push below ran.
- name: Upload staged harness as workflow artifact
uses: actions/upload-artifact@v7
with:
name: harness-claude-artifact
path: ${{ steps.stage.outputs.dir }}
# PR-scoped freshness — workflow artifacts auto-expire
# after the configured retention (90 d default), so this
# never accumulates indefinitely.
if-no-files-found: error
retention-days: 7
# Three files (binary + binary + 200-byte toml); leave
# compression default.
- name: Download and stage Codex CLI 0.161.0
id: stage_codex
run: |
set -euo pipefail
STAGE="$PWD/var/harness-codex-stage"
deploy/harness-codex/stage.sh x86_64 \
target/x86_64-unknown-linux-musl/release/engram-harness-codex \
"$STAGE"
echo "dir=$STAGE" >> "$GITHUB_OUTPUT"
- name: Upload staged Codex harness as workflow artifact
uses: actions/upload-artifact@v7
with:
name: harness-codex-artifact
path: ${{ steps.stage_codex.outputs.dir }}
if-no-files-found: error
retention-days: 7
# Push-to-main only: also publish to the production GHCR tag
# so production hosts (node-assets stages it into the bundle
# stamp) and future consumers see the same artifact.
- name: Log in to GHCR
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push harness-claude artifact to GHCR (main only)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
STAGE: ${{ steps.stage.outputs.dir }}
TAG: ghcr.io/${{ github.repository }}/harness-claude:${{ env.HARNESS_VERSION }}-${{ env.HARNESS_PLATFORM }}
run: |
# ADR 0021 P1.7: `engram-publish-builtin-harness` replaces
# the retired `engram-cli harness push`. Same underlying
# `engram_oci::OciClient::push_harness` primitive; same
# wire shape (one tar.gz layer at our media type). The tag
# is the catalog's expected format `<repo>:<version>-
# <platform>` — no `:latest` / `:main` / SHA aliases, per
# the ADR's "one explicit version, baker records the
# digest" rule.
./target/release/engram-publish-builtin-harness \
--from "$STAGE" \
--to "$TAG"
echo "Published $TAG"
- name: Push harness-codex artifact to GHCR (main only)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
STAGE: ${{ steps.stage_codex.outputs.dir }}
TAG: ghcr.io/${{ github.repository }}/harness-codex:${{ env.HARNESS_VERSION }}-${{ env.HARNESS_PLATFORM }}
run: |
./target/release/engram-publish-builtin-harness --from "$STAGE" --to "$TAG"
- name: Summarize
if: always()
env:
PUSH_RAN: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: |
echo "## harness-claude bake" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "- version: \`${HARNESS_VERSION}-${HARNESS_PLATFORM}\`" >> "$GITHUB_STEP_SUMMARY"
echo "- uploaded as workflow artifact: \`harness-claude-artifact\`" >> "$GITHUB_STEP_SUMMARY"
if [ "$PUSH_RAN" = "true" ]; then
echo "- pushed to: \`ghcr.io/${{ github.repository }}/harness-claude:${HARNESS_VERSION}-${HARNESS_PLATFORM}\`" >> "$GITHUB_STEP_SUMMARY"
else
echo "- GHCR push: skipped (PR / non-main)" >> "$GITHUB_STEP_SUMMARY"
fi
# Demo image bake — relocated from
# engrams-internal/.github/workflows/bake-demo-image.yml so the
# production demo image and the e2e test image come from one
# publish path. Push-to-main only (PRs don't need to push; the
# e2e lane bakes its own image locally for test isolation).
#
# ADR 0062/0080: ONE `demo` image — the workspace rootfs (debian +
# git/curl/socat/iproute2) with NO harness, NO agentd, and NO ttyd
# baked in. The harness (`claude`), agentd, and ttyd (`guest-tools`)
# all ride the fleet `current_bundles` stamp, staged onto hosts by
# node-assets. Prod points here for the default session and selects
# `harness = "claude"` per session.
#
# Publishes `ghcr.io/cortexapps/engrams/demo:warm-<sha>` (plus the
# `:warm-<short>`, `:main`, `:latest` aliases). Kept as a 1-entry
# matrix so a second image variant is a one-line addition.
# ------------------------------------------------------------------
bake-demo-image:
name: bake ${{ matrix.variant }} image
if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30
permissions:
contents: read
# `packages: write` for the GHCR push (`write` implies `read`).
packages: write
strategy:
fail-fast: false
matrix:
variant: [demo]
steps:
- uses: actions/checkout@v7
# ADR 0080: a session image is a plain `docker build && docker push`
# of a standard OCI image — no engram-cli bake, no agentd/ttyd
# injection, no ext4 pack. The coordinator materializes the rootfs
# host-side (MaterializeImage) at enable time. So this job is now a
# straight buildx build+push, same shape as bake-images.yml.
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Derive image tags
id: tags
env:
SHA: ${{ github.sha }}
VARIANT: ${{ matrix.variant }}
run: |
BASE="ghcr.io/${{ github.repository }}/$VARIANT"
SHORT="${SHA:0:7}"
# buildx pushes every tag in one build — the :warm-<sha> pin plus
# the :warm-<short> / :main / :latest aliases prod points at.
{
echo "list<<EOF"
echo "$BASE:warm-$SHA"
echo "$BASE:warm-$SHORT"
echo "$BASE:main"
echo "$BASE:latest"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- uses: docker/setup-buildx-action@v4
- name: Build + push ${{ matrix.variant }} image
uses: docker/build-push-action@v7
with:
context: .
file: deploy/${{ matrix.variant }}/Dockerfile
push: true
tags: ${{ steps.tags.outputs.list }}
- name: Summarize
if: always()
env:
SHA: ${{ github.sha }}
VARIANT: ${{ matrix.variant }}
run: |
echo "## ${VARIANT} image bake" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "- engrams SHA: \`$SHA\`" >> "$GITHUB_STEP_SUMMARY"
echo "- pushed: \`ghcr.io/${{ github.repository }}/$VARIANT:warm-$SHA\`" >> "$GITHUB_STEP_SUMMARY"
# ------------------------------------------------------------------
# Build the release binaries the e2e lane consumes. Separated so the
# ~3min compile happens once and the e2e job downloads via the
# workflow artifact rather than rebuilding.
# ------------------------------------------------------------------
artifacts-e2e-stack:
name: build e2e binaries
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 25
# Only consumed by test-e2e-stack, so gate it on the same condition —
# no point building the e2e binaries when the e2e lane won't run.
needs:
- detect
if: >-
needs.detect.outputs.e2e == 'true'
|| github.event_name == 'merge_group'
|| (github.event_name == 'push' && github.ref == 'refs/heads/main')
steps:
- uses: actions/checkout@v7
- uses: actions-rust-lang/setup-rust-toolchain@v2
with:
rustflags: ''
target: x86_64-unknown-linux-musl
# Install protoc via apt: arduino/setup-protoc@v3 with a pinned
# version *still* called the GH releases API to validate and
# 401'd with "Bad credentials" on a not-rare-enough fraction
# of runs. Ubuntu 24.04's protobuf-compiler ships 3.21.12,
# well above tonic-build/prost-build's minimum, and `apt`
# never hits the GH API — deterministic, ~2s.
- name: Install protoc
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq --no-install-recommends protobuf-compiler
protoc --version
- name: Install musl tooling
run: sudo apt-get update -qq && sudo apt-get install -y -qq --no-install-recommends musl-tools
- name: Setup mold linker
uses: rui314/setup-mold@v1
- name: Cache cargo build
uses: Swatinem/rust-cache@v2
with:
# Shared with bake-demo-image — see that job's cache step
# for the rationale (release+musl dep graph).
shared-key: release-musl-bake
- name: Build host binaries (release)
run: |
# `engram-publish-builtin-harness` is added so the
# downstream `test-e2e-stack` job can republish the
# `harness-claude` workflow artifact into the integration
# registry without a separate cargo build (ADR 0021 P0).
# ADR 0121: host-agent refuses to serve without a confirmed
# egress daemon (fail-closed), so the stack ships the daemon
# binary beside it. `engram-cli` is the `engrams` binary the
# e2e lane drives enable/registry/session with (ENGRAMS_BIN).
# Every resume spawns `engram-uffd-handler` beside the host agent.
cargo build --release \
-p engram-coordinator \
-p engram-host-agent \
-p engram-egress-proxyd \
-p engram-uffd-handler \
-p engram-publish-builtin-harness \
-p engram-cli
- name: Build musl agentd (release)
run: |
cargo build --release --target x86_64-unknown-linux-musl \
-p engram-agentd
- name: Upload e2e binaries
uses: actions/upload-artifact@v7
with:
name: e2e-binaries
path: |
target/release/engram-coordinator
target/release/engram-host-agent
target/release/engram-egress-proxyd
target/release/engram-uffd-handler
target/release/engram-publish-builtin-harness
target/release/engrams
target/x86_64-unknown-linux-musl/release/engram-agentd
retention-days: 1
if-no-files-found: error
# ------------------------------------------------------------------
# True end-to-end against the prod-shape stack. Brings up postgres
# + fake-gcs + local registry + real coord + real host-agent + real
# Firecracker. ADR 0062: the `demo` image bakes NO harness — the
# built-in `claude` harness's tree is downloaded from the
# `bake-harness-claude-artifact` workflow artifact, packed into the
# host `current_bundles` stamp (ENGRAM_HARNESS_CLAUDE_TREE +
# `just bundles-squashfs`), and resolved from there per session.
# Runs the selected flows in `e2e_stack.rs`.
#
# `needs:` only lists jobs whose *artifacts* this lane downloads
# (artifacts-e2e-stack's release binaries, bake-harness-claude-artifact's
# harness tree, detect's `e2e` flag). It used to also list the cheap
# gates (lint, test-linux, web, cross-musl-linux) as a cost-saving
# DAG dep, but GitHub Actions force-skips a job whenever ANY of its
# `needs:` was skipped — overriding this job's own `if:`. `web` (gated
# on web-path changes) and `cross-musl-linux`/`lint`/`test-linux`
# (gated on their own path flags) routinely skip on a Rust-only PR
# that doesn't touch their paths, which silently skipped this entire
# lane on every Rust-only push/PR (never actually exercising the
# coord HTTP → gRPC → host-agent path CI claims to cover). Those
# lanes are still independently required via `ci-gate`'s `needs:`, so
# dropping them here doesn't weaken the overall gate — it just means
# this lane no longer skips itself as a side effect of an unrelated
# lane skipping. The test-fc-* lanes are intentionally NOT in `needs:`
# — they test the host-agent's PooledBackend in isolation; this lane
# tests the coord HTTP → gRPC → host-agent path. Orthogonal coverage;
# running them in parallel saves ~6min on the critical path on
# push-to-main and a flaky `proxy_e2e` doesn't suppress e2e-stack
# signal.
# ------------------------------------------------------------------
test-e2e-stack:
name: e2e stack ${{ matrix.variant }} (coord app-gRPC → FC)
# The detector selects from three variants of the same prod-shape stack
# (egress proxy on — the proven config):
# - suite: single host. Runs every e2e_stack test EXCEPT the two-host
# evacuation test and the quarantined Claude auth test. This includes
# the orchestrator automation tests in the normal full posture.
# - teleport: two hosts. Check pinned teleport, then retirement and deletion.
# - orchestrator: single host. Runs only the webhook and cron automation
# scenarios that call the orchestrator's public RPC and HTTP surfaces.
# The detector uses this variant only for an orchestrator-only PR.
#
# A core-stack change selects suite and teleport. An orchestrator-only PR
# selects only orchestrator. Push and merge-group runs use suite and
# teleport, so the full posture stays at two concurrent stacks.
#
# e2e stack IS gated now (in the CI Gate's needs). Branch protection requires
# only the CI Gate, never the matrix-suffixed job names directly.
strategy:
fail-fast: false
matrix: ${{ fromJSON(github.event_name == 'pull_request' && needs.detect.outputs.e2e_matrix || needs.detect.outputs.e2e_full_matrix) }}
# Path-gate: run on any e2e-relevant change, and always on merge_group +
# push-to-main. On changes that can't affect e2e it skips, which the CI Gate
# treats as OK (so gating it doesn't wedge non-coord PRs).
#
# `!cancelled()` is required because this job's `needs:` includes jobs
# (artifacts-e2e-stack, bake-harness-claude-artifact) that share this same
# path-gate — without it, GitHub Actions' default "skip if any needed job
# skipped" behavior would force-skip this job whenever those upstream jobs
# skip, regardless of this `if:`. That default skip-propagation is exactly
# what silently dropped this lane on Rust-only changes before `web` /
# `cross-musl-linux` were removed from `needs:` below. Since `!cancelled()`
# also stops GitHub from implicitly requiring those `needs:` entries to have
# *succeeded*, each one this job actually depends on for artifacts is
# checked explicitly below instead.
if: >-
!cancelled()
&& needs.detect.result == 'success'
&& needs.artifacts-e2e-stack.result == 'success'
&& needs.bake-harness-claude-artifact.result == 'success'
&& (
needs.detect.outputs.e2e == 'true'
|| github.event_name == 'merge_group'
|| (github.event_name == 'push' && github.ref == 'refs/heads/main')
)
needs:
- detect
- artifacts-e2e-stack
# ADR 0062: the demo image is harness-free. The built-in `claude`
# harness rides the host `current_bundles` stamp instead — the job
# below builds its tree (entry binary + claude CLI) and uploads it as
# a workflow artifact (on every run, regardless of branch). The
# "Download harness-claude artifact" + "Stage RO bundles" steps pack
# that tree into a squashfs and stamp `harness-claude`, so the in-PR
# harness binary is what the agent tests exec — no registration, no
# local-registry republish.
- bake-harness-claude-artifact
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30
# `contents: read` for the checkout; `packages: read` because the
# host-agent (via coord's HttpAuthResolver, ADR 0013) reads sealed
# creds from PG seeded by `engrams registry add` below — that
# path still uses GHCR for the demo image's chunked OCI layers if
# the integration test expands. The *baker* never pulls from GHCR
# in this lane: the harness artifact comes from a workflow-artifact
# download + local re-publish (see "Pull harness-claude artifact"
# below), and the catalog override redirects the resolution there.
permissions:
contents: read
packages: read
env:
# deploy/dev/engrams-cli.sh runs this binary (from the e2e-binaries
# artifact) instead of a debug build.
ENGRAMS_BIN: ${{ github.workspace }}/target/release/engrams
steps:
- uses: actions/checkout@v7
- uses: actions-rust-lang/setup-rust-toolchain@v2
with:
rustflags: ''
# nextest is what every other test step in this workflow uses.
- uses: taiki-e/install-action@nextest
# The Tiltfile's `bootstrap` local_resource runs `just bootstrap`,
# so the runner needs `just` (Blacksmith runners don't ship it; the
# other CI jobs hit cargo directly).
- uses: taiki-e/install-action@just
# Install protoc via apt: arduino/setup-protoc@v3 with a pinned
# version *still* called the GH releases API to validate and
# 401'd with "Bad credentials" on a not-rare-enough fraction
# of runs. Ubuntu 24.04's protobuf-compiler ships 3.21.12,
# well above tonic-build/prost-build's minimum, and `apt`
# never hits the GH API — deterministic, ~2s.
- name: Install protoc
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq --no-install-recommends protobuf-compiler
protoc --version
- name: Cache cargo build (for the e2e test binary itself)
uses: Swatinem/rust-cache@v2
with:
# Shared with lint + test-linux: the e2e_stack test binary
# links in engram-coordinator's full dep graph at debug
# profile, so the cache populated by the earlier debug
# workspace jobs hits ~all of it. Saves ~1-2min of cold
# cargo compile on this lane.
shared-key: workspace-debug
# Same KVM + UFFD relax pattern the fc-setup composite uses.
# Blacksmith runners ship /dev/kvm but the
# default perms exclude non-root user processes.
- name: Relax KVM + UFFD permissions
run: |
sudo chmod 0666 /dev/kvm
sudo sysctl -w vm.unprivileged_userfaultfd=1
sudo chmod 0666 /dev/userfaultfd
- name: Install build deps (musl-tools)
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq --no-install-recommends \
musl-tools jq bc python3
# The forked firecracker the host image ships, as in the fc-setup
# action: keyed by the submodule's gitlink SHA, and an error when the
# artifact is missing.
- uses: oras-project/setup-oras@v2
with:
version: 1.3.0
- name: Install forked firecracker
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
FC_SHA="$(git ls-tree HEAD third_party/firecracker | awk '{print $3}')"
echo "$GH_TOKEN" | oras login ghcr.io -u "${{ github.actor }}" --password-stdin
mkdir -p "$HOME/fc-fork"
if ! oras pull "ghcr.io/${{ github.repository }}/firecracker:$FC_SHA" --output "$HOME/fc-fork"; then
echo "::error::forked firecracker artifact firecracker:$FC_SHA is not published; dispatch bake-images on this branch to build it"
exit 1
fi
sudo install -m 0755 "$HOME/fc-fork/firecracker" /usr/local/bin/firecracker
firecracker --version
- name: Cache FC kernel + rootfs artifacts
uses: actions/cache@v6
with:
path: ~/.cache/engram-fc-test
key: fc-test-artifacts-${{ hashFiles('crates/engram-sandbox-firecracker/scripts/fetch-fc-test-artifacts.sh') }}
restore-keys: |
fc-test-artifacts-
- name: Fetch FC kernel + rootfs artifacts
# GH_TOKEN: private release asset for the FC guest kernel (ADR 0025).
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bash crates/engram-sandbox-firecracker/scripts/fetch-fc-test-artifacts.sh \
--cache-dir "$HOME/.cache/engram-fc-test"
# Pull the release binaries AFTER the Swatinem/rust-cache@v2
# restore step (`Cache cargo build` above). Surfaced in CI run
# 26344875066: rust-cache's restore prunes "stale" entries from
# target/<profile>/ when the lockfile hash changes (Cargo.lock
# touched by a workspace dep add in ADR 0016 Phase A). The
# download placed engram-coordinator/host-agent at
# target/release/, the cache restore wiped them, and
# the Tiltfile's prebuilt-binary branch had nothing to exec for
# coord + host-agent. Moving
# the download below all rust-cache operations
# makes the order unambiguous: nothing can prune what hasn't
# been written yet.
#
# actions/upload-artifact@v7 strips the longest common path
# prefix shared by all `path:` entries when packing — for the
# artifacts-e2e-stack upload that's `target/`, so the artifact
# contents are flattened to `release/...` +
# `x86_64-unknown-linux-musl/release/...`. Downloading directly
# into `./target/` reconstructs the expected layout in place.
- name: Download e2e binaries
uses: actions/download-artifact@v8
with:
name: e2e-binaries
path: ./target/
- name: Mark e2e binaries executable
run: |
chmod +x target/release/engram-{coordinator,host-agent,egress-proxyd,uffd-handler,publish-builtin-harness}
chmod +x target/release/engrams
chmod +x target/x86_64-unknown-linux-musl/release/engram-agentd
ls -l target/release/engram-{coordinator,host-agent,egress-proxyd,uffd-handler,publish-builtin-harness} \
target/release/engrams \
target/x86_64-unknown-linux-musl/release/engram-agentd
# `tilt up` (via tilt-up-ci.sh) boots: postgres + fake-gcs +
# registry + jaeger via docker-compose, then coord + host-agent.
# ENGRAM_INTEG_BIN_DIR=target/release makes the Tiltfile exec the
# downloaded release binaries instead of `cargo run`/build.
# ENGRAM_SKIP_WEB=1 because there's no browser in CI for the SPA.
# Tilt is the one dev orchestrator (ADR 0024). Local dev gets it
# from the nix devShell; CI runners aren't in nix, so install the
# pinned release binary via the official script.
- name: Install Tilt
run: |
curl -fsSL https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.sh \
| sudo bash
tilt version
# The orchestrator (a core stack member — the Tiltfile boots it even
# under ENGRAM_SKIP_WEB=1) runs on bun.
- uses: oven-sh/setup-bun@v2
with:
bun-version-file: .bun-version
# ADR 0027 → 0035 → 0055 → 0062: the e2e host-agent reads its RO bundles
# from var/shared (Tiltfile sets ENGRAM_BUNDLE_DIR there), CONTENT-ADDRESSED
# (<sha256>.squashfs + a current.json stamp) and staged by `just
# bundles-squashfs` when tilt brings the stack up — the host reads the stamp
# ONCE at startup (host_agent/src/lib.rs read_stamp) and reports the same
# current_bundles on every heartbeat, exactly like prod's Packer-baked stamp.
# The coord resolves a session's selected_skills + harness against that.
# `bundles-squashfs` stages `sentinel` (MANDATORY — base-snapshot capture
# resolves every reserved dyn-* slot to its sha) + `skills` (the catalog skill
# `e2e_session_has_mounted_skills_bundle` asserts).
#
# ADR 0062: the built-in `claude` harness rides that same stamp. Its tree
# (entry binary + claude CLI) is BUILT, not committed, so download it (from
# `bake-harness-claude-artifact`) and hand it to `bundles-squashfs` via
# ENGRAM_HARNESS_CLAUDE_TREE (next step) — it packs `harness-claude` into the
# stamp alongside skills/sentinel. No RegisterHarness; the coordinator
# resolves the built-in from the host's current_bundles + its embedded
# descriptor.
- name: Download harness-claude artifact
uses: actions/download-artifact@v8
with:
name: harness-claude-artifact
path: var/harness-claude-stage
- name: Download harness-codex artifact
uses: actions/download-artifact@v8
with:
name: harness-codex-artifact
path: var/harness-codex-stage
- name: Restore +x on the harness binaries + hand the tree to tilt
run: |
# upload/download-artifact's ZIP drops Unix mode bits; the guest execs
# /opt/engram/dyn/0/harness, so it must stay executable in the squashfs.
chmod +x var/harness-claude-stage/harness var/harness-claude-stage/claude
chmod +x var/harness-codex-stage/harness var/harness-codex-stage/codex
ls -la var/harness-claude-stage/
# Point `just bundles-squashfs` (tilt runs it next) at this downloaded
# tree so it packs `harness-claude` into var/shared's stamp.
echo "ENGRAM_HARNESS_CLAUDE_TREE=$PWD/var/harness-claude-stage" >> "$GITHUB_ENV"
echo "ENGRAM_HARNESS_CODEX_TREE=$PWD/var/harness-codex-stage" >> "$GITHUB_ENV"
# ADR 0080: likewise hand it the pre-built musl agentd (downloaded
# with the e2e binaries above) so packing `bundle-agentd` doesn't
# recompile anything in this no-cargo lane.
echo "ENGRAM_AGENTD_BIN=$PWD/target/x86_64-unknown-linux-musl/release/engram-agentd" >> "$GITHUB_ENV"
# `just bundles-squashfs` (the tilt `bundles` resource) packs the RO bundles
# with mksquashfs, so squashfs-tools must be on PATH before the stack comes up.
- name: Install squashfs-tools (for bundles-squashfs)
run: sudo apt-get update -qq && sudo apt-get install -y -qq squashfs-tools
# A Firecracker host-agent needs a session-disk pool; Tilt names
# engram-pool for the Firecracker backend, and engram-pool-b for the
# second host-agent of the two-host variant.
- name: Build the dm-thin pools
run: |
sudo apt-get install -y -qq --no-install-recommends thin-provisioning-tools
sudo env POOL_DIR=/var/lib/engram/thin POOL_DATA_SIZE=12G POOL_META_SIZE=256M \
sh deploy/helm/engram-host-fleet/files/thin-pool.sh
if [ "${{ matrix.two_hosts }}" = "1" ]; then
sudo env POOL_NAME=engram-pool-b POOL_DIR=/var/lib/engram/thin-b \
POOL_DATA_SIZE=12G POOL_META_SIZE=256M \
sh deploy/helm/engram-host-fleet/files/thin-pool.sh
fi
- name: Bring up prod-shape stack (tilt)
env:
ENGRAM_INTEG_BIN_DIR: ./target/release
ENGRAM_SKIP_WEB: "1"
# Per-session egress proxy. The local dev path defaults to
# disabled (unfiltered network — relies on the dev VM's host
# masquerade). The Blacksmith runner doesn't NAT FC TAP
# traffic to its outbound interface, so guests need to route
# via the proxy. Mirrors what `e2e_harness.rs` in
# test-fc-e2e already does at the PooledBackend layer.
# (Host-b gets a distinct port in the two-host variant; see
# the Tiltfile.)
ENGRAM_EGRESS_PROXY_PORT: "14443"
# Empty for suite (single host), "1" for teleport (host-a +
# host-b). tilt-up-ci.sh waits for the matching host count.
ENGRAM_INTEG_TWO_HOSTS: "${{ matrix.two_hosts }}"
run: |
# ADR 0025/0027: boot the OWNED guest kernel (6.1.102) the fetch
# script provides + prod runs — it carries CONFIG_SQUASHFS_ZSTD=y so
# the init-shim can mount the RO bundles. (The stale vmlinux-5.10.223
# reference predated ADR 0025 owning the kernel.)
export ENGRAM_KERNEL_IMAGE_PATH="$HOME/.cache/engram-fc-test/vmlinux"
bash deploy/dev/tilt-up-ci.sh
# ADR 0013: host-agent doesn't read docker config; it asks
# the coord per-pull, and the coord reads sealed credentials
# from the `registry_credentials` PG table populated via
# `engrams registry add` (→ the orchestrator's ImageService
# passthrough). Seed ghcr.io with the GITHUB_TOKEN this job was
# issued (the `permissions: packages: read` block at the top of
# this job is what makes it pullable). Pipe via --password-stdin
# so the token never lands in argv / ps. Endpoint + admin key
# come from the shared helper (tilt-up-ci.sh already waited for
# the seeded var/dev-api-key).
- name: Seed GHCR credential in coord PG
env:
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
source deploy/dev/engrams-cli.sh
printf '%s' "$GHCR_TOKEN" | engrams \
registry add \
--host ghcr.io \
--username "${{ github.actor }}" \
--password-stdin
# ADR 0062: the built-in claude harness is no longer registered or pushed
# to a local registry — its tree was downloaded + packed into the host stamp
# before the stack came up (see "Download harness-claude artifact" + the
# stage step above), so the coordinator resolves it from `current_bundles`.
- name: Bake demo image + capture URI
run: |
IMAGE_URI=$(bash deploy/dev/integration-bake-demo.sh)
echo " baked image: $IMAGE_URI"
echo "ENGRAM_E2E_IMAGE_URI=$IMAGE_URI" >> "$GITHUB_ENV"
- name: Run e2e_stack tests
env:
# ADR 0051 Drip E: the coordinator's web-facing REST surface is
# gone; e2e_stack now drives the coord over app-gRPC. These match
# the Tiltfile's coord_env (ENGRAM_APP_GRPC_ADDR /
# ENGRAM_APP_GRPC_TOKENS). The address needs the http:// scheme so
# tonic's Endpoint::from_shared parses it.
ENGRAM_E2E_GRPC_ADDR: http://127.0.0.1:50061
ENGRAM_E2E_GRPC_TOKEN: dev-app-grpc-token
# ENGRAM_E2E_IMAGE_URI set via $GITHUB_ENV in the bake step;
# points at the just-baked `demo` image (harness-free; ADR 0062 —
# the `claude` harness rides the host `current_bundles` stamp).
# suite: "" → the two-host evac test self-skips (and is filtered out
# below anyway). teleport: "1" → the evac test hard-asserts that >=2
# hosts registered (a single-host regression fails loud instead of
# silently skipping).
ENGRAM_EXPECT_TWO_HOSTS: "${{ matrix.expect_two_hosts }}"
# Retirement deletes a fixture host, so it runs last in a separate invocation.
E2E_NEXTEST_FILTER: "${{ matrix.nextest_filter }}"
run: |
cargo nextest run \
-p engram-coordinator \
--test e2e_stack \
--run-ignored ignored-only \
--no-fail-fast \
--test-threads=1 \
-E "$E2E_NEXTEST_FILTER"
if [ "${{ matrix.variant }}" = "teleport" ]; then
cargo nextest run -p engram-coordinator --test e2e_stack --run-ignored ignored-only \
-E 'test(e2e_retire_host_relocates_and_grants)'
fi
- name: Dump tilt + stack logs on failure
if: failure()
run: |
# Full log minus the two DEBUG heartbeat spam lines that
# drown everything (the disagreement alarm fires 2/s for
# harness=none sessions); cap defensively at 20k lines.
echo "--- tilt.log (filtered, last 20000 lines) ---"
grep -vE "disagreement alarm|op deferred \(retryable\)" \
var/integration/tilt.log 2>/dev/null | tail -20000 || true
# The control-plane's end state: which sessions/ops are
# wedged and what they're holding.
echo "--- sessions table ---"
docker exec "$(docker ps -q --filter ancestor=postgres:16 | head -1)" \
psql -U engram -d engram -c \
"SELECT id, status, host_id IS NOT NULL AS bound_host, sandbox_id, \
park_rung, mem_budget_mib, evict_attempts, missing_strikes, \
created_at, last_active_at FROM sessions ORDER BY created_at" \
2>/dev/null || true
echo "--- session_ops (non-terminal) ---"
docker exec "$(docker ps -q --filter ancestor=postgres:16 | head -1)" \
psql -U engram -d engram -c \
"SELECT id, session_id, kind, state, attempts, not_before, claimed_by \
FROM session_ops WHERE state IN ('queued','running') ORDER BY id" \
2>/dev/null || true
echo "--- snapshots (latest 15) ---"
docker exec "$(docker ps -q --filter ancestor=postgres:16 | head -1)" \
psql -U engram -d engram -c \
"SELECT id, session_id, recoverable, disk_manifest_id IS NOT NULL AS has_disk, \
memory_manifest_id IS NOT NULL AS has_mem, created_at \
FROM snapshots ORDER BY created_at DESC LIMIT 15" \
2>/dev/null || true
- name: Tear down stack
if: always()
run: |
# `tilt down` re-evaluates the Tiltfile, which fail()s if the
# FC kernel env isn't set (only the bring-up step exported it).
# ADR 0025/0027: boot the OWNED guest kernel (6.1.102) the fetch
# script provides + prod runs — it carries CONFIG_SQUASHFS_ZSTD=y so
# the init-shim can mount the RO bundles. (The stale vmlinux-5.10.223
# reference predated ADR 0025 owning the kernel.)
export ENGRAM_KERNEL_IMAGE_PATH="$HOME/.cache/engram-fc-test/vmlinux"
bash deploy/dev/tilt-down-ci.sh || true
# ─────────────────────────────────────────────────────────────────────
# macOS / Apple-Silicon coverage (consolidated here from the former
# ci-macos-vz.yml — one workflow + one detect + one gate, no duplicate). Two
# jobs, path-gated on `test_rust` like the Linux Rust lanes, on Blacksmith M4
# runners (faster than the GitHub-hosted macos SKU). Protects the macOS dev-loop
# surface; Linux/FC remains the canonical production gate.
vz:
name: engram-sandbox-vz unit tests
needs: detect
if: needs.detect.outputs.test_rust == 'true'
runs-on: blacksmith-6vcpu-macos-15 # arm64, has Xcode CLT pre-installed
steps:
- uses: actions/checkout@v7
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin
# ADR 0013: engram-protocol/build.rs needs protoc.
- uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: Swatinem/rust-cache@v2
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Install entitlements (verify file is well-formed plist)
run: plutil -lint crates/engram-sandbox-vz/entitlements.plist
- name: Build sandbox-vz test binaries (nextest shape)
# MUST be `cargo nextest run --no-run` — the same invocation shape the
# run steps use, so they reuse these exact binaries and the signatures
# below survive. A plain `cargo build -p a -p b --tests` resolves
# features differently and nextest would recompile fresh UNSIGNED
# binaries after codesign (ADR 0096).
run: cargo nextest run -p engram-sandbox-vz --no-run
- name: Codesign with virtualization entitlement
run: bash crates/engram-sandbox-vz/scripts/codesign.sh debug
# `if: always()` from here so one VZ-test step's failure doesn't hide the
# ones after it — same pattern as the lint / test-linux jobs.
- name: Run engram-sandbox-vz unit tests (default)
if: always()
run: cargo nextest run -p engram-sandbox-vz --no-fail-fast
# The ignored VZ tests split two ways here:
# - `config_validation_surfaces_clear_error_without_entitlement` builds a
# VZ config and asserts `validateWithError:` surfaces a clear error. It
# never boots a VM, but it *does* stat a kernel + rootfs file, skipping
# if either is missing — so the pulled kernel + the empty placeholder
# below let it actually run.
# - the `e2e_vz_*` smokes DO boot real VMs. ADR 0096 made them
# self-staging (Docker-free rootfs via mkext4 + `just vz-e2e`), so
# they run HERE whenever the runner's hypervisor is available —
# probed explicitly below, since a hosted macOS runner may itself be
# a VM without nested virtualization. When the probe passes,
# ENGRAM_VZ_REQUIRE=1 turns any leftover preflight SKIP into a hard
# failure (no more skip-and-green); when it fails, the skip is loud
# in the log and `just vz-e2e` is the documented local pre-merge
# gate (ADR 0096 D3).
- name: Cache VZ test artifacts (kernel + Alpine minirootfs)
if: always()
uses: actions/cache@v6
with:
path: ~/.cache/engram-vz-test
key: vz-test-artifacts-${{ hashFiles('crates/engram-sandbox-vz/scripts/pull-kernel.sh', 'crates/engram-sandbox-vz/scripts/make-test-rootfs.sh') }}
- name: Pull VZ kernel (engram arm64 Image, ADR 0096)
if: always()
# GH_TOKEN: the kernel is a private release asset fetched via `gh`
# (same as the FC lane's fetch-fc-test-artifacts step).
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bash crates/engram-sandbox-vz/scripts/pull-kernel.sh
- name: Stage rootfs placeholder (for the non-booting config-validation test)
if: always()
run: touch /tmp/engram-vz-rootfs.ext4
- name: Run ignored VZ tests (config validation; e2e_vz runs live below)
if: always()
run: cargo nextest run -p engram-sandbox-vz --run-ignored ignored-only --no-fail-fast -E 'not test(e2e_vz)'
- name: Probe nested virtualization
id: hv
if: always()
run: |
hv="$(sysctl -n kern.hv_support 2>/dev/null || echo 0)"
echo "hv=${hv}" >> "$GITHUB_OUTPUT"
echo "kern.hv_support=${hv}"
- name: Install live-e2e staging deps (just, squashfs-tools, musl cross cc)
if: always() && steps.hv.outputs.hv == '1'
run: |
brew install just squashfs messense/macos-cross-toolchains/aarch64-unknown-linux-musl
rustup target add aarch64-unknown-linux-musl
- name: Live VZ e2e (just vz-e2e — boots real VMs)
if: always() && steps.hv.outputs.hv == '1'
env:
# .cargo/config.toml names the nix devshell's aarch64-linux-musl-gcc;
# the brew tap installs aarch64-unknown-linux-musl-gcc. Env overrides
# the config linker for this step only.
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-unknown-linux-musl-gcc
# vz-e2e depends on pull-kernel (a no-op when the step above
# cached it, but `gh` still needs the token on a cache miss).
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: just vz-e2e
- name: Workspace check (catches downstream-of-VZ regressions)
if: always()
run: cargo check --workspace --all-targets
test-macos:
name: workspace tests (macOS arm64, excl. sandbox-vz)
needs: detect
if: needs.detect.outputs.test_rust == 'true'
runs-on: blacksmith-6vcpu-macos-15
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@nextest
# Same default set as Linux minus engram-sandbox-vz (the `vz` job runs that
# codesigned) — catches macOS-only regressions in cross-platform crates.
- name: cargo nextest run --workspace --exclude engram-sandbox-vz
if: always()
run: cargo nextest run --workspace --exclude engram-sandbox-vz --no-fail-fast
# The SINGLE required status check. Because the lanes above are path-gated (and
# so legitimately `skipped` on changes that can't affect them), they must NOT be
# required individually — a skipped required check never reports and would wedge
# the merge queue. Instead this gate ALWAYS runs, depends on EVERY lane (Linux +
# macOS + the e2e stack), and is the one required check: it passes iff each lane
# succeeded or was skipped, and fails on any `failure`/`cancelled`.
# ADR 0098 D7: the deterministic-simulation swarm. Fixed seed ranges
# (a CI failure is always locally reproducible: `just sim SEED=<n>`);
# the deep-horizon exploration arm is nightly-sim.yml. Runs whenever
# the Rust lanes run — the sim's dep closure is the coordinator itself.
test-sim:
name: simulation swarm (engram-dst)
needs: detect
if: needs.detect.outputs.test_rust == 'true'
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- name: Install protoc
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq --no-install-recommends protobuf-compiler
- name: Setup mold linker
uses: rui314/setup-mold@v1
- uses: Swatinem/rust-cache@v2
with:
shared-key: workspace-release-sim
# R3 (#722): faithful hosts are the swarm default now — every seed
# exercises the schedulable, digest-gated `candidates_for` path the
# coordinator actually runs. `--faithful` is passed explicitly (it is
# also the binary default) so the swarm's intent is self-documenting.
- name: chaos swarm (200 seeds x 1500 steps, faithful hosts)
run: cargo run -p engram-dst --release --bin sim -- --faithful --seeds 0..200 --steps 1500 --profile chaos
- name: calm swarm (100 seeds x 1500 steps, faithful hosts)
run: cargo run -p engram-dst --release --bin sim -- --faithful --seeds 0..100 --steps 1500 --profile calm
# ADR 0098 R-CoSim (rung 1): the coordinator↔host BOUNDARY simulator
# (engram-dst-cosim). Unlike test-sim (a swarm binary over the coordinator
# closure), this is a small set of DIRECTED pinned-seed scenarios
# — the real coordinator drivers and the real host-agent flows co-simulated
# over one shared clock — so it runs as `nextest`, not a swarm bin. Gated on
# the crate's own (deliberately spanning) release closure (detect's
# `test_cosim`).
test-cosim:
name: boundary simulation (engram-dst-cosim)
needs: detect
if: needs.detect.outputs.test_cosim == 'true'
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- name: Install protoc
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq --no-install-recommends protobuf-compiler
- name: Setup mold linker
uses: rui314/setup-mold@v1
- uses: Swatinem/rust-cache@v2
with:
shared-key: workspace-cosim
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: directed boundary scenarios
run: cargo nextest run -p engram-dst-cosim
# The seeded boundary swarm (rung 2, #784). Sized honestly for the
# two-sided (coordinator + host) cost: a 40-seed x 600-step window in each
# profile measures ~1.2s/window locally (per-seed ~29ms), well under 5
# min even with the release build. The wide/deep windows run nightly
# (nightly-sim.yml `cosim-swarm`); this fixed window replays the same
# territory on every PR. Reproduce a failure locally with the printed
# replay line.
- name: chaos swarm (0..40 x 600)
run: cargo run -p engram-dst-cosim --release --bin sim-cosim -- --seeds 0..40 --steps 600 --profile chaos
- name: calm swarm (0..40 x 600)
run: cargo run -p engram-dst-cosim --release --bin sim-cosim -- --seeds 0..40 --steps 600 --profile calm
# ------------------------------------------------------------------
# Build every container image a PR changes — WITHOUT pushing.
#
# `bake-images.yml` is `on: push: [main]` and ci.yml's `bake-demo-image` is
# gated on push-to-main, so before this job no workflow built any image on a
# pull request. A change to `docker/*.Dockerfile` therefore ran zero lanes:
# the detector correctly reported `images=true` and no test lane, the CI Gate
# passes when every lane is "succeeded-or-skipped", and the first real build
# happened on the push to main that deploys.
#
# That is how a base-image bump (PR #130: node 20 -> 25, rust 1.95 -> 1.97,
# nginx, busybox) sat green for two months having proved nothing.
#
# Build-only on purpose: publishing is still main's job, so this cannot churn
# the SHA tag the host-fleet DaemonSet pins (the 2026-07-20 incident where a
# spurious rebake rolled every FC host four times in 90 minutes).
#
# `node-assets` is deliberately excluded — it fetches Firecracker, the guest
# kernel and the RO bundles, and its own lane already gates those inputs.
# ------------------------------------------------------------------
build-images:
name: build ${{ matrix.image }} image (no push)
needs: detect
# Gated on `dockerfiles`, NOT the whole `images` lane. The lane also fires
# for any web/orchestrator/Cargo change, which would put three release
# image builds on every Rust PR for no signal `tests (linux)` does not
# already give. Only a build-instruction change needs this.
if: needs.detect.outputs.dockerfiles == 'true' && needs.detect.outputs.images_matrix != '[]'
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30
permissions:
contents: read
strategy:
fail-fast: false
matrix:
image: ${{ fromJSON(needs.detect.outputs.images_matrix) }}
steps:
- uses: actions/checkout@v7
- uses: docker/setup-buildx-action@v4
- name: Build ${{ matrix.image }}
uses: docker/build-push-action@v7
with:
context: .
file: docker/${{ matrix.image }}.Dockerfile
push: false
load: false
# NO `cache-to/from type=gha`, matching bake-images.yml — see the long
# comment there. That exporter round-trips to GitHub's real cache
# service from inside the Blacksmith microVM (~0.2 MB/s, ~24 min/job),
# and the repo had already blown past the hard 10 GB per-repo cap and
# begun evicting — which would take the `workspace-debug` rust-cache
# that lint/test-linux/test-e2e-stack depend on with it. The expensive
# layer here is a build-local `RUN --mount=type=cache` that BuildKit
# never exports to gha anyway; it stays warm through Blacksmith's
# colocated BuildKit cache.
ci-gate:
name: CI Gate
if: always()
needs:
- detect
- integrations-cli
- lint
- test-linux
- cross-musl-linux
- web
- site
- orchestrator
- buf
- test-fc-unprivileged
- test-fc-pooled
- test-fc-root
- test-ublk-root
- test-fc-e2e
- vz
- test-macos
- test-sim
- test-cosim
# The end-to-end coord lane + its upstream bake/artifact deps. Previously
# omitted (e2e was non-required), which let a red e2e merge — now gated.
- bake-harness-claude-artifact
- artifacts-e2e-stack
- test-e2e-stack
# A Dockerfile-only change used to run nothing at all; this lane is the
# one that now proves the image still builds.
- build-images
# ADR 0122: helm lint/template + terraform fmt/validate. A
# deploy-template-only change used to run nothing at all.
- deploy-config
runs-on: blacksmith-2vcpu-ubuntu-2404
steps:
- name: Check lane results
env:
NEEDS_JSON: ${{ toJSON(needs) }}
run: |
set -euo pipefail
# Per-lane result table. `skipped` is OK (path filter didn't match);
# fail only on `failure`/`cancelled`.
echo "$NEEDS_JSON" | jq -r '
to_entries
| sort_by(.key)
| (["LANE","RESULT"], ["----","------"], (.[] | [.key, .value.result]))
| @tsv' | column -t -s "$(printf '\t')"
failed=$(echo "$NEEDS_JSON" | jq -r '
[to_entries[] | select(.value.result != "success" and .value.result != "skipped") | .key]
| join(", ")')
if [ -n "$failed" ]; then
echo "::error::CI Gate failed — non-passing lanes: $failed"
exit 1
fi
echo "CI Gate passed."