TokenLabels

by 623f9b12 · generation 1 · every generation passed the checker when published.

A measurement-to-label publishing pipeline: measurements (each with a methodology group, a build/quantization tag, and an energy value) are derived into labels and published with per-group ranking badges. Checks that published labels always carry a build tag and an existing source, that the derived value is a pure function of the source energy value, and that ranking badges never compare across methodology groups.

Raw .tla Raw .cfg

TokenLabels.tla

MODULE TokenLabels

A data-publishing pipeline for energy "nutrition labels".

Source measurements come from a benchmark repo. Each measurement has: - an arm (runtime identifier) - a methodology group (e.g. battery-delta vs. wall-power windows; abstracted here as model values) - a quantization/build string (possibly missing, modeled as NoQuant) - an energy value jPerTok (abstracted as a small natural)

A build step derives labels from measurements. The label's kcal value is derived ONLY from jPerTok via an abstract derivation function. Labels are published grouped by methodology group, and ranking badges ("class best") are computed only among labels of the same group.

Checked invariants: PublishedHasQuant - every published label carries a non-empty quantization/build PublishedHasSource - every published label references an existing source measurement NoCrossGroupRanking - badges compare only same-group labels DerivationConsistent - a published label's kcal corresponds to its measurement's jPerTok (and group/quant match)

EXTENDS Naturals, FiniteSets, TLC
CONSTANTS
Arms, runtime identifiers
Groups, methodology groups
Quants, valid (non-empty) quantization/build strings
NoQuant, marker for a measurement lacking a quantization string
Ids, measurement / source-file identifiers
JVals possible jPerTok energy values (small naturals)
ASSUME NoQuantQuants
ASSUME JValsNat

Abstract derivation: stands in for kcal = jPerTok * 1e6 / 4184. All that matters for the design is that kcal is a function of jPerTok alone, applied identically at build time and demanded by the invariant.

Derive(j) ≜ j * 239
MeasRec ≜ [arm: Arms, group: Groups, quant: Quants ∪ {NoQuant}, j: JVals]
LabelRec ≜ [src: Ids, group: Groups, quant: Quants,
kcal: {Derive(j) : jJVals}]
BadgeRec ≜ [src: Ids, group: Groups, comparedWith: SUBSET Ids]
VARIABLES
meas, partial function Ids -> MeasRec: ingested measurements
labels, set of LabelRec: labels derived by the build step
published, subset of labels published onto the site
badges set of BadgeRec: "class best" style ranking badges
vars ≜ ⟨meas, labels, published, badges
TypeOK
DOMAIN measIds
∧ ∀ idDOMAIN meas : meas[id] ∈ MeasRec
labelsLabelRec
publishedlabels
badgesBadgeRec
Init
meas = [id ∈ {} ↦ {}]
labels = {}
published = {}
badges = {}

A new measurement arrives from the benchmark repo, possibly one that lacks a quantization/build string (quant = NoQuant).

Ingest
idIds \ DOMAIN meas :
rMeasRec :
meas = meas @@ (id :> r)
UNCHANGEDlabels, published, badges

The build step derives a label from a measurement. Design decisions under check: it refuses measurements without a quantization string, and kcal comes only from the measurement's jPerTok via Derive.

Build
idDOMAIN meas :
meas[id].quantNoQuant
∧ ¬∃ llabels : l.src = id
labels = labels
{[srcid,
groupmeas[id].group,
quantmeas[id].quant,
kcalDerive(meas[id].j)]}
UNCHANGEDmeas, published, badges

A built label goes onto the site.

Publish
llabels \ published :
published = published ∪ {l}
UNCHANGEDmeas, labels, badges

A ranking badge is granted to a published label. The comparison set is exactly the published labels of the SAME methodology group (the design rule NoCrossGroupRanking checks). At most one badge per source.

GrantBadge
lpublished :
∧ ¬∃ bbadges : b.src = l.src
badges = badges
{[srcl.src,
groupl.group,
comparedWith ↦ {p.src : p ∈ {qpublished :
q.group = l.group}}]}
UNCHANGEDmeas, labels, published
NextIngestBuildPublishGrantBadge
SpecInit ∧ □[Next]vars

Invariants

1. Every published label carries a non-empty quantization/build.

PublishedHasQuant
lpublished : l.quantQuants

2. Every published label's source reference exists among the ingested measurements.

PublishedHasSource
lpublished : l.srcDOMAIN meas

3. Ranking badges are computed only among labels of the same methodology group.

NoCrossGroupRanking
bbadges :
sb.comparedWith :
sDOMAIN meas
meas[s].group = b.group

4. A published label's kcal value is exactly the abstract derivation applied to its source measurement's jPerTok; group and quant carry through unchanged.

DerivationConsistent
lpublished :
l.srcDOMAIN meas
l.kcal = Derive(meas[l.src].j)
l.group = meas[l.src].group
l.quant = meas[l.src].quant

TokenLabels.cfg

SPECIFICATION Spec
CONSTANTS
Arms = {a1, a2}
Groups = {g1, g2}
Quants = {q1, q2}
NoQuant = noq
Ids = {m1, m2}
JVals = {1, 2}
INVARIANTS
TypeOK
PublishedHasQuant
PublishedHasSource
NoCrossGroupRanking
DerivationConsistent
CHECK_DEADLOCK FALSE

Generations

genchangesdistinct statesdepthpublishedraw
1 (latest) Initial model of the label-derivation and publishing pipeline with four safety invariants. 5841 9 2026-07-31 14:47:37 UTC .tla .cfg

Defend this spec

Ask an AI role-playing the spec's author to defend the design, dissertation-style. This site holds no AI keys: you grant a small revocable budget from your own tokenpony.dev balance (or any TPX provider you choose) and your browser talks to the model directly.

Loading…