From 078e432c314438fdd755baa24457870d635cfe48 Mon Sep 17 00:00:00 2001 From: tensorlink-dev Date: Tue, 1 Dec 2026 12:53:08 +0000 Subject: [PATCH 1/4] fix(lane D): each challenger is judged from its own reveal, not the cohort's latest (owner 2026-12-01) Settlement 9626400: four frozen members of one joint cohort; the joint set forward of the latest T met no floor, the latest member was dropped until none was left (61ab1757, 1,924 own fresh windows, dropped because its joint set with 7b11d440 held 2; 7b11d440 alone had 84 fresh windows left). - One miner cohort per frozen member, in reveal order, over the windows eligible from its own T; consecutive members whose own-T candidate sets coincide (record for record) share one cohort and one draw. - max_windows_per_settlement is shared across cohorts, earliest reveal first. - A window an earlier cohort judged under another windows[] record is left out of a later cohort (one record per window; checkers re-derive the class at each cohort's bound). - A frozen set is feasible only on windows not yet judged: a set whose fresh windows were spent on an earlier duel reopens and grows (7b11d440). - Released checkers 890fe6d1 / 0445a442 pay the multi-cohort report. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BMT4D7f8wd5dXsASyWUBwe --- cascade/validator/lane_d.py | 135 +++++++--- cascade/validator/lane_d_frozen.py | 15 +- docs/MINER_LANE_D.md | 10 + tests/accept/w5c/PATHS | 2 + tests/accept/w5c/README.md | 71 +++--- tests/accept/w5c/test_w5c_cohort.py | 114 +++++---- tests/accept/w5c/test_w5c_house_report.py | 6 +- tests/accept/w5c/test_w5c_own_t.py | 291 ++++++++++++++++++++++ 8 files changed, 519 insertions(+), 125 deletions(-) create mode 100644 tests/accept/w5c/test_w5c_own_t.py diff --git a/cascade/validator/lane_d.py b/cascade/validator/lane_d.py index 4f584dd15..75ee63815 100644 --- a/cascade/validator/lane_d.py +++ b/cascade/validator/lane_d.py @@ -1101,6 +1101,46 @@ def _window_embargo_fields(w: dict, v, h: int) -> dict: "freq_class": freq_class(freq), "h": int(h), "origin": int(w["target_ts"][0])} +def _window_record(w: dict, src_pool: dict, v, cfg, picks: dict) -> dict: + """The report's ``windows[]`` record of one judged window, as the + cohort that judges it (its snapshot and its §1.3 verdict at the cohort's + bound) writes it.""" + lag = (src_pool["feeds"].get(w["feed"]) or {}).get("mirror_lag_hours") + rec = {"window_id": w["window_id"], "source": w["source"], "feed": w["feed"], + "min_target_ts": int(min(w["target_ts"])), + "min_first_seen_ts": int(min(w["first_seen_ts"])), + "mirror_lag_hours": None if lag is None else float(lag), + # The snapshot whose version of the window was scored. + "snapshot_sha256": str(src_pool["sha256"]), + # rev6.10 (a) / rev6.12 (W7a): the effective embargo, the release + # time and the rule it was admitted under, the fresh / embargo + # class, and the W5j draw cell. + **_window_embargo_fields(w, v, window_horizon(w, cfg))} + if w["window_id"] in picks: + # rev6.18 A4 (F2, W7a): a multichannel window's channel pick (absent + # on a univariate window). + rec.update(channel_record(picks[w["window_id"]])) + return rec + + +def _cand_key(cands: list[tuple[dict, dict, object]], cfg, picks: dict | None) -> list: + """A candidate list as the sorted ``windows[]`` records it would judge.""" + picks = picks or {} + return sorted(json.dumps(_window_record(*c, cfg, picks), sort_keys=True) for c in cands) + + +def _same_record(cands: list[tuple[dict, dict, object]], windows_out: dict, cfg, + picks: dict | None) -> list[tuple[dict, dict, object]]: + """``cands`` without the windows an earlier cohort of this settlement + judged under a different ``windows[]`` record (owner 2026-12-01: the + per-member cohorts have different bounds, so a window's fresh / embargo + class can differ between them; the report carries one record per window + and every checker re-derives the class at each cohort's bound).""" + picks = picks or {} + return [c for c in cands if c[0]["window_id"] not in windows_out + or windows_out[c[0]["window_id"]] == _window_record(*c, cfg, picks)] + + def _subscore(scores, idx: list[int]) -> dict: """rev6.12 (b): ``{n, geomean}`` of one digest's rows at positions ``idx`` (the lane D geomean of its CRPS and MASE, floors 1e-12 / 1e-9); null @@ -1590,14 +1630,22 @@ def skip(dg: str, reason: str, rec: dict | None = None) -> None: house_open = False # rev6.11 (b): every member is judged at its first (and only) verdict - # against the current KING_D: one miner cohort, then the house challenger + # against the current KING_D: the miner cohorts, then the house challenger # in its own cohort against KING_D (§2 item 2): the house is never its own # second bar. + # + # owner 2026-12-01 ("it shouldn't reset the window, it should only be + # from when they submitted"): each miner member is its own cohort, judged + # in reveal order (earliest T first) on the windows eligible from ITS OWN + # T, never on a joint set cut to the latest member's T. A member below + # its floors (or out of what is left of max_windows_per_settlement) + # waits ``pending_floor`` alone; no other member's set shrinks for it. + # Consecutive members whose own-T candidate sets coincide share one + # cohort (one draw, one budget share; see the look-ahead below). kd0 = str(state["king"]["digest"]) jobs = [] - if chosen: - jobs.append((kd0, "first", list(chosen), - {m: state["entries"][m] for m in chosen}, False)) + for m in sorted(chosen, key=lambda d: (int(state["entries"][d]["reveal_ts"]), d)): + jobs.append((kd0, "first", [m], {m: state["entries"][m]}, False)) if house_open and not house_held and not state["king"].get("house"): jobs.append((kd0, "first", [hd], {hd: house_rec}, True)) @@ -1612,7 +1660,11 @@ def skip(dg: str, reason: str, rec: dict | None = None) -> None: candidates: list[dict] = [] # rev6.18 A3 (F4): every digest scored on the public half (report rows). pub_scored: set[str] = set() - for kd, stage, members, recs, is_house in jobs: + # The members whose frozen set this settlement already advanced (a + # cohort looks ahead at the next member's set: see below). + advanced: set[str] = set() + while jobs: + kd, stage, members, recs, is_house = jobs.pop(0) king_ts = _king_reveal_ts(state, kd) # DEC-CA-0076 (owner 2026-11-24): KING_D is the only bar. At genesis # it is the house; after the first miner crown the house is no @@ -1634,7 +1686,9 @@ def skip(dg: str, reason: str, rec: dict | None = None) -> None: frozen = [] for m in members: rec = recs[m] - rec["frozen_set"] = _advance_member(rec, pools, int(king_ts), cfg, cap_seed) + if m not in advanced: + rec["frozen_set"] = _advance_member(rec, pools, int(king_ts), cfg, cap_seed) + advanced.add(m) if rec["frozen_set"]["frozen"]: frozen.append(m) else: @@ -1644,24 +1698,52 @@ def skip(dg: str, reason: str, rec: dict | None = None) -> None: continue # W5j: the judged windows are the cohort's seeded per-bin draw over # its eligible set, within what is left of the settlement's - # max_windows_per_settlement; a draw below the floors (or short of - # the minimum fresh share, or out of budget) leaves the latest-T - # member pending. + # max_windows_per_settlement (earlier cohorts, i.e. earlier reveals, + # draw first); a draw below the floors (or short of the minimum fresh + # share, or out of budget) leaves the member pending. budget = int(cfg.max_windows_per_settlement) - len(windows_out) - eligible, refused = _cohort_set(pools, members, bars, king_ts, recs, forecasts, cfg, - pinned, picks) - # owner 2026-11-30: the seen candidates the draw fills the set with - seen_c = _seen_set(pools, members, bars, king_ts, recs, forecasts, cfg, pinned, - picks, eligible) + + def cands_of(ms, bars=bars, king_ts=king_ts, recs=recs): + el, why = _cohort_set(pools, ms, bars, king_ts, recs, forecasts, cfg, pinned, + picks) + # owner 2026-11-30: the seen candidates the draw fills the set with + sc = _seen_set(pools, ms, bars, king_ts, recs, forecasts, cfg, pinned, picks, el) + # owner 2026-12-01: cohorts of one settlement have different T; + # the report holds ONE record per judged window, so a window an + # earlier cohort judged under another record (its class at that + # cohort's bound) is left out of this one (fail closed). + return (_same_record(el, windows_out, cfg, picks), why, + _same_record(sc, windows_out, cfg, picks)) + + eligible, refused, seen_c = cands_of(members) + # The next members in reveal order whose own-T candidate set is this + # one, window for window and record for record, join this cohort: + # one draw serves them all (the same draw each would get alone), so + # they share the window budget instead of each spending it. + while not is_house and jobs and not jobs[0][4] and jobs[0][0] == kd: + nm = jobs[0][2][0] + nrec = jobs[0][3][nm] + if not _pub_ready(pub_of(nm)): + break + if nm not in advanced: + nrec["frozen_set"] = _advance_member(nrec, pools, int(king_ts), cfg, cap_seed) + advanced.add(nm) + if not nrec["frozen_set"]["frozen"]: + break + n_el, _, n_sc = cands_of([nm], recs={**recs, nm: nrec}) + if _cand_key(n_el, cfg, picks) != _cand_key(eligible, cfg, picks) \ + or _cand_key(n_sc, cfg, picks) != _cand_key(seen_c, cfg, picks): + break + jobs.pop(0) + recs = {**recs, nm: nrec} + members.append(nm) + eligible, refused, seen_c = cands_of(members, recs=recs) picked, drawn, ok = _drawn(eligible, cfg, boundary_block_hash, budget, seen_c) while members and not ok: m = members.pop() skip(m, "pending_floor", recs[m]) if members: - eligible, refused = _cohort_set(pools, members, bars, king_ts, recs, - forecasts, cfg, pinned, picks) - seen_c = _seen_set(pools, members, bars, king_ts, recs, forecasts, cfg, - pinned, picks, eligible) + eligible, refused, seen_c = cands_of(members, recs=recs) picked, drawn, ok = _drawn(eligible, cfg, boundary_block_hash, budget, seen_c) if not members: continue @@ -1673,23 +1755,8 @@ def skip(dg: str, reason: str, rec: dict | None = None) -> None: w["seasonal_period"]) for w in ws] scores[dg] = (np.asarray([p[0] for p in pairs]), np.asarray([p[1] for p in pairs])) for i, (w, src_pool, v) in enumerate(picked): - lag = (src_pool["feeds"].get(w["feed"]) or {}).get("mirror_lag_hours") pinned[w["window_id"]] = str(src_pool["sha256"]) - windows_out[w["window_id"]] = { - "window_id": w["window_id"], "source": w["source"], "feed": w["feed"], - "min_target_ts": int(min(w["target_ts"])), - "min_first_seen_ts": int(min(w["first_seen_ts"])), - "mirror_lag_hours": None if lag is None else float(lag), - # The snapshot whose version of the window was scored. - "snapshot_sha256": str(src_pool["sha256"]), - # rev6.10 (a) / rev6.12 (W7a): the effective embargo, the - # release time and the rule it was admitted under, the - # fresh / embargo class, and the W5j draw cell. - **_window_embargo_fields(w, v, window_horizon(w, cfg))} - if w["window_id"] in picks: - # rev6.18 A4 (F2, W7a): a multichannel window's channel - # pick (absent on a univariate window). - windows_out[w["window_id"]].update(channel_record(picks[w["window_id"]])) + windows_out[w["window_id"]] = _window_record(w, src_pool, v, cfg, picks) for dg in scored: rows.append({"window_id": w["window_id"], "digest": dg, "cohort": len(cohorts), "crps": float(scores[dg][0][i]), "mase": float(scores[dg][1][i])}) diff --git a/cascade/validator/lane_d_frozen.py b/cascade/validator/lane_d_frozen.py index 7507a54e3..5bff3668c 100644 --- a/cascade/validator/lane_d_frozen.py +++ b/cascade/validator/lane_d_frozen.py @@ -19,8 +19,10 @@ ``K = fresh_keep(E, F, s)`` embargo windows are kept, so ``F + K`` must reach ``min_windows``. A set of embargo windows only would otherwise freeze, fail every draw ``fresh_share_short`` and never gain the fresh windows it needs. -A frozen record that fails this check (one written by code without it) -reopens: it keeps its windows as its union and grows. The record lists its +A frozen record that fails this check (one written by code without it, or, +owner 2026-12-01, one whose fresh windows were spent on an earlier duel: the +check counts only the windows not yet judged) reopens: it keeps its windows +not yet judged as its union and grows. The record lists its embargo windows in ``embargo_ids`` (only when there are any). The progress record (:func:`advance_frozen_set`) is plain JSON so it can live @@ -163,11 +165,16 @@ class recorded when it joined; a window of a record written before the def embargo_of(ids) -> list[str]: return sorted(k for k in ids if klass.get(k, k in recorded)) + skip = {str(x) for x in exclude} if frozen: - ids = [str(k) for k in progress.get("window_ids") or ()] + # owner 2026-12-01 (live 9626400): feasible on the windows the entry + # can still be judged on, i.e. without those in ``exclude``. A set + # whose fresh windows were spent on an earlier duel (7b11d440: 84 of + # 360 left) reopens and grows from its own T instead of staying + # frozen and failing every draw. + ids = [str(k) for k in progress.get("window_ids") or () if str(k) not in skip] if fresh_feasible(ids, embargo_of(ids), cfg): return copy.deepcopy(progress) - skip = {str(x) for x in exclude} sources: dict[str, str] = {} if progress is not None: sources = {str(k): str(v) for k, v in (progress.get("sources") or {}).items() diff --git a/docs/MINER_LANE_D.md b/docs/MINER_LANE_D.md index 6823ebf5a..7c3f16dd1 100644 --- a/docs/MINER_LANE_D.md +++ b/docs/MINER_LANE_D.md @@ -237,6 +237,16 @@ blocks, about 24 h) of `submit`, or the entry expires (`ready_expired`). charged: they go back to `pending` (`pending_floor`) and are duelled at the next settlement against the new king. Only if no held entry passes are the new clears gated, and the highest LCB crowns. +- **Your windows start at your own reveal.** Every entry is judged in a + cohort of its own, on the windows that are unseen from its own reveal + time T (and the king's, if the king is newer). A later entry never + shrinks your set, and an earlier entry that cannot meet the floors yet + never blocks yours. Entries are judged in reveal order, earliest first, + sharing the settlement's `max_windows_per_settlement` budget. If the + budget runs short of `min_windows`, the later entries wait + (`pending_floor`) for the next settlement. Windows you were already + judged on are never used again. If that leaves too few fresh windows, + your set reopens and grows with the newer windows. ## How you are paid diff --git a/tests/accept/w5c/PATHS b/tests/accept/w5c/PATHS index 37769a6a8..fa3a6e904 100644 --- a/tests/accept/w5c/PATHS +++ b/tests/accept/w5c/PATHS @@ -8,3 +8,5 @@ cascade/validator/lane_d_frozen.py # RV5: the audit counts the house's rows and re-derives the house judgement # (cohorts[].house_digest, verdicts[].house) from the signed rows. cascade/audit/lane_d.py +# owner 2026-12-01: the miner doc states the own-T cohort rule. +docs/MINER_LANE_D.md diff --git a/tests/accept/w5c/README.md b/tests/accept/w5c/README.md index 1bdb4a23b..41f531c46 100644 --- a/tests/accept/w5c/README.md +++ b/tests/accept/w5c/README.md @@ -13,49 +13,56 @@ behaviour is change 3, and those tests fail on main. ## Contract (`settle_lane_d`, `cascade/validator/lane_d.py`) -### Cohort formation - -- A cohort is every open entry, judged against the same KING_D at the same - stage, whose `frozen_set` is frozen at this settlement. That includes an - entry frozen and deferred at an earlier settlement. -- An entry that is still unfrozen is not a member. Its T does not enter the - cohort's max-T, and it does not shrink the intersection. It stays +### Cohort formation (owner 2026-12-01: one cohort per member, own T) + +- Each open entry whose `frozen_set` is frozen at this settlement is its own + miner cohort, judged against KING_D. That includes an entry frozen and + deferred at an earlier settlement. ("It shouldn't reset the window, it + should only be from when they submitted.") Until 2026-12-01 the frozen + entries formed ONE joint cohort judged forward of the latest member's T. +- An entry that is still unfrozen is not judged and stays `pending` / `pending_floor`. -- `cohorts[].members` is ordered by T (`reveal_ts`) ascending, with ties - broken by digest. It is not digest order and not input order. -- `cohorts[].t_max` is max(T over the members and the king). +- Cohorts are indexed in T (`reveal_ts`) order, ties by digest. It is not + digest order and not input order. +- `cohorts[].t_max` is max(the member's T, the king's T). ### The judged set -- The set is the intersection of the members' frozen sets that is eligible - (§1.3, W5a) for the cohort's `t_max`. It also needs a usable target and a - usable forecast from the king and every member. -- A window that is eligible for a member's own T but not for `t_max` is - excluded, even though it is in that member's frozen set. -- Every member and the king are scored on exactly this set +- A member's set is its frozen set that is eligible (§1.3, W5a) for its own + `t_max`, with a usable target and a usable forecast from the king and the + member, minus the windows it was already judged on. No other member's T + or frozen set shrinks it. +- The settlement's `max_windows_per_settlement` budget is shared across the + cohorts, earliest reveal first (a window judged in two cohorts counts once). +- A window an earlier cohort of the settlement judged under a different + `windows[]` record (another snapshot, or another fresh / embargo class at + that cohort's bound) is left out (one record per window, fail closed). +- The member and the king are scored on exactly this set (`rows`, `cohorts[].window_ids`, `set_sha256 = sha256("\n".join(sorted ids))`). -### Floors after the intersection: latest-T deferral - -- If the set misses `min_windows` or `min_clusters`, the member with the - latest T is deferred. Then `t_max` and the set are recomputed for the - remaining members, and this repeats until the set meets the floors or no - member is left. -- A deferred entry is not judged: no rows, no verdict, not in `judged`, and - no cohort if every member is deferred. It gets one `skipped` record with - the typed reason `pending_floor` (in `ENTRY_REASONS`), and its state stays - `pending` / `pending_floor` with `used_windows == []`. Its `frozen_set` - stays frozen and unchanged. -- At the next settlement it is a cohort member again, judged on its - unchanged frozen set: the cohort's `set_sha256` equals the frozen set's. +### Floors per member + +- If a member's draw misses `min_windows` or `min_clusters` (or the minimum + fresh share, or the budget left), that member is deferred alone. No other + member is affected. +- A deferred entry is not judged: no rows, no verdict, not in `judged`. It + gets one `skipped` record with the typed reason `pending_floor` (in + `ENTRY_REASONS`), and its state stays `pending` / `pending_floor` with + `used_windows` unchanged. Its `frozen_set` stays frozen and unchanged, + unless the windows it was not yet judged on can no longer meet the fresh + share: then it reopens and grows (W5b). +- At the next settlement it is judged on its frozen set: the cohort's + `set_sha256` equals the frozen set's. +- The released satellite checkers (890fe6d1, 0445a442) pay a report with + several miner cohorts (`test_w5c_own_t.py`). ### Verdict: max-T against KING_D - Each verdict's `lcb`, `gain` and `cleared` equal `judge_cohort(king_scores, member_scores, clusters=sources, cfg, seed=report["seed"])`. - This is computed from the report's own rows over `cohorts[].window_ids` in - order, with the members in cohort order. It is the joint `cohort_maxt_lcbs` - over the cohort against KING_D (`verdicts[].king_digest`). + This is computed from the report's own rows of that cohort over + `cohorts[].window_ids` in order. It is `cohort_maxt_lcbs` over the cohort + against KING_D (`verdicts[].king_digest`). ### Proposed change 3 (accepted): the house bar diff --git a/tests/accept/w5c/test_w5c_cohort.py b/tests/accept/w5c/test_w5c_cohort.py index 2ed5dc69e..204f6f54e 100644 --- a/tests/accept/w5c/test_w5c_cohort.py +++ b/tests/accept/w5c/test_w5c_cohort.py @@ -1,6 +1,7 @@ -"""W5c through `settle_lane_d`: cohort formation, the intersection eligible for -the cohort's max-T, latest-T deferral, floors after the intersection, the -max-T comparison against KING_D, determinism (plan rev6 §1.3 Cohorts, T9). +"""W5c through `settle_lane_d`: cohort formation (one cohort per frozen entry, +in reveal order, owner 2026-12-01), each judged on the set eligible for its +own T, floors per member, the max-T comparison against KING_D, determinism +(plan rev6 §1.3 Cohorts, T9). The pool holds three §1.3 bands, a day apart: @@ -8,8 +9,8 @@ * band B (8 windows): eligible for T_A and T_B; * band C (24 windows): eligible for T_A, T_B and T_C. -So A freezes on 40 windows, B on 32, C on 24, and the cohort {A, B, C} is -judged on band C alone. The genesis house holds KING_D (T earlier than all). +So A freezes on 40 windows, B on 32, C on 24, and each is judged on its own +set (before 2026-12-01 the joint cohort {A, B, C} was judged on band C alone). The genesis house holds KING_D (T earlier than all). """ from __future__ import annotations @@ -100,32 +101,42 @@ def test_cohort_fixture_bands_and_frozen_sets(tmp_path): assert state["entries"][e["digest"]]["frozen_set"]["frozen"] is True -# ── cohort formation + intersection for max-T ─────────────────────────────── +# ── cohort formation: one cohort per member, in reveal order ──────────────── +# +# owner 2026-12-01 ("it shouldn't reset the window, it should only be from +# when they submitted"): each frozen entry is its own cohort, judged on the +# windows eligible from ITS OWN T; no joint set cut to the latest member's T. -def test_t9_cohort_is_every_entry_frozen_this_settlement_ordered_by_t(tmp_path): +def _cohort_of(report, e) -> dict: + (c,) = [c for c in report["cohorts"] if e["digest"] in c["members"]] + return c + + +def test_t9_each_frozen_entry_is_its_own_cohort_ordered_by_t(tmp_path): a_band, b_band, c_band = _bands() A, B, C = _entries() s, *_ = _run(tmp_path, a_band + b_band + c_band, (A, B, C), order=(C, A, B)) - (cohort,) = s.report["cohorts"] - assert cohort["members"] == [A["digest"], B["digest"], C["digest"]], \ - "the cohort is not the frozen entries ordered by T" - assert cohort["t_max"] == T_C, "the cohort's T is not max(T over cohort and king)" - assert sorted(s.report["judged"]) == sorted(cohort["members"]) + cohorts = sorted(s.report["cohorts"], key=lambda c: c["index"]) + assert [c["members"] for c in cohorts] == [[A["digest"]], [B["digest"]], [C["digest"]]], \ + "the cohorts are not one per frozen entry in T order" + assert [c["t_max"] for c in cohorts] == [T_A, T_B, T_C], \ + "a cohort's T is not max(its member's T, the king's)" + assert sorted(s.report["judged"]) == sorted(m for c in cohorts for m in c["members"]) -def test_t9_cohort_is_judged_on_the_intersection_eligible_for_max_t(tmp_path): +def test_t9_each_member_is_judged_on_the_set_eligible_for_its_own_t(tmp_path): a_band, b_band, c_band = _bands() A, B, C = _entries() s, _, h, *_ = _run(tmp_path, a_band + b_band + c_band, (A, B, C)) - (cohort,) = s.report["cohorts"] - want = set(wids(c_band)) - assert sorted(cohort["window_ids"]) == sorted(want), \ - "windows eligible for a member's own T but not the cohort's max-T were judged" - assert cohort["set_sha256"] == set_sha(want) - for dg in (A["digest"], B["digest"], C["digest"], h["digest"]): - assert rows_of(s.report, dg) == want, f"{dg[:8]} not scored on the shared set" - assert not rows_of(s.report, A["digest"]) & set(wids(a_band + b_band)) + for e, want in ((A, a_band + b_band + c_band), (B, b_band + c_band), (C, c_band)): + cohort = _cohort_of(s.report, e) + assert sorted(cohort["window_ids"]) == wids(want), \ + f"{e['digest'][:8]} was not judged on the windows eligible for its own T" + assert cohort["set_sha256"] == set_sha(wids(want)) + assert rows_of(s.report, e["digest"]) == set(wids(want)) + # KING_D is scored in every cohort: on the union of the members' sets. + assert rows_of(s.report, h["digest"]) == set(wids(a_band + b_band + c_band)) def test_an_unfrozen_entry_is_not_a_cohort_member(tmp_path): @@ -133,35 +144,30 @@ def test_an_unfrozen_entry_is_not_a_cohort_member(tmp_path): A, B, C = _entries() late = entry("late", reveal_ts=T_LATE) # no window is eligible for its T s, path, *_ = _run(tmp_path, a_band + b_band + c_band, (A, B, C, late)) - (cohort,) = s.report["cohorts"] - assert late["digest"] not in cohort["members"] - assert cohort["t_max"] == T_C, "an unfrozen entry's T entered the cohort's max-T" - assert sorted(cohort["window_ids"]) == wids(c_band) + assert all(late["digest"] not in c["members"] for c in s.report["cohorts"]) + assert max(c["t_max"] for c in s.report["cohorts"]) == T_C, \ + "an unfrozen entry's T entered a cohort's max-T" + assert sorted(_cohort_of(s.report, C)["window_ids"]) == wids(c_band) rec = read_state(path)["entries"][late["digest"]] assert (rec["status"], rec["reason"]) == ("pending", "pending_floor") assert rec["frozen_set"]["frozen"] is False assert rows_of(s.report, late["digest"]) == set() -# ── floors after the intersection: latest-T deferral ──────────────────────── +# ── floors per member: a member short of them waits alone ─────────────────── -def test_t9_latest_t_member_is_deferred_when_the_intersection_misses_the_floors(tmp_path): +def test_t9_a_member_short_of_the_floors_waits_alone(tmp_path): from cascade.validator.lane_d_state import ENTRY_REASONS a_band, b_band, c_band = _bands() A, B, C = _entries() s, path, h, *_ = _run(tmp_path, a_band + b_band + c_band, (A, B, C), skip={C["digest"]: _short_c(c_band)}) - (cohort,) = s.report["cohorts"] - assert cohort["members"] == [A["digest"], B["digest"]], \ - "the latest-T member was not the one deferred" - assert cohort["t_max"] == T_B, "the cohort's max-T was not recomputed after the deferral" - want = set(wids(b_band + c_band)) - assert sorted(cohort["window_ids"]) == sorted(want) - assert rows_of(s.report, A["digest"]) == want - assert rows_of(s.report, B["digest"]) == want - assert rows_of(s.report, h["digest"]) == want + assert [c["members"] for c in s.report["cohorts"]] == [[A["digest"]], [B["digest"]]], \ + "the member short of its floors was not the one deferred" + assert sorted(_cohort_of(s.report, A)["window_ids"]) == wids(a_band + b_band + c_band) + assert sorted(_cohort_of(s.report, B)["window_ids"]) == wids(b_band + c_band) assert rows_of(s.report, C["digest"]) == set(), "a deferred entry was judged" assert verdict_of(s.report, C["digest"]) is None @@ -247,24 +253,26 @@ def test_verdicts_are_cohort_max_t_against_king_d_on_the_shared_set(tmp_path): a_band, b_band, c_band = _bands() A, B, C = _entries() s, _, h, _, _, cfg = _run(tmp_path, a_band + b_band + c_band, (A, B, C)) - (cohort,) = s.report["cohorts"] - assert cohort["king_digest"] == h["digest"] - order = list(cohort["window_ids"]) + assert len(s.report["cohorts"]) == 3 src = {w["window_id"]: w["source"] for w in s.report["windows"]} - by = {(r["digest"], r["window_id"]): (r["crps"], r["mase"]) for r in s.report["rows"]} - - def scores(dg): - pairs = [by[(dg, w)] for w in order] - return (np.asarray([p[0] for p in pairs]), np.asarray([p[1] for p in pairs])) - - want = judge_cohort(scores(h["digest"]), [scores(m) for m in cohort["members"]], - clusters=[src[w] for w in order], cfg=cfg, seed=s.report["seed"]) - for m, w in zip(cohort["members"], want, strict=True): - v = verdict_of(s.report, m) - assert v["king_digest"] == h["digest"] and v["cohort"] == cohort["index"] - assert v["lcb"] == w["lcb"] and v["gain"] == w["gain"], \ - "a verdict is not the cohort's joint max-T result against KING_D" - assert v["cleared"] is w["cleared"] + for cohort in s.report["cohorts"]: + assert cohort["king_digest"] == h["digest"] + order = list(cohort["window_ids"]) + by = {(r["digest"], r["window_id"]): (r["crps"], r["mase"]) for r in s.report["rows"] + if r["cohort"] == cohort["index"]} + + def scores(dg, order=order, by=by): + pairs = [by[(dg, w)] for w in order] + return (np.asarray([p[0] for p in pairs]), np.asarray([p[1] for p in pairs])) + + want = judge_cohort(scores(h["digest"]), [scores(m) for m in cohort["members"]], + clusters=[src[w] for w in order], cfg=cfg, seed=s.report["seed"]) + for m, w in zip(cohort["members"], want, strict=True): + v = verdict_of(s.report, m) + assert v["king_digest"] == h["digest"] and v["cohort"] == cohort["index"] + assert v["lcb"] == w["lcb"] and v["gain"] == w["gain"], \ + "a verdict is not its cohort's max-T result against KING_D" + assert v["cleared"] is w["cleared"] # ── determinism ───────────────────────────────────────────────────────────── diff --git a/tests/accept/w5c/test_w5c_house_report.py b/tests/accept/w5c/test_w5c_house_report.py index 73c08e292..75de78fc6 100644 --- a/tests/accept/w5c/test_w5c_house_report.py +++ b/tests/accept/w5c/test_w5c_house_report.py @@ -233,7 +233,7 @@ def test_house_report_rows_are_king_d_and_members_only(chains, scenario): def _house_king_reports(chains, tmp_path): """Reports where the house holds KING_D: BOUNDARY_1 (K1 vs H0) of the - house chain, and a W5c three-member cohort vs the genesis house.""" + house chain, and three W5c member cohorts vs the genesis house.""" c = chains("bad", "good") a = group("bandA", 2, band_start(T_A)) b = group("bandB", 2, band_start(T_B)) @@ -248,7 +248,9 @@ def _house_king_reports(chains, tmp_path): pool = write_pool(tmp_path / "pool", recs, "w5c-cohort") s = settle(lane_d_cfg(), BOUNDARY_1, pool, list(members), h, fc, uids(*members), tmp_path / "state" / "lane_d_state.json") - assert s.report["cohorts"] and set(s.report["cohorts"][0]["window_ids"]) == set(wids(cc)) + # owner 2026-12-01: one cohort per member, each on its own-T set + assert [set(c["window_ids"]) for c in s.report["cohorts"]] == \ + [set(wids(a + b + cc)), set(wids(b + cc)), set(wids(cc))] # BOUNDARY_2: K1 is judged while the house holds KING_D (BOUNDARY_1 # lists no entry, rev6.11 (b)). return [("house-chain-b2", c["reports"][1]), ("cohort", s.report)] diff --git a/tests/accept/w5c/test_w5c_own_t.py b/tests/accept/w5c/test_w5c_own_t.py new file mode 100644 index 000000000..15ce6f8ce --- /dev/null +++ b/tests/accept/w5c/test_w5c_own_t.py @@ -0,0 +1,291 @@ +"""Each lane D member is judged from ITS OWN reveal (owner 2026-12-01: "it +shouldn't reset the window, it should only be from when they submitted"). + +Live case (settlement 9626400): six entries of one miner cohort; four froze. +The joint set over windows eligible for ALL of them (forward of the latest +T) met no floor, so the latest-T member was dropped ``pending_floor`` until +none was left: 61ab1757 (1,924 fresh windows of its own) was dropped because +its joint set with the older 7b11d440 held 2 fresh windows, and 7b11d440 +alone had 84 fresh windows left (its other fresh ones were used in its +9623700 duel), under the 20 % fresh share of a 1,000-window floor. Nobody +was judged. + +Now each member is its own cohort, in reveal order, over the windows +eligible from its own T, within what is left of +``max_windows_per_settlement`` (earliest reveal first), with the floors per +member; a frozen set whose fresh windows were spent on an earlier duel +reopens and grows. The released satellite checkers (890fe6d1, 0445a442) pay +a report with several miner cohorts. +""" + +from __future__ import annotations + +import json +import subprocess + +import pytest + +from tests.accept.w_hz.helpers import ( + BAND_RAW, + BOUNDARY_1, + CHALLENGER_UID, + HASH_A, + HOUR, + LIVE_ONLY, + MINUTE, + REPO, + T0, + band_cfg, + band_series, + entry, + feeds_for, + fixture_key, + forecasts, + house, + old_tree, + run_old_checker, + settle, + write_band_pool, +) + +from .helpers import BOUNDARY_1 as W5C_BOUNDARY +from .helpers import ( + T_A, + T_B, + T_C, + band_start, + group, + lane_d_cfg, + model_forecasts, + read_state, + rows_of, + skipped_reasons, + uids, + wids, + write_pool, +) +from .helpers import entry as w5c_entry +from .helpers import house as w5c_house +from .helpers import settle as w5c_settle + +# The lane D checkers the deployed validator releases carry (2026-12-01): +# validator-release-laned-live and validator-release-laned-1201b. +RELEASED = (("890fe6d1", "890fe6d1"), ("0445a442", "0445a442")) + + +# ── the w5c day-band pool (A: 40 own-T windows, B: 32, C: 24) ─────────────── + + +def _bands(a=2, b=2, c=6): + return (group("bandA", a, band_start(T_A)), group("bandB", b, band_start(T_B)), + group("bandC", c, band_start(T_C))) + + +def _people(): + return (w5c_entry("alpha", reveal_ts=T_A), w5c_entry("bravo", reveal_ts=T_B), + w5c_entry("charlie", reveal_ts=T_C)) + + +def _run(tmp_path, records, members, *, skip=None, order=None, **over): + cfg = lane_d_cfg(**over) + h = w5c_house() + pool = write_pool(tmp_path / "pool", records, "w5c-own-t") + skip = skip or {} + fc = {h["digest"]: model_forecasts(records, "bad", "house")} + for e in members: + fc[e["digest"]] = model_forecasts(records, "good", e["digest"], + skip=skip.get(e["digest"], ())) + path = tmp_path / "state" / "lane_d_state.json" + s = w5c_settle(cfg, W5C_BOUNDARY, pool, list(order or members), h, fc, uids(*members), + path) + return s, path, h + + +def _cohort(report, e) -> dict | None: + got = [c for c in report["cohorts"] if e["digest"] in c["members"]] + assert len(got) <= 1 + return got[0] if got else None + + +def test_an_older_member_is_judged_on_its_own_t_windows_despite_a_newer_one(tmp_path): + """A (oldest) is judged on all 40 windows eligible from T_A, though B and + C (newer, both judged) can use only 32 / 24 of them. On the base A was + judged on the joint set forward of T_C (band C, 24 windows).""" + a_band, b_band, c_band = _bands() + A, B, C = _people() + s, _, h = _run(tmp_path, a_band + b_band + c_band, (A, B, C)) + ca = _cohort(s.report, A) + assert ca is not None and ca["members"] == [A["digest"]], \ + "the oldest member is not judged in a cohort of its own" + assert ca["t_max"] == T_A, "the oldest member's set is bound by a newer member's T" + assert sorted(ca["window_ids"]) == wids(a_band + b_band + c_band) + assert rows_of(s.report, A["digest"]) == set(wids(a_band + b_band + c_band)) + assert {B["digest"], C["digest"]} <= set(s.report["judged"]) + + +def test_a_newer_member_below_its_floor_does_not_shrink_the_older_ones(tmp_path): + """C (newest) lacks forecasts on a third of band C: below the floor. A + and B are each judged on their own-T set (on the base they were judged + jointly, forward of T_B: 32 windows for A instead of 40).""" + a_band, b_band, c_band = _bands() + A, B, C = _people() + s, path, _ = _run(tmp_path, a_band + b_band + c_band, (A, B, C), + skip={C["digest"]: wids(c_band[:8])}) + assert sorted(_cohort(s.report, A)["window_ids"]) == wids(a_band + b_band + c_band) + assert sorted(_cohort(s.report, B)["window_ids"]) == wids(b_band + c_band) + assert _cohort(s.report, C) is None + assert skipped_reasons(s.report, C["digest"]) == ["pending_floor"] + rec = read_state(path)["entries"][C["digest"]] + assert (rec["status"], rec["reason"], rec["used_windows"]) == \ + ("pending", "pending_floor", []) + + +def test_an_older_member_below_its_floor_does_not_block_a_newer_one(tmp_path): + """The live 9626400 shape: the OLDEST member (A) cannot meet the floors + on its own (no forecasts outside band A: 8 windows), the newest (C) can + (24). On the base the joint set failed, C (latest T) was dropped, then A + failed alone: nobody was judged. Now C is judged on its own set.""" + a_band, b_band, c_band = _bands() + A, _, C = _people() + s, path, _ = _run(tmp_path, a_band + b_band + c_band, (A, C), + skip={A["digest"]: wids(b_band + c_band)}) + cc = _cohort(s.report, C) + assert cc is not None, "an older member below its floor blocked a newer one" + assert cc["members"] == [C["digest"]] and sorted(cc["window_ids"]) == wids(c_band) + assert _cohort(s.report, A) is None + assert skipped_reasons(s.report, A["digest"]) == ["pending_floor"] + assert read_state(path)["entries"][A["digest"]]["used_windows"] == [] + + +def test_cohorts_follow_reveal_order_not_digest_or_input_order(tmp_path): + """Cohort indices, rows and verdicts follow T (digest order and input + order both differ from it).""" + a_band, b_band, c_band = _bands() + A, B, C = _people() + assert sorted(d["digest"] for d in (A, B, C)) != [A["digest"], B["digest"], C["digest"]] + s, *_ = _run(tmp_path, a_band + b_band + c_band, (A, B, C), order=(C, A, B)) + by_index = sorted(s.report["cohorts"], key=lambda c: c["index"]) + assert [c["members"] for c in by_index] == [[A["digest"]], [B["digest"]], [C["digest"]]] + assert [v["digest"] for v in s.report["verdicts"]] == [A["digest"], B["digest"], C["digest"]] + assert [r["cohort"] for r in s.report["rows"]] == sorted(r["cohort"] for r in s.report["rows"]) + + +def test_the_window_budget_is_shared_across_cohorts_earliest_reveal_first(tmp_path): + """max_windows_per_settlement 50: A (earliest) draws its 40 windows; 10 + are left, under the 24-window floor, so B and C wait ``pending_floor`` + (on the base the joint cohort {A, B, C} was judged on band C).""" + a_band, b_band, c_band = _bands() + A, B, C = _people() + s, path, _ = _run(tmp_path, a_band + b_band + c_band, (A, B, C), + max_windows_per_settlement=50) + assert [c["members"] for c in s.report["cohorts"]] == [[A["digest"]]], \ + "the budget was not spent earliest reveal first" + assert len({w["window_id"] for w in s.report["windows"]}) <= 50 + state = read_state(path) + for e in (B, C): + assert skipped_reasons(s.report, e["digest"]) == ["pending_floor"] + assert state["entries"][e["digest"]]["used_windows"] == [] + + +# ── a frozen set spent on an earlier duel reopens (7b11d440) ──────────────── + + +def test_a_frozen_set_whose_fresh_windows_were_used_reopens_and_grows(tmp_path): + """7b11d440 at 9626400: frozen with 360 fresh windows, 276+ of them used + in its 9623700 duel; the frozen check counted the used ones, so the set + stayed frozen and every draw failed the fresh share. Now the check + counts only windows not yet judged: the set reopens, keeps those, and + grows with the windows that arrived since (all forward of its own T).""" + from cascade.validator.lane_d import load_pool_for + from cascade.validator.lane_d_frozen import advance_frozen_set, fresh_feasible + + cfg = band_cfg(min_fresh_window_share=0.2, embargo_hours=48.0) + kt = T0 - 2 * 86_400 + + def fleet(tag, start, n=24): + return [band_series(f"{tag}-s{i % 4}-{i}", f"src{i % 4}", freq="min", step=MINUTE, + region=736, start=start + i * 7, bound=T0) for i in range(n)] + + first = fleet("first", T0 + HOUR) + d1 = write_band_pool(tmp_path / "p1", first, feeds=feeds_for(first, 48.0), snapshot="p1") + p1 = load_pool_for(d1, cfg) + froze = advance_frozen_set(None, [p1], t_entry=T0, t_king=kt, cfg=cfg, seed="s1") + assert froze["frozen"] is True + fresh = [w for w in froze["window_ids"] if w not in set(froze.get("embargo_ids") or ())] + used = fresh[: len(fresh) - 1] # the earlier duel spent all but one + assert not fresh_feasible([w for w in froze["window_ids"] if w not in set(used)], + froze.get("embargo_ids") or (), cfg), "fixture" + later = fleet("later", T0 + 20 * HOUR) + d2 = write_band_pool(tmp_path / "p2", first + later, + feeds=feeds_for(first + later, 48.0), snapshot="p2") + p2 = load_pool_for(d2, cfg) + again = advance_frozen_set(json.loads(json.dumps(froze)), [p1, p2], t_entry=T0, t_king=kt, + cfg=cfg, seed="s2", exclude=used) + assert again != froze, "a frozen set the draw can no longer serve stayed frozen" + assert not set(used) & set(again["window_ids"]), "a used window rejoined the set" + assert again["frozen"] is True and fresh_feasible( + again["window_ids"], again.get("embargo_ids") or (), cfg) + kept = set(froze["window_ids"]) - set(used) + assert kept <= set(again["window_ids"]), "the set was reset, not grown" + + +# ── the released satellite checkers pay several miner cohorts ─────────────── + +SHARE, EMBARGO = 0.2, 48.0 +OVER = {"min_fresh_window_share": SHARE, "embargo_hours": EMBARGO, + "max_windows_per_settlement": 5000} + + +def _fleet(tag, start, n=24): + return [band_series(f"{tag}-s{i % 4}-{i}", f"src{i % 4}", freq="min", step=MINUTE, + region=736, start=start + i * 7, bound=start) for i in range(n)] + + +def _two_member_report(tmp_path): + """Alice (T0) and Bob (T0 + 14 h). Fleet one lies between them: fresh for + Alice, an embargo window for Bob (seen before his T, inside 48 h); fleet + two follows Bob. Both clear the house.""" + from cascade.validator.lane_d import load_pool_for + + cfg = band_cfg(**OVER) + t_bob = T0 + 14 * HOUR + alice, bob, h = entry("alice", reveal_ts=T0), entry("bob", reveal_ts=t_bob), house() + one, two = _fleet("one", T0 + HOUR), _fleet("two", t_bob + HOUR) + d = write_band_pool(tmp_path / "pool", one + two, feeds=feeds_for(one + two, EMBARGO), + snapshot="own-t") + p = load_pool_for(d, cfg) + fc = forecasts([p], [alice["digest"], bob["digest"]], h["digest"]) + st = tmp_path / "state.json" + out = settle(cfg, BOUNDARY_1, d, [alice, bob], h, fc, + {alice["hotkey"]: CHALLENGER_UID, bob["hotkey"]: CHALLENGER_UID + 1}, st, + HASH_A) + return out.report, alice, bob + + +def test_fixture_two_miner_cohorts_with_own_t_bounds(tmp_path): + rep, alice, bob = _two_member_report(tmp_path) + assert [c["members"] for c in rep["cohorts"]] == [[alice["digest"]], [bob["digest"]]] + assert [c["t_max"] for c in rep["cohorts"]] == [alice["reveal_ts"], bob["reveal_ts"]] + a, b = (set(c["window_ids"]) for c in rep["cohorts"]) + assert a - b, "Alice was not judged on windows only her own T admits" + win = {w["window_id"]: w for w in rep["windows"]} + # every window has one record, so one class across the cohorts judging it + assert all(win[x]["embargo_window"] is False for x in a & b) + + +@pytest.mark.parametrize("release", [r for r, _ in RELEASED]) +def test_the_released_checkers_pay_several_miner_cohorts(tmp_path, release): + """No burn and no finding from the checker of either deployed release on + a report with one cohort per member (different t_max).""" + rep, *_ = _two_member_report(tmp_path) + assert len(rep["cohorts"]) == 2 + got = subprocess.run(["git", "-C", str(REPO), "cat-file", "-e", f"{release}^{{commit}}"], + capture_output=True, text=True) + assert got.returncode == 0, f"release {release} is not in this clone: {got.stderr}" + tree = old_tree(tmp_path, release) + raw = {**BAND_RAW, **LIVE_ONLY, **OVER} + res = run_old_checker(tree, rep, raw, fixture_key("signer").ss58_address, tmp_path) + assert res["transient"] == "", res + assert res["burn"] is None, res + assert res["findings"] == [], res + assert res["n_cohorts"] == 2 and res["n_rows"] == len(rep["rows"]) From 3030520cf5c8f3209e553d5dc0c8c208c20c9e69 Mon Sep 17 00:00:00 2001 From: tensorlink-dev Date: Tue, 1 Dec 2026 20:20:59 +0000 Subject: [PATCH 2/4] fix(lane D): window eligibility is the member's cut-off alone; windows are never spent (owner 2026-12-01) Owner on #1056: "Miners should be able to use the same windows; it should be driven by cut-off." used_windows no longer excludes anything (the frozen-set advance, the cohort set, the seen set): a window judged in an earlier duel, against any king, stays eligible; members share windows. used_windows stays in state as a record. The frozen-set reopen-on-used change is dropped (moot). The per-member cohort rule moves into a score-free planner, _cohort_plan, so the floor pre-pass (#1055) and the judge run the same rule. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BMT4D7f8wd5dXsASyWUBwe --- cascade/validator/lane_d.py | 254 +++++++++++++++++------------ cascade/validator/lane_d_frozen.py | 15 +- docs/MINER_LANE_D.md | 7 +- tests/accept/w5c/README.md | 11 +- tests/accept/w5c/test_w5c_own_t.py | 75 ++++----- 5 files changed, 194 insertions(+), 168 deletions(-) diff --git a/cascade/validator/lane_d.py b/cascade/validator/lane_d.py index 75ee63815..79786fb80 100644 --- a/cascade/validator/lane_d.py +++ b/cascade/validator/lane_d.py @@ -18,14 +18,15 @@ the §1.3 verdicts of :func:`~cascade.validator.lane_d_forward.eligible_windows` admit for ``max(T_E, T_K)`` (both clocks after the bound, mirror lag, forecast - products, present in S0, no backfill), excluding windows the entry was - already judged on, capped at + products, present in S0, no backfill), windows the entry was already + judged on included (owner 2026-12-01: the cut-off alone decides), capped at ``max_source_share`` with a drop seeded by the boundary, frozen at the floors (``min_windows``, ``min_clusters``). An unfrozen entry stays - ``pending_floor``; nothing resets at an era boundary (T18). A cohort is - the frozen members, judged on the intersection of their frozen sets that - is eligible for ``max(T over cohort ∪ king)`` and has forecasts; the - latest-T members are deferred until that intersection meets the floors. + ``pending_floor``; nothing resets at an era boundary (T18). Each frozen + member is its own cohort (owner 2026-12-01), in reveal order, judged on + its frozen set eligible for ``max(T_E, T_K)`` with forecasts (consecutive + members with the same candidate set share one); a member whose draw + misses the floors is deferred alone. With ``min_unseen_window_share`` below 1 (owner 2026-11-30: "like lane A, with at least some guaranteed unseen data") those are the cohort's UNSEEN windows and the draw fills the rest of the judged set with SEEN @@ -932,8 +933,9 @@ def _cohort_set(pools: list[dict], members: list[str], bars: list[str], king_ts: ``max(T over cohort ∪ king)``, each window in the version of its earliest admitting snapshot (:func:`_admitted_versions`), with a usable target, a usable forecast from every bar the cohort is judged against (KING_D, plus - the house when a miner holds KING_D) and from every member, and no window - a member was already judged on; plus the §1.3 refusal counts. + the house when a miner holds KING_D) and from every member (a window a + member was judged on before stays in: owner 2026-12-01, the cut-off alone + decides); plus the §1.3 refusal counts. ``pinned`` maps a window an earlier cohort of this settlement already judged to its snapshot's sha256. The report carries one row per window, @@ -956,8 +958,11 @@ def _cohort_set(pools: list[dict], members: list[str], bars: list[str], king_ts: if not _usable(w, h) or any( _fc_ok(forecasts.get(b), wid, h, picks) is not True for b in bars): continue - if any(wid in recs[m]["used_windows"] - or _fc_ok(forecasts.get(m), wid, h, picks) is not True for m in members): + # owner 2026-12-01 ("miners should be able to use the same windows; + # it should be driven by cut-off"): a window a member was judged on + # before (against any king) stays eligible; only the cut-off rule + # (its T and KING_D's) decides. + if any(_fc_ok(forecasts.get(m), wid, h, picks) is not True for m in members): continue out.append((w, pool, v)) return out, refused @@ -973,10 +978,10 @@ def _seen_set(pools: list[dict], members: list[str], bars: list[str], king_ts: i (:func:`~cascade.validator.lane_d_forward.seen_pick_ids`) whose verdict for ``max(T over cohort ∪ king)`` is ``seen`` (not provably unseen, but from a listed feed with recorded clocks, not a forecast product), with a - usable target, a usable forecast from every bar and member, and that no - member was judged on before. A window any snapshot admits as unseen for - that bound is never a seen candidate, nor one a cohort of this settlement - judged from another snapshot.""" + usable target and a usable forecast from every bar and member (a window + a member was judged on before included, owner 2026-12-01). A window any + snapshot admits as unseen for that bound is never a seen candidate, nor + one a cohort of this settlement judged from another snapshot.""" if not seen_on(cfg) or not pools: return [] pool = pools[-1] @@ -999,8 +1004,11 @@ def _seen_set(pools: list[dict], members: list[str], bars: list[str], king_ts: i if not _usable(w, h) or any( _fc_ok(forecasts.get(b), wid, h, picks) is not True for b in bars): continue - if any(wid in recs[m]["used_windows"] - or _fc_ok(forecasts.get(m), wid, h, picks) is not True for m in members): + # owner 2026-12-01 ("miners should be able to use the same windows; + # it should be driven by cut-off"): a window a member was judged on + # before (against any king) stays eligible; only the cut-off rule + # (its T and KING_D's) decides. + if any(_fc_ok(forecasts.get(m), wid, h, picks) is not True for m in members): continue out.append((w, pool, v)) return sorted(out, key=lambda x: x[0]["window_id"]) @@ -1101,6 +1109,117 @@ def _window_embargo_fields(w: dict, v, h: int) -> dict: "freq_class": freq_class(freq), "h": int(h), "origin": int(w["target_ts"][0])} +def _cohort_plan(jobs: list, *, king_ts_of, pools: list[dict], forecasts: dict, cfg, picks: dict, + block_hash, cap_seed: str, pub_ready, pinned: dict[str, str], + windows_out: dict): + """The cohorts of one settlement and their draws, in order (owner + 2026-12-01: "it shouldn't reset the window, it should only be from when + they submitted"; "miners should be able to use the same windows; it + should be driven by cut-off"). Score-free, so the floor pre-pass and the + judge run the same rule. + + ``jobs``: ``(king digest, stage, [member], {member: record}, is_house)``, + one per miner member in reveal order, then the house challenger. Yields + ``("skip", digest, reason, record)`` and ``("cohort", king digest, stage, + members, records, is_house, bars, king_ts, eligible, refused, seen, + picked, draw)``. Each miner member is judged on the windows eligible + from its own cut-off (``max(T_E, T_K)``), whatever any other member or an + earlier duel used; consecutive members whose candidate sets coincide + (record for record) share one cohort and one draw. The draws share + ``max_windows_per_settlement``, earliest reveal first; a member whose + draw misses the floors waits ``pending_floor`` alone. Each cohort's + picked windows enter ``pinned`` / ``windows_out`` before it is yielded + (a later cohort skips a window an earlier one judged under another + record: the report holds one per window).""" + jobs = list(jobs) + advanced: set[str] = set() + while jobs: + kd, stage, members, recs, is_house = jobs.pop(0) + members = list(members) + king_ts = king_ts_of(kd) + # DEC-CA-0076 (owner 2026-11-24): KING_D is the only bar. At genesis + # it is the house; after the first miner crown the house is no + # second bar (W5c change 3 retired). + bars = [kd] + if king_ts is None or any(forecasts.get(b) is None or not pub_ready(b) for b in bars): + for m in members: + yield ("skip", m, "king_unscored", recs[m]) + continue + # A member without a public score set (never asked of the eval host) + # cannot be judged on the combined rule: it waits (fail closed). + for m in [m for m in members if not pub_ready(m)]: + yield ("skip", m, "king_unscored", recs[m]) + members.remove(m) + if not members: + continue + members = sorted(members, key=lambda m: (recs[m]["reveal_ts"], m)) + frozen = [] + for m in members: + rec = recs[m] + if m not in advanced: + rec["frozen_set"] = _advance_member(rec, pools, int(king_ts), cfg, cap_seed) + advanced.add(m) + if rec["frozen_set"]["frozen"]: + frozen.append(m) + else: + yield ("skip", m, "pending_floor", rec) + members = frozen + if not members: + continue + # W5j: the judged windows are the cohort's seeded per-bin draw over + # its eligible set, within what is left of the settlement's + # max_windows_per_settlement (earlier cohorts, i.e. earlier reveals, + # draw first); a draw below the floors (or short of the minimum fresh + # share, or out of budget) leaves the member pending. + budget = int(cfg.max_windows_per_settlement) - len(windows_out) + + def cands_of(ms, recs, bars=bars, king_ts=king_ts): + el, why = _cohort_set(pools, ms, bars, king_ts, recs, forecasts, cfg, pinned, + picks) + # owner 2026-11-30: the seen candidates the draw fills the set with + sc = _seen_set(pools, ms, bars, king_ts, recs, forecasts, cfg, pinned, picks, el) + return (_same_record(el, windows_out, cfg, picks), why, + _same_record(sc, windows_out, cfg, picks)) + + eligible, refused, seen_c = cands_of(members, recs) + # The next members in reveal order whose candidate set is this one, + # window for window and record for record, join this cohort: one + # draw serves them all (the draw each would get alone), so they share + # the window budget instead of each spending it. + while not is_house and jobs and not jobs[0][4] and jobs[0][0] == kd: + nm = jobs[0][2][0] + nrec = jobs[0][3][nm] + if not pub_ready(nm): + break + if nm not in advanced: + nrec["frozen_set"] = _advance_member(nrec, pools, int(king_ts), cfg, cap_seed) + advanced.add(nm) + if not nrec["frozen_set"]["frozen"]: + break + n_el, _, n_sc = cands_of([nm], {**recs, nm: nrec}) + if _cand_key(n_el, cfg, picks) != _cand_key(eligible, cfg, picks) \ + or _cand_key(n_sc, cfg, picks) != _cand_key(seen_c, cfg, picks): + break + jobs.pop(0) + recs = {**recs, nm: nrec} + members.append(nm) + eligible, refused, seen_c = cands_of(members, recs) + picked, drawn, ok = _drawn(eligible, cfg, block_hash, budget, seen_c) + while members and not ok: + m = members.pop() + yield ("skip", m, "pending_floor", recs[m]) + if members: + eligible, refused, seen_c = cands_of(members, recs) + picked, drawn, ok = _drawn(eligible, cfg, block_hash, budget, seen_c) + if not members: + continue + for w, src_pool, v in picked: + pinned[w["window_id"]] = str(src_pool["sha256"]) + windows_out[w["window_id"]] = _window_record(w, src_pool, v, cfg, picks) + yield ("cohort", kd, stage, members, recs, is_house, bars, king_ts, eligible, refused, + seen_c, picked, drawn) + + def _window_record(w: dict, src_pool: dict, v, cfg, picks: dict) -> dict: """The report's ``windows[]`` record of one judged window, as the cohort that judges it (its snapshot and its §1.3 verdict at the cohort's @@ -1164,7 +1283,7 @@ def _advance_member(rec: dict, pools: list[dict], king_ts: int, cfg, seed: str) if prog is not None and int(prog.get("t_max", -1)) != t_max: prog = None prog = advance_frozen_set(prog, pools, t_entry=int(rec["reveal_ts"]), t_king=int(king_ts), - cfg=cfg, seed=seed, exclude=rec["used_windows"]) + cfg=cfg, seed=seed) prog["t_max"] = t_max return prog @@ -1660,93 +1779,17 @@ def skip(dg: str, reason: str, rec: dict | None = None) -> None: candidates: list[dict] = [] # rev6.18 A3 (F4): every digest scored on the public half (report rows). pub_scored: set[str] = set() - # The members whose frozen set this settlement already advanced (a - # cohort looks ahead at the next member's set: see below). - advanced: set[str] = set() - while jobs: - kd, stage, members, recs, is_house = jobs.pop(0) - king_ts = _king_reveal_ts(state, kd) - # DEC-CA-0076 (owner 2026-11-24): KING_D is the only bar. At genesis - # it is the house; after the first miner crown the house is no - # second bar (W5c change 3 retired). - bars = [kd] - if king_ts is None or any(forecasts.get(b) is None or not _pub_ready(pub_of(b)) - for b in bars): - for m in members: - skip(m, "king_unscored", recs[m]) - continue - # A member without a public score set (never asked of the eval host) - # cannot be judged on the combined rule: it waits (fail closed). - for m in [m for m in members if not _pub_ready(pub_of(m))]: - skip(m, "king_unscored", recs[m]) - members.remove(m) - if not members: - continue - members = sorted(members, key=lambda m: (recs[m]["reveal_ts"], m)) - frozen = [] - for m in members: - rec = recs[m] - if m not in advanced: - rec["frozen_set"] = _advance_member(rec, pools, int(king_ts), cfg, cap_seed) - advanced.add(m) - if rec["frozen_set"]["frozen"]: - frozen.append(m) - else: - skip(m, "pending_floor", rec) - members = frozen - if not members: - continue - # W5j: the judged windows are the cohort's seeded per-bin draw over - # its eligible set, within what is left of the settlement's - # max_windows_per_settlement (earlier cohorts, i.e. earlier reveals, - # draw first); a draw below the floors (or short of the minimum fresh - # share, or out of budget) leaves the member pending. - budget = int(cfg.max_windows_per_settlement) - len(windows_out) - - def cands_of(ms, bars=bars, king_ts=king_ts, recs=recs): - el, why = _cohort_set(pools, ms, bars, king_ts, recs, forecasts, cfg, pinned, - picks) - # owner 2026-11-30: the seen candidates the draw fills the set with - sc = _seen_set(pools, ms, bars, king_ts, recs, forecasts, cfg, pinned, picks, el) - # owner 2026-12-01: cohorts of one settlement have different T; - # the report holds ONE record per judged window, so a window an - # earlier cohort judged under another record (its class at that - # cohort's bound) is left out of this one (fail closed). - return (_same_record(el, windows_out, cfg, picks), why, - _same_record(sc, windows_out, cfg, picks)) - - eligible, refused, seen_c = cands_of(members) - # The next members in reveal order whose own-T candidate set is this - # one, window for window and record for record, join this cohort: - # one draw serves them all (the same draw each would get alone), so - # they share the window budget instead of each spending it. - while not is_house and jobs and not jobs[0][4] and jobs[0][0] == kd: - nm = jobs[0][2][0] - nrec = jobs[0][3][nm] - if not _pub_ready(pub_of(nm)): - break - if nm not in advanced: - nrec["frozen_set"] = _advance_member(nrec, pools, int(king_ts), cfg, cap_seed) - advanced.add(nm) - if not nrec["frozen_set"]["frozen"]: - break - n_el, _, n_sc = cands_of([nm], recs={**recs, nm: nrec}) - if _cand_key(n_el, cfg, picks) != _cand_key(eligible, cfg, picks) \ - or _cand_key(n_sc, cfg, picks) != _cand_key(seen_c, cfg, picks): - break - jobs.pop(0) - recs = {**recs, nm: nrec} - members.append(nm) - eligible, refused, seen_c = cands_of(members, recs=recs) - picked, drawn, ok = _drawn(eligible, cfg, boundary_block_hash, budget, seen_c) - while members and not ok: - m = members.pop() - skip(m, "pending_floor", recs[m]) - if members: - eligible, refused, seen_c = cands_of(members, recs=recs) - picked, drawn, ok = _drawn(eligible, cfg, boundary_block_hash, budget, seen_c) - if not members: + for step in _cohort_plan(jobs, king_ts_of=lambda kd: _king_reveal_ts(state, kd), + pools=pools, forecasts=forecasts, cfg=cfg, picks=picks, + block_hash=boundary_block_hash, cap_seed=cap_seed, + pub_ready=lambda dg: _pub_ready(pub_of(dg)), pinned=pinned, + windows_out=windows_out): + if step[0] == "skip": + _, m, why, rec = step + skip(m, why, rec) continue + (_, kd, stage, members, recs, is_house, bars, king_ts, eligible, refused, seen_c, + picked, drawn) = step ws = [w for w, _, _ in picked] scores = {} scored = [*bars, *members] @@ -1754,9 +1797,8 @@ def cands_of(ms, bars=bars, king_ts=king_ts, recs=recs): pairs = [score_window(forecasts[dg][w["window_id"]], w["target"], w["history"], w["seasonal_period"]) for w in ws] scores[dg] = (np.asarray([p[0] for p in pairs]), np.asarray([p[1] for p in pairs])) - for i, (w, src_pool, v) in enumerate(picked): - pinned[w["window_id"]] = str(src_pool["sha256"]) - windows_out[w["window_id"]] = _window_record(w, src_pool, v, cfg, picks) + for i, (w, _src_pool, _v) in enumerate(picked): + # (``pinned`` / ``windows_out`` already hold it: _cohort_plan) for dg in scored: rows.append({"window_id": w["window_id"], "digest": dg, "cohort": len(cohorts), "crps": float(scores[dg][0][i]), "mase": float(scores[dg][1][i])}) diff --git a/cascade/validator/lane_d_frozen.py b/cascade/validator/lane_d_frozen.py index 5bff3668c..7507a54e3 100644 --- a/cascade/validator/lane_d_frozen.py +++ b/cascade/validator/lane_d_frozen.py @@ -19,10 +19,8 @@ ``K = fresh_keep(E, F, s)`` embargo windows are kept, so ``F + K`` must reach ``min_windows``. A set of embargo windows only would otherwise freeze, fail every draw ``fresh_share_short`` and never gain the fresh windows it needs. -A frozen record that fails this check (one written by code without it, or, -owner 2026-12-01, one whose fresh windows were spent on an earlier duel: the -check counts only the windows not yet judged) reopens: it keeps its windows -not yet judged as its union and grows. The record lists its +A frozen record that fails this check (one written by code without it) +reopens: it keeps its windows as its union and grows. The record lists its embargo windows in ``embargo_ids`` (only when there are any). The progress record (:func:`advance_frozen_set`) is plain JSON so it can live @@ -165,16 +163,11 @@ class recorded when it joined; a window of a record written before the def embargo_of(ids) -> list[str]: return sorted(k for k in ids if klass.get(k, k in recorded)) - skip = {str(x) for x in exclude} if frozen: - # owner 2026-12-01 (live 9626400): feasible on the windows the entry - # can still be judged on, i.e. without those in ``exclude``. A set - # whose fresh windows were spent on an earlier duel (7b11d440: 84 of - # 360 left) reopens and grows from its own T instead of staying - # frozen and failing every draw. - ids = [str(k) for k in progress.get("window_ids") or () if str(k) not in skip] + ids = [str(k) for k in progress.get("window_ids") or ()] if fresh_feasible(ids, embargo_of(ids), cfg): return copy.deepcopy(progress) + skip = {str(x) for x in exclude} sources: dict[str, str] = {} if progress is not None: sources = {str(k): str(v) for k, v in (progress.get("sources") or {}).items() diff --git a/docs/MINER_LANE_D.md b/docs/MINER_LANE_D.md index 7c3f16dd1..cc83dd673 100644 --- a/docs/MINER_LANE_D.md +++ b/docs/MINER_LANE_D.md @@ -244,9 +244,10 @@ blocks, about 24 h) of `submit`, or the entry expires (`ready_expired`). never blocks yours. Entries are judged in reveal order, earliest first, sharing the settlement's `max_windows_per_settlement` budget. If the budget runs short of `min_windows`, the later entries wait - (`pending_floor`) for the next settlement. Windows you were already - judged on are never used again. If that leaves too few fresh windows, - your set reopens and grows with the newer windows. + (`pending_floor`) for the next settlement. Only the cut-off decides + which windows you can be judged on: entries may share windows, and a + window you were judged on in an earlier duel (against any king) stays + eligible. ## How you are paid diff --git a/tests/accept/w5c/README.md b/tests/accept/w5c/README.md index 41f531c46..af209142f 100644 --- a/tests/accept/w5c/README.md +++ b/tests/accept/w5c/README.md @@ -30,8 +30,10 @@ behaviour is change 3, and those tests fail on main. - A member's set is its frozen set that is eligible (§1.3, W5a) for its own `t_max`, with a usable target and a usable forecast from the king and the - member, minus the windows it was already judged on. No other member's T - or frozen set shrinks it. + member. A window the member was judged on in an earlier duel (against any + king) stays in (owner 2026-12-01: "Miners should be able to use the same + windows; it should be driven by cut-off"), and members share windows. No + other member's T or frozen set shrinks it. - The settlement's `max_windows_per_settlement` budget is shared across the cohorts, earliest reveal first (a window judged in two cohorts counts once). - A window an earlier cohort of the settlement judged under a different @@ -48,9 +50,8 @@ behaviour is change 3, and those tests fail on main. - A deferred entry is not judged: no rows, no verdict, not in `judged`. It gets one `skipped` record with the typed reason `pending_floor` (in `ENTRY_REASONS`), and its state stays `pending` / `pending_floor` with - `used_windows` unchanged. Its `frozen_set` stays frozen and unchanged, - unless the windows it was not yet judged on can no longer meet the fresh - share: then it reopens and grows (W5b). + `used_windows` unchanged (a record of what it was judged on; it no longer + excludes anything). Its `frozen_set` stays frozen and unchanged. - At the next settlement it is judged on its frozen set: the cohort's `set_sha256` equals the frozen set's. - The released satellite checkers (890fe6d1, 0445a442) pay a report with diff --git a/tests/accept/w5c/test_w5c_own_t.py b/tests/accept/w5c/test_w5c_own_t.py index 15ce6f8ce..16ff2ea84 100644 --- a/tests/accept/w5c/test_w5c_own_t.py +++ b/tests/accept/w5c/test_w5c_own_t.py @@ -6,21 +6,21 @@ T) met no floor, so the latest-T member was dropped ``pending_floor`` until none was left: 61ab1757 (1,924 fresh windows of its own) was dropped because its joint set with the older 7b11d440 held 2 fresh windows, and 7b11d440 -alone had 84 fresh windows left (its other fresh ones were used in its -9623700 duel), under the 20 % fresh share of a 1,000-window floor. Nobody +alone had 84 fresh windows left (its other fresh ones were excluded as used +in its 9623700 duel), under the 20 % fresh share of a 1,000-window floor. Nobody was judged. Now each member is its own cohort, in reveal order, over the windows eligible from its own T, within what is left of ``max_windows_per_settlement`` (earliest reveal first), with the floors per -member; a frozen set whose fresh windows were spent on an earlier duel -reopens and grows. The released satellite checkers (890fe6d1, 0445a442) pay +member. A window a member was judged on before stays eligible (owner +2026-12-01: "Miners should be able to use the same windows; it should be +driven by cut-off"), and members share windows freely. The released satellite checkers (890fe6d1, 0445a442) pay a report with several miner cohorts. """ from __future__ import annotations -import json import subprocess import pytest @@ -187,46 +187,34 @@ def test_the_window_budget_is_shared_across_cohorts_earliest_reveal_first(tmp_pa assert state["entries"][e["digest"]]["used_windows"] == [] -# ── a frozen set spent on an earlier duel reopens (7b11d440) ──────────────── +# ── windows are never spent: the cut-off alone decides (owner 2026-12-01) ── -def test_a_frozen_set_whose_fresh_windows_were_used_reopens_and_grows(tmp_path): - """7b11d440 at 9626400: frozen with 360 fresh windows, 276+ of them used - in its 9623700 duel; the frozen check counted the used ones, so the set - stayed frozen and every draw failed the fresh share. Now the check - counts only windows not yet judged: the set reopens, keeps those, and - grows with the windows that arrived since (all forward of its own T).""" - from cascade.validator.lane_d import load_pool_for - from cascade.validator.lane_d_frozen import advance_frozen_set, fresh_feasible - - cfg = band_cfg(min_fresh_window_share=0.2, embargo_hours=48.0) - kt = T0 - 2 * 86_400 - - def fleet(tag, start, n=24): - return [band_series(f"{tag}-s{i % 4}-{i}", f"src{i % 4}", freq="min", step=MINUTE, - region=736, start=start + i * 7, bound=T0) for i in range(n)] - - first = fleet("first", T0 + HOUR) - d1 = write_band_pool(tmp_path / "p1", first, feeds=feeds_for(first, 48.0), snapshot="p1") - p1 = load_pool_for(d1, cfg) - froze = advance_frozen_set(None, [p1], t_entry=T0, t_king=kt, cfg=cfg, seed="s1") - assert froze["frozen"] is True - fresh = [w for w in froze["window_ids"] if w not in set(froze.get("embargo_ids") or ())] - used = fresh[: len(fresh) - 1] # the earlier duel spent all but one - assert not fresh_feasible([w for w in froze["window_ids"] if w not in set(used)], - froze.get("embargo_ids") or (), cfg), "fixture" - later = fleet("later", T0 + 20 * HOUR) - d2 = write_band_pool(tmp_path / "p2", first + later, - feeds=feeds_for(first + later, 48.0), snapshot="p2") - p2 = load_pool_for(d2, cfg) - again = advance_frozen_set(json.loads(json.dumps(froze)), [p1, p2], t_entry=T0, t_king=kt, - cfg=cfg, seed="s2", exclude=used) - assert again != froze, "a frozen set the draw can no longer serve stayed frozen" - assert not set(used) & set(again["window_ids"]), "a used window rejoined the set" - assert again["frozen"] is True and fresh_feasible( - again["window_ids"], again.get("embargo_ids") or (), cfg) - kept = set(froze["window_ids"]) - set(used) - assert kept <= set(again["window_ids"]), "the set was reset, not grown" +def test_a_window_judged_in_an_earlier_duel_stays_eligible(tmp_path): + """Owner 2026-12-01: "Miners should be able to use the same windows; it + should be driven by cut-off." 7b11d440 at 9626400: 1,380 of its windows + were judged in its 9623700 duel against the house king; on the base they + were excluded against the new king, leaving 84 fresh. Now a window the + member was judged on before (against any king) stays in its set.""" + from cascade.validator.lane_d import _cohort_set, load_pool_for + + a_band, b_band, c_band = _bands() + records = a_band + b_band + c_band + A = w5c_entry("alpha", reveal_ts=T_A) + h = w5c_house() + cfg = lane_d_cfg() + pool = load_pool_for(write_pool(tmp_path / "pool", records, "w5c-reuse"), cfg) + every = wids(records) + used = every[: len(every) // 2] + rec = {"reveal_ts": T_A, "used_windows": list(used), + "frozen_set": {"frozen": True, "window_ids": list(every)}} + fc = {h["digest"]: model_forecasts(records, "bad", "house"), + A["digest"]: model_forecasts(records, "good", A["digest"])} + got, _ = _cohort_set([pool], [A["digest"]], [h["digest"]], h["reveal_ts"], + {A["digest"]: rec}, fc, cfg, {}, {}) + ids = {w["window_id"] for w, _, _ in got} + assert set(used) <= ids, "a window judged in an earlier duel was excluded (spent)" + assert ids == set(every) # ── the released satellite checkers pay several miner cohorts ─────────────── @@ -268,6 +256,7 @@ def test_fixture_two_miner_cohorts_with_own_t_bounds(tmp_path): assert [c["t_max"] for c in rep["cohorts"]] == [alice["reveal_ts"], bob["reveal_ts"]] a, b = (set(c["window_ids"]) for c in rep["cohorts"]) assert a - b, "Alice was not judged on windows only her own T admits" + assert a & b, "members may share windows" win = {w["window_id"]: w for w in rep["windows"]} # every window has one record, so one class across the cohorts judging it assert all(win[x]["embargo_window"] is False for x in a & b) From 05fb3ea5a9420032d0c17813d8ccae0a42a8fd2e Mon Sep 17 00:00:00 2001 From: tensorlink-dev Date: Tue, 1 Dec 2026 20:27:35 +0000 Subject: [PATCH 3/4] test(lane D): W7c migration re-judges on the cut-off, first-clear windows included (owner 2026-12-01) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BMT4D7f8wd5dXsASyWUBwe --- tests/accept/w7c/README.md | 10 ++-- .../accept/w7c/test_w7c_confirm_migration.py | 46 +++++++++++-------- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/tests/accept/w7c/README.md b/tests/accept/w7c/README.md index 6ec9a3c22..526a85ba0 100644 --- a/tests/accept/w7c/README.md +++ b/tests/accept/w7c/README.md @@ -261,10 +261,12 @@ settlement after the release `settle_lane_d` migrates it: `confirm.king_digest` names: `pending` / `pending_floor`, the first clear discarded (the old D20 (a) outcome). The legacy `confirm` record carries no first-clear LCB, so the entry cannot be ranked or gated as a crown - candidate; it is re-judged under the first-verdict rule once fresh - windows meet the floors. Its first-clear windows stay in `used_windows`, - so it is never re-judged on them (§1.3: an entry is never judged twice on - a window). Testnet only: lane D was never armed on mainnet. + candidate; it is re-judged under the first-verdict rule once its windows + meet the floors. Its first-clear windows stay recorded in `used_windows`; + since owner 2026-12-01 ("miners should be able to use the same windows; it + should be driven by cut-off") they are not excluded, so it is re-judged at + b2 on everything eligible from its cut-off, those windows included. + Testnet only: lane D was never armed on mainnet. - Either way the settlement's signed report carries the typed tag `confirm_state_migrated` as a string value somewhere in its body (where is the implementer's choice; `extensions` is the open place). The next diff --git a/tests/accept/w7c/test_w7c_confirm_migration.py b/tests/accept/w7c/test_w7c_confirm_migration.py index a1f19d664..7eb562349 100644 --- a/tests/accept/w7c/test_w7c_confirm_migration.py +++ b/tests/accept/w7c/test_w7c_confirm_migration.py @@ -107,33 +107,43 @@ def _binds(settlement, legacy: dict, path) -> None: verify_receipt(rec, report=settlement.report, state=json.loads(path.read_bytes())) +def _judged_afresh(report: dict, chain: Chain, x: str, king: str) -> None: + """The migrated entry's only verdict is a fresh one at b2, against the + KING_D of b2, on a set that may hold its first-clear windows (owner + 2026-12-01: the cut-off alone decides); any crown comes from it.""" + mine = [v for v in report.get("verdicts") or [] if v.get("digest") == x] + assert len(mine) == 1, "the migrated entry is not judged afresh at b2" + (v,) = mine + assert v["king_digest"] == king and v["stage"] == "first" + (c,) = [c for c in report["cohorts"] if x in c["members"]] + assert set(_first_clear_ids(chain)) & set(c["window_ids"]), \ + "the first-clear windows were excluded (spent)" + if report["crowned"] is not None: + assert report["crowned"] == x and v["cleared"] is True + + def test_rev611_confirm_pending_against_the_current_king_returns_to_pending_floor(tmp_path): """Orchestrator decision 2026-11-23: the legacy `confirm` record carries no first-clear LCB, so even when its king is still KING_D the entry is - not a crown candidate: it is `pending` / `pending_floor`, its first clear - discarded, its first-clear windows still used. Snapshot 2 alone is below - the floors, so nothing is judged, gated or crowned at the migration.""" + not a crown candidate on it: it is re-queued, its first clear discarded, + its first-clear windows still recorded as used. Owner 2026-12-01 ("miners + should be able to use the same windows; it should be driven by cut-off"): + used windows are not excluded, so the entry is judged afresh at the + migration on everything eligible from its cut-off, the first-clear + windows included.""" chain = W7cChain(tmp_path) path = chain.state_path("legacy") legacy = _legacy_state(chain, path, king_matches=True) x = chain.x["digest"] king = legacy["king"]["digest"] - hosts = len(chain.hosts) s2 = _settle_b2(chain, path, legacy) - assert s2.report["crowned"] is None, \ - "a migrated confirm_pending entry is never crowned on its discarded first clear" - assert not any(h.calls for h in chain.hosts[hosts:]), \ - "no gate runs for a migrated entry (it is not a candidate)" - assert not any(v.get("digest") == x for v in s2.report.get("verdicts") or []), \ - "below the floors on fresh windows, the migrated entry is not judged at b2" + _judged_afresh(s2.report, chain, x, king) state = json.loads(path.read_bytes()) - assert state["king"]["digest"] == king, "KING_D is unchanged by the migration" rec = state["entries"][x] - assert (rec["status"], rec["reason"]) == ("pending", "pending_floor"), \ - (rec["status"], rec["reason"]) + assert rec["status"] != "confirm_pending" and rec.get("confirm") is None, rec assert set(_first_clear_ids(chain)) <= set(rec["used_windows"]), \ - "the windows of the discarded first clear stay used (never re-judged)" + "the windows of the discarded first clear stay recorded as used" assert "confirm_pending" not in canonical(state).decode(), \ "no confirm_pending survives the migration" assert _tag_paths(s2.report), f"the signed report tags the migration ({TAG})" @@ -150,14 +160,14 @@ def test_rev611_confirm_pending_against_another_king_returns_to_pending_floor(tm legacy = _legacy_state(chain, path, king_matches=False) x = chain.x["digest"] + king = legacy["king"]["digest"] s2 = _settle_b2(chain, path, legacy) - assert s2.report["crowned"] is None, "a first clear against another king is discarded" + _judged_afresh(s2.report, chain, x, king) state = json.loads(path.read_bytes()) rec = state["entries"][x] - assert (rec["status"], rec["reason"]) == ("pending", "pending_floor"), \ - (rec["status"], rec["reason"]) + assert rec["status"] != "confirm_pending" and rec.get("confirm") is None, rec assert set(_first_clear_ids(chain)) <= set(rec["used_windows"]), \ - "the windows of the discarded first clear stay used (never re-judged)" + "the windows of the discarded first clear stay recorded as used" assert "confirm_pending" not in canonical(state).decode() assert _tag_paths(s2.report), f"the signed report tags the migration ({TAG})" _binds(s2, legacy, path) From 31eaf87577cda9ea228dc0cb5d078e591b9ef314 Mon Sep 17 00:00:00 2001 From: tensorlink-dev Date: Tue, 1 Dec 2026 20:40:41 +0000 Subject: [PATCH 4/4] refactor(lane D): _cohort_plan takes the floor pre-pass's floored members (#1055 seam) A group sharing one candidate set fails as one, in reveal order. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BMT4D7f8wd5dXsASyWUBwe --- cascade/validator/lane_d.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/cascade/validator/lane_d.py b/cascade/validator/lane_d.py index 79786fb80..80c74ccc3 100644 --- a/cascade/validator/lane_d.py +++ b/cascade/validator/lane_d.py @@ -1111,7 +1111,7 @@ def _window_embargo_fields(w: dict, v, h: int) -> dict: def _cohort_plan(jobs: list, *, king_ts_of, pools: list[dict], forecasts: dict, cfg, picks: dict, block_hash, cap_seed: str, pub_ready, pinned: dict[str, str], - windows_out: dict): + windows_out: dict, floored=frozenset()): """The cohorts of one settlement and their draws, in order (owner 2026-12-01: "it shouldn't reset the window, it should only be from when they submitted"; "miners should be able to use the same windows; it @@ -1130,7 +1130,11 @@ def _cohort_plan(jobs: list, *, king_ts_of, pools: list[dict], forecasts: dict, draw misses the floors waits ``pending_floor`` alone. Each cohort's picked windows enter ``pinned`` / ``windows_out`` before it is yielded (a later cohort skips a window an earlier one judged under another - record: the report holds one per window).""" + record: the report holds one per window). + + ``floored``: miner members the floor pre-pass found below the floors (no + forecast was asked for them): each is skipped ``pending_floor`` where its + own draw would have failed, the report unchanged.""" jobs = list(jobs) advanced: set[str] = set() while jobs: @@ -1141,13 +1145,18 @@ def _cohort_plan(jobs: list, *, king_ts_of, pools: list[dict], forecasts: dict, # it is the house; after the first miner crown the house is no # second bar (W5c change 3 retired). bars = [kd] - if king_ts is None or any(forecasts.get(b) is None or not pub_ready(b) for b in bars): + # with every member below the floors no bar was forecast either + # (nothing is scored); the floors still run + only_floored = king_ts is not None and all(m in floored for m in members) + if king_ts is None or (not only_floored and any( + forecasts.get(b) is None or not pub_ready(b) for b in bars)): for m in members: yield ("skip", m, "king_unscored", recs[m]) continue # A member without a public score set (never asked of the eval host) - # cannot be judged on the combined rule: it waits (fail closed). - for m in [m for m in members if not pub_ready(m)]: + # cannot be judged on the combined rule: it waits (fail closed). A + # floored member was not asked: the floors below skip it. + for m in [m for m in members if m not in floored and not pub_ready(m)]: yield ("skip", m, "king_unscored", recs[m]) members.remove(m) if not members: @@ -1159,7 +1168,7 @@ def _cohort_plan(jobs: list, *, king_ts_of, pools: list[dict], forecasts: dict, if m not in advanced: rec["frozen_set"] = _advance_member(rec, pools, int(king_ts), cfg, cap_seed) advanced.add(m) - if rec["frozen_set"]["frozen"]: + if rec["frozen_set"]["frozen"] and m not in floored: frozen.append(m) else: yield ("skip", m, "pending_floor", rec) @@ -1189,7 +1198,7 @@ def cands_of(ms, recs, bars=bars, king_ts=king_ts): while not is_house and jobs and not jobs[0][4] and jobs[0][0] == kd: nm = jobs[0][2][0] nrec = jobs[0][3][nm] - if not pub_ready(nm): + if nm in floored or not pub_ready(nm): break if nm not in advanced: nrec["frozen_set"] = _advance_member(nrec, pools, int(king_ts), cfg, cap_seed) @@ -1205,13 +1214,11 @@ def cands_of(ms, recs, bars=bars, king_ts=king_ts): members.append(nm) eligible, refused, seen_c = cands_of(members, recs) picked, drawn, ok = _drawn(eligible, cfg, block_hash, budget, seen_c) - while members and not ok: - m = members.pop() - yield ("skip", m, "pending_floor", recs[m]) - if members: - eligible, refused, seen_c = cands_of(members, recs) - picked, drawn, ok = _drawn(eligible, cfg, block_hash, budget, seen_c) - if not members: + if not ok: + # The members share one candidate set, so each alone gets this + # same draw: every one waits, in reveal order. + for m in members: + yield ("skip", m, "pending_floor", recs[m]) continue for w, src_pool, v in picked: pinned[w["window_id"]] = str(src_pool["sha256"])