execution

package
v0.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package execution provides domain models for execution results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ControlResult

type ControlResult struct {
	Index              int                 `json:"index" yaml:"index"` // Original definition order (0-indexed) for deterministic output
	ID                 string              `json:"id" yaml:"id"`
	Name               string              `json:"name" yaml:"name"`
	Description        string              `json:"description,omitempty" yaml:"description,omitempty"`
	Severity           string              `json:"severity,omitempty" yaml:"severity,omitempty"`
	Tags               []string            `json:"tags,omitempty" yaml:"tags,omitempty"`
	Status             values.Status       `json:"status" yaml:"status"`
	ObservationResults []ObservationResult `json:"observations" yaml:"observations"`
	Message            string              `json:"message,omitempty" yaml:"message,omitempty"`
	SkipReason         string              `json:"skip_reason,omitempty" yaml:"skip_reason,omitempty"`
	Duration           time.Duration       `json:"duration_ms" yaml:"duration_ms"`
}

ControlResult represents the result of executing a single control.

type Evidence

type Evidence struct {
	Status    bool
	Error     *PluginError // Plugin execution error
	Timestamp time.Time
	Data      map[string]interface{}
	Raw       *string // Optional raw data
}

Evidence represents observation results (proof of compliance state). This is a core domain concept representing the evidence collected during a check.

type ExecutionResult

type ExecutionResult struct {
	ExecutionID    values.ExecutionID `json:"execution_id" yaml:"execution_id"`
	Version        int                `json:"version" yaml:"version"` // For optimistic locking
	RegletVersion  string             `json:"reglet_version,omitempty" yaml:"reglet_version,omitempty"`
	ProfileName    string             `json:"profile_name" yaml:"profile_name"`
	ProfileVersion string             `json:"profile_version" yaml:"profile_version"`
	StartTime      time.Time          `json:"start_time" yaml:"start_time"`
	EndTime        time.Time          `json:"end_time" yaml:"end_time"`
	Duration       time.Duration      `json:"duration_ms" yaml:"duration_ms"`
	Controls       []ControlResult    `json:"controls" yaml:"controls"`
	Summary        ResultSummary      `json:"summary" yaml:"summary"`
	// contains filtered or unexported fields
}

ExecutionResult represents the complete result of executing a profile.

func NewExecutionResult

func NewExecutionResult(profileName, profileVersion string) *ExecutionResult

NewExecutionResult creates a new execution result.

func NewExecutionResultWithID

func NewExecutionResultWithID(id values.ExecutionID, profileName, profileVersion string) *ExecutionResult

NewExecutionResultWithID creates a new execution result with a specific ID.

func (*ExecutionResult) AddControlResult

func (r *ExecutionResult) AddControlResult(cr ControlResult)

AddControlResult adds a control result to the execution result. Thread-safe for concurrent calls during parallel execution.

func (*ExecutionResult) AddPartialResult

func (r *ExecutionResult) AddPartialResult(cr ControlResult)

AddPartialResult adds a control result from a partial execution (e.g. worker).

func (*ExecutionResult) Finalize

func (r *ExecutionResult) Finalize()

Finalize completes the execution result and calculates the summary. Controls are sorted by their original definition order for deterministic output.

func (*ExecutionResult) GetControlResultByID

func (r *ExecutionResult) GetControlResultByID(id string) *ControlResult

GetControlResultByID returns a pointer to the control result with the given ID, or nil if not found. Thread-safe.

func (*ExecutionResult) GetControlStatus

func (r *ExecutionResult) GetControlStatus(id string) (values.Status, bool)

GetControlStatus returns the status of a control by ID. Returns the status and a boolean indicating if the control was found. Thread-safe.

func (*ExecutionResult) GetID

func (r *ExecutionResult) GetID() values.ExecutionID

GetID returns the execution ID.

func (*ExecutionResult) GetVersion

func (r *ExecutionResult) GetVersion() int

GetVersion returns the optimistic locking version.

func (*ExecutionResult) IncrementVersion

func (r *ExecutionResult) IncrementVersion()

IncrementVersion increments the version counter.

func (*ExecutionResult) IsComplete

func (r *ExecutionResult) IsComplete(expectedControlCount int) bool

IsComplete checks if the number of executed controls matches the expected count.

type ExpectationResult

type ExpectationResult struct {
	Expression string `json:"expression" yaml:"expression"`               // The expect expression (e.g., "data.size == 2785")
	Passed     bool   `json:"passed" yaml:"passed"`                       // Whether the expectation passed
	Message    string `json:"message,omitempty" yaml:"message,omitempty"` // Human-readable description (only set on failure/error)
}

ExpectationResult represents the result of evaluating a single expectation expression. The Message field provides human-readable context about failures, constructed by the StatusAggregator which has full access to the evidence and expression evaluation context.

type ObservationResult

type ObservationResult struct {
	Plugin       string                 `json:"plugin" yaml:"plugin"`
	Config       map[string]interface{} `json:"config" yaml:"config"`
	Status       values.Status          `json:"status" yaml:"status"`
	Evidence     *Evidence              `json:"evidence,omitempty" yaml:"evidence,omitempty"`
	Error        *PluginError           `json:"error,omitempty" yaml:"error,omitempty"`
	Expectations []ExpectationResult    `json:"expectations,omitempty" yaml:"expectations,omitempty"`
	Duration     time.Duration          `json:"duration_ms" yaml:"duration_ms"`
}

ObservationResult represents the result of executing a single observation.

type PluginError

type PluginError struct {
	Code    string
	Message string
}

PluginError represents an error from plugin execution. This is a domain concept representing a failure in collecting evidence.

func (*PluginError) Error

func (e *PluginError) Error() string

Error implements the error interface

type ResultSummary

type ResultSummary struct {
	TotalControls      int `json:"total_controls" yaml:"total_controls"`
	PassedControls     int `json:"passed_controls" yaml:"passed_controls"`
	FailedControls     int `json:"failed_controls" yaml:"failed_controls"`
	ErrorControls      int `json:"error_controls" yaml:"error_controls"`
	SkippedControls    int `json:"skipped_controls" yaml:"skipped_controls"`
	TotalObservations  int `json:"total_observations" yaml:"total_observations"`
	PassedObservations int `json:"passed_observations" yaml:"passed_observations"`
	FailedObservations int `json:"failed_observations" yaml:"failed_observations"`
	ErrorObservations  int `json:"error_observations" yaml:"error_observations"`
}

ResultSummary provides aggregate statistics about the execution.

Jump to

Keyboard shortcuts

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