uBixKelpie is uBixSys's AI automation product for GitLab. It reviews merge requests, triages the threads the review leaves, proposes a fix for each one or pushes it, triages new issues and opens a merge request for an issue a developer asks it to fix, and re-runs the sign-off job when someone approves.
Kelpie never approves and never merges. Every merge stays a person's click. Code monitoring, the other half of the product's aim, is not built.
include: - project: ubixsys/ubixkelpie ref: dev # no release tag carries this job yet file: ci/kelpie.yml variables: AI_REVIEW_MODE: advisory
This adds the kelpie-review job to merge request pipelines that target dev (set AI_REVIEW_BASE_BRANCH for another branch). The job runs Kelpie's kelpie:review command in Kelpie's image and needs no Kelpie server or database.
uBixKelpie is a uBixCore application with two parts. The review is a CI job any project can include. The server, the KelpieApi app with its worker and its own database, receives GitLab webhooks and does everything after the review: it triages review threads, proposes or pushes fixes, triages issues, opens merge requests for issues, resolves settled threads and retries the sign-off job.
The work runs in this order: review a merge request, triage each thread, propose a fix or push it, handle issues the same way, and leave the sign-off to a person.
Projects are enrolled one at a time, each with a mode: off (Kelpie does nothing there, also the case for a project that is not enrolled), propose (it comments, labels and proposes diffs) or push (it may also push fixes to the merge request branch).
The review complements uBixCore's code:review rather than repeating it. code:review is the deterministic gate: lint, static types, tests, conventions. The AI review is judgement: logic bugs, security, edge cases, design smells and missing tests for changed behaviour. It is told not to report what a linter or code:review would catch.
Two masked, unprotected group variables: OPENROUTER_API_KEY, and AI_REVIEW_GITLAB_TOKEN (a group access token, Reporter role, api scope, which posts the threads). With either missing the job exits 75, posts an UNREVIEWED note when it can, and is allowed to fail. It never turns a pipeline red for being unconfigured. It needs a runner tagged shell with Docker.
variables: AI_REVIEW_MODE: blocking # default advisory: threads posted, the job never fails AI_REVIEW_MAX_ROUNDS: "3" # one round is one pushed commit AI_REVIEW_MODEL: openrouter/anthropic/claude-haiku-5.5 # the default
blocking exits 1 only when a blocker or major finding with high confidence stands.
# dismiss a review finding: resolve the thread with a reply that starts with the word Dismissed: this path is only reached from the admin CLI # steer Kelpie on a thread it has triaged (MR author or a maintainer) Triage: keep the old name and add an alias instead # ask Kelpie to look at a thread it has not triaged yet Triage: retry
On a fix Kelpie has proposed, a 👍 from the merge request's author or a maintainer applies it (in push mode) and a 👎 declines it. Anyone else's reactions and replies are ignored.
$ php bin/ubix kelpie:review --dry-run --diff my.diff --canned reply.json --repo . --dry-run never calls GitLab and prints the validated review and every comment it would post. --canned uses a file as the model's reply; without it the command asks the model, which needs OPENROUTER_API_KEY.
push mode, fixes go out as one gated commit per round, within a round cap.kelpie::fix, Kelpie makes one attempt and opens a merge request.The review needs only the CI job. Everything from triage on needs Kelpie's server, a webhook on the project, and the project enrolled in propose or push mode.
The job skips drafts, docs-only changes and empty diffs, and leaves lockfiles, vendor/, node_modules/ and generated files out of the diff. Over the size cap (3000 lines or 150 KiB by default) or past the round cap it posts a note and stops; the review:extra label allows more rounds.
The model reads the checkout through three read-only tools, read, grep and glob, whose paths stay inside the checkout and never reach .git. The GitLab token is used by Kelpie's GitLab client alone; the model only sees tool output. A repository's standards are context: CLAUDE.md, AGENTS.md, CONTRIBUTING.md, docs/standards/**/*.md and an optional .ai-review.md, read from the target branch, so a merge request cannot rewrite the rules it is judged by.
Each new finding is an inline thread. A finding already open or dismissed is matched by its id or by file and title, so a reworded finding does not duplicate. A clean or skipped review still leaves a note saying so. The summary ends with the model, tokens and cost of the run. Two labels show the state in the merge request list: kelpie-review:: (reviewing, reviewed, clean, last-round, hard-cap, skipped, unreviewed) and kelpie-findings::, the worst finding still open (blocker, major, minor-only, none).
Models. The default is Claude Haiku 5.5 through OpenRouter. A project can set AI_REVIEW_MODEL_PUBLIC to a cheaper model for open-source repositories, such as a -contributor tier. That tier trains on the prompts it receives, including the code under review, so it is used only where GitLab detects an open-source licence (BSD, MIT, Apache, GPL and the like). A repository with no licence, or one whose licence the job cannot read, stays on the regular model: a training-tier model never sees a project that is not known to be open source. If the open-source model gives no valid review, the review runs again on the regular model, and the summary names the model that wrote it.
The webhook turns merge request comments, failed gate pipelines and finished kelpie-review jobs into queued jobs, and a worker (kelpie:work) runs them. For each unresolved thread, a triage model decides one of: fix, not an issue (Kelpie proposes dismissing it, with a reason), already fixed, defer (it proposes a deferral, with a reason) or needs a person. Each reply ends with the model, tokens and cost.
Same-family guard. The triage and propose models must come from a different model family than the one that wrote the review, or the thread goes to a person: a model is not asked to judge its own family's findings. On an open-source project, where either review model may have written the review, both families are refused, as they are on a project whose licence Kelpie could not read.
While a run works on a merge request it carries kelpie::working; when it ends, one of kelpie::pushed, kelpie::proposed or kelpie::needs-you replaces it. A reply that starts Triage: from the author or a maintainer runs the thread again with the rest of the text as steering. On a thread Kelpie has not looked at, Triage: retry queues it, or replies once with the reason when it cannot (the project is not enrolled, or a cap was hit).
Propose. For a fix, a second model is asked for exact-text edits. Kelpie applies them itself in a scratch checkout and replies on the thread with the diff git writes. When that model has no usable edit, a fixing agent with file tools only (no shell, no git) works in the same checkout with the whole repository to read, so it can add the missing test or change the file the finding is really about. Either way the change is measured from git and checked by a safety policy: size, file count, protected paths (CI, migrations, secrets, lockfiles, tool configuration, manifests) and no deletes.
Push. In push mode, once a merge request's thread jobs are done, Kelpie takes every fix proposed at the current head and pushes them as one round: the project's gate on the whole result, one fix(review) commit with a Thread: line per thread, one plain push, never forced. A round may touch files the merge request already changes, test files, and files the thread names by path. A red gate or a moved head pushes nothing. Each pushed thread gets a Fixed: reply with the commit.
A round is capped at 5 threads and 80 changed lines. Over either, nothing is pushed, each thread is told once, and its proposal stays open: a 👍 pushes it alone. In propose mode a 👍 pushes nothing; Kelpie replies that the project is not set to let it push, and the diff stays there to apply by hand.
The project's gate is its own gate_command, else make check, else Kelpie's PHP gate. A project whose toolchain Kelpie's image lacks can set it to ci: the merge request pipeline then gates the pushed commit, and the reply says so.
Every Kelpie fix commit carries an Assisted-by: Kelpie <agent> (<model>) trailer naming the agent and model that made it, and its replies open their usage footer the same way. The commit author is Kelpie's bot account.
Settled threads. Kelpie resolves a thread once it is settled: fixed and pushed (in a commit the merge request carries), or dismissed with a reason. Only the bot, a configured agent account or the thread's opener may settle a thread; on a thread the AI review opened, the merge request's author may too. A thread where a person has spoken since, or whose last note is a question, stays open.
A new issue on an enrolled project gets a 👀 and is queued for triage. Triage posts one comment and one label: kelpie::fixable, kelpie::needs-human or kelpie::not-a-defect. Triage never changes code. kelpie:triage-backfill queues issues that were open before triage was switched on.
When someone with Developer access or higher adds kelpie::fix, Kelpie makes one attempt: a kelpie/fix-<number>-<slug> branch from the target branch, the propose model's edits, the safety policy and the project's gate. If all hold, it pushes the branch, opens a merge request with Closes #<number> (and a reviewer, when one is configured), links it on the issue and adds kelpie::fix-proposed. Otherwise nothing is pushed: the issue gets one comment with the reason and kelpie::needs-human. To ask again, a person removes the label and adds it back.
Every merge needs a person's Approve or 👍, enforced by a sign-off job in the pipeline. GitLab does not re-run a pipeline when someone approves, so Kelpie's webhook retries that one job (require-approval or require-approval-mr) on an Approve or a 👍, and never creates a pipeline. The merge sign-off guide has the wiring.
When the approver is one of the owners listed in KELPIE_APPROVAL_OWNERS, Kelpie first answers and resolves the threads still open ("Resolved on owner approval"), then retries the job, so open threads do not hold a merge the owner has passed. Anyone not listed, or an approval taken back, changes nothing.
Kelpie never approves and never merges. The client the sign-off retry uses refuses every request except reading a merge request, reading a pipeline's jobs and retrying or playing a job, and a test asserts the refusals. The merge button stays a person's click.
Every cap has a soft limit, which warns (one note on the merge request with kelpie::over-soft-cap, or a log line) while the work goes on, and a hard limit, which stops it. Hard limits are unlimited until set.
| Cap | Soft default |
|---|---|
| Jobs per merge request, per 24 h | 30 |
| Jobs per project, per 24 h | 200 |
| Fix commits per merge request | 3 |
| Fix attempts per thread | 2 |
| Daily spend, per project and Kelpie-wide | set by the operator |
A job refused at a hard job cap leaves one note on the merge request naming the cap and about when it frees up, with kelpie::over-cap. A job held by a spend cap gets one reply on its thread and runs after the reset.
GET /api/v1/projects, GET /api/v1/projects/{path} and PATCH /api/v1/projects/{path} on KelpieApi read and change a project's mode, its soft and hard caps and its models. Requests carry Authorization: Bearer with KELPIE_SETTINGS_API_TOKEN, a separate secret from the webhook's; until it is set the API answers 503. A patch is validated whole and applied only if every rule holds. Enrolling a project is not part of the API: it stays an operator step.
Requires: GitLab CI, a runner tagged shell with Docker, and the two group variables above. A project other than Kelpie's own logs in to the registry that holds Kelpie's image with KELPIE_REGISTRY_USER and KELPIE_REGISTRY_TOKEN (a read-registry deploy token).
Add the include to .gitlab-ci.yml. If the pipeline has its own stages without test, put the job on one of them:
kelpie-review: stage: lint-and-test
After changing the include, check it with a new push, not a job retry: a retry reuses the pipeline's old CI configuration.
Requires: PHP 8.5+, Composer, and uBixCore v0.47.0 or later (installed by Composer). Triage, fixes and the webhook also need Kelpie's database and a GitLab bot token.
$ composer install $ cp .env.example .env # local development only $ php bin/ubix list $ APP_NAME=HelloApi php -S 127.0.0.1:8080 -t public $ curl http://127.0.0.1:8080/health
The last tag is v0.1.0-beta.1. The changelog's v0.1.0-beta.2 (issue intake and triage, the propose workflow, per-project modes, Kelpie's database) is not tagged, and more has landed since. This page describes the dev branch, which is what the include points at.
| Works today | Not yet |
|---|---|
The kelpie-review job: advisory, blocking or shadow, with labels and cost guards | Monitoring code on servers |
Thread triage, the same-family guard, Triage: steering and Triage: retry | Hard limits on the per-project issue counts: stored and shown, but not enforced |
| Propose and push modes, push rounds with a round cap, settled threads resolved | Running issue triage again when someone comments on the issue |
Issue triage, and one fix attempt per kelpie::fix label | Per-project round caps: the 5-thread, 80-line figures are fixed |
| Sign-off retry and owner approval | A release tag for this work |
| Soft and hard caps, the settings API |