# Bake Integration
## Tasks
| Task | Core operation |
| --- | --- |
| `benchmark:list` | `Workspace::suites`: packages with `[package.metadata.base-benchmark]`, including unpublished packages. Nothing is built or run. |
| `benchmark:prepare` | `Workspace::prepare`: labelled `--tree LABEL=PATH` source trees, baseline first, plus `--replicas N` layout replicas of the baseline (one by default for two or more trees), built once for each feature set of the scenarios, or of those named with `--scenario`. `--overlay true` builds every tree with this workspace's workload package. Writes `artifacts.json`. |
| `benchmark:smoke` | `Workspace::smoke`: build the current tree and run every scenario once with its smoke arguments. `--program NAME=PATH`, repeatable, gives the path of each external program that a multi-process scenario's role runs (`Workspace::with_program`). |
| `benchmark:run` | `Workspace::run`: collect a scenario from prepared artifacts in `screening` or `recorded` mode. `--cpus` places a single-process scenario's workloads, and `--role-cpus ROLE=CPUS`, repeatable, each role of a multi-process scenario (`RunRequest::role_cpus`); `--program NAME=PATH`, repeatable, gives an external program's path, as for `smoke`. |
| `benchmark:summarize` | `summarize_directory`: regenerate `summary.json` from a complete campaign. |
The planned `benchmark:build` became `benchmark:prepare`, because the operation also freezes executables, records their identity, and builds the layout replica. Relative paths, external programs' included, are resolved against the Bake project root. Absolute paths are used as they are, and `--manifest-path` selects a standalone workspace, such as a benchmark suite excluded from the main workspace. Each `--tree` is built from its own `Cargo.toml`, so with a standalone suite every tree must name that suite's workspace directory within its checkout, such as `--tree base=../base/benchmarks/suite`. `prepare`, `run`, and `smoke` cancel on the first SIGINT, SIGTERM, or SIGHUP, so workload process groups are killed before the host lock is released, and preparation fails as cancelled and writes no manifest, either after the build in progress or at once when the signal reaches Cargo too, as Ctrl-C does; a second signal exits immediately. Bake errors carry only a message, so a cancelled task fails with the core's, such as `benchmark:prepare: preparation was cancelled`.
`prepare`, `run`, and `smoke` accept `--host HOST`, with `--remote-directory` and `--remote-program`, to run on a measuring host over SSH through the core's `remote::Remote`, exactly as the command's `--host` does: local paths are mirrored on the host, and outputs are copied back, also after a failure. The tasks then return what a local task returns, read from the downloaded output: the prepared manifest, or the summaries of the campaigns, regenerated locally and, for `smoke`, in declaration order. `--lock` and `--program` paths are the host's, relative to the remote user's home, and are forwarded unchanged, as the command forwards them; other relative paths are resolved against the project root before they are mirrored. A malformed `--cpus` or `--role-cpus`, or a malformed or repeated `--program`, fails before the host is contacted.
Tasks pass unset options through, and the core resolves every default, so a task and the `base-benchmark` command given equivalent options produce the same plan, summary, and errors. The core takes `--program` and `--role-cpus` as maps, so the tasks split each `NAME=VALUE` as the command does, with the command's errors, refusing a program named twice and letting a later `--role-cpus` for the same role replace an earlier one.
Registration uses ordinary `#[bake::task]` attributes and the crate-derived `benchmark:` namespace; there is no plugin registry. Discovery uses locked Cargo metadata rather than `bake_cargo::packages`, which deliberately filters for publishable packages. Historical `results/**/Cargo.toml` snapshots are never executed.
## Dependency
`bake-benchmark` depends on `base-benchmark`, never the reverse. It uses the `runner` feature of the released crate; its public API exposes `base-benchmark` types, so a semver-incompatible `base-benchmark` release needs a matching release of this crate.
This crate requires Bake 0.20.1 or a later 0.20 release. Tasks register through Bake's link-time slice, so a project resolving a semver-incompatible Bake would not see them; each Bake minor version needs a matching release of this crate. It also requires Rust 1.88, as Bake does. Consumers add this crate to their private `bake/Cargo.toml`. It is never a dependency of workloads or published libraries. Integration through `base-project` should follow demonstrated use in more than one project.
## Not yet covered
- Task options for capabilities the core does not yet implement: downstream patch preparation, revision archives, and external comparator subjects.
- History import, reporting, or a comparison UI; see the core's [history follow-up](https://github.com/base-rs/base-benchmark/blob/main/context/history.md).
- Investigation record generation. Use the core's [investigation convention](https://github.com/base-rs/base-benchmark/blob/main/context/investigations.md) and template by hand.
Later entry points must delegate to shared core APIs rather than add a Bake-only runner, store, or statistics pipeline.