Mirror `attest`'s legacy sidecar write exactly ({node, source} wrapper).
(
repo: &Repository,
id: &str,
node: &CanonicalNode,
inputs: &LiftInputs,
)
| 390 | |
| 391 | /// Mirror `attest`'s legacy sidecar write exactly ({node, source} wrapper). |
| 392 | fn write_legacy_sidecar( |
| 393 | repo: &Repository, |
| 394 | id: &str, |
| 395 | node: &CanonicalNode, |
| 396 | inputs: &LiftInputs, |
| 397 | ) { |
| 398 | let path = attested_sidecar_path(repo, id).unwrap(); |
| 399 | std::fs::create_dir_all(path.parent().unwrap()).unwrap(); |
| 400 | let mut artifact = serde_json::Map::new(); |
| 401 | artifact.insert("node".to_string(), node.to_value()); |
| 402 | let mut source = serde_json::Map::new(); |
| 403 | source.insert( |
| 404 | "sourceContentHash".to_string(), |
| 405 | Value::String(source_content_hash(inputs)), |
| 406 | ); |
| 407 | artifact.insert("source".to_string(), Value::Object(source)); |
| 408 | std::fs::write( |
| 409 | &path, |
| 410 | serde_json::to_string_pretty(&Value::Object(artifact)).unwrap(), |
| 411 | ) |
| 412 | .unwrap(); |
| 413 | } |
| 414 | |
| 415 | #[test] |
| 416 | fn test_load_attestation_prefers_tracked_then_legacy() { |