Skip to content

Preserve check receipts when a stage runner fails - #1960

Draft
eowca wants to merge 8 commits into
mainfrom
lean178/1179-runner-results-v2
Draft

eowca wants to merge 8 commits into
mainfrom
lean178/1179-runner-results-v2

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1179. Supersedes #1752. Implements the OD ruling of 26 Nov (Lean178 r59) on #1179.

A complete, valid nonzero stage result still records a failed check. A runner exit or interruption without a complete stage result preserves the previous receipt, skips publishing a verdict, and passes through the runner status. Readiness still requires the receipt to match the candidate head. The existing heavy-slot guard requires a fresh failed receipt, so it skips these runner failures without a host-config change. The diagnosis skill stops after one failed retry and records the status, log path and host.

Verification covers valid stage failures, runner exits 75 and 124, SIGTERM and SIGKILL after partial output, a supervisor timeout, receipt contents and timestamp, and readiness on a new head with only an older green receipt.


Run Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Review

Validation

Recorded for ab7376fd3f1b

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 1

eowca and others added 4 commits November 26, 2026 16:01
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>

Architecture-Review: unchanged; both entry points use the same process-status handling.

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

loopzero primary review by claude on 1b3e724f8c41a96136595d61adf9342394da8e8c, 62.5s: approve (0 critical, 0 important, 4 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/sandbox.py Outdated
except (LoopZeroError, ValueError, TypeError, OverflowError, RecursionError, OSError) as exc:
detail = _redact_check_output(config, str(exc))
return CheckResult(command, 1, 0.0, _check_tail(f"Stage runner failed: {detail}"))
detail = failure_detail or _check_tail(str(exc), config)

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: Runner exit detail hides the real reason when the worktree changes after a stage

failure_detail is set as soon as runner_exit is nonzero (line 666–668). It then takes priority over str(exc) in the handler: detail = failure_detail or _check_tail(str(exc), config). Suppose the runner returns a valid frame with a nonzero exit, but _stage_unchanged then fails (Worktree changed after stage, line 671). The operator only sees process exit N plus stderr, so the drift cause is lost. That cause is the thing that tells the agent to stop retrying. Smallest fix: when failure_detail is set and the exception is not the frame-validation error, add the exception text too, e.g. detail = '\n'.join(filter(None, (failure_detail, _check_tail(str(exc), config)))).

Comment thread src/loopzero/sandbox.py
failure_detail = f"{failure_detail or f'process exit {runner_exit}'}\n{stderr}".rstrip()
frame = _stage_frame(done.stdout, binding, runner_exit)
if not _stage_unchanged(config, worktree, head):
raise ValueError("Worktree changed after stage")

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: Worktree drift is now reported as a runner failure

Before this change, a clean exit 0 runner followed by a worktree change produced a dirty CheckReport, and _save_report discarded it. Now it raises StageRunnerFailure(1, 'Worktree changed after stage') (the same applies to 'before stage' and 'before fallback'). The CLI prints runner failure, not a check result. The new diagnose-skill guidance tells agents to retry once and then report the runner exit, log path and host. Here the cause is the agent's own worktree mutation, not the runner or host, so that guidance sends diagnosis the wrong way. Keeping the prior receipt is fine. Consider raising a distinct message or exception for drift, e.g. a WorktreeError that _run already maps, so it isn't labelled a runner failure.

Comment thread src/loopzero/cli.py Outdated
return " | ".join(ln.strip() for ln in (str(exc) or type(exc).__name__).splitlines() if ln.strip())


def _exit_status(code: int) -> int:

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: Signal passthrough in _exit_status is untested and re-raises core-dumping signals

test_check_receipt_requires_stage_result calls cli._run through run(), so it never reaches _exit_status. Nothing checks that a runner killed by -15/-9 makes loopzero itself end with that signal, as both _cli_entry.main and __main__ now do. Also, signals like SIGSEGV or SIGABRT reset to SIG_DFL and are raised on the loopzero process, which can dump core for a runner crash. Add a subprocess-level test of python -m loopzero (or main) with a signalled runner. Optionally map core-dumping signals to 128+N instead of re-raising them.

Comment thread docs/ARCHITECTURE.md
also exits nonzero. Missing, extra, duplicate, malformed or mismatched fields
and interruption before a complete result are runner failures. Check preserves
the prior receipt, returns the runner status (124 for a supervisor timeout), and
does not publish a stage verdict. A receipt is eligible only for its own HEAD. `not_started=true` requires exit_code=0,

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: Unwrapped long lines in the rewritten paragraphs

The new text ...does not publish a stage verdict. A receipt is eligible only for its own HEAD. \not_started=true` requires exit_code=0,andfor reuse. Delegated results are published only after the check completes. A checkpoint cannot replace...` go well past the wrap width the rest of the file uses. Rewrap these paragraphs to keep the diffs reviewable.

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

loopzero delta review by claude on ab7376fd3f1b87828b82ebb02ebe2e295a762b07, 30.3s: approve (0 critical, 0 important, 1 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/sandbox.py Outdated
_checkpoint_stage(
checkpoint, CheckReport(head, dirty, tuple(results), settings_sha256),
previous, commands[ordinal:],
checkpoint if result.exit_code or not config.check_runner else None,

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: Merge resolution changes runner checkpoint behaviour without a test

Before this merge, the branch side (1b3e724) never checkpointed when config.check_runner was set. The resolved code now checkpoints right away when a delegated stage returns a nonzero result (checkpoint if result.exit_code or not config.check_runner). It still skips checkpoints for successful delegated stages. This change matches the task ("a complete, valid nonzero stage result records a failed check and replaces the receipt") and the updated ARCHITECTURE.md text. A runner exit, timeout or signal still raises StageRunnerFailure from _dispatch_one before any checkpoint, so the prior receipt stays intact. However, nothing in tests/ calls run_checks with a runner and a checkpoint callback. The only checkpoint tests are in tests/test_cli.py and use a stubbed run_checks. If someone later reverts this gating, no test would fail. Smallest fix: add a test_stage_runner case with two delegated stages. In the first variant, stage 1 passes and stage 2 returns a nonzero result: the checkpoint should be called exactly once, with the failing report and no INCOMPLETE_CHECK. In the second variant, _dispatch_one raises StageRunnerFailure: the checkpoint should never be called.

eowca and others added 3 commits November 26, 2026 16:20
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>

Architecture-Review: unchanged; the receipt publication path already uses the shared checkpoint marker.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Report delegated runner outages as infrastructure failures

1 participant