midnight-saci

Testing

This page is for contributors. It lists the test gates, the fixtures that replace real models and services, and what the main test suites check.

Run the tests

make check         # cargo fmt --check, clippy -D warnings, cargo test
make web-check     # web console checks, browser tests, backend console tests
make image-check   # build the worker image and run a plan in it

CI (.github/workflows/ci.yml) runs the same gates, and also the worker-image and kubernetes jobs below. See quality gates.

Fixtures

The saci-testkit crate has controlled fixtures, so tests need no real model or service: a scripted OpenAI-compatible model (saci-fake-model), a fake orders service (saci-fake-target), a fake MCP server and a fake Kubernetes API. Use them instead of real models or services.

The fake MCP server

saci-fake-mcp (in crates/saci-testkit) is a controlled MCP server with echo, fail, sleep and env tools, and record, which stands in for an external action: it appends each call to the file named by FAKE_MCP_RECORD. It speaks stdio by default, or Streamable HTTP with saci-fake-mcp --http 127.0.0.1:9090 (endpoint /mcp, requiring Authorization: Bearer $FAKE_MCP_TOKEN when that variable is set).

Saci tests Saci

test/ holds Saci test plans for Saci itself: one Saci runs them, with a real model, against a second Saci.

The Self-test workflow (.github/workflows/self-test.yml) runs these plans on each pull request and on each push to main, with the TypeSafe judge and, optionally, a model. See running the plans in CI for the repository secrets it needs.

Outcome actions

crates/saci-backend/tests/outcome_actions.rs replays recorded runs through the worker API, and the backend dispatches to a stdio saci-fake-mcp. The tests check the following:

crates/saci-backend/tests/action_approvals.rs checks that:

crates/saci-backend/tests/action_recovery.rs uses fixtures/recovery.yaml and fixtures/lost-responses.yaml. The fake server records each call and ignores repeated idempotency keys. The tests check that:

crates/saci-cli/tests/action_commands.rs drives saci actions list, show, approve, reject, redispatch and reconcile and the actions section of saci report.

saci-core unit tests check template rendering and configuration validation.

Supervision

MCP tools in steps

crates/saci-worker/tests/mcp_tools.rs runs whole plans through the saci-worker binary with the fake server. It checks the report, the redacted evidence, the offered tool names and schemas, tool and protocol errors, a server that cannot start, and runs without MCP.

Kubernetes Jobs

Helm chart

Worker images in CI

To enable publication, configure the repository secrets QUAY_USERNAME and QUAY_PASSWORD with credentials that can push to the Quay repository. The optional repository variables CONTAINER_REGISTRY and CONTAINER_GROUP override quay.io and the GitHub repository owner. Without both secrets, CI builds and tests the images but skips publication. Pull requests also build and test both architectures without publication. Architecture images use tags unique to the workflow run. The manifest job combines these images only after all CI jobs pass.

Next steps