MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / write_legacy_sidecar

Function write_legacy_sidecar

atomic-cli/src/commands/memory/bridge.rs:454–475  ·  view source on GitHub ↗

Mirror `attest`'s legacy sidecar write exactly ({node, source} wrapper).

(
        repo: &Repository,
        id: &str,
        node: &MemoryNode,
        inputs: &MemLiftInputs,
    )

Source from the content-addressed store, hash-verified

452
453 /// Mirror `attest`'s legacy sidecar write exactly ({node, source} wrapper).
454 fn write_legacy_sidecar(
455 repo: &Repository,
456 id: &str,
457 node: &MemoryNode,
458 inputs: &MemLiftInputs,
459 ) {
460 let path = attested_sidecar_path(repo, id);
461 std::fs::create_dir_all(path.parent().unwrap()).unwrap();
462 let mut artifact = serde_json::Map::new();
463 artifact.insert("node".to_string(), node.to_value());
464 let mut source = serde_json::Map::new();
465 source.insert(
466 "sourceContentHash".to_string(),
467 Value::String(source_content_hash(inputs)),
468 );
469 artifact.insert("source".to_string(), Value::Object(source));
470 std::fs::write(
471 &path,
472 serde_json::to_string_pretty(&Value::Object(artifact)).unwrap(),
473 )
474 .unwrap();
475 }
476
477 #[test]
478 fn test_normalize_memory_path_all_forms() {

Calls 7

parentMethod · 0.80
attested_sidecar_pathFunction · 0.70
source_content_hashFunction · 0.70
writeFunction · 0.50
unwrapMethod · 0.45
insertMethod · 0.45
to_valueMethod · 0.45