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
Check · Review · Land · Live done — Landed and live in production.
bridge-room-honest → main 0 commits
5 files
changed +23
−13
src/flow/slots.ts +13 −10
| @@ -63,7 +63,9 @@ export interface SlotLine { | ||
| 63 | 63 | * serving keeps, and what one check or crew run is taken to use. A check's share is the runner |
| 64 | 64 | * pool's (`checks/runner_pool.ts`: forge.json's `check.limits`, else 4 cores and 4 GiB); a crew |
| 65 | 65 | * 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. | |
| 67 | 69 | */ |
| 68 | 70 | export interface SlotRoom { |
| 69 | 71 | readonly cpus: number; |
| @@ -73,6 +75,7 @@ export interface SlotRoom { | ||
| 73 | 75 | readonly perCpus: number | null; |
| 74 | 76 | readonly perMiB: number; |
| 75 | 77 | readonly declared: boolean; |
| 78 | readonly unread: boolean; | |
| 76 | 79 | } |
| 77 | 80 | |
| 78 | 81 | 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 | ||
| 192 | 195 | /** |
| 193 | 196 | * The forge's own check share, read once from its own forge.json (a release replaces the process). |
| 194 | 197 | */ |
| 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 } { | |
| 197 | 200 | if (ownShape !== undefined) return ownShape; |
| 198 | 201 | const root = join(import.meta.dir, "..", ".."); |
| 199 | let declared = false; | |
| 202 | let text: string | undefined; | |
| 200 | 203 | try { |
| 201 | declared = declaredCheckLimits(readFileSync(join(root, "forge.json"), "utf8")) !== undefined; | |
| 204 | text = readFileSync(join(root, "forge.json"), "utf8"); | |
| 202 | 205 | } catch { |
| 203 | declared = false; | |
| 206 | text = undefined; | |
| 204 | 207 | } |
| 205 | ownShape = { shape: shapeFromRepository(root), declared }; | |
| 208 | ownShape = { shape: shapeFromRepository(root), declared: text !== undefined && declaredCheckLimits(text) !== undefined, unread: text === undefined }; | |
| 206 | 209 | return ownShape; |
| 207 | 210 | } |
| 208 | 211 | |
| @@ -210,10 +213,10 @@ function checkShape(): { shape: PoolShape; declared: boolean } { | ||
| 210 | 213 | /** The machine against one slot of `kind`, as {@link SlotRoom} says. */ |
| 211 | 214 | export function slotRoom(kind: SlotLine["kind"]): SlotRoom { |
| 212 | 215 | const machine = { cpus: cpuLimit(), memoryMiB: Math.floor(memoryLimitBytes() / 1_048_576) }; |
| 213 | const { shape, declared } = checkShape(); | |
| 216 | const { shape, declared, unread } = checkShape(); | |
| 214 | 217 | 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 }; | |
| 217 | 220 | } |
| 218 | 221 | |
| 219 | 222 | /** 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 */ ` | ||
| 148 | 148 | ? what + ' would need up to ' + need + ', more than this machine has free beside serving (' + free + '): they would slow each other and the pages.' |
| 149 | 149 | : what + ' would use up to ' + need + ' of the ' + free + ' free beside serving.'; |
| 150 | 150 | 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.') : '.'); | |
| 152 | 152 | return { text: text, over: over }; |
| 153 | 153 | } |
| 154 | 154 | function figure(t) { |
src/web/flow_slots.ts +1 −1
| @@ -66,7 +66,7 @@ function kept(l: SlotLine): Html | null { | ||
| 66 | 66 | |
| 67 | 67 | /** The machine against one slot, for the bridge to say what a setting would take (`slotRoom`). */ |
| 68 | 68 | 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" : ""}"`; | |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * 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 */ ` | ||
| 63 | 63 | /* A line at the foot of the page, like a status line, not a sheet: one rule above it, the page's own ground. */ |
| 64 | 64 | .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); } |
| 65 | 65 | .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; } | |
| 67 | 67 | .br-close kbd { font-size: var(--fs-min); } |
| 68 | 68 | .br-room[data-over] { color: var(--danger); } |
| 69 | 69 | .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 | ||
| 162 | 162 | key('k'); out.back = where(); |
| 163 | 163 | out.fi = fi; |
| 164 | 164 | out.close = bar.querySelector('.br-close')?.textContent.trim() ?? null; |
| 165 | out.closeH = Math.round(bar.querySelector('.br-close')?.getBoundingClientRect().height ?? 0); | |
| 165 | 166 | bar.querySelector('.br-close').click(); |
| 166 | 167 | out.closed = bar.hidden && !document.querySelector('[data-selected]'); |
| 167 | 168 | 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 | ||
| 189 | 190 | expect(s.figL, seen).toBe("slots:crew"); |
| 190 | 191 | expect(String(s.back), seen).toMatch(/^\d+:\d+$/); |
| 191 | 192 | 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); | |
| 192 | 195 | expect(s.closed, seen).toBe(true); |
| 193 | 196 | expect(s.reopened, seen).toBe(true); |
| 194 | 197 | 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 | ||
| 288 | 291 | expect(fig).toContain('data-room-cpus="4"'); |
| 289 | 292 | expect(fig).toContain(`data-room-per-cpus="${String(shape.perRunnerCpus)}"`); |
| 290 | 293 | 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."); | |
| 291 | 298 | expect(/<div class="sl" data-kind="crew"[^>]*>/.exec(page)![0]).toContain('data-room-per-cpus=""'); |
| 292 | 299 | } finally { |
| 293 | 300 | provideCpusForTest(undefined); |
new above
offline