validation

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

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 (
	// ErrInvalidUint64 is returned when a value cannot be unmarshaled as uint64
	ErrInvalidUint64 = errors.New("failed to unmarshal value as uint64")
	// ErrExternalNotInitialized is returned when external model bounds cache is not yet populated
	ErrExternalNotInitialized = errors.New("external model bounds not initialized")
)
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

Functions

This section is empty.

Types

type ExternalModelValidator

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

ExternalModelValidator implements the ExternalValidator interface

func NewExternalModelExecutor

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

NewExternalModelExecutor creates a new external model executor

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 FlexUint64 added in v0.0.2

type FlexUint64 uint64

FlexUint64 is a custom type that can unmarshal from both string and number JSON values and scan from string or numeric database columns

func (*FlexUint64) Scan added in v0.0.49

func (f *FlexUint64) Scan(src interface{}) error

Scan implements sql.Scanner for FlexUint64 to handle database values. Supports string columns (e.g., '123') and numeric columns.

func (*FlexUint64) UnmarshalJSON added in v0.0.2

func (f *FlexUint64) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler for FlexUint64

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