MCPcopy Create free account
hub / github.com/AIScientists-Dev/Flowtrace / validate

Function validate

crates/flowtrace-core/src/validate.rs:119–144  ·  view source on GitHub ↗
(r: &Trace)

Source from the content-addressed store, hash-verified

117}
118
119pub fn validate(r: &Trace) -> Result<()> {
120 validate_trace_id(&r.id)?;
121 let ident = ident_re();
122 for (k, step) in &r.steps {
123 if !ident.is_match(k) {
124 return Err(TraceError::Validation(format!(
125 "step id `{}` invalid",
126 k
127 )));
128 }
129 for fs in &step.from_steps {
130 if !r.steps.contains_key(fs) {
131 return Err(TraceError::Validation(format!(
132 "step `{}` references unknown step `{}`",
133 k, fs
134 )));
135 }
136 }
137 }
138 if has_cycle(r) {
139 return Err(TraceError::Validation(
140 "DAG cycle detected in from_steps".into(),
141 ));
142 }
143 Ok(())
144}
145
146fn has_cycle(r: &Trace) -> bool {
147 use std::collections::HashSet;

Callers 7

cmd_validateFunction · 0.85
getFunction · 0.85
add_stepFunction · 0.85
rename_stepFunction · 0.85
add_from_stepFunction · 0.85
validates_minimalFunction · 0.85
rejects_bad_idFunction · 0.85

Calls 3

validate_trace_idFunction · 0.85
ident_reFunction · 0.85
has_cycleFunction · 0.85

Tested by 2

validates_minimalFunction · 0.68
rejects_bad_idFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…