paramread

package
v1.0.0-alpha.14 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package paramread is the ONE way built-in code reads an operator's `params` object: every runtime decode of a slot's Params blob (or a lookup into an overlay's params map) goes through Decode / DecodeOptional / Get / Read, naming the operator it reads for.

Production behaviour is exactly encoding/json's: Decode is json.Unmarshal. The package exists so the keys an operator READS are observable: while a Recording is active, every call records (category, operator, key) — a struct target contributes every top-level json key it can decode (all of them, whether the blob set them or not), a map lookup the key it looked up. The declared-vs-read gate (TestParamsDeclaredMatchRead, root package) runs the example library under a Recording and holds every recorded key to the operator's manifest Param list, the allowlist strict params decode enforces (internal/descriptor ParamsRefusal) — so a manifest list cannot fall behind what the runtime reads and cause a false refusal. TestParamsReadThroughParamread bans a direct json decode of a slot's `.Params` anywhere else.

Leaf package: stdlib only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Declare

func Declare(cat Category, op string, v any)

Declare records every top-level key the decode target v (a pointer to a struct) accepts, without decoding — for a site that decodes the blob elsewhere or only conditionally.

func Decode

func Decode(cat Category, op string, raw []byte, v any) error

Decode is json.Unmarshal(raw, v) for op's params, recording v's keys.

func DecodeOptional

func DecodeOptional(cat Category, op string, raw []byte, v any) error

DecodeOptional is Decode skipped when raw is empty (an absent params object): v keeps its defaults. The keys are recorded either way.

func DecodeStrict

func DecodeStrict(cat Category, op string, raw []byte, v any) error

DecodeStrict is Decode refusing an unknown key (encoding/json's DisallowUnknownFields), for a reader that already judged its own keys before the manifest allowlist did.

func Get

func Get[V any](cat Category, op string, m map[string]V, key string) (V, bool)

Get looks key up in a decoded params map, recording the read.

func Probe

func Probe(raw []byte, v any) error

Probe is json.Unmarshal(raw, v) WITHOUT recording: a lenient look at a key whose operator decodes (and records) it elsewhere — a planner peeking at params.fit, a default rule reading params.metric. A probe never makes a key valid, so it is not a read the manifest must declare.

func Read

func Read(cat Category, op string, keys ...string)

Read records that the code reading op's params reads keys (a lookup into a decoded params map or a raw-object scan). It is the declaration Get makes for one key.

Types

type Category

type Category string

Category names an operator family, spelled as the manifest's Operator.Category (and "test" / "matrix" / "overlay" for the non-Operator catalogs).

const (
	Aggregator Category = "aggregator"
	Attribute  Category = "attribute"
	Filterer   Category = "filterer"
	Grouper    Category = "grouper"
	Window     Category = "window"
	Feature    Category = "feature"
	Test       Category = "test"
	PostTest   Category = "post_test"
	Matrix     Category = "matrix"
	Overlay    Category = "overlay"
)

The operator families whose slots carry a params object.

type Key

type Key struct {
	Category Category
	Op       string
}

Key identifies one operator.

type Recording

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

Recording collects the keys read while it is active.

func Start

func Start() *Recording

Start begins recording, replacing any active Recording. Test-only: production never starts one, so a read costs one atomic load.

func (*Recording) Stop

func (r *Recording) Stop() map[Key][]string

Stop ends recording (when r is still the active one) and returns the keys read per operator.

Jump to

Keyboard shortcuts

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