MERGE_AUTHORITY=agent-after-green — the harness merges an agent PR once its checks are green #15

Closed
opened 2026-08-22 11:35:09 +00:00 by ben · 2 comments
Owner

Part of the agent-driven install-session arc (Ben, 2026-08-21/22; docs/superpowers/specs/2026-08-21-vendor-command-design.md §Context records the decomposition: 2 vendor ✅ → 1 policy layer + prompt rendering → 3 host enrolment → 4 the install session). Worked by the factory's own swarm (STATUS.md 2026-08-22 — SELF-HOSTED).

Depends on the LANDING=pr ticket.

Why

Ben's ruling: whether agents merge is decided per repo. human (default) is today's matou-app behaviour. agent-after-green lets a repo with a trusted gate close the loop without a human click.

Deliverables

  • landing-lib.sh: landing_merge_if_green <N> — reads the PR's combined status via forgejo-lib.sh; merges (rebase or merge per the repo's Forgejo setting, never squash-rewrite of a human commit) only when every required check is success; on pending leaves it (the next run retries); on failure labels the issue agent-blocked with the failing check named.
  • Called from run-swarm.sh's reconcile pass for every open agent PR, not only this run's — a PR whose checks went green after the run ended still lands.
  • The close-report gate's pr-mode success path (from the LANDING=pr ticket) now closes the issue when this merged it.
  • tests/landing-lib-test.sh: green → merged, pending → untouched, failure → agent-blocked with reason; MERGE_AUTHORITY=human → never merges.

Acceptance

  • With MERGE_AUTHORITY=human nothing merges; with agent-after-green, a shimmed green PR is merged and its issue closed with the envelope posted; a red one is parked agent-blocked.
