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

@ -55,6 +55,7 @@ import "./ReviewTryOut.css";
const TRY_OUT = "/api/review-classifier/try-out";
const RULES = "/api/review-classifier/rules";
const OPEN_PR = "/api/review-classifier/open-pr";
const SETTINGS = "/api/review-classifier/settings";
const PULL_REPOS = "/api/pulls/repos";
const PULLS = "/api/pulls";
// How long the repo field rests before its PRs are fetched, so typing a repo
@ -111,6 +112,9 @@ export function ReviewTryOut() {
useState<ProblemDetails | null>(null);
const [pulls, setPulls] = useState<OpenPull[]>([]);
const [pullsError, setPullsError] = useState<ProblemDetails | null>(null);
const [maxClassifications, setMaxClassifications] = useState<number | null>(
null,
);
const running = starting || runId !== null;
@ -139,6 +143,27 @@ export function ReviewTryOut() {
};
}, []);
// How many rows a run takes: the classifier settings', read once. Until it
// is known, or when it cannot be read, the run endpoint is the only cap.
useEffect(() => {
let cancelled = false;
void (async () => {
try {
const res = await fetch(SETTINGS);
if (cancelled || !res.ok) return;
const body = (await res.json()) as { max_classifications?: number };
if (!cancelled && typeof body.max_classifications === "number") {
setMaxClassifications(body.max_classifications);
}
} catch {
// The endpoint still refuses a run that is too long.
}
})();
return () => {
cancelled = true;
};
}, []);
// The open PRs of the repo once it is typed or picked and has stopped
// changing. A repo that is not valid yet has no list.
useEffect(() => {
@ -224,7 +249,7 @@ export function ReviewTryOut() {
const openPrProblem = rowsProblem(repo, drafts);
const problem = runProblem(repo, pr, drafts);
const capProblem = addProblem(drafts.length);
const capProblem = addProblem(drafts.length, maxClassifications);
async function run(e: Event) {
e.preventDefault();

View file

@ -150,14 +150,13 @@ export function duplicateName(drafts: ClassificationDraft[]): string | null {
return null;
}
/** More classifications than this are not offered a row. It is the try-out
* endpoint's own cap, which answers a longer list with a 400. */
export const MAX_CLASSIFICATIONS = 10;
/** Why another row cannot be added, or null while there is room. */
export function addProblem(count: number): string | null {
return count >= MAX_CLASSIFICATIONS
? `a run takes at most ${MAX_CLASSIFICATIONS} classifications`
/** Why another row cannot be added, or null while there is room. `max` is the
* classifier settings' `max_classifications`, the cap the try-out endpoint
* answers a longer list with a 400 for; null while the settings have not
* loaded, when the endpoint stays the only gate. */
export function addProblem(count: number, max: number | null): string | null {
return max !== null && count >= max
? `a run takes at most ${max} classifications, as the classifier's settings say`
: null;
}