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

Knobs: one panel on the crew page with five plain dials, each showing its live effect, editable in place #10468

Closed opened this in answer to
Closed without merging

scout/forge:scout/10461-knobs-one-panel-on-the-crew-page-with-fi → main 1 commit fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
21 files changed +618 −71
docs/features/knobs.md added +12
@@ -0,0 +1,12 @@
1 # Knobs
2
3 Five dials for the crew, on **Settings › Crew** (admin), in the terminal's palette (`Knobs`) and in the MCP `knobs` tool, in the same words (#10461).
4
5 1. **Speed**: crew runs at once (`crew.concurrency`). The pace floor (half, at least 1) and the merge-queue depth are derived from it.
6 2. **Weekly budget**: percent of the week to use (`week.use`, default 90); the rest is the reserve the pacer keeps.
7 3. **Polish share**: percent of the week's spend polish may take (`polishShare`, applied to every repository the crew works). The small-issue slot share is fixed at 30% and the polish run cap at 60 minutes: no longer dials.
8 4. **Autonomy**: per repository, `off`, `ask` (plans need a nod, decisions come to you) or `go` (the decider answers, plans open).
9 5. **Feedback first**: always on; shown, not tuned.
10
11 A change applies on the next pump and leaves the event the setting's own page leaves (`capacity.changed`, `repo.settings_updated`).
12 Not done: the per-repository dollar ceiling (`autonomyCeilingUsd`) and `reserve.ts`'s two-per-slot reserve still stand.
src/actions/knobs.ts added +57
@@ -0,0 +1,57 @@
1 /**
2 * Turning a knob (#10461), an admin's: each one writes through the setting
3 * the forge already keeps and leaves the same event that setting's own page
4 * leaves (`capacity.changed`, `repo.settings_updated`), so the feed says who
5 * turned what. The next pump reads the change; nothing restarts.
6 */
7
8 import type { App } from "../app.ts";
9 import { changeCapacity } from "./capacity.ts";
10 import { updateRepoSettings } from "./repos.ts";
11 import { getRepo } from "../core/repos.ts";
12 import { AUTONOMY_WORDS, knobRepos, type AutonomyWord, type KnobId } from "../crew/knobs.ts";
13 import { validPolishShare } from "../crew/small_share.ts";
14 import { err, ok, type Result } from "../kernel/result.ts";
15 import type { User } from "../core/users.ts";
16
17 export type KnobError = "not_found" | "no_such_knob" | "invalid_value";
18
19 const WORDS: Record<AutonomyWord, { autonomy: "off" | "autonomous"; plansNeedNod: boolean; decisionsBy: "me" | "decider" }> = {
20 off: { autonomy: "off", plansNeedNod: true, decisionsBy: "me" },
21 ask: { autonomy: "autonomous", plansNeedNod: true, decisionsBy: "me" },
22 go: { autonomy: "autonomous", plansNeedNod: false, decisionsBy: "decider" },
23 };
24
25 export async function setKnob(
26 app: App,
27 actor: User | undefined,
28 knob: string,
29 value: string,
30 repoPath?: string,
31 ): Promise<Result<{ knob: KnobId; value: string }, KnobError>> {
32 if (actor?.isAdmin !== true || actor.kind === "agent") return err("not_found");
33 const v = value.trim();
34 if (knob === "speed" || knob === "budget") {
35 const changed = changeCapacity(app, actor, knob === "speed" ? "crew.concurrency" : "week.use", v);
36 if (!changed.ok) return err(changed.error === "not_found" ? "not_found" : "invalid_value");
37 return ok({ knob, value: v });
38 }
39 if (knob === "polish") {
40 const n = /^\d+$/.test(v) ? Number(v) : Number.NaN;
41 if (!validPolishShare(n)) return err("invalid_value");
42 for (const repo of knobRepos(app).filter((r) => r.autonomy !== "off")) {
43 const done = await updateRepoSettings(app, actor, repo, { polishShare: n });
44 if (!done.ok) return err("invalid_value");
45 }
46 return ok({ knob, value: v });
47 }
48 if (knob === "autonomy") {
49 if (!(AUTONOMY_WORDS as readonly string[]).includes(v)) return err("invalid_value");
50 const [owner, name] = (repoPath ?? "").split("/");
51 const repo = owner === undefined || name === undefined ? undefined : getRepo(app.db, owner, name);
52 if (repo === undefined) return err("not_found");
53 const done = await updateRepoSettings(app, actor, repo, WORDS[v as AutonomyWord]);
54 return done.ok ? ok({ knob, value: v }) : err("invalid_value");
55 }
56 return err("no_such_knob");
57 }
src/core/capacity.ts +29 −42
@@ -19,17 +19,14 @@ export type CapacityKey =
1919 | "crew.concurrency"
2020 | "checks.concurrency"
2121 | "checks.shards"
22 | "queue.depth"
2322 | "queue.batch"
23 | "week.use"
2424 | "children.max"
2525 | "cells.egress"
2626 | "children.modelEgress"
2727 | "children.registryEgress"
2828 | "guard_new_accounts"
29 | "signin.edge"
30 | "slots.smallShare"
31 | "polish.capMinutes"
32 | "pace.floor";
29 | "signin.edge";
3330
3431 interface Definition {
3532 /** What the settings page and the API call it. */
@@ -71,13 +68,6 @@ export const CAPACITY: Record<CapacityKey, Definition> = {
7168 sized: (cpus) => shardsForCpus(cpus),
7269 help: "How many parallel shards a check's test run uses (handed to checks and crew shells as FORGE_CHECK_SHARDS). Empty: the pod's CPUs, at most 4 — and, in a check, no more than its cell holds.",
7370 },
74 "queue.depth": {
75 label: "Merge queue candidates at once",
76 env: "FORGE_QUEUE_DEPTH",
77 kind: { type: "count", min: 1, max: 4 },
78 fallback: "2",
79 help: "How many merge-queue candidates of one repository gate at once, each on top of the one before: while one gates on main the next gates on it, and lands right after it if both are green. 1 gates one candidate at a time. A gate beyond the first takes a free check slot only, never one of the two kept for pull checks.",
80 },
8171 "queue.batch": {
8272 label: "Merge queue batch size",
8373 env: "FORGE_QUEUE_BATCH",
@@ -85,6 +75,13 @@ export const CAPACITY: Record<CapacityKey, Definition> = {
8575 fallback: "8",
8676 help: "The most pulls one merge-queue candidate carries. A bigger batch lands more pulls per green gate; a red one costs more search gates to find its culprit (one bad pull in 16 is found in two rounds, at most √16 = 4 gates each). The queue starts each line here, halves the batch after a red gate and doubles it back after two green gates in a row, never past this. Read on every sweep.",
8777 },
78 "week.use": {
79 label: "Share of the week to use (%)",
80 env: "FORGE_WEEK_USE",
81 kind: { type: "count", min: 10, max: 100 },
82 fallback: "90",
83 help: "The weekly budget knob: how much of the week's subscription the crew may spend, evenly to the reset. The rest is kept for conversations and a person's own requests; the crew stops at it. Read on every pump.",
84 },
8885 "children.max": {
8986 label: "Forges this one may send",
9087 env: "FORGE_CHILDREN_MAX",
@@ -127,27 +124,6 @@ export const CAPACITY: Record<CapacityKey, Definition> = {
127124 fallback: "on",
128125 help: "on reads the platform edge's identity headers (when the forge has an edge secret) and offers its sign-in; off ignores them on every door, so people sign in with the forge's own methods — password and passkey. Accounts the edge made keep their names but have no password until they set one. Takes effect on the next request.",
129126 },
130 "slots.smallShare": {
131 label: "Builder slots small issues may hold (%)",
132 env: "FORGE_SLOTS_SMALL_SHARE",
133 kind: { type: "count", min: 0, max: 100 },
134 fallback: "30",
135 help: "The most of a repository's builder slots that tests-only and small-addition issues (\"A test pins …\", or a label test, tests, tests-only or small) hold at once, as a percent rounded up: 30 lets 2 of 5 slots go to them. At the cap a small issue is skipped and the slot goes to the next issue in the Next up order; a ranked small issue is still taken. 100 lifts the cap; 0 starts none. Read on every pick.",
136 },
137 "polish.capMinutes": {
138 label: "Run time a polish issue may take (minutes)",
139 env: "FORGE_POLISH_CAP_MINUTES",
140 kind: { type: "count", min: 1, max: 1440 },
141 fallback: "60",
142 help: "An issue labelled polish is small work: a builder run on it that has gone this many minutes is stopped, not extended, and the issue gets one comment saying what is left. Read on every tick.",
143 },
144 "pace.floor": {
145 label: "Slots the pace always leaves reviews and assigned work",
146 env: "FORGE_PACE_FLOOR",
147 kind: { type: "count", min: 1, max: 16 },
148 fallback: "2",
149 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. Read on every pump.",
150 },
151127 };
152128
153129 export const CAPACITY_KEYS = Object.keys(CAPACITY) as CapacityKey[];
@@ -365,9 +341,20 @@ export function capacityCount(
365341 return Number.isInteger(n) && n > 0 ? n : fallback;
366342 }
367343
368 /** The slots the pace leaves reviews and assigned work (`pace.floor`). */
344 /** Speed: the crew runs at once now (`crew.concurrency`), the one number the derived dials below follow. */
345 export function speed(db: Database): number {
346 const n = Number(capacityValue(db, "crew.concurrency"));
347 return Number.isInteger(n) && n > 0 ? n : 2;
348 }
349
350 /** The slots the pace leaves reviews and assigned work: half of Speed, at least 1 (derived, #10461). */
369351 export function paceFloor(db: Database): number {
370 return Number(capacityValue(db, "pace.floor"));
352 return Math.max(1, Math.floor(speed(db) / 2));
353 }
354
355 /** The share of the week the crew may use, in percent (`week.use`); the rest is the reserve. */
356 export function weekUse(db: Database): number {
357 return Number(capacityValue(db, "week.use"));
371358 }
372359
373360 /** How many hosted children this forge may hold now; read on every use. */
@@ -408,7 +395,7 @@ export const BUILD_HOSTS: readonly string[] = [
408395
409396 /** How many merge-queue candidates of one repository gate at once (#4053). */
410397 export function queueDepth(db: Database): number {
411 return Number(capacityValue(db, "queue.depth"));
398 return Math.min(4, Math.max(1, Math.ceil(speed(db) / 2)));
412399 }
413400
414401 /** The most pulls one merge-queue candidate carries (#6674); the line adapts below it. */
@@ -416,14 +403,14 @@ export function queueBatch(db: Database): number {
416403 return Number(capacityValue(db, "queue.batch"));
417404 }
418405
419 /** The percent of builder slots small issues may hold (#7571). */
420 export function smallShare(db: Database): number {
421 return Number(capacityValue(db, "slots.smallShare"));
406 /** The percent of builder slots small issues may hold: fixed, no longer a dial (#10461); the polish share is the dial. */
407 export function smallShare(_db: Database): number {
408 return 30;
422409 }
423410
424 /** The minutes of run time a polish issue may take before its run is stopped (#8852). */
425 export function polishCapMinutes(db: Database): number {
426 return Number(capacityValue(db, "polish.capMinutes"));
411 /** The minutes of run time a polish issue may take before its run is stopped: fixed, no longer a dial (#10461). */
412 export function polishCapMinutes(_db: Database): number {
413 return 60;
427414 }
428415
429416 /** Whether the platform edge's identity is read at all; on every request. */
src/crew/knobs.ts added +141
@@ -0,0 +1,141 @@
1 /**
2 * The five knobs (#10461): Speed, Weekly budget, Polish share, Autonomy per
3 * repository, Feedback first. Plain data out: one row each with its name, a
4 * line on what it does, the value, a control kind and its live effect. The
5 * crew page, the terminal and the MCP `knobs` tool print these same rows;
6 * `actions/knobs.ts` is the one place that turns them. Everything else
7 * (pace floor, queue depth, the reserve) is derived from them or fixed.
8 */
9
10 import type { App } from "../app.ts";
11 import { capacityValue, paceFloor, queueDepth, speed } from "../core/capacity.ts";
12 import { labelsForIssues } from "../core/issues.ts";
13 import { getRepoById, type Repo } from "../core/repos.ts";
14 import { listActive } from "../core/runs.ts";
15 import { waitingOnPeople } from "./people_first.ts";
16 import { POLISH_SHARE_DEFAULT, isPolish, polishSpend } from "./small_share.ts";
17 import { budgetEffect } from "./week_read.ts";
18
19 export type KnobId = "speed" | "budget" | "polish" | "autonomy" | "feedback";
20 export type AutonomyWord = "off" | "ask" | "go";
21 export const AUTONOMY_WORDS: readonly AutonomyWord[] = ["off", "ask", "go"];
22
23 export interface KnobRow {
24 readonly id: KnobId;
25 readonly name: string;
26 readonly does: string;
27 /** The value as typed back: a number, a percent's number, or one of the words. */
28 readonly value: string;
29 readonly control: "number" | "percent" | "words" | "fixed";
30 readonly min?: number;
31 readonly max?: number;
32 readonly words?: readonly string[];
33 /** What it does right now, in a line. */
34 readonly effect: string;
35 /** For Autonomy: the repository (`owner/name`) this row is for. */
36 readonly repo?: string;
37 /** Derived dials this knob drives, shown read-only. */
38 readonly derived?: string;
39 }
40
41 /** A repository's autonomy in the knob's three words. */
42 export function autonomyWord(repo: Repo): AutonomyWord {
43 if (repo.autonomy === "off") return "off";
44 return !repo.plansNeedNod && repo.decisionsBy !== "me" ? "go" : "ask";
45 }
46
47 function runsLine(app: App): string {
48 const active = listActive(app.db, "agent");
49 const running = active.filter((r) => r.state === "running").length;
50 return `${running} running · ${active.length - running} queued`;
51 }
52
53 function polishWaiting(app: App, repos: readonly Repo[]): number {
54 let n = 0;
55 for (const repo of repos) {
56 const rows = app.db
57 .query<{ id: string; title: string }, [string]>("SELECT id, title FROM issue WHERE repo_id = ?1 AND state = 'open' AND assignee_id IS NULL")
58 .all(repo.id);
59 const labels = labelsForIssues(app.db, rows.map((r) => r.id));
60 n += rows.filter((r) => isPolish(r.title, (labels.get(r.id) ?? []).map((l) => l.name))).length;
61 }
62 return n;
63 }
64
65 /** The repositories the Autonomy knob lists: awake ones, those with the crew on first. */
66 export function knobRepos(app: App, limit = 12): Repo[] {
67 return app.db
68 .query<{ id: string }, [number]>("SELECT id FROM repo WHERE archived_at IS NULL ORDER BY autonomy = 'off', name LIMIT ?1")
69 .all(limit)
70 .flatMap((r) => getRepoById(app.db, r.id) ?? []);
71 }
72
73 /** The five knobs now (Autonomy is one row per repository). */
74 export function readKnobs(app: App, now: Date = new Date()): KnobRow[] {
75 const repos = knobRepos(app);
76 const live = repos.filter((r) => r.autonomy !== "off");
77 const share = live[0]?.polishShare ?? POLISH_SHARE_DEFAULT;
78 const spend = live[0] === undefined ? undefined : polishSpend(app.db, live[0].id, share, now);
79 const waiting = waitingOnPeople(app.db, listActive(app.db, "agent").filter((r) => r.state === "queued"));
80 const hhmm = waiting.since === null ? "" : ` since ${waiting.since.slice(11, 16)}`;
81 const rows: KnobRow[] = [
82 {
83 id: "speed",
84 name: "Speed",
85 does: "How many crew runs go at once.",
86 value: String(speed(app.db)),
87 control: "number",
88 min: 1,
89 max: 16,
90 effect: runsLine(app),
91 derived: `pace floor ${paceFloor(app.db)} · merge queue depth ${queueDepth(app.db)} (derived)`,
92 },
93 {
94 id: "budget",
95 name: "Weekly budget",
96 does: "How much of the week's subscription to use, evenly to the reset.",
97 value: capacityValue(app.db, "week.use"),
98 control: "percent",
99 min: 10,
100 max: 100,
101 effect: budgetEffect(app, now),
102 },
103 {
104 id: "polish",
105 name: "Polish share",
106 does: "The share of the week's spend polish may take.",
107 value: String(share),
108 control: "percent",
109 min: 0,
110 max: 50,
111 effect: `polish ${spend === undefined ? 0 : Math.round(spend.percent)}% of this week's spend · ${polishWaiting(app, live)} polish issues waiting`,
112 },
113 ];
114 for (const repo of repos) {
115 const word = autonomyWord(repo);
116 rows.push({
117 id: "autonomy",
118 name: "Autonomy",
119 does: "off: the crew leaves it alone · ask: plans need a nod, decisions come to you · go: the decider answers, plans open.",
120 value: word,
121 control: "words",
122 words: AUTONOMY_WORDS,
123 repo: `${repo.ownerName}/${repo.name}`,
124 effect: word === "off" ? "off · the crew does not work here" : `${word} · ${repo.autonomySlots} builder slots`,
125 });
126 }
127 rows.push({
128 id: "feedback",
129 name: "Feedback first",
130 does: "A person's comment, assignment or note from an app starts ahead of everything. Always on.",
131 value: "on",
132 control: "fixed",
133 effect: waiting.count === 0 ? "nothing from a person waiting" : `${waiting.count} waiting${hhmm}`,
134 });
135 return rows;
136 }
137
138 /** The knobs as the plain lines the terminal and the MCP print. */
139 export function knobLines(rows: readonly KnobRow[]): string[] {
140 return rows.map((r) => `${r.name}${r.repo === undefined ? "" : ` (${r.repo})`}: ${r.value}${r.control === "percent" ? "%" : ""} — ${r.effect}`);
141 }
src/crew/people_first.ts +15
@@ -55,3 +55,18 @@ export function peopleFirst(
5555 if (first.length === 0 || first.length === queued.length) return [...queued];
5656 return [...first, ...queued.filter((r) => !personal(r))];
5757 }
58
59 /**
60 * The queued runs that carry a person's ask and the time the oldest one
61 * began waiting (the Feedback-first knob's live effect, #10461): a person's
62 * comment, a note from an app, or work a person assigned.
63 */
64 export function waitingOnPeople(db: Database, queued: readonly Run[]): { count: number; since: string | null } {
65 const fromApp = fromAppIssues(db, queued.flatMap((r) => (r.issueId === null ? [] : [r.issueId])));
66 const spoke = people(db, queued.flatMap((r) => (r.actorId !== null && (r.reason === "feedback" || r.reason === "assigned") ? [r.actorId] : [])));
67 const mine = queued.filter(
68 (r) => (r.issueId !== null && fromApp.has(r.issueId)) || ((r.reason === "feedback" || r.reason === "assigned") && r.actorId !== null && spoke.has(r.actorId)),
69 );
70 const since = mine.map((r) => r.createdAt).filter((t): t is string => typeof t === "string").sort()[0] ?? null;
71 return { count: mine.length, since };
72 }
src/crew/week.ts +3 −1
@@ -70,6 +70,8 @@ export interface WeekInput {
7070 * is a meter too coarse to read, not a crew that is behind (#10440).
7171 */
7272 readonly crewRan?: boolean;
73 /** The share of the week kept for people (1 − the weekly budget knob); `WEEK.reserve` when absent. */
74 readonly reserve?: number;
7375 }
7476
7577 export interface WeekDecision {
@@ -116,7 +118,7 @@ export function weekDecision(input: WeekInput): WeekDecision | null {
116118 const hours = left / 3_600_000;
117119 const capPct = Math.max(0, 100 - meter.keptPct);
118120 const used = 100 - meter.freePct;
119 const wall = capPct * (1 - WEEK.reserve);
121 const wall = capPct * (1 - (input.reserve ?? WEEK.reserve));
120122 const targetPctPerHour = Math.max(0, capPct - used) / hours;
121123
122124 // Allowed: what the crew may still spend before the reserve, over the hours left.
src/crew/week_read.ts +20 −3
@@ -10,7 +10,7 @@ import { measureFor } from "../core/measure.ts";
1010 import { getHeadroom, WINDOW_MS } from "../core/standing.ts";
1111 import { grantedAccounts, PLATFORM } from "../core/subscriptions.ts";
1212 import { burnFrom, noteReading, readingsSince } from "./week_burn.ts";
13 import { belowCeiling, capacityCount, capacityValue, paceFloor } from "../core/capacity.ts";
13 import { belowCeiling, capacityCount, capacityValue, paceFloor, weekUse } from "../core/capacity.ts";
1414 import { efficiencyWords, WEEK, weekDecision, type Efficiency, type WeekDecision, type WeekMeter } from "./week.ts";
1515
1616 /** The week as the provider's meter reads it: a meter, or null while no account's limit is known. */
@@ -132,7 +132,7 @@ export function weekFor(
132132 seen: { idleSlots: number; startable: number; gated: number } = { idleSlots: 0, startable: 0, gated: 0 },
133133 ): WeekDecision | null {
134134 const week = weekOf(app, repo, now);
135 return weekDecision({ ...week, now, ceiling: repo.autonomySlots, floorSlots: paceFloor(app.db), ...seen });
135 return weekDecision({ ...week, now, ceiling: repo.autonomySlots, floorSlots: paceFloor(app.db), reserve: 1 - weekUse(app.db) / 100, ...seen });
136136 }
137137
138138 /** The key of the accounts a repository draws its week from. */
@@ -158,7 +158,7 @@ export function crewCeiling(app: App, repo: Repo): number {
158158 */
159159 export function crewWeekFor(app: App, repo: Repo, now: Date): WeekDecision | null {
160160 const week = weekOf(app, repo, now);
161 return weekDecision({ ...week, now, ceiling: crewCeiling(app, repo), floorSlots: paceFloor(app.db), idleSlots: 0, startable: 0, gated: 0 });
161 return weekDecision({ ...week, now, ceiling: crewCeiling(app, repo), floorSlots: paceFloor(app.db), reserve: 1 - weekUse(app.db) / 100, idleSlots: 0, startable: 0, gated: 0 });
162162 }
163163
164164 /** A sentence saying the crew's cap is lowered, so pacing is not mistaken for it; empty at the ceiling. */
@@ -240,3 +240,20 @@ export function weekBlock(app: App, now: Date = new Date()): string[] {
240240 const words = weekWords(app, now, crew !== null);
241241 return [...(crew === null ? [] : [crew]), ...(words === null ? [] : [words])];
242242 }
243
244 /**
245 * The weekly-budget knob's live effect (#10461): `25% used, 73% of the time
246 * left · on pace · lasts to the reset Sat 02:00 UTC` — the busiest repository's
247 * meter, the same week `weekWords` states. Plain words while it is unmeasured.
248 */
249 export function budgetEffect(app: App, now: Date = new Date()): string {
250 const words = busiest(app, now, (repo, week) => {
251 const meter = weekOf(app, repo, now).meter;
252 if (meter === null) return null;
253 const used = Math.round(Math.min(100, Math.max(0, 100 - meter.freePct)));
254 const left = Math.round(Math.min(100, Math.max(0, ((meter.resetsAt.getTime() - now.getTime()) / WINDOW_MS.week) * 100)));
255 const lasts = week.runsOutAt === null ? `lasts to ${dayTime(meter.resetsAt)}` : `runs out ${dayTime(week.runsOutAt)}`;
256 return `${used}% used, ${left}% of the time left · ${week.status} · ${lasts}`;
257 });
258 return words ?? "the week is not measured yet · the crew holds at a few slots until it is";
259 }
src/http/mcp/tools/index.ts +1
@@ -84,6 +84,7 @@ export { tool as issue_teams } from "./issue_teams.ts";
8484 export { tool as issues } from "./issues.ts";
8585 export { tool as iterations } from "./iterations.ts";
8686 export { tool as keep_plan } from "./keep_plan.ts";
87 export { tool as knobs } from "./knobs.ts";
8788 export { tool as labels } from "./labels.ts";
8889 export { tool as land_past_gate } from "./land_past_gate.ts";
8990 export { tool as lift } from "./lift.ts";
src/http/mcp/tools/knobs.ts added +37
@@ -0,0 +1,37 @@
1 import { setKnob } from "../../../actions/knobs.ts";
2 import { knobLines, readKnobs } from "../../../crew/knobs.ts";
3 import { scopeAllows } from "../../../core/tokens.ts";
4 import { good, bad, type Tool } from "../shared.ts";
5
6 export const tool: Tool = {
7 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.",
10 inputSchema: {
11 type: "object",
12 properties: {
13 knob: { type: "string", enum: ["speed", "budget", "polish", "autonomy"] },
14 value: { type: "string", maxLength: 16 },
15 repo: { type: "string", maxLength: 100 },
16 dryRun: { type: "boolean" },
17 },
18 },
19 writes: true,
20 dryByDefault: true,
21 async run(ctx, user, args) {
22 if (user?.isAdmin !== true || user.kind === "agent") return bad("not_found", "no such tool here");
23 const knob = typeof args["knob"] === "string" ? args["knob"] : undefined;
24 if (knob === undefined) {
25 const rows = readKnobs(ctx.app);
26 return good({ knobs: rows, says: knobLines(rows) });
27 }
28 const value = typeof args["value"] === "string" ? args["value"] : "";
29 const repo = typeof args["repo"] === "string" ? args["repo"] : undefined;
30 if (args["dryRun"] !== false)
31 return good({ says: `Would set ${knob}${repo === undefined ? "" : ` for ${repo}`} to ${value}. Send dryRun: false to change it.` });
32 if (!scopeAllows(ctx.auth.scope ?? "ro", "admin")) return bad("forbidden", "turning a knob needs an admin-scope token");
33 const set = await setKnob(ctx.app, user, knob, value, repo);
34 if (!set.ok) return bad(set.error, "That knob or value is not one the knobs take.");
35 return good({ says: `${knob}: ${set.value.value}, from the next pump on.`, ...set.value });
36 },
37 };
src/http/settings_routes.ts +2
@@ -11,6 +11,7 @@ import type { Handler } from "./context.ts";
1111 import type { Router } from "./router.ts";
1212 import { parentLinkStart } from "./rp.ts";
1313 import { accessPage } from "../web/pages/access.ts";
14 import { knobSet } from "../web/pages/knobs.ts";
1415 import { capacityPage, capacitySet } from "../web/pages/capacity.ts";
1516 import { teamPage, teamSet, teamsPage, teamsStream } from "../web/pages/teams.ts";
1617 import { telemetryPage, telemetrySet } from "../web/pages/telemetry.ts";
@@ -247,6 +248,7 @@ export function settingsRoutes(router: Router<Handler>, knownPatterns: () => rea
247248 router.add("POST", "/settings/accounts/:username/retire", retireAct);
248249 router.add("POST", "/settings/accounts/:username/verify", accountAct("verify"));
249250 router.add("GET", "/settings/crew", crewPage);
251 router.add("POST", "/settings/crew/knobs", knobSet);
250252 router.add("POST", "/settings/crew", agentCreate);
251253 router.add("GET", "/settings/teams", teamsPage);
252254 router.add("GET", "/settings/teams/stream", teamsStream);
src/tui/screens/entries.ts +2
@@ -21,6 +21,7 @@ import { entry as cloud } from "./cloud.ts";
2121 import { entry as connections } from "./connections.ts";
2222 import { entry as crewHandover } from "./crewhandover.ts";
2323 import { entry as crewSplits } from "./crewsplits.ts";
24 import { entry as knobs } from "./knobs.ts";
2425 import { entry as displays } from "./displays.ts";
2526 import { entry as domains } from "./domains.ts";
2627 import { entry as edgeOnly } from "./edgeonly.ts";
@@ -97,6 +98,7 @@ export const ENTRIES: readonly PaletteEntry[] = [
9798 audit,
9899 secrets,
99100 crewSplits,
101 knobs,
100102 crewHandover,
101103 scorecard,
102104 modelGrantEntry,
src/tui/screens/knobs.ts added +42
@@ -0,0 +1,42 @@
1 /**
2 * The crew's five knobs in the terminal (#10461), a forge admin's: the same
3 * rows the crew page and the MCP `knobs` tool print (`readKnobs`), read once
4 * when the screen opens. Turning one is the crew page's or the tool's.
5 */
6
7 import { knobLines, readKnobs } from "../../crew/knobs.ts";
8 import type { Ctx, Screen } from "../app/app.ts";
9 import { binding } from "../app/keys.ts";
10 import { style } from "../term/style.ts";
11 import { truncate } from "../term/width.ts";
12 import type { Session } from "../session.ts";
13 import { fill, len, split } from "../ui/layout.ts";
14 import { ListState, drawList, type ListRow } from "./common.ts";
15 import type { PaletteEntry } from "./entries.ts";
16
17 export function knobsScreen(f: Session, ctx: Ctx): Screen {
18 const state = new ListState();
19 const allowed = f.user?.isAdmin === true;
20 const rows: ListRow[] = allowed ? knobLines(readKnobs(f.app)).map((title) => ({ title })) : [];
21 return {
22 title: "Knobs",
23 keys: [binding(["j", "k"], "move cursor")],
24 render(area, s) {
25 const c = ctx.theme.c;
26 const [head, list] = split(area, "v", [len(1), fill(1)]);
27 const text = allowed ? "Five dials for the crew; turn them on the crew page or with the knobs tool." : "The knobs are a forge admin's.";
28 s.text(head!.x, head!.y, truncate(text, head!.w), style(c.mutedFg, c.bg), head!.x + head!.w);
29 drawList(s, list!, c, state, rows);
30 },
31 key: (e) => state.key(e, rows.length),
32 };
33 }
34
35 export const entry: PaletteEntry = {
36 id: "knobs",
37 title: "Knobs",
38 hint: "speed, weekly budget, polish, autonomy, feedback first",
39 after: ["crew-scorecard", "usage"],
40 offered: (session) => session.user?.isAdmin === true,
41 run: (session, ctx) => ctx.push(knobsScreen(session, ctx)),
42 };
src/web/pages/crew.ts +2
@@ -37,6 +37,7 @@ import {
3737 type SplitScorecard,
3838 } from "../../core/scorecard.ts";
3939 import { keeperDays, type KeeperDay } from "../../flow/keeper_rate.ts";
40 import { knobsCard } from "./knobs.ts";
4041 import { decideChange, readReview } from "../../actions/model_review.ts";
4142 import { wastedDays, type WastedDay } from "../../core/wasted_days.ts";
4243 import { modelDays, type ModelDay } from "../../core/model_days.ts";
@@ -602,6 +603,7 @@ function crewView(
602603 error !== undefined && /username/i.test(error) ? error : undefined;
603604 const handover = crewHandover(ctx.app.db);
604605 return html`${crewReadiness(ctx)}
606 ${knobsCard(ctx)}
605607 ${when(spending.length > 0, () =>
606608 spendingCard(spending, forgeCeiling(ctx.app.config) ?? undefined),
607609 )}
src/web/pages/knobs.ts added +67
@@ -0,0 +1,67 @@
1 /**
2 * The knobs card on the crew page (#10461): one row per knob with its name,
3 * what it does, its value, its live effect and the control right there. A
4 * change posts to `knobSet`, which turns it through `actions/knobs.ts` and
5 * leaves the event the setting's own page leaves.
6 */
7
8 import { setKnob } from "../../actions/knobs.ts";
9 import { readKnobs, type KnobRow } from "../../crew/knobs.ts";
10 import type { Ctx } from "../../http/context.ts";
11 import { notFoundPage, signInFirst } from "../chrome.ts";
12 import { field, readForm } from "../form.ts";
13 import { html, type Html } from "../html.ts";
14 import { flashTo } from "../layout.ts";
15 import { btn } from "../ui.ts";
16
17 function control(r: KnobRow): Html {
18 if (r.control === "fixed") return html`<span class="badge">${r.value}</span>`;
19 const label = `${r.name}${r.repo === undefined ? "" : ` for ${r.repo}`}`;
20 const input =
21 r.control === "words"
22 ? html`<select class="input" name="value" aria-label="${label}">${(r.words ?? []).map(
23 (w) => html`<option value="${w}" ${w === r.value ? "selected" : ""}>${w}</option>`,
24 )}</select>`
25 : html`<input class="input mono" type="number" name="value" value="${r.value}" min="${r.min ?? 0}" max="${r.max ?? 100}" aria-label="${label}" style="width:5rem">${r.control === "percent" ? html` %` : html``}`;
26 return html`<form method="post" action="/settings/crew/knobs" class="row-actions">
27 <input type="hidden" name="knob" value="${r.id}">
28 <input type="hidden" name="repo" value="${r.repo ?? ""}">
29 ${input} ${btn("Set", { variant: "primary" })}
30 </form>`;
31 }
32
33 /** The card: five knobs, the autonomy one per repository. */
34 export function knobsCard(ctx: Ctx): Html {
35 const rows = readKnobs(ctx.app);
36 return html`<section class="settings-block" id="knobs">
37 <h2>Knobs</h2>
38 <p class="muted">Five dials for the crew. A change applies on the next pump.</p>
39 ${rows.map(
40 (r) => html`<div class="knob" data-knob="${r.id}">
41 <div><strong>${r.name}</strong>${r.repo === undefined ? html`` : html` <span class="mono">${r.repo}</span>`}
42 <div class="muted small">${r.does}</div>
43 <div class="small">${r.effect}</div>
44 ${r.derived === undefined ? html`` : html`<div class="muted small">${r.derived}</div>`}</div>
45 ${control(r)}
46 </div>`,
47 )}
48 </section>`;
49 }
50
51 // POST /settings/crew/knobs
52 export async function knobSet(ctx: Ctx): Promise<Response> {
53 if (!ctx.auth.user) return signInFirst(ctx);
54 if (!ctx.auth.user.isAdmin) return notFoundPage(ctx);
55 const form = await readForm(ctx, "admin");
56 if (form instanceof Response) return form;
57 const knob = field(form, "knob");
58 const set = await setKnob(ctx.app, ctx.auth.user, knob, field(form, "value"), field(form, "repo"));
59 if (!set.ok && set.error === "not_found") return notFoundPage(ctx);
60 return flashTo(
61 ctx,
62 "/settings/crew",
63 set.ok
64 ? { message: `${knob}: ${set.value.value}, from the next pump on.` }
65 : { tone: "danger", message: "That value is outside what this knob takes." },
66 );
67 }
test/crew-small-share.test.ts +4 −17
@@ -218,21 +218,8 @@ test("an epic's issue leads older plain work only as the page's ready order has
218218 opened.splice(opened.length - 3, 3);
219219 });
220220
221 test("slots.smallShare set on /settings/capacity changes the pick: 0 starts no small issue, 100 does; out of range is refused", async () => {
222 // The earlier ticks filled the slots; those runs end so this pick has room.
223 app.db.query("UPDATE run SET state = 'ok' WHERE repo_id = ?1 AND state IN ('queued','running')").run(repo.id);
224 const small = open("A test pins the colour");
225 expect((await setShare("0")).status).toBe(303);
226 expect(smallShare(app.db)).toBe(0);
227 expect(await drive(opened)).toEqual([]);
228 expect(getIssueById(app.db, small.id)!.assigneeId).toBeNull();
229 expect((await setShare("100")).status).toBe(303);
230 expect(smallShare(app.db)).toBe(100);
231 const picked = await drive(opened);
232 expect(picked.length).toBeGreaterThan(0);
233 for (const i of picked) expect(isSmall(i.title, [])).toBe(true);
234 for (const value of ["101", "-1", "half"]) {
235 await setShare(value);
236 expect(smallShare(app.db)).toBe(100);
237 }
221 test("slots.smallShare is no longer a dial: the capacity page refuses it and the share stays 30 (#10461)", async () => {
222 const res = await setShare("100");
223 expect(res.status).not.toBe(500);
224 expect(smallShare(app.db)).toBe(30);
238225 });
test/knobs-page.test.ts added +54
@@ -0,0 +1,54 @@
1 /** The knobs card on the crew page (#10461): five rows, edited in place by a same-origin POST. */
2 import { afterAll, beforeAll, expect, test } from "bun:test";
3 import { mkdtemp, rm } from "node:fs/promises";
4 import { tmpdir } from "node:os";
5 import { join } from "node:path";
6 import { createApp, type App } from "../src/app.ts";
7 import { capacityValue } from "../src/core/capacity.ts";
8 import { serve, type Servers } from "../src/http/server.ts";
9 import { seedAdmin } from "./helpers/admin.ts";
10
11 let dataDir = "";
12 let app: App, servers: Servers, bearer = "";
13
14 beforeAll(async () => {
15 dataDir = await mkdtemp(join(tmpdir(), "forge-knobs-page-"));
16 app = createApp({ dataDir, port: 0 });
17 servers = await serve(app);
18 const admin = await seedAdmin(app, { username: "alice", email: "[email protected]", password: "correct-horse-battery" });
19 if (!admin.ok) throw new Error(admin.error);
20 const minted = await fetch(`${servers.url}/api/v1/tokens`, {
21 method: "POST",
22 headers: { "content-type": "application/json" },
23 body: JSON.stringify({ adminConfirm: true, username: "alice", password: "correct-horse-battery", name: "cli", scope: "admin" }),
24 });
25 bearer = ((await minted.json()) as { token: string }).token;
26 });
27 afterAll(async () => {
28 servers.stop();
29 app.close();
30 await rm(dataDir, { recursive: true, force: true });
31 });
32
33 const post = (origin: string, body: Record<string, string>) =>
34 fetch(`${servers.url}/settings/crew/knobs`, {
35 method: "POST",
36 redirect: "manual",
37 headers: { authorization: `Bearer ${bearer}`, "content-type": "application/x-www-form-urlencoded", origin },
38 body: new URLSearchParams(body),
39 });
40
41 test("the crew page shows the knobs, and a same-origin post turns one", async () => {
42 const res = await fetch(`${servers.url}/settings/crew`, { headers: { authorization: `Bearer ${bearer}` } });
43 const body = await res.text();
44 for (const id of ["speed", "budget", "polish", "feedback"]) expect(body).toContain(`data-knob="${id}"`);
45 expect(body).toContain("nothing from a person waiting");
46 const done = await post(servers.url, { knob: "speed", value: "3", repo: "" });
47 expect(done.status).toBe(303);
48 expect(capacityValue(app.db, "crew.concurrency")).toBe("3");
49 });
50
51 test("another origin changes nothing", async () => {
52 await post("https://evil.example", { knob: "speed", value: "5", repo: "" });
53 expect(capacityValue(app.db, "crew.concurrency")).toBe("3");
54 });
test/knobs.test.ts added +120
@@ -0,0 +1,120 @@
1 /**
2 * The five knobs (#10461): read in plain words, turned in place, and each
3 * turn read by the next pump; the dials they drive are derived, the two
4 * dials they fold in are gone.
5 */
6
7 import { afterAll, beforeAll, expect, 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 { createRepo } from "../src/actions/repos.ts";
12 import { setKnob } from "../src/actions/knobs.ts";
13 import { createApp, type App } from "../src/app.ts";
14 import { CAPACITY_KEYS, capacityCount, paceFloor, queueDepth, setCapacity, smallShare, weekUse } from "../src/core/capacity.ts";
15 import { listEvents } from "../src/core/events.ts";
16 import { getRepoById } from "../src/core/repos.ts";
17 import { createUser, type User } from "../src/core/users.ts";
18 import { knobLines, readKnobs } from "../src/crew/knobs.ts";
19 import { weekDecision } from "../src/crew/week.ts";
20 import { tool } from "../src/http/mcp/tools/knobs.ts";
21 import { quietLogs } from "./helpers/globals.ts";
22
23 quietLogs();
24
25 let dir: string;
26 let app: App;
27 let admin: User;
28 let bob: User;
29 let repoId: string;
30
31 beforeAll(async () => {
32 dir = await mkdtemp(join(tmpdir(), "forge-knobs-"));
33 app = createApp({ dataDir: dir, port: 0 });
34 const mk = async (username: string, first = false) => {
35 const r = await createUser(app.db, { origin: "seed", trusted: true, username, email: `${username}@forge.local`, password: "a-good-passphrase", adminIfFirst: first });
36 if (!r.ok) throw new Error(r.error);
37 return r.value;
38 };
39 admin = await mk("carol", true);
40 bob = await mk("bob");
41 const made = await createRepo(app, admin, { name: "site", visibility: "private" });
42 if (!made.ok) throw new Error(String(made.error));
43 repoId = made.value.id;
44 }, 30_000);
45 afterAll(async () => {
46 app.close();
47 await rm(dir, { recursive: true, force: true });
48 });
49
50 test("the panel has Speed, Weekly budget, Polish share, Autonomy per repository and Feedback first, each with an effect", () => {
51 const rows = readKnobs(app);
52 expect(rows.map((r) => r.id)).toEqual(["speed", "budget", "polish", "autonomy", "feedback"]);
53 for (const r of rows) {
54 expect(r.does.length).toBeGreaterThan(0);
55 expect(r.effect.length).toBeGreaterThan(0);
56 }
57 expect(rows[0]!.effect).toMatch(/\d+ running · \d+ queued/);
58 expect(rows[4]!.effect).toBe("nothing from a person waiting");
59 expect(knobLines(rows)).toHaveLength(5);
60 });
61
62 test("Speed 4 → 2 is read by the next pump, and the dials it drives follow", async () => {
63 setCapacity(app.db, "crew.concurrency", "4", admin.id);
64 expect([paceFloor(app.db), queueDepth(app.db)]).toEqual([2, 2]);
65 expect((await setKnob(app, admin, "speed", "2")).ok).toBe(true);
66 // The pump asks exactly this, with the number it booted on as the fallback.
67 expect(capacityCount(app.db, "crew.concurrency", 4)).toBe(2);
68 expect([paceFloor(app.db), queueDepth(app.db)]).toEqual([1, 1]);
69 expect(readKnobs(app)[0]!.value).toBe("2");
70 expect((await setKnob(app, admin, "speed", "99")).ok).toBe(false);
71 expect(listEvents(app.db, {}).some((e) => e.kind === "capacity.changed")).toBe(true);
72 });
73
74 test("the folded and derived dials are gone from capacity; smallShare is fixed", () => {
75 for (const key of ["slots.smallShare", "polish.capMinutes", "pace.floor", "queue.depth"]) expect(CAPACITY_KEYS as string[]).not.toContain(key);
76 expect(smallShare(app.db)).toBe(30);
77 });
78
79 test("Weekly budget sets the reserve the pacer holds back", () => {
80 expect(weekUse(app.db)).toBe(90);
81 const week = (reserve: number) =>
82 weekDecision({
83 meter: { freePct: 20, keptPct: 0, burnPctPerHour: 1, resetsAt: new Date(Date.now() + 3 * 86_400_000) },
84 now: new Date(),
85 ceiling: 4,
86 floorSlots: 1,
87 idleSlots: 0,
88 startable: 0,
89 gated: 0,
90 reserve,
91 })!;
92 expect(week(0.1).slots).toBeGreaterThan(0);
93 expect(week(0.9).slots).toBe(0);
94 });
95
96 test("Autonomy turns ask and go into the repository's settings; Polish share sets its share", async () => {
97 expect((await setKnob(app, admin, "autonomy", "ask", "carol/site")).ok).toBe(true);
98 let repo = getRepoById(app.db, repoId)!;
99 expect([repo.autonomy, repo.plansNeedNod, repo.decisionsBy]).toEqual(["autonomous", true, "me"]);
100 expect((await setKnob(app, admin, "autonomy", "go", "carol/site")).ok).toBe(true);
101 repo = getRepoById(app.db, repoId)!;
102 expect([repo.plansNeedNod, repo.decisionsBy]).toEqual([false, "decider"]);
103 expect(readKnobs(app).find((r) => r.id === "autonomy" && r.repo === "carol/site")!.value).toBe("go");
104 expect((await setKnob(app, admin, "polish", "20")).ok).toBe(true);
105 expect(getRepoById(app.db, repoId)!.polishShare).toBe(20);
106 expect((await setKnob(app, admin, "polish", "70")).ok).toBe(false);
107 expect((await setKnob(app, admin, "autonomy", "maybe", "carol/site")).ok).toBe(false);
108 expect(listEvents(app.db, {}).some((e) => e.kind === "repo.settings_updated")).toBe(true);
109 expect((await setKnob(app, admin, "autonomy", "off", "carol/site")).ok).toBe(true);
110 });
111
112 test("only a forge admin turns a knob, and the MCP tool says the same words", async () => {
113 expect((await setKnob(app, bob, "speed", "3")).ok).toBe(false);
114 const ctx = { app, auth: { scope: "admin" } } as never;
115 const read = (await tool.run(ctx, admin, {})) as { content?: unknown };
116 expect(JSON.stringify(read)).toContain("Weekly budget");
117 const dry = await tool.run(ctx, admin, { knob: "speed", value: "3" });
118 expect(JSON.stringify(dry)).toContain("Would set speed");
119 expect(JSON.stringify(await tool.run(ctx, bob, {}))).toContain("not_found");
120 });
test/pace-floor.test.ts +1 −1
@@ -23,7 +23,7 @@ let standIn: StandInCrew;
2323
2424 beforeAll(async () => {
2525 standIn = await startStandInCrew({ tickMs: 50 });
26 setCapacity(standIn.app.db, "crew.concurrency", "10", standIn.alice.id);
26 setCapacity(standIn.app.db, "crew.concurrency", "5", standIn.alice.id);
2727 }, 30_000);
2828 afterAll(() => stopStandInCrew(standIn));
2929
test/tui-capacity.test.ts +4 −4
@@ -81,7 +81,7 @@ describe("tui capacity", () => {
8181 await h.press();
8282 expect(h.text()).toContain("Crew runs at once");
8383 expect(h.text()).toContain("takes 1–16");
84 expect(h.text()).toContain("Merge queue candidates at once");
84 expect(h.text()).toContain("Share of the week to use");
8585 expect(h.text()).not.toContain("read-only");
8686 h.stop();
8787 });
@@ -134,14 +134,14 @@ describe("tui capacity", () => {
134134 h.stop();
135135 });
136136
137 test("queue.depth, which the page sets, changes after a confirm", async () => {
137 test("queue.batch, which the page sets, changes after a confirm", async () => {
138138 const h = boot(carol);
139 for (let i = 0; i < CAPACITY_KEYS.indexOf("queue.depth"); i++) await h.press("j");
139 for (let i = 0; i < CAPACITY_KEYS.indexOf("queue.batch"); i++) await h.press("j");
140140 await h.press("e");
141141 for (let i = 0; i < 4; i++) await h.press("backspace");
142142 await h.press("4", "enter");
143143 await h.press("left", "enter");
144 expect(capacityValue(app.db, "queue.depth")).toBe("4");
144 expect(capacityValue(app.db, "queue.batch")).toBe("4");
145145 h.stop();
146146 });
147147
test/week-pump.test.ts +1 −1
@@ -78,7 +78,7 @@ test("builds fill the pace slots, yet a review or assigned run still starts; a t
7878 if (!sub.ok) throw new Error(sub.error);
7979 setHeadroom(app.db, sub.value.id, 0);
8080 app.db.query("INSERT INTO subscription_grant (scope_id, agent_id, subscription_id) VALUES (?1, '', ?2)").run(made.value.id, sub.value.id);
81 setCapacity(app.db, "crew.concurrency", "10", alice.id);
81 setCapacity(app.db, "crew.concurrency", "5", alice.id);
8282 const now = Date.now();
8383 noteMeasure(app.db, sub.value.id, { window: "week", usedPct: 70, resetsAt: new Date(now + 3.5 * DAY).toISOString(), observedAt: new Date(now).toISOString() });
8484 // 30% free now, 36% an hour ago: 6 points an hour, far over what is allowed, so the pace is the floor of 2 slots.
test/week-wiring.test.ts +4 −2
@@ -19,7 +19,7 @@ import { recordUsage } from "../src/core/usage.ts";
1919 import { createUser, type User } from "../src/core/users.ts";
2020 import { driveRepo, repoPace } from "../src/crew/autonomy.ts";
2121 import { changeCapacity } from "../src/actions/capacity.ts";
22 import { capacityDefault } from "../src/core/capacity.ts";
22 import { bootDefault, noteBooted } from "../src/core/capacity.ts";
2323 import { crewLineWords, forgetWeek, weekWords } from "../src/crew/week_read.ts";
2424 import { createForgeApp } from "../src/tui/forge.ts";
2525 import { headlessTerminal } from "../src/tui/term/terminal.ts";
@@ -117,6 +117,8 @@ afterAll(async () => {
117117 });
118118
119119 beforeEach(() => forgetWeek());
120 // The floor is half of Speed (#10461): tests state the Speed they expect, not the machine's.
121 beforeAll(() => noteBooted(app.db, "crew.concurrency", "4"));
120122 // A failed expectation must not leave the lowered crew concurrency for later tests.
121123 afterEach(() => {
122124 changeCapacity(app, alice, "crew.concurrency", null);
@@ -175,7 +177,7 @@ test("home and the terminal print the same sentence, the terminal for an admin",
175177
176178 test("the pace sentence says when crew concurrency is below its ceiling, and not at it", () => {
177179 week(20);
178 const ceiling = Number(capacityDefault("crew.concurrency"));
180 const ceiling = Number(bootDefault(app.db, "crew.concurrency"));
179181 expect(changeCapacity(app, alice, "crew.concurrency", String(ceiling)).ok).toBe(true);
180182 expect(weekWords(app, NOW)!).not.toContain("below its ceiling");
181183 expect(changeCapacity(app, alice, "crew.concurrency", "1").ok).toBe(true);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs