diff --git a/SETUP.md b/SETUP.md index d2153ef9..29a2e13c 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 42d721ba..35cbe342 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -498,4 +498,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 dfc31abb..09dfa972 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -2991,6 +2991,28 @@ def change_policy(_seconds): assert run(capsys, *args, "check")[0] == 1 +@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 + + @pytest.mark.parametrize("base_sensitive", [False, True]) def test_wait_snapshot_handles_trusted_base_advance(wt, repo, base_sensitive): if base_sensitive: