aidlc

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package aidlc provides AIDLC document evaluation using structured-evaluation rubrics.

Package aidlc provides workflow progress tracking for AIDLC workflows.

Package aidlc provides document templates for AIDLC workflows.

Package aidlc provides phase transition logic for AIDLC workflows.

Package aidlc provides types and utilities for integrating with AWS AI DLC Workflows. It enables bidirectional sync between VisionSpec (.visionspec/) and AIDLC (aidlc-docs/) directories, visualization of AIDLC workflow phases, and LLM-as-judge evaluation.

Index

Constants

This section is empty.

Variables

View Source
var DefaultStateParser = NewStateParser()

DefaultStateParser is the default state parser instance.

Functions

func AllTemplates

func AllTemplates() map[DocType]*Template

AllTemplates returns all registered templates.

func BuildCategoryPrompt

func BuildCategoryPrompt(docType DocType, content string, cat *rubric.Category) string

BuildCategoryPrompt builds the evaluation prompt for a category. This can be used by Judge implementations to construct prompts.

func CheckRubricAvailable

func CheckRubricAvailable(docType DocType) error

CheckRubricAvailable verifies that a rubric exists for the document type.

func DefaultTransitionRules

func DefaultTransitionRules() map[Phase]TransitionRule

DefaultTransitionRules returns the default transition rules.

func GetRubricSet

func GetRubricSet(docType DocType) (*rubric.RubricSet, error)

GetRubricSet returns the structured-evaluation rubric set for a document type.

func GetSpecType

func GetSpecType(docType DocType) (types.SpecType, bool)

GetSpecType returns the visionspec SpecType for an AIDLC DocType.

func RenderTemplate

func RenderTemplate(docType DocType, data TemplateData) (string, error)

RenderTemplate renders a template with the given data.

func WorkflowToPIDL

func WorkflowToPIDL(w *Workflow) *pidl.Protocol

WorkflowToPIDL converts an AIDLC workflow to a pidl Protocol. This provides a basic protocol representation for visualization.

Types

type ConflictStrategy

type ConflictStrategy string

ConflictStrategy determines how sync conflicts are resolved.

const (
	// ConflictSkip skips conflicting files.
	ConflictSkip ConflictStrategy = "skip"
	// ConflictNewerWins uses the newer file.
	ConflictNewerWins ConflictStrategy = "newer_wins"
	// ConflictVisionSpecWins prefers VisionSpec files.
	ConflictVisionSpecWins ConflictStrategy = "visionspec_wins"
	// ConflictAIDLCWins prefers AIDLC files.
	ConflictAIDLCWins ConflictStrategy = "aidlc_wins"
)

type DimensionScore

type DimensionScore struct {
	// ID is the dimension identifier.
	ID string `json:"id" yaml:"id"`

	// Name is the dimension display name.
	Name string `json:"name" yaml:"name"`

	// Score is the dimension score (0.0-1.0).
	Score float64 `json:"score" yaml:"score"`

	// Weight is the dimension weight in the overall score.
	Weight float64 `json:"weight" yaml:"weight"`

	// Findings are dimension-specific issues.
	Findings []Issue `json:"findings,omitempty" yaml:"findings,omitempty"`
}

DimensionScore represents a score for a single evaluation dimension.

type DocType

type DocType string

DocType represents an AIDLC document type.

const (
	// Inception phase documents
	DocVisionDocument   DocType = "vision_document"
	DocRequirementsSpec DocType = "requirements_spec"
	DocTechnicalSpec    DocType = "technical_spec"
	DocArchitectureSpec DocType = "architecture_spec"

	// Construction phase documents
	DocImplementationPlan DocType = "implementation_plan"
	DocTestPlan           DocType = "test_plan"
	DocIntegrationPlan    DocType = "integration_plan"
	DocSecurityReview     DocType = "security_review"

	// Operations phase documents
	DocRunbook        DocType = "runbook"
	DocMonitoringPlan DocType = "monitoring_plan"
	DocDisasterPlan   DocType = "disaster_recovery_plan"
	DocSLODocument    DocType = "slo_document"
)

func AllDocTypes

func AllDocTypes() []DocType

AllDocTypes returns all document types in workflow order.

func AllDocTypesWithRubrics

func AllDocTypesWithRubrics() []DocType

AllDocTypesWithRubrics returns all document types that have rubrics defined.

func ConstructionDocTypes

func ConstructionDocTypes() []DocType

ConstructionDocTypes returns document types in the construction phase.

func DocTypesByPhase

func DocTypesByPhase(phase Phase) []DocType

DocTypesByPhase returns document types for a given phase.

func InceptionDocTypes

func InceptionDocTypes() []DocType

InceptionDocTypes returns document types in the inception phase.

func OperationsDocTypes

func OperationsDocTypes() []DocType

OperationsDocTypes returns document types in the operations phase.

func (DocType) DisplayName

func (d DocType) DisplayName() string

DisplayName returns a human-readable name for the document type.

func (DocType) Filename

func (d DocType) Filename() string

Filename returns the canonical filename for this document type.

func (DocType) IsValid

func (d DocType) IsValid() bool

IsValid returns whether this is a known document type.

func (DocType) Phase

func (d DocType) Phase() Phase

Phase returns the phase this document type belongs to.

func (DocType) String

func (d DocType) String() string

String returns the document type name.

type Document

type Document struct {
	// Type is the document type.
	Type DocType `json:"type" yaml:"type"`

	// Phase is the workflow phase this document belongs to.
	Phase Phase `json:"phase" yaml:"phase"`

	// Path is the file path relative to the project root.
	Path string `json:"path" yaml:"path"`

	// Title is the document title.
	Title string `json:"title" yaml:"title"`

	// Status is the current document status.
	Status DocumentStatus `json:"status" yaml:"status"`

	// Content is the raw markdown content.
	Content string `json:"content,omitempty" yaml:"content,omitempty"`

	// Metadata contains frontmatter and other parsed metadata.
	Metadata map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty"`

	// Score is the quality evaluation score (if evaluated).
	Score *QualityScore `json:"score,omitempty" yaml:"score,omitempty"`

	// UpdatedAt is when the document was last modified.
	UpdatedAt time.Time `json:"updated_at" yaml:"updated_at"`

	// Checksum is the content hash for change detection.
	Checksum string `json:"checksum,omitempty" yaml:"checksum,omitempty"`
}

Document represents a parsed AIDLC document.

type DocumentStatus

type DocumentStatus string

DocumentStatus represents the status of an AIDLC document.

const (
	StatusPending    DocumentStatus = "pending"
	StatusDraft      DocumentStatus = "draft"
	StatusInProgress DocumentStatus = "in_progress"
	StatusReview     DocumentStatus = "review"
	StatusApproved   DocumentStatus = "approved"
	StatusRejected   DocumentStatus = "rejected"
)

type EdgeType

type EdgeType string

EdgeType represents the type of workflow edge.

const (
	// EdgeDependency indicates the target depends on the source.
	EdgeDependency EdgeType = "dependency"
	// EdgeBlocks indicates the source blocks the target.
	EdgeBlocks EdgeType = "blocks"
	// EdgeSuggests indicates the source suggests the target.
	EdgeSuggests EdgeType = "suggests"
)

type EvaluationResult

type EvaluationResult struct {
	// Document is the evaluated document.
	Document *Document

	// RubricSet is the rubric used for evaluation.
	RubricSet *rubric.RubricSet

	// Report is the full evaluation report.
	Report *rubric.Rubric

	// QualityScore is the aggregated quality score in AIDLC format.
	QualityScore *QualityScore

	// Decision is the evaluation decision.
	Decision *rubric.Decision

	// Error contains any evaluation error.
	Error error
}

EvaluationResult contains the result of evaluating an AIDLC document.

func EvaluateContent

func EvaluateContent(ctx context.Context, docType DocType, content string, judge Judge) (*EvaluationResult, error)

EvaluateContent evaluates raw content for a specific document type.

func EvaluateDocument

func EvaluateDocument(ctx context.Context, doc *Document, judge Judge) (*EvaluationResult, error)

EvaluateDocument is a convenience function to evaluate a document with a judge.

type Evaluator

type Evaluator struct {
	// Judge is the LLM judge for evaluation.
	// When nil, Evaluate returns a stub result.
	Judge Judge
}

Evaluator evaluates AIDLC documents using structured-evaluation rubrics.

func NewEvaluator

func NewEvaluator() *Evaluator

NewEvaluator creates a new AIDLC document evaluator.

func NewEvaluatorWithJudge

func NewEvaluatorWithJudge(judge Judge) *Evaluator

NewEvaluatorWithJudge creates a new evaluator with the specified judge.

func (*Evaluator) Evaluate

func (e *Evaluator) Evaluate(ctx context.Context, doc *Document) (*EvaluationResult, error)

Evaluate evaluates an AIDLC document using its rubric.

type ExecutionMetrics

type ExecutionMetrics struct {
	// TotalSteps is the total number of steps.
	TotalSteps int `json:"total_steps" yaml:"total_steps"`

	// CompletedSteps is the number of completed steps.
	CompletedSteps int `json:"completed_steps" yaml:"completed_steps"`

	// InProgressSteps is the number of in-progress steps.
	InProgressSteps int `json:"in_progress_steps" yaml:"in_progress_steps"`

	// BlockedSteps is the number of blocked steps.
	BlockedSteps int `json:"blocked_steps" yaml:"blocked_steps"`

	// PendingSteps is the number of pending steps.
	PendingSteps int `json:"pending_steps" yaml:"pending_steps"`

	// FailedSteps is the number of failed steps.
	FailedSteps int `json:"failed_steps" yaml:"failed_steps"`

	// ProgressPercent is the completion percentage.
	ProgressPercent float64 `json:"progress_percent" yaml:"progress_percent"`

	// ElapsedTime is the total elapsed time.
	ElapsedTime time.Duration `json:"elapsed_time" yaml:"elapsed_time"`

	// EstimatedRemaining is the estimated remaining time (if available).
	EstimatedRemaining time.Duration `json:"estimated_remaining,omitempty" yaml:"estimated_remaining,omitempty"`

	// PhaseMetrics contains per-phase metrics.
	PhaseMetrics map[string]*PhaseMetrics `json:"phase_metrics,omitempty" yaml:"phase_metrics,omitempty"`
}

