validation

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: GPL-3.0 Imports: 10 Imported by: ? modules, 0 packages

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

Documentation

Overview

Package validation provides dependency validation for CBT models

Package validation provides dependency validation for CBT models. It determines valid position ranges based on dependency data availability and validates whether positions can be processed.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrModelNotFound               = errors.New("model not found")
	ErrDependencyNotFound          = errors.New("dependency model not found")
	ErrRangeNotAvailable           = errors.New("required range not available")
	ErrRangeNotCovered             = errors.New("range not fully covered")
	ErrNotTransformationModel      = errors.New("model is not a transformation")
	ErrInvalidDependencyType       = errors.New("invalid dependency type")
	ErrInvalidModelType            = errors.New("invalid dependency model type")
	ErrFailedModelCast             = errors.New("failed to cast model to transformation")
	ErrNoORDependencyAvailable     = errors.New("no dependencies in OR group are available")
	ErrUninitializedTransformation = errors.New("transformation dependency has not been initialized")
)

Validation-specific errors

View Source
var ErrExternalNotInitialized = errors.New("external model bounds not initialized")

ErrExternalNotInitialized is returned when external model bounds cache is not yet populated.

Functions

This section is empty.

Types

type ExternalModelValidator

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

ExternalModelValidator implements the ExternalValidator interface

func NewExternalModelValidator added in v0.1.7

func NewExternalModelValidator(log logrus.FieldLogger, adminService admin.Service) *ExternalModelValidator

NewExternalModelValidator creates a new external model validator

func (*ExternalModelValidator) GetMinMax

func (e *ExternalModelValidator) GetMinMax(ctx context.Context, model models.External) (minPos, maxPos uint64, err error)

GetMinMax retrieves the min and max position values for an external model

type ExternalValidator added in v0.0.2

type ExternalValidator interface {
	GetMinMax(ctx context.Context, model models.External) (uint64, uint64, error)
}

ExternalValidator defines the interface for external model bounds retrieval

type MockValidator added in v0.0.2

type MockValidator struct {

	// Control behavior
	ValidateDependenciesFunc func(ctx context.Context, modelID string, position, interval uint64) (Result, error)
	GetValidRangeFunc        func(ctx context.Context, modelID string, semantics RangeSemantics) (uint64, uint64, error)
	GetStartPositionFunc     func(ctx context.Context, modelID string) (uint64, error)

	// Track calls for assertions
	ValidateCalls   []ValidateCall
	ValidRangeCalls []ValidRangeCall
	StartPosCalls   []string
	// contains filtered or unexported fields
}

MockValidator is a mock implementation of Validator for testing

func NewMockValidator added in v0.0.2

func NewMockValidator() *MockValidator

NewMockValidator creates a new mock validator

func (*MockValidator) GetStartPosition added in v0.0.51

func (m *MockValidator) GetStartPosition(ctx context.Context, modelID string) (uint64, error)

GetStartPosition implements Validator

func (*MockValidator) GetValidRange added in v0.0.2

func (m *MockValidator) GetValidRange(ctx context.Context, modelID string, semantics RangeSemantics) (minPos, maxPos uint64, err error)

GetValidRange implements Validator

func (*MockValidator) GetValidateCallCount added in v0.0.2

func (m *MockValidator) GetValidateCallCount() int

GetValidateCallCount returns the number of ValidateDependencies calls

func (*MockValidator) Reset added in v0.0.2

func (m *MockValidator) Reset()

Reset clears all recorded calls

func (*MockValidator) ValidateDependencies added in v0.0.2

func (m *MockValidator) ValidateDependencies(ctx context.Context, modelID string, position, interval uint64) (Result, error)

ValidateDependencies implements Validator

type RangeSemantics added in v0.0.51

type RangeSemantics int

RangeSemantics determines how dependency bounds are combined

const (
	// Union semantics: min = MIN(external_mins), useful for forward fill
	// where we can start as soon as ANY external dependency has data
	Union RangeSemantics = iota

	// Intersection semantics: min = MAX(all_mins), useful for backfill
	// where we need ALL dependencies to have data at a position
	Intersection
)

type Result

type Result struct {
	CanProcess   bool    // Whether current position can be processed
	Errors       []error // Validation errors
	NextValidPos uint64  // Next position where dependencies are available (0 if can process or no next position)
}

Result contains the result of dependency validation

type ValidRangeCall added in v0.0.51

type ValidRangeCall struct {
	ModelID   string
	Semantics RangeSemantics
}

ValidRangeCall records a GetValidRange call

type ValidateCall added in v0.0.2

type ValidateCall struct {
	ModelID  string
	Position uint64
	Interval uint64
}

ValidateCall records a ValidateDependencies call

type Validator added in v0.0.2

type Validator interface {
	// ValidateDependencies checks if all dependencies are satisfied for a given position.
	// Returns whether the position can be processed and the next valid position if not.
	ValidateDependencies(ctx context.Context, modelID string, position, interval uint64) (Result, error)

	// GetValidRange returns the valid position range [min, max] based on dependency bounds.
	// Use Union for forward fill, Intersection for backfill.
	GetValidRange(ctx context.Context, modelID string, semantics RangeSemantics) (minPos, maxPos uint64, err error)

	// GetStartPosition calculates the starting position for a NEW model.
	// Considers fill direction (head-first vs tail-first) from handler config.
	GetStartPosition(ctx context.Context, modelID string) (uint64, error)
}

Validator defines the interface for dependency validation

func NewDependencyValidator

func NewDependencyValidator(
	log logrus.FieldLogger,
	adminService admin.Service,
	externalValidator ExternalValidator,
	dag models.DAGReader,
) Validator

NewDependencyValidator creates a new dependency validator with explicit dependencies.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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