Documentation
¶
Overview ¶
Package workflow routes product lifecycle events to engineering and security workflow destinations (Slack, Jira, Linear) and emits an auditable record of every dispatch attempt for governance.
The package is destination-agnostic: a Router fans an Event out to any Destination that opts in via its AlertPolicy. Every dispatch — success or failure — is captured as a DispatchRecord and forwarded to the AuditSink so the deployment can prove which lifecycle transitions reached which systems.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlertPolicy ¶
type AlertPolicy struct {
MinSeverity domain.FindingSeverity
AllowKinds []EventKind
AllowTypes []domain.FindingType
}
AlertPolicy filters events before they reach a destination. Zero-value fields are treated as "no constraint".
func (AlertPolicy) Allow ¶
func (p AlertPolicy) Allow(event Event) bool
Allow reports whether the event passes the policy.
A policy with an unrecognized MinSeverity fails closed (no events admitted) so a typo in configuration cannot accidentally fan low-severity events out to ticketing/chat destinations.
func (AlertPolicy) Validate ¶
func (p AlertPolicy) Validate() error
Validate reports whether the policy is internally consistent. An unset MinSeverity is valid (no floor); a set MinSeverity must be a recognized severity value so the policy cannot silently fail open at runtime.
type AuditSink ¶
type AuditSink interface {
Record(ctx context.Context, record DispatchRecord) error
}
AuditSink records every dispatch attempt for governance traceability.
type Destination ¶
Destination is one downstream workflow system that can receive lifecycle events.
type DispatchRecord ¶
type DispatchRecord struct {
EventKind EventKind `json:"event_kind"`
FindingID string `json:"finding_id,omitempty"`
SubjectID string `json:"subject_id,omitempty"`
ConnectionID string `json:"connection_id,omitempty"`
SCIMOp string `json:"scim_op,omitempty"`
Destination string `json:"destination"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
AttemptedAt time.Time `json:"attempted_at"`
}
DispatchRecord captures one delivery attempt by the Router.
type Event ¶
type Event struct {
Kind EventKind `json:"kind"`
Finding domain.Finding `json:"finding,omitzero"`
SCIMProvisioning *SCIMProvisioningEvent `json:"scim_provisioning,omitempty"`
Actor string `json:"actor,omitempty"`
Note string `json:"note,omitempty"`
EmittedAt time.Time `json:"emitted_at"`
RelatedURL string `json:"related_url,omitempty"`
}
Event is one lifecycle event delivered to workflow destinations.
type EventKind ¶
type EventKind string
EventKind enumerates the lifecycle transitions that can be routed.
const ( EventFindingCreated EventKind = "finding.created" EventFindingAcknowledged EventKind = "finding.acknowledged" EventFindingSuppressed EventKind = "finding.suppressed" EventFindingResolved EventKind = "finding.resolved" EventFixPROpened EventKind = "finding.fix_pr_opened" EventSCIMProvisioned EventKind = "scim.provisioned" )
type JSONLineAuditSink ¶
JSONLineAuditSink writes one DispatchRecord per line as NDJSON to the configured writer. Suitable for governance-friendly append-only audit logs and easy ingestion by SIEM pipelines.
func (*JSONLineAuditSink) Record ¶
func (s *JSONLineAuditSink) Record(_ context.Context, record DispatchRecord) error
Record implements AuditSink by serializing the record as one JSON line.
type JiraDestination ¶
type JiraDestination struct {
BaseURL string // e.g. https://acme.atlassian.net
Email string
APIToken string
ProjectKey string
IssueType string // defaults to "Task"
HTTPClient *http.Client
}
JiraDestination creates issues in a Jira Cloud project via the v3 REST API.
type LinearDestination ¶
type LinearDestination struct {
APIURL string // defaults to https://api.linear.app/graphql
APIKey string
TeamID string
HTTPClient *http.Client
}
LinearDestination creates issues in a Linear team via GraphQL.
func (LinearDestination) Name ¶
func (l LinearDestination) Name() string
Name implements Destination.
type RoutedDestination ¶
type RoutedDestination struct {
Destination Destination
Policy AlertPolicy
}
RoutedDestination binds a Destination to its activation policy.
type Router ¶
type Router struct {
Destinations []RoutedDestination
Audit AuditSink
// Now is injectable for deterministic tests; defaults to time.Now().UTC().
Now func() time.Time
}
Router fans events out to all destinations whose policy admits them and forwards a DispatchRecord for each attempt to the AuditSink.
func (Router) Dispatch ¶
Dispatch routes one event. Returns a record per destination considered and the first error encountered. Errors from one destination do not stop fan-out to the others; every attempted delivery is still recorded.
Audit failures are surfaced through the returned error so callers can fail closed when the governance trail cannot be persisted. Nil destinations in the configured slice are skipped defensively and recorded as misconfiguration rather than panicking on Name()/Send().
type SCIMProvisioningEvent ¶
type SCIMProvisioningEvent struct {
OrgID string `json:"org_id,omitempty"`
ConnectionID string `json:"connection_id"`
Operation string `json:"operation"`
UserID string `json:"user_id"`
UserName string `json:"user_name,omitempty"`
ExternalID string `json:"external_id,omitempty"`
Active bool `json:"active"`
}
SCIMProvisioningEvent describes one directory-sync user lifecycle delta that should be routed to governance and customer workflow destinations.
type SlackDestination ¶
SlackDestination posts events to a Slack incoming webhook URL.