feat(workflow): trace standalone workflow steps and parallel branches (issue #322) #381
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
yuluo-yx
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_STEPwithStageEntered/StageExited— through an opt-in observer list onWorkflowAgent.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 shipsWorkflowStepObservationObserver, translating the events intoargi.agent.workflow.stepspans on the sharedAgentTracerfrom #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
parallelExecutorbuilder seam (defaultForkJoinPool.commonPool, unchanged) exists purely so tests can drive deterministic branch interleaving.The bridge details
WorkflowStepObservationObserverpairs 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 theWORKFLOW_STEPoperation (argi.agent.workflow.step), a high-cardinalityargi.agent.step.idkey and afailure()marker onAgentTraceSpanfor 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