feat(gh-merge-green): freeze gate, merged-head checks and RELEASE mail for feat-cmux-next merges

Merged
TE
2mo ago
+655-6

Summary

Three coordinator rules for merges into feat-cmux-next, enforced in gh-merge-green instead of by memory.

Freeze gate. Lawrence's rule after #18178 merged during a freeze.

  • After every check is green and before merging, it reads the coordinator's WINDOW file over ssh.
  • Every FREEZE: <path prefix>... token=<token> line freezes its prefixes. A prefix matches the path itself, or anything under it as a directory. webviews/src/agent-session/ freezes webviews/src/agent-session/acpmux/x.tsx, but not webviews/src/agent-session-web/.
  • A PR that changes a frozen path is refused, and the refusal lists each path with its freeze. Only the holder merges into it, with --freeze-token <token>. --override never lifts a freeze.
  • An unreadable WINDOW (no ssh access, empty file, or timeout) refuses with "check with the coordinator".

Merged-head checks. #18326 grew a god file because an unrelated lint red hid the god-file check.

  • It merges the PR head into the current base in a temp worktree.
  • If Packages/macOS/CmuxNext/ changed, the merged tree must pass check-no-godfiles.sh --only swift --base <base sha>. If webviews/ changed, it must pass vp check. Both use the base's copy of the scripts, so a PR can't loosen them.
  • A vp check red the base already has is a note, not a refusal. Only files new to the PR refuse.
  • A fork PR, a head that moved, or a merge conflict refuses.

RELEASE mail. Lawrence's coordinator missed a manual RELEASE mail.

  • --window-token <token> (repeatable) names the WINDOW tokens a merge lands under. Before merging, each must be current: an [AREA] section's token: or a hold line's token=. A stale token refuses.
  • Right after the merge, it reads the merge commit and writes RELEASE <AREA>: #N landed <sha> to the coordinator's inbox (tmp file, then mv). A --freeze-token merge mails RELEASE FREEZE.
  • If the mail fails, it exits non-zero and prints the text to send by hand.

GH_MERGE_GREEN_WINDOW_FILE, GH_MERGE_GREEN_REPO_DIR and GH_MERGE_GREEN_MAILBOX_DIR point the tool at local paths. Under GH_MERGE_GREEN_TEST, or with a local WINDOW file, a token merge without GH_MERGE_GREEN_MAILBOX_DIR refuses before merging, so a test can never mail a fake RELEASE. An earlier head of this PR did exactly that: its freeze-token test mailed three fake RELEASE FREEZE: #42 mails to the real inbox.

Draft because main is frozen; this is for Lawrence.

Testing

  • Each feature has its red commit first: d420e5b2358 (freeze), 76c5cd36630 (merged-head checks), 4eac57b8b48 (base vp red), e442a6d669c (RELEASE mail), e681a9e1653 (tests never reach the real mailbox). Each fails at its red commit and passes at the head.
  • python3 -m unittest tests.test_gh_merge_green tests.test_gh_merge_green_revert tests.test_base_red_excuse: 101 tests OK at f027daf0318. shellcheck is clean. With a recording ssh first on PATH, the whole suite makes 0 ssh calls.
  • Read the live WINDOW over ssh. Checked the remote tmp-then-mv write against a scratch path on the mailbox host: the file arrived and no .tmp was left.
  • Not yet exercised: a real WINDOW token merge sending a live RELEASE mail. The first one will be.

Changelog

none

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

gh-merge-green now enforces the coordinator's freeze and release rules for feat-cmux-next merges, checks the merged head before landing, and excuses base-owned test crashes.

  • Each FREEZE: line in the coordinator's WINDOW freezes that path and everything under it; a refused PR lists each matching freeze, and only the token holder merges with --freeze-token.
  • An unreadable WINDOW refuses with "check with the coordinator."
  • Before a feat-cmux-next merge, the PR head is merged into the base locally; the merged tree must pass the Swift god-file check (when CmuxNext changes) and vp check (when webviews changes), running the base branch's own scripts so the PR cannot loosen them.
  • A vp check failure the base already has does not block; only failures new to the PR refuse.
  • A fork PR, unreachable repository, moved head, or merge conflict refuses.
  • --window-token (repeatable) and --freeze-token name the WINDOW tokens a merge lands under; each must be current, and a stale token refuses before merging.
  • Right after the merge, the tool writes a RELEASE <AREA> mail with the landed SHA to inbox/lawrence-coordinator; a failed mail exits non-zero and prints the text to send by hand.
  • A test helper crash is excused only when the base's job died on the same signal; crash lines and in-flight test names, which differ run to run, are no longer compared.
  • Under test or with a local WINDOW file, a token merge without GH_MERGE_GREEN_MAILBOX_DIR refuses before merging, so tests can never reach the real mailbox or run ssh.

[!NOTE]
High Risk
Changes merge gating for feat-cmux-next (freeze enforcement, local merged-head checks, coordinator mail) and alter when CI reds are excused—mistakes could block merges, allow bad landings, or send incorrect RELEASE messages.

Overview
gh-merge-green now enforces coordinator rules on merges into feat-cmux-next: it reads the WINDOW (ssh or GH_MERGE_GREEN_WINDOW_FILE), blocks PRs that touch FREEZE: path prefixes unless the holder passes --freeze-token, and --override cannot lift freezes. --window-token / freeze-token merges must match current WINDOW tokens; after merge the tool emails RELEASE <AREA> with the landed SHA to inbox/lawrence-coordinator (tests must set GH_MERGE_GREEN_MAILBOX_DIR so fake RELEASEs never hit production).

Before merging feat-cmux-next, it builds a local base + head worktree and runs the Swift god-file check when Packages/macOS/CmuxNext/ changes and vp check when webviews/ changes, always using the base branch’s god-file script/baseline so PRs cannot weaken checks; fork PRs are refused for this path. vp failures already on the base are noted, not blocking.

base_red_excuse.py treats SwiftPM test-helper signal crashes as base-owned when the base job died on the same signal, instead of comparing noisy crash log lines; failed steps and failing tests before the crash are still compared.

Reviewed by Cursor Bugbot for commit 4b9fbcec4f8a2c5249c0fc9a446317a09420dc23. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • CI now more accurately distinguishes matching crashes between a proposed change and its base run, reducing incorrect failure reports.
  • New Features
    • Merge checks now enforce active change freezes and require valid authorization for protected changes.
    • Changes to macOS and web components receive additional validation before merging.
    • Successful authorized merges send release notifications; validation, authorization, or notification issues are reported.