Watch
0
0
Fork
You've already forked hyperhive
0

review classifier: the most classifications a run carries is a setting

The limit was a constant of ten in swarm-wire, so a repo with eleven rules
could not be reviewed and nothing short of a rebuild changed it. It is now
`max_classifications` in the classifier settings, beside
`max_concurrent_reviews`: 1 to 1000, ten until set, and a document stored
before the field decodes with the default. The classifier settings form in
the swarm UI gets a "rules per review" field, and the try-out's add button
stops at the saved limit instead of a hard-coded ten.

The controller checks a try-out, and a requested review's rules file, against
the setting where the run starts. The rules file itself may hold up to the
1000 the setting allows, so raising the limit needs no change to a repo.
A review whose rules exceed the limit posts a no-verdict comment saying so.

A run's reply deadline was a constant that covered ten classifications, a
minute plus three each. It is now computed from the run's own size, so a
bigger run waits as long as it needs and a default-sized one still waits 31
minutes. The classifier's answer window in the queue permissions covers the
biggest run the setting allows.
This commit is contained in:
iris 2026-11-07 10:37:52 +01:00 • committed by mara
commit cffe8895df
2 changed files with 400 additions and 101 deletions

View file

@ -1,5 +1,6 @@
// <ClassifierSettings> — the review classifier's runtime, model, effort and
// how many requested reviews run at once, shown and saved here
// how many requested reviews run at once and how many rules a run takes, shown
// and saved here
// (`GET`/`PUT /api/review-classifier/settings`). A PUT changes only the
// fields it carries: the form sends the runtime, model, effort and limit, and
// the ACP provider only while the runtime is ACP, so the stored provider
@ -19,7 +20,9 @@ import { TextField } from "../../ui/text-field/TextField.js";
import {
EFFORTS,
MAX_REVIEWS,
MAX_RULES,
MIN_REVIEWS,
MIN_RULES,
changed,
draftOf,
settingsProblem,
@ -177,6 +180,13 @@ export function ClassifierSettings() {
pattern="[0-9]+"
onInput={(max) => edit({ ...draft, max })}
/>
<TextField
id="classifier-max-rules"
label={`rules per review (${MIN_RULES} to ${MAX_RULES})`}
value={draft.maxRules}
pattern="[0-9]+"
onInput={(maxRules) => edit({ ...draft, maxRules })}
/>
</FieldGrid>
{draft.runtime === "acp" ? (
<fieldset class="ui-classifier-settings-group">

View file

@ -33,6 +33,8 @@ export interface ClassifierSettingsBody {
* `--effort`, or opencode's. */
effort: Effort | null;
max_concurrent_reviews: number;
/** The most classifications (rules) one run carries. */
max_classifications: number;
runtime: Runtime;
/** The provider record. It stays stored while the runtime is `api-key`. */
acp: AcpSettings | null;
@ -44,6 +46,8 @@ export interface SettingsDraft {
/** An effort, or `""` for the runtime's own default. */
effort: string;
max: string;
/** The most classifications one run carries. */
maxRules: string;
runtime: Runtime;
acpUrl: string;
acpModel: string;
@ -56,6 +60,8 @@ export interface SettingsDraft {
export const MIN_REVIEWS = 1;
export const MAX_REVIEWS = 8;
export const MIN_RULES = 1;
export const MAX_RULES = 1000;
export function draftOf(s: ClassifierSettingsBody): SettingsDraft {
const acp = s.acp;
@ -63,6 +69,7 @@ export function draftOf(s: ClassifierSettingsBody): SettingsDraft {
model: s.model,
effort: s.effort ?? "",
max: String(s.max_concurrent_reviews),
maxRules: String(s.max_classifications),
runtime: s.runtime,
acpUrl: acp?.base_url ?? "",
acpModel: acp?.model ?? "",
@ -86,6 +93,15 @@ export function maxValue(text: string): number | null {
return n >= MIN_REVIEWS && n <= MAX_REVIEWS ? n : null;
}
/** The rules limit as a number, or null when it is not a whole number in
* range. */
export function rulesValue(text: string): number | null {
const t = text.trim();
if (!/^\d+$/.test(t)) return null;
const n = Number(t);
return n >= MIN_RULES && n <= MAX_RULES ? n : null;
}
/** A price as a number, or null when it is not a number of 0 or more. */
export function priceValue(text: string): number | null {
const t = text.trim();
@ -124,6 +140,9 @@ export function settingsProblem(d: SettingsDraft): string | null {
if (maxValue(d.max) === null) {
return `concurrent reviews is a whole number from ${MIN_REVIEWS} to ${MAX_REVIEWS}`;
}
if (rulesValue(d.maxRules) === null) {
return `rules per review is a whole number from ${MIN_RULES} to ${MAX_RULES}`;
}
return d.runtime === "acp" ? acpProblem(d) : null;
}
@ -153,6 +172,7 @@ export function toSettings(
model: d.model.trim(),
effort: d.effort === "" ? null : (d.effort as Effort),
max_concurrent_reviews: maxValue(d.max) ?? MIN_REVIEWS,
max_classifications: rulesValue(d.maxRules) ?? MIN_RULES,
runtime: d.runtime,
};
return d.runtime === "acp" ? { ...body, acp: toAcp(d) } : body;
@ -169,6 +189,7 @@ export function changed(
d.model.trim() !== now.model ||
d.effort !== now.effort ||
d.max.trim() !== now.max ||
d.maxRules.trim() !== now.maxRules ||
d.runtime !== now.runtime;
if (base) return true;
// The provider fields only save on the ACP runtime.
@ -185,12 +206,16 @@ export function changed(
/** The settings in force as one short line, for a folded view of them: the
* runtime and the model it runs, the effort when one is set, and how many
* reviews run at once. The model is the provider's under ACP. */
* reviews run at once and how many rules a run takes. The model is the
* provider's under ACP. */
export function settingsSummary(s: ClassifierSettingsBody): string {
const model = s.runtime === "acp" ? (s.acp?.model ?? "") : s.model;
const parts = [s.runtime, model, s.effort ? `${s.effort} effort` : ""].filter(
(p) => p !== "",
);
parts.push(`${s.max_concurrent_reviews} at once`);
parts.push(
`${s.max_concurrent_reviews} at once`,
`up to ${s.max_classifications} rules`,
);
return parts.join(" · ");
}