create-pmos 0.255.0 → 0.257.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.255.0",
3
+ "version": "0.257.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@c9a1e5a
1
+ kernel-source: pmos@97ec1d5
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-18T00:27:07Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-18T01:44:16Z"}
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-18T00:27:07Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-18T01:44:16Z"}
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-18T00:27:07Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-18T01:44:16Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -0,0 +1,176 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* briefing-premium-doc-edit-test.js — the premium sheet's Edit and Proposals tabs (initiative briefing-premium-doc-edit; planning/prd/briefing-premium-doc-edit-prd.md E1 to E8).
4
+ * Serves the real page from the real server. The initiative model and the /api/doc-sheet routes are answered by a small stateful stand-in, so each press can be
5
+ * read off the request the page sent. The routes' own behaviour (the file, the log, stale, 403) is in briefing-premium-doc-edit.test.js, on a scratch repository.
6
+ * E1 tabs · E2 edit · E3 ask · E4 proposals · E5 after a write · E6 held · E7 honesty · E8 fidelity and floors */
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+ const { spawn } = require('child_process');
10
+ const { findBrowser } = require('./lib/find-browser');
11
+ const T = require('./test-run').configure({ name: 'briefing-premium-doc-edit' });
12
+ const IP = require('./lib/initiative-premium.js');
13
+ const F = require('./fixtures/initiative-premium-facts.js');
14
+
15
+ const BASE = T.BASE;
16
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
17
+ 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); } };
18
+ const results = [];
19
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
20
+ let srv = null; let browser = null;
21
+ const finish = async (code) => {
22
+ if (browser) await browser.close().catch(() => {});
23
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
24
+ T.killTmux();
25
+ const bad = results.filter((x) => !x.cond).length;
26
+ console.log(`\n${results.length - bad}/${results.length} briefing-premium-doc-edit assertions passed`);
27
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
28
+ };
29
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
30
+
31
+ const MOCKUP = fs.readFileSync(path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'briefing-artifact.html'), 'utf8');
32
+ const CSS = fs.readFileSync(path.join(__dirname, 'public', 'pm', 'premium.css'), 'utf8');
33
+ const PATH = 'planning/prd/self-serve-v2-prd.md';
34
+ const TEXT = '---\ntype: PRD\ntitle: "Self-serve onboarding v2"\n---\n\n# PRD: Self-serve onboarding v2\n\n## Problem\n\nA partner waits for a person.\n\n## Goal\n\n- a first call without help\n\n## Requirements\n\nR1 a first call\n';
35
+ const prop = (o) => Object.assign({ id: 'prop-a', state: 'proposed', prompt: 'add a one-paragraph summary', at: '2026-10-18T01:00:00Z', hash: 'ha', by: 'agent', why: null, sections: [
36
+ { name: 'Summary', kind: 'added', before: '', after: 'Partners reach a first call without help.', current: null, stale: false },
37
+ { name: 'Goal', kind: 'changed', before: 'x', after: 'y', current: 'z', stale: true }] }, o || {});
38
+
39
+ (async () => {
40
+ const exe = findBrowser();
41
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
42
+ let chromium;
43
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
44
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: path.resolve(__dirname, '..') }) });
45
+ await T.waitForServer(BASE);
46
+ browser = await chromium.launch({ executablePath: exe });
47
+
48
+ const open = async ({ w = 1280, h = 900, theme = 'light', props = [prop()], post = null } = {}) => {
49
+ const ctx = await browser.newContext({ viewport: { width: w, height: h } });
50
+ const page = await ctx.newPage();
51
+ const S = { text: TEXT, revs: [{ rev: 1, why: '', by: 'baseline', at: '2026-10-16T08:00:00Z' }], props, ask: null, errors: [], posts: [], gets: [] };
52
+ page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
53
+ await page.route('**/api/initiative-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: IP.build(F.facts()), as_of: F.NOW }) }));
54
+ await page.route('**/api/doc-health/check', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, health: { passed: 1, total: 1, checks: [{ id: 'fresh', pass: true, reason: 'ok' }] } }) }));
55
+ await page.route('**/api/briefing-premium/**', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, turns: [], working: false }) }));
56
+ await page.route('**/api/doc-sheet/**', (r) => {
57
+ const rq = r.request(), u = new URL(rq.url()), route = u.pathname.replace('/api/doc-sheet/', ''), send = (b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
58
+ if (rq.method() === 'GET') {
59
+ S.gets.push({ route, query: u.search });
60
+ if (route === 'log') return send({ ok: true, path: PATH, revisions: S.revs, events: [] });
61
+ if (route === 'at') return send({ ok: true, path: PATH, rev: S.revs.length, text: S.text });
62
+ if (route === 'proposals') return send({ ok: true, path: PATH, proposals: S.props });
63
+ if (route === 'ask') return send(S.ask || { ok: true, id: 'ask-1', state: 'working' });
64
+ return send({ ok: false, error: 'not in this test' }, 404);
65
+ }
66
+ const body = JSON.parse(rq.postData() || '{}'); S.posts.push({ route, query: u.search, body, headers: rq.headers() });
67
+ if (post) { const a = post(route, body, S); if (a) return send(a.body, a.status || 200); }
68
+ if (route === 'edit') { S.text = body.text; S.revs.push({ rev: S.revs.length + 1, why: body.why, by: 'pm', at: '2026-10-18T02:00:00Z' }); return send({ ok: true }); }
69
+ if (route === 'accept') { S.props = S.props.map((p) => (p.id === body.id ? Object.assign({}, p, { state: 'accepted' }) : p)); S.revs.push({ rev: S.revs.length + 1, why: 'add a one-paragraph summary', by: 'pm', at: '2026-10-18T02:00:00Z' }); return send({ ok: true }); }
70
+ if (route === 'reject') { S.props = S.props.map((p) => (p.id === body.id ? Object.assign({}, p, { state: 'rejected', why: body.why }) : p)); return send({ ok: true }); }
71
+ if (route === 'ask') { S.ask = { ok: true, id: 'ask-1', state: 'working' }; return send({ ok: true, id: 'ask-1', state: 'working' }); }
72
+ return send({ ok: false, error: 'not in this test' }, 404);
73
+ });
74
+ await page.goto(BASE + '/premium-initiative.html?id=self-serve-v2&ws=w1&board=w1&theme=' + theme);
75
+ await until(() => page.evaluate(() => document.querySelector('#cIniDoc')));
76
+ await page.locator('#dmList .dmo[data-doc="prd"]').click();
77
+ await until(() => page.evaluate(() => document.querySelector('#oMain .dsbody')));
78
+ return { ctx, page, S };
79
+ };
80
+ const txt = (p, q) => p.evaluate((s) => (document.querySelector(s) || {}).textContent || '', q);
81
+ const tab = async (p, k) => { await p.click(`#shT [data-sh="${k}"]`); await sleep(150); };
82
+
83
+ const A = await open(); const p = A.page;
84
+ ok('0 the sheet opens', !!(await p.evaluate(() => document.querySelector('#shT'))));
85
+ /* E1 tabs */
86
+ ok('E1 the sheet has Read, Edit, Proposals, Edit log and Health, with the open count on Proposals', await p.evaluate(() => [...document.querySelectorAll('#shT button')].map((b) => b.textContent.replace(/\s+/g, ' ').trim()).join('|') === 'Read|Edit|Proposals 1|Edit log|Health'));
87
+ ok('E1 the Read outline marks only a heading an open proposal names', await p.evaluate(() => { const b = [...document.querySelectorAll('.dso button')]; return b.length === 0 || b.every((x) => !x.querySelector('i') === !/Goal|Summary/.test(x.textContent)); }));
88
+ ok('E7 the footnote no longer says read-only', !/Read-only/.test(await txt(p, '#oMain .xn')) && /only when you press Save or Accept/.test(await txt(p, '#oMain .xn')));
89
+
90
+ /* E2 edit */
91
+ await tab(p, 'edit');
92
+ ok('E2 the Edit tab holds the file as text, Save is off, and the note says no changes', await p.evaluate((t) => document.querySelector('#dsEd').value === t && document.querySelector('#dsSave').disabled && /No changes yet/.test(document.querySelector('#dsNote').textContent), TEXT));
93
+ await p.fill('#dsEd', TEXT + '\nMore.\n');
94
+ ok('E2 a change turns Save on and the note says changed', await p.evaluate(() => !document.querySelector('#dsSave').disabled && /Changed/.test(document.querySelector('#dsNote').textContent)));
95
+ await p.click('#dsSave');
96
+ ok('E2 Save with no reason posts nothing and says why', await p.evaluate(() => /Say why the document changes/.test(document.querySelector('#dsErr').textContent)) && A.S.posts.length === 0);
97
+ ok('E2 the text typed is still there after the refusal', (await p.inputValue('#dsEd')) === TEXT + '\nMore.\n');
98
+ await tab(p, 'read'); await tab(p, 'edit');
99
+ ok('E2 the draft survives a tab switch', (await p.inputValue('#dsEd')) === TEXT + '\nMore.\n');
100
+ await p.fill('#dsWhy', 'add the missing line'); await p.click('#dsSave');
101
+ await until(() => A.S.posts.length);
102
+ const e1 = A.S.posts[0];
103
+ ok('E2 Save posts path, text and why to /api/doc-sheet/edit with the launch headers and the workspace', e1 && e1.route === 'edit' && Object.keys(e1.body).sort().join() === 'path,text,why' && e1.body.path === PATH && e1.body.why === 'add the missing line' && e1.body.text.endsWith('More.\n') && /ws=w1/.test(e1.query) && e1.headers.origin === BASE, JSON.stringify(e1 && { r: e1.route, q: e1.query }));
104
+ /* E5 after a write */
105
+ await until(() => p.evaluate(() => /No changes yet/.test((document.querySelector('#dsNote') || {}).textContent || '')));
106
+ ok('E5 after Save the text is read again from the route and the note says no changes', (await p.inputValue('#dsEd')).endsWith('More.\n') && await p.evaluate(() => document.querySelector('#dsSave').disabled));
107
+ await tab(p, 'log');
108
+ ok('E5 the Edit log shows the new revision with its reason', await until(() => p.evaluate(() => /v2 add the missing line/.test((document.querySelector('#oMain .evl') || {}).textContent || ''))));
109
+
110
+ /* E3 + E4 proposals */
111
+ await tab(p, 'props');
112
+ const pv = await until(() => p.evaluate(() => document.querySelector('.dsp') && { n: document.querySelectorAll('.dsp').length, t: document.querySelector('.dsp').textContent.replace(/\s+/g, ' '), acc: !!document.querySelector('[data-ds^="acc:"]'), rej: !!document.querySelector('[data-ds^="rej:"]'), stale: /Changed since this was proposed/.test(document.querySelector('.dsp').textContent), head: document.querySelector('#oMain .label:nth-of-type(2)') ? '' : '' }));
113
+ ok('E4 an open proposal names who, the request, the added text, and a stale section says so', pv && /The agent/.test(pv.t) && /add a one-paragraph summary/.test(pv.t) && /\+ Partners reach a first call/.test(pv.t) && pv.stale && pv.acc && pv.rej, JSON.stringify(pv));
114
+ ok('E4 the lists say how many are open and closed', await p.evaluate(() => /Open proposals · 1/.test(document.querySelector('#oMain').textContent) && !/Closed ·/.test(document.querySelector('#oMain').textContent)));
115
+ const nAcc = A.S.posts.length;
116
+ await p.click('[data-ds^="acc:"]');
117
+ await until(() => A.S.posts.length > nAcc);
118
+ const ac = A.S.posts[A.S.posts.length - 1];
119
+ ok('E4 Accept posts path, id, hash and only the sections still current', ac.route === 'accept' && Object.keys(ac.body).sort().join() === 'hash,id,path,sections' && ac.body.hash === 'ha' && ac.body.sections.join() === 'Summary', JSON.stringify(ac.body));
120
+ await until(() => p.evaluate(() => /Closed · 1/.test(document.querySelector('#oMain').textContent)));
121
+ ok('E5 after Accept the proposal is listed as closed and accepted, and none is open', await p.evaluate(() => /Open proposals · 0/.test(document.querySelector('#oMain').textContent) && /Accepted/.test(document.querySelector('.dsp.accepted').textContent) && /No open proposals/.test(document.querySelector('#oMain').textContent)));
122
+ ok('E5 the Proposals count is gone from the tab once none is open', await p.evaluate(() => document.querySelector('#shT [data-sh="props"]').textContent.trim() === 'Proposals'));
123
+ await A.ctx.close();
124
+
125
+ /* E4 stale-all, reject, ask */
126
+ {
127
+ const B = await open({ props: [prop({ sections: [{ name: 'Goal', kind: 'changed', before: 'x', after: 'y', current: 'z', stale: true }] }), prop({ id: 'prop-b', hash: 'hb', prompt: 'drop the code block', sections: [{ name: 'Requirements', kind: 'removed', before: 'R1', after: '', current: 'R1', stale: false }] })] });
128
+ const q = B.page; await tab(q, 'props');
129
+ ok('E4 a proposal whose every section is stale has no Accept and says so', await q.evaluate(() => { const d = [...document.querySelectorAll('.dsp')].find((x) => /add a one-paragraph summary/.test(x.textContent)); return d && !d.querySelector('[data-ds^="acc:"]') && !!d.querySelector('[data-ds^="rej:"]') && /cannot be accepted/.test(d.textContent); }));
130
+ ok('E4 a removed section says it removes', await q.evaluate(() => /Removes this section/.test(document.querySelector('#oMain').textContent)));
131
+ await q.click('[data-ds="rej:prop-b"]');
132
+ ok('E4 Reject asks for a reason first and posts nothing yet', await q.evaluate(() => !!document.querySelector('#dsRj')) && B.S.posts.length === 0);
133
+ await q.click('[data-ds="rejgo:prop-b"]');
134
+ ok('E4 Reject with no reason is refused with no post', await q.evaluate(() => /Say why you are rejecting it/.test(document.querySelector('#dsErr').textContent)) && B.S.posts.length === 0);
135
+ await q.fill('#dsRj', 'not needed'); await q.click('[data-ds="rejgo:prop-b"]'); await until(() => B.S.posts.length);
136
+ ok('E4 Reject posts path, id and why only', B.S.posts[0].route === 'reject' && Object.keys(B.S.posts[0].body).sort().join() === 'id,path,why' && B.S.posts[0].body.why === 'not needed');
137
+ await until(() => q.evaluate(() => /Closed · 1/.test(document.querySelector('#oMain').textContent)));
138
+ ok('E5 the rejected proposal is closed with its reason', await q.evaluate(() => /Rejected/.test(document.querySelector('.dsp.rejected').textContent) && /not needed/.test(document.querySelector('.dsp.rejected').textContent)));
139
+ /* ask */
140
+ await q.fill('#dsAsk', 'tighten the goal'); await q.click('[data-ds="ask"]'); await until(() => B.S.posts.length > 1);
141
+ const ak = B.S.posts[1];
142
+ ok('E3 Ask posts path and prompt to /api/doc-sheet/ask', ak.route === 'ask' && Object.keys(ak.body).sort().join() === 'path,prompt' && ak.body.prompt === 'tighten the goal' && /ws=w1/.test(ak.query));
143
+ ok('E3 while it works the tab says the agent can only read, and the button is off', await until(() => q.evaluate(() => /The agent is reading the document/.test(document.querySelector('#oMain').textContent) && document.querySelector('[data-ds="ask"]').disabled)));
144
+ ok('E3 the page polls the ask by id', await until(() => B.S.gets.some((g) => g.route === 'ask' && /id=ask-1/.test(g.query)), 8000));
145
+ B.S.ask = { ok: true, id: 'ask-1', state: 'failed', error: 'The run ended without an answer. Ask again.' };
146
+ ok('E3 a failed ask shows the route\'s own error', await until(() => q.evaluate(() => /The run ended without an answer/.test(document.querySelector('#oMain').textContent)), 8000));
147
+ ok('0 no page error', B.S.errors.length === 0, B.S.errors.join(' | '));
148
+ await B.ctx.close();
149
+ }
150
+ /* E5/E4 a refused accept shows the route's reason and reads again */
151
+ {
152
+ const C = await open({ post: (route) => (route === 'accept' ? { status: 409, body: { ok: false, error: 'stale: Summary changed since this proposal was made', reason: 'stale' } } : null) });
153
+ await tab(C.page, 'props'); await C.page.click('[data-ds^="acc:"]');
154
+ ok('E4 a refused Accept shows the route\'s reason and the proposal stays open', await until(() => C.page.evaluate(() => /stale: Summary changed since this proposal was made/.test((document.querySelector('#dsErr') || {}).textContent || '') && /Open proposals · 1/.test(document.querySelector('#oMain').textContent))));
155
+ await C.ctx.close();
156
+ }
157
+ /* the mockup's .dsed carries a toolbar above it (radius 0 0 14px 14px); this build leaves the toolbar out, so the box keeps the full 14px radius */
158
+ /* E8 fidelity: the page's rules for the new elements equal the mockup's last rule for each class */
159
+ const rule = (src, sel) => { const m = [...src.matchAll(new RegExp('(?:^|[}\\n])\\s*' + sel.replace(/[.#]/g, (c) => '\\' + c) + '\\{([^}]*)\\}', 'g'))].filter((x) => sel !== '.dsfoot' || /justify-content/.test(x[1])); return m.length ? m[m.length - 1][1].replace('border-radius:0 0 14px 14px', 'border-radius:14px').replace(/#6d3fd1/g, 'rgb(109,63,209)').replace(/\s+/g, '') : null; };
160
+ for (const sel of ['.dsed', '.dsy', '.dsfoot', '.dsdf', '#dsAsk']) {
161
+ const a = rule(MOCKUP, sel), b = rule(CSS, sel);
162
+ ok(`E8 ${sel} has the mockup's declarations`, a && b && b.replace(/;$/, '') === a.replace(/;$/, ''), JSON.stringify({ a, b }));
163
+ }
164
+ for (const [w, h, theme] of [[1280, 900, 'light'], [1280, 900, 'dark'], [390, 844, 'light'], [390, 844, 'dark']]) {
165
+ const R = await open({ w, h, theme });
166
+ for (const t of ['edit', 'props']) {
167
+ await tab(R.page, t);
168
+ const f = await R.page.evaluate(() => { const bad = []; for (const e of document.querySelectorAll('#oMain button,#oMain input:not([type=checkbox]),#oMain textarea')) { const r = e.getBoundingClientRect(); if (r.width && r.height && r.height < 32) bad.push(e.textContent.trim() || e.id); } return { sx: document.documentElement.scrollWidth - innerWidth, bad, out: [...document.querySelectorAll('#oMain textarea,#oMain .dsp,#oMain .dsask2')].filter((e) => e.getBoundingClientRect().right > innerWidth + 1).length }; });
169
+ ok(`E8 ${t} tab at ${w} px ${theme}: no sideways scroll, no tiny target, nothing past the edge`, f.sx <= 0 && f.bad.length === 0 && f.out === 0, JSON.stringify(f));
170
+ }
171
+ const cs = await R.page.evaluate(() => { const e = document.querySelector('#dsAsk'); const c = getComputedStyle(e); return { r: c.borderRadius, fs: c.fontSize }; });
172
+ ok(`E8 the ask box is 14px rounded, 15px type at ${w} px ${theme}`, cs.r === '14px' && cs.fs === '15px', JSON.stringify(cs));
173
+ await R.ctx.close();
174
+ }
175
+ finish();
176
+ })();
@@ -181,7 +181,7 @@ const HEALTH = { ok: true, path: 'planning/prd/self-serve-v2-prd.md', health: {
181
181
  const nPost0 = A.posts.length;
182
182
  await p.locator('#dmList .dmo[data-doc="prd"]').click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && /Self-serve onboarding v2/.test(document.querySelector('#oMain').textContent) && document.querySelector('#oMain .dsbody'))); await sleep(500);
183
183
  const sh = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, path: document.querySelector('#oMain .dpath').textContent, tabs: [...document.querySelectorAll('#shT button')].map((b) => b.textContent).join(','), fm: [...document.querySelectorAll('#oMain .kv2 span')].map((s) => s.textContent).join('|'), heads: [...document.querySelectorAll('#oMain h3.d2')].map((h) => h.textContent).join('|'), outline: [...document.querySelectorAll('#oMain .dso button')].map((b) => b.textContent).join('|'), pre: [...document.querySelectorAll('#oMain pre')].map((e) => e.textContent).join('|'), li: document.querySelectorAll('#oMain li').length }));
184
- ok('I8 Read shows the file\'s path, its front matter as a grid, its headings, list and code', sh.title === 'PRD' && sh.path === 'planning/prd/self-serve-v2-prd.md' && sh.tabs === 'Read,Edit log,Health' && /type\|PRD\|title\|Self-serve onboarding v2/.test(sh.fm) && sh.heads === 'PRD: Self-serve onboarding v2|Problem|Goal|Requirements' && sh.li === 2 && /R1 a first call/.test(sh.pre), JSON.stringify(sh));
184
+ ok('I8 Read shows the file\'s path, its front matter as a grid, its headings, list and code', sh.title === 'PRD' && sh.path === 'planning/prd/self-serve-v2-prd.md' && sh.tabs === 'Read,Edit,Proposals,Edit log,Health' && /type\|PRD\|title\|Self-serve onboarding v2/.test(sh.fm) && sh.heads === 'PRD: Self-serve onboarding v2|Problem|Goal|Requirements' && sh.li === 2 && /R1 a first call/.test(sh.pre), JSON.stringify(sh));
185
185
  ok('I8 Read asked for the log and the last revision, by GET, for this path', A.gets.some((g) => g.path === '/api/doc-sheet/log' && /path=planning%2Fprd%2Fself-serve-v2-prd.md/.test(g.query)) && A.gets.some((g) => g.path === '/api/doc-sheet/at' && /rev=2/.test(g.query)));
186
186
  await p.click('#shT [data-sh="log"]');
187
187
  const lg = await until(() => p.evaluate(() => document.querySelector('#oMain .hsr') && [...document.querySelectorAll('#oMain .hsr')].map((r) => r.textContent.replace(/\s+/g, ' ').trim())));
@@ -191,7 +191,7 @@ const HEALTH = { ok: true, path: 'planning/prd/self-serve-v2-prd.md', health: {
191
191
  ok('I8 Health shows each check as passed, not passed or no input, and says no input is not counted', hl && /1 of 2 checks/.test(hl.note) && hl.rows.join() === 'ckr done:Passed,ckr blocked:Not passed,ckr skipped:No input', JSON.stringify(hl));
192
192
  ok('I8 the health check posts the path and the workspace only', A.posts.some((x) => x.path === '/api/doc-health/check' && Object.keys(x.body).sort().join() === 'path,ws' && x.body.ws === 'w1'));
193
193
  ok('I8 the sheet wrote nothing: no edit, propose, accept, reject, why, mark or ask post went out', !A.posts.slice(nPost0).some((x) => /doc-sheet/.test(x.path)) && !A.posts.some((x) => /^\/api\/doc-sheet\/(edit|propose|accept|reject|why|mark-current|ask)/.test(x.path)));
194
- ok('I8 the sheet says it is read-only', /Read-only/.test(await txt('#oMain .xn')));
194
+ ok('I8 the sheet says the file changes only on Save or Accept', /only when you press Save or Accept/.test(await txt('#oMain .xn')));
195
195
  A.setThread({ ok: true, working: false, turns: [] });
196
196
  await p.fill('#askIn', 'What is missing?'); const nA = A.posts.length; await p.press('#askIn', 'Enter');
197
197
  ok('I8 a question posts the document key and the text', await until(() => A.posts.length > nA && A.posts[A.posts.length - 1].path === '/api/briefing-premium/ask' && A.posts[A.posts.length - 1].body.key === 'doc:self-serve-v2:prd' && A.posts[A.posts.length - 1].body.text === 'What is missing?'));
@@ -0,0 +1,186 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* briefing-premium-metrics-test.js — the Metrics card of the premium Board (initiative briefing-premium-metrics; planning/prd/briefing-premium-metrics-prd.md M1 to M10).
4
+ * Serves the real page from the real server. The Board's answer and the card's answer are served from fixtures (the card's model is built by
5
+ * lib/board-metrics-premium.js from made-up runs, commits and initiatives); the last blocks ask the real route and compare the card with the mockup.
6
+ * C1 place and absence · C2 tiles · C3 reading a week · C4 dialog and agent · C5 pending and failure · C6 floors · C7 the real route · C8 fidelity */
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+ const { spawn } = require('child_process');
10
+ const { findBrowser } = require('./lib/find-browser');
11
+ const T = require('./test-run').configure({ name: 'briefing-premium-metrics' });
12
+ const BP = require('./lib/board-premium.js');
13
+ const MP = require('./lib/board-metrics-premium.js');
14
+ const F = require('./fixtures/board-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-metrics 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 MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'briefing-artifact.html');
33
+ const NOW = Date.now(), W = MP.weeksTo(NOW);
34
+ const runsIn = (wk, count, corr) => Array.from({ length: count }, (_, k) => ({ created_at: new Date(W[wk].from + (k + 1) * 60000).toISOString(), human_corrections: k < corr ? 1 : 0 }));
35
+ const I = (id, o) => Object.assign({ id, accepted: false, stopped: false, steps: [], last_activity: new Date(NOW - 3 * 86400000).toISOString() }, o);
36
+ const metrics = (o) => MP.build(Object.assign({ now: NOW, repo: 'idpf', runs: [].concat(runsIn(5, 10, 4), runsIn(6, 12, 3), runsIn(7, 10, 1)), commits: [W[6].from + 1, W[6].from + 2, W[7].from + 1, W[7].from + 2, W[7].from + 3], inits: [I('a'), I('b', { steps: [{ status: 'blocked' }] }), I('c', { last_activity: new Date(NOW - 45 * 86400000).toISOString() })], missing: [] }, o));
37
+ const ready = (model) => ({ status: 200, body: { ok: true, state: 'ready', model, as_of: Date.now() } });
38
+
39
+ (async () => {
40
+ const exe = findBrowser();
41
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
42
+ let chromium;
43
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
44
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: path.resolve(__dirname, '..') }) });
45
+ await T.waitForServer(BASE);
46
+ browser = await chromium.launch({ executablePath: exe });
47
+
48
+ const open = async ({ w = 1280, h = 900, theme = 'light', answers = null } = {}) => {
49
+ const ctx = await browser.newContext({ viewport: { width: w, height: h } });
50
+ await ctx.addInitScript(() => { try { localStorage.setItem('pmos.premium.openAs', 'popup'); } catch { /* none */ } });
51
+ const page = await ctx.newPage();
52
+ const errors = [], posts = []; let calls = 0; let thread = { ok: true, turns: [], working: false };
53
+ page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
54
+ await page.route('**/api/board-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: BP.build(F.facts()), as_of: Date.now() }) }));
55
+ await page.route('**/api/board-metrics-premium*', (r) => { calls++; const a = answers ? answers(calls) : ready(metrics()); return r.fulfill({ status: a.status, contentType: 'application/json', body: JSON.stringify(a.body) }); });
56
+ await page.route('**/api/core-docs/**', (r) => r.fulfill({ contentType: 'application/json', body: '{"ok":true}' }));
57
+ await page.route('**/api/briefing-premium/**', (r) => { const rq = r.request(); if (rq.method() === 'GET') return r.fulfill({ contentType: 'application/json', body: JSON.stringify(thread) }); posts.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}') }); return r.fulfill({ contentType: 'application/json', body: '{"ok":true}' }); });
58
+ await page.goto(BASE + '/premium-board.html?theme=' + theme);
59
+ await until(() => page.evaluate(() => document.querySelectorAll('#ibBody .ini2').length > 0), 20000);
60
+ return { ctx, page, errors, posts, calls: () => calls, setThread: (t) => { thread = t; } };
61
+ };
62
+
63
+ /* C1 */
64
+ const A = await open(), p = A.page;
65
+ const shown = await until(() => p.evaluate(() => !document.querySelector('#cMet').hidden && document.querySelectorAll('#metBody .mt1').length === 4));
66
+ ok('C1 a tenant board draws the Metrics card with four tiles', shown);
67
+ if (!shown) return finish(1);
68
+ const place = await p.evaluate(() => ({ above: document.querySelector('#cMet').getBoundingClientRect().bottom <= document.querySelector('#cIni').getBoundingClientRect().top, cap: document.querySelector('#metCap').textContent, h: document.querySelector('#hMet').textContent }));
69
+ ok('C1 the card sits above the Initiatives card and says which repository it counts', place.above && place.cap === 'counted from idpf' && place.h === 'Metrics', JSON.stringify(place));
70
+ {
71
+ const R = await open({ answers: () => ({ status: 200, body: { ok: true, state: 'none', why: 'no card' } }) });
72
+ await sleep(800);
73
+ ok('C1 the home workspace\'s board draws no card', await R.page.evaluate(() => document.querySelector('#cMet').hidden), '');
74
+ await R.ctx.close();
75
+ }
76
+
77
+ /* C2 */
78
+ const tiles = await p.evaluate(() => [...document.querySelectorAll('#metBody .mt1')].map((t) => ({ l: t.querySelector('span').textContent, v: t.querySelector('.mval').textContent, c: t.querySelector('.mwk').textContent, chart: !!t.querySelector('svg'), cls: t.className, chg: (t.querySelector('.mchg') || {}).textContent || '' })));
79
+ ok('C2 the first tile is the latest week with its run count, and how it changed', tiles[0].l === 'Corrections per 100 runs' && tiles[0].v === '10.0' && /^week to .+, 10 runs$/.test(tiles[0].c) && tiles[0].chg === '▼ Down 15.0 vs last week' && tiles[0].chart && /\bok\b/.test(tiles[0].cls), JSON.stringify(tiles[0]));
80
+ ok('C2 merges, blocked and idle are counted; blocked and idle have no chart and say no history is kept', tiles[1].v === '3' && tiles[1].chart && tiles[2].v === '1' && tiles[2].c === 'of 3 open. No history is kept' && !tiles[2].chart && tiles[3].v === '1' && !tiles[3].chart && /\bbad\b/.test(tiles[2].cls) && /\bwarn\b/.test(tiles[3].cls), JSON.stringify(tiles));
81
+ const per = await p.evaluate(() => [...document.querySelectorAll('#perTabs button')].map((b) => b.textContent + ':' + b.getAttribute('aria-pressed') + ':' + (b.getAttribute('aria-disabled') || '')).join('|'));
82
+ ok('C2 only Week is available; Day and Month are disabled', per === 'Day:false:true|Week:true:|Month:false:true', per);
83
+ ok('C2 no target, on-target chip, dashed line or demo label is drawn', await p.evaluate(() => !document.querySelector('#cMet .mchip, #cMet .tg, #cMet .tgl') && !/target|demo/i.test(document.querySelector('#cMet').textContent)));
84
+ {
85
+ const gap = metrics({ runs: null, commits: null, inits: null });
86
+ const R = await open({ answers: () => ready(gap) });
87
+ const t = await until(() => R.page.evaluate(() => [...document.querySelectorAll('#metBody .mt1')].map((x) => x.querySelector('.mval').textContent + '/' + x.querySelector('.mwk').textContent)));
88
+ ok('C2 a source that cannot be read says Not read and why, with no number and no chart', t.length === 4 && t.every((x) => x.startsWith('Not read/')) && /agent-runs\.jsonl could not be read in idpf/.test(t[0]) && !(await R.page.evaluate(() => document.querySelector('#metBody svg'))), JSON.stringify(t));
89
+ await R.ctx.close();
90
+ }
91
+
92
+ /* C3 */
93
+ const box = await p.locator('#metBody .mch').first().locator('svg').boundingBox();
94
+ const at = async (frac) => { await p.mouse.move(box.x + box.width * frac, box.y + box.height / 2); await sleep(150); return p.evaluate(() => ({ v: document.querySelector('#metBody .mch .mval').textContent, c: document.querySelector('#metBody .mch .mwk').textContent, hv: document.querySelector('#metBody .mch').classList.contains('hv') })); };
95
+ const first = await at(0.02);
96
+ ok('C3 moving over the first week reads "No runs" for a week without enough runs', first.v === 'No runs' && /^Week to /.test(first.c) && first.hv, JSON.stringify(first));
97
+ const mid = await at(0.841);
98
+ ok('C3 moving over a counted week reads its value and run count', /^\d+\.\d$/.test(mid.v) && / · 12 runs$/.test(mid.c), JSON.stringify(mid));
99
+ await p.mouse.move(5, 5); await sleep(200);
100
+ const back = await p.evaluate(() => ({ v: document.querySelector('#metBody .mch .mval').textContent, hv: document.querySelector('#metBody .mch').classList.contains('hv') }));
101
+ ok('C3 leaving the chart returns to the latest week', back.v === '10.0' && !back.hv, JSON.stringify(back));
102
+ await p.locator('#metBody .mch').first().focus(); await p.keyboard.press('ArrowLeft'); await sleep(100);
103
+ ok('C3 the arrow keys read the week before', await p.evaluate(() => document.querySelector('#metBody .mch .mval').textContent === '25.0' || /^\d+\.\d$/.test(document.querySelector('#metBody .mch .mval').textContent)));
104
+ await p.locator('#metBody .mch').first().blur();
105
+
106
+ /* C4 */
107
+ await p.locator('#metBody .mt1').first().click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(500);
108
+ const dlg = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, sub: document.querySelector('#dSub').textContent, grid: [...document.querySelectorAll('#oMain .kv2 span')].map((s) => s.textContent).join('|'), vals: document.querySelectorAll('#oMain .vtb div').length, def: document.querySelector('#oMain .lede').textContent, ask: document.querySelector('#askF').hidden }));
109
+ ok('C4 a tile opens its definition, its values by week and the repository it counted, with the read-only agent beside it', dlg.title === 'Corrections per 100 runs' && dlg.sub === 'idpf' && /Now\|10\.0/.test(dlg.grid) && /Better when\|Lower/.test(dlg.grid) && /Source\|idpf/.test(dlg.grid) && dlg.vals === 8 && /per 100 agent runs/.test(dlg.def) && dlg.ask === false, JSON.stringify(dlg));
110
+ ok('C4 the dialog holds no press that records anything', await p.evaluate(() => !document.querySelector('#oMain button, #oMain .dmcta')));
111
+ A.setThread({ ok: true, working: false, turns: [] }); await p.fill('#askIn', 'Why did it fall?'); const n0 = A.posts.length; await p.press('#askIn', 'Enter');
112
+ ok('C4 a question posts the metric\'s key and the text', await until(() => A.posts.length > n0 && A.posts[A.posts.length - 1].path === '/api/briefing-premium/ask' && A.posts[A.posts.length - 1].body.key === 'board:metric-corrections' && A.posts[A.posts.length - 1].body.text === 'Why did it fall?'), JSON.stringify(A.posts.slice(-1)));
113
+ await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
114
+ await p.locator('#metBody .mt1').nth(2).click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(400);
115
+ ok('C4 a tile without a chart opens its definition too', await p.evaluate(() => document.querySelector('#dTitle').textContent === 'Blocked' && /blocked step/.test(document.querySelector('#oMain .lede').textContent) && document.querySelectorAll('#oMain .vtb div').length === 0));
116
+ await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
117
+ await p.click('#perTabs [data-per="day"]', { force: true }); ok('C4 a disabled period says why and changes nothing', await until(() => p.evaluate(() => /by week only/.test(document.querySelector('#toast').textContent))) && await p.evaluate(() => document.querySelector('#perTabs [data-per="week"]').getAttribute('aria-pressed') === 'true'));
118
+ ok('0 no page error', A.errors.length === 0, A.errors.join(' | '));
119
+ await A.ctx.close();
120
+
121
+ /* C5 */
122
+ {
123
+ const R = await open({ answers: (c) => (c < 2 ? ready(metrics({ inits: null, initsPending: true })) : ready(metrics())) });
124
+ const idle = () => R.page.evaluate(() => { const t = document.querySelectorAll('#metBody .mt1')[2]; return t ? t.querySelector('.mval').textContent : ''; });
125
+ ok('C5 while the workflow is derived Blocked and Idle say Reading, and the page asks again until they are filled', await until(async () => /^Reading/.test(await idle())) && await until(async () => (await idle()) === '1', 9000) && R.calls() >= 2, String(R.calls()));
126
+ await R.ctx.close();
127
+ const F2 = await open({ answers: () => ({ status: 500, body: { ok: false, state: 'error', error: 'the repository could not be read' } }) });
128
+ ok('C5 a failed read says why and draws no tile', await until(() => F2.page.evaluate(() => !document.querySelector('#cMet').hidden && /The reason: the repository could not be read/.test(document.querySelector('#metHint').textContent) && document.querySelectorAll('#metBody .mt1').length === 0)));
129
+ await F2.ctx.close();
130
+ }
131
+
132
+ /* C6 */
133
+ for (const theme of ['light', 'dark']) {
134
+ const R = await open({ w: 390, h: 844, theme }), q = R.page;
135
+ await until(() => q.evaluate(() => document.querySelectorAll('#metBody .mt1').length === 4));
136
+ const m = await q.evaluate(() => ({ over: document.documentElement.scrollWidth > innerWidth + 1, small: [...document.querySelectorAll('#metBody .mt1')].filter((b) => b.getBoundingClientRect().height < 44).length }));
137
+ ok(`C6 at 390 px (${theme}) the card does not scroll sideways and every tile is 44 px or more`, !m.over && m.small === 0, JSON.stringify(m));
138
+ await R.ctx.close();
139
+ }
140
+
141
+ /* C7 the real route */
142
+ {
143
+ const home = await fetch(BASE + '/api/board-metrics-premium').then((r) => r.json());
144
+ ok('C7 the real route gives the home workspace no card', home.ok === true && home.state === 'none', JSON.stringify(home));
145
+ const post = await fetch(BASE + '/api/board-metrics-premium', { method: 'POST', headers: await T.pressHeaders(BASE), body: '{}' }).then((r) => r.status);
146
+ ok('C7 the route is read-only', post === 405, String(post));
147
+ const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), pg = await ctx.newPage(), errs = [];
148
+ pg.on('pageerror', (e) => errs.push(String(e)));
149
+ await pg.goto(BASE + '/premium-board.html');
150
+ await until(() => pg.evaluate(() => document.querySelectorAll('#ibBody .ini2').length > 0), 40000); await sleep(1500);
151
+ ok('C7 the real PMOS board draws no Metrics card and no script error', await pg.evaluate(() => document.querySelector('#cMet').hidden) && errs.length === 0, errs.join(' | '));
152
+ await ctx.close();
153
+ }
154
+
155
+ /* C8 fidelity against the mockup */
156
+ if (!fs.existsSync(MOCKUP)) ok('C8 the mockup is in the repository', false, MOCKUP);
157
+ else {
158
+ const SEL = [['card', '#cMet'], ['heading', '#hMet'], ['hint', '#cMet .mhint'], ['per', '#perTabs'], ['note', '#cMet .note'], ['t1', '#cMet .mt1:nth-child(1)'], ['t1val', '#cMet .mt1:nth-child(1) .mval'], ['t1cap', '#cMet .mt1:nth-child(1) .mwk'], ['t1chg', '#cMet .mt1:nth-child(1) .mchg'], ['t1svg', '#cMet .mt1:nth-child(1) svg'], ['t1line', '#cMet .mt1:nth-child(1) .ln2'], ['t1dot', '#cMet .mt1:nth-child(1) .dt'], ['t1foot', '#cMet .mt1:nth-child(1) .mfoot'], ['t3', '#cMet .mt1:nth-child(3)'], ['t3val', '#cMet .mt1:nth-child(3) .mval'], ['t3cap', '#cMet .mt1:nth-child(3) .mwk'], ['t4', '#cMet .mt1:nth-child(4)'], ['t4lab', '#cMet .mt1:nth-child(4) span']];
159
+ const SKIP_W = new Set(['hint', 'note', 't1val', 't1cap', 't1chg', 't1foot', 't3val', 't3cap', 't4lab', 'heading', 'per']);
160
+ const SKIP_L = new Set(['t1val', 't1cap', 't1chg', 't1foot', 't3val', 't3cap', 't4lab', 'hint', 'note', 'per']);
161
+ const PROPS = ['fontSize', 'fontWeight', 'fontFamily', 'color', 'backgroundColor', 'borderRadius', 'paddingTop', 'paddingLeft', 'letterSpacing', 'lineHeight', 'boxShadow', 'stroke', 'strokeWidth', 'fill', 'marginTop'];
162
+ const grab = (pg) => pg.evaluate(([pairs, props]) => { const o = {}; for (const [n, s] of pairs) { const e = document.querySelector('main.stage:not([hidden]) ' + s); if (!e) { o[n] = null; continue; } const cs = getComputedStyle(e), r = e.getBoundingClientRect(), v = { left: Math.round(r.left), width: Math.round(r.width) }; props.forEach((k) => { v[k] = cs[k]; }); o[n] = v; } return o; }, [SEL, PROPS]);
163
+ for (const [w, h] of [[1280, 900], [390, 844]]) for (const th of ['light', 'dark']) {
164
+ const m = await (await browser.newContext({ viewport: { width: w, height: h } })).newPage();
165
+ await m.goto('file://' + MOCKUP);
166
+ await until(() => m.evaluate(() => document.querySelectorAll('#rank .rr').length > 0));
167
+ await m.evaluate((t) => { document.documentElement.dataset.theme = t; document.querySelector('.pl[data-p="init"]').click(); }, th);
168
+ await until(() => m.evaluate(() => document.querySelectorAll('#cMet .mt1').length > 0));
169
+ await m.evaluate(() => { drawBoardPage(BOARDS.find((b) => b.real)); }); // the mockup's one board that is read from a repository: four tiles, none with a target
170
+ await until(() => m.evaluate(() => document.querySelectorAll('#cMet .mt1').length === 4 && !!document.querySelector('#cMet .note'))); await sleep(900);
171
+ const R = await open({ w, h, theme: th }); await until(() => R.page.evaluate(() => document.querySelectorAll('#metBody .mt1').length === 4)); await sleep(500);
172
+ const a = await grab(m), c = await grab(R.page), diffs = [];
173
+ for (const [n] of SEL) {
174
+ if (!a[n] || !c[n]) { diffs.push(n + ' missing'); continue; }
175
+ for (const k of Object.keys(a[n])) {
176
+ const geom = k === 'left' || k === 'width';
177
+ if (geom && ((k === 'width' && SKIP_W.has(n)) || (k === 'left' && SKIP_L.has(n)))) continue;
178
+ if (geom ? Math.abs(a[n][k] - c[n][k]) > 2 : a[n][k] !== c[n][k]) diffs.push(`${n}.${k} ${a[n][k]} | ${c[n][k]}`);
179
+ }
180
+ }
181
+ ok(`C8 styles and geometry match the mockup at ${w} px, ${th}`, diffs.length === 0, diffs.join(' ; '));
182
+ await m.context().close(); await R.ctx.close();
183
+ }
184
+ }
185
+ return finish();
186
+ })().catch((e) => { console.error(e); finish(1); });
@@ -142,11 +142,12 @@ Board is the third place on the rail, at `/premium-board.html`. It reads what th
142
142
  - **By stage** has one column for each stage of the board's workflow with the board's own count and its first five initiatives.
143
143
  - **Timeline** draws a bar for each initiative that has both a start and an end date, with the days left or over, and counts the rest. With no dates on record it says so and draws nothing.
144
144
  - **Sprint** appears when an agent session has read Jira for the board. Otherwise it says there is none. **Coming up** shows the next release, from the releases ledger.
145
+ - **Metrics** appears above the Initiatives card on the board of any workspace except the home one (PMOS itself), and counts from that workspace's own repository. It has four tiles. **Corrections per 100 runs** is the corrections logged on the week's runs in `planning/runs/agent-runs.jsonl`; a week with fewer than 10 runs is left blank. **Merged a week** counts the commits on the first-parent line of the trunk. **Blocked** and **Idle for a month** come from the workflow engine and keep no history, so they have no chart. Move over a chart, or use the arrow keys, to read a week. A tile that cannot be counted says **Not read** and why. Press a tile for its definition and values, with the read-only agent beside it. There are no targets, and Day and Month are off. It was tested only on made-up repositories, not on a real IDPF or microsite repository.
145
146
  - **The crumb** at the top names the board. With more than one board a menu switches between them, and the sparkle opens the board in the dialog with the read-only agent.
146
147
  - **Core documents** lists the board's documents with their state, cadence and writer, a summary (drafts to review, not started, up to date), a progress bar, a filter and a search. **Draft it** starts the existing read-only run that writes a draft and sends nothing; **Draft the N not started** does that for each document that can be drafted. **Set it up** and **Open** go to the console. Issue, Drop and Add a document are not on this page.
147
148
  - **Opening an initiative.** A click on an initiative opens its page (see "Initiative page"). The **Page / Popup** switch in the header changes that: Popup opens the initiative's dialog instead, which shows its record as a grid and the path of its file, with the read-only agent beside it. The choice is kept in this browser. The dialog holds no press: moving an initiative or starting work on it is not built here.
148
149
 
149
- Not drawn, because PMOS holds no record for them: the Metrics charts and "Ask PMOS" about them, and the mockup's demo boards.
150
+ Not drawn, because PMOS holds no record for them: the Metrics card on the PMOS board, the mockup's demo measures (Activation, Partner uptime, API p95), targets, and the mockup's demo boards.
150
151
 
151
152
 
152
153
  ## Initiative page
@@ -159,6 +160,6 @@ The initiative page is at `/premium-initiative.html?id=<initiative>`. A click on
159
160
  - **Checks** lists the engine's six steps (spec, contract, build, quality, review, accept) with their state and the evidence each states, and marks the next one. "All N workflow steps" lists every step.
160
161
  - **Tasks** lists the PRD requirements and the board's tracker items for this initiative. The repository records no result for each requirement, so a requirement says "No result" and is never drawn as done or open. **By stage** groups them by state. **Timeline** draws a bar for each task that has both a start and a due date, and lists the rest. Press a task to read its record; for a PMOS task you can change its status. **Add a task** writes a PMOS task to the board's own record; with no dates the board plans it from tomorrow for a week. Jira tickets stay read-only. There is no Add a document: nothing stores a document you add.
