Repository navigation
Preserve passing receipts across late check checkpoints #1379
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
bcf882e
f30fb48
9f51879
c8bed8f
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 |
|---|---|---|
|
|
@@ -359,7 +359,7 @@ def _lock_task_state(wt: Path) -> Iterator[None]: | |
| os.close(fd) | ||
|
|
||
|
|
||
| def _save_report(wt: Path, report: CheckReport) -> str | None: | ||
| def _save_report(wt: Path, report: CheckReport, *, checkpoint_checks: tuple[str, ...] | None = None) -> str | None: | ||
| """Publish the receipt or return the current HEAD if the result is stale.""" | ||
| path = wt / CHECKS_FILE | ||
| payload = { | ||
|
|
@@ -375,6 +375,11 @@ def _save_report(wt: Path, report: CheckReport) -> str | None: | |
| current_head = worktree.head(wt) | ||
| if report.head != current_head: | ||
| return current_head | ||
| saved = _load_report(wt) if checkpoint_checks is not None else None | ||
| if (saved is not None and saved.ok and not saved.dirty and saved.head == report.head | ||
|
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: Guard treats any same-head/same-settings pass as authoritative, even if its check list differs The checks list is not part of |
||
| and saved.settings_sha256 == report.settings_sha256 | ||
| and tuple(result.command for result in saved.results) == checkpoint_checks): | ||
| return None | ||
| _write_json_atomically(path, payload) | ||
| return None | ||
|
|
||
|
|
@@ -598,7 +603,7 @@ def cmd_check(args: argparse.Namespace) -> int: | |
| report = sandbox.run_checks(config, wt, progress=lambda command: print( | ||
| f"running: {command}", flush=True), | ||
| status=lambda message: print(message, flush=True), | ||
| checkpoint=lambda partial: _save_report(wt, partial)) | ||
| checkpoint=lambda partial: _save_report(wt, partial, checkpoint_checks=config.checks)) | ||
| except sandbox.SandboxUnavailable as exc: | ||
| print(f"sandbox unavailable: {exc}", file=sys.stderr) | ||
| return 2 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| import subprocess | ||
| import sys | ||
| from dataclasses import replace | ||
| from functools import partial | ||
| from pathlib import Path | ||
| from types import SimpleNamespace | ||
| from unittest.mock import Mock | ||
|
|
@@ -4763,3 +4764,22 @@ def test_pr_marks_legacy_same_head_check_unverified(wt, gh, capsys): | |
| assert "unverified" not in draft | ||
| assert f"Recorded for `{head[:12]}`\n- `echo ok`: exit 0" in draft | ||
| assert "Manual validation evidence." in draft | ||
|
|
||
|
|
||
| def test_late_checkpoint_preserves_completed_pass(wt, head): | ||
|
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: Regression drives the internal helper instead of an actual interrupted overlapping run The test calls |
||
| cfg = config.load(wt / "workflow.toml") | ||
| passed = CheckReport(head, False, tuple(CheckResult(c, 0, 0, "", input_key="key") for c in cfg.checks), | ||
| cli.sandbox.settings_fingerprint(cfg, wt)) | ||
| save = partial(cli._save_report, wt) | ||
| checkpoint = cli.sandbox._checkpoint_success | ||
| checkpoint(partial(save, checkpoint_checks=cfg.checks), passed, {}, ()) | ||
| assert cli._load_report(wt).results[0].input_key == "key" | ||
| save(passed) | ||
| checkpoint(partial(save, checkpoint_checks=cfg.checks), passed, {}, ()) | ||
| assert cli._current_check_report(wt, cfg, head) == passed | ||
| failed = replace(passed, results=(replace(passed.results[0], exit_code=1),)) | ||
| save(failed) | ||
| assert cli._load_report(wt) == failed | ||
| save(passed) | ||
| checkpoint(partial(save, checkpoint_checks=cfg.checks[:1]), replace(passed, results=passed.results[:1]), {}, ()) | ||
| assert not cli._load_report(wt).ok | ||
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.
suggestion: Unwrapped long line in reflowed paragraph
The edited paragraph leaves 'failures still replace passes. Runners cannot select stages or mint receipts. Stage admission' on one line, much longer than the surrounding wrap width. Reflow the paragraph to match.