Skip to content

Review pushed branches side by side, not one after another - #172

Open
ammartahamohamedy wants to merge 2 commits into
prooflinedev:mainfrom
ammar-taha-dev:fix/pre-push-concurrent-reviews
Open

ammartahamohamedy wants to merge 2 commits into
prooflinedev:mainfrom
ammar-taha-dev:fix/pre-push-concurrent-reviews

Conversation

@ammartahamohamedy

Copy link
Copy Markdown

Fixes #171

Problem

hook run pre-push requested a branch's review, polled it until it finished or the hook's deadline passed, and only then requested the next branch, looking the repository up again each time. A push therefore took the sum of its reviews plus each one's poll lag. With longer reviews, a later branch could be reported "still running" only because an earlier one had used the shared deadline. The progress line (Review is RUNNING; checking again in N seconds.) didn't say which branch it meant.

Fix (src/hooks.rs)

  • run now finishes every branch's local checks before the first upload; they used to alternate. It still connects once, and only if something needs a review.
  • review runs one future per branch: upload the patch, then poll its review. A tokio::sync::Mutex is held only for the upload, so uploads still go one at a time and in Git's order, and each accepted review is read at once, while later branches upload.
  • request looks the repository up once per push; the mutex holds its ID. A failed lookup is retried for the next branch, as before.
  • wait reads one review the way read_review does (the same poll_until and read_review_once, so the same schedule and deadline rules), and names the branch on each progress line: Review of feature is RUNNING; checking again in 20 seconds. read_review itself is unchanged.
  • join_all is a small helper that polls the branches' futures together on the current task. The runtime is single-threaded, JoinSet::spawn needs 'static futures, and the crate has no futures dependency.
  • Unchanged: at most three branches, one POST per branch (never retried), the shared deadline and its rules, the local preflight before each upload, the report order and the exit policy. For one branch or pre-commit, the only change is the progress line naming its subject.

Measurements (Windows 11, release builds of fecf6c6 and this branch)

Live, against proofline.sh: the same three-branch push with fresh patches, one run of each build back to back. Each review finished about 3 s after it was requested. An earlier fecf6c6 run took 20.92 s.

Hook time Progress lines
fecf6c6 23.48 s three identical Review is PENDING; …
this branch 9.16 s Review of live-a is PENDING; …, … live-b …, … live-c …

Stand-in console: each review completes after the given time; 300 s default timeout; median of 3 runs.

Branches × review time fecf6c6 This branch
3 × 3 s 15.29 s 5.27 s
2 × 30 s 70.26 s 35.27 s
3 × 60 s 225.33 s 75.30 s
2 × 140 s 300.11 s, second branch still running 195.26 s, both reviewed
1 × 5 s 5.18 s 5.19 s
1 × 30 s 35.19 s 35.19 s

One-branch client time, against an instant stand-in (medians of 100 runs per build, alternating): pre-push 168.9 ms before, 166.3 ms after; pre-commit 292.2 ms before, 289.6 ms after. No measurable change.

Tests (written first)

Test What it checks
a_push_requests_every_branch_before_any_review_finishes (new, tests/hooks.rs) The stand-in keeps each review RUNNING until both branches have been requested, and the timeout is 8 s. Both branches are reported COMPLETED, none "still running", and the repository is looked up once
progress_lines_name_the_branch_they_are_about (new) Each review completes 1 s after its request. Every progress line starts with Review of feature or Review of main, and both appear
a_slow_later_upload_does_not_hide_an_earlier_finding (new, from the fork review) The first review is complete with a SERIOUS finding, the second upload takes 3.5 s, each read takes 2 s and the timeout is 5 s. With mode=block and onIncomplete=warn the push is blocked, the first read starts before the second upload ends, and the uploads don't overlap

The first two fail on fecf6c6. The third passes there and fails on this PR's first version, which let the push through.

Mutation checks: looking the repository up for every branch, an unnamed progress line, holding the mutex through the wait, and overlapping uploads each fail a test.

Checks

  • cargo fmt --check: ✅
  • cargo clippy --locked --all-targets -- -D warnings: clean on Linux. On Windows, --all-targets stops at the 2 errors main already has (src/agent/tests.rs); the lib, the bins and tests/hooks.rs are clean.
  • cargo test --locked --no-fail-fast:
    • Linux: everything passes except setup_brief_commands_are_available_in_this_release, which fails on main too.
    • Windows: the same 13 failures as fecf6c6, checked side by side (tests/mcp.rs ×7, agent_install ×2, update, local_patch, the hooks push-URL test, and the same setup test), and none in this change.
  • cargo deny check: no dependency changes.
  • Fork CI: ✅ check (Linux) and windows pass on ammar-taha-dev/proofline-cli#11 at 15667f0.

Overlaps:

Proofline review log

Fork review PR: ammar-taha-dev/proofline-cli#11. Rounds capped at 2.

Round Finding What I made of it Outcome
1 Serious: a later upload can make a multi-branch push miss a blocking finding Right, and a regression: the first version read nothing until every upload had finished, so an earlier review's first read could be cut off by the deadline Fixed: each review is read as soon as it is accepted. The new test reproduced the missed finding first
1 Warning: later uploads can push earlier reads past the hook deadline Right for reads delayed by later uploads, which was new here Fixed by the same change. Not changed: a review accepted after the deadline still gets one read not capped by it, which is read_review's documented rule and what main does
2 (15667f0) Warning: a later branch's first read can start just before the shared deadline and be cut off, where main could have given it one full read after the deadline Correct, but narrow: the upload has to be accepted within one read's latency of the deadline, and the review has to be complete already (in practice, an identical patch reviewed earlier). main has the same cutoff whenever an upload lands just before the deadline Not changed: it follows poll_until's documented rule that a read still pending at the deadline is dropped. Letting a first read outlive the deadline would be a separate policy change

The prompts below are the ones that drove this implementation; the benchmark, the reproduction, the fix scope and the assessment of the fork review were done outside them and aren't included.

This branch has not been deployed

No deployments
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.

A pre-push hook waits out each branch's review before requesting the next, so a stacked push takes the sum of its reviews

1 participant