diff --git a/.github/workflows/laned-king-sync.yml b/.github/workflows/laned-king-sync.yml index 9d7946e71..4c3b093b6 100644 --- a/.github/workflows/laned-king-sync.yml +++ b/.github/workflows/laned-king-sync.yml @@ -3,8 +3,8 @@ name: laned-king-sync # Copies the signed lane D index (champions/lane_d/index.json) into the repo # and writes one card pair per king: champions/lane_d// # {PROVENANCE.json, MODEL_CARD.md} (LANE_D_PLAN §11.1, W13). No weights in -# git: the checkpoints live on the Hippius Hub, the R2 public mirror and the -# HF dataset tensorlink-dev/cascade-lane-d-kings. +# git: the checkpoints live on the mirrors of [lane_d_ops] king_mirrors (owner +# 2026-12-01: the Hippius Hub only by default). # # scripts/laned_king_sync.py reads the public index, verifies it under the # pinned [manifest] validator_hotkey and writes through diff --git a/cascade/lane_d/mirrors.py b/cascade/lane_d/mirrors.py index f7d870804..eee5291fd 100644 --- a/cascade/lane_d/mirrors.py +++ b/cascade/lane_d/mirrors.py @@ -360,21 +360,34 @@ def _r2_client(storage, environ: Mapping[str, str]): def open_live_mirrors(cfg, *, context: int, hotkey: str, digest: str, environ: Mapping[str, str] | None = None, hub_api=None, hf_api=None, r2_client=None, - tmp_dir: str | os.PathLike | None = None) -> dict: - """``{"hub", "r2", "hf"}`` mirror clients for one king from the loaded - ``ChainConfig`` (``[storage]``). The ``*_api`` / ``r2_client`` arguments + tmp_dir: str | os.PathLike | None = None, names=None) -> dict: + """The mirror clients of ``names`` (the king mirrors, + :func:`cascade.lane_d.publish.king_mirror_names`: the Hub only by + default) for one king from the loaded ``ChainConfig`` (``[storage]``); no + other mirror's client is built. The ``*_api`` / ``r2_client`` arguments replace the live backends (tests). ``tmp_dir`` is where the Hub and HF mirrors download a file for a read-back (default: the system temp directory).""" + from .publish import king_mirror_names + env = os.environ if environ is None else environ storage = cfg.storage - hub = hub_api if hub_api is not None else _LazyApi(lambda: _hub_api(env)) - hf = hf_api if hf_api is not None else _LazyApi(lambda: _hf_api(env)) - r2 = (lambda: r2_client) if r2_client is not None else _lazy(lambda: _r2_client(storage, env)) - return {"hub": hub_mirror(hub, namespace=str(getattr(storage, "hub_namespace", "cascade")), - context=context, hotkey=hotkey, digest=digest, tmp_dir=tmp_dir), - "r2": S3Mirror(r2, bucket=r2_bucket(storage)), - "hf": hf_mirror(hf, tmp_dir=tmp_dir)} + out: dict = {} + for name in king_mirror_names(names): + if name == "hub": + hub = hub_api if hub_api is not None else _LazyApi(lambda: _hub_api(env)) + out[name] = hub_mirror(hub, namespace=str(getattr(storage, "hub_namespace", + "cascade")), + context=context, hotkey=hotkey, digest=digest, + tmp_dir=tmp_dir) + elif name == "r2": + r2 = ((lambda: r2_client) if r2_client is not None + else _lazy(lambda: _r2_client(storage, env))) + out[name] = S3Mirror(r2, bucket=r2_bucket(storage)) + else: + hf = hf_api if hf_api is not None else _LazyApi(lambda: _hf_api(env)) + out[name] = hf_mirror(hf, tmp_dir=tmp_dir) + return out class _LazyApi: diff --git a/cascade/lane_d/ops_jobs.py b/cascade/lane_d/ops_jobs.py index 0128dd7b2..eaa599524 100644 --- a/cascade/lane_d/ops_jobs.py +++ b/cascade/lane_d/ops_jobs.py @@ -31,7 +31,9 @@ ``lane_d_state.json`` and its persisted reports. * ``king-check``: every crowned persisted report against the signed lane D index (and, given local copies, the vault and the mirrors): §11.1 "one - digest, one identity" via :func:`cascade.lane_d.publish.check_one_digest`. + digest, one identity" via :func:`cascade.lane_d.publish.check_one_digest`, + over the king mirrors only (``[lane_d_ops] king_mirrors`` of + ``--chain-toml``; without it the default, the Hub only). With ``--path-unit`` (the installed ``cascade-laned-king-publish.path``) it also fails when that unit does not watch the folder the validator writes publish requests to (``lane_d_publish_requests`` beside ``--state``). @@ -42,7 +44,8 @@ * ``king-publish``: for every crowned persisted report not yet in the signed index (the validator's settlement step leaves a ``laned_king_publish_request/1`` per crowning), copy the king from the vault - to the Hub, R2 and HF mirrors (:func:`cascade.lane_d.publish.publish_king`, + to the king mirrors (``[lane_d_ops] king_mirrors``, default the Hippius Hub + only; :func:`cascade.lane_d.publish.publish_king`, read-back re-hash), re-sign ``champions/lane_d/index.json`` with the validator hotkey, put it on the public store and write the local copy ``king-check`` reads. A checkpoint is never held in memory: it is spooled @@ -50,8 +53,8 @@ ``--state``; removed when the job ends) and streamed from there, so the job runs on the box. It refuses (exit 1, nothing written) when that disk has less free than the king's files, one read-back and 1 GiB. -* ``takedown``: B13, unpublish one king from the Hub and HF mirrors and - re-sign the index (``--reason licence|rights``). +* ``takedown``: B13, unpublish one king from the configured Hub / HF king + mirrors and re-sign the index (``--reason licence|rights``). Exit codes (every job): 0 done / nothing to do / dry-run planned; 1 an input is unreadable or invalid, or a check found a problem (nothing written); @@ -392,6 +395,25 @@ def delete(self, key: str) -> None: return out +def _king_mirrors(args, cfg=None) -> tuple[str, ...]: + """``[lane_d_ops] king_mirrors`` of ``cfg`` (else of ``--chain-toml`` when + given), else the default (the Hub only).""" + from .publish import DEFAULT_KING_MIRRORS + + if cfg is None and getattr(args, "chain_toml", None) is not None: + from ..shared.config import load_chain_config + + cfg = load_chain_config(args.chain_toml) + if cfg is None: + return DEFAULT_KING_MIRRORS + from ..shared.config.lane_d_ops import lane_d_ops_config + + try: + return lane_d_ops_config(cfg).king_mirrors + except ValueError as e: + raise JobError(str(e)) from None + + def king_check(args) -> dict: from ..validator.lane_d_report import verify_report from .publish import check_one_digest, verify_index @@ -401,6 +423,7 @@ def king_check(args) -> dict: if index is not None and not verify_index(index, args.signer_ss58): raise JobError(f"{args.index} does not verify under {args.signer_ss58}") mirrors = _mirrors(args.mirror) + names = _king_mirrors(args) vault = FilesystemStorage(args.vault_dir) if args.vault_dir else None full = vault is not None and bool(mirrors) problems: dict[str, list[str]] = {} @@ -419,7 +442,8 @@ def king_check(args) -> dict: problems[f"{b}"] = ["index_missing"] continue if full: - found = check_one_digest(index=index, report=report, vault=vault, mirrors=mirrors) + found = check_one_digest(index=index, report=report, vault=vault, mirrors=mirrors, + king_mirrors=names) else: # index-only check (no local copies) entry = next((k for k in index.get("kings") or () if isinstance(k, dict) and k.get("digest") == report["crowned"]), None) @@ -551,13 +575,15 @@ def _fs_or_live(args, cfg_needed: bool): return cfg, vault -def _mirrors_for(args, cfg, king: dict, tmp_dir: Path | None = None) -> dict: +def _mirrors_for(args, cfg, king: dict, names: tuple[str, ...], + tmp_dir: Path | None = None) -> dict: + """The clients of the king mirrors ``names`` only.""" if args.mirror: - return _mirrors(args.mirror) + return {k: v for k, v in _mirrors(args.mirror).items() if k in names} from .mirrors import open_live_mirrors return open_live_mirrors(cfg, context=int(king["context"]), hotkey=str(king["hotkey"]), - digest=str(king["digest"]), tmp_dir=tmp_dir) + digest=str(king["digest"]), tmp_dir=tmp_dir, names=names) class _TermAsExit: @@ -650,6 +676,7 @@ def king_publish(args) -> dict: from .mirrors import open_live_vault vault = open_live_vault(cfg) + names = _king_mirrors(args, cfg) signer = _signer(args) def alert(doc: dict) -> None: @@ -661,21 +688,21 @@ def alert(doc: dict) -> None: try: with _TermAsExit(): res = publish_king(hotkey=king["hotkey"], digest=king["digest"], vault=vault, - mirrors=_mirrors_for(args, cfg, king, tmp_dir=spool), - alert=alert, spool_dir=spool) + mirrors=_mirrors_for(args, cfg, king, names, tmp_dir=spool), + alert=alert, spool_dir=spool, king_mirrors=names) except PublishError as e: raise JobError(f"king {king['digest'][:16]}: {e}") from None published.append(res) kings = [*(index or {}).get("kings", ()), *planned] new_index = build_index(kings, signer) _write_index(args, new_index, cfg) - log.warning("lane_d_ops_king_published %d king(s) on the mirrors; index re-signed with %d " - "king(s)", len(planned), len(new_index["kings"])) + log.warning("lane_d_ops_king_published %d king(s) on the mirrors %s; index re-signed with " + "%d king(s)", len(planned), list(names), len(new_index["kings"])) return {**out, "action": "published", "mirrors": published} def takedown_job(args) -> dict: - from .publish import PublishError, takedown + from .publish import PublishError, takedown, takedown_mirror_names index = _local_index(args.index, args.signer_ss58) if index is None: @@ -689,21 +716,22 @@ def takedown_job(args) -> dict: log.info("lane_d_ops_takedown_planned %s is already taken down (%s)", args.digest[:16], king["takedown"]) return {**out, "action": "current"} + names = _king_mirrors(args) + gone = list(takedown_mirror_names(names)) if args.dry_run: - log.info("lane_d_ops_takedown_planned would unpublish %s from the Hub and HF (%s, block " - "%d)", args.digest[:16], args.reason, args.block) - return {**out, "action": "planned"} + log.info("lane_d_ops_takedown_planned would unpublish %s from %s (%s, block %d)", + args.digest[:16], gone, args.reason, args.block) + return {**out, "action": "planned", "mirrors": gone} cfg, _ = _fs_or_live(args, cfg_needed=not args.mirror or not args.index_store_dir) - mirrors = _mirrors_for(args, cfg, king) + mirrors = _mirrors_for(args, cfg, king, tuple(gone)) try: new_index = takedown(index, digest=args.digest, reason=args.reason, block=args.block, - mirrors={k: v for k, v in mirrors.items() if k in ("hub", "hf")}, - signer=_signer(args)) + mirrors=mirrors, signer=_signer(args), king_mirrors=names) except PublishError as e: raise JobError(str(e)) from None _write_index(args, new_index, cfg) - log.warning("lane_d_ops_takedown_done %s unpublished from the Hub and HF (%s); index " - "re-signed", args.digest[:16], args.reason) + log.warning("lane_d_ops_takedown_done %s unpublished from %s (%s); index re-signed", + args.digest[:16], gone, args.reason) return {**out, "action": "taken_down"} @@ -811,6 +839,9 @@ def common(sp): k.add_argument("--signer-ss58", required=True, help="the pinned report / index signer") k.add_argument("--vault-dir", type=Path, default=None, help="local vault copy (full check)") k.add_argument("--mirror", action="append", default=[], help="NAME=DIR local mirror copy") + k.add_argument("--chain-toml", type=Path, default=None, + help="the deployed chain.toml ([lane_d_ops] king_mirrors: the mirrors " + "checked; default the Hub only)") k.add_argument("--path-unit", type=Path, default=None, help="the installed cascade-laned-king-publish.path: fail unless it watches " "lane_d_publish_requests beside --state") @@ -834,7 +865,7 @@ def publication(sp, *, index_help: str): help="filesystem vault (testnet / tests); default the live vault") sp.add_argument("--mirror", action="append", default=[], help="NAME=DIR filesystem mirror (testnet / tests); default the live " - "Hub, R2 and HF mirrors") + "king mirrors ([lane_d_ops] king_mirrors, default the Hub only)") sp.add_argument("--index-store-dir", type=Path, default=None, help="filesystem public store for the index; default the manifest store") sp.add_argument("--wallet-name", default=None) @@ -853,7 +884,7 @@ def publication(sp, *, index_help: str): publication(kp, index_help="the local champions/lane_d/index.json copy king-check reads") kp.set_defaults(job_func=king_publish) - td = jobs.add_parser("takedown", help="B13: unpublish one king from the Hub and HF") + td = jobs.add_parser("takedown", help="B13: unpublish one king from its Hub / HF mirrors") td.add_argument("--digest", required=True) td.add_argument("--reason", required=True, choices=("licence", "rights")) td.add_argument("--block", type=int, required=True, help="the block of the claim") diff --git a/cascade/lane_d/publish.py b/cascade/lane_d/publish.py index cbed5c6fc..c140e367e 100644 --- a/cascade/lane_d/publish.py +++ b/cascade/lane_d/publish.py @@ -1,11 +1,18 @@ """Lane D king publication (LANE_D_PLAN §11.1, W13). -A crowned lane D king leaves the private vault for three public mirrors (the -Hippius Hub, the R2 public bucket and the HF dataset -:data:`HF_MIRROR_REPO`), is listed in the signed +A crowned lane D king leaves the private vault for its public mirrors, is +listed in the signed ``champions/lane_d/index.json`` and gets repo cards ``champions/lane_d//{PROVENANCE.json, MODEL_CARD.md}``. +Which mirrors (owner 2026-12-01): ``[lane_d_ops] king_mirrors``, a subset of +:data:`MIRRORS` (the Hippius Hub, the R2 public bucket and the HF dataset +:data:`HF_MIRROR_REPO`), default :data:`DEFAULT_KING_MIRRORS` = the Hub only. +Publication, the read-back, the one-digest check, the takedown and the cards +use that set and nothing else: with the Hub only, nothing touches R2 or HF and +no check asks for them. The signed index entry names no mirror (its schema is +unchanged by the set). + Immutability (rev6.4 §1.2): Hippius offers no write-once storage mode, so nothing here asks a mirror for one and nothing published claims one. A king's bytes are pinned by @@ -16,7 +23,7 @@ hash to the digest in the path and every file to its manifest sha256, so an overwrite in place, even a consistent rewrite of weights and manifest, reads as ``digest_mismatch``; -* the signed digest in the index, and the three independent mirrors. +* the signed digest in the index (and any further mirror configured). A mirror client is any object with ``put(key, data)``, ``get(key)`` (raises ``KeyError`` when absent), ``list(prefix)`` (sorted keys), ``size(key)`` and @@ -31,9 +38,9 @@ (:data:`cascade.lane_d.storage.STREAM_CHUNK_BYTES`). A client without them is given and asked for whole files as bytes (test fakes, small local copies). -Takedown (rev5, B13): a licence or rights claim removes the Hub and HF copies -(:func:`takedown`); the vault, the R2 copy, the digest and the verdict record -stay, and the re-signed index marks the king ``takedown``. +Takedown (rev5, B13): a licence or rights claim removes the configured Hub +and HF copies (:func:`takedown`); the vault, any R2 copy, the digest and the +verdict record stay, and the re-signed index marks the king ``takedown``. Torch-free: stdlib plus the lane D intake helpers and the sr25519 verifier. """ @@ -60,7 +67,10 @@ manifest_digest, ) +# Every mirror a king MAY be published to; ``[lane_d_ops] king_mirrors`` +# picks the ones it is (owner 2026-12-01: the Hippius Hub only by default). MIRRORS = ("hub", "r2", "hf") +DEFAULT_KING_MIRRORS = ("hub",) HF_MIRROR_REPO = "tensorlink-dev/cascade-lane-d-kings" # Mirror key layout: ``//``. KINGS_PREFIX = "lane-d-kings" @@ -75,6 +85,9 @@ # B13: the claims a takedown answers, and the mirrors it unpublishes. TAKEDOWN_REASONS = ("licence", "rights") TAKEDOWN_MIRRORS = ("hub", "hf") +_MIRROR_WORDS = {"hub": "the Hippius Hub", "r2": "the R2 public mirror", + "hf": f"the Hugging Face dataset `{HF_MIRROR_REPO}`"} +_MIRROR_SHORT = {"hub": "Hub", "r2": "R2", "hf": "HF"} OK, MISSING, DIGEST_MISMATCH = "ok", "missing", "digest_mismatch" @@ -111,6 +124,33 @@ def hub_repo(ns: str, context: int, hotkey: str) -> str: return f"{ns}/laned-king-c{int(context)}-{str(hotkey)[:8]}" +def king_mirror_names(names=None) -> tuple[str, ...]: + """The mirrors kings are published to, in :data:`MIRRORS` order: ``names`` + (``[lane_d_ops] king_mirrors``), or :data:`DEFAULT_KING_MIRRORS` when + ``None``. A non-empty list of unique names from :data:`MIRRORS`, else + ``ValueError``.""" + if names is None: + return DEFAULT_KING_MIRRORS + if isinstance(names, str) or not isinstance(names, list | tuple): + raise ValueError(f"king mirrors must be a list of names from {list(MIRRORS)}; " + f"got {names!r}") + got = list(names) + if not got or len(set(got)) != len(got) or any(n not in MIRRORS for n in got): + raise ValueError(f"king mirrors must be a non-empty list of unique names from " + f"{list(MIRRORS)}; got {got!r}") + return tuple(n for n in MIRRORS if n in got) + + +def takedown_mirror_names(names=None) -> tuple[str, ...]: + """The configured mirrors a takedown unpublishes (those of + :data:`TAKEDOWN_MIRRORS`; an R2 copy stays).""" + return tuple(n for n in king_mirror_names(names) if n in TAKEDOWN_MIRRORS) + + +def _spoken(parts: list[str]) -> str: + return parts[0] if len(parts) == 1 else ", ".join(parts[:-1]) + " and " + parts[-1] + + def mirror_prefix(digest: str) -> str: """The mirror prefix of one king (trailing ``/``).""" if not isinstance(digest, str) or not _DIGEST_RE.fullmatch(digest): @@ -284,12 +324,15 @@ def verify_mirrors(digest: str, mirrors: Mapping) -> dict[str, str]: def publish_king(*, hotkey: str, digest: str, vault, mirrors: Mapping, alert: Callable[[dict], object], - spool_dir: str | os.PathLike | None = None) -> dict: - """Copy the vault entry ``lane-d///`` to the Hub, R2 and - HF mirrors under ``lane-d-kings//`` and read every mirror back. + spool_dir: str | os.PathLike | None = None, + king_mirrors=None) -> dict: + """Copy the vault entry ``lane-d///`` to the king mirrors + (``king_mirrors``, :func:`king_mirror_names`: the Hub only by default) + under ``lane-d-kings//`` and read each of them back. A client in + ``mirrors`` outside that set is never called. The vault entry is re-hashed first (``vault_digest_mismatch``, alerted, - nothing written); all three mirrors are required (``mirror_missing``, + nothing written); every king mirror is required (``mirror_missing``, nothing written); a mirror that reads back other bytes is alerted and refused (``mirror_digest_mismatch``). A mirror that already holds the king intact is not rewritten. The vault is only read. @@ -299,12 +342,15 @@ def publish_king(*, hotkey: str, digest: str, vault, mirrors: Mapping, from there; that directory is removed before this returns or raises. A disk without room for it is refused first (``spool_disk_low``, nothing fetched, nothing written).""" - absent = [name for name in MIRRORS if name not in mirrors] + names = king_mirror_names(king_mirrors) + absent = [name for name in names if name not in mirrors] if absent: - raise PublishError("mirror_missing", f"publishing needs every mirror; missing {absent}") + raise PublishError("mirror_missing", + f"publishing needs every king mirror {list(names)}; missing {absent}") spool = Path(tempfile.mkdtemp(prefix=SPOOL_PREFIX, dir=spool_dir)) try: - return _publish_spooled(hotkey, digest, vault, mirrors, alert, spool) + return _publish_spooled(hotkey, digest, vault, {n: mirrors[n] for n in names}, alert, + spool) finally: shutil.rmtree(spool, ignore_errors=True) @@ -318,15 +364,14 @@ def _publish_spooled(hotkey: str, digest: str, vault, mirrors: Mapping, alert({"code": e.code, "digest": digest, "hotkey": hotkey, "detail": e.detail}) raise prefix = mirror_prefix(digest) - for name in MIRRORS: - client = mirrors[name] + for client in mirrors.values(): if _verify_one(digest, client) == OK: continue for fname in sorted(files): _put_spooled(client, prefix + fname, files[fname], int(manifest["files"][fname]["size"])) client.put(prefix + MANIFEST_OBJECT, raw_manifest) - verdicts = {name: _verify_one(digest, mirrors[name]) for name in MIRRORS} + verdicts = {name: _verify_one(digest, client) for name, client in mirrors.items()} bad = [name for name, v in verdicts.items() if v != OK] for name in bad: alert({"code": "mirror_digest_mismatch", "mirror": name, "digest": digest, @@ -465,10 +510,12 @@ def publish_index(index: Mapping, store, signer_ss58: str) -> str: # ── repo cards (laned-king-sync.yml) ───────────────────────────────────────── -def provenance(king: Mapping) -> dict: - """``PROVENANCE.json`` of one index entry.""" +def provenance(king: Mapping, king_mirrors=None) -> dict: + """``PROVENANCE.json`` of one index entry (``hf_repo`` only when the HF + dataset is a king mirror).""" out = {f: copy.deepcopy(king[f]) for f in KING_FIELDS} - out["hf_repo"] = HF_MIRROR_REPO + if "hf" in king_mirror_names(king_mirrors): + out["hf_repo"] = HF_MIRROR_REPO out["mirror_path"] = mirror_prefix(king["digest"]) if "takedown" in king: out["takedown"] = copy.deepcopy(king["takedown"]) @@ -478,8 +525,12 @@ def provenance(king: Mapping) -> dict: return out -def model_card(king: Mapping) -> str: - """``MODEL_CARD.md`` of one index entry.""" +def model_card(king: Mapping, king_mirrors=None) -> str: + """``MODEL_CARD.md`` of one index entry, naming the king mirrors only.""" + names = king_mirror_names(king_mirrors) + where = _spoken([_MIRROR_WORDS[n] for n in names]) + down = [_MIRROR_SHORT[n] for n in takedown_mirror_names(names)] + gone = f" from the {_spoken(down)} mirror{'s' if len(down) > 1 else ''}" if down else "" digest = king["digest"] sentinel = king["sentinel"] lines = [ @@ -496,8 +547,7 @@ def model_card(king: Mapping) -> str: "## Where the weights are", "", f"The checkpoint is not in git. Its files are published under `{mirror_prefix(digest)}`" - f" on the Hippius Hub, the R2 public mirror and the Hugging Face dataset " - f"`{HF_MIRROR_REPO}`.", + f" on {where}.", "", "## Checking a copy", "", @@ -512,7 +562,7 @@ def model_card(king: Mapping) -> str: lines += [ "## Takedown", "", - f"Unpublished from the Hub and HF mirrors at block {td['block']} after a " + f"Unpublished{gone} at block {td['block']} after a " f"{td['reason']} claim. The digest and the verdict record stay in the signed index.", "", ] @@ -529,12 +579,14 @@ def _write_if_changed(path: Path, data: bytes) -> bool: return True -def sync_cards(repo_root, index, signer_ss58: str) -> list[Path]: +def sync_cards(repo_root, index, signer_ss58: str, king_mirrors=None) -> list[Path]: """Write the signed index and every king's cards under ``/champions/lane_d/``; returns the paths written (files whose bytes changed). ``index is None`` (lane D unarmed, nothing published) writes nothing. An index that does not verify under ``signer_ss58`` is - refused (``index_signature_invalid``) before anything is written.""" + refused (``index_signature_invalid``) before anything is written. The + cards name the ``king_mirrors`` (:func:`king_mirror_names`).""" + names = king_mirror_names(king_mirrors) if index is None: return [] if not verify_index(index, signer_ss58): @@ -543,20 +595,23 @@ def sync_cards(repo_root, index, signer_ss58: str) -> list[Path]: planned: list[tuple[Path, bytes]] = [(root / "index.json", index_bytes(index))] for king in index["kings"]: d = root / king["digest"] - planned.append((d / PROVENANCE_FILE, index_bytes(provenance(king)))) - planned.append((d / MODEL_CARD_FILE, model_card(king).encode("utf-8"))) + planned.append((d / PROVENANCE_FILE, index_bytes(provenance(king, names)))) + planned.append((d / MODEL_CARD_FILE, model_card(king, names).encode("utf-8"))) return [path for path, data in planned if _write_if_changed(path, data)] # ── one digest, one identity ───────────────────────────────────────────────── -def check_one_digest(*, index, report, vault, mirrors: Mapping) -> list[str]: - """§11.1: the report's crowned digest, the index, the vault and the - mirrors must agree. Read-only (vault and mirror ``get``/``list`` only, +def check_one_digest(*, index, report, vault, mirrors: Mapping, + king_mirrors=None) -> list[str]: + """§11.1: the report's crowned digest, the index, the vault and the king + mirrors (``king_mirrors``, :func:`king_mirror_names`; a client in + ``mirrors`` outside the set is not read) must agree. Read-only (vault and mirror ``get``/``list`` only, ``get_to`` where offered: files are hashed as they stream, none is kept). Returns problem codes; ``[]`` means everything agrees. The report's signature is the caller's check (``verify_report``).""" + names = king_mirror_names(king_mirrors) crowned = report.get("crowned") if isinstance(report, Mapping) else None if crowned is None: return ["report_no_crown"] @@ -569,7 +624,7 @@ def check_one_digest(*, index, report, vault, mirrors: Mapping) -> list[str]: elif entry.get("crown_block") != report.get("boundary"): problems.append("crown_block_mismatch") if not isinstance(crowned, str) or not _DIGEST_RE.fullmatch(crowned): - return [*problems, "vault_digest_mismatch", *(f"{m}_{MISSING}" for m in MIRRORS)] + return [*problems, "vault_digest_mismatch", *(f"{m}_{MISSING}" for m in names)] hotkey = entry.get("hotkey") if entry is not None else _vault_hotkey(vault, crowned) try: if not isinstance(hotkey, str): @@ -578,7 +633,7 @@ def check_one_digest(*, index, report, vault, mirrors: Mapping) -> list[str]: except PublishError: problems.append("vault_digest_mismatch") taken_down = entry is not None and isinstance(entry.get("takedown"), Mapping) - for name in MIRRORS: + for name in names: client = mirrors.get(name) verdict = _verify_one(crowned, client) if client is not None else MISSING if verdict == MISSING and taken_down and name in TAKEDOWN_MIRRORS: @@ -675,13 +730,21 @@ def king_entry(report: Mapping, *, licence: str, sentinel: Mapping) -> dict: # ── takedown (rev5, B13) ───────────────────────────────────────────────────── -def takedown(index, *, digest: str, reason: str, block: int, mirrors: Mapping, signer) -> dict: - """Unpublish a king from the Hub and HF mirrors after a licence or rights - claim and return the re-signed index whose entry gains - ``"takedown": {"reason", "block"}``. The vault, the R2 copy and every - §11.1 field stay. The input index is verified under ``signer`` first and +def takedown(index, *, digest: str, reason: str, block: int, mirrors: Mapping, signer, + king_mirrors=None) -> dict: + """Unpublish a king from the configured Hub and HF mirrors + (:func:`takedown_mirror_names` of ``king_mirrors``: the Hub only by + default) after a licence or rights claim and return the re-signed index + whose entry gains ``"takedown": {"reason", "block"}``. The vault, any R2 + copy and every §11.1 field stay; a client in ``mirrors`` outside the set + is never called. The input index is verified under ``signer`` first and never mutated; an unknown digest is refused (``unknown_king``) before any mirror changes.""" + names = takedown_mirror_names(king_mirrors) + if not names: + raise PublishError("takedown_incomplete", + f"no takedown mirror among the king mirrors " + f"{list(king_mirror_names(king_mirrors))}") if not reason: raise ValueError("takedown needs a reason ('licence' or 'rights')") if reason not in TAKEDOWN_REASONS: @@ -697,26 +760,27 @@ def takedown(index, *, digest: str, reason: str, block: int, mirrors: Mapping, s entry = next((k for k in kings if k["digest"] == digest), None) if entry is None: raise PublishError("unknown_king", f"{digest!r} is not in the index") - absent = [name for name in TAKEDOWN_MIRRORS if name not in mirrors] + absent = [name for name in names if name not in mirrors] if absent: raise PublishError("mirror_missing", f"takedown needs the {absent} mirror(s)") prefix = mirror_prefix(digest) - for name in TAKEDOWN_MIRRORS: + for name in names: client = mirrors[name] for k in client.list(prefix): client.delete(k) - left = {name: mirrors[name].list(prefix) for name in TAKEDOWN_MIRRORS} + left = {name: mirrors[name].list(prefix) for name in names} if any(left.values()): raise PublishError("takedown_incomplete", f"objects remain under {prefix}: {left}") entry["takedown"] = {"reason": reason, "block": block} return build_index(kings, signer) -__all__ = ["HF_MIRROR_REPO", "INDEX_KEY", "INDEX_SCHEMA", "KINGS_PREFIX", "KING_FIELDS", +__all__ = ["DEFAULT_KING_MIRRORS", "HF_MIRROR_REPO", "INDEX_KEY", "INDEX_SCHEMA", "KINGS_PREFIX", "KING_FIELDS", "MIRRORS", "PUBLISH_CODES", "PUBLISH_REQUESTS_DIR", "PUBLISH_REQUEST_SCHEMA", "PublishError", "SENTINEL_NOT_ARMED", "SPOOL_MARGIN_BYTES", "SPOOL_PREFIX", "TAKEDOWN_MIRRORS", "TAKEDOWN_REASONS", "build_index", "check_one_digest", - "hub_repo", "index_body", "index_bytes", "king_entry", "mirror_prefix", + "hub_repo", "index_body", "index_bytes", "king_entry", "king_mirror_names", + "mirror_prefix", "model_card", "provenance", "publish_index", "publish_king", "publish_request", "publish_request_path", "sentinel_entry", "spool_bytes_needed", "sync_cards", - "takedown", "verify_index", "verify_mirrors"] + "takedown", "takedown_mirror_names", "verify_index", "verify_mirrors"] diff --git a/cascade/shared/config/lane_d_ops.py b/cascade/shared/config/lane_d_ops.py index 83e9d0735..b19455e8d 100644 --- a/cascade/shared/config/lane_d_ops.py +++ b/cascade/shared/config/lane_d_ops.py @@ -31,9 +31,13 @@ DEFAULT_QUEUE_MAX_INFLIGHT = 1 # one launch eval host (24 GB class) DEFAULT_QUEUE_MAX_PENDING = 64 # advisory; consensus caps stay in [lane_d] DEFAULT_QUEUE_POLL_SECONDS = 60 +# Owner 2026-12-01: lane D king weights go to the Hippius Hub only. The names +# a king MAY go to are cascade.lane_d.publish.MIRRORS (kept equal by test). +KING_MIRROR_NAMES = ("hub", "r2", "hf") +DEFAULT_KING_MIRRORS = ("hub",) KEYS = ("vault_bucket", "vault_prefix", "pool_d_bucket", "pool_d_prefix", "eval_host", - "queue_max_inflight", "queue_max_pending", "queue_poll_seconds") + "queue_max_inflight", "queue_max_pending", "queue_poll_seconds", "king_mirrors") # [storage] buckets other services share or publish from; the private lane D # buckets are never one of them (§1.2 / §13: private code once leaked through @@ -57,7 +61,10 @@ class LaneDOpsConfig: that runs lane D forecasts (``""`` = none configured). ``queue_max_inflight``: forecast jobs in flight on the eval host. ``queue_max_pending``: the intake's backpressure cap on pending entries (advisory). ``queue_poll_seconds``: the - ready-queue poll interval.""" + ready-queue poll interval. ``king_mirrors``: the public mirrors a crowned + king's weights are published to (and read back, checked and taken down + from), a non-empty subset of ``hub`` / ``r2`` / ``hf`` held in that order; + default the Hippius Hub only (owner 2026-12-01).""" vault_bucket: str = DEFAULT_VAULT_BUCKET vault_prefix: str = DEFAULT_VAULT_PREFIX @@ -67,6 +74,7 @@ class LaneDOpsConfig: queue_max_inflight: int = DEFAULT_QUEUE_MAX_INFLIGHT queue_max_pending: int = DEFAULT_QUEUE_MAX_PENDING queue_poll_seconds: int = DEFAULT_QUEUE_POLL_SECONDS + king_mirrors: tuple[str, ...] = DEFAULT_KING_MIRRORS def _is_secret_name(key: object) -> bool: @@ -103,6 +111,14 @@ def _positive_int(key: str, v: object) -> int: return v +def _king_mirrors(v: object) -> tuple[str, ...]: + if (not isinstance(v, list | tuple) or not v or not all(isinstance(n, str) for n in v) + or len(set(v)) != len(v) or any(n not in KING_MIRROR_NAMES for n in v)): + raise ValueError(f"[{TABLE}] king_mirrors must be a non-empty list of unique names " + f"from {list(KING_MIRROR_NAMES)}; got {v!r}") + return tuple(n for n in KING_MIRROR_NAMES if n in v) + + def parse_lane_d_ops(table: dict | None, storage: dict | None = None) -> LaneDOpsConfig: """Parse a ``[lane_d_ops]`` table (None/absent = the defaults), checking its buckets against the ``[storage]`` table's shared buckets.""" @@ -132,6 +148,7 @@ def parse_lane_d_ops(table: dict | None, storage: dict | None = None) -> LaneDOp "queue_max_pending", table.get("queue_max_pending", DEFAULT_QUEUE_MAX_PENDING)), queue_poll_seconds=_positive_int( "queue_poll_seconds", table.get("queue_poll_seconds", DEFAULT_QUEUE_POLL_SECONDS)), + king_mirrors=_king_mirrors(table.get("king_mirrors", list(DEFAULT_KING_MIRRORS))), ) if out.pool_d_bucket == out.vault_bucket: raise ValueError(f"[{TABLE}] pool_d_bucket must differ from vault_bucket " diff --git a/deploy/laned/systemd/cascade-laned-king-check.service b/deploy/laned/systemd/cascade-laned-king-check.service index 1abc2fbc5..c5ca7bcf0 100644 --- a/deploy/laned/systemd/cascade-laned-king-check.service +++ b/deploy/laned/systemd/cascade-laned-king-check.service @@ -1,8 +1,9 @@ # TEMPLATE (not installed by any script): §11.1 "one digest, one identity". # Every crowned persisted lane D report must be in the signed # champions/lane_d/index.json with its crown block; with a local vault copy -# and mirror copies (--vault-dir, --mirror hub=DIR r2=DIR hf=DIR in a drop-in) -# the full check_one_digest also re-hashes the vault and the mirrors. +# and mirror copies (--vault-dir, --mirror NAME=DIR per king mirror and +# --chain-toml for [lane_d_ops] king_mirrors, default hub only, in a drop-in) +# the full check_one_digest also re-hashes the vault and those mirrors. # Read-only: it writes nothing. Exit 1 with lane_d_ops_king_unpublished # (critical) when a crowned king is missing or disagrees: the # cascade-laned-king-publish job publishes it (started by the validator's diff --git a/deploy/laned/systemd/cascade-laned-king-publish.service b/deploy/laned/systemd/cascade-laned-king-publish.service index eb4a62f67..8810054a4 100644 --- a/deploy/laned/systemd/cascade-laned-king-publish.service +++ b/deploy/laned/systemd/cascade-laned-king-publish.service @@ -2,7 +2,8 @@ # publication. Every crowned persisted lane D report not yet in the signed # index (the validator's settlement step leaves # lane_d_publish_requests/.json beside lane_d_state.json) is copied -# from the vault to the Hub, R2 and HF mirrors with a read-back re-hash, the +# from the vault to the king mirrors ([lane_d_ops] king_mirrors of +# LANED_CHAIN_TOML; default the Hippius Hub only) with a read-back re-hash, the # index is re-signed with the validator hotkey (by name from the wallet dir), # put on the public manifest store and written to LANED_INDEX for king-check. # publish_king holds no checkpoint in memory: the king is spooled to a diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index d9520438e..7cab5bf8f 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -316,8 +316,9 @@ satellites and the audit: replay the signed report (no pool, no weights, no torc `lane_d_state.json` (`cascade/validator/lane_d_state.py`) before the state that binds it. The receipt binds the prior and posterior state digests and the report digest. -- Crowned kings are published to the Hub, R2 and HF mirrors and listed in - the signed `champions/lane_d/index.json`. +- Crowned kings are published to the Hippius Hub (`[lane_d_ops] + king_mirrors`, default Hub only) and listed in the signed + `champions/lane_d/index.json`. ## The controlled-experiment invariant diff --git a/docs/LANE_D.md b/docs/LANE_D.md index 0082580f2..02c1736b6 100644 --- a/docs/LANE_D.md +++ b/docs/LANE_D.md @@ -201,11 +201,10 @@ the CLI shows the statement and sends nothing. Distillation is allowed, from Ephemeris or anything else, on your own account, as long as the teacher's licence permits it. -Kings are published to the Hippius Hub, the R2 public bucket and the HF -dataset `tensorlink-dev/cascade-lane-d-kings`. A licence or rights claim -triggers a takedown: the Hub and HF copies are removed, while the vault, the -R2 copy, the digest and the verdict record stay, and the re-signed lane D -index marks the king `takedown`. +Kings are published to the Hippius Hub only (owner 2026-12-01; the mirrors +are `[lane_d_ops] king_mirrors`). A licence or rights claim triggers a +takedown: the Hub copy is removed, while the vault, the digest and the verdict +record stay, and the re-signed lane D index marks the king `takedown`. ## How entries are judged diff --git a/docs/MINER_LANE_D.md b/docs/MINER_LANE_D.md index 5c67a8d10..6823ebf5a 100644 --- a/docs/MINER_LANE_D.md +++ b/docs/MINER_LANE_D.md @@ -77,8 +77,8 @@ pool, and the bench gate, caps and queue run only live. **Where `--king` and `--pool-dir` come from.** No `cascade` command downloads either yet. Before the first lane D crown the bar is the house, a BF16 cast of the frozen lane A king (uid 164) that the operator builds and does not publish. -After a crown, each king's checkpoint is published (HF dataset -`tensorlink-dev/cascade-lane-d-kings`, indexed in the signed +After a crown, each king's checkpoint is published (Hippius Hub repo +`cascade/laned-king-c-`, indexed in the signed `champions/lane_d/index.json`). Spent `pool_d` snapshots are public (see [Past evaluations](#past-evaluations)): every window of a snapshot no entry can still be judged on, with the house's forecasts and scores. Preview on @@ -284,8 +284,7 @@ These are shares of the validators' weight vector, not TAO or dollars. - **Train on multivariate data.** Panels are scored as panels. Related channels (covariates, sensor groups, sales hierarchies) are where a model can beat a univariate king. -- **Fine-tune the king.** Kings are public under MIT (Hub, R2, HF mirror - `tensorlink-dev/cascade-lane-d-kings`). `python -P -m +- **Fine-tune the king.** Kings are public under MIT on the Hippius Hub. `python -P -m cascade.miner.lane_d_finetune` (`--base`, `--data`, `--out`, `--steps`, `--lr`, `--context-length`, `--dry-run`) is a starting point. - **Distil only from teachers you may republish.** Restricted-licence @@ -413,5 +412,5 @@ used. **Does winning lane A help in lane D?** The lane A king is the house. It is the bar for the first crown only, and never a paid seat. -**Where are kings published?** Hippius Hub, the R2 public mirror and the HF -mirror, indexed in the signed `champions/lane_d/index.json`. +**Where are kings published?** The Hippius Hub only, indexed in the signed +`champions/lane_d/index.json`. diff --git a/docs/OPERATOR.md b/docs/OPERATOR.md index 18d5f8fe4..9fc2a5abe 100644 --- a/docs/OPERATOR.md +++ b/docs/OPERATOR.md @@ -4065,7 +4065,8 @@ rules, so retention is our job. `python -P -m cascade.laned.vault_sweeper` moves losers out of the vault `[lane_d] loser_ttl_eras` after judgement into an owner-only archive, then deletes archive copies after the 14-day dispute window. `--dry-run` writes nothing; a live run needs the owner's standing -approval (D16). Kings are published to the Hub, R2 and HF mirrors and kept. +approval (D16). Kings are published to the Hippius Hub only (`[lane_d_ops] king_mirrors`, default +`["hub"]`; `r2` / `hf` are opt-in) and kept. **Runbook, per settlement.** Refresh the house if lane A's king digest changed. Check that the newest `pool_d` snapshot is pinned (stale over about @@ -4404,7 +4405,7 @@ is blocked on an owner step. | `cascade-laned-evidence` | 3 h | `ops_jobs evidence` | `LANED_CHAIN_TOML`, `LANED_EVIDENCE_STAGE`, `LANED_PINNED_READINESS` / `LANED_PINNED_T7` (the inputs TOML `readiness` / `t7`) | **T7 is an owner step.** On the eval host pod run `python -P -m cascade.eval.lane_d_t7_pod --checkpoint-dir --histories (or --synthetic-seed N) --host --gpu --mem-gb --out t7.json` (CUDA, `source = "pod"`; every variant at 1000 and 5000 windows, the 5000 row gates, both under `window_sweep`), stage `t7.json`, then add `--t7`. A non-pod T7, an unparseable document, or one that disarms an armed context is refused (`--allow-disarm` overrides the last). | | `cascade-laned-vault-sweep` | daily 04:30 UTC | `ops_jobs vault-ledger`, then `python -P -m cascade.laned.vault_sweeper --dry-run` | `LANED_STATE`, `LANED_LEDGER`, `LANED_VAULT_DIR` / `LANED_ARCHIVE_DIR` (fs mode, testnet), `LANED_SWEEP_LOG_DIR` | A `--live` sweep needs the standing approval **D16** and a drop-in. S3 mode (`--s3 --archive-bucket`) takes its credentials from the owner's own mode-600 env file, never this one. | | `cascade-laned-king-check` | hourly | `ops_jobs king-check` | `LANED_STATE` (its persisted reports), `LANED_INDEX`, `LANED_SIGNER_SS58`, `LANED_PUBLISH_PATH_UNIT` (`--path-unit`: the installed `cascade-laned-king-publish.path`); optional `--vault-dir` and `--mirror hub=… r2=… hf=…` local copies for the full re-hash (files are hashed as they stream) | A red check after `cascade-laned-king-publish` ran is an owner look. `path_unit_mismatch` / `path_unit_unreadable` under `problems.path_unit`: the installed path unit does not watch the validator's request folder (below); fix its `PathChanged=`. | -| `cascade-laned-king-publish` (+ `.path`) | on each publish request, hourly backstop; **runs on the validator host, the 7 GB box included** (bounded memory, `MemoryMax=1G`) | `ops_jobs king-publish` | `LANED_STATE` (its reports and `lane_d_publish_requests/`), `LANED_INTAKE_STATE` (ready licences), `LANED_INDEX`, `LANED_SIGNER_SS58`, `LANED_CHAIN_TOML` (`[storage]` names), `LANED_WALLET_NAME` / `LANED_WALLET_HOTKEY`; env credentials by name only: `HIPPIUS_S3_*`, `HIPPIUS_HUB_TOKEN`, `HF_TOKEN`, `BACKUP_S3_*` | The validator's settlement step writes `lane_d_publish_requests/.json` for each crowning (with the era's sentinel record). The job copies the king vault → Hub `{hub_namespace}/laned-king-c{context}-{hotkey8}`, R2 (`[storage] backup_bucket`, else `manifest_bucket`, under `lane-d-kings/`) and HF `tensorlink-dev/cascade-lane-d-kings`, re-signs the index, puts it on the manifest store and writes `LANED_INDEX`. Exit 3 without a ready licence record or a missing armed sentinel record. Live drop-in. Memory, spool and trigger folder: below. **Takedown** (B13) is a one-shot: `ops_jobs takedown --digest D --reason licence\|rights --block B --index … --signer-ss58 … --chain-toml …` (`--dry-run` first). | +| `cascade-laned-king-publish` (+ `.path`) | on each publish request, hourly backstop; **runs on the validator host, the 7 GB box included** (bounded memory, `MemoryMax=1G`) | `ops_jobs king-publish` | `LANED_STATE` (its reports and `lane_d_publish_requests/`), `LANED_INTAKE_STATE` (ready licences), `LANED_INDEX`, `LANED_SIGNER_SS58`, `LANED_CHAIN_TOML` (`[storage]` names), `LANED_WALLET_NAME` / `LANED_WALLET_HOTKEY`; env credentials by name only: `HIPPIUS_S3_*`, `HIPPIUS_HUB_TOKEN`, `HF_TOKEN`, `BACKUP_S3_*` | The validator's settlement step writes `lane_d_publish_requests/.json` for each crowning (with the era's sentinel record). The job copies the king vault → the king mirrors of `[lane_d_ops] king_mirrors` (default the Hub only: `{hub_namespace}/laned-king-c{context}-{hotkey8}`; opt-in R2 `[storage] backup_bucket`, else `manifest_bucket`, under `lane-d-kings/`, and HF `tensorlink-dev/cascade-lane-d-kings`), re-signs the index, puts it on the manifest store and writes `LANED_INDEX`. Exit 3 without a ready licence record or a missing armed sentinel record. Live drop-in. Memory, spool and trigger folder: below. **Takedown** (B13) is a one-shot: `ops_jobs takedown --digest D --reason licence\|rights --block B --index … --signer-ss58 … --chain-toml …` (`--dry-run` first). | **`king-publish` on the box.** The job signs the index with the validator hotkey, so it runs on the validator host. It holds no checkpoint in memory: diff --git a/scripts/laned_king_sync.py b/scripts/laned_king_sync.py index 838aef9b2..979c7c396 100644 --- a/scripts/laned_king_sync.py +++ b/scripts/laned_king_sync.py @@ -8,7 +8,8 @@ hotkey (``[manifest] validator_hotkey``) and writes ``champions/lane_d/index.json`` plus ``champions/lane_d// {PROVENANCE.json, MODEL_CARD.md}`` through -:func:`cascade.lane_d.publish.sync_cards`. No weights land in git, and the +:func:`cascade.lane_d.publish.sync_cards`. The cards name the mirrors of +``[lane_d_ops] king_mirrors`` (default: the Hippius Hub only). No weights land in git, and the script holds no storage or HF credential: the index is public-read. Nothing published yet (HTTP 404: lane D unarmed or no king crowned) is a @@ -95,6 +96,9 @@ def main(argv: list[str] | None = None) -> int: return 2 try: url = index_url(cfg) + from cascade.shared.config.lane_d_ops import lane_d_ops_config + + mirrors = lane_d_ops_config(cfg).king_mirrors except ValueError as e: print(f"laned-king-sync: {e}", file=sys.stderr) return 2 @@ -107,7 +111,7 @@ def main(argv: list[str] | None = None) -> int: print(f"laned-king-sync: no lane D index published at {url}; nothing to sync") return 0 try: - written = sync_cards(args.repo_root, index, signer) + written = sync_cards(args.repo_root, index, signer, king_mirrors=mirrors) except PublishError as e: print(f"laned-king-sync: refused: {e}", file=sys.stderr) return 1 diff --git a/tests/accept/w13/PATHS b/tests/accept/w13/PATHS index 17b94598e..acb8a9486 100644 --- a/tests/accept/w13/PATHS +++ b/tests/accept/w13/PATHS @@ -18,3 +18,14 @@ cascade/lane_d/ops_jobs.py # Lane D ops gaps PR: the production mirror clients (Hub / HF / R2 over the # existing storage clients and key names) the king-publish / takedown jobs use. cascade/lane_d/mirrors.py +# Owner 2026-12-01 (king weights on the Hippius Hub only): the mirror set is +# [lane_d_ops] king_mirrors, parsed here; the publish / check unit templates, +# the streaming unit tests and the docs that name the mirrors ride along. +cascade/shared/config/lane_d_ops.py +deploy/laned/systemd/cascade-laned-king-publish.service +deploy/laned/systemd/cascade-laned-king-check.service +tests/unit/test_lane_d_king_publish_streaming.py +docs/LANE_D.md +docs/MINER_LANE_D.md +docs/OPERATOR.md +docs/ARCHITECTURE.md diff --git a/tests/accept/w13/helpers.py b/tests/accept/w13/helpers.py index 196520bc2..182355601 100644 --- a/tests/accept/w13/helpers.py +++ b/tests/accept/w13/helpers.py @@ -35,6 +35,9 @@ PUBLISH_SRC = REPO / "cascade" / "lane_d" / "publish.py" MIRRORS = ("hub", "r2", "hf") +# Owner 2026-12-01: kings go to the Hippius Hub only unless [lane_d_ops] +# king_mirrors names more. The three-mirror tests configure every mirror. +DEFAULT_KING_MIRRORS = ("hub",) INDEX_PATH = "champions/lane_d/index.json" INDEX_SCHEMA = "lane-d-index/1" HF_REPO = "tensorlink-dev/cascade-lane-d-kings" @@ -56,6 +59,35 @@ def publish(): return importlib.import_module(MODULE) +def every_mirror(fn) -> dict: + """The keyword that configures every mirror for ``fn`` + (``king_mirrors=MIRRORS``), or nothing for a release whose ``fn`` has no + such keyword (there every mirror was the only rule).""" + import inspect + + return {"king_mirrors": MIRRORS} if "king_mirrors" in inspect.signature(fn).parameters else {} + + +def chain_toml_with_king_mirrors(tmp: Path, names) -> Path: + """The shipped chain.toml with ``[lane_d_ops] king_mirrors = names``.""" + src = (REPO / "chain.toml").read_text(encoding="utf-8") + assert src.count("\n[lane_d_ops]\n") == 1 + line = "king_mirrors = [" + ", ".join(f'"{n}"' for n in names) + "]" + out = tmp / f"chain.king_mirrors.{'-'.join(names)}.toml" + out.write_text(src.replace("\n[lane_d_ops]\n", f"\n[lane_d_ops]\n{line}\n"), + encoding="utf-8") + return out + + +def every_mirror_argv(tmp: Path) -> list[str]: + """``--chain-toml`` configuring every mirror for an ops job, or nothing + for a release without ``[lane_d_ops] king_mirrors`` (every mirror was the + only rule there).""" + if not every_mirror(publish().check_one_digest): + return [] + return ["--chain-toml", str(chain_toml_with_king_mirrors(tmp, MIRRORS))] + + @pytest.fixture(autouse=True) def no_network(monkeypatch): """Any socket connect raises: publication is tested with fakes only. diff --git a/tests/accept/w13/test_w13_index.py b/tests/accept/w13/test_w13_index.py index ac26a27f4..27f861a8c 100644 --- a/tests/accept/w13/test_w13_index.py +++ b/tests/accept/w13/test_w13_index.py @@ -176,7 +176,8 @@ def test_sync_cards_armed_nonempty_lane_d_effect(tmp_path, kings, signer): def test_cards_carry_the_king_record(tmp_path, kings, signer): pub = h.publish() - pub.sync_cards(tmp_path, pub.build_index(kings, signer), signer.ss58_address) + pub.sync_cards(tmp_path, pub.build_index(kings, signer), signer.ss58_address, + **h.every_mirror(pub.sync_cards)) for king in kings: d = tmp_path / "champions" / "lane_d" / king["digest"] prov = json.loads((d / "PROVENANCE.json").read_text(encoding="utf-8")) diff --git a/tests/accept/w13/test_w13_king_check_job.py b/tests/accept/w13/test_w13_king_check_job.py index 235e6101d..e79783869 100644 --- a/tests/accept/w13/test_w13_king_check_job.py +++ b/tests/accept/w13/test_w13_king_check_job.py @@ -19,7 +19,7 @@ import pytest -from .helpers import fixture_key, king_record, vault_with_king +from .helpers import every_mirror, every_mirror_argv, fixture_key, king_record, vault_with_king B = 9_000_900 @@ -114,10 +114,11 @@ def test_full_check_rehashes_vault_and_mirrors(setup, capsys, tmp_path): hk = fixture_key("miner").ss58_address vault, digest, _files = vault_with_king(tmp_path, hk) mirrors = {n: FilesystemStorage(tmp_path / "m" / n) for n in MIRRORS} - publish_king(hotkey=hk, digest=digest, vault=vault, mirrors=mirrors, alert=lambda a: None) + publish_king(hotkey=hk, digest=digest, vault=vault, mirrors=mirrors, alert=lambda a: None, + **every_mirror(publish_king)) _report(setup, B, digest) index = _index(setup, [king_record(hk, digest, crown_block=B)]) - full = ["--vault-dir", str(tmp_path / "vault"), + full = ["--vault-dir", str(tmp_path / "vault"), *every_mirror_argv(tmp_path), *[f"--mirror={n}={tmp_path / 'm' / n}" for n in MIRRORS]] assert _run(_argv(setup, index, *full)) == 0 assert _last(capsys)["scope"] == "full" diff --git a/tests/accept/w13/test_w13_king_mirrors.py b/tests/accept/w13/test_w13_king_mirrors.py new file mode 100644 index 000000000..f069769c3 --- /dev/null +++ b/tests/accept/w13/test_w13_king_mirrors.py @@ -0,0 +1,172 @@ +"""W13: the king mirrors come from config (owner 2026-12-01). + +Lane D king weights are published to the Hippius Hub only unless +``[lane_d_ops] king_mirrors`` names more (a non-empty subset of hub / r2 / +hf). Every path uses that set: publication and its read-back, the +one-digest check, the takedown, the cards and the live clients. With the +default nothing touches R2 or HF and no check reports them missing. + +The R2 / HF mirrors here are :class:`Untouchable`: any call on them is an +assertion failure, so "no R2/HF call" is checked, not assumed. +""" + +from __future__ import annotations + +import json + +import pytest + +from . import helpers as h +from .helpers import no_network # noqa: F401 + +CROWN = 9_000_900 + + +class Untouchable: + """A mirror client nothing may call (hub-only publication).""" + + def __init__(self, name: str): + self.name = name + + def __getattr__(self, attr): + raise AssertionError(f"the {self.name} mirror was used ({attr}) under the Hub-only " + "default") + + +def _hub_only(): + hub = h.FakeMirror("hub") + return hub, {"hub": hub, "r2": Untouchable("r2"), "hf": Untouchable("hf")} + + +def _copy_to_hub(vault, hotkey: str, digest: str, hub) -> None: + """The king on the Hub as publication leaves it (vault bytes, mirror keys).""" + src = f"lane-d/{hotkey}/{digest}/" + for key in vault.list(src): + hub.objects[f"lane-d-kings/{digest}/{key[len(src):]}"] = bytes(vault.get(key)) + + +@pytest.fixture(scope="module") +def signer(): + return h.fixture_key("signer") + + +# ── config: [lane_d_ops] king_mirrors ─────────────────────────────────────── + + +def test_default_king_mirrors_are_the_hub_only(): + from cascade.shared.config import lane_d_ops + + pub = h.publish() + ops = lane_d_ops.parse_lane_d_ops(None) + assert getattr(ops, "king_mirrors", None) == ("hub",), ops + assert getattr(pub, "DEFAULT_KING_MIRRORS", None) == h.DEFAULT_KING_MIRRORS + assert getattr(lane_d_ops, "KING_MIRROR_NAMES", None) == tuple(pub.MIRRORS) == h.MIRRORS + + +def test_king_mirrors_round_trip_through_load_chain_config(tmp_path): + from cascade.shared.config import load_chain_config + from cascade.shared.config.lane_d_ops import lane_d_ops_config + + shipped = lane_d_ops_config(load_chain_config(h.REPO / "chain.toml")) + assert getattr(shipped, "king_mirrors", None) == ("hub",), "the shipped file: Hub only" + for names, want in ((["hf", "hub"], ("hub", "hf")), (["r2"], ("r2",)), + (["hub", "r2", "hf"], h.MIRRORS)): + path = h.chain_toml_with_king_mirrors(tmp_path, names) + try: + got = getattr(lane_d_ops_config(load_chain_config(path)), "king_mirrors", None) + except ValueError as e: + got = e + assert got == want, (names, got) + + +def test_bad_king_mirrors_are_refused(): + from cascade.shared.config.lane_d_ops import parse_lane_d_ops + + assert getattr(parse_lane_d_ops({}), "king_mirrors", None) == ("hub",) + for bad in ([], ["hub", "hub"], ["s3"], "hub", [1], None): + with pytest.raises(ValueError): + parse_lane_d_ops({"king_mirrors": bad}) + + +# ── publication, read-back and the one-digest check ───────────────────────── + + +def test_hub_only_publish_makes_no_r2_or_hf_call(tmp_path): + pub = h.publish() + hotkey = h.fixture_key("king").ss58_address + vault, digest, files = h.vault_with_king(tmp_path, hotkey) + hub, mirrors = _hub_only() + out = pub.publish_king(hotkey=hotkey, digest=digest, vault=vault, mirrors=mirrors, + alert=[].append) + assert out["mirrors"] == {"hub": "ok"} + assert sorted(k.rsplit("/", 1)[-1] for k in hub.keys_with(digest)) == sorted( + [*files, "manifest.json"]) + # a mapping with the Hub alone is enough + hub2 = h.FakeMirror("hub") + out2 = pub.publish_king(hotkey=hotkey, digest=digest, vault=vault, mirrors={"hub": hub2}, + alert=[].append) + assert out2["mirrors"] == {"hub": "ok"} + + +def test_hub_only_check_one_digest_passes_without_r2_or_hf(tmp_path, signer): + pub = h.publish() + hotkey = h.fixture_key("king").ss58_address + vault, digest, _ = h.vault_with_king(tmp_path, hotkey) + hub, mirrors = _hub_only() + _copy_to_hub(vault, hotkey, digest, hub) + index = pub.build_index([h.king_record(hotkey, digest, crown_block=CROWN)], signer) + report = {"crowned": digest, "boundary": CROWN} + assert pub.check_one_digest(index=index, report=report, vault=vault, + mirrors={"hub": hub}) == [] + assert pub.check_one_digest(index=index, report=report, vault=vault, mirrors=mirrors) == [] + # the Hub is still checked: a broken Hub copy is named + key = hub.key_ending(digest, "weights.safetensors") + hub.objects[key] = b"overwritten in place" + assert pub.check_one_digest(index=index, report=report, vault=vault, + mirrors={"hub": hub}) == ["hub_digest_mismatch"] + + +def test_hub_only_takedown_touches_the_hub_alone(tmp_path, signer): + pub = h.publish() + hotkey = h.fixture_key("king").ss58_address + vault, digest, _ = h.vault_with_king(tmp_path, hotkey) + hub, mirrors = _hub_only() + _copy_to_hub(vault, hotkey, digest, hub) + index = pub.build_index([h.king_record(hotkey, digest, crown_block=CROWN)], signer) + out = pub.takedown(index, digest=digest, reason="licence", block=CROWN + 1, + mirrors=mirrors, signer=signer) + assert hub.keys_with(digest) == [] + assert out["kings"][0]["takedown"] == {"reason": "licence", "block": CROWN + 1} + report = {"crowned": digest, "boundary": CROWN} + assert pub.check_one_digest(index=out, report=report, vault=vault, + mirrors={"hub": hub}) == [] + + +def test_hub_only_cards_name_the_hub_alone(tmp_path, signer): + pub = h.publish() + king = h.king_record(h.fixture_key("king").ss58_address, h.sha256(b"w13 card")) + pub.sync_cards(tmp_path, pub.build_index([king], signer), signer.ss58_address) + d = tmp_path / "champions" / "lane_d" / king["digest"] + prov = json.loads((d / "PROVENANCE.json").read_text(encoding="utf-8")) + card = (d / "MODEL_CARD.md").read_text(encoding="utf-8") + assert "hf_repo" not in prov, prov + assert "Hippius Hub" in card + for word in ("R2", "Hugging Face", h.HF_REPO): + assert word not in card, word + # the index entry schema is unchanged (no mirror field) + index = json.loads((tmp_path / "champions" / "lane_d" / "index.json").read_text()) + assert set(index["kings"][0]) == set(h.KING_FIELDS) + + +def test_live_clients_default_to_the_hub_alone(): + from types import SimpleNamespace + + from cascade.lane_d.mirrors import open_live_mirrors + + cfg = SimpleNamespace(storage=SimpleNamespace(hub_namespace="cascade", backup_bucket="", + manifest_bucket="cascade-manifests", + backup_s3_endpoint="https://r2.example")) + ms = open_live_mirrors(cfg, context=8192, hotkey="5" * 48, digest="a" * 64, environ={}, + hub_api=object(), hf_api=Untouchable("hf"), + r2_client=Untouchable("r2")) + assert sorted(ms) == ["hub"] diff --git a/tests/accept/w13/test_w13_mirrors.py b/tests/accept/w13/test_w13_mirrors.py index faf363e4a..3dc27061e 100644 --- a/tests/accept/w13/test_w13_mirrors.py +++ b/tests/accept/w13/test_w13_mirrors.py @@ -28,8 +28,9 @@ def king(tmp_path): def _publish(king, mirrors, alerts=None): hotkey, vault, digest, _ = king sink = alerts if alerts is not None else [] - return h.publish().publish_king(hotkey=hotkey, digest=digest, vault=vault, - mirrors=mirrors, alert=sink.append) + pk = h.publish().publish_king + return pk(hotkey=hotkey, digest=digest, vault=vault, mirrors=mirrors, alert=sink.append, + **h.every_mirror(pk)) def test_publish_writes_every_mirror_and_each_hashes_to_the_digest(king): diff --git a/tests/accept/w13/test_w13_one_digest.py b/tests/accept/w13/test_w13_one_digest.py index 0485f2e88..13419111d 100644 --- a/tests/accept/w13/test_w13_one_digest.py +++ b/tests/accept/w13/test_w13_one_digest.py @@ -32,7 +32,8 @@ def build_world(tmp_path, signer): hotkey = h.fixture_key("king").ss58_address vault, digest, _ = h.vault_with_king(tmp_path, hotkey) mirrors = h.mirrors() - pub.publish_king(hotkey=hotkey, digest=digest, vault=vault, mirrors=mirrors, alert=[].append) + pub.publish_king(hotkey=hotkey, digest=digest, vault=vault, mirrors=mirrors, alert=[].append, + **h.every_mirror(pub.publish_king)) index = pub.build_index([h.king_record(hotkey, digest, crown_block=CROWN)], signer) report = {"crowned": digest, "boundary": CROWN} return {"pub": pub, "hotkey": hotkey, "vault": vault, "digest": digest, @@ -41,6 +42,7 @@ def build_world(tmp_path, signer): def _check(w, **override): args = {k: w[k] for k in ("index", "report", "vault", "mirrors")} + args.update(h.every_mirror(w["pub"].check_one_digest)) args.update(override) return list(w["pub"].check_one_digest(**args)) @@ -115,7 +117,8 @@ def test_takedown_unpublishes_hub_and_hf_and_keeps_the_record(tmp_path, signer, w, pub = world, world["pub"] original = copy.deepcopy(w["index"]) out = pub.takedown(w["index"], digest=w["digest"], reason=reason, block=CROWN + 1800, - mirrors=w["mirrors"], signer=signer) + mirrors=w["mirrors"], signer=signer, + **h.every_mirror(w["pub"].takedown)) assert w["index"] == original, "takedown must not mutate its input" for name in ("hub", "hf"): assert w["mirrors"][name].keys_with(w["digest"]) == [], name @@ -132,7 +135,8 @@ def test_takedown_keeps_the_vault(tmp_path, signer): world = build_world(tmp_path, signer) before = h.tree(tmp_path / "vault") world["pub"].takedown(world["index"], digest=world["digest"], reason="rights", - block=CROWN + 1, mirrors=world["mirrors"], signer=signer) + block=CROWN + 1, mirrors=world["mirrors"], signer=signer, + **h.every_mirror(world["pub"].takedown)) assert h.tree(tmp_path / "vault") == before @@ -142,7 +146,8 @@ def test_a_taken_down_king_still_passes_the_one_digest_check(tmp_path, signer): which is not a disagreement for a king the index marks taken down.""" w = world out = w["pub"].takedown(w["index"], digest=w["digest"], reason="licence", block=CROWN + 1, - mirrors=w["mirrors"], signer=signer) + mirrors=w["mirrors"], signer=signer, + **h.every_mirror(w["pub"].takedown)) problems = _check(w, index=out) assert not [p for p in problems if p.startswith(("hub_", "hf_", "vault_", "index_", "report_"))] assert "crown_block_mismatch" not in problems @@ -154,7 +159,8 @@ def test_takedown_of_an_unknown_digest_is_refused(tmp_path, signer): before = {n: dict(m.objects) for n, m in world["mirrors"].items()} with pytest.raises(pub.PublishError) as e: pub.takedown(world["index"], digest=h.sha256(b"never crowned"), reason="rights", - block=CROWN + 1, mirrors=world["mirrors"], signer=signer) + block=CROWN + 1, mirrors=world["mirrors"], signer=signer, + **h.every_mirror(world["pub"].takedown)) assert e.value.code == "unknown_king" assert {n: dict(m.objects) for n, m in world["mirrors"].items()} == before @@ -164,16 +170,17 @@ def test_takedown_needs_a_reason(tmp_path, signer): pub = world["pub"] with pytest.raises(ValueError): pub.takedown(world["index"], digest=world["digest"], reason="", block=CROWN + 1, - mirrors=world["mirrors"], signer=signer) + mirrors=world["mirrors"], signer=signer, **h.every_mirror(pub.takedown)) def test_takedown_cards_keep_the_record(tmp_path, signer): world = build_world(tmp_path, signer) w, pub = world, world["pub"] out = pub.takedown(w["index"], digest=w["digest"], reason="licence", block=CROWN + 1, - mirrors=w["mirrors"], signer=signer) + mirrors=w["mirrors"], signer=signer, + **h.every_mirror(w["pub"].takedown)) repo = tmp_path / "repo" - pub.sync_cards(repo, out, signer.ss58_address) + pub.sync_cards(repo, out, signer.ss58_address, **h.every_mirror(pub.sync_cards)) prov = json.loads((repo / "champions" / "lane_d" / w["digest"] / "PROVENANCE.json") .read_text(encoding="utf-8")) assert prov["digest"] == w["digest"] diff --git a/tests/accept/w13/test_w13_publication_wiring.py b/tests/accept/w13/test_w13_publication_wiring.py index 471428406..f45981f9d 100644 --- a/tests/accept/w13/test_w13_publication_wiring.py +++ b/tests/accept/w13/test_w13_publication_wiring.py @@ -29,7 +29,14 @@ import pytest -from .helpers import MIRRORS, fixture_key, no_network, vault_with_king # noqa: F401 +from .helpers import ( # noqa: F401 + MIRRORS, + every_mirror, + every_mirror_argv, + fixture_key, + no_network, + vault_with_king, +) def jobs(): @@ -109,12 +116,12 @@ def _publish(t, *extra: str) -> int: "--signer-ss58", t["signer"].ss58_address, *_fs(t), *extra]) -def _check(t) -> int: +def _check(t, *extra: str) -> int: return _main(["king-check", "--state", str(t["state"]), "--index", str(t["tmp"] / "index.json"), "--signer-ss58", t["signer"].ss58_address, "--vault-dir", str(t["vault"]), *(a for m in MIRRORS - for a in ("--mirror", f"{m}={t['tmp'] / 'mirrors' / m}"))]) + for a in ("--mirror", f"{m}={t['tmp'] / 'mirrors' / m}")), *extra]) # ── the index entry of a real crowned report ───────────────────────────────── @@ -171,6 +178,29 @@ def test_king_check_is_red_before_and_green_after_king_publish(rig, capsys): assert public == index and [k["digest"] for k in index["kings"]] == [rig["digest"]] +def test_hub_only_jobs_publish_check_and_take_down_on_the_hub_alone(rig, capsys): + """Owner 2026-12-01: with the default king mirrors (the Hub only) the + jobs need, write and check the Hub copy alone; R2 and HF are never + named, written or reported missing.""" + hub = ["--mirror", f"hub={rig['tmp'] / 'mirrors' / 'hub'}"] + common = ["--index", str(rig["tmp"] / "index.json"), + "--signer-ss58", rig["signer"].ss58_address, "--vault-dir", str(rig["vault"])] + assert _main(["king-publish", "--state", str(rig["state"]), "--intake-state-dir", + str(rig["intake"]), *common, *hub, + "--index-store-dir", str(rig["tmp"] / "public")]) == 0 + assert _last(capsys)["mirrors"][0]["mirrors"] == {"hub": "ok"} + assert sorted(p.name for p in (rig["tmp"] / "mirrors").iterdir()) == ["hub"] + assert _main(["king-check", "--state", str(rig["state"]), *common, *hub]) == 0 + out = _last(capsys) + assert out["scope"] == "full" and out["problems"] == {} + assert _main(["takedown", "--digest", rig["digest"], "--reason", "rights", "--block", + str(rig["report"]["boundary"] + 1), *common, *hub, + "--index-store-dir", str(rig["tmp"] / "public")]) == 0 + assert not list((rig["tmp"] / "mirrors" / "hub").rglob("*.safetensors")) + assert _main(["king-check", "--state", str(rig["state"]), *common, *hub]) == 0 + assert sorted(p.name for p in (rig["tmp"] / "mirrors").iterdir()) == ["hub"] + + def test_king_publish_is_idempotent_and_dry_run_writes_nothing(rig, capsys): assert _publish(rig, "--dry-run") == 0 assert _last(capsys)["action"] == "planned" @@ -201,10 +231,11 @@ def test_king_publish_refuses_a_wallet_that_is_not_the_pinned_signer(rig, monkey def test_takedown_unpublishes_hub_and_hf_and_king_check_stays_green(rig, capsys): - assert _publish(rig) == 0 + three = every_mirror_argv(rig["tmp"]) + assert _publish(rig, *three) == 0 argv = ["takedown", "--digest", rig["digest"], "--reason", "licence", "--block", str(rig["report"]["boundary"] + 1), "--index", str(rig["tmp"] / "index.json"), - "--signer-ss58", rig["signer"].ss58_address, *_fs(rig)] + "--signer-ss58", rig["signer"].ss58_address, *_fs(rig), *three] assert _main([*argv, "--dry-run"]) == 0 capsys.readouterr() assert _main(argv) == 0 @@ -215,7 +246,7 @@ def test_takedown_unpublishes_hub_and_hf_and_king_check_stays_green(rig, capsys) assert not list((rig["tmp"] / "mirrors" / m).rglob("*.safetensors")) assert list((rig["tmp"] / "mirrors" / "r2").rglob("*.safetensors")), "R2 copy stays" capsys.readouterr() - assert _check(rig) == 0 + assert _check(rig, *three) == 0 # ── the live mirror adapters (fakes of the API / client objects) ───────────── @@ -318,10 +349,12 @@ def test_live_adapters_carry_publish_king_and_check_one_digest(tmp_path): cfg = SimpleNamespace(storage=SimpleNamespace(hub_namespace="cascade", backup_bucket="", manifest_bucket="cascade-manifests", backup_s3_endpoint="https://r2.example")) + names = {"names": MIRRORS} if every_mirror(publish_king) else {} ms = open_live_mirrors(cfg, context=8192, hotkey=hk, digest=digest, environ={}, - hub_api=hub, hf_api=hf, r2_client=r2) + hub_api=hub, hf_api=hf, r2_client=r2, **names) assert sorted(ms) == sorted(MIRRORS) - publish_king(hotkey=hk, digest=digest, vault=vault, mirrors=ms, alert=lambda d: None) + publish_king(hotkey=hk, digest=digest, vault=vault, mirrors=ms, alert=lambda d: None, + **every_mirror(publish_king)) assert sorted(hub.repos[(hub_repo("cascade", 8192, hk), "model")]) == sorted( [*files, "manifest.json"]) assert f"lane-d-kings/{digest}/weights.safetensors" in hf.repos[(HF_MIRROR_REPO, "dataset")] @@ -334,7 +367,8 @@ def test_live_adapters_carry_publish_king_and_check_one_digest(tmp_path): index = build_index([king_record(hk, digest, crown_block=7)], signer) report = {"crowned": digest, "boundary": 7} - assert check_one_digest(index=index, report=report, vault=vault, mirrors=ms) == [] + assert check_one_digest(index=index, report=report, vault=vault, mirrors=ms, + **every_mirror(check_one_digest)) == [] with pytest.raises(KeyError): ms["hf"].get(f"lane-d-kings/{'e' * 64}/manifest.json") for key in ms["hf"].list(f"lane-d-kings/{digest}/"): diff --git a/tests/unit/test_lane_d_king_publish_streaming.py b/tests/unit/test_lane_d_king_publish_streaming.py index c2befbe89..b2770fb1e 100644 --- a/tests/unit/test_lane_d_king_publish_streaming.py +++ b/tests/unit/test_lane_d_king_publish_streaming.py @@ -27,7 +27,7 @@ from cascade.lane_d import ops_jobs, publish, storage from cascade.lane_d.hippius_vault import S3VaultStorage from cascade.lane_d.storage import FilesystemStorage -from tests.accept.w13.helpers import MIRRORS, FakeMirror, vault_with_king +from tests.accept.w13.helpers import MIRRORS, FakeMirror, every_mirror, vault_with_king REPO = Path(__file__).resolve().parents[2] SYSTEMD = REPO / "deploy" / "laned" / "systemd" @@ -142,7 +142,8 @@ def king(tmp_path): def _publish(king, mirrors, alerts=None, vault=None): return publish.publish_king( hotkey=HOTKEY, digest=king["digest"], vault=vault or king["vault"], mirrors=mirrors, - alert=(alerts if alerts is not None else []).append, spool_dir=king["spool"]) + alert=(alerts if alerts is not None else []).append, spool_dir=king["spool"], + **every_mirror(publish.publish_king)) def _writes(mirrors) -> list[tuple[str, str]]: