feat(runtime): workflow correlation ID threading (closes #86, FWS-2)#98
Merged
Merged
Conversation
Forge agents now extract orchestrator correlation headers (X-Workflow-ID, X-Workflow-Stage-ID, X-Workflow-Step-ID, X-Invocation-Caller) at the A2A dispatch boundary (JSON-RPC + REST), stash them as a WorkflowContext in context.Context, and auto-tag every audit event with workflow_id / stage_id / step_id / invocation_caller via a new AuditLogger.EmitFromContext. Direct A2A invocations (no orchestrator headers) leave the fields unset — emitted JSON is byte-identical to the pre-FWS-2 shape, so existing audit consumers keep working. Header names are deliberately vendor-neutral: any A2A-compatible orchestrator can drive the correlation surface without adopting a vendor prefix. WorkflowContext.ApplyToHTTPHeaders is exposed for tools that want to propagate headers onto outbound agent-to-agent A2A calls; auto-propagation is off by default to prevent leaking workflow identity to third-party APIs. See docs/security/workflow-correlation.md for the full reference.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
X-Workflow-ID,X-Workflow-Stage-ID,X-Workflow-Step-ID,X-Invocation-Caller— into aWorkflowContextcarried oncontext.Context. A newAuditLogger.EmitFromContextauto-tagsworkflow_id/stage_id/step_id/invocation_calleron every event emitted under that ctx.omitempty. ExistingauditLogger.Emit(...)callers continue to work unchanged.WorkflowContext.ApplyToHTTPHeaders) is exposed for tools that explicitly call workflow peers; auto-propagation on every outbound HTTP request is deliberately off to prevent leaking workflow identity to third-party APIs (the egress proxy can't tell a peer agent from a vendor endpoint).Wiring
forge-core/runtime/workflow.go(new)EmitFromContextforge-core/runtime/audit.goforge-cli/server/a2a_server.go/tasks/send+/tasks/sendSubscribehandlersforge-cli/runtime/runner.go(also migrated in-requestEmit→EmitFromContext)forge-cli/runtime/runner.go(pulls headers directly fromreq.Headersince auth runs before dispatcher)Tests
forge-core/runtime/workflow_test.go— 8 tests covering IsZero, header extraction (all/missing/partial), ctx round-trip,ApplyToHTTPHeaders, headers↔ctx↔headers round-tripforge-core/runtime/audit_workflow_test.go— 6 tests coveringEmitFromContexttagging from ctx, omission when ctx empty (backward compat), explicit fields take precedence, also tags CorrelationID/TaskID, partial WorkflowContext omits absent sub-fields, classicEmitpath unchangedforge-cli/server/a2a_server_workflow_test.go— 2 HTTP end-to-end tests: dispatcher extracts headers into ctx; missing headers yield IsZero WorkflowContextDocs
docs/security/workflow-correlation.md(new) — header table, flow diagram, audit shape, outbound propagation guidance, backward-compat notes, file-by-file wiring tabledocs/security/audit-logging.md— Workflow correlation subsectiondocs/security/overview.md— note about workflow-tagging in Audit Logging sectionREADME.md— Workflow Correlation entry under SecurityCHANGELOG.md— Unreleased entryTest plan
go test -race -count=1 ./forge-core/runtime/...— passgo test -race -count=1 ./forge-cli/server/...— passgo test -race -count=1 ./forge-cli/runtime/...— passgolangci-lint runacross forge-core/runtime + forge-cli/server + forge-cli/runtime — 0 issuesgofmt -lclean on all touched files