Imported from tuist/tuist (
cli/Sources/TuistCargoCommand/AGENTS.md). Install upstream withnpx skills add tuist/tuist --skill TuistCargoCommand. Copyright stays with the author.
Cargo decoration
tuist cargo forwards Cargo's command line without redefining its test semantics. The same command can be installed as a mise Cargo wrapper. test-build is Tuist's build-once nextest shard planner; nextest run applies a shard only when explicitly configured.
Compilation cache
- The implementation is Swift in this module, not a vendored engine, external cache tool, Rust executable, or mechanical translation.
tuist cargo __compileris the invocation-local compiler wrapper. Keep it free of authentication and command-event publication. Keep debug diagnostics on stderr rather than bootstrapping the generic Noora logger; stdout belongs to Cargo/rustc's protocol. CargoCacheSetupreads Tuist's existing configuration, resolvesCacheURLStoreandGetCacheTokenService, and refreshes a private mode-0600 token file. Failed remote setup leaves an isolated local cache. Inject endpoint/token services,CacheDirectoriesProviding, andFileSysteming. Store entries in the sharedCargocache category soXDG_CACHE_HOME, normal cache cleaning, support-cache retention, and runner byte budgets apply. The shared pruner addresses individual action/blob files and staging entries beneath each project, not the perpetually hot project directory. Successful blob reads usemarkCacheEntryUsedso active contents stay recent without protecting every old artifact in that project. There is no[cargo]configuration section or enablement knob. Clear inherited internal cache settings. Remote publication currently retains protected GitHub branch-push eligibility; other invocations read remotely and store locally.CargoCacheInvocationadmits only registry leaf libraries emitting dep-info, metadata, and an rlib. Hash the full package, compiler and toolchain libraries, arguments, working directory, and effective environment. Absolute paths intentionally remain in keys: this first version does not promise cross-checkout relocation. Recheck fingerprints before publication and restoration. Resolve bare and absolute compiler paths like the process launcher. Accept the known rustup proxy only with a pinned toolchain, and include both proxy and compiler bytes in the key; arbitrary custom launchers bypass caching.CargoInputHashershares digests only within one compiler invocation, rechecking device/inode/size/mode and exact mtime/ctime on every use; coarse change timestamps require rehashing and mutations during reads reject the entry. Source admission uses a complete bounded read and its exact digest in the key, and reuses lexical decisions only for already-validated content digests; do not independently read one source version for admission and another for hashing. Keep stat/streaming operations narrow because FileSystem does not expose this identity. Reject package/output symlinks (toolchain library file links may resolve only within the toolchain), incomplete/oversized snapshots, native linking/assembly,include!and identifier-concatenation macro sources, nonstandard code generation, extern dependencies, build scripts, procedural macros, incremental compilation, workspace crates, custom targets, and executables rather than guessing their inputs.- Cargo's dep-info must contain only package-local dependencies. Exclude volatile wrapper/session/jobserver settings from keys only when dep-info proves they were not read by the crate. Never cache failed compiler executions. Preserve and replay bounded stdout/stderr on hits; hits must not become compiler-observation rows.
CargoCompilationCacheuses the existingTuistREAPItransport with project-scoped SHA-256 Command/Action indexes and content blobs, never a new HTTP protocol. Verify every output digest and the complete expected output set, including bounded crate-prefixed split-debug objects, before materialization. Probe the complete local cache before constructing a remote transport. Kura's tenant/account header and REAPI project instance name are separate:owner/projectbecomes headerownerplus instanceproject, never instanceowner/project. Cache metadata calls use a one-second request timeout; large artifacts retain the shared transfer guards. A failed remote read disables publication for that compiler and opens a private session-scoped circuit so later compilers do not repeatedly wait on the same unavailable endpoint; a new Cargo command retries normally. Publish remote action results only after all referenced blobs exist. Corrupt, missing, unsupported, or unavailable entries fall back to compilation. Cache failures must not replace Cargo/compiler failures.CargoCacheMeasurementemits version-1 bounded aggregate and public inspection records. Key timings measure actual index operations, not compilation, hashing, or artifact transfers. CAS timings describe the measured batch operation shared by its blobs; byte counts describe uncompressed content. Transfers are observed, not inferred from task hits. The shared client distinguishes blobs actually uploaded from objects already present. No predictions, speculative prefetch, background publication, or estimated savings are implemented.- Keep
CargoCacheReportandCargoCacheDetailsReportbounded by file count, bytes, records, keys, and wire size. Never collect arbitrary compiler arguments, environment values, or credentials in telemetry, or infer local/remote hit provenance. Historical server payload fields remain compatible, but unsupported counters stay zero.
Cargo and nextest semantics
- Project, server, and network configuration is exclusively
tuist.tomlplus environment overrides, even in checkouts withTuist.swift. UseConfigLoader.loadCargoConfig; do not extend ProjectDescription for Cargo settings. - Dispatch Cargo before generic flag stripping and command analytics. Preserve Cargo's quiet/verbose flags, output, argument order, failures, and signals. Nested Cargo commands must not recursively decorate a session.
- Compiler observers record actual executions only. Preserve existing global compiler wrappers without interpreting their results as compiler executions; they bypass Tuist caching/observation. Leave custom workspace wrappers authoritative.
- Inherit terminal stdio for the primary command. Pin rustup's default toolchain before Cargo changes directories. Forward nightly
-Cwithout observation; sharding rejects it rather than executing an unfiltered suite. - Nextest enumeration is not execution. Never report tests omitted by fail-fast as passing. Nextest commands do not submit build reports because their wall time includes tests;
test-buildreports the compile-once/archive phase. - Stable identities use nextest binary IDs and Rust namespaces, not artifact hashes or checkout paths.
- Nextest binaries are concurrent module-level units, not Xcode suite-level units. Declare
concurrent_modulesand reuse the shared measured-concurrency planner with a longest-binary floor. Binary/suite timings use complete attempt timestamp windows, including retry delays and ignoring skips. Omit concurrency evidence when timestamps or wall time are missing; never infer utilization from CPU count or thread limits. - Analytics failures must not change Cargo's exit status. Planning/downloading failures must fail a shard rather than execute the entire suite.
- Repeatable archive upload/download, exactly-once shard execution, merged reports, and fail-closed checks live in
cli/Tests/Fixtures/CargoSharding/AGENTS.md. - Keep docs aligned with the deliberately narrow experimental cache. Do not claim parity with a general compiler cache, undeclared-input sandboxing, cross-worker qualification, quarantine enforcement, coverage, or selective testing.
