Documentation
¶
Overview ¶
Package provenance tracks exact native-constraint/refinement correspondences. It is not a replacement for native schema structure or payload validation.
Index ¶
- func Fold[R any](s Status, cs StatusCases[R]) R
- func LowerAvroConstraint(program *language.Program, constraint Constraint) (string, error)
- func LowerDependentRequiredConstraint(program *language.Program, constraint Constraint) (string, error)
- func StatusEqual(a, b Status) bool
- func StatusEqualWith(a, b Status, ov StatusEqOverrides) bool
- func StatusName(status Status) string
- type Avro
- type Changed
- type Constraint
- type Error
- type Finding
- type JSONSchema
- type OpenAPI
- func (o *OpenAPI) AuditResourceSource(resource, source string) ([]Finding, error)
- func (o *OpenAPI) AuditSource(source string) ([]Finding, error)
- func (o *OpenAPI) ConstraintSource() string
- func (o *OpenAPI) Constraints() []Constraint
- func (o *OpenAPI) RecoverNative(name, source string) (string, error)
- func (o *OpenAPI) RecoverResourceNative(resource, name, source string) (string, error)
- func (o *OpenAPI) ResourceConstraintSource(resource string) string
- func (o *OpenAPI) ResourceConstraints(resource string) []Constraint
- func (o *OpenAPI) Resources() []OpenAPIResource
- type OpenAPIOptions
- type OpenAPIResource
- type OpenAPIResourceRole
- type OpenAPISchemaRoot
- type OpenAPISyntax
- type Removed
- type Status
- type StatusCases
- type StatusEqOverrides
- type Unchanged
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 ¶
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 ¶
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) ConstraintSource ¶
func (*Avro) Constraints ¶
func (a *Avro) Constraints() []Constraint
func (*Avro) ForResource ¶
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.
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 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 (*OpenAPI) ConstraintSource ¶
func (*OpenAPI) Constraints ¶
func (o *OpenAPI) Constraints() []Constraint
func (*OpenAPI) RecoverNative ¶
func (*OpenAPI) RecoverResourceNative ¶
func (*OpenAPI) ResourceConstraintSource ¶
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 ¶
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 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.