Skip to content
Closed
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
23 changes: 23 additions & 0 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: New paragraph has no blank line before it, so it merges into the delegated-runner paragraph

The added text starts right after "Unavailable runner identity prevents receipt reuse." with no blank line. Markdown therefore renders the whole-job note as part of the stage-runner receipt-binding paragraph, which mixes the two routes this change tries to separate. Add a blank line before "A worker running the entire check…".

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.
22 changes: 22 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2991,6 +2991,28 @@ def change_policy(_seconds):
assert run(capsys, *args, "check")[0] == 1


@pytest.mark.parametrize("worker", ["legacy", "different-path", "matching"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Overlaps existing receipt-rejection tests

The legacy branch repeats the existing "legacy" condition at tests/test_cli.py:2947-2948, which also deletes settings_sha256 and asserts that ready rejects it. The different-path branch largely repeats test_ready_matches_effective_inherited_check_environment. The acceptance asks for these three cases to be exercised, so the overlap is defensible. If you want less duplication, fold the different-path and matching cases into the existing inherited-environment test and keep legacy only in the existing condition test. Also, the receipt.write_text(json.dumps(payload)) round-trip for the non-legacy cases only re-serializes the file. Its comment about "transport" is the only thing tying the test to the whole-job scenario.

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:
Expand Down
Loading