create-pmos 0.262.0 → 0.264.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.262.0",
3
+ "version": "0.264.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": {
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@9a1003d
1
+ kernel-source: pmos@4f2710e
2
2
  assembled: 2026-10-18
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-10-18T07:58:49Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-18T08:53:35Z"}
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-10-18T07:58:49Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-18T08:53:35Z"}
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-10-18T07:58:49Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-18T08:53:35Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -0,0 +1,195 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* briefing-premium-calendar-test.js — the Today / This week switch and the meeting dialog on the premium Briefing (initiative briefing-premium-calendar, slice 1;
4
+ * planning/prd/briefing-premium-calendar-prd.md C1 to C10). Serves the real page from the real server. The Briefing model, the calendar answer, the replay and the material
5
+ * are answered by stand-ins, so each press can be read off the request the page sent; the routes' own behaviour is in their own suites.
6
+ * C1 the switch · C2 the week · C3 honest states · C4 the dialog · C5 link it · C6 notes · C7 material · C8 replay summary · C9 only the link write · C10 floors and fidelity
7
+ * Every wait polls the page; no fixed sleep stands in for a state. */
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ const { spawn } = require('child_process');
11
+ const { findBrowser } = require('./lib/find-browser');
12
+ const T = require('./test-run').configure({ name: 'briefing-premium-calendar' });
13
+ const B = require('./lib/briefing-premium.js');
14
+ const F = require('./fixtures/briefing-premium-facts.js');
15
+
16
+ const BASE = T.BASE;
17
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
18
+ const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
19
+ const results = [];
20
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
21
+ let srv = null; let browser = null;
22
+ const finish = async (code) => {
23
+ if (browser) await browser.close().catch(() => {});
24
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
25
+ T.killTmux();
26
+ const bad = results.filter((x) => !x.cond).length;
27
+ console.log(`\n${results.length - bad}/${results.length} briefing-premium-calendar assertions passed`);
28
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
29
+ };
30
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
31
+
32
+ const pad = (n) => String(n).padStart(2, '0');
33
+ const dayKey = (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
34
+ const iso = (d) => { const off = -d.getTimezoneOffset(), a = Math.abs(off); return `${dayKey(d)}T${pad(d.getHours())}:${pad(d.getMinutes())}:00${off >= 0 ? '+' : '-'}${pad(Math.floor(a / 60))}:${pad(a % 60)}`; };
35
+ const NOW = new Date();
36
+ const at = (h, m, plus = 0) => { const d = new Date(NOW.getFullYear(), NOW.getMonth(), NOW.getDate() + plus, h, m, 0, 0); return d; };
37
+ const monday = () => { const d = new Date(NOW.getFullYear(), NOW.getMonth(), NOW.getDate()); d.setDate(d.getDate() - ((d.getDay() + 6) % 7)); return d; };
38
+ const weekAnswer = () => {
39
+ const m = monday(), cells = [];
40
+ for (let i = 0; i < 7; i++) { const d = new Date(m.getFullYear(), m.getMonth(), m.getDate() + i); cells.push({ key: dayKey(d), start: dayKey(d), end: dayKey(d), events: [] }); }
41
+ const put = (d, e) => cells.find((c) => c.key === dayKey(d)).events.push(e);
42
+ put(at(9, 30), { id: 'ev-checkout', at: iso(at(9, 30)), end: iso(at(10, 15)), title: 'Checkout sync', attendees: ['Priya', 'Dara'] });
43
+ put(at(14, 0), { id: 'ev-sprint', at: iso(at(14, 0)), end: iso(at(15, 0)), title: 'Sprint planning', attendees: ['Dara', 'Priya', 'Sam'], series: 'sprint-planning' });
44
+ const other = at(9, 30, NOW.getDay() === 0 ? -1 : 1); // a day other than today, still in the week unless it runs off the end
45
+ if (cells.some((c) => c.key === dayKey(other))) put(other, { id: 'ev-standup', at: iso(other), end: iso(new Date(other.getTime() + 30 * 60000)), title: 'Standup', attendees: [] });
46
+ return { ok: true, view: 'week', range: { start: cells[0].key, end: cells[6].key }, cells, events_source: 'calendar-memory', today: dayKey(NOW),
47
+ context: { 'ev-sprint': { phase: 'upcoming', level: { kind: 'board', ws: 'w1', id: 'idpf', name: 'IDPF', why: 'you linked it to the board', by: 'pm' } } },
48
+ link_boards: [{ ws: 'w1', id: 'idpf', name: 'IDPF' }, { ws: 'w1', id: 'pay', name: 'Payments' }], gantt: [{ id: 'premium-ux', title: 'Premium UX' }] };
49
+ };
50
+ const REPLAY = { ok: true, note: { id: 'n1', title: 'Sprint planning notes' }, meeting: { title: 'Sprint planning', attendees: ['Dara', 'Priya', 'Sam'] }, audio: { url: '/x', ms: 1500000 }, length_ms: 1500000, lines: [{}],
51
+ keys: [{ k: 'decision', text: 'Plan the sprint with eight people', state: 'draft' }, { k: 'action', text: 'Sam confirms the data fix owner', owner: 'Sam', due: 'Tue', state: 'owner' }, { k: 'question', text: 'Does a release eat the capacity?', state: 'open' }] };
52
+ const MATERIAL = { ok: true, key: 'k', items: [{ id: 'm1', kind: 'doc', ref: 'r', title: 'Capacity sheet', scope: 'series' }, { id: 'm2', kind: 'link', url: 'https://x.example', title: 'Roadmap', scope: 'meeting' }] };
53
+ const MOCKUP = fs.readFileSync(path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'briefing-artifact.html'), 'utf8');
54
+
55
+ (async () => {
56
+ const exe = findBrowser();
57
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
58
+ let chromium;
59
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
60
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
61
+ await T.waitForServer(BASE);
62
+ browser = await chromium.launch({ executablePath: exe });
63
+
64
+ const facts = () => { const f = F.facts(); f.meetings = [{ start: at(14, 0).getTime(), end: at(15, 0).getTime(), title: 'Sprint planning', with: 'Dara, Priya, Sam', initiative: null }]; return f; };
65
+ const open = async ({ w = 1280, h = 900, theme = 'light', week = weekAnswer(), replay = 404, material = MATERIAL, linkRes = { ok: true, link: { kind: 'portfolio' } } } = {}) => {
66
+ const ctx = await browser.newContext({ viewport: { width: w, height: h } });
67
+ const page = await ctx.newPage();
68
+ const S = { errors: [], reqs: [], posts: [], weekGets: [], replayGets: [] };
69
+ page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
70
+ page.on('request', (r) => { if (r.url().startsWith(BASE)) S.reqs.push(r.method() + ' ' + new URL(r.url()).pathname); });
71
+ const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
72
+ await page.route('**/api/briefing-premium*', (r) => json(r, { ok: true, state: 'ready', model: B.build(facts()), as_of: Date.now() }));
73
+ await page.route('**/api/calendar-views*', (r) => { S.weekGets.push(new URL(r.request().url()).search); json(r, week, week && week.ok === false ? 500 : 200); });
74
+ await page.route('**/api/meeting-replay*', (r) => { S.replayGets.push(new URL(r.request().url()).search); if (replay === 404) json(r, { ok: false, error: 'no note for that meeting' }, 404); else json(r, replay); });
75
+ await page.route('**/api/meeting-material*', (r) => json(r, material));
76
+ await page.route('**/api/calendar-links', (r) => { S.posts.push(JSON.parse(r.request().postData() || '{}')); json(r, linkRes, linkRes.ok ? 200 : 403); });
77
+ await page.goto(BASE + '/premium.html?theme=' + theme);
78
+ S.up = await until(() => page.evaluate(() => document.querySelectorAll('#rank .rr').length > 0 && document.querySelectorAll('#tl .ev').length > 0), 20000);
79
+ return Object.assign(S, { ctx, page });
80
+ };
81
+ const week = (p) => p.click('#rng [data-r=week]').then(() => until(() => p.evaluate(() => !document.querySelector('#tl').hasAttribute('aria-busy') && (!!document.querySelector('#tl .wkd') || /Calendar not read/.test(document.querySelector('#tl').textContent)))));
82
+
83
+ const A = await open();
84
+ ok('0 the page draws the list and Today', A.up);
85
+ if (!A.up) return finish(1);
86
+ const p = A.page;
87
+
88
+ /* C1 */
89
+ const sw = await p.evaluate(() => ({ labels: [...document.querySelectorAll('#rng button')].map((b) => b.textContent + ':' + b.getAttribute('aria-pressed')), box: [...document.querySelectorAll('#rng button')].map((b) => { const r = b.getBoundingClientRect(); return Math.round(Math.min(r.width, r.height)); }), ahead: !!document.querySelector('#tl .grp'), group: document.querySelector('#rng').getAttribute('role') }));
90
+ ok('C1 the switch is beside the title, Today is pressed by default and Today is unchanged', sw.labels.join() === 'Today:true,This week:false' && sw.ahead && sw.group === 'group', JSON.stringify(sw));
91
+ ok('C1 both switch buttons are at least 44 px', sw.box.every((n) => n >= 44), JSON.stringify(sw.box));
92
+ ok('C1 the week is not read until the PM presses it', A.weekGets.length === 0);
93
+
94
+ /* C2 */
95
+ await week(p);
96
+ const wk = await p.evaluate(() => ({
97
+ days: [...document.querySelectorAll('#tl .wkd')].map((d) => d.textContent), rows: [...document.querySelectorAll('#tl .ev')].map((e) => e.querySelector('b').textContent + '|' + e.querySelector('time').textContent + '|' + e.querySelector('.d').textContent),
98
+ now: document.querySelector('#tl .wkd.now') && document.querySelector('#tl .wkd.now').textContent, empty: document.querySelectorAll('#tl .empty').length, cap: document.querySelector('#rcap').textContent, capShown: !document.querySelector('#rcap').hidden,
99
+ filter: getComputedStyle(document.querySelector('#todayCard .fbtn')).display, pressed: document.querySelector('#rng [data-r=week]').getAttribute('aria-pressed'), past: document.querySelectorAll('#tl .ev.wkpast').length,
100
+ label: document.querySelector('#tl').getAttribute('aria-label') }));
101
+ ok('C2 pressing This week reads the week once, for today\'s date', A.weekGets.length === 1 && /view=week/.test(A.weekGets[0]) && A.weekGets[0].includes('date=' + dayKey(NOW)), JSON.stringify(A.weekGets));
102
+ ok('C2 the card lists seven days with their counts and marks today', wk.days.length === 7 && /today/.test(wk.now || '') && wk.days.some((d) => /2 meetings/.test(d)), JSON.stringify(wk.days));
103
+ ok('C2 a row shows time, title, length, people and what it is about', wk.rows.some((r) => r === 'Sprint planning|14:00|1 h · with Dara, Priya, Sam · Board: IDPF') && wk.rows.some((r) => r === 'Checkout sync|09:30|45 min · with Priya, Dara'), JSON.stringify(wk.rows));
104
+ ok('C2 days with no meetings say so', wk.empty >= 3, String(wk.empty));
105
+ ok('C2 the caption counts the meetings, the switch shows the week, the filter is hidden', /meetings? · /.test(wk.cap) && wk.capShown && wk.pressed === 'true' && wk.filter === 'none' && /This week/.test(wk.label), JSON.stringify(wk));
106
+ await p.click('#rng [data-r=today]');
107
+ const back = await p.evaluate(() => ({ ahead: !!document.querySelector('#tl .grp'), wk: !!document.querySelector('#tl .wkd'), filter: getComputedStyle(document.querySelector('#todayCard .fbtn')).display, cap: document.querySelector('#todayCap').textContent }));
108
+ ok('C2 Today comes back unchanged', back.ahead && !back.wk && back.filter !== 'none' && /earlier · \d+ ahead/.test(back.cap), JSON.stringify(back));
109
+ await week(p);
110
+ ok('C2 pressing This week again reads again', await until(() => A.weekGets.length === 2));
111
+
112
+ /* C4 C5 C6 C7 C8: the dialog from a week row */
113
+ await p.focus('#tl .ev[data-w]');
114
+ const rowKey = await p.evaluate(() => { const r = [...document.querySelectorAll('#tl .ev')].find((e) => e.querySelector('b').textContent === 'Sprint planning'); r.id = 'rowSprint'; return r.dataset.w; });
115
+ await p.click('#rowSprint');
116
+ const dlg = await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && /Capacity sheet/.test(document.querySelector('#oMain').textContent) ? { title: document.querySelector('#dTitle').textContent, eye: document.querySelector('#dEye').textContent, sub: document.querySelector('#dSub').textContent, text: document.querySelector('#oMain').textContent, ask: document.querySelector('#askF').hidden } : null));
117
+ ok('C4 a week row opens the standard dialog with its title and when', dlg && dlg.title === 'Sprint planning' && /14:00/.test(dlg.sub) && /Calendar/.test(dlg.eye), JSON.stringify(dlg));
118
+ ok('C4 the dialog reads the replay and the material of that meeting', A.replayGets.some((q) => q.includes('event=ev-sprint')) && !!dlg);
119
+ ok('C6 with no note the dialog says so', dlg && /No notes for this meeting\./.test(dlg.text));
120
+ ok('C7 the material is listed with the scope it was linked at', dlg && /Capacity sheet/.test(dlg.text) && /every meeting of this series/.test(dlg.text) && /Roadmap/.test(dlg.text) && /for this meeting/.test(dlg.text));
121
+ ok('C8 with no recording the dialog draws no Replay', dlg && !/Replay/.test(dlg.text) && !/recording/i.test(dlg.text));
122
+ ok('C4 the conversation is not offered on a week row', dlg && dlg.ask === true);
123
+ ok('C5 the dialog says what it is about, and that the calendar is never written', dlg && /It is about Board: IDPF/.test(dlg.text) && /calendar itself is never written/.test(dlg.text));
124
+ await p.keyboard.press('Escape');
125
+ const closed = await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
126
+ ok('C4 Escape closes it and focus returns to the row', closed && await p.evaluate(() => document.activeElement && document.activeElement.id === 'rowSprint'));
127
+
128
+ /* C5 link it */
129
+ await p.click('#rowSprint');
130
+ await until(() => p.evaluate(() => !!document.querySelector('#mtgSel') && /Capacity sheet/.test(document.querySelector('#oMain').textContent)));
131
+ const dis = await p.evaluate(() => document.querySelector('#mtgLink').disabled);
132
+ ok('C5 Link it is off until a choice is made', dis === true);
133
+ const optsText = await p.evaluate(() => [...document.querySelectorAll('#mtgSel option')].map((o) => o.textContent));
134
+ ok('C5 the choices are the Portfolio, the answer\'s boards and initiatives, and removing the link', optsText.includes('Portfolio') && optsText.includes('Board: Payments') && optsText.includes('Initiative: Premium UX') && optsText.includes('Remove the link'), JSON.stringify(optsText));
135
+ await p.selectOption('#mtgSel', 'board|w1|pay');
136
+ await p.click('#mtgLink');
137
+ await until(() => A.posts.length === 1);
138
+ ok('C5 the press posts one link to /api/calendar-links for the meeting and its series', A.posts.length === 1 && A.posts[0].kind === 'board' && A.posts[0].board === 'pay' && A.posts[0].ws === 'w1' && A.posts[0].event.title === 'Sprint planning' && A.posts[0].event.series === 'sprint-planning', JSON.stringify(A.posts));
139
+ ok('C5 after the write the week is read again', await until(() => A.weekGets.length >= 3));
140
+ await p.keyboard.press('Escape');
141
+
142
+ /* C3 honest states */
143
+ const E = await open({ week: { ok: false, error: 'the calendar could not read the repository: boom' } });
144
+ await week(E.page);
145
+ const er = await E.page.evaluate(() => ({ text: document.querySelector('#tl').textContent, rows: document.querySelectorAll('#tl .ev').length, cap: document.querySelector('#rcap').textContent }));
146
+ ok('C3 a failed read says "Calendar not read" with the reason and draws no meeting', /Calendar not read\./.test(er.text) && /boom/.test(er.text) && er.rows === 0 && er.cap === 'Calendar not read', JSON.stringify(er));
147
+ const Z = await open({ week: Object.assign(weekAnswer(), { cells: weekAnswer().cells.map((c) => Object.assign({}, c, { events: [] })), context: {} }) });
148
+ await week(Z.page);
149
+ ok('C3 an empty week says so', await Z.page.evaluate(() => /No meetings this week/.test(document.querySelector('#rcap').textContent) && document.querySelectorAll('#tl .ev').length === 0));
150
+
151
+ /* C6 C8 with a note and a recording */
152
+ const R = await open({ replay: REPLAY });
153
+ await week(R.page);
154
+ await R.page.evaluate(() => { [...document.querySelectorAll('#tl .ev')].find((e) => e.querySelector('b').textContent === 'Sprint planning').click(); });
155
+ const rd = await until(() => R.page.evaluate(() => /Decisions/.test(document.querySelector('#oMain').textContent) ? document.querySelector('#oMain').textContent : null));
156
+ ok('C6 the note\'s decisions, next steps and questions are listed as the note holds them', rd && /Plan the sprint with eight people/.test(rd) && /Sam confirms the data fix owner/.test(rd) && /Sam · Tue/.test(rd) && /Does a release eat the capacity\?/.test(rd) && /Sprint planning notes/.test(rd), String(rd).slice(0, 300));
157
+ ok('C8 a kept recording is summarised, and Replay opens in the console', rd && /A recording is kept: 25 min, 3 key points/.test(rd) && /Replay opens in the console/.test(rd));
158
+ ok('C6 the replay answer\'s people are used only when the calendar lists none', rd && /Dara, Priya, Sam/.test(rd));
159
+
160
+ /* C4 a Today row opens the same dialog when the calendar answer knows the meeting */
161
+ const Tt = await open({ replay: REPLAY });
162
+ await Tt.page.evaluate(() => { [...document.querySelectorAll('#tl .ev')].find((e) => e.querySelector('b').textContent === 'Sprint planning').click(); });
163
+ const td = await until(() => Tt.page.evaluate(() => /Capacity sheet/.test(document.querySelector('#oMain').textContent) ? { ask: document.querySelector('#askF').hidden, title: document.querySelector('#dTitle').textContent } : null));
164
+ ok('C4 a Today meeting row opens the full dialog and keeps its conversation', td && td.title === 'Sprint planning' && td.ask === false, JSON.stringify(td));
165
+ const Mg = await open({ week: { ok: false, error: 'down' } });
166
+ await Mg.page.evaluate(() => { [...document.querySelectorAll('#tl .ev')].find((e) => e.dataset.kind !== 'x' && e.querySelector('b').textContent === 'Sprint planning').click(); });
167
+ ok('C4 when the calendar answer is down, a Today row keeps the plain dialog', await until(() => Mg.page.evaluate(() => document.querySelector('#dlg').classList.contains('on') && document.querySelector('#dTitle').textContent === 'Sprint planning' && !document.querySelector('#mtgSel'))));
168
+
169
+ /* C9 */
170
+ const allPosts = [].concat(A.reqs, R.reqs, Tt.reqs).filter((r) => /^POST /.test(r));
171
+ ok('C9 the only write the page sent is the link', allPosts.length === 1 && allPosts[0] === 'POST /api/calendar-links', JSON.stringify(allPosts));
172
+ ok('C9 no recording, Focus or material request was sent', ![].concat(A.reqs, R.reqs, Tt.reqs).some((r) => /\/api\/(notes|meeting-focus)|POST \/api\/meeting-material/.test(r)));
173
+ ok('C9 no page error', [A, E, Z, R, Tt, Mg].every((x) => x.errors.length === 0), JSON.stringify([A, E, Z, R, Tt, Mg].map((x) => x.errors)));
174
+
175
+ /* C10 floors and fidelity */
176
+ for (const th of ['light', 'dark']) {
177
+ const P = await open({ w: 390, h: 844, theme: th });
178
+ await week(P.page);
179
+ const f = await P.page.evaluate(() => ({ scroll: document.documentElement.scrollWidth <= innerWidth + 1, rows: [...document.querySelectorAll('#tl .ev')].map((e) => e.getBoundingClientRect().height), sw: [...document.querySelectorAll('#rng button')].map((b) => Math.min(b.getBoundingClientRect().width, b.getBoundingClientRect().height)) }));
180
+ ok(`C10 at 390 px (${th}) there is no sideways scroll and rows and switch buttons are at least 44 px`, f.scroll && f.rows.every((h) => h >= 44) && f.sw.every((n) => n >= 44), JSON.stringify(f));
181
+ await P.ctx.close();
182
+ }
183
+ const css = (page, sel) => page.evaluate((s) => { const e = document.querySelector(s); if (!e) return null; const c = getComputedStyle(e); return ['fontSize', 'fontWeight', 'letterSpacing', 'textTransform', 'borderRadius', 'paddingTop', 'color'].map((k) => c[k]).join('|'); }, sel);
184
+ const mk = await browser.newContext({ viewport: { width: 1280, height: 900 } }); const mp = await mk.newPage();
185
+ await mp.setContent(MOCKUP); await mp.waitForTimeout(500);
186
+ const F1 = await open();
187
+ const pairs = [['#todayCard', '#todayCard'], ['#tl .ev b', '#tl .ev b'], ['#tl .nowl', '#tl .nowl']];
188
+ for (const [a, b] of pairs) { const x = await css(mp, a), y = await css(F1.page, b); ok('C10 fidelity: ' + a + ' keeps the mockup\'s computed style at 1280 px', x === y || (x === null && true), x + ' vs ' + y); }
189
+ const grp = await css(mp, '#tl .grp');
190
+ await week(F1.page);
191
+ const wd = await css(F1.page, "#tl .wkd");
192
+ ok('C10 fidelity: a day heading uses the mockup\'s group-heading type', grp && wd && wd.split('|').slice(0, 4).join('|') === grp.split('|').slice(0, 4).join('|'), grp + ' vs ' + wd);
193
+ await mk.close();
194
+ return finish();
195
+ })().catch((e) => { console.error(e); finish(1); });
@@ -94,7 +94,7 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
94
94
  ok('I4 a measure with one reading or none is listed with the record\'s reason and not drawn', ns[0] === 'No series recorded · 2' && /Partner NPS.*Only one reading is recorded\. It is not drawn\./.test(ns[1]) && /Monthly churn.*No reading is recorded yet\./.test(ns[2]), JSON.stringify(ns));
95
95
  /* I5 dashboards */
96
96
  const tabs = await p.evaluate(() => [...document.querySelectorAll('#dashTabs button')].map((b) => b.textContent + ':' + b.getAttribute('aria-pressed')));
97
- ok('I5 dashboards are the pillars the records name, all measures first', tabs.join() === 'All measures:true,Growth:false,Reliability:false', tabs.join());
97
+ ok('I5 dashboards: all measures first, then the saved ones (main marked), then the pillars the records name', tabs.join() === 'All measures:true,Weekly partner review · Main:false,Growth:false,Reliability:false', tabs.join());
98
98
  await p.click('#dashTabs [data-d="p:Reliability"]');
99
99
  ok('I5 choosing a pillar shows only its charts and one count', (await p.evaluate(() => document.querySelectorAll('#dashBody .mch').length)) === 1 && /1 of 1.*on their line/.test(await txt('#dashBody .mhint')) && (await p.evaluate(() => document.querySelector('#dashBody .mprog').getAttribute('aria-valuenow'))) === '1');
100
100
  await p.click('#dashTabs [data-d="all"]');
@@ -107,8 +107,8 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
107
107
  ok('I6 no sentence forecasts or gives a cause', !fd.some((x) => /forecast|will reach|because|caused|expected to/i.test(x)));
