diff --git a/SETUP.md b/SETUP.md index 557f4782..30258c12 100644 --- a/SETUP.md +++ b/SETUP.md @@ -339,6 +339,29 @@ access to the configured GitHub repository even before a PR exists. See the [workflow diagram](docs/WORKFLOW.md#1-from-idea-to-merged) and [Blockers](core/CONTRACT.md#blockers) for the rest of the workflow. +### Check receipts with remote execution + +Run the current `loopzero check` coordinator from the task worktree with +the same effective settings used by `loopzero ready`. To execute stages +remotely, configure an operator-trusted `[checks].runner` that implements the +[stage protocol](docs/ARCHITECTURE.md#check-stage-runners). The local coordinator +writes the receipt. + +Without a stage adapter, run the whole check locally. Use a local slot if the +host requires one. On miki, run this from the task worktree. + +```sh +HEAVY_SLOT_REMOTE_HOSTS="$HOME/.cache/intelflo-scratch/locks/no-remote-hosts.json" "$HOME/.cache/intelflo-scratch/locks/heavy-slot.sh" loopzero check +``` + +A whole-job remote worker writes its own receipt. Ready can use it only if it +passes the existing checks for a clean, passing receipt at the exact head, +with the current ordered commands and matching settings fingerprint. An older +worker can omit the fingerprint. A current worker can produce a different +fingerprint, for example when its inherited `PATH` differs. GitHub required +CI supplies separate evidence. The [owner queue route](core/CONTRACT.md#blockers) +applies only under its documented conditions. + ## Removing an abandoned task worktree For a merged PR, retry cleanup from a durable directory with diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 661a86f4..b2b29b9a 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -501,4 +501,11 @@ Receipts that use saved stage results bind the current head and check settings. For delegated checks, both the receipt and the stage key bind the runner's launch path, resolved executable path and executable bytes. Unavailable runner identity prevents receipt reuse. + +A worker running the entire check is itself the coordinator and writes a +receipt with its own effective settings. Transferring it preserves the +fingerprint, if present. Local readiness applies the same receipt predicate +as for any other coordinator. See [check receipts with remote execution](../SETUP.md#check-receipts-with-remote-execution) +for the operator route. + CI and merge-queue candidates run fresh without a local worktree receipt. diff --git a/tests/test_cli.py b/tests/test_cli.py index 3cd7131b..bf6c9382 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -3099,6 +3099,28 @@ def test_ready_matches_effective_inherited_check_environment( assert code == 1 and "not ready: check receipt has an incompatible settings fingerprint." in out +@pytest.mark.parametrize("worker", ["legacy", "different-path", "matching"]) +def test_ready_checks_transferred_whole_job_receipt(wt, gh, capsys, head, tmp_path, monkeypatch, worker): + arm_approved_ready_pr(gh, head, wt, readiness={"local_exit": None}, isDraft=False) + with monkeypatch.context() as worker_env: + if worker == "different-path": + worker_env.setenv("PATH", str(tmp_path / "worker-bin"), prepend=":") + assert run(capsys, "check")[0] == 0 + + receipt = wt / ".loopzero/checks.json" + payload = json.loads(receipt.read_bytes()) + if worker == "legacy": + # Older producers serialize these results without a settings fingerprint. + del payload["settings_sha256"] + # Whole-job transport preserves the producer's fields. + receipt.write_text(json.dumps(payload)) + assert run(capsys, "ready")[0] == (0 if worker == "matching" else 1) + + if worker != "matching": + assert run(capsys, "check")[0] == 0 + assert run(capsys, "ready")[0] == 0 + + def test_ready_ignores_forged_markers(wt: Path, gh: FakeGh, capsys, head) -> None: arm_approved_pr_with_check_result(gh, head, wt, "success", reviews=[rev(head, "primary", login="stranger"), rev(head, "primary", commit="1" * 40)]) code, out, _ = run(capsys, "ready")