validation

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeDuplicateIdentifier                     = "factory.duplicateIdentifier"
	CodeDanglingWorkerReference                 = "factory.worker.danglingReference"
	CodeDanglingPlaceReference                  = "factory.route.danglingPlaceReference"
	CodeDanglingResourceReference               = "factory.resource.danglingReference"
	CodeWorkstationMissingFailureRoute          = "factory.workstation.missingFailureRoute"
	CodeWorkstationMissingRejectionRoute        = "factory.workstation.missingRejectionRoute"
	CodeWorkstationConflictingOutputs           = "factory.workstation.conflictingWorkStateOutputs"
	CodeWorkTypeMissingCompletionState          = "factory.workType.missingCompletionState"
	CodeWorkTypeMissingFailureState             = "factory.workType.missingFailureState"
	CodeWorkStateMissingTerminalPath            = "factory.workState.missingTerminalCompletionPath"
	CodeWorkTypeHandlingBehaviorValue           = "work-type-handling-behavior-value"
	CodeWorkTypeHandlingBehaviorDuplicate       = "work-type-handling-behavior-duplicate"
	CodeWorkTypeHandlingBehaviorUniqueDefault   = "work-type-handling-behavior-unique-default"
	CodeWorkTypeHandlingBehaviorRequiredDefault = "work-type-handling-behavior-required-default"
)
View Source
const (
	CodeFactoryPayloadInvalid = "factory.payload.invalid"
	CodeFactoryNameInvalid    = "factory.name.invalid"
	CodeFactoryVersionStale   = "factory.version.stale"
	CodeFactoryRuntimeNotIdle = "factory.runtime.notIdle"
	CodeFactorySessionField   = "factory.session.field"
)
View Source
const CrossPathInvalidFactoryJSON = `` /* 386-byte string literal not displayed */

CrossPathInvalidFactoryJSON is the shared invalid factory used to prove canonical validation targets are equivalent across explicit validation, config validation, factory save rejection, and POST /factory-validations.

ProfilePrePersist (editable save pre-check) and ProfileTopology (validate-only endpoint) intentionally diverge on this fixture: validate-only includes deferred outcome-route findings; save pre-check rejects with the blocking-load subset only. See validationentry cross_path_profile_gap_test.go.

View Source
const CrossPathValidAlphaFactoryJSON = `` /* 435-byte string literal not displayed */

CrossPathValidAlphaFactoryJSON is a persistable alpha factory compatible with CrossPathInvalidFactoryJSON work-type names for save-rejection equivalence tests.

View Source
const DefaultTopologyValidationMessage = "Factory topology contains invalid graph references."

DefaultTopologyValidationMessage is the operator-facing save rejection message when callers do not supply a custom topology validation message.

Variables

This section is empty.

Functions

func CanonicalAPITargetSignatures

func CanonicalAPITargetSignatures(targets []factoryapi.FactoryValidationTarget) []string

CanonicalAPITargetSignatures returns sorted signatures for API validation targets.

func CanonicalTargetSignatures

func CanonicalTargetSignatures(targets []Target) []string

CanonicalTargetSignatures returns sorted stable signatures for cross-path equivalence.

func DecodeCrossPathInvalidFactory

func DecodeCrossPathInvalidFactory() (factoryapi.Factory, error)

DecodeCrossPathInvalidFactory decodes the shared invalid factory fixture.

func DecodeCrossPathValidAlphaFactory

func DecodeCrossPathValidAlphaFactory() (factoryapi.Factory, error)

DecodeCrossPathValidAlphaFactory decodes the shared valid alpha factory fixture.

func EquivalentCanonicalTargetSignatures

func EquivalentCanonicalTargetSignatures(want, got []string) bool

EquivalentCanonicalTargetSignatures reports whether two signature lists match.

func FactoryRuntimeNotIdleTarget

func FactoryRuntimeNotIdleTarget() factoryapi.FactoryValidationTarget

FactoryRuntimeNotIdleTarget reports activation blocked by active runtime work.

func FactorySessionFieldTarget

func FactorySessionFieldTarget(reason, field, message string) factoryapi.FactoryValidationTarget

FactorySessionFieldTarget reports factory-session open validation failures.

func FormFactoryPayloadTarget

func FormFactoryPayloadTarget() factoryapi.FactoryValidationTarget

FormFactoryPayloadTarget reports invalid or unreadable factory request bodies.

func InvalidFactoryNameTarget

func InvalidFactoryNameTarget() factoryapi.FactoryValidationTarget

InvalidFactoryNameTarget reports invalid named-factory identifiers.

func NormalizeFixtureConfig

func NormalizeFixtureConfig(cfg *interfaces.FactoryConfig)

NormalizeFixtureConfig augments programmatic test fixtures with the minimum structural fields required by canonical validation without changing mapping intent.

func StaleFactoryVersionTarget

func StaleFactoryVersionTarget() factoryapi.FactoryValidationTarget

StaleFactoryVersionTarget reports optimistic-concurrency conflicts on editable saves.

func ToValidationTargets

func ToValidationTargets(targets []Target) []factoryapi.FactoryValidationTarget

ToValidationTargets maps canonical targets onto the validation-only API response shape.

Types

type Options

type Options struct {
	// Profile selects topology-only vs pre-persist canonical checks. When empty,
	// ProfileTopology is used.
	Profile Profile

	// WorkstationLoader is required for ProfilePrePersist when split worker or
	// workstation definitions must be resolved during LoadFromCanonicalJSON.
	// Values implementing pkg/config.WorkstationLoader are accepted.
	WorkstationLoader WorkstationLoader
}

Options configures ValidateFactoryAPI for a single validation invocation.

func (Options) ResolvedProfile

func (o Options) ResolvedProfile() Profile

ResolvedProfile returns the profile to apply, defaulting to ProfileTopology.

type Profile

type Profile string

Profile selects which validation rules run for one OpenAPI factory payload.

const (
	// ProfileTopology runs structural validation on a mapped FactoryConfig without
	// canonical JSON normalization or LoadFromCanonicalJSON blocking checks. It
	// matches POST /factory-validations: duplicate identifiers, dangling references,
	// conflicting outputs, and outcome-route / work-type completion invariants.
	ProfileTopology Profile = "topology"

	// ProfilePrePersist runs the same pre-write checks as editable factory save and
	// CLI save-from-file: canonical JSON normalization via LoadFromCanonicalJSON
	// (including bundled-file and blocking-load rules), then full structural
	// validation when load succeeds. Blocking-load failures return a subset of
	// structural targets that omit deferred outcome-route-only codes.
	ProfilePrePersist Profile = "pre_persist"
)

type Result

type Result struct {
	Targets []Target
}

Result aggregates canonical validation targets for one factory definition.

func Validate

func Validate(cfg *interfaces.FactoryConfig) Result

Validate runs structural factory validation for a complete factory definition and returns aggregated canonical targets.

func ValidateBlockingLoad

func ValidateBlockingLoad(cfg *interfaces.FactoryConfig) Result

ValidateBlockingLoad returns structural validation targets that should fail factory load before runtime definition merge. Outcome-route invariants remain on save and explicit validation paths until legacy fixtures migrate.

func ValidateStructural

func ValidateStructural(cfg *interfaces.FactoryConfig) Result

ValidateStructural runs shared structural validation without work-type outcome invariants that legacy mapper fixtures may omit until they are migrated.

func (Result) FactoryValidationResult

func (r Result) FactoryValidationResult() factoryapi.FactoryValidationResult

FactoryValidationResult maps canonical targets onto the validate-only API response shape used by POST /factory-validations.

func (Result) HasTargets

func (r Result) HasTargets() bool

HasTargets reports whether the result contains one or more validation targets.

func (Result) TopologyValidationErrorInput

func (r Result) TopologyValidationErrorInput(message string) (string, []factoryapi.FactoryValidationTarget)

TopologyValidationErrorInput returns the message and API targets used to build apisurface.TopologyValidationError via apisurface.NewTopologyValidationError. message is used when non-empty; otherwise DefaultTopologyValidationMessage is returned.

type Severity

type Severity string

Severity classifies how a validation target should be treated by callers.

const (
	SeverityError   Severity = "error"
	SeverityWarning Severity = "warning"
	SeverityHint    Severity = "hint"
)

type Subject

type Subject struct {
	Type     SubjectType     `json:"type"`
	ID       string          `json:"id"`
	Location SubjectLocation `json:"location"`
}

Subject identifies the affected factory component without UI-specific identifiers.

type SubjectLocation

type SubjectLocation string

SubjectLocation identifies the factory-domain location within a subject.

const (
	SubjectLocationOnRejection SubjectLocation = "ON_REJECTION"
	SubjectLocationOnFailure   SubjectLocation = "ON_FAILURE"
	SubjectLocationOutputs     SubjectLocation = "OUTPUTS"
	SubjectLocationInputs      SubjectLocation = "INPUTS"
	SubjectLocationStates      SubjectLocation = "STATES"
	SubjectLocationTerminal    SubjectLocation = "TERMINAL"
	SubjectLocationReference   SubjectLocation = "REFERENCE"
	SubjectLocationDefinition  SubjectLocation = "DEFINITION"
)

type SubjectType

type SubjectType string

SubjectType identifies the factory component a target refers to.

const (
	SubjectTypeFactory     SubjectType = "FACTORY"
	SubjectTypeWorkstation SubjectType = "WORKSTATION"
	SubjectTypeWorkType    SubjectType = "WORK_TYPE"
	SubjectTypeWorkState   SubjectType = "WORK_STATE"
	SubjectTypeWorker      SubjectType = "WORKER"
	SubjectTypeResource    SubjectType = "RESOURCE"
	SubjectTypeRoute       SubjectType = "ROUTE"
)

type Target

type Target struct {
	Code     string   `json:"code"`
	Severity Severity `json:"severity"`
	Message  string   `json:"message"`
	Subject  Subject  `json:"subject"`
	// Path is a legacy config-style location retained for config delegation and adapters.
	Path string `json:"-"`
}

Target is one canonical factory validation issue.

func WorkTypeHandlingBehaviorTargets

func WorkTypeHandlingBehaviorTargets(cfg *interfaces.FactoryConfig, opts WorkTypeHandlingBehaviorOptions) []Target

WorkTypeHandlingBehaviorTargets validates handlingBehavior markers on work types.

type WorkTypeHandlingBehaviorOptions

type WorkTypeHandlingBehaviorOptions struct {
	RequireDefault bool
}

WorkTypeHandlingBehaviorOptions configures optional handling-behavior validation.

type WorkstationLoader

type WorkstationLoader interface {
	Load(name string) (*interfaces.FactoryWorkstationConfig, error)
}

WorkstationLoader loads workstation definitions by name for pre-persist validation.

Jump to

Keyboard shortcuts

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