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

Function lift_task

atomic-canonical/src/lift.rs:227–309  ·  view source on GitHub ↗
(d: &Directive, id_base: &str, n: usize)

Source from the content-addressed store, hash-verified

225}
226
227fn lift_task(d: &Directive, id_base: &str, n: usize) -> Result<Task> {
228 let local =
229 d.id.clone()
230 .unwrap_or_else(|| format!("{}-{n}", slug(id_base)));
231 let mut touches: Vec<String> = Vec::new();
232 if let Some(f) = d.attr("touchesFile") {
233 touches.push(f.to_string());
234 }
235 for child in &d.children {
236 if child.name == "file-ref" {
237 if let Some(path) = child.attr("path") {
238 touches.push(path.to_string());
239 }
240 }
241 }
242 // A task may fulfill more than one acceptance criterion. Both `satisfies`
243 // and the `criteria` alias accept a comma-separated list; each entry becomes
244 // its own `urn:atomic:ac:*` edge rather than being collapsed into a single
245 // malformed URN.
246 let satisfies = d
247 .attr("satisfies")
248 .or_else(|| d.attr("criteria"))
249 .map(|v| {
250 v.split(',')
251 .map(str::trim)
252 .filter(|s| !s.is_empty())
253 .map(|s| as_urn("ac", s))
254 .collect::<Vec<_>>()
255 })
256 .unwrap_or_default();
257 let cards: Vec<_> = d
258 .children
259 .iter()
260 .filter(|child| child.name == "review-card")
261 .collect();
262 if cards.len() > 1 {
263 return Err(CanonicalError::Lift(
264 "a review task requires exactly one card result".into(),
265 ));
266 }
267 let review_card = cards
268 .first()
269 .map(|card| {
270 let required = |name| {
271 card.attr(name)
272 .filter(|s| !s.trim().is_empty())
273 .map(str::to_owned)
274 .ok_or_else(|| CanonicalError::Lift(format!("review-card requires {name}")))
275 };
276 Ok(crate::review_work::CardAssessment {
277 intent: required("intent")?,
278 criterion: required("criterion")?,
279 card: required("card")?,
280 result_hash: required("result")?,
281 outcome: match card.attr("outcome").unwrap_or("pending") {
282 "pending" => crate::review_work::CardOutcome::Pending,
283 "met" => crate::review_work::CardOutcome::Met,
284 "unmet" => crate::review_work::CardOutcome::Unmet,

Callers 1

lift_intentFunction · 0.85

Calls 9

as_urnFunction · 0.85
attrMethod · 0.80
cloneMethod · 0.45
pushMethod · 0.45
is_emptyMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected