DevStack Guide

The CRAIG devstack is a Docker Compose environment that runs every piece of infrastructure and every application service on your own machine. It gives you a complete, self-contained development and testing environment: ephemeral data, pre-configured authentication, and realistic seed data.

Prerequisites

  • Docker Desktop (Windows/macOS) or Docker Engine (Linux)

  • Docker Compose v2 (included with Docker Desktop)

  • At least 8 GB of RAM allocated to Docker

On Windows, use Docker Desktop with the WSL 2 backend for best performance.

Quick Start

cargo xtask dev start

The start command:

  1. Builds all Docker images

  2. Starts infrastructure (PostgreSQL, RabbitMQ, Keycloak, Garage)

  3. Starts CRAIG services (rules, cases, placement, exchange, financial, reporting, security, intake, web)

  4. Initializes the Garage S3-compatible object store (idempotent)

  5. Waits for all services to pass health checks (up to 5 minutes)

  6. Runs the craig-seed one-shot container to load mock data

Once complete you will see:

==> CRAIG devstack is ready.

Open http://localhost:8080 to access the web UI. Log in with one of the test user accounts.

Command Reference

The cargo xtask dev command supports the following subcommands. Running with no arguments or help prints usage information.

start

Build images, start all containers, initialize Garage, and wait for health checks.

cargo xtask dev start

This is the primary command for bringing up the devstack. If the images are already cached, subsequent starts are faster: only changed layers are rebuilt.

stop

Stop all containers and remove them — including the fault profile’s Toxiproxy sidecar (#1636; before that fix the profile-gated sidecar survived a stop). Data volumes (Garage, PostgreSQL) are preserved, so a subsequent start will resume with existing data.

cargo xtask dev stop

reload

Rebuild containers and restart without wiping data. Useful after making code changes: the new binaries are compiled into fresh Docker images, but databases and object storage keep their data.

cargo xtask dev reload

This is equivalent to stop followed by start.

restart

Wipe all data and start fresh. Removes all containers, volumes, and orphan resources, then performs a full start including Garage initialization and seed data loading.

cargo xtask dev restart

Use this when you want a completely clean environment (e.g., after schema changes or to reset seed data).

reseed

Wipe data volumes and restart the stack with cached images. This is faster than restart because the built images are kept: only the containers are recreated and craig-seed re-run. cargo xtask e2e runs it first, because the integration battery leaves data behind and the e2e suite needs a clean seed.

cargo xtask dev reseed

Typical duration: 30–60 seconds versus ~20 minutes for a full restart.

restart-service

Restart a single CRAIG application service without touching the rest of the stack. Data volumes are preserved; the command polls the service’s /healthz endpoint and waits for a healthy response before returning. Used by the E2E cookie-lifecycle suite to prove sessions survive a web-tier restart (ADR-013).

cargo xtask dev restart-service craig-web
cargo xtask dev restart-service craig-security-issuer --kill

--kill sends SIGKILL to every container of the service (no graceful shutdown), starts it again and waits for every replica’s health (#2744; the identity capacity experiment’s killed-replica case, deployment guide § Identity capacity).

The service name is validated against the CRAIG application services list (craig-rules, craig-cases, craig-placement, craig-exchange, craig-financial, craig-reporting, craig-security, craig-security-issuer, craig-intake, craig-composition, craig-web, craig-portal, mock-server — CRAIG_SERVICES in xtask/src/docker.rs) to prevent arbitrary docker compose restart invocations.

clean

Stop everything and wipe all data without restarting. Like restart but without the subsequent start — leaves the environment fully torn down.

cargo xtask dev clean --confirm

status

Display a formatted table showing the state, health, ports, and uptime of every service.

cargo xtask dev status

Example output:

CRAIG Devstack Status
=====================

Infrastructure:
  SERVICE              STATE      HEALTH     ADDRESS (project network)  UPTIME
  -------              -----      ------     -------------------------  ------
  postgres             running    healthy    postgres:5432              47 minutes
  postgres-test        running    healthy    postgres-test:5432         47 minutes
  rabbitmq             running    healthy    rabbitmq:5672, rabbitmq:15672 47 minutes
  keycloak             running    healthy    keycloak:8080              47 minutes
  garage               running    healthy    garage:3900, garage:3903   47 minutes

Services:
  SERVICE              STATE      HEALTH     PORT(S)        UPTIME
  -------              -----      ------     -------        ------
  craig-rules          running    healthy    8001           47 minutes
  craig-cases          running    healthy    8002           47 minutes
  craig-placement      running    healthy    8003           47 minutes
  craig-exchange       running    healthy    8004           47 minutes
  craig-financial      running    healthy    8005           47 minutes
  craig-reporting      running    healthy    8006           47 minutes
  craig-security       running    healthy    8007           47 minutes
  craig-intake         running    healthy    8008           47 minutes
  craig-web            running    healthy    8080           10 minutes
  mock-server          running    healthy    9090           47 minutes

One-shot:
  SERVICE              STATE      HEALTH     PORT(S)        UPTIME
  -------              -----      ------     -------        ------
  craig-seed           exited     -          -              Exited (0)

Volumes:
  craig_garage-data
  craig_garage-meta

If nothing is running, it prints CRAIG devstack is not running (no containers found).

logs

Follow container logs in real time. With no argument, follows all services. With a service name, follows only that service.

# All services
cargo xtask dev logs

# Single service
cargo xtask dev logs craig-rules

Press Ctrl+C to stop following. If you pass an invalid service name, the script prints an error with the list of available services.

e2e

Run the Playwright end-to-end test suite against the running devstack. If the devstack is not running, it is started automatically.

# Run the full E2E suite (the Playwright report gives live counts;
# they drift too fast to pin here)
cargo xtask e2e

# Run only tests matching "rule" in the name
cargo xtask e2e --grep "rule"

# Run with a visible browser window
cargo xtask e2e --headed

# Step through tests interactively
cargo xtask e2e --debug

Any extra arguments are forwarded directly to npx playwright test inside the container. On failure, a hint is printed with the path to the HTML report:

Hint: open tests/e2e/playwright-report/index.html for the full report

help

Print the built-in usage text.

cargo xtask dev help

# Also shown when no arguments are given:
cargo xtask dev

Services and Ports

Nothing publishes a host port (plan merge-trains-gate design 3, #2922). The tables give each service’s compose name and container port: on the project network — inside cargo xtask dev exec, and for every test process — a service is http://<service>:<port>; (postgres:5432, http://keycloak:8080, …). The OIDC issuer is http://keycloak:8080/realms/craig.

For a browser on the host, cargo xtask dev start --profile dev layers docker-compose.dev.yml, which publishes five services on loopback and switches the issuer and the BFF redirect URIs to localhost:

Service Host URL (dev profile) Container

keycloak

http://localhost:8180 (issuer http://localhost:8180/realms/craig)

keycloak:8080

craig-web

http://localhost:8080

craig-web:8080

craig-portal

http://localhost:8081

craig-portal:8080

craig-intake

http://localhost:8008

craig-intake:8008

craig-intake-standalone-shines

http://localhost:8011

craig-intake-standalone-shines:8009

The the_compose_file_publishes_no_port_outside_the_dev_profile contract test (xtask) holds every other compose file to no ports: at all.

Infrastructure

Service Image Container port(s) Purpose

PostgreSQL 18

postgres:18-alpine

5432

Database server; each CRAIG service gets its own database

PostgreSQL 18 (test plane)

postgres:18-alpine (same devstack/postgres build)

5432 (postgres-test)

postgres-test carries only throwaway scratch and template databases (#1403). It keeps its data directory on tmpfs and runs with fsync=off, so the forced checkpoints that constant database creation and teardown trigger never land on the shared instance the services use.

RabbitMQ 4.2

rabbitmq:4.2-management-alpine

5672, 15672

Message broker (speaking AMQP, the standard message-queue protocol) plus its management UI

Keycloak 26.5

quay.io/keycloak/keycloak:26.5

8080

OpenID Connect (OIDC) identity provider; imports the craig realm on startup

Garage

dxflrs/garage:v2.2.0

3900, 3903

S3-compatible object storage for file attachments

CRAIG Services

Service Container port Database Purpose

craig-rules

8001

craig_rules

Rules and policy engine (rule sets in the JSON Decision Model, JDM)

craig-cases

8002

craig_cases

Case management (referrals, investigations, cases, plans)

craig-placement

8003

craig_placement

Placement and foster care (homes, placements, matching)

craig-exchange

8004

craig_exchange

Data exchange and ICPC (partners, agreements, transactions)

craig-financial

8005

craig_financial

Financial management (payments, rate tables, claims)

craig-reporting

8006

craig_reporting

Reporting and analytics (AFCARS, NCANDS, ad-hoc reports)

craig-security

8007

craig_security

Security, audit logging, compliance reviews, NIST controls

craig-security-issuer

8011

craig_security (login craig_security_issuer)

The internal token issuer (ADR-085 D2, #2741): craig-security’s image as craig-security issuer, depending on postgres and the migrate gate only. Listening, and so healthy, once its first signing key’s 60 s staged lead has passed (start_period 90 s; #3152), so cargo xtask dev start waits about a minute for it. Not yet trusted by any service (ADR-085 D15)

craig-intake

8008

 — (stateless edge per ADR-017; the pre-created craig_intake DB is never populated)

Public intake: the anonymous child abuse/neglect reporting API

craig-intake-keyring

8010

craig_intake_keyring

Signer registry + replay ledger for the standalone-SHINES signed path only (ADR-042 §D8)

craig-composition

8009

craig_composition

Composition layer engine: arranges plugin surfaces (ADR-035)

craig-web

8080

 — 

Web UI, built as a backend-for-frontend (BFF): it proxies to the backend services and handles authentication itself, so the browser never talks to them directly

craig-portal

8080 (host 8081 under the dev profile)

 — 

The caregiver self-service portal, a second BFF beside craig-web (ADR-076) for the PORTAL roles — pat.foster is its test user

mock-server

9090

 — 

A stand-in for the typed partner systems of the stack’s configuration layers, so craig-exchange adapters can be exercised in the devstack without any real partner endpoint (ADR-032). The mocks are the layers' own: the server loads each layer’s partners/simulators.wasm and mounts every simulator in it at /partner/{adapter_kind} (Georgia’s ten; DOE’s adapter token is doe_slds), and no build compiles a mock in (ADR-090, Partner modules). Seed data points the eight partners Georgia’s manifest gives a seed at http://mock-server:9090/partner/{adapter_kind}; the other four seeded partners (cwca, tanf, external_data, tribal) have no SHINES equivalent to mock and keep fake https URLs. Routes: GET /health returns the mounted kinds; partner traffic goes to GET|POST /partner/{adapter_kind}/…​. The DOE-SLDS mock is a partner simulator (#3188): it answers an entry that fails its request type’s validation (a required field absent, a length bound broken) with 422, an entry for a GTID it does not know as a student with ERR, and otherwise SNT, keeping the custody list and serving the weekly student file at GET /partner/doe_slds/weekly (the DOE simulator). The EMPI mock is the devstack’s person index (#3192): it holds clients under nine-digit ids, answers a find by name and date of birth at a score a test sets, creates a client on a registration and notes a participation (the EMPI simulator). Every route answers 401 to the bearer credential devstack-refused, and /_echo/{status} (any method, and any path below it, …/health included) answers that status with the request’s headers in its body, so tests can make a partner refuse or echo a credential (#1813). GET /_capture?path=/partner/{adapter_kind} and DELETE /_capture (a 1 024-request ring, #1835) return and reset the requests the mock received; the outbound-trigger suites assert the bytes a partner got there. The partner simulators are loaded through /_sim/people and /_sim/reload (#3188): MOCK_PEOPLE_FILE names the people file craig-seed writes into the partner-sim volume, mounted read-only here, which the server reads at boot and on the seed’s reload (Partner simulators).

One-Shot Containers

Container Purpose

craig-config-fetch

Fetches each configuration layer config-sources.lock pins (federal, georgia, texas), verifies its head commit against ci/config-trust/ and publishes it into the craig-config volume as /config/<name>/current, then exits (Config fetch (ADR-087, #2955)). Every service that loads configuration, and craig-seed, starts only after it exits 0.

returns-pki

Writes the devstack’s certificates for the partner-return listener (a return, #3193) into the returns-pki volume, then exits: a development authority, the listener’s certificate (for craig-exchange, localhost and 127.0.0.1) and one client certificate per partner simulator of the stack’s layers that calls CRAIG (Georgia’s: ies). It is the mock server’s image run as craig-mock-server pki --out /returns-pki. What the volume already holds is kept, so a certificate a test registered survives a restart; only what is missing is made. craig-exchange and the mock server mount the volume read-only and start after it. The keys exist only in the volume, and none of it is for production.

craig-seed

Generates and loads seed data into all databases once the services are healthy, using the craig-seed binary for scalable and optionally deterministic generation. Two environment variables control it: CRAIG_SEED picks the random seed (the compose file sets 42; leave it empty for a random run) and CRAIG_FAMILIES picks the dataset size (the compose file sets 12, the operational dataset; the binary’s own default of 9 is the byte-identity baseline from #1006). With CRAIG_SEED__PARTNER_SIM_URL set (the compose file names the mock server), it also writes the seeded people a partner could know to /partner-sim/people.json and, once the databases are loaded, has the mock server load them into its partner simulators; a refusal fails the seed (#3188). Exits with code 0 on success.

craig-e2e

Playwright browser tests. Only runs on demand via cargo xtask e2e or docker compose --profile e2e run --rm craig-e2e.

Databases

PostgreSQL is pre-configured with nine CRAIG databases:

CREATE DATABASE craig_rules;
CREATE DATABASE craig_cases;
CREATE DATABASE craig_placement;
CREATE DATABASE craig_financial;
CREATE DATABASE craig_exchange;
CREATE DATABASE craig_reporting;
CREATE DATABASE craig_security;
CREATE DATABASE craig_intake;
CREATE DATABASE craig_composition;

craig_intake is pre-created but never populated, because the intake edge is stateless per ADR-017. The databases are defined in devstack/postgres/init.sql, which runs on first startup and also creates the multibackend-profile IdP databases (authentik, zitadel) and the per-service migration-owner/runtime role pairs (#1310). Schema application happens in the per-service craig-<svc>-migrate one-shot gates (ADR-063); serving boot only verifies the schema.

Connection credentials: craig / craig (user/password), configured in docker-compose.yml.

Test Users (Keycloak)

The devstack imports a pre-configured craig realm with nine test users. The sub column is the UUID the realm import pins for each user (the seed and the test fixtures reference these values, so they must not change).

Username Password Roles sub (pinned UUID)

admin

password

admin

00000000-0000-0000-0000-000000000003

jane.doe

password

caseworker, supervisor

00000000-0000-0000-0000-000000000001

bob.smith

password

caseworker, eligibility_worker

00000000-0000-0000-0000-000000000002

carol.reader

password

readonly

00000000-0000-0000-0000-000000000004

dana.county

password

supervisor, county_director

00000000-0000-0000-0000-000000000005

rita.regional

password

supervisor, regional_director

00000000-0000-0000-0000-000000000006

sam.state

password

admin, state_office

00000000-0000-0000-0000-000000000007

paula.county

password

county_director — a PURE office role with no operational role: the two-axis authorization probe user (#1624)

00000000-0000-0000-0000-000000000008

pat.foster

password

foster_parent — a PORTAL role and no worker role: craig-web refuses the session (#1842); the portal admits it once a caregiver binding exists (ADR-076)

00000000-0000-0000-0000-000000000009

The Keycloak admin console is available at http://localhost:8180 under the dev profile (cargo xtask dev start --profile dev; login: admin / admin).

Four clients are configured:

  • craig-api: a public client with direct access grants (the resource-owner password credentials flow, ROPC), used by the CLI and integration tests

  • craig-ui: a public client using the authorization-code flow with PKCE (Proof Key for Code Exchange), used by the web UI

  • craig-portal-ui: a public client using the authorization-code flow with PKCE for the self-service portals — CLIENT-level lifespans (access 300 s, session idle 1800 s, session max 28800 s) and audiences craig-placement + craig-financial ONLY (ADR-076, #1843)

  • craig-portal: the portal BFF’s confidential client (realm role service:craig-portal, the same two audiences)

The realm carries 9 worker roles — admin, supervisor, caseworker, eligibility_worker, icpc_coordinator, readonly, county_director, regional_director, state_office — plus the 3 PORTAL roles (craig_auth::PORTAL_REALM_ROLES: foster_parent, family, provider), disjoint from the worker set. API handlers identify the acting worker by claims.sub; the web UI displays preferred_username (Security); the design is IdP-neutral with Keycloak as the reference backend (IdP integration).

Token lifetime for craig-api / craig-ui is 30 minutes. Long-running test sessions may hit 401 errors if tokens expire.

Object Storage (Garage)

Garage provides S3-compatible object storage for file attachments (case documents, exchange files). The start command initializes Garage automatically:

  1. Assigns the single node to a data center zone

  2. Applies the cluster layout

  3. Imports a static API key (GKdeadbeefdeadbeefdeadbeef)

  4. Creates the craig-dev bucket

  5. Grants read/write/owner permissions to the key

This initialization is idempotent: it skips if the bucket already exists.

Configuration

Environment Variables

Services are configured via CRAIG_<SERVICE>__* environment variables defined in docker-compose.yml. Key variables:

Variable Purpose

KC_HOSTNAME

Keycloak’s pinned frontend URL (default http://keycloak:8080; http://localhost:8180 under the dev profile). Keycloak 26 and later use hostname v2, which requires a full URL so the port is pinned in JWT iss claims.

OIDC_ISSUER

Full issuer URL for JWT validation (default http://keycloak:8080/realms/craig).

WEB_EXTERNAL_URL, PORTAL_EXTERNAL_URL

The browser-facing base of craig-web’s and craig-portal’s OIDC redirect URIs (default the container URLs http://craig-web:8080 and http://craig-portal:8080, which the in-network Playwright browser uses; the dev profile sets localhost).

CRAIG_EXCHANGETRIGGERS<INTERFACE>__ENABLED

Outbound-trigger consent per interface. The devstack sets CPRS and, since #1821, DOE_SLDS to true (production default off). The seeded partners carry no data-sharing agreement, so a trigger admission holds dsa-missing until a test (or you) installs an active partner with an admitting agreement.

CRAIG_EXCHANGECOLLECTIONS<INTERFACE>__ENABLED

Collection consent per interface, separate from the send consent above: whether an admin may collect what the partner published (#3188). Either consent variable must name an interface the deployment’s partner set has a leg of that kind for, or craig-exchange refuses to start (#3196). The devstack sets DOE_SLDS to true (production default off), and CRAIG_EXCHANGE__PLACEMENT_BASE_URL names craig-placement, which stores each admitted report. A run needs an active partner with an admitting agreement, as a send does.

CRAIG_EXCHANGERETURNSPORT, …TLS_CERT_FILE, …TLS_KEY_FILE, …__CLIENT_CA_FILE

The partner-return listener (#3193): port 8443 and the files of the returns-pki volume. They are read because an interface consents to a partner’s calls (below); craig-exchange’s /healthz lists the returns-listener worker running.

CRAIG_EXCHANGETRIGGERSIESENABLED, CRAIG_EXCHANGERETURNSIESENABLED

Consent to refer a submitted Medicaid application to the eligibility system (IES), and, as its own consent, to take that system’s calls on the return listener (production default off for both). The seeded IES partner row links no agreement and names no caller, and no certificate is registered, so a referral’s admission holds dsa-missing and a call is refused until a test claims the return slot (The IES simulator). Either consent must name an interface the partner set has a leg of that kind for, or craig-exchange refuses to start.

MOCK_RETURNS_LISTENER, MOCK_RETURNS_PKI_DIR (mock-server)

Where a partner simulator’s calls to CRAIG go (https://craig-exchange:8443) and the certificates they are made with (/returns-pki), for POST /_sim/partners/{kind}/run (Partner simulators). With either unset the mock server calls nobody.

CRAIG_PARTNER_SECRET_DEVSTACK_TOKEN, …_REFUSED (each with _HOSTS=mock-server), CRAIG_EXCHANGE__PARTNER_AUTH_PLAIN_HTTP_HOSTS=mock-server

Public, obviously fake partner secrets for the auth tests (#1813): a partner row naming devstack_token presents devstack-token; devstack_refused presents the value the mock refuses. Never real credentials; ADR-064’s store is not involved.

Passkeys (WebAuthn)

The keyring owns the passkey policy (ADR-082 D2); both SHINES intake instances fetch it at boot from GET /webauthn/config. On the devstack, the craig-intake-keyring service in docker-compose.yml sets CRAIG_INTAKE_KEYRINGWEBAUTHN_RP_ID to localhost and CRAIG_INTAKE_KEYRINGWEBAUTHN_ALLOWED_ORIGINS to two origins, one per instance: http://localhost:8011 (craig-intake-standalone-shines) and https://localhost:8013 (craig-intake-standalone-shines-tls), the fixed loopback ports a developer would publish them on. The dev profile publishes the first; the TLS instance is never published (#2922).

Why localhost: WebAuthn needs a secure context, and browsers treat http://localhost as one without TLS, so the plain-http instance qualifies as well as the TLS one. An RP ID is a host, not an origin, so the one RP ID covers both ports.

From a browser on the host, start the stack with --profile dev and open http://localhost:8011/keygen. A passkey created there is scoped to localhost. The TLS instance is not published: its certificate is self-signed, which a host browser does not trust. A browser that reaches intake by its container name is outside this policy: that host is neither the RP ID nor on the origin list. The Playwright project intake-ui-shines-tls therefore starts Chromium with a host-resolver rule that maps localhost:8013 to wherever the TLS instance listens, so its pages load from https://localhost:8013 and its virtual authenticator’s passkeys are accepted.

Split Keycloak URLs

Services use two Keycloak URLs:

Without the dev profile the two are the same URL; tests read the issuer as TestConfig::oidc_issuer (CRAIG_TEST__OIDC_ISSUER, which cargo xtask dev exec sets under the profile).

Dockerfiles (Not Bind Mounts)

Configuration files (RabbitMQ definitions.json, Keycloak realm export, Postgres init script, Garage config) are baked into images via COPY in their respective Dockerfiles under devstack/. This avoids a Docker Desktop on Windows bug where bind-mounted files are sometimes mounted as directories.

Config fetch (ADR-087, #2955)

No image carries jurisdiction configuration. The source lists are committed files under devstack/config-sources/, generated from config-sources.lock by cargo xtask config env (#3143): fetch.env (every locked layer, for the fetcher) and one <name>.env per jurisdiction layer (federal, then that layer). docker-compose.yml hands each to its services through env_file: as CRAIG_CONFIG_SOURCE, so a plain docker compose reads the same lists cargo xtask dev does (Deployment Guide § Running the compose stack without xtask). A pin bump regenerates them in the same change: cargo xtask config env --check, a gate of cargo xtask validate and a line of the car, fails naming each stale file, and the verbs that bring the stack up (dev start, refresh, reload, restart, reseed) refuse stale files before any compose call, so the devstack never runs on pins other than the lock’s. xtask passes compose only CRAIG_CONFIG_TRUST_HOST_DIR, the checkout’s ci/config-trust/. The craig-config-fetch one-shot publishes the layers into the craig-config volume. Every service that loads configuration mounts it read-only at /config with CRAIG_CONFIG_ROOT=/config and CRAIG_CONFIG_SOURCE set to the georgia list: craig-rules, craig-cases (with its migration gate and the craig-cases-rewrite tool service), craig-placement, craig-exchange, craig-financial, craig-reporting, craig-security, craig-composition, craig-web, craig-intake, the three craig-intake-standalone* services, craig-seed and the mock server, which serves the partner simulators those layers hold: Georgia’s ten mocks come from its layer’s partners/simulators.wasm, and the seed’s mock partner rows from its manifest (Partner modules). craig-intake-tx gets the texas list. Each takes its jurisdiction and its reference data (the layer’s bundle/ directory: rates, codes, calendars, theme, terminology) from those layers, boots from the verified commits, and the stateful services report them on GET /version with verified: true. craig-portal, craig-intake-keyring, craig-security-issuer and the other migration gates load no configuration.

The devstack sets CRAIG_RULES__RULE_SET_AUTHORITY=api on craig-rules: the seed loads the rule sets of every published layer (/config//current/.json) into craig-rules over the API, and the tests create and promote rule sets the same way. Under the default, config, craig-rules reconciles its rule sets from the layers and its write routes answer 409.

The stack records the names of the layers it is seeded from in .devstack/config-layers. A stack whose marker is absent or names other layers is wiped and reseeded on the next dev start or dev refresh, once.

A refused fetch (a commit not signed by a key in ci/config-trust/, an unreachable repository) exits non-zero, leaves /config/<name>/status.json saying why, and nothing that reads configuration starts: cargo xtask dev logs craig-config-fetch shows the reason. Bumping a pin is a cached rebuild; the fetch and the seed re-run against the new commits (Development Workflow).

Development Workflow

Making Code Changes

After modifying Rust source code, you must rebuild the Docker containers for changes to take effect:

cargo xtask dev reload

This rebuilds all images (Docker layer caching makes unchanged services fast) and restarts containers while preserving database data.

Running Integration Tests

Integration tests run on the host against the devstack services. Make sure to rebuild containers first if you’ve changed code:

# Rebuild and restart
cargo xtask dev reload

# Run the devstack battery (re-executes in craig-tools on the project network)
cargo xtask test --integration

Running E2E Tests

The Playwright e2e test suite runs in a Docker container against the web UI:

# Run the full suite (starts devstack if needed)
cargo xtask e2e

# Filter by test name
cargo xtask e2e --grep "dashboard"

# Debug a specific test interactively
cargo xtask e2e --debug --grep "login"

Connecting the CLI

The CRAIG CLI connects to devstack services via a profile configuration. The devstack publishes no host port, so run the CLI on the project network (cargo xtask dev exec — craig …, with the container URLs http://keycloak:8080/realms/craig, http://craig-rules:8001, …), or publish what you need. The profile below assumes ports reachable on localhost. Create or update ~/.config/craig/profiles.toml (Linux/macOS) or %APPDATA%\craig\profiles.toml (Windows):

[devstack]
oidc_internal_url = "http://localhost:8180/realms/craig"
keycloak_client_id = "craig-api"
rules_url = "http://localhost:8001"
cases_url = "http://localhost:8002"
placement_url = "http://localhost:8003"
exchange_url = "http://localhost:8004"
financial_url = "http://localhost:8005"
reporting_url = "http://localhost:8006"
security_url = "http://localhost:8007"
intake_url = "http://localhost:8008"

Then use:

craig --profile devstack rules sets list

Troubleshooting

Service Fails to Start

Check the service logs for errors:

cargo xtask dev logs craig-rules

If a service fails its health check, the start command will time out after 5 minutes and print the last 20 log lines automatically.

Port Conflicts

The devstack publishes no host port, so it cannot collide with a host listener. Under the dev profile it binds 127.0.0.1:8180, 8080, 8081, 8008 and 8011; a listener already on one of those fails the start with the daemon’s address already in use message. Stop that listener, or start without --profile dev.

RabbitMQ Authentication Errors

The RabbitMQ user is defined in devstack/rabbitmq/definitions.json with a SHA-256 password hash — not via the RABBITMQ_DEFAULT_USER environment variable. This is because the custom rabbitmq.conf (which loads definitions.json) overrides the Docker entrypoint’s generated config.

If you see AMQP authentication failures, verify that definitions.json contains a valid user entry.

Keycloak Token Expiry

Access tokens expire after 30 minutes. If integration tests or CLI commands start returning 401 errors after running for a while, re-authenticate:

craig --profile devstack auth login

Windows-Specific Issues

  • Git Bash path mangling: The xtask sets MSYS_NO_PATHCONV=1 to prevent Git Bash from converting /garage paths to Windows paths.

  • File bind-mount bug: Docker Desktop on Windows sometimes mounts files as directories. The devstack avoids this by baking config files into images via COPY in Dockerfiles. Do not switch to bind mounts.

  • Line endings: The craig-seed container runs a shell script that must have Unix line endings. The Dockerfile’s craig-seed stage runs sed -i 's/\r$//' to strip Windows carriage returns.

Starting Over

When in doubt, wipe everything and start fresh:

cargo xtask dev restart

This removes all containers, volumes, and orphan resources, then rebuilds and re-seeds from scratch.

File Layout

Path Purpose

docker-compose.yml

Service definitions, ports, environment variables, health checks

xtask/

Cargo xtask: the cross-platform home of cargo xtask dev and cargo xtask e2e

devstack/postgres/

PostgreSQL Dockerfile and init.sql (creates per-service databases)

devstack/rabbitmq/

RabbitMQ Dockerfile, rabbitmq.conf, and definitions.json (user/vhost)

devstack/keycloak/

Keycloak Dockerfile and craig-realm.json (realm import)

devstack/garage/

Garage Dockerfile and garage.toml (storage config)

devstack/seed/

seed.sh, the shell script that invokes the craig-seed binary and loads rule sets from JSON. The seed container image is built from the main Dockerfile (target: craig-seed).

tools/craig-seed/

Rust binary that generates deterministic, scalable seed SQL. Controlled via CRAIG_SEED and CRAIG_FAMILIES environment variables. The numbers it draws for columns the schema keeps unique (case numbers, foster home licence numbers, person identifiers) are issued once each: a row that draws a number an earlier row holds takes the next free one, so a large seed loads (#3183). At CRAIG_FAMILIES=45000 it yields about 27,700 cases, 9,200 foster homes and 16,800 active placements.

Dockerfile

Multi-stage build for all CRAIG Rust services and tools

tests/e2e/

Playwright test suite — Dockerfile, specs, page objects, fixtures

CI/CD

The ci-integration job (.gitlab-ci.yml) brings the stack up with raw docker compose, naming the checkout’s project explicitly (docker compose -p "$(xtask dev project)"), then runs xtask test --integration (then spelled --fault-gate), e2e, security and perf, which re-execute in craig-tools on the project network through the runner’s Docker socket — the same path as a laptop. No issuer or hostname override is needed. Plan merge-trains-gate U3 (#1739) replaced the job with cargo xtask ci stages, and plan ci-dev-loop U4 (#3046) those with the car job, which runs cargo xtask dev start and the developer’s lanes (Quality Gates § CI: the car).

Edit this page · latest