Skip to content

Reject check receipts when declared inputs cannot be verified - #1440

Closed
eowca wants to merge 2 commits into
mainfrom
lean178/1296-stage-keys-current-main
Closed

eowca wants to merge 2 commits into
mainfrom
lean178/1296-stage-keys-current-main

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Reject check receipts when declared inputs cannot be verified

Context and goal

  • Goal: Make readiness and merge require a fresh check when the bytes of a declared input change.
  • Problem: Git can rewrite LF to CRLF while keeping the head unchanged and the worktree clean. The old passing receipt remains accepted even when a fresh check would fail.
  • Context: The check runner already stores stage input keys. Recompute those keys during receipt validation and refuse mismatches or unavailable keys.

Closes #1296. Supersedes #1392, which replaced #1308.

Acceptance

  • An unchanged declared input still passes readiness.
  • A clean LF-to-CRLF checkout at the same head blocks both ready and merge on the older receipt, and a fresh check fails.
  • A declared stage without a verifiable key blocks readiness and gives actionable recovery guidance.
  • Reuse the existing input key and receipt fields.

Notes

  • The fail-closed repair from d4b03c01 is unchanged. This branch keeps both the new regression from main and the regression in Reject check receipts when declared inputs cannot be verified #1392 after their Git insertion points conflicted.
  • The receipt must still match the head, check commands and settings. An absent stage key cannot establish that the declared bytes are unchanged.

Validation

(no loopzero check run recorded)


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

Review

  • primary, claude, 9c12b0a, request_changes
  • delta, claude, 018f43f, approve

Architecture-Review: unchanged; readiness reuses existing head-bound receipts and stage keys, and reports unavailable keys.
Co-Authored-By: Codex <noreply@openai.com>

@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 9c12b0ac3f7d83cbf3355fd1f66f18126260ebd1, 47.4s: request_changes (0 critical, 1 important, 3 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)

Findings without a file location:

  • suggestion: loopzero check reports success for a receipt that readiness will always reject — When _input_key returns None for a keyed stage, run_checks records the result without a key and check exits 0. Only a later ready or merge explains that the receipt is unusable, as in the test's keyable=False branch where check returns 0 and ready returns 1. Running check again cannot fix it. Consider having check print, or fail on, the same 'declared input keys unavailable' guidance when a keyed stage ends up with input_key is None. That would keep the two commands consistent and surface the problem where the user can act on it.

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

Comment thread src/loopzero/cli.py Resolved
Comment thread src/loopzero/sandbox.py
return command in config.inputs or "." in config.inputs.get("*", ())


def receipt_inputs_match(config: Config, worktree: Path, report: CheckReport) -> bool:

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: Readiness now rehashes every declared input once per stage

receipt_inputs_match calls _input_key for each keyed result. Each call runs hash-object and diff-tree and SHA-256s every matched file. With "*" = ["."] that means the whole tree is read N times for N stages, on every ready, merge, PR body refresh (_validation_section) and wait snapshot. This is correct, but it can be slow on large repos. One option is to compute the diff-tree output and file digests once per distinct pathspec set and reuse them across stages. This is non-blocking.

Comment thread src/loopzero/cli.py
if report.settings_sha256 != sandbox.settings_fingerprint(config, wt):
return f"check receipt has an incompatible settings fingerprint. {recovery}"
if not sandbox.receipt_inputs_match(config, wt, report):
return ("declared input keys changed or are unavailable; run loopzero check at this head. "

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: Recovery guidance omits the oversized-pathspec cause

_input_key also returns None when git raises E2BIG for too many pathspecs. In that case the recovery message ('ensure the check base is available and declared paths select only readable regular files') does not point at the real cause. Consider mentioning that the declarations should be reduced, or reusing the recovery wording above it so the guidance stays in one place.

Co-Authored-By: Codex <noreply@openai.com>

@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 018f43fa9f07386ebb96697700f0276bbaab8907, 19.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/cli.py
if report.settings_sha256 != sandbox.settings_fingerprint(config, wt):
return f"check receipt has an incompatible settings fingerprint. {recovery}"
if not sandbox.receipt_inputs_match(config, wt, report):
return ("declared input keys changed or are unavailable; run loopzero check at this head. "

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: The ready/merge error message leaves out the oversized-pathspec recovery that the docs now describe

The new text in docs/ARCHITECTURE.md lists three ways to recover when keys are unavailable: restore the base, narrow oversized pathspecs, or narrow declarations that match unreadable or non-regular paths. The code supports all three: _input_key (sandbox.py:279-281) returns None on E2BIG, which is what happens when the pathspec list is too long.

The error message users actually see, at cli.py:330-332, only covers the base and the readable-regular-files cases. A user who hits E2BIG would rerun loopzero check and keep getting the same block with nothing pointing at the cause.

Smallest fix: add "and pathspecs are not oversized" (or similar) to that message so it matches the docs. Separately, the doc sentence "narrow oversized pathspecs and declarations that match unreadable or non-regular paths" is hard to parse; splitting it into two clauses would make it clearer.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Parking approved head 018f43f. Its full local slotted check passed. The merge projection against origin/main at 29a3f88 has 13,885 test lines against the 13,850 cap. The tests merge cleanly, but #1410 also conflicts in src/loopzero/sandbox.py. No queue candidate was requested because those integration blockers are known.

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.

Reject saved check passes when declared input bytes change

1 participant