Skip to content

feat: add opt-in GitLab project delivery - #6866

Open
dimasmjunior wants to merge 18 commits into
kunchenguid:mainfrom
dimasmjunior:fm/firstmate-gitlab-upstream-u2
Open

dimasmjunior wants to merge 18 commits into
kunchenguid:mainfrom
dimasmjunior:fm/firstmate-gitlab-upstream-u2

Conversation

@dimasmjunior

@dimasmjunior dimasmjunior commented Oct 8, 2026 •

Copy link
Copy Markdown

Changes

Adds an optional GitLab project-delivery workflow using glab for hosted and self-hosted instances.
Enable it in the chosen operational home, then register the project with forge=gitlab:

mkdir -p config
printf '1\n' > config/gitlab-support

The setting follows the existing FM_HOME and FM_CONFIG_OVERRIDE directory selection and is disabled unless its value is 1.
A project binding or an existing merge waiver does not enable it.

GitLab-bound workers receive commands for creating a merge request, marking it ready and waiting on its pipeline.
The existing spawn and promotion checks enforce agreement between the registered binding and the worker's instructions.
Enabled homes can propose GitLab during project intake and check glab, jq and each bound instance's authentication during bootstrap.

The opt-in also enables additional GitLab draft/readiness checks, raw safety-field reads, synchronous ordinary merge submission, merged-state readback and MR head/content evidence during cleanup.

Uses the existing upstream waiver

This relies on the attended-only --allow-no-pipeline flag and GitLab artifact-note handling already merged through #7462.
Their implementations and tests remain upstream's; this adds no second waiver or artifact-note API.
Unopted waiver calls keep the existing upstream checks, arguments and submission outcomes.

When the home integration is enabled, its raw merge verification additionally corroborates readable boolean-false only_allow_merge_if_pipeline_succeeds project policy before applying that existing absence waiver.
The home setting grants no waiver by itself.
Present pipelines still need to have succeeded at the current head, and the upstream flag's provider and attended-only restrictions remain intact.

Compatibility and scope

Homes without the setting retain the existing GitHub tool requirements and broad authentication probe, Gerrit detection evidence and startup messages.
Existing URL-only GitLab operations keep upstream behavior, including calls that explicitly select the upstream absence waiver.
Forge-aware bootstrap honors an explicit GH_HOST rather than redirecting it to github.com.

Delivery modes, +yolo, Gerrit's publication and human-approval rules, and GitHub's named-base behavior are unchanged.
Explicit GitLab bindings still refuse unsupported --base-branch overrides.
The integration adds no MR media uploader, CI configuration, general watcher changes, automatic ready reconciliation or instance-specific configuration.
Current upstream main is merged without rewriting published commits.

Local verification

A tests-first regression rejects accidental activation of the home integration by the existing upstream waiver.
The landed waiver and artifact-note regressions remain, alongside opted-in draft, policy, outcome and cleanup coverage.

Local shell/workflow lint, documentation-audience checks and the portable coverage guard passed.
All 23 selected portable suites passed with unchanged assertions.
The host lacks shasum, and unmodified current main fails at the same hash invocation; candidate tests used a development-only shasum -a 256 frontend to native sha256sum.
Final owner lint and the complete replay suite also passed after quoting one test literal.

Thirty disabled-mode outputs matched an unmodified current-main export exactly, including exit status, stdout and stderr.
The comparisons include nine generated delivery contracts, registry/mode/branch-prefix behavior and original Gerrit detection evidence.

A committed-head CLI smoke passed all six scenario groups through the production Bash entrypoints with native glab, Git, jq and a private tmux socket, including the unopted standalone upstream waiver.
The GitLab API was a loopback fixture, not a deployed GitLab server; its runtime fixtures were removed without changing a real project or shared service.

Risk Assessment

⚠️ Medium: The bin/ changes I read gate the new GitLab behaviour on config/gitlab-support=1 and leave the unopted paths on the upstream code, but the diff is large and I did not read the tests or docs.

Testing

I ran the prepared handoff harness against the worktree at ee4b204. It drives the real Bash entrypoints with native glab, git, jq and tmux in disposable marked homes, with the GitLab API served by a loopback fixture. All six groups passed, the fixture was removed afterwards, and the harness reported no writes to a shared daemon or real project. I used expected head ee4b204, the candidate under test, instead of the older ab7dbe78 from the earlier instruction. I did not run the portable suites or the rest of the repository tests.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Registry accepts forge=gitlab with +yolo in an opted-in home and refuses local-only ✅ pass live scenarios.json (project-binding)
Guarded GitLab merge binds the verified head, runs synchronously, refuses draft and bad pipelines, and reads back the outcome ✅ pass live scenarios.json (guarded-merge), api-requests.json
Rendered brief uses glab guidance, and spawn refuses a binding mismatch ✅ pass live scenarios.json (brief-binding)
Forge detection from host and config proposes GitLab only when the home is opted in ✅ pass live scenarios.json (forge-detection)
Teardown refuses unlanded work and cleans a real gotmp checkout in a marked lab ✅ pass live scenarios.json (teardown-gotmp)
Ready registration and raw API field validation in PR-check security ✅ pass live scenarios.json (pr-check-security)
Evidence: scenario results

Source: scenario results

[
  {
    "name": "project-binding",
    "result": "pass",
    "real_production_cli": true
  },
  {
    "name": "guarded-merge",
    "result": "pass",
    "real_production_cli": true
  },
  {
    "name": "brief-binding",
    "result": "pass",
    "real_production_cli": true
  },
  {
    "name": "forge-detection",
    "result": "pass",
    "real_production_cli": true
  },
  {
    "name": "teardown-gotmp",
    "result": "pass",
    "real_production_cli": true
  },
  {
    "name": "pr-check-security",
    "result": "pass",
    "real_production_cli": true
  }
]
Evidence: API exchanges

Source: API exchanges

[
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/approval_state"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/approval_state"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "PUT",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/merge",
    "body": {
      "sha": "2704c1fe0477c8cf501a1c3e1a74a284c738d79b"
    }
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/approval_state"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "PUT",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/merge",
    "body": {
      "sha": "2704c1fe0477c8cf501a1c3e1a74a284c738d79b"
    }
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/approval_state"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "PUT",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/merge",
    "body": {
      "sha": "2704c1fe0477c8cf501a1c3e1a74a284c738d79b"
    }
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/approval_state"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "PUT",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/merge",
    "body": {
      "sha": "2704c1fe0477c8cf501a1c3e1a74a284c738d79b"
    }
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "PUT",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/merge",
    "body": {
      "sha": "2704c1fe0477c8cf501a1c3e1a74a284c738d79b"
    }
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/approval_state"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "PUT",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/merge",
    "body": {
      "sha": "2704c1fe0477c8cf501a1c3e1a74a284c738d79b"
    }
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/approval_state"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "PUT",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/merge",
    "body": {
      "sha": "2704c1fe0477c8cf501a1c3e1a74a284c738d79b"
    }
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/approval_state"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/approval_state"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7/approval_state"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  },
  {
    "method": "GET",
    "path": "/api/v4/projects/group%2Fproject/merge_requests/7"
  }
]
Evidence: commands

Source: commands

[
  {
    "label": "create-marked-lab",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-lab-home.sh",
      "create",
      "/tmp/fm-gitlab-live-jgyc5t5l/lab"
    ],
    "exit": 0,
    "stdout": "/tmp/fm-gitlab-live-jgyc5t5l/lab\n",
    "stderr": ""
  },
  {
    "label": "origin-init",
    "argv": [
      "git",
      "init",
      "--bare",
      "-q",
      "/tmp/fm-gitlab-live-jgyc5t5l/origin.git"
    ],
    "exit": 0,
    "stdout": "",
    "stderr": ""
  },
  {
    "label": "origin-main",
    "argv": [
      "git",
      "--git-dir",
      "/tmp/fm-gitlab-live-jgyc5t5l/origin.git",
      "symbolic-ref",
      "HEAD",
      "refs/heads/main"
    ],
    "exit": 0,
    "stdout": "",
    "stderr": ""
  },
  {
    "label": "seed-clone",
    "argv": [
      "git",
      "clone",
      "-q",
      "/tmp/fm-gitlab-live-jgyc5t5l/origin.git",
      "/tmp/fm-gitlab-live-jgyc5t5l/seed"
    ],
    "exit": 0,
    "stdout": "",
    "stderr": "warning: You appear to have cloned an empty repository.\n"
  },
  {
    "label": "seed-add",
    "argv": [
      "git",
      "-C",
      "/tmp/fm-gitlab-live-jgyc5t5l/seed",
      "add",
      "fixture.txt"
    ],
    "exit": 0,
    "stdout": "",
    "stderr": ""
  },
  {
    "label": "seed-commit",
    "argv": [
      "git",
      "-C",
      "/tmp/fm-gitlab-live-jgyc5t5l/seed",
      "-c",
      "user.name=Fixture",
      "-c",
      "[email protected]",
      "commit",
      "-qm",
      "fixture"
    ],
    "exit": 0,
    "stdout": "",
    "stderr": ""
  },
  {
    "label": "seed-publish-local",
    "argv": [
      "git",
      "-C",
      "/tmp/fm-gitlab-live-jgyc5t5l/seed",
      "push",
      "-q",
      "origin",
      "HEAD:main"
    ],
    "exit": 0,
    "stdout": "",
    "stderr": ""
  },
  {
    "label": "project-clone",
    "argv": [
      "git",
      "clone",
      "-q",
      "/tmp/fm-gitlab-live-jgyc5t5l/origin.git",
      "/tmp/fm-gitlab-live-jgyc5t5l/lab/projects/sample"
    ],
    "exit": 0,
    "stdout": "",
    "stderr": ""
  },
  {
    "label": "fixture-head",
    "argv": [
      "git",
      "-C",
      "/tmp/fm-gitlab-live-jgyc5t5l/lab/projects/sample",
      "rev-parse",
      "HEAD"
    ],
    "exit": 0,
    "stdout": "2704c1fe0477c8cf501a1c3e1a74a284c738d79b\n",
    "stderr": ""
  },
  {
    "label": "fixture-branch",
    "argv": [
      "git",
      "-C",
      "/tmp/fm-gitlab-live-jgyc5t5l/lab/projects/sample",
      "switch",
      "-qc",
      "fm/fixture"
    ],
    "exit": 0,
    "stdout": "",
    "stderr": ""
  },
  {
    "label": "fixture-publish-ref",
    "argv": [
      "git",
      "-C",
      "/tmp/fm-gitlab-live-jgyc5t5l/lab/projects/sample",
      "update-ref",
      "refs/remotes/origin/fm/fixture",
      "2704c1fe0477c8cf501a1c3e1a74a284c738d79b"
    ],
    "exit": 0,
    "stdout": "",
    "stderr": ""
  },
  {
    "label": "gitlab-identity",
    "argv": [
      "git",
      "-C",
      "/tmp/fm-gitlab-live-jgyc5t5l/lab/projects/sample",
      "remote",
      "set-url",
      "origin",
      "https://gitlab.example.com/group/project.git"
    ],
    "exit": 0,
    "stdout": "",
    "stderr": ""
  },
  {
    "label": "fixture-url-rewrite",
    "argv": [
      "git",
      "config",
      "--file",
      "/tmp/fm-gitlab-live-jgyc5t5l/gitconfig",
      "url.file:///tmp/fm-gitlab-live-jgyc5t5l/origin.git.insteadOf",
      "https://gitlab.example.com/group/project.git"
    ],
    "exit": 0,
    "stdout": "",
    "stderr": ""
  },
  {
    "label": "real-glab-version",
    "argv": [
      "glab",
      "version"
    ],
    "exit": 0,
    "stdout": "glab 1.114.0 ()\n",
    "stderr": ""
  },
  {
    "label": "real-glab-read",
    "argv": [
      "glab",
      "mr",
      "view",
      "7",
      "--repo",
      "https://gitlab.example.com/group/project",
      "--output",
      "json"
    ],
    "exit": 0,
    "stdout": "{\"id\":7,\"iid\":7,\"target_branch\":\"main\",\"source_branch\":\"fm/fixture\",\"project_id\":42,\"title\":\"Disposable CLI fixture\",\"state\":\"opened\",\"imported\":false,\"imported_from\":\"\",\"created_at\":null,\"updated_at\":null,\"upvotes\":0,\"downvotes\":0,\"author\":{\"id\":1,\"username\":\"fixture\",\"name\":\"Fixture\",\"state\":\"\",\"created_at\":null,\"avatar_url\":\"\",\"web_url\":\"\"},\"assignee\":null,\"assignees\":null,\"reviewers\":null,\"source_project_id\":0,\"target_project_id\":0,\"labels\":null,\"label_details\":null,\"description\":\"Disposable fixture\",\"draft\":false,\"milestone\":null,\"merge_when_pipeline_succeeds\":false,\"detailed_merge_status\":\"mergeable\",\"merge_user\":null,\"merged_at\":null,\"merge_after\":null,\"prepared_at\":null,\"closed_by\":null,\"closed_at\":null,\"sha\":\"2704c1fe0477c8cf501a1c3e1a74a284c738d79b\",\"merge_commit_sha\":\"\",\"squash_commit_sha\":\"\",\"user_notes_count\":0,\"should_remove_source_branch\":false,\"force_remove_source_branch\":false,\"allow_collaboration\":false,\"allow_maintainer_to_push\":false,\"web_url\":\"https://gitlab.example.com/group/project/-/merge_requests/7\",\"references\":null,\"discussion_locked\":false,\"time_stats\":null,\"squash\":false,\"squash_on_merge\":false,\"task_completion_status\":null,\"has_conflicts\":false,\"blocking_discussions_resolved\":true,\"merged_by\":null,\"merge_error\":\"\",\"subscribed\":false,\"changes_count\":\"\",\"user\":{\"can_merge\":true},\"latest_build_started_at\":null,\"latest_build_finished_at\":null,\"first_deployed_to_production_at\":null,\"pipeline\":null,\"head_pipeline\":null,\"diff_refs\":{\"base_sha\":\"\",\"head_sha\":\"\",\"start_sha\":\"\"},\"rebase_in_progress\":false,\"diverged_commits_count\":0,\"first_contribution\":false,\"work_in_progress\":false}\n",
    "stderr": ""
  },
  {
    "label": "unopted-binding-keeps-upstream-refusal",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-project-mode.sh",
      "--forge",
      "sample"
    ],
    "exit": 3,
    "stdout": "",
    "stderr": "refused: unknown forge \"gitlab\" registered for sample in /tmp/fm-gitlab-live-jgyc5t5l/lab/data/projects.md; the accepted values are forge=gerrit, forge=forgejo, and forge=external, or no forge token at all for a forge whose pull requests no-mistakes already drives; correct the registry entry\n"
  },
  {
    "label": "unopted-detection-keeps-upstream-none",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-forge-detect.sh",
      "/tmp/fm-gitlab-live-jgyc5t5l/lab/projects/sample"
    ],
    "exit": 0,
    "stdout": "forge=none\n",
    "stderr": ""
  },
  {
    "label": "binding-direct-PR",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-project-mode.sh",
      "sample"
    ],
    "exit": 0,
    "stdout": "direct-PR on\n",
    "stderr": ""
  },
  {
    "label": "binding-forge-direct-PR",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-project-mode.sh",
      "--forge",
      "sample"
    ],
    "exit": 0,
    "stdout": "gitlab\n",
    "stderr": ""
  },
  {
    "label": "binding-no-mistakes",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-project-mode.sh",
      "sample"
    ],
    "exit": 0,
    "stdout": "no-mistakes on\n",
    "stderr": ""
  },
  {
    "label": "binding-forge-no-mistakes",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-project-mode.sh",
      "--forge",
      "sample"
    ],
    "exit": 0,
    "stdout": "gitlab\n",
    "stderr": ""
  },
  {
    "label": "local-only-forge-refused",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-project-mode.sh",
      "sample"
    ],
    "exit": 3,
    "stdout": "",
    "stderr": "refused: sample is registered local-only with forge=gitlab in /tmp/fm-gitlab-live-jgyc5t5l/lab/data/projects.md; local-only publishes nothing, so a f

... [20991 bytes truncated] ...

r": ""
  },
  {
    "label": "unlanded-teardown-refusal",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-teardown.sh",
      "handoff-unlanded"
    ],
    "exit": 1,
    "stdout": "",
    "stderr": "fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-gitlab-live-jgyc5t5l/lab\nWARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.\nWARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.\nREFUSED: worktree /tmp/fm-gitlab-live-jgyc5t5l/unlanded-clone has work not on any remote and not landed.\nunpushed commits:\n8bf7fab unlanded\nPush the branch, land its PR, or get the captain's explicit OK to discard, then --force.\n"
  },
  {
    "label": "gotmp-marked-lab",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-lab-home.sh",
      "create",
      "/tmp/fm-gitlab-live-jgyc5t5l/gotmp-lab"
    ],
    "exit": 0,
    "stdout": "/tmp/fm-gitlab-live-jgyc5t5l/gotmp-lab\n",
    "stderr": ""
  },
  {
    "label": "gotmp-window",
    "argv": [
      "tmux",
      "-S",
      "/tmp/fml.zasiR2/handoff.sock",
      "new-window",
      "-d",
      "-t",
      "handoff",
      "-n",
      "fm-handoff-gotmp",
      "sleep",
      "600"
    ],
    "exit": 0,
    "stdout": "",
    "stderr": ""
  },
  {
    "label": "gotmp-real-teardown",
    "argv": [
      "bash",
      "/tmp/fm-gitlab-live-jgyc5t5l/gotmp-lab/bin/fm-teardown.sh",
      "handoff-gotmp"
    ],
    "exit": 0,
    "stdout": "teardown handoff-gotmp complete (window handoff:fm-handoff-gotmp, worktree /tmp/fm-gitlab-live-jgyc5t5l/missing-copy)\nBacklog: handoff-gotmp just finished (config/backlog-backend selects manual editing). Update /tmp/fm-gitlab-live-jgyc5t5l/gotmp-lab/data/backlog.md - move handoff-gotmp to Done, keep Done to the 10 most recent, then re-scan Queued and dispatch only work whose blockers are gone and date is due.\n",
    "stderr": "fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-gitlab-live-jgyc5t5l/gotmp-lab\n\u25cf\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\u25cf  WATCHER DOWN - SUPERVISION IS OFF\n\u25cf  1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).\n\u25cf  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.\n\u25cf  This is a supervision warning only; the guarded operation WILL still run.\n\u25cf  watcher supervision needs Stop-owned automatic recovery; inspect the hook registration and startup status before ending the turn.\n\u25cf\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n/tmp/fm-gitlab-live-jgyc5t5l/gotmp-lab/bin/fm-teardown.sh: line 3772: /tmp/fm-gitlab-live-jgyc5t5l/gotmp-lab/bin/fm-remote-job-reap-orphans.sh: No such file or directory\n"
  },
  {
    "label": "draft-ready-refused",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-pr-check.sh",
      "handoff-ready",
      "https://gitlab.example.com/group/project/-/merge_requests/7"
    ],
    "exit": 1,
    "stdout": "",
    "stderr": "error: https://gitlab.example.com/group/project/-/merge_requests/7 is a draft merge request; a draft cannot be merged - mark it ready for review and arm again, or declare a wait instead of done if the draft is deliberate\n"
  },
  {
    "label": "ready-registration",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-pr-check.sh",
      "handoff-ready",
      "https://gitlab.example.com/group/project/-/merge_requests/7"
    ],
    "exit": 0,
    "stdout": "armed: state/handoff-ready.check.sh\n",
    "stderr": "WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.\nWARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.\n"
  },
  {
    "label": "raw-api-missing-draft",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-pr-merge.sh",
      "handoff-raw-0",
      "https://gitlab.example.com/group/project/-/merge_requests/7"
    ],
    "exit": 1,
    "stdout": "armed: state/handoff-raw-0.check.sh\n",
    "stderr": "WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.\nWARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.\nerror: refusing to merge https://gitlab.example.com/group/project/-/merge_requests/7\n  - draft is \"unreadable\", not boolean false\n"
  },
  {
    "label": "raw-api-null-draft",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-pr-merge.sh",
      "handoff-raw-1",
      "https://gitlab.example.com/group/project/-/merge_requests/7"
    ],
    "exit": 1,
    "stdout": "armed: state/handoff-raw-1.check.sh\n",
    "stderr": "WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.\nWARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.\nerror: refusing to merge https://gitlab.example.com/group/project/-/merge_requests/7\n  - draft is \"unreadable\", not boolean false\n"
  },
  {
    "label": "raw-api-string-draft",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-pr-merge.sh",
      "handoff-raw-2",
      "https://gitlab.example.com/group/project/-/merge_requests/7"
    ],
    "exit": 1,
    "stdout": "armed: state/handoff-raw-2.check.sh\n",
    "stderr": "WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.\nWARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.\nerror: refusing to merge https://gitlab.example.com/group/project/-/merge_requests/7\n  - draft is \"unreadable\", not boolean false\n"
  },
  {
    "label": "raw-api-missing-pipeline",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-pr-merge.sh",
      "handoff-raw-3",
      "https://gitlab.example.com/group/project/-/merge_requests/7",
      "--allow-no-pipeline"
    ],
    "exit": 1,
    "stdout": "armed: state/handoff-raw-3.check.sh\n",
    "stderr": "WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.\nWARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.\nerror: refusing to merge https://gitlab.example.com/group/project/-/merge_requests/7\n  - the head pipeline status is \"none\", not success\n  - the head pipeline ran at \"none\", not at the current head 2704c1fe0477c8cf501a1c3e1a74a284c738d79b\n"
  },
  {
    "label": "unsafe-url-refused",
    "argv": [
      "bash",
      "~/.no-mistakes/worktrees/a38bb9f09f5e/01M58BKYK4NND598PQTF7AG93M/bin/fm-pr-check.sh",
      "handoff-unsafe",
      "https://gitlab.example.com/group/project/-/merge_requests/7?ambiguous=1"
    ],
    "exit": 2,
    "stdout": "",
    "stderr": "error: invalid PR check request\n"
  }
]
Evidence: manifest

Source: manifest

{
  "source_head": "ee4b204c2268d4edee6e94725adbd2edc5a143f5",
  "scenarios": [
    {
      "name": "project-binding",
      "result": "pass",
      "real_production_cli": true
    },
    {
      "name": "guarded-merge",
      "result": "pass",
      "real_production_cli": true
    },
    {
      "name": "brief-binding",
      "result": "pass",
      "real_production_cli": true
    },
    {
      "name": "forge-detection",
      "result": "pass",
      "real_production_cli": true
    },
    {
      "name": "teardown-gotmp",
      "result": "pass",
      "real_production_cli": true
    },
    {
      "name": "pr-check-security",
      "result": "pass",
      "real_production_cli": true
    }
  ],
  "external_api": "explicit loopback protocol fixture, not a deployed GitLab server",
  "native_glab_git_bash_jq_tmux": true,
  "owned_fixture_removed": true,
  "shared_daemon_or_real_project_writes": false
}

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - medium risk

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Registry accepts forge=gitlab with +yolo in an opted-in home and refuses local-only ✅ pass live scenarios.json (project-binding)
Guarded GitLab merge binds the verified head, runs synchronously, refuses draft and bad pipelines, and reads back the outcome ✅ pass live scenarios.json (guarded-merge), api-requests.json
Rendered brief uses glab guidance, and spawn refuses a binding mismatch ✅ pass live scenarios.json (brief-binding)
Forge detection from host and config proposes GitLab only when the home is opted in ✅ pass live scenarios.json (forge-detection)
Teardown refuses unlanded work and cleans a real gotmp checkout in a marked lab ✅ pass live scenarios.json (teardown-gotmp)
Ready registration and raw API field validation in PR-check security ✅ pass live scenarios.json (pr-check-security)
  • python3 gitlab-live-handoff.py --source <worktree> --expected-head ee4b204c2268d4edee6e94725adbd2edc5a143f5 --evidence <evidence>/gitlab-live-handoff --max-seconds 300
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@dimasmjunior dimasmjunior changed the title feat: support GitLab project delivery and guarded merges feat: support GitLab project delivery and guarded landing Oct 8, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks, @dimasmjunior. I read the thread and the diff of head 114e9cfd against main b062eb94 (35 files, +1399/-292). The attestation matches 114e9cfd.

What it does: it adds forge=gitlab as an explicit project binding. That covers intake detection, glab-based worker briefs, guarded GitLab merges with a readback confirmation, and teardown that verifies landed MRs. It also changes two things that aren't GitLab-only:

  • fm-bootstrap.sh now drops the gh/gh-axi/NEEDS_GH_AUTH checks when no origin in the home is on github.com. It also narrows the GitHub login check for every home from gh auth status to gh auth status --active --hostname github.com.
  • The GitLab merge guard no longer always refuses an MR with no head pipeline. It merges when the project's only_allow_merge_if_pipeline_succeeds is false. Your own note flags that a pipeline that hasn't been created yet looks the same as no pipeline.

Security review before approving fork CI: there are no workflow, secret or CI-config edits. New process calls are glab auth status --hostname, glab api, and a local ssh -G host lookup with canonicalization and batch mode set. I approved CI 37812962827 and no-mistakes 37814419066. Security FYI: this loosens a merge-authority refusal on the GitLab path and changes default bootstrap auth detection. Kun needs to see both explicitly before any merge.

Contract-class: new-default. The GitLab binding itself is opt-in. But the bootstrap tool/auth change applies to every home without configuration. That includes GitHub Enterprise-only homes, where --hostname github.com can now report NEEDS_GH_AUTH. And the no-pipeline merge reverses a specified refusal. So it won't auto-merge. When CI is green and it's otherwise ready, it goes to Kun.

VISION.md, rule by rule

  • One captain, one interface: aligns. Bootstrap stops nagging GitLab-only homes about GitHub.
  • Authority is explicit and never inferred: tension. Merging a GitLab MR that has no pipeline, on the strength of a project setting, is a new merge allowance. The binding is explicit, but the loosened guard is a captain call.
  • Scripts own the mechanics, agents own the judgment: aligns. Readiness and readback are deterministic.
  • A restart is a non-event: aligns. MR links are kept in backlog notes, and teardown re-verifies.
  • Delegation with a spine: aligns. Draft MRs are refused, and the head SHA is bound.
  • The fleet outlives any vendor: aligns. It adds a forge without coupling to one.
  • Scope: aligns. Command-layer forge plumbing.

Heads-up: #6868 rewrites the same PR-URL parser, merge, teardown and backlog-transition code for GitHub hosts, so whichever lands second will need a rebase.

Next step: fork CI is now running. Nothing is needed from you unless it goes red.

@dimasmjunior dimasmjunior changed the title feat: support GitLab project delivery and guarded landing feat: support GitLab project delivery and guarded merges Oct 8, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate (OSS triage, not the captain).

Thanks @dimasmjunior. New head 8f710994 (attestation MATCH) against main 19fcbbde.

Contract-class: new-default (re-verified). GitLab project binding itself is opt-in, but bootstrap tool/auth changes apply without GitLab config (drop gh checks when no github.com origin; narrow login check to gh auth status --active --hostname github.com), and the GitLab merge guard can merge when only_allow_merge_if_pipeline_succeeds is false even with no head pipeline.

VISION.md

  • One captain, one interface: aligns (GitLab-only homes stop getting GitHub nags).
  • Authority explicit: tension (new merge allowance without pipeline) — captain call.
  • Scripts / Restart / Delegation / Vendor / Scope: align.

Security FYI: loosens a GitLab merge-authority refusal; changes default bootstrap auth detection (GHE-only homes can newly report NEEDS_GH_AUTH).

Fork CI approved this head: 37845298345 (CI), 37845298175 + 37853520538 (Require no-mistakes). Outcome: waiting-ci. When green, Kun merge-or-leave. No auto-merge. Heads-up: overlaps #6868 parser/merge/teardown surfaces.

@dimasmjunior
dimasmjunior force-pushed the fm/firstmate-gitlab-upstream-u2 branch from 8f71099 to b2c51f9 Compare October 14, 2026 16:02
@dimasmjunior dimasmjunior changed the title feat: support GitLab project delivery and guarded merges feat: support GitLab as a bound project forge Oct 14, 2026
@dimasmjunior dimasmjunior changed the title feat: support GitLab as a bound project forge feat: support GitLab project delivery and guarded merges Oct 14, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate (OSS triage, not the captain).

Thanks @dimasmjunior for rebasing this onto current main. I read the new head b2c51f91 against main 0397cb2b (37 files, +1471/-312). The no-mistakes attestation matches b2c51f91.

Contract-class: new-default (my own check, same as last time). The forge=gitlab binding is opt-in. Two changes still reach homes that never configure GitLab, though:

  • fm-bootstrap.sh now skips the gh/gh-axi/NEEDS_GH_AUTH checks in any home with no github.com origin.
  • It also narrows the GitHub login check to gh auth status --active --hostname github.com.

On top of that, the GitLab guard now merges an MR that has no head pipeline when the project's only_allow_merge_if_pipeline_succeeds is false. That reverses a refusal the docs described as intended (docs/gitlab-merge-watch.md). So this won't auto-merge. Once CI is green, it goes to Kun to merge or leave.

VISION.md, rule by rule

  • One captain, one interface: aligns. GitLab-only homes stop getting GitHub nags.
  • Authority is explicit and never inferred: tension. The new no-pipeline merge allowance is Kun's call.
  • Scripts own the mechanics / A restart is a non-event / Delegation with a spine: aligns. Readiness, head binding and readback are deterministic, and MR links are kept in backlog notes.
  • The fleet outlives any vendor: aligns. It adds a second bound forge next to Gerrit.
  • Scope: aligns. The forge work stays in the forge CLI.

Security review before approving fork CI: no workflow, secret or CI-config edits. The new process calls are glab auth status --hostname, glab api, and a local ssh -G host lookup. The one eval is test-only, against a stub fm-send.sh. I approved CI 38594604906 and no-mistakes 38594599370, 38594655880 and 38595628868. Security FYI (unchanged): this loosens a merge-authority refusal on the GitLab path and changes the default bootstrap auth detection. GitHub Enterprise-only homes can newly see NEEDS_GH_AUTH.

One gentle ask, if you have the time: the testing note says no real GitLab server was exercised. If you could push one real MR through the guarded merge path on a GitLab instance (gitlab.com is fine) and post the evidence, it would make Kun's decision much easier. That covers both the pipeline-required refusal and the no-pipeline allowance. Re-raising through no-mistakes with that scenario works too. No rush, and thank you for sticking with this one.

Outcome: waiting-ci. When CI is green, Kun decides merge or leave. This won't auto-merge. Heads-up: #6970 (yours too) touches the same GitLab merge and review surfaces.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: a quick update on b2c51f91 now that the approved CI has partly finished. Two jobs are red, and both look like they come from this branch rather than from flakes:

  • Lint 2 (job): ShellCheck SC2329 in tests/fm-task-delivery.test.sh line 1590, test_forge_gerrit_direct_pr_publishes_one_change is never invoked. Either wire it into the runner or drop it.
  • Behavior portable parallel 2 (job): tests/fm-brief.test.sh fails with not ok - a value outside the closed set must be refused: expected exit 1, got 0. My guess is that the fm-brief.sh closed-set check (likely around --forge) or its test expectation needs updating for gitlab.

This is now waiting on you, no rush. A re-raise through no-mistakes with those two fixed will refresh the attestation. The earlier ask about real-GitLab evidence still stands as a nice-to-have for Kun's decision. Contract-class is still new-default, so once green it goes to Kun to merge or leave.

@dimasmjunior

Copy link
Copy Markdown
Author

I exercised b2c51f911b997413eb19548431552987f1a4029c on a self-hosted GitLab CE 19.4.1 instance with glab 1.114.0, using one throwaway private project.
The unchanged bin/fm-pr-check.sh and bin/fm-pr-merge.sh ran from a read-only source export with a disposable lab home.

MR only_allow_merge_if_pipeline_succeeds Head pipeline Guard exit Fresh API readback
A, before CI true null 1, refused state=opened
A, after CI true Successful, SHA matches the current MR head 0, merged state=merged
B false null 0, merged state=merged
C false Failed, SHA matches the current MR head 1, refused state=opened

The successful and deliberately failing jobs both ran on the instance's existing runner.
The failing job exited with status 1; its MR was otherwise reported as mergeable, so that refusal isolates the failed-pipeline check.

Commands exercised, with local paths and identifiers replaced by variables:

FM_HOME="$LAB_HOME" bash "$SOURCE/bin/fm-pr-check.sh" "$TASK_ID" "$MR_URL"
FM_HOME="$LAB_HOME" bash "$SOURCE/bin/fm-pr-merge.sh" "$TASK_ID" "$MR_URL"

The scratch project, local clone, lab home and source export were removed afterwards.
Authenticated project lookups by ID and path returned HTTP 404 after permanent deletion.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @dimasmjunior, on both counts.

Real-GitLab evidence: the run on self-hosted GitLab CE 19.4.1 with glab 1.114.0 is exactly what I hoped for. It covers four cases: pipeline-required + no pipeline is refused, pipeline-required + green head pipeline merges, pipeline-optional + no pipeline merges, and a failed head pipeline is refused. Each one has a fresh API readback. I'm counting the live-evidence ask as closed. Since then, only test files have changed, so the evidence still applies to the shipped scripts.

New head c8af1ad2 (was b2c51f91): the no-mistakes attestation matches. The incremental diff touches tests only. It removes the duplicate test_forge_gerrit_direct_pr_publishes_one_change definition, so the Lint 2 SC2329 is gone and the original is still defined and invoked. It also moves the fm-brief closed-set refusal row to bitbucket with the gitlab wording. The full diff has no workflow, secret, or CI-config edits, so I approved this head's fork CI: CI 38620605295 and no-mistakes 38620605528.

Contract-class: new-default (unchanged, my own read). The forge=gitlab binding is opt-in. The bootstrap gh check changes still reach homes that never configure GitLab, and the no-head-pipeline merge allowance reverses a refusal the docs described. Security FYI (unchanged): this loosens a GitLab merge-authority refusal and changes default bootstrap auth detection. GitHub Enterprise-only homes could newly see NEEDS_GH_AUTH.

VISION.md: unchanged from my last pass. Authority is the one tension (the no-pipeline merge allowance is Kun's call); every other rule aligns.

Next step: waiting on CI. If it's green, this goes to Kun to merge or leave. Heads-up: #6970 touches the same GitLab merge and review surfaces.

@dimasmjunior
dimasmjunior force-pushed the fm/firstmate-gitlab-upstream-u2 branch from af42d61 to 0cdd811 Compare October 16, 2026 04:04
@dimasmjunior dimasmjunior changed the title feat: support GitLab project delivery and guarded merges feat(bin): add GitLab forge support for PR check, merge, and teardown Oct 16, 2026
@dimasmjunior dimasmjunior changed the title feat(bin): add GitLab forge support for PR check, merge, and teardown feat: support GitLab project delivery and guarded merges Oct 16, 2026
@dimasmjunior

Copy link
Copy Markdown
Author

The latest head is waiting for maintainer approval to run the Require no-mistakes workflow. No jobs ran in https://github.com/kunchenguid/firstmate/actions/runs/38849572156. Could you approve that run so CI can report on this version?

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @dimasmjunior. Both runs for this head are approved now: CI 38848748734 and Require no-mistakes 38849572156. The no-mistakes run has already passed.

New head 0cdd811d (was c8af1ad2): the no-mistakes attestation matches. I reviewed the changes since my last pass. They come from the rebase onto #7368: forge=external now sits alongside forge=gitlab in the forge lists in fm-brief.sh, fm-dod-lib.sh, fm-project-mode.sh and the project-management skill. There's also a docs/scripts.md row for fm-forge-host-lib.sh, and tests/fm-remote-reply.test.sh goes back to upstream. None of this changes the GitLab merge logic, so I'm still counting your real-GitLab evidence. There are no workflow, secret or CI-config changes in the diff.

Contract-class: new-default (unchanged, my own read). Setting forge=gitlab is opt-in, but the bootstrap gh auth-detection change also reaches homes that never set it, and allowing a merge with no head pipeline reverses a refusal the docs describe. Security FYI (unchanged): this loosens a GitLab merge-authority refusal and changes the default bootstrap auth detection.

Next step: waiting on CI. Nothing is needed from you right now. If CI goes green, the decision is Kun's: merge or leave. That will be a captain-decision hold, not something waiting on you. #6970 still overlaps the same GitLab merge and review surfaces.

A project can now be registered with forge=gitlab next to the
existing forge=gerrit binding. Workers on a GitLab-bound task are told
to create the merge request, check that it is not a draft, and wait on
its pipeline with glab instead of gh-axi. The existing spawn and
scout-promotion checks compare the brief with the registered binding.
Intake can propose it from the origin host or glab's local config,
but registration still needs confirmation. Intake evidence prints
only the host, keeping embedded origin credentials out of the report.
+yolo stays available, and local-only still refuses any forge.

Arming a merge watch refuses a positive GitLab draft. Merge-time
verification independently requires a boolean-false draft field and
binds the operation to the verified head SHA. Ordinary GitLab merges
explicitly disable auto-merge; asynchronous requests need an attended
override. Success requires readback proving the MR merged, while an
unproven outcome leaves monitoring armed and returns nonzero.

A present head pipeline must have succeeded at the current head.
When there is none, the guarded merge reads the project's
only_allow_merge_if_pipeline_succeeds setting and accepts absence only
when it is false. An unreadable setting refuses that absent-pipeline
case; successful current-head pipelines need no project-setting read.

Cleanup proves landed work through glab, by recorded URL or source
branch, and fetches refs/merge-requests/<iid>/head when its head is no
longer local. GitLab completion links are kept as backlog notes because
tasks-axi accepts only GitHub and Forgejo pull-request links.
Bootstrap scopes authentication to each selected host, resolves SSH
aliases, and reports missing glab or jq for bound GitLab clones.
The creation instructions cover approved GitLab instances, namespaces,
and visibility under the existing exact-consent requirement.
Supply the required forge library in both teardown fixtures.
Use generation-aware ensure-listening in the remote-reply helper instead of its racy liveness check.
Keep all existing assertions unchanged.

Both full suites, five repeated NUL probes, lint, and diff checks passed.
…_gerrit_direct_pr_publishes_one_change in tests/fm-task-delivery.test.sh (rebase leftover; the first copy was shadowed, which caused shellcheck SC2329). The suite passes and shellcheck on that file prints nothing. Behavior portable parallel 2: tests/fm-brief.test.sh still asserted that --forge gitlab is refused; fm-brief now accepts gitlab and its message is 'expected none, gerrit, gitlab, or forgejo'. I changed the refusal row to an invalid value (bitbucket) and updated the expected message in both rows. The fm-brief suite exits 0. The CI log excerpt did not name the failing script; I found this one by running the shard's scripts locally. tests/fm-test-run.test.sh still exits 1 in this sandbox (a comm sorted-order warning, then under LC_ALL=C a pty-host reparenting failure in fm-session-lock-ancestry, which this change does not touch). I believe that is environmental but have not confirmed it against unmodified main. I did not run the full CI shard or the full lint partition
…The only failed family was `secondmate`. I ran every serial-4 script that can be run here, and only `tests/fm-remote-reply.test.sh` failed. It is flaky: under 8 to 10 parallel runs it failed about once per batch with "a not-fully-applied capture lost its check-wake announcement". A debug copy showed that `start` never captured result 8, so the wake queue had no entry for it. The cause is a race in the test helper `await_reply_result`. It launches `fm-procevent.sh ensure-listening` in the background and never waits for it. That launcher could start a listener after `stop_reply_listener`, and that listener then held the source, so the later `start` captured nothing. The fix is in `tests/fm-remote-reply.test.sh`. The helper now waits for its background launcher before returning, on both the success and timeout paths. No assertion was changed or weakened. After the change, 12 parallel runs of the suite all passed. The invariant is that no helper-launched background process may outlive the call that started it and act on later test phases. `await_reply_result` was the only site that launched one without waiting. Not verified: I did not run the full CI shard. `fm-pi-branch-extension`, `fm-kimi-harness`, `fm-session-start`, `fm-task-delivery`, `fm-wake-drain-open-decisions-cursor` and the other long scripts in serial 4 were not run. I also did not confirm that `fm-remote-reply` was the script that failed in CI
@dimasmjunior
dimasmjunior force-pushed the fm/firstmate-gitlab-upstream-u2 branch from 0cdd811 to fabc7ed Compare October 18, 2026 01:19
@dimasmjunior dimasmjunior changed the title feat: support GitLab project delivery and guarded merges feat: support GitLab as a bound project forge Oct 18, 2026
@dimasmjunior dimasmjunior changed the title feat: support GitLab as a bound project forge feat: support GitLab project delivery and guarded merges Oct 18, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @dimasmjunior. The new head's runs are approved: CI 39086078048 and Require no-mistakes 39086078042 / 39086098269 / 39086650976. They're queued now.

New head fabc7ede (was 0cdd811d): the no-mistakes attestation matches. I compared every file's patch on the old head (base 1a6714f2) against the new one (base main c7b7798b). The added and removed lines are identical, so this is a pure rebase. My earlier review and your real-GitLab evidence still apply. There are no workflow, secret or CI-config changes.

Contract-class: new-default (unchanged, my own read). Setting forge=gitlab is opt-in. But the bootstrap gh/gh-axi/NEEDS_GH_AUTH skip and the --hostname github.com auth narrowing also reach homes that never set it. Merging an MR with no head pipeline whenever the project doesn't require pipelines also reverses a refusal the docs describe.

VISION.md (unchanged): One captain aligns. Authority explicit: tension, because the no-pipeline merge needs no flag and so it's Kun's call. Scripts own mechanics, restart, delegation, vendor and scope all align.

Overlap FYI: #7462 (closes #7355) takes the other route to the same GitLab no-pipeline gap. It adds an attended-only --allow-no-pipeline flag that is refused while away. It also adds a near-identical GitLab backlog note carve-out. The two PRs conflict in fm-pr-merge.sh, fm-backlog-transition-lib.sh, fm-captain-hold.sh and two docs, so whichever lands second will need a rebase.

Next step: waiting on CI, not on you. Once it's green, this goes to Kun to merge or leave, because of the default-behavior change.

Require config/gitlab-support=1 for the bound-forge integration and its
changes to existing URL-only operations. Preserve upstream tooling,
authentication, diagnostics and legacy behavior when disabled.

Require an attended --allow-no-pipeline flag for an explicitly absent
pipeline and readable project policy permitting it. Keep present-pipeline
status/SHA requirements and existing merge-authority settings unchanged.

Cover disabled and enabled paths with behavioral regressions and document
the home setting separately from the one-run waiver.
@dimasmjunior dimasmjunior changed the title feat: support GitLab project delivery and guarded merges feat(bin): add opt-in GitLab support for bound projects Oct 18, 2026
@dimasmjunior dimasmjunior changed the title feat(bin): add opt-in GitLab support for bound projects feat: add opt-in GitLab project delivery Oct 18, 2026
@dimasmjunior

Copy link
Copy Markdown
Author

Before I spend time on a large rebase, one question: do you still want an opt-in forge=gitlab binding next to #7243?

The current head (ee4b204) answers the new-default concerns from the last triage. Everything GitLab-related sits behind config/gitlab-support=1, so homes without it see no change in bootstrap or merge behavior. The no-pipeline case uses the existing --allow-no-pipeline waiver from #7462 instead of a separate rule.

The branch now conflicts with 19 files, because main rebuilt the poll and teardown paths after it was cut (#7858, #7965). #7243 proposes the same forge=gitlab value, so part of this PR overlaps it.

If the answer is yes, I'll rebase and drop the parts #7243 and main already cover. If you'd rather take #7243 alone, I'll close this one.

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