feat(land): mergePolicy.mode "auto" — real GitHub gate, squash push

Merged
KH
1mo ago
+603-45

Summary

Phase 3 of AgentWorkforce/cloud#5806. mergePolicy.mode: "auto" lands for real where shadow only planned:

  • Stage E really runs the repo's GitHub gate (ci.flow.ts {"github":true}). A gate short enough to finish inside runner.stageMinutes applies its verdict in the same run. One that overruns dies with the sandbox — but the ci/<sha> snapshot it pushed and the Actions runs it dispatched outlive it, so the next E run finds the snapshot (its parent is the head under test) and polls gh run list until the dispatched runs complete. Bookkeeping in <stateDir>/github-gate.json, capped at GITHUB_GATE_MAX_ATTEMPTS dispatches / GITHUB_GATE_MAX_POLLS awaits. Red feeds the fix loop like a closed gate (round cap, stuck-finding, not-decreasing all apply); green moves to F.
  • Stage F squashes the land head onto the latest base and pushes <commit>:refs/heads/<base> with Relay-Session / Land-Run trailers. Base moved since the last gate → D; non-fast-forward push → D. Other push failures → needs_human.
  • fixLoop.harness accepts claude|codex|grok|devin, default codex, and is passed to the review flows as their clis.
  • Shadow is unchanged: no write token, E records a would-dispatch, F writes a pushed:false plan; Cloud still maps shadow landed → would_land. approval remains declined.

Test plan

  • npm test in examples/land — 72/72 pass, covering every new transition (E pending/green/red, F pushed/moved/non-FF, mode discipline, trailers in the commit message, ci/<sha> deletion)
  • npm run typecheck clean
  • flows check land.flow.ts passed
  • Codex review of this PR
  • Cloud PR: auto allowlist + write grant + secrets, then first real auto land on relay-desktop

Generated with Devin


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Implements mergePolicy.mode: "auto" so the land flow really lands changes — running the repo's GitHub gate at stage E and squash-pushing to the base branch at stage F — where shadow mode only planned them.

Behavior

  • Stage E dispatches the repo's gate for real; a gate that overruns the stage window dies with the sandbox, but the ci/<sha> snapshot and dispatched Actions runs outlive it, so the next E run awaits them via gh run list, capped at 3 dispatches and 6 await runs.
  • Red gates feed the fix loop like a closed gate; green moves to F.
  • Stage F squashes the land head onto the latest base and pushes with Relay-Session and Land-Run trailers; a moved base or non-fast-forward push returns to D. A stage reaped after the push records the landed commit instead of landing twice.
  • D rebases a head that predates the base even when the base sha is unchanged, and F refuses to squash a head that never contained the base.
  • fixLoop.harness accepts claude|codex|grok|devin (default codex) and passes the chosen CLI to the review flows; grok and devin are refused at stage one until their worker adapters land.
  • Shadow mode is unchanged (no write token, would-dispatch recorded, pushed:false plan), and approval is still declined. Auto preflights gh auth and a dry-run push at stage one.

Agent Relay sessions

  • devin session gorgeous · opened via gh pr create · last active 2026-11-02