create-pmos 0.798.0 → 0.800.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.798.0",
3
+ "version": "0.800.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -33,6 +33,41 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.800.0",
38
+ "at": "2026-11-25T01:39:46.319Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1825,
43
+ "t": "Today, Work and an initiative open within 200 ms",
44
+ "s": "Today, Work and an initiative open within 200 ms",
45
+ "k": "imp",
46
+ "try": {
47
+ "steps": [
48
+ "Open Today, then Work, then an initiative from Work.",
49
+ "Change something on the initiative (a task title), wait a second, then open Work again.",
50
+ "Open the same initiative again."
51
+ ],
52
+ "see": "each page shows its rows at once, in about the blink of an eye; the change you made shows on Work and on the initiative.",
53
+ "open": "/premium-board.html"
54
+ }
55
+ }
56
+ ]
57
+ },
58
+ {
59
+ "v": "0.799.0",
60
+ "at": "2026-11-25T00:01:31.314Z",
61
+ "f": 4,
62
+ "prs": [
63
+ {
64
+ "n": 1824,
65
+ "t": "Drafting the goal keeps the initiative page; one toast for one draft press",
66
+ "s": "Drafting the goal keeps the initiative page; one toast for one draft press",
67
+ "k": "fix"
68
+ }
69
+ ]
70
+ },
36
71
  {
37
72
  "v": "0.798.0",
38
73
  "at": "2026-11-24T23:17:36.353Z",
@@ -429,40 +464,6 @@
429
464
  "k": "new"
430
465
  }
431
466
  ]
432
- },
433
- {
434
- "v": "0.780.0",
435
- "at": "2026-11-24T15:38:49.543Z",
436
- "f": 4,
437
- "prs": [
438
- {
439
- "n": 1754,
440
- "t": "The strategy draft speaks for the whole product; Positioning folds to one line",
441
- "s": "The strategy draft speaks for the whole product; Positioning folds to one line",
442
- "k": "new"
443
- }
444
- ]
445
- },
446
- {
447
- "v": "0.779.0",
448
- "at": "2026-11-24T15:18:38.678Z",
449
- "f": 4,
450
- "prs": [
451
- {
452
- "n": 1743,
453
- "t": "PMOS reads each report draft as the CFO, engineer and sceptic, questions under the ✦",
454
- "s": "PMOS reads each report draft as the CFO, engineer and sceptic, questions under the ✦",
455
- "k": "new",
456
- "h": "PMOS reads each report draft as the CFO, engineer and sceptic, questions under the ✦",
457
- "try": {
458
- "steps": [
459
- "Open Library and draft a report (or ask the chat: draft the weekly report)",
460
- "Wait about a minute, then open Work and the ✦ on an initiative the report covers"
461
- ],
462
- "see": "The ✦ lists up to 6 questions such as 'CFO asks: What does a slip of the cutover cost?', each quoting the report, with the smallest fix as its next step"
463
- }
464
- }
465
- ]
466
467
  }
467
468
  ]
468
469
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@dcdbb0fb4
2
- assembled: 2026-11-24
1
+ kernel-source: pmos@6cd2bca37
2
+ assembled: 2026-11-25
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-11-24T23:17:32Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T01:39:43Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-11-24T23:17:32Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T01:39:43Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-11-24T23:17:32Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T01:39:43Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  Newest first, ISO dates.
4
4
 
5
- ## 2026-11-24
5
+ ## 2026-11-25
6
6
 
7
7
  - Adopted OKF v0.2 (D73).
@@ -1,4 +1,39 @@
1
1
  [
2
+ {
3
+ "v": "0.800.0",
4
+ "at": "2026-11-25T01:39:46.319Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1825,
9
+ "t": "Today, Work and an initiative open within 200 ms",
10
+ "s": "Today, Work and an initiative open within 200 ms",
11
+ "k": "imp",
12
+ "try": {
13
+ "steps": [
14
+ "Open Today, then Work, then an initiative from Work.",
15
+ "Change something on the initiative (a task title), wait a second, then open Work again.",
16
+ "Open the same initiative again."
17
+ ],
18
+ "see": "each page shows its rows at once, in about the blink of an eye; the change you made shows on Work and on the initiative.",
19
+ "open": "/premium-board.html"
20
+ }
21
+ }
22
+ ]
23
+ },
24
+ {
25
+ "v": "0.799.0",
26
+ "at": "2026-11-25T00:01:31.314Z",
27
+ "f": 4,
28
+ "prs": [
29
+ {
30
+ "n": 1824,
31
+ "t": "Drafting the goal keeps the initiative page; one toast for one draft press",
32
+ "s": "Drafting the goal keeps the initiative page; one toast for one draft press",
33
+ "k": "fix"
34
+ }
35
+ ]
36
+ },
2
37
  {
3
38
  "v": "0.798.0",
4
39
  "at": "2026-11-24T23:17:36.353Z",
@@ -189,7 +189,7 @@ On a computer the popup is built from the parts of the PMOS design system. The t
189
189
  **Overview** is one block across the top. Press its name to fold it, and press it again to open it. PMOS keeps your choice for every initiative, on each device you use. When it is folded, it shows one line of **Where it stands**, and **1 suggestion** (or more) when PMOS has one; press that to open it. When it is open, it shows three parts side by side:
190
190
 
191
191
  - **Where it stands.** What is happening, in a few sentences. Then **Next**: the next three dates, a milestone as a diamond and the outcome check as a circle; press a milestone to open it. Then one suggestion from PMOS with **Why**, **PMOS will** and **Based on**. The pencil opens it so you can change it first, ✓ does it and ✕ drops it. Other suggestions are one link under it.
192
- - **The case.** **Problem**, **Goal** and **Done when** from the initiative's records. Press a line to change it. A line not written offers a PMOS draft (✦) or ✕. When no line is written yet, one suggestion offers to draft them all from what is linked: ✓ sends the request to the chat, ✕ says not this, and the pencil lets you write it yourself. When the chat saves a line, the case shows it as soon as the chat's turn ends, with no reload and no commit. It also reads its lines again when you come back to the page.
192
+ - **The case.** **Problem**, **Goal** and **Done when** from the initiative's records. Press a line to change it. A line not written offers a PMOS draft (✦) or ✕. When no line is written yet, one suggestion offers to draft them all from what is linked: ✓ sends the request to the chat, ✕ says not this, and the pencil lets you write it yourself. When PMOS drafts several lines from one press, one message names them ("Problem and Goal drafted."), and its **Undo** takes back every line it wrote. When the chat saves a line, the case shows it as soon as the chat's turn ends, with no reload and no commit. It also reads its lines again when you come back to the page.
193
193
  - **Details.** The facts: dates, the next milestone, product, program, workflow and what is open.
194
194
 
195
195
  Under it, two blocks use the full width of the popup:
@@ -2,7 +2,7 @@
2
2
  type: Guide
3
3
  title: "Reports and dashboards: set up, shape, design, draft and issue"
4
4
  description: "Set up a report by asking, shape what it says, design how it looks, draft and issue a cadence report, and the ready-made dashboards."
5
- timestamp: 2026-11-22
5
+ timestamp: 2026-11-24
6
6
  ---
7
7
 
8
8
  # Reports and dashboards
@@ -417,7 +417,7 @@ PMOS puts only a few of these on a schedule by itself. The others draft when the
417
417
 
418
418
  ### Where the dashboard shows
419
419
 
420
- - **Program and initiative.** One icon in the header switches between **Work** and **Dashboard**. The page remembers your last choice for each program and initiative. Until you choose, a Work row opens on Work. The charter is still under the **Milestones** pencil and in **Documents**.
420
+ - **Program and initiative.** One icon in the header switches between **Work** and **Dashboard**. The page remembers your last choice for each program and initiative. Until you choose, a Work row opens on Work. The charter is still under the **Milestones** pencil and in **Documents**. When you press something on Work before the dashboard has loaded, the page stays on Work, even when your last choice was Dashboard. On a phone, the icon that brings back Work stays in the header while the dashboard shows.
421
421
  - **Product.** The product page is the dashboard. Its reports are in **This week**.
422
422
 
423
423
  The dashboard shows these blocks, in this order:
@@ -503,6 +503,7 @@ A refresh waits for the sources it uses. The briefing waits for work assigned to
503
503
  - **One server runs the schedules.** When several PMOS servers run on one computer (for example an npm install and a checkout), only one of them runs the schedules and starts background runs; the others serve pages only. If that server stops, another one takes over within 3 minutes. A refresh you press runs on the server where you press it.
504
504
  - **Quiet start**: a server starts no background run in its first 5 minutes, so the first pages load quickly. A missed refresh catches up after that.
505
505
  - **Warm start**: 5 seconds after PMOS starts, it reads what Today and Work show once, so your first page opens as fast as later ones. This read writes nothing you would see as read or seen. `PMOS_WARM=off` turns it off.
506
+ - **Pages open from their last answer**: Today, Work and an initiative show the answer PMOS read last, while nothing changed since, and PMOS reads them again quietly when it is not busy. A change you, the chat or an agent make shows on the next open, also when it is written outside PMOS (PMOS watches the planning and pmos folders): the change makes every kept answer too old, and PMOS reads the newest pages again about a second later. Work also reads its first twelve initiatives ahead, so opening one from Work is fast too. A restart starts empty.
506
507
  - **Fresh answers, asked once**: when two parts of a page ask for the same thing at the same moment, the server is asked once and both get the same answer. Nothing is kept after it arrives, so the next look always reads again.
507
508
  - **Last view while Today reads**: Today shows the list from your last visit at once, with a hollow ring next to "Good morning". You can read that list, but you cannot use it until the new read is in. Then the ring goes away. Before a section has data, it shows grey shapes with no names and no counts. Each section fills in when its own data arrives. If the Viewer was open on your last visit, its space stays empty, so the chat does not change width. Adler's face next to the greeting thinks while Today reads, and changes to handled when the read is in. If the read fails, it changes to honest.
508
509
  - **Work while it reads**: the toolbar and the tabs show at once, with grey rows below them. If the read takes more than 2 seconds, the line "Still reading the board." shows. There is no progress bar and no percent.
@@ -0,0 +1,185 @@
1
+ 'use strict';
2
+ /* answer-cache.js — the slow reads a page opens on answer at once from their last answer, and are read again in the background
3
+ * (page-open-200ms, Wawan 2026-11-25: "Benchmark is to not exceed 200ms").
4
+ *
5
+ * The server answers one request at a time. On the PM's data a few reads took most of a second each (an initiative's page 1.4 s, its
6
+ * dashboard 0.9 s, Today's events 0.9 s) and every other read of the page queued behind them, so Today showed its first rows after
7
+ * 1.2 to 3.3 s. Each of these reads is the same answer for the same question until something is written.
8
+ *
9
+ * cacheable(pathname) → true for the routes on SLOW
10
+ * serve(req, res, url, ctx, run) → Promise<boolean> run(ctx2, res2) is the route's own handler; ctx2.json is watched for the answer
11
+ * bump(method, pathname) a write: every kept answer is too old to show from now on (the next read waits for a fresh one)
12
+ * idle() a request came in: the background reads wait until the server has had IDLE_MS with no request
13
+ * warm(url, run, ctx) read this answer in the background, once the server is idle, so its first open is fast too
14
+ * onKept(fn) fn(url, body, ctx) after each fresh answer is kept: route-modules warms what the page opens next from it
15
+ * watch(roots) watch each workspace's records for a write made outside the server (an agent's `pmos` command, an editor)
16
+ * stats() · reset() for the tests
17
+ *
18
+ * THE RULES
19
+ * - A kept answer is shown only when nothing was written since it was read (GEN). A write the PM makes (any POST, PUT, PATCH or
20
+ * DELETE but the few on QUIET that change no record), and the end of a chat turn (the page posts /api/answer-cache/drop), make
21
+ * every kept answer too old: the next read waits for a fresh one, as before. So an edit shows at once, and a chat write lands.
22
+ * The AGAIN_MAX answers kept last are then read again in the background once the server is idle, so the next open after a
23
+ * write is fast again within about a second.
24
+ * - A kept answer older than FRESH_MS is shown, and the route is read again in the background once the server is idle, so a change
25
+ * made outside the server (a Jira read, a file) shows on the next open. One background read at a time; the newest ask wins.
26
+ * - A write made outside the server counts as a write too: each workspace's planning/ and pmos/ folders are watched (watch), and
27
+ * any change in them makes every kept answer too old. A workspace whose folders cannot be watched keeps nothing at all.
28
+ * - A kept answer older than MAX_AGE_MS, or kept on another day, is not shown: the read waits, as before.
29
+ * - Only a 200 answer that is ready is kept: a "reading" (202), stale or pending answer, and an error, are never kept.
30
+ * Nothing is written to disk; a restart starts empty (lib/page-warm.js fills the common ones). */
31
+
32
+ const SLOW = new Set([
33
+ '/api/initiative-premium',
34
+ '/api/board-premium',
35
+ '/api/ready-reports/dashboard',
36
+ '/api/events-place',
37
+ '/api/board-trail',
38
+ '/api/onboard/state',
39
+ '/api/news-for-you',
40
+ ]);
41
+ // writes that change no record a SLOW route reads: the use log, a session's heartbeat, view preferences
42
+ const fs = require('fs');
43
+ const path = require('path');
44
+ const QUIET = [/^\/api\/use-log(\/|$)/, /^\/api\/card-log(\/|$)/, /^\/api\/session\/touch$/, /^\/api\/view-prefs$/, /^\/api\/next-prompt\/prefs$/, /^\/api\/draft-keep\/mark$/];
45
+ const FRESH_MS = 3000;
46
+ const MAX_AGE_MS = 30 * 60 * 1000;
47
+ const IDLE_MS = 600;
48
+ const AHEAD_IDLE_MS = 2000; // a read nobody asked for yet waits for a longer quiet: it may hold the next press for up to its own length
49
+ const MAX_KEYS = 200;
50
+ const AGAIN_MAX = 12; // kept answers read again after a write, newest first
51
+ const QUEUE_MAX = 40;
52
+
53
+ let GEN = 0;
54
+ // the background read answers nobody: a route that touches `res` itself finds a response that takes nothing
55
+ const DUMMY = { headersSent: false, setHeader() {}, getHeader() {}, writeHead() { return this; }, write() { return true; }, end() {}, on() {} };
56
+ const kept = new Map(); // key → { gen, day, at, body, again } again(): the background read of the same question
57
+ const queue = new Map(); // key → run(ctx2) for the background read
58
+ const ahead = new Map(); // key → run(ctx2) for a read ahead (warm): only when queue is empty and the server was quiet AHEAD_IDLE_MS
59
+ let lastReq = 0, timer = null, busy = false, follower = null;
60
+ const n = { hit: 0, miss: 0, kept: 0, again: 0, bumped: 0, warmed: 0, outside: 0 };
61
+
62
+ const dayOf = () => new Date().toDateString(); // an answer kept yesterday is never shown today (Today, Events)
63
+ const keyOf = (url) => {
64
+ const q = [...url.searchParams.entries()].filter(([k]) => k !== '_' && k !== 't').sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
65
+ return url.pathname + '?' + q.map(([k, v]) => k + '=' + v).join('&');
66
+ };
67
+ const ready = (code, body) => (code || 200) === 200 && body && typeof body === 'object' && body.ok !== false
68
+ && body.state !== 'reading' && body.state !== 'error' && !body.stale && !body.pending;
69
+
70
+ function cacheable(pathname) { return SLOW.has(pathname); }
71
+ function bump(method, pathname) {
72
+ const m = String(method || 'GET').toUpperCase();
73
+ if (m === 'GET' || m === 'HEAD' || m === 'OPTIONS') return false;
74
+ if (!String(pathname || '').startsWith('/api/')) return false;
75
+ if (QUIET.some((re) => re.test(pathname))) return false;
76
+ return drop();
77
+ }
78
+ /** Every kept answer is too old from now on; the newest are read again once the server is idle. */
79
+ function drop() {
80
+ GEN++; n.bumped++; queue.clear(); ahead.clear();
81
+ // the newest kept answers are read again once the server is idle; until then a read waits for its own fresh answer
82
+ const last = [...kept.entries()].slice(-AGAIN_MAX).reverse();
83
+ for (const [key, e] of last) if (e.again) queue.set(key, e.again);
84
+ schedule();
85
+ return true;
86
+ }
87
+ function idle() { lastReq = Date.now(); }
88
+
89
+ /* ── writes made outside the server ── an agent's `pmos` command, a git checkout or an editor writes the records with no request to
90
+ * the server. The folders the records live in are watched: planning/ and pmos/ of each workspace, each with every folder under it, and
91
+ * the workspace folder itself (so a planning/ or pmos/ made later is watched from then on). .git and node_modules are never watched. */
92
+ const SKIP = /(^|[\\/])(\.git|node_modules)([\\/]|$)/;
93
+ const watched = new Map(); // folder → FSWatcher | 'none' (not there) | 'blind' (there, but it cannot be watched)
94
+ let blind = false;
95
+ function watchDir(dir, recursive) {
96
+ if (watched.has(dir) && watched.get(dir) !== 'none') return;
97
+ let there = false; try { there = fs.statSync(dir).isDirectory(); } catch { there = false; }
98
+ if (!there) { watched.set(dir, 'none'); return; }
99
+ try {
100
+ const w = fs.watch(dir, { recursive, persistent: false }, (ev, f) => {
101
+ if (f && SKIP.test(String(f))) return;
102
+ n.outside++; drop();
103
+ if (!recursive && (f === 'planning' || f === 'pmos')) watchDir(path.join(dir, f), true);
104
+ });
105
+ w.on('error', () => { try { w.close(); } catch { /* closed */ } watched.set(dir, 'blind'); blind = true; drop(); });
106
+ watched.set(dir, w);
107
+ } catch { watched.set(dir, 'blind'); blind = true; }
108
+ }
109
+ function watch(roots) {
110
+ for (const root of roots || []) {
111
+ if (!root || typeof root !== 'string') continue;
112
+ watchDir(root, false);
113
+ watchDir(path.join(root, 'planning'), true);
114
+ watchDir(path.join(root, 'pmos'), true);
115
+ }
116
+ return !blind;
117
+ }
118
+
119
+ function keep(key, gen, body, again, url, ctx) {
120
+ if (gen !== GEN) return; // a write landed while it was read: this answer may already be old
121
+ kept.delete(key); kept.set(key, { gen, day: dayOf(), at: Date.now(), body, again }); n.kept++;
122
+ while (kept.size > MAX_KEYS) kept.delete(kept.keys().next().value);
123
+ if (follower && url) { try { follower(url, body, ctx); } catch { /* a warm-up is never needed for the answer */ } }
124
+ }
125
+ const fresh = (e) => !!e && e.gen === GEN && e.day === dayOf() && Date.now() - e.at < MAX_AGE_MS;
126
+ function warm(url, run, ctx) {
127
+ const key = keyOf(url);
128
+ if (fresh(kept.get(key)) || queue.has(key) || ahead.has(key) || ahead.size >= QUEUE_MAX) return false;
129
+ ahead.set(key, () => capture(run, ctx, null).catch(() => null));
130
+ n.warmed++;
131
+ schedule();
132
+ return true;
133
+ }
134
+ function onKept(fn) { follower = typeof fn === 'function' ? fn : null; }
135
+
136
+ /** Runs the route with ctx.json watched; the answer still goes to `res` when `res` is given. → { handled, code?, body? } */
137
+ async function capture(run, ctx, res, url) {
138
+ let got = null;
139
+ const ctx2 = Object.assign({}, ctx, { json: (r, obj, code) => { got = { code: code || 200, body: obj }; if (res) return ctx.json(res, obj, code); return undefined; } });
140
+ const handled = (await run(ctx2, res || DUMMY)) === true;
141
+ return { handled, url, ctx, ...(got || {}) };
142
+ }
143
+
144
+ function schedule() {
145
+ if (timer || busy || (!queue.size && !ahead.size)) return;
146
+ const need = queue.size ? IDLE_MS : AHEAD_IDLE_MS;
147
+ const wait = Math.max(0, need - (Date.now() - lastReq));
148
+ timer = setTimeout(async () => {
149
+ timer = null;
150
+ if (Date.now() - lastReq < (queue.size ? IDLE_MS : AHEAD_IDLE_MS)) { schedule(); return; }
151
+ const from = queue.size ? queue : ahead;
152
+ const [key, job] = from.entries().next().value; from.delete(key);
153
+ busy = true;
154
+ try { const gen = GEN, a = await job(); if (a && a.handled && ready(a.code, a.body)) { keep(key, gen, a.body, job, a.url, a.ctx); n.again++; } }
155
+ catch { /* the next open reads it in the foreground */ }
156
+ busy = false;
157
+ schedule();
158
+ }, wait);
159
+ if (timer.unref) timer.unref();
160
+ }
161
+
162
+ async function serve(req, res, url, ctx, run) {
163
+ if (blind) return (await capture(run, ctx, res, url)).handled; // a write outside the server could not be seen: keep nothing
164
+ // a write that landed just before this request is seen first: the watchers' events of this turn of the loop run before the check
165
+ if (kept.size) await new Promise((r) => setImmediate(r));
166
+ const key = keyOf(url), e = kept.get(key), now = Date.now();
167
+ const again = () => capture(run, ctx, null, url).catch(() => null);
168
+ if (fresh(e)) {
169
+ n.hit++;
170
+ ctx.json(res, e.body, 200);
171
+ if (now - e.at >= FRESH_MS) { queue.delete(key); queue.set(key, again); schedule(); }
172
+ return true;
173
+ }
174
+ n.miss++;
175
+ const gen = GEN;
176
+ const a = await capture(run, ctx, res, url);
177
+ if (!a.handled) return false;
178
+ if (a.body !== undefined && ready(a.code, a.body)) keep(key, gen, a.body, again, url, ctx);
179
+ return true;
180
+ }
181
+
182
+ function stats() { return { ...n, size: kept.size, gen: GEN, queued: queue.size, ahead: ahead.size }; }
183
+ function reset() { for (const w of watched.values()) if (w && typeof w === 'object') { try { w.close(); } catch { /* closed */ } } watched.clear(); blind = false; kept.clear(); queue.clear(); ahead.clear(); GEN = 0; if (timer) clearTimeout(timer); timer = null; busy = false; lastReq = 0; follower = null; for (const k of Object.keys(n)) n[k] = 0; }
184
+
185
+ module.exports = { SLOW, QUIET, FRESH_MS, MAX_AGE_MS, IDLE_MS, AHEAD_IDLE_MS, AGAIN_MAX, cacheable, serve, bump, drop, idle, warm, onKept, watch, stats, reset, keyOf };
@@ -190,7 +190,7 @@ function workflow({ root }) {
190
190
  * split, same reasons, stated in `historyRange`'s own header. The `build` rung is attributed per
191
191
  * initiative now (R-2), so a trunk-wide range no longer means a trunk-wide answer.
192
192
  */
193
- const range = engine.historyRange(root);
193
+ const range = historyRangeOf(engine, root);
194
194
  const changeRange = engine.commitRange(root);
195
195
  // ONE delivery index for the board, built once and shared, exactly as the CLI board does.
196
196
  let deliveryIndex = null;
@@ -243,6 +243,27 @@ function workflow({ root }) {
243
243
 
244
244
  // ENGINE_PATHS/loadEngine are exported for the packaging guard in workspace/test.js: the incident
245
245
  // that made them a list was invisible to every unit test precisely because resolution was inline.
246
+ /* The trunk's whole history, kept per repository until a trunk ref moves (page-open-200ms). `historyRange` reads every commit of the
247
+ * trunk with one `git log` (about 1 s on this repository), and the board, every initiative page and the initiative's sheet each asked
248
+ * for it again. The trunk refs' own ids (one `git for-each-ref`, a few ms) say whether it moved: a commit, a pull or a fetch gives a
249
+ * new key and the next read reads the history again. A range that could not be read is never kept. */
250
+ const RANGES = new Map(); // root → { key, range }
251
+ const TRUNK_REFS = ['refs/remotes/origin/main', 'refs/heads/main', 'refs/remotes/origin/master', 'refs/heads/master'];
252
+ function trunkKey(root) {
253
+ try {
254
+ const out = require('child_process').execFileSync('git', ['for-each-ref', '--format=%(refname) %(objectname)', ...TRUNK_REFS], { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], timeout: 5000 });
255
+ const head = require('child_process').execFileSync('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], timeout: 5000 });
256
+ return out.trim() + '|' + head.trim();
257
+ } catch { return null; }
258
+ }
259
+ function historyRangeOf(engine, root) {
260
+ const key = trunkKey(root), got = RANGES.get(root);
261
+ if (key && got && got.key === key) return got.range;
262
+ const range = engine.historyRange(root);
263
+ if (key && range && range.ok) { RANGES.set(root, { key, range }); if (RANGES.size > 16) RANGES.delete(RANGES.keys().next().value); }
264
+ return range;
265
+ }
266
+
246
267
  /* ONE initiative's ladder, derived on demand.
247
268
  *
248
269
  * WHY THIS IS SEPARATE FROM `workflow`. The board caps what it returns (`inFlight`) and reports the
@@ -274,7 +295,7 @@ function ladder({ root, id }) {
274
295
  // the PM named, and "where does it stand" is a question the pull-request range cannot answer — on
275
296
  // main it is empty, so the panel reported `BUILD 0/3` on delivered work (R-3).
276
297
  let range, changeRange, row;
277
- try { range = engine.historyRange(root); }
298
+ try { range = historyRangeOf(engine, root); }
278
299
  catch (e) { return { ok: false, error: 'could not resolve the commit range: ' + String((e && e.message) || 'error').slice(0, 120) }; }
279
300
  try { changeRange = engine.commitRange(root); } catch { changeRange = { ok: false }; }
280
301
  try { row = engine.computeWorkflow(id, { root, range, changeRange }); }
@@ -296,4 +317,4 @@ function ladder({ root, id }) {
296
317
  };
297
318
  }
298
319
 
299
- module.exports = { metrics, radar, workflow, ladder, computeMetricsFromRuns, loadJson, loadJsonl, ENGINE_PATHS, loadEngine };
320
+ module.exports = { metrics, radar, workflow, ladder, historyRangeOf, computeMetricsFromRuns, loadJson, loadJsonl, ENGINE_PATHS, loadEngine };
@@ -18,6 +18,9 @@ const PATHS = [
18
18
  '/api/notes',
19
19
  '/api/live',
20
20
  '/api/insights-premium',
21
+ // Today's events and the onboarding check, kept by lib/answer-cache.js once read (page-open-200ms)
22
+ '/api/events-place',
23
+ '/api/onboard/state',
21
24
  ];
22
25
 
23
26
  function httpGet(host, port, p) {
@@ -29,6 +29,8 @@
29
29
  */
30
30
  const fs = require('fs');
31
31
  const path = require('path');
32
+ // a copy of this loader without answer-cache.js beside it (package-closure.test.js) still routes, with nothing kept
33
+ let answerCache; try { answerCache = require('./answer-cache.js'); } catch { answerCache = { cacheable: () => false, onKept() {}, warm() { return false; }, watch() { return false; } }; }
32
34
 
33
35
  const MODULES = Object.freeze([
34
36
  'routes-setup', // Claude-ready onboarding, explicit profile checks and real first work
@@ -218,9 +220,31 @@ function pmModules(url) {
218
220
  return { ok: true, present, grantScopes };
219
221
  }
220
222
 
223
+ /* What a page opens next, read in the background once the server is idle (lib/answer-cache.js warm, page-open-200ms): Work's answer names
224
+ * its initiatives, so the first WARM_INI of them open from a kept answer too. The warm read asks exactly as the initiative page does
225
+ * (id, ws, board) and holds no request of its own: no header is passed on. */
226
+ const WARM_INI = 12;
227
+ // a suite's server (a state folder under the system temp folder) reads nothing ahead, as it does not warm at start (lib/page-warm.js)
228
+ let aheadOn = null;
229
+ const readsAhead = () => { if (aheadOn === null) { try { aheadOn = require('./page-warm.js').shouldWarm(process.env, process.env.PMOS_STATE_DIR || null); } catch { aheadOn = false; } } return aheadOn; };
230
+ answerCache.onKept((url, body, ctx) => {
231
+ if (url.pathname !== '/api/board-premium' || !readsAhead()) return;
232
+ const m = body && body.model, b = m && m.board;
233
+ if (!b || b.all) return;
234
+ const owner = ownerOf('/api/initiative-premium'), t = load();
235
+ if (!owner || !t.mods[owner.name]) return;
236
+ const rows = (m.initiatives && m.initiatives.list && m.initiatives.list.rows) || [];
237
+ for (const r of rows.slice(0, WARM_INI)) {
238
+ if (!r || !r.id) continue;
239
+ const u = new URL('http://local/api/initiative-premium?id=' + encodeURIComponent(r.id) + (b.ws ? '&ws=' + encodeURIComponent(b.ws) : '') + (b.id ? '&board=' + encodeURIComponent(b.id) : ''));
240
+ answerCache.warm(u, (c, r2) => t.mods[owner.name].handle({ method: 'GET', headers: {} }, r2, u, c), ctx);
241
+ }
242
+ });
221
243
  async function dispatch(req, res, url, ctx) {
222
244
  const p = url.pathname;
223
245
  if (!p.startsWith('/api/')) return false;
246
+ // the end of a chat turn: the page says so, and the write it makes drops every kept answer (server.js bumps on every write)
247
+ if (p === '/api/answer-cache/drop') { ctx.json(res, req.method === 'POST' ? { ok: true } : { ok: false, error: 'POST only' }, req.method === 'POST' ? 200 : 405); return true; }
224
248
  const owner = ownerOf(p);
225
249
  if (!owner) return false;
226
250
  const t = load();
@@ -233,6 +257,18 @@ async function dispatch(req, res, url, ctx) {
233
257
  const readJson = async (r) => {
234
258
  try { return { ok: true, body: JSON.parse((await ctx.readBody(r)) || '{}') }; } catch { return { ok: false }; }
235
259
  };
260
+ // the slow reads a page opens on answer from their last answer while nothing was written (lib/answer-cache.js, page-open-200ms)
261
+ if (req.method === 'GET' && answerCache.cacheable(p)) {
262
+ try {
263
+ answerCache.watch((ctx.workspaceList ? ctx.workspaceList() : []).map((w) => w && w.root));
264
+ return await answerCache.serve(req, res, url, { ...ctx, readJson }, (c, r) => t.mods[owner.name].handle(req, r, url, c));
265
+ }
266
+ catch (e) {
267
+ if (res.headersSent) { try { res.end(); } catch { /* already closed */ } return true; }
268
+ ctx.json(res, { ok: false, error: `${owner.name} failed: ${String((e && e.message) || e).slice(0, 200)}` }, 500);
269
+ return true;
270
+ }
271
+ }
236
272
  try { return (await t.mods[owner.name].handle(req, res, url, { ...ctx, readJson })) === true; }
237
273
  catch (e) {
238
274
  if (res.headersSent) { try { res.end(); } catch { /* already closed */ } return true; }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.798.0",
3
+ "version": "0.800.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.798.0",
9
+ "version": "0.800.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.798.0",
3
+ "version": "0.800.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -639,14 +639,29 @@ function toAsk(text, h) {
639
639
  * job (pm/star-draft.js, POST /api/star-drafts) with no chat and no session of the PM's. The line says PMOS is drafting it; the draft then
640
640
  * lands on the line itself through the line's own save, with Undo. A job that fails says why, with Try again. */
641
641
  const DRAFTING = new Set(); // '<popup key>:<line id>' while its job runs
642
- async function draftLine(L, x, h) {
642
+ /* o.quiet: no toast of its own; the line's saved ref comes back so one press that drafts several lines says it once (draftLines) */
643
+ async function draftLine(L, x, h, o = {}) {
643
644
  const w = h.where ? h.where() : {}, kid = keyOf(x.v(), x.o()), k = kid + ':' + L.id;
644
- if (DRAFTING.has(k)) return;
645
+ if (DRAFTING.has(k)) return null;
645
646
  DRAFTING.add(k); if (h.redraw) h.redraw();
646
647
  const r = await SD.run(L.ask, { ws: w.ws || x.o().ws, pmPost, pmGet });
647
648
  DRAFTING.delete(k);
648
- if (!r.ok) { if (h.redraw) h.redraw(); undoToast(r.why, () => draftLine(L, x, h), 12000, 'Try again'); return; }
649
- await saveLine(L, r.text.replace(/\s+/g, ' ').trim().slice(0, 600), x, h);
649
+ if (!r.ok) { if (h.redraw) h.redraw(); undoToast(L.k + ': ' + r.why, () => draftLine(L, x, h), 12000, 'Try again'); return null; }
650
+ return saveLine(L, r.text.replace(/\s+/g, ' ').trim().slice(0, 600), x, h, { quiet: o.quiet, said: L.k + ' drafted.' });
651
+ }
652
+ /** One press that drafts several lines ("Draft the Problem and Goal"): the drafts run side by side and land with ONE toast that names every
653
+ * line drafted and ONE Undo for all of them. Before, each line's own toast replaced the last, so "Problem saved." stood for a press about the
654
+ * goal and Undo took back only one line. */
655
+ async function draftLines(Ls, x, h) {
656
+ if (Ls.length === 1) { await draftLine(Ls[0], x, h); return; }
657
+ const got = await Promise.all(Ls.map((L) => draftLine(L, x, h, { quiet: true }).then((ref) => (typeof ref === 'string' && ref ? { L, ref } : null))));
658
+ const ok = got.filter(Boolean); if (!ok.length) return;
659
+ const w = h.where ? h.where() : {}, o = x.o(), ws = w.ws || o.ws, names = ok.map((g) => g.L.k);
660
+ undoToast((names.length === 2 ? names.join(' and ') : names.length + ' lines') + ' drafted.', async () => {
661
+ let bad = '';
662
+ for (const g of ok) { const u = await pmPost('/api/artefacts/undo', { ws, ref: g.ref }).catch(() => null); if (!u || u.ok === false) bad = (u && u.error) || 'The undo did not land.'; }
663
+ ART.delete(o.id); if (bad && h.toast) h.toast(bad); if (h.redraw) h.redraw();
664
+ });
650
665
  }
651
666
  /* a program's line (its charter's why or goal): the same job, saved with POST /api/programs/save, and Undo saves the line as it was */
652
667
  const LV_FIELD = { for: 'why', goal: 'goal' };
@@ -895,7 +910,7 @@ export function wire(body, h0, x0) {
895
910
  if ('swSave' in d) { if (SLED) SLED.save(); return; }
896
911
  if (d.pwLine) { const L = W.overview.lines.find((q) => q.id === d.pwLine); if (L && L.edit) editLine(b, L, c, x, h); return; }
897
912
  // a phone asks for several lines in one proposal: "problem,done"
898
- if (d.pwLkeep) { const ls = d.pwLkeep.split(',').map((k) => W.overview.lines.find((q) => q.id === k)).filter((L) => L && L.ask); for (const L of ls) { if (L.edit) draftLine(L, x, h); else toAsk(L.ask, h); } return; }
913
+ if (d.pwLkeep) { const ls = d.pwLkeep.split(',').map((k) => W.overview.lines.find((q) => q.id === k)).filter((L) => L && L.ask); for (const L of ls) if (!L.edit) toAsk(L.ask, h); draftLines(ls.filter((L) => L.edit), x, h); return; }
899
914
  if (d.pwLdrop) { const dd = dropped(); for (const k of d.pwLdrop.split(',')) dd.add(k); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
900
915
  if ('pwPdocs' in d) { if (PH_ARTS.has(c.id)) PH_ARTS.delete(c.id); else PH_ARTS.add(c.id); redraw(); return; }
901
916
  if (d.pwSrc) { if (h.doc) h.doc(d.pwSrc); return; }
@@ -1050,7 +1065,7 @@ function editLine(el, L, c, x, h) {
1050
1065
  ta.addEventListener('blur', () => leave(true));
1051
1066
  ta.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); leave(false); } else if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); ta.blur(); } });
1052
1067
  }
1053
- async function saveLine(L, text, x, h) {
1068
+ async function saveLine(L, text, x, h, opt = {}) {
1054
1069
  if (L.edit.to === 'desc') return saveDesc(text, x, h);
1055
1070
  const w = h.where ? h.where() : {}, o = x.o(), id = o.id, ws = w.ws || o.ws, kid = keyOf(x.v(), o);
1056
1071
  // shown at once (Wawan, 2026-11-23); the next read of the artefacts replaces it
@@ -1065,13 +1080,13 @@ async function saveLine(L, text, x, h) {
1065
1080
  }
1066
1081
  const ref = res.line.id;
1067
1082
  ART.delete(id);
1068
- undoToast(L.k + ' saved.', async () => {
1083
+ if (!opt.quiet) undoToast(opt.said || L.k + ' saved.', async () => {
1069
1084
  const u = await pmPost('/api/artefacts/undo', { ws, ref }).catch(() => null);
1070
1085
  if (!u || u.ok === false) { if (h.toast) h.toast((u && u.error) || 'The undo did not land.'); return; }
1071
1086
  ART.delete(id); if (h.redraw) h.redraw();
1072
1087
  });
1073
1088
  if (h.redraw) h.redraw();
1074
- return true;
1089
+ return ref;
1075
1090
  }
1076
1091
  function rename(btn, uid, h) {
1077
1092
  const inp = document.createElement('input');
@@ -281,10 +281,16 @@ export function wireDash(body, h0) {
281
281
  * menu (on a phone the toggle sits in ⋯) }
282
282
  * → { presses(), shows(), html(work), read(via), toggle(), wire(body) } */
283
283
  export function dashHost(o) {
284
- const x = { view: 'work', d: null, read: false, open: new Set() };
284
+ // used: the PM pressed or typed in the Work view before the first read landed (drafting the goal, ticking a task). That read may still bring
285
+ // the PM's Dashboard choice or the server's opening view, but it never swaps the page from under a press in progress: the view the PM is
286
+ // using stays, and ⋯ › Show the dashboard is one press away. Before, a phone that read the dashboard slowly opened it seconds after a press
287
+ // on Work, and ← then left the initiative.
288
+ const x = { view: 'work', d: null, read: false, used: false, open: new Set() };
285
289
  const W = () => (typeof o.ws === 'function' ? o.ws() : o.ws) || '', B = () => (typeof o.board === 'function' ? o.board() : o.board) || '';
286
290
  // o.menu: on a phone the toggle goes into ⋯ (the initiative's page, batch 18 item 1)
287
- const presses = () => (x.d ? [{ ...togglePress(x.view), menu: !!o.menu }] : []);
291
+ // while the Dashboard shows, its way back to the work stays in the header on a phone too: ← leaves the initiative, so "Show the work" must
292
+ // not hide in ⋯ (drafting the goal from a phone, 2026-11-24)
293
+ const presses = () => (x.d ? [{ ...togglePress(x.view), menu: !!o.menu && x.view !== 'dash' }] : []);
288
294
  const shows = () => x.view === 'dash' && !!x.d;
289
295
  // the body is drawn again only when it shows the dashboard, before or after: a read that lands on the Work view only adds the header icon,
290
296
  // so the focus (a stage picker, a task being typed) stays where the PM left it
@@ -292,7 +298,7 @@ export function dashHost(o) {
292
298
  async function read(via) {
293
299
  const was = shows();
294
300
  const d = await readDash(W(), o.scope, via);
295
- if (!d) { x.d = null; if (x.view === 'dash') x.view = 'work'; } else { const first = !x.read; x.d = d; if (first) x.view = viewOf(o.page, d.opens); }
301
+ if (!d) { x.d = null; if (x.view === 'dash') x.view = 'work'; } else { const first = !x.read; x.d = d; if (first && !x.used) x.view = viewOf(o.page, d.opens); }
296
302
  x.read = true; sync(was);
297
303
  }
298
304
  function toggle() {
@@ -302,6 +308,9 @@ export function dashHost(o) {
302
308
  }
303
309
  const html = (work) => (shows() ? dashHtml(x.d, { open: x.open, mdHtml: o.mdHtml ? o.mdHtml() : '' }) : work());
304
310
  function wire(body) {
311
+ // a press or a key in the Work view before the first read lands: the PM is using this page (x.used above). Once per body, like wireDash.
312
+ body._dbHost = x;
313
+ if (!body._dbUse) { body._dbUse = true; const use = () => { const h = body._dbHost; if (h && !h.read && h.view === 'work') h.used = true; }; body.addEventListener('pointerdown', use, true); body.addEventListener('keydown', use, true); }
305
314
  // ✎ on Needs you: the work shows (this once, not kept as the PM's choice) and Claude proposes opens on the decision (pm/ini-props.js)
306
315
  const editNeeds = o.editNeeds || (() => { x.view = 'work'; sync(); setTimeout(() => { const c = document.querySelector('#czViewer [data-cz-vw="chip"]'); if (c) c.click(); }, 0); });
307
316
  wireDash(body, { d: () => { const c = o.VW.current && o.VW.current(); return shows() && c && c.id === o.vid ? x.d : null; }, open: x.open, get ws() { return W(); }, get board() { return B(); }, toast: o.toast, redraw: o.redraw, reload: () => read(), openReport: o.openReport, editNeeds });
@@ -1067,9 +1067,10 @@ const chat = mountChat($('#hmChat'), {
1067
1067
  let turnT = null;
1068
1068
  function turnEnded() {
1069
1069
  clearTimeout(turnT);
1070
- turnT = setTimeout(async () => { await load(); iniFresh(); if (progPanel) progPanel.then((PP) => PP.refresh()); }, 400); // two chats that finish together read once
1071
- // the popup's own reads (the case card, the Library's rows) are read again too, as on every other page (initiative chat-saves-to-cards)
1072
- document.dispatchEvent(new CustomEvent('cz:chat-turn'));
1070
+ const drop = pmPost('/api/answer-cache/drop', {}).catch(() => null); // kept answers go first (page-open-200ms)
1071
+ turnT = setTimeout(async () => { await drop; await load(); iniFresh(); if (progPanel) progPanel.then((PP) => PP.refresh()); }, 400); // two chats read once
1072
+ drop.then(() => document.dispatchEvent(new CustomEvent('cz:chat-turn')));
1073
+ // ↑ the popup's own reads (the case card, the Library's rows) are read again too, as on every other page (initiative chat-saves-to-cards)
1073
1074
  }
1074
1075
  /* claude-onboarding-build: set up a project as a conversation in this chat's place (cozy-onboard.js). It opens on ?onboard=1, shows the
1075
1076
  * finished project's next steps on ?onboarded=1, and opens by itself on a first run: setup not finished and no registered folder holds an
@@ -96,7 +96,8 @@ function host() {
96
96
  workItem: () => toast('Make it a task from Today, in the initiative’s own chat.'),
97
97
  viewerClosed: () => false, reopenViewer: () => {}, desk: () => true, head: () => '',
98
98
  // a finished turn: the page reads its records again, so what Claude changed shows with no refresh (as Home, batch 25 item 3)
99
- turnEnded: () => document.dispatchEvent(new CustomEvent('cz:chat-turn')),
99
+ // the server's kept answers are dropped first, so the reads see what the chat wrote (lib/answer-cache.js, page-open-200ms)
100
+ turnEnded: () => { Promise.resolve(pmPost('/api/answer-cache/drop', {})).catch(() => null).then(() => document.dispatchEvent(new CustomEvent('cz:chat-turn'))); },
100
101
  };
101
102
  }
102
103
  async function mod() {
@@ -256,16 +256,23 @@ function drawPick() {
256
256
  }
257
257
  // a saved pick (this chip, or Settings): the Board opens on the ticked products, without a one-off link's ws or board
258
258
  addEventListener('pp:changed', () => { const q = new URLSearchParams(location.search); ['ws', 'board', 'all', 'pick'].forEach((k) => q.delete(k)); const s = q.toString(); location.assign(location.pathname + (s ? '?' + s : '')); });
259
+ const SW_KEY = 'pmos.board.switcher';
260
+ function keptSwitcher() { try { const a = JSON.parse(store.get(SW_KEY) || 'null'); return Array.isArray(a) && a.length && a.every((b) => b && b.id) ? a : null; } catch { return null; } }
259
261
  /** Turn the saved pick into the boards to read: every product's board (All), several (PICK), one (ONE) or the default board. false while the
260
262
  * default board is still being read (its switcher lists the boards). A one-off link keeps its own. */
261
263
  async function resolvePick() {
262
264
  if (picked) return true;
263
265
  if (!PKP) PKP = await PK.readPick();
264
266
  if (DEEP || !PKP) { picked = true; return true; }
265
- const h = await readBoard('');
266
- if (h.r && h.r.state === 'reading') return false;
267
+ // the boards to pick between, as the last read of any board listed them (page-open-200ms): the default board is read only when no
268
+ // board was read on this browser before, so Work reads the picked boards once instead of the default board first
269
+ let sw = keptSwitcher();
270
+ if (!sw) {
271
+ const h = await readBoard('');
272
+ if (h.r && h.r.state === 'reading') return false;
273
+ sw = (h.r && h.r.ok && h.r.model && h.r.model.board.switcher) || null;
274
+ }
267
275
  picked = true;
268
- const sw = (h.r && h.r.ok && h.r.model && h.r.model.board.switcher) || null;
269
276
  if (!sw) return true; // one board: nothing to pick between
270
277
  const on = new Set(PKP.products.filter((p) => p.on).map((p) => p.ws)), keys = sw.filter((b) => on.has(b.ws)).map((b) => b.ws + '|' + b.id);
271
278
  if (!keys.length) return true;
@@ -1444,10 +1451,12 @@ function newOnce() {
1444
1451
  history.replaceState(history.state, '', location.pathname + (s ? '?' + s : ''));
1445
1452
  Acts.open.new($('#newIni'));
1446
1453
  }
1447
- /** One board's model (GET /api/board-premium); { r, status }. */
1454
+ /** One board's model (GET /api/board-premium); { r, status }. Its switcher is kept for the next open's pick (resolvePick). */
1448
1455
  async function readBoard(q) {
1449
1456
  let r = null, status = 0;
1450
1457
  try { const res = await fetch('/api/board-premium' + (q ? '?' + q : ''), { credentials: 'same-origin' }); status = res.status; r = await res.json(); } catch { r = null; }
1458
+ const sw = r && r.ok && r.model && r.model.board && r.model.board.switcher;
1459
+ if (Array.isArray(sw) && sw.length) store.set(SW_KEY, JSON.stringify(sw.map((b) => ({ ws: b.ws || '', id: b.id, name: b.name }))));
1451
1460
  return { r, status };
1452
1461
  }
1453
1462
  /** All products: this board first, then every other product's board, merged into one model (pm/bd-prog.js mergeBoards). While any board
@@ -179,6 +179,7 @@ const jiraMoveSessions = new Map();
179
179
  const jiraMoves = require('./lib/jira-moves.js');
180
180
  const planItems = require('./lib/plan-items.js'); // pm-os-absorb Run 1 — the ONE writer and fold of plan-items.jsonl (control graph)
181
181
  const planTree = require('./lib/plan-tree.js'); // …and the Breakdown layout: derived stages, owed rows, the Board columns
182
+ const answerCache = require('./lib/answer-cache.js'); // page-open-200ms: the slow reads a page opens on, kept until a write
182
183
  const routeModules = require('./lib/route-modules.js'); // pm-os-absorb Runs 2–5 — each run's routes in its own lib/routes-<name>.js
183
184
  const needsProviders = require('./lib/needs-providers.js'); // …and each run's needs-you rows, folded into deriveNeeds
184
185
  const pmGuard = require('./lib/pm-guard.js'); // pm-os-absorb Run 2 (R25) — Origin, nonce and writer fields on every PM press
@@ -7358,6 +7359,8 @@ function json(res, obj, code = 200) {
7358
7359
 
7359
7360
  async function handleRequest(req, res) {
7360
7361
  const url = new URL(req.url, 'http://localhost');
7362
+ // page-open-200ms: a write makes every kept answer too old to show; any request holds the background reads back (lib/answer-cache.js)
7363
+ if (url.pathname.startsWith('/api/')) { answerCache.idle(); answerCache.bump(req.method, url.pathname); }
7361
7364
  // A page file under this or an earlier launch's build prefix is the same file without it (see BUILD above).
7362
7365
  const built = BUILD_RE.exec(url.pathname);
7363
7366
  const p = built ? built[2] : url.pathname;
@@ -133,7 +133,8 @@
133
133
  "loop-telemetry.test.js",
134
134
  "signals.test.js",
135
135
  "task-jira-sync.test.js",
136
- "correction-kinds.test.js"
136
+ "correction-kinds.test.js",
137
+ "answer-cache.test.js"
137
138
  ],
138
139
  "panels": [
139
140
  "pm-r7-test.js",