execution

package
v0.4.5-alpha Latest Latest
Warning

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

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

Documentation

Overview

Package execution provides domain models for execution results.

Index

Constants

View Source
const DefaultMaxEvidenceSize = constants.DefaultMaxEvidenceSize

DefaultMaxEvidenceSize is the default limit for evidence size (1MB). Re-exported from constants.DefaultMaxEvidenceSize for backward compatibility.

Variables

This section is empty.

Functions

This section is empty.

Types

type ControlResult

type ControlResult struct {
	ID                 string
	Name               string
	Description        string
	Severity           string
	Status             values.Status
	Message            string
	SkipReason         string
	Tags               []string
	ObservationResults []ObservationResult
	Index              int
	Duration           time.Duration
}

ControlResult represents the result of executing a single control.

type Evidence

type Evidence struct {
	Timestamp time.Time
	Error     *PluginError
	Data      map[string]interface{}
	Raw       *string
	Status    bool
}

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

type EvidenceMeta

type EvidenceMeta struct {
	Reason       string
	OriginalSize int
	TruncatedAt  int
	Truncated    bool
}

EvidenceMeta contains metadata about evidence truncation.

type ExecutionResult

type ExecutionResult struct {
	StartTime      time.Time
	EndTime        time.Time
	RegletVersion  string
	ProfileName    string
	ProfileVersion string
	Controls       []ControlResult
	Summary        ResultSummary
	Version        int
	Duration       time.Duration

	ExecutionID values.ExecutionID
	// 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
	Message    string
	Passed     bool
}

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 GreedyTruncator

type GreedyTruncator struct{}

GreedyTruncator implements a simple greedy truncation strategy. It truncates large string fields or replaces large complex objects until the size is reduced.

func (*GreedyTruncator) Truncate

func (t *GreedyTruncator) Truncate(data map[string]interface{}, limit int) (map[string]interface{}, *EvidenceMeta, error)

Truncate returns a truncated copy of the evidence if it exceeds the limit.

type ObservationResult

type ObservationResult struct {
	RawError     error
	LoopItem     interface{}
	Config       map[string]interface{}
	Evidence     *Evidence
	EvidenceMeta *EvidenceMeta
	Error        *PluginError
	Status       values.Status
	Plugin       string
	Expectations []ExpectationResult
	Children     []ObservationResult
	Duration     time.Duration
	LoopIndex    int
	IsLoop       bool
}

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
	PassedControls     int
	FailedControls     int
	ErrorControls      int
	SkippedControls    int
	TotalObservations  int
	PassedObservations int
	FailedObservations int
	ErrorObservations  int
}

ResultSummary provides aggregate statistics about the execution.

type TruncationStrategy

type TruncationStrategy interface {
	Truncate(data map[string]interface{}, limit int) (map[string]interface{}, *EvidenceMeta, error)
}

TruncationStrategy defines how evidence should be truncated when it exceeds limits.

Jump to

Keyboard shortcuts

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