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

Method validate

atomic-canonical/src/review_decision.rs:495–543  ·  view source on GitHub ↗
(
        &self,
        scope: &ReviewScope,
        report: &Value,
        issues: &[ReviewIssue],
    )

Source from the content-addressed store, hash-verified

493 }
494
495 pub fn validate(
496 &self,
497 scope: &ReviewScope,
498 report: &Value,
499 issues: &[ReviewIssue],
500 ) -> Result<(), String> {
501 if self.schema != EVALUATION_SCHEMA
502 || self.scope_hash != scope.hash()
503 || self.report_hash != report_hash(report)
504 {
505 return Err("Evaluation is stale or belongs to a different review scope/report".into());
506 }
507 let mut seen = BTreeSet::new();
508 for evaluation in &self.passes {
509 if !seen.insert(evaluation.pass)
510 || !evaluation.evaluated
511 || evaluation.rationale.trim().is_empty()
512 {
513 return Err("Explicit evaluation and rationale are required exactly once for each of the three review passes".into());
514 }
515 let expected: BTreeSet<_> = issues
516 .iter()
517 .filter(|issue| issue.pass == evaluation.pass)
518 .map(|issue| issue.id.as_str())
519 .collect();
520 let mut accepted = BTreeSet::new();
521 for entry in &evaluation.accepted_degradations {
522 if entry.rationale.trim().is_empty()
523 || !expected.contains(entry.issue.as_str())
524 || issues
525 .iter()
526 .any(|issue| issue.id == entry.issue && !issue.waivable)
527 || !accepted.insert(entry.issue.as_str())
528 {
529 return Err("Accepted degradation must name an exact waivable current issue once with a nonempty rationale; integrity failures are not waivable".into());
530 }
531 }
532 match evaluation.disposition {
533 Disposition::Ready if !expected.is_empty() || !accepted.is_empty()=>return Err("Outstanding native evidence cannot be labelled ready; explicitly accept degradation or retain not_ready".into()),
534 Disposition::AcceptedDegradation if expected.is_empty() || accepted!=expected=>return Err("Every outstanding issue in an accepted-degradation pass must be explicitly accounted for".into()),
535 Disposition::NotReady if !accepted.is_empty()=>return Err("A not-ready pass cannot also claim accepted degradation".into()),
536 _=>{},
537 }
538 }
539 if seen != PASSES.into_iter().collect() {
540 return Err("All three passes must be explicitly evaluated".into());
541 }
542 Ok(())
543 }
544
545 pub fn insertion_disposition(&self) -> Disposition {
546 if self

Calls 11

report_hashFunction · 0.85
issuesFunction · 0.85
validate_reportMethod · 0.80
hashMethod · 0.45
insertMethod · 0.45
is_emptyMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
as_strMethod · 0.45
containsMethod · 0.45
into_iterMethod · 0.45