packageprops

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: 2 Imported by: 0

Documentation

Overview

Package packageprops is the shared, zero-dependency vocabulary for per-package property declarations (ADR-0080). Each participating package declares a top-level value referencing these types:

package option

import "github.com/stergiotis/boxer/public/packageprops"

// PackageProps records this package's curated properties (ADR-0080).
var PackageProps = packageprops.Props{
	WASMWASI:         packageprops.WASMCompiles,
	WASMJS:           packageprops.WASMCompiles,
	WASMFreestanding: packageprops.WASMCompiles,
}

The declaration is co-located with the package (single source of truth), typed (goto-definition and find-references work — find-references on packageprops.WASMCompiles lists every package in that state), readable at runtime as pkg.PackageProps, and statically harvestable into an overview table by `props harvest`.

Props grows over time (ADR-0080 SD4). Besides the WASM* verdicts it carries a Kind classifying the package's primary role — KindDemo, KindExample, or KindIntegrationTest — for the packages that are not ordinary library code; the zero KindUnspecified asserts nothing. Kind is purely human-curated (no survey computes it), so `props verify` does not reconcile it, though `props generate` seeds the obvious demo/example cases from directory name.

The tooling is the `props` group of the wasmsurvey command, four levels down the CLI:

boxer code analysis golang wasmsurvey props {generate,harvest,drift,verify}

The path is spelled once here because the short form is not runnable; the verbs are named on their own below.

The lifecycle is hybrid (ADR-0080 SD3): `props generate` seeds the declarations from the computed verdict (idempotent-create, never clobbering a curated file), humans then curate them as intent, and `props verify` reconciles declaration against the freshly computed reality and gates regressions in CI.

Two discovery surfaces (registry.go): generated files Register their Props from init, so packageprops.All() enumerates the packages compiled into the running binary; `props harvest --tracked --emit go` emits a static Table of the whole repo for embedding into a binary that does not link everything. `props drift` gates that Table against the tracked declarations, so the two surfaces cannot silently disagree — they did, by 63 packages, until it was added.

This package depends only on the standard library (sync, sort) and on no boxer or external package (ADR-0080 SD2): every package imports it, so a boxer/external dependency would become universal and could create cycles or taint the very wasm verdicts it records. It mirrors public/compiletimeflags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(importPath string, p Props)

Register records a package's Props under its import path. Generated package_props.go files call it from init, so it normally runs single-threaded at startup; the lock keeps a late runtime Register safe against a concurrent All(). Last write wins for a given path.

Types

type Entry

type Entry struct {
	ImportPath string
	Props      Props
}

Entry is one package's declared Props keyed by its import path. It is both the registry's record type and the element type of the harvested Table.

type Kind added in v0.0.12

type Kind uint8

Kind classifies a package by its primary role — what the package *is* — when it is not ordinary library/production code (ADR-0080 §SD4, 2026-07-02 Update). Unlike the WASM* verdicts there is no survey that computes it, so it is human-curated and `props verify` does not reconcile it. The zero value is KindUnspecified, so an unset field asserts nothing — the common case being ordinary library code that carries no special role.

const (
	KindUnspecified     Kind = iota // ordinary library code / not classified
	KindDemo                        // a runnable demonstration (e.g. a keelson demo scene)
	KindExample                     // illustrative usage code, not part of the shipped surface
	KindIntegrationTest             // a package whose primary role is integration testing
)

func (Kind) String added in v0.0.12

func (k Kind) String() (str string)

String renders the kind as a stable lowercase token (for harvest tables and diagnostics). KindUnspecified renders "unspecified"; display sites that want a blank cell for the common case should special-case it.

type Props

type Props struct {
	// WASM* record the TinyGo/wasm compile state per target (ADR-0078):
	// wasi (GOOS=wasip1), js (browser), and freestanding wasm-unknown.
	WASMWASI         WASMState
	WASMJS           WASMState
	WASMFreestanding WASMState

	// Kind classifies the package's primary role (demo / example /
	// integration-test) when it is not ordinary library code. Human-curated;
	// the zero value KindUnspecified asserts nothing (ADR-0080 §SD4).
	Kind Kind
}

Props is the curated, co-located property record of a Go package (ADR-0080). It is a plain typed struct — refactor-safe and IDE-navigable — read at runtime as the package's PackageProps value and statically harvestable into an overview table. The zero value asserts nothing. New properties are added as fields over time (purity, determinism, ownership, stability, …); wasm amenability is the first.

func Lookup

func Lookup(importPath string) (p Props, ok bool)

Lookup returns the registered Props for an import path, if present.

type Table

type Table []Entry

Table is a set of Entries — the static harvest output and the All() snapshot.

func All

func All() (t Table)

All returns a snapshot of the registry sorted by import path: the Props of every package whose init has run (i.e. that is linked into this binary).

type WASMState

type WASMState uint8

WASMState is a package's TinyGo/WebAssembly compile state for one target — the verdict computed by the wasmsurvey (ADR-0078) and reconciled against the declaration by `props verify`. The zero value is WASMUnknown, so an unset field asserts nothing.

const (
	WASMUnknown  WASMState = iota // not asserted / not yet determined
	WASMCompiles                  // verified to compile under TinyGo for the target
	WASMBlocked                   // does not compile (a transitive blocker — see the survey for blame)
)

func (WASMState) String

func (s WASMState) String() (str string)

String renders the state as a stable lowercase token (for harvest tables and diagnostics).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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