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

Function project_emits_expected_shape

atomic-canonical/src/prov.rs:254–318  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

252
253 #[test]
254 fn project_emits_expected_shape() {
255 let person = "did:atomic:PERSONFINGERPRINT";
256 let value = project(&sample_input(person));
257
258 // Top-level named subgraph.
259 assert_eq!(
260 value.get("@id").and_then(Value::as_str),
261 Some("urn:atomic:provgraph:CHANGEBASE32")
262 );
263 assert_eq!(
264 value.get("@context").and_then(Value::as_str),
265 Some(CONTEXT_URL)
266 );
267
268 // Exactly Activity + SoftwareAgent + Person.
269 assert_eq!(graph_nodes(&value).len(), 3);
270
271 let activity = node_of_type(&value, "prov:Activity");
272 assert_eq!(
273 activity.get("@id").and_then(Value::as_str),
274 Some("urn:atomic:activity:session-123")
275 );
276 assert_eq!(
277 activity.get("associatedWith").and_then(Value::as_str),
278 Some("urn:atomic:agent:claude")
279 );
280 assert_eq!(
281 activity.get("actedOnBehalfOf").and_then(Value::as_str),
282 Some(person)
283 );
284 assert_eq!(
285 activity.get("generated"),
286 Some(&json!(["urn:atomic:change:CHANGEBASE32"]))
287 );
288 // `used` is populated (the flywheel input edge).
289 assert_eq!(
290 activity.get("used"),
291 Some(&json!([
292 "urn:atomic:intent:019efe85",
293 "urn:atomic:memory:01J8ZC4R8T"
294 ]))
295 );
296 assert_eq!(
297 activity.get("turnParent").and_then(Value::as_str),
298 Some("urn:atomic:activity:session-000")
299 );
300
301 // SoftwareAgent @id is a URN, NEVER a did:.
302 let agent = node_of_type(&value, "prov:SoftwareAgent");
303 let agent_id = agent.get("@id").and_then(Value::as_str).unwrap();
304 assert!(agent_id.starts_with("urn:atomic:agent:"));
305 assert!(!agent_id.starts_with("did:"));
306 assert_eq!(
307 agent.get("label").and_then(Value::as_str),
308 Some("Claude Code")
309 );
310 assert_eq!(
311 agent.get("vendor").and_then(Value::as_str),

Callers

nothing calls this directly

Calls 5

projectFunction · 0.85
sample_inputFunction · 0.85
node_of_typeFunction · 0.85
getMethod · 0.65
unwrapMethod · 0.45

Tested by

no test coverage detected