Skip to content

feat: GitLab merge requests across intake, briefs, review, merge, and teardown - #7226

Closed
gh0stwin wants to merge 1 commit into
kunchenguid:mainfrom
gh0stwin:gitlab-forge-port
Closed

gh0stwin wants to merge 1 commit into
kunchenguid:mainfrom
gh0stwin:gitlab-forge-port

Conversation

@gh0stwin

Copy link
Copy Markdown

What this adds

Firstmate can now drive a project whose remote is a GitLab instance end to end. A project registers the explicit binding forge=gitlab (same explicit-binding rule as forge=gerrit; nothing is inferred from host names), and every forge-facing path then speaks merge requests:

  • Registry and intake: bin/fm-project-mode.sh accepts forge=gitlab in the closed set (now gerrit, gitlab, forgejo, composing with feat(bin): support Forgejo/Gitea as a forge via the tea CLI #4395); bin/fm-forge-detect.sh proposes gitlab from gitlab.com remote spellings at project-add intake.
  • Briefs and definition of done: a gitlab ship brief's tool rule names glab-axi (keeping gh-axi named for secondary sync work such a project may still do); a direct-PR worker opens its own merge request with glab-axi including a ready-not-draft readback check (glab-axi mr view must print draft: no); a no-mistakes run's pull request stays the pipeline's own publish at its configured push target, so that block keeps its existing readback.
  • Merge watch (fm-pr-check): arms on an MR URL, reads one JSON view (requiring jq) to refuse a draft and record the MR head as pr_head=, and never arms on a work-in-progress MR.
  • Review (fm-review-diff): always fetches refs/merge-requests/<iid>/head freshly, so review follows fix rounds that push to the MR; a recorded head is only a fallback.
  • Merge (fm-pr-merge): verifies open, mergeable, and a green pipeline at the live head (a recorded head that disagrees is treated as stale, never authoritative), then merges with --squash by default and --auto-merge=false, binding the merge to the verified head.
  • Teardown: proves landed work through the MR ref with the same ancestor-or-patch-id containment proof as the GitHub path, so squash merges and deleted source branches are covered; failures fall back to the content check, never to a discard.
  • Backlog: wherever tasks-axi cannot type a merge request URL as a pr link, the URL is recorded as a labeled note (GitLab merge request <url>) on close, retain, and retained-artifact paths.
  • Reads without plain glab: falls back to glab-axi, reading GitLab's native states including opened and locked (native spelling opened, not the GitHub twin's open; locked passes through as a readable non-merged state). An unknown state stays unreadable rather than guessed.

Design notes

  • The binding is explicit for the same reason as gerrit: a provider family must never be guessed from a remote name, host, or protocol.
  • Identity and host scoping: MR URLs are parsed and re-parsed before any forge call, so a hand-edited record cannot steer a proof at another instance; host-scoped addressing (-R <host>/<path>) is used throughout, never a configured default host.
  • Squash is the unnamed-method default for the same reason as the GitHub path: the recording and teardown machinery reasons on squash merges.

Testing

  • New GitLab cases across the seven touched test files: arm/draft refusal/head recording, squash default and flag composition in merge, teardown landed-work proof via the MR ref, review-diff fresh MR-head fetch, forge-detect proposals, the closed-set rows, the DoD block, the rendered tool rule, the retain/retained-artifact labels, and a fake-glab-axi state matrix for the fallback (merged, opened, locked, closed, unknown-state refusal).
  • An independent adversarial review of the port verified URL identity, draft refusal, head pinning and drift, squash defaults, teardown semantics, forge-detect precedence, and docs consistency, and its findings (including the opened-state gap the new fallback tests pin) are folded into this PR.

… teardown

A project whose remote is a GitLab instance registers forge=gitlab, and
every forge-facing path then speaks merge requests: the registry accepts
the binding, briefs name glab-axi (with gh-axi kept for secondary sync
work), a direct-PR worker opens its own merge request with a ready-not-
draft check, fm-pr-check arms a merge watch with the MR head recorded
from the one JSON view (requiring jq) and refuses a draft, fm-review-diff
fetches refs/merge-requests/<iid>/head freshly so review follows fix
rounds, fm-pr-merge verifies open/mergeable/green at the live head and
merges with squash by default and --auto-merge=false, teardown proves
landed work through the MR ref with the same containment proof as the
GitHub path, and the backlog records a merge request URL as a labeled
note wherever tasks-axi cannot type it as a pr link. Reads fall back to
glab-axi on hosts without plain glab, reading GitLab's native states
including opened and locked. Composes with the Forgejo forge support:
the closed forge set is gerrit, gitlab, forgejo.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @gh0stwin — a real forge=gitlab binding that mirrors the gerrit/forgejo explicit-binding rule is welcome work, and the host-scoped glab/glab-axi reads (including native opened/locked) look carefully done.

I reviewed tip ae3e58e8 vs main (23 files, +949/−158). No .github/**, no secret or unexpected network surface — forge calls stay on glab/glab-axi with URL-derived -R hosts. I approved fork CI and the Require no-mistakes run for this tip.

Contract-class: opt-in. Unconfigured homes stay on forge=none. forge=gitlab only takes effect when the captain registers it; forge-detect proposing gitlab.com at intake is propose-only. (One small note: GitLab MR merges now default to --squash when no method is named, aligning with the GitHub path — that is the intended recording/teardown contract.)

VISION.md: one-interface / authority / scripts / restart / spine / vendor / scope: align (explicit captain binding; scripts own forge mechanics; GitLab is another forge family beside gerrit/forgejo, not a vendor lock-in).

Still waiting on you:

  1. no-mistakes attestation. The PR body has no no-mistakes-pipeline-attestation binding this tip. Please re-raise through git push no-mistakes so the attestation head_sha matches ae3e58e8 (or the new tip if you push again).
  2. Live evidence. Warm ask: if you can, drive one real GitLab path end-to-end (or the pieces you can safely run) — e.g. arm/refuse-draft on a real MR, a fresh refs/merge-requests/<iid>/head review fetch, and the teardown landed-work proof — and post the evidence (or fold it into a no-mistakes re-raise). Unit coverage is strong; live is the remaining gate.

Main is red on unrelated Pi type drift, so even when this clears there will be no merge until main is green. When attestation MATCH, live ok, and CI green → auto-merge (opt-in).

@gh0stwin

Copy link
Copy Markdown
Author

Re-raised through the no-mistakes pipeline as #7243 - it carries this PR's full diff plus the review rulings applied (no forced squash default on GitLab, glab-axi for the forge=gitlab no-mistakes draft readback, jq-optional arm matching the GitHub twin, restored forgejo base-branch refusal, neutralized private fixture identifiers), a matching-head_sha attestation, and the live evidence you asked for: arm/refuse-draft on a real merge request, a fresh refs/merge-requests//head review fetch over a stale recorded head, and the teardown landed-work proof, all against https://gitlab.com/gh0stwin/firstmate-gitlab-port-fixture (merge request !1 merged, !2 used for the draft/arm cycle and cleaned up). The inherited-from-main Pi lane failures are named in the new PR's description rather than fixed. Closing this one in favor of #7243.

@gh0stwin gh0stwin closed this Oct 13, 2026
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.

2 participants