scope

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxSegmentsTemplateDepth is the maximum number of path segments in a
	// scope.type="segments" template (ADR-0009).
	MaxSegmentsTemplateDepth = 16
	// MaxDiscoveredPrefixesPerLevel is the maximum number of discovered
	// prefixes permitted at any single segment level in scope.type="segments".
	MaxDiscoveredPrefixesPerLevel = 10000
	// MaxCompiledScopePrefixes is the maximum total compiled prefixes permitted
	// from scope.type="segments" (matches durable-index/v0 MaxPlanScopes).
	MaxCompiledScopePrefixes = 65536
)
View Source
const (
	MatchPrefixMigrationSchema  = "gonimbus.scope.match_prefix_migration.v1"
	MatchPrefixMigrationVersion = 1
)

Migration plan schema identity for prefix-equivalent match→scope conversion.

View Source
const (
	ClassificationConvertible       = "convertible"
	ClassificationAlreadyCompatible = "already_compatible"
	ClassificationAlreadyMigrated   = "already_migrated"
	ClassificationRefused           = "refused"
)

Classification outcomes for a match→scope migration audit.

View Source
const (
	ReasonConvertible               = "prefix_includes_convertible"
	ReasonDatePartitionsConvertible = "date_partitions_include_convertible"
	ReasonSegmentsConvertible       = "segments_include_convertible"
	ReasonAlreadyCompatible         = "default_match_no_scope"
	ReasonAlreadyMigrated           = "proposed_form_present"
	ReasonExistingScope             = "existing_scope"
	ReasonNonPrefixInclude          = "non_prefix_include"
	ReasonHasExcludes               = "has_excludes"
	ReasonHasFilters                = "has_filters"
	ReasonIncludeHidden             = "include_hidden"
	ReasonEmptyOrRootPrefix         = "empty_or_root_prefix"
	ReasonBaseAnchorMismatch        = "base_anchor_mismatch"
	ReasonEmptyLegacyPlan           = "empty_legacy_plan"
	ReasonPlanInequality            = "plan_inequality"
	ReasonInvalidBaseURI            = "invalid_base_uri"
	ReasonInvalidManifest           = "invalid_manifest"
	ReasonEmitValidateFailed        = "emit_validate_failed"
	ReasonUnsupportedScopeType      = "unsupported_scope_type"
	ReasonIdentityComputeFailed     = "identity_compute_failed"
	ReasonNoIncludes                = "no_includes"
	ReasonMixedDefaultAndPrefix     = "mixed_default_and_prefix"
)

Stable reason codes for classification (allowlist + refuse matrix).

Variables

View Source
var ErrDiscoveryBudgetExceeded = errors.New("scope discovery budget exceeded")

ErrDiscoveryBudgetExceeded is returned when a scope.type="segments" template exceeds template depth or discovered-prefix resource bounds.

Functions

func CanonicalizeSegmentsTemplate added in v0.5.0

func CanonicalizeSegmentsTemplate(cfg *manifest.IndexScopeConfig) ([]manifest.IndexScopeDiscoverSegment, error)

CanonicalizeSegmentsTemplate validates a scope.type="segments" configuration and returns its ordered, canonical segment rules (indices 0..N-1).

func HashConfig

func HashConfig(cfg *manifest.IndexScopeConfig) (string, error)

HashConfig computes a canonical scope hash for identity purposes.

func RequiresPrefixLister

func RequiresPrefixLister(cfg *manifest.IndexScopeConfig) bool

Types

type ComputedIdentityEvidence

type ComputedIdentityEvidence struct {
	Kind            string   `json:"kind"` // always "computed"
	IndexSetID      string   `json:"index_set_id"`
	CanonicalSHA256 string   `json:"canonical_sha256"`
	ScopeHash       string   `json:"scope_hash,omitempty"`
	Includes        []string `json:"includes,omitempty"`
	GonimbusVersion string   `json:"gonimbus_version,omitempty"`
}

ComputedIdentityEvidence is an identity calculation under the current binary. It is not authoritative for a live on-disk set unless bound to a marker/receipt.

type DiscoveredScopeProposal added in v0.5.0

type DiscoveredScopeProposal struct {
	ReasonCode             string                     `json:"reason_code"`
	Detail                 string                     `json:"detail,omitempty"`
	ProposedScope          *manifest.IndexScopeConfig `json:"proposed_scope"`
	ProposedScopeHash      string                     `json:"proposed_scope_hash"`
	ProposedManifestYAML   string                     `json:"proposed_manifest_yaml,omitempty"`
	ProposedManifestDigest string                     `json:"proposed_manifest_digest,omitempty"`
}

DiscoveredScopeProposal describes an offline discovered-scope candidate (date_partitions or segments) when a single mid-path wildcard include pattern cannot be converted to a static prefix_list.

type IdentityComputer

type IdentityComputer func(m *manifest.IndexManifest, gonimbusVersion string) (*ComputedIdentityEvidence, error)

IdentityComputer optionally computes index-set identity evidence from a fully defaulted/reparsed manifest. Callers that need identity evidence must inject an implementation; pkg/scope remains storage-free (ADR-0006).

type MigrationPlan

type MigrationPlan struct {
	Schema  string `json:"schema"`
	Version int    `json:"version"`

	Classification string `json:"classification"`
	ReasonCode     string `json:"reason_code"`
	Detail         string `json:"detail,omitempty"`

	SourceManifestDigest string `json:"source_manifest_digest"`

	CanonicalLegacyIncludes []string `json:"canonical_legacy_includes,omitempty"`

	LegacyProviderPrefixes []string `json:"legacy_provider_prefixes,omitempty"`
	LegacyPlanDigest       string   `json:"legacy_plan_digest,omitempty"`
	LegacyPlanCount        int      `json:"legacy_plan_count,omitempty"`

	ProposedScope            *manifest.IndexScopeConfig `json:"proposed_scope,omitempty"`
	ProposedManifestYAML     string                     `json:"proposed_manifest_yaml,omitempty"`
	ProposedManifestDigest   string                     `json:"proposed_manifest_digest,omitempty"`
	ProposedProviderPrefixes []string                   `json:"proposed_provider_prefixes,omitempty"`
	ProposedPlanDigest       string                     `json:"proposed_plan_digest,omitempty"`
	ProposedPlanCount        int                        `json:"proposed_plan_count,omitempty"`
	ProposedScopeHash        string                     `json:"proposed_scope_hash,omitempty"`
	DiscoveredScopeProposal  *DiscoveredScopeProposal   `json:"discovered_scope_proposal,omitempty"`
	LegacyConfigIdentity     *ComputedIdentityEvidence  `json:"legacy_config_identity_under_current_binary,omitempty"`
	ProposedConfigIdentity   *ComputedIdentityEvidence  `json:"proposed_config_identity_under_current_binary,omitempty"`
}

MigrationPlan is the immutable audit record for one match→scope classification.

Experimental prefix-equivalent match→scope migration. Pure classification and conversion; no provider calls, authority, or filesystem side effects.

func PlanMatchPrefixMigration

func PlanMatchPrefixMigration(raw []byte, opts PlanOptions) (*MigrationPlan, error)

PlanMatchPrefixMigration classifies and, when convertible, converts prefix-shaped match.includes into an explicit build.scope prefix_list (or a discovered date_partitions / segments scope when opts.AllowDiscoveredScope is set). It never mutates disk or contacts a provider.

type Plan

type Plan struct {
	Prefixes []string
}

func Compile

func Compile(ctx context.Context, cfg *manifest.IndexScopeConfig, basePrefix string, lister provider.PrefixLister) (*Plan, error)

Compile compiles a build.scope configuration into an explicit prefix plan.

type PlanOptions

type PlanOptions struct {
	// GonimbusVersion is injected into identity evidence so tests can hold version constant.
	// When empty and ComputeIdentity is nil, identity evidence fields are omitted.
	GonimbusVersion string
	// ComputeIdentity is optional. When set (and GonimbusVersion is non-empty), identity
	// evidence is attached. Implementations may live in storageful packages (CLI adapter).
	ComputeIdentity IdentityComputer
	// AllowDiscoveredScope enables converting a single mid-path wildcard include
	// pattern into a discovered build.scope (date_partitions when the tail is a
	// date partition shape, or segments when the tail is literal/non-date).
	// When false (default), such patterns remain classified as refused
	// (non_prefix_include) while attaching DiscoveredScopeProposal for offline
	// operator inspection.
	AllowDiscoveredScope bool
}

PlanOptions configures PlanMatchPrefixMigration.

Jump to

Keyboard shortcuts

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