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) <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-03-24 09:32:22 -04:00
parent f7e2391535
commit 5c33b87dce
2 changed files with 12 additions and 3 deletions

View file

@ -118,6 +118,13 @@ impl Context {
// --- Internal accessors for bridge code ---
pub(crate) fn from_values(values: HashMap<String, Value>) -> Self {
Self {
values: Arc::new(RwLock::new(values)),
logs: Arc::new(RwLock::new(Vec::new())),
}
}
pub(crate) fn values_arc(&self) -> Arc<RwLock<HashMap<String, Value>>> {
self.values.clone()
}

View file

@ -101,10 +101,12 @@ impl Graph for WorkflowGraph {
&self,
node: &Self::Node,
outcome: &Outcome,
_context: &CoreContext,
context: &CoreContext,
) -> Option<EdgeSelection<Self>> {
// 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,