Let bin/eval score the MR Risk Labeler and its rules

What does this MR do and why?

bin/eval can now score the MR Risk Labeler. A change to its rules or rubrics under instructions/, or to src/mr-risk/, can be scored git:origin/main against the working tree, as AGENTS.md asks for a prompt change. Until now, a cut mr-risk flow stopped at its first read of the catalogue (get_repository_file), so no run reached the rater.

ruby bin/eval run mr-risk-deps --variant main=git:origin/main --variant branch=flows/mr-risk.yml

How it works

  • A variant carries its rules. git:REF reads flows/mr-risk.yml and instructions/ at the ref. A file source reads the instructions/ of the checkout the file is in, as they are on disk. The variant's digest covers its rules, so a resumed run refuses a label whose rules changed.
  • The rubric slots are worked out before the run. The gate picks each slot's rubric from the case alone. So for each variant and case, the variant's own compiled locate_rules and classify_areas run outside the sandbox first, on the replayed merge request and that variant's rules. Then each get_repository_file read becomes a read_file of a snapshot, and its consumer gets the reply as a literal, in the {"content": …} shape and through Duo's filters. A read the run never reaches, or whose file the tree lacks, gets no snapshot, so it fails as a fetch of a missing file would.
  • The answer file. mr-risk writes answer.txt itself, so the cut flow keeps that step instead of adding a second save that would fail.
  • Scoring. Decisions and the scorecard read labels with or without the test- prefix. The decisive tier, test-gitlab-bot::risk::<tier>, is the scored tier, and a new "Per area" section shows the tier each area a case touched was labelled. Reports for the deps and flow suites are unchanged. --classifier-only is refused for mr-risk, because such a run never writes labels.
  • A suite, mr-risk-deps. It reads deps-gitlab's 30 saved dependency-bot MRs (saved: deps-gitlab) rather than copying them.
    • It replays each one as opened from the project it targets (unforked: true). Every one comes from the bot's fork, which the mr-risk gate refuses whatever the rules say, so the suite scores the rules and the rater, not the fork rule.
    • As in deps-gitlab, only the below-1.0 runtime group is labelled.
  • Locale. The offline steps run with RUBYOPT=-EUTF-8. Without it, on Ruby 3.4 the gate refuses any merge request holding non-ASCII as unreadable. A spec fails if that setting goes.

Validation

  • make check stops only at main's own RuboCop offense in src/mr-risk/scripts/payload.rb, which !106 (closed) fixes. The specs pass: 167 deps, 390 flow, 162 mr-risk and 165 eval examples, with 0 failures. bin/compile --check and yamllint pass.
  • --show-flow for gitlab-261992 (a CI image) and gitlab-258858 (a qa gem). Both variants' cut flows have 33 steps and keep classify_risk and decide_labels, with no writing step. Each variant replays its own deps.md.
  • A full run, used to score a rewritten deps.md (in !112 (merged)):
    • 30 cases, three passes, 180 sessions;
    • main with !110 (merged)'s tip at the time, on both sides, with the old deps.md against the new one;
    • no run unreadable or refused, and no wrong low. The new rubric gave the same deps tier in every pass of all 19 cases that reach it.

Not in this MR

!112 (merged) carries this MR merged in, and builds on it:

  • The upstream check's replay. !112 (merged) adds the check to mr-risk, and extends this harness to run it outside the sandbox.
  • The fork rule itself. In production, mr-risk refuses every dependency-bot MR in gitlab-org/gitlab as a fork. !112 (merged) also lets the bot's own fork through.
  • The suite's upstream labels. !112 (merged) gives mr-risk-deps the deps-gitlab design's label for each case.

🤖 Generated with Claude Code

Edited by Connor Sanders

Merge request reports

Loading
Loading