// Prep-memo schema for the rust-plan target-cache preparation phase
// (soldr#1540). Hand-written prost mirror lives in `rust_plan_memo.rs`
// (`mod wire`); keep the two in sync. Round-trip unit tests in
// `rust_plan_tests/prep_memo.rs` catch drift.
//
// The memo caches the outputs of the three preparation subprocesses
// (`cargo metadata --format-version 1`, `rustc -Vv`, `cargo --version`)
// keyed by a content-identity hash over every input that can change
// their output: discovered/ancestor manifests, workspace manifest
// hashes, Cargo.lock, hierarchical `.cargo/config*` files, explicit
// `--config`/`--features`/`--manifest-path`-style passthrough args,
// toolchain binary identity (path + size + mtime), rustup channel
// pinning files, and the relevant environment variables.
//
// A memo whose `key_hash` no longer matches the freshly recomputed
// identity is discarded and the authoritative subprocesses run again.
// Decode errors, schema mismatches, and any discovery error also fall
// back to the authoritative subprocesses.

syntax = "proto3";

package soldr.rust_plan_memo.v1;

message RustPlanPrepMemoV1 {
  // Always 1 for this revision. Readers reject other values.
  uint32 schema_version = 1;
  // sha256 hex over the canonical JSON of the full identity key.
  string key_hash = 2;
  // Raw stdout of `rustc -Vv` (trailing whitespace preserved).
  string rustc_verbose_version = 3;
  // Raw stdout of `cargo --version`.
  string cargo_version_line = 4;
  // `cargo metadata` derived fields soldr actually consumes.
  string workspace_root = 5;
  string target_directory = 6;
  repeated string workspace_members = 7;
  repeated PrepMemoPackage packages = 8;
}

message PrepMemoPackage {
  string id = 1;
  // Package source (`registry+...` / `git+...`); empty for path deps.
  string source = 2;
  bool has_source = 3;
  // Absolute manifest path as reported by `cargo metadata`. Used to
  // re-hash path-dependency manifests that live outside the workspace
  // root during memo validation.
  string manifest_path = 4;
}