ExecutionMetrics contains overall execution metrics.

type Issue

type Issue struct {
	// Severity is the issue severity.
	Severity IssueSeverity `json:"severity" yaml:"severity"`

	// Category is the issue category (e.g., "clarity", "completeness").
	Category string `json:"category" yaml:"category"`

	// Code is a machine-readable issue code (e.g., "MISSING_ACCEPTANCE_CRITERIA").
	Code string `json:"code,omitempty" yaml:"code,omitempty"`

	// Message is a human-readable description.
	Message string `json:"message" yaml:"message"`

	// Location references where the issue was found (e.g., section or line).
	Location string `json:"location,omitempty" yaml:"location,omitempty"`

	// Suggestion provides remediation guidance.
	Suggestion string `json:"suggestion,omitempty" yaml:"suggestion,omitempty"`
}

Issue represents a quality issue found during evaluation.

type IssueSeverity

type IssueSeverity string

IssueSeverity represents the severity of an issue.

const (
	SeverityCritical IssueSeverity = "critical"
	SeverityHigh     IssueSeverity = "high"
	SeverityMedium   IssueSeverity = "medium"
	SeverityLow      IssueSeverity = "low"
	SeverityInfo     IssueSeverity = "info"
)

func (IssueSeverity) Weight

func (s IssueSeverity) Weight() float64

Weight returns a numeric weight for prioritization (higher = more severe).

type Judge

type Judge interface {
	// EvaluateCategory evaluates a document against a single category's criteria.
	// Returns the category result with score, reasoning, and any findings.
	EvaluateCategory(ctx context.Context, content string, category *rubric.Category) (*rubric.CategoryResult, error)
}

Judge is the interface for LLM-based document evaluation. Implementations provide the actual LLM interaction for evaluating documents.

type NodeStatus

type NodeStatus string

NodeStatus represents the status of a workflow node.

const (
	NodePending    NodeStatus = "pending"
	NodeReady      NodeStatus = "ready"
	NodeInProgress NodeStatus = "in_progress"
	NodeCompleted  NodeStatus = "completed"
	NodeBlocked    NodeStatus = "blocked"
	NodeSkipped    NodeStatus = "skipped"
	NodeFailed     NodeStatus = "failed"
)

type Phase

type Phase string

Phase represents an AIDLC workflow phase.

const (
	// PhaseInception is the initial discovery and requirements phase.
	PhaseInception Phase = "inception"
	// PhaseConstruction is the implementation planning and testing phase.
	PhaseConstruction Phase = "construction"
	// PhaseOperations is the deployment and operational readiness phase.
	PhaseOperations Phase = "operations"
)

func AllPhases

func AllPhases() []Phase

AllPhases returns all AIDLC phases in order.

func (Phase) IsValid

func (p Phase) IsValid() bool

IsValid returns whether this is a known phase.

func (Phase) Order

func (p Phase) Order() int

Order returns the phase order (0-indexed).

func (Phase) String

func (p Phase) String() string

String returns the phase name.

type PhaseMetrics

type PhaseMetrics struct {
	// PhaseID is the phase identifier.
	PhaseID string `json:"phase_id" yaml:"phase_id"`

	// TotalSteps is the total steps in this phase.
	TotalSteps int `json:"total_steps" yaml:"total_steps"`

	// CompletedSteps is the completed steps in this phase.
	CompletedSteps int `json:"completed_steps" yaml:"completed_steps"`

	// ProgressPercent is the phase completion percentage.
	ProgressPercent float64 `json:"progress_percent" yaml:"progress_percent"`

	// Status is the phase status.
	Status PhaseStatus `json:"status" yaml:"status"`
}

PhaseMetrics contains metrics for a specific phase.

type PhaseRequirements

type PhaseRequirements struct {
	// Phase is the phase being checked.
	Phase Phase `json:"phase" yaml:"phase"`

	// RequiredDocs are the required documents.
	RequiredDocs []DocType `json:"required_docs" yaml:"required_docs"`

	// CompletedDocs are the completed required documents.
	CompletedDocs []DocType `json:"completed_docs" yaml:"completed_docs"`

	// PendingDocs are the pending required documents.
	PendingDocs []DocType `json:"pending_docs" yaml:"pending_docs"`

	// ProgressPercent is the completion percentage.
	ProgressPercent float64 `json:"progress_percent" yaml:"progress_percent"`

	// CanAdvance indicates if the phase can advance.
	CanAdvance bool `json:"can_advance" yaml:"can_advance"`
}

PhaseRequirements returns the requirements for completing a phase.

type PhaseStatus

type PhaseStatus string

PhaseStatus represents the status of a workflow phase.

const (
	// PhaseStatusPending indicates the phase has not started.
	PhaseStatusPending PhaseStatus = "pending"
	// PhaseStatusInProgress indicates the phase is currently active.
	PhaseStatusInProgress PhaseStatus = "in_progress"
	// PhaseStatusCompleted indicates all required documents are complete.
	PhaseStatusCompleted PhaseStatus = "completed"
	// PhaseStatusBlocked indicates the phase cannot proceed due to issues.
	PhaseStatusBlocked PhaseStatus = "blocked"
)

type QualityRating

type QualityRating string

QualityRating represents the overall quality assessment.

const (
	RatingExcellent        QualityRating = "EXCELLENT"
	RatingGood             QualityRating = "GOOD"
	RatingNeedsImprovement QualityRating = "NEEDS_IMPROVEMENT"
	RatingPoor             QualityRating = "POOR"
)

func (QualityRating) Score

func (r QualityRating) Score() float64

Score returns a numeric score (0.0-1.0) for the rating.

type QualityScore

type QualityScore struct {
	// Rating is the overall quality rating.
	Rating QualityRating `json:"rating" yaml:"rating"`

	// Score is a numeric score (0.0-1.0).
	Score float64 `json:"score" yaml:"score"`

	// Issues are identified problems.
	Issues []Issue `json:"issues,omitempty" yaml:"issues,omitempty"`

	// Dimensions contains per-dimension scores (if available).
	Dimensions map[string]DimensionScore `json:"dimensions,omitempty" yaml:"dimensions,omitempty"`

	// EvaluatedAt is when the evaluation was performed.
	EvaluatedAt time.Time `json:"evaluated_at" yaml:"evaluated_at"`
}

QualityScore represents the evaluation score for a document.

type State

type State struct {
	// CurrentPhase is the current workflow phase.
	CurrentPhase Phase `json:"current_phase" yaml:"current_phase"`

	// CurrentDocument is the document currently being worked on.
	CurrentDocument DocType `json:"current_document,omitempty" yaml:"current_document,omitempty"`

	// CompletedDocs lists completed document types.
	CompletedDocs []DocType `json:"completed_docs" yaml:"completed_docs"`

	// PendingDocs lists pending document types.
	PendingDocs []DocType `json:"pending_docs" yaml:"pending_docs"`

	// InProgressDocs lists in-progress document types.
	InProgressDocs []DocType `json:"in_progress_docs,omitempty" yaml:"in_progress_docs,omitempty"`

	// DocumentScores maps document types to their quality scores.
	DocumentScores map[DocType]*QualityScore `json:"document_scores,omitempty" yaml:"document_scores,omitempty"`

	// PhaseProgress tracks progress per phase (0.0-1.0).
	PhaseProgress map[Phase]float64 `json:"phase_progress,omitempty" yaml:"phase_progress,omitempty"`

	// LastUpdated is when the state was last modified.
	LastUpdated time.Time `json:"last_updated" yaml:"last_updated"`

	// WorkflowStarted is when the workflow began.
	WorkflowStarted time.Time `json:"workflow_started,omitempty" yaml:"workflow_started,omitempty"`

	// Metadata contains additional parsed state data.
	Metadata map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty"`
}

State represents the parsed aidlc-state.md file content.

func ParseStateFile

func ParseStateFile(path string) (*State, error)

ParseStateFile parses an aidlc-state.md file using the default parser.

func ParseStateString

func ParseStateString(content string) (*State, error)

ParseStateString parses state from a markdown string using the default parser.

func (*State) IsPhaseComplete

func (s *State) IsPhaseComplete(phase Phase) bool

IsPhaseComplete returns whether a phase is fully complete.

func (*State) NextDocument

func (s *State) NextDocument() DocType

NextDocument returns the next document to work on, or empty if none.

func (*State) OverallProgress

func (s *State) OverallProgress() float64

OverallProgress returns the overall workflow progress (0.0-1.0).

type StateParser

type StateParser struct {
	// contains filtered or unexported fields
}

StateParser parses aidlc-state.md files.

func NewStateParser

func NewStateParser() *StateParser

NewStateParser creates a new state parser.

func (*StateParser) ParseFile

func (p *StateParser) ParseFile(path string) (*State, error)

ParseFile parses an aidlc-state.md file.

func (*StateParser) ParseString

func (p *StateParser) ParseString(content string) (*State, error)

ParseString parses state from a markdown string.

type StepExecutionStatus

type StepExecutionStatus string

StepExecutionStatus represents the execution status of a workflow 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 StepTiming

type StepTiming struct {
	// StepID is the step identifier.
	StepID string `json:"step_id" yaml:"step_id"`

	// StartTime is when the step started.
	StartTime time.Time `json:"start_time,omitempty" yaml:"start_time,omitempty"`

	// EndTime is when the step completed.
	EndTime time.Time `json:"end_time,omitempty" yaml:"end_time,omitempty"`

	// Duration is the step duration.
	Duration time.Duration `json:"duration,omitempty" yaml:"duration,omitempty"`

	// Status is the current step status.
	Status StepExecutionStatus `json:"status" yaml:"status"`
}

StepTiming tracks timing metrics for a workflow step.

type SyncAction

type SyncAction struct {
	// Direction is the sync direction.
	Direction SyncDirection `json:"direction" yaml:"direction"`

	// DocType is the document type being synced.
	DocType DocType `json:"doc_type" yaml:"doc_type"`

	// SourcePath is the source file path.
	SourcePath string `json:"source_path" yaml:"source_path"`

	// DestPath is the destination file path.
	DestPath string `json:"dest_path" yaml:"dest_path"`

	// Action describes the operation (create, update, delete).
	Action string `json:"action" yaml:"action"`

	// Reason explains why the action is needed.
	Reason string `json:"reason,omitempty" yaml:"reason,omitempty"`
}

SyncAction represents a single sync operation.

type SyncConflict

type SyncConflict struct {
	// DocType is the conflicting document type.
	DocType DocType `json:"doc_type" yaml:"doc_type"`

	// VisionSpecPath is the VisionSpec file path.
	VisionSpecPath string `json:"visionspec_path" yaml:"visionspec_path"`

	// AIDLCPath is the AIDLC file path.
	AIDLCPath string `json:"aidlc_path" yaml:"aidlc_path"`

	// VisionSpecModTime is when the VisionSpec file was modified.
	VisionSpecModTime time.Time `json:"visionspec_mod_time" yaml:"visionspec_mod_time"`

	// AIDLCModTime is when the AIDLC file was modified.
	AIDLCModTime time.Time `json:"aidlc_mod_time" yaml:"aidlc_mod_time"`

	// Reason explains the conflict.
	Reason string `json:"reason" yaml:"reason"`
}

SyncConflict represents a sync conflict requiring resolution.

type SyncDiff

type SyncDiff struct {
	// VisionSpecDir is the .visionspec directory path.
	VisionSpecDir string `json:"visionspec_dir" yaml:"visionspec_dir"`

	// AIDLCDocsDir is the aidlc-docs directory path.
	AIDLCDocsDir string `json:"aidlc_docs_dir" yaml:"aidlc_docs_dir"`

	// Actions lists required sync operations.
	Actions []SyncAction `json:"actions" yaml:"actions"`

	// Conflicts lists documents with conflicts requiring resolution.
	Conflicts []SyncConflict `json:"conflicts,omitempty" yaml:"conflicts,omitempty"`

	// ComputedAt is when the diff was computed.
	ComputedAt time.Time `json:"computed_at" yaml:"computed_at"`
}

SyncDiff represents the difference between VisionSpec and AIDLC directories.

func (*SyncDiff) HasChanges

func (d *SyncDiff) HasChanges() bool

HasChanges returns whether there are any changes to sync.

type SyncDirection

type SyncDirection string

SyncDirection indicates the direction of synchronization.

const (
	// SyncToAIDLC exports VisionSpec documents to AIDLC format.
	SyncToAIDLC SyncDirection = "to_aidlc"
	// SyncFromAIDLC imports AIDLC documents to VisionSpec format.
	SyncFromAIDLC SyncDirection = "from_aidlc"
	// SyncBidirectional performs two-way sync based on timestamps.
	SyncBidirectional SyncDirection = "bidirectional"
)

type SyncEngine

type SyncEngine struct {
	// VisionSpecDir is the .visionspec directory path.
	VisionSpecDir string

	// AIDLCDocsDir is the aidlc-docs directory path.
	AIDLCDocsDir string

	// ConflictStrategy determines how conflicts are resolved.
	ConflictStrategy ConflictStrategy

	// DryRun prevents actual file modifications when true.
	DryRun bool
}

SyncEngine handles bidirectional sync between VisionSpec and AIDLC directories.

func NewSyncEngine

func NewSyncEngine(visionSpecDir, aidlcDocsDir string) *SyncEngine

NewSyncEngine creates a new sync engine.

func (*SyncEngine) DiffState

func (e *SyncEngine) DiffState(ctx context.Context) (*SyncDiff, error)

DiffState computes the difference between VisionSpec and AIDLC directories.

func (*SyncEngine) ExportToAIDLC

func (e *SyncEngine) ExportToAIDLC(ctx context.Context) (*SyncResult, error)

ExportToAIDLC exports VisionSpec documents to AIDLC format.

func (*SyncEngine) ImportFromAIDLC

func (e *SyncEngine) ImportFromAIDLC(ctx context.Context) (*SyncResult, error)

ImportFromAIDLC imports AIDLC documents to VisionSpec format.

func (*SyncEngine) Sync

func (e *SyncEngine) Sync(ctx context.Context) (*SyncResult, error)

Sync performs bidirectional sync based on the diff.

type SyncResult

