Merge policies
Once meiksense has opened the merge requests of an issue and they are green and reviewed, the merge policy
decides who merges them: people (human), people through a merge command (command), or meiksense itself
(auto). The decision is a pure function over what GitLab or GitHub reports about each
merge request; agent output never counts.
Where it is configured
One policy applies to every project in this release (per-project policies are not supported yet):
- cli mode:
merge_policyin~/.meiksense/config.yaml(or in the older~/.meiksense/scm.yamlwhenconfig.yamlhas no SCM integration); - service mode: the setting
merge_policy(PUT /api/v1/settings/merge_policy, admin, or the web UI's settings page). Workers read settings when they start: restart the control worker after a change.
merge_policy:
mode: human # human (default) | command | auto
conditions:
min_approvals: 1 # approvals the host counts
pipeline_green: true # the pipeline of the head meiksense pushed succeeded
no_unresolved_threads: true # no open resolvable review threads
not_draft: true # the MR is not a draft
method: merge # merge | squash | rebase
command_groups: [] # who may write `merge` (mode command)
multi_repo: all # all | each
when_pipeline_succeeds: false # hand the merge to the host while only the pipeline is still running
The three modes
| Mode | When the conditions hold | Who merges |
|---|---|---|
human | The issue moves to READY_TO_MERGE; the bot comments "The merge request(s) meet the merge conditions and can be merged." and Slack sends ready_to_merge. | People, on GitLab/GitHub. meiksense notices the merge (webhook or poll) and finishes the issue. A merge command is refused. |
command | READY_TO_MERGE; the comment says that a member of an allowed group can write @meiksense-agentik merge. | meiksense, when an allowed person writes merge (comment, web UI or API). |
auto | meiksense merges right away. | meiksense. It tries at most issues.max_merge_attempts (3) times; if the host keeps refusing, the issue stays in READY_TO_MERGE for a person. A merge command is refused. |
If the conditions stop holding while the issue is READY_TO_MERGE (a new review thread, a red pipeline), it goes back to MR_OPEN. People can always merge by hand; meiksense then finishes the issue as merged.
"Let meik merge once you approve"
Under human, an approver who cannot merge on GitLab or GitHub (a product owner without write access there, or
someone meik cannot match to a host account) is offered Let meik merge once you approve on the issue at MR_OPEN
or READY_TO_MERGE. The issue's Accept does the same.
- Accepting records a merge consent on that issue, in their name: an issue event
merge.consent, the audit entryissue.merge_consentand a tracker comment. - meik then merges that issue's merge requests once the policy's conditions hold, as
autowould, for this issue only. The project's policy does not change. - API:
GET /issues/:id/merge-offer(whether it is offered, and a consent already given), andPOST /issues/:id/merge-consent, which needsissue.merge.
merge under command
- The command is accepted while merge requests are open (MR_OPEN or READY_TO_MERGE). meiksense reads every merge request fresh and evaluates the policy; if something is missing it replies, for example "Not merged: api: min_approvals (0/1); api: pipeline_green (running)."
- Comment commands: the commenter's tracker groups must include one of
command_groups(Jira group names, GitHub team slugs through the MCP mapping). If the tracker does not report groups,mergeis refused. - Web UI / API: the user needs the role maintainer or admin on the project, and
command_groupsmust name a meiksense role:meik:maintainer(maintainers of that project and global maintainers) ormeik:admin. - An empty
command_groupsmeans nobody may merge by command.
Conditions
Each condition is checked against the host's view of every open merge request of the issue:
| Condition | Holds when | Shown as when not met |
|---|---|---|
not_draft | the MR is not a draft | not_draft |
min_approvals | approvals ≥ the number. GitLab: the approvers of the MR. GitHub: reviewers whose latest decisive review approves | min_approvals (0/1) |
pipeline_green | the pipeline of the head sha meiksense pushed last succeeded (GitHub: all check runs, statuses and workflow runs of that sha) | pipeline_green (running), (failed), (none) |
no_unresolved_threads | no resolvable thread is unresolved (GitLab discussions, GitHub review threads). meiksense replies but never resolves: a person resolves the threads | no_unresolved_threads (2 open) |
| host mergeability | the host does not report conflicts or unmet protection rules; while the host is still computing it, meiksense waits | mergeable (conflicts or host rules) |
Practical consequences:
- A repository without CI never has a green pipeline (
pipeline_green (none)): setpipeline_green: false. - With
issues.mr_draft: true(ordraft: trueon the SCM integration, which wins for its MRs) the MRs are drafts and never meetnot_draftuntil someone marks them ready. - Host rules (required approvals, protected branches, "pipelines must succeed") apply on top: the host's mergeability is a condition of its own.
Method and safety
method: merge | squash | rebase. GitHub merges with that method. GitLab squashes forsquash; forrebaseit uses the project's own merge method (configure fast-forward or semi-linear merges on the project).- Every merge names the head sha meiksense pushed last. If somebody pushed to the branch since, the host refuses ("head sha changed") and nothing unseen is merged.
when_pipeline_succeeds: true: when the only unmet condition is a pipeline that is still running, meiksense asks the host to merge once it succeeds (GitLab "merge when pipeline succeeds" / auto-merge, GitHub auto-merge; on GitHub enable "Allow auto-merge" and have a protection rule the merge can wait for). The reply is "The merge is scheduled: the host merges when the running pipeline succeeds."
Several repositories
An issue that touches several repositories has one merge request per repository, linked to each other in their descriptions.
multi_repo: all(default): merge only when every open merge request would merge now; merge requests already merged count as done. Amergecommand is refused with the missing conditions per repository.multi_repo: each: each merge request is merged on its own as soon as it qualifies.
The issue is MERGED when all of its merge requests are merged. A merge request closed without merging cancels the issue.
After the merge
MERGED → meiksense accepts the tasks (their worktrees are removed) → DONE: the issue moves to the done status
(default "Done"), the bot comments "All merge requests are merged. Done." and Slack sends merged. On GitLab the
source branch is deleted with the merge.
Examples
Review by people, merge by people (the default):
merge_policy: { mode: human }
Release managers merge by command, squash, with two approvals:
merge_policy:
mode: command
command_groups: [release-managers, "meik:maintainer"]
method: squash
conditions: { min_approvals: 2 }
Fully automatic for an internal tool (no approval required, green pipeline and resolved threads are):
merge_policy:
mode: auto
conditions: { min_approvals: 0, pipeline_green: true, no_unresolved_threads: true }
when_pipeline_succeeds: true