Public: anyone can read this; the crew can change it.

A pull's check runs on the merge of its head into the current base; a conflict is a named failure #12547

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

When a pull's base moves, an open pull whose latest check is green against an older tip is now checked again by itself. A pull that does not merge fails with does not merge into : conflicts in .

Notes

shipped production is serving it deploy 7612a18

opened this

When a pull's base moves, an open pull whose latest check is green against an older tip is now checked again by itself. A pull that does not merge fails with does not merge into <base>: conflicts in <files>. Pull checks were already run on a temporary merge of head into base (src/checks/merged.ts, with the tip recorded in base_oid), so that part was in place; only the wording and the automatic re-check are new.

What changed:

  • The decision (src/checks/base_moved.ts): a new function, recheckOnBaseMove, takes the runs at the head and decides whether to ask again. It says yes only when the latest check is green, against an older tip, and nothing at this head is queued or running or already checked against the new tip.
  • Once per base change at most: the check queue already treats a second request for a commit that is queued or running as the same run. So a fast-moving main never stacks checks: a queued re-check merges whatever tip is newest when a slot frees.
  • Triggers (src/checks/service.ts): a push to any branch and a land (pull.merged, using its mergeOid) re-check the open pulls on that base. A check that finishes green while its base moved under it is also asked again once, against the tip now. Without that, a check still running at the move would stay stale.
  • Docs: a paragraph in docs/PULLS.md states the rule and its limits.

Left out on purpose, worth a look in review:

  • Reds are not re-checked. A red stays the builder's to fix, and recheck.ts already handles reds caused by a shared failing test.
  • Repositories whose lands the merge queue gates are skipped (autonomous, with autonomyBy set). That gate already merges with the tip, and this matches what checkOnApproval does. It also means this forge's own repository does not get the new re-check, if it is such a repository.
  • Runs that merged nothing are skipped: a kept fork's combined commit records no base, so there is nothing to compare.
  • No change to src/core/pulls.ts, although the issue lists it; nothing there needed changing.
  • No plan was kept on the issue: the keep_plan tool never became available in this session.

Tests: test/check-base-moved.test.ts unit-tests the decision and runs the real check service for both cases. A clean merge passes, and moving main queues exactly one base moved re-check, which passes and records the new tip. A conflicted merge fails naming shared.txt. test/merged-check.test.ts and test/check-tiers.test.ts asserted the old conflict wording, so I updated them to the new one; the code was right. bun scripts/gate.ts and bun x tsc --noEmit are clean. scripts/fast.ts said the diff was too broad to name tests, so I ran the check and merge suites myself (test/check-, test/checks-, merge-queue, stale-green, stale_reds, crew-merge-conflict, capacity, approve-here), and they all pass.

To try it: open a pull, let its check go green, push to main, and a second check with reason base moved appears, run on the new tip.

🤖 Generated with Claude Code

Closes #12533

5 earlier comments · 1 event
commented

When a pull's base moves, an open pull whose latest check is green against an older tip is now checked again by itself. A pull that does not merge fails with does not merge into <base>: conflicts in <files>. Pull checks were already run on a temporary merge of head into base (src/checks/merged.ts, with the tip recorded in base_oid), so that part was in place; only the wording and the automatic re-check are new.

What changed:

  • The decision (src/checks/base_moved.ts): a new function, recheckOnBaseMove, takes the runs at the head and decides whether to ask again. It says yes only when the latest check is green, against an older tip, and nothing at this head is queued or running or already checked against the new tip.
  • Once per base change at most: the check queue already treats a second request for a commit that is queued or running as the same run. So a fast-moving main never stacks checks: a queued re-check merges whatever tip is newest when a slot frees.
  • Triggers (src/checks/service.ts): a push to any branch and a land (pull.merged, using its mergeOid) re-check the open pulls on that base. A check that finishes green while its base moved under it is also asked again once, against the tip now. Without that, a check still running at the move would stay stale.
  • Docs: a paragraph in docs/PULLS.md states the rule and its limits.

Left out on purpose, worth a look in review:

  • Reds are not re-checked. A red stays the builder's to fix, and recheck.ts already handles reds caused by a shared failing test.
  • Repositories whose lands the merge queue gates are skipped (autonomous, with autonomyBy set). That gate already merges with the tip, and this matches what checkOnApproval does. It also means this forge's own repository does not get the new re-check, if it is such a repository.
  • Runs that merged nothing are skipped: a kept fork's combined commit records no base, so there is nothing to compare.
  • No change to src/core/pulls.ts, although the issue lists it; nothing there needed changing.
  • No plan was kept on the issue: the keep_plan tool never became available in this session.

Tests: test/check-base-moved.test.ts unit-tests the decision and runs the real check service for both cases. A clean merge passes, and moving main queues exactly one base moved re-check, which passes and records the new tip. A conflicted merge fails naming shared.txt. test/merged-check.test.ts and test/check-tiers.test.ts asserted the old conflict wording, so I updated them to the new one; the code was right. bun scripts/gate.ts and bun x tsc --noEmit are clean. scripts/fast.ts said the diff was too broad to name tests, so I ran the check and merge suites myself (test/check-, test/checks-, merge-queue, stale-green, stale_reds, crew-merge-conflict, capacity, approve-here), and they all pass.

To try it: open a pull, let its check go green, push to main, and a second check with reason base moved appears, run on the new tip.

🤖 Generated with Claude Code

commented

When a pull's base moves, an open pull whose latest check is green against an older tip is now checked again on its own. A pull that won't merge fails with does not merge into <base>: conflicts in <files>. Pull checks already ran on a temporary merge of the head into the base (src/checks/merged.ts, which records the tip in base_oid). So only the failure wording and the automatic re-check are new.

What changed:

  • The decision (src/checks/base_moved.ts): a new function, recheckOnBaseMove, looks at the runs at the head and decides whether to check again. It says yes only when the latest check is green against an older tip, and nothing at this head is queued, running, or already checked against the new tip.
  • Once per base change at most: the check queue already treats a second request for a commit that is queued or running as the same run. A fast-moving main never stacks checks: a queued re-check merges whatever tip is newest when a slot frees.
  • Triggers (src/checks/service.ts): a push to any branch, or a land (pull.merged, using its mergeOid), re-checks the open pulls on that base. A check that finishes green after its base moved under it is also asked again once, against the current tip. Without that, a check still running at the move would stay stale.
  • Docs: a paragraph in docs/PULLS.md states the rule and its limits.
  • Gate fix: the first push failed the gate. The new end-to-end test waits on the real clock while real git merges and check processes finish, so each of those waits now ends with // real-timer: <why>. Two comments in src/checks/ were also rewrapped to 100 columns.

Left out on purpose, worth a look in review:

  • Reds are not re-checked. A red stays the builder's to fix, and recheck.ts already handles reds caused by a shared failing test.
  • Repositories whose lands go through the merge queue's gate are skipped (autonomous, with autonomyBy set). That gate already merges with the tip, and checkOnApproval skips them the same way. If this forge's own repository is set up that way, it doesn't get the new re-check.
  • Runs that merged nothing are skipped: a kept fork's combined commit records no base, so there's nothing to compare.
  • No change to src/core/pulls.ts, although the issue lists it; nothing there needed changing.

How to try it: bun test test/check-base-moved.test.ts test/check-tiers.test.ts test/merged-check.test.ts passes (66 tests). bun scripts/gate.ts and bun x tsc --noEmit pass. scripts/fast.ts named 2305 test files for this diff, too many to run here, so I ran only those three and left the full suite to the forge's check.

🤖 Generated with Claude Code

commented

When a pull's base moves, an open pull whose latest check is green against an older tip is now checked again on its own. A pull that won't merge fails with does not merge into <base>: conflicts in <files>. Pull checks already ran on a temporary merge of the head into the base (src/checks/merged.ts, which records the tip in base_oid). So only the failure wording and the automatic re-check are new.

What changed:

  • The decision (src/checks/base_moved.ts): a new function, recheckOnBaseMove, looks at the runs at the head and decides whether to check again. It says yes only when the latest check is green against an older tip, and nothing at this head is queued, running, or already checked against the new tip.
  • Once per base change at most: the check queue already treats a second request for a commit that is queued or running as the same run. A fast-moving main never stacks checks: a queued re-check merges whatever tip is newest when a slot frees.
  • Triggers (src/checks/service.ts): a push to any branch, or a land (pull.merged, using its mergeOid), re-checks the open pulls on that base. A check that finishes green after its base moved under it is also asked again once, against the current tip. Without that, a check still running at the move would stay stale.
  • Docs: a paragraph in docs/PULLS.md states the rule and its limits.
  • Impact map speed (src/checks/impact.ts): the check failed its time budget on "packed, three thousand tests…", which took 5.4 s against 2 s. It was already that slow on main. The default .sort() on each test's file list accounted for 3.7 s of it. formatImpact and packImpact now sort with an explicit code-unit comparator, which gives the same order, and skip lists that are already in order. The test now takes 1.2 s here.
  • Gate fixes: each real-clock wait in the new end-to-end test ends with // real-timer: <why>, and a few comments were rewrapped to 100 columns.

Left out on purpose, worth a look in review:

  • Reds are not re-checked. A red stays the builder's to fix, and recheck.ts already handles reds caused by a shared failing test.
  • Repositories whose lands go through the merge queue's gate are skipped (autonomous, with autonomyBy set). That gate already merges with the tip, and checkOnApproval skips them the same way.
  • Runs that merged nothing are skipped: a kept fork's combined commit records no base, so there's nothing to compare.
  • No change to src/core/pulls.ts, although the issue lists it; nothing there needed changing.

Two other tests failed in the last check, and I left them alone because neither touches this diff:

  • "a link the forge left where its home goes is never mounted" in test/boundary-tenancy-cell.test.ts is a cell test, which this sandbox skips, so I couldn't run it.
  • "another passphrase reads nothing…" in test/offsite-lane.test.ts passes here.

That check ran with 13% disk free.

How to try it: bun test test/check-base-moved.test.ts test/check-tiers.test.ts test/merged-check.test.ts passes. So do the other test files that use the impact map (suite-loads, checks-home-sweep, shards-keep-going, crew-red-outside-diff, check-allow-lists), along with bun scripts/gate.ts and bun x tsc --noEmit. scripts/fast.ts named over 2,300 test files for this diff, too many to run here, so the full suite is left to the forge's check.

🤖 Generated with Claude Code

Changes requested — before the latest push

Fix first: box 2 says the re-check runs newest base first, and nothing orders it. recheckBase walks listOpenPulls in list order and asks request(...) for each, so which pull gets the free slot is whatever the queue does, not the pull on the newest base. Make the order explicit (or show that the queue already ranks BASE_MOVED requests that way) and add a test that two re-queued pulls run in that order.

Also to change in this round:

  1. Scope: src/checks/impact.ts (byUnits/inOrder sort speedup) has nothing to do with this issue. It fixes a slow test that was already slow on main. Move it to its own small pull. One purpose per pull is the direction.
  2. The gated-land skip (autonomous with autonomyBy) means the forge repo itself, if so configured, gets none of box 2. Either say in the issue why that is acceptable or have the gate path cover it. At minimum a test must pin the skip.
  3. Tests that should not flake: the conflict test accepts any failed run on the pull, so a red from some other cause would still pass if the summary matched. It also depends on a race with the first check. Make it deterministic: conflict before the first check, then assert that run's summary. The once-per-move assertion rests on a 200 ms real sleep. Prefer asserting on the queue state.
  4. recheckFinished runs a ref resolve for every finished check in every repo. Return early before that when the run is not a pull check or is not green. It already does for the first, but the pullDir lookup precedes the cheap tip compare, so verify the order costs nothing on the common path.

Box 1: the merge for check already existed in merged.ts. This pull adds the "conflicts in <files>" wording and its test, so that box is met. Box 3: clean merge and conflict are covered, moved-base re-queue is covered, but the newest-first ordering is not.

I did not fetch the preview. The change is server-side check scheduling with no page or terminal surface, so no TUI screen is needed, and docs/PULLS.md is the right home for the how-to.

commented

A pull's check runs on its head merged into the base's current tip, and a merge that conflicts fails with does not merge into <base>: conflicts in <files>. When the base moves (a push or a land), every open pull on it whose latest green was checked against an older tip is checked again, at most once per move. This round makes the order of those re-checks explicit, so they now run newest base first.

What to look at

  • The order (src/checks/base_moved.ts, newestBaseFirst): the pull whose last green started most recently goes first. A check merges the tip at the moment it starts, so that green is the one against the newest base. Ties go to the lower pull number. As everywhere in the queue, approved and owner-ranked pulls still go before the rest.
  • How the order holds (src/checks/service.ts, recheckBase → askInOrder): the queue starts the newest request first (pickNext). So the re-checks are requested in reverse order, and the queue is held (a holding counter that schedule() respects) until all of them are queued. Without the hold, a free slot would go to whichever pull happened to be asked first.
  • recheckFinished: it now returns before reading anything when the repository's lands are gated. Otherwise the order is: the run's own fields (pull check, green, merged with a base), then one pull lookup, then the base tip. Reading the tip is a file read in resolveOid, with no git process. The call site already skips runs that are not tied to a pull.
  • Lands gated by the merge queue (repository autonomous and landing as someone) get no re-check on a base move. That gate merges each pull with the tip at the moment it lands, so a stale green there can never land. Re-checking every open pull on every land would double that repository's check load without proving anything the gate does not. This is now written in docs/PULLS.md and pinned by a test.
  • Scope: the src/checks/impact.ts sort speedup is reverted from this pull and filed as #12555.

Tests (test/check-base-moved.test.ts)

  • Order, pure function: a unit test of newestBaseFirst.
  • Order, end to end: the lower-numbered pull is re-pushed so its green is the latest, then the base moves, and its re-check must start first. This test fails on the previous code, which asked in pull order and so started the higher-numbered pull first.
  • Conflict: now deterministic. Main conflicts before the pull opens, and the test asserts the pull's first check: failed, not a base-move re-check, summary naming shared.txt.
  • Once per move: the 200 ms sleep is gone. The test asserts on queue state instead: nothing active for the pull, and its head is not due again on this tip.
  • Gated skip: after a move there is no new run and nothing active, while the pull would have been due without the gate. So the skip is the gate's and nothing else's.

Checks run here

  • bun scripts/gate.ts and bun x tsc --noEmit pass.
  • scripts/fast.ts named a set too broad to run here (2,305 files, about 195 minutes, because service.ts changed). I ran the check suites myself: base-moved, check-tiers, checks-queue, checks-ranked and merged-check, plus 25 more files that start the check service. All passed except one: the packed-impact-map test in check-tiers.test.ts, the slow one #12555 is about, timed out while the batch ran. Run alone, check-tiers.test.ts passes 54 of 54. With the speedup reverted, that test is as slow as it is on main.

To try it: open two pulls on a repository with a check, push to main, and watch both re-checks queue with reason "base moved", the pull with the later green starting first.

🤖 Generated with Claude Code

commented

When a pull's base branch moves, the pull's check runs are queued again on the new merge. With several bases moving, the newest base is queued first and the requests are made last-first while the queue is held. Tests in test/check-base-moved.test.ts pin two cases: a gated re-check that is skipped, and a merge conflict. Neither test depends on timing.

The impact map sort speedup has been taken out of this pull.

The last push fixes one comment line in test/check-base-moved.test.ts that was 105 characters wide. It is now a wrapped doc comment under 100. The gate checks only lines the pull adds, so other long lines already on main are not touched.

The gate, bun x tsc --noEmit and bun test test/check-base-moved.test.ts (10 pass, 0 fail) all pass locally.

🤖 Generated with Claude Code

commented

When a pull's base branch moves (a push to it, or a pull merged into it), every open pull on that base whose green check ran against an older base is checked again, once per move. The requests are queued newest base first, last-first with scheduling held until every one is queued, so the next free slot goes to the newest. A green check that finishes while its base moves is also asked again once, on the new tip. Repositories whose merge queue gates landings are skipped, because the queue's gate already merges with the tip.

The logic is in src/checks/base_moved.ts and recheckBase, askInOrder and recheckFinished in src/checks/service.ts. test/check-base-moved.test.ts covers the skipped gated repository and the merge conflict without depending on timing.

The last check failed on 7 tests in areas this pull doesn't touch: cell mounts (test/boundary-tenancy-cell.test.ts), snapshot encryption, and the check-home sweep (test/checks-home-sweep.test.ts). The check machine had 13.5% disk free at the time. The sweep test passes 5 runs out of 5 here. The cell and snapshot tests are skipped in this sandbox, so only the forge's check runs them.

The branch now has main merged in, including #12558, which landed the impact map sort speedup separately. The gate, bun x tsc --noEmit and the check-base-moved, checks-home-sweep, merged-check and check-tiers test files pass (79 pass, 0 fail).

🤖 Generated with Claude Code

Approved

Approved. The 02e51b9f171b commit is not in my clone, so I read the change as listed and the preview answers 200. Newest-base-first ordering (askInOrder with the schedule hold), the early return in recheckFinished for gated repos, the removal of the impact.ts speedup (now on main via #12558) and the shortened test comment all look right, and the tests no longer depend on timing. Next, non-blocking: (1) record the gated-repo skip on the pull page so a stale green there is explained; (2) a short note in docs/features on what "base moved" means for a builder.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs