bareloop 0.47.0 → 0.47.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ All notable changes to bareloop are documented here. Format:
5
5
  [SemVer](https://semver.org/spec/v2.0.0.html). Pre-1.0: **minor** = a ladder rung or
6
6
  feature lands, **patch** = docs, fixes, scaffolding.
7
7
 
8
+ ## [0.47.1] - 2026-10-24
9
+
10
+ ### Fixed
11
+
12
+ - **The launcher no longer calls a loaded panel "not running".** The `GET /api/whoami` probe gave each port 300 ms; under machine load a live panel answered in 0.8 s, so `bareloop status` printed "panel not running" while it was up and `start` would have started a second one. Each port now gets 2000 ms per probe (all ports are still asked in parallel; a closed port refuses at once, so a quiet machine is as fast as before), and `start` waits about 10 seconds on a silent taken port (see the next entry).
13
+ - **`bareloop start` no longer opens a second panel next to a silent one.** A port that is taken but did not answer `whoami` in time was skipped, so a very loaded panel on 4700 got a second one on 4701 (two schedulers, double scheduled runs). `start` now asks such a port again for about 10 seconds: a bareloop answer means it is already running, any other reply moves on to the next port, and still silent stops with "Port 4700 is taken and not answering. If it's a stuck bareloop, stop it first." and starts nothing.
14
+ - **`bareloop stop` no longer says "Panel stopped." while the process is still alive.** It only watched the port go quiet; a panel that stopped answering but kept running read as stopped. `stop` now also checks each pid is gone (signal 0) within the deadline; one still alive is named ("The panel at ... (pid N) did not stop.", exit 1) and any that did stop are still named.
15
+ - **`whoami` (and the page topbar) report the version the panel runs, not the one on disk.** Both re-read `package.json` on every request, so a panel started on older code answered with the new version after an upgrade and the launcher's stop-and-start note could never fire. The version is now read once when the panel starts.
16
+ - **The Audit tab's folded rows show an open/closed arrow.** Every part row in the Grouped view and the "What the planner was told from earlier runs" box now lead with an open/closed arrow, flipping on each click; a live run's running part starts open.
17
+ - **The Audit fold arrows are the bigger ones fwdloop uses.** ▶ when folded and ▼ when open, faint, on the part rows, the learnings box and the schedule box alike; on a phone the gap after the arrow is smaller.
18
+ - **`bareloop stop` and `start` give up after the stated time, not many times it.** The wait-until-gone loop counted 100 ms per poll, but a poll against a panel that answers slowly can take up to 2 seconds, so a 10-second wait could run for minutes. The deadline is now real clock time.
19
+
8
20
  ## [0.47.0] - 2026-10-24
9
21
 
10
22
  ### Added
@@ -3306,13 +3306,13 @@ changes them, and a piped or `NO_COLOR` run prints the plain words above (the th
3306
3306
  - `installed ✓` = `~/.config/bareloop/` exists, `config.json` is there and reads with no problem, `.env` exists with mode 600, node >= 22;
3307
3307
  otherwise `not installed — <first missing thing>, pick 4 install`. The run counts use the panel's own status words and Needs-you rule over the
3308
3308
  run list file ($0, works with the panel stopped).
3309
- - **No pid file.** The panel is found by asking `127.0.0.1:4700..4709` for `GET /api/whoami` (300 ms each, in parallel); a reply with `app: "bareloop"` is a panel.
3310
- `GET /api/whoami` → `{ app: "bareloop", version, pid, port, drafts, schedules }` (open drafting sessions, jobs with a schedule), read-only, same Host guard as every
3309
+ - **No pid file.** The panel is found by asking `127.0.0.1:4700..4709` for `GET /api/whoami` (2000 ms each, in parallel — a loaded panel answered in 0.8 s; 300 ms missed it); a reply with `app: "bareloop"` is a panel. `start` never opens a second panel next to a silent one: a port that is taken but did not answer is asked again for about 10 s; a late bareloop answer counts as "already running", another kind of reply moves on to the next port, and still silent makes `start` stop with `Port 4700 is taken and not answering. If it's a stuck bareloop, stop it first.` (exit 1, nothing started). `stop` also checks each pid is really gone (signal 0) before it says "Panel stopped."; a pid still alive at the deadline is named (`did not stop`, exit 1) and the ones that did stop are still named.
3310
+ `GET /api/whoami` → `{ app: "bareloop", version, pid, port, drafts, schedules }` (`version` is the version the panel STARTED with, read once at start, never re-read from package.json — so a panel on old code after a bump still reports the old one and the launcher's stop-and-start note can fire; the page topbar is the same) (open drafting sessions, jobs with a schedule), read-only, same Host guard as every
3311
3311
  route, no token.
3312
3312
  - **`bareloop start`** → already running: says so, opens the page, starts nothing (if the running panel's version differs from this bareloop's it adds `It is version X; this bareloop is Y. Run bareloop stop, then bareloop start, to use Y.`). Else starts `bareloop panel --port N` DETACHED (`setsid`; log appended to
3313
- `~/.config/bareloop/panel.log`) on the first free port from 4700 (a taken port is skipped and named), waits up to 10 s for it to answer, opens the page with
3313
+ `~/.config/bareloop/panel.log`) on the first free port from 4700 (a taken port that replies as something else is skipped and named; one that stays silent for ~10 s stops `start` with `Port N is taken and not answering…`, nothing started), waits up to 10 s for it to answer, opens the page with
3314
3314
  `xdg-open`/`open` (no opener: prints the URL). `bareloop panel [--port N]` is unchanged (foreground, fixed port).
3315
- - **`bareloop stop [--yes]`** → SIGTERM to the pid of EVERY panel the probe finds (one panel at a time; no which-one question), waits until each port is quiet. Open drafts (in memory, summed over all found panels) are warned about and a y/N is asked;
3315
+ - **`bareloop stop [--yes]`** → SIGTERM to the pid of EVERY panel the probe finds (one panel at a time; no which-one question), waits until each pid is gone (signal 0) and each port is quiet; a pid still alive at the 10 s deadline is named and exits 1, never `Panel stopped.`. Open drafts (in memory, summed over all found panels) are warned about and a y/N is asked;
3316
3316
  `--yes` skips it. Not running: `Panel not running.`, exit 0. Several found: all stopped, `N panels stopped.`. Any other option (e.g. `--port`) is refused in plain words. Runs are separate processes and keep going.
3317
3317
  - **`bareloop status`** → header plus `pid N · version X · N draft(s) open · N schedule(s) on`. Exit 0 running, 3 not running. A panel whose version differs from the CLI's shows `(version X — stop and start to use Y)` after its URL in the header (yellow on a terminal).
3318
3318
  - **`bareloop install`** → creates only what is missing (folder mode 700, `.env` with the keys-file comment lines, mode 600, `config.json`); never reads a key value;
@@ -4426,7 +4426,7 @@ A **Rubric** job whose first Input is the full path of a FILE (not a repo folder
4426
4426
  - **Panel wording.** `stageQuestionText` words a rubric-step stage "line N — does its output pass the line's checks?". The worker brief also tells the worker to copy every number, time and price in a claim exactly as the input writes it ("9:27 AM", not "09:27").
4427
4427
  - **Shown == run (run mv5bk400).** The plan card after drafting is built from the signed close (`checksOfClose`, code-written sentences), not from the confirm turn's prose. A countable part may list the confirmed checks it carries out in `covers` (the composer prompt numbers them `#n`); `reconcileRubricPlan` moves every confirmed check no part covers to Not checked ("... — nothing in this close counts it or checks it against a quote"). `signRun` calls `planMatchesClose(session.state.finalPlan.checkItems, closeDecl)` and refuses, spawning nothing, when the two differ. `minClaims` / `maxClaims` (parts with `value` + `source`) count the claims listed under an input: `flattenStep` takes the count from the file's own `cites.<label>` list as the field `claims:<label>` and bareguard's `min`/`max` compares it. A free-text note is never a check.
4428
4428
  - **Labels.** A text close carries `genre: "TEXT"` (`genreForLang`; `TYPES` is for code languages, and a genre must match its language); its spine records carry no `judgedCount` (no judge ran); the progress list words a file job's steps from `FILE_JOB_STEP_LABELS` ("copying input files", "reading input files").
4429
- - **Panel topbar.** `bareloop · v<version> · automate a job, verified`: the version is bareloop's own package.json, templated into the page at serve time (`__BARELOOP_PANEL_VERSION__`).
4429
+ - **Panel topbar.** `bareloop · v<version> · automate a job, verified`: the version is bareloop's own package.json, read once when the panel starts and templated into the page when it is served (`__BARELOOP_PANEL_VERSION__`), so it is the version the process runs, not what package.json says now.
4430
4430
  - **After drafting, the code-worded card is the only plan on screen (run mv5e1ktb).** The confirm turn's plan bubble is the drafter's own prose (written before any close existed) and used to stay in the thread above the code-worded card; when the rubric card is ready the earlier `kind:'plan'` messages are dropped. `partSentence` now reads "1 line" / "1 word" for a count of one.
4431
4431
  - **Each `~` guardrail is its own row on the plan card.** `planFromSpec` / `planFromConfirm` lines carry `rules: string[]` (the line's own `rules`, else the joined `rule` split on "; "); `renderJobPlan` draws one `~ rule` row per rule under its numbered line, in the plan card and the Job tab alike (one renderer). Gutter numbers stay on job lines only.
4432
4432
  - **The review door's held line is true for a no-judge close.** Credit is held by VERDICT CLASS (`quarantinesCredit`: soft-green), whether or not a judge ran; the door now says "this is a rubric (soft-green) job, so its green earns NO reuse and NO learning credit until you accept it, whether or not a judge ran". Wording only; `bridges.js`/`reuse.js`/the Reuse refusal still say "rendered by the judged floor".
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bareloop",
3
- "version": "0.47.0",
3
+ "version": "0.47.1",
4
4
  "description": "Workflows that earn their own design, with receipts — agent-authored workflows for repeated, long, verifiable jobs that improve across runs under an un-gameable gate.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/launcher.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // L (PANEL-BUILD.md addendum 2026-10-24) — the `bareloop` launcher: the bare-`bareloop` menu and `bareloop start | stop | status | install`.
2
2
  //
3
- // No pid file: the panel is FOUND by asking 127.0.0.1:4700..4709 for `GET /api/whoami` (src/panel/server.js), several at once, 300 ms
3
+ // No pid file: the panel is FOUND by asking 127.0.0.1:4700..4709 for `GET /api/whoami` (src/panel/server.js), several at once, 2000 ms
4
4
  // each; a reply with `app === "bareloop"` is a panel. Every call prints the same two header lines first, from {@link buildHeader}.
5
5
  // The run counts are the panel's own (`runsListForCount`: the `listRuns` rows' `status.key` and `needs`, plus the schedules that gave up) — never a second spelling of "running" or "needs you".
6
6
  // This file owns no arbiter state: it starts/stops the panel process and reads the run list at $0. Every OS touch (spawn, kill, open,
@@ -23,8 +23,10 @@ const HERE = dirname(fileURLToPath(import.meta.url));
23
23
  /** the first port tried, and how many in a row (4700..4709) */
24
24
  export const PORT_START = 4700;
25
25
  export const PORT_COUNT = 10;
26
- const PROBE_TIMEOUT_MS = 300;
26
+ const PROBE_TIMEOUT_MS = 2000;
27
27
  const WAIT_DEADLINE_MS = 10_000;
28
+ /** how long `start` keeps asking a TAKEN port that stays silent before it refuses to open another panel next to it */
29
+ const SILENT_PORT_WAIT_MS = 10_000;
28
30
  const POLL_MS = 100;
29
31
  const MIN_NODE_MAJOR = 22;
30
32
  const RULE_WIDTH = 56;
@@ -42,10 +44,11 @@ const RULE_WIDTH = 56;
42
44
  * @property {number[]} [ports] an explicit port list (tests); wins over portStart/portCount
43
45
  * @property {number} [timeoutMs] probe timeout per port
44
46
  * @property {number} [deadlineMs] start/stop wait deadline
47
+ * @property {number} [silentWaitMs] how long start keeps asking a taken, silent port (default 10 s)
45
48
  * @property {string} [nodeVersion] default process.versions.node
46
49
  * @property {typeof fetch} [fetchImpl]
47
50
  * @property {(cmd: string, args: string[], o: object) => any} [spawnFn] default node:child_process spawn
48
- * @property {(pid: number, sig: string) => void} [kill] default process.kill
51
+ * @property {(pid: number, sig: string|number) => void} [kill] default process.kill
49
52
  * @property {((target: string) => Promise<boolean>)} [open] default the shared OS opener
50
53
  * @property {(port: number) => Promise<boolean>} [portFree] default: try to bind 127.0.0.1:port
51
54
  * @property {(ms: number) => Promise<void>} [sleep]
@@ -98,30 +101,45 @@ export function installState(o) {
98
101
  }
99
102
 
100
103
  /**
101
- * Ask 127.0.0.1 across the ports in parallel; a reply with `app === "bareloop"` is a panel. Never throws.
102
- * @param {{ports: number[], timeoutMs?: number, fetchImpl?: typeof fetch}} o
103
- * @returns {Promise<Panel[]>} in port order
104
+ * Ask one port for `/api/whoami`. Never throws. `silent` = no reply inside the timeout (a loaded or stuck process may still be a
105
+ * panel); `other` = something replied (or refused) and it is not a bareloop whoami.
106
+ * @param {{port: number, timeoutMs?: number, fetchImpl?: typeof fetch}} o
107
+ * @returns {Promise<{state: 'panel', panel: Panel}|{state: 'other'}|{state: 'silent'}>}
104
108
  */
105
- export async function probePanels(o) {
109
+ export async function probePort(o) {
106
110
  const f = o.fetchImpl ?? fetch;
107
111
  const ms = o.timeoutMs ?? PROBE_TIMEOUT_MS;
108
- const answers = await Promise.all(o.ports.map(async (port) => {
109
- try {
110
- const res = await f(`${panelUrl(port)}/api/whoami`, { signal: AbortSignal.timeout(ms) });
111
- if (!res.ok) return null;
112
- const j = /** @type {any} */ (await res.json());
113
- if (!j || j.app !== 'bareloop') return null;
114
- return /** @type {Panel} */ ({
112
+ const port = o.port;
113
+ try {
114
+ const res = await f(`${panelUrl(port)}/api/whoami`, { signal: AbortSignal.timeout(ms) });
115
+ if (!res.ok) return { state: 'other' };
116
+ const j = /** @type {any} */ (await res.json());
117
+ if (!j || j.app !== 'bareloop') return { state: 'other' };
118
+ return {
119
+ state: 'panel',
120
+ panel: {
115
121
  port,
116
122
  pid: Number(j.pid),
117
123
  version: String(j.version ?? ''),
118
124
  drafts: Number(j.drafts) || 0,
119
125
  schedules: Number(j.schedules) || 0,
120
126
  url: panelUrl(port),
121
- });
122
- } catch { return null; }
123
- }));
124
- return /** @type {Panel[]} */ (answers.filter((a) => a !== null));
127
+ },
128
+ };
129
+ } catch (e) {
130
+ const name = /** @type {any} */ (e)?.name;
131
+ return name === 'TimeoutError' || name === 'AbortError' ? { state: 'silent' } : { state: 'other' };
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Ask 127.0.0.1 across the ports in parallel; a reply with `app === "bareloop"` is a panel. Never throws.
137
+ * @param {{ports: number[], timeoutMs?: number, fetchImpl?: typeof fetch}} o
138
+ * @returns {Promise<Panel[]>} in port order
139
+ */
140
+ export async function probePanels(o) {
141
+ const answers = await Promise.all(o.ports.map((port) => probePort({ port, timeoutMs: o.timeoutMs, fetchImpl: o.fetchImpl })));
142
+ return /** @type {Panel[]} */ (answers.flatMap((a) => (a.state === 'panel' ? [a.panel] : [])));
125
143
  }
126
144
 
127
145
  /** @param {LauncherDeps} d @returns {number[]} */
@@ -272,7 +290,9 @@ export async function statusCmd(io, d, shown) {
272
290
  async function waitFor(d, port, gone) {
273
291
  const sleep = sleepOf(d);
274
292
  const deadline = d.deadlineMs ?? WAIT_DEADLINE_MS;
275
- for (let waited = 0; waited <= deadline; waited += POLL_MS) {
293
+ // real clock time (CLOCK_MONOTONIC): a probe can take up to its whole timeout, so counting POLL_MS a turn would overshoot the deadline many times over
294
+ const t0 = performance.now();
295
+ while (performance.now() - t0 <= deadline) {
276
296
  const found = await probePanels({ ports: [port], timeoutMs: d.timeoutMs, fetchImpl: d.fetchImpl });
277
297
  if (gone ? found.length === 0 : found.length > 0) return true;
278
298
  await sleep(POLL_MS);
@@ -280,6 +300,24 @@ async function waitFor(d, port, gone) {
280
300
  return false;
281
301
  }
282
302
 
303
+ /**
304
+ * A taken port that no probe recognised: ask it again until it answers or ~10 s of real time pass. A bareloop whoami = a panel;
305
+ * any other reply = not ours (move on); still silent at the end = `silent`.
306
+ * @param {LauncherDeps} d @param {number} port
307
+ * @returns {Promise<{state: 'panel', panel: Panel}|{state: 'other'}|{state: 'silent'}>}
308
+ */
309
+ async function askTakenPort(d, port) {
310
+ const sleep = sleepOf(d);
311
+ const limit = d.silentWaitMs ?? SILENT_PORT_WAIT_MS;
312
+ const t0 = performance.now();
313
+ for (;;) {
314
+ const r = await probePort({ port, timeoutMs: d.timeoutMs, fetchImpl: d.fetchImpl });
315
+ if (r.state !== 'silent') return r;
316
+ if (performance.now() - t0 >= limit) return r;
317
+ await sleep(POLL_MS);
318
+ }
319
+ }
320
+
283
321
  /**
284
322
  * `bareloop start` — find a running panel first; else start one detached on the first free port 4700..4709, wait until it answers,
285
323
  * open the page.
@@ -296,17 +334,28 @@ export async function startCmd(io, d, shown) {
296
334
  io.out(opened ? `${said} — opening the page.` : `${said} — open it in your browser.`);
297
335
  return 0;
298
336
  };
299
- if (h.panels.length > 0) {
300
- const rc = await finish(h.panels[0].url, `Panel already running at ${P.cyan(h.panels[0].url)}`);
337
+ /** @param {Panel} found */
338
+ const alreadyRunning = async (found) => {
339
+ const rc = await finish(found.url, `Panel already running at ${P.cyan(found.url)}`);
301
340
  const mine = d.version ?? packageVersion();
302
- if (h.panels[0].version !== mine) io.out(P.yellow(`It is version ${h.panels[0].version}; this bareloop is ${mine}. Run bareloop stop, then bareloop start, to use ${mine}.`));
341
+ if (found.version !== mine) io.out(P.yellow(`It is version ${found.version}; this bareloop is ${mine}. Run bareloop stop, then bareloop start, to use ${mine}.`));
303
342
  return rc;
304
- }
343
+ };
344
+ if (h.panels.length > 0) return alreadyRunning(h.panels[0]);
305
345
  const free = d.portFree ?? bindFree;
306
346
  const ports = portsOf(d);
307
347
  /** @type {number|null} */
308
348
  let chosen = null;
309
- for (const p of ports) { if (await free(p)) { chosen = p; break; } }
349
+ for (const p of ports) {
350
+ if (await free(p)) { chosen = p; break; }
351
+ // taken: if it is a loaded panel that missed the probe, a second panel next to it would double every scheduled run
352
+ const verdict = await askTakenPort(d, p);
353
+ if (verdict.state === 'panel') return alreadyRunning(verdict.panel);
354
+ if (verdict.state === 'silent') {
355
+ fail(io, d, `Port ${p} is taken and not answering. If it's a stuck bareloop, stop it first.`);
356
+ return 1;
357
+ }
358
+ }
310
359
  if (chosen === null) {
311
360
  fail(io, d, `Every port from ${ports[0]} to ${ports[ports.length - 1]} is taken by something else, so the panel was not started.`);
312
361
  return 1;
@@ -373,6 +422,25 @@ export async function stopCmd(args, io, d, shown) {
373
422
  return 1;
374
423
  }
375
424
  }
425
+ // the pid being gone is the truth (signal 0: ESRCH = gone, EPERM = alive); the port going quiet is checked after, for those that went
426
+ const t0 = performance.now();
427
+ const limit = d.deadlineMs ?? WAIT_DEADLINE_MS;
428
+ const sleep = sleepOf(d);
429
+ let pending = panels.slice();
430
+ while (pending.length > 0) {
431
+ pending = pending.filter((p) => {
432
+ try { kill(p.pid, 0); return true; } catch (e) { return /** @type {any} */ (e)?.code !== 'ESRCH'; }
433
+ });
434
+ if (pending.length === 0 || performance.now() - t0 > limit) break;
435
+ await sleep(POLL_MS);
436
+ }
437
+ if (pending.length > 0) {
438
+ for (const p of panels) {
439
+ if (!pending.includes(p)) io.out(`The panel at ${p.url} (pid ${p.pid}) stopped.`);
440
+ }
441
+ for (const p of pending) fail(io, d, `The panel at ${p.url} (pid ${p.pid}) did not stop.`);
442
+ return 1;
443
+ }
376
444
  for (const p of panels) {
377
445
  if (!(await waitFor(d, p.port, true))) {
378
446
  fail(io, d, `The panel at ${p.url} still answers after ${(d.deadlineMs ?? WAIT_DEADLINE_MS) / 1000} seconds (pid ${p.pid}).`);
@@ -170,6 +170,8 @@
170
170
  1.2s, matching design/panel-mockup.html's pulsing amber dot exactly —
171
171
  one fixed rhythm, never re-derived per call site. */
172
172
  @keyframes pulse-glyph{0%,100%{opacity:1;}50%{opacity:0.3;}}
173
+ .audit-caret{flex:none;color:var(--text-faint);margin-right:.6em;}
174
+ @media (max-width: 640px){ .audit-caret{margin-right:.2em;} }
173
175
  .dot.amber::before{content:"[▶]";color:var(--amber);}
174
176
  /* RULED 2026-10-15 (matches fwdloop glyphPulses): a sign blinks only while running or waiting for your Accept, keyed to `.pulse` (dotPulses decides) */
175
177
  .dot.pulse::before{animation:pulse-glyph 1.2s ease-in-out infinite;}
@@ -1116,7 +1118,9 @@
1116
1118
  }
1117
1119
 
1118
1120
  // ---- step map renderer (buildStepMapHTML below — ONE renderer, no second hand-authored map anywhere on this page) ----
1119
- function escapeXml(s){
1121
+ // The one Audit fold arrow (fwdloop's): \u25B6 closed, \u25BC open, faint, never shrinking; the gap after it is CSS (smaller on a phone).
1122
+ function auditCaret(open){ return '<span class="audit-caret">' + (open ? "\u25BC" : "\u25B6") + '</span>'; }
1123
+ function escapeXml(s){
1120
1124
  return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");
1121
1125
  }
1122
1126
  // s.noNumber (F196): a synthetic placeholder box (e.g. "died during
@@ -2922,8 +2926,8 @@
2922
2926
  });
2923
2927
  });
2924
2928
  var label = items.length ? head + " \u00B7 " + first + (first === 1 ? " hint" : " hints") : head;
2925
- // no arrow (hamr 2026-10-23): the state chip leads; aria-expanded carries open/closed. The same `[✓] word` state markup the schedule/step headers wear (stateDotHTML), then the plain-words title
2926
- var paint = function(){ sum.innerHTML = stateDotHTML(glyphClass("\u2713"), "learnings", "audit-learnings-state") + " " + escapeXml(label); };
2929
+ // arrow back (hamr 2026-10-24, latest wins over 2026-10-23): auditCaret (\u25BC open / \u25B6 closed) first, as the schedule header; then the same `[✓] word` state markup the schedule/step headers wear (stateDotHTML), then the plain-words title
2930
+ var paint = function(){ sum.innerHTML = auditCaret(sum.getAttribute("aria-expanded") === "true") + stateDotHTML(glyphClass("\u2713"), "learnings", "audit-learnings-state") + " " + escapeXml(label); };
2927
2931
  paint();
2928
2932
  // ONE fold, same as the other Audit sections: the header button toggles the body (wired once)
2929
2933
  sum.onclick = function(){
@@ -3451,7 +3455,7 @@
3451
3455
  gBtn.className = "btn audit-part-toggle";
3452
3456
  gBtn.setAttribute("aria-expanded", "false");
3453
3457
  gBtn.setAttribute("data-testid", "audit-schedule-toggle");
3454
- var secHead = function(open){ return (open ? "\u25BE " : "\u25B8 ") + stateDotHTML(glyphClass(sec.sign), sec.word, "audit-schedule-state") + " " + escapeXml(sec.title) + " &middot; " + escapeXml(sec.head); };
3458
+ var secHead = function(open){ return auditCaret(open) + stateDotHTML(glyphClass(sec.sign), sec.word, "audit-schedule-state") + " " + escapeXml(sec.title) + " &middot; " + escapeXml(sec.head); };
3455
3459
  gBtn.innerHTML = secHead(false);
3456
3460
  var gBody = document.createElement("div");
3457
3461
  gBody.className = "audit-part-body";
@@ -3500,11 +3504,15 @@
3500
3504
  headBtn.setAttribute("aria-expanded", startExpanded ? "true" : "false");
3501
3505
  headBtn.setAttribute("data-testid", "audit-part-toggle-" + idx);
3502
3506
  var groupResultGlyph = partResultGlyph(part, box);
3503
- headBtn.innerHTML =
3504
- stepStateHTML(box, 'audit-part-state-' + idx) + ' ' + titleText + ' &middot; ' + partLine1Text(part, detail) +
3505
- (groupResultGlyph !== null ? ' &middot; ' + groupResultGlyph : '') +
3506
- (box.blocked > 0 ? ' <span class="badge red" data-testid="audit-part-blocked-' + idx + '">' + box.blocked + ' blocked</span>' : '') +
3507
- actorMarkHtml(part);
3507
+ // same arrow as the schedule section's secHead (auditCaret): \u25BC open, \u25B6 closed, at the very start of the button text
3508
+ var partHead = function(open){
3509
+ return auditCaret(open) +
3510
+ stepStateHTML(box, 'audit-part-state-' + idx) + ' ' + titleText + ' &middot; ' + partLine1Text(part, detail) +
3511
+ (groupResultGlyph !== null ? ' &middot; ' + groupResultGlyph : '') +
3512
+ (box.blocked > 0 ? ' <span class="badge red" data-testid="audit-part-blocked-' + idx + '">' + box.blocked + ' blocked</span>' : '') +
3513
+ actorMarkHtml(part);
3514
+ };
3515
+ headBtn.innerHTML = partHead(startExpanded);
3508
3516
  var body = document.createElement("div");
3509
3517
  body.className = "audit-part-body";
3510
3518
  body.hidden = !startExpanded;
@@ -3550,6 +3558,7 @@
3550
3558
  var expanded = headBtn.getAttribute("aria-expanded") === "true";
3551
3559
  headBtn.setAttribute("aria-expanded", expanded ? "false" : "true");
3552
3560
  body.hidden = expanded;
3561
+ headBtn.innerHTML = partHead(!expanded);
3553
3562
  if(!expanded && !built) buildBody();
3554
3563
  });
3555
3564
  rowWrap.appendChild(headBtn);
@@ -79,7 +79,7 @@ import { stageQuestionsByName } from '../stagewords.js';
79
79
 
80
80
  const HERE = dirname(fileURLToPath(import.meta.url));
81
81
 
82
- /** bareloop's own version, from its package.json (read each time the page is served); 'unknown' if it cannot be read, never a guess
82
+ /** bareloop's own version, from its package.json (read once when the panel starts); 'unknown' if it cannot be read, never a guess
83
83
  * @param {string} [file] test seam: another package.json
84
84
  * @returns {string} */
85
85
  export function packageVersion(file = join(HERE, '..', '..', 'package.json')) {
@@ -91,13 +91,13 @@ export function packageVersion(file = join(HERE, '..', '..', 'package.json')) {
91
91
 
92
92
  /**
93
93
  * `GET /api/whoami` body. `drafts` counts the person's drafting sessions that are not finished (the headless scheduled ones are not drafts).
94
- * @param {{ port: number, packageJsonPath?: string, authorRoutes?: ReturnType<typeof createAuthorRoutes>, schedules?: ReturnType<typeof createScheduleDoor> }} opts
94
+ * @param {{ port: number, version?: string, packageJsonPath?: string, authorRoutes?: ReturnType<typeof createAuthorRoutes>, schedules?: ReturnType<typeof createScheduleDoor> }} opts
95
95
  */
96
96
  function whoamiPayload(opts) {
97
97
  const drafts = opts.authorRoutes ? opts.authorRoutes.openDrafts() : 0;
98
98
  let schedules = 0;
99
99
  try { schedules = opts.schedules ? opts.schedules.scan().length : 0; } catch { schedules = 0; }
100
- return { app: 'bareloop', version: packageVersion(opts.packageJsonPath), pid: process.pid, port: opts.port, drafts, schedules };
100
+ return { app: 'bareloop', version: opts.version ?? packageVersion(opts.packageJsonPath), pid: process.pid, port: opts.port, drafts, schedules };
101
101
  }
102
102
 
103
103
  /** Largest POST body the panel buffers (job cards are short prose); a bigger one is refused with 413. */
@@ -3743,7 +3743,7 @@ function sendText(res, code, text) {
3743
3743
  * only `createPanelServer` below always supplies one.
3744
3744
  * @param {import('node:http').IncomingMessage} req
3745
3745
  * @param {import('node:http').ServerResponse} res
3746
- * @param {{ home?: string, sessionsRoot?: string, packageJsonPath?: string, port: number, token?: string, authorRoutes?: ReturnType<typeof createAuthorRoutes>, settingsRoutes?: ReturnType<typeof createSettingsRoutes>, runRoutes?: ReturnType<typeof createRunRoutes>, importRoutes?: ReturnType<typeof createImportRoutes>, schedules?: ReturnType<typeof createScheduleDoor> }} opts
3746
+ * @param {{ home?: string, sessionsRoot?: string, version?: string, packageJsonPath?: string, port: number, token?: string, authorRoutes?: ReturnType<typeof createAuthorRoutes>, settingsRoutes?: ReturnType<typeof createSettingsRoutes>, runRoutes?: ReturnType<typeof createRunRoutes>, importRoutes?: ReturnType<typeof createImportRoutes>, schedules?: ReturnType<typeof createScheduleDoor> }} opts
3747
3747
  */
3748
3748
  export function handleRequest(req, res, opts) {
3749
3749
  /** the ONE writable route family for a path, or null — `/api/author/*` (authoring) or
@@ -3839,9 +3839,9 @@ export function handleRequest(req, res, opts) {
3839
3839
  return;
3840
3840
  }
3841
3841
  html = html.replace(/__BARELOOP_PANEL_PORT__/g, String(opts.port));
3842
- // the topbar reads `bareloop · v<version> · ...`: the version is bareloop's OWN package.json, read when the page is served
3842
+ // the topbar reads `bareloop · v<version> · ...`: the version is bareloop's OWN package.json, read once when the panel starts
3843
3843
  // and templated in exactly like the port — never written into the HTML
3844
- html = html.replace(/__BARELOOP_PANEL_VERSION__/g, packageVersion(opts.packageJsonPath));
3844
+ html = html.replace(/__BARELOOP_PANEL_VERSION__/g, opts.version ?? packageVersion(opts.packageJsonPath));
3845
3845
  // PANEL-BUILD.md P3's human-click guard: a per-server-start token,
3846
3846
  // templated into the page exactly like the port — absent on every P1/P2
3847
3847
  // caller (no `opts.token`), which is fine: the page's own JS only reads
@@ -3968,6 +3968,8 @@ export function createPanelServer(opts = {}) {
3968
3968
  const requestedPort = opts.port ?? DEFAULT_PORT;
3969
3969
  const home = opts.home;
3970
3970
  const token = mintToken();
3971
+ // the version THIS process runs, read once at start: package.json on disk can move on while the panel keeps running old code
3972
+ const version = packageVersion(opts.packageJsonPath);
3971
3973
  return new Promise((resolve, reject) => {
3972
3974
  // Bound port is resolved from the live socket (`server.address().port`)
3973
3975
  // once listening starts, not the requested value — this is what makes
@@ -3990,7 +3992,7 @@ export function createPanelServer(opts = {}) {
3990
3992
  const server = createServer((req, res) => {
3991
3993
  try {
3992
3994
  handleRequest(req, res, {
3993
- home, sessionsRoot: opts.sessionsRoot, port: boundPort, token, authorRoutes, settingsRoutes, runRoutes, importRoutes, packageJsonPath: opts.packageJsonPath, schedules: schedulesRef,
3995
+ home, sessionsRoot: opts.sessionsRoot, port: boundPort, token, authorRoutes, settingsRoutes, runRoutes, importRoutes, version, packageJsonPath: opts.packageJsonPath, schedules: schedulesRef,
3994
3996
  });
3995
3997
  } catch (e) {
3996
3998
  sendText(res, 500, `internal error: ${/** @type {Error} */ (e).message}`);
@@ -10,10 +10,11 @@
10
10
  * @property {number[]} [ports] an explicit port list (tests); wins over portStart/portCount
11
11
  * @property {number} [timeoutMs] probe timeout per port
12
12
  * @property {number} [deadlineMs] start/stop wait deadline
13
+ * @property {number} [silentWaitMs] how long start keeps asking a taken, silent port (default 10 s)
13
14
  * @property {string} [nodeVersion] default process.versions.node
14
15
  * @property {typeof fetch} [fetchImpl]
15
16
  * @property {(cmd: string, args: string[], o: object) => any} [spawnFn] default node:child_process spawn
16
- * @property {(pid: number, sig: string) => void} [kill] default process.kill
17
+ * @property {(pid: number, sig: string|number) => void} [kill] default process.kill
17
18
  * @property {((target: string) => Promise<boolean>)} [open] default the shared OS opener
18
19
  * @property {(port: number) => Promise<boolean>} [portFree] default: try to bind 127.0.0.1:port
19
20
  * @property {(ms: number) => Promise<void>} [sleep]
@@ -50,6 +51,24 @@ export function installState(o: {
50
51
  ok: boolean;
51
52
  problem: string | null;
52
53
  };
54
+ /**
55
+ * Ask one port for `/api/whoami`. Never throws. `silent` = no reply inside the timeout (a loaded or stuck process may still be a
56
+ * panel); `other` = something replied (or refused) and it is not a bareloop whoami.
57
+ * @param {{port: number, timeoutMs?: number, fetchImpl?: typeof fetch}} o
58
+ * @returns {Promise<{state: 'panel', panel: Panel}|{state: 'other'}|{state: 'silent'}>}
59
+ */
60
+ export function probePort(o: {
61
+ port: number;
62
+ timeoutMs?: number;
63
+ fetchImpl?: typeof fetch;
64
+ }): Promise<{
65
+ state: "panel";
66
+ panel: Panel;
67
+ } | {
68
+ state: "other";
69
+ } | {
70
+ state: "silent";
71
+ }>;
53
72
  /**
54
73
  * Ask 127.0.0.1 across the ports in parallel; a reply with `app === "bareloop"` is a panel. Never throws.
55
74
  * @param {{ports: number[], timeoutMs?: number, fetchImpl?: typeof fetch}} o
@@ -184,6 +203,10 @@ export type LauncherDeps = {
184
203
  * start/stop wait deadline
185
204
  */
186
205
  deadlineMs?: number | undefined;
206
+ /**
207
+ * how long start keeps asking a taken, silent port (default 10 s)
208
+ */
209
+ silentWaitMs?: number | undefined;
187
210
  /**
188
211
  * default process.versions.node
189
212
  */
@@ -196,7 +219,7 @@ export type LauncherDeps = {
196
219
  /**
197
220
  * default process.kill
198
221
  */
199
- kill?: ((pid: number, sig: string) => void) | undefined;
222
+ kill?: ((pid: number, sig: string | number) => void) | undefined;
200
223
  /**
201
224
  * default the shared OS opener
202
225
  */
@@ -1,4 +1,4 @@
1
- /** bareloop's own version, from its package.json (read each time the page is served); 'unknown' if it cannot be read, never a guess
1
+ /** bareloop's own version, from its package.json (read once when the panel starts); 'unknown' if it cannot be read, never a guess
2
2
  * @param {string} [file] test seam: another package.json
3
3
  * @returns {string} */
4
4
  export function packageVersion(file?: string): string;
@@ -782,11 +782,12 @@ export function getStartFromImport(id: string, opts?: {
782
782
  * only `createPanelServer` below always supplies one.
783
783
  * @param {import('node:http').IncomingMessage} req
784
784
  * @param {import('node:http').ServerResponse} res
785
- * @param {{ home?: string, sessionsRoot?: string, packageJsonPath?: string, port: number, token?: string, authorRoutes?: ReturnType<typeof createAuthorRoutes>, settingsRoutes?: ReturnType<typeof createSettingsRoutes>, runRoutes?: ReturnType<typeof createRunRoutes>, importRoutes?: ReturnType<typeof createImportRoutes>, schedules?: ReturnType<typeof createScheduleDoor> }} opts
785
+ * @param {{ home?: string, sessionsRoot?: string, version?: string, packageJsonPath?: string, port: number, token?: string, authorRoutes?: ReturnType<typeof createAuthorRoutes>, settingsRoutes?: ReturnType<typeof createSettingsRoutes>, runRoutes?: ReturnType<typeof createRunRoutes>, importRoutes?: ReturnType<typeof createImportRoutes>, schedules?: ReturnType<typeof createScheduleDoor> }} opts
786
786
  */
787
787
  export function handleRequest(req: import("node:http").IncomingMessage, res: import("node:http").ServerResponse, opts: {
788
788
  home?: string;
789
789
  sessionsRoot?: string;
790
+ version?: string;
790
791
  packageJsonPath?: string;
791
792
  port: number;
792
793
  token?: string;