Repository navigation
Match saved check input keys before accepting a receipt #1762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -274,6 +274,17 @@ def _input_blobs(config: Config, worktree: Path, paths: tuple[str, ...]) -> str | |
| raise | ||
|
|
||
|
|
||
| def receipt_inputs_match(config: Config, worktree: Path, report: CheckReport) -> bool: | ||
| keyed = [stage for stage in report.results if stage.input_key is not None] | ||
| if not keyed: | ||
| return True | ||
| 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): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||
| return False | ||
|
|
||
|
|
||
| def _input_key(config: Config, worktree: Path, command: str, base: str, *, | ||
| status: Callable[[str], None] | None = None, | ||
| workflow: str | Path = "workflow.toml") -> str | None: | ||
|
|
||
There was a problem hiding this comment.
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_inputshashes_execution_settings(config, base). For local checks that includesenvironment, andenvironmentincludes an inheritedHEAVY_SLOT_GRANTED_CORESwhenever it is on the allowlist.settings_fingerprintdeliberately removes that variable (sandbox.py:256-258, and docs/ARCHITECTURE.md:113 says the receipt excludes it), soready/mergecan accept a receipt recorded under a different worker grant. The newreceipt_inputs_matchrecomputes the full stage key inready's own environment. Supposecheckran with a heavy slot granted (e.g.HEAVY_SLOT_GRANTED_CORES=2) andreadyruns 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 Noneafter the grant changes to 4 and after it is removed). That test should now fail, because README.md matches the*.mdinputs 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_inputsso it takes the settings dict, then compare using the grant-stripped settings thatsettings_fingerprintuses. 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.