# Distribution Contract for `codex-controller-loop` ## v1 Contract This document defines the first stable, versioned distribution contract for the Rust controller binary. It is the canonical compatibility and consumption reference for external projects. ## 1) Contract version and release identity - Contract version: `distribution-contract@1.0` - Release artifact identity is immutable for a given tuple: - `artifact_version` (semver) - `git_rev` (full SHA, immutable reference) - `toolchain` and `build_profile` - `target` - `dist_revision` (incrementing revision when rebuilds occur for the same release tuple) - Consumers must pin by immutable tuple, never by moving tags. ## 2) Canonical artifact entrypoint - Primary entrypoint: `codex-controller-loop` CLI. - Canonical binary names: - `codex-controller-loop` (single binary) - Canonical distribution entrypoint index: `dist/index.json`. - Deprecated compatibility entrypoint (removed after 2026-07-01): `dist/{distribution_contract_version}/index.json`. ## 3) Canonical dist layout and naming - `dist/` is the only published artifact namespace. - Directory template (contract version stable): - `dist/{distribution_contract_version}/{artifact_version}/{target}/{profile}/{toolchain}/{gitsha}/{dist_revision}/` - Example: `dist/1.0.0/0.1.0/x86_64-unknown-linux-gnu/release/1.84.0/ab12cd34/r1/` - Canonical artifact filename: - `codex-controller-loop-v{version}-{target}-{profile}-{rust}-{gitsha}-{dist_revision}.{ext}` - `version` = semver release (e.g. `1.4.2`) - `target` = Rust target triple - `profile` = `release` or `debug` - `rust` = rustc version string used in build - `gitsha` = short git commit hash of source revision - `dist_revision` = `r1`, `r2`, ... for immutable re-build iterations - `ext` = container format used by release pipeline (e.g. `tar.gz`) - Canonical generator entrypoint: - `scripts/release-orchestrator.py` (single orchestrator) - Controlled by `scripts/release-orchestrator.config.json` - Index manifest output: `dist/index.json` - Deterministic provenance snapshot in generated index: - Each index artifact row is keyed by `version + target + profile + toolchain + gitsha + dist_revision` - `artifact_file`, `manifest_file`, `checksums_file`, `artifact_sha256`, and `source_date_epoch` are emitted ## 8) Consumer integration examples Use the canonical index first, then fail fast if no rows match the requested immutable tuple. Optional legacy fallback is accepted only during migration. ```bash VERSION=0.1.0 TARGET=x86_64-unknown-linux-gnu PROFILE=release TOOLCHAIN=1.84.0 GITSHA=ab12cd34 DIST_REVISION=r1 INDEX=dist/index.json if [ ! -f "$INDEX" ]; then INDEX=dist/1.0.0/index.json echo "warning: using deprecated index path, remove by 2026-07-01" fi ARTIFACTS=$(jq -r --arg version "$VERSION" --arg target "$TARGET" --arg profile "$PROFILE" \ --arg toolchain "$TOOLCHAIN" --arg git "$GITSHA" --arg dist "$DIST_REVISION" \ '.releases[] | select(.version==$version) | .targets[] | select(.target==$target) | .profiles[] | select(.profile==$profile) | .artifacts[] | select(.toolchain|startswith($toolchain)) | select(.git_rev|startswith($git)) | select(.dist_revision==$dist) | .artifact_file' "$INDEX") COUNT=$(printf "%s\n" "$ARTIFACTS" | awk 'NF {count += 1} END {print count + 0}') if [ "$COUNT" -ne 1 ]; then echo "expected exactly one artifact for immutable tuple" >&2 exit 1 fi ARTIFACT_FILE=$(printf "%s" "$ARTIFACTS") echo "resolved artifact: $ARTIFACT_FILE" PACKAGE_DIR="${ARTIFACT_FILE%/*}/package" CHECKSUMS="$PACKAGE_DIR/checksums.json" python - <