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

A check that replaces a waiting one keeps its place in line: main's own check… #17240

opened this in answer to

Merged 37h 21m ago, live in production

A check that replaces a waiting one now takes the older check's createdAt, so main's check keeps its place in line across landings. I did not run the full suite, and I did not run scripts/design-lint.ts, since no page changed. What changed CreateRunInput in src/core/runs.ts takes an optional createdAt.

Notes

opened this

A check that replaces a waiting one now takes the older check's createdAt, so main's check keeps its place in line across landings. I did not run the full suite, and I did not run scripts/design-lint.ts, since no page changed.

What changed

  • CreateRunInput in src/core/runs.ts takes an optional createdAt. createRun writes it with COALESCE(?16, strftime(...)), so the table's default still applies when none is given.
  • In src/checks/request.ts, the transaction records the earliest createdAt among the queued runs it cancels and passes it to the new run. A running check it stops passes nothing on, because that check already had its turn. Ties still break by id, as pickNext does.
  • I changed no budget, STARVATION_MS, CREW_WAIT_CAP_MS, LAND_SETTLE_MS or concurrency.

Tests

  • The new test/check-supersede-keeps-place.test.ts covers your three cases against a real request. For the first two it uses a stub lane with a real app and repository.
  • Run with the source change stashed, the first (main keeps R1's createdAt) and third (pickOrder puts R2 before P2) tests fail. With the change, all three pass.
  • The second test (a stopped running check hands nothing on) passes either way, since it asserts the old behaviour is kept.
  • test/checks-queue.test.ts and test/checks.test.ts pass, and tsc --noEmit is clean.

Not done, and checks

  • There is no terminal or docs/features change. The change is queue ordering only, and the commit line says No door: ….
  • scripts/gate.ts raised no error. It noted that two test helpers resemble commit in test/check-base-moved.test.ts and olden in test/runs-lease.test.ts. I did not fold them together, because that would touch unrelated tests.
  • I did not use the keep_plan or estimate tools.

Closes #17229

Show 2 earlier items

7 earlier comments
commented

A check that replaces a waiting one now keeps the waiting one's place in line, so main's check is no longer pushed to the back each time a new commit lands (#17229).

What changed

  • In src/checks/request.ts, when a newer commit supersedes a queued check, the new check takes the earliest created_at among the checks it replaced.
  • A check that was already running had its turn, so it passes nothing on.
  • createRun in src/core/runs.ts takes an optional createdAt. Without it, the column keeps its current "now" default.
  • test/check-supersede-keeps-place.test.ts has three tests, including that the replacing check is picked before a pull check queued after the one it replaced.

Review feedback

  • I removed the no-op .replace(/\.(\d+)Z$/, ".$1Z"). It was in the test's back() helper, not in src/, and the test still passes without it.
  • tsc --noEmit is clean and the 3 tests pass. I did not run the full suite; the forge runs it on the push.

Check refusals you listed

  • Both doors: the commit says No door: internal queue ordering, since no page, action, API route or tool changed.
  • Issue number: both commits are named Direction: … (#17229).
  • as never: the test uses no as never.
  • Dead-code test: the new CreateRunInput.createdAt field has a caller in request.ts, and I added no new exports.

Not changed

  • gate.ts flags back() in the test as a duplicate of olden in test/runs-lease.test.ts. They update different columns (created_at versus heartbeat_at), so I left both.
  • The over-100-column comment in src/core/runs.ts is for the nightly rewrap.

To try it, run bun test test/check-supersede-keeps-place.test.ts.

🤖 Generated with Claude Code

commented

Reviewed: correct, and it is the fix main needs right now. In the last five minutes main's check was superseded unstarted three times (6896d92 at 22:18:56, 0c2f468 at 22:18:59, 8192e6e at 22:20:42), each replacement going to the back of the line; 7e3dfba's is queued behind about ten pull checks now. Two readers of created_at I checked on main: silenceUnstartedChecks only fires after the runner has been idle 10 minutes, so an inherited age can only settle a check the runner was already not answering (no new risk); and pickOrder's starvation boost is exactly what should carry main's check forward. Land this as soon as its own check passes.

commented

The reviewer's latest comment asks for no code change, so I made none. The branch is already pushed at fb6300e9a, and its check will run against that commit.

What this pull does

  • A check that replaces a waiting one takes the earliest created_at among the checks it replaced (src/checks/request.ts).
  • createRun takes an optional createdAt (src/core/runs.ts). When it is absent, the column keeps the "now" default.
  • A check that was already running passes nothing on.
  • test/check-supersede-keeps-place.test.ts has three tests, including that the replacing check is picked ahead of a pull check queued after the one it replaced.

Readers of created_at

  • I did not re-check these myself. I'm relying on your reading of silenceUnstartedChecks and pickOrder's starvation boost.
  • My earlier read was that checksForHead and the verdict order by id, so they are untouched.

Check refusals you listed

  • Both doors: the commits say No door: …, since no page, action, API route or tool changed.
  • Issue number: both commits are named Direction: … (#17229).
  • as never: the test uses none.
  • Dead-code test: I added no new exports. The one new field, CreateRunInput.createdAt, is used in request.ts.

bun x tsc --noEmit is clean and the three new tests pass. I did not run the full suite, because the forge runs it on the push.

gate.ts flags back() in the test as a duplicate of olden in test/runs-lease.test.ts. They update different columns (created_at versus heartbeat_at), so I left both.

To try it, run bun test test/check-supersede-keeps-place.test.ts.

🤖 Generated with Claude Code

commented

A check that replaces a waiting one now takes over that check's place in line. The new test file and the type check pass. I didn't run the rest of the suite, and the forge's check runs it on the push. The gate has no failures and two notes: a long comment in src/core/runs.ts, and two small test helpers that look like ones in other test files. I left both.

  • Ordering: CreateRunInput in src/core/runs.ts takes an optional createdAt. createRun writes it when given and uses the table's default otherwise.
  • Supersede: in request (src/checks/request.ts), when the transaction cancels a run that was still queued, the new run inherits the earliest such createdAt. A check that was already running passes nothing on, so a replacement for it goes to the back as before.
  • Tests: test/check-supersede-keeps-place.test.ts covers the replacement keeping the cancelled check's createdAt, and a running check passing nothing on.
  • Check findings: the four findings you listed are met, and each commit line is named Direction: … (#17229). The change is internal ordering, with no page, action, route or tool, so no terminal or how-to change was needed.
  • Not changed: no budget, knob, limit or concurrency change, and no change to pickNext.

To try it, run bun test test/check-supersede-keeps-place.test.ts.

commented

@mason The check on fb6300e (run 01m8stwhwasg59b4cxmyyf41yn) failed 4 of 28,849, all git-heavy fork tests at bun's 5 s budget: "the last ten follows, newest first…", "fork flows > the MCP tool answers the same data", "a repeat on the same two heads does not run the comparison again". None of them touch createRun's new createdAt or request's supersede. The same follow-history test failed on #17161's check at 22:48 and on #17221, #17177 and #17226 before it (load flake, fixed for that one test by #17260). The runner had 11% disk free.

Please run this check again as it stands, with no new push, and land fb6300e when it passes. It is the one that lets main's own check start, and pulls that are red only on lane flakes wait for main's next green check, so everything held that way waits on this pull.

commented

No code change and no push. Re-running the check and landing the pull are both outside what I can do. I can't trigger a check run, and a person merges.

The branch is at fb6300e. I rebased it onto main while investigating, then reset it to fb6300e. A rebase would have rewritten the commit, and a plain push of a rewritten branch would be rejected as a force push.

Cause. The four failures are not caused by this pull's change (createRun's new createdAt and the supersede path in request). The failing tests are git-heavy fork tests: the last-ten-follows history test, "fork flows > the MCP tool answers the same data", and "a repeat on the same two heads does not run the comparison again". They hit bun's 5 s limit while the runner was loaded, as you described.

What I ran locally. The new test test/check-supersede-keeps-place.test.ts and the three fork test files (fork-flows, fork-follow-history, upstream-counts) pass when run alone. Running those four files together twice, the follow-history test failed once with toBe mismatching and passed once. So it is a load flake, as you said, and I haven't touched it.

What this pull does. A check that replaces a waiting check for the same repo and environment now takes over the replaced check's created_at, so it keeps its place in line. A check that was already running had its turn, so its replacement goes to the back as before. The test covers this.

Needed from a person. Re-run the check on fb6300e as it stands, then merge it once it is green.

No page, action, API route or tool changed.

commented

This pull's only check on fb6300e failed at 22:51, and nothing has re-run it since (the pulls list's "green" is the list bug #17265 fixes). Two of its four reds are fixed now: #17260 landed at 23:04 and splits the follow-history test, and #17269 (for #17268, the /mcp lazy load) is queued. None of the four touch this diff. Please re-run the check on fb6300e as is, with no push, and land it when it is green. Main's own check is still waiting in line behind pull checks (queued since 23:15), which is the problem this pull fixes.

commented

Re-running the check on fb6300e is not something I can do from here, and I made no push. I can't trigger a check, and a person lands the pull. The branch is still at fb6300e, which has no code change since the failed run.

I also looked at the four things the check refuses most often. None of them applies to this diff:

  • Both doors: the pull changes no page, action, API route or tool. The commit line says No door: internal queue ordering; no page, action, API route or tool changes.
  • Tests building the real input: the new test test/check-supersede-keeps-place.test.ts doesn't use as never.
  • Dead-code test: this pull adds no new export. It adds an optional createdAt field to the existing CreateRunInput, and request uses it.
  • Issue number in the commit line: both commits carry (#17229) in the Direction: form.

The pull description follows.

What changed. A check that replaces a waiting check for the same repo and environment now takes over the replaced check's created_at. It keeps its place in line instead of going to the back, which stops pull checks starving main's own check.

  • src/checks/request.ts records the earliest createdAt among the queued checks it supersedes.
  • src/core/runs.ts lets createRun accept an optional createdAt. Without one it still uses the database default.
  • A check that was already running had its turn, so its replacement queues at the back as before.
  • test/check-supersede-keeps-place.test.ts covers both cases.

What I chose not to do. I did not touch the fork-follow-history, MCP or upstream-counts tests that failed on fb6300e. They are git-heavy fork tests that hit the 5 s limit under load. Locally they pass alone, and the follow-history one failed once in two runs of the four files together. Neither #17260 nor #17269 touches this diff.

How to try it. Run bun test test/check-supersede-keeps-place.test.ts. Queue a check, push a newer commit while it waits, and the new run keeps the old one's created_at. A person needs to re-run the check on fb6300e as it stands and land the pull once it is green.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs