midnight-saci

Development

Prerequisites

The workspace uses Rust edition 2024. The minimum supported Rust version is declared once as rust-version = "1.97" in Cargo.toml and matches the pinned toolchain and the Clippy msrv setting.

Build and run

cargo build                 # all crates
cargo run -p saci-cli -- --help
cargo run -p saci-backend -- --help
cargo run -p saci-worker -- --help

Build the worker image and run a fixture-backed plan in it with make image-check (the worker); CI does the same in its worker-image job.

Cargo.lock is committed so a fresh checkout resolves the same dependency versions. Use cargo build --locked to verify that.

Build commit

Every Saci binary contains the commit that it was built from. The run report and the web console show it, so you can identify the build that ran a run (environment details).

crates/saci-core/build.rs gets the commit as follows:

  1. If the SACI_BUILD_COMMIT environment variable is set, the build uses its value.
  2. Otherwise, the build uses the HEAD commit that git reports. Cargo builds again when HEAD or the current branch changes.
  3. If neither is available, the commit is unknown and the report does not include it.

The image build context does not contain .git. Thus make image and CI give the commit to the Containerfile as a build argument:

podman build -f Containerfile --build-arg SACI_BUILD_COMMIT="$(git rev-parse HEAD)" -t localhost/saci-worker:latest .

Workspace layout

Crate Kind Owns
saci-core library Contracts shared by every process: plan model, parser and bundles, YAML configuration, run/step/attempt/evidence/event/report types, outcome aggregation, redaction. No network, process or database access.
saci-mcp library MCP client connections (stdio and Streamable HTTP through rmcp), tool selection and argument checks against tool schemas. Used by the worker for step tools and by the backend for outcome actions.
saci-worker library + saci-worker binary Per-run execution: the agent-library integration, shell, HTTP and MCP tools, sequential plan execution, and reporting events to the backend.
saci-backend library + saci-backend binary The REST API, SQLite run records, worker launchers (Podman/Docker and Kubernetes Jobs), supervision and outcome actions.
saci-testkit library (test only) Controlled fixtures: a scripted OpenAI-compatible model server, a fake MCP server, a fake orders service and a fake Kubernetes API.
web/ TypeScript (React) The web console served by the backend at /ui/, embedded in every backend build once web/dist is built. Talks to the backend only through the REST API.
saci-cli saci binary Offline authoring, validation and agent skills (saci new test-plan, saci check, saci skill), backend startup, and run submission, progress, report and cancellation commands.
saci-script-runner library + saci-script-runner binary The MCP script runner: configured scripts as MCP tools over Streamable HTTP. It is installed and in the image, but no other crate depends on it and nothing starts it.
saci-julia library + saci-julia binary The Julia 1 judge: the open Julia 1 model in ONNX Runtime, as a System One judge service. It is installed, but no other crate depends on it and nothing starts it. Its build downloads ONNX Runtime.

Dependencies only point “down”: saci-cli → saci-backend/saci-core, saci-backend → saci-mcp/saci-core, saci-worker → saci-mcp/saci-core, saci-mcp → saci-core. saci-script-runner and saci-julia depend on no other Saci crate. The worker and the backend never link each other; they communicate through the REST contract in saci-core.

Agent skills

Agent skills are in skills/<name>/, at the repository root. Each skill has a SKILL.md with name and description front matter. The saci binary embeds the skills, and saci skill install writes them for a coding agent (command line).

To add a skill:

  1. Create skills/<name>/SKILL.md. The name must start with saci-, so that it does not clash with other skills, and the name in the front matter must be the same as the directory name. Write the skill in Simplified Technical English. Use full URLs for links to the Saci documentation, because the skill is installed outside this repository.
  2. Add the skill and each of its files to SKILLS in crates/saci-cli/src/skills.rs.
  3. Run make check. A test fails if a skill directory or file is not in SKILLS, or if a name does not obey these rules.

To use a skill while you work on Saci, install it into your checkout, for example with saci skill install --all --agent claude.

Quality gates

Run every gate CI runs with:

make check   # cargo fmt --check, cargo clippy -D warnings, cargo test

CI (.github/workflows/ci.yml) runs the same three jobs on every push to main and on pull requests, using the pinned toolchain. Its web job checks the console (make web-check, web console).

The lint baseline is adopted from the Wanaku Rust project:

Scoped exceptions:

Next steps