From 27456d40e8d2701166f70e469308e6a074b5998b Mon Sep 17 00:00:00 2001 From: tensorlink-dev Date: Tue, 1 Dec 2026 07:10:01 +0000 Subject: [PATCH] fix(lane D): the bench host builds the house the eval host holds (live 2026-12-01) Every lane D gate sweep held: "checkpoint_unavailable: b0d4f8e4... is not cached and no grant was given". The house (KING_D at genesis, the BF16 cast of lane A's king) is not in the vault, so VaultGetGrants gives it no grant; the eval host holds it only because the owner's `house_source build --cache-dir` step cast it into that host's cache. The bench host never had that step. SSHBenchHost now takes house_sources (HouseSidecarSource: the house pointer's .source.json, written by ops_jobs house-pointer, wired in load_inputs_services) and, for a grantless digest it names, sends house_sources[digest] = {digest, king_pointer} (optional key; requests without a house are unchanged). serve_sweep builds it there the eval host's way (fetch_from_hub of the king ref + build_house_entry) and admits it only when it hashes to the digest. A missing source, failed build or digest mismatch is checkpoint_unavailable: bench_hold as today. Signed report unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BMT4D7f8wd5dXsASyWUBwe --- cascade/eval/lane_d_bench_sweep.py | 92 +++++++- cascade/validator/lane_d_bench_host.py | 63 ++++- cascade/validator/lane_d_inputs.py | 5 +- tests/accept/w3b6a/PATHS | 5 + tests/accept/w3b6a/test_w3b6a_house_source.py | 220 ++++++++++++++++++ 5 files changed, 369 insertions(+), 16 deletions(-) create mode 100644 tests/accept/w3b6a/test_w3b6a_house_source.py diff --git a/cascade/eval/lane_d_bench_sweep.py b/cascade/eval/lane_d_bench_sweep.py index 8e295d09..319032ef 100644 --- a/cascade/eval/lane_d_bench_sweep.py +++ b/cascade/eval/lane_d_bench_sweep.py @@ -8,7 +8,14 @@ 1. the W15 :class:`~cascade.eval.lane_d_cache.PrefetchCache` (the eval host's rule, :func:`cascade.eval.lane_d_forecasts._checkpoint`): a verified hit is - used as is, a miss with a grant fills through W4 ingest; + used as is, a miss with a grant fills through W4 ingest; a miss of the + house (``house_sources``: the lane A king pointer the box read from the + house pointer's ``.source.json``) is built here exactly as the eval host's + house is (``python -P -m cascade.lane_d.house_source build --cache-dir``: + the king fetched from the Hub, the D47 BF16 cast, + :func:`~cascade.lane_d.house_source.build_house_entry`) and admitted only + when it hashes to the requested digest (live bug 2026-12-01: the house was + never on the bench host, so every gate sweep held); 2. the entry (already lane A's sidecar layout: W4 admits exactly ``config.json``, ``forecast_wrapper.py``, ``model.py``, ``weights.safetensors`` with the release's own code) is materialised into @@ -19,8 +26,9 @@ :func:`~cascade.eval.benchmarks.item_rows_from_report`. **Faults.** Infrastructure fails the whole sweep (:class:`LaneDBenchSweepError`, -nothing swept; the box raises, the gate holds): a miss without a grant, a -failed fetch, a vault / disk / budget fault (``checkpoint_unavailable``), a +nothing swept; the box raises, the gate holds): a miss without a grant or a +house source, a failed fetch or house build (or one that does not hash to its +digest), a vault / disk / budget fault (``checkpoint_unavailable``), a pass with no report at all (``sweep_failed``). The miner's bytes (a W4 refusal) and a digest the sidecar gave no report for get ``{"status": "error", "rows": []}`` on every suite: the gate's ``checkpoint_fault`` on a @@ -96,6 +104,64 @@ def _checked(request) -> tuple[list[str], list[str], dict[str, int], dict]: _checked_settings(request.get("settings"))) +def _checked_house_sources(request: Mapping, digests: list[str]) -> dict[str, str]: + """``{digest: lane A king pointer}`` from the optional ``house_sources`` + (absent: none). Every key is a requested digest whose value names it.""" + raw = request.get("house_sources") + if raw is None: + return {} + if not isinstance(raw, Mapping) or not set(raw) <= set(digests) or not all( + isinstance(v, Mapping) and v.get("digest") == d + and isinstance(v.get("king_pointer"), str) and v["king_pointer"] + for d, v in raw.items()): + raise ValueError("request house_sources must map requested digests to " + '{"digest", "king_pointer"}') + return {str(d): str(v["king_pointer"]) for d, v in raw.items()} + + +def build_house(king_pointer: str, out_dir) -> dict: + """The eval host's house build (``cascade.lane_d.house_source build`` + without the documents): fetch ``king_pointer``'s checkpoint from the Hub + into ``out_dir/king`` and cast it to the house entry ``out_dir/entry``. + Returns :func:`~cascade.lane_d.house_source.build_house_entry`'s + ``{"digest", "manifest", "cast"}`` plus ``"dir"``.""" + from ..lane_d.house_source import build_house_entry, king_ref + from ..shared.hippius import fetch_from_hub + + out = Path(out_dir) + king_dir = out / "king" + fetch_from_hub(king_ref(king_pointer), king_dir) + entry_dir = out / "entry" + shutil.rmtree(entry_dir, ignore_errors=True) + return {**build_house_entry(king_dir, entry_dir), "dir": entry_dir} + + +def _house_entry(cache, digest: str, king_pointer: str, work_dir, *, + build: Callable) -> Path: + """Admit the house ``digest`` to ``cache`` from ``build(king_pointer, + dir)``; raises :class:`LaneDBenchSweepError` (``checkpoint_unavailable``) + on any fault, including a build that does not hash to ``digest``.""" + tmp = Path(work_dir) / f".house-{digest}" + try: + built = build(king_pointer, tmp) + if built.get("digest") != digest: + raise ValueError(f"the house built from {king_pointer!r} is " + f"{str(built.get('digest'))[:16]}, not {digest[:16]}") + src = Path(built["dir"]) + + def fill(staging: Path) -> None: + for name in sorted(p.name for p in src.iterdir() if p.is_file()): + shutil.copyfile(src / name, Path(staging) / name) + + return Path(cache.put(digest, fill)) + except Exception as e: # noqa: BLE001 — the house is ours: never the miner's fault + raise LaneDBenchSweepError("checkpoint_unavailable", + f"{digest[:16]}: house build failed " + f"({type(e).__name__}: {e})") from e + finally: + shutil.rmtree(tmp, ignore_errors=True) + + def _pos_int(v, floor: int) -> bool: return type(v) is int and v >= floor @@ -212,13 +278,16 @@ def suite_aggregates(report: Mapping | None) -> dict: def serve_sweep(request, *, cache, work_dir, contract=None, expect=None, - sidecar: Callable | None = None, fingerprint: Mapping | None = None) -> dict: + sidecar: Callable | None = None, fingerprint: Mapping | None = None, + house_build: Callable | None = None) -> dict: """Answer one :data:`REQUEST_SCHEMA` request (see the module docstring). ``ValueError`` on a malformed request; :class:`LaneDBenchSweepError` when - the sweep cannot run here.""" + the sweep cannot run here. ``house_build(king_pointer, dir)`` defaults to + :func:`build_house`.""" from .lane_d_forecasts import LaneDForecastError, _checkpoint, _scoring_lease digests, suites, contexts, grants, settings = _checked(request) + houses = _checked_house_sources(request, digests) names = _gate_keys() rows: dict[str, dict] = {} aggregates: dict[str, dict] = {} @@ -231,12 +300,17 @@ def serve_sweep(request, *, cache, work_dir, contract=None, expect=None, try: entry = _checkpoint(cache, dg, grants[dg], contract=contract, expect=expect) except LaneDForecastError as e: - if e.code != "checkpoint_refused": + if e.code == "checkpoint_unavailable" and grants[dg] is None and dg in houses: + entry = _house_entry(cache, dg, houses[dg], work_dir, + build=build_house if house_build is None + else house_build) + elif e.code != "checkpoint_refused": raise LaneDBenchSweepError("checkpoint_unavailable", f"{dg[:16]}: {e}") from e - log.warning("lane_d_bench_refused digest=%s detail=%s", dg[:16], e) - rows[dg] = _error_rows(suites) - continue + else: + log.warning("lane_d_bench_refused digest=%s detail=%s", dg[:16], e) + rows[dg] = _error_rows(suites) + continue try: dirs.append((dg, materialise(entry, work_dir, digest=dg, context=contexts[dg]))) except (OSError, ValueError) as e: diff --git a/cascade/validator/lane_d_bench_host.py b/cascade/validator/lane_d_bench_host.py index 4fbb31bb..9e8144ae 100644 --- a/cascade/validator/lane_d_bench_host.py +++ b/cascade/validator/lane_d_bench_host.py @@ -10,6 +10,16 @@ GET grant (never weights, histories or targets: D12, §10.2), and runs ``python -m cascade.eval.lane_d_bench_sweep sweep`` there over SSH. +The house (KING_D at genesis) is not in the vault, so it has no grant: the +eval host holds it because the owner's ``house_source build --cache-dir`` +step cast it there. The bench host gets the same build instead: for a digest +without a grant that the house pointer's ``.source.json`` sidecar names +(:class:`HouseSidecarSource`), the request carries ``house_sources[digest] = +{"digest", "king_pointer"}`` and the bench host fetches lane A's king from +the Hub, casts it (D47) and admits it only if it hashes to the digest (live +bug 2026-12-01: without it every gate sweep held on +``checkpoint_unavailable``). A digest with neither still holds. + Every failure raises (no host, a digest without a context, a non-zero exit, a malformed or unexpected reply): ``lane_d._run_gate`` turns it into ``bench_hold``. A row is never guessed. @@ -51,13 +61,43 @@ class LaneDBenchHostError(RuntimeError): """The bench host cannot answer this sweep (the gate holds).""" +class HouseSidecarSource: + """``source(digest)``: ``{"digest", "king_pointer"}`` when the house + pointer's ``laned_house_source/1`` sidecar (``.source.json``, + written by ``ops_jobs house-pointer`` beside the signed pointer) names + ``digest``, else ``None``. Unsigned, and need not be: the bench host + admits the build only when it hashes to ``digest``.""" + + def __init__(self, house_pointer): + from ..lane_d.ops_jobs import SIDECAR_SUFFIX + + p = Path(house_pointer) + self.path = p.with_name(p.name + SIDECAR_SUFFIX) + + def __call__(self, digest: str) -> dict | None: + from ..lane_d.ops_jobs import HOUSE_SOURCE_SCHEMA + + try: + doc = json.loads(self.path.read_text(encoding="utf-8")) + except (OSError, UnicodeDecodeError, ValueError): + return None + if not isinstance(doc, dict) or doc.get("schema") != HOUSE_SOURCE_SCHEMA \ + or doc.get("digest") != digest: + return None + kp = doc.get("king_pointer") + return {"digest": digest, "king_pointer": kp} if isinstance(kp, str) and kp else None + + class SSHBenchHost: """``host(digests, suites)``: one sweep on the bench host (module docstring). ``grants(digest)`` gives a presigned GET grant or ``None``; - ``run`` is the ``subprocess.run``-shaped runner.""" + ``house_sources(digest)`` gives ``{"digest", "king_pointer"}`` for a + digest without a grant that the bench host builds as the house (or + ``None``); ``run`` is the ``subprocess.run``-shaped runner.""" def __init__(self, hosts_path, *, cache_dir: str, budget_bytes: int, settings: Mapping, grants: Callable[[str], Mapping | None] | None = None, + house_sources: Callable[[str], Mapping | None] | None = None, run: Callable | None = None): self.hosts_path = Path(hosts_path) self.cache_dir = str(cache_dir) @@ -69,6 +109,7 @@ def __init__(self, hosts_path, *, cache_dir: str, budget_bytes: int, settings: M self.timeout_per_checkpoint_s = float( self.settings.get("timeout_s_per_checkpoint", DEFAULT_TIMEOUT_S)) self._grants = grants + self._house_sources = house_sources self._run = run or subprocess.run self._contexts: dict[str, int] = {} @@ -103,9 +144,19 @@ def _request(self, digests: list[str], suites: list[str], for d in digests: g = None if self._grants is None else self._grants(d) grants[d] = None if g is None else dict(g) - return {"schema": REQUEST_SCHEMA, "digests": digests, "suites": suites, - "contexts": {d: ctx[d] for d in digests}, "grants": grants, - "settings": {k: self.settings[k] for k in SETTINGS_KEYS}} + houses = {} + for d in digests: + src = None if grants[d] is not None or self._house_sources is None \ + else self._house_sources(d) + if src is not None and src.get("digest") == d and src.get("king_pointer"): + houses[d] = {"digest": d, "king_pointer": str(src["king_pointer"])} + request = {"schema": REQUEST_SCHEMA, "digests": digests, "suites": suites, + "contexts": {d: ctx[d] for d in digests}, "grants": grants, + "settings": {k: self.settings[k] for k in SETTINGS_KEYS}} + if houses: + # optional key: a request without a house is byte-identical to before + request["house_sources"] = houses + return request @staticmethod def _checked(reply, digests: list[str]) -> dict: @@ -197,5 +248,5 @@ def _sweep(self, ds: list[str], ss: list[str], *, return reply -__all__ = ["REPLY_SCHEMA", "REQUEST_SCHEMA", "SETTINGS_KEYS", "LaneDBenchHostError", "SSHBenchHost", - "bench_settings"] +__all__ = ["REPLY_SCHEMA", "REQUEST_SCHEMA", "SETTINGS_KEYS", "HouseSidecarSource", + "LaneDBenchHostError", "SSHBenchHost", "bench_settings"] diff --git a/cascade/validator/lane_d_inputs.py b/cascade/validator/lane_d_inputs.py index 6ea17cea..3e201965 100644 --- a/cascade/validator/lane_d_inputs.py +++ b/cascade/validator/lane_d_inputs.py @@ -1611,10 +1611,13 @@ def load_inputs_services(cfg: Any, path) -> dict: score_cache = ScoreCache(raw["score_cache_dir"]) bench = None if raw.get("bench_hosts"): - from .lane_d_bench_host import SSHBenchHost, bench_settings + from .lane_d_bench_host import HouseSidecarSource, SSHBenchHost, bench_settings + # the house has no vault grant: the bench host builds it from the + # house pointer's sidecar (the eval host's house_source build step) bench = SSHBenchHost(raw["bench_hosts"], cache_dir=raw["eval_cache_dir"], budget_bytes=raw["eval_cache_budget_bytes"], grants=grants, + house_sources=HouseSidecarSource(raw["house_pointer"]), settings=bench_settings(cfg)) return {"intake_state_dir": intake, "pool": PinFilePool(raw["pool_pins"]), "eval_host": host, "house_pointer": Path(raw["house_pointer"]), diff --git a/tests/accept/w3b6a/PATHS b/tests/accept/w3b6a/PATHS index 032c118a..1362d932 100644 --- a/tests/accept/w3b6a/PATHS +++ b/tests/accept/w3b6a/PATHS @@ -19,3 +19,8 @@ cascade/validator/eval_offload.py # (suite_aggregates: lane A's extract_bench_scores convention) beside the # unchanged gate rows; SSHBenchHost.sweep_full returns them merged into the # rows, with a context override and a capped allowance. +# Live bug 2026-12-01 (every gate sweep held: the house has no vault grant): +# SSHBenchHost sends house_sources for a grantless digest the house pointer's +# .source.json names (HouseSidecarSource, wired in lane_d_inputs.py); the +# bench host builds it as the eval host's house_source build step does (Hub +# fetch + D47 cast) and admits it only when it hashes to the digest. diff --git a/tests/accept/w3b6a/test_w3b6a_house_source.py b/tests/accept/w3b6a/test_w3b6a_house_source.py new file mode 100644 index 00000000..32af631e --- /dev/null +++ b/tests/accept/w3b6a/test_w3b6a_house_source.py @@ -0,0 +1,220 @@ +"""W3b6a, the house on the bench host (live bug 2026-12-01). + +The house (KING_D at genesis: lane A's frozen king, BF16) is not in the +vault, so the box has no presigned grant for it; the eval host holds it only +because the owner's ``house_source build --cache-dir`` step cast it into that +host's cache. Every gate sweep on the bench host therefore failed +``checkpoint_unavailable: is not cached and no grant was given`` and +held. Now the box sends, for a grantless digest the house pointer's +``.source.json`` sidecar names, ``house_sources[digest] = {"digest", +"king_pointer"}``; the bench host runs the same build (Hub fetch, D47 cast) +and admits it only when it hashes to the digest. Anything else still holds. +""" + +from __future__ import annotations + +import inspect +import json +from pathlib import Path + +import pytest + +from . import helpers as h + +CAND, KING, HOUSE = "c" * 64, "d" * 64, "e" * 64 +KING_A = "metro-v1:trained:hippius:cascade/king@sha256:" + "f" * 64 + + +def _sidecar(pointer: Path, digest: str, king_pointer: str = KING_A) -> None: + pointer.with_name(pointer.name + ".source.json").write_text(json.dumps( + {"schema": "laned_house_source/1", "king_pointer": king_pointer, "digest": digest, + "reveal_ts": 1700000000}), encoding="utf-8") + + +def _source_cls(): + m = h.host_mod() + assert hasattr(m, "HouseSidecarSource"), \ + "the box reads the house's king pointer from the house pointer's sidecar" + return m.HouseSidecarSource + + +def _host(tmp_path, run, **kw): + cls = h.host_mod().SSHBenchHost + assert "house_sources" in inspect.signature(cls).parameters, \ + "SSHBenchHost(..., house_sources=) gives the bench host a way to the house" + host = cls(h.hosts_file(tmp_path), run=run, cache_dir="/root/lane_d_cache", + budget_bytes=10 ** 11, settings=dict(h.SETTINGS), **kw) + host.set_contexts({CAND: 4096, KING: 4096, HOUSE: 2048}) + return host + + +def _serve_kw(): + params = inspect.signature(h.sweep_mod().serve_sweep).parameters + assert "house_build" in params, "serve_sweep builds the house from its source" + + +# ── the box ───────────────────────────────────────────────────────────────── + + +def test_request_carries_a_house_source_for_the_grantless_house(tmp_path): + pointer = tmp_path / "house_pointer.json" + _sidecar(pointer, HOUSE) + run = h.Run(h.reply({d: h.rows_entry(i) for i, d in enumerate((CAND, KING, HOUSE))})) + host = _host(tmp_path, run, grants=lambda d: h.grant(d) if d in (CAND, KING) else None, + house_sources=_source_cls()(pointer)) + host((CAND, KING, HOUSE), h.SUITES) + req = run.request() + assert req["grants"] == {CAND: h.grant(CAND), KING: h.grant(KING), HOUSE: None} + assert req["house_sources"] == {HOUSE: {"digest": HOUSE, "king_pointer": KING_A}}, \ + "the house (no vault grant) is resolvable on the bench host" + + +def test_sidecar_naming_another_digest_gives_no_source(tmp_path): + pointer = tmp_path / "house_pointer.json" + _sidecar(pointer, "9" * 64) + src = _source_cls()(pointer) + assert src(HOUSE) is None + assert _source_cls()(tmp_path / "absent.json")(HOUSE) is None + + +def test_no_source_keeps_the_request_unchanged_and_the_sweep_raises(tmp_path): + """Unresolvable on the box: no house_sources key (the request is the + pre-fix one) and a failing bench host is a hold, as today.""" + run = h.Run(h.reply({}), returncode=1) + host = _host(tmp_path, run, house_sources=lambda d: None) + from cascade.validator.lane_d_bench import SweepSession + + with pytest.raises(h.host_mod().LaneDBenchHostError): + SweepSession("lane-d-bench/1", host).paired(CAND, KING, HOUSE, suites=h.SUITES) + assert "house_sources" not in run.request() + + +def test_inputs_file_wires_the_house_pointer_sidecar(tmp_path): + from tests.accept.w8b import helpers as w8b + + m = __import__("cascade.validator.lane_d_inputs", fromlist=["x"]) + pointer = tmp_path / "house_pointer.json" + _sidecar(pointer, HOUSE) + keys = {"intake_state_dir": str(tmp_path / "i"), "pool_pins": "/p.json", + "house_pointer": str(pointer), "house_signer_ss58": "5x", "eval_hosts": "/e.toml", + "eval_cache_dir": "/c", "readiness": "/r.json", "t7": "/t.json", + "bench_hosts": str(h.hosts_file(tmp_path))} + p = tmp_path / "inputs.toml" + p.write_text("\n".join(f'{k} = "{v}"' for k, v in keys.items()) + + "\neval_cache_budget_bytes = 10\n", encoding="utf-8") + bench = m.load_inputs_services(w8b.chain_cfg(tmp_path / "v"), p)["bench_host"] + req = bench._request([HOUSE], list(h.SUITES), {HOUSE: 2048}) + assert req.get("house_sources") == {HOUSE: {"digest": HOUSE, "king_pointer": KING_A}}, \ + "load_inputs_services hands the bench host the house pointer's sidecar" + + +# ── the bench host ────────────────────────────────────────────────────────── + + +class Build: + """``house_build(king_pointer, dir)``: writes ``entry`` (as the D47 cast + would) and reports ``digest`` (default: the entry's).""" + + def __init__(self, entry, digest=None, exc=None): + self.entry, self.digest, self.exc = entry, digest, exc + self.calls = [] + + def __call__(self, king_pointer, out_dir): + self.calls.append(king_pointer) + if self.exc is not None: + raise self.exc + d = Path(out_dir) / "entry" + d.mkdir(parents=True) + self.entry.fill(d) + return {"digest": self.digest or self.entry.digest, "dir": d} + + +def _src(e): + return {e.digest: {"digest": e.digest, "king_pointer": KING_A}} + + +def test_candidate_house_and_miner_king_all_resolve(tmp_path, monkeypatch): + _serve_kw() + cand, king, house = h.Entry(11), h.Entry(12), h.Entry(13) + cache = h.cache(tmp_path, cand) + ingested = h.fake_ingest(monkeypatch, king) + build = Build(house) + ds = [cand.digest, king.digest, house.digest] + req = h.request(ds, grants={cand.digest: None, king.digest: h.grant(king.digest), + house.digest: None}) + req["house_sources"] = _src(house) + sidecar = h.Sidecar({e.digest: h.report_for(i) for i, e in enumerate((cand, king, house))}) + got = h.sweep_mod().serve_sweep(req, cache=cache, work_dir=tmp_path / "work", + sidecar=sidecar, fingerprint=dict(h.FINGERPRINT), + house_build=build) + assert build.calls == [KING_A] and len(ingested) == 1 + assert {house.digest, king.digest, cand.digest} <= set(cache.entries()) + assert all(got["rows"][d]["gift"]["status"] == "ok" for d in ds) + # a second sweep hits the cache: no rebuild + h.sweep_mod().serve_sweep(req, cache=cache, work_dir=tmp_path / "work", sidecar=sidecar, + fingerprint=dict(h.FINGERPRINT), house_build=build) + assert build.calls == [KING_A] + + +@pytest.mark.parametrize("fault", ["wrong_digest", "build_raises"]) +def test_unusable_house_build_fails_the_sweep(tmp_path, fault): + _serve_kw() + house = h.Entry(14) + cache = h.cache(tmp_path) + build = (Build(house, digest="0" * 64) if fault == "wrong_digest" + else Build(house, exc=OSError("hub down"))) + req = h.request([house.digest]) + req["house_sources"] = _src(house) + sidecar = h.Sidecar({house.digest: h.report_for(1)}) + m = h.sweep_mod() + with pytest.raises(m.LaneDBenchSweepError) as ei: + m.serve_sweep(req, cache=cache, work_dir=tmp_path / "work", sidecar=sidecar, + fingerprint=dict(h.FINGERPRINT), house_build=build) + assert ei.value.code == "checkpoint_unavailable" + assert sidecar.calls == [] and house.digest not in cache.entries() + + +def test_no_grant_and_no_house_source_still_fails(tmp_path): + _serve_kw() + house = h.Entry(15) + build = Build(house) + m = h.sweep_mod() + with pytest.raises(m.LaneDBenchSweepError) as ei: + m.serve_sweep(h.request([house.digest]), cache=h.cache(tmp_path), + work_dir=tmp_path / "work", sidecar=h.Sidecar(), + fingerprint=dict(h.FINGERPRINT), house_build=build) + assert ei.value.code == "checkpoint_unavailable" and build.calls == [] + + +@pytest.mark.parametrize("bad", [[], {"x" * 64: {"digest": "x" * 64, "king_pointer": KING_A}}, + {"SELF": {"digest": "0" * 64, "king_pointer": KING_A}}, + {"SELF": {"digest": "SELF", "king_pointer": ""}}]) +def test_malformed_house_sources_are_refused(tmp_path, bad): + _serve_kw() + e = h.Entry(16) + req = h.request([e.digest]) + req["house_sources"] = (json.loads(json.dumps(bad).replace("SELF", e.digest)) + if isinstance(bad, dict) else bad) + with pytest.raises(ValueError): + h.sweep_mod().serve_sweep(req, cache=h.cache(tmp_path, e), work_dir=tmp_path / "w", + sidecar=h.Sidecar(), fingerprint=dict(h.FINGERPRINT)) + + +def test_default_build_is_the_eval_hosts_house_build(tmp_path, monkeypatch): + m = h.sweep_mod() + assert hasattr(m, "build_house"), "the bench host's house build" + import cascade.lane_d.house_source as hs + import cascade.shared.hippius as hip + + fetched, built = [], [] + monkeypatch.setattr(hip, "fetch_from_hub", lambda ref, dest: fetched.append((ref, dest))) + + def fake_build(king_dir, entry_dir): + built.append((Path(king_dir), Path(entry_dir))) + return {"digest": HOUSE, "manifest": {}, "cast": {}} + + monkeypatch.setattr(hs, "build_house_entry", fake_build) + out = m.build_house(KING_A, tmp_path / "b") + assert fetched == [(hs.king_ref(KING_A), tmp_path / "b" / "king")] + assert built == [(tmp_path / "b" / "king", tmp_path / "b" / "entry")] + assert out["digest"] == HOUSE and out["dir"] == tmp_path / "b" / "entry"