- Project/component:
cargo-monocrate foundation contract - Canonical path:
crates/cargo-mono
- Runtime: Rust CLI (
cargosubcommand integration) - Primary language: Rust
- Release engineers operating monorepo version and publish workflows
- Maintainers running local and CI release automation
- Binary naming contract:
cargo-monomust remain compatible withcargo monoinvocation. - Binary entrypoint must force-link
swc_mallocallocator policy, while the library target remains allocator-agnostic for downstream consumers. - Command identifiers for lifecycle operations must remain stable and documented.
- Publish and bump workflows must preserve scriptable output contracts for automation.
bumpmust not create Git tags.publishis the only command allowed to create release tags, and only for packages listed in[workspace.metadata.cargo-mono.publish.tag].packages.publishmust always delegate tocargo publish --no-verify, including whencargo mono publish --dry-runis used.publishmust treat only index propagation lag and registry rate limiting as retryable failures; other publish failures must still fail immediately.- Retryable
publishfailures must retry indefinitely by default with capped exponential backoff (2s,4s,8s,16s,32s, then60s), and rate-limit retries must honorRetry-Afterwhen present. - Operators must be able to cap retry attempts via
cargo mono publish --max-attempts <count>orCARGO_MONO_PUBLISH_MAX_ATTEMPTS, with precedence--max-attempts> env > default unlimited retries. - Publish tag creation is opt-in by default (no config means no tags), must remain local-only (
git tagwithout push), and must use<crate>@v<version>naming. - Remote tag publication is owned by CI automation:
.github/workflows/auto-publish.ymlmust rungit push --tagsafter a successfulpublishcommand, with checkout credential persistence disabled and authentication bound tosecrets.GH_TOKEN(non-GITHUB_TOKEN) so downstream tag-triggered workflows run. - If
publishtag configuration references unknown workspace packages, command execution must fail withinvalid-input. - Human-output color contract:
- Global CLI flag:
--color <auto|always|never>. - Environment override:
CARGO_MONO_OUTPUT_COLOR=auto|always|never. - Global opt-out:
NO_COLOR. - Precedence:
--color>CARGO_MONO_OUTPUT_COLOR>NO_COLOR> auto-detection.
- Global CLI flag:
- Machine-readable contract: JSON output must remain ANSI-free and schema-stable regardless of color settings.
- Uses workspace metadata and package manifests as canonical input.
- Uses temporary local files/caches only for transient command execution.
- Publishing workflows must rely on explicit credentials and least-privilege secrets.
- Logs and errors must avoid exposing secret registry tokens.
- Use structured
tracinglogs for release automation operations. - Include command phase, package target, and outcome status for debugging.
- Retry logs must include retry reason, retry attempt number, configured retry-limit mode, and computed delay seconds.
- Keep
CARGO_MONO_LOG_COLORsemantics scoped to structured log rendering (separate from human result-output color controls).
- Runtime errors must use a fixed three-line format:
Summary: ...Context: key=value, ...Hint: ...
- Context values must include safe operational data (for example package name, manifest path, command, status, attempt count) needed for debugging.
- Context values must normalize whitespace and be length-limited to avoid noisy or unsafe output.
- Dependency-cycle conflicts from package ordering must include
selected_count,selected_sample,unresolved_count,unresolved_sample,cycle_package_count,cycle_packages, anddependency_scope=all-cargo-metadata-kinds. - Cargo metadata load failures must include
working_directoryandmetadata_commandcontext keys in addition to the underlyingerrordetails. - Human stderr must include stable error kind labels while preserving the existing exit-code mapping contract.
- Publish failure summaries must prefer actionable
details_excerptcontent in this order: firsterror:line, then firstfailed to ...line, then first non-empty line. - Error messaging improvements must not change CLI command behavior or JSON output schema keys.
- Error and log output must not expose secret credentials or registry tokens.
- Local validation:
cargo test -p cargo-mono - Workspace validation baseline:
cargo test --workspace --all-targets - CI alignment:
.github/workflows/CI.ymlRust jobs - Release contract checks should align with
.github/workflows/release-cargo-mono.yml. - Release signing outputs must use Sigstore bundle sidecars (
SHA256SUMS.sigstore.jsonand<artifact>.sigstore.json).
- Integrates with Cargo workspace metadata and release workflows.
- Integrates with root automation (
auto-publish) through stable command contracts, including CI-driven tag publication. - Integrates with tag-based binary distribution automation (
release-cargo-mono) through stable artifact naming and bundle-signing contracts.
- Update
docs/project-cargo-mono.mdwith this file when command identifiers or ownership changes. - Update
crates/AGENTS.mdand rootAGENTS.mdwhen policy or path contracts change.
docs/project-cargo-mono.mddocs/domain-template.md