Skip to content

Preserve PR body sections across checkouts - #1865

Closed
eowca wants to merge 4 commits into
mainfrom
lean178/1371-pr-section-merge
Closed

eowca wants to merge 4 commits into
mainfrom
lean178/1371-pr-section-merge

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Preserve PR body sections across checkouts

Context and goal

  • Context: Check, review, and explicit PR updates send a complete body to GitHub.
  • Problem: Distinct checkouts hold different locks, so a delayed Validation PATCH can erase a newly written Review entry.
  • Goal: Serialize live body reads and updates per repository and PR across local checkouts while preserving unrelated prose and the worktree-scoped receipt lock.

Closes #1371

Acceptance

  • Pause check before its PATCH while the review summary writer in another checkout attempts to update the same PR. Both sections and human prose survive.
  • Check, review, and pr use the same short lock for the live body update; independent PR numbers use independent locks.

Base

Base: 3c2697f

Validation

Recorded for f5ba6c08fc78

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0

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

Review

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

The race replay pauses a real check just before its body PATCH, starts the review-summary updater from another checkout, and waits for a proven lock contention event. A scratch negative control with separate locks reproduced the stale PATCH erasing ## Review; the shared-lock replay keeps Review, recorded Validation, and human prose. The 20 focused cases passed. Main integration preserves the +17 source / +19 test delta. The lock uses a case-insensitive repository and PR hash, a private leaf directory opened without following a leaf symlink, and a descriptor released in finally; GitHub authentication and the worktree receipt lock are unchanged.

@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 71a500821d2118b85d871c05a2ad3b9b983a9992, 33.7s: approve (0 critical, 0 important, 2 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
@contextmanager
def _lock_pr_body(repo: str, number: int) -> Iterator[None]:
key = hashlib.sha256(f"{repo.casefold()}#{number}".encode()).hexdigest()
path = Path.home() / ".cache" / "loopzero" / "pr-bodies" / key

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: Lock directories accumulate forever and ignore XDG_CACHE_HOME

Each repository and PR pair creates a permanent empty directory under ~/.cache/loopzero/pr-bodies/<sha256>, and nothing ever removes them. Over many PRs these pile up, though slowly and harmlessly. The path is also hard-coded to ~/.cache instead of respecting XDG_CACHE_HOME. Suggested fix: use os.environ.get('XDG_CACHE_HOME') or Path.home()/'.cache' as the base. Optionally, lock a single regular file per key, or accept the growth and note it in the docs.

Comment thread src/loopzero/cli.py
if body != (pr.body or "").replace("\r\n", "\n"):
github.update_body(config.repo, pr.number, body)
upstream = config_mod.run_git(wt, "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{upstream}")
if upstream.exit_code != 0:

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: Check refresh now always makes an extra live PR read

_refresh_pr_checks now calls pr_for_branch outside the lock and then pr_view inside it. That makes every check on a pushed branch do two GitHub lookups, even when the body is unchanged; the updated test expectations show this. The re-read is needed for correctness under the lock, so this does not block the change. A future cleanup could drop the outer pr_for_branch body use and keep it only to find the PR number.

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 b22c4f57cf248523fce4ea1b49df0a633610564c, 6.7s: approve (0 critical, 0 important, 0 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.

@eowca
eowca marked this pull request as ready for review November 26, 2026 12:17
@eowca
eowca marked this pull request as draft November 26, 2026 12:19
Architecture-Review: unchanged; keep the separately documented PR body lock and main’s GitHub timestamp handling.
Co-Authored-By: Codex <noreply@openai.com>
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Conflict-only refresh after #1841 at f5ba6c08: keep this PR’s contextmanager import and main’s removal of UTC/datetime. The original delta-approved change is unchanged. The size gate still reports +17 source / +19 test lines, and all 11 affected focused tests passed.

@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 f5ba6c08fc78d72d57fd64873785a64a0980d8e9, 8.7s: approve (0 critical, 0 important, 0 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.

@eowca
eowca marked this pull request as ready for review November 26, 2026 12:26
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

❌ Left the queue · checks failed

2 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 12:27 · rule main · triggered by @eowca with the @mergifyio queue command
  • ❌ Checks failed · draft #1882
  • 🚫 Left the queue 12:29 · f5ba6c0

Not proven to be this pull request's failure. It failed on top of the pull requests ahead of it, and was not tested alone.

Reason

The merge conditions cannot be satisfied due to failing checks

  • checks

Failing checks:

To get back in the queue

  • If the failure comes from the pull requests it was tested with, or is a flake, comment @mergifyio queue to queue it again as it is.
  • If it is this pull request's, push a fix: the pull request is queued again once its queue conditions match.

Merge conditions not met when it left the queue

  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-neutral = checks
    • check-skipped = checks
    • check-success = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility
    • check-success = Loop-zero Eligibility
1 merge condition met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify mergify Bot added dequeued and removed queued labels Nov 26, 2026
@eowca
eowca marked this pull request as draft November 26, 2026 12:33
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Parked at approved head f5ba6c08 for test headroom. The fresh slotted check and all eight hosted source checks passed. Mergify candidate #1882 failed the test-line gate at 13,868/13,850 when stacked behind #1860 and #1565. Both predecessors have now merged. Verified integration with current origin/main 9f055936 is conflict-free, at 8,092/8,250 source lines and 13,868/13,850 test lines. Main is at 8,075 source and 13,849 test lines. This head needs at least 18 test lines freed before it can re-enter the queue.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

The test cap has room after #1885 and #1886. A merge-tree against ac55b163 still finds two conflicts in cli.py introduced by #1876. This PR already used its primary, ordinary delta, and conflict-only delta at f5ba6c08, so it remains parked at that approved head pending a fresh replacement with review coverage.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Closed by Lean ruling (26 Nov): four-file conflict with main and no review round left. #1371 is rescoped: a fresh minimal replacement reuses github.pr_lock (from #1451) and preserves the #1866 worktree lock. Branch kept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve PR sections when Loop Zero updates them from separate checkouts

1 participant