Skip to content

Reuse passing checks and guard concurrent runs at the same head - #1557

Closed
eowca wants to merge 4 commits into
mainfrom
lean178/1526-reuse-check-receipts
Closed

eowca wants to merge 4 commits into
mainfrom
lean178/1526-reuse-check-receipts

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by #1712 for #1526.

Goal

A clean checkout with a passing receipt that satisfies readiness can run loopzero check again without launching stages. A second active check at the same checkout and HEAD fails immediately. A newer HEAD can run separately, while the existing receipt writer rejects stale results.

Closes #1526
Closes #1528

Validation

  • Offline CLI tests cover exact receipt reuse, fail-fast overlap, interrupted checks, and late results after HEAD moves.
  • The full sandboxed check passed on e2cbc3a6 with a settings fingerprint in the receipt.
  • Net lines against the branch base are +35 source, 0 tests, and +2 architecture documentation.

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

Review

  • primary, codex, e2cbc3a, request_changes
  • delta, codex, 2c53eca, request_changes

@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 codex on e2cbc3a6d238b59905c32dfe17595e38eacd457d, 105.0s: request_changes (1 critical, 2 important, 0 suggestion)

Same-family fallback: independent reviewers failed: claude: not authenticated. Cross-family review is preferred.

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

  • Call 1: requested model gpt-6.2-astra (effort medium); CLI-reported model gpt-6.2-astra (effort medium); configured model gpt-6.2-astra (effort medium)
Raw reviewer output
Native Codex transcript retained in the restricted local review receipt; public evidence is publisher-derived, not backend attestation. Exact raw SHA256: 1c649bac093440324845110f70a089a8bbbae9825894a42555a2a7266e6d1c72

Comment thread src/loopzero/cli.py Resolved
Comment thread src/loopzero/cli.py Resolved
Comment thread src/loopzero/cli.py Resolved
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 codex on 2c53ecaa26e01be3acc191edb4e1e8148088a400, 23.5s: request_changes (0 critical, 2 important, 0 suggestion)

Same-family fallback: independent reviewers failed: claude: not authenticated. Cross-family review is preferred.

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

  • Call 1: requested model gpt-6.2-astra (effort medium); CLI-reported model gpt-6.2-astra (effort medium); configured model gpt-6.2-astra (effort medium)
Raw reviewer output
Native Codex transcript retained in the restricted local review receipt; public evidence is publisher-derived, not backend attestation. Exact raw SHA256: ab808f775bba8f3886e5884d295a3a1f5e41bfea14353c73ce582dd755666d1f

Comment thread src/loopzero/cli.py
path = git_dir / "commondir"
if not path.is_file():
path = git_dir / "config"
with path.open("r+b", buffering=0) as lock:

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: Use a stable lock file in the main worktree

In the main worktree, the lock is held on the inode of .git/config. A concurrent git config --local write replaces that file by rename without changing HEAD. A second check then opens the new inode and acquires the same byte-range lock while the first check is still running. Use a dedicated lock file under the worktree Git directory, keep it in place across runs, and cover a config write between the two acquisitions.

Comment thread src/loopzero/cli.py
with path.open("r+b", buffering=0) as lock:
try:
fcntl.lockf(lock, fcntl.LOCK_EX | fcntl.LOCK_NB, 1, int(head[:15], 16))
except OSError as exc:

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: Preserve exclusion between checks in the same process

lockf record locks belong to the process. A nested or threaded cmd_check at the same HEAD can acquire the range a second time and launch stages. Closing either descriptor also releases the process’s locks on that file, allowing another process in while the outer check is active. The test change replaces the previous nested invocation, so it misses this regression. Use a separately opened, persistent per-HEAD lock file with flock and exercise both nested and subprocess callers.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

The receipt-reuse slice is now in #1587. This combined PR remains draft with both lock findings open. The lock must survive Git config replacement and exclude nested callers. The suggested persistent lock file needs a change to the task’s no-new-state-files constraint.

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.

Prevent overlapping checks from executing the same stages twice Reuse an eligible passing receipt before loopzero check launches stages

1 participant