108
108
  /* I7 dialog */
109
109
  await p.locator('.nfd .nfr').first().click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(500);
110
- const dl = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, eye: document.querySelector('#dEye').textContent, kv: [...document.querySelectorAll('#oMain .kv2')].map((k) => k.textContent.replace(/\s+/g, ' ')).join(' | '), path: document.querySelector('#oMain .dpath').textContent, btn: document.querySelectorAll('#oMain button').length, hold: document.querySelector('#holdWhy').textContent, inert: ['.rail', 'main.stage', '#dock'].every((s) => document.querySelector(s).inert) }));
111
- ok('I7 a finding opens the standard dialog: the record\'s numbers, its readings with dates, its path, no press', dl.title === 'Time to first call' && /real data/.test(dl.eye) && /Target3 days by 31 Dec/.test(dl.kv) && /15 Oct9 days/.test(dl.kv) && dl.path === 'planning/records/kr-metrics.jsonl' && dl.btn === 0 && /Nothing here changes a record/.test(dl.hold) && dl.inert, JSON.stringify(dl));
110
+ const dl = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, eye: document.querySelector('#dEye').textContent, kv: [...document.querySelectorAll('#oMain .kv2')].map((k) => k.textContent.replace(/\s+/g, ' ')).join(' | '), path: document.querySelector('#oMain .dpath').textContent, btn: document.querySelectorAll('#oMain button').length, hold: document.querySelector('#holdWhy').textContent, sw: [...document.querySelectorAll('#oMain [role=switch]')].map((b) => b.querySelector('b').textContent + ':' + b.getAttribute('aria-checked')).join(), inert: ['.rail', 'main.stage', '#dock'].every((s) => document.querySelector(s).inert) }));
111
+ ok('I7 a finding opens the standard dialog: the record\'s numbers, its readings with dates, its path, and only the dashboard switch as a press', dl.title === 'Time to first call' && /real data/.test(dl.eye) && /Target3 days by 31 Dec/.test(dl.kv) && /15 Oct9 days/.test(dl.kv) && dl.path === 'planning/records/kr-metrics.jsonl' && dl.btn === 1 && dl.sw === 'Weekly partner review:true' && /Nothing here changes a record/.test(dl.hold) && dl.inert, JSON.stringify(dl));
112
112
  ok('I7 Escape closes it and focus returns', (await p.keyboard.press('Escape'), await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')))));
113
113
  await p.locator('#dashBody [data-open]').filter({ hasText: 'Details' }).first().click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(300);
114
114
  ok('I7 the Details link of a chart opens that chart\'s dialog', (await txt('#dTitle')) === 'Partner activation');
@@ -123,16 +123,16 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
123
123
  await R.ctx.close();
124
124
  }
125
125
  /* I8 reports */
126
- const rp = await p.evaluate(() => ({ rows: [...document.querySelectorAll('#repBody .dmr')].map((r) => r.querySelector('.dmn b').textContent + ' / ' + r.querySelector('.s').textContent), note: document.querySelector('#repBody .mhint').textContent, cap: document.querySelector('#repCap').textContent }));
126
+ const rp = await p.evaluate(() => ({ rows: [...document.querySelectorAll('#repDocs .dmr')].map((r) => r.querySelector('.dmn b').textContent + ' / ' + r.querySelector('.s').textContent), note: document.querySelector('#repBody .mhint').textContent, cap: document.querySelector('#repCap').textContent }));
127
127
  ok('I8 the Reports card lists the report files: cadence, slot, draft or issued', rp.rows.join() === 'biweekly · 14 Oct / Draft,monthly · 30 Sep / Issued 1 Oct' && /Nothing is sent from here/.test(rp.note) && rp.cap === '2', JSON.stringify(rp));
128
- { const R = await open(); await R.page.locator('#repBody .dmo').first().click(); ok('I8 a report opens the console\'s Reports tab to read it', await until(() => /\/c3\.html\?tab=rep/.test(R.page.url()), 5000), R.page.url()); await R.ctx.close(); }
128
+ { const R = await open(); await R.page.locator('#repDocs .dmo').first().click(); ok('I8 a report opens the console\'s Reports tab to read it', await until(() => /\/c3\.html\?tab=rep/.test(R.page.url()), 5000), R.page.url()); await R.ctx.close(); }
129
129
  /* I9 labels */
130
130
  ok('I9 no demo label, and the foot says what is left out', !(await p.evaluate(() => /demo/i.test(document.querySelector('main.stage').textContent))) && /Left out: the Insight Studio/.test(await txt('#foot')) && /Real data/.test(await txt('#snap')));
131
131
  ok('I9 the page makes no write request on its own', A.posts.length === 0, A.posts.join());
132
132
  /* I10 empty */
133
133
  {
134
134
  const R = await open({ model: mk({ outcomes: [] }) });
135
- ok('I10 with no KR metric the page says so in one sentence and the Reports card still lists its files', await R.page.evaluate(() => /No KR metric is recorded/.test(document.querySelector('#brief').textContent) && /No KR metric is recorded for this workspace/.test(document.querySelector('#dashBody').textContent) && document.querySelectorAll('#repBody .dmr').length === 2 && document.querySelectorAll('#dashBody .mch').length === 0));
135
+ ok('I10 with no KR metric the page says so in one sentence and the Reports card still lists its files', await R.page.evaluate(() => /No KR metric is recorded/.test(document.querySelector('#brief').textContent) && /No KR metric is recorded for this workspace/.test(document.querySelector('#dashBody').textContent) && document.querySelectorAll('#repDocs .dmr').length === 2 && document.querySelectorAll('#dashBody .mch').length === 0));
136
136
  await R.ctx.close();
137
137
  const R2 = await open({ model: mk({ reportsOk: false, reports: [], missing: ['reports'] }) });
138
138
  ok('I10 reports that could not be read are said to be unread, not empty', await R2.page.evaluate(() => /report files could not be read/.test(document.querySelector('#repBody').textContent) && /not read: reports/.test(document.querySelector('#snap').textContent)));
@@ -147,10 +147,68 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
147
147
  await c2.close();
148
148
  }
149
149
 
150
+ /* briefing-premium-reports: the dashboard store and the report presses (PRD D3 to D6, R2 to R4, R7) */
151
+ {
152
+ const R = await open(), q = R.page, sent = [];
153
+ let answer = (u, b) => ({ ok: true, dashboard: { id: b.id || 'pd-9' }, dashboards: [], drafted: { slot: '2026-10-23', path: 'planning/reports/release-readiness/2026-10-23.md' } });
154
+ await q.route(/\/api\/(premium-dashboards|report-setups)\//, (r) => { const u = new URL(r.request().url()).pathname, b = JSON.parse(r.request().postData() || '{}'); sent.push([u, b]); const a = answer(u, b); r.fulfill({ status: a.ok === false ? 409 : 200, contentType: 'application/json', body: JSON.stringify(a) }); });
155
+ const qt = (sel) => q.evaluate((x) => (document.querySelector(x) || {}).textContent || '', sel);
156
+ const last = () => sent[sent.length - 1] || [null, {}];
157
+ const dlgOn = () => until(() => q.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
158
+ const shut = async () => { await q.keyboard.press('Escape'); await until(() => q.evaluate(() => !document.querySelector('#dlg').classList.contains('on'))); };
159
+ await q.click('#dashTabs [data-d="pd-1"]'); await sleep(200);
160
+ const sv = await q.evaluate(() => ({ tiles: [...document.querySelectorAll('#dashBody .mch .mlab')].map((e) => e.firstChild.textContent), gone: [...document.querySelectorAll('#dashBody .dplist .nempty')].map((e) => e.textContent.replace(/\s+/g, ' ')), bar: document.querySelector('#dashBar').textContent }));
161
+ ok('R1 a saved dashboard draws its charts in its order and says which chart is gone, in its place', sv.tiles.join() === 'Partner activation,Time to first call' && sv.gone.length === 1 && /krm-gone.*No KR metric record is called krm-gone/.test(sv.gone[0]) && /Main dashboard\..*Monday partner review/.test(sv.bar), JSON.stringify(sv));
162
+ await q.click('#pdEdit'); await dlgOn();
163
+ const ed = await q.evaluate(() => ({ n: document.querySelector('#pdN').value, rows: [...document.querySelectorAll('#pdList .pdrow b')].map((b) => b.textContent), main: document.querySelector('#pdMain').checked, note: document.querySelector('#oMain .addf .note').textContent }));
164
+ ok('R2 Edit opens the dialog with the name, Main and the charts in order, and says what Save changes', ed.n === 'Weekly partner review' && ed.rows.join() === 'Partner activation,Time to first call,krm-gone' && ed.main && /changes nothing else/.test(ed.note), JSON.stringify(ed));
165
+ await q.click('#pdList [data-mv="1:-1"]'); await q.click('#pdList [data-rm="2"]'); await q.selectOption('#pdAdd', 'krm-up'); await q.fill('#pdN', 'Monday review'); await q.click('#pdGo'); await sleep(400);
166
+ ok('R2 Save posts the dashboard with the new order, name and Main to the one save route', last()[0] === '/api/premium-dashboards/save' && JSON.stringify(last()[1]) === JSON.stringify({ ws: 'w1', board: 'w1', id: 'pd-1', name: 'Monday review', purpose: 'The measures the Monday partner review reads.', charts: ['krm-ttfc', 'krm-act', 'krm-up'], main: true }), JSON.stringify(last()));
167
+ await q.click('#pdNew'); await dlgOn(); await q.click('#pdGo'); await sleep(200);
168
+ ok('R2 a new dashboard without a name says so and posts nothing', /Give the dashboard a name/.test(await qt('#pdM')) && last()[1].id === 'pd-1');
169
+ answer = () => ({ ok: false, error: '“Weekly partner review” is already a dashboard on this board.' });
170
+ await q.fill('#pdN', 'Weekly partner review'); await q.fill('#pdP', 'x'); await q.click('#pdGo'); await sleep(300);
171
+ ok('R7 the server\'s refusal is shown in words and the dialog stays open', /already a dashboard on this board/.test(await qt('#pdM')) && await q.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !document.querySelector('#pdGo').disabled));
172
+ answer = (u, b) => ({ ok: true, dashboard: { id: b.id || 'pd-9' }, dashboards: [], setup: {}, drafted: { slot: '2026-10-23', path: 'planning/reports/release-readiness/2026-10-23.md' } });
173
+ await shut();
174
+ await q.click('#dashTabs [data-d="all"]'); await q.locator('#dashBody [data-open="ins:krm-up"]').click(); await dlgOn(); await q.click('#oMain [data-pdsw="pd-1"]'); await sleep(300);
175
+ ok('R3 the chart dialog\'s switch saves that dashboard with the chart added', last()[0] === '/api/premium-dashboards/save' && JSON.stringify(last()[1].charts) === JSON.stringify(['krm-act', 'krm-ttfc', 'krm-gone', 'krm-up']) && /Added to Weekly partner review/.test(await qt('#pdSwM')), JSON.stringify(last()));
176
+ await shut();
177
+ const groups = await q.evaluate(() => [...document.querySelectorAll('#repBody .ngrp > .label')].map((e) => e.textContent));
178
+ ok('R1 the Reports card lists your requests, what PMOS found, the set-up reports and the documents', groups.join() === 'Your requests · 2,Found in your work · 1,Set up · 1,Documents · 1 draft · 1 issued', groups.join());
179
+ await q.click('#repFound .dmo'); await dlgOn();
180
+ ok('R2 a finding opens with its proposal and what PMOS saw', /ScheduleWeekly, Thursdays 09:00/.test(await qt('#oMain .kv2')) && (await q.evaluate(() => document.querySelectorAll('#oMain .pdev li').length)) === 2);
181
+ const n0 = sent.length;
182
+ await q.click('#oMain [data-rx="no"]'); await sleep(300);
183
+ ok('R2 Not a report hides the row and waits; Undo sends nothing', (await q.evaluate(() => !document.querySelector('#repFound'))) && sent.length === n0 && (await q.click('#rxUndo'), await sleep(5400), sent.length === n0) && await q.evaluate(() => !!document.querySelector('#repFound')));
184
+ await q.click('#oMain [data-rx="no"]'); await sleep(5600);
185
+ ok('R2 without Undo, Not a report is sent after 5 seconds', last()[0] === '/api/report-setups/dismiss' && last()[1].finding === 'f-1' && last()[1].ws === 'w1', JSON.stringify(last()));
186
+ await until(() => q.evaluate(() => !document.querySelector('#dlg').classList.contains('on') || true)); if (await q.evaluate(() => document.querySelector('#dlg').classList.contains('on'))) await shut();
187
+ await q.click('#repFound .dmo'); await dlgOn(); await q.click('#oMain [data-rx="set"]'); await sleep(400);
188
+ ok('R2 Set it up posts the finding and says where the first draft is', last()[0] === '/api/report-setups/setup' && last()[1].finding === 'f-1' && /first draft is planning\/reports\/release-readiness\/2026-10-23\.md/.test(await qt('#toast')), JSON.stringify(last()));
189
+ await q.fill('#repAskIn', 'A weekly risk note'); await q.click('#repAskGo'); await sleep(300);
190
+ ok('R3 the Ask box posts the request and says it only proposes', last()[0] === '/api/report-setups/ask' && last()[1].text === 'A weekly risk note' && /Nothing is set up yet/.test(await qt('#toast')) && /only proposes/.test(await qt('#repBody .nask-n')), JSON.stringify(last()));
191
+ await q.click('#repAsks [data-ask="a-1"]'); await dlgOn(); await q.click('#oMain [data-rx="chg"]'); await sleep(100);
192
+ ok('R3 Change it needs words first', /Say what to change/.test(await qt('#rxM')));
193
+ await q.fill('#rxChg', 'quarterly'); await q.click('#oMain [data-rx="chg"]'); await sleep(300);
194
+ ok('R3 Change it posts the correction for that request', last()[0] === '/api/report-setups/change' && last()[1].id === 'a-1' && last()[1].text === 'quarterly', JSON.stringify(last()));
195
+ await q.click('#repAsks [data-ask="a-2"]'); await dlgOn();
196
+ ok('R3 a running request says it is working and offers only Cancel', /background run is working/.test(await qt('#oMain')) && (await q.evaluate(() => [...document.querySelectorAll('#oMain [data-rx]')].map((b) => b.dataset.rx).join())) === 'cancel');
197
+ await shut();
198
+ await q.click('#repSetups .dmo'); await dlgOn();
199
+ const su = await q.evaluate(() => ({ kv: document.querySelector('#oMain .kv2').textContent, acts: [...document.querySelectorAll('#oMain [data-rx]')].map((b) => b.dataset.rx).join() }));
200
+ ok('R4 a set-up report shows its schedule and next draft, with Draft it now and Pause', /ScheduleEvery other Monday at 09:00/.test(su.kv) && /Next draft26 Oct/.test(su.kv) && su.acts === 'draft,pause', JSON.stringify(su));
201
+ await q.click('#oMain [data-rx="pause"]'); await sleep(300);
202
+ ok('R4 Pause posts that report', last()[0] === '/api/report-setups/pause' && last()[1].id === 'partner-update', JSON.stringify(last()));
203
+ ok('R7 every press went to the dashboard save route or an existing report-setups route', R.posts.every((x) => /^POST \/api\/(premium-dashboards\/save|report-setups\/(ask|change|cancel|setup|dismiss|pause|resume|draft))$/.test(x)), R.posts.join());
204
+ ok('R6 the Reports card shows no demo row', !/demo/i.test(await qt('#repBody')));
205
+ await R.ctx.close();
206
+ }
207
+
150
208
  /* I11 floors */
151
209
  for (const theme of ['light', 'dark']) {
152
210
  const R = await open({ w: 390, h: 844, theme }), q = R.page;
153
- const m = await q.evaluate(() => { const small = [...document.querySelectorAll('#dashTabs button, #dashBody .lk, #dashBody .nfr, #repBody .dmo, #repBody .lk, #crSw')].filter((b) => !b.closest('[hidden]') && b.getBoundingClientRect().height > 0 && b.getBoundingClientRect().height < 44).map((b) => b.className + ':' + Math.round(b.getBoundingClientRect().height)); return { over: document.documentElement.scrollWidth > innerWidth + 1, small }; });
211
+ const m = await q.evaluate(() => { const small = [...document.querySelectorAll('#dashTabs button, #dashBar button, #dashBody .lk, #dashBody .nfr, #repBody .dmo, #repBody .lk, #repBody input, #repAskGo, #crSw')].filter((b) => !b.closest('[hidden]') && b.getBoundingClientRect().height > 0 && b.getBoundingClientRect().height < 44).map((b) => b.className + ':' + Math.round(b.getBoundingClientRect().height)); return { over: document.documentElement.scrollWidth > innerWidth + 1, small }; });
154
212
  ok(`I11 at 390 px (${theme}) the page has no sideways scroll and every control is 44 px`, !m.over && m.small.length === 0, JSON.stringify(m));
155
213
  await q.locator('#dashBody .nfr').first().click(); await until(() => q.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(900);
156
214
  const g = await q.evaluate(() => { const r = document.querySelector('#dlg').getBoundingClientRect(); return { l: Math.round(r.left), w: Math.round(r.width), vw: innerWidth, tabs: getComputedStyle(document.querySelector('#dTabs')).display }; });
@@ -193,6 +251,17 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
193
251
  pg.on('pageerror', (e) => errs.push(String(e)));
194
252
  await pg.goto(base2 + '/premium-insights.html');
195
253
  ok('E7 the real page draws that chart with the record\'s numbers and no script error', await until(() => pg.evaluate(() => { const t = document.querySelector('#dashBody .mch'); return !!t && t.querySelector('.mval').textContent === '30%' && /Partner activation/.test(t.textContent); }), 20000) && errs.length === 0, errs.join(' | '));
254
+ /* briefing-premium-reports against the real server: New dashboard, Save, the switch, then the ledger answers it back */
255
+ await pg.click('#pdNew'); await until(() => pg.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
256
+ await pg.fill('#pdN', 'Partner review'); await pg.fill('#pdP', 'The Monday partner review.'); await pg.selectOption('#pdAdd', m.charts[0].id); await pg.check('#pdMain'); await pg.click('#pdGo');
257
+ ok('E8 a dashboard made on the real page is saved and drawn as the main one', await until(() => pg.evaluate(() => !document.querySelector('#dlg').classList.contains('on') && [...document.querySelectorAll('#dashTabs button')].some((b) => b.textContent === 'Partner review · Main' && b.getAttribute('aria-pressed') === 'true') && document.querySelectorAll('#dashBody .mch').length === 1), 10000), await pg.evaluate(() => (document.querySelector('#pdM') || {}).textContent + ' / ' + [...document.querySelectorAll('#dashTabs button')].map((b) => b.textContent).join()));
258
+ const j2 = await (await fetch(base2 + '/api/insights-premium')).json(), d2 = j2.model.dashboards.find((d) => d.saved);
259
+ ok('E8 the model reads it back from the ledger', !!d2 && d2.name === 'Partner review' && d2.main && d2.charts.join() === m.charts[0].id, JSON.stringify(d2));
260
+ const H = await T.pressHeaders(base2), body = JSON.stringify({ ws: m.board.ws, board: m.board.id, name: 'From an agent', purpose: 'x', charts: [] });
261
+ const asAgent = await fetch(base2 + '/api/premium-dashboards/save', { method: 'POST', headers: { ...H, 'x-pmos-session': 's1' }, body }).then((x) => x.status);
262
+ const noNonce = await fetch(base2 + '/api/premium-dashboards/save', { method: 'POST', headers: { 'Content-Type': 'application/json', Origin: base2 }, body }).then((x) => x.status);
263
+ const unknown = await fetch(base2 + '/api/premium-dashboards/save', { method: 'POST', headers: H, body: JSON.stringify({ ws: m.board.ws, board: m.board.id, name: 'Other', purpose: 'x', charts: ['krm-none'] }) }).then((x) => x.status);
264
+ ok('E9 the real save route refuses an agent session (403), a press without the nonce (403) and a chart no record holds (400)', asAgent === 403 && noNonce === 403 && unknown === 400, [asAgent, noNonce, unknown].join());
196
265
  await ctx.close();
197
266
  }
198
267
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
  /* fixtures/insights-premium-facts.js — the facts lib/insights-premium.js builds from, for a plausible workspace on 18 Oct 2026. Shapes follow the answers of
3
3
  * lib/routes-c3-strategy.js (outcomes) and lib/routes-reports.js (reports). Five KR metrics: three with a series, one with a single reading, one with none.
4
- * The Activation series has a month with no reading in it, so the page must draw a gap and not a zero. */
4
+ * The Activation series has a month with no reading in it, so the page must draw a gap and not a zero. The saved dashboard holds a chart id no record has. */
5
5
  const NOW = new Date(2026, 9, 18, 9, 0).getTime();
6
6
  const rd = (at, v) => ({ at, v });
7
7
  const OUTCOMES = [
@@ -20,11 +20,27 @@ const REPORTS = [
20
20
  { cadence: 'biweekly', slot: '2026-10-14', path: 'planning/reports/biweekly/2026-10-14.md', status: 'draft', bytes: 900, edited: false, issued: null },
21
21
  { cadence: 'monthly', slot: '2026-09-30', path: 'planning/reports/monthly/2026-09-30.md', status: null, bytes: 1200, edited: false, issued: { at: '2026-10-01T09:00:00Z', by: 'wawan', via: 'ui', sha: 'a'.repeat(40) } },
22
22
  ];
23
+ // briefing-premium-reports: one saved dashboard (main) on the board, and the GET /api/report-setups answer with one setup, one finding and two asks.
24
+ const SAVED = [
25
+ { id: 'pd-1', board: 'w1', name: 'Weekly partner review', purpose: 'The measures the Monday partner review reads.', charts: ['krm-act', 'krm-ttfc', 'krm-gone'], main: true, at: '2026-10-17T09:00:00.000Z' },
26
+ ];
27
+ const SETUPS = {
28
+ setups: [{ id: 'partner-update', name: 'Partner update', purpose: 'What moved for partners this fortnight.', audience: 'Leadership', source: 'work', output: 'docx',
29
+ schedule: { cadence: 'bi-weekly', day: 'Mon', time: '09:00' }, label: 'Every other Monday at 09:00', next_draft: '2026-10-26T09:00:00.000Z', last_issued: '2026-10-14', status: 'active', cycles: 3,
30
+ copy: { kind: 'none', state: 'none', url: null }, structure: null, draft: null }],
31
+ findings: [{ id: 'f-1', name: 'Release readiness', why: 'You review the release measures before every release meeting.', evidence: [{ kind: 'calendar', text: 'Release review, 3 times in 6 weeks' }, { kind: 'drive', text: 'Release checklist doc' }],
32
+ confidence: 'likely', proposal: { name: 'Release readiness', purpose: 'Whether the measures are safe for the release.', audience: 'Leadership', source: 'work', output: 'pdf', schedule: { cadence: 'weekly', day: 'Thu', time: '09:00' } } }],
33
+ asks: [{ id: 'a-1', text: 'A monthly churn report for finance', state: 'ready', changed: false, error: null,
34
+ proposal: { name: 'Churn for finance', purpose: 'Monthly churn for the finance review.', audience: 'Finance', source: 'work', output: 'xlsx', schedule: { cadence: 'monthly', dayOfMonth: 1, time: '09:00' } } },
35
+ { id: 'a-2', text: 'A weekly uptime note', state: 'running', changed: false, error: null, proposal: null }],
36
+ finder: { cadence: 'weekly', sources: {}, last_run: null, next_run: null },
37
+ };
23
38
  function facts(o = {}) {
24
39
  return {
25
40
  now: NOW, pending: false, missing: [],
26
41
  board: { ws: 'w1', id: 'w1', name: 'pmos' }, boards: [{ ws: 'w1', id: 'w1', name: 'pmos' }],
27
- outcomes: OUTCOMES.map((x) => ({ ...x, readings: x.readings.map((r) => ({ ...r })) })), reports: REPORTS.map((r) => ({ ...r })), reportsOk: true, ...o,
42
+ outcomes: OUTCOMES.map((x) => ({ ...x, readings: x.readings.map((r) => ({ ...r })) })), reports: REPORTS.map((r) => ({ ...r })), reportsOk: true,
43
+ saved: JSON.parse(JSON.stringify(SAVED)), setups: JSON.parse(JSON.stringify(SETUPS)), ...o,
28
44
  };
29
45
  }
30
- module.exports = { NOW, facts, OUTCOMES, REPORTS };
46
+ module.exports = { NOW, facts, OUTCOMES, REPORTS, SAVED, SETUPS };
@@ -82,6 +82,14 @@ The pin on a row keeps it at the top for this session.
82
82
 
83
83
  Today lists the day in time order: what is ahead, a marker for the time the data was read, and what came earlier. It has three sources: the calendar PMOS holds, merges to `main`, and agent runs. The filter button turns a source on or off. Press an item to read it.
84
84
 
85
+ ### This week
86
+
87
+ The Today card has a **Today / This week** switch. **This week** lists the meetings of the current week from the calendar PMOS holds, grouped by day. It reads the week once when you press it; while it reads, the list says so. If the calendar cannot be read, the card says "Calendar not read" and gives the reason, and does not guess. A meeting in the past is shown dimmer. The switch changes only what the card shows and records nothing.
88
+
89
+ Press a meeting, from Today or from the week, to open the meeting dialog. It shows the time, the people, and what the meeting is about. It also shows the notes (decisions, next steps and open questions), the material, and, when a recording was kept, its length and the key points. Each part appears only when a record holds it.
90
+
91
+ When the meeting is not linked, the dialog has a **Link it** press. You choose the portfolio, a board, an initiative or none. The press writes one calendar link, through a check that only a real press from this page can pass, so an agent session is refused. After the write, the page reads the week again. Adding or removing material, routing next steps, recording and Focus stay in the console for now.
92
+
85
93
  ## The dock
86
94
 
87
95
  When you scroll past the hero, the hero folds into a bar at the top. The bar shows how many rows need you and the next item in Today.
@@ -171,12 +179,16 @@ Not drawn, because PMOS holds no record for them: the mockup's demo tasks, its J
171
179
 
172
180
  ## Insights
173
181
 
174
- Insights is the fourth place on the rail, at `/premium-insights.html`. It reads the KR metric records of the board's workspace and the report files the console's Reports tab lists. It presses nothing and writes nothing.
182
+ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads the KR metric records of the board's workspace, your saved dashboards, and the report files and report setups the console's Reports tab lists. It writes only when you press a button: a dashboard goes to the workspace's state folder (`premium-dashboards.jsonl`), and a report press goes to the report ledger through the console's own report routes. An agent session cannot make either write.
175
183
 
176
184
  - **Charts.** One chart for each KR metric that holds at least two readings. The line runs through the readings at their dates, so a month with no reading is a gap and not a zero. The dashed line is the metric's target. The chip is the record's own line status: on its line, behind it, or well behind it. Pressing a chart, or its Details link, opens the metric's record in the dialog with the read-only agent beside it.
177
- - **Dashboards.** The records hold no dashboard, so the groups are the pillars the metrics name, with all measures first. The switch shows only when there is more than one pillar.
185
+ - **Dashboards.** The switch lists All measures first, then your saved dashboards (the main one first, marked Main), then the pillars the metrics name. A saved dashboard draws its charts in the order you saved them. A chart whose record is gone, or that has fewer than two readings, is listed in its place with the reason and is not drawn.
186
+ - **Make or edit a dashboard.** Press **New dashboard**, or **Edit** on a saved one. Give it a name, say what it is for, choose its measures and their order, and decide whether it is the main dashboard. **Save** records it. **Remove the dashboard** asks once more and then removes it. The dialog says when a dashboard holds more than six charts, and it still saves. In a chart's dialog, **On your dashboards** has a switch for each saved dashboard, which adds the chart to it or takes it off.
178
187
  - **What stands out.** Up to three plain sentences taken from the series: behind its line for three readings in a row, behind and still moving away from the target, closing in, slipped, reached its target, or a large one-step move. There is no forecast and no cause.
179
188
  - **No series recorded.** A KR metric with one reading or none is listed with the reason and is not drawn.
180
- - **Reports.** The report files of the workspace, with cadence, slot and whether each is a draft or issued. Pressing one opens the console's Reports tab, where it is read, edited or issued. Nothing is sent from this page.
189
+ - **Ask PMOS to set up a report.** Type what the report is for and press **Ask**. A background run proposes a report and does nothing else. The request is listed as Working, then Ready to review. A ready request opens with its proposal: **Set it up**, **Change it** (say what to change; the run revises it), or **Cancel**.
190
+ - **Found in your work.** Up to three reports PMOS found in your calendar, mail or documents, each with why and what it saw. **Set it up** records the report and drafts its first cycle as a file. **Not a report** hides it and records it after 5 seconds, unless you press **Undo**.
191
+ - **Set up.** Your recurring reports, with their schedule and next draft. A report opens with **Draft it now** (for a report drawn from your work) and **Pause** or **Resume**.
192
+ - **Documents.** The report files of the workspace, with cadence, slot and whether each is a draft or issued. Pressing one opens the console's Reports tab, where it is read, edited or issued. Nothing is sent from this page.
181
193
 
182
- Not built: the Insight Studio (making your own chart, dashboard or report by conversation), run-based charts such as corrections per 100 runs (they belong to the Board's Metrics card), saved dashboards and their layout, and any measure no record holds. KR metric records belong to a workspace, so every board of a workspace shows the same charts.
194
+ Not built: the Insight Studio (making a chart or a report by conversation), the report deck, present and print, tile sizes and free layout, the finder's settings, run-based charts such as corrections per 100 runs (they belong to the Board's Metrics card), and any measure no record holds. The console's own dashboards are separate and unchanged. KR metric records belong to a workspace, so every board of a workspace shows the same charts.
@@ -2,13 +2,15 @@
2
2
  /* lib/insights-premium.js — the premium Insights page's model, built from the KR metric records and the report files the console's Reports tab reads
3
3
  * (initiative briefing-premium-insights).
4
4
  *
5
- * build(facts) → model PURE. facts = { now, board, boards, outcomes, reports, reportsOk, missing[] }
5
+ * build(facts) → model PURE. facts = { now, board, boards, outcomes, reports, reportsOk, missing[], saved, setups }
6
6
  * peekModel() → the last model built, for the agent to find a chart in (null before the first)
7
7
  *
8
8
  * facts come from the routes of lib/routes-c3-strategy.js and lib/routes-reports.js:
9
9
  * board { ws, id, name } the board the page shows (KR metric records belong to its workspace, PRD D2)
10
10
  * outcomes GET /api/c3-strategy → .outcomes [{ id, name, pillar, unit, start (the baseline), target, by, now, expected, shortfall, status, pivot, reason, readings: [{ at, v }] }]
11
11
  * reports GET /api/report → .reports [{ cadence, slot, path, status, issued: { at, by } | null, edited }]
12
+ * saved lib/premium-dashboards.js list(root, board.id) → [{ id, name, purpose, charts: [KR metric id], main, at }] (briefing-premium-reports D1)
13
+ * setups GET /api/report-setups → { setups, findings, asks } | null when it could not be read (briefing-premium-reports R1)
12
14
  *
13
15
  * THE RULE THE FILE FOLLOWS (as the other premium models): a number, chip, line or date is made only from a field of a record. A measure with fewer than two
14
16
  * readings gets no chart and says why. The time between two readings is drawn as the time it is, so a gap in a series shows as a gap and never as a zero. No
@@ -99,6 +101,56 @@ function reportRows(reports) {
99
101
  });
100
102
  }
101
103
 
104
+ /** The board's saved dashboards (briefing-premium-reports D3/D5), main first as the ledger folds them. A chart id that has no record, or no series, stays
105
+ * in `charts` and is listed in `gone` with the reason, so the page can say so in its place. `checks` are the two advisory checks, never a refusal. */
106
+ function savedOf(saved, outcomes, charts) {
107
+ return (saved || []).map((d) => {
108
+ const ids = Array.isArray(d.charts) ? d.charts : [];
109
+ const L = ids.map((id) => charts.find((c) => c.id === id)).filter(Boolean);
110
+ const gone = ids.filter((id) => !charts.some((c) => c.id === id)).map((id) => {
111
+ const o = outcomes.find((x) => x.id === id);
112
+ return { id, title: o ? clip(o.name, 120) : id, why: o ? 'This measure has fewer than two readings, so it has no chart.' : 'No KR metric record is called ' + id + ' any more.' };
113
+ });
114
+ const checks = [];
115
+ if (ids.length > 6) checks.push('This dashboard holds ' + ids.length + ' charts. A dashboard that serves one routine usually holds six or fewer.');
116
+ if (new Set(ids).size !== ids.length) checks.push('The same measure is on this dashboard twice.');
117
+ const off = L.filter((c) => c.off).length;
118
+ return { id: d.id, name: clip(d.name, 60), purpose: clip(d.purpose, 200), saved: true, main: !!d.main, charts: ids.slice(), keys: L.map((c) => c.key), total: L.length, off,
119
+ chip: !L.length ? '' : off ? off + ' off its line' : 'On their lines', gone, checks, at: d.at || null };
120
+ });
121
+ }
122
+
123
+ /** The Reports card's setups, findings and asks from GET /api/report-setups (briefing-premium-reports R1–R4). Each field is the ledger's; an absent one is left out. */
124
+ function setupsOf(su, now) {
125
+ if (!su) return { setupsOk: false, setups: [], found: [], asks: [] };
126
+ const setups = (su.setups || []).map((s) => ({
127
+ id: s.id, name: clip(s.name, 120), purpose: clip(s.purpose, 240), audience: s.audience || '', source: s.source || '', output: s.output || '', label: s.label || '',
128
+ next: s.next_draft ? shortDate(s.next_draft) : '', lastIssued: s.last_issued ? shortDate(s.last_issued) : '', status: s.status || '', cycles: fin(s.cycles) ? s.cycles : 0,
129
+ paused: s.status === 'paused', fromWork: s.source === 'work', structured: !!(s.structure && s.structure.saved), drafting: !!(s.draft && s.draft.state === 'drafting'),
130
+ }));
131
+ const found = (su.findings || []).slice(0, 3).map((x) => ({
132
+ id: x.id, name: clip(x.name, 120), why: clip(x.why, 240), evidence: (x.evidence || []).map((e) => ({ kind: e.kind || '', text: clip(e.text, 240) })),
133
+ confidence: x.confidence === 'likely' ? 'Likely a report' : x.confidence === 'not-sure' ? 'Not sure' : '', proposal: proposalOf(x.proposal),
134
+ }));
135
+ const asks = (su.asks || []).filter((a) => a.state === 'running' || a.state === 'ready' || a.state === 'failed').map((a) => ({
136
+ id: a.id, text: clip(a.text, 240), state: a.state, changed: !!a.changed, error: a.error ? clip(a.error, 240) : '', proposal: proposalOf(a.proposal),
137
+ }));
138
+ return { setupsOk: true, setups, found, asks, findingsMore: Math.max(0, (su.findings || []).length - 3) };
139
+ }
140
+ function proposalOf(p) {
141
+ if (!p || typeof p !== 'object') return null;
142
+ const sc = p.schedule && typeof p.schedule === 'object' ? p.schedule : null;
143
+ const rows = [
144
+ p.name ? ['Name', clip(p.name, 120)] : null,
145
+ p.purpose ? ['Purpose', clip(p.purpose, 240)] : null,
146
+ p.audience ? ['Audience', clip(p.audience, 120)] : null,
147
+ sc && sc.cadence ? ['Schedule', require('./report-setups.js').scheduleLabel(sc)] : null,
148
+ p.source ? ['Source', p.source === 'work' ? 'Your work' : String(p.source)] : null,
149
+ p.output ? ['Output', String(p.output)] : null,
150
+ ].filter(Boolean);
151
+ return { name: p.name ? clip(p.name, 120) : '', rows };
152
+ }
153
+
102
154
  function build(facts) {
103
155
  const f = facts || {};
104
156
  const outcomes = f.outcomes || [], missing = (f.missing || []).slice();
@@ -110,7 +162,7 @@ function build(facts) {
110
162
  const pillars = [...new Set(charts.map((c) => c.pillar).filter(Boolean))];
111
163
  const offOf = (L) => L.filter((c) => c.off).length;
112
164
  const dash = (id, name, L) => ({ id, name, keys: L.map((c) => c.key), total: L.length, off: offOf(L), chip: !L.length ? '' : offOf(L) ? offOf(L) + ' off its line' : 'On their lines' });
113
- const dashboards = [dash('all', 'All measures', charts)].concat(pillars.length > 1 ? pillars.map((p) => dash('p:' + p, p, charts.filter((c) => c.pillar === p))) : []);
165
+ const dashboards = [dash('all', 'All measures', charts)].concat(savedOf(f.saved, outcomes, charts), pillars.length > 1 ? pillars.map((p) => dash('p:' + p, p, charts.filter((c) => c.pillar === p))) : []);
114
166
  const findings = findingsOf(charts);
115
167
  const rep = reportRows(f.reports);
116
168
  const off = offOf(charts);
@@ -121,7 +173,8 @@ function build(facts) {
121
173
  charts, noSeries, dashboards, rows: charts,
122
174
  findings: findings.length ? findings : [{ kind: 'calm', key: null, text: charts.length ? (charts.some((c) => c.target !== null) ? 'Nothing stands out. No measure moved much, and none is far behind its line.' : 'Nothing stands out. No measure here has a target, so the series can only be described.') : '' }],
123
175
  calm: !findings.length && charts.length > 0,
124
- reports: { rows: rep, ok: f.reportsOk !== false, counts: { draft: rep.filter((r) => r.state === 'draft').length, issued: rep.filter((r) => r.state === 'issued').length }, missing: f.reportsOk === false },
176
+ reports: Object.assign({ rows: rep, ok: f.reportsOk !== false, counts: { draft: rep.filter((r) => r.state === 'draft').length, issued: rep.filter((r) => r.state === 'issued').length }, missing: f.reportsOk === false }, setupsOf(f.setups, f.now)),
177
+ measures: outcomes.map((o) => ({ id: o.id, title: clip(o.name, 120), pillar: o.pillar || '', charted: charts.some((c) => c.id === o.id) })),
125
178
  empty: !outcomes.length ? 'No KR metric is recorded for this workspace, so there is nothing to chart. Add one where the KR metrics are kept.' : !charts.length ? 'No KR metric holds two readings yet, so nothing is drawn.' : '',
126
179
  dock: { needs: off, label: off === 1 ? 'measure off its line' : 'measures off their line', next: findings[0] && findings[0].chart ? (charts.find((c) => c.key === findings[0].chart) || {}).title || null : null },
127
180
  counts: { charts: charts.length, noSeries: noSeries.length, off, total: outcomes.length },