Skip to content

fix(issue-radar): a crew never merges or arms auto-merge on gitlab - #31713

Merged
KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
shane-ong:fix/issue-radar-crew-auto-merge
Nov 14, 2026
Merged

KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
shane-ong:fix/issue-radar-crew-auto-merge

Conversation

@shane-ong

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: An Issue Radar crew never merges its own merge request on GitLab, and the crew's "Arm auto-merge when green" toggle controls what the crew is told on every forge.

In a live run on a self-managed GitLab project, a crew fixed an issue, opened the MR, then ran glab api -X PUT .../merge_requests/1/merge -f merge_when_pipeline_succeeds=true from its shell. GitLab merged it when the pipeline passed. The project had no approval rule, so no person ever looked at it.

The crew was told three different things. The every-turn rule said "never merge a MR yourself". crew_brief.md said "re-arm auto-merge unconditionally". The crew's auto_merge toggle, on by default with the hint "Merges once a human approves.", was read by nothing in the backend.

Why it matters

Anyone running a crew on GitLab can get unreviewed code merged into their default branch, because GitLab's auto-merge waits only for the pipeline unless the project has approval rules. Issue Radar's own /pull/auto-merge route already refuses GitLab for this reason; the crew went around it through its shell. On every forge, turning the toggle off did nothing.

Not a goal

  • A hard command-level block on a crew's glab merge calls. The existing deny seams (an agent spec's deniedCommands, the global deny rules) are text matches a reworded command or curl gets past. The hard fence on GitLab stays the project's own: a merge-request approval rule or protected-branch merge permissions.
  • Changing what Issue Radar's own merge buttons or /pull/auto-merge route do.
  • Azure DevOps auto-complete semantics: Azure keeps the route's existing classification.

What changed (motivation → approach → change)

One function now decides whether a crew may arm auto-merge, and every place that tells the crew anything reads it.

Part Before After
Crew prompt (crew_runtime_prompt.py) "never merge yourself" only may_arm_auto_merge: the crew's auto_merge is on, the repo key is known, and the forge is not GitLab; build_snapshot carries it; the Never block renders one merge rule from it in the forge's own words
Crew update route (crew_routes.py) recomposes the running crew's cached prompt only when the Additional prompt changes also when auto_merge changes, so turning it off reaches the next idle turn
Brief (crew_brief.md) "re-arm auto-merge" twice, unconditionally both lines apply only when the turn's rule says auto-merge is on
Crew editor (CrewEditor.tsx) toggle shown on every forge; hint "Merges once a human approves." on GitLab the toggle is off and disabled with its own hint, and a new GitLab crew is saved with it off; elsewhere the hint is "Merges once its required reviews and checks pass."; strings in website/src/i18n/locales/ (12 catalogs + en.manual.json)
Specs auto_merge row: "default true" issue-radar.md and crew_ledger_spec.md say what the toggle controls, and that turning it off does not cancel an auto-merge already armed

On GitLab the rule reads: never merge a MR yourself or arm auto-merge (merge_when_pipeline_succeeds is a merge); leave it for a person. GitHub and Azure crews with the toggle on are told to arm the provider's own auto-merge once green, as before.

Backwards compatibility

Compatible: the crew record schema and every route are unchanged, and a GitHub or Azure crew with the default toggle still arms auto-merge.

Reader: website/src/apps/issue-radar/components/CrewEditor.tsx:auto_merge -- crew page -- still reads and writes the stored value; on GitLab it shows it off and leaves the stored value alone (IssueRadarCrewEditor.test.tsx)
Reader: src/kiro_crew/apps/builtins/issue_radar/backend/crew_store_records.py:_DEFAULT_CREW -- crew page -- default unchanged; the prompt ignores it on GitLab (test_issue_radar_crew_auto_merge.py)
Reader: src/kiro_crew/apps/builtins/issue_radar/backend/crew_runtime_prompt.py:compose_nudge -- crew -- a snapshot without the flag, or built without a repo key, renders the never-arm rule (test_issue_radar_crew_auto_merge.py)

Tests

Proof: PROVEN test/test_issue_radar_crew_auto_merge.py::TestCrewMergeRule::test_a_github_crew_with_auto_merge_off_never_arms_it, test/test_issue_radar_crew_auto_merge.py::TestCrewMergeRule::test_a_gitlab_crew_is_told_never_to_arm_and_why, test/test_issue_radar_crew_auto_merge.py::TestCrewMergeRule::test_a_snapshot_built_without_a_key_leaves_the_merge_to_a_person (head 7adfe05)

  • test/test_issue_radar_crew_auto_merge.py (new): GitHub and Azure crews arm only with the toggle on; a GitLab crew never arms whatever the toggle, and its nudge names merge_when_pipeline_succeeds as a merge; no repo key never arms; GitLab's enable_auto_merge really refuses.
  • test_issue_radar_crew_routes_controls.py: turning auto_merge off on a live crew rewrites the armed loop's cached merge rule, and turning it on brings it back.
  • IssueRadarCrewEditor.test.tsx: on GitLab the toggle is off, disabled, shows the GitLab hint, and a new crew saves it off; the GitHub hint says nothing about a human.
  • test_issue_radar_crew_runtime.py: the Never-block word ceiling covers every merge-rule variant.
  • Mutation checks, one at a time, all caught: route skips the refresh on auto_merge; no key arms; GitLab allowed; GitLab create saves the toggle's value; toggle ignored; editor treats GitLab as arming; locked toggle not disabled; GitLab hint not swapped.

Backend: 2,190 Issue Radar crew tests and 478 facade tests pass. Frontend: 2,833 Issue Radar and i18n vitest pass, tsc clean, i18n-check 19/19. isort, flake8, mypy, black, line-cap and comment-history gates pass.

Manual verification

The defect was found in a live end-to-end run against a self-managed GitLab: a crew took an issue to a merged MR with green pipelines, merging it itself. The fix is covered by the unit tests above; the editor change was checked in a throwaway gateway on this head with fixture repos.

Screenshots / video

Committed under temp-screenshots/issue-radar-crew-auto-merge/ (fork PR, --attach is not available to me):

New Crew on a GitLab repo: Arm auto-merge when green is off and disabled, hint says a person merges each merge request

New Crew on a GitHub repo: the toggle is on, hint says it merges once required reviews and checks pass

Related Issues

Closes #31578

Sibling sweep

Swept: git grep -nE "auto-merge|auto_merge|merge_when_pipeline_succeeds" -- src/kiro_crew/apps/builtins/issue_radar/backend/crew_brief.md src/kiro_crew/apps/builtins/issue_radar/backend/crew_runtime_prompt.py src/kiro_crew/apps/builtins/issue_radar/backend/crew_store_records.py
Sibling: src/kiro_crew/apps/builtins/issue_radar/backend/crew_brief.md -- changed here
Sibling: src/kiro_crew/apps/builtins/issue_radar/backend/crew_runtime_prompt.py -- changed here
Sibling: src/kiro_crew/apps/builtins/issue_radar/backend/azure_client_pr_actions.py -- not affected -- keeps the route's existing rule that Azure auto-complete arms like GitHub

Pattern harvest

Rule candidate: review-prompt
Pattern: a setting the UI stores and shows, but no backend code reads, while the agent is told the opposite elsewhere

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@shane-ong
shane-ong requested review from a team and KiroCrewCaptain as code owners November 6, 2026 19:29
@shane-ong
shane-ong requested a review from Zedmor November 6, 2026 19:29
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Nov 6, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 14, 2026
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS

UX-level review of fc790e1efb0b371213f06a480a4c5571e54afcb0 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Both forge states of the auto-merge toggle are in the committed screenshots: GitHub on, and GitLab off and locked. No first-time reader has seen them, because this fork lane has no blind read. Pushing the branch to this repository runs the blind read.

Notes

  • In crew-editor-gitlab-automerge.png the locked switch's track is barely visible against the row, so it looks the same as an unlocked "off" switch. Only the hint "Off on GitLab: a person merges each merge request." tells the user they can't turn it on. Give the disabled Toggle a visible locked look, such as a muted fill or a lock icon, so the switch itself shows it can't be changed.

[UX-REVIEWED] fc790e1

Description read

[DESCRIPTION-READ] ae85e0b44d8f704d9b6f6cd06a0bc8ea809e25742eed689a3315cff9d7e0e4f1

That sha256 names everything this verdict read: the PR description, plus the 5 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of fc790e1efb0b371213f06a480a4c5571e54afcb0 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The fix works at the cause: one predicate decides the merge rule, and the stored toggle that no backend code read now has a reader.

Inventory (7 items) — 6 justified

Intent: a crew should never merge its own MR on GitLab, and the "Arm auto-merge" toggle should change what the crew is told on every forge. This is a FIX (#31578).

  1. A GitLab crew is told never to merge or arm auto-merge, and the rule names merge_when_pipeline_succeeds — justified
  2. On GitHub and Azure, turning the toggle off now tells the crew never to arm auto-merge — justified
  3. The brief's two "re-arm unconditionally" lines now defer to the turn's merge rule — justified
  4. Changing auto_merge on a live crew rewrites the cached idle-turn prompt — justified
  5. On GitLab the editor toggle shows off and disabled, with its own hint — justified
  6. The GitHub hint no longer promises that a human approves — justified
  7. A new GitLab crew is saved with auto_merge false — rides along; may_arm_auto_merge already ignores the value on GitLab

[FIRST-PRINCIPLES-REVIEWED] fc790e1

Description read

[DESCRIPTION-READ] e70335b7911e58372190da10f09e1e0692b40431faa91c7b7da27bc59d359fbb

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of fc790e1efb0b371213f06a480a4c5571e54afcb0 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. One function now decides the merge rule, both the prompt and the editor follow it, a missing flag means the crew does not arm, and the rendered evidence shows the GitLab editor state.

Notes

  • On GitLab the only control is still the prompt: the crew can still run glab ... merge_when_pipeline_succeeds from its shell. The description already names the project's own approval rule or protected-branch merge setting as the real fence. Say that in the GitLab hint or the spec so operators know to set it.

[DESIGN-REVIEWED] fc790e1

Description read

[DESCRIPTION-READ] 917e05a9512f201e7d86dcbb2d6904e8945ba280723685ff448dd28580d93c32

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed fc790e1efb0b371213f06a480a4c5571e54afcb0 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] fc790e1

@iamwhatever
iamwhatever force-pushed the fix/issue-radar-crew-auto-merge branch from 7adfe05 to 8fef873 Compare November 14, 2026 09:25
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed fc790e1efb0b371213f06a480a4c5571e54afcb0 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] fc790e1

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

Fixes a GitLab crew merging its own MR. One function, may_arm_auto_merge (toggle on, key known, forge not GitLab), now decides the merge clause of the per-turn Never block. The brief's two re-arm lines defer to it, and the update route rebuilds the cached prompt when auto_merge changes. Verified: every production prompt path (launch, wake, watchdog, route refresh) passes a real key, so GitHub and Azure crews still arm by default. _coerce_crew fills auto_merge=True on read and patches only accept bools. No other unconditional arm or merge instruction is left in the brief. The editor's disabled Toggle ignores input, edits send only changed fields, and a new GitLab crew is saved off. New tests cover each behaviour change. No regressions found.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 8fef8730a1 · 337 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

A crew on a self-managed GitLab project opened an MR and armed GitLab's
merge_when_pipeline_succeeds from its shell; GitLab merged it when the
pipeline passed, with no human review. The per-turn rule said never
merge, but crew_brief.md said "re-arm auto-merge unconditionally", and
the crew's auto_merge toggle was read by nothing.

crew_runtime_prompt.may_arm_auto_merge decides it: the crew's auto_merge
is on, the repo key is known, and the forge is not GitLab (whose
auto-merge is a merge that waits for no human, the same reason the
/pull/auto-merge route refuses it). build_snapshot carries the result
and the Never block renders one merge rule from it, in the forge's own
words. The brief's two auto-merge lines defer to that rule. The crew
update route recomposes the armed loop's cached prompt when auto_merge
changes, as it already did for extra_prompt, so turning the toggle off
reaches the next idle turn. The crew editor shows the toggle off and
disabled on GitLab and saves a new GitLab crew with it off; the hint
elsewhere says it merges once required reviews and checks pass.

Closes kirodotdev#31578
@iamwhatever
iamwhatever force-pushed the fix/issue-radar-crew-auto-merge branch from 8fef873 to fc790e1 Compare November 14, 2026 11:03
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 14, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 14, 2026 14:27

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. The review checked this head (fc790e1) as follows:

  • It traced every prompt composer (launch, watchdog, wake and the route refresh) and confirmed each one passes a real repo key into may_arm_auto_merge. A GitLab crew is always told never to merge or arm auto-merge. A GitHub or Azure crew follows its toggle.
  • A missing key or a missing snapshot flag means the crew does not arm.
  • The new tests pass, and four single-line mutations of the production hunks each made a test fail.
  • The Never-block word cap now measures every variant.

Done well: one predicate decides the merge rule, the prompt, brief, live-loop refresh and editor all read it, and turning the toggle off rewrites the armed loop's cached prompt.

Optional:

  • Open #36446 pins issue-radar for adoption at an external app tree that still says "re-arm auto-merge unconditionally". Whichever PR merges second, port this fix to that app repository so adopting hosts keep it.
  • No test fails if the two crew_brief.md re-arm lines go back to "unconditionally". One assertion over brief_text() in test_issue_radar_crew_auto_merge.py would pin them.
  • The GitLab hint "a person merges each merge request" states something only the prompt backs. Wording such as "the crew leaves each merge request for a person to merge" matches what is enforced.

@KiroCrewCaptain
KiroCrewCaptain merged commit 9b660c6 into kirodotdev:main Nov 14, 2026
92 of 95 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 14, 2026
KiroCrewCaptain added a commit to KiroCrewCaptain/kirocrew-app-issue-radar that referenced this pull request Nov 14, 2026
Merge every change to the built-in Issue Radar since 4e4bba39 three-way
onto this tree, so a host that adopts this repository runs what the
wheel copy runs today, and release it as 0.1.2 for the Kiro Crew pin
(kirodotdev/KiroCrew#26967).

The changes, all in kirodotdev/KiroCrew:

- kirodotdev/KiroCrew#31713: a crew never merges or arms auto-merge on
  GitLab. may_arm_auto_merge decides the one merge rule the nudge
  states, the brief defers to it, a crew update that changes
  auto_merge refreshes the armed loop's prompt, and the crew editor
  shows the toggle off and locked on GitLab with its reason.
- kirodotdev/KiroCrew#32503: every bad-body 400 carries a code,
  invalid_json or body_not_object.
- kirodotdev/KiroCrew#37301: the generic noun crew in each catalog's
  own script in bn, ja, ko, zh-CN and ru.
- Test-only: kirodotdev/KiroCrew#37262, kirodotdev/KiroCrew#36562,
  kirodotdev/KiroCrew#31863 and kirodotdev/KiroCrew#36062.

The test host moves to the Kiro Crew commit these tests expect, and
the built-in manifest fixture is the wheel manifest at 0.1.2. PORTING.md
lists each change.

Co-authored-by: KiroCrewCaptain <312312717+KiroCrewCaptain@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An Issue Radar crew can merge its own GitLab merge request without a human

2 participants