kindcheck

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package kindcheck answers "do these facts-CBOR bytes claim kind K?" for hosts that must validate a payload at a boundary without importing the payload's Go type (ADR-0135 §SD1: the window host refuses a malformed or mistargeted launch config before the target app sees it).

The boxer.facts sparse-CBOR wire carries no kind marker — a row's kind is implied by which vocabulary membership ids populate its tagged sections, and only the kind's generated codec knows that set. So the check cannot be a header peek; instead each codec module registers a probe minted from its own generated decoder, and Check runs the claimed kind's probe against the bytes. A probe failure (garbage, truncation, or a payload whose memberships belong to another kind) refuses the claim.

Registration is one hand-written init line per module (see launchrequest/register.go); the generated .out.go files are untouched. Only kinds that cross a validated boundary need to register — the registry is deliberately not a census of the codec corpus.

Index

Constants

This section is empty.

Variables

View Source
var PackageProps = packageprops.Props{
	WASMWASI:         packageprops.WASMBlocked,
	WASMJS:           packageprops.WASMBlocked,
	WASMFreestanding: packageprops.WASMBlocked,
}

PackageProps records this package's curated properties (ADR-0080). Seeded by `boxer code analysis golang wasmsurvey props generate`; curate by hand. The same group's `props verify` reconciles it.

Functions

func Check

func Check(kind string, b []byte) (err error)

Check verifies that b decodes as the claimed kind. An unregistered kind is refused — the caller cannot distinguish "unknown kind" from "kind with no codec", and both must fail closed.

func PeekKind

func PeekKind(b []byte) (kind string, err error)

PeekKind identifies which registered kind b decodes as by probing all registrations. Exactly one probe must accept: zero acceptances refuse the bytes (garbage, truncation, or an unregistered kind), and more than one is reported as ambiguous rather than resolved by iteration order. Diagnostic / test helper; boundary code that already holds a claimed kind should call Check instead.

func Register

func Register(kind string, probe ProbeFunc)

Register installs the probe for a kind name (the DTO's `kind:` tag). Intended for package-init use from the codec module that owns the kind. Registering a nil probe or re-registering an existing kind panics — both indicate a wiring bug worth failing loudly at startup.

Types

type ProbeFunc

type ProbeFunc func(b []byte) (err error)

ProbeFunc reports whether b decodes as the registering kind's DTO. Implementations are typically one line over the module's generated buscodec decoder. A nil return accepts the bytes.

Jump to

Keyboard shortcuts

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