Public: anyone can read this; the crew can change it.

An issue too large for one run is handed to the planner to split before a builder starts it #15845

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

torque/forge:torque/15820-an-issue-too-large-for-one-run-is-handed → main 0 commits fork 4 threads · 4 unresolved

  • Merged. torque/15820-an-issue-too-large-for-one-run-is-handed was merged into main as 2d4dc7d.

Review

Sign in to review this change.
16 files changed +390 −18
docs/features/capacity.md +4
@@ -25,3 +25,7 @@ under the row.
2525 `/settings/capacity` is one table in four groups (Crew, Checks, Hosted forges, Sign-in and safety): each row is the name, the value as an input, and its live effect in a few words ("6 running · 4 queued", "4 candidates"; `effectOf` in `src/actions/capacity_effects.ts`, one source: the MCP `knobs` tool's Speed, Pace floor and Queue depth rows call it too). Why, how it is computed, the key, the environment variable, the boot default and Put back fold behind one ⓘ. A changed setting shows "changed 22:33 by trevato" on its row, and the history is the Changes list below. Pace floor and queue depth are text that follows Crew runs at once, never inputs. One line on top is the load the knobs act on: machine load, checks, crew runs, merges in the last hour (`loadLine`).
2626
2727 **One Save** posts every input as `v.<key>`; the server writes only the rows that differ from what is in force and answers with each change and its effect. The terminal's Capacity screen prints the same effect and load line. Pinned by `test/capacity-first-view.test.ts` (under 800 words and 25 KB with every row folded).
28
29 ## Issue size limits
30
31 Under Crew, `issue.maxBoxes` (most `- [ ]` boxes, default 12) and `issue.maxChars` (longest body, default 6000) decide when an issue is too big for one run. An open issue over either is held and handed to the planner to split before a builder starts it, once; a person's ask is split, never dropped. Each row shows its reason and takes effect on the next pick.
docs/features/knobs.md +3 −2
@@ -4,13 +4,14 @@ row: Knobs
44 ---
55 # Knobs
66
7 Five dials for the crew, on **Settings › Crew** (admin), in the terminal's palette (`Knobs`; `e` turns the one under the cursor) and in the MCP `knobs` tool, in the same words (#10461).
7 Seven dials for the crew, on **Settings › Crew** (admin), in the terminal's palette (`Knobs`; `e` turns the one under the cursor) and in the MCP `knobs` tool, in the same words (#10461).
88
99 1. **Speed**: crew runs at once (`crew.concurrency`).
1010 2. **Weekly budget**: percent of the week to use (`week.use`, default 90); the rest is the reserve the pacer keeps.
1111 3. **Polish share**: percent of the week's spend polish may take (`polishShare`, applied to every repository the crew works).
1212 4. **Autonomy**: per repository, `off`, `ask` (plans need a nod, decisions come to you) or `go` (the decider answers, plans open).
13 5. **Feedback first**: always on; shown, not tuned.
13 5. **Most checklist boxes** (`issue.maxBoxes`, default 12) and 6. **Longest issue body** (`issue.maxChars`, default 6000 characters): an open issue over either is held and handed to the planner once, to split into smaller issues before a builder starts it. A person's ask is split, never dropped. Read on every pick.
14 7. **Feedback first**: always on; shown, not tuned.
1415
1516 A change applies on the next pump and leaves the event the setting's own page leaves (`capacity.changed`, `repo.settings_updated`).
1617
src/actions/capacity_effects.ts +4
@@ -63,6 +63,10 @@ export function effectOf(app: App, key: CapacityKey, value: string): string {
6363 return busy(counts(app, "check"));
6464 case "checks.shards":
6565 return `${value} process${value === "1" ? "" : "es"} per check`;
66 case "issue.maxBoxes":
67 return `more than ${value} boxes goes to the planner`;
68 case "issue.maxChars":
69 return `more than ${value} characters goes to the planner`;
6670 case "queue.batch":
6771 return `up to ${value} pulls per candidate`;
6872 case "cells.servingCores":
src/actions/knobs.ts +5
@@ -37,6 +37,11 @@ export async function setKnob(
3737 if (!changed.ok) return err(changed.error === "not_found" ? "not_found" : "invalid_value");
3838 return ok({ knob, value: v });
3939 }
40 if (knob === "boxes" || knob === "chars") {
41 const changed = changeCapacity(app, actor, knob === "boxes" ? "issue.maxBoxes" : "issue.maxChars", v);
42 if (!changed.ok) return err(changed.error === "not_found" ? "not_found" : "invalid_value");
43 return ok({ knob, value: v });
44 }
4045 if (knob === "polish") {
4146 const n = /^\d+$/.test(v) ? Number(v) : Number.NaN;
4247 if (!validPolishShare(n)) return err("invalid_value");
src/core/capacity.ts +19 −1
@@ -36,7 +36,9 @@ export type CapacityKey =
3636 | "children.ownFilesystem"
3737 | "guard_new_accounts"
3838 | "signin.edge"
39 | "pace.floor";
39 | "pace.floor"
40 | "issue.maxBoxes"
41 | "issue.maxChars";
4042
4143 interface Definition {
4244 /** What the settings page and the API call it. */
@@ -207,6 +209,22 @@ export const CAPACITY: Record<CapacityKey, Definition> = {
207209 reason: "Reviews and assigned work are a person waiting, so the pace never slows them to nothing.",
208210 help: "While the week's pace allows any slots, this many reviews and issues a person assigned may run at once, apart from the crew's own picks, however hard the pace slows them; also the fewest slots a fast burn slows a repository to. At the reserve's wall everything waits. Derived from Speed (half of it, at least 1), read-only; FORGE_PACE_FLOOR is ignored; read on every pump.",
209211 },
212 "issue.maxBoxes": {
213 label: "Most checklist boxes in an issue one run takes",
214 env: "FORGE_ISSUE_MAX_BOXES",
215 kind: { type: "count", min: 1, max: 100 },
216 fallback: "12",
217 reason: "Big issues go red and cost about three times as much, so the planner splits them first.",
outdated

Principle 8: this is shown beside the setting. Say it plainly, e.g. 'Big issues go red and cost about three times as much, so the planner splits them first.' Drop the issue number and the dollar and line stats.

218 help: "An open issue with more `- [ ]` boxes than this is held and handed to the planner to split before a builder starts it, once. A person's ask is split, never dropped. Read on every pick.",
219 },
220 "issue.maxChars": {
221 label: "Longest issue body one run takes (characters)",
222 env: "FORGE_ISSUE_MAX_CHARS",
223 kind: { type: "count", min: 500, max: 60000 },
224 fallback: "6000",
225 reason: "A long issue is a big change, and big changes fail more often, so the planner splits it first.",
outdated

Principle 8: same: plain words, no '#14250' in text a person reads.

226 help: "An open issue whose body is longer than this is held and handed to the planner to split before a builder starts it, once. A person's ask is split, never dropped. Read on every pick.",
227 },
210228 };
211229
212230 export const CAPACITY_KEYS = Object.keys(CAPACITY) as CapacityKey[];
src/crew/autonomy.ts +9 −1
@@ -130,6 +130,7 @@ import {
130130 parkedCount as countParks,
131131 parkedTwice,
132132 } from "./parks.ts";
133 import { handedTooLarge, noteTooLarge } from "./too_large.ts";
133134 import { due, reserveOf, reserveWords } from "./reserve.ts";
134135 import { createLog } from "../kernel/log.ts";
135136 import { err, ok, type Result } from "../kernel/result.ts";
@@ -510,6 +511,8 @@ async function driveOnce(
510511 const sorted = () => heldBy(app, repo, readyNow(repoGraph(app.db, repo.id, { sealed: true })), crew, active);
511512 let held = sorted();
512513 if (freeParked(app, repo, by, held) > 0) held = sorted();
514 // An issue over the size limit is handed to the planner once, with a note (#15820).
515 noteTooLarge(app, by, repo, held.by.too_large);
513516 // A pull red on three checks is said once on its issue and owed to the planner.
514517 noteRedThrice(app, repo, by);
515518 // An issue a landing left open with boxes is given the reviewer's pass once (#8682).
@@ -802,7 +805,12 @@ async function planIfThin(
802805 // The direction is the planner's own issue: a park on it (the breaker's, for runs that repeat)
803806 // hands the planner nothing it has not read, so it owes no pass. Counted, each park bought
804807 // another empty pass, which bought another park.
805 const handed = [...parkedTwice(app.db, [repo]), ...handedOverPulls(app.db, repo), ...redThricePulls(app.db, repo)].filter(
808 const handed = [
809 ...parkedTwice(app.db, [repo]),
810 ...handedTooLarge(app.db, repo),
811 ...handedOverPulls(app.db, repo),
812 ...redThricePulls(app.db, repo),
813 ].filter(
806814 (h) => h.issueId !== repo.directionIssueId,
807815 );
808816 const limbs = pendingReplans(app.db, repo);
src/crew/brief.ts +6 −2
@@ -402,6 +402,8 @@ export interface HandedOver {
402402 readonly reasons: readonly string[];
403403 /** Whether an agent wrote it. A person's ask is never dropped. */
404404 readonly byAgent?: boolean | undefined;
405 /** Held for its size, not parked: over the checklist-box or character limit. */
406 readonly large?: true | undefined;
405407 /** A pull whose three reviews asked for changes, not a parked issue. */
406408 readonly pull?: boolean | undefined;
407409 }
@@ -852,9 +854,11 @@ function parkedTwiceLines(input: TaskInput): string[] {
852854 if (handed.length === 0) return [];
853855 const issues = `$FORGE_URL/api/v1/repos/${input.repo.ownerName}/${input.repo.name}/issues`;
854856 return [
855 "The crew tried each of these twice and could not finish it as written. They are yours now, before anything new:",
857 handed.every((h) => h.large === true)
858 ? "These issues are too large for one run, so no builder starts them as written. Split each into issues one run can finish; they are yours now, before anything new:"
859 : "The crew tried each of these twice and could not finish it as written (or held it as too large for one run). They are yours now, before anything new:",
856860 ...handed.flatMap((issue) => [
857 `- ${issue.pull === true ? "Three reviews asked for changes, pull" : "Parked twice:"} #${issue.number} ${issue.title} (${issue.byAgent === true ? "the crew's own" : "a person's ask"})`,
861 `- ${issue.pull === true ? "Three reviews asked for changes, pull" : issue.large === true ? "Too large for one run:" : "Parked twice:"} #${issue.number} ${issue.title} (${issue.byAgent === true ? "the crew's own" : "a person's ask"})`,
858862 ...issue.reasons.map((reason, n) => ` ${n + 1}. ${reason}`),
859863 ]),
860864 "Leave every one of them in exactly one of these states, and say which in a comment on it:",
src/crew/held.ts +8
@@ -29,6 +29,9 @@
2929 * rerun alone on the same commit, or failed alone while other checks shared the
3030 * runner (`checks/report.ts`, #14404, #15240); it starts when a
3131 * second full-suite run is red for the same file and the report lifts its label.
32 * - `too_large`: its body is over the checklist-box or character limit (the
33 * crew settings page); the planner splits it once before a builder starts
34 * it (`too_large.ts`, #15820).
3235 * - `stalled`: a builder ran on it and left without a pull, and nobody
3336 * who directs the crew has spoken since. The next tick parks it in the
3437 * crew's name, which frees it (`stalls.ts`).
@@ -73,6 +76,7 @@ import { retryReason } from "./retry.ts";
7376 import { heldFiles, type FileHold } from "./file_holds.ts";
7477 import { expectedFiles, hotFiles, hotOverlap, pullsTouching, relievedFiles } from "./hot_files.ts";
7578 import { coveredByRedFix } from "./red_fix.ts";
79 import { limitsOf, tooLarge } from "./too_large.ts";
7680 import { landedUnder } from "./stalls.ts";
7781 import { isShared, sharedTitles, twinOf, type Twin } from "./twin.ts";
7882 import { variantGroupOf } from "../core/runs.ts";
@@ -88,6 +92,7 @@ export const HOLDS = [
8892 NO_KEY_HELD,
8993 CREW_OFF_HELD,
9094 "full_suite_flake",
95 "too_large",
9196 "stalled",
9297 "run_cap",
9398 "parked_twice",
@@ -278,6 +283,7 @@ export function heldBy(
278283 .filter(([, labels]) => labels.some((l) => l.name === ALONE_GREEN_LABEL))
279284 .map(([id]) => id),
280285 );
286 const limits = limitsOf(app.db);
281287 const holdOf = (issue: Issue): HoldName | null => {
282288 if (busyIssues.has(issue.id)) return "running";
283289 if (reds.has(issue.number)) return "red_thrice";
@@ -291,6 +297,7 @@ export function heldBy(
291297 if (noKey) return NO_KEY_HELD;
292298 if (crewOff) return CREW_OFF_HELD;
293299 if (flakes.has(issue.id)) return "full_suite_flake";
300 if (tooLarge(app.db, repo, issue, limits)) return "too_large";
294301 if (stalled(app, repo, issue, lastRuns)) return "stalled";
295302 if (capped().get(issue.id) ?? atRunCap(app, repo, issue)) return "run_cap";
296303 if (!isGo(repo) && parkedCount(app.db, repo, issue.id) >= PARK_STRIKES && retryReason(app.db, repo, issue, now) === undefined)
@@ -401,6 +408,7 @@ const HOLD_WORDS: Readonly<Record<HoldName, string>> = {
401408 [NO_KEY_HELD]: "this forge has no model key; it starts when one is added",
402409 [CREW_OFF_HELD]: CREW_OFF_WORDS,
403410 full_suite_flake: "red only in the full suite; it waits for a second full-suite red",
411 too_large: "too large for one run; the planner will split it first",
404412 stalled: "a builder ran on it and left without a pull",
405413 run_cap: "it has used its runs for the day",
406414 parked_twice: "parked twice; it is the planner's",
src/crew/knobs.ts +22 −3
@@ -11,7 +11,7 @@
1111
1212 import { effectOf } from "../actions/capacity_effects.ts";
1313 import type { App } from "../app.ts";
14 import { capacityValue, paceFloor, queueDepth, weekUse } from "../core/capacity.ts";
14 import { CAPACITY, capacityValue, paceFloor, queueDepth, weekUse } from "../core/capacity.ts";
1515 import { labelsForIssues } from "../core/issues.ts";
1616 import { getRepoById, isGo, type Repo } from "../core/repos.ts";
1717 import { listActive } from "../core/runs.ts";
@@ -19,7 +19,7 @@ import { waitingOnPeople } from "./people_first.ts";
1919 import { POLISH_SHARE_DEFAULT, isPolish, polishSpend } from "./polish_share.ts";
2020 import { budgetEffect } from "./week_read.ts";
2121
22 export type KnobId = "speed" | "budget" | "polish" | "autonomy" | "feedback" | "floor" | "depth" | "reserve";
22 export type KnobId = "speed" | "budget" | "polish" | "autonomy" | "feedback" | "boxes" | "chars" | "floor" | "depth" | "reserve";
2323 /** The dials Speed sets: shown on the panel with their value, never turned there. */
2424 const FOLLOWS: Readonly<Record<string, string>> = {
2525 floor: "Speed",
@@ -93,7 +93,24 @@ export function knobRepos(app: App, limit = 12): Repo[] {
9393 .flatMap((r) => getRepoById(app.db, r.id) ?? []);
9494 }
9595
96 /** The five knobs now (Autonomy is one row per repository). */
96 /** A size limit's row: the capacity setting's reason beside it, and where an issue over it goes. */
97 function sizeRow(id: "boxes" | "chars", name: string, key: "issue.maxBoxes" | "issue.maxChars", app: App): KnobRow {
98 const def = CAPACITY[key];
99 const kind = def.kind;
100 if (kind.type !== "count") throw new Error(`${key} is a count`);
outdated

Dead fallback: both keys are count kinds, so the : { min: 1, max: 100 } branch never runs. Narrow the type or read min/max directly.

101 return {
102 id,
103 name,
104 does: `An open issue over this is handed to the planner to split before a builder starts it. Why: ${def.reason}`,
105 value: capacityValue(app.db, key),
106 control: "number",
107 min: kind.min,
108 max: kind.max,
109 effect: effectOf(app, key, capacityValue(app.db, key)),
110 };
111 }
112
113 /** The seven knobs now (Autonomy is one row per repository). */
97114 export function readKnobs(app: App, now: Date = new Date()): KnobRow[] {
98115 const repos = knobRepos(app);
99116 const live = repos.filter((r) => r.autonomy !== "off");
@@ -162,6 +179,8 @@ export function readKnobs(app: App, now: Date = new Date()): KnobRow[] {
162179 max: 50,
163180 effect: `polish ${spend === undefined ? 0 : Math.round(spend.percent)}% of this week's spend · ${polishWaiting(app, live)} polish issues waiting`,
164181 },
182 sizeRow("boxes", "Issue size: boxes", "issue.maxBoxes", app),
183 sizeRow("chars", "Issue size: characters", "issue.maxChars", app),
165184 ];
166185 for (const repo of repos) {
167186 const word = autonomyWord(repo);
src/crew/runner.ts +3
@@ -162,6 +162,7 @@ import { laterGate } from "./later.ts";
162162 import { MERGES_CLEAN_NOW, mergesCleanNow } from "./clean_now.ts";
163163 import { handedLimbs } from "./handed_limbs.ts";
164164 import { parkedTwice, parkReasons } from "./parks.ts";
165 import { handedTooLarge } from "./too_large.ts";
165166 import { budgetLimit, budgetVerdict, cutOffBy, isOwnForge } from "./forge_budget.ts";
166167 import { boxesOf, landedBoxes } from "./box_pass.ts";
167168 import { reviewRange } from "./review_range.ts";
@@ -1431,6 +1432,7 @@ async function work(
14311432 ? {
14321433 parkedTwice: [
14331434 ...parkedTwice(app.db, [repo]),
1435 ...handedTooLarge(app.db, repo),
14341436 ...handedOverPulls(app.db, repo),
14351437 ],
14361438 limbs: handedLimbs(app, repo),
@@ -1646,6 +1648,7 @@ async function work(
16461648 const handed =
16471649 brief.role === "planner" &&
16481650 (parkedTwice(app.db, [repo]).length > 0 ||
1651 handedTooLarge(app.db, repo).length > 0 ||
16491652 handedOverPulls(app.db, repo).length > 0 ||
16501653 handedLimbs(app, repo).length > 0);
16511654 const facts = modelFacts(
src/crew/too_large.ts added +141
@@ -0,0 +1,141 @@
1 /**
2 * An issue too large for one run (#15820, point 2 of #14250). Size, not
3 * wording, predicts red checks and cost: steward issues run a median 433
4 * lines and $4.43 per landing against 125 lines and $1.42. An open issue
5 * whose body has more checklist boxes, or more characters, than the two
6 * knobs allow (`issue.maxBoxes`, `issue.maxChars`, on the crew settings
7 * page) is held as `too_large` (`held.ts`) and handed to the planner to
8 * split before a builder starts it, once: the crew writes a note on it, the
9 * planner is owed one pass (`autonomy.ts`), and when that pass has ended the
10 * hold lifts, so an issue the planner left whole is not held for good.
11 *
12 * A person's ask is held the same way and the note says the planner will
13 * split it, never that it was dropped. Plain data in, plain data out.
14 */
15
16 import type { Database } from "bun:sqlite";
17 import type { App } from "../app.ts";
18 import { addComment, getIssueById, standsForPerson, type Issue } from "../core/issues.ts";
19 import { capacityValue } from "../core/capacity.ts";
20 import type { Repo } from "../core/repos.ts";
21 import { getUserById, type User } from "../core/users.ts";
22 import { speaksForCrew } from "./direct.ts";
23 import type { ParkedTwice } from "./parks.ts";
24
25 export interface Limits {
26 readonly boxes: number;
27 readonly chars: number;
28 }
29
30 /** What every hand-over note starts with. */
31 export const TOO_LARGE_NOTE = "Too large for one run: ";
32
33 /** The two limits now, read on every pick. */
34 export function limitsOf(db: Database): Limits {
35 return { boxes: Number(capacityValue(db, "issue.maxBoxes")), chars: Number(capacityValue(db, "issue.maxChars")) };
36 }
37
38 /** A markdown checklist line, ticked or not: `- [ ] x`, `* [x] y`, `+ [X] z`. */
39 const BOX = /^[ \t]*[-*+][ \t]+\[[ xX]\]/gm;
40
41 /** The checklist boxes and characters of a body. */
42 export function sizeOf(body: string): { boxes: number; chars: number } {
43 return { boxes: (body.match(BOX) ?? []).length, chars: body.length };
44 }
45
46 /**
47 * Why `issue` is over a limit, as a line; undefined when it is within both (a limit is the most
48 * allowed).
49 */
50 export function overLimit(issue: Pick<Issue, "body">, limits: Limits): string | undefined {
51 const { boxes, chars } = sizeOf(issue.body);
52 const over: string[] = [];
53 if (boxes > limits.boxes) over.push(`${boxes} checklist boxes, more than ${limits.boxes}`);
54 if (chars > limits.chars) over.push(`${chars} characters, more than ${limits.chars}`);
55 return over.length === 0 ? undefined : over.join(" and ");
56 }
57
58 /**
59 * The note the crew writes: for a person's ask it says the planner will split it, never that it was
60 * dropped.
61 */
62 export function noteText(why: string, person: boolean): string {
63 return `${TOO_LARGE_NOTE}${why}. ${person ? "It is a person's ask and stays: the" : "The"} planner will split it into smaller issues before a builder starts it${person ? ", and it is not dropped" : ""}.`;
64 }
65
66 /** The crew's newest hand-over note on `issueId`: written by someone who may direct the crew. */
67 function noteOn(db: Database, repo: Repo, issueId: string): string | undefined {
68 const rows = db
69 .query<{ at: string; author_id: string }, [string]>(
70 `SELECT created_at AS at, author_id FROM comment
71 WHERE issue_id = ?1 AND body LIKE '${TOO_LARGE_NOTE}%' AND origin_author IS NULL
72 ORDER BY created_at DESC, id DESC`,
73 )
74 .all(issueId);
75 return rows.find((r) => speaksForCrew(db, repo, getUserById(db, r.author_id)))?.at;
76 }
77
78 /** Whether a planning pass that started after `at` has ended: the hand-over is answered. */
79 function answered(db: Database, repo: Repo, at: string): boolean {
80 if (repo.directionIssueId === null) return false;
81 return (
82 (db
83 .query<{ n: number }, [string, string]>(
84 `SELECT COUNT(*) AS n FROM run WHERE issue_id = ?1 AND kind = 'agent'
85 AND state IN ('ok','failed') AND created_at > ?2`,
86 )
87 .get(repo.directionIssueId, at)?.n ?? 0) > 0
88 );
89 }
90
91 /** Whether `issue` is held as too large: over a limit, and not yet handed over and answered. */
92 export function tooLarge(db: Database, repo: Repo, issue: Issue, limits: Limits = limitsOf(db)): boolean {
93 if (issue.id === repo.directionIssueId || overLimit(issue, limits) === undefined) return false;
94 const at = noteOn(db, repo, issue.id);
95 return at === undefined || !answered(db, repo, at);
96 }
97
98 /** Write the note on each of `issues` that has none yet; returns how many. Once per issue, ever. */
99 export function noteTooLarge(app: App, by: User, repo: Repo, issues: readonly Issue[]): number {
100 const limits = limitsOf(app.db);
101 let n = 0;
102 for (const issue of issues) {
103 const why = overLimit(issue, limits);
104 if (why === undefined || noteOn(app.db, repo, issue.id) !== undefined) continue;
105 const person = standsForPerson(app.db, issue);
106 if (addComment(app.db, { issueId: issue.id, authorId: by.id, body: noteText(why, person) }).ok) n++;
107 }
108 return n;
109 }
110
111 /** The open issues handed to the planner and not answered, shaped like a parked one. */
112 export function handedTooLarge(db: Database, repo: Repo): (ParkedTwice & { large: true })[] {
113 const limits = limitsOf(db);
114 const noted = db
115 .query<{ id: string }, [string]>(
116 `SELECT DISTINCT i.id FROM issue i JOIN comment c ON c.issue_id = i.id
117 WHERE i.repo_id = ?1 AND i.kind = 'issue' AND i.state = 'open'
118 AND c.body LIKE '${TOO_LARGE_NOTE}%' AND c.origin_author IS NULL
119 ORDER BY i.number`,
120 )
121 .all(repo.id);
122 const out: (ParkedTwice & { large: true })[] = [];
123 for (const { id } of noted) {
124 const issue = getIssueById(db, id);
125 if (issue === undefined || issue.id === repo.directionIssueId) continue;
126 const why = overLimit(issue, limits);
127 const at = noteOn(db, repo, issue.id);
128 if (why === undefined || at === undefined || answered(db, repo, at)) continue;
129 out.push({
130 issueId: issue.id,
131 repoId: repo.id,
132 number: issue.number,
133 title: issue.title,
134 reasons: [why],
135 byAgent: !standsForPerson(db, issue),
136 at,
137 large: true,
138 });
139 }
140 return out;
141 }
src/http/mcp/tools/knobs.ts +3 −3
@@ -5,12 +5,12 @@ import { good, bad, type Tool } from "../shared.ts";
55
66 export const tool: Tool = {
77 name: "knobs",
8 doc: "`{ knob?, value?, repo?, dryRun? }` (forge admin): the crew's five knobs in the page's words, each with its live effect: `speed` (runs at once, 1-16), `budget` (percent of the week to use, 10-100), `polish` (percent share, 0-50), `autonomy` (`off`, `ask` or `go`, with `repo` as `owner/name`), and `feedback` (always on). With `knob` and `value`, planned first (`dryRun` is true unless `false`); applying needs an admin-scope token",
9 description: "The crew's five knobs and what each does now. With `knob` and `value`, plans.",
8 doc: "`{ knob?, value?, repo?, dryRun? }` (forge admin): the crew's seven knobs in the page's words, each with its live effect: `speed` (runs at once, 1-16), `budget` (percent of the week to use, 10-100), `polish` (percent share, 0-50), `boxes` and `chars` (most checklist boxes and characters an issue may have before the planner splits it), `autonomy` (`off`, `ask` or `go`, with `repo` as `owner/name`), and `feedback` (always on). With `knob` and `value`, planned first (`dryRun` is true unless `false`); applying needs an admin-scope token",
outdated

The doc still says 'the crew's five knobs' while listing eight; fix the count.

9 description: "What each crew knob does now; with `knob` and `value`, plans.",
1010 inputSchema: {
1111 type: "object",
1212 properties: {
13 knob: { type: "string", enum: ["speed", "budget", "polish", "autonomy"] },
13 knob: { type: "string", enum: ["speed", "budget", "polish", "autonomy", "boxes", "chars"] },
1414 value: { type: "string", maxLength: 16 },
1515 repo: { type: "string", maxLength: 100 },
1616 dryRun: { type: "boolean" },
src/web/pages/capacity.ts +1 −1
@@ -30,7 +30,7 @@ function requireAdmin(ctx: Ctx): Response | undefined {
3030
3131 /** The groups of the table, in order: each a heading and the keys it holds. */
3232 const GROUPS: readonly { readonly title: string; readonly keys: readonly CapacityKey[] }[] = [
33 { title: "Crew", keys: ["crew.concurrency", "pace.floor", "week.use"] },
33 { title: "Crew", keys: ["crew.concurrency", "pace.floor", "week.use", "issue.maxBoxes", "issue.maxChars"] },
3434 { title: "Checks", keys: ["checks.concurrency", "checks.shards", "queue.batch", "queue.depth", "cells.servingCores"] },
3535 {
3636 title: "Hosted forges",
test/capacity-first-view.test.ts +2 −2
@@ -65,9 +65,9 @@ test("the first view: under 800 words and 25 KB with every row folded, every set
6565 expect(new TextEncoder().encode(main).length).toBeLessThan(25_000);
6666 expect(words(page)).toBeLessThan(800);
6767 const rows = [...page.matchAll(/<tr data-key="([^"]+)">/g)].map((m) => m[1]);
68 expect(rows.length).toBe(18);
68 expect(rows.length).toBe(20);
6969 // The rest is behind one ⓘ per row, closed.
70 expect(page.match(/<details class="hint why"/g)).toHaveLength(18);
70 expect(page.match(/<details class="hint why"/g)).toHaveLength(20);
7171 expect(page).not.toMatch(/<details[^>]*\sopen/);
7272 expect(page).toContain("running");
7373 expect(page).toContain("queued");
test/crew-too-large.test.ts added +157
@@ -0,0 +1,157 @@
1 /**
2 * An issue too large for one run is held and handed to the planner once
3 * (#15820): over 12 checklist boxes or 6000 characters by default, the
4 * limits being knobs; under them it is startable.
5 */
6 import { seatAs } from "./helpers/seat.ts";
7 import { afterAll, beforeAll, describe, expect, spyOn, test } from "bun:test";
8 import { mkdtemp, rm } from "node:fs/promises";
9 import { tmpdir } from "node:os";
10 import { join } from "node:path";
11 import { createApp, type App } from "../src/app.ts";
12 import { addToCrew, createAgent } from "../src/actions/crew.ts";
13 import { openIssue } from "../src/actions/issues.ts";
14 import { setKnob } from "../src/actions/knobs.ts";
15 import { createRepo, updateRepoSettings } from "../src/actions/repos.ts";
16 import { listComments, type Issue } from "../src/core/issues.ts";
17 import { getRepoById, listAutonomousRepos, type Repo } from "../src/core/repos.ts";
18 import { claimRun, createRun, finishRun } from "../src/core/runs.ts";
19 import { createUser, getUserByName, type User } from "../src/core/users.ts";
20 import { autonomyTick } from "../src/crew/autonomy.ts";
21 import { heldNow } from "../src/crew/held.ts";
22 import { readKnobs } from "../src/crew/knobs.ts";
23 import { handedTooLarge, overLimit, sizeOf, TOO_LARGE_NOTE } from "../src/crew/too_large.ts";
24 import { serve, type Servers } from "../src/http/server.ts";
25
26 let dataDir: string;
27 let app: App;
28 let servers: Servers;
29 let alice: User;
30
31 const boxes = (n: number): string => Array.from({ length: n }, (_, i) => `- [ ] step ${i}`).join("\n");
32
33 beforeAll(async () => {
34 dataDir = await mkdtemp(join(tmpdir(), "forge-toolarge-"));
35 app = createApp({ dataDir, port: 0 });
36 servers = await serve(app);
37 const a = await createUser(app.db, {
38 origin: "seed",
39 trusted: true,
40 username: "alice",
41 email: "[email protected]",
42 password: "a-good-passphrase",
43 adminIfFirst: true,
44 });
45 if (!a.ok) throw new Error(a.error);
46 alice = a.value;
47 });
48
49 afterAll(async () => {
50 servers.stop();
51 app.close();
52 await rm(dataDir, { recursive: true, force: true });
53 });
54
55 async function crewed(name: string): Promise<Repo> {
56 const created = await createRepo(app, alice, { name, visibility: "private" });
57 if (!created.ok) throw new Error(String(created.error));
58 for (const n of ["atlas", "mason"]) {
59 if (getUserByName(app.db, n) === undefined) await createAgent(app, alice, { username: n });
60 expect(addToCrew(app, alice, created.value, n).ok).toBe(true);
61 }
62 seatAs(app.db, created.value.id, getUserByName(app.db, "atlas")!.id, "planner");
63 const set = await updateRepoSettings(app, alice, created.value, {
64 autonomy: "assisted",
65 autonomyDirection: "Keep the engine small.",
66 autonomySlots: 2,
67 autonomyBy: alice.id,
68 });
69 if (!set.ok) throw new Error(JSON.stringify(set.error));
70 return getRepoById(app.db, created.value.id)!;
71 }
72
73 function open(repo: Repo, title: string, body: string): Issue {
74 const opened = openIssue(app, alice, repo, { title, body });
75 if (!opened.ok) throw new Error(String(opened.error));
76 return opened.value;
77 }
78
79 async function tick(repo: Repo): Promise<string> {
80 for (const other of listAutonomousRepos(app.db))
81 if (other.id !== repo.id) app.db.query("UPDATE repo SET autonomy = 'off' WHERE id = ?1").run(other.id);
82 const lines: string[] = [];
83 const spy = spyOn(console, "info").mockImplementation((l: unknown) => void lines.push(String(l)));
84 try {
85 await autonomyTick(app, new Date(), async () => 0);
86 } finally {
87 spy.mockRestore();
88 }
89 await Promise.resolve();
90 return lines.join("\n");
91 }
92
93 describe("size", () => {
94 test("counts ticked and unticked boxes and characters, and names what is over", () => {
95 expect(sizeOf(`${boxes(3)}\n* [x] done\n + [X] nested\nnot - [ ] a box`)).toEqual({ boxes: 5, chars: 80 });
96 const limits = { boxes: 12, chars: 6000 };
97 expect(overLimit({ body: boxes(12) }, limits)).toBeUndefined();
98 expect(overLimit({ body: boxes(13) }, limits)).toContain("13 checklist boxes, more than 12");
99 expect(overLimit({ body: "x".repeat(6000) }, limits)).toBeUndefined();
100 expect(overLimit({ body: "x".repeat(6001) }, limits)).toContain("6001 characters, more than 6000");
101 });
102 });
103
104 describe("an issue too large for one run", () => {
105 test("is held and handed to the planner once; one under the limit is startable", async () => {
106 const repo = await crewed("toolarge1");
107 const big = open(repo, "Everything at once", boxes(13));
108 const wide = open(repo, "Wordy", "x".repeat(6001));
109 const small = open(repo, "One small thing", boxes(12));
110
111 const held = heldNow(app, repo);
112 expect(held.by.too_large.map((i) => i.number)).toEqual([big.number, wide.number]);
113 expect(held.startable.map((r) => r.issue.number)).toEqual([small.number]);
114
115 const line = await tick(repo);
116 expect(line).toContain("planner asked");
117 const note = listComments(app.db, big.id).find((c) => c.body.startsWith(TOO_LARGE_NOTE))!;
118 expect(note.body).toContain("13 checklist boxes, more than 12");
119 // A person's ask: it is said to be split, never dropped.
120 expect(note.body).toContain("planner will split it");
121 expect(note.body).toContain("not dropped");
122 expect(handedTooLarge(app.db, getRepoById(app.db, repo.id)!).map((h) => h.number)).toEqual([big.number, wide.number]);
123
124 // Handed once: a second tick writes no second note.
125 await tick(repo);
126 expect(listComments(app.db, big.id).filter((c) => c.body.startsWith(TOO_LARGE_NOTE))).toHaveLength(1);
127
128 const planning = createRun(app.db, {
129 repoId: repo.id,
130 kind: "agent",
131 issueId: getRepoById(app.db, repo.id)!.directionIssueId!,
132 actorId: alice.id,
133 reason: "assigned",
134 });
135 claimRun(app.db, planning.id);
136 // Still running: the hand-over is not answered yet, so the hold stays.
137 expect(heldNow(app, getRepoById(app.db, repo.id)!).by.too_large).toHaveLength(2);
138 finishRun(app.db, planning.id, { state: "ok", summary: "left it", costUsd: 0.1 });
139 expect(heldNow(app, getRepoById(app.db, repo.id)!).by.too_large).toHaveLength(0);
140 expect(handedTooLarge(app.db, getRepoById(app.db, repo.id)!)).toHaveLength(0);
141 });
142
143 test("the limit is a knob with its reason beside it", async () => {
144 const repo = await crewed("toolarge2");
145 const big = open(repo, "Fourteen steps", boxes(14));
146 const row = readKnobs(app).find((r) => r.id === "boxes")!;
147 expect(row.value).toBe("12");
148 expect(row.does).toContain("cost about three times as much");
149 expect(heldNow(app, repo).by.too_large.map((i) => i.number)).toEqual([big.number]);
150
151 expect((await setKnob(app, alice, "boxes", "20")).ok).toBe(true);
152 expect(readKnobs(app).find((r) => r.id === "boxes")!.value).toBe("20");
153 expect(heldNow(app, repo).by.too_large).toHaveLength(0);
154 expect((await setKnob(app, alice, "boxes", "0")).ok).toBe(false);
155 await setKnob(app, alice, "boxes", "12");
156 });
157 });
test/knobs.test.ts +3 −3
@@ -50,14 +50,14 @@ afterAll(async () => {
5050
5151 test("the panel has Speed, the derived pace floor and queue depth, Weekly budget, Polish share, Autonomy per repository and Feedback first, each with an effect", () => {
5252 const rows = readKnobs(app);
53 expect(rows.map((r) => r.id)).toEqual(["speed", "floor", "depth", "budget", "reserve", "polish", "autonomy", "feedback"]);
53 expect(rows.map((r) => r.id)).toEqual(["speed", "floor", "depth", "budget", "reserve", "polish", "boxes", "chars", "autonomy", "feedback"]);
5454 for (const r of rows) {
5555 expect(r.does.length).toBeGreaterThan(0);
5656 expect(r.effect.length).toBeGreaterThan(0);
5757 }
5858 expect(rows[0]!.effect).toMatch(/\d+ running · \d+ queued/);
59 expect(rows[7]!.effect).toBe("nothing from a person waiting");
60 expect(knobLines(rows)).toHaveLength(8);
59 expect(rows[9]!.effect).toBe("nothing from a person waiting");
60 expect(knobLines(rows)).toHaveLength(10);
6161 });
6262
6363 test("Speed 4 → 2 is read by the next pump", async () => {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs