Skip to content

Match saved check input keys before accepting a receipt - #1762

Closed
eowca wants to merge 1 commit into
mainfrom
lean178/1296-match-saved-check-inputs
Closed

eowca wants to merge 1 commit into
mainfrom
lean178/1296-match-saved-check-inputs

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Match saved check input keys before accepting a receipt

Context and goal

  • Goal: Reject a passing receipt when the checkout bytes of a recorded check input have changed.
  • Problem: Git can rewrite a checkout to CRLF without changing its head or clean status. The current receipt gate overlooks the saved input key.
  • Context: Recompute the keys already in the receipt using the existing rules. A stage with no saved key, including one run fresh when its inputs did not match, keeps its current path.

Closes #1296

Acceptance

  • A saved key that changes or cannot be recomputed blocks ready and merge with the existing rerun instruction.
  • An unchanged keyed input remains eligible. A clean LF-to-CRLF conversion is rejected on the same head in an offline replay.
  • Reuse the current key and receipt fields.

Base

Base: 5d49e6d

Notes

Reuses the input-key idea from #1440. The comparison is scoped to saved keys so it preserves fresh runs that did not produce a cache key.

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, 9018045, request_changes

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 9018045bf14da545dedda4ba9ee5f88e6b73110c, 32.7s: request_changes (0 critical, 1 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
return True
try:
base = _check_base(config, worktree)
return all(stage.input_key == _input_key(config, worktree, stage.command, base) for stage in keyed)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

important: Recomputed input key binds the transient HEAVY_SLOT_GRANTED_CORES grant, so ready falsely rejects valid receipts

_hash_inputs hashes _execution_settings(config, base). For local checks that includes environment, and environment includes an inherited HEAVY_SLOT_GRANTED_CORES whenever it is on the allowlist. settings_fingerprint deliberately removes that variable (sandbox.py:256-258, and docs/ARCHITECTURE.md:113 says the receipt excludes it), so ready/merge can accept a receipt recorded under a different worker grant. The new receipt_inputs_match recomputes the full stage key in ready's own environment. Suppose check ran with a heavy slot granted (e.g. HEAVY_SLOT_GRANTED_CORES=2) and ready runs with a different grant or none. Every keyed stage then mismatches and the receipt is rejected with "declared check inputs changed", even though no input byte changed. This contradicts the existing contract asserted in tests/test_sandbox.py:783-787 (test_declared_input_reuse[grant] expects _current_check_report(...) is not None after the grant changes to 4 and after it is removed). That test should now fail, because README.md matches the *.md inputs and so the stages carry keys. Smallest fix: build the comparison from the same settings that the receipt gate already accepts. One way is to factor _hash_inputs so it takes the settings dict, then compare using the grant-stripped settings that settings_fingerprint uses. Since the settings fingerprint already binds the other settings, another option is to compare only the per-path content digests and blob listing against something saved in the receipt. Run the existing grant test as a regression.

Comment thread src/loopzero/sandbox.py
try:
base = _check_base(config, worktree)
return all(stage.input_key == _input_key(config, worktree, stage.command, base) for stage in keyed)
except (SandboxUnavailable, OSError, _proc.ProcTimeout, _proc.ToolMissing):

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: Exception set differs from _input_key's, so a ValueError escapes ready/merge

_input_key catches (SandboxUnavailable, _proc.ProcTimeout, OSError, ValueError) and re-raises when base is non-empty, which is always the case for a keyed receipt. receipt_inputs_match catches ToolMissing but not ValueError. Any ValueError from _git or the blob listing would therefore propagate out of _check_report_problem and crash ready/merge instead of returning the rerun instruction. Add ValueError to the caught tuple (or share one tuple constant) so that 'cannot be recomputed' always maps to rejection, as the acceptance criteria require.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Parked after review. Existing stage keys include the inherited CPU grant, while #1698 requires readiness to accept a changed grant and preserves those keys. Comparing them with the current grant would reject valid receipts.

waits for test headroom after #1663

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Closed by Lean ruling on #1296: the fix needs a receipt-format change that is not approved now. Branch kept.

@eowca eowca closed this Nov 26, 2026
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