type SyncResult struct {
	// Direction is the sync direction performed.
	Direction SyncDirection `json:"direction" yaml:"direction"`

	// Created lists newly created files.
	Created []string `json:"created,omitempty" yaml:"created,omitempty"`

	// Updated lists updated files.
	Updated []string `json:"updated,omitempty" yaml:"updated,omitempty"`

	// Skipped lists skipped files (conflicts or errors).
	Skipped []string `json:"skipped,omitempty" yaml:"skipped,omitempty"`

	// Errors lists any errors encountered.
	Errors []string `json:"errors,omitempty" yaml:"errors,omitempty"`

	// CompletedAt is when the sync completed.
	CompletedAt time.Time `json:"completed_at" yaml:"completed_at"`
}

SyncResult contains the result of a sync operation.

func (*SyncResult) Success

func (r *SyncResult) Success() bool

Success returns whether the sync completed without errors.

type Template

type Template struct {
	// DocType is the document type this template is for.
	DocType DocType `json:"doc_type" yaml:"doc_type"`

	// Name is the template display name.
	Name string `json:"name" yaml:"name"`

	// Description describes the document's purpose.
	Description string `json:"description" yaml:"description"`

	// Content is the markdown template content.
	Content string `json:"content" yaml:"content"`

	// Sections lists the expected sections.
	Sections []TemplateSection `json:"sections" yaml:"sections"`
}

Template represents a document template.

func GetTemplate

func GetTemplate(docType DocType) (*Template, bool)

GetTemplate returns the template for a document type.

type TemplateData

type TemplateData struct {
	// ProjectName is the project name.
	ProjectName string

	// Title is the document title.
	Title string

	// Author is the document author.
	Author string

	// Date is the creation date.
	Date string

	// Version is the document version.
	Version string

	// Description is a brief description.
	Description string

	// Custom contains additional custom fields.
	Custom map[string]string
}

TemplateData contains variables for template rendering.

func DefaultTemplateData

func DefaultTemplateData(projectName string) TemplateData

DefaultTemplateData returns template data with defaults.

type TemplateSection

type TemplateSection struct {
	// ID is the section identifier.
	ID string `json:"id" yaml:"id"`

	// Title is the section heading.
	Title string `json:"title" yaml:"title"`

	// Required indicates if this section is mandatory.
	Required bool `json:"required" yaml:"required"`

	// Description explains what goes in this section.
	Description string `json:"description" yaml:"description"`
}

TemplateSection describes a section in a document template.

type TransitionEntry

type TransitionEntry struct {
	// FromPhase is the source phase.
	FromPhase Phase `json:"from_phase" yaml:"from_phase"`

	// ToPhase is the target phase.
	ToPhase Phase `json:"to_phase" yaml:"to_phase"`

	// Timestamp is when the transition occurred.
	Timestamp time.Time `json:"timestamp" yaml:"timestamp"`

	// ApprovedBy is who approved the transition (if required).
	ApprovedBy string `json:"approved_by,omitempty" yaml:"approved_by,omitempty"`

	// Notes are optional notes about the transition.
	Notes string `json:"notes,omitempty" yaml:"notes,omitempty"`
}

TransitionEntry records a single transition event.

type TransitionLog

type TransitionLog struct {
	// Entries are the transition history.
	Entries []TransitionEntry `json:"entries" yaml:"entries"`
}

TransitionLog tracks phase transitions over time.

func NewTransitionLog

func NewTransitionLog() *TransitionLog

NewTransitionLog creates a new transition log.

func (*TransitionLog) AddEntry

func (l *TransitionLog) AddEntry(from, to Phase, approvedBy, notes string)

AddEntry adds a transition entry to the log.

func (*TransitionLog) EntriesForPhase

func (l *TransitionLog) EntriesForPhase(phase Phase) []TransitionEntry

EntriesForPhase returns all entries related to a phase.

func (*TransitionLog) LatestEntry

func (l *TransitionLog) LatestEntry() *TransitionEntry

LatestEntry returns the most recent transition entry.

type TransitionResult

type TransitionResult struct {
	// Success indicates if the transition succeeded.
	Success bool `json:"success" yaml:"success"`

	// FromPhase is the source phase.
	FromPhase Phase `json:"from_phase" yaml:"from_phase"`

	// ToPhase is the target phase.
	ToPhase Phase `json:"to_phase" yaml:"to_phase"`

	// BlockingDocs are documents preventing transition.
	BlockingDocs []DocType `json:"blocking_docs,omitempty" yaml:"blocking_docs,omitempty"`

	// BlockingIssues are issues preventing transition.
	BlockingIssues []string `json:"blocking_issues,omitempty" yaml:"blocking_issues,omitempty"`

	// Timestamp is when the transition was attempted.
	Timestamp time.Time `json:"timestamp" yaml:"timestamp"`
}

TransitionResult contains the result of a phase transition attempt.

type TransitionRule

type TransitionRule struct {
	// TargetPhase is the phase to transition to.
	TargetPhase Phase `json:"target_phase" yaml:"target_phase"`

	// RequiredDocs are document types that must be completed.
	RequiredDocs []DocType `json:"required_docs" yaml:"required_docs"`

	// MinScore is the minimum quality score required (0-1).
	MinScore float64 `json:"min_score,omitempty" yaml:"min_score,omitempty"`

	// AllowPartial allows transition with partial scores.
	AllowPartial bool `json:"allow_partial,omitempty" yaml:"allow_partial,omitempty"`

	// RequireApproval requires explicit approval for transition.
	RequireApproval bool `json:"require_approval,omitempty" yaml:"require_approval,omitempty"`
}

TransitionRule defines requirements for transitioning to a phase.

type Workflow

type Workflow struct {
	// Name is the workflow name.
	Name string `json:"name" yaml:"name"`

	// Description is a brief description of the workflow.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	// Phases are the workflow phases in order.
	Phases []WorkflowPhase `json:"phases" yaml:"phases"`

	// Nodes are all workflow nodes indexed by ID.
	Nodes map[string]*WorkflowNode `json:"nodes" yaml:"nodes"`

	// Edges define dependencies between nodes.
	Edges []WorkflowEdge `json:"edges" yaml:"edges"`
}

Workflow represents the full AIDLC workflow DAG.

func DefaultWorkflow

func DefaultWorkflow() *Workflow

DefaultWorkflow creates the default AIDLC workflow with all document types.

func NewWorkflow

func NewWorkflow() *Workflow

NewWorkflow creates a new AIDLC workflow.

func (*Workflow) AddEdge

func (w *Workflow) AddEdge(from, to string, edgeType EdgeType)

AddEdge adds an edge to the workflow.

func (*Workflow) AllPhaseRequirements

func (w *Workflow) AllPhaseRequirements() []PhaseRequirements

AllPhaseRequirements returns requirements for all phases.

func (*Workflow) CanTransitionTo

func (w *Workflow) CanTransitionTo(targetPhase Phase, rules map[Phase]TransitionRule) *TransitionResult

CanTransitionTo checks if the workflow can transition to a target phase.

func (*Workflow) CurrentPhase

func (w *Workflow) CurrentPhase() Phase

CurrentPhase determines the current workflow phase based on node statuses.

func (*Workflow) GetNode

func (w *Workflow) GetNode(id string) (*WorkflowNode, bool)

GetNode returns a node by ID.

func (*Workflow) GetPhase

func (w *Workflow) GetPhase(id string) (*WorkflowPhase, bool)

GetPhase returns a phase by ID.

func (*Workflow) GetPhaseRequirements

func (w *Workflow) GetPhaseRequirements(phase Phase) PhaseRequirements

GetPhaseRequirements returns the requirements for a phase.

func (*Workflow) GetPhaseStatus

func (w *Workflow) GetPhaseStatus(phase Phase) PhaseStatus

GetPhaseStatus returns the status of a specific phase.

func (*Workflow) Progress

func (w *Workflow) Progress() WorkflowProgress

Progress computes the current workflow progress.

func (*Workflow) ReadyNodes

func (w *Workflow) ReadyNodes() []*WorkflowNode

ReadyNodes returns nodes that are ready to be worked on.

func (*Workflow) ToMermaid

func (w *Workflow) ToMermaid() string

ToMermaid generates a Mermaid flowchart representation.

func (*Workflow) TransitionTo

func (w *Workflow) TransitionTo(targetPhase Phase, rules map[Phase]TransitionRule) (*TransitionResult, error)

TransitionTo attempts to transition the workflow to a new phase.

func (*Workflow) UpdateFromState

func (w *Workflow) UpdateFromState(state *State)

UpdateFromState updates the workflow from an AIDLC state.

func (*Workflow) UpdateNodeStatus

func (w *Workflow) UpdateNodeStatus(nodeID string, status NodeStatus, score *QualityScore) error

UpdateNodeStatus updates a node's status and recalculates dependent statuses.

func (*Workflow) ValidatePhaseTransition

func (w *Workflow) ValidatePhaseTransition(targetPhase Phase) []string

ValidatePhaseTransition performs comprehensive validation for a phase transition.

type WorkflowEdge

type WorkflowEdge struct {
	// From is the source node ID.
	From string `json:"from" yaml:"from"`

	// To is the target node ID.
	To string `json:"to" yaml:"to"`

	// Type is the edge type (dependency, blocks, suggests).
	Type EdgeType `json:"type" yaml:"type"`

	// Label is an optional edge label.
	Label string `json:"label,omitempty" yaml:"label,omitempty"`
}

WorkflowEdge represents a dependency edge between nodes.

type WorkflowExecutionContext

type WorkflowExecutionContext struct {
	// Workflow is the underlying AIDLC workflow.
	Workflow *Workflow

	// Protocol is the pidl protocol representation.
	Protocol *pidl.Protocol

	// StartTime is when execution started.
	StartTime time.Time

	// StepTimings tracks timing for each step.
	StepTimings map[string]*StepTiming

	// StepStatus tracks the status of each step.
	StepStatus map[string]StepExecutionStatus

	// ExecutionOrder is the topologically sorted execution order.
	ExecutionOrder []string

	// Dependencies maps step ID to its required predecessor step IDs.
	Dependencies map[string][]string

	// Dependents maps step ID to steps that depend on it.
	Dependents map[string][]string
}

