← Back to Pull requests

feat(workflow): trace standalone workflow steps and parallel branches (issue #322) #381

Closed
unknown closed this pull request without merging on Nov 29, 2026 08:45 UTC
View on GitHub
unknown unknown commented on Nov 21, 2026 09:46 UTC
Author

Describe what this PR does / why we need it

Issue #322 asks for tracing on standalone Workflow steps and parallel branches. The workflow engine had no observability seam at all, and the micrometer trace package lives in a module the workflow core deliberately does not depend on. This PR wires step-level tracing through the neutral lifecycle contract and adds a micrometer bridge where both sides are visible.

The two-layer design

The workflow core now emits the neutral lifecycle events of the agent-api contract — LifecycleStage.WORKFLOW_STEP with StageEntered/StageExited — through an opt-in observer list on WorkflowAgent.Builder. It gains no micrometer dependency and no Graph/Loop dependency; with no observers, execution behavior is preserved exactly. The bridge lives in the agent-framework, which already sees both worlds: it gains a workflow-core dependency (acyclic) and ships WorkflowStepObservationObserver, translating the events into argi.agent.workflow.step spans on the shared AgentTracer from #131, following the established cross-agent naming conventions.

Emission semantics

Every executed step — Agent, Tool, Condition, Loop body, Parallel branch, Subflow — emits exactly one paired enter/exit on its executing thread. Retries fold into a single step-level exit (the issue's "each step ends exactly once"), a suspension exits successfully because handing off control is not a failure (resume-span fragments are issue #324's scope, stated as a boundary), and cancellation or failure exits with a failure reason. Parallel branches attribute their spans on the branch worker thread regardless of completion order — the fan-in merge still happens in declaration order and is untouched. The workflow run identity travels as the event's invocation id, sourced from the trusted run id, so spans stay correlatable without inheriting anything between independent runs. A parallelExecutor builder seam (default ForkJoinPool.commonPool, unchanged) exists purely so tests can drive deterministic branch interleaving.

The bridge details

WorkflowStepObservationObserver pairs enter/exit through a per-thread LIFO stack, which satisfies the "close on the starting thread" contract for nested sequences, loop bodies, condition branches and parallel branch workers alike. The trace vocabulary gains the WORKFLOW_STEP operation (argi.agent.workflow.step), a high-cardinality argi.agent.step.id key and a failure() marker on AgentTraceSpan for lifecycle exits that carry only a reason string — the event contract has no throwable, so the error-type key stays unset by design. With a disabled tracer the observer still receives events but creates no observation.

Testing

WorkflowStepLifecycleTest (workflow core) drives deterministic scenarios with a recording observer: paired LIFO emission over a sequence, once-only exits under retry, cancellation and suspension (with the resume not double-exiting), reversed parallel completion order gated by latches with correct branch attribution and worker-thread identity, loop iteration pairs including the container, and zero event inheritance between two independent runs. WorkflowStepObservationObserverTest (agent framework) asserts the span name, step id, run id, success and outcome keys on the micrometer side, including the failing path. The NOOP acceptance is covered by the untouched existing workflow tests (72/72 in workflow core), and the graph-core (593 run, known Windows baseline) and agent-framework (1420 run, same baseline) regressions are unchanged; checkstyle and spring-javaformat are clean.

Fixes #322

Diff: 453 lines (+339 / -114) across 5 files Reviewer: yuluo-yx Review duration: 11458m
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 453 lines diff across 5 files
0.45
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.366
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #381"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 45.5% (MEDIUM) · Higher = larger blast radius
45.5%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 18.0% · Safe to merge
18.0%