provenance

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 15 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 provenance tracks exact native-constraint/refinement correspondences. It is not a replacement for native schema structure or payload validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fold

func Fold[R any](s Status, cs StatusCases[R]) R

Fold reduces Status by one-level case analysis.

func LowerAvroConstraint

func LowerAvroConstraint(program *language.Program, constraint Constraint) (string, error)

LowerAvroConstraint is the exact structural inverse for one edited canonical Avro unit. It does not evaluate user functions or infer logical equivalence. The returned JSON token is canonical for edits; RecoverNative is the separate API that returns the exact original token only while the imported form holds.

func LowerDependentRequiredConstraint

func LowerDependentRequiredConstraint(program *language.Program, constraint Constraint) (string, error)

LowerDependentRequiredConstraint is the exact structural inverse for one edited canonical unit. It never executes arbitrary code or accepts a copied Constraint that tries to weaken the keyword-derived scope/builtin checks.

func StatusEqual

func StatusEqual(a, b Status) bool

StatusEqual reports structural equality of a and b.

func StatusEqualWith

func StatusEqualWith(a, b Status, ov StatusEqOverrides) bool

StatusEqualWith reports structural equality of a and b under ov.

func StatusName

func StatusName(status Status) string

Types

type Avro

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

Avro retains exact, independently auditable correspondences for the small subset of Avro structural constraints with identical refinement semantics. It does not validate a complete Avro schema and never replaces Original.

func DiscoverAvro

func DiscoverAvro(input []byte, limits schemajson.Limits) (*Avro, error)

DiscoverAvro identifies only fixed size and the complete ordered enum symbol array at actual Avro schema positions. Defaults, docs, aliases and custom properties are data/metadata, never recursively guessed to be schemas. Structurally unsupported shapes stay opaque; full Avro validation belongs to the native package.

func (*Avro) AuditSource

func (a *Avro) AuditSource(source string) ([]Finding, error)

func (*Avro) ConstraintSource

func (a *Avro) ConstraintSource() string

func (*Avro) Constraints

func (a *Avro) Constraints() []Constraint

func (*Avro) ForResource

func (a *Avro) ForResource(resource string) *Avro

ForResource returns the same immutable correspondences with URI-framed identities. Multi-resource Avro projects use it so equal JSON Pointers in different schema documents cannot collide in one checked source module.

func (*Avro) Original

func (a *Avro) Original() string

func (*Avro) RecoverNative

func (a *Avro) RecoverNative(name, source string) (string, error)

type Changed

type Changed struct{}

type Constraint

type Constraint struct {
	Name          string
	Resource      string
	Pointer       string
	SchemaPointer string
	Keyword       string
	// PairedKeyword and PairedNative describe a second native member whose
	// semantics are inseparable from Keyword. OpenAPI 3.0 numeric bounds use
	// this for the Boolean exclusiveMinimum/exclusiveMaximum member. Empty
	// PairedNative means the member was omitted and its native default applies.
	PairedKeyword string
	PairedNative  string
	Scope         string
	Predicate     string
	Native        string
	Fingerprint   string
	Builtins      []string
}

Constraint describes one locally translatable native keyword. Scope is the Haskell type of that keyword's subject, not a claim about the whole document. SchemaPointer retains applicator context; e.g. a bound inside not/if/anyOf must never be hoisted into an unconditional root predicate.

type Error

type Error struct {
	Code    string
	Pointer string
	Message string
}

func (*Error) Error

func (e *Error) Error() string

type Finding

type Finding struct {
	Constraint Constraint
	Status     Status
}

type JSONSchema

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

JSONSchema retains the entire original document, including native keywords without an exact DSL translation. Public descriptions are detached copies.

func DiscoverJSONSchema

func DiscoverJSONSchema(input []byte, limits schemajson.Limits) (*JSONSchema, error)

DiscoverJSONSchema identifies exact numeric-bound, collection-count, uniqueness and const/enum correspondences in Draft 2020-12 schema positions. It deliberately does not interpret arbitrary objects in annotations/examples as subschemas, infer types from constraints, resolve references, or substitute UTF-16 length/RE2 for native semantics. Full native structure validation and projection remain separate phases. Values that cannot fit the bounded intrinsic-JSON projection remain opaque native constraints instead of making an otherwise valid schema unimportable.

func (*JSONSchema) AuditSource

func (s *JSONSchema) AuditSource(source string) ([]Finding, error)

AuditSource statically checks an edited constraint projection and reports each native correspondence independently. Formatting and extra where clauses do not invalidate an untouched rule; logically equivalent predicate rewrites do. Arbitrary new declarations/rules are allowed and have no native guarantee to break. No predicate executes, and no edited native output is silently emitted.

func (*JSONSchema) ConstraintSource

func (s *JSONSchema) ConstraintSource() string

ConstraintSource emits independently typed, editable constraint declarations. It is a projection of the discovered units, NOT a standalone replacement for the native schema: applicators/references/API metadata remain in Original(). Keeping that distinction prevents a local bound under `not` from accidentally becoming an unconditional rule. Full contract assembly uses these same units.

func (*JSONSchema) Constraints

func (s *JSONSchema) Constraints() []Constraint

func (*JSONSchema) Original

func (s *JSONSchema) Original() string

func (*JSONSchema) RecoverNative

func (s *JSONSchema) RecoverNative(name, source string) (string, error)

RecoverNative returns the exact original native token only when the selected constraint's canonical form still holds. A caller cannot accidentally claim a bijection after editing a bound. Other constraints remain recoverable.

type OpenAPI

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

func DiscoverOpenAPI

func DiscoverOpenAPI(resources []OpenAPIResource, options OpenAPIOptions) (*OpenAPI, error)

func DiscoverOpenAPIIndexed

func DiscoverOpenAPIIndexed(resources []OpenAPIResource, options OpenAPIOptions, locations []OpenAPISchemaRoot) (*OpenAPI, error)

DiscoverOpenAPIIndexed discovers lexical constraint units at explicitly supplied, already schema-checked physical locations. It does not resolve references or validate an OpenAPI document. Embedders must obtain locations and effective dialects from a complete schema-aware resource catalog, never from a recursive search for keyword-shaped instance data. This separation lets native validators share one reference authority with provenance.

func (*OpenAPI) AuditResourceSource

func (o *OpenAPI) AuditResourceSource(resource, source string) ([]Finding, error)

func (*OpenAPI) AuditSource

func (o *OpenAPI) AuditSource(source string) ([]Finding, error)

func (*OpenAPI) ConstraintSource

func (o *OpenAPI) ConstraintSource() string

func (*OpenAPI) Constraints

func (o *OpenAPI) Constraints() []Constraint

func (*OpenAPI) RecoverNative

func (o *OpenAPI) RecoverNative(name, source string) (string, error)

func (*OpenAPI) RecoverResourceNative

func (o *OpenAPI) RecoverResourceNative(resource, name, source string) (string, error)

func (*OpenAPI) ResourceConstraintSource

func (o *OpenAPI) ResourceConstraintSource(resource string) string

func (*OpenAPI) ResourceConstraints

func (o *OpenAPI) ResourceConstraints(resource string) []Constraint

func (*OpenAPI) Resources

func (o *OpenAPI) Resources() []OpenAPIResource

type OpenAPIOptions

type OpenAPIOptions struct {
	EntryResource string
	Limits        schemajson.Limits
}

type OpenAPIResource

type OpenAPIResource struct {
	URI     string
	Source  []byte
	Syntax  OpenAPISyntax
	Role    OpenAPIResourceRole
	Dialect string
}

type OpenAPIResourceRole

type OpenAPIResourceRole string
const (
	OpenAPIDocument OpenAPIResourceRole = "document"
	OpenAPISchema   OpenAPIResourceRole = "schema"
	OpenAPIFragment OpenAPIResourceRole = "fragment"
)

type OpenAPISchemaRoot

type OpenAPISchemaRoot struct {
	Resource string
	Pointer  string
	Dialect  string
}

OpenAPISchemaRoot identifies a physical Schema Object root reached through a checked OpenAPI wrapper role. Schema keywords below this root deliberately remain the responsibility of a JSON Schema catalog and resolver.

func IndexOpenAPISchemaRoots

func IndexOpenAPISchemaRoots(resources []OpenAPIResource, options OpenAPIOptions) ([]OpenAPISchemaRoot, error)

IndexOpenAPISchemaRoots returns the sorted, deduplicated physical Schema Object roots in an explicit OpenAPI resource closure. Every explicit Document is indexed under its own OpenAPI version and schema dialect. Wrapper references are resolved with the same role-aware traversal used by provenance discovery; Schema Object references, IDs, and anchors are not interpreted here.

type OpenAPISyntax

type OpenAPISyntax string
const (
	OpenAPIJSON OpenAPISyntax = "json"
	OpenAPIYAML OpenAPISyntax = "yaml"
)

type Removed

type Removed struct{}

type Status

type Status interface {
	// contains filtered or unexported methods
}

type StatusCases

type StatusCases[R any] struct {
	Unchanged func() R
	Changed   func() R
	Removed   func() R
}

StatusCases selects one handler per Status variant for Fold.

type StatusEqOverrides

type StatusEqOverrides struct {
	Unchanged func(x, y Unchanged) (eq, handled bool)
	Changed   func(x, y Changed) (eq, handled bool)
	Removed   func(x, y Removed) (eq, handled bool)
}

StatusEqOverrides carries optional per-variant hooks for StatusEqualWith. A hook returning handled=false falls through to the derived comparison.

type Unchanged

type Unchanged struct{}

Jump to

Keyboard shortcuts

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