WorkflowExecutionContext tracks AIDLC workflow execution.

func NewWorkflowExecutionContext

func NewWorkflowExecutionContext(w *Workflow) (*WorkflowExecutionContext, error)

NewWorkflowExecutionContext creates a new execution context for an AIDLC workflow.

func (*WorkflowExecutionContext) CompleteStep

func (ctx *WorkflowExecutionContext) CompleteStep(stepID string, score *QualityScore) error

CompleteStep marks a step as completed.

func (*WorkflowExecutionContext) FailStep

func (ctx *WorkflowExecutionContext) FailStep(stepID string) error

FailStep marks a step as failed.

func (*WorkflowExecutionContext) GetBlockedSteps

func (ctx *WorkflowExecutionContext) GetBlockedSteps() map[string][]string

GetBlockedSteps returns steps that are blocked and their blocking reasons.

func (*WorkflowExecutionContext) GetCriticalPath

func (ctx *WorkflowExecutionContext) GetCriticalPath() []string

GetCriticalPath returns the steps on the critical path (longest execution path).

func (*WorkflowExecutionContext) GetMetrics

func (ctx *WorkflowExecutionContext) GetMetrics() *ExecutionMetrics

GetMetrics returns current execution metrics.

func (*WorkflowExecutionContext) GetReadySteps

func (ctx *WorkflowExecutionContext) GetReadySteps() []string

GetReadySteps returns steps that are ready to be executed.

func (*WorkflowExecutionContext) GetStepTiming

func (ctx *WorkflowExecutionContext) GetStepTiming(stepID string) (*StepTiming, bool)

GetStepTiming returns timing information for a specific step.

func (*WorkflowExecutionContext) IsComplete

func (ctx *WorkflowExecutionContext) IsComplete() bool

IsComplete returns whether all steps are completed or failed/skipped.

func (*WorkflowExecutionContext) Reset

func (ctx *WorkflowExecutionContext) Reset()

Reset resets the execution context for a new run.

func (*WorkflowExecutionContext) SkipStep

func (ctx *WorkflowExecutionContext) SkipStep(stepID string) error

SkipStep marks a step as skipped.

func (*WorkflowExecutionContext) StartStep

func (ctx *WorkflowExecutionContext) StartStep(stepID string) error

StartStep marks a step as in progress.

func (*WorkflowExecutionContext) SyncFromWorkflow

func (ctx *WorkflowExecutionContext) SyncFromWorkflow()

SyncFromWorkflow syncs the execution context from the workflow state.

type WorkflowNode

type WorkflowNode struct {
	// ID is the unique node identifier.
	ID string `json:"id" yaml:"id"`

	// DocType is the AIDLC document type.
	DocType DocType `json:"doc_type" yaml:"doc_type"`

	// Phase is the workflow phase.
	Phase Phase `json:"phase" yaml:"phase"`

	// Name is the display name.
	Name string `json:"name" yaml:"name"`

	// Description describes the node purpose.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	// Status is the node status.
	Status NodeStatus `json:"status" yaml:"status"`

	// Score is the quality score (if evaluated).
	Score *QualityScore `json:"score,omitempty" yaml:"score,omitempty"`

	// DependsOn lists node IDs this node depends on.
	DependsOn []string `json:"depends_on,omitempty" yaml:"depends_on,omitempty"`

	// Blocks lists node IDs blocked by this node.
	Blocks []string `json:"blocks,omitempty" yaml:"blocks,omitempty"`

	// Required indicates if this node is required.
	Required bool `json:"required" yaml:"required"`

	// Automated indicates if this node is LLM-generated.
	Automated bool `json:"automated,omitempty" yaml:"automated,omitempty"`

	// Metadata contains additional node data.
	Metadata map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty"`
}

WorkflowNode represents a document node in the workflow.

type WorkflowPhase

type WorkflowPhase struct {
	// ID is the phase identifier.
	ID string `json:"id" yaml:"id"`

	// Name is the display name.
	Name string `json:"name" yaml:"name"`

	// Description describes the phase purpose.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	// Order is the phase order (0-indexed).
	Order int `json:"order" yaml:"order"`

	// NodeIDs are the node IDs in this phase.
	NodeIDs []string `json:"node_ids" yaml:"node_ids"`
}

WorkflowPhase represents a phase in the workflow.

type WorkflowProgress

type WorkflowProgress struct {
	// Completed is the number of completed nodes.
	Completed int `json:"completed" yaml:"completed"`

	// Total is the total number of nodes.
	Total int `json:"total" yaml:"total"`

	// Percent is the completion percentage (0-100).
	Percent float64 `json:"percent" yaml:"percent"`

	// PhaseProgress maps phase IDs to progress.
	PhaseProgress map[string]float64 `json:"phase_progress,omitempty" yaml:"phase_progress,omitempty"`
}

WorkflowProgress tracks completion progress.

Jump to

Keyboard shortcuts

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