Fail runs that bypass goal gates

This commit is contained in:
Bryan Helmkamp 2026-08-01 12:10:12 -04:00
parent d16cd75c56
commit 885bc92122
No known key found for this signature in database

View file

@ -5,7 +5,7 @@ use rand::Rng;
use crate::condition::evaluate_condition;
use crate::context::Context;
use crate::outcome::{Outcome, StageOutcome};
use crate::outcome::Outcome;
/// Result of edge selection: the chosen edge and the reason it was selected.
pub(crate) struct SelectedGraphEdge<'a> {
@ -99,14 +99,13 @@ pub(crate) fn check_goal_gates(
graph: &GvGraph,
node_outcomes: &HashMap<String, Outcome>,
) -> std::result::Result<(), String> {
for (node_id, outcome) in node_outcomes {
if let Some(node) = graph.nodes.get(node_id) {
if node.goal_gate()
&& outcome.status != StageOutcome::Succeeded
&& outcome.status != StageOutcome::PartiallySucceeded
{
return Err(node_id.clone());
}
for (node_id, node) in &graph.nodes {
if node.goal_gate()
&& !node_outcomes
.get(node_id)
.is_some_and(|outcome| outcome.status.is_successful())
{
return Err(node_id.clone());
}
}
Ok(())
@ -632,6 +631,19 @@ mod tests {
assert_eq!(check_goal_gates(&g, &outcomes), Err("work".to_string()));
}
#[test]
fn goal_gates_unvisited_returns_node_id() {
let mut g = Graph::new("test");
let mut n = Node::new("verify");
n.attrs
.insert("goal_gate".to_string(), AttrValue::Boolean(true));
g.nodes.insert("verify".to_string(), n);
let outcomes = HashMap::new();
assert_eq!(check_goal_gates(&g, &outcomes), Err("verify".to_string()));
}
#[test]
fn goal_gates_non_gate_nodes_ignored() {
let mut g = Graph::new("test");