Read each project's test or live mode from its own rules

What does this MR do and why?

Gives the MR Risk Labeler a test or live mode per project, as Karan asked for item 4 of gitlab-org/gitlab#638236. Test mode keeps the test- labels, and live mode writes the same labels with no prefix, so a project starts counting through one reviewed change to its own folder. It is stacked on !128 (merged), whose record takes mode= from the prefix the labels went on with.

  • The field. mode: live at the top of a project's mr-risk-rules.yml. Anything else, or nothing, is test, so a misspelt mode stays inert, and instructions_spec fails any value but test or live. The mode decides whether anything acts on the rating, not the rating: the tiers, the action and every check are the same in either mode.
  • The steps.
    • classify_areas writes the mode into gate.json. Manifest.document replaces Manifest.read, so one parse gives the areas and the mode.
    • decide_labels composes its labels unprefixed, the action and the decisive tier once, and adds test- unless the mode is live. build_note is unchanged: its mode= follows the applied prefix.
    • plan_removals takes off the labels of the mode the gate read. With no gate, or with rules the gate could not read, it takes off test- ones alone, because an unprefixed gitlab-bot:: label may then be the older flow's.
  • The older flow. Live labels share the MR Approval Action Labeler's gitlab-bot:: scopes, so a project goes live only once that flow no longer labels it. docs/specs/mr-risk.md says so, with requirement 10 and invariant 13, and instructions/README.md has a "Test mode and live mode" section.
  • gitlab-merge-request goes live here. The last commit puts mode: live in its own rules. Once the code that reads the mode is tagged, its merge requests get live labels and mode=live records. Nothing approves on them until gitlab-org/quality/triage-ops!4549 (merged) is deployed, which approves this project's low ratings. The MR Approval Action Labeler has no consumer here; bin/live_test runs it on its own fixtures alone.
  • Every other project stays in test mode. gitlab-org/gitlab goes live with the triage-ops switch in gitlab-org/quality/triage-ops!4551 (merged), which moves its approvals onto live ratings.
  • Going live takes a person. The catalogue's own rubric rates a rules file that says mode: live high, in a new folder as much as an existing one, and the schema example shows mode: test.
  • A check on the older flow. instructions_spec fails a live project the MR Approval Action Labeler still lists under consumers:. It reads the flow's own list, not the catalog mapping, which a sync rewrites only on a tag, so the change that takes a project live can pass in the same merge request. Once the older flow is retired and its file is gone, no project is listed and the suite still loads.
  • The suite runs on a rules change. instructions/ is added to the pre-commit spec hook's file filter. A project goes live through a change to its rules file alone, and such a change ran no spec before.
  • The docs. The README's onboarding steps describe low_scopes and the record, which arrive with gitlab-org/quality/triage-ops!4549 (merged). instructions/README.md says going back to test is not a stop, and that approve: false in triage-ops is.

Size under the catalog's limit

The mode alone would grow the flow, so this drops output nothing reads:

  • gate.json's files, additions, deletions, diff_bytes, unsupported_paths and complete_list, and its checks and failed_checks. The steps read eligible, areas, mode, head_sha and rules_path; the status line has its own copies, the session log still names the failed checks, and bin/live_test runs the older flow.
  • Diffs.changed_line_count, which only fed them, and Diffs.text, which had one caller left.
  • DecideLabels::FIXED, which only a spec read.

flows/mr-risk.yml now has a 40,762-byte definition, 198 under the catalog's 40,960-byte limit (40,790 after !128 (merged)).

Not done here

  • Labels from the other mode stay on open merge requests when a project changes mode. Nothing acts on a test- label, and a refusal takes off the labels of the mode it read. Cleaning them up is not in this change.
  • Karan to confirm the rules file as where the mode lives, rather than a list compiled into the flow.
  • The rubric change is not scored with bin/eval: no suite covers the catalogue's own rules.

How to set up and validate locally

make check

🤖 Generated with Claude Code

Edited by Connor Sanders

Merge request reports

Loading
Loading