lnd icon indicating copy to clipboard operation
lnd copied to clipboard

ci: run PR severity classification on request, with a path floor and calibration

Open litbot-9000 opened this issue 1 month ago • 0 comments

pr-severity.yml makes one pinned claude-sonnet-5 call on every PR open and push. The prompt contains the path rules, and the call applies a severity-* label. It has three problems:

  • Too many runs. It fires on every opened and synchronize event, including fork PRs, through pull_request_target. Most of those runs classify PRs nobody has asked about yet.
  • No deterministic floor. Hard rules such as "migrations are always CRITICAL" live in the prompt, so the model can drop them. It also rates .github/, scripts/, and tests as LOW, although changes to CI, release, or build execution can be security-sensitive whatever their size.
  • No feedback loop. severity-override-* labels are the only human signal, and nothing records them. There is no way to tell whether a rubric change made the ratings better or worse.

lightninglabs/terminal-web recently built the missing pieces in .github/ai-review/: policy.mjs, prompts/rubric.md, calibration.json, and calibrate.mjs. This issue proposes porting that rating pattern to lnd, not terminal-web's whole review pipeline. lnd reviews through Gateway.

1. Run only when asked

Classify a PR only when a maintainer applies a label, for example severity-check. Applying a label needs triage or write access, so contributors cannot trigger model runs. Remove opened and synchronize from the triggers. Pushes after the label is applied do not reclassify the PR. Re-applying the label reclassifies it, which replaces today's reclassify label. skip-severity-check and the severity-override-* labels keep working.

Because the workflow stays on pull_request_target and runs only on labels from trusted users, the read-only classifier job and the model-free apply job keep their current split.

2. Deterministic path floor, run from master

Move the hard rules out of the prompt and into a checked-in policy script. Because the workflow runs on pull_request_target, the script always comes from the base branch, so a PR cannot lower its own floor. The final severity is the higher of the floor and the model's score, and never goes below the floor.

Keep a separate never-auto-approve list for paths where risk and autonomy differ: .github/, scripts/, release and build files, go.mod/go.sum dependency sources, and agent instructions. Those paths can score low on user impact and still require a human. This is the risk-vs-autonomy split from lightninglabs/keybase-claw#42.

3. A rubric for real-world impact

Score how much harm a mistake could cause a node operator, not which files changed:

Score If the change is wrong Examples
CRITICAL Funds lost for good, or state corrupted signing, sweeps, justice transactions, channel state machine, DB migrations, wallet/keychain
HIGH Funds at risk, or a force-close fee and HTLC limits, routing policy, peer protocol messages, chain backends
MEDIUM A bug users notice and report RPC behavior, CLI, invoice fields, config
LOW Nothing users would notice tests, docs, logging, refactors with no behavior change

The score then moves at most one level, based on what the PR's CI and review actually exercised. It never drops below the path floor.

4. Calibration from labels we already apply

  • Add calibration.json with team-scored PRs: a low–high range plus who scored it and why. Seed it from existing severity-override-* uses.
  • Add a script that re-scores those PRs with the current rubric and path rules and reports the gap.
  • Any PR that changes the rubric or the policy runs the calibration and must show the gap did not grow.
  • New examples are recorded automatically. When a maintainer applies a severity-override-* label or posts their own score, that PR is added to the calibration set. Claudell can do this in a periodic PR. A merged PR that is later reverted or needs a follow-up fix is flagged as possibly under-scored.

Open questions

  • Does Gateway already produce a risk score? If so, calibrate that score and retire pr-severity.yml instead of running both.
  • Name of the trigger label (severity-check vs. reusing reclassify).
  • Model: keep claude-sonnet-5, or move to Opus 5.5 as #42 proposes? Running only when asked makes the larger model affordable.

litbot-9000 avatar Oct 27 '26 01:10 litbot-9000