_Part of the agent-driven install-session arc (Ben, 2026-08-21/22; `docs/superpowers/specs/2026-08-21-vendor-command-design.md` §Context records the decomposition: 2 vendor ✅ → 1 policy layer + prompt rendering → 3 host enrolment → 4 the install session). Worked by the factory's own swarm (STATUS.md 2026-08-22 — SELF-HOSTED)._ **Depends on** the `LANDING=pr` ticket. ## Why Ben's ruling: whether agents merge is decided per repo. `human` (default) is today's matou-app behaviour. `agent-after-green` lets a repo with a trusted gate close the loop without a human click. ## Deliverables - `landing-lib.sh`: `landing_merge_if_green <N>` — reads the PR's combined status via `forgejo-lib.sh`; merges (rebase or merge per the repo's Forgejo setting, never squash-rewrite of a human commit) only when every required check is `success`; on `pending` leaves it (the next run retries); on `failure` labels the issue `agent-blocked` with the failing check named. - Called from `run-swarm.sh`'s reconcile pass for every open agent PR, not only this run's — a PR whose checks went green after the run ended still lands. - The close-report gate's pr-mode success path (from the `LANDING=pr` ticket) now closes the issue when this merged it. - `tests/landing-lib-test.sh`: green → merged, pending → untouched, failure → `agent-blocked` with reason; `MERGE_AUTHORITY=human` → never merges. ## Acceptance - With `MERGE_AUTHORITY=human` nothing merges; with `agent-after-green`, a shimmed green PR is merged and its issue closed with the envelope posted; a red one is parked `agent-blocked`.

swarm-claim host=elitebook-distributed-server-03 run=94
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=94 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #15 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 15,
  "status": "success",
  "commits": [
    "5c31c1abeffe7aac6909494d0ed65b755b17df3f"
  ],
  "changed_files": [
    "STATUS.md",
    "close-report.sh",
    "forgejo-lib.sh",
    "landing-lib.sh",
    "run-swarm.sh",
    "tests/close-report-test.sh",
    "tests/fakebin/curl",
    "tests/forgejo-lib-test.sh",
    "tests/landing-lib-test.sh",
    "tests/run-swarm-landing-test.sh"
  ],
  "tests": [
    {
      "command": "bash tests/landing-lib-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/forgejo-lib-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/close-report-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/run-swarm-landing-test.sh",
      "exit_code": 0
    },
    {
      "command": "full offline suite (tests/*.sh onboarding/tests/*.sh)",
      "exit_code": 0
    }
  ],
  "criteria": {
    "landing-lib.sh: landing_merge_if_green <N> reads combined status via forgejo-lib.sh, merges (rebase/merge per repo setting, never squash) only when every required check success; pending leaves it; failure labels agent-blocked with the failing check named": "landing-lib.sh landing_merge_if_green + landing_park_agent_blocked; forgejo_pr_combined_status + forgejo_repo_default_merge_style in forgejo-lib.sh; tests/landing-lib-test.sh green/pending/failure cases",
    "Called from run-swarm.sh's reconcile pass for every open agent PR, not only this run's": "run-swarm.sh calls landing_merge_reconcile in the pr-mode reconcile pass; landing_open_agent_issues enumerates ALL open agent/issue-<N> PRs; tests/run-swarm-landing-test.sh scenarios 4-5",
    "The close-report gate's pr-mode success path now closes the issue when this merged it": "close-report.sh agent-after-green path routes through landing_merge_if_green; on merged+closed it releases claim labels; tests/close-report-test.sh PR-2/PR-2b/PR-2c",
    "tests/landing-lib-test.sh: green->merged, pending->untouched, failure->agent-blocked with reason; MERGE_AUTHORITY=human->never merges": "tests/landing-lib-test.sh: 38 checks passed covering all four",
    "Acceptance: human->nothing merges; agent-after-green green PR merged + issue closed + envelope posted; red parked agent-blocked": "close-report PR-2 (merged+closed+envelope), PR-2b (red->agent-blocked, no merge/close), PR-2c (pending), landing-lib human->not-authorized"
  },
  "summary": "MERGE_AUTHORITY=agent-after-green consumed: the harness merges an open agent PR once its required checks are green, parks a red one agent-blocked, and leaves a pending one for a later reconcile pass.",
  "blockers": []
}
**close-report** for #15 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 15, "status": "success", "commits": [ "5c31c1abeffe7aac6909494d0ed65b755b17df3f" ], "changed_files": [ "STATUS.md", "close-report.sh", "forgejo-lib.sh", "landing-lib.sh", "run-swarm.sh", "tests/close-report-test.sh", "tests/fakebin/curl", "tests/forgejo-lib-test.sh", "tests/landing-lib-test.sh", "tests/run-swarm-landing-test.sh" ], "tests": [ { "command": "bash tests/landing-lib-test.sh", "exit_code": 0 }, { "command": "bash tests/forgejo-lib-test.sh", "exit_code": 0 }, { "command": "bash tests/close-report-test.sh", "exit_code": 0 }, { "command": "bash tests/run-swarm-landing-test.sh", "exit_code": 0 }, { "command": "full offline suite (tests/*.sh onboarding/tests/*.sh)", "exit_code": 0 } ], "criteria": { "landing-lib.sh: landing_merge_if_green <N> reads combined status via forgejo-lib.sh, merges (rebase/merge per repo setting, never squash) only when every required check success; pending leaves it; failure labels agent-blocked with the failing check named": "landing-lib.sh landing_merge_if_green + landing_park_agent_blocked; forgejo_pr_combined_status + forgejo_repo_default_merge_style in forgejo-lib.sh; tests/landing-lib-test.sh green/pending/failure cases", "Called from run-swarm.sh's reconcile pass for every open agent PR, not only this run's": "run-swarm.sh calls landing_merge_reconcile in the pr-mode reconcile pass; landing_open_agent_issues enumerates ALL open agent/issue-<N> PRs; tests/run-swarm-landing-test.sh scenarios 4-5", "The close-report gate's pr-mode success path now closes the issue when this merged it": "close-report.sh agent-after-green path routes through landing_merge_if_green; on merged+closed it releases claim labels; tests/close-report-test.sh PR-2/PR-2b/PR-2c", "tests/landing-lib-test.sh: green->merged, pending->untouched, failure->agent-blocked with reason; MERGE_AUTHORITY=human->never merges": "tests/landing-lib-test.sh: 38 checks passed covering all four", "Acceptance: human->nothing merges; agent-after-green green PR merged + issue closed + envelope posted; red parked agent-blocked": "close-report PR-2 (merged+closed+envelope), PR-2b (red->agent-blocked, no merge/close), PR-2c (pending), landing-lib human->not-authorized" }, "summary": "MERGE_AUTHORITY=agent-after-green consumed: the harness merges an open agent PR once its required checks are green, parks a red one agent-blocked, and leaves a pending one for a later reconcile pass.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/dev-factory#15
No description provided.