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

Function context_from_inputs

atomic-repository/src/intent_evidence.rs:155–181  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

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.
155pub 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.
184pub fn read_context(repo: &Repository, id: &str) -> Result<EvidenceContext, EvidenceError> {

Callers 3

runMethod · 0.85
read_contextFunction · 0.85
prepareFunction · 0.85

Calls 10

intent_substance_hashFunction · 0.85
get_view_infoMethod · 0.80
state_base32Method · 0.80
kind_labelMethod · 0.80
liftFunction · 0.70
source_content_hashFunction · 0.70
current_viewMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected