— asserting the full chain of golden metrics in order. It is the end-to-end proof that the substrate delivers: one runnable loop from raw embeddings to a calibrated, audited prediction, every stage carrying a measured verdict. Nothing upstream is recomputed; every number is read from the committed artifacts or recomputed on CPU from them and asserted against golden_metrics.json via the measurement rail.
import collectionsimport numpy as npimport jammifrom jammi_cookbook import contracts, railsdb = jammi.connect("file:///tmp/jammi_closed_loop") # CPU arm; conformal is local mathalpha =round(1- contracts.golden("arxiv.tier04.nominal_coverage").value, 4)print(f"nominal coverage target: {1- alpha:.2f} (alpha = {alpha})")
nominal coverage target: 0.90 (alpha = 0.1)
11.1 Stage 1 — Construct: the graph carries signal the embeddings cannot
Tier 01 builds the derived similarity graph and contrasts it with the declared citation graph. The load-bearing fact is the citation graph’s homophily on the subject label — the precondition the whole loop turns on (it is what later breaks conformal exchangeability). We recompute it from the committed edges + labels.
cite = contracts.load_artifact("arxiv.cite_edges").to_pylist()papers = contracts.load_artifact("arxiv.papers").to_pylist()subject = {p["paper_id"]: p["subject"] for p in papers}same =sum(subject.get(e["src"]) == subject.get(e["dst"]) for e in citeif e["src"] in subject and e["dst"] in subject)cite_homophily = same /len(cite)print(f"citation-graph subject homophily: {cite_homophily:.3f} (random ≈ {1/40:.3f})")rails.measure("arxiv.tier01.cite_homophily", cite_homophily)
11.2 Stage 2 — Propagate: a low-pass graph filter is a denoiser
Tier 02 propagates the embeddings over the citation graph (APPNP-flavoured degree_normalized + teleport). The honest test is a downstream measurement: same-subject retrieval recall@10 must rise. We read the raw and propagated recall from the cache and assert the denoising gain.
Tier 03 fine-tunes the encoder contrastively over declared citation walks (fine_tune_graph(edge_provenance="declared")), trained to convergence. The frozen recall confirms the largest gain of the three graphs the keystone tried — declared citation supervision (SPECTER, Cohan et al. 2020), a self-similarity bootstrap (NNCLR, Dwibedi et al. 2021), and a random null.
recall@10 declared-edge fine-tune: 0.594 (Δ +0.056 over base)
control gains — similarity graph: +0.023 random graph: -0.014
The construct→propagate→learn chain in three numbers: 0.538 → 0.556 → 0.594 (recall@10). Propagation denoises; the declared-edge fine-tune beats the base by the largest margin of the three graphs tried — a self-similarity graph gives a smaller but real gain, and a random graph hurts. Each step is a real, asserted move.
11.4 Stage 4 — Predict & Quantify: the predictor fits, both cruxes under-cover
Tier 04 is the crux Neptune structurally lacks. Two complementary results, both recomputed live on CPU from the committed per-row outputs and asserted.
11.4.1 4a — The bidirectional win: the gaussian predictor fits
Authoring the keystone surfaced an engine gaussian-collapse bug; the fix made the year-regression-conformal workflow run at all. The proof is that the predictor fits a real mean (≈ 2018.4, essentially unbiased across eras) with real spread — not the old collapse (~2163 / std 0.001).
reg = contracts.load_artifact("arxiv.tier04_regression").to_pylist()reg_cal = [r for r in reg if r["split"] =="calibration"]reg_test = [r for r in reg if r["split"] =="test"]cal_mean =float(np.mean([r["pred_mean"] for r in reg_cal]))test_mean =float(np.mean([r["pred_mean"] for r in reg_test]))pred_std =float(np.mean([r["pred_std"] for r in reg]))print(f"predictor mean (cal era / test era): {cal_mean:.2f} / {test_mean:.2f}")print(f"mean predictive std: {pred_std:.3f} (real spread — no collapse)")rails.measure("arxiv.tier04.reg_cal_mean", cal_mean)rails.measure("arxiv.tier04.reg_test_mean", test_mean)rails.measure("arxiv.tier04.reg_pred_std", pred_std)
predictor mean (cal era / test era): 2018.36 / 2018.45
mean predictive std: 0.855 (real spread — no collapse)
0.8546865108342508
11.4.2 4b — Both conformal cruxes under-cover under the time-split
We rerun the engine’s marginal conformal live on CPU against the committed per-row outputs. Both the year-regression interval and the subject-classification set fall below the nominal 0.90 — the citation graph’s homophily (stage 1) carries a non-exchangeable time-split.
# Regression interval — conformalize_interval on the committed gaussian means.cal_year = [float(r["true_year"]) for r in reg_cal]test_year = [r["true_year"] for r in reg_test]intervals = db.conformalize_interval([r["pred_mean"] for r in reg_cal], cal_year, [r["pred_mean"] for r in reg_test], alpha=alpha)reg_cov =float(np.mean([lo <= test_year[i] <= hi for i, (lo, hi) inenumerate(intervals)]))print(f"year-regression interval coverage: {reg_cov:.3f} (nominal {1- alpha:.2f})")rails.measure("arxiv.tier04.reg_interval_coverage", reg_cov)# Subject classification — engine APS marginal on the committed class scores.preds = contracts.load_artifact("arxiv.tier04_predictions").to_pylist()cal = [r for r in preds if r["split"] =="calibration"]test = [r for r in preds if r["split"] =="test"]marg_sets = db.conformalize([r["scores"] for r in cal], [r["true_label"] for r in cal], [r["scores"] for r in test], alpha=alpha, score="aps")marg_cov =float(np.mean([test[i]["true_label"] in marg_sets[i] for i inrange(len(test))]))print(f"subject-classification APS coverage: {marg_cov:.3f} (nominal {1- alpha:.2f})")rails.measure("arxiv.tier04.marginal_coverage", marg_cov)
11.4.3 4c — Weighting moves coverage but restores neither
The textbook covariate-shift remedy is importance-weighted conformal. The keystone ran it and froze the records. Regression is an exact no-op — not because cal/test residual magnitudes match (the test era actually runs larger), but because residual size is uncorrelated with test-likeness within the calibration set, so reweighting cannot move the |residual| quantile. Classification moves coverage — the kNN scheme is the largest mover — but no scheme reaches nominal (the shift is ≈orthogonal to the APS score). Weighting nudges; it does not repair.
reg_w = contracts.load_artifact("arxiv.tier04_regression_weighting")print(f"regression: weighting Δ = {reg_w['weighting_delta']:+.4f} (exact no-op)")rails.measure("arxiv.tier04.reg_weighting_delta", float(reg_w["weighting_delta"]))cls_w = contracts.load_artifact("arxiv.tier04_weighting")deltas = {name: s["delta_vs_marginal"] for name, s in cls_w["schemes"].items()}covs = {name: s["coverage"] for name, s in cls_w["schemes"].items()}largest =max(deltas, key=lambda n: abs(deltas[n]))print(f"classification scheme Δ vs marginal: "f"{ {n: round(d, 4) for n, d in deltas.items()} }")print(f"largest mover: {largest} (Δ {deltas[largest]:+.4f} → {covs[largest]:.3f}); "f"none reaches {1- alpha:.2f}")rails.measure("arxiv.tier04.weighting_max_abs_delta", max(abs(d) for d in deltas.values()))
recall 0.594 (Δ +0.056, the largest of declared/similarity/random)
Predict
train/predict_with_context_predictor
predictor fits ≈ 2018.4 (the bidirectional win)
Quantify
conformalize / conformalize_interval
both cruxes under-cover (0.721 / 0.867); weighting restores neither
Every cell executed against the committed cache; every number was asserted against the frozen golden. The loop is closed: raw data to a calibrated, audited, honestly-quantified prediction — and where the OSS marginal surface cannot repair the under-coverage, the chapter says so plainly and forward-points to the governed cohort the consumer owns. That honesty is the deliverable.