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

Function write_legacy_sidecar

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

341
342 /// Mirror `attest`'s legacy sidecar write exactly ({node, source} wrapper).
343 fn write_legacy_sidecar(
344 repo: &Repository,
345 id: &str,
346 node: &MemoryNode,
347 inputs: &MemLiftInputs,
348 ) {
349 let path = attested_sidecar_path(repo, id);
350 std::fs::create_dir_all(path.parent().unwrap()).unwrap();
351 let mut artifact = serde_json::Map::new();
352 artifact.insert("node".to_string(), node.to_value());
353 let mut source = serde_json::Map::new();
354 source.insert(
355 "sourceContentHash".to_string(),
356 Value::String(source_content_hash(inputs)),
357 );
358 artifact.insert("source".to_string(), Value::Object(source));
359 std::fs::write(
360 &path,
361 serde_json::to_string_pretty(&Value::Object(artifact)).unwrap(),
362 )
363 .unwrap();
364 }
365
366 #[test]
367 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