Expand description
cargoless-proto — the cross-crate contract for cargoless.
This crate is the seam the daemon (watcher/analyzer/model), the build
pipeline + CAS (build/cargoless-cas), the dev server (server), the CLI, and
future remote backends communicate through. Cross-boundary data flows as
these types; nobody reaches across a module boundary with a direct call.
Authoring this jointly and freezing it early is the whole point of Plane
CWDL-19 (D8) — the two-engineer split silently diverges otherwise.
§Why dependency-free and serde-free in v0 (decision of record)
v0 is single-machine, single-process: every consumer of these types links
cargoless-proto directly and passes them in-memory (channels / function args).
Nothing crosses a process or network boundary, so nothing needs to be
serialized. Adding serde now would (a) put a non-trivial dependency in the
crate every other crate depends on, slowing the cold build that AC#1/#2 are
measured against, and (b) freeze a wire format we have no v0 consumer for.
When a boundary genuinely needs serialization (the dev-server↔browser reload
channel speaks WebSocket — decision D3 — and remote CAS is a v1 want),
the owning crate adds serde here behind an off-by-default serde feature
and derives it on exactly the types that cross that boundary. The contract
shapes below are designed so that bolt-on is additive, never a reshape.
§The data-flow at a glance
watcher → analyzer → model ──StateEvent──▶ everyone (verdict stream)
│
└─on BecameGreen──▶ BuildTrigger ─▶ build/CAS
│
server ◀──BuildResult── build/CAS ◀─────┘The model is the single source of truth for “what works”; the build/CAS layer is the single source of truth for “is this exact input already built”. Everything else subscribes.
Structs§
- Artifact
Meta - Metadata persisted alongside every cached artifact in the CAS, and the payload the dev server consumes to decide whether to hot-reload the browser.
- Build
Identity - The complete set of inputs whose identity determines a build artifact.
- Build
Result - Returned by the build/CAS layer for each
BuildTrigger; consumed by the daemon (logging/state) and the dev server (reload decision — decisions D3 WebSocket signaling and D5 full-reload-not-hot-swap govern how the browser is told, not this contract). - Build
Trigger - Sent by the daemon to the build/CAS layer to request that a green input set
be made servable. The only legitimate cause of a
BuildTriggeris aStateEvent::BecameGreen— red inputs are never built (AC#4). - Check
Result - The rich one-shot check verdict: the existing boolean
TreeStatepaired with the full diagnostic list a user needs to fix a red tree. Returned by the adjacentcargoless_core::model::check_once_with_diagnostics; existing callers ofTreeState-returning APIs (check_once, frozen for cli-ux and the bench harness) are byte-unaffected. - Content
Hash - An opaque content hash, rendered as a hex string.
- Diagnostic
- One actionable diagnostic, surfaced by the LSP layer and aggregated by
the daemon model. Carries the absolute file path, 1-based (file:line:col)
position, severity, optional compiler/lint code, the human message, and
the diagnostic
sourcestring verbatim ("rustc"for cargo-check authoritative,"rust-analyzer"for native advisory, anything else for future tiers) so the CLI can both show provenance and the model can keep classifying authoritative-vs-advisory off the same value. - Input
Hash - The CAS key: the single digest derived from a
BuildIdentity. - Pointer
Format Error - Returned by
PublishedArtifact::parsewhen the pointer file is not the expectedcargoless-latest-green/v1shape. Dependency-free (nothiserror); a corrupt pointer is treated as “no green yet”, never half-decoded into a wrong artifact. - Published
Artifact - The latest-green publisher record (decision D-A1; AC#4 “never publish
red”). The build/CAS layer writes this beside the canonical pointer file
.cargoless/latest-greenon every servable green build; the CLIstatusreads it back. This is the only additive v0 contract surface — it does not touch the four frozen seams (StateEvent/BuildTrigger/BuildResult/ArtifactMeta) and adds no dependency: the on-disk form is a hand-rolled, versioned text codec (render/parse). - Target
Triple - The target triple a build is produced for (e.g.
wasm32-unknown-unknown). - Unix
Seconds - Wall-clock seconds since the Unix epoch (UTC). A newtype so a timestamp
cannot be transposed with any other
u64at a call site.cargoless-protois deliberately dependency-free, so there is nochrono/timehere: the producer (cargoless-core::build) fills this fromstd::time::SystemTime; this crate only carries the value.
Enums§
- Build
Outcome - What the build/CAS layer did with a
BuildTrigger. - File
State - Per-file compile verdict.
- Profile
- Cargo build profile. v0 inner-loop builds are always
Profile::Dev(workspace[profile.dev]pinsopt-level = 0, nowasm-opt, per the AC#3 latency constraint);Profile::Releaseexists in the contract so the identity is honest and a release build can never alias a dev artifact. - Severity
- Diagnostic severity, derived from the LSP
DiagnosticSeverityintegers (1=Error, 2=Warning, 3=Information, 4=Hint). A typed enum so the CLI renderserror/warning/info/hintheaders without re-deriving from raw numbers, and so a future consumer can pattern-match exhaustively. - State
Event - The event stream emitted by the daemon’s green/red model. Every other subsystem subscribes to this; nothing calls the model directly.
- Tree
State - Aggregate verdict for the whole watched tree.