`atomic memory write` over UpdateVaultEntity's MemoryWrite arm — the stdin read + frontmatter stay client-side (interactive/file-only); the store + materialize run handler-side and the content hash rides the response.
(args: &super::memory::write::MemoryWrite)
| 6410 | /// the store + materialize run handler-side and the content hash rides |
| 6411 | /// the response. |
| 6412 | pub fn memory_write(args: &super::memory::write::MemoryWrite) -> CliResult<bool> { |
| 6413 | // Freeform body from stdin — no lift/gate; this is the raw path. |
| 6414 | use std::io::Read; |
| 6415 | let mut content = String::new(); |
| 6416 | std::io::stdin() |
| 6417 | .read_to_string(&mut content) |
| 6418 | .map_err(CliError::Io)?; |
| 6419 | let path = crate::commands::memory::bridge::normalize_memory_path(&args.name); |
| 6420 | let frontmatter = serde_json::json!({ |
| 6421 | "name": args.name.replace(".md", ""), |
| 6422 | "type": args.r#type, |
| 6423 | }) |
| 6424 | .to_string(); |
| 6425 | let Some(session) = Service::open()? else { |
| 6426 | return Ok(false); |
| 6427 | }; |
| 6428 | let request = pb::UpdateVaultEntityRequest { |
| 6429 | repository: Some(session.reference.clone()), |
| 6430 | meta: request_meta(), |
| 6431 | kind: Kind::Memory as i32, |
| 6432 | id: args.name.clone(), |
| 6433 | update: Some(UpdateKind::MemoryWrite(pb::MemoryWriteAction { |
| 6434 | path: path.clone(), |
| 6435 | content: content.into_bytes(), |
| 6436 | frontmatter_json: frontmatter, |
| 6437 | })), |
| 6438 | expected: None, |
| 6439 | view: None, |
| 6440 | }; |
| 6441 | let response = session.update_vault_entity(request)?; |
| 6442 | let hash = response |
| 6443 | .write_hash |
| 6444 | .as_ref() |
| 6445 | .and_then(|hash| hash.value.clone().try_into().ok()) |
| 6446 | .map(|bytes: [u8; 32]| Merkle(bytes).to_base32()) |
| 6447 | .unwrap_or_default(); |
| 6448 | println!("Wrote memory: {} ({})", path, &hash[..12]); |
| 6449 | Ok(true) |
| 6450 | } |
| 6451 | |
| 6452 | /// `atomic vault goal start` over CreateVaultEntity (kind=GOAL) — |
| 6453 | /// GoalStartOptions' fields ride the request and the created goal's |
no test coverage detected