decode

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package decode owns immutable, closed persisted-row images for P4 mutations. Provider-specific scanning remains in the P3 read decoder; this package consumes its exact policy values and validates them against the one active schema registry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthoredFields

func AuthoredFields(registry *schema.Registry, before, after Row, authored []policyir.FieldID) ([]policyir.FieldID, error)

AuthoredFields intersects the exact persisted diff with the explicit input inventory. Database-generated, database/read-only, contract read-only, and runtime-updated fields can never be reported as caller-authored changes.

func ChangedFields

func ChangedFields(before, after Row) ([]policyir.FieldID, error)

ChangedFields returns the exact persisted before/after diff, including database-owned changes. Results are sorted by stable field identity.

func EqualCell

func EqualCell(left, right Cell) bool

func EqualRow

func EqualRow(left, right Row) bool

func EqualValue

func EqualValue(left, right policyir.Value) bool

EqualValue is exact logical equality. It deliberately compares floating point bits, byte content, normalized Decimal values, and canonical JSON/list structure without any interface or float64 JSON conversion.

func ValidateIdentity

func ValidateIdentity(registry *schema.Registry, model policyir.ModelID, identity Identity) error

ValidateIdentity proves a decoded durable identity against the active model and logical field types without requiring a complete row image.

Types

type Cell

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

Cell is one exact persisted scalar. A null cell has no policy value.

func Null

func Null(field policyir.FieldID) Cell

func Value

func Value(field policyir.FieldID, value policyir.Value) Cell

func (Cell) FieldID

func (cell Cell) FieldID() policyir.FieldID

func (Cell) IsNull

func (cell Cell) IsNull() bool

func (Cell) PolicyValue

func (cell Cell) PolicyValue() (policyir.Value, bool)

type Error

type Error struct {
	Model  policyir.ModelID
	Field  policyir.FieldID
	Detail string
	Cause  error
}

Error is a fail-closed persisted-image validation failure.

func (*Error) Error

func (failure *Error) Error() string

func (*Error) Unwrap

func (failure *Error) Unwrap() error

type Identity

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

Identity preserves key-declared component order. It supports scalar and composite primary/unique identities without reducing values to strings.

func ExtractIdentity

func ExtractIdentity(registry *schema.Registry, row Row, key golem.KeyID) (Identity, error)

func ExtractOrderedIdentity

func ExtractOrderedIdentity(registry *schema.Registry, row Row, fields []policyir.FieldID) (Identity, error)

ExtractOrderedIdentity resolves the exact key whose declared component order matches a FactRequirement identity inventory, then extracts only those components from a possibly partial row.

func NewIdentity

func NewIdentity(key golem.KeyID, components []IdentityComponent) (Identity, error)

func PrimaryIdentity

func PrimaryIdentity(registry *schema.Registry, row Row) (Identity, error)

func (Identity) Components

func (identity Identity) Components() []IdentityComponent

func (Identity) KeyID

func (identity Identity) KeyID() golem.KeyID

type IdentityComponent

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

func IdentityNull

func IdentityNull(field policyir.FieldID) (IdentityComponent, error)

func IdentityValue

func IdentityValue(field policyir.FieldID, value policyir.Value) (IdentityComponent, error)

func (IdentityComponent) FieldID

func (component IdentityComponent) FieldID() policyir.FieldID

func (IdentityComponent) IsNull

func (component IdentityComponent) IsNull() bool

func (IdentityComponent) PolicyValue

func (component IdentityComponent) PolicyValue() (policyir.Value, bool)

type IdentityTransition

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

func PrimaryIdentityTransition

func PrimaryIdentityTransition(registry *schema.Registry, before, after *Row) (IdentityTransition, error)

PrimaryIdentityTransition retains both sides of an identity-changing update. Exactly one side may be nil for create/delete.

func (IdentityTransition) After

func (transition IdentityTransition) After() (Identity, bool)

func (IdentityTransition) Before

func (transition IdentityTransition) Before() (Identity, bool)

type Row

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

Row is a closed persisted scalar image sorted by stable field identity. It may be partial: the owning ImageRequirements define which fields an operation must project. Relation handles never belong to a row image.

func FromReadCells

func FromReadCells(registry *schema.Registry, model policyir.ModelID, cells []readdecode.Cell) (Row, error)

FromReadCells is the intended runtime seam. SQL RETURNING or a locked row is projected through the ordinary P3 decoder, then frozen here as a complete P4 image. Completeness is defined by the caller's ImageRequirements. No provider return type is interpreted in this package.

func NewCompleteRow

func NewCompleteRow(registry *schema.Registry, model policyir.ModelID, cells []Cell) (Row, error)

NewCompleteRow is the opt-in diagnostic boundary for callers that truly require every persisted scalar field, such as bounded batch capture.

func NewRow

func NewRow(registry *schema.Registry, modelID policyir.ModelID, cells []Cell) (Row, error)

NewRow validates a closed provider-decoded persisted image. Values are normalized only at the declared temporal precision; every other logical value stays exact.

func (Row) Cell

func (row Row) Cell(field policyir.FieldID) (Cell, bool)

func (Row) Cells

func (row Row) Cells() []Cell

func (Row) IsComplete

func (row Row) IsComplete(registry *schema.Registry) (bool, error)

func (Row) ModelID

func (row Row) ModelID() policyir.ModelID

func (Row) RequireFields

func (row Row) RequireFields(fields []policyir.FieldID) error

RequireFields proves that an operation's explicit field inventory is present in this partial image. Extra fields are allowed because a single SQL image may satisfy several authorization/hook/result requirements.

func (Row) Select

func (row Row) Select(registry *schema.Registry, fields []policyir.FieldID) (Row, error)

Select returns an exact partial image containing only the requested fields.

Jump to

Keyboard shortcuts

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