Measurement Schema
The Measurement type in github.com/NVIDIA/aicr/pkg/measurement is the
on-wire shape used throughout aicr’s Snapshot → Recipe → Validate → Bundle
pipeline. Snapshots serialize a []*Measurement to YAML/JSON; recipes and
validators consume the same shape. This page is the schema contract — any
external producer (cross-repo Go library, CI tool, custom collector) emitting
Measurements should follow it exactly.
The Go types are documented in pkg/measurement/types.go. This page documents
the conventions on top of the types (which Type appears how often, which
Subtype names mean what, which fields live in Context vs Data).
Top-level structure
Type cardinality
Find-first-by-Type consumers (constraint extractor, recipe validation, diff
indexing) are sound today because every Type appears at most once. When
NetworkTopology becomes multi-instance, the relevant consumer rewrites are
tracked alongside the multi-group enablement work.
Subtype
A Subtype has a name plus up to three payload fields:
A subtype must carry at least one entry in data or items. data and
items are independent and may both be populated.
ItemEntry
Each ItemEntry mirrors a Subtype’s scalar contract: data holds Reading
scalars; context holds string-typed descriptive fields. ItemEntry does
NOT support nested items — the scalar Reading model is preserved.
NetworkTopology shape
TypeNetworkTopology describes one hardware group’s network layout (PFs,
rails, RDMA capabilities, kernel modules, identity). When emitted, the
Measurement MUST follow this layout:
Subtypes
identity— group identity and high-level facts. Strings (machineType, gpuType, linkType, identifier, nodeSelector) live incontext. Numeric facts (pf-count, rail-count) live indata.capabilities— boolean cluster capabilities (sriov, rdma, ib) as scalarReadingvalues indata.pfs— per-PF records asitems. Per-PF descriptive identifiers (PCI address, device ID, PSID, part number, RDMA device name, netdev name, VPD model string, connectedGPU + gpuProximity from preset topology) live incontext; per-PF scalar facts (rail index, NUMA node, traffic class) live indata. Optional fields (model,connectedGPU,gpuProximity) are omitted when unset by l8k.kernel-modules— flat ordered lists of storage and third-party RDMA modules. Keys are dotted with a numeric suffix (storage.0,storage.1,thirdParty.0, …) to preserve order and stay within the scalarReadingmodel. (This is a deliberate exception to the array-via-items pattern: the lists are short, lookup is rare, and the dotted-key form is cheap.)
Field-placement convention
context— values that describe or identify a record: textual, cardinality-low, used for grouping or display. Not constrained to be scalarReadings.data— values that are measured or counted: int / float / bool / short string, addressable by key, comparable in validator constraints.
Constraint paths
The constraints package addresses a single value within a Measurement using:
Selector forms:
Predicate behavior — deterministic single-match resolution:
- LHS is looked up in
ItemEntry.Datafirst (stringified viaReading.String()); falls back toItemEntry.Contextif not found in Data. - Exactly one matching entry is required.
- Zero matches returns
ErrCodeNotFound. - Two or more matches returns
ErrCodeConflict. Predicates that can match more than one entry are a recipe authoring error; pick a more specific field to disambiguate.
Key resolution inside the chosen ItemEntry:
Datais consulted first (returnsReading.String()).Contextis consulted next (returns the string directly).- Missing key returns
ErrCodeNotFound.
Stability contract
pkg/measurement is part of aicr’s public API surface (see
/aicr/integrator-guide/public-api-surface). The Go types AND the schema conventions
documented above are part of the contract. Field-level changes (renames,
type changes, semantic shifts in which fields go in data vs context)
are breaking and require a pseudo-version bump that downstream consumers
(k8s-launch-kit, external CI tools) pin against.
See also
pkg/measurement/types.go— the Go typesdocs/integrator//aicr/integrator-guide/public-api-surface— package stability tiersdocs/integrator//aicr/integrator-guide/recipe-development— how recipes consume Measurement values via constraint paths