Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cascade/lane_d/mirrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
:data:`~cascade.lane_d.storage.STREAM_CHUNK_BYTES`, never held in memory:

* **hub**: the public Hippius Hub repo ``{[storage] hub_namespace}/laned-king-
c{context}-{hotkey8}`` (:func:`cascade.lane_d.publish.hub_repo`; one repo per
king), through ``hippius_hub.HippiusApi``; the token is the existing
c{context}-{hotkey8}`` (``hotkey8`` lowercased: an OCI repo name is
lowercase; :func:`cascade.lane_d.publish.hub_repo`; one repo per king),
through ``hippius_hub.HippiusApi``; the token is the existing
``HIPPIUS_HUB_TOKEN`` / ``HIPPIUS_TOKEN`` (or the username/password pair),
resolved by :mod:`cascade.shared.hippius`. A file is ``<file>`` in the repo.
* **hf**: the HF dataset :data:`cascade.lane_d.publish.HF_MIRROR_REPO` through
Expand Down
20 changes: 18 additions & 2 deletions cascade/lane_d/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,25 @@ def __init__(self, code: str, detail: str = ""):
self.detail = detail


# An OCI distribution repository name: lowercase path components only. The
# Hippius registry (Harbor) answers 401 "un-recognized request" for ANY call on
# a name with an uppercase letter (live 2026-12-01: the first king publish
# failed on ``cascade/laned-king-c4096-5HpKLEju/manifests/main``), so a king's
# repo carries the lowercased hotkey prefix.
OCI_REPO_RE = re.compile(r"^[a-z0-9]+(?:(?:[._]|__|-+)[a-z0-9]+)*"
r"(?:/[a-z0-9]+(?:(?:[._]|__|-+)[a-z0-9]+)*)+$")


def hub_repo(ns: str, context: int, hotkey: str) -> str:
"""§11.1: the public Hub repository of a king."""
return f"{ns}/laned-king-c{int(context)}-{str(hotkey)[:8]}"
"""§11.1: the public Hub repository of a king,
``{ns}/laned-king-c{context}-{hotkey8}`` with ``hotkey8`` the LOWERCASED
first 8 characters of the ss58 hotkey (an OCI repository name is lowercase).
``ValueError`` when the result is still not a valid OCI repository name."""
repo = f"{ns}/laned-king-c{int(context)}-{str(hotkey)[:8].lower()}"
if not OCI_REPO_RE.match(repo):
raise ValueError(f"{repo!r} is not a valid OCI repository name (lowercase "
f"[a-z0-9] components separated by '.', '_', '__' or '-')")
return repo


def king_mirror_names(names=None) -> tuple[str, ...]:
Expand Down
2 changes: 1 addition & 1 deletion cascade/miner/lane_d_pull_king.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

A crowned lane D king is published to the Hippius Hub only (``[lane_d_ops]
king_mirrors``, default ``["hub"]``): one public model repo per king,
``{[storage] hub_namespace}/laned-king-c{context}-{hotkey8}``
``{[storage] hub_namespace}/laned-king-c{context}-{hotkey8}`` (``hotkey8`` lowercased)
(:func:`cascade.lane_d.publish.hub_repo`), holding the entry's four files
and its ``manifest.json``. The signed index ``champions/lane_d/index.json`` on
the public manifest store lists every king (context, digest, crown block,
Expand Down
2 changes: 1 addition & 1 deletion docs/LANE_D.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ licence permits it.

Kings are published to the Hippius Hub only (owner 2026-12-01; the mirrors
are `[lane_d_ops] king_mirrors`), one public repo per king,
`cascade/laned-king-c<context>-<hotkey8>`. `cascade lane-d pull-king [--digest D]
`cascade/laned-king-c<context>-<hotkey8>` (`hotkey8`: the first 8 characters of the hotkey, lowercased — OCI repo names are lowercase). `cascade lane-d pull-king [--digest D]
--out DIR` downloads the current king (or a prior one) anonymously, after it
has checked the signed index against `[manifest] validator_hotkey` and every
file against the signed digest. Pass `DIR` to `cascade lane-d test --king DIR
Expand Down
2 changes: 1 addition & 1 deletion docs/MINER_LANE_D.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ It reads the signed index `champions/lane_d/index.json` from the public
manifest store (<https://s3.hippius.com/cascade-manifests/champions/lane_d/index.json>,
`--index-url` to override) and checks its signature against the main
validator hotkey pinned in `chain.toml` (`[manifest] validator_hotkey`). It
then pulls the king's Hippius Hub repo `cascade/laned-king-c<context>-<hotkey8>`
then pulls the king's Hippius Hub repo `cascade/laned-king-c<context>-<hotkey8>` (`hotkey8`: the first 8 characters of the hotkey, lowercased — OCI repo names are lowercase)
anonymously and checks `manifest.json` against the signed digest and every
file against its sha256. Nothing is written unless every check passes.
`--out` then holds `config.json`, `weights.safetensors`, `model.py`,
Expand Down
2 changes: 1 addition & 1 deletion docs/OPERATOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -4405,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 <a lane D entry> --histories <pool_d windows .npz> (or --synthetic-seed N) --host <eval_host> --gpu <model> --mem-gb <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/<boundary>.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). |
| `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/<boundary>.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}` (hotkey8 lowercased); 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:
Expand Down
3 changes: 3 additions & 0 deletions tests/accept/w13/PATHS
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ docs/LANE_D.md
docs/MINER_LANE_D.md
docs/OPERATOR.md
docs/ARCHITECTURE.md
# Live 2026-12-01 (first king publish 401): hub_repo lowercases hotkey8 (the
# Hippius registry 401s any uppercase repository name); the regression test.
tests/unit/test_lane_d_hub_repo_lowercase.py
2 changes: 1 addition & 1 deletion tests/accept/w13/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Torch-free. It may use the existing lane D intake and storage modules
MIRRORS = ("hub", "r2", "hf")
HF_MIRROR_REPO = "tensorlink-dev/cascade-lane-d-kings"
class PublishError(ValueError): # .code: a string from the codes below
def hub_repo(ns, context, hotkey) -> str # f"{ns}/laned-king-c{context}-{hotkey[:8]}"
def hub_repo(ns, context, hotkey) -> str # f"{ns}/laned-king-c{context}-{hotkey[:8].lower()}"
def publish_king(*, hotkey, digest, vault, mirrors, alert) -> dict
def verify_mirrors(digest, mirrors) -> dict[str, str]
def build_index(kings, signer) -> dict
Expand Down
4 changes: 2 additions & 2 deletions tests/accept/w13/test_w13_mirrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def test_hub_repo_and_hf_mirror_names():
"""§11.1: ``{ns}/laned-king-c{context}-{hotkey8}`` and the HF dataset."""
pub = h.publish()
hotkey = h.fixture_key("king").ss58_address
assert pub.hub_repo("tensorlink", 8192, hotkey) == f"tensorlink/laned-king-c8192-{hotkey[:8]}"
assert pub.hub_repo("ns", 4096, hotkey) == f"ns/laned-king-c4096-{hotkey[:8]}"
assert pub.hub_repo("tensorlink", 8192, hotkey) == f"tensorlink/laned-king-c8192-{hotkey[:8].lower()}"
assert pub.hub_repo("ns", 4096, hotkey) == f"ns/laned-king-c4096-{hotkey[:8].lower()}"
assert pub.HF_MIRROR_REPO == h.HF_REPO
assert tuple(pub.MIRRORS) == h.MIRRORS
123 changes: 123 additions & 0 deletions tests/unit/test_lane_d_hub_repo_lowercase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
"""A lane D king's Hub repo is a valid (lowercase) OCI repository name.

Live 2026-12-01: the first king publish failed with ``401 Unauthorized`` on
``cascade/laned-king-c4096-5HpKLEju/manifests/main``. The Hippius registry
(Harbor) answers 401 "un-recognized request" for ANY call on a repository name
with an uppercase letter (an existing repo with its name case-changed answers
401 too; a missing lowercase repo answers 404), and ``hub_repo`` put the raw
mixed-case ss58 prefix into the name. The fake API below rejects such names the
same way. Torch-free.
"""

from __future__ import annotations

from pathlib import Path

import pytest

from cascade.lane_d import mirrors as mirrors_mod
from cascade.lane_d import publish
from tests.accept.w13.helpers import fixture_key, vault_with_king

HOTKEY = fixture_key("king").ss58_address


class _Resp:
def __init__(self, status_code: int):
self.status_code = status_code


class HTTPStatusError(Exception):
"""httpx-shaped: ``response.status_code``."""

def __init__(self, msg: str, status_code: int):
super().__init__(msg)
self.response = _Resp(status_code)


class RevisionNotFoundError(Exception):
pass


class HarborLikeApi:
"""``hippius_hub.HippiusApi``-shaped: every call on a repo name that is not
a lowercase OCI name answers 401, like registry.hippius.com; a missing repo
or file answers a not-found error."""

def __init__(self):
self.repos: dict[str, dict[str, bytes]] = {}
self.calls: list[tuple[str, str]] = []

def _gate(self, op: str, repo_id: str) -> None:
self.calls.append((op, repo_id))
if repo_id != repo_id.lower():
raise HTTPStatusError(
f"Client error '401 Unauthorized' for url "
f"'https://registry.hippius.com/v2/{repo_id}/manifests/main'", 401)

def create_repo(self, repo_id, *, repo_type, private, exist_ok):
self._gate("create_repo", repo_id)
assert private is False and exist_ok is True
self.repos.setdefault(repo_id, {})

def upload_file(self, *, path_or_fileobj, path_in_repo, repo_id, repo_type, commit_message):
self._gate("upload_file", repo_id)
data = (path_or_fileobj if isinstance(path_or_fileobj, bytes)
else Path(path_or_fileobj).read_bytes())
self.repos.setdefault(repo_id, {})[path_in_repo] = data

def hf_hub_download(self, *, repo_id, filename, repo_type, local_dir):
self._gate("hf_hub_download", repo_id)
files = self.repos.get(repo_id)
if files is None or filename not in files:
raise RevisionNotFoundError(f"{repo_id}:{filename}")
p = Path(local_dir) / filename
p.parent.mkdir(parents=True, exist_ok=True)
p.write_bytes(files[filename])
return str(p)


def test_the_fixture_hotkey_is_mixed_case():
assert HOTKEY.lower() != HOTKEY, "the regression needs an ss58 with uppercase letters"


def test_hub_repo_is_a_lowercase_oci_name():
repo = publish.hub_repo("cascade", 4096, HOTKEY)
assert repo == f"cascade/laned-king-c4096-{HOTKEY[:8].lower()}"
assert repo == repo.lower() and publish.OCI_REPO_RE.match(repo)
# the live king's name
assert (publish.hub_repo("cascade", 4096, "5HpKLEjuXXXXXXXX")
== "cascade/laned-king-c4096-5hpkleju")


def test_hub_repo_refuses_a_name_that_is_still_invalid():
with pytest.raises(ValueError, match="OCI repository name"):
publish.hub_repo("Cascade", 4096, HOTKEY)
with pytest.raises(ValueError, match="OCI repository name"):
publish.hub_repo("", 4096, HOTKEY)


def test_a_king_publishes_to_a_registry_that_401s_uppercase_names(tmp_path):
vault, digest, files = vault_with_king(tmp_path, HOTKEY)
api = HarborLikeApi()
hub = mirrors_mod.hub_mirror(api, namespace="cascade", context=4096, hotkey=HOTKEY,
digest=digest, tmp_dir=tmp_path)
spool = tmp_path / "spool"
spool.mkdir()
alerts: list[dict] = []
out = publish.publish_king(hotkey=HOTKEY, digest=digest, vault=vault,
mirrors={"hub": hub}, alert=alerts.append, spool_dir=spool)
assert out["mirrors"] == {"hub": "ok"} and alerts == []
repo = f"cascade/laned-king-c4096-{HOTKEY[:8].lower()}"
assert {r for _, r in api.calls} == {repo}
assert {n: api.repos[repo][n] for n in files} == files
assert publish.MANIFEST_OBJECT in api.repos[repo]
# the read-back re-hash ran after the upload
ops = [op for op, _ in api.calls]
assert "hf_hub_download" in ops[ops.index("upload_file"):]


def test_pull_king_reads_the_same_repo_the_publisher_writes():
from cascade.miner import lane_d_pull_king

assert lane_d_pull_king._publish().hub_repo is publish.hub_repo
Loading