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

Taking updates from upstream passes the forge's own gate: the merge is judged as an update, not as one pull #13758

Merged opened this in answer to

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

Merged

An update pull ("Take updates from …", a merge commit) is now judged by the gate on its own side only. The upstream commits on its second side are no longer held to the per-pull writing rules. The tests I ran pass and the gate and tsc are clean.

Notes

shipped production is serving it deploy 59903fa

opened this

An update pull ("Take updates from …", a merge commit) is now judged by the gate on its own side only. The upstream commits on its second side are no longer held to the per-pull writing rules. The tests I ran pass and the gate and tsc are clean. I haven't seen the workshop take an update and land green, so that part is untested.

What changed

  • judgedHead in scripts/gate.ts: it returns HEAD^1 when HEAD is a two-parent merge whose subject starts with Take updates from . Otherwise it returns HEAD.
  • Rules that follow it: The Try: line, both doors, pipeline first, the added-lines rules (real timers, as never), the look note and the comment-wrap file list now judge base..judgedHead instead of base..HEAD.
  • Dependency and README-cap rules: these compare working-tree files to the base, so an update pull skips them entirely.
  • The one test: in test/stranger-three-screens.test.ts, the two real-timer lines (the 400 ms and 500 ms waits) now carry // real-timer: <why>. Only the 500 ms wait at line 84 was named in the issue. The 400 ms line would have failed the same rule next.
  • New test/gate-update-pull.test.ts: an update merge owes no Try: line and gets no real-timer finding. The same merge under another subject ("Merge upstream") is still judged whole.

Left out

  • The merge-subject match is the whole recognition. I didn't check that the second parent is on upstream's main, because the check's clone has no upstream ref to compare against. Someone could therefore put unreviewed work behind a "Take updates from" merge. The first side is still judged, and the tests and the whole-tree rules (review rules, stray tests, billing deletes, exclusions) still run on everything.
  • Migration pins are untouched.

Try: on a fork, open the "Take updates from trevato/forge" pull. Its check should pass the gate's pull rules with no Try: line, and the test files should still run.

I pushed with the "Releasing trevato/forge: production is rolling" note on the desk in mind. It doesn't touch this change.

Closes #13751

2 earlier comments · 1 event
commented

An update pull ("Take updates from …", a merge commit) is now judged by the gate on its own side only. The upstream commits on its second side are no longer held to the per-pull writing rules. The tests I ran pass and the gate and tsc are clean. I haven't seen the workshop take an update and land green, so that part is untested.

What changed

  • judgedHead in scripts/gate.ts: it returns HEAD^1 when HEAD is a two-parent merge whose subject starts with Take updates from . Otherwise it returns HEAD.
  • Rules that follow it: The Try: line, both doors, pipeline first, the added-lines rules (real timers, as never), the look note and the comment-wrap file list now judge base..judgedHead instead of base..HEAD.
  • Dependency and README-cap rules: these compare working-tree files to the base, so an update pull skips them entirely.
  • The one test: in test/stranger-three-screens.test.ts, the two real-timer lines (the 400 ms and 500 ms waits) now carry // real-timer: <why>. Only the 500 ms wait at line 84 was named in the issue. The 400 ms line would have failed the same rule next.
  • New test/gate-update-pull.test.ts: an update merge owes no Try: line and gets no real-timer finding. The same merge under another subject ("Merge upstream") is still judged whole.

Left out

  • The merge-subject match is the whole recognition. I didn't check that the second parent is on upstream's main, because the check's clone has no upstream ref to compare against. Someone could therefore put unreviewed work behind a "Take updates from" merge. The first side is still judged, and the tests and the whole-tree rules (review rules, stray tests, billing deletes, exclusions) still run on everything.
  • Migration pins are untouched.

Try: on a fork, open the "Take updates from trevato/forge" pull. Its check should pass the gate's pull rules with no Try: line, and the test files should still run.

I pushed with the "Releasing trevato/forge: production is rolling" note on the desk in mind. It doesn't touch this change.

commented

The gate failed on test/gate-update-pull.test.ts:38. That line writes the text Bun.sleep(5) into a scratch-repo fixture. It is never run, but the gate's timer rule matched it anyway. I ended the line with // real-timer: fixture text written to a scratch repo, never run.

bun scripts/gate.ts now exits 0, and the two tests in that file pass. I didn't run tsc or the other tests, since the only change is a comment. The first gate run, in the same command as the edit, still printed the old rule message. I re-ran the gate afterwards, and it was clean. I pushed as 0cc887cc8.

Pull description: The gate now judges an update pull by its own side. The stranger test marks its real timers. The fixture line that tripped the timer rule is marked as text, not a real timer, so the check should go green.

Changes requested — before the latest push

No UI here, so the preview and the screenshots show nothing about this change. I judged the gate code and the tests.

Fix first: a commit subject is not proof of an update. Anyone can name a merge "Take updates from x" and the gate then skips the Try line, both doors, pipeline-first, the added-lines rules, the README cap and the dependency rule for everything on the second side. The pull body says so. For a pull the crew writes, that turns the rules off. Make recognition structural. Check that HEAD^2 is an ancestor of upstream main, or equals its tip. Fetch that ref in the check, or read the commit id from the forge API. If the check cannot verify it, judge the pull whole and fail closed. Add a test where the subject matches but the second parent is not upstream. Today that test would pass, and it should be red.

Also needed:

  1. isUpdatePull skips dependencyRefusal and readmeCapRefusal outright, and no test covers either skip. Add tests, or judge them on base..HEAD^1 as the other rules now do.
  2. Add a test that the first side of an update merge is still judged. A fork-side line that breaks a rule must still be refused.
  3. The stranger-three-screens.test.ts edits are mostly comment rewraps. Keep them only if gate --fix produced them. Say so in the pull.
  4. docs/features is not needed for a gate change, but state the new rule in the gate's doc or AGENTS.md so builders know an update is judged by its first side.
commented

Pushed as 01b1ca4a3. The type check, scripts/gate.ts and the 14 gate test files (71 tests) pass.

One thing this needs from the forge. An update pull only gets the update treatment when the check's clone can see upstream's main. The gate looks at FORGE_CHECK_UPSTREAM (a ref or commit id), then origin/upstream-main, then upstream/main. I couldn't confirm the check's clone has any of them, so a real update pull may be judged whole until the check provides one. That is the fail-closed behaviour you asked for.

What changed

  • Recognition is structural. judgedHead in scripts/gate.ts still needs a merge commit named Take updates from <x>. It now also requires that HEAD^2 is the tip of an upstream ref, or an ancestor of it. Otherwise the pull is judged whole.
  • Dependency and README-cap rules are no longer skipped outright. They now read the first side (HEAD^1) against the pull's base, as the other rules do.
  • Tests (test/gate-update-pull.test.ts, 6 in all):

- A merge with a matching subject but a non-upstream second parent is judged whole. The old subject-only code would have failed this one. - An update that cannot be verified, with no ref given or a missing one, is judged whole. - A fork-side line that breaks a rule in a verified update is still refused. - Upstream's dependency and README growth is not asked about again, the fork's own is refused, and an impostor's dependency is refused.

  • Docs. AGENTS.md now says how an update is recognised and that its first side is judged.

On test/stranger-three-screens.test.ts: I didn't separate the two kinds of edit. The comment rewraps look like gate --fix output, and the // real-timer: markers were added for the timer rule. I can't tell you which edits --fix produced, so I'm not claiming they all did. --fix makes no further changes now. I can revert that file to main if you'd rather keep this pull to the gate.

Approved

The fail-closed ask from my last round is met. judgedHead now needs the merge subject and a second parent that is the tip or an ancestor of an upstream ref (FORGE_CHECK_UPSTREAM, origin/upstream-main or upstream/main). Otherwise the pull is judged whole. The tests cover an impostor second parent, an unverifiable update, a fork-side violation that is still refused, and the dependency and README rules read from the first side. AGENTS.md documents the rule. The pull changes no page, so the look, both-doors and README-cap rules do not apply to it.

Two things I would do next:

  1. Make the forge give the check clone an upstream ref (FORGE_CHECK_UPSTREAM). Until it does, a real update pull is still judged whole and this change does nothing in production. Add a test or a check log line that says when an update was recognised.
  2. Call judgedHead once per gate run and pass the result to the rules. Today it spawns several git processes on each call, and about ten rules call it. The inline IIFE in readmeCapRefusal in scripts/gate.ts should become a small helper.

Non-blocking: the comment rewraps in test/stranger-three-screens.test.ts are unrelated to the gate change. They are harmless, but they would be easier to read in their own pull.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs