From 30c31b3cbcd3fdbfc3adff50666d5e67f2ab9cb2 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Mon, 5 Oct 2026 09:11:42 -0500 Subject: [PATCH 1/5] estimation v6 pre-freeze: development tools est6dev and est6opchar (D1 only, not frozen) est6dev: G1 PIT bins, lower/upper miss rates and block bootstrap by load segment; reduced G1S kappa check with block cross-validation; schedule and seed balance. est6opchar: operating-characteristics simulation (reads no data). Both refuse held-out paths. No v5 tool, threshold, parameter or receipt is changed. Co-Authored-By: Claude Opus 5.5 --- mk/estimation_v6dev.mk | 29 ++ tools/estimation/est6dev.c | 500 +++++++++++++++++++++++++++ tools/estimation/est6opchar.c | 332 ++++++++++++++++++ tools/estimation/est6opchar_table.sh | 20 ++ tools/estimation/test_est6dev.sh | 51 +++ 5 files changed, 932 insertions(+) create mode 100644 mk/estimation_v6dev.mk create mode 100644 tools/estimation/est6dev.c create mode 100644 tools/estimation/est6opchar.c create mode 100755 tools/estimation/est6opchar_table.sh create mode 100755 tools/estimation/test_est6dev.sh diff --git a/mk/estimation_v6dev.mk b/mk/estimation_v6dev.mk new file mode 100644 index 000000000..1d0731c29 --- /dev/null +++ b/mk/estimation_v6dev.mk @@ -0,0 +1,29 @@ +# ESTIMATION v6 pre-freeze development tools (docs/estimation/protocols/est-v6.md section 9, +# appendix docs/estimation/protocols/est-v6-appendix-prefreeze.md). Development tools only: not the v6 +# tool, no protocol identity, no binding mode. Picked up by `-include mk/*.mk`; not part of `all` or `test`. +# +# est6dev G1 PIT / miss-rate / block-bootstrap analysis, reduced G1S check, schedule and seed balance +# est6opchar operating-characteristics simulation (reads no data file) +# test-est6dev tests for both (D1 development data and synthetic only; held-out refusals) +# est6-opchar-table prints the appendix operating-characteristics table (about 3 minutes) +ifndef ESTIMATION_V6DEV_MK +ESTIMATION_V6DEV_MK := 1 +include mk/estimation_v4.mk +.PHONY: est6dev est6opchar test-est6dev est6-opchar-table +ESTV6D_DIR = $(OUT_DIR)/estimation-v6dev +ESTV6D_SRCS = tools/estimation/est6dev.c tools/estimation/est3c_common.c tools/estimation/est_replay.c \ + src/estimation/est_v4.c src/estimation/est_pred.c src/estimation/est_mix.c $(EST_KF_SRCS) +ESTV6D_HDRS = tools/estimation/est3c_common.h tools/estimation/est_replay.h $(ESTV4_HDRS) +$(ESTV6D_DIR)/est6dev: $(ESTV6D_SRCS) $(ESTV6D_HDRS) + @mkdir -p $(ESTV6D_DIR) + $(CC) $(EST_CFLAGS) -Itools/estimation -o $@ $(ESTV6D_SRCS) -lm +$(ESTV6D_DIR)/est6opchar: tools/estimation/est6opchar.c + @mkdir -p $(ESTV6D_DIR) + $(CC) $(EST_CFLAGS) -o $@ $< -lm +est6dev: $(ESTV6D_DIR)/est6dev +est6opchar: $(ESTV6D_DIR)/est6opchar +test-est6dev: $(ESTV6D_DIR)/est6dev $(ESTV6D_DIR)/est6opchar + sh tools/estimation/test_est6dev.sh $(ESTV6D_DIR)/est6dev $(ESTV6D_DIR)/est6opchar +est6-opchar-table: $(ESTV6D_DIR)/est6opchar + sh tools/estimation/est6opchar_table.sh $(ESTV6D_DIR)/est6opchar 4000 +endif diff --git a/tools/estimation/est6dev.c b/tools/estimation/est6dev.c new file mode 100644 index 000000000..150c882ae --- /dev/null +++ b/tools/estimation/est6dev.c @@ -0,0 +1,500 @@ +/* ESTIMATION v6 pre-freeze development analysis (docs/estimation/protocols/est-v6.md section 9 + * items 1 and 4; appendix est-v6-appendix-prefreeze.md). NOT the v6 tool, not a result about any + * held-out data, and not a protocol tool: it changes no v5 threshold, parameter or receipt. + * + * est6dev g1pit --raw R --marks M --dyn D --q Q --lam L --nu N --c C [--boot B] [--seed S] [--blocks] + * One-step G1 (est_v4.c, the v5 code, unchanged) with the GIVEN parameters on one run folder. + * Prints the v5 statistics it must reproduce (n, PIT bin shares, coverage 50/80/95, mean z, + * lag-1 z), the lower and upper 2.5 % miss rates separately, and a block bootstrap over load + * segments (a block is one marked load segment, or one idle stretch between marked segments) + * giving standard errors, percentile intervals and the design effect against independent + * steps for every bin share and miss rate. + * est6dev sched + * The est_load schedule for a seed (same splitmix64 draw order as est_load.c) with per-level + * totals and the section 3 balance check (each of idle, L6, L12, L18 within 400..900 s). + * + * Refuses, before opening anything, any path that names a held-out run (v3, v4, v5 or v6 held-out + * tag) or the v5 D2 folder; after loading, refuses an input whose SHA-256 is the v5 D2 raw SHA. */ +#include +#include +#include +#include +#include +#include + +#include "est3c_common.h" +#include "est_v4.h" + +#define D2_DATE_TAG "20261005T112838Z" +#define D2_RAW_SHA "7dda21f664587c4401326c3082f28039e133ba5627c8564678f259e2d7036ff0" + +static uint64_t splitmix64(uint64_t *s) +{ + uint64_t z = (*s += 0x9e3779b97f4a7c15ull); + z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9ull; + z = (z ^ (z >> 27)) * 0x94d049bb133111ebull; + return z ^ (z >> 31); +} + +static int forbidden_path(const char *path) +{ + static const char *tags[] = { "-heldout-", D2_DATE_TAG, "-est5-heldout", "-est4-heldout", "-est3c-heldout", "-est6-heldout", NULL }; + char rp[PATH_MAX]; + for (int i = 0; tags[i]; i++) { + if (strstr(path, tags[i])) return 1; + if (realpath(path, rp) && strstr(rp, tags[i])) return 1; + } + return 0; +} + +/* ------------------------------------------------------------ schedule (item 4) */ +static int cmd_sched(int argc, char **argv) +{ + if (argc != 2) { fprintf(stderr, "usage: est6dev sched \n"); return 2; } + uint64_t seed = strtoull(argv[0], NULL, 0); + long total = strtol(argv[1], NULL, 10); + if (total <= 0) { fprintf(stderr, "seconds must be > 0\n"); return 2; } + static const int levels[4] = { 0, 6, 12, 18 }; + long secs_by_level[4] = { 0, 0, 0, 0 }; + long acc = 0; int n = 0; + uint64_t s = seed; + printf("seed %llu seconds %ld\n", (unsigned long long)seed, total); + while (acc < total && n < 4096) { + int li = (int)(splitmix64(&s) % 4u); + long d = 20 + (long)(splitmix64(&s) % 101u); + if (acc + d > total) d = total - acc; + printf("schedule %d %d %ld\n", n, levels[li], d); + secs_by_level[li] += d; acc += d; n++; + } + int ok = 1; + for (int i = 0; i < 4; i++) if (secs_by_level[i] < 400 || secs_by_level[i] > 900) ok = 0; + printf("segments %d idle %ld L6 %ld L12 %ld L18 %ld\n", n, secs_by_level[0], secs_by_level[1], secs_by_level[2], secs_by_level[3]); + printf("balance %s\n", ok ? "PASS" : "FAIL"); + return 0; +} + +/* first seed at or after (step +1) whose schedule passes the section 3 balance rule */ +static int balance_ok(uint64_t seed, long total, long lv[4], int *nseg) +{ + static const int levels[4] = { 0, 6, 12, 18 }; + uint64_t s = seed; long acc = 0; int n = 0, ok = 1; + for (int i = 0; i < 4; i++) lv[i] = 0; + while (acc < total && n < 4096) { + int li = (int)(splitmix64(&s) % 4u); + long d = 20 + (long)(splitmix64(&s) % 101u); + if (acc + d > total) d = total - acc; + lv[li] += d; acc += d; n++; + } + (void)levels; + for (int i = 0; i < 4; i++) if (lv[i] < 400 || lv[i] > 900) ok = 0; + *nseg = n; + return ok; +} + +static int cmd_pick(int argc, char **argv) +{ + if (argc != 2) { fprintf(stderr, "usage: est6dev pick \n"); return 2; } + uint64_t seed = strtoull(argv[0], NULL, 0); + long total = strtol(argv[1], NULL, 10), lv[4]; int ns; + for (int k = 0; k < 100000; k++) { + int ok = balance_ok(seed + (uint64_t)k, total, lv, &ns); + printf("seed 0x%llx segments %d idle %ld L6 %ld L12 %ld L18 %ld balance %s\n", (unsigned long long)(seed + (uint64_t)k), ns, lv[0], lv[1], lv[2], lv[3], ok ? "PASS" : "FAIL"); + if (ok) { printf("picked 0x%llx after %d failures\n", (unsigned long long)(seed + (uint64_t)k), k); return 0; } + } + printf("none found\n"); + return 1; +} + +/* ------------------------------------------------------------ one-step G1 PIT trace */ +typedef struct { int64_t t; double flo, fhi, z; } step_t; + +static est_obs_class classify(const c3_tick *t, est_pobs *ob) +{ + est_assumption a; c3_assumption_base(&a, EST_FAM_STUDENT_T); + a.nparam = 2; a.param[0] = 5; a.param[1] = 100; + if (est_pobs_classify(&a, t->value, t->present, &t->ev, ob) != EST_OK) return EST_OBS_CLASSES_; + return ob->cls; +} + +/* mirrors est5.c e4_score, one-step part only (same classification, burn-in, unscorable rule) */ +static int run_g1(const c3_ticks *tk, const est4_params *p, step_t **out, size_t *nout, size_t *unscorable) +{ + est4_state s; + est_dpred *dp = malloc(sizeof *dp); + step_t *st = malloc((tk->n ? tk->n : 1) * sizeof *st); + size_t n = 0; *unscorable = 0; + if (!dp || !st) return 1; + if (est4_init(p, &s) != EST_OK) return 1; + long first = -1; + for (size_t t = 0; t < tk->n; t++) { + const c3_tick *tc = &tk->t[t]; + est_pobs ob; est_pinnov iv; + est_obs_class cls = classify(tc, &ob); + if (cls == EST_OBS_CLASSES_) return 1; + int ok = cls == EST_OBS_OK; + if (ok && first < 0) first = (long)t; + int scored = first >= 0 && (long)t - first >= (long)C3_BURN_IN; + if (ok && scored) { + if ((uint64_t)s.gap + 1u > EST_PRED_MAX_H) (*unscorable)++; + else { + est4_pred pr; + if (est4_predict(&s, 1, &pr) != EST_OK || est4_dpred(&s, &pr, dp) != EST_OK) return 1; + if (est_dpred_score(dp, &ob, &iv) != EST_OK) return 1; + if (iv.valid) { st[n].t = tc->wall_ns; st[n].flo = iv.F_lo; st[n].fhi = iv.F_hi; st[n].z = iv.z; n++; } + } + } + if (est4_update(&s, ok, ok ? ob.value : NAN) != EST_OK) return 1; + } + free(dp); + *out = st; *nout = n; + return 0; +} + +#define NSTAT 13 /* bins 0..9, lower miss, upper miss, cov95 */ +static const char *STAT_NAME[NSTAT] = { "pit_bin0", "pit_bin1", "pit_bin2", "pit_bin3", "pit_bin4", "pit_bin5", "pit_bin6", + "pit_bin7", "pit_bin8", "pit_bin9", "lower_miss_2.5", "upper_miss_2.5", "coverage95" }; + +static double overlap(double a, double b, double c, double d) +{ + double lo = a > c ? a : c, hi = b < d ? b : d; + return hi > lo ? hi - lo : 0.0; +} + +/* per-step contribution to each statistic: expected value under u ~ U(F_lo, F_hi) */ +static void contrib(const step_t *s, double v[NSTAT]) +{ + double span = s->fhi - s->flo; + for (int j = 0; j < 10; j++) { + if (span > 0.0) v[j] = overlap(s->flo, s->fhi, j / 10.0, (j + 1) / 10.0) / span; + else { int k = (int)floor(s->flo * 10.0); if (k < 0) k = 0; if (k > 9) k = 9; v[j] = (k == j) ? 1.0 : 0.0; } + } + if (span > 0.0) { + double l = (0.025 - s->flo) / span, u = (s->fhi - 0.975) / span; + v[10] = l < 0 ? 0 : l > 1 ? 1 : l; + v[11] = u < 0 ? 0 : u > 1 ? 1 : u; + } else { v[10] = s->flo < 0.025; v[11] = s->flo > 0.975; } + v[12] = 1.0 - v[10] - v[11]; +} + +static int cmpd(const void *a, const void *b) { double x = *(const double *)a, y = *(const double *)b; return x < y ? -1 : x > y; } + +static double quant(const double *sorted, int n, double q) +{ + double pos = q * (double)(n - 1); + int i = (int)floor(pos); + if (i >= n - 1) return sorted[n - 1]; + return sorted[i] + (pos - i) * (sorted[i + 1] - sorted[i]); +} + +/* block id of a time: odd 2i+1 inside marked pair i, even 2m between (m = pairs ended before t) */ +static size_t block_of(const c3_marks *mk, int64_t t) +{ + size_t ended = 0; + for (size_t i = 0; i < mk->n; i++) { + if (t >= mk->b[i] && t <= mk->e[i]) return 2 * i + 1; + if (mk->e[i] < t) ended++; + } + return 2 * ended; +} + +static int cmd_g1pit(int argc, char **argv) +{ + const char *raw = NULL, *mkp = NULL; + double dyn = NAN, q = NAN, lam = NAN, nu = NAN, c = NAN; + int boot = 2000, show_blocks = 0; + uint64_t seed = 0xE6B007ull; + for (int i = 0; i < argc; i++) { + if (!strcmp(argv[i], "--raw") && i + 1 < argc) raw = argv[++i]; + else if (!strcmp(argv[i], "--marks") && i + 1 < argc) mkp = argv[++i]; + else if (!strcmp(argv[i], "--dyn") && i + 1 < argc) dyn = atof(argv[++i]); + else if (!strcmp(argv[i], "--q") && i + 1 < argc) q = atof(argv[++i]); + else if (!strcmp(argv[i], "--lam") && i + 1 < argc) lam = atof(argv[++i]); + else if (!strcmp(argv[i], "--nu") && i + 1 < argc) nu = atof(argv[++i]); + else if (!strcmp(argv[i], "--c") && i + 1 < argc) c = atof(argv[++i]); + else if (!strcmp(argv[i], "--boot") && i + 1 < argc) boot = atoi(argv[++i]); + else if (!strcmp(argv[i], "--seed") && i + 1 < argc) seed = strtoull(argv[++i], NULL, 0); + else if (!strcmp(argv[i], "--blocks")) show_blocks = 1; + else { fprintf(stderr, "usage: est6dev g1pit --raw R --marks M --dyn D --q Q --lam L --nu N --c C [--boot B] [--seed S] [--blocks]\n"); return 2; } + } + if (!raw || !mkp || isnan(dyn) || isnan(q) || isnan(lam) || isnan(nu) || isnan(c) || boot < 10) { fprintf(stderr, "est6dev g1pit: missing argument\n"); return 2; } + if (forbidden_path(raw) || forbidden_path(mkp)) { fprintf(stderr, "refuse: a held-out path (v5 D2 and every held-out tag are forbidden in v6 development)\n"); return 2; } + char err[512]; + est_file f; + if (est_file_load(raw, &f, err, sizeof err)) { fprintf(stderr, "refuse: %s\n", err); return 1; } + if (!strcmp(f.sha_hex, D2_RAW_SHA)) { fprintf(stderr, "refuse: input is the v5 D2 raw data (SHA-256)\n"); est_file_free(&f); return 2; } + static c3_marks mk; + if (c3_marks_load(mkp, 1, &mk, err, sizeof err)) { fprintf(stderr, "refuse: marks: %s\n", err); est_file_free(&f); return 1; } + c3_ticks tk; + if (c3_ticks_build(&f, &tk, err, sizeof err)) { fprintf(stderr, "ticks: %s\n", err); est_file_free(&f); return 1; } + printf("input raw_sha256 %s marks_sha256 %s lines %zu marks_pairs %zu\n", f.sha_hex, mk.sha, tk.lines, mk.n); + + est4_params p = { EST4_G1_LAG, dyn, q, lam, nu, c, 0.95, 0.8, 0.2, C3_QUANTUM }; + step_t *st = NULL; size_t n = 0, unsc = 0; + if (run_g1(&tk, &p, &st, &n, &unsc) || n == 0) { fprintf(stderr, "g1 run failed\n"); return 1; } + + /* per-step contributions, per-block sums */ + size_t nb_max = 2 * mk.n + 2; + double (*bs)[NSTAT] = calloc(nb_max, sizeof *bs); + double *bn = calloc(nb_max, sizeof *bn); + double tot[NSTAT] = { 0 }; + double zsum = 0; + if (!bs || !bn) return 1; + for (size_t i = 0; i < n; i++) { + double v[NSTAT]; + contrib(&st[i], v); + size_t b = block_of(&mk, st[i].t); + for (int k = 0; k < NSTAT; k++) { bs[b][k] += v[k]; tot[k] += v[k]; } + bn[b] += 1.0; + zsum += st[i].z; + } + double zm = zsum / (double)n; + printf("params dyn %.17g q %.17g lam %.17g nu %.17g c %.17g\n", dyn, q, lam, nu, c); + printf("n_scored %zu unscorable %zu\n", n, unsc); + printf("mean_z_midpit %.6f\n", zm); + + /* blocks that have steps */ + size_t nb = 0, nload = 0, *idx = malloc(nb_max * sizeof *idx); + for (size_t b = 0; b < nb_max; b++) if (bn[b] > 0) { idx[nb++] = b; nload += (b & 1u); } + printf("blocks %zu (loaded %zu, idle %zu) mean_steps_per_block %.1f\n", nb, nload, nb - nload, (double)n / (double)nb); + if (show_blocks) + for (size_t i = 0; i < nb; i++) { + size_t b = idx[i]; + printf("block %zu %s level %d steps %.0f bin0_mass %.3f lower_miss_mass %.3f upper_miss_mass %.3f\n", b, (b & 1u) ? "load" : "idle", + (b & 1u) ? mk.level[b / 2] : 0, bn[b], bs[b][0], bs[b][10], bs[b][11]); + } + + { /* descriptive: shares by declared load level (idle = 0) */ + double ls[4][NSTAT] = { { 0 } }, ln[4] = { 0 }; + for (size_t i = 0; i < nb; i++) { + size_t b = idx[i]; + int lv = (b & 1u) ? mk.level[b / 2] : 0, li = lv == 6 ? 1 : lv == 12 ? 2 : lv == 18 ? 3 : 0; + ln[li] += bn[b]; + for (int k = 0; k < NSTAT; k++) ls[li][k] += bs[b][k]; + } + static const int lvn[4] = { 0, 6, 12, 18 }; + for (int li = 0; li < 4; li++) + if (ln[li] > 0) printf("by_level L%d steps %.0f pit_bin0 %.4f pit_bin9 %.4f lower_miss %.4f upper_miss %.4f\n", lvn[li], ln[li], ls[li][0] / ln[li], ls[li][9] / ln[li], ls[li][10] / ln[li], ls[li][11] / ln[li]); + } + /* bootstrap: resample whole blocks with replacement; ratio estimator */ + double *draw = malloc((size_t)boot * NSTAT * sizeof(double)); + if (!draw) return 1; + uint64_t rng = seed; + for (int r = 0; r < boot; r++) { + double sum[NSTAT] = { 0 }, cnt = 0; + for (size_t i = 0; i < nb; i++) { + size_t b = idx[splitmix64(&rng) % nb]; + for (int k = 0; k < NSTAT; k++) sum[k] += bs[b][k]; + cnt += bn[b]; + } + for (int k = 0; k < NSTAT; k++) draw[(size_t)r * NSTAT + k] = sum[k] / cnt; + } + printf("bootstrap draws %d seed 0x%llx unit whole_blocks\n", boot, (unsigned long long)seed); + printf("# stat value iid_se boot_se design_effect ci95_lo ci95_hi ci995_lo ci995_hi\n"); + double *col = malloc((size_t)boot * sizeof *col); + for (int k = 0; k < NSTAT; k++) { + double val = tot[k] / (double)n, mean = 0, var = 0; + for (int r = 0; r < boot; r++) { col[r] = draw[(size_t)r * NSTAT + k]; mean += col[r]; } + mean /= boot; + for (int r = 0; r < boot; r++) var += (col[r] - mean) * (col[r] - mean); + var /= (boot - 1); + double iid = sqrt(val * (1.0 - val) / (double)n); + qsort(col, (size_t)boot, sizeof *col, cmpd); + double bse = sqrt(var); + printf("stat %s %.6f %.6f %.6f %.3f %.6f %.6f %.6f %.6f\n", STAT_NAME[k], val, iid, bse, iid > 0 ? (bse * bse) / (iid * iid) : NAN, + quant(col, boot, 0.025), quant(col, boot, 0.975), quant(col, boot, 0.0025), quant(col, boot, 0.9975)); + } + free(st); free(bs); free(bn); free(idx); free(draw); free(col); + c3_ticks_free(&tk); est_file_free(&f); + return 0; +} + +/* ------------------------------------------------------------ G1S exploratory (item 2, reduced) */ +/* Reduced item 2: the filter parameters (dyn q lam nu) stay at the v5 D1 values; only the skew kappa + * and the scale c are searched (kappa x c grid), by 5-fold block cross-validation over load segments. + * The two-piece t is built from the symmetric est4_fast_logp kernel (est_v4.c unchanged): scale c b on + * the upper side and c kappa b on the lower side, side masses 1/(1+kappa) and kappa/(1+kappa). */ +typedef struct { int64_t t; double y, m, b, anchor; } trace_t; + +static int run_g1_trace(const c3_ticks *tk, const est4_params *p, trace_t **out, size_t *nout) +{ + est4_state s; + trace_t *tr = malloc((tk->n ? tk->n : 1) * sizeof *tr); + size_t n = 0; + if (!tr || est4_init(p, &s) != EST_OK) return 1; + long first = -1; + for (size_t t = 0; t < tk->n; t++) { + est_pobs ob; + est_obs_class cls = classify(&tk->t[t], &ob); + if (cls == EST_OBS_CLASSES_) return 1; + int ok = cls == EST_OBS_OK; + if (ok && first < 0) first = (long)t; + int scored = first >= 0 && (long)t - first >= (long)C3_BURN_IN; + if (ok && scored && (uint64_t)s.gap + 1u <= EST_PRED_MAX_H) { + double m, v; + if (est4_moments(&s, 1, &m, &v) != EST_OK) return 1; + tr[n].t = tk->t[t].wall_ns; tr[n].y = ob.value; tr[n].m = m; tr[n].b = sqrt(s.g * v); tr[n].anchor = s.anchor; n++; + } + if (est4_update(&s, ok, ok ? ob.value : NAN) != EST_OK) return 1; + } + *out = tr; *nout = n; + return 0; +} + +/* un-floored cdf at the bin edges from the symmetric kernel */ +static void sym_edges(const trace_t *r, double scale, double nu, double *lo, double *hi) +{ + est4_pred pr = { 1u, r->m, scale, nu }; + double Fl, Fh; + est4_fast_logp(&pr, C3_QUANTUM, r->anchor, r->y, &Fl, &Fh); + double kd = nearbyint((r->y - r->anchor) / C3_QUANTUM); + if (kd < -(double)EST_PRED_K) kd = -(double)EST_PRED_K; + if (kd > (double)EST_PRED_K) kd = (double)EST_PRED_K; + double f = EST_PRED_FLOOR, u = EST_PRED_FLOOR / (double)EST_PRED_N, idx = kd + (double)EST_PRED_K; + *lo = (Fl - u * idx) / (1.0 - f); + *hi = (Fh - u * (idx + 1.0)) / (1.0 - f); +} + +static double two_piece(const trace_t *r, double c, double kappa, double nu, double *Flo, double *Fhi) +{ + double a = 1.0 / (1.0 + kappa), b = kappa / (1.0 + kappa); + double lo_u, hi_u, lo_l, hi_l; + sym_edges(r, c * r->b, nu, &lo_u, &hi_u); + sym_edges(r, c * kappa * r->b, nu, &lo_l, &hi_l); + double kd = nearbyint((r->y - r->anchor) / C3_QUANTUM); + if (kd < -(double)EST_PRED_K) kd = -(double)EST_PRED_K; + if (kd > (double)EST_PRED_K) kd = (double)EST_PRED_K; + double mu = r->m - r->anchor, xa = (kd - 0.5) * C3_QUANTUM, xb = (kd + 0.5) * C3_QUANTUM; + double Fa = xa < mu ? 2.0 * b * lo_l : b + 2.0 * a * (lo_u - 0.5); + double Fb = xb < mu ? 2.0 * b * hi_l : b + 2.0 * a * (hi_u - 0.5); + if (kd == -(double)EST_PRED_K) Fa = 0.0; + if (kd == (double)EST_PRED_K) Fb = 1.0; + double p = Fb - Fa; if (p < 0) p = 0; + double f = EST_PRED_FLOOR, u = EST_PRED_FLOOR / (double)EST_PRED_N, idx = kd + (double)EST_PRED_K; + *Flo = (1.0 - f) * Fa + u * idx; *Fhi = (1.0 - f) * Fb + u * (idx + 1.0); + p = (1.0 - f) * p + u; + return log(p > 1e-300 ? p : 1e-300); +} + +#define NK 5 +#define NCG 21 +static const double KAPPA[NK] = { 0.6, 0.7, 0.8, 0.9, 1.0 }; + +static int cmd_g1s(int argc, char **argv) +{ + const char *raw = NULL, *mkp = NULL; + double dyn = NAN, q = NAN, lam = NAN, nu = NAN; + int nfold = 5; + for (int i = 0; i < argc; i++) { + if (!strcmp(argv[i], "--raw") && i + 1 < argc) raw = argv[++i]; + else if (!strcmp(argv[i], "--marks") && i + 1 < argc) mkp = argv[++i]; + else if (!strcmp(argv[i], "--dyn") && i + 1 < argc) dyn = atof(argv[++i]); + else if (!strcmp(argv[i], "--q") && i + 1 < argc) q = atof(argv[++i]); + else if (!strcmp(argv[i], "--lam") && i + 1 < argc) lam = atof(argv[++i]); + else if (!strcmp(argv[i], "--nu") && i + 1 < argc) nu = atof(argv[++i]); + else if (!strcmp(argv[i], "--folds") && i + 1 < argc) nfold = atoi(argv[++i]); + else { fprintf(stderr, "usage: est6dev g1s --raw R --marks M --dyn D --q Q --lam L --nu N [--folds K]\n"); return 2; } + } + if (!raw || !mkp || isnan(dyn) || isnan(q) || isnan(lam) || isnan(nu) || nfold < 2 || nfold > 20) { fprintf(stderr, "est6dev g1s: missing argument\n"); return 2; } + if (forbidden_path(raw) || forbidden_path(mkp)) { fprintf(stderr, "refuse: a held-out path (v5 D2 and every held-out tag are forbidden in v6 development)\n"); return 2; } + char err[512]; + est_file f; + if (est_file_load(raw, &f, err, sizeof err)) { fprintf(stderr, "refuse: %s\n", err); return 1; } + if (!strcmp(f.sha_hex, D2_RAW_SHA)) { fprintf(stderr, "refuse: input is the v5 D2 raw data (SHA-256)\n"); est_file_free(&f); return 2; } + static c3_marks mk; + if (c3_marks_load(mkp, 1, &mk, err, sizeof err)) { fprintf(stderr, "refuse: marks: %s\n", err); est_file_free(&f); return 1; } + c3_ticks tk; + if (c3_ticks_build(&f, &tk, err, sizeof err)) { fprintf(stderr, "ticks: %s\n", err); est_file_free(&f); return 1; } + printf("input raw_sha256 %s marks_sha256 %s\n", f.sha_hex, mk.sha); + est4_params p = { EST4_G1_LAG, dyn, q, lam, nu, 1.0, 0.95, 0.8, 0.2, C3_QUANTUM }; + trace_t *tr = NULL; size_t n = 0; + if (run_g1_trace(&tk, &p, &tr, &n) || n == 0) { fprintf(stderr, "g1 trace failed\n"); return 1; } + /* fold of a step = rank of its block among blocks that have steps, modulo nfold */ + size_t nb_max = 2 * mk.n + 2; + int *rank = malloc(nb_max * sizeof *rank), *seen = calloc(nb_max, sizeof *seen); + size_t *blk = malloc(n * sizeof *blk); + for (size_t i = 0; i < n; i++) { blk[i] = block_of(&mk, tr[i].t); seen[blk[i]] = 1; } + int nr = 0; + for (size_t b = 0; b < nb_max; b++) rank[b] = seen[b] ? nr++ : -1; + int *fold = malloc(n * sizeof *fold); + for (size_t i = 0; i < n; i++) fold[i] = rank[blk[i]] % nfold; + /* per grid point, per step: logp, F_lo, F_hi */ + size_t G = (size_t)NK * NCG; + double *lp = malloc(G * n * sizeof *lp), *Flo = malloc(G * n * sizeof *Flo), *Fhi = malloc(G * n * sizeof *Fhi); + if (!lp || !Flo || !Fhi) return 1; + for (int ki = 0; ki < NK; ki++) + for (int ci = 0; ci < NCG; ci++) { + size_t g = (size_t)ki * NCG + (size_t)ci; + double c = (double)(20 + 5 * ci) / 100.0; + for (size_t i = 0; i < n; i++) lp[g * n + i] = two_piece(&tr[i], c, KAPPA[ki], nu, &Flo[g * n + i], &Fhi[g * n + i]); + } + /* bit-for-bit style check: kappa = 1.0 against est4_fast_logp (maximum absolute difference) */ + double maxd = 0; + for (int ci = 0; ci < NCG; ci++) + for (size_t i = 0; i < n; i++) { + est4_pred pr = { 1u, tr[i].m, ((double)(20 + 5 * ci) / 100.0) * tr[i].b, nu }; + double d = fabs(est4_fast_logp(&pr, C3_QUANTUM, tr[i].anchor, tr[i].y, NULL, NULL) - lp[(size_t)(NK - 1) * NCG * n + (size_t)ci * n + i]); + if (d > maxd) maxd = d; + } + printf("check kappa1_vs_est4_fast_logp max_abs_diff %.3g\n", maxd); + /* in-sample best over the whole run, per kappa and overall */ + for (int ki = 0; ki < NK; ki++) { + double best = -INFINITY; int bc = 0; + for (int ci = 0; ci < NCG; ci++) { + double s = 0; size_t g = (size_t)ki * NCG + (size_t)ci; + for (size_t i = 0; i < n; i++) s += lp[g * n + i]; + if (s / (double)n > best) { best = s / (double)n; bc = ci; } + } + { + size_t g = (size_t)ki * NCG + (size_t)bc; double b0 = 0, b9 = 0, l = 0, u = 0; + for (size_t i = 0; i < n; i++) { step_t st = { 0, Flo[g * n + i], Fhi[g * n + i], 0 }; double v[NSTAT]; contrib(&st, v); b0 += v[0]; b9 += v[9]; l += v[10]; u += v[11]; } + printf("insample kappa %.1f best_c %.2f mean_logscore %.6f pit_bin0 %.4f pit_bin9 %.4f lower_miss %.4f upper_miss %.4f\n", KAPPA[ki], (double)(20 + 5 * bc) / 100.0, best, b0 / (double)n, b9 / (double)n, l / (double)n, u / (double)n); + } + } + /* out-of-fold: for each fold choose (kappa, c) on the other folds, score the held-out fold. restrict = 0: kappa free; 1: kappa fixed at 1.0 */ + for (int restrict_k = 0; restrict_k < 2; restrict_k++) { + double bins[10] = { 0 }, lm = 0, um = 0, ls = 0; + printf("oof %s\n", restrict_k ? "kappa=1.0 only (c refit by fold, control)" : "kappa free in {0.6..1.0}, c refit by fold"); + for (int fo = 0; fo < nfold; fo++) { + double best = -INFINITY; size_t bg = 0; + for (int ki = restrict_k ? NK - 1 : 0; ki < NK; ki++) + for (int ci = 0; ci < NCG; ci++) { + size_t g = (size_t)ki * NCG + (size_t)ci; double s = 0; + for (size_t i = 0; i < n; i++) if (fold[i] != fo) s += lp[g * n + i]; + if (s > best) { best = s; bg = g; } + } + size_t nf = 0; double fl = 0; + for (size_t i = 0; i < n; i++) if (fold[i] == fo) { + step_t st = { 0, Flo[bg * n + i], Fhi[bg * n + i], 0 }; + double v[NSTAT]; contrib(&st, v); + for (int j = 0; j < 10; j++) bins[j] += v[j]; + lm += v[10]; um += v[11]; ls += lp[bg * n + i]; fl += lp[bg * n + i]; nf++; + } + printf("fold %d steps %zu chosen_kappa %.1f chosen_c %.2f oof_mean_logscore %.6f\n", fo, nf, KAPPA[bg / NCG], (double)(20 + 5 * (int)(bg % NCG)) / 100.0, nf ? fl / (double)nf : 0.0); + } + printf("oof_pooled n %zu mean_logscore %.6f pit_bin0 %.4f pit_bin9 %.4f lower_miss %.4f upper_miss %.4f bins", n, ls / (double)n, bins[0] / (double)n, bins[9] / (double)n, lm / (double)n, um / (double)n); + for (int j = 0; j < 10; j++) printf(" %.4f", bins[j] / (double)n); + printf("\n"); + } + /* in-sample overall best (kappa, c) PIT shares, for reference */ + { + double best = -INFINITY; size_t bg = 0; + for (size_t g = 0; g < G; g++) { double s = 0; for (size_t i = 0; i < n; i++) s += lp[g * n + i]; if (s > best) { best = s; bg = g; } } + double bins[10] = { 0 }, lm = 0, um = 0; + for (size_t i = 0; i < n; i++) { step_t st = { 0, Flo[bg * n + i], Fhi[bg * n + i], 0 }; double v[NSTAT]; contrib(&st, v); for (int j = 0; j < 10; j++) bins[j] += v[j]; lm += v[10]; um += v[11]; } + printf("insample_best kappa %.1f c %.2f mean_logscore %.6f pit_bin0 %.4f pit_bin9 %.4f lower_miss %.4f upper_miss %.4f\n", KAPPA[bg / NCG], (double)(20 + 5 * (int)(bg % NCG)) / 100.0, best / (double)n, bins[0] / (double)n, bins[9] / (double)n, lm / (double)n, um / (double)n); + } + free(tr); free(rank); free(seen); free(blk); free(fold); free(lp); free(Flo); free(Fhi); + c3_ticks_free(&tk); est_file_free(&f); + return 0; +} + +int main(int argc, char **argv) +{ + if (argc < 2) { fprintf(stderr, "usage: est6dev g1pit|g1s|sched|pick ...\n"); return 2; } + if (!strcmp(argv[1], "g1pit")) return cmd_g1pit(argc - 2, argv + 2); + if (!strcmp(argv[1], "sched")) return cmd_sched(argc - 2, argv + 2); + if (!strcmp(argv[1], "pick")) return cmd_pick(argc - 2, argv + 2); + if (!strcmp(argv[1], "g1s")) return cmd_g1s(argc - 2, argv + 2); + fprintf(stderr, "usage: est6dev g1pit|g1s|sched|pick ...\n"); + return 2; +} diff --git a/tools/estimation/est6opchar.c b/tools/estimation/est6opchar.c new file mode 100644 index 000000000..db8ff5e09 --- /dev/null +++ b/tools/estimation/est6opchar.c @@ -0,0 +1,332 @@ +/* ESTIMATION v6 pre-freeze operating-characteristics simulation (docs/estimation/protocols/est-v6.md + * section 6, section 9 item 3; appendix est-v6-appendix-prefreeze.md). Development tool: it reads NO + * data file at all, so no held-out file can be touched. It simulates the pooled H1 + H2 scoring of the + * primary gates P1 to P10 and the three-way verdict on synthetic PIT sequences. + * + * est6opchar run --case a|b|c [--bin0 X] [--reps N] [--boot B] [--runs R] [--seconds S] + * [--w W] [--rho RHO] [--rho10 RHO10] [--seed SEED] + * est6opchar deff [--reps N] [--runs R] [--w W] [--rho RHO] [--seed SEED] + * est6opchar selftest + * + * Generator. Each run has 20..120 s segments (splitmix64, est_load.c draw order, level uniform on + * {0,6,12,18}) and one step per second after a 30 s burn-in. Latent z_t = sqrt(W) b_k + sqrt(1 - W) a_t + * with b_k ~ N(0,1) per segment and a_t AR(1) with coefficient RHO, so z_t ~ N(0,1) marginally. The + * randomised PIT is u = G(Phi(z)): + * case a G = identity (perfectly calibrated forecaster); + * case b u = Phi(s z) with s chosen so the nominal 95 % interval truly covers 92 %; + * case c G^-1 = piecewise-uniform CDF over cells built from the v5 D1 in-sample PIT shares + * (--bin0 X rescales bin 0 to X and the other bins pro rata; default 0.0760 is the D1 value). + * The ten-step PIT sequence for P7 is an independent sequence from the same generator with RHO10 + * (overlapping ten-step windows are strongly dependent); its marginal coverage is 0.95 (a), 0.92 (b) or + * the D1 value 0.9402 (c, by the same scale trick). + * + * Gates, verdict. As protocol section 6 on the pooled steps; intervals are 99.5 % block-bootstrap + * percentiles over whole segments for P1 to P7 and mean z; the lag-1 part of P8 and the P9 quarter and + * regime coverages use the point value only (interval = point), which can only make HELD_OUT_FAIL more + * likely than the real tool. The baseline comparison is not simulated (assumed met). */ +#include +#include +#include +#include + +typedef unsigned long long u64; +static u64 splitmix64(u64 *s) +{ + u64 z = (*s += 0x9e3779b97f4a7c15ull); + z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9ull; + z = (z ^ (z >> 27)) * 0x94d049bb133111ebull; + return z ^ (z >> 31); +} +static double unif(u64 *s) { return ((double)(splitmix64(s) >> 11) + 0.5) / 9007199254740992.0; } +static double gauss(u64 *s) +{ + double u1 = unif(s), u2 = unif(s); + return sqrt(-2.0 * log(u1)) * cos(6.283185307179586 * u2); +} +static double Phi(double x) { return 0.5 * erfc(-x / 1.4142135623730951); } +/* Acklam inverse normal CDF, then one Halley step (error ~1e-15) */ +static double probit(double p) +{ + static const double a[] = { -3.969683028665376e+01, 2.209460984245205e+02, -2.759285104469687e+02, 1.383577518672690e+02, -3.066479806614716e+01, 2.506628277459239e+00 }; + static const double b[] = { -5.447609879822406e+01, 1.615858368580409e+02, -1.556989798598866e+02, 6.680131188771972e+01, -1.328068155288572e+01 }; + static const double c[] = { -7.784894002430293e-03, -3.223964580411365e-01, -2.400758277161838e+00, -2.549732539343734e+00, 4.374664141464968e+00, 2.938163982698783e+00 }; + static const double d[] = { 7.784695709041462e-03, 3.224671290700398e-01, 2.445134137142996e+00, 3.754408661907416e+00 }; + double x; + if (p < 0.02425) { double q = sqrt(-2 * log(p)); x = (((((c[0] * q + c[1]) * q + c[2]) * q + c[3]) * q + c[4]) * q + c[5]) / ((((d[0] * q + d[1]) * q + d[2]) * q + d[3]) * q + 1); } + else if (p > 1 - 0.02425) { double q = sqrt(-2 * log(1 - p)); x = -(((((c[0] * q + c[1]) * q + c[2]) * q + c[3]) * q + c[4]) * q + c[5]) / ((((d[0] * q + d[1]) * q + d[2]) * q + d[3]) * q + 1); } + else { double q = p - 0.5, r = q * q; x = (((((a[0] * r + a[1]) * r + a[2]) * r + a[3]) * r + a[4]) * r + a[5]) * q / (((((b[0] * r + b[1]) * r + b[2]) * r + b[3]) * r + b[4]) * r + 1); } + double e = Phi(x) - p, u = e * 2.5066282746310002 * exp(x * x / 2); + return x - u / (1 + x * u / 2); +} + +/* ---- case c cells: cut points and masses (v5 D1 in-sample shares, receipts/est-v5/params.txt and + * est6dev g1pit: lower miss 0.0122 and upper miss 0.0349 are inside bins 0 and 9) ---- */ +#define NCELL 12 +static const double D1_BIN[10] = { 0.075981, 0.115129, 0.105204, 0.098830, 0.105904, 0.108086, 0.098644, 0.083913, 0.085837, 0.122472 }; +static const double D1_LOW = 0.012163, D1_UP = 0.034887; +static double cell_cut[NCELL + 1], cell_cum[NCELL + 1]; +static void make_cells(double bin0) +{ + double m[NCELL], rest = 0; + for (int j = 1; j < 10; j++) rest += D1_BIN[j]; + double scale = (1.0 - bin0) / rest; + double b[10]; + b[0] = bin0; + for (int j = 1; j < 10; j++) b[j] = D1_BIN[j] * scale; + double lfrac = D1_LOW / D1_BIN[0], ufrac = D1_UP / D1_BIN[9]; + m[0] = b[0] * lfrac; m[1] = b[0] - m[0]; + for (int j = 1; j < 9; j++) m[j + 1] = b[j]; + m[10] = b[9] - b[9] * ufrac; m[11] = b[9] * ufrac; + double cut[NCELL + 1] = { 0, 0.025, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.975, 1.0 }; + double cum = 0; + for (int i = 0; i <= NCELL; i++) { cell_cut[i] = cut[i]; cell_cum[i] = cum; if (i < NCELL) cum += m[i]; } + cell_cum[NCELL] = 1.0; +} +/* u such that the cell CDF at u equals p */ +static double cells_inv(double p) +{ + for (int i = 0; i < NCELL; i++) + if (p <= cell_cum[i + 1] || i == NCELL - 1) { + double w = cell_cum[i + 1] - cell_cum[i]; + double f = w > 0 ? (p - cell_cum[i]) / w : 0.5; + return cell_cut[i] + f * (cell_cut[i + 1] - cell_cut[i]); + } + return 1.0; +} +/* scale s so that P(|s z| < 1.959964) = cov */ +static double scale_for_cov(double cov) +{ + double lo = 0.5, hi = 3.0; + for (int i = 0; i < 80; i++) { + double s = 0.5 * (lo + hi); + double c = 2 * Phi(1.959963984540054 / s) - 1; + if (c > cov) lo = s; else hi = s; + } + return 0.5 * (lo + hi); +} + +typedef struct { int nrun; long seconds; double w, rho, rho10; int cas; double bin0; double s_b, s_b10, s_c10; } cfg_t; + +#define MAXN 20000 +#define MAXB 1000 +typedef struct { + int n, nb; + double u[MAXN], z[MAXN]; + int blk[MAXN]; unsigned char idle[MAXN]; + int bstart[MAXB], blevel[MAXB]; +} seq_t; + +/* one sequence over nrun runs; kind 0 = one-step, 1 = ten-step */ +static void gen_seq(const cfg_t *g, u64 *rng, int kind, seq_t *sq) +{ + double rho = kind ? g->rho10 : g->rho; + int n = 0, nb = 0; + for (int r = 0; r < g->nrun; r++) { + long acc = 0, step = 0; + double a = gauss(rng); + while (acc < g->seconds && nb < MAXB - 1) { + int lv = (int)(splitmix64(rng) % 4u); + long d = 20 + (long)(splitmix64(rng) % 101u); + if (acc + d > g->seconds) d = g->seconds - acc; + double b = gauss(rng); + sq->bstart[nb] = n; sq->blevel[nb] = lv; + for (long k = 0; k < d; k++, step++) { + a = rho * a + sqrt(1 - rho * rho) * gauss(rng); + double z0 = sqrt(g->w) * b + sqrt(1 - g->w) * a; + if (step >= 30 && n < MAXN) { + double u, zz; + if (g->cas == 1) { double s = kind ? g->s_b10 : g->s_b; zz = s * z0; u = Phi(zz); } + else if (g->cas == 2 && kind == 0) { u = cells_inv(Phi(z0)); zz = probit(u < 1e-12 ? 1e-12 : u > 1 - 1e-12 ? 1 - 1e-12 : u); } + else if (g->cas == 2) { zz = g->s_c10 * z0; u = Phi(zz); } + else { zz = z0; u = Phi(z0); } + sq->u[n] = u; sq->z[n] = zz; sq->blk[n] = nb; sq->idle[n] = lv == 0; n++; + } + } + acc += d; nb++; + } + } + sq->n = n; sq->nb = nb; + sq->bstart[nb] = n; +} + +/* statistic vector: cov50 cov80 cov95 low up bin0..9 z */ +#define NS 16 +static void contrib1(double u, double z, double v[NS]) +{ + double d = fabs(u - 0.5); + v[0] = d < 0.25; v[1] = d < 0.4; v[2] = d < 0.475; v[3] = u < 0.025; v[4] = u > 0.975; + int j = (int)(u * 10); if (j > 9) j = 9; if (j < 0) j = 0; + for (int k = 0; k < 10; k++) v[5 + k] = (k == j); + v[15] = z; +} +static const double LO[NS] = { 0.46, 0.76, 0.93, 0.010, 0.010, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, -0.10 }; +static const double HI[NS] = { 0.54, 0.84, 0.97, 0.040, 0.040, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.10 }; + +static int cmpd(const void *a, const void *b) { double x = *(const double *)a, y = *(const double *)b; return x < y ? -1 : x > y; } + +/* outcome 0 PASS, 1 NOT_ESTABLISHED, 2 HELD_OUT_FAIL */ +static int one_rep(const cfg_t *g, u64 *rng, int boot) +{ + static seq_t s1, s10; + static double bs[MAXB][NS], bs10[MAXB]; + static double lo[NS], hi[NS], val[NS], *draw[NS + 1]; + gen_seq(g, rng, 0, &s1); + gen_seq(g, rng, 1, &s10); + memset(bs, 0, sizeof bs); memset(bs10, 0, sizeof bs10); + double tot[NS] = { 0 }, bn[MAXB] = { 0 }, bn10[MAXB] = { 0 }, tot10 = 0; + for (int i = 0; i < s1.n; i++) { + double v[NS]; contrib1(s1.u[i], s1.z[i], v); + for (int k = 0; k < NS; k++) { bs[s1.blk[i]][k] += v[k]; tot[k] += v[k]; } + bn[s1.blk[i]] += 1; + } + for (int i = 0; i < s10.n; i++) { double c = fabs(s10.u[i] - 0.5) < 0.475; bs10[s10.blk[i]] += c; tot10 += c; bn10[s10.blk[i]] += 1; } + int n = s1.n, n10 = s10.n; + for (int k = 0; k < NS; k++) val[k] = tot[k] / n; + double v10 = tot10 / n10; + /* bootstrap */ + static double buf[NS + 1][2000]; + if (boot > 2000) boot = 2000; + for (int k = 0; k <= NS; k++) draw[k] = buf[k]; + for (int r = 0; r < boot; r++) { + double sum[NS] = { 0 }, cnt = 0, sum10 = 0, cnt10 = 0; + for (int i = 0; i < s1.nb; i++) { int b = (int)(splitmix64(rng) % (u64)s1.nb); for (int k = 0; k < NS; k++) sum[k] += bs[b][k]; cnt += bn[b]; } + for (int i = 0; i < s10.nb; i++) { int b = (int)(splitmix64(rng) % (u64)s10.nb); sum10 += bs10[b]; cnt10 += bn10[b]; } + for (int k = 0; k < NS; k++) draw[k][r] = sum[k] / cnt; + draw[NS][r] = sum10 / cnt10; + } + int ilo = (int)floor(0.0025 * (boot - 1)), ihi = (int)ceil(0.9975 * (boot - 1)); + for (int k = 0; k <= NS; k++) { + qsort(draw[k], (size_t)boot, sizeof(double), cmpd); + if (k < NS) { lo[k] = draw[k][ilo]; hi[k] = draw[k][ihi]; } + } + double lo10 = draw[NS][ilo], hi10 = draw[NS][ihi]; + int fail = 0, definite = 0; + for (int k = 0; k < NS; k++) { + if (val[k] < LO[k]) { fail = 1; if (hi[k] < LO[k]) definite = 1; } + if (val[k] > HI[k]) { fail = 1; if (lo[k] > HI[k]) definite = 1; } + } + if (v10 < 0.90) { fail = 1; if (hi10 < 0.90) definite = 1; } + if (v10 > 0.99) { fail = 1; if (lo10 > 0.99) definite = 1; } + /* P8 lag-1 of z, point only */ + double zm = val[15], num = 0, den = 0; + for (int i = 0; i < n; i++) { den += (s1.z[i] - zm) * (s1.z[i] - zm); if (i) num += (s1.z[i] - zm) * (s1.z[i - 1] - zm); } + if (fabs(num / den) > 0.20) { fail = 1; definite = 1; } + /* P9 quarters and regimes, point only */ + for (int q = 0; q < 4; q++) { + long a = (long)q * n / 4, b = (long)(q + 1) * n / 4; double c = 0; + for (long i = a; i < b; i++) c += fabs(s1.u[i] - 0.5) < 0.475; + c /= (double)(b - a); + if (c < 0.90 || c > 0.99) { fail = 1; definite = 1; } + } + for (int rg = 0; rg < 2; rg++) { + double c = 0, m = 0; + for (int i = 0; i < n; i++) if (s1.idle[i] == rg) { c += fabs(s1.u[i] - 0.5) < 0.475; m++; } + if (m >= 100 && (c / m < 0.90 || c / m > 0.99)) { fail = 1; definite = 1; } + } + if (n < 4000) { fail = 1; definite = 1; } + return !fail ? 0 : definite ? 2 : 1; +} + +static void setup(cfg_t *g) +{ + g->s_b = scale_for_cov(0.92); + g->s_b10 = scale_for_cov(0.92); + g->s_c10 = scale_for_cov(0.9402); +} + +static int cmd_run(int argc, char **argv) +{ + cfg_t g = { 2, 2700, 0.08, 0.02, 0.90, 0, 0.075981, 0, 0, 0 }; + int reps = 1000, boot = 1000; u64 seed = 0xE6A001ull; char cs = 'a'; + for (int i = 0; i < argc; i++) { + if (!strcmp(argv[i], "--case") && i + 1 < argc) cs = argv[++i][0]; + else if (!strcmp(argv[i], "--bin0") && i + 1 < argc) g.bin0 = atof(argv[++i]); + else if (!strcmp(argv[i], "--reps") && i + 1 < argc) reps = atoi(argv[++i]); + else if (!strcmp(argv[i], "--boot") && i + 1 < argc) boot = atoi(argv[++i]); + else if (!strcmp(argv[i], "--runs") && i + 1 < argc) g.nrun = atoi(argv[++i]); + else if (!strcmp(argv[i], "--seconds") && i + 1 < argc) g.seconds = atol(argv[++i]); + else if (!strcmp(argv[i], "--w") && i + 1 < argc) g.w = atof(argv[++i]); + else if (!strcmp(argv[i], "--rho") && i + 1 < argc) g.rho = atof(argv[++i]); + else if (!strcmp(argv[i], "--rho10") && i + 1 < argc) g.rho10 = atof(argv[++i]); + else if (!strcmp(argv[i], "--seed") && i + 1 < argc) seed = strtoull(argv[++i], NULL, 0); + else { fprintf(stderr, "est6opchar run: bad argument %s\n", argv[i]); return 2; } + } + if (cs != 'a' && cs != 'b' && cs != 'c') { fprintf(stderr, "case must be a, b or c\n"); return 2; } + if (g.nrun < 1 || g.nrun > 4 || g.seconds < 100 || g.seconds > 4000 || reps < 1 || boot < 200 || g.w < 0 || g.w >= 1 || g.rho < 0 || g.rho >= 1 || g.rho10 < 0 || g.rho10 >= 1) { fprintf(stderr, "bad parameter range\n"); return 2; } + g.cas = cs == 'a' ? 0 : cs == 'b' ? 1 : 2; + setup(&g); + make_cells(g.bin0); + u64 rng = seed; + int cnt[3] = { 0, 0, 0 }; + for (int r = 0; r < reps; r++) cnt[one_rep(&g, &rng, boot)]++; + printf("case %c bin0 %.4f runs %d seconds %ld w %.3f rho %.3f rho10 %.3f reps %d boot %d seed 0x%llx\n", cs, g.bin0, g.nrun, g.seconds, g.w, g.rho, g.rho10, reps, boot, seed); + printf("PASS %.4f NOT_ESTABLISHED %.4f HELD_OUT_FAIL %.4f (counts %d %d %d)\n", (double)cnt[0] / reps, (double)cnt[1] / reps, (double)cnt[2] / reps, cnt[0], cnt[1], cnt[2]); + return 0; +} + +/* design effect of a bin-0 share (p = 0.1) over reps of calibrated case-a sequences, no bootstrap */ +static int cmd_deff(int argc, char **argv) +{ + cfg_t g = { 1, 2700, 0.08, 0.02, 0.90, 0, 0, 0, 0, 0 }; + int reps = 2000; u64 seed = 0xE6A002ull; + for (int i = 0; i < argc; i++) { + if (!strcmp(argv[i], "--reps") && i + 1 < argc) reps = atoi(argv[++i]); + else if (!strcmp(argv[i], "--runs") && i + 1 < argc) g.nrun = atoi(argv[++i]); + else if (!strcmp(argv[i], "--w") && i + 1 < argc) g.w = atof(argv[++i]); + else if (!strcmp(argv[i], "--rho") && i + 1 < argc) g.rho = atof(argv[++i]); + else if (!strcmp(argv[i], "--seed") && i + 1 < argc) seed = strtoull(argv[++i], NULL, 0); + else { fprintf(stderr, "est6opchar deff: bad argument %s\n", argv[i]); return 2; } + } + static seq_t s; + u64 rng = seed; + double m = 0, m2 = 0, nn = 0; + for (int r = 0; r < reps; r++) { + gen_seq(&g, &rng, 0, &s); + double c = 0; + for (int i = 0; i < s.n; i++) c += s.u[i] < 0.1; + c /= s.n; nn += s.n; m += c; m2 += c * c; + } + m /= reps; m2 /= reps; nn /= reps; + double var = m2 - m * m; + printf("deff w %.3f rho %.3f runs %d reps %d mean_steps %.0f bin0_mean %.4f bin0_se %.5f design_effect %.3f\n", g.w, g.rho, g.nrun, reps, nn, m, sqrt(var), var / (0.1 * 0.9 / nn)); + return 0; +} + +static int check(int ok, const char *what) { if (!ok) fprintf(stderr, "FAIL %s\n", what); return !ok; } + +static int cmd_selftest(void) +{ + int bad = 0; + bad += check(fabs(Phi(probit(0.975)) - 0.975) < 1e-12, "probit round trip"); + bad += check(fabs(probit(0.5)) < 1e-12 && fabs(probit(0.975) - 1.959963984540054) < 1e-9, "probit values"); + bad += check(fabs(2 * Phi(1.959963984540054 / scale_for_cov(0.92)) - 1 - 0.92) < 1e-9, "scale for 92 percent"); + make_cells(0.075981); + bad += check(fabs(cell_cum[2] - 0.075981) < 1e-9 && fabs(cell_cum[11] - (1 - 0.034887)) < 1e-9, "cells reproduce D1 bin shares"); + bad += check(fabs(cells_inv(0.075981) - 0.1) < 1e-9 && fabs(cells_inv(0.012163) - 0.025) < 1e-9, "cell inverse"); + cfg_t g = { 2, 2700, 0.08, 0.02, 0.90, 0, 0.075981, 0, 0, 0 }; + setup(&g); + u64 r1 = 77, r2 = 77; + static seq_t a, b; + gen_seq(&g, &r1, 0, &a); gen_seq(&g, &r2, 0, &b); + bad += check(a.n == b.n && a.n > 5000 && a.n < 5400 && !memcmp(a.u, b.u, sizeof(double) * (size_t)a.n), "deterministic, about 2 x 2650 steps"); + double m = 0; for (int i = 0; i < a.n; i++) m += a.u[i]; + bad += check(fabs(m / a.n - 0.5) < 0.05, "case a PIT mean near 0.5"); + /* case a at large n: pass; case b: never pass; deterministic outcomes */ + g.cas = 0; u64 r3 = 5; int pass_a = 0; + for (int i = 0; i < 20; i++) pass_a += one_rep(&g, &r3, 300) == 0; + bad += check(pass_a >= 14, "calibrated forecaster passes most reps"); + g.cas = 1; u64 r4 = 6; int pass_b = 0; + for (int i = 0; i < 20; i++) pass_b += one_rep(&g, &r4, 300) == 0; + bad += check(pass_b == 0, "92 percent coverage never passes"); + if (!bad) printf("est6opchar selftest: PASS\n"); + return bad ? 1 : 0; +} + +int main(int argc, char **argv) +{ + if (argc >= 2 && !strcmp(argv[1], "run")) return cmd_run(argc - 2, argv + 2); + if (argc >= 2 && !strcmp(argv[1], "deff")) return cmd_deff(argc - 2, argv + 2); + if (argc >= 2 && !strcmp(argv[1], "selftest")) return cmd_selftest(); + fprintf(stderr, "usage: est6opchar run|deff|selftest ...\n"); + return 2; +} diff --git a/tools/estimation/est6opchar_table.sh b/tools/estimation/est6opchar_table.sh new file mode 100755 index 000000000..0e8d5e4a1 --- /dev/null +++ b/tools/estimation/est6opchar_table.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# Operating-characteristics table for est-v6 section 6 (appendix est-v6-appendix-prefreeze.md). +# usage: est6opchar_table.sh [reps] +# Reads no data file. Clustering settings: w 0.08 (design effect about 3.3), 0.12 (about 4.5), +# 0.20 (about 7); rho 0.02. Two 2700 s runs pooled (H1 + H2); three runs for comparison. +set -eu +B=${1:?usage: est6opchar_table.sh BIN [reps]} +R=${2:-4000} +for w in 0.08 0.12 0.20; do + for runs in 2 3; do + for c in a b; do + "$B" run --case $c --w $w --rho 0.02 --runs $runs --reps "$R" --boot 1000 | tail -n 2 | paste -sd' ' | sed "s/^/w=$w runs=$runs /" + done + done +done +for w in 0.08 0.12 0.20; do + for b0 in 0.100 0.090 0.080 0.076 0.070 0.065 0.060; do + "$B" run --case c --bin0 $b0 --w $w --rho 0.02 --runs 2 --reps "$R" --boot 1000 | tail -n 2 | paste -sd' ' | sed "s/^/w=$w /" + done +done diff --git a/tools/estimation/test_est6dev.sh b/tools/estimation/test_est6dev.sh new file mode 100755 index 000000000..d253d85c8 --- /dev/null +++ b/tools/estimation/test_est6dev.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# Tests for est6dev and est6opchar (pre-freeze development tools). Reads only the committed v5 D1 +# development folder; every held-out path must be refused before any file is opened. +# usage: test_est6dev.sh +set -eu +E=${1:?est6dev binary} +O=${2:?est6opchar binary} +D1=evidence/EST5/raw/20261001T153156Z-est5-fit-silicon +fail=0 +chk() { if [ "$1" = ok ]; then :; else echo "FAIL $2"; fail=1; fi; } + +# 1. held-out refusals (path tags and the v5 D2 date tag), exit status 2, nothing opened +for p in evidence/EST5/raw/20261005T112838Z-est5-heldout-silicon evidence/X/raw/zz-est6-heldout-silicon evidence/EST3C/raw/zz-est3c-heldout-q; do + rc=0 + "$E" g1pit --raw "$p/machine-state.ndjson" --marks "$p/machine-state-marks.txt" --dyn 1 --q 10000 --lam 0.1 --nu 1.25 --c 0.7 >/dev/null 2>&1 || rc=$? + [ "$rc" = 2 ] && chk ok x || chk bad "g1pit did not refuse held-out path $p (rc $rc)" + rc=0 + "$E" g1s --raw "$p/machine-state.ndjson" --marks "$p/machine-state-marks.txt" --dyn 1 --q 10000 --lam 0.1 --nu 1.25 >/dev/null 2>&1 || rc=$? + [ "$rc" = 2 ] && chk ok x || chk bad "g1s did not refuse held-out path $p (rc $rc)" +done + +# 2. schedule generator reproduces the v5 protocol text (seed 0xE5C5D1: idle 406, L6 929, L12 655, L18 710) +"$E" sched 0xE5C5D1 2700 | grep -q '^segments 39 idle 406 L6 929 L12 655 L18 710$' && chk ok x || chk bad "schedule totals for 0xE5C5D1" +"$E" sched 0xE5C5D1 2700 | grep -q '^schedule 0 0 74$' && chk ok x || chk bad "schedule first segment 0xE5C5D1" +# ... and the recorded schedule.txt of the v5 D1 folder (seed 0xE5C5D2) line for line +"$E" sched 0xE5C5D2 2700 | grep '^schedule' | cut -d' ' -f2- > "${TMPDIR:-/tmp}/e6dev.sched.$$" +grep '^schedule' $D1/schedule.txt | cut -d' ' -f2- | cmp -s - "${TMPDIR:-/tmp}/e6dev.sched.$$" && chk ok x || chk bad "schedule 0xE5C5D2 vs D1 schedule.txt" +rm -f "${TMPDIR:-/tmp}/e6dev.sched.$$" +# balance rule: 0xE5C5D1 fails (L6 929 > 900), pick moves +1 until it passes +"$E" sched 0xE5C5D1 2700 | grep -q '^balance FAIL$' && chk ok x || chk bad "balance FAIL expected" +"$E" pick 0xE6C6D1 2700 | grep -q '^picked 0xe6c6d3 after 2 failures$' && chk ok x || chk bad "pick 0xE6C6D1" + +# 3. G1 on v5 D1 with the v5 parameters reproduces params.txt (n 2652, bin0 0.075981, cov95 0.952950, mean z 0.046045) +out=$("$E" g1pit --raw $D1/machine-state.ndjson --marks $D1/machine-state-marks.txt --dyn 1 --q 10000 --lam 0.1 --nu 1.25 --c 0.7 --boot 200) +echo "$out" | grep -q '^n_scored 2652 unscorable 0$' && chk ok x || chk bad "n_scored" +echo "$out" | grep -q '^stat pit_bin0 0.075981 ' && chk ok x || chk bad "pit_bin0 vs params.txt" +echo "$out" | grep -q '^stat coverage95 0.952950 ' && chk ok x || chk bad "coverage95 vs params.txt" +echo "$out" | grep -q '^mean_z_midpit 0.046045$' && chk ok x || chk bad "mean z vs params.txt" +# deterministic bootstrap +out2=$("$E" g1pit --raw $D1/machine-state.ndjson --marks $D1/machine-state-marks.txt --dyn 1 --q 10000 --lam 0.1 --nu 1.25 --c 0.7 --boot 200) +[ "$out" = "$out2" ] && chk ok x || chk bad "bootstrap not deterministic" + +# 4. G1S at kappa 1.0 reproduces the G1 in-sample log score (-1.962811) +"$E" g1s --raw $D1/machine-state.ndjson --marks $D1/machine-state-marks.txt --dyn 1 --q 10000 --lam 0.1 --nu 1.25 | grep -q '^insample kappa 1.0 best_c 0.70 mean_logscore -1.962811 ' && chk ok x || chk bad "g1s kappa 1.0 log score" + +# 5. simulation tool self test +"$O" selftest | grep -q 'selftest: PASS' && chk ok x || chk bad "est6opchar selftest" +a=$("$O" run --case a --reps 50 --boot 300) ; b=$("$O" run --case a --reps 50 --boot 300) +[ "$a" = "$b" ] && chk ok x || chk bad "est6opchar not deterministic" + +if [ "$fail" = 0 ]; then echo "test-est6dev: PASS"; else exit 1; fi From ca12ad5bb771d41056b9c99571d736171a64b78d Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Mon, 5 Oct 2026 09:13:07 -0500 Subject: [PATCH 2/5] estimation v6: pre-freeze development appendix (D1 only, not frozen) Items 1 to 4 of est-v6 section 9 on development data only: G1 PIT and miss-rate clustering (design effect 3.0 and 4.2), exact seed schedules and the balance defect, reduced G1S block-CV check, operating-characteristics simulation. Co-Authored-By: Claude Opus 5.5 --- .../protocols/est-v6-appendix-prefreeze.md | 291 ++++++++++++++++++ 1 file changed, 291 insertions(+) create mode 100644 docs/estimation/protocols/est-v6-appendix-prefreeze.md diff --git a/docs/estimation/protocols/est-v6-appendix-prefreeze.md b/docs/estimation/protocols/est-v6-appendix-prefreeze.md new file mode 100644 index 000000000..1719bd9bd --- /dev/null +++ b/docs/estimation/protocols/est-v6-appendix-prefreeze.md @@ -0,0 +1,291 @@ +# ESTIMATION v6 pre-freeze development appendix (D1 only, NOT FROZEN) + +Companion to `est-v6.md` (a PROPOSAL, sha256 in section 7). This appendix is +the development work of section 9 of that file, items 1 to 4. It is not a freeze, not a v6 result and +says nothing about held-out performance. It changes no v5 threshold, parameter, receipt or tool and +no v6 protocol text. Item 5 (hashes, freeze commit) is not done here. + +Tool commit for every command below: `ec0b815ad4d475d640781ee9a95bd45621037ecf` (adds +`tools/estimation/est6dev.c`, `est6opchar.c`, `est6opchar_table.sh`, `test_est6dev.sh`, +`mk/estimation_v6dev.mk`; sources sha256 are in section 7). Machine: quiet flag free at every run +(`quietlock check` returned 0 before each build and long run); no collection, no chip window, no +`est5_collect`. + +## 1. Data used and not used + +Read (development data only): + +| input | sha256 | +|---|---| +| v5 D1 `evidence/EST5/raw/20261001T153156Z-est5-fit-silicon/machine-state.ndjson` | `7da6e4950c333bae65e5663c32c9cfe9de6657f0ff88c55e9b9e767152634465` | +| v5 D1 `machine-state-marks.txt` | `6cd7fda33d877a07e6fd21423f0ebc425c616c4d029f3575165ed6e32a02f748` | +| v5 D1 `schedule.txt` | `061e287c76b6878caa675833225c98df601aa15fe4231254a1bf1ab086fcb417` | +| v3 D1 `evidence/EST3C/raw/20261001T025159Z-est3c-fit-silicon/machine-state.ndjson` | `9d5473b56dbb3765e5fc5335ef74aec47a11485651bcffc75272062ab48dc230` | +| v3 D1 `machine-state-marks.txt` | `4dfd06ec3f07c96eefe9697da2809634a0d4db2bfe4718909f2d0ca2c23d7a72` | + +Also read: `docs/estimation/protocols/est-v5.md`, `est-v6.md`, `receipts/est-v5/params.txt` (D1 fit +numbers), `receipts/est-v5/d1.sha256`, and, for the `est5` build only, the hash text of +`receipts/est-v5/d2.sha256` that `mk/estimation_v5.mk` compiles into the binary (hashes, not data). +`docs/estimation/RECEIPT_JSON.md` is not on main (the receipt JSON fix is on another branch) and was +not read. + +Never read: any v5 D2 file (raw, marks, schedule), any held-out folder of any version. Check: every +data-tool run below was executed under `strace -f -e trace=openat`; the opened `evidence/` paths were +exactly the five D1 and v3 D1 files above plus their `SHA256SUMS`, and `grep -c "20261005T112838Z\|heldout"` +over the four tool traces is 0. The one literal `est5 fit` rerun (section 2) also lists D1 `WINDOW` and +`process-monitor.log`. Its trace shows the `git status` that `est5` runs on itself stat-ing and +listing the names inside the D2 folder (directory entries only); no D2 file was opened or read. The +est6dev tool and its test refuse held-out path tags and the D2 date tag before opening anything and refuse +an input whose SHA-256 is the D2 raw SHA. + +## 2. Item 1: v5 G1 on v5 D1 and v3 D1 + +2a. Existing tool rerun. `make est5` (clean tree at e9c2829), then +`est5 fit --raw --marks --out /tmp/est5-rerun-params.txt` (not written to the repo). +Result: `EST5_FIT selected=G1 phase_a=PASS`. The new params file differs from +`receipts/est-v5/params.txt` in exactly one line, `tool_commit` (e9c2829 against d7fbc5c); every +parameter, score, screen value and grid-edge flag is identical. So the v5 fit reproduces +bit for bit on v5 D1 with the existing tool. + +2b. PIT bins, lower and upper miss rates, block bootstrap. The existing tool has no mode that scores +fixed parameters and prints per-step PIT, so `est6dev g1pit` runs the unchanged v5 library +(`src/estimation/est_v4.c`) with the selected G1 parameters (dyn 1, q 10000, lam 0.1, nu 1.25, c 0.7), same +classification, burn-in and scoring loop as `est5.c`, and reproduces `params.txt` exactly (n 2652, pit_bin0 +0.075981, coverage95 0.952950, mean z 0.046045; checked by `make test-est6dev`). + +``` +est6dev g1pit --raw /machine-state.ndjson --marks /machine-state-marks.txt \ + --dyn 1 --q 10000 --lam 0.1 --nu 1.25 --c 0.7 --blocks +``` + +Lower miss rate = expected share of outcomes below the 2.5 % quantile of the predictive (fractional, +as the v5 bins); upper the same above 97.5 %. Blocks = whole load segments: each marked load segment, +and each idle stretch between marked segments (adjacent idle schedule segments leave no marks and are +one block). Resampling: whole blocks with replacement, 2000 draws, seed 0xE6B007, ratio estimator. +Design effect = bootstrap variance over the independent-step variance p(1-p)/n. + +v5 D1, n 2652, 35 blocks (27 loaded, 8 idle): + +| statistic | value | iid SE | block SE | design effect | 95 % interval | 99.5 % interval | +|---|---|---|---|---|---|---| +| pit_bin0 | 0.0760 | 0.0051 | 0.0089 | 3.0 | 0.0577 to 0.0933 | 0.0508 to 0.0977 | +| pit_bin1 | 0.1151 | 0.0062 | 0.0054 | 0.8 | 0.1036 to 0.1250 | 0.0983 to 0.1291 | +| pit_bin2 to bin8 | 0.0839 to 0.1081 | | 0.0031 to 0.0053 | 0.3 to 0.9 | | | +| pit_bin9 | 0.1225 | 0.0064 | 0.0087 | 1.9 | 0.1061 to 0.1403 | 0.1001 to 0.1480 | +| lower miss 2.5 % | 0.0122 | 0.0021 | 0.0028 | 1.7 | 0.0072 to 0.0179 | 0.0049 to 0.0204 | +| upper miss 2.5 % | 0.0349 | 0.0036 | 0.0038 | 1.1 | 0.0276 to 0.0426 | 0.0248 to 0.0456 | +| coverage95 | 0.9530 | 0.0041 | 0.0046 | 1.3 | 0.9436 to 0.9616 | 0.9400 to 0.9654 | + +v3 D1 (same v5 G1 parameters, not refitted; v3 D1 was never fit data for v4 or v5), n 2651, 39 blocks: + +| statistic | value | iid SE | block SE | design effect | 99.5 % interval | +|---|---|---|---|---|---| +| pit_bin0 | 0.0602 | 0.0046 | 0.0094 | 4.2 | 0.0359 to 0.0881 | +| pit_bin9 | 0.0920 | 0.0056 | 0.0077 | 1.9 | 0.0702 to 0.1125 | +| lower miss 2.5 % | 0.0132 | 0.0022 | 0.0026 | 1.4 | 0.0070 to 0.0214 | +| upper miss 2.5 % | 0.0234 | 0.0029 | 0.0034 | 1.4 | 0.0143 to 0.0335 | +| coverage95 | 0.9634 | 0.0036 | 0.0043 | 1.4 | 0.9503 to 0.9739 | + +Findings (each from the numbers above; tags as in v6 section 2). +- PROVEN, bin 0 clustering: design effect 3.0 on v5 D1 and 4.2 on v3 D1, measured with 35 and 39 blocks + (so themselves noisy). Section 2a asked whether it is near 7.5 (the value needed for the shortfall to be + noise). It is not, on either set. With these design effects one run's bin share at 0.10 has a standard + error of 0.010 to 0.012, and the 0.07 limit is 2.5 to 3 standard errors away (5.2 under independence). + Pooling two runs (n about 5300, about 75 blocks) the standard error falls to about 0.007 to 0.008. +- PROVEN, G1 with the v5 parameters puts bin 0 below 0.07 on v3 D1 (0.0602) where the parameters + were not fitted. The shortfall is not specific to the D2 run: v5 D1 in sample 0.0760, v3 D1 0.0602. +- PROVEN, the lower tail is not light in the 2.5 % sense: lower miss 0.0122 and 0.0132 are just above the + proposed P4 floor of 0.010 on both sets, upper miss 0.0349 and 0.0234. Lower miss is thin on v5 D1 + (0.0122 against a floor of 0.010; 99.5 % interval 0.0049 to 0.0204 reaches below it). +- PROVEN, the PIT is regime dependent, which a global skew cannot reproduce. By declared load level + (descriptive, from `est6dev g1pit`): + +| level | v5 D1 steps | bin0 | bin9 | lower miss | upper miss | v3 D1 steps | bin0 | bin9 | +|---|---|---|---|---|---|---|---|---| +| idle | 818 | 0.116 | 0.077 | 0.030 | 0.036 | 235 | 0.152 | 0.086 | +| L6 | 739 | 0.111 | 0.114 | 0.010 | 0.017 | 672 | 0.127 | 0.102 | +| L12 | 970 | 0.025 | 0.159 | 0.000 | 0.041 | 1079 | 0.025 | 0.091 | +| L18 | 125 | 0.000 | 0.184 | 0.000 | 0.085 | 665 | 0.018 | 0.087 | + + Bin 0 is over-filled when idle or at L6 (above 0.11) and almost empty at L12 and L18. The forecast under-reads + heating under load (outcomes land above the median) and over-reads cooling. The pooled 0.076 is a mixture. LIKELY + (not tested by a fit): the dominant cause of the pooled bin 0 and bin 9 deviations is regime-dependent bias + (the model lags load changes), not a symmetric-tail problem. The section 2b hypothesis (asymmetric tails) is at + best a partial explanation (section 4 below). + +## 3. Item 4: exact schedules for the declared seeds and the balance check + +`est6dev sched 2700` implements the `est_load.c` draw order (splitmix64, level = draw mod 4 over +{0,6,12,18}, length = 20 + draw mod 101, last segment clipped), without running any load. Validation: +`est6dev sched 0xE5C5D1 2700` reproduces the schedule printed in `est-v5.md` section 4 (39 segments; idle 406, +L6 929, L12 655, L18 710; first segment 0/74), and `est6dev sched 0xE5C5D2 2700` reproduces the recorded +`schedule.txt` of the v5 D1 folder line for line (checked in `make test-est6dev`). Side finding: the v5 D1 +folder that was fitted was collected with seed 0xE5C5D2 (the seed + 1 recollection of v5 section 7), not the +0xE5C5D1 whose schedule `est-v5.md` section 4 prints. + +Balance rule of v6 section 3 (each of idle, L6, L12, L18 between 400 and 900 s), applied literally and +repeatedly (+1 until a seed passes), command `est6dev pick 2700`: + +| role | declared seed | schedule at declared seed (segments; idle, L6, L12, L18 s) | balance | seed after rule | +|---|---|---|---|---| +| v6 F | 0xE6C6D1 | 36; 368, 518, 1271, 543 | FAIL (idle, L6, L12) | 0xE6C6D2 fails (938, 738, 374, 650), **0xE6C6D3** passes (36 segments; 460, 896, 606, 738) | +| v6 H1 | 0xD6E6C7 | 38; 257, 909, 836, 698 | FAIL (idle, L6) | 0xD6E6C8, C9, CA fail, **0xD6E6CB** passes (41 segments; 522, 572, 857, 749) | +| v6 H2 | 0xD6E6C8 | 36; 411, 686, 543, 1060 | FAIL (L18) | 0xD6E6C9, CA fail, **0xD6E6CB** passes | + +Exact segment lists (level/seconds) for the seeds that pass, from `est6dev sched`: +- F, 0xE6C6D3: 18/106 12/107 18/84 12/118 6/36 6/90 18/58 0/90 18/48 18/25 6/84 12/51 6/116 18/88 6/65 + 12/117 18/47 0/41 18/116 6/65 6/62 6/35 0/34 18/87 18/79 12/67 12/54 0/104 6/94 0/97 0/86 6/95 6/36 6/118 + 12/92 0/8 +- H1, 0xD6E6CB: 12/90 0/22 6/62 12/93 18/71 6/97 6/26 18/45 18/52 0/43 18/22 0/64 12/29 0/75 6/79 12/53 + 18/112 6/62 18/107 12/102 0/23 18/68 6/23 18/37 6/67 18/91 0/20 0/82 18/115 0/45 0/96 12/50 12/97 12/83 6/95 + 12/109 12/98 12/53 0/52 6/61 18/29 + +**Defect in the proposal, to be fixed at freeze (not decided here).** All three declared seeds fail the balance +rule. Applied literally, H1 and H2 both land on 0xD6E6CB, so the two "independent" held-out runs would have the +identical schedule. A freeze text must say, for example, that each later seed in a chain skips seeds already +used, in which case H2 becomes the next passing seed after 0xD6E6CB, which is **0xD6E6CD** (38 segments; idle 640, +L6 810, L12 569, L18 681; `est6dev pick 0xD6E6CC 2700`). Alternatively choose declared seeds that pass. The +schedule alone decides either way; no data is needed. + +## 4. Item 2: G1S fit with block cross-validation (REDUCED, not the full item) + +Size assessment of the full item. The protocol's G1S fit is a new model plus the whole fit machinery with +block CV: a two-piece Student-t discretiser that must equal `est_v4.c` bit for bit at kappa 1.0 (a new +`est_v6.c`, about 150 lines with its own t CDF, or an edited copy of `est_v4.c`), segment-fold bookkeeping, +the full G1 grid per fold for each of 5 kappa values (47628 stage-1 points per kappa, six fits), a full-pmf +rescoring path for PIT statistics, and agreement checks with the fast path. That is roughly 500 to 700 lines and +a long grid run, over the 300 line limit set for this session, so the full item is NOT implemented. Design +note for the full item: build `est_v6.c` as `est4_dpred` with side masses 1/(1+kappa) and kappa/(1+kappa) +(density continuous at the location), scale c on the upper side and c kappa on the lower side; reuse the `est5.c` +trace and fast-score structure with a per-step fold mask (fold = segment rank mod 5); search the v5 grid +(dyn, q, lam, nu, c) times kappa in {0.6..1.0} on 4 folds, score the held-out fold, pool; test kappa 1.0 against the +unchanged v5 library bit for bit before any other use. + +What was done instead (about 110 lines in `est6dev g1s`): keep the v5 G1 filter parameters (dyn 1, q 10000, +lam 0.1, nu 1.25) fixed and search only kappa in {0.6, 0.7, 0.8, 0.9, 1.0} and c in 0.20 to 1.20 by 5 folds +over blocks (fold = rank of the block among load segments and idle stretches, modulo 5), the two-piece t built +from the unchanged symmetric kernel `est4_fast_logp`. Check: at kappa 1.0 it reproduces the G1 log score +-1.962811 (maximum absolute difference to `est4_fast_logp` 2.4e-11, so not bit for bit; not the final +estimator). Command: + +``` +est6dev g1s --raw /machine-state.ndjson --marks /machine-state-marks.txt --dyn 1 --q 10000 --lam 0.1 --nu 1.25 +``` + +v5 D1, in sample (best c per kappa): + +| kappa | c | mean log score | bin0 | bin9 | lower miss | upper miss | +|---|---|---|---|---|---|---| +| 0.6 | 0.90 | -1.9977 | 0.151 | 0.077 | 0.025 | 0.018 | +| 0.7 | 0.80 | -1.9782 | 0.132 | 0.093 | 0.022 | 0.024 | +| 0.8 | 0.75 | -1.9674 | 0.110 | 0.105 | 0.018 | 0.029 | +| 0.9 | 0.70 | -1.9630 | 0.095 | 0.117 | 0.016 | 0.033 | +| 1.0 (G1) | 0.70 | -1.9628 | 0.076 | 0.123 | 0.012 | 0.035 | + +Out of fold on v5 D1 (pooled, 2652 steps): + +| selection | mean log score | bin0 | bin9 | lower miss | upper miss | kappa chosen in folds 0 to 4 | +|---|---|---|---|---|---|---| +| kappa free, c refit by fold | -1.9649 | 0.0858 | 0.1203 | 0.0135 | 0.0342 | 1.0, 1.0, 0.9, 0.9, 1.0 | +| kappa 1.0, c refit by fold (control) | -1.9634 | 0.0770 | 0.1236 | 0.0122 | 0.0358 | 1.0 in all | + +Same procedure on v3 D1 (extra development data, not "v5 D1 alone"): out of fold kappa free: log score +-1.6046, bin0 0.0936, bin9 0.1007, lower miss 0.0186, upper miss 0.0259; control kappa 1.0: -1.6072, bin0 0.0787, bin9 +0.1109. In sample on v3 D1, kappa 0.9 is the best log score (-1.6025 against -1.6041 at 1.0). + +Reading (PROVEN as numbers, interpretation LIKELY): +- Kappa below 1 does move bin 0 up and bin 9 down, as hypothesised. Out of fold on v5 D1 by +0.009 (0.077 to 0.086); + on v3 D1 by +0.015 (0.079 to 0.094). Forcing kappa 0.8 to 0.9 gives bin 0 of 0.095 to 0.110 in sample on v5 D1. +- On v5 D1 the log score never prefers kappa below 1 in sample (-1.9628 at 1.0 against -1.9630 at 0.9) and the + out-of-fold log score is 0.0015 nats worse when kappa is free. On v3 D1 it prefers 0.9 by 0.0016 nats. The + gains are small against the 0.01 nat tie rule of section 5, which would keep G1 over G1S in both cases. +- The proposed inner-band screen (bins within [0.08, 0.12]) would reject G1 on v5 D1 out of fold (bin 0 0.0770) + and would pass G1S only barely on bin 0 (0.0858) while failing bin 9 by a hair (0.1203 against 0.12). So on this + evidence neither family cleanly passes the v6 inner screen on v5 D1 alone. +- Section 9 item 2 asked whether kappa below 1 fixes the lower bin out of fold. Answer: it moves it in the right + direction by about 0.01, not enough to settle the question, with the tail structure above (regime-dependent + bias) still unexplained by kappa. The main-hypothesis rejection test ("kappa stays at 1.0 and bin 0 stays low") is not + met cleanly: kappa 0.9 was chosen in 2 of 5 folds and bin 0 rose. A decision on G1S versus a regime-aware remedy + (v6 section 5 excluded regime-conditioned scale) needs the full item and belongs to the freeze lane. + +## 5. Item 3: operating characteristics of the v6 verdict + +Tool: `est6opchar` (reads no data file; `make est6-opchar-table`, 4000 replicates, 1000 bootstrap draws each, +seed 0xE6A001; selftest and determinism in `make test-est6dev`). Simulates the pooled H1 + H2 scoring of P1 to +P10 and the three-way verdict of v6 section 6 on synthetic randomised-PIT sequences: +latent Gaussian z with a per-segment effect (variance share w) and AR(1) within segments (rho 0.02), u = G(Phi(z)). +Segments follow the est_load draw (20 to 120 s, random level), one step per second after 30 s burn-in, two runs of +2700 s (n about 5300, P10 met). Intervals: 99.5 % block-bootstrap percentiles for P1 to P7 and mean z; lag-1 of +z and the P9 quarters and regimes use the point value (this can only raise the chance of HELD_OUT_FAIL). +Ten-step P7 is a separate sequence with within-segment rho 0.9 (an assumption: overlapping windows). The F1/E0 baseline +comparison is assumed met. Clustering w: 0.08 gives a bin-0 design effect of 3.3 (measured 3.0 on v5 D1), 0.12 gives +4.5 (measured 4.2 on v3 D1), 0.20 gives about 7 (the value 2a called necessary for noise); `est6opchar deff`. + +Case (a) calibrated forecaster; case (b) nominal 95 % that covers 92 % (scale 1.1195 on z); case (c) a forecaster +with the **v5 D1** PIT cell shares (bin 0 0.0760, bin 9 0.1225, lower miss 0.0122, upper miss 0.0349, from the table +above) and a bin 0 sweep. Case (c) is built from D1 numbers only; the D2 summary numbers are not used (the +protocol forbids D2 for power analysis). + +| clustering | runs | (a) calibrated: PASS / NOT_EST / HELD_OUT_FAIL | (b) covers 92 %: PASS / NOT_EST / HELD_OUT_FAIL | +|---|---|---|---| +| w 0.08 (deff about 3.3) | 2 | 0.9928 / 0.0073 / 0.0000 | 0.0025 / 0.5697 / 0.4278 | +| w 0.08 | 3 | 0.9992 / 0.0008 / 0.0000 | 0.0008 / 0.3835 / 0.6158 | +| w 0.12 (deff about 4.5) | 2 | 0.9732 / 0.0230 / 0.0037 | 0.0050 / 0.6535 / 0.3415 | +| w 0.12 | 3 | 0.9932 / 0.0067 / 0.0000 | 0.0020 / 0.5170 / 0.4810 | +| w 0.20 (deff about 7, stress) | 2 | 0.3478 / 0.0250 / 0.6272 | 0.0190 / 0.3220 / 0.6590 | +| w 0.20 | 3 | 0.3262 / 0.0097 / 0.6640 | 0.0135 / 0.2993 / 0.6873 | + +Requirement check (v6 section 6: false-fail under (a) at most 10 %, pass under (b) at most 10 %), two runs: +- w 0.08 and 0.12 (the measured range): false-fail, read as not PASS, 0.7 % and 2.7 %; as HELD_OUT_FAIL 0.0 % and + 0.4 %. Pass under (b) 0.25 % and 0.5 %. Both requirements are met with two runs; no length increase is needed + at these settings. +- w 0.20: fails. Cause: z lag-1 correlation about equals w, so the P8 bound of 0.20 on lag-1 z fails by + construction (the measured lag-1 z is -0.012 on v5 D1 in sample, so w this large is not supported by D1). The row + is a stress case, not a finding. It shows the gate set, not the interval rule, fails under very strong + serial dependence. +- Weak point of (b): a 92 % forecaster is called HELD_OUT_FAIL only 34 to 43 % of the time and NOT_ESTABLISHED + the rest (it never passes). It is flagged, not hidden, by the three-way verdict; a freeze that wants a + definite failure for a 92 % forecaster needs more data (three runs: 48 to 62 %). + +Case (c), power against a lower-tail shortfall (bin 0 swept, two runs): + +| true bin 0 | w 0.08: PASS / NOT_EST / HELD_OUT_FAIL | w 0.12: PASS / NOT_EST / HELD_OUT_FAIL | +|---|---|---| +| 0.100 | 0.872 / 0.128 / 0.000 | 0.820 / 0.177 / 0.004 | +| 0.090 | 0.836 / 0.164 / 0.000 | 0.788 / 0.208 / 0.004 | +| 0.080 | 0.755 / 0.244 / 0.001 | 0.701 / 0.295 / 0.004 | +| 0.076 (v5 D1 in sample) | 0.678 / 0.321 / 0.001 | 0.619 / 0.377 / 0.005 | +| 0.070 | 0.411 / 0.581 / 0.009 | 0.392 / 0.594 / 0.014 | +| 0.065 | 0.152 / 0.798 / 0.051 | 0.171 / 0.780 / 0.049 | +| 0.060 | 0.025 / 0.768 / 0.208 | 0.034 / 0.806 / 0.161 | + +Reading. A forecaster whose true bin 0 is 0.076 passes only 62 to 68 % of the time, and one at 0.070 only about 40 %, +because the other P gates (P4 floor on the lower miss, bin 9, P9) fail at the same time; it is called a definite fail +almost never. The verdict gives HELD_OUT_FAIL for a bin 0 as low as 0.065 in only 5 % of replicates; a shortfall of +that size would mostly be reported NOT_ESTABLISHED. That is the intended behaviour of the third outcome, and it also +means v6 as drafted rarely certifies a bin-0 shortfall as wrong. (c) with the D1 cells also embeds D1's lower miss +rate of 0.0122, which sits near the P4 floor of 0.010. + +Limits of the simulation: the data-generating model is a Gaussian copula with a segment effect, not the +forecaster; real clustering is partly a regime bias (section 2) that is not noise and not random across replicates; +P7 is crude; the baseline comparison and the real est_load level structure are not simulated. + +## 6. What this appendix does not do + +Item 5 is not done (hashes, `est_v6.c`, freeze commit). The full G1S fit (item 2) is not done; the design note is in +section 4. No v6 text was changed, so the findings above (seed collision, balance rule applied by chaining, regime +dependence, the G1S inner-band outcome, the weak definite-fail power of the verdict) are for the freeze lane to act on. +Nothing here uses or concerns held-out data. + +## 7. Reproduction, hashes + +``` +make test-est6dev # tools tests, D1 and synthetic data only +make est6dev est6opchar +make est6-opchar-table # section 5 table +``` +- `docs/estimation/protocols/est-v6.md` sha256 `4fee44c729130cb37e5588b105077f4d8c17ea8c160dbfb310fdec720ff6316f` (commit e9c2829). +- `tools/estimation/est6dev.c` sha256 `c020ee872be90f7cdd62a56a8bd0c8f09e20f3ae4cdd659ccbb2b18b90e81c4d`; + `tools/estimation/est6opchar.c` sha256 `bab7a55043065ed689478f96420de6a698763c4eb4589881438562aff126f0c1`. +- `est5` rerun: tool commit e9c2829, protocol sha256 `275cd5b72570d5182ef73d635e16775026e9d911e818b8e12f8300a701187af5`; + params.txt of the rerun differs from the committed one only by the tool_commit line. From 03668208f618092c4e33ba9691e5b1a4ede9a613 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Mon, 5 Oct 2026 09:13:12 -0500 Subject: [PATCH 3/5] crumb compile for est6 pre-freeze tools Co-Authored-By: Claude Opus 5.5 --- .crumb | 24 ++++++++++++------------ docs/.crumb | 16 ++++++++-------- docs/estimation/.crumb | 10 +++++----- mk/.crumb | 10 +++++----- tools/.crumb | 16 ++++++++-------- tools/estimation/.crumb | 10 +++++----- 6 files changed, 43 insertions(+), 43 deletions(-) diff --git a/.crumb b/.crumb index 7bd530f11..78ebb601f 100644 --- a/.crumb +++ b/.crumb @@ -51,8 +51,8 @@ "purpose": "Directory calibration. Purpose not yet described by a human." }, { - "digest": "2b90281fb966737f5cfca02ad640c02326422b4146bca69cdbae095785ce2939", - "last_commit": "84b8efb", + "digest": "6e14289e56c71da98a060589cfd4c23818169b62a9d030c8f76dc4c3c933bac5", + "last_commit": "ca12ad5", "name": "docs", "purpose": "Directory docs. Purpose not yet described by a human." }, @@ -63,8 +63,8 @@ "purpose": "Directory doctrine. Purpose not yet described by a human." }, { - "digest": "1a09c53fc4d21cd13d4f307282aeabcbf896a0639618c8767a3011d49d4cc613", - "last_commit": "84b8efb", + "digest": "c5c1674600955e86dbd99a603d76ef472cd3742a1e8ed239a442fd0246f10d56", + "last_commit": "30c31b3", "name": "mk", "purpose": "Directory mk. Purpose not yet described by a human." }, @@ -99,21 +99,21 @@ "purpose": "Directory tests. Purpose not yet described by a human." }, { - "digest": "fcf0d77d97acf0c597b39c054307650cff03295797be8686f7aeaf634ba5c2b8", - "last_commit": "84b8efb", + "digest": "5ad4b231acdb798c3095477ce78effae88548c3703a9453c18ab95187fa6de81", + "last_commit": "30c31b3", "name": "tools", "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:be98693d48cc260552b701dcb16310940951090c323e3ef71e111d29b432d523", - "compiled_at": "2026-10-05T14:06:04Z", + "children_root": "sha256:766d986607c6c57c15323c085cc11ac26b442585c894276b4be4bd24d2b8558d", + "compiled_at": "2026-10-05T14:17:15Z", "compiler": "crumb-compile/1", - "digest": "sha256:2b3977f6ffc8a26a56977c451a50dd399ef3faa63652c71d686a85edd339b746", + "digest": "sha256:ebd63cbb38f19ac0da618b5eaf257f0dfa94ce3ac106b9706c5c645a06f32ba1", "evidence_files": 2749, "evidence_root": "sha256:c6e60c5b2803cfddf6a1fed130c92066d285ddb68aeea0bc65d58668cf139dfc", - "files": 4532, - "generated_at_commit": "84b8efb7b8cf2f6d7b3bd6c889d44c28c9e41e9f", - "source_tree": "sha256:89bbca0c2dbc0b31c5c074bb1ed807b50bd743a5b165078b9394682864f7004c" + "files": 4538, + "generated_at_commit": "ca12ad5bb771d41056b9c99571d736171a64b78d", + "source_tree": "sha256:4f2ba443e819ae28d02b04c281dbaa932cd56ca5fd061ca10c9d5a7a07e99154" }, "owner_lane": "", "provenance": { diff --git a/docs/.crumb b/docs/.crumb index 88c01185b..a68ddfc91 100644 --- a/docs/.crumb +++ b/docs/.crumb @@ -75,8 +75,8 @@ "purpose": "DUAL (ARCH-0031) documents in omega: applicability experiment method and findings (APPLICABILITY" }, { - "digest": "15c85e0bc41f6e3934e81753d361dea468177df79cb01b233e6a788af2a1dfb5", - "last_commit": "e9c2829", + "digest": "309099a51e1b169e9efddeec6aaf6003f130181e9d6087d9a2a64f62ed793cf9", + "last_commit": "ca12ad5", "name": "estimation", "purpose": "Directory docs/estimation. Purpose not yet described by a human." }, @@ -117,15 +117,15 @@ "purpose": "Directory docs/turing. Purpose not yet described by a human." } ], - "children_root": "sha256:eb93b138839b7bcbe693b0e315a1af8df7f1b82ea1bc7e313bfa606a893e7f6a", - "compiled_at": "2026-10-05T13:53:36Z", + "children_root": "sha256:bfed325d083303b9d78a04fe90d4c99d6feb960cf3059b0fc29828699de70803", + "compiled_at": "2026-10-05T14:17:15Z", "compiler": "crumb-compile/1", - "digest": "sha256:2b90281fb966737f5cfca02ad640c02326422b4146bca69cdbae095785ce2939", + "digest": "sha256:6e14289e56c71da98a060589cfd4c23818169b62a9d030c8f76dc4c3c933bac5", "evidence_files": 31, "evidence_root": "sha256:3f4d8ab7c723c9fddacc5a872541933a4b87d1bb39868b8ec376320db6c929af", - "files": 108, - "generated_at_commit": "e9c28294247e2add87335d615c762db9bbc0e48d", - "source_tree": "sha256:b2fab0ee7afbb68b3228f7830c4245a45c681aeaee3f60a88e65fbfccbd4de15" + "files": 109, + "generated_at_commit": "ca12ad5bb771d41056b9c99571d736171a64b78d", + "source_tree": "sha256:8d260d4f48b5fd2d0fe40289fc801b19e02749ef29ad7a7fcf2be7a9777d4e89" }, "owner_lane": "", "provenance": { diff --git a/docs/estimation/.crumb b/docs/estimation/.crumb index 75b89d5f1..394ffffd4 100644 --- a/docs/estimation/.crumb +++ b/docs/estimation/.crumb @@ -24,14 +24,14 @@ } ], "children_root": "sha256:35cd3af03e079556db7f3ebcfd7590fa68659e84dd603795ae6b5b048dc2af0d", - "compiled_at": "2026-10-05T13:53:36Z", + "compiled_at": "2026-10-05T14:17:15Z", "compiler": "crumb-compile/1", - "digest": "sha256:15c85e0bc41f6e3934e81753d361dea468177df79cb01b233e6a788af2a1dfb5", + "digest": "sha256:309099a51e1b169e9efddeec6aaf6003f130181e9d6087d9a2a64f62ed793cf9", "evidence_files": 31, "evidence_root": "sha256:3f4d8ab7c723c9fddacc5a872541933a4b87d1bb39868b8ec376320db6c929af", - "files": 43, - "generated_at_commit": "e9c28294247e2add87335d615c762db9bbc0e48d", - "source_tree": "sha256:6641d05683459dc4f7b550f6ac88c9f93c90f807ad9b844d58cfefcb99a33b48" + "files": 44, + "generated_at_commit": "ca12ad5bb771d41056b9c99571d736171a64b78d", + "source_tree": "sha256:ed08f3b155508dfe44e820bb68f822e611cf546ed5c7e802582a4965cc34db69" }, "owner_lane": "", "provenance": { diff --git a/mk/.crumb b/mk/.crumb index f0eaa15e0..2f29a3f14 100644 --- a/mk/.crumb +++ b/mk/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-05T13:53:36Z", + "compiled_at": "2026-10-05T14:17:15Z", "compiler": "crumb-compile/1", - "digest": "sha256:1a09c53fc4d21cd13d4f307282aeabcbf896a0639618c8767a3011d49d4cc613", + "digest": "sha256:c5c1674600955e86dbd99a603d76ef472cd3742a1e8ed239a442fd0246f10d56", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 54, - "generated_at_commit": "e9c28294247e2add87335d615c762db9bbc0e48d", - "source_tree": "sha256:0c0db4ce1cda31f967e370106adb4971612b07e230f1b41b28f343960cfb6861" + "files": 55, + "generated_at_commit": "ca12ad5bb771d41056b9c99571d736171a64b78d", + "source_tree": "sha256:5236dbd9da84e1d6c1733a05fd7cd2d0e5aba277aa822b3b9bcc1ce1d89356f7" }, "owner_lane": "", "provenance": { diff --git a/tools/.crumb b/tools/.crumb index 3fd5d1ee9..16ed2814d 100644 --- a/tools/.crumb +++ b/tools/.crumb @@ -43,8 +43,8 @@ "purpose": "Runner for the DUAL applicability experiment: runs the pre-registered campaign and writes result" }, { - "digest": "f21d39178dd934c3d59c800fb5e2e900365f1d968cca6927ff64533471ed2d5d", - "last_commit": "38b4e4c", + "digest": "17026b0e107420b5343e5c6e8268ac77079ce4bd8a732d9b24aa530156e285ee", + "last_commit": "30c31b3", "name": "estimation", "purpose": "Directory tools/estimation. Purpose not yet described by a human." }, @@ -55,15 +55,15 @@ "purpose": "Directory tools/turing_verify_indep. Purpose not yet described by a human." } ], - "children_root": "sha256:e1e9c33c1bd279d2fe5dfd86f51a39198081fa2b63818fce1ef7b04f43f91e6b", - "compiled_at": "2026-10-05T14:00:59Z", + "children_root": "sha256:be00f834f88d351112f1c65d06c8a85f332258aa49dc2ca5876c650bb02b7336", + "compiled_at": "2026-10-05T14:17:15Z", "compiler": "crumb-compile/1", - "digest": "sha256:fcf0d77d97acf0c597b39c054307650cff03295797be8686f7aeaf634ba5c2b8", + "digest": "sha256:5ad4b231acdb798c3095477ce78effae88548c3703a9453c18ab95187fa6de81", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 128, - "generated_at_commit": "38b4e4ccb54e38d96c477e4060c7e38ee06d6135", - "source_tree": "sha256:55541fe8381b0b12806b451ba2b1b75357596e787bd330a2b4a303141c2e3b44" + "files": 132, + "generated_at_commit": "ca12ad5bb771d41056b9c99571d736171a64b78d", + "source_tree": "sha256:935cfbbb07f5c20c9d72fc32817398907554adb710c5ffb0589e9cee2859e8cd" }, "owner_lane": "", "provenance": { diff --git a/tools/estimation/.crumb b/tools/estimation/.crumb index 8ac0a4302..a5f89a9fc 100644 --- a/tools/estimation/.crumb +++ b/tools/estimation/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-05T13:59:08Z", + "compiled_at": "2026-10-05T14:17:15Z", "compiler": "crumb-compile/1", - "digest": "sha256:f21d39178dd934c3d59c800fb5e2e900365f1d968cca6927ff64533471ed2d5d", + "digest": "sha256:17026b0e107420b5343e5c6e8268ac77079ce4bd8a732d9b24aa530156e285ee", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 25, - "generated_at_commit": "ab4b911f8c078258785cd564b89ca7c7a48119c4", - "source_tree": "sha256:0b8161bcf57fdd2d11769f11a23d7b12c7a7d71ce1c1f9bac481bd50e5d5f726" + "files": 29, + "generated_at_commit": "ca12ad5bb771d41056b9c99571d736171a64b78d", + "source_tree": "sha256:31a75c94c45fdf6509b225385d036a61f80c48a76f7842e5a6829787a0641bce" }, "owner_lane": "", "provenance": { From 2275438a645b03cc09c37d51f104fbb8283046f4 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Mon, 5 Oct 2026 09:13:20 -0500 Subject: [PATCH 4/5] crumb compile (docs) Co-Authored-By: Claude Opus 5.5 --- .crumb | 4 ++-- docs/.crumb | 4 ++-- docs/estimation/.crumb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.crumb b/.crumb index 78ebb601f..90883b04d 100644 --- a/.crumb +++ b/.crumb @@ -106,13 +106,13 @@ } ], "children_root": "sha256:766d986607c6c57c15323c085cc11ac26b442585c894276b4be4bd24d2b8558d", - "compiled_at": "2026-10-05T14:17:15Z", + "compiled_at": "2026-10-05T14:17:16Z", "compiler": "crumb-compile/1", "digest": "sha256:ebd63cbb38f19ac0da618b5eaf257f0dfa94ce3ac106b9706c5c645a06f32ba1", "evidence_files": 2749, "evidence_root": "sha256:c6e60c5b2803cfddf6a1fed130c92066d285ddb68aeea0bc65d58668cf139dfc", "files": 4538, - "generated_at_commit": "ca12ad5bb771d41056b9c99571d736171a64b78d", + "generated_at_commit": "03668208f618092c4e33ba9691e5b1a4ede9a613", "source_tree": "sha256:4f2ba443e819ae28d02b04c281dbaa932cd56ca5fd061ca10c9d5a7a07e99154" }, "owner_lane": "", diff --git a/docs/.crumb b/docs/.crumb index a68ddfc91..bc5750949 100644 --- a/docs/.crumb +++ b/docs/.crumb @@ -118,13 +118,13 @@ } ], "children_root": "sha256:bfed325d083303b9d78a04fe90d4c99d6feb960cf3059b0fc29828699de70803", - "compiled_at": "2026-10-05T14:17:15Z", + "compiled_at": "2026-10-05T14:17:16Z", "compiler": "crumb-compile/1", "digest": "sha256:6e14289e56c71da98a060589cfd4c23818169b62a9d030c8f76dc4c3c933bac5", "evidence_files": 31, "evidence_root": "sha256:3f4d8ab7c723c9fddacc5a872541933a4b87d1bb39868b8ec376320db6c929af", "files": 109, - "generated_at_commit": "ca12ad5bb771d41056b9c99571d736171a64b78d", + "generated_at_commit": "03668208f618092c4e33ba9691e5b1a4ede9a613", "source_tree": "sha256:8d260d4f48b5fd2d0fe40289fc801b19e02749ef29ad7a7fcf2be7a9777d4e89" }, "owner_lane": "", diff --git a/docs/estimation/.crumb b/docs/estimation/.crumb index 394ffffd4..4710a99ca 100644 --- a/docs/estimation/.crumb +++ b/docs/estimation/.crumb @@ -24,13 +24,13 @@ } ], "children_root": "sha256:35cd3af03e079556db7f3ebcfd7590fa68659e84dd603795ae6b5b048dc2af0d", - "compiled_at": "2026-10-05T14:17:15Z", + "compiled_at": "2026-10-05T14:17:16Z", "compiler": "crumb-compile/1", "digest": "sha256:309099a51e1b169e9efddeec6aaf6003f130181e9d6087d9a2a64f62ed793cf9", "evidence_files": 31, "evidence_root": "sha256:3f4d8ab7c723c9fddacc5a872541933a4b87d1bb39868b8ec376320db6c929af", "files": 44, - "generated_at_commit": "ca12ad5bb771d41056b9c99571d736171a64b78d", + "generated_at_commit": "03668208f618092c4e33ba9691e5b1a4ede9a613", "source_tree": "sha256:ed08f3b155508dfe44e820bb68f822e611cf546ed5c7e802582a4965cc34db69" }, "owner_lane": "", From 52ca0da13e4e11407e16d1f05cbfd7a00fba462f Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Mon, 5 Oct 2026 09:15:12 -0500 Subject: [PATCH 5/5] est6dev: refuse the v5 D2 marks by SHA too; test the backstop hashes against d2.sha256 (review on #293) Co-Authored-By: Claude Opus 5.5 --- .crumb | 12 ++++++------ tools/.crumb | 12 ++++++------ tools/estimation/.crumb | 8 ++++---- tools/estimation/est6dev.c | 5 ++++- tools/estimation/test_est6dev.sh | 9 +++++++++ 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/.crumb b/.crumb index 90883b04d..a7ee21cee 100644 --- a/.crumb +++ b/.crumb @@ -99,21 +99,21 @@ "purpose": "Directory tests. Purpose not yet described by a human." }, { - "digest": "5ad4b231acdb798c3095477ce78effae88548c3703a9453c18ab95187fa6de81", + "digest": "473ff59af294d59c6d7239ba756b3815b61abf89b620a17c05a2a1279a9591ee", "last_commit": "30c31b3", "name": "tools", "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:766d986607c6c57c15323c085cc11ac26b442585c894276b4be4bd24d2b8558d", - "compiled_at": "2026-10-05T14:17:16Z", + "children_root": "sha256:8aa5fccd75ff8f002572785f604f972739216c0279033de45fac1178c9c5745b", + "compiled_at": "2026-10-05T14:17:17Z", "compiler": "crumb-compile/1", - "digest": "sha256:ebd63cbb38f19ac0da618b5eaf257f0dfa94ce3ac106b9706c5c645a06f32ba1", + "digest": "sha256:71c3ad20fbae4d1ac2ff02c8a3959691bf448033bf92ab3029c3fbccbf0bdc1c", "evidence_files": 2749, "evidence_root": "sha256:c6e60c5b2803cfddf6a1fed130c92066d285ddb68aeea0bc65d58668cf139dfc", "files": 4538, - "generated_at_commit": "03668208f618092c4e33ba9691e5b1a4ede9a613", - "source_tree": "sha256:4f2ba443e819ae28d02b04c281dbaa932cd56ca5fd061ca10c9d5a7a07e99154" + "generated_at_commit": "2275438a645b03cc09c37d51f104fbb8283046f4", + "source_tree": "sha256:d023816cdf01afe757fe2fb0cd23cea9842b644be6ffa0cf13eb4e881b9ccf9b" }, "owner_lane": "", "provenance": { diff --git a/tools/.crumb b/tools/.crumb index 16ed2814d..c18297be3 100644 --- a/tools/.crumb +++ b/tools/.crumb @@ -43,7 +43,7 @@ "purpose": "Runner for the DUAL applicability experiment: runs the pre-registered campaign and writes result" }, { - "digest": "17026b0e107420b5343e5c6e8268ac77079ce4bd8a732d9b24aa530156e285ee", + "digest": "d4a6875be9942403548ed74e5f75e57bfe5824237dc985ae51813f42230d6134", "last_commit": "30c31b3", "name": "estimation", "purpose": "Directory tools/estimation. Purpose not yet described by a human." @@ -55,15 +55,15 @@ "purpose": "Directory tools/turing_verify_indep. Purpose not yet described by a human." } ], - "children_root": "sha256:be00f834f88d351112f1c65d06c8a85f332258aa49dc2ca5876c650bb02b7336", - "compiled_at": "2026-10-05T14:17:15Z", + "children_root": "sha256:3f9857a8b0946837f5556bcea0b4deaddd3a5aa3a60a31aa08ac917ac69d19f9", + "compiled_at": "2026-10-05T14:17:17Z", "compiler": "crumb-compile/1", - "digest": "sha256:5ad4b231acdb798c3095477ce78effae88548c3703a9453c18ab95187fa6de81", + "digest": "sha256:473ff59af294d59c6d7239ba756b3815b61abf89b620a17c05a2a1279a9591ee", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 132, - "generated_at_commit": "ca12ad5bb771d41056b9c99571d736171a64b78d", - "source_tree": "sha256:935cfbbb07f5c20c9d72fc32817398907554adb710c5ffb0589e9cee2859e8cd" + "generated_at_commit": "2275438a645b03cc09c37d51f104fbb8283046f4", + "source_tree": "sha256:800b487949450814bb97a57bb235e1166de4df135cdc3c7401e76a6f2a4c8333" }, "owner_lane": "", "provenance": { diff --git a/tools/estimation/.crumb b/tools/estimation/.crumb index a5f89a9fc..731a09f64 100644 --- a/tools/estimation/.crumb +++ b/tools/estimation/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-05T14:17:15Z", + "compiled_at": "2026-10-05T14:17:17Z", "compiler": "crumb-compile/1", - "digest": "sha256:17026b0e107420b5343e5c6e8268ac77079ce4bd8a732d9b24aa530156e285ee", + "digest": "sha256:d4a6875be9942403548ed74e5f75e57bfe5824237dc985ae51813f42230d6134", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 29, - "generated_at_commit": "ca12ad5bb771d41056b9c99571d736171a64b78d", - "source_tree": "sha256:31a75c94c45fdf6509b225385d036a61f80c48a76f7842e5a6829787a0641bce" + "generated_at_commit": "2275438a645b03cc09c37d51f104fbb8283046f4", + "source_tree": "sha256:a2218268e4b412fa6bf0f0853871fb3335db5d0ee11976f87c8c1eaef3914724" }, "owner_lane": "", "provenance": { diff --git a/tools/estimation/est6dev.c b/tools/estimation/est6dev.c index 150c882ae..603de5b40 100644 --- a/tools/estimation/est6dev.c +++ b/tools/estimation/est6dev.c @@ -14,7 +14,7 @@ * totals and the section 3 balance check (each of idle, L6, L12, L18 within 400..900 s). * * Refuses, before opening anything, any path that names a held-out run (v3, v4, v5 or v6 held-out - * tag) or the v5 D2 folder; after loading, refuses an input whose SHA-256 is the v5 D2 raw SHA. */ + * tag) or the v5 D2 folder; after loading, refuses an input whose SHA-256 is the v5 D2 raw or marks SHA (committed d2.sha256). */ #include #include #include @@ -27,6 +27,7 @@ #define D2_DATE_TAG "20261005T112838Z" #define D2_RAW_SHA "7dda21f664587c4401326c3082f28039e133ba5627c8564678f259e2d7036ff0" +#define D2_MARKS_SHA "95879ed909b8fec1207695dc1093b24be56f00563cd364c62bd30007b0dc26bb" static uint64_t splitmix64(uint64_t *s) { @@ -224,6 +225,7 @@ static int cmd_g1pit(int argc, char **argv) if (!strcmp(f.sha_hex, D2_RAW_SHA)) { fprintf(stderr, "refuse: input is the v5 D2 raw data (SHA-256)\n"); est_file_free(&f); return 2; } static c3_marks mk; if (c3_marks_load(mkp, 1, &mk, err, sizeof err)) { fprintf(stderr, "refuse: marks: %s\n", err); est_file_free(&f); return 1; } + if (!strcmp(mk.sha, D2_MARKS_SHA)) { fprintf(stderr, "refuse: marks are the v5 D2 marks (SHA-256)\n"); est_file_free(&f); return 2; } c3_ticks tk; if (c3_ticks_build(&f, &tk, err, sizeof err)) { fprintf(stderr, "ticks: %s\n", err); est_file_free(&f); return 1; } printf("input raw_sha256 %s marks_sha256 %s lines %zu marks_pairs %zu\n", f.sha_hex, mk.sha, tk.lines, mk.n); @@ -402,6 +404,7 @@ static int cmd_g1s(int argc, char **argv) if (!strcmp(f.sha_hex, D2_RAW_SHA)) { fprintf(stderr, "refuse: input is the v5 D2 raw data (SHA-256)\n"); est_file_free(&f); return 2; } static c3_marks mk; if (c3_marks_load(mkp, 1, &mk, err, sizeof err)) { fprintf(stderr, "refuse: marks: %s\n", err); est_file_free(&f); return 1; } + if (!strcmp(mk.sha, D2_MARKS_SHA)) { fprintf(stderr, "refuse: marks are the v5 D2 marks (SHA-256)\n"); est_file_free(&f); return 2; } c3_ticks tk; if (c3_ticks_build(&f, &tk, err, sizeof err)) { fprintf(stderr, "ticks: %s\n", err); est_file_free(&f); return 1; } printf("input raw_sha256 %s marks_sha256 %s\n", f.sha_hex, mk.sha); diff --git a/tools/estimation/test_est6dev.sh b/tools/estimation/test_est6dev.sh index d253d85c8..cde6fb8d3 100755 --- a/tools/estimation/test_est6dev.sh +++ b/tools/estimation/test_est6dev.sh @@ -19,6 +19,15 @@ for p in evidence/EST5/raw/20261005T112838Z-est5-heldout-silicon evidence/X/raw/ [ "$rc" = 2 ] && chk ok x || chk bad "g1s did not refuse held-out path $p (rc $rc)" done +# 1b. the D2 SHA backstops equal the committed d2.sha256 (hash list only; no D2 file is opened) +D2S=docs/estimation/receipts/est-v5/d2.sha256 +for pair in "D2_RAW_SHA machine-state.ndjson" "D2_MARKS_SHA machine-state-marks.txt"; do + set -- $pair + want=$(awk -v n="$2" '$2 == n { print $1 }' "$D2S") + got=$(sed -n "s/^#define $1 \"\([0-9a-f]*\)\"$/\1/p" tools/estimation/est6dev.c) + [ -n "$want" ] && [ "$want" = "$got" ] && chk ok x || chk bad "$1 in est6dev.c ($got) != d2.sha256 $2 ($want)" +done + # 2. schedule generator reproduces the v5 protocol text (seed 0xE5C5D1: idle 406, L6 929, L12 655, L18 710) "$E" sched 0xE5C5D1 2700 | grep -q '^segments 39 idle 406 L6 929 L12 655 L18 710$' && chk ok x || chk bad "schedule totals for 0xE5C5D1" "$E" sched 0xE5C5D1 2700 | grep -q '^schedule 0 0 74$' && chk ok x || chk bad "schedule first segment 0xE5C5D1"