Build pins from an already-read lift input set. Using the same inputs as the gated node guarantees the pins and the definition cannot disagree.
(
repo: &Repository,
inputs: &LiftInputs,
)
| 153 | /// Build pins from an already-read lift input set. Using the same inputs as |
| 154 | /// the gated node guarantees the pins and the definition cannot disagree. |
| 155 | pub fn context_from_inputs( |
| 156 | repo: &Repository, |
| 157 | inputs: &LiftInputs, |
| 158 | ) -> Result<EvidenceContext, EvidenceError> { |
| 159 | let node = intent_bridge::lift(inputs)?; |
| 160 | let mut next = Some(repo.current_view().to_string()); |
| 161 | let mut seen = HashSet::new(); |
| 162 | let mut view_chain = Vec::new(); |
| 163 | while let Some(name) = next { |
| 164 | if !seen.insert(name.clone()) { |
| 165 | return Err(EvidenceError::ViewCycle); |
| 166 | } |
| 167 | let info = repo.get_view_info(&name)?; |
| 168 | view_chain.push(EvidenceViewPin { |
| 169 | name, |
| 170 | merkle: info.state_base32(), |
| 171 | scope: info.kind_label().to_string(), |
| 172 | }); |
| 173 | next = info.parent_name; |
| 174 | } |
| 175 | Ok(EvidenceContext { |
| 176 | intent_id: node.id.clone(), |
| 177 | intent_substance_hash: intent_substance_hash(&node), |
| 178 | intent_source_hash: intent_bridge::source_content_hash(inputs), |
| 179 | view_chain, |
| 180 | }) |
| 181 | } |
| 182 | |
| 183 | /// Re-read an intent and its view chain. |
| 184 | pub fn read_context(repo: &Repository, id: &str) -> Result<EvidenceContext, EvidenceError> { |
no test coverage detected