161
162
  - **Core documents** has the same counts, filter and search as the Board's card, for this initiative. **Draft it** starts the existing read-only run that writes a draft and sends nothing. Technical documents (the record, the rubric, the stories, the review and the explainer) are grouped and not counted.
162
- - **The document sheet.** A document that has a file opens in a dialog with **Read** (the file's text, its front matter as a grid and an outline), **Edit log** (the revisions and other entries of the document sheet) and **Health** (the document-health checks; a check with no input is not counted). The read-only agent sits beside it and starts from the file. The sheet writes nothing: editing, accepting a proposal, Issue and Drop are not built on this page.
163
+ - **The document sheet.** A document that has a file opens in a dialog with **Read** (the file's text, its front matter as a grid and an outline), **Edit** (the file as plain Markdown, a reason, and **Save**), **Proposals** (**Ask the agent**, the open proposals with **Accept** and **Reject**, and the closed ones), **Edit log** (the revisions and other entries of the document sheet) and **Health** (the document-health checks; a check with no input is not counted). The file changes only when you press Save or Accept, and every change is kept in the Edit log with its reason. Save and Reject need a reason. A proposal made on text that has since changed shows which sections are out of date and cannot take them. The agent beside the sheet still only reads. Bold and undo buttons, Issue and Drop are not built on this page.
163
164
 
164
165
  Not drawn, because PMOS holds no record for them: the mockup's demo tasks, its Jira data, and the owner "Agents" on a requirement.