Skip to content

Serialize updates to the pull request body - #1230

Merged
mergify[bot] merged 4 commits into
mainfrom
lean178/1003-preserve-pr-body-replacement
Nov 26, 2026
Merged

mergify[bot] merged 4 commits into
mainfrom
lean178/1003-preserve-pr-body-replacement

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Preserve review summaries when check refreshes a PR

Context and goal

  • Goal: Concurrent local PR updates preserve review summaries, checks, and unrelated prose.
  • Problem: Two writers can read the same old body and the last write erases sections written by the first.
  • Context: GitHub replaces the whole PR body on each update.

Closes #1003

Acceptance

  • Local check, review, and PR refreshes read the body inside the same lock used for the corresponding update.
  • A delayed check retains both the newly written review summary and unrelated body text.

Notes

Use the existing task state directory for the lock. Keep check execution, reviewer dispatch, and Git push outside the lock.

Supersedes #1099 and carries its reviewed diff plus the conflict resolution tested at e935bf9.

Base

main @ e2a56e2


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

Review

Carry forward the reviewed change and tested merge resolution from #1099.

Co-Authored-By: Codex <noreply@openai.com>
@eowca
eowca marked this pull request as draft November 26, 2026 00:38

@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 15878aeec12be040edd0b4195a54a474c95c5249, 37.3s: 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 tests/test_cli.py
assert text in updated


def test_delayed_check_preserves_review_summary(wt, gh, fake_bin, capsys, monkeypatch):

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: Regression test checks the stale-read fix but not the lock

test_delayed_check_preserves_review_summary runs review inside the patched _update_pr_checks, before the real function takes the lock. It fails on the old code, because the old code wrote back the stale pr.body read before the update. But the new code would still pass this test if the _lock_task_state call were removed from _update_pr_checks, cmd_pr or cmd_review. The fix here comes from reading the body again just before writing, so nothing tests the serialization guarantee. Smallest fix: add a test that holds _lock_task_state(wt) (or patches fcntl.flock to record calls) and asserts that each writer's pr_view/pr_for_branch read and its update_body both happen while the lock is held.

Comment thread docs/ARCHITECTURE.md
reviews, finding threads, check statuses and merge state. CI and branch protection
reviews, finding threads, check statuses and merge state. Within a task worktree,
PR body writers lock the state directory from the live read through the update.
CI and branch protection

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: Paragraph has an awkward line break

The new sentence leaves 'CI and branch protection' alone on a short line, with 'provide the hosted enforcement' on the next line. Reflow the paragraph so the Markdown source reads normally.

Carry the already-landed receipt rendering change from #1160 into the delta. Keep the check lookup and write under the shared lock and render from the freshly read PR when publishing.

Architecture-Review: unchanged; receipt verification and serialized body updates retain their documented behavior.
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 3f5a27cba2113a4fa6ccca16044f065134aa54cd, 41.3s: approve (0 critical, 0 important, 3 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 tests/test_cli.py
body = "# PR\n\n## Notes\nHuman evidence.\n"
gh.respond_pr_list([pr_json(headRefOid=head, body=body)])
git(wt, "push", "-q", "-u", "origin", "lz/t1")
refresh = cli._refresh_pr_checks

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: Delayed-check test no longer exercises a stale read

The test now wraps _refresh_pr_checks and runs review to completion before calling the real refresh. Because of that, the refresh's pr_for_branch read always happens after the review summary has been written. The test would also pass on the pre-#1003 code, which had no lock and read the body in the same place, so it doesn't show that the lock prevents a lost update. The old version injected the delay after the PR snapshot was taken. With the read now inside flock, running review in-process at that point would deadlock, because each call to _lock_task_state opens a new file description. Smallest fix: keep this test as an ordering smoke test. Separately, add a test that holds _lock_task_state from a thread or subprocess and checks that _refresh_existing_pr_checks doesn't call pr_for_branch until the lock is released. Another option is to assert that github.pr_for_branch is called while the lock is held.

Comment thread src/loopzero/cli.py
if loaded is None:
return "(no `loopzero check` run recorded)"
recorded, results = loaded.head, loaded.results
lines = [f"Recorded for `{recorded[:12]}`" + ("" if recorded == head else " (not current head)")]

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: Stale-head receipts get two annotations

_check_report_matches already requires report.head == head. So a receipt for an older head gets both suffixes: "Recorded for abc… (not current head) (unverified, run loopzero check)". Fix: add "unverified" only when recorded == head, or merge both into a single suffix.

Comment thread src/loopzero/cli.py

def cmd_pr(args: argparse.Namespace) -> int:
wt, config = _context(args)
wt, config = _context(args, pin_checks=True)

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: Receipt-verification and check-pinning changes are outside this task's scope

The task is about serializing PR body updates under the task-state lock. This delta also changes how cmd_pr behaves for users. It switches to pin_checks=True, which can print "checks are unpinned because --config was provided" and reads the base workflow. It also adds an "unverified" marker to the generated Validation block. Both changes look reasonable, but they aren't in the acceptance criteria or the PR description, which makes the change harder to review and to revert. Fix: list them in the PR body, or move them to their own PR. Also, github.PR.body is always a str (github.py:101, :537), so the new pr.body or "" guards at lines 530, 676 and 696 do nothing. Line 697 still uses live.body.replace without the guard, so the code is inconsistent. Remove the guards.

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

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Owner queue route: the full sandboxed check passed on 65ef54ea using the installed b0ab7dd CLI. The local settings guard rejected the receipt fingerprint outside the runner. Required hosted checks and the inherited delta approval are green. Mergify will verify the integration candidate.

@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, less than a minute of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 01:12 · rule main · triggered by @eowca with the @mergifyio queue command
  • ❌ Checks failed · draft #1273
  • 🚫 Left the queue 01:13 · 65ef54e

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
2 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@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 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Mergify candidate #1273 failed the source size budget at 7,514 lines against the 7,500 cap. The exact source head passed the installed b0ab7dd check and both required hosted checks. The current clean integration tree still measures 7,514 source lines. Requeue after the owner-approved cap update in #1272 lands.

@mergify mergify Bot removed the dequeued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Owner queue route: e48e7d0d is a clean merge of main onto the previously checked head. Its fresh full sandboxed check passed under the 8,250-line cap. The local receipt guard still rejects the slot receipt. Both required hosted checks are green, so requeueing for Mergify’s integration proof.

@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

✅ Merged into main as 92e4695 at 02:00 UTC

5 min in the queue, 5 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 01:55 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1354
  • ✅ Merged 02:00 · 92e4695 · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 26, 2026
@mergify
mergify Bot merged commit 92e4695 into main Nov 26, 2026
7 checks passed
@mergify mergify Bot removed the queued label 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.

Preserve PR sections during overlapping Loop Zero updates

1 participant