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

Bridge: the room line says when the forge can't read its own forge.json; Close is 44 px at every width #16969

Merged opened this

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

Merged

bridge-room-honest → main 0 commits

  • Merged. bridge-room-honest was merged into main as 86b2cd3.

Review

Sign in to review this change.
5 files changed +23 −13
src/flow/slots.ts +13 −10
@@ -63,7 +63,9 @@ export interface SlotLine {
6363 * serving keeps, and what one check or crew run is taken to use. A check's share is the runner
6464 * pool's (`checks/runner_pool.ts`: forge.json's `check.limits`, else 4 cores and 4 GiB); a crew
6565 * run's is the 3 GiB `crewForMemory` sizes by, beside the forge's own 2 GiB, and its CPU is not
66 * measured (`perCpus` null). `declared` says whether the share is the repository's own words.
66 * measured (`perCpus` null). `declared` says whether the share is the repository's own words, and
67 * `unread` that the forge could not read its forge.json at all (a release image may not carry it),
68 * so the share is the default for that reason, not because the file declares none.
6769 */
6870 export interface SlotRoom {
6971 readonly cpus: number;
@@ -73,6 +75,7 @@ export interface SlotRoom {
7375 readonly perCpus: number | null;
7476 readonly perMiB: number;
7577 readonly declared: boolean;
78 readonly unread: boolean;
7679 }
7780
7881 const KEY: Readonly<Record<SlotLine["kind"], "checks.concurrency" | "crew.concurrency">> = { checks: "checks.concurrency", crew: "crew.concurrency" };
@@ -192,17 +195,17 @@ function lastEstimates(db: Database): Map<string, { at: string; slots: number; m
192195 /**
193196 * The forge's own check share, read once from its own forge.json (a release replaces the process).
194197 */
195 let ownShape: { shape: PoolShape; declared: boolean } | undefined;
196 function checkShape(): { shape: PoolShape; declared: boolean } {
198 let ownShape: { shape: PoolShape; declared: boolean; unread: boolean } | undefined;
199 function checkShape(): { shape: PoolShape; declared: boolean; unread: boolean } {
197200 if (ownShape !== undefined) return ownShape;
198201 const root = join(import.meta.dir, "..", "..");
199 let declared = false;
202 let text: string | undefined;
200203 try {
201 declared = declaredCheckLimits(readFileSync(join(root, "forge.json"), "utf8")) !== undefined;
204 text = readFileSync(join(root, "forge.json"), "utf8");
202205 } catch {
203 declared = false;
206 text = undefined;
204207 }
205 ownShape = { shape: shapeFromRepository(root), declared };
208 ownShape = { shape: shapeFromRepository(root), declared: text !== undefined && declaredCheckLimits(text) !== undefined, unread: text === undefined };
206209 return ownShape;
207210 }
208211
@@ -210,10 +213,10 @@ function checkShape(): { shape: PoolShape; declared: boolean } {
210213 /** The machine against one slot of `kind`, as {@link SlotRoom} says. */
211214 export function slotRoom(kind: SlotLine["kind"]): SlotRoom {
212215 const machine = { cpus: cpuLimit(), memoryMiB: Math.floor(memoryLimitBytes() / 1_048_576) };
213 const { shape, declared } = checkShape();
216 const { shape, declared, unread } = checkShape();
214217 return kind === "checks"
215 ? { ...machine, keepCpus: shape.servingCpus, keepMiB: shape.servingMemoryMiB, perCpus: shape.perRunnerCpus, perMiB: shape.perRunnerMemoryMiB, declared }
216 : { ...machine, keepCpus: shape.servingCpus, keepMiB: FORGE_OWN_MIB, perCpus: null, perMiB: CREW_RUN_MIB, declared: false };
218 ? { ...machine, keepCpus: shape.servingCpus, keepMiB: shape.servingMemoryMiB, perCpus: shape.perRunnerCpus, perMiB: shape.perRunnerMemoryMiB, declared, unread }
219 : { ...machine, keepCpus: shape.servingCpus, keepMiB: FORGE_OWN_MIB, perCpus: null, perMiB: CREW_RUN_MIB, declared: false, unread: false };
217220 }
218221
219222 /** The setting as a count: what is in force now, so the line moves the moment it is changed. */
src/web/bridge_client.ts +1 −1
@@ -148,7 +148,7 @@ export const bridgeJs = /* js */ `
148148 ? what + ' would need up to ' + need + ', more than this machine has free beside serving (' + free + '): they would slow each other and the pages.'
149149 : what + ' would use up to ' + need + ' of the ' + free + ' free beside serving.';
150150 if (perC === null) text += ' Their CPU is not measured.';
151 text += d.roomDeclared === '1' ? '' : ' Each ' + WORD[kind] + ' is taken as ' + (perC === null ? '' : perC + ' cores and ') + gib(perM) + (kind === 'checks' ? ', since forge.json declares no check limits.' : '.');
151 text += d.roomDeclared === '1' ? '' : ' Each ' + WORD[kind] + ' is taken as ' + (perC === null ? '' : perC + ' cores and ') + gib(perM) + (kind === 'checks' ? (d.roomUnread === '1' ? ', since this forge cannot read its own forge.json.' : ', since forge.json declares no check limits.') : '.');
152152 return { text: text, over: over };
153153 }
154154 function figure(t) {
src/web/flow_slots.ts +1 −1
@@ -66,7 +66,7 @@ function kept(l: SlotLine): Html | null {
6666
6767 /** The machine against one slot, for the bridge to say what a setting would take (`slotRoom`). */
6868 const roomData = (r: SlotRoom): Html =>
69 html` data-room-cpus="${String(r.cpus)}" data-room-mem="${String(r.memoryMiB)}" data-room-keep-cpus="${String(r.keepCpus)}" data-room-keep-mem="${String(r.keepMiB)}" data-room-per-cpus="${r.perCpus === null ? "" : String(r.perCpus)}" data-room-per-mem="${String(r.perMiB)}" data-room-declared="${r.declared ? "1" : ""}"`;
69 html` data-room-cpus="${String(r.cpus)}" data-room-mem="${String(r.memoryMiB)}" data-room-keep-cpus="${String(r.keepCpus)}" data-room-keep-mem="${String(r.keepMiB)}" data-room-per-cpus="${r.perCpus === null ? "" : String(r.perCpus)}" data-room-per-mem="${String(r.perMiB)}" data-room-declared="${r.declared ? "1" : ""}" data-room-unread="${r.unread ? "1" : ""}"`;
7070
7171 /**
7272 * One kind's line. For an admin it is also a figure the bridge can select (`bridge_client.ts`):
src/web/pages/home_flow_style.ts +1 −1
@@ -63,7 +63,7 @@ export const homeFlowCss = /* css */ `
6363 /* A line at the foot of the page, like a status line, not a sheet: one rule above it, the page's own ground. */
6464 .br-bar { position: sticky; bottom: 0; display: grid; gap: 4px; margin: 12px 0 0; padding: 8px 16px max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--bg); }
6565 .br-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
66 .br-close { min-height: 44px; gap: 6px; flex: none; }
66 .br-top .br-close { min-height: 44px; gap: 6px; flex: none; }
6767 .br-close kbd { font-size: var(--fs-min); }
6868 .br-room[data-over] { color: var(--danger); }
6969 .br-bar[hidden] { display: none; }
test/bridge.test.ts +7
@@ -162,6 +162,7 @@ test.skipIf(skip)("the lanes are a grid: l and h cross lanes at the same row, j
162162 key('k'); out.back = where();
163163 out.fi = fi;
164164 out.close = bar.querySelector('.br-close')?.textContent.trim() ?? null;
165 out.closeH = Math.round(bar.querySelector('.br-close')?.getBoundingClientRect().height ?? 0);
165166 bar.querySelector('.br-close').click();
166167 out.closed = bar.hidden && !document.querySelector('[data-selected]');
167168 pick(shown(from)[0]);
@@ -189,6 +190,8 @@ test.skipIf(skip)("the lanes are a grid: l and h cross lanes at the same row, j
189190 expect(s.figL, seen).toBe("slots:crew");
190191 expect(String(s.back), seen).toMatch(/^\d+:\d+$/);
191192 expect(s.close, seen).toBe("× CloseEsc");
193 // A 44 px target at a desk too, not only on a phone.
194 expect(s.closeH, seen).toBeGreaterThanOrEqual(44);
192195 expect(s.closed, seen).toBe(true);
193196 expect(s.reopened, seen).toBe(true);
194197 expect(s.outside, seen).toBe(true);
@@ -288,6 +291,10 @@ test("a slot's room is the machine against what one takes: a check is forge.json
288291 expect(fig).toContain('data-room-cpus="4"');
289292 expect(fig).toContain(`data-room-per-cpus="${String(shape.perRunnerCpus)}"`);
290293 expect(fig).toContain(`data-room-declared="${declared ? "1" : ""}"`);
294 // The checkout carries forge.json, so it was read; a release image without it says so, not
295 // "declares none".
296 expect(fig).toContain('data-room-unread=""');
297 expect(bridgeJs).toContain("since this forge cannot read its own forge.json.");
291298 expect(/<div class="sl" data-kind="crew"[^>]*>/.exec(page)![0]).toContain('data-room-per-cpus=""');
292299 } finally {
293300 provideCpusForTest(undefined);

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs