Skip to content

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

Merged
khaliqgant merged 1 commit into
mainfrom
feat/land-auto-merge
Nov 2, 2026
Merged

khaliqgant merged 1 commit into
mainfrom
feat/land-auto-merge

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

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.

Written for commit 09fe985. Summary will update on new commits.

View guided diff Turn on auto-fix


Agent Relay sessions

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T19:06:06.566049Z 46f2ed0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 64b6ac55-acb9-4483-8edb-20ea5092f062
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b0ed0bbe-ce6d-4cc2-bf93-8daa751fc428
Commits

Reviewing files that changed from the base of the PR and between 5abbb7a and 46f2ed0.

Files selected for processing: 6
  • examples/land/README.md
  • examples/land/land.config.schema.json
  • examples/land/land.flow.ts
  • examples/land/tests/config.test.ts
  • examples/land/tests/flow.test.ts
  • examples/land/tests/transition.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The land flow now supports auto mode, which dispatches and polls GitHub Actions before pushing a squash commit. Pending gates can resume across runs. Red findings return to the fix loop, while moved bases and non-fast-forward pushes return the flow to D. Configuration, stage outcomes, and tests cover auto and shadow modes.

Changes: Land flow auto mode

Layer / File(s) Summary
Mode configuration and stage contracts
examples/land/land.config.schema.json, examples/land/land.flow.ts, examples/land/README.md, examples/land/tests/config.test.ts, examples/land/tests/flow.test.ts, examples/land/tests/transition.test.ts
The harness options now include grok and devin, and the default is codex. Stage results distinguish shadow, pending, green, and red gate outcomes, as well as planned, pushed, moved, and non-fast-forward merge outcomes. Approval mode remains declined.
Persisted GitHub gate and Stage E
examples/land/land.flow.ts, examples/land/README.md, examples/land/tests/flow.test.ts, examples/land/tests/transition.test.ts
Auto mode dispatches the GitHub gate and persists polling state across runs. Stage E remains pending while runs continue, advances to F on green, and sends red findings into the fix loop. Dispatches and await runs have limits.
Squash push and recovery
examples/land/land.flow.ts, examples/land/README.md, examples/land/tests/flow.test.ts, examples/land/tests/transition.test.ts
Auto mode checks the gated base before pushing a squash commit. A moved base or non-fast-forward result returns the flow to D. Other push failures require human attention. Tests cover merge outcomes and mode-specific transitions.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant StageE
  participant githubGate
  participant GitHubActions
  participant StageF
  StageE->>githubGate: Dispatch gate or resume polling
  githubGate->>GitHubActions: Dispatch workflow and poll runs
  GitHubActions-->>githubGate: Return run status
  githubGate-->>StageE: Return pending, green, or red findings
  StageE->>StageF: Continue when the gate is green
Loading

Possibly related PRs

Merge Risk: Moderate · previous review 46f2e

Auto landing can loop indefinitely when a push is rejected by branch protection, and gates that overrun the stage window may never reach a verdict and end in needs_human. Fix the push-failure classification and the since bound before relying on auto mode. Shadow mode is unaffected.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main changes: enabling auto landing with a real GitHub gate and squash push.
Description check Passed The description directly explains the auto-landing behavior, Stage E and F changes, harness updates, shadow behavior, testing, and remaining deployment work.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 9 functions across 4 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the gate at E,
Then waits for green from GitHub CI.
Red findings send the fix loop round,
A squash commit is pushed when clear and sound.
If bases move, back to D we bound,
And codex hops with ears unbound.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 46f2ed09fe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/land/land.flow.ts Resolved
Comment thread examples/land/land.flow.ts Resolved
Comment thread examples/land/land.flow.ts Resolved
@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[High impact] No new merge-blocking findings were accepted, and the numbered finding from the previous review is fixed.

Summary

Adds real GitHub gating and squash pushes for mergePolicy.mode: "auto".

  • Stage E runs GitHub checks before auto mode can land a change.
  • Stage F pushes a squash commit to the latest base branch.
  • Review and fix work use the configured harness.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["Review stages"] --> B["B: local checks"]
  B -->|blockers| C["C: repair"]
  C --> A
  B -->|clean| D["D: check base"]
  D -->|rebased| A
  D -->|ready| E["E: GitHub gate"]
  E -->|pending| E
  E -->|red| C
  E -->|green| F["F: squash and push"]
  F -->|base moved or non-fast-forward| D
  F -->|pushed or already landed| L["landed"]
Loading

Reviews (4) · Last reviewed commit: "feat(land): mergePolicy.mode "auto" — re..." · Reviewed by Greptile

Comment thread examples/land/land.flow.ts Resolved
Comment thread examples/land/land.flow.ts Resolved
Comment thread examples/land/land.flow.ts Resolved
Comment thread examples/land/land.flow.ts Resolved

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread examples/land/land.flow.ts Resolved
Comment thread examples/land/land.flow.ts Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread examples/land/land.flow.ts Resolved
Comment thread examples/land/tests/flow.test.ts Resolved
Comment thread examples/land/tests/flow.test.ts Resolved
Comment thread examples/land/land.flow.ts Resolved
Comment thread examples/land/land.flow.ts Resolved
Comment thread examples/land/land.flow.ts Resolved
Comment thread examples/land/land.flow.ts Resolved
Comment thread examples/land/land.flow.ts Resolved
Comment thread examples/land/land.flow.ts Resolved
@khaliqgant

Copy link
Copy Markdown
Member Author

All review threads addressed at 2fd3183. Local test run (CI only runs guard):

$ cd examples/land && node --experimental-strip-types --test tests/*.test.ts
✔ auto F: pushed lands with the commit; moved and non_ff go back to D (0.323895ms)
✔ mode discipline: shadow outcomes refuse auto and vice versa (0.379017ms)
ℹ tests 79
ℹ suites 0
ℹ pass 79
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 209.095253

And tsc -p tsconfig.json in examples/land is clean.

Comment thread examples/land/land.flow.ts Resolved
Comment thread examples/land/land.flow.ts Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread examples/land/land.flow.ts Resolved
Comment thread examples/land/land.flow.ts Resolved
Comment thread examples/land/land.flow.ts Resolved
Comment thread examples/land/land.flow.ts Resolved
@khaliqgant

Copy link
Copy Markdown
Member Author

Round 2 addressed at 0842e43 — all 6 new threads replied + resolved. Local test run:

$ cd examples/land && node --experimental-strip-types --test tests/*.test.ts
✔ auto F: pushed lands with the commit; moved and non_ff go back to D (0.261107ms)
✔ mode discipline: shadow outcomes refuse auto and vice versa (0.436314ms)
ℹ tests 81
ℹ suites 0
ℹ pass 81
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 212.504277

And tsc -p tsconfig.json in examples/land is clean.

Comment thread examples/land/land.flow.ts Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread examples/land/land.flow.ts Resolved
Phase 3 of cloud#5806. Auto mode lands for real where shadow only planned:

- E really runs the repo's gate (`ci.flow.ts {"github":true}`). A gate that
  finishes inside runner.stageMinutes applies its verdict in-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 (parent = the head under test) and polls `gh run list` until the
  dispatched runs complete. Bookkeeping in <stateDir>/github-gate.json,
  capped at 3 dispatches / 6 awaits. Red feeds the fix loop like a closed
  gate; green moves to F.
- F squashes the land head onto the latest base and pushes with the
  Relay-Session / Land-Run trailers. A moved base or a non-fast-forward
  sends the run back to D for a rebase + regate.
- fixLoop.harness accepts claude|codex|grok|devin (default codex) and is
  also 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, 'landed' still maps to would_land.

Tests: 72 pass covering every new transition — pending/green/red at E,
push success, moved base and non-FF at F, mode discipline both ways.
@khaliqgant
khaliqgant merged commit e21707a into main Nov 2, 2026
4 checks passed
@khaliqgant
khaliqgant deleted the feat/land-auto-merge branch November 2, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant