discovery

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DiagnosticCodeCandidateTooLarge         = "artifact.discovery.candidate-too-large"
	DiagnosticCodeContentDigestMismatch     = "artifact.discovery.content-digest-mismatch"
	DiagnosticCodeDecoderAmbiguous          = "artifact.discovery.decoder-ambiguous"
	DiagnosticCodeDecoderInvalidRecognition = "artifact.discovery.decoder-invalid-recognition"
	DiagnosticCodeDecoderNoLongerRecognizes = "artifact.discovery.decoder-no-longer-recognizes"
	DiagnosticCodeDefinitionInvalid         = "artifact.discovery.definition-invalid"
	DiagnosticCodeResourceMissing           = "artifact.discovery.resource-missing"
	DiagnosticCodeSubresourceMissing        = "artifact.discovery.subresource-missing"
)

Variables

This section is empty.

Functions

func ValidateIncludePattern added in v0.2.13

func ValidateIncludePattern(pattern string) error

ValidateIncludePattern validates a source-relative glob. It deliberately rejects path traversal and host-path syntax before passing the pattern to path.Match.

Types

type Candidate

type Candidate struct {
	SourceID            basespec.SourceID
	SourceKind          basespec.SourceKind
	Locator             basespec.Locator
	SourceContentDigest cryptoutil.Digest
	Content             []byte
	RequestedDecoderIDs []basespec.DecoderID
}

func (Candidate) RequestsDecoder added in v0.2.11

func (c Candidate) RequestsDecoder(id basespec.DecoderID) bool

type Decoded

type Decoded struct {
	SubresourceLocator basespec.SubresourceLocator
	Definition         definition.Definition
	Diagnostics        []diagnostic.Diagnostic
}

type Decoder

type Decoder interface {
	ID() basespec.DecoderID
	Revision() string
	Recognize(ctx context.Context, candidate Candidate) Recognition

	// Decode returns candidate-level diagnostics as its second result.
	//
	// Diagnostics attached to Decoded apply only to that emitted subresource.
	Decode(
		ctx context.Context,
		candidate Candidate,
	) ([]Decoded, []diagnostic.Diagnostic)
}

type DecoderHint added in v0.2.11

type DecoderHint struct {
	Locator    basespec.Locator     `json:"locator"`
	Recursive  bool                 `json:"recursive"`
	DecoderIDs []basespec.DecoderID `json:"decoderIDs"`
}

type DecoderRegistry

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

func NewDecoderRegistry

func NewDecoderRegistry(
	decoders ...Decoder,
) (*DecoderRegistry, error)

func (*DecoderRegistry) Fingerprint added in v0.2.13

func (r *DecoderRegistry) Fingerprint() (cryptoutil.Digest, error)

type DirectoryRoot

type DirectoryRoot struct {
	Root            basespec.Locator `json:"root"`
	Recursive       bool             `json:"recursive"`
	IncludePatterns []string         `json:"includePatterns,omitempty"`
}

DirectoryRoot is generic source-discovery scope shared by planners, preferences, and executable SourcePlans.

func (DirectoryRoot) Validate added in v0.2.13

func (r DirectoryRoot) Validate() error

type Engine

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

func NewEngine

func NewEngine(
	decoders *DecoderRegistry,
	timeClock clockutil.Clock,
) (*Engine, error)

func (*Engine) DecoderFingerprint added in v0.2.13

func (e *Engine) DecoderFingerprint() (cryptoutil.Digest, error)

func (*Engine) Discover

func (e *Engine) Discover(
	ctx context.Context,
	rootID basespec.RootID,
	collectionID basespec.CollectionID,
	sourceID basespec.SourceID,
	sourceKind basespec.SourceKind,
	snapshot source.Snapshot,
	plan SourcePlan,
	previous []catalog.Occurrence,
) (Result, error)

type Plan

type Plan struct {
	// Revision is consumer-owned discovery-policy identity. Consumers must
	// change it whenever planner behavior changes in a way that can alter
	// discovery scope, decoder eligibility, or interpretation.
	//
	// It is intentionally included in the catalog plan fingerprint while
	// source snapshot generations remain concurrency preconditions only.
	Revision string       `json:"revision,omitempty"`
	Sources  []SourcePlan `json:"sources"`
}

func (Plan) BySource

func (p Plan) BySource() map[basespec.SourceID]SourcePlan

func (Plan) Fingerprint added in v0.2.13

func (p Plan) Fingerprint() (cryptoutil.Digest, error)

func (Plan) Validate

func (p Plan) Validate() error

type Recognition

type Recognition int
const (
	RecognitionNone Recognition = iota
	RecognitionPossible
	RecognitionPreferred
)

type Result

type Result struct {
	Occurrences []catalog.Occurrence
	Definitions map[cryptoutil.Digest]definition.Definition
	Diagnostics []diagnostic.Diagnostic
	Candidates  int
}

type SourcePlan

type SourcePlan struct {
	SourceID               basespec.SourceID                      `json:"sourceID"`
	ExplicitLocators       []basespec.Locator                     `json:"explicitLocators,omitempty"`
	DirectoryRoots         []DirectoryRoot                        `json:"directoryRoots,omitempty"`
	DecoderHints           []DecoderHint                          `json:"decoderHints,omitempty"`
	ExpectedContentDigests map[basespec.Locator]cryptoutil.Digest `json:"expectedContentDigests,omitempty"`
	ExpectedGeneration     string                                 `json:"expectedGeneration,omitempty"`
	AllowedDecoderIDs      []basespec.DecoderID                   `json:"allowedDecoderIDs,omitempty"`
	Authoritative          bool                                   `json:"authoritative"`
	MaxCandidateBytes      int64                                  `json:"maxCandidateBytes"`
	MaxTotalBytes          int64                                  `json:"maxTotalBytes"`
	MaxCandidates          int                                    `json:"maxCandidates"`
	MaxEntries             int                                    `json:"maxEntries"`
	MaxDepth               int                                    `json:"maxDepth"`
}

func (SourcePlan) Normalized

func (p SourcePlan) Normalized() SourcePlan

Normalized returns an owned, deterministic copy with default limits.

It intentionally does not mutate the input plan or its backing slices.

func (SourcePlan) RequestedDecoderIDs added in v0.2.11

func (p SourcePlan) RequestedDecoderIDs(locator basespec.Locator) []basespec.DecoderID

func (SourcePlan) Validate

func (p SourcePlan) Validate() error

Jump to

Keyboard shortcuts

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