feat(gitlab): issue and merge request writeback parity

Merged
KH
1mo ago
+1990-189

GitLab writeback parity for issues and merge requests

Problem

GitLab is advertised as a first-class Relayfile provider, but its writeback catalog previously exposed only merge-request discussions and issue notes. A GitLab-backed software factory could not create issues or merge requests through Relayfile.

Catalog

BeforeAfter
comments, discussionsissues (create + update), merge-requests (create + update), refs, merge, close-merge-request, plus the existing comments and discussions

New canonical writeback templates:

  • /gitlab/projects/{projectPath}/issues
  • /gitlab/projects/{projectPath}/issues/{issueIid}__{slug}/meta.json
  • /gitlab/projects/{projectPath}/merge-requests
  • /gitlab/projects/{projectPath}/merge_requests/{mergeRequestIid}__{slug}/meta.json
  • /gitlab/projects/{projectPath}/merge_requests/{mergeRequestIid}__{slug}/merge.json
  • /gitlab/projects/{projectPath}/merge_requests/{mergeRequestIid}__{slug}/close.json
  • /gitlab/projects/{projectPath}/refs

GitLab REST v4 endpoints

  • POST /projects/:id/issues
  • PUT /projects/:id/issues/:iid
  • POST /projects/:id/merge_requests
  • PUT /projects/:id/merge_requests/:iid
  • PUT /projects/:id/merge_requests/:iid/merge
  • PUT /projects/:id/merge_requests/:iid with state_event: close | reopen
  • POST /projects/:id/repository/branches

Payload validation rejects missing required fields, invalid lifecycle states, read-only fields, unknown fields, and unsupported paths. Label arrays are normalized to GitLab's comma-separated API representation.

Discovery and layout

Every new resource has non-empty JSON Schema and create-example contracts, is represented in the GitLab adapter discovery guide, layout manifest, LAYOUT prompt, mappings, and generated writeback catalog. The shared file-native router now supports nested GitLab projectPath segments when recognizing exact writeback sidecars.

Validation

  • npm test -w @relayfile/adapter-gitlab — 93 passing
  • npm run typecheck -w @relayfile/adapter-gitlab
  • npm run build -w @relayfile/adapter-gitlab
  • npm test (workspace gate)
  • npm run typecheck (workspace gate)
  • npm run test:writeback-discovery — 119 endpoints verified
  • npm run test:digest-contracts
  • Veto diff review — PASS (one low-severity follow-up: restore explicit TypeScript payload/request types in writeback.ts)

Scope

Nothing was skipped. refs is included because it is the GitLab equivalent of GitHub's branch-creation route and lets a flow create a branch before opening a merge request. f.gitlab was not changed.

Release note

@relayfile/adapter-gitlab is bumped from 0.4.2 to 0.5.0 for the new capability. Consumers that mount GitLab paths should resync to materialize the new discovery and catalog surface.

Reviewer notes (orchestrator)

  • Rebased onto main after relayfile-adapters#281 / the 0.2.1 publish; re-ran npm test -w packages/gitlab (93/93), root npm run typecheck (55/55 tasks) and root npm test (105/105 tasks) post-rebase.
  • One shared-runtime change to flag: packages/core/src/runtime/file-native-router.ts readExactFileResourceId no longer requires equal segment counts, so a {projectPath} placeholder can span a nested GitLab namespace (group/subgroup/project). Fixed suffix segments are still matched from the right; only placeholder templates are affected.
  • packages/core gained mapping + generated catalog entries but its version is not bumped here — the publish workflow's changed-package mode should pick it up; shout if you want an explicit core bump in this PR.
  • Follow-up (out of scope, ../flows): make the f.gitlab helper's read/list gap visible or close it, per the "second-class provider" note that prompted this.

🤖 Generated with Claude Code


[!NOTE]
Medium Risk
Expands provider write surface (create branches, MRs, merges) and changes shared exact-file ID matching for nested GitLab project paths; mis-routing could affect non-GitLab adapters using similar templates.

Overview
Adds file-native GitLab writeback for issues, merge requests, branches, and merge-request lifecycle actions—beyond the prior discussions/notes-only surface.

Agents can draft creates under issues/, merge-requests/, and refs/, patch issue/MR meta.json, and drive merge and close/reopen via merge.json / close.json sidecars. GitLabWritebackHandler routes these to GitLab REST v4 with stricter payload validation (allowed fields, read-only rejection, label normalization, state_event checks).

Discovery and contracts are wired through mappings, generated writeback catalog, JSON schemas/examples, layout manifest, and LAYOUT.md. Path helpers and parseGitLabPath understand merge-requests vs merge_requests and new draft/sidecar paths.

In adapter-core, readExactFileResourceId no longer requires equal segment counts so nested {projectPath} namespaces match exact sidecar templates (e.g. group/subgroup/project).

Reviewed by Cursor Bugbot for commit 70de4fa998148f6c78bbee65cab72e75de0e8232. Bugbot is set up for automated code reviews on this repo. Configure here.


Agent Relay sessions

  • claude session 7fa0c082 · opened via gh pr create · last active 2026-09-19