Repository navigation
fix(issue-radar): a crew never merges or arms auto-merge on gitlab - #31713
Conversation
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of 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
[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 |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of 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 justifiedIntent: 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).
[FIRST-PRINCIPLES-REVIEWED] fc790e1 Description read[DESCRIPTION-READ] e70335b7911e58372190da10f09e1e0692b40431faa91c7b7da27bc59d359fbb That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of 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
[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 |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
7adfe05 to
8fef873
Compare
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Code change approver recommendation: ApproveWhy: 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 |
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
8fef873 to
fc790e1
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
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.mdre-arm lines go back to "unconditionally". One assertion overbrief_text()intest_issue_radar_crew_auto_merge.pywould 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.
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>
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=truefrom 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.mdsaid "re-arm auto-merge unconditionally". The crew'sauto_mergetoggle, 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-mergeroute 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
glabmerge calls. The existing deny seams (an agent spec'sdeniedCommands, the global deny rules) are text matches a reworded command orcurlgets past. The hard fence on GitLab stays the project's own: a merge-request approval rule or protected-branch merge permissions./pull/auto-mergeroute do.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.
crew_runtime_prompt.py)may_arm_auto_merge: the crew'sauto_mergeis on, the repo key is known, and the forge is not GitLab;build_snapshotcarries it; the Never block renders one merge rule from it in the forge's own wordscrew_routes.py)auto_mergechanges, so turning it off reaches the next idle turncrew_brief.md)CrewEditor.tsx)website/src/i18n/locales/(12 catalogs +en.manual.json)auto_mergerow: "default true"issue-radar.mdandcrew_ledger_spec.mdsay what the toggle controls, and that turning it off does not cancel an auto-merge already armedOn GitLab the rule reads: never merge a MR yourself or arm auto-merge (
merge_when_pipeline_succeedsis 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 namesmerge_when_pipeline_succeedsas a merge; no repo key never arms; GitLab'senable_auto_mergereally refuses.test_issue_radar_crew_routes_controls.py: turningauto_mergeoff 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.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,
tscclean,i18n-check19/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,--attachis not available to me):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
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.