gitlab.ai-servicers.com · design decision · 2026-10-24 · updated 2026-11-06

MR Pre-Merge AI Review

Every merge request gets an AI analysis before a human merges.
The AI advises — deterministic controls and the human click decide.

The problem — a privilege path hiding in plain sight

Developer edits a hook in their clone runs as developer — harmless Developer merges to claude-shared main closed 2026-11-06 — merge needs Maintainer Administrator pulls claude-shared routine /updateskills Claude Code loads hooks & skills now runs as ADMINISTRATOR

One shared repo ships executable payloads (9 hook scripts, the safety guard itself, setup.py) and instruction payloads (skills, CLAUDE.md imports) to every user's sessions.

Verified facts (as of 2026-11-06)

Merge = Maintainer

Closed 2026-11-06. Protected main: merge and push need Maintainer, held only by the administrator account; force-push off. Developers still push branches and open MRs.

Threads must resolve

"All threads must be resolved" is on, so the review thread blocks the merge. "Pipelines must succeed" is off: claude-shared has no CI yet.

GitLab CE

No approval rules, no CODEOWNERS, no push rules, no Duo — all Premium. Controls must be CE-native.

Instructions = code

Under bypass-permissions sessions, a poisoned SKILL.md or CLAUDE.md executes shell without touching a single .sh file.

No auto-pull

The admin clone changes only on manual pull — a natural checkpoint we can put a gate on.

Incident precedent

2026-06-07: webhook → auto-executing AI caused real damage. Lesson: webhook AI must only ever comment.

design principle

The AI layer produces comments.
The deterministic layer and the human merge click are the controls.

AI advises Classifier routes attention Human decides

Architecture — one in-house service

MR opened / updated │ webhook (merge_request events only · exact-host allowlist) ▼ mr-review in-house container · Reporter identity · cannot merge or push ├─ 1. Deterministic classifier default-deny paths/patterns · no labels │ └─> risk class + reasons · reviewed SHA recorded ├─ 2. Peer review the other model family · dedicated 2nd Review Board │ └─> uploaded MR only · credential-shaped output withheld built, not yet live ├─ 3. Fallback tool-less LiteLLM chat · 3 model families on escalation live └─ 4. One thread per head SHA → must be resolved before merge │ Maintainer reads → human merge click = the only approval

The real controls (all free on GitLab CE · green = in place · amber = planned)

Branch lock

Done 2026-11-06. main: merge = Maintainer, push = Maintainer, force-push off. Plan said push = No one; the administrator account can still push directly.

Merge checks

"All threads must be resolved" is on — the review thread is a click-to-acknowledge gate. "Pipelines must succeed" waits for CI.

Admin tokens

Closed. Developers can no longer read GitLab admin tokens: rotated 2026-10-31, permissions fixed by 2026-11-04, history locked 2026-11-06.

External CI config

Pipeline definition lives in administrators/cicd — MR authors can't edit it. Guard tests, shellcheck, semgrep, gitleaks. claude-shared has no CI yet.

Pull-side gate

/updateskills shows the executable/instruction diff and requires tty confirmation before the admin clone fast-forwards.

AI identity split

AI sessions and review services get their own GitLab identities, never the administrator's.

Rollout — order only, all parts are the end state

#StepStatus
1Lock claude-shared main (merge=Maintainer) · secrets hygiene · runner auditLock done 2026-11-06 · admin tokens closed · runners tracked internally
2Build mr-review service + external CI with guard tests, in cicd · pilot on claude-sharedService live since 2026-10-24 · peer review built · CI planned
3/updateskills tty gate · separate AI GitLab identityPlanned
4agent-session moves into claude-shared — gated on 1–3, not on the AI reviewer · retire runtime copyPlanned
5cicd-dashboard risk badge · expand repos on pilot metricsPlanned

Residual risk — stated plainly

Irreducible

A confident, misleading "looks clean" review lowering the merger's scrutiny. Mitigation: AI output framed as questions the merger must answer — never "safe".

Managed

Review comments are untrusted input to any downstream AI session — never wire a label or comment to autonomous execution.

0
merge, push, or execution rights held by any AI component in this design