Documentation
¶
Overview ¶
Package pidl provides types and utilities for the Protocol Interaction Description Language. PIDL is a JSON-based DSL for describing protocol choreography that compiles to diagrams.
Index ¶
- Constants
- Variables
- func CalculateExecutionCost(entity *Entity, metrics ExecutionMetrics) float64
- func CanExecuteInParallel(p *Protocol, entityA, entityB string) bool
- func EstimateLatencyPercentile(analysis *ProcessLatencyAnalysis, percentile int) time.Duration
- func FormatLatencyReport(analysis *ProcessLatencyAnalysis) string
- func GetCostEfficiency(analysis *ProcessCostAnalysis) map[string]float64
- func GetLatencyBreakdown(analysis *ProcessLatencyAnalysis) map[string]time.Duration
- func GetMaxParallelism(p *Protocol) int
- func IsValidAnnotationType(t AnnotationType) bool
- func IsValidCategory(c Category) bool
- func IsValidComponentType(t string) bool
- func IsValidCredential(c string) bool
- func IsValidEntityType(t EntityType) bool
- func IsValidFlowMode(m FlowMode) bool
- func IsValidProtocol(protocol string) bool
- func IsValidSchemaURI(uri string) bool
- func IsValidSecurityRequirement(r SecurityRequirement) bool
- func IsValidTrustLevel(t TrustLevel) bool
- func IsValidTrustRelationType(t string) bool
- func SanitizeID(s string) string
- func TitleCase(s string) string
- func ValidateFile(filename string) (*Protocol, ValidationErrors, error)
- type Alternative
- type AnimationPreset
- type Annotation
- type AnnotationType
- type Breakpoint
- type Category
- type CostEstimate
- type CostModel
- type CostModelType
- type DataLineage
- func (l *DataLineage) GetDataProvenance(entityID string) []string
- func (l *DataLineage) GetDownstream(entityID, portName string) []PortReference
- func (l *DataLineage) GetImpactedEntities(entityID string) []string
- func (l *DataLineage) GetUpstream(entityID, portName string) []PortReference
- func (l *DataLineage) HasSensitiveDataFlow() bool
- type DataPort
- type DataPortKind
- type DataPortMapping
- type DebugSession
- func (d *DebugSession) Continue() (*ExecutionStep, error)
- func (d *DebugSession) EnableBreakpoint(flowIndex int, enabled bool) error
- func (d *DebugSession) FormatFlowList() string
- func (d *DebugSession) Inspect() *DebugState
- func (d *DebugSession) InspectEntity(id string) (*Entity, string, error)
- func (d *DebugSession) InspectFlow(index int) (*Flow, error)
- func (d *DebugSession) ListBreakpoints() []*Breakpoint
- func (d *DebugSession) ListFlows() []FlowListItem
- func (d *DebugSession) Protocol() *Protocol
- func (d *DebugSession) RemoveBreakpoint(flowIndex int) error
- func (d *DebugSession) Reset()
- func (d *DebugSession) SetBreakpoint(flowIndex int, condition string) error
- func (d *DebugSession) SetEntityState(entityID, stateID string) error
- func (d *DebugSession) Step() (*ExecutionStep, error)
- func (d *DebugSession) Trace() *ExecutionTrace
- type DebugState
- type DependencyAnalysis
- type DeploymentComponent
- type Determinism
- type DiffCategory
- type DiffItem
- type DiffOptions
- type DiffSummary
- type DiffType
- type Entity
- func (e Entity) FailureModeByID(id string) *FailureMode
- func (e Entity) HasInputs() bool
- func (e Entity) HasOutputs() bool
- func (e Entity) HasProtocolRoles() bool
- func (e Entity) HasRole(protocol, role string) bool
- func (e Entity) HasStates() bool
- func (e Entity) InitialState() *EntityState
- func (e Entity) InputByName(name string) *DataPort
- func (e Entity) IsDeterministic() bool
- func (e Entity) IsExternalStep() bool
- func (e Entity) IsHumanStep() bool
- func (e Entity) IsLLMStep() bool
- func (e Entity) IsNonDeterministic() bool
- func (e Entity) IsProcessStep() bool
- func (e Entity) IsToolStep() bool
- func (e Entity) OutputByName(name string) *DataPort
- func (e Entity) RequiredInputs() []DataPort
- func (e Entity) RolesByProtocol(protocol string) []ProtocolRole
- func (e Entity) SensitiveInputs() []DataPort
- func (e Entity) SensitiveOutputs() []DataPort
- func (e Entity) StateByID(id string) *EntityState
- func (e Entity) StateIDs() []string
- type EntityMetadata
- type EntityState
- type EntityType
- type ExecutionContext
- type ExecutionEvent
- type ExecutionGraph
- type ExecutionMetrics
- type ExecutionReadiness
- type ExecutionStage
- type ExecutionStep
- type ExecutionTrace
- type Executor
- func (e *Executor) NewContext() *ExecutionContext
- func (e *Executor) Reset(ctx *ExecutionContext)
- func (e *Executor) Run(ctx *ExecutionContext) (*ExecutionTrace, error)
- func (e *Executor) RunN(ctx *ExecutionContext, n int) (*ExecutionTrace, error)
- func (e *Executor) Step(ctx *ExecutionContext) (*ExecutionStep, error)
- type FailureMode
- type FileValidationResult
- type Flow
- func (f Flow) DisplayLabel() string
- func (f Flow) EffectiveMode() FlowMode
- func (f Flow) HasAlternatives() bool
- func (f Flow) HasAnnotations() bool
- func (f Flow) HasCondition() bool
- func (f Flow) HasNote() bool
- func (f Flow) HasSecurity() bool
- func (f Flow) HasStateMutations() bool
- func (f Flow) RequiresEncryption() bool
- func (f Flow) RequiresToken() bool
- type FlowAnimation
- type FlowListItem
- type FlowMode
- type FlowSecurity
- type JoinCondition
- type LatencyBudget
- type LatencyBudgetViolation
- type LatencyEstimate
- type LatencyMeasurement
- type LatencyVarianceClass
- type LineageEdge
- type NetworkConfig
- type NetworkLayoutConfig
- type ParallelBlock
- type ParallelBranch
- type ParallelConfig
- type ParallelMode
- type Phase
- type PortReference
- type PortSchemaValidator
- func (v *PortSchemaValidator) SetBasePath(path string)
- func (v *PortSchemaValidator) ValidateEntityInputs(entity Entity, inputs map[string]interface{}) (*SchemaValidationResult, error)
- func (v *PortSchemaValidator) ValidateEntityOutputs(entity Entity, outputs map[string]interface{}) (*SchemaValidationResult, error)
- func (v *PortSchemaValidator) ValidatePortData(port DataPort, data interface{}) (*SchemaValidationResult, error)
- type ProcessCostAnalysis
- type ProcessExecutionContext
- type ProcessExecutor
- func (pe *ProcessExecutor) AnalyzeDependencies() []DependencyAnalysis
- func (pe *ProcessExecutor) CompleteStep(ctx *ProcessExecutionContext, entityID string) error
- func (pe *ProcessExecutor) FailStep(ctx *ProcessExecutionContext, entityID string) error
- func (pe *ProcessExecutor) GetBlockedSteps(ctx *ProcessExecutionContext) map[string][]string
- func (pe *ProcessExecutor) GetExecutionReadiness(ctx *ProcessExecutionContext) ExecutionReadiness
- func (pe *ProcessExecutor) GetReadySteps(ctx *ProcessExecutionContext) []string
- func (pe *ProcessExecutor) MarkInputAvailable(ctx *ProcessExecutionContext, entityID, inputName string)
- func (pe *ProcessExecutor) MarkOutputProduced(ctx *ProcessExecutionContext, entityID, outputName string)
- func (pe *ProcessExecutor) NewProcessContext() *ProcessExecutionContext
- func (pe *ProcessExecutor) StartStep(ctx *ProcessExecutionContext, entityID string) error
- func (pe *ProcessExecutor) TopologicalSort() []string
- type ProcessLatencyAnalysis
- type ProcessingConfig
- type Protocol
- func (p *Protocol) AllComponentTypes() []string
- func (p *Protocol) AllProtocols() []string
- func (p *Protocol) AllTrustRelationTypes() []string
- func (p *Protocol) ChildPhases(parentID string) []Phase
- func (p *Protocol) ComponentByID(id string) *DeploymentComponent
- func (p *Protocol) ComponentForEntity(entityID string) *DeploymentComponent
- func (p *Protocol) ComponentsByType(componentType string) []DeploymentComponent
- func (p *Protocol) DeterministicSteps() []Entity
- func (p *Protocol) EntitiesByProtocol(protocol string) []Entity
- func (p *Protocol) EntitiesByRole(protocol, role string) []Entity
- func (p *Protocol) EntitiesInComponent(componentID string) []Entity
- func (p *Protocol) EntitiesWithProtocolRoles() []Entity
- func (p *Protocol) EntitiesWithStates() []Entity
- func (p *Protocol) EntityByID(id string) *Entity
- func (p *Protocol) EntityIDs() []string
- func (p *Protocol) FlowsByPhase(phaseID string) []Flow
- func (p *Protocol) IsProcessSpec() bool
- func (p *Protocol) IsResolved() bool
- func (p *Protocol) IsValid() bool
- func (p *Protocol) Kind() ProtocolKind
- func (p *Protocol) LLMSteps() []Entity
- func (p *Protocol) NeedsResolution() bool
- func (p *Protocol) PhaseByID(id string) *Phase
- func (p *Protocol) PhaseDepth(phaseID string) int
- func (p *Protocol) PhaseIDs() []string
- func (p *Protocol) ProcessSteps() []Entity
- func (p *Protocol) Resolve(opts ResolveOptions) (*Protocol, error)
- func (p *Protocol) RootPhases() []Phase
- func (p *Protocol) StateTransitions() []StateTransition
- func (p *Protocol) StateTransitionsForEntity(entityID string) []StateTransition
- func (p *Protocol) ToJSON() ([]byte, error)
- func (p *Protocol) ToJSONCompact() ([]byte, error)
- func (p *Protocol) TokenByID(id string) *TokenDefinition
- func (p *Protocol) TrustRelationByID(id string) *TrustRelationship
- func (p *Protocol) TrustRelationsByType(relType string) []TrustRelationship
- func (p *Protocol) TrustRelationsFrom(id string) []TrustRelationship
- func (p *Protocol) TrustRelationsTo(id string) []TrustRelationship
- func (p *Protocol) Validate() ValidationErrors
- func (p *Protocol) ValidateProcess() ValidationErrors
- func (p *Protocol) WriteFile(filename string) error
- type ProtocolDiff
- type ProtocolExtends
- type ProtocolImport
- type ProtocolKind
- type ProtocolMeta
- type ProtocolMetadata
- type ProtocolRole
- type Reference
- type ResolveOptions
- type RetryStrategy
- type SchemaRegistry
- type SchemaValidationError
- type SchemaValidationResult
- type SecurityRequirement
- type StateChange
- type StateMutation
- type StateTransition
- type StepExecutionStatus
- type StepType
- type TokenDefinition
- type TrustLevel
- type TrustRelationship
- type ValidationError
- type ValidationErrors
Constants ¶
const ( ProtocolOAuth = "oauth" ProtocolSCIM = "scim" ProtocolSPIFFE = "spiffe" ProtocolAAuth = "aauth" ProtocolIDJAG = "idjag" ProtocolAuthZEN = "authzen" ProtocolMCP = "mcp" ProtocolA2A = "a2a" ProtocolSAML = "saml" ProtocolWebAuthn = "webauthn" ProtocolFIDO2 = "fido2" ProtocolOIDC = "oidc" )
Protocol identifier constants.
const ( ComponentTypeIdP = "idp" ComponentTypeIGA = "iga" ComponentTypeAgentProvider = "agent_provider" ComponentTypePersonServer = "person_server" ComponentTypeAccessServer = "access_server" ComponentTypePDP = "pdp" ComponentTypeGateway = "gateway" ComponentTypeMCPClient = "mcp_client" ComponentTypeMCPServer = "mcp_server" ComponentTypeResourceAPI = "resource_api" ComponentTypeSPIRE = "spire" )
Component type constants.
const ( TrustTypeAuthenticates = "authenticates" TrustTypeValidates = "validates" TrustTypeDelegates = "delegates" TrustTypeAuthorizes = "authorizes" TrustTypeIssues = "issues" TrustTypeTrusts = "trusts" TrustTypeProvisions = "provisions" TrustTypeAttests = "attests" )
Trust relationship type constants.
const ( CredentialX509SVID = "x509_svid" CredentialJWTSVID = "jwt_svid" CredentialJWTAssertion = "jwt_assertion" CredentialAccessToken = "access_token" CredentialIDToken = "id_token" CredentialAAAgentJWT = "aa_agent_jwt" CredentialAAAuthJWT = "aa_auth_jwt" CredentialMTLS = "mtls" CredentialAPIKey = "api_key" CredentialX509Certificate = "x509_certificate" CredentialAttestationCert = "attestation_certificate" CredentialBearerToken = "bearer_token" CredentialSAMLAssertion = "saml_assertion" CredentialSessionCookie = "session_cookie" )
Credential type constants.
Variables ¶
var LLMCostPresets = map[string]struct { InputCost float64 OutputCost float64 }{ "gpt-4": {InputCost: 0.03, OutputCost: 0.06}, "gpt-4-turbo": {InputCost: 0.01, OutputCost: 0.03}, "gpt-3.5-turbo": {InputCost: 0.0005, OutputCost: 0.0015}, "claude-3-opus": {InputCost: 0.015, OutputCost: 0.075}, "claude-3-sonnet": {InputCost: 0.003, OutputCost: 0.015}, "claude-3-haiku": {InputCost: 0.00025, OutputCost: 0.00125}, }
LLMCostPresets provides common LLM pricing (per 1K tokens, in USD).
var StepTypeLatencyDefaults = map[StepType]struct { P50 time.Duration P95 time.Duration P99 time.Duration Max time.Duration Variance LatencyVarianceClass }{ StepTypeDeterministic: { P50: 50 * time.Millisecond, P95: 100 * time.Millisecond, P99: 200 * time.Millisecond, Max: 500 * time.Millisecond, Variance: LatencyVarianceLow, }, StepTypeLLM: { P50: 2 * time.Second, P95: 8 * time.Second, P99: 15 * time.Second, Max: 30 * time.Second, Variance: LatencyVarianceHigh, }, StepTypeHuman: { P50: 5 * time.Minute, P95: 30 * time.Minute, P99: 2 * time.Hour, Max: 24 * time.Hour, Variance: LatencyVarianceHigh, }, StepTypeExternal: { P50: 200 * time.Millisecond, P95: 1 * time.Second, P99: 3 * time.Second, Max: 10 * time.Second, Variance: LatencyVarianceMedium, }, StepTypeTool: { P50: 100 * time.Millisecond, P95: 500 * time.Millisecond, P99: 1 * time.Second, Max: 5 * time.Second, Variance: LatencyVarianceMedium, }, }
StepTypeLatencyDefaults provides default latency estimates by step type.
Functions ¶
func CalculateExecutionCost ¶ added in v0.5.0
func CalculateExecutionCost(entity *Entity, metrics ExecutionMetrics) float64
CalculateExecutionCost calculates actual cost from execution metrics.
func CanExecuteInParallel ¶ added in v0.5.0
CanExecuteInParallel determines if two entities can execute concurrently.
func EstimateLatencyPercentile ¶ added in v0.5.0
func EstimateLatencyPercentile(analysis *ProcessLatencyAnalysis, percentile int) time.Duration
EstimateLatencyPercentile returns a specific percentile latency estimate.
func FormatLatencyReport ¶ added in v0.5.0
func FormatLatencyReport(analysis *ProcessLatencyAnalysis) string
FormatLatencyReport generates a human-readable latency report.
func GetCostEfficiency ¶ added in v0.5.0
func GetCostEfficiency(analysis *ProcessCostAnalysis) map[string]float64
GetCostEfficiency returns cost per unit of output for comparison.
func GetLatencyBreakdown ¶ added in v0.5.0
func GetLatencyBreakdown(analysis *ProcessLatencyAnalysis) map[string]time.Duration
GetLatencyBreakdown returns latency contribution by step type.
func GetMaxParallelism ¶ added in v0.5.0
GetMaxParallelism returns the maximum number of entities that can execute concurrently.
func IsValidAnnotationType ¶ added in v0.2.0
func IsValidAnnotationType(t AnnotationType) bool
IsValidAnnotationType checks if the annotation type is valid.
func IsValidCategory ¶ added in v0.4.0
IsValidCategory checks if the category is valid.
func IsValidComponentType ¶ added in v0.4.0
IsValidComponentType checks if the component type is a known type.
func IsValidCredential ¶ added in v0.4.0
IsValidCredential checks if the credential type is a known type.
func IsValidEntityType ¶ added in v0.4.0
func IsValidEntityType(t EntityType) bool
IsValidEntityType checks if the entity type is valid.
func IsValidFlowMode ¶ added in v0.4.0
IsValidFlowMode checks if the flow mode is valid.
func IsValidProtocol ¶ added in v0.4.0
IsValidProtocol checks if the protocol identifier is a known protocol.
func IsValidSchemaURI ¶ added in v0.5.0
IsValidSchemaURI checks if a schema URI is syntactically valid.
func IsValidSecurityRequirement ¶ added in v0.4.0
func IsValidSecurityRequirement(r SecurityRequirement) bool
IsValidSecurityRequirement checks if the security requirement is valid.
func IsValidTrustLevel ¶ added in v0.4.0
func IsValidTrustLevel(t TrustLevel) bool
IsValidTrustLevel checks if the trust level is valid.
func IsValidTrustRelationType ¶ added in v0.4.0
IsValidTrustRelationType checks if the trust relation type is a known type.
func SanitizeID ¶
SanitizeID converts a string to a valid PIDL ID (lowercase, alphanumeric, underscores/hyphens).
func ValidateFile ¶
func ValidateFile(filename string) (*Protocol, ValidationErrors, error)
ValidateFile parses and validates a PIDL file, returning any validation errors.
Types ¶
type Alternative ¶ added in v0.2.0
type Alternative struct {
// Condition describes when this alternative is taken.
Condition string `json:"condition"`
// Flows are the steps in this alternative path.
Flows []Flow `json:"flows"`
// Description provides additional context.
Description string `json:"description,omitempty"`
}
Alternative represents an alternative path in the flow.
type AnimationPreset ¶ added in v0.3.0
type AnimationPreset string
AnimationPreset represents a semantic animation preset.
const ( // AnimationPresetRequest is the default for outgoing requests. AnimationPresetRequest AnimationPreset = "request" // AnimationPresetResponse is for return values (gray, dashed). AnimationPresetResponse AnimationPreset = "response" // AnimationPresetSuccess indicates successful operations (green). AnimationPresetSuccess AnimationPreset = "success" // AnimationPresetError indicates errors/failures (red, pulsing). AnimationPresetError AnimationPreset = "error" // AnimationPresetWarning indicates warnings (orange, pulsing). AnimationPresetWarning AnimationPreset = "warning" // AnimationPresetHighlight emphasizes critical paths (yellow, larger dot). AnimationPresetHighlight AnimationPreset = "highlight" // AnimationPresetNone disables animation (static arrow). AnimationPresetNone AnimationPreset = "none" )
type Annotation ¶ added in v0.2.0
type Annotation struct {
// Type categorizes the annotation.
Type AnnotationType `json:"type"`
// Text is the annotation message.
Text string `json:"text"`
// Details provides additional context.
Details string `json:"details,omitempty"`
}
Annotation represents a typed annotation on a flow.
type AnnotationType ¶ added in v0.2.0
type AnnotationType string
AnnotationType represents the type of annotation.
const ( AnnotationTypeSecurity AnnotationType = "security" AnnotationTypePerformance AnnotationType = "performance" AnnotationTypeDeprecated AnnotationType = "deprecated" AnnotationTypeInfo AnnotationType = "info" AnnotationTypeWarning AnnotationType = "warning" AnnotationTypeError AnnotationType = "error" )
type Breakpoint ¶ added in v0.4.0
type Breakpoint struct {
// FlowIndex is the flow index where the breakpoint is set.
FlowIndex int
// Condition is an optional condition expression (evaluated by ConditionEvaluator).
Condition string
// Enabled indicates if the breakpoint is active.
Enabled bool
// HitCount tracks how many times this breakpoint was hit.
HitCount int
}
Breakpoint represents a debug breakpoint.
type CostEstimate ¶ added in v0.5.0
type CostEstimate struct {
// EntityID is the entity this estimate is for (empty for total).
EntityID string `json:"entity_id,omitempty"`
// MinCost is the minimum expected cost.
MinCost float64 `json:"min_cost"`
// MaxCost is the maximum expected cost.
MaxCost float64 `json:"max_cost"`
// ExpectedCost is the average/expected cost.
ExpectedCost float64 `json:"expected_cost"`
// CostUnit is the currency or unit.
CostUnit string `json:"cost_unit"`
// Breakdown shows cost by category.
Breakdown map[string]float64 `json:"breakdown,omitempty"`
}
CostEstimate represents an estimated cost for a step or process.
type CostModel ¶ added in v0.5.0
type CostModel struct {
// Type classifies the cost model.
Type CostModelType `json:"type"`
// FixedCost is the base cost per execution (in the cost unit).
FixedCost float64 `json:"fixed_cost,omitempty"`
// VariableCost is the cost per unit of work.
VariableCost float64 `json:"variable_cost,omitempty"`
// CostUnit is the currency or unit for costs (e.g., "USD", "tokens", "credits").
CostUnit string `json:"cost_unit,omitempty"`
// TokenCosts for LLM steps (per 1K tokens).
InputTokenCost float64 `json:"input_token_cost,omitempty"`
OutputTokenCost float64 `json:"output_token_cost,omitempty"`
// EstimatedInputTokens for LLM cost estimation.
EstimatedInputTokens int `json:"estimated_input_tokens,omitempty"`
// EstimatedOutputTokens for LLM cost estimation.
EstimatedOutputTokens int `json:"estimated_output_tokens,omitempty"`
// ComputeCostPerSecond for compute-based steps.
ComputeCostPerSecond float64 `json:"compute_cost_per_second,omitempty"`
// APICallCost for external API steps.
APICallCost float64 `json:"api_call_cost,omitempty"`
}
CostModel defines the cost characteristics of a processing step.
type CostModelType ¶ added in v0.5.0
type CostModelType string
CostModelType classifies how costs are calculated.
const ( // CostModelTypeFixed has a fixed cost per execution. CostModelTypeFixed CostModelType = "fixed" // CostModelTypeTokenBased costs based on input/output tokens. CostModelTypeTokenBased CostModelType = "token_based" // CostModelTypeTimeBased costs based on execution time. CostModelTypeTimeBased CostModelType = "time_based" // CostModelTypeAPICall costs per API call. CostModelTypeAPICall CostModelType = "api_call" // CostModelTypeHybrid combines multiple cost factors. CostModelTypeHybrid CostModelType = "hybrid" )
type DataLineage ¶ added in v0.5.0
type DataLineage struct {
// ProtocolID is the ID of the source protocol.
ProtocolID string `json:"protocol_id"`
// Edges are the data flow connections.
Edges []LineageEdge `json:"edges"`
// Sources are ports that have no upstream connections.
Sources []PortReference `json:"sources"`
// Sinks are ports that have no downstream connections.
Sinks []PortReference `json:"sinks"`
// SensitiveDataPaths tracks paths containing sensitive data.
SensitiveDataPaths [][]PortReference `json:"sensitive_paths,omitempty"`
}
DataLineage represents the complete data lineage graph for a protocol.
func AnalyzeDataLineage ¶ added in v0.5.0
func AnalyzeDataLineage(p *Protocol) *DataLineage
AnalyzeDataLineage extracts the data lineage graph from a process protocol. It traces data flow from sources through transformations to sinks.
func (*DataLineage) GetDataProvenance ¶ added in v0.5.0
func (l *DataLineage) GetDataProvenance(entityID string) []string
GetDataProvenance returns all source entities that contribute to the specified entity's inputs (upstream provenance analysis).
func (*DataLineage) GetDownstream ¶ added in v0.5.0
func (l *DataLineage) GetDownstream(entityID, portName string) []PortReference
GetDownstream returns all ports that receive data from the specified port.
func (*DataLineage) GetImpactedEntities ¶ added in v0.5.0
func (l *DataLineage) GetImpactedEntities(entityID string) []string
GetImpactedEntities returns all entities that would be affected if the specified entity's output changes (downstream impact analysis).
func (*DataLineage) GetUpstream ¶ added in v0.5.0
func (l *DataLineage) GetUpstream(entityID, portName string) []PortReference
GetUpstream returns all ports that feed data into the specified port.
func (*DataLineage) HasSensitiveDataFlow ¶ added in v0.5.0
func (l *DataLineage) HasSensitiveDataFlow() bool
HasSensitiveDataFlow returns true if there's any sensitive data flowing through the lineage graph.
type DataPort ¶ added in v0.5.0
type DataPort struct {
// Kind classifies the data type.
Kind DataPortKind `json:"kind"`
// Name is the identifier for this port.
Name string `json:"name"`
// Description provides additional context.
Description string `json:"description,omitempty"`
// Schema is an optional reference to a JSON Schema.
Schema string `json:"schema,omitempty"`
// Required indicates if this input must be provided.
Required bool `json:"required,omitempty"`
// Sensitive marks data as containing PII or secrets.
Sensitive bool `json:"sensitive,omitempty"`
}
DataPort represents an input or output of a process step.
type DataPortKind ¶ added in v0.5.0
type DataPortKind string
DataPortKind classifies the type of data port.
const ( // DataPortKindFile represents file-based data. DataPortKindFile DataPortKind = "file" // DataPortKindObject represents in-memory object data. DataPortKindObject DataPortKind = "object" // DataPortKindAPI represents API endpoint data. DataPortKindAPI DataPortKind = "api" // DataPortKindDatabase represents database data. DataPortKindDatabase DataPortKind = "database" // DataPortKindQueue represents message queue data. DataPortKindQueue DataPortKind = "queue" // DataPortKindStream represents streaming data. DataPortKindStream DataPortKind = "stream" )
type DataPortMapping ¶ added in v0.5.0
type DataPortMapping struct {
// OutputPort is the source port name on the From entity.
OutputPort string `json:"output_port"`
// InputPort is the target port name on the To entity.
InputPort string `json:"input_port"`
// Transformation describes any data transformation applied.
Transformation string `json:"transformation,omitempty"`
}
DataPortMapping explicitly maps output ports to input ports across a flow.
type DebugSession ¶ added in v0.4.0
type DebugSession struct {
// Executor runs the protocol.
Executor *Executor
// Context holds the execution state.
Context *ExecutionContext
// Breakpoints maps flow indices to breakpoints.
Breakpoints map[int]*Breakpoint
// Watchpoints maps entity IDs to watched state patterns.
Watchpoints map[string]string
// contains filtered or unexported fields
}
DebugSession provides interactive debugging of protocol execution.
func NewDebugSession ¶ added in v0.4.0
func NewDebugSession(p *Protocol) *DebugSession
NewDebugSession creates a new debug session for a protocol.
func (*DebugSession) Continue ¶ added in v0.4.0
func (d *DebugSession) Continue() (*ExecutionStep, error)
Continue runs until a breakpoint is hit or execution completes. Returns the step where it stopped (breakpoint or final step).
func (*DebugSession) EnableBreakpoint ¶ added in v0.4.0
func (d *DebugSession) EnableBreakpoint(flowIndex int, enabled bool) error
EnableBreakpoint enables or disables a breakpoint.
func (*DebugSession) FormatFlowList ¶ added in v0.4.0
func (d *DebugSession) FormatFlowList() string
FormatFlowList returns a formatted string of all flows.
func (*DebugSession) Inspect ¶ added in v0.4.0
func (d *DebugSession) Inspect() *DebugState
Inspect returns the current debug state.
func (*DebugSession) InspectEntity ¶ added in v0.4.0
func (d *DebugSession) InspectEntity(id string) (*Entity, string, error)
InspectEntity returns the entity and its current state.
func (*DebugSession) InspectFlow ¶ added in v0.4.0
func (d *DebugSession) InspectFlow(index int) (*Flow, error)
InspectFlow returns a flow by index.
func (*DebugSession) ListBreakpoints ¶ added in v0.4.0
func (d *DebugSession) ListBreakpoints() []*Breakpoint
ListBreakpoints returns all breakpoints.
func (*DebugSession) ListFlows ¶ added in v0.4.0
func (d *DebugSession) ListFlows() []FlowListItem
ListFlows returns all flows with their status.
func (*DebugSession) Protocol ¶ added in v0.4.0
func (d *DebugSession) Protocol() *Protocol
Protocol returns the protocol being debugged.
func (*DebugSession) RemoveBreakpoint ¶ added in v0.4.0
func (d *DebugSession) RemoveBreakpoint(flowIndex int) error
RemoveBreakpoint removes a breakpoint at the specified flow index.
func (*DebugSession) Reset ¶ added in v0.4.0
func (d *DebugSession) Reset()
Reset restarts the debug session from the beginning.
func (*DebugSession) SetBreakpoint ¶ added in v0.4.0
func (d *DebugSession) SetBreakpoint(flowIndex int, condition string) error
SetBreakpoint sets a breakpoint at the specified flow index.
func (*DebugSession) SetEntityState ¶ added in v0.4.0
func (d *DebugSession) SetEntityState(entityID, stateID string) error
SetEntityState manually sets an entity's state.
func (*DebugSession) Step ¶ added in v0.4.0
func (d *DebugSession) Step() (*ExecutionStep, error)
Step executes the next flow and returns the step details. Returns nil when execution is complete.
func (*DebugSession) Trace ¶ added in v0.4.0
func (d *DebugSession) Trace() *ExecutionTrace
Trace returns the current execution trace.
type DebugState ¶ added in v0.4.0
type DebugState struct {
// FlowIndex is the current position in the protocol.
FlowIndex int
// StepsExecuted is the number of steps executed so far.
StepsExecuted int
// CurrentFlow is the next flow to be executed (nil if complete).
CurrentFlow *Flow
// EntityStates maps entity IDs to their current states.
EntityStates map[string]string
// IsCompleted indicates if execution has finished.
IsCompleted bool
// AtBreakpoint indicates if execution stopped at a breakpoint.
AtBreakpoint bool
// Error holds any execution error.
Error error
}
DebugState represents the current state of a debug session.
func (*DebugState) String ¶ added in v0.4.0
func (d *DebugState) String() string
DebugStateString returns a human-readable representation of the debug state.
type DependencyAnalysis ¶ added in v0.5.0
type DependencyAnalysis struct {
// EntityID is the step being analyzed.
EntityID string `json:"entity_id"`
// Name is the entity name.
Name string `json:"name"`
// StepType is the step type.
StepType StepType `json:"step_type"`
// DirectDependencies are steps that must complete before this one.
DirectDependencies []string `json:"direct_dependencies"`
// TransitiveDependencies are all upstream steps (direct and indirect).
TransitiveDependencies []string `json:"transitive_dependencies"`
// DirectDependents are steps that depend on this one.
DirectDependents []string `json:"direct_dependents"`
// TransitiveDependents are all downstream steps (direct and indirect).
TransitiveDependents []string `json:"transitive_dependents"`
// RequiredInputs lists required input ports.
RequiredInputs []string `json:"required_inputs"`
// ProducedOutputs lists output ports.
ProducedOutputs []string `json:"produced_outputs"`
// CriticalPath indicates if this step is on the critical path.
CriticalPath bool `json:"critical_path"`
}
DependencyAnalysis returns a detailed analysis of step dependencies.
type DeploymentComponent ¶ added in v0.4.0
type DeploymentComponent struct {
// ID is the unique identifier for this component.
ID string `json:"id"`
// Name is the human-readable display name.
Name string `json:"name"`
// Type classifies the component (e.g., "idp", "iga", "gateway", "mcp_client").
Type string `json:"type"`
// Description provides additional context.
Description string `json:"description,omitempty"`
// Entities lists the entity IDs contained in this component.
Entities []string `json:"entities,omitempty"`
// Implements lists the protocol roles this component implements.
Implements []ProtocolRole `json:"implements,omitempty"`
// Examples lists real-world products that represent this component type.
Examples []string `json:"examples,omitempty"`
}
DeploymentComponent defines a logical deployment component that groups entities.
type Determinism ¶ added in v0.5.0
type Determinism string
Determinism classifies processing predictability.
const ( // DeterminismDeterministic indicates repeatable, predictable results. DeterminismDeterministic Determinism = "deterministic" // DeterminismNonDeterministic indicates variable results (e.g., LLM output). DeterminismNonDeterministic Determinism = "non_deterministic" )
type DiffCategory ¶ added in v0.4.0
type DiffCategory string
DiffCategory represents the category of a diff item.
const ( DiffCategoryEntity DiffCategory = "entity" DiffCategoryFlow DiffCategory = "flow" DiffCategoryPhase DiffCategory = "phase" DiffCategoryMetadata DiffCategory = "metadata" )
type DiffItem ¶ added in v0.4.0
type DiffItem struct {
// Type indicates whether the item was added, removed, or modified.
Type DiffType `json:"type"`
// Category classifies what was changed.
Category DiffCategory `json:"category"`
// Path identifies the location of the change (e.g., "entities[0]", "flows[2].action").
Path string `json:"path"`
// OldValue is the value before the change (nil for additions).
OldValue interface{} `json:"old_value,omitempty"`
// NewValue is the value after the change (nil for removals).
NewValue interface{} `json:"new_value,omitempty"`
// Summary is a human-readable description of the change.
Summary string `json:"summary"`
}
DiffItem represents a single difference between two protocols.
type DiffOptions ¶ added in v0.4.0
type DiffOptions struct {
// IgnoreMetadata skips metadata comparison.
IgnoreMetadata bool
// IgnoreDescriptions skips description field comparisons.
IgnoreDescriptions bool
// DeepFlowCompare enables detailed flow field comparison.
DeepFlowCompare bool
}
DiffOptions controls comparison behavior.
func DefaultDiffOptions ¶ added in v0.4.0
func DefaultDiffOptions() DiffOptions
DefaultDiffOptions returns default comparison options.
type DiffSummary ¶ added in v0.4.0
type DiffSummary struct {
// TotalChanges is the total number of differences.
TotalChanges int `json:"total_changes"`
// Added counts items that were added.
Added int `json:"added"`
// Removed counts items that were removed.
Removed int `json:"removed"`
// Modified counts items that were modified.
Modified int `json:"modified"`
// ByCategory breaks down changes by category.
ByCategory map[DiffCategory]int `json:"by_category"`
}
DiffSummary provides counts of changes by category.
type Entity ¶
type Entity struct {
// ID is the unique identifier used in flow references.
ID string `json:"id"`
// Name is the human-readable display name.
Name string `json:"name"`
// Type classifies the entity.
Type EntityType `json:"type"`
// Description of the entity's role.
Description string `json:"description,omitempty"`
// TrustLevel classifies the trust level of this entity.
TrustLevel TrustLevel `json:"trust_level,omitempty"`
// Metadata contains additional entity properties for rendering.
Metadata *EntityMetadata `json:"metadata,omitempty"`
// States defines the possible states for this entity.
States []EntityState `json:"states,omitempty"`
// ProtocolRoles defines the protocol-specific roles this entity implements.
ProtocolRoles []ProtocolRole `json:"protocol_roles,omitempty"`
// StepType classifies the processing nature (process profile).
StepType StepType `json:"step_type,omitempty"`
// Inputs defines input specifications (process profile).
Inputs []DataPort `json:"inputs,omitempty"`
// Outputs defines output specifications (process profile).
Outputs []DataPort `json:"outputs,omitempty"`
// Processing configures step execution (process profile).
Processing *ProcessingConfig `json:"processing,omitempty"`
// FailureModes lists possible failure scenarios (process profile).
FailureModes []FailureMode `json:"failure_modes,omitempty"`
// RetryStrategy configures retry behavior (process profile).
RetryStrategy *RetryStrategy `json:"retry_strategy,omitempty"`
// Parallel configures parallel execution for this step.
Parallel *ParallelConfig `json:"parallel,omitempty"`
}
Entity represents a participant in the protocol.
func (Entity) FailureModeByID ¶ added in v0.5.0
func (e Entity) FailureModeByID(id string) *FailureMode
FailureModeByID returns the failure mode with the given ID, or nil if not found.
func (Entity) HasOutputs ¶ added in v0.5.0
HasOutputs returns true if this entity has outputs defined.
func (Entity) HasProtocolRoles ¶ added in v0.4.0
HasProtocolRoles returns true if the entity has protocol roles defined.
func (Entity) HasStates ¶ added in v0.4.0
HasStates returns true if the entity has any states defined.
func (Entity) InitialState ¶ added in v0.4.0
func (e Entity) InitialState() *EntityState
InitialState returns the initial state, or nil if none is marked as initial.
func (Entity) InputByName ¶ added in v0.5.0
InputByName returns the input with the given name, or nil if not found.
func (Entity) IsDeterministic ¶ added in v0.5.0
IsDeterministic returns true if this is a deterministic step.
func (Entity) IsExternalStep ¶ added in v0.5.0
IsExternalStep returns true if this is an external service step.
func (Entity) IsHumanStep ¶ added in v0.5.0
IsHumanStep returns true if this is a human-in-the-loop step.
func (Entity) IsNonDeterministic ¶ added in v0.5.0
IsNonDeterministic returns true if this step may produce different outputs for the same inputs.
func (Entity) IsProcessStep ¶ added in v0.5.0
IsProcessStep returns true if this entity has process step semantics.
func (Entity) IsToolStep ¶ added in v0.5.0
IsToolStep returns true if this is a tool invocation step.
func (Entity) OutputByName ¶ added in v0.5.0
OutputByName returns the output with the given name, or nil if not found.
func (Entity) RequiredInputs ¶ added in v0.5.0
RequiredInputs returns inputs that are marked as required.
func (Entity) RolesByProtocol ¶ added in v0.4.0
func (e Entity) RolesByProtocol(protocol string) []ProtocolRole
RolesByProtocol returns all roles for a specific protocol.
func (Entity) SensitiveInputs ¶ added in v0.5.0
SensitiveInputs returns inputs that are marked as sensitive.
func (Entity) SensitiveOutputs ¶ added in v0.5.0
SensitiveOutputs returns outputs that are marked as sensitive.
func (Entity) StateByID ¶ added in v0.4.0
func (e Entity) StateByID(id string) *EntityState
StateByID returns the state with the given ID, or nil if not found.
type EntityMetadata ¶ added in v0.3.0
type EntityMetadata struct {
// Network is the network boundary this entity belongs to.
Network string `json:"network,omitempty"`
// ServiceType classifies the service (e.g., "api", "database", "gateway").
ServiceType string `json:"type,omitempty"`
}
EntityMetadata contains additional entity properties.
type EntityState ¶ added in v0.4.0
type EntityState struct {
// ID is the unique identifier for this state within the entity.
ID string `json:"id"`
// Name is the human-readable display name.
Name string `json:"name,omitempty"`
// Description provides additional context.
Description string `json:"description,omitempty"`
// Initial marks this as the initial state.
Initial bool `json:"initial,omitempty"`
// Final marks this as a terminal/final state.
Final bool `json:"final,omitempty"`
}
EntityState represents a possible state for an entity.
type EntityType ¶
type EntityType string
EntityType represents the type of an entity.
const ( EntityTypeClient EntityType = "client" EntityTypeAuthorizationServer EntityType = "authorization_server" EntityTypeResourceServer EntityType = "resource_server" EntityTypeUser EntityType = "user" EntityTypeBrowser EntityType = "browser" EntityTypeAgent EntityType = "agent" EntityTypeToolServer EntityType = "tool_server" EntityTypeTool EntityType = "tool" EntityTypeDelegatedAgent EntityType = "delegated_agent" EntityTypeIdentityProvider EntityType = "identity_provider" EntityTypeServiceProvider EntityType = "service_provider" EntityTypeServer EntityType = "server" EntityTypeOther EntityType = "other" )
type ExecutionContext ¶ added in v0.4.0
type ExecutionContext struct {
// Protocol being executed.
Protocol *Protocol
// EntityStates maps entity ID to current state ID.
EntityStates map[string]string
// FlowIndex is the current position in the protocol's flows.
FlowIndex int
// Trace records execution history.
Trace *ExecutionTrace
// EventQueue holds pending events for event-driven execution.
EventQueue []ExecutionEvent
// Completed indicates execution has finished.
Completed bool
// Error holds any execution error.
Error error
}
ExecutionContext holds the runtime state of a protocol execution.
func (*ExecutionContext) CurrentFlow ¶ added in v0.4.0
func (ctx *ExecutionContext) CurrentFlow() *Flow
CurrentFlow returns the next flow to be executed, or nil if complete.
func (*ExecutionContext) GetEntityState ¶ added in v0.4.0
func (ctx *ExecutionContext) GetEntityState(entityID string) string
GetEntityState returns the current state of an entity.
func (*ExecutionContext) Progress ¶ added in v0.4.0
func (ctx *ExecutionContext) Progress() float64
Progress returns execution progress as a percentage (0-100).
func (*ExecutionContext) SetEntityState ¶ added in v0.4.0
func (ctx *ExecutionContext) SetEntityState(entityID, stateID string)
SetEntityState manually sets an entity's state.
type ExecutionEvent ¶ added in v0.4.0
type ExecutionEvent struct {
// Type categorizes the event.
Type string `json:"type"`
// FlowIndex references a specific flow (if applicable).
FlowIndex int `json:"flow_index,omitempty"`
// EntityID references a specific entity (if applicable).
EntityID string `json:"entity_id,omitempty"`
// Data holds event-specific payload.
Data map[string]interface{} `json:"data,omitempty"`
}
ExecutionEvent represents a pending event in the queue.
type ExecutionGraph ¶ added in v0.5.0
type ExecutionGraph struct {
// ProtocolID is the source protocol ID.
ProtocolID string
// Stages are ordered groups of steps that can execute in parallel.
Stages []ExecutionStage
// CriticalPath is the longest path through the graph.
CriticalPath []string
// EstimatedDuration is the estimated total execution time.
EstimatedDuration time.Duration
}
ExecutionGraph represents the execution order of steps.
func AnalyzeExecutionGraph ¶ added in v0.5.0
func AnalyzeExecutionGraph(p *Protocol) *ExecutionGraph
AnalyzeExecutionGraph builds an execution graph from a process protocol.
type ExecutionMetrics ¶ added in v0.5.0
type ExecutionMetrics struct {
// Duration is the actual execution time.
Duration time.Duration `json:"duration"`
// InputTokens is the actual input token count.
InputTokens int `json:"input_tokens,omitempty"`
// OutputTokens is the actual output token count.
OutputTokens int `json:"output_tokens,omitempty"`
// APICallCount is the number of API calls made.
APICallCount int `json:"api_call_count,omitempty"`
}
ExecutionMetrics captures actual execution data for cost calculation.
type ExecutionReadiness ¶ added in v0.5.0
type ExecutionReadiness struct {
// TotalSteps is the total number of process steps.
TotalSteps int `json:"total_steps"`
// ReadySteps is the number of steps ready to execute.
ReadySteps int `json:"ready_steps"`
// BlockedSteps is the number of blocked steps.
BlockedSteps int `json:"blocked_steps"`
// CompletedSteps is the number of completed steps.
CompletedSteps int `json:"completed_steps"`
// InProgressSteps is the number of steps currently executing.
InProgressSteps int `json:"in_progress_steps"`
// FailedSteps is the number of failed steps.
FailedSteps int `json:"failed_steps"`
// NextSteps lists the entity IDs of steps ready to execute.
NextSteps []string `json:"next_steps"`
// BlockedReasons maps blocked step IDs to their blocking reasons.
BlockedReasons map[string][]string `json:"blocked_reasons"`
}
ExecutionReadiness summarizes the execution readiness of the process.
type ExecutionStage ¶ added in v0.5.0
type ExecutionStage struct {
// ID is the stage identifier.
ID string
// Steps are entity IDs that can execute in parallel at this stage.
Steps []string
// Dependencies are stage IDs that must complete before this stage.
Dependencies []string
// IsParallelBlock indicates this stage is an explicit parallel block.
IsParallelBlock bool
// ParallelConfig is the configuration for parallel execution.
ParallelConfig *ParallelConfig
}
ExecutionStage represents a group of steps that can execute concurrently.
type ExecutionStep ¶ added in v0.4.0
type ExecutionStep struct {
// StepNumber is the 1-based step counter.
StepNumber int `json:"step_number"`
// FlowIndex is the index in Protocol.Flows.
FlowIndex int `json:"flow_index"`
// Timestamp when this step executed.
Timestamp time.Time `json:"timestamp"`
// From is the source entity ID.
From string `json:"from"`
// To is the target entity ID.
To string `json:"to"`
// Action is the flow action.
Action string `json:"action"`
// Label is the flow display label.
Label string `json:"label,omitempty"`
// Mode is the flow mode.
Mode FlowMode `json:"mode,omitempty"`
// Phase is the phase ID.
Phase string `json:"phase,omitempty"`
// Condition is the flow's condition (if any).
Condition string `json:"condition,omitempty"`
// ConditionMet indicates if condition was satisfied (for conditional flows).
ConditionMet *bool `json:"condition_met,omitempty"`
// StateChanges records state mutations from this step.
StateChanges []StateChange `json:"state_changes,omitempty"`
// Skipped indicates this flow was skipped (condition not met).
Skipped bool `json:"skipped,omitempty"`
// SkipReason explains why flow was skipped.
SkipReason string `json:"skip_reason,omitempty"`
}
ExecutionStep records a single flow execution.
type ExecutionTrace ¶ added in v0.4.0
type ExecutionTrace struct {
// ProtocolID identifies the executed protocol.
ProtocolID string `json:"protocol_id"`
// ProtocolName is the human-readable protocol name.
ProtocolName string `json:"protocol_name"`
// StartTime when execution began.
StartTime time.Time `json:"start_time"`
// EndTime when execution completed.
EndTime time.Time `json:"end_time,omitempty"`
// Steps records each executed flow.
Steps []ExecutionStep `json:"steps"`
// InitialStates captures entity states at start.
InitialStates map[string]string `json:"initial_states,omitempty"`
// FinalStates captures entity states at end.
FinalStates map[string]string `json:"final_states,omitempty"`
// Completed indicates if execution ran to completion.
Completed bool `json:"completed"`
// Error message if execution failed.
Error string `json:"error,omitempty"`
}
ExecutionTrace records the complete execution history.
func (*ExecutionTrace) Duration ¶ added in v0.4.0
func (t *ExecutionTrace) Duration() time.Duration
Duration returns the execution duration so far.
func (*ExecutionTrace) SkippedCount ¶ added in v0.4.0
func (t *ExecutionTrace) SkippedCount() int
SkippedCount returns the number of skipped steps.
func (*ExecutionTrace) StateChangeCount ¶ added in v0.4.0
func (t *ExecutionTrace) StateChangeCount() int
StateChangeCount returns the total number of state changes.
func (*ExecutionTrace) StepCount ¶ added in v0.4.0
func (t *ExecutionTrace) StepCount() int
StepCount returns the number of executed steps.
func (*ExecutionTrace) ToJSON ¶ added in v0.4.0
func (t *ExecutionTrace) ToJSON() ([]byte, error)
ToJSON returns the trace as JSON bytes.
type Executor ¶ added in v0.4.0
type Executor struct {
// Protocol to execute.
Protocol *Protocol
// ConditionEvaluator is called to evaluate flow conditions.
// If nil, all conditions are assumed to be met.
ConditionEvaluator func(ctx *ExecutionContext, flow *Flow) bool
}
Executor runs protocol simulations.
func NewExecutor ¶ added in v0.4.0
NewExecutor creates an Executor for the given protocol.
func (*Executor) NewContext ¶ added in v0.4.0
func (e *Executor) NewContext() *ExecutionContext
NewContext creates a fresh execution context with initial states.
func (*Executor) Reset ¶ added in v0.4.0
func (e *Executor) Reset(ctx *ExecutionContext)
Reset restarts execution from the beginning.
func (*Executor) Run ¶ added in v0.4.0
func (e *Executor) Run(ctx *ExecutionContext) (*ExecutionTrace, error)
Run executes all flows to completion.
func (*Executor) RunN ¶ added in v0.4.0
func (e *Executor) RunN(ctx *ExecutionContext, n int) (*ExecutionTrace, error)
RunN executes up to n steps.
func (*Executor) Step ¶ added in v0.4.0
func (e *Executor) Step(ctx *ExecutionContext) (*ExecutionStep, error)
Step executes the next flow and returns the step details. Returns nil when execution is complete.
type FailureMode ¶ added in v0.5.0
type FailureMode struct {
// ID is the unique identifier for this failure mode.
ID string `json:"id"`
// Name is the human-readable name.
Name string `json:"name"`
// Description explains the failure scenario.
Description string `json:"description,omitempty"`
// Severity indicates the impact level.
Severity string `json:"severity,omitempty"`
// Recovery describes how to handle this failure.
Recovery string `json:"recovery,omitempty"`
}
FailureMode describes a possible failure scenario.
type FileValidationResult ¶
type FileValidationResult struct {
Filename string
Protocol *Protocol
Errors ValidationErrors
ParseErr error
}
FileValidationResult contains the result of validating a single file.
func ValidateFiles ¶
func ValidateFiles(filenames []string) []FileValidationResult
ValidateFiles validates multiple PIDL files, returning results for each.
func (FileValidationResult) IsValid ¶
func (r FileValidationResult) IsValid() bool
IsValid returns true if the file parsed and validated successfully.
type Flow ¶
type Flow struct {
// From is the source entity ID.
From string `json:"from"`
// To is the target entity ID.
To string `json:"to"`
// Action identifies the action being performed.
Action string `json:"action"`
// Label is the display label (defaults to Action).
Label string `json:"label,omitempty"`
// Mode is the interaction mode.
Mode FlowMode `json:"mode,omitempty"`
// Phase is the phase ID this flow belongs to.
Phase string `json:"phase,omitempty"`
// Description provides additional details.
Description string `json:"description,omitempty"`
// Sequence provides explicit ordering.
Sequence int `json:"sequence,omitempty"`
// Condition specifies when this flow is executed (e.g., "token_valid", "error").
Condition string `json:"condition,omitempty"`
// Note is a visible annotation displayed on the diagram.
Note string `json:"note,omitempty"`
// Annotations are typed annotations for tooling and documentation.
Annotations []Annotation `json:"annotations,omitempty"`
// Alternatives are alternative paths from this flow point.
Alternatives []Alternative `json:"alternatives,omitempty"`
// Animation configures animation for this flow in animated SVG output.
// Can be a string (preset name) or FlowAnimation object.
Animation *FlowAnimation `json:"animation,omitempty"`
// Sets defines state mutations that occur when this flow executes.
Sets []StateMutation `json:"sets,omitempty"`
// Security specifies security requirements for this flow.
Security *FlowSecurity `json:"security,omitempty"`
// DataMappings explicitly maps output ports to input ports for data lineage.
DataMappings []DataPortMapping `json:"data_mappings,omitempty"`
}
Flow represents an interaction between two entities.
func (Flow) DisplayLabel ¶
DisplayLabel returns the label for display, falling back to Action if Label is empty.
func (Flow) EffectiveMode ¶
EffectiveMode returns the flow mode, defaulting to FlowModeRequest if empty.
func (Flow) HasAlternatives ¶ added in v0.2.0
HasAlternatives returns true if the flow has alternative paths.
func (Flow) HasAnnotations ¶ added in v0.2.0
HasAnnotations returns true if the flow has annotations.
func (Flow) HasCondition ¶ added in v0.2.0
HasCondition returns true if the flow has a condition.
func (Flow) HasSecurity ¶ added in v0.4.0
HasSecurity returns true if the flow has security requirements.
func (Flow) HasStateMutations ¶ added in v0.4.0
HasStateMutations returns true if the flow has any state mutations.
func (Flow) RequiresEncryption ¶ added in v0.4.0
RequiresEncryption returns true if the flow requires encryption.
func (Flow) RequiresToken ¶ added in v0.4.0
RequiresToken returns true if the flow requires a token.
type FlowAnimation ¶ added in v0.3.0
type FlowAnimation struct {
// Enabled controls whether this flow is animated. Defaults to true.
Enabled *bool `json:"enabled,omitempty"`
// Preset is a semantic preset name (request, success, error, warning, highlight, none).
Preset AnimationPreset `json:"preset,omitempty"`
// Duration is the animation cycle duration (e.g., "2s", "1.5s").
Duration string `json:"duration,omitempty"`
// Delay is the animation start delay (e.g., "0.5s").
Delay string `json:"delay,omitempty"`
// DotColor is the animated dot fill color.
DotColor string `json:"dot_color,omitempty"`
// DotSize is the animated dot radius in pixels.
DotSize int `json:"dot_size,omitempty"`
// Pulse adds a pulsing effect (useful for errors/warnings).
Pulse bool `json:"pulse,omitempty"`
// Easing is the CSS easing function (linear, ease-in-out, etc.).
Easing string `json:"easing,omitempty"`
}
FlowAnimation configures animation for a flow in animated SVG output.
func (*FlowAnimation) EffectiveDotColor ¶ added in v0.3.0
func (f *FlowAnimation) EffectiveDotColor(defaultColor string) string
EffectiveDotColor returns the dot color, applying preset defaults.
func (*FlowAnimation) EffectiveDotSize ¶ added in v0.3.0
func (f *FlowAnimation) EffectiveDotSize(defaultSize int) int
EffectiveDotSize returns the dot size, applying preset defaults.
func (*FlowAnimation) IsAnimationEnabled ¶ added in v0.3.0
func (f *FlowAnimation) IsAnimationEnabled() bool
IsAnimationEnabled returns whether animation is enabled for this flow.
func (*FlowAnimation) ShouldGlow ¶ added in v0.4.0
func (f *FlowAnimation) ShouldGlow() bool
ShouldGlow returns whether the dot should have a glow effect.
func (*FlowAnimation) ShouldPulse ¶ added in v0.3.0
func (f *FlowAnimation) ShouldPulse() bool
ShouldPulse returns whether the dot should pulse.
type FlowListItem ¶ added in v0.4.0
FlowListItem represents a flow for listing purposes.
type FlowMode ¶
type FlowMode string
FlowMode represents the type of interaction.
const ( FlowModeRequest FlowMode = "request" FlowModeResponse FlowMode = "response" FlowModeRedirect FlowMode = "redirect" FlowModeCallback FlowMode = "callback" FlowModeInteractive FlowMode = "interactive" FlowModeEvent FlowMode = "event" FlowModeToolCall FlowMode = "tool_call" FlowModeToolResult FlowMode = "tool_result" )
type FlowSecurity ¶ added in v0.4.0
type FlowSecurity struct {
// Requires lists security mechanisms required for this flow.
Requires []SecurityRequirement `json:"requires,omitempty"`
// Token is the token definition ID used for this flow.
Token string `json:"token,omitempty"`
// Confidential indicates if the flow carries sensitive data.
Confidential bool `json:"confidential,omitempty"`
// Description provides additional security context.
Description string `json:"description,omitempty"`
}
FlowSecurity describes security requirements for a flow.
type JoinCondition ¶ added in v0.5.0
type JoinCondition string
JoinCondition specifies when parallel execution is considered complete.
const ( // JoinConditionAll waits for all branches to complete. JoinConditionAll JoinCondition = "all" // JoinConditionAny completes when any branch completes. JoinConditionAny JoinCondition = "any" // JoinConditionMajority completes when majority of branches complete. JoinConditionMajority JoinCondition = "majority" // JoinConditionQuorum completes when a quorum of branches complete. JoinConditionQuorum JoinCondition = "quorum" )
type LatencyBudget ¶ added in v0.5.0
type LatencyBudget struct {
// P50 is the 50th percentile latency target.
P50 string `json:"p50,omitempty"`
// P95 is the 95th percentile latency target.
P95 string `json:"p95,omitempty"`
// P99 is the 99th percentile latency target.
P99 string `json:"p99,omitempty"`
// Max is the maximum acceptable latency (hard limit).
Max string `json:"max,omitempty"`
// ExpectedLatency is the expected typical latency.
ExpectedLatency string `json:"expected_latency,omitempty"`
// Critical marks this step as on the critical path.
Critical bool `json:"critical,omitempty"`
// VarianceClass indicates latency variability (low, medium, high).
VarianceClass LatencyVarianceClass `json:"variance_class,omitempty"`
}
LatencyBudget defines timing SLIs (Service Level Indicators) for a step.
type LatencyBudgetViolation ¶ added in v0.5.0
type LatencyBudgetViolation struct {
// EntityID is the violating entity.
EntityID string `json:"entity_id"`
// Metric is the violated metric (p50, p95, p99, max).
Metric string `json:"metric"`
// Budget is the budgeted latency.
Budget time.Duration `json:"budget"`
// Estimated is the estimated latency.
Estimated time.Duration `json:"estimated"`
// Severity indicates the violation severity.
Severity string `json:"severity"`
}
LatencyBudgetViolation describes a step exceeding its latency budget.
type LatencyEstimate ¶ added in v0.5.0
type LatencyEstimate struct {
// EntityID is the entity this estimate is for (empty for total).
EntityID string `json:"entity_id,omitempty"`
// P50 is the 50th percentile latency.
P50 time.Duration `json:"p50"`
// P95 is the 95th percentile latency.
P95 time.Duration `json:"p95"`
// P99 is the 99th percentile latency.
P99 time.Duration `json:"p99"`
// Max is the maximum expected latency.
Max time.Duration `json:"max"`
// Expected is the expected typical latency.
Expected time.Duration `json:"expected"`
// VarianceClass indicates the latency variability.
VarianceClass LatencyVarianceClass `json:"variance_class"`
// OnCriticalPath indicates if this step is on the critical path.
OnCriticalPath bool `json:"on_critical_path"`
}
LatencyEstimate represents an estimated latency for a step.
type LatencyMeasurement ¶ added in v0.5.0
type LatencyMeasurement struct {
// EntityID is the entity that was measured.
EntityID string `json:"entity_id"`
// Duration is the actual execution duration.
Duration time.Duration `json:"duration"`
// ExceedsP50 indicates if duration exceeded P50 budget.
ExceedsP50 bool `json:"exceeds_p50,omitempty"`
// ExceedsP95 indicates if duration exceeded P95 budget.
ExceedsP95 bool `json:"exceeds_p95,omitempty"`
// ExceedsP99 indicates if duration exceeded P99 budget.
ExceedsP99 bool `json:"exceeds_p99,omitempty"`
// ExceedsMax indicates if duration exceeded Max budget.
ExceedsMax bool `json:"exceeds_max,omitempty"`
}
LatencyMeasurement records actual execution latency.
func CalculateActualLatency ¶ added in v0.5.0
func CalculateActualLatency(entity *Entity, duration time.Duration) *LatencyMeasurement
CalculateActualLatency calculates latency from execution metrics.
type LatencyVarianceClass ¶ added in v0.5.0
type LatencyVarianceClass string
LatencyVarianceClass classifies the variability of step latency.
const ( // LatencyVarianceLow indicates consistent, predictable latency. LatencyVarianceLow LatencyVarianceClass = "low" // LatencyVarianceMedium indicates moderate latency variance. LatencyVarianceMedium LatencyVarianceClass = "medium" // LatencyVarianceHigh indicates high variance (e.g., LLM, human tasks). LatencyVarianceHigh LatencyVarianceClass = "high" )
type LineageEdge ¶ added in v0.5.0
type LineageEdge struct {
// SourceEntity is the ID of the entity providing the data.
SourceEntity string `json:"source_entity"`
// SourcePort is the name of the output port.
SourcePort string `json:"source_port"`
// TargetEntity is the ID of the entity consuming the data.
TargetEntity string `json:"target_entity"`
// TargetPort is the name of the input port.
TargetPort string `json:"target_port"`
// FlowIndex is the index of the flow that creates this connection.
FlowIndex int `json:"flow_index"`
// Transformation describes any data transformation applied.
Transformation string `json:"transformation,omitempty"`
}
LineageEdge represents a data flow connection between ports.
type NetworkConfig ¶ added in v0.3.0
type NetworkConfig struct {
// Name is the display name for the boundary.
Name string `json:"name,omitempty"`
// Style is the visual style: trusted, dmz, external, cloud.
Style string `json:"style,omitempty"`
// Entities explicitly lists entity IDs in this boundary.
Entities []string `json:"entities,omitempty"`
// Description provides tooltip/hover text.
Description string `json:"description,omitempty"`
// Color overrides the default boundary color.
Color string `json:"color,omitempty"`
}
NetworkConfig defines a network boundary.
type NetworkLayoutConfig ¶ added in v0.3.0
type NetworkLayoutConfig struct {
// Direction is the layout direction: horizontal or vertical.
Direction string `json:"direction,omitempty"`
// Order specifies the boundary ordering.
Order []string `json:"order,omitempty"`
}
NetworkLayoutConfig configures network diagram layout.
type ParallelBlock ¶ added in v0.5.0
type ParallelBlock struct {
// ID is the unique identifier for this block.
ID string
// ForkEntity is the entity that starts the parallel execution.
ForkEntity string
// JoinEntity is the entity that collects results (if any).
JoinEntity string
// Branches are the parallel branches.
Branches []ParallelBranch
// Mode is the parallel execution mode.
Mode ParallelMode
// JoinCondition specifies completion criteria.
JoinCondition JoinCondition
}
ParallelBlock represents a detected parallel execution block.
func DetectParallelBlocks ¶ added in v0.5.0
func DetectParallelBlocks(p *Protocol) []ParallelBlock
DetectParallelBlocks identifies explicit parallel execution blocks in the protocol.
type ParallelBranch ¶ added in v0.5.0
type ParallelBranch struct {
// ID is the unique identifier for this branch.
ID string `json:"id"`
// Name is the human-readable name.
Name string `json:"name,omitempty"`
// EntityID is the target entity for this branch (optional).
EntityID string `json:"entity_id,omitempty"`
// FlowRefs lists flow indices that belong to this branch.
FlowRefs []int `json:"flow_refs,omitempty"`
// Condition specifies when this branch is executed.
Condition string `json:"condition,omitempty"`
// Weight for load balancing in scatter mode.
Weight float64 `json:"weight,omitempty"`
}
ParallelBranch represents a branch in parallel execution.
type ParallelConfig ¶ added in v0.5.0
type ParallelConfig struct {
// Mode specifies the parallel execution mode.
Mode ParallelMode `json:"mode"`
// Branches lists the parallel branches (entity IDs or flow groups).
Branches []ParallelBranch `json:"branches,omitempty"`
// JoinCondition specifies when parallel execution is considered complete.
JoinCondition JoinCondition `json:"join_condition,omitempty"`
// MaxConcurrency limits the number of concurrent executions.
MaxConcurrency int `json:"max_concurrency,omitempty"`
// Timeout for the entire parallel block.
Timeout string `json:"timeout,omitempty"`
}
ParallelConfig configures parallel execution for a step or flow.
type ParallelMode ¶ added in v0.5.0
type ParallelMode string
ParallelMode specifies how parallel execution is structured.
const ( // ParallelModeForkJoin executes branches in parallel and waits for all. ParallelModeForkJoin ParallelMode = "fork_join" // ParallelModeRace executes branches in parallel, first to complete wins. ParallelModeRace ParallelMode = "race" // ParallelModeScatter distributes work across multiple instances. ParallelModeScatter ParallelMode = "scatter" // ParallelModeGather collects results from parallel branches. ParallelModeGather ParallelMode = "gather" )
type Phase ¶
type Phase struct {
// ID is the unique identifier.
ID string `json:"id"`
// Name is the human-readable name.
Name string `json:"name"`
// Description of the phase.
Description string `json:"description,omitempty"`
// Parent is the ID of the parent phase for nested phases.
Parent string `json:"parent,omitempty"`
}
Phase represents a logical grouping of flows.
type PortReference ¶ added in v0.5.0
type PortReference struct {
// EntityID is the ID of the entity.
EntityID string `json:"entity_id"`
// PortName is the name of the port.
PortName string `json:"port_name"`
// PortKind indicates if this is an input or output port.
PortKind string `json:"port_kind"` // "input" or "output"
// Sensitive indicates if the port handles sensitive data.
Sensitive bool `json:"sensitive,omitempty"`
}
PortReference identifies a specific port on an entity.
type PortSchemaValidator ¶ added in v0.5.0
type PortSchemaValidator struct {
// contains filtered or unexported fields
}
PortSchemaValidator validates data ports against their schemas.
func NewPortSchemaValidator ¶ added in v0.5.0
func NewPortSchemaValidator() *PortSchemaValidator
NewPortSchemaValidator creates a new port schema validator.
func (*PortSchemaValidator) SetBasePath ¶ added in v0.5.0
func (v *PortSchemaValidator) SetBasePath(path string)
SetBasePath sets the base directory for resolving relative schema paths.
func (*PortSchemaValidator) ValidateEntityInputs ¶ added in v0.5.0
func (v *PortSchemaValidator) ValidateEntityInputs(entity Entity, inputs map[string]interface{}) (*SchemaValidationResult, error)
ValidateEntityInputs validates all input data for an entity.
func (*PortSchemaValidator) ValidateEntityOutputs ¶ added in v0.5.0
func (v *PortSchemaValidator) ValidateEntityOutputs(entity Entity, outputs map[string]interface{}) (*SchemaValidationResult, error)
ValidateEntityOutputs validates all output data from an entity.
func (*PortSchemaValidator) ValidatePortData ¶ added in v0.5.0
func (v *PortSchemaValidator) ValidatePortData(port DataPort, data interface{}) (*SchemaValidationResult, error)
ValidatePortData validates data against a port's schema.
type ProcessCostAnalysis ¶ added in v0.5.0
type ProcessCostAnalysis struct {
// ProtocolID is the source protocol.
ProtocolID string `json:"protocol_id"`
// TotalEstimate is the total estimated cost.
TotalEstimate CostEstimate `json:"total_estimate"`
// StepEstimates are per-step cost estimates.
StepEstimates []CostEstimate `json:"step_estimates"`
// CostByType shows costs grouped by step type.
CostByType map[StepType]float64 `json:"cost_by_type"`
// CriticalPathCost is the cost of the critical path.
CriticalPathCost float64 `json:"critical_path_cost"`
// ParallelSavings is estimated savings from parallelization.
ParallelSavings float64 `json:"parallel_savings,omitempty"`
}
ProcessCostAnalysis provides complete cost analysis for a process.
func AnalyzeProcessCosts ¶ added in v0.5.0
func AnalyzeProcessCosts(p *Protocol) *ProcessCostAnalysis
AnalyzeProcessCosts calculates cost estimates for a process protocol.
type ProcessExecutionContext ¶ added in v0.5.0
type ProcessExecutionContext struct {
*ExecutionContext
// AvailableInputs tracks which data ports have data available.
// Key is "entityID.portName", value is true if available.
AvailableInputs map[string]bool
// ProducedOutputs tracks which outputs have been produced.
// Key is "entityID.portName", value is true if produced.
ProducedOutputs map[string]bool
// BlockedSteps tracks which steps are blocked and why.
BlockedSteps map[string][]string // entityID -> list of missing inputs
// ExecutionOrder is the topologically sorted execution order.
ExecutionOrder []string
// StepStatus tracks the status of each step.
StepStatus map[string]StepExecutionStatus
}
ProcessExecutionContext extends ExecutionContext with process-specific tracking.
type ProcessExecutor ¶ added in v0.5.0
type ProcessExecutor struct {
*Executor
// DataFlowGraph maps entity outputs to consuming entity inputs.
// Key is "sourceEntityID.outputName", value is list of "targetEntityID.inputName".
DataFlowGraph map[string][]string
// Dependencies maps entity ID to its required predecessor entity IDs.
Dependencies map[string][]string
// Dependents maps entity ID to entities that depend on it.
Dependents map[string][]string
}
ProcessExecutor provides process-aware execution with data flow tracking.
func NewProcessExecutor ¶ added in v0.5.0
func NewProcessExecutor(p *Protocol) (*ProcessExecutor, error)
NewProcessExecutor creates a ProcessExecutor for process spec simulation.
func (*ProcessExecutor) AnalyzeDependencies ¶ added in v0.5.0
func (pe *ProcessExecutor) AnalyzeDependencies() []DependencyAnalysis
AnalyzeDependencies returns dependency analysis for all process steps.
func (*ProcessExecutor) CompleteStep ¶ added in v0.5.0
func (pe *ProcessExecutor) CompleteStep(ctx *ProcessExecutionContext, entityID string) error
CompleteStep marks a step as completed and produces its outputs.
func (*ProcessExecutor) FailStep ¶ added in v0.5.0
func (pe *ProcessExecutor) FailStep(ctx *ProcessExecutionContext, entityID string) error
FailStep marks a step as failed.
func (*ProcessExecutor) GetBlockedSteps ¶ added in v0.5.0
func (pe *ProcessExecutor) GetBlockedSteps(ctx *ProcessExecutionContext) map[string][]string
GetBlockedSteps returns steps that cannot execute due to missing inputs.
func (*ProcessExecutor) GetExecutionReadiness ¶ added in v0.5.0
func (pe *ProcessExecutor) GetExecutionReadiness(ctx *ProcessExecutionContext) ExecutionReadiness
GetExecutionReadiness returns a summary of execution readiness.
func (*ProcessExecutor) GetReadySteps ¶ added in v0.5.0
func (pe *ProcessExecutor) GetReadySteps(ctx *ProcessExecutionContext) []string
GetReadySteps returns steps that have all required inputs available.
func (*ProcessExecutor) MarkInputAvailable ¶ added in v0.5.0
func (pe *ProcessExecutor) MarkInputAvailable(ctx *ProcessExecutionContext, entityID, inputName string)
MarkInputAvailable marks a data port as having data available.
func (*ProcessExecutor) MarkOutputProduced ¶ added in v0.5.0
func (pe *ProcessExecutor) MarkOutputProduced(ctx *ProcessExecutionContext, entityID, outputName string)
MarkOutputProduced marks an output as produced and propagates to connected inputs.
func (*ProcessExecutor) NewProcessContext ¶ added in v0.5.0
func (pe *ProcessExecutor) NewProcessContext() *ProcessExecutionContext
NewProcessContext creates a fresh process execution context.
func (*ProcessExecutor) StartStep ¶ added in v0.5.0
func (pe *ProcessExecutor) StartStep(ctx *ProcessExecutionContext, entityID string) error
StartStep marks a step as in progress.
func (*ProcessExecutor) TopologicalSort ¶ added in v0.5.0
func (pe *ProcessExecutor) TopologicalSort() []string
TopologicalSort returns entities in topological execution order. Steps with no dependencies come first.
type ProcessLatencyAnalysis ¶ added in v0.5.0
type ProcessLatencyAnalysis struct {
// ProtocolID is the source protocol.
ProtocolID string `json:"protocol_id"`
// TotalLatency is the estimated end-to-end latency.
TotalLatency LatencyEstimate `json:"total_latency"`
// StepLatencies are per-step latency estimates.
StepLatencies []LatencyEstimate `json:"step_latencies"`
// CriticalPathLatency is the latency of the critical path.
CriticalPathLatency LatencyEstimate `json:"critical_path_latency"`
// CriticalPath is the list of entity IDs on the critical path.
CriticalPath []string `json:"critical_path"`
// ParallelSavings is the latency saved by parallel execution.
ParallelSavings time.Duration `json:"parallel_savings"`
// BudgetViolations lists steps exceeding their latency budget.
BudgetViolations []LatencyBudgetViolation `json:"budget_violations,omitempty"`
// LatencyByType shows latencies grouped by step type.
LatencyByType map[StepType]time.Duration `json:"latency_by_type"`
}
ProcessLatencyAnalysis provides complete latency analysis for a process.
func AnalyzeProcessLatency ¶ added in v0.5.0
func AnalyzeProcessLatency(p *Protocol) *ProcessLatencyAnalysis
AnalyzeProcessLatency calculates latency estimates for a process protocol.
type ProcessingConfig ¶ added in v0.5.0
type ProcessingConfig struct {
// Engine identifies the processing engine.
Engine string `json:"engine,omitempty"`
// Determinism indicates processing predictability.
Determinism Determinism `json:"determinism,omitempty"`
// ModelPolicy specifies model selection for LLM steps.
ModelPolicy string `json:"model_policy,omitempty"`
// Timeout is the maximum processing duration.
Timeout string `json:"timeout,omitempty"`
// Idempotent indicates if repeated execution is safe.
Idempotent bool `json:"idempotent,omitempty"`
// Cacheable indicates if outputs can be cached.
Cacheable bool `json:"cacheable,omitempty"`
// CacheTTL is the cache time-to-live if cacheable.
CacheTTL string `json:"cache_ttl,omitempty"`
// CostModel specifies the cost tracking model for this step.
CostModel *CostModel `json:"cost_model,omitempty"`
// LatencyBudget specifies timing SLIs for this step.
LatencyBudget *LatencyBudget `json:"latency_budget,omitempty"`
}
ProcessingConfig describes how a step processes its inputs.
type Protocol ¶
type Protocol struct {
// ProtocolMeta contains metadata about the protocol.
ProtocolMeta ProtocolMeta `json:"protocol"`
// Extends specifies a base protocol to extend.
Extends *ProtocolExtends `json:"extends,omitempty"`
// Imports specifies other protocol files to import from.
Imports []ProtocolImport `json:"imports,omitempty"`
// Entities are the participants in the protocol (systems, actors, services).
Entities []Entity `json:"entities"`
// Phases provide optional logical grouping of flows.
Phases []Phase `json:"phases,omitempty"`
// Flows are the interactions between entities.
Flows []Flow `json:"flows"`
// Metadata contains additional protocol-level configuration.
Metadata *ProtocolMetadata `json:"metadata,omitempty"`
// contains filtered or unexported fields
}
Protocol represents a complete PIDL document describing a protocol's choreography.
func MustParse ¶
MustParse parses PIDL JSON data and panics on error. Use only in tests or initialization code.
func MustParseFile ¶
MustParseFile reads and parses a PIDL JSON file, panicking on error. Use only in tests or initialization code.
func NewMinimalProtocol ¶
NewMinimalProtocol creates a minimal valid protocol scaffold.
func ParseReader ¶
ParseReader parses PIDL JSON from an io.Reader.
func (*Protocol) AllComponentTypes ¶ added in v0.4.0
AllComponentTypes returns a unique list of all component types. Returns an empty slice if no components exist or Metadata is nil.
func (*Protocol) AllProtocols ¶ added in v0.4.0
AllProtocols returns a unique list of all protocols referenced in entity roles. Returns an empty slice if no protocols are found.
func (*Protocol) AllTrustRelationTypes ¶ added in v0.4.0
AllTrustRelationTypes returns a unique list of all trust relation types. Returns an empty slice if no trust relations exist or Metadata is nil.
func (*Protocol) ChildPhases ¶ added in v0.2.0
ChildPhases returns phases that have the given parent ID.
func (*Protocol) ComponentByID ¶ added in v0.4.0
func (p *Protocol) ComponentByID(id string) *DeploymentComponent
ComponentByID returns the component with the given ID, or nil if not found.
func (*Protocol) ComponentForEntity ¶ added in v0.4.0
func (p *Protocol) ComponentForEntity(entityID string) *DeploymentComponent
ComponentForEntity returns the component that contains an entity, or nil if not found.
func (*Protocol) ComponentsByType ¶ added in v0.4.0
func (p *Protocol) ComponentsByType(componentType string) []DeploymentComponent
ComponentsByType returns all components of a given type. Returns an empty slice if no components match or Metadata is nil.
func (*Protocol) DeterministicSteps ¶ added in v0.5.0
DeterministicSteps returns all entities that are deterministic steps.
func (*Protocol) EntitiesByProtocol ¶ added in v0.4.0
EntitiesByProtocol returns all entities that implement a role for a specific protocol.
func (*Protocol) EntitiesByRole ¶ added in v0.4.0
EntitiesByRole returns all entities that implement a specific protocol role.
func (*Protocol) EntitiesInComponent ¶ added in v0.4.0
EntitiesInComponent returns all entities that belong to a component. Returns an empty slice if the component is not found.
func (*Protocol) EntitiesWithProtocolRoles ¶ added in v0.4.0
EntitiesWithProtocolRoles returns all entities that have protocol roles defined.
func (*Protocol) EntitiesWithStates ¶ added in v0.4.0
EntitiesWithStates returns all entities that have states defined.
func (*Protocol) EntityByID ¶
EntityByID returns the entity with the given ID, or nil if not found.
func (*Protocol) FlowsByPhase ¶
FlowsByPhase returns all flows belonging to the given phase.
func (*Protocol) IsProcessSpec ¶ added in v0.5.0
IsProcessSpec returns true if this is a process specification.
func (*Protocol) IsResolved ¶ added in v0.4.0
IsResolved returns true if the protocol has been resolved.
func (*Protocol) Kind ¶ added in v0.5.0
func (p *Protocol) Kind() ProtocolKind
Kind returns the protocol kind, defaulting to "protocol".
func (*Protocol) LLMSteps ¶ added in v0.5.0
LLMSteps returns all entities that are LLM-powered steps.
func (*Protocol) NeedsResolution ¶ added in v0.4.0
NeedsResolution returns true if the protocol has imports or extends that need resolution.
func (*Protocol) PhaseDepth ¶ added in v0.2.0
PhaseDepth returns the nesting depth of a phase (0 for root phases).
func (*Protocol) ProcessSteps ¶ added in v0.5.0
ProcessSteps returns all entities that have process step semantics (StepType set).
func (*Protocol) Resolve ¶ added in v0.4.0
func (p *Protocol) Resolve(opts ResolveOptions) (*Protocol, error)
Resolve resolves all imports and extends in the protocol, returning a new fully-resolved Protocol. The original is not modified.
func (*Protocol) RootPhases ¶ added in v0.2.0
RootPhases returns phases that have no parent (top-level phases).
func (*Protocol) StateTransitions ¶ added in v0.4.0
func (p *Protocol) StateTransitions() []StateTransition
StateTransitions extracts all state transitions from the protocol's flows.
func (*Protocol) StateTransitionsForEntity ¶ added in v0.4.0
func (p *Protocol) StateTransitionsForEntity(entityID string) []StateTransition
StateTransitionsForEntity returns state transitions for a specific entity.
func (*Protocol) ToJSONCompact ¶
ToJSONCompact serializes a Protocol to compact JSON.
func (*Protocol) TokenByID ¶ added in v0.4.0
func (p *Protocol) TokenByID(id string) *TokenDefinition
TokenByID returns the token definition with the given ID, or nil if not found.
func (*Protocol) TrustRelationByID ¶ added in v0.4.0
func (p *Protocol) TrustRelationByID(id string) *TrustRelationship
TrustRelationByID returns the trust relation with the given ID, or nil if not found.
func (*Protocol) TrustRelationsByType ¶ added in v0.4.0
func (p *Protocol) TrustRelationsByType(relType string) []TrustRelationship
TrustRelationsByType returns all trust relations of a given type. Returns an empty slice if no relations match or Metadata is nil.
func (*Protocol) TrustRelationsFrom ¶ added in v0.4.0
func (p *Protocol) TrustRelationsFrom(id string) []TrustRelationship
TrustRelationsFrom returns all trust relations originating from an entity or component. Returns an empty slice if no relations match or Metadata is nil.
func (*Protocol) TrustRelationsTo ¶ added in v0.4.0
func (p *Protocol) TrustRelationsTo(id string) []TrustRelationship
TrustRelationsTo returns all trust relations targeting an entity or component. Returns an empty slice if no relations match or Metadata is nil.
func (*Protocol) Validate ¶
func (p *Protocol) Validate() ValidationErrors
Validate checks the Protocol for errors and returns all found issues.
func (*Protocol) ValidateProcess ¶ added in v0.5.0
func (p *Protocol) ValidateProcess() ValidationErrors
ValidateProcess performs process-specific validation. These validations only apply when protocol.kind is "process".
type ProtocolDiff ¶ added in v0.4.0
type ProtocolDiff struct {
// BaseProtocolID is the ID of the base protocol.
BaseProtocolID string `json:"base_protocol_id"`
// NewProtocolID is the ID of the new protocol.
NewProtocolID string `json:"new_protocol_id"`
// Items contains all differences found.
Items []DiffItem `json:"items"`
// Summary provides aggregate statistics.
Summary DiffSummary `json:"summary"`
}
ProtocolDiff contains the complete comparison result.
func Compare ¶ added in v0.4.0
func Compare(base, new *Protocol, opts DiffOptions) *ProtocolDiff
Compare compares two protocols and returns the differences.
func (*ProtocolDiff) HasChanges ¶ added in v0.4.0
func (d *ProtocolDiff) HasChanges() bool
HasChanges returns true if there are any differences.
func (*ProtocolDiff) String ¶ added in v0.4.0
func (d *ProtocolDiff) String() string
String returns a human-readable text representation of the diff.
func (*ProtocolDiff) ToJSON ¶ added in v0.4.0
func (d *ProtocolDiff) ToJSON() ([]byte, error)
ToJSON returns the diff as JSON bytes.
func (*ProtocolDiff) ToMarkdown ¶ added in v0.4.0
func (d *ProtocolDiff) ToMarkdown() string
ToMarkdown returns a markdown representation of the diff.
type ProtocolExtends ¶ added in v0.4.0
type ProtocolExtends struct {
// Path is the file path to the base protocol (relative to current file).
Path string `json:"path"`
// ExcludeEntities lists entity IDs from the base to exclude.
ExcludeEntities []string `json:"exclude_entities,omitempty"`
// ExcludePhases lists phase IDs from the base to exclude.
ExcludePhases []string `json:"exclude_phases,omitempty"`
// ExcludeFlows lists flow indices from the base to exclude.
ExcludeFlows []int `json:"exclude_flows,omitempty"`
}
ProtocolExtends specifies a base protocol to extend.
type ProtocolImport ¶ added in v0.4.0
type ProtocolImport struct {
// Path is the file path to import (relative to current file).
Path string `json:"path"`
// Alias prefixes imported IDs to avoid collisions (e.g., "oauth_").
Alias string `json:"alias,omitempty"`
// Entities lists specific entity IDs to import (empty = all).
Entities []string `json:"entities,omitempty"`
// Phases lists specific phase IDs to import (empty = none unless entities need them).
Phases []string `json:"phases,omitempty"`
// IncludeFlows imports flows between the specified entities.
IncludeFlows bool `json:"include_flows,omitempty"`
}
ProtocolImport specifies another protocol file to import from.
type ProtocolKind ¶ added in v0.5.0
type ProtocolKind string
ProtocolKind identifies the PIDL profile type.
const ( // ProtocolKindProtocol is the default for protocol choreography. ProtocolKindProtocol ProtocolKind = "protocol" // ProtocolKindProcess is for workflow/process specifications. ProtocolKindProcess ProtocolKind = "process" )
type ProtocolMeta ¶
type ProtocolMeta struct {
// ID is the unique identifier for the protocol.
ID string `json:"id"`
// Name is the human-readable name.
Name string `json:"name"`
// Kind identifies the PIDL profile type (protocol or process).
Kind ProtocolKind `json:"kind,omitempty"`
// Version of this protocol description.
Version string `json:"version,omitempty"`
// Description provides a brief summary.
Description string `json:"description,omitempty"`
// Category classifies the protocol type.
Category Category `json:"category,omitempty"`
// References links to relevant specifications.
References []Reference `json:"references,omitempty"`
}
ProtocolMeta contains metadata about a protocol.
type ProtocolMetadata ¶ added in v0.3.0
type ProtocolMetadata struct {
// Networks defines network boundary configurations.
Networks map[string]*NetworkConfig `json:"networks,omitempty"`
// NetworkLayout configures network diagram layout.
NetworkLayout *NetworkLayoutConfig `json:"network_layout,omitempty"`
// Tokens defines token types used in the protocol.
Tokens []TokenDefinition `json:"tokens,omitempty"`
// Components defines logical deployment components.
Components []DeploymentComponent `json:"components,omitempty"`
// TrustRelations defines trust relationships between entities or components.
TrustRelations []TrustRelationship `json:"trust_relations,omitempty"`
}
ProtocolMetadata contains additional protocol-level configuration.
type ProtocolRole ¶ added in v0.4.0
type ProtocolRole struct {
// Protocol is the protocol identifier (e.g., "oauth", "scim", "aauth", "authzen", "mcp", "a2a", "spiffe").
Protocol string `json:"protocol"`
// Role is the role within that protocol (e.g., "authorization_server", "client", "pep", "pdp").
Role string `json:"role"`
// Variant is an optional sub-role or variant (e.g., "person_server" vs "access_server" for AAuth).
Variant string `json:"variant,omitempty"`
// Description provides additional context.
Description string `json:"description,omitempty"`
}
ProtocolRole defines a protocol-specific role that an entity implements.
type Reference ¶
type Reference struct {
// Name of the reference (e.g., "RFC 6749").
Name string `json:"name"`
// URL to the reference.
URL string `json:"url"`
}
Reference links to external documentation.
type ResolveOptions ¶ added in v0.4.0
type ResolveOptions struct {
// BasePath is the directory to resolve relative paths from.
BasePath string
// MaxDepth limits import nesting depth (default: 10).
MaxDepth int
}
ResolveOptions configures protocol resolution behavior.
func DefaultResolveOptions ¶ added in v0.4.0
func DefaultResolveOptions() ResolveOptions
DefaultResolveOptions returns default resolution options.
type RetryStrategy ¶ added in v0.5.0
type RetryStrategy struct {
// MaxAttempts is the maximum number of retry attempts.
MaxAttempts int `json:"max_attempts,omitempty"`
// InitialDelay is the delay before the first retry.
InitialDelay string `json:"initial_delay,omitempty"`
// MaxDelay is the maximum delay between retries.
MaxDelay string `json:"max_delay,omitempty"`
// BackoffMultiplier increases delay between retries.
BackoffMultiplier float64 `json:"backoff_multiplier,omitempty"`
// RetryOn lists failure mode IDs that trigger retry.
RetryOn []string `json:"retry_on,omitempty"`
}
RetryStrategy configures retry behavior for a step.
type SchemaRegistry ¶ added in v0.5.0
type SchemaRegistry struct {
// contains filtered or unexported fields
}
SchemaRegistry holds loaded JSON schemas for validation.
func NewSchemaRegistry ¶ added in v0.5.0
func NewSchemaRegistry() *SchemaRegistry
NewSchemaRegistry creates a new schema registry.
func (*SchemaRegistry) LoadSchema ¶ added in v0.5.0
func (r *SchemaRegistry) LoadSchema(uri string) (interface{}, error)
LoadSchema loads a JSON Schema from a URI or file path. Supported URI formats:
- file:///path/to/schema.json
- ./relative/path/schema.json
- /absolute/path/schema.json
- #/definitions/TypeName (inline reference)
func (*SchemaRegistry) RegisterSchema ¶ added in v0.5.0
func (r *SchemaRegistry) RegisterSchema(uri string, schema interface{})
RegisterSchema registers a schema with a given URI.
func (*SchemaRegistry) SetBasePath ¶ added in v0.5.0
func (r *SchemaRegistry) SetBasePath(path string)
SetBasePath sets the base directory for resolving relative schema paths.
type SchemaValidationError ¶ added in v0.5.0
type SchemaValidationError struct {
// Path is the JSON path to the invalid field.
Path string
// Message describes the validation failure.
Message string
// SchemaPath is the path in the schema that failed.
SchemaPath string
}
SchemaValidationError represents a single validation error.
type SchemaValidationResult ¶ added in v0.5.0
type SchemaValidationResult struct {
// Valid indicates if the data passed validation.
Valid bool
// Errors contains validation error messages.
Errors []SchemaValidationError
}
SchemaValidationResult holds the result of schema validation.
func ValidateData ¶ added in v0.5.0
func ValidateData(data interface{}, schema interface{}) *SchemaValidationResult
ValidateData validates data against a JSON Schema. This is a basic implementation that checks type constraints. For full JSON Schema validation, use a dedicated library like github.com/santhosh-tekuri/jsonschema/v5.
func (*SchemaValidationResult) Error ¶ added in v0.5.0
func (r *SchemaValidationResult) Error() string
Error returns the validation errors as a string.
type SecurityRequirement ¶ added in v0.4.0
type SecurityRequirement string
SecurityRequirement represents a security mechanism required for a flow.
const ( // SecurityRequirementToken requires a bearer or bound token. SecurityRequirementToken SecurityRequirement = "token" // SecurityRequirementSignature requires message signing. SecurityRequirementSignature SecurityRequirement = "signature" // SecurityRequirementEncryption requires message encryption. SecurityRequirementEncryption SecurityRequirement = "encryption" // SecurityRequirementMTLS requires mutual TLS authentication. SecurityRequirementMTLS SecurityRequirement = "mtls" // SecurityRequirementMAC requires message authentication code. SecurityRequirementMAC SecurityRequirement = "mac" )
type StateChange ¶ added in v0.4.0
type StateChange struct {
// Entity is the entity ID.
Entity string `json:"entity"`
// FromState is the prior state (empty if not tracked).
FromState string `json:"from_state,omitempty"`
// ToState is the new state.
ToState string `json:"to_state"`
}
StateChange records a single state mutation.
type StateMutation ¶ added in v0.4.0
type StateMutation struct {
// Entity is the ID of the entity whose state changes.
Entity string `json:"entity"`
// To is the target state ID.
To string `json:"to"`
// From is the optional required prior state (for validation).
From string `json:"from,omitempty"`
}
StateMutation represents a state change for an entity triggered by a flow.
type StateTransition ¶ added in v0.4.0
type StateTransition struct {
// EntityID is the entity undergoing the state change.
EntityID string
// FromState is the prior state (empty if not specified).
FromState string
// ToState is the target state.
ToState string
// FlowAction is the action that triggers this transition.
FlowAction string
// FlowLabel is the display label for the triggering flow.
FlowLabel string
}
StateTransition represents a state transition extracted from flows.
type StepExecutionStatus ¶ added in v0.5.0
type StepExecutionStatus string
StepExecutionStatus represents the execution status of a process step.
const ( StepStatusPending StepExecutionStatus = "pending" StepStatusReady StepExecutionStatus = "ready" StepStatusBlocked StepExecutionStatus = "blocked" StepStatusInProgress StepExecutionStatus = "in_progress" StepStatusCompleted StepExecutionStatus = "completed" StepStatusFailed StepExecutionStatus = "failed" StepStatusSkipped StepExecutionStatus = "skipped" )
type StepType ¶ added in v0.5.0
type StepType string
StepType classifies the processing nature of a process step.
const ( // StepTypeDeterministic is for repeatable, predictable processing. StepTypeDeterministic StepType = "deterministic" // StepTypeLLM is for LLM/AI-powered non-deterministic processing. StepTypeLLM StepType = "llm" // StepTypeHuman is for human-in-the-loop steps. StepTypeHuman StepType = "human" // StepTypeExternal is for external API/service calls. StepTypeExternal StepType = "external" // StepTypeTool is for tool invocations (MCP-style). StepTypeTool StepType = "tool" // StepTypeParallel is for parallel execution blocks. StepTypeParallel StepType = "parallel" // StepTypeConditional is for conditional branching. StepTypeConditional StepType = "conditional" )
type TokenDefinition ¶ added in v0.4.0
type TokenDefinition struct {
// ID is the unique identifier for this token definition.
ID string `json:"id"`
// Name is the human-readable display name.
Name string `json:"name,omitempty"`
// Type is the token type: jwt, opaque, saml, api_key.
Type string `json:"type,omitempty"`
// Issuer is the entity ID that issues this token.
Issuer string `json:"issuer,omitempty"`
// Audience is the entity ID that consumes this token.
Audience string `json:"audience,omitempty"`
// Binding is the token binding method: bearer, mtls, dpop.
Binding string `json:"binding,omitempty"`
// Description provides additional context.
Description string `json:"description,omitempty"`
}
TokenDefinition describes a token type used in the protocol.
type TrustLevel ¶ added in v0.4.0
type TrustLevel string
TrustLevel represents the trust classification of an entity.
const ( // TrustLevelTrusted is for fully trusted internal systems. TrustLevelTrusted TrustLevel = "trusted" // TrustLevelSemiTrusted is for partially trusted systems (DMZ, partners). TrustLevelSemiTrusted TrustLevel = "semi_trusted" // TrustLevelUntrusted is for external/public systems. TrustLevelUntrusted TrustLevel = "untrusted" // TrustLevelAuthoritative is for sources of truth (IdPs, CAs). TrustLevelAuthoritative TrustLevel = "authoritative" )
type TrustRelationship ¶ added in v0.4.0
type TrustRelationship struct {
// ID is an optional unique identifier for this relationship.
ID string `json:"id,omitempty"`
// From is the source entity or component ID.
From string `json:"from"`
// To is the target entity or component ID.
To string `json:"to"`
// Type is the relationship type (e.g., "authenticates", "validates", "delegates").
Type string `json:"type"`
// Credentials lists what credentials are exchanged in this relationship.
Credentials []string `json:"credentials,omitempty"`
// Mutual indicates if this is a bidirectional trust (e.g., mTLS).
Mutual bool `json:"mutual,omitempty"`
// Description provides additional context.
Description string `json:"description,omitempty"`
}
TrustRelationship defines a trust relationship between entities or components.
type ValidationError ¶
ValidationError represents a validation error with context.
func (ValidationError) Error ¶
func (e ValidationError) Error() string
type ValidationErrors ¶
type ValidationErrors []ValidationError
ValidationErrors is a collection of validation errors.
func (ValidationErrors) Error ¶
func (e ValidationErrors) Error() string
func (ValidationErrors) HasErrors ¶
func (e ValidationErrors) HasErrors() bool
HasErrors returns true if there are any validation errors.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package analyze provides security analysis for PIDL protocols.
|
Package analyze provides security analysis for PIDL protocols. |
|
cmd
|
|
|
pidl
command
Command pidl is the CLI tool for the Protocol Interaction Description Language.
|
Command pidl is the CLI tool for the Protocol Interaction Description Language. |
|
Package examples provides embedded PIDL example protocols.
|
Package examples provides embedded PIDL example protocols. |
|
Package export provides exporters for converting PIDL protocols to workflow engine formats.
|
Package export provides exporters for converting PIDL protocols to workflow engine formats. |
|
Package render provides diagram rendering for PIDL protocols.
|
Package render provides diagram rendering for PIDL protocols. |
|
svg
Package svg provides SVG rendering utilities for PIDL protocols.
|
Package svg provides SVG rendering utilities for PIDL protocols. |
|
Package schema provides the embedded PIDL JSON Schema.
|
Package schema provides the embedded PIDL JSON Schema. |