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