Decision Rule API

Req 5's decision procedure over the three panels of roadmap D8, and the records that carry it (roadmap Stage 4); and the economic artifact's decision over the two growth panels, against the reference covariates+ancestors (Req 24).

Decision statistics

Each panel's per-unit scores and its decision statistic (D10).

Scores are long: one row per panel, statistic and item, with the item's resampling unit.

  • Outcome panel. An item is a validation query and its unit is its true code. Every Req 3 metric is a statistic; the decision statistic is mrr, the per-query reciprocal rank that D6 already selects checkpoints on.
  • Regressor regimes. An item is a level-6 code in a feature year and its unit is its four-digit group. Every Req 2 comparator is a statistic, valued at the row's squared error averaged over the read's repeats, so a row counts once however many repeats scored it. The decision statistic is the mean squared error of covariates+embedding.

outcome_scores(per_query)

The outcome panel's scores from DecodingResult.per_query: every Req 3 metric per query.

Raises:

Type Description
ValueError

If a query id repeats.

panel_statistic(scores, panel, statistic)

A statistic's mean over its items: one seed's value on every unit.

regressor_scores(predictions, repeats, panels=REGRESSOR_PANELS)

Both regimes' scores from level-6 validation predictions: each comparator's squared error per row (a code in a feature year), averaged over the row's repeats.

Parameters:

Name Type Description Default
predictions DataFrame

The reads' predictions (panels.regressor.PREDICTION_COLUMNS).

required
repeats int

The validation repeats each row was scored under.

required
panels Sequence[str]

The read names the predictions may carry: D8's regressor regimes, or the growth panels of the economic decision (Req 24).

REGRESSOR_PANELS

Raises:

Type Description
ValueError

If a row is not a level-6 validation row of panels, or a row does not have exactly repeats predictions, one per repeat, under every comparator of its panel.

seed_scores(per_query, predictions, repeats)

One seed's scores on all three panels.

Raises:

Type Description
ValueError

If a panel has no scores.

statistic_means(scores)

Every statistic's mean over its items, by panel.

statistic_values(scores, panel, statistic)

One statistic's items (unit, item, feature_year, value) on one panel.

Raises:

Type Description
ValueError

If the scores hold no such items.

Paired resampling

The paired two-stage bootstrap (Req 5: "both arms are scored on the same resample of the evaluation unit, with seeds nested within the resample").

Each replicate draws the panel's units with replacement, one draw shared by every arm, and then, inside it, each arm's seeds with replacement, a draw of the arm's own. The replicate's statistic is the mean over the drawn seeds of the item-weighted mean over the drawn units:

sum_s m_s (C . S_s) / (n_seeds (C . N))

with C the unit counts, m the seed counts, S_s seed s's per-unit sums and N the items per unit. Unit counts come from the generator seeded [bootstrap_seed, stream(panel)] and an arm's seed counts from [bootstrap_seed, stream(panel), stream(arm)], so an arm's replicates are the same in every comparison it enters.

PanelItems dataclass

One statistic's items in a fixed order (by unit, then item), with each item's unit.

sizes property

Items per unit, as floats.

from_values(frame) classmethod

The items of a frame with unit and item columns.

Raises:

Type Description
ValueError

If an item repeats.

sums(values)

Per-unit sums of (seeds, items) values: (seeds, units).

values(frame)

The frame's value column in this order.

Raises:

Type Description
ValueError

If the frame holds other items, or puts an item in another unit: paired arms must be scored on the same items (Req 5).

percentile_interval(replicates, level)

The two-sided percentile interval at level.

point_statistic(sums, sizes)

The mean over seeds of each seed's statistic on every unit.

replicate_statistics(sums, sizes, units, seeds)

Each replicate's statistic.

Parameters:

Name Type Description Default
sums ndarray

Per-seed unit sums, (n_seeds, n_units).

required
sizes ndarray

Items per unit, (n_units,).

required
units ndarray

Unit counts, (replicates, n_units).

required
seeds ndarray

Seed counts, (replicates, n_seeds).

required

seed_draws(panel, arm, n_seeds, replicates, bootstrap_seed)

One arm's seed counts per replicate, (replicates, n_seeds).

stream(name)

A generator stream for a name: the first 16 hex digits of its sha256, as an integer.

unit_draws(panel, n_units, replicates, bootstrap_seed)

Unit counts per replicate, (replicates, n_units), shared by every arm on the panel.

The rule

Req 5's rule on paired resamples, over a decision's panels.

  • Non-inferior on a panel: the lower bound of the 95 % interval on Δ exceeds −δ.
  • Superior on a panel: the interval at 1 − 0.05/n lies above zero, for a decision over n panels, each of which gets an even share of the 5 % error rate (Req 24). D8's three panels read 98⅓ %, which supersedes the 97.5 % that Req 5 names for two; the economic decision's two growth panels read 97.5 %.
  • Adopted: non-inferior on every panel and superior on at least one.
  • Several arms: the survivors are the arms no other arm is adopted over; when every arm is, dominance cycles and the tie order picks among all of them. The pairwise comparisons are not corrected for multiplicity: the tie order toward the simpler arm is the guard (Req 5).
  • Tie order: fewer components, then lower dimension, then non-hyperbolic geometry, then the higher held-out gain over covariates+ancestors (D11): on regressor_heldout for D8's decision, on growth_heldout for the economic decision, where it is the reference (Req 24).

TieUnresolvedError

Bases: RuntimeError

Two candidate arms tie on every key of the tie order.

compare(a, b, panels)

A against B on every panel.

compare_panel(panel, delta, replicates, margin, *, superiority)

One panel's verdict for A against B.

Parameters:

Name Type Description Default
panel str

The panel's name.

required
delta float

The point estimate of Δ, positive when it favours A.

required
replicates ndarray

Δ on each paired resample, oriented the same way.

required
margin float

The panel's δ.

required
superiority float

The superiority interval's level (superiority_level).

required

non_dominated(arms, comparisons)

The arms no other arm is adopted over, and whether dominance cycled.

Returns:

Type Description
List[str]

(survivors, cycle): when every arm is dominated, cycle is true and every arm

bool

survives, for the tie order to pick among (Req 5).

superiority_level(panels)

The superiority interval's level for a decision over panels panels: 1 − 0.05/n (Req 24).

Raises:

Type Description
ValueError

If panels is below 1.

tie_order(specs, heldout_gain)

The arms from the one that stands first.

Raises:

Type Description
TieUnresolvedError

If two arms tie on every key.

Records and artifacts

The records of Req 5's decisions (Verification "Decision records"; roadmap Stage 4).

Three kinds, each one JSON file:

  • Arm record. One configuration's seed sweep: its spec, the text-only table it was paired with and that table's provenance (D9), the panels it read, and per seed the encoder checkpoint, the 2,125-code table, the stored scores and the selection-log records of the run's reads (the log itself is gitignored and dies with its worktree or Lambda instance). A trained seed also carries the monitor reads that selected its checkpoint (spec 4.4).
  • Margin record. Each panel's δ, a stated multiple of a reference arm's across-seed standard deviation, fixed before any other arm's first read.
  • Decision record. Its arms and margins, every paired comparison with its 95 % non-inferiority and 98⅓ % superiority intervals (D8), the non-dominated set, the tie order, the chosen arm, and the reported statistics.

The economic decision (Req 24) has kinds of its own:

  • Relative margin record. Each growth panel's δ, r times the reference comparator's validation MSE, from a margin read that reads no candidate.
  • Economic arm record. A deterministic candidate's single replicate: its table and that table's provenance (Req 23), read once on each growth panel, with no checkpoint or monitor reads.
  • Economic decision record. Its candidates and margins, each candidate's comparison with the reference covariates+ancestors with its 95 % non-inferiority and 97.5 % superiority intervals, the candidates adopted over the reference, the non-dominated set and tie order among them, and the chosen candidate, or none when the reference stands.

Artifact references are paths relative to an ArtifactStore root with their sha256, so a record names exactly the bytes it was computed from.

ArmRecord

Bases: _Record

One configuration's seed sweep (decision.sweep.run_seed_sweep).

ArmReport

Bases: _Record

What a decision reports for an arm besides the rule's statistics (D10).

Attributes:

Name Type Description
statistics Dict[str, float]

Each panel's decision statistic.

outcome_metrics Dict[str, float]

Every Req 3 metric on the outcome panel.

comparator_mse Dict[str, Dict[str, float]]

Each regime's mean squared error for every Req 2 comparator.

gain Dict[str, Estimate]

Each regime's gain over its sparse encoding (Req 1): the sparse comparator's mean squared error minus covariates+embedding's, on the decision's draws.

heldout_by_feature_year Dict[str, Dict[str, float]]

The held-out regime by feature year: covariates+embedding, covariates+ancestors and the gain.

ArmSpec

Bases: _Record

A configuration, with what the tie order and D9 read.

Attributes:

Name Type Description
components int

Stages or post-processing steps: Req 5's "fewer components".

backbone, (backbone_revision, descriptions_sha256, summaries_sha256, max_length)

What the arm's encoder reads, which its text-only table and each seed's table must match (D9). summaries_sha256 is null for a backbone with no pinned summaries.

settings Dict[str, Any]

The configuration's own settings, recorded as given.

ArtifactRef

Bases: _Record

A stored file: its path relative to the store root, its sha256 and its size.

Comparison

Bases: _Record

A against B: adopted when non-inferior on every panel and superior on at least one.

DecisionRecord

Bases: _Record

A Req 5 decision over two or more arms.

DecisionSettings

Bases: _Record

How the decision resampled and which intervals it read.

EconomicArmRecord

Bases: _Record

An economic candidate's reads of the growth panels (decision.economic).

Attributes:

Name Type Description
spec ArmSpec

The candidate, with what the tie order and D9 read.

text_only TextOnlyRef

The text-only table its reads scored as covariates+text_only (D9).

store str

The artifact store's root.

panels GrowthPanelSet

The growth panel it read.

environment ReadEnvironment

Where it was read.

runs List[EconomicRun]

Its replicates: one, for a deterministic candidate (Req 24).

EconomicDecisionRecord

Bases: _Record

The economic decision (Req 24): each candidate against the reference on both growth panels, and Req 5's rule among the candidates adopted over it.

Attributes:

Name Type Description
reference str

The reference comparator (U9).

comparisons List[Comparison]

Each candidate against the reference, then each eligible candidate against each other.

eligible List[str]

The candidates adopted over the reference.

non_dominated List[str]

The eligible candidates no eligible candidate is adopted over.

cycle bool

Whether dominance among the eligible cycled.

tie_order List[str]

The non-dominated candidates, from the one that stands first.

heldout_gain Dict[str, float]

Each candidate's held-out gain over the reference: the reference's growth_heldout MSE minus the candidate's (D11).

chosen Optional[str]

The candidate whose table is the economic deliverable; None when no candidate is eligible, and the reference stands.

EconomicDecisionSettings

Bases: _Record

How the economic decision resampled and which intervals it read.

EconomicReport

Bases: _Record

What the economic decision reports for a candidate besides the rule's statistics.

Attributes:

Name Type Description
statistics Dict[str, float]

Each growth panel's decision statistic, covariates+embedding's MSE.

comparator_mse Dict[str, Dict[str, float]]

Each growth panel's MSE for every comparator its read scored, one-hot included where the seen regime scores it (Req 24).

EconomicRun

Bases: _Record

One replicate of an economic candidate: its table, read once on each growth panel.

A deterministic candidate is a single replicate (Req 24), so a run has no seed, and no field for a checkpoint or monitor reads: an imported run that names one does not load.

Attributes:

Name Type Description
seed Optional[StrictInt]

None: a deterministic candidate has no seed.

run_id str

Names the run in its selection-log records.

table TableRef

The candidate's 2,125-code table, in the export form.

provenance TableProvenance

The table's provenance.

scores ArtifactRef

Both growth panels' per-row scores (decision.scores.SCORE_COLUMNS).

predictions ArtifactRef

Both growth panels' level-6 validation predictions.

statistics Dict[str, float]

Each growth panel's decision statistic.

log_records List[Dict[str, Any]]

The selection-log records of the run's reads.

Estimate

Bases: _Record

A point estimate with its 95 % percentile interval.

GrowthPanelSet

Bases: _Record

The growth panel an economic read scored (Req 21), which every read of a decision shares.

Attributes:

Name Type Description
regressor str

The held-out draw (RegressorPanel.fingerprint).

regressor_data str

Its rows at the decision level (RegressorPanel.data_fingerprint).

fit_settings Dict[str, Any]

The panel's tuning and resampling settings.

MarginRecord

Bases: _Record

Each panel's δ, fixed from a reference arm before any other arm's first read (Req 5).

margin(panel)

The panel's δ.

Raises:

Type Description
ValueError

If the record holds no δ for the panel.

PanelComparison

Bases: _Record

Δ on one panel, oriented so that a positive value favours A, with both intervals.

PanelMargin

Bases: _Record

One panel's δ: the multiple times the reference's across-seed standard deviation.

PanelSet

Bases: _Record

The panels a run read; every arm of a decision must share them (Req 5's pairing).

A split's fingerprint is the name the selection log gives it, and it does not pin the data a read scored, so each panel is named twice.

Attributes:

Name Type Description
outcome str

The outcome panel's role assignment (OutcomePanel.fingerprint).

outcome_data str

Its validation queries, text included, and its candidates (OutcomePanel.data_fingerprint).

regressor str

The regressor panel's held-out draw (RegressorPanel.fingerprint).

regressor_data str

Its rows at the decision level (RegressorPanel.data_fingerprint).

fit_settings Dict[str, Any]

The regressor panel's tuning and resampling settings.

ReadEnvironment

Bases: _Record

Where a growth read ran. Decisions pair reads only on bit-identical rows and fits, so every candidate read of an economic decision runs where its margin read ran (Req 24).

Attributes:

Name Type Description
platform str

platform.platform().

python str

platform.python_version().

lock_sha256 str

The sha256 of the uv.lock the read ran under.

ReferenceRead

Bases: _Record

The margin read (Req 24): each growth panel's validation split at the decision level, scored by the comparators that read no candidate.

Attributes:

Name Type Description
run_id str

Names the read in its selection-log records.

panels GrowthPanelSet

The growth panel it read.

predictions ArtifactRef

Both regimes' level-6 validation predictions.

scores ArtifactRef

Their per-row scores (decision.scores.SCORE_COLUMNS).

log_records List[Dict[str, Any]]

The selection-log records of the read, one per growth panel.

environment ReadEnvironment

Where the read ran.

RelativeMargin

Bases: _Record

One growth panel's δ: r times the reference comparator's validation MSE (Req 24).

RelativeMarginRecord

Bases: _Record

Each growth panel's δ, fixed from the margin read before any candidate is read (Req 24).

Attributes:

Name Type Description
r float

Each δ as a multiple of the reference's MSE (U13).

reference str

The reference comparator, which reads no candidate (U9).

read ReferenceRead

The margin read the MSEs come from.

margin(panel)

The panel's δ.

Raises:

Type Description
ValueError

If the record holds no δ for the panel.

SeedRun

Bases: _Record

One seed of an arm.

A trained seed names its training run and its checkpoint's epoch, and carries the monitor reads that selected the checkpoint (spec 4.4). A seed from a runner that trains nothing has none of the three.

Attributes:

Name Type Description
scores ArtifactRef

The seed's scores on all three panels (decision.scores.SCORE_COLUMNS).

decoding ArtifactRef

DecodingResult.per_query of the outcome read.

predictions ArtifactRef

Both regimes' level-6 validation predictions.

statistics Dict[str, float]

Each panel's decision statistic on every unit.

log_records List[Dict[str, Any]]

The selection-log records of this run's reads.

training_run Optional[str]

The id of the training run the checkpoint is from, which its checkpoints save and its monitor reads name.

checkpoint_epoch Optional[StrictInt]

The checkpoint's epoch: the earliest with the highest monitor MRR.

monitor_records List[Dict[str, Any]]

The training run's monitor_reads.jsonl records, in the file's order, each {'mrr': …, 'read': …}: an epoch's MRR, and its read as the selection log appended it. The checks read each record's epoch, never its position.

TableProvenance

Bases: _Record

A candidate table's provenance, as its builder wrote it beside the table (Req 23).

Attributes:

Name Type Description
file ArtifactRef

The stored provenance file.

content Dict[str, Any]

Its JSON object, verbatim: what the table was built from.

TableRef

Bases: ArtifactRef

A stored code table, with the matrix_fingerprint the selection log names it by.

TextOnlyRef

Bases: _Record

An arm's text-only table and its provenance, with the provenance fields D9 checks.

read_record(path, kind)

Read and validate a record of the given kind.

write_record(record, path)

Write a record as indented JSON, once.

The file is created exclusively, so a writer racing for the same path fails instead of overwriting it, and a write that fails removes its file, which would otherwise block the path. A process killed mid-write can still leave a partial file.

Raises:

Type Description
FileExistsError

If the path exists.

The content-addressed store behind decision records' artifact references (roadmap Stage 4).

A file is copied to objects/<sha[:2]>/<sha>/<name> under the store root, and its reference is that relative path with its sha256 and size. The store never deletes or overwrites: an object is written once and verified again on every read. Records need these files until Stage 12, so the root belongs outside any worktree (removing a worktree deletes its ignored files), and a Lambda instance's store must be copied off before the instance terminates (specs/lambda-remote-workflow.md).

ArtifactStore

Immutable, content-addressed files under one root.

The root is made absolute, so a record names the same store from any working directory, and no reference may lead out of it, whether through .., an absolute path or a symlink.

candidate_provenance(table, provenance)

A stored candidate table's provenance, read from the store.

Raises:

Type Description
FileNotFoundError

If either file is not in the store.

ValueError

If either file changed since it was stored, or as check_provenance.

put(path)

Copy a file into the store (once per content and name) and return its reference.

Raises:

Type Description
FileNotFoundError

If the file does not exist.

ValueError

If the file changes while it is copied, or the stored copy does not hash to the file's sha256.

put_candidate(table_path)

Store an economic candidate's code table (the export form) and the provenance beside it, once the provenance is checked to describe the table (Req 23).

Raises:

Type Description
FileNotFoundError

If the provenance is missing.

ValueError

As check_provenance, before anything is stored, or if either file changes while it is stored.

put_frame(frame, name)

Store a frame as a parquet file named name.

Raises:

Type Description
ValueError

If name is not a plain file name.

put_table(path)

Store an arm's code table (the export form) with its matrix_fingerprint.

put_text_only(table_path)

Store a text-only table and the provenance beside it (tools text-only-table), once the provenance is checked to describe the table.

Raises:

Type Description
FileNotFoundError

If the provenance is missing.

ValueError

As provenance_fields, before anything is stored, or if either file changes while it is stored.

read_frame(reference)

A stored parquet file, verified.

resolve(reference)

The stored file, verified.

Raises:

Type Description
FileNotFoundError

If the store has no such file.

ValueError

If the reference leads out of the store, or the file no longer hashes to the reference's sha256.

text_only(table, provenance)

A stored text-only table's reference, with the fields D9 checks read from its stored provenance.

Raises:

Type Description
FileNotFoundError

If either file is not in the store.

ValueError

If either file changed since it was stored, or as provenance_fields.

check_provenance(provenance, table_sha256, matrix_fingerprint, name)

Require a table's provenance to describe the table.

Parameters:

Name Type Description Default
provenance Any

The provenance's JSON content.

required
table_sha256 str

The table's sha256, which the provenance must name.

required
matrix_fingerprint str

The table's matrix_fingerprint, which the provenance must name if it names one.

required
name str

Names the provenance in an error.

required

Raises:

Type Description
ValueError

If the provenance is not a JSON object, describes another file or names another matrix_fingerprint.

provenance_fields(provenance, table_sha256, matrix_fingerprint, name)

The fields D9 checks, from a table's provenance that describes the table.

A text-only table's provenance (tools text-only-table) and an exported table's (tools export-table) both carry them.

Parameters:

Name Type Description Default
provenance Mapping[str, Any]

The provenance's JSON content.

required
table_sha256 str

The table's sha256.

required
matrix_fingerprint str

The table's matrix_fingerprint.

required
name str

Names the provenance in an error.

required

Raises:

Type Description
ValueError

As check_provenance, or if the provenance lacks a field D9 reads.

Margins and decisions

Margins from a reference arm, and a decision over arms (Req 5; D8, D10, D11).

Before any number is computed, every arm is checked:

  • it has at least min_seeds seeds, each read once on each of the three panels;
  • every stored artifact still hashes to its reference;
  • its text-only table's stored provenance matches the arm's backbone, revision, descriptions, summaries and window (D9);
  • each run's log records are validation reads that name the run, its table and its text-only table by the fingerprints the store recorded; its outcome read decodes by the distance of the arm's geometry, and its regressor reads name the arm's dimension (Req 12);
  • a trained run's monitor records are its training run's reads of the outcome panel's validation split, under the distance of the arm's geometry, no epoch twice, and its checkpoint is from the earliest epoch with the highest MRR (spec 4.4); a run with no training run has neither monitor records nor a checkpoint epoch;
  • all arms read the same panels, with the same data on them and the same fit settings, so Δ pairs item for item.

A decision also requires the margins to hold one δ per panel, for its decision statistic, and every run other than the margin record's own reference runs to have read nothing, its monitor reads included, before the margins were fixed. Every read's time, and the margins', must name its timezone.

check_arm(arm, store, min_seeds)

Require an arm record to be complete, intact and read as the decision reads it.

Raises:

Type Description
ValueError

If min_seeds is below Req 5's floor of MIN_SEEDS, or on the first problem found.

check_margins(margins)

Require the margins to hold one δ per panel, for the panel's decision statistic (D10).

Raises:

Type Description
ValueError

If a panel has no δ or several, a δ is for another statistic, or the margins name a panel no decision reads.

check_margins_first(arms, fixed_at, *, exempt=())

Require every run but the exempt ones to read after the margins were fixed at fixed_at: its decision reads and, for a trained run, the monitor reads that selected its checkpoint. arms are arm records or economic arm records.

Run it after check_arm, which requires each monitor record to name its epoch.

Raises:

Type Description
ValueError

If fixed_at or a read's time is missing or names no timezone, so that the two cannot be compared, or if a run read before fixed_at.

check_pairing(arms, margins)

Require every arm, and the margins' reference, to have read the same panels, with the same data on them, under the same fit settings.

Raises:

Type Description
ValueError

If two arms share a name, or one read other panels (naming what differs).

check_recorded_text_only(spec, text_only, store)

Require a record's text-only fields to be those of its stored provenance, and that provenance to be the arm's (D9).

Raises:

Type Description
ValueError

If a recorded field differs from the stored provenance, or as check_text_only.

check_seed_distance(spec, seed, distance)

Require a seed's encoder to decode by the distance of the arm's geometry (Req 12).

Parameters:

Name Type Description Default
spec ArmSpec

The arm.

required
seed int

The seed, which names the refusal.

required
distance str

The distance the seed's encoder decodes by.

required

Raises:

Type Description
ValueError

If it is another distance.

check_seed_table(spec, seed, fields)

Require a seed's table to have been exported from what the arm reads (D9).

Parameters:

Name Type Description Default
spec ArmSpec

The arm.

required
seed int

The seed, which names the refusal.

required
fields Mapping[str, Any]

The table's export provenance, as provenance_fields reads it.

required

Raises:

Type Description
ValueError

If the backbone, revision, descriptions sha256, summaries sha256 or window differs from the arm's.

check_text_only(spec, text_only)

Require the text-only table to come from the arm's backbone reading the arm's text (D9).

Raises:

Type Description
ValueError

If the provenance's backbone, revision, descriptions sha256, summaries sha256 or window differs from the arm's.

decide(name, question, arms, margins, store, *, replicates, bootstrap_seed, min_seeds)

Req 5's decision over two or more arms.

Raises:

Type Description
ValueError

If fewer than two arms are given, or a guard fails (module docstring).

TieUnresolvedError

If the tie order cannot separate the surviving arms.

fix_margins(reference, multiple, name, store, *, min_seeds)

Each panel's δ: multiple times the reference arm's across-seed standard deviation of the panel's decision statistic (Req 5).

Raises:

Type Description
ValueError

If the multiple is not positive, the reference fails check_arm, or a panel's statistic does not vary across seeds.

read_time(record, name)

A selection-log record's time: an ISO 8601 string that names its timezone.

Parameters:

Name Type Description Default
record Any

The record, as the selection log appended it.

required
name str

Names the read in a refusal.

required

Raises:

Type Description
ValueError

If the record has no time, or its time is not ISO 8601 or names no timezone.

Seed sweeps

The seed-sweep driver (roadmap Stage 4): run a configuration for N seeds, read each seed once on each of D8's three panels, and keep everything a decision record references.

A runner trains (or loads) one seed of a configuration and returns its encoder checkpoint, its 2,125-code table in the export form and a QueryCodeEncoder; for a trained seed, also its training run, its checkpoint's epoch and the monitor reads that selected it, which the seed's record carries (spec 4.4).

Every read goes through the panels, so it is logged, and it carries the run's id, which is how the arm record picks its runs' records out of the selection log. The checkpoint, the table, the text-only table with its provenance, the scores, the decoding and the predictions go to the artifact store.

ArmRunner

Bases: Protocol

Trains or loads one seed of a configuration.

SeedArtifacts dataclass

What one seed of a configuration produces.

Attributes:

Name Type Description
checkpoint Path

The encoder checkpoint file.

table Path

The 2,125-code table in the export form (tangent coordinates if hyperbolic), with its export provenance beside it.

encoder QueryCodeEncoder

Queries and codes embedded in one space, for the outcome panel.

distance str

The arm's decoding distance (panels.decoding.DISTANCES).

training_run Optional[str]

The id of the training run the checkpoint is from; None for a seed that was not trained.

checkpoint_epoch Optional[int]

The checkpoint's epoch, for a trained seed: the earliest with the highest monitor MRR.

monitor_records Sequence[Dict[str, Any]]

A trained seed's monitor_reads.jsonl records, in the file's order: the reads that selected its checkpoint.

run_seed_sweep(spec, seeds, runner, *, outcome_panel, regressor_panel, text_only_table, store, purpose)

Run a configuration for each seed and read each seed once on each panel's validation split.

Raises:

Type Description
ValueError

If the regressor panel is not in level mode (D8; Req 24); if a seed repeats; if the text-only table, or a seed's table by its export provenance, was not built from the arm's backbone, revision, descriptions, summaries and window (D9); if a seed's encoder does not decode by the distance of the arm's geometry (Req 12); or if a seed's table width is not the arm spec's dimension.

The economic decision

The economic artifact's decision (Req 24; Req 23; Req 18): the margin read, the candidates' reads and the decision over the two growth panels.

  • Panels. growth_seen and growth_heldout, the growth outcome's regimes at level 6 (Req 21), and no other: no artifact's decision reads another artifact's panel (Req 18).
  • Statistic. D10's, applied to growth: each row's squared error averaged over its repeats (decision.scores.regressor_scores); a candidate's is covariates+embedding's MSE.
  • Reference. The comparator covariates+ancestors (U9). It reads no candidate, and the folds depend on the regime, level, repeat and group alone, so the margin read's row errors are those every candidate's read computes, and they pair exactly.
  • Margins. δ = r × the reference's validation MSE on each panel (U13), from a margin read that reads no candidate, fixed before any candidate is read.
  • Candidates. A deterministic candidate, such as the text-only table or a tree embedding, is one replicate: its table, with the provenance its builder wrote, read once on each growth panel the margins read, with no checkpoint or monitor reads (Req 24; Req 23). Its reads pair with the margin read only where the reference predicts bit for bit as it did there.
  • Decision. Each candidate against the reference on both panels, at 95 % non-inferiority and 97.5 % superiority. Only a candidate adopted over the reference is eligible; among the eligible, Req 5's non-dominated set and tie order pick one, the higher held-out gain over the reference breaking a last tie (D11). With none eligible, the reference stands. The decision scores each read's stored predictions itself, so the values it resamples are those the pairing compared.

check_economic_arm(arm, store)

Require an economic arm record to be a deterministic candidate's single replicate, intact, with its provenance, read once on each growth panel as the decision reads it (Req 24; Req 23).

Raises:

Type Description
ValueError

On the first problem found.

check_economic_margins_first(arms, margins)

Require the margin read to precede the margins, and every candidate read to follow them (Req 24: δ is fixed from a reference-only read before any candidate is read).

Raises:

Type Description
ValueError

If a read's time or the margins' is missing or names no timezone, or if either order fails.

check_reference_pairing(margins, arm, store)

Require the arm to have read the growth panel the margins read, and the reference to predict in each of its runs exactly as in the margin read, so its errors pair with δ's (Req 24).

Only the predictions decide; the environments name where each read ran.

Run it after check_economic_arm, which requires the record to be one intact deterministic replicate. Called alone, it still refuses an arm that does not hold exactly one run, since a loop over no runs would pair nothing.

Raises:

Type Description
ValueError

If the arm does not hold exactly one run, if the panels, data or fit settings differ, or if the reference's predictions in a run differ from the margin read's.

check_relative_margins(margins, store)

Require the margins to hold, for each growth panel, δ = r × the reference's validation MSE, from a margin read that read no candidate (Req 24; U9; U13).

Raises:

Type Description
ValueError

If the margins name another reference, hold another δ than one per growth panel for the reference's statistic, or their read logged or scored a comparator that reads a candidate; or if a δ is not r times the MSE the read's predictions give.

decide_economic(name, question, arms, margins, store, *, replicates, bootstrap_seed)

Req 24's decision: each candidate against the reference on both growth panels; among those adopted over it, Req 5's non-dominated set and tie order pick one. With none adopted, the reference stands and chosen is None.

Every check runs before any number is computed: the margins (check_relative_margins), each candidate (check_economic_arm) and its pairing with the margin read (check_reference_pairing), then the order of the reads (check_economic_margins_first).

Raises:

Type Description
ValueError

If no candidate is given, two share a name or one is named for the reference, or a check fails.

TieUnresolvedError

If the tie order cannot separate the surviving candidates.

fix_relative_margins(panel, r, name, store, *, purpose, lock)

Read the reference alone on each growth panel's validation split, and fix each panel's δ as r times the reference comparator's MSE there (Req 24).

The read logs and scores only the comparators that read no candidate (reference_comparators), so no candidate's growth error exists before δ is recorded.

Parameters:

Name Type Description Default
panel RegressorPanel

The growth panel.

required
r float

Each δ as a multiple of the reference's MSE (U13).

required
name str

Names the margins in the decisions that use them.

required
store ArtifactStore

Where the read's predictions and scores go.

required
purpose str

Why the read happens, which the selection log records.

required
lock Union[str, Path]

The uv.lock the read runs under, which the record names.

required

Raises:

Type Description
ValueError

If r is not a positive finite number, or the panel is not the growth panel at the decision level, before anything is read.

FileNotFoundError

If lock is not a file, before anything is read.

growth_panel_set(panel)

The growth panel's identity at the decision level, which every read of a decision shares.

read_deterministic_arm(spec, table, *, regressor_panel, text_only_table, margins, store, purpose, lock)

Read a deterministic candidate once on each growth panel's validation split: a single replicate (Req 24), recorded with its table's provenance (Req 23).

Every check runs before the first read.

Parameters:

Name Type Description Default
spec ArmSpec

The candidate, with what the tie order and D9 read.

required
table Union[str, Path]

Its 2,125-code table in the export form, with its builder's provenance beside it (panels.text_only.provenance_path).

required
regressor_panel RegressorPanel

The growth panel the margins read.

required
text_only_table Union[str, Path]

The text-only table its reads score as covariates+text_only (D9).

required
margins RelativeMarginRecord

The margins the candidate will be judged against.

required
store ArtifactStore

Where the tables, the provenance and the read's outputs go.

required
purpose str

Why the read happens, which the selection log records.

required
lock Union[str, Path]

The uv.lock the read runs under, which the record names.

required

Raises:

Type Description
ValueError

If the panel is not the growth panel the margins read, with their data and fit settings; if the provenance does not describe the table; if the text-only table was not built from what the candidate reads (D9); or if the table's width is not the spec's dimension.

FileNotFoundError

If the table has no provenance beside it, or lock is not a file.

read_environment(lock)

This process's platform and Python, and the sha256 of lock, the uv.lock it runs under.

Raises:

Type Description
FileNotFoundError

If lock is not a file.