workflow

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

type Destination interface {
	Name() string
	Send(ctx context.Context, event Event) error
}

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.

func (Event) Validate

func (e Event) Validate() error

Validate enforces the minimum invariants every destination relies on.

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

type JSONLineAuditSink struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

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.

func (JiraDestination) Name

func (j JiraDestination) Name() string

Name implements Destination.

func (JiraDestination) Send

func (j JiraDestination) Send(ctx context.Context, event Event) error

Send creates one Jira issue per event.

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.

func (LinearDestination) Send

func (l LinearDestination) Send(ctx context.Context, event Event) error

Send creates one Linear issue per event.

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

func (r Router) Dispatch(ctx context.Context, event Event) ([]DispatchRecord, error)

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

type SlackDestination struct {
	WebhookURL string
	HTTPClient *http.Client
}

SlackDestination posts events to a Slack incoming webhook URL.

func (SlackDestination) Name

func (s SlackDestination) Name() string

Name implements Destination.

func (SlackDestination) Send

func (s SlackDestination) Send(ctx context.Context, event Event) error

Send delivers the event as a formatted Slack message.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL