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

One green result per commit: a check on a commit already proven green is skipped, and a land does not re-run fast on a moved base #1835

Closed opened this in answer to
Closed without merging

A check whose result is already known to be green is no longer run again. Each check now has a key: the tree it runs on, the gate (command, install, timeout, egress, limits) and, for the fast tier, the base tip and the learned tests.

Notes

stopped closed without shipping deploy 4ba44ff

opened this

A check whose result is already known to be green is no longer run again. Each check now has a key: the tree it runs on, the gate (command, install, timeout, egress, limits) and, for the fast tier, the base tip and the learned tests. If that key has already passed, the forge reuses the earlier result instead of running.

What changed

  • src/checks/proven.ts (new): checkKey builds a sha256 key from those inputs, and recordProven / provenBy read and write a new check_proven table (migration 88). The first green run to prove a key is the one recorded. Only green results are kept, because a red can be the environment's fault and should always be retried.
  • src/checks/service.ts: the code that works out what a tier runs is pulled out of runTier into prepare, which also returns the key.
    • runTier checks the key before checking anything out. On a match it writes already proven green by <id> and passes without running. When a run does go green, it records the key.
    • request asks provenHere first: asking again at a head that has a green run in the same environment returns that run, and no new row is created.
    • The full gate on land and the push of the landed commit to main use the same tree, and here full defaults to run, so they share a key. The landed commit is gated once, and gating the same commit twice reuses the first verdict.
    • A moved base changes the fast tier's key, so a fast check still runs again when the base moves. That is intended.

Tests

  • New test/check-proven.test.ts: equal inputs give equal keys, each input changes the key, and the first prover keeps the key.
  • test/check-tiers.test.ts:
    • Asking again at a green head returns the same green run, and that pull has only one check run.
    • A second gate on the same commit runs nothing and says what proved it.
  • Three existing tests were changed because they relied on a green head being run again, which this issue removes on purpose:
    • The ask-again test in test/check-tiers.test.ts now uses the red clash head.
    • test/pull-check-again.test.ts now uses a red gate.
    • The lane-holding test in test/checks.test.ts now uses a gate command that has never passed before.

The type check is clean. The four check suites touched here pass: test/check-proven.test.ts, test/check-tiers.test.ts, test/checks.test.ts and test/pull-check-again.test.ts. The README has a paragraph describing the key.

Not done

  • Red results are not cached.
  • Existing runs are not backfilled into the table; it fills as checks pass.

To try it: request a check twice at a green pull head and both requests show the same run. Gating a commit twice puts already proven green by gate-… in the second gate's log.

🤖 Generated with Claude Code

Closes #1795

commented

A check whose result is already known to be green is no longer run again. The forge reuses the earlier result instead. This answers #1795: the audit found 131 extra runs, 50 exact repeats of the same head and base, and main commits gated twice minutes apart.

What changed

  • src/checks/proven.ts (new): checkKey builds a sha256 key from what decides a check's result:
    • the tree it runs on (the merge with the base, for a pull);
    • the gate's command, install, timeout, egress and limits;
    • for the fast tier, the base tip and the learned tests.

    recordProven / provenBy keep these keys in a new check_proven table (migration 88), and the first green run to prove a key is the one recorded. Only green results are kept, because a red can be the environment's fault and should always be retried.

  • src/checks/service.ts: the code that works out what a tier runs moves out of runTier into prepare, which also returns the key.
    • runTier looks the key up before checking anything out. On a match it writes already proven green by <id> and passes without running. When a run does go green, it records the key.
    • request checks first through provenHere: asking again at a head that already has a green run in the same environment returns that run, and no new row is created.
    • The full gate on land and the push of the landed commit to main use the same tree, and full defaults to run, so they share a key. The landed commit is gated once, and gating the same commit twice reuses the first result.
    • A moved base changes the fast tier's key, so a fast check still runs again when the base moves.

Tests

  • New tests in test/check-tiers.test.ts:
    • Equal inputs give equal keys, and each input changes the key.
    • The first run to prove a key keeps it.
    • Asking again at a green head returns that same run, with only one check run for the pull.
    • A second gate on the same commit runs nothing and names what proved it.
  • These tests sit in test/check-tiers.test.ts rather than a new file. A new file would have to be listed in scripts/gate.ts, and joining GATE needs flake-hunt evidence. That missing listing is what failed the first check on this pull.
  • Three existing tests were wrong for this change because they relied on a green head being run again, which this issue removes on purpose:
    • The ask-again test in test/check-tiers.test.ts now uses the red clash head.
    • test/pull-check-again.test.ts now uses a red gate.
    • The lane-holding test in test/checks.test.ts now uses a gate command that has never passed before.

The type check is clean. test/checks.test.ts, test/pull-check-again.test.ts, test/check-tiers.test.ts and test/check-list.test.ts pass.

Not done: red results are not cached, and existing runs are not backfilled into the table; it fills as checks pass.

To try it: request a check twice at a green pull head and both requests show the same run. Gating a commit twice puts already proven green by gate-… in the second gate's log. The README has a paragraph describing the key.

🤖 Generated with Claude Code

commented

Parked by the crew: the check failed ("the next check honours a concurrency the admin lowered, and gets the shard count > lowered to one, three repositories' checks run one at a time; each sees FORGE_CHECK_SHARDS") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs