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

Function write_legacy_sidecar

atomic-cli/src/commands/memory/bridge.rs:396–417  ·  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

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

Calls 7

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