From 5c33b87dce83bcc4e18a869d6fd73ca66d508478 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Tue, 24 Mar 2026 09:32:22 -0400 Subject: [PATCH] Fix core_adapter select_edge to use actual context for edge conditions The select_edge bridge was creating an empty Context, which meant edge conditions reading context values (e.g. context.failure_class=budget_exhausted) would never match when using the core engine. Now snapshots the CoreContext into a wf Context so evaluate_condition sees the real runtime state. Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/crates/fabro-workflows/src/context/mod.rs | 7 +++++++ lib/crates/fabro-workflows/src/core_adapter/graph.rs | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/crates/fabro-workflows/src/context/mod.rs b/lib/crates/fabro-workflows/src/context/mod.rs index b1260f87b..f2f2e3c73 100644 --- a/lib/crates/fabro-workflows/src/context/mod.rs +++ b/lib/crates/fabro-workflows/src/context/mod.rs @@ -118,6 +118,13 @@ impl Context { // --- Internal accessors for bridge code --- + pub(crate) fn from_values(values: HashMap) -> Self { + Self { + values: Arc::new(RwLock::new(values)), + logs: Arc::new(RwLock::new(Vec::new())), + } + } + pub(crate) fn values_arc(&self) -> Arc>> { self.values.clone() } diff --git a/lib/crates/fabro-workflows/src/core_adapter/graph.rs b/lib/crates/fabro-workflows/src/core_adapter/graph.rs index dcc02c7a7..87e53eb89 100644 --- a/lib/crates/fabro-workflows/src/core_adapter/graph.rs +++ b/lib/crates/fabro-workflows/src/core_adapter/graph.rs @@ -101,10 +101,12 @@ impl Graph for WorkflowGraph { &self, node: &Self::Node, outcome: &Outcome, - _context: &CoreContext, + context: &CoreContext, ) -> Option> { - // Outcome is now the wf type directly — no conversion needed - let wf_context = crate::context::Context::new(); + // Build a wf Context from the core context snapshot so edge conditions + // that read context values (e.g. `context.failure_class=budget_exhausted`) + // evaluate correctly. + let wf_context = crate::context::Context::from_values(context.snapshot()); let selection = engine::select_edge( node.inner(), outcome,