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

Function substance_hash_tracks_the_definition

atomic-canonical/src/node.rs:471–537  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

469
470 #[test]
471 fn substance_hash_tracks_the_definition() {
472 let base = intent_substance_hash(&node());
473
474 // Editing a criterion's text changes the definition — hash moves.
475 let mut edited = node();
476 edited.has_acceptance_criterion[0].text = "a different outcome".to_string();
477 assert_ne!(
478 intent_substance_hash(&edited),
479 base,
480 "AC text must move substance"
481 );
482
483 // Adding a task changes the definition — hash moves.
484 let mut tasked = node();
485 tasked.has_task.push(Task {
486 type_: "Task".to_string(),
487 id: "urn:atomic:task:sub-1-1".to_string(),
488 text: "do the thing".to_string(),
489 task_status: "open".to_string(),
490 touches_file: Vec::new(),
491 satisfies: Satisfies::default(),
492 });
493 assert_ne!(
494 intent_substance_hash(&tasked),
495 base,
496 "a new task must move substance"
497 );
498
499 // requiredKinds is part of the AC *definition* (the verification bar),
500 // not review state — changing it moves the hash.
501 let mut required = node();
502 required.has_acceptance_criterion[0].required_kinds = vec!["unit".to_string()];
503 let with_one = intent_substance_hash(&required);
504 assert_ne!(
505 with_one, base,
506 "adding a requiredKinds entry must move substance"
507 );
508
509 required.has_acceptance_criterion[0]
510 .required_kinds
511 .push("e2e".to_string());
512 assert_ne!(
513 intent_substance_hash(&required),
514 with_one,
515 "changing requiredKinds must move substance"
516 );
517
518 // A scope-out `::file-ref` is part of the reviewable boundary
519 // definition, so declaring a file out of scope moves the substance hash
520 // (it is NOT excluded by substance_view). The empty case is unchanged.
521 let mut scoped = node();
522 scoped.has_scope_out.push(ScopeItem {
523 type_: "ScopeItem".to_string(),
524 id: "urn:atomic:scope:sub-1-scope-out-1".to_string(),
525 text: "billing is off limits".to_string(),
526 files: Vec::new(),
527 });
528 let with_prose_scope = intent_substance_hash(&scoped);

Callers

nothing calls this directly

Calls 3

intent_substance_hashFunction · 0.85
nodeFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected