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

Function build_report

atomic-repository/src/triage/report.rs:72–842  ·  view source on GitHub ↗

Build the canonical triage report for `feature` relative to `target`.

(
    repo: &Repository,
    feature: &str,
    target: &str,
)

Source from the content-addressed store, hash-verified

70
71/// Build the canonical triage report for `feature` relative to `target`.
72pub fn build_report(
73 repo: &Repository,
74 feature: &str,
75 target: &str,
76) -> Result<TriageReport, RepositoryError> {
77 // 1. The candidate set (T0): only-in-feature, closure additions, baggage.
78 let set = repo.triage_candidate_set(feature, target)?;
79 let project = repo.project_id()?;
80 let syntax = repo.syntax_index(Some(feature))?;
81
82 // 2. The pinned view Merkle (the materialized state the report is about).
83 let view_merkle = repo.get_view_info(feature)?.state_base32();
84
85 // Promotion scope: an unreviewed change BLOCKS promotion into a shared
86 // view, but is only a warning into a draft. Resolved once here.
87 let target_is_shared = repo.get_view_info(target)?.scope.is_shared();
88
89 // 3. The change → intent join.
90 //
91 // The change's modified files come from the change itself
92 // (`change_modified_paths`) — authoritative and present WITHOUT any KG
93 // enrichment. Only the intent side of the join (TOUCHES/HAS_TASK/SATISFIES,
94 // projected on `vault sync`) is read from the KG, so a change is orphaned
95 // iff no intent's task touches one of its files — never merely because
96 // `atomic vault query enrich` has not run.
97 //
98 // intent_to_changes: KG intent id → candidate hashes that reach it.
99 // ac_to_changes: KG ac id → candidate hashes that satisfy it.
100 let mut change_reports: Vec<ChangeReport> = Vec::new();
101 let mut intent_to_changes: BTreeMap<String, BTreeSet<String>> = BTreeMap::new();
102 let mut ac_to_changes: BTreeMap<String, BTreeSet<String>> = BTreeMap::new();
103 let mut reached_any_intent: HashMap<String, bool> = HashMap::new();
104 let mut all_modified_files: HashSet<String> = HashSet::new();
105 // Raw modified paths per candidate hash (for the actionable orphan message).
106 let mut change_raw_paths: HashMap<String, Vec<String>> = HashMap::new();
107 // Entities defined in each candidate's modified files (parallel to
108 // `change_reports`) — the seeds for the blast-radius walk below.
109 let mut change_entities: Vec<Vec<String>> = Vec::new();
110 // Walkthrough facts, collected in the same KG passes (no extra queries):
111 // path → module (PART_OF) and file → file dependency edges (IMPORTS/
112 // INCLUDES). Best-effort — empty on an unenriched KG.
113 let file_module = syntax.file_modules.clone();
114 let file_deps = syntax.file_deps.clone();
115 // Task facts from reached intents (id, text, touches, satisfies), in
116 // intent-id order — the walkthrough's narrative inputs.
117 let mut task_facts: Vec<TaskFact> = Vec::new();
118
119 for full in &set.only_in_feature {
120 let hash = Hash::from_base32(full.as_bytes());
121
122 // Authoritative modified paths straight from the change's file_ops —
123 // no KG `MODIFIES` edge (hence no `atomic vault query enrich`) required.
124 let paths: Vec<String> = hash
125 .map(|h| repo.change_modified_paths(&h).unwrap_or_default())
126 .unwrap_or_default();
127 change_raw_paths.insert(full.clone(), paths.clone());
128
129 // Review context straight from the loaded change (best-effort): commit

Callers 7

runMethod · 0.85
remediation_reportFunction · 0.85
report_with_intentFunction · 0.85
review_gate_reportFunction · 0.85

Calls 15

hunk_display_summariesFunction · 0.85
build_change_diffFunction · 0.85
kind_isFunction · 0.85
load_provenance_compactFunction · 0.85
parse_intentFunction · 0.85
load_intent_nodeFunction · 0.85
validate_intentFunction · 0.85
intent_substance_hashFunction · 0.85
load_intent_done_pinFunction · 0.85
mint_childFunction · 0.85
is_vault_pathFunction · 0.85