create-pmos 0.267.0 → 0.269.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.267.0",
3
+ "version": "0.269.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@277fdcb
1
+ kernel-source: pmos@b1f2a1a
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-18T11:30:29Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-18T12:16:13Z"}
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-18T11:30:29Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-18T12:16:13Z"}
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-18T11:30:29Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-18T12:16:13Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -125,7 +125,7 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
125
125
  const docs = await p.evaluate(() => ({ cap: document.querySelector('#docCap').textContent, rows: [...document.querySelectorAll('#docBody .dmr')].map((r) => ({ t: r.querySelector('.dmn b').textContent, s: r.querySelector('.dmm .s').textContent.trim(), b: r.querySelector('.dmcta') ? r.querySelector('.dmcta').textContent.trim() : null, dis: r.querySelector('.dmcta') ? r.querySelector('.dmcta').disabled : null, kind: r.querySelector('.dmcta') ? (r.querySelector('.dmcta').dataset.draft ? 'draft' : 'go') : null })), all: document.querySelector('#cDocs').textContent }));
126
126
  ok('B7 the documents come from the record with their state, and the summary counts them', docs.cap === '6' && docs.rows.length === 6 && docs.rows[0].t === 'Board charter' && docs.rows[0].s === 'Not started' && docs.rows[1].s === 'Live' && docs.rows[3].s === 'Draft' && docs.rows[4].s === 'Stale', JSON.stringify(docs));
127
127
  ok('B7 the button is the record\'s own action: Draft it, Set it up, Open; a draft to review and a document with no action have none; a running one is off', docs.rows[0].b === 'Draft it' && docs.rows[0].kind === 'draft' && docs.rows[2].b === 'Set it up' && docs.rows[2].kind === 'go' && docs.rows[1].b === 'Open' && docs.rows[3].b === null && docs.rows[5].b === 'Drafting' && docs.rows[5].dis === true, JSON.stringify(docs.rows));
128
- ok('B7 Issue and Drop are not on the page', !/\b(Issue|Drop)\b/.test(docs.all));
128
+ ok('B7 Drop is not on the page, and the list has no Issue it press (it is in a draft\'s reader)', !/\bDrop\b/.test(docs.all) && await p.evaluate(() => !document.querySelector('#docBody [data-rd="issue"], #docBody button.dmcta')?.textContent.includes('Issue it')));
129
129
  A.set({ status: 200, body: { ok: true, run: 'r1' } });
130
130
  const g0 = A.calls();
131
131
  await p.locator('#docBody [data-draft="charter"]').click();
@@ -169,7 +169,7 @@ const HEALTH = { ok: true, path: 'planning/prd/self-serve-v2-prd.md', health: {
169
169
  A.set({ status: 409, body: { ok: false, error: 'a run is already drafting that document' } });
170
170
  await p.locator('#dmList [data-draft="problem"]').click();
171
171
  ok('I10 a refused press shows the route\'s reason and turns the button back on', await until(() => p.evaluate(() => /already drafting/.test(document.querySelector('#toast').textContent) && !document.querySelector('#dmList [data-draft="problem"]').disabled)));
172
- ok('I10 Issue, Drop and editing are not on the page', !/\b(Issue it|Drop|Accept|Edit)\b/.test(await txt('#iMain')));
172
+ ok('I10 Drop, Accept and editing are not on the page, and no Issue it press is in the list (it is on a draft\'s sheet)', !/\b(Drop|Accept|Edit)\b/.test(await txt('#iMain')) && await p.evaluate(() => ![...document.querySelectorAll('#iMain button')].some((b) => /Issue it/.test(b.textContent))));
173
173
  ok('I7 a running document shows Drafting and is off', await p.evaluate(() => { const b = document.querySelector('#dmList [data-draft="launch"]'); return !!b && b.disabled && /Drafting/.test(b.textContent); }));
174
174
 
175
175
  /* the batch press: one existing draft run for each document not started */
@@ -155,20 +155,23 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
155
155
  const qt = (sel) => q.evaluate((x) => (document.querySelector(x) || {}).textContent || '', sel);
156
156
  const last = () => sent[sent.length - 1] || [null, {}];
157
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'))); };
158
+ const shut = async () => { for (let i = 0; i < 2 && await q.evaluate(() => document.querySelector('#dlg').classList.contains('on')); i++) { await q.keyboard.press('Escape'); await sleep(150); } await until(() => q.evaluate(() => !document.querySelector('#dlg').classList.contains('on'))); }; // a full-screen dialog leaves full screen on the first Escape
159
159
  await q.click('#dashTabs [data-d="pd-1"]'); await sleep(200);
160
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
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
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);
163
+ const chipv = (k) => q.evaluate((x) => (document.querySelector(`#oMain [data-st="chip|${x}"] b`) || {}).textContent || '', k);
164
+ await q.click('#oMain [data-st="chip|charts"]');
165
+ const ed = await q.evaluate(() => ({ eye: document.querySelector('#dEye').textContent, rows: [...document.querySelectorAll('#stTr .sul li > span:first-child')].map((b) => b.childNodes[0].textContent) }));
166
+ ok('R2 Edit opens the Studio with the name, Main and the charts in order', /^Insight Studio · /.test(ed.eye) && await chipv('name') === 'Weekly partner review' && await chipv('main') === 'Yes' && ed.rows.join() === 'Partner activation,Time to first call,krm-gone', JSON.stringify(ed));
167
+ await q.click('#stTr [data-st="mv|1|-1"]'); await q.click('#stTr [data-st="rm|2"]'); await q.click('#oMain [data-st="lib"]'); await q.click('#stLb [data-st="libc|krm-up"]');
168
+ await q.click('#oMain [data-st="chip|name"]'); await q.fill('#stI', 'Monday review'); await q.click('#oMain [data-st="save"]'); await sleep(400);
166
169
  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');
170
+ await q.click('#pdNew'); await dlgOn(); await q.click('#oMain [data-st="save"]'); await sleep(200);
171
+ ok('R2 a new dashboard without a name says so and posts nothing', /Give the dashboard a name/.test(await qt('#stMsg')) && last()[1].id === 'pd-1');
169
172
  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));
173
+ await q.click('#oMain [data-st="chip|name"]'); await q.fill('#stI', 'Weekly partner review'); await q.click('#oMain [data-st="chip|use"]'); await q.fill('#stI', 'x'); await q.click('#oMain [data-st="save"]'); await sleep(300);
174
+ ok('R7 the server\'s refusal is shown in words and the dialog stays open', /already a dashboard on this board/.test(await qt('#stMsg')) && await q.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !document.querySelector('#oMain [data-st="save"]').disabled));
172
175
  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
176
  await shut();
174
177
  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);
@@ -253,7 +256,8 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
253
256
  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
257
  /* briefing-premium-reports against the real server: New dashboard, Save, the switch, then the ledger answers it back */
255
258
  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');
259
+ await pg.click('#oMain [data-st="chip|name"]'); await pg.fill('#stI', 'Partner review'); await pg.click('#oMain [data-st="chip|use"]'); await pg.fill('#stI', 'The Monday partner review.');
260
+ await pg.click('#stLb [data-st="libc|' + m.charts[0].id + '"]'); await pg.click('#oMain [data-st="chip|main"]'); await pg.click('#stTr [data-st="set|main|1"]'); await pg.click('#oMain [data-st="save"]');
257
261
  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
262
  const j2 = await (await fetch(base2 + '/api/insights-premium')).json(), d2 = j2.model.dashboards.find((d) => d.saved);
259
263
  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));
@@ -78,6 +78,32 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
78
78
  ok('R1 the console stays the default page', /id="c3-root"/.test(def) && !/class="rail/.test(def));
79
79
  { const tc = await p.evaluate(() => { const a = document.querySelector('#toConsole'); if (!a) return null; const r = a.getBoundingClientRect(); return { href: a.getAttribute('href'), label: a.getAttribute('aria-label'), w: Math.round(r.width), h: Math.round(r.height), tab: a.tabIndex }; }); ok('R1 the header links to the console (premium-console-link)', tc && tc.href === '/c3.html' && tc.label === 'Open the console' && tc.w >= 44 && tc.h >= 44 && tc.tab === 0, JSON.stringify(tc)); }
80
80
 
81
+ /* premium-search-bell: the Search button, the bell and Ctrl K, from the shared shell */
82
+ {
83
+ await p.route('**/api/boards/backlog*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, ws: 'w1', board: 'b1', rows: [{ id: 'sb-alpha', title: 'Alpha launch plan', lane: 'feature', stage: 'Build' }] }) }));
84
+ await p.route('**/api/core-docs*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, scope: { name: 'PMOS' }, docs: [{ key: 'roadmap', title: 'Roadmap' }] }) }));
85
+ await p.route('**/api/sessions', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ sessions: [{ id: 's1', name: 'Fix the footer', state: 'idle', cwd: '.' }, { id: 's2', name: 'Nightly run', state: 'idle', automatic: true }] }) }));
86
+ const sb = await until(() => p.evaluate(() => { const s = document.querySelector('#pvSearch'), b = document.querySelector('#pvBell'), g = document.querySelector('#pvBdg'); if (!s || !b || !g || g.hidden) return null; const rs = s.getBoundingClientRect(), rb = b.getBoundingClientRect(); return { sw: Math.round(rs.width), sh: Math.round(rs.height), bw: Math.round(rb.width), bh: Math.round(rb.height), n: g.textContent, lab: b.getAttribute('aria-label') }; }), 8000);
87
+ const want = MODEL.list.count;
88
+ ok('SB1 the header has a Search button and a bell, 44 px, and the bell counts what the Briefing lists', sb && sb.sw >= 44 && sb.sh >= 44 && sb.bw >= 44 && sb.bh >= 44 && sb.n === String(want) && sb.lab === 'Needs you: ' + want, JSON.stringify(sb));
89
+ await p.keyboard.press('Control+k');
90
+ const pal = await until(() => p.evaluate(() => { const o = document.querySelector('#pvOv'); return o && !o.hidden && document.activeElement && document.activeElement.id === 'pvQ' ? { rail: document.querySelector('.rail').inert, groups: [...document.querySelectorAll('#pvList .pv-grp')].map((x) => x.textContent) } : null; }), 6000);
91
+ ok('SB2 Ctrl K opens the search with the box focused and the page behind it inert', pal && pal.rail === true, JSON.stringify(pal));
92
+ await p.keyboard.type('alpha');
93
+ const hit = await until(() => p.evaluate(() => { const r = [...document.querySelectorAll('#pvList .pv-row b')].map((x) => x.textContent); return r.length === 1 && r[0] === 'Alpha launch plan' ? r : null; }), 6000);
94
+ ok('SB3 typing narrows the results to a record read from the board', !!hit);
95
+ await p.keyboard.press('Control+a'); await p.keyboard.type('fix');
96
+ const ses = await until(() => p.evaluate(() => [...document.querySelectorAll('#pvList .pv-row b')].map((x) => x.textContent).join() === 'Fix the footer' ? 1 : 0), 6000);
97
+ ok('SB4 sessions are listed and automatic ones are left out', !!ses);
98
+ await p.keyboard.press('Escape');
99
+ const closed = await until(() => p.evaluate(() => document.querySelector('#pvOv').hidden && !document.querySelector('.rail').inert && document.activeElement.id === 'pvSearch'), 4000);
100
+ ok('SB5 Escape closes it and puts the focus back on the button', !!closed);
101
+ await p.click('#pvBell');
102
+ const rows = await until(() => p.evaluate(() => { const o = document.querySelector('#pvOv'); return !o.hidden ? document.querySelectorAll('#pvList .pv-row').length : 0; }), 6000);
103
+ ok('SB6 the bell lists the Briefing rows and a row opens the Briefing', rows === MODEL.list.rows.length, String(rows));
104
+ await p.keyboard.press('Escape');
105
+ ok('SB7 search and the bell only read: no POST left the page', !A.reqs.some((x) => x.startsWith('POST ')));
106
+ }
81
107
  /* premium-settings: the dialog holds Workspaces and Connectors only; each press goes to its existing route */
82
108
  { const bt = await p.evaluate(() => { const b = document.querySelector('#settingsBtn'); if (!b) return null; const r = b.getBoundingClientRect(); return { label: b.getAttribute('aria-label'), w: Math.round(r.width), h: Math.round(r.height) }; });
83
109
  ok('S1 the header has a Settings button of at least 44 px', bt && bt.label === 'Settings' && bt.w >= 44 && bt.h >= 44, JSON.stringify(bt));
@@ -13,7 +13,7 @@ A rail on the left names four places: Briefing, My work, Board and Insights. Eac
13
13
 
14
14
  Every premium page has an **Open the console** button beside the theme button. It opens the console at `/c3.html`, for the places premium does not have yet (agent sessions, Calendar, Settings). In the console, the More menu has **Open premium**, which opens this page.
15
15
 
16
- Every premium page has a **Settings** button beside it. It opens one dialog with two sections. **Workspaces** lists the repositories PMOS works in, with Add (a folder path) and Remove; Remove forgets the address and never deletes the folder, and a refusal shows the server's reason. **Connectors** has an On/Off switch for each source the Briefing reads. Each press saves that one record. Every other setting runs on a default and stays in the console; the dialog links to it. Remove needs the page's launch nonce, so an agent session cannot call it.
16
+ Every premium page also has a **Search** button and a bell. Ctrl K (or `/`) opens the search over places, initiatives, documents and your running sessions; Enter opens the result. The bell counts the same things the Briefing lists under what you need to do, and a press opens the Briefing. Both only read; neither changes a record. Every premium page has a **Settings** button beside it. It opens one dialog with two sections. **Workspaces** lists the repositories PMOS works in, with Add (a folder path) and Remove; Remove forgets the address and never deletes the folder, and a refusal shows the server's reason. **Connectors** has an On/Off switch for each source the Briefing reads. Each press saves that one record. Every other setting runs on a default and stays in the console; the dialog links to it. Remove needs the page's launch nonce, so an agent session cannot call it.
17
17
 
18
18
  Every premium page has an **Agent sessions** button beside the console button, with a count of the sessions running. It opens a dialog that lists each running session and background run with its note, state and start time. **Stop** asks first and says what it ends, then ends the session and closes its terminal. If the session has not exited yet, the row says so and offers Stop again. Terminals, new sessions and run questions stay in the console; the dialog links to it.
19
19
 
@@ -162,7 +162,7 @@ Board is the third place on the rail, at `/premium-board.html`. It reads what th
162
162
  - **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.
163
163
  - **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.
164
164
  - **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.
165
- - **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. **Add a document** opens a form (title, who writes it, where it lives) and saves a document the core set does not cover on the board's record, in `custom-docs.jsonl`. A document with no link reads "Not started". A document with a link to Confluence or Google Docs reads "Linked" and shows its address. PMOS does not read or sync the linked page, so a linked document is never counted as up to date. Issue and Drop are not on this page.
165
+ - **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. A document with a file opens in the dialog, read only, with its path and state; a draft there has **Issue it**, which marks it issued through the console's own route and sends nothing, and **Draft it again**, which starts a new draft that replaces this one (a board draft has no Edit tab). **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. **Add a document** opens a form (title, who writes it, where it lives) and saves a document the core set does not cover on the board's record, in `custom-docs.jsonl`. A document with no link reads "Not started". A document with a link to Confluence or Google Docs reads "Linked" and shows its address. PMOS does not read or sync the linked page, so a linked document is never counted as up to date. Issue and Drop are not on this page.
166
166
  - **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.
167
167
  - **New asks** sits at the top of the right column on a team board. Each ask shows where it came from and the drafted title, lane and anchor. **Accept** makes it an initiative in the first stage, through the console's accept route; **Decline** asks for a reason first. The card says when nothing is left to triage.
168
168
  - **New initiative** (beside the Initiatives heading, team boards only) asks for a title, a lane and an anchor (a KR or a health budget). It writes an ask and accepts it, as the console does. An unanchored initiative is refused on the page.
@@ -182,7 +182,7 @@ The initiative page is at `/premium-initiative.html?id=<initiative>`. A click on
182
182
  - **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.
183
183
  - **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. **Add a document** works as on the Board, with a phase as well, and saves on the initiative's record.
184
184
  - **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.
185
- - **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.
185
+ - **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. A draft shows a bar above its text: **Issue it** marks the draft issued, through the console's own route, and sends nothing; it refuses while the Edit tab holds unsaved changes. Bold and undo buttons and Drop are not built on this page.
186
186
 
187
187
  Not drawn, because PMOS holds no record for them: the mockup's demo tasks, its Jira data, and the owner "Agents" on a requirement.
188
188
 
@@ -192,7 +192,7 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
192
192
 
193
193
  - **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.
194
194
  - **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.
195
- - **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.
195
+ - **Make or edit a dashboard.** **New dashboard**, or **Edit** on a saved one, opens the **Insight Studio**, a wide dialog. On the right, the brief shows the Name, Purpose, Charts and Main dashboard; press a chip to change it. **Library** lists the board's measures and saved dashboards to add. The preview draws the dashboard as the page will, and lists a measure with no series as not drawn. The checks (a name, a purpose, a chart, six or fewer, no repeat, a main dashboard on the board) say what fails, with a one-press fix. On the left you can say it instead: "add Partner activation", "remove …", "move … first", "call it …", "it is for …", "make it the main dashboard", "undo" or "start a new one". A turn changes the draft only. **Undo** steps back one change. **Save the dashboard** records it; **Remove the dashboard** asks once more and then removes it. 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.
196
196
  - **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.
197
197
  - **No series recorded.** A KR metric with one reading or none is listed with the reason and is not drawn.
198
198
  - **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**.
@@ -200,4 +200,4 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
200
200
  - **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**.
201
201
  - **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.
202
202
 
203
- 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.
203
+ Not built: the Insight Studio's Chart and Report modes, 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.
@@ -131,7 +131,7 @@ function build(f) {
131
131
  cap: dd.summary ? [(dd.summary.missing + nCustomNone) ? (dd.summary.missing + nCustomNone) + ' not started' : null, dd.summary.draft ? dd.summary.draft + ' ' + plural(dd.summary.draft, 'draft', 'drafts') : null, dd.summary.stale ? dd.summary.stale + ' stale' : null, dd.summary.due ? dd.summary.due + ' due' : null].concat(nLinked ? [nLinked + ' linked'] : []).filter(Boolean).join(' · ') || 'all up to date' : '',
132
132
  scope: dd.scope || null,
133
133
  counts: null,
134
- rows: (dd.docs || []).map((d) => ({ key: d.key, title: d.title, what: d.for || '', state: d.kind === 'live' ? 'Live' : DOC_STATE[d.st] || d.st || '', st: d.st, cadence: d.cadence || '', by: BY[d.by] || d.by || '', running: !!d.running,
134
+ rows: (dd.docs || []).map((d) => ({ key: d.key, title: d.title, what: d.for || '', state: d.kind === 'live' ? 'Live' : DOC_STATE[d.st] || d.st || '', st: d.st, cadence: d.cadence || '', by: BY[d.by] || d.by || '', running: !!d.running, when: d.when ? shortDate(d.when) : '', path: d.open && d.open.path ? d.open.path : null, slot: d.st === 'draft' && d.draft && d.draft.slot ? d.draft.slot : '',
135
135
  act: d.act && d.act.do === 'draft' ? { kind: 'draft', label: d.running ? 'Drafting' : d.act.label || 'Draft it' } : d.act && d.act.go ? { kind: 'go', label: d.act.label || 'Open', tab: GO[d.act.go] || 'init' } : d.open && d.open.tab ? { kind: 'go', label: 'Open', tab: GO[d.open.tab] || 'init' } : null })).concat(custom),
136
136
  } : { cap: '', rows: custom, missing: true, scope: board.id ? 'board:' + board.id : null };
137
137
  docs.counts = dd || custom.length ? { all: docs.rows.length, none: docs.rows.filter((d) => d.st === 'missing').length, draft: docs.rows.filter((d) => d.st === 'draft').length, ok: docs.rows.filter((d) => d.st === 'ok').length } : { all: 0, none: 0, draft: 0, ok: 0 };
@@ -103,7 +103,7 @@ function build(f) {
103
103
  const dd = f.docs || null;
104
104
  const all = dd ? (dd.docs || []).map((d) => ({
105
105
  key: d.key, title: d.title, what: d.for || '', st: d.st, state: d.kind === 'live' ? 'Live' : DOC_STATE[d.st] || d.st || '', by: BY[d.by] || d.by || '', byKey: d.by || '',
106
- when: d.when ? shortDate(d.when) : '', cat: d.cat === 'Do' ? 'Build' : d.cat === 'Learn' ? 'Evaluate' : d.cat || 'Board', path: d.open && d.open.path ? d.open.path : null, running: !!d.running, tech: TECH.has(d.key),
106
+ when: d.when ? shortDate(d.when) : '', cat: d.cat === 'Do' ? 'Build' : d.cat === 'Learn' ? 'Evaluate' : d.cat || 'Board', path: d.open && d.open.path ? d.open.path : null, slot: d.st === 'draft' && d.draft && d.draft.slot ? d.draft.slot : '', running: !!d.running, tech: TECH.has(d.key),
107
107
  act: d.act && d.act.do === 'draft' ? { kind: 'draft', label: d.running ? 'Drafting' : d.act.label || 'Draft it' } : null,
108
108
  })) : [];
109
109
  const custom = (f.custom || []).map((d) => Object.assign(Custom.rowOf(d), { added: shortDate(d.at), cat: d.phase || 'Board' }));
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.267.0",
3
+ "version": "0.269.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.267.0",
9
+ "version": "0.269.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.267.0",
3
+ "version": "0.269.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-core-doc-issue-test.js — Issue it on a core document draft, on the premium Board and the premium initiative page (initiative premium-core-doc-issue;
4
+ * planning/prd/premium-core-doc-issue-prd.md I1 to I7). A real server on a scratch `team` repository, never the PMOS checkout. The drafts are written by the
5
+ * core-docs writer (lib/core-docs.js writeDraft), so the pages read what the agent's run would leave. The real pages press the real route:
6
+ * R reading (slot and path) · B the Board reader and Issue it · I the initiative sheet, unsaved edits and a refusal · P the POST allow-list · F 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: 'premium-core-doc-issue' });
12
+ const { makeRepos, codeRepo, write, git } = require('./plan-test-repos');
13
+ const CD = require('./lib/core-docs.js');
14
+
15
+ const BASE = T.BASE;
16
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
17
+ const until = async (fn, ms = 20000, step = 150) => { 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 !== '' ? ' — ' + String(extra).slice(0, 500) : ''}`); };
20
+ const R = makeRepos('premium-core-doc-issue');
21
+ const team = codeRepo(path.join(R.base, 'team'));
22
+ fs.mkdirSync(path.join(team, 'pmos', 'state'), { recursive: true });
23
+ write(team, 'planning/initiatives/pa-one.md', '---\ntype: Initiative\ntitle: Partner rate limits\ntimestamp: 2026-10-01\nid: pa-one\nlane: chore\nparent_kr: health:tech\nspecimen_test: "description-judgeable — x"\nsurface_check: "greenfield — x"\n---\n\nbody\n');
24
+ git(team, ['add', '-A']); git(team, ['commit', '-q', '-m', 'pa-one']);
25
+ let srv = null; let browser = null;
26
+ const finish = async (code) => {
27
+ if (browser) await browser.close().catch(() => {});
28
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
29
+ T.killTmux(); R.cleanup();
30
+ const bad = results.filter((x) => !x.cond).length;
31
+ console.log(`\n${results.length - bad}/${results.length} premium-core-doc-issue assertions passed`);
32
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
33
+ };
34
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
35
+
36
+ const ledger = () => { const f = CD.ledgerFile(team); return fs.existsSync(f) ? fs.readFileSync(f, 'utf8').split('\n').filter(Boolean).map((x) => JSON.parse(x)) : []; };
37
+ const ALLOWED = /^\/api\/(?:core-docs\/issue|briefing-premium\/note)$/;
38
+ const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers.\n';
39
+
40
+ (async () => {
41
+ const exe = findBrowser();
42
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
43
+ let chromium;
44
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
45
+ 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: team, PMOS_NO_OPEN: '1' }) });
46
+ await T.waitForServer(BASE);
47
+ const ready = await until(async () => { const r = await fetch(BASE + '/api/board-premium'); const j = await r.json().catch(() => null); return r.status === 200 && j && j.ok && j.state === 'ready' && j.model.initiatives.list.rows.length ? j : null; }, 90000, 400);
48
+ if (!ready) { ok('setup the real route reads the scratch board', false); return finish(1); }
49
+ const B = ready.model.board, bscope = ready.model.docs.scope;
50
+ const bkey = (ready.model.docs.rows.find((d) => d.act && d.act.kind === 'draft' && d.st === 'missing') || {}).key;
51
+ ok('setup the board has a core document not started, and a scope', !!bkey && /^board:/.test(bscope), JSON.stringify({ bscope, bkey }));
52
+ const d1 = CD.writeDraft(team, { scope: bscope, key: bkey, markdown: BODY, by: 'agent:test', now: Date.now() });
53
+ const iq = '?id=pa-one&ws=' + encodeURIComponent(B.ws) + '&board=' + encodeURIComponent(B.id);
54
+ const ini = await until(async () => { const r = await fetch(BASE + '/api/initiative-premium' + iq); const j = await r.json().catch(() => null); return r.status === 200 && j && j.ok && j.state === 'ready' ? j : null; }, 90000, 400);
55
+ /* the initiative documents PMOS keeps itself are Risks and Outcome review (lib/core-docs.js storable); the others are read from their own source */
56
+ const free = ini ? ['risks', 'outcome'].filter((k) => ini.model.docs.rows.some((d) => d.key === k && !d.tech)) : [];
57
+ const ikey = free[0];
58
+ const iscope = ini && ini.model.docs.scope;
59
+ ok('setup the initiative has two core documents not started', free.length >= 2 && iscope === 'initiative:pa-one', JSON.stringify({ iscope, ikey }));
60
+ if (!ikey) return finish(1);
61
+ const d2 = CD.writeDraft(team, { scope: iscope, key: ikey, markdown: BODY, by: 'agent:test', now: Date.now() });
62
+ const d3 = CD.writeDraft(team, { scope: iscope, key: free[1], markdown: BODY, by: 'agent:test', now: Date.now() });
63
+ ok('setup the writer left three drafts', d1.ok && d2.ok && d3.ok, JSON.stringify([d1, d2, d3]));
64
+
65
+ /* R reading */
66
+ const board2 = await (await fetch(BASE + '/api/board-premium')).json();
67
+ const br = board2.model.docs.rows.find((d) => d.key === bkey);
68
+ ok('R1 the board model carries the draft\'s slot and path from the core-docs answer', br.st === 'draft' && br.slot === d1.slot && br.path === d1.path, JSON.stringify(br));
69
+ const ini2 = await (await fetch(BASE + '/api/initiative-premium' + iq)).json();
70
+ const ir = ini2.model.docs.rows.find((d) => d.key === ikey);
71
+ ok('R2 the initiative model carries the draft\'s slot and path', ir.st === 'draft' && ir.slot === d2.slot && ir.path === d2.path, JSON.stringify(ir));
72
+
73
+ browser = await chromium.launch({ executablePath: exe });
74
+ const open = async (url, { w = 1280, h = 900, theme = 'light' } = {}) => {
75
+ const ctx = await browser.newContext({ viewport: { width: w, height: h } });
76
+ await ctx.addInitScript(() => { try { localStorage.setItem('pmos.premium.openAs', 'popup'); } catch { /* none */ } });
77
+ const page = await ctx.newPage(), errors = [], posts = [];
78
+ page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
79
+ page.on('request', (rq) => { if (rq.method() === 'POST') posts.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}'), headers: rq.headers() }); });
80
+ await page.goto(BASE + url);
81
+ if (theme === 'dark') await page.evaluate(() => { document.documentElement.dataset.theme = 'dark'; });
82
+ return { ctx, page, errors, posts };
83
+ };
84
+ const dlgOn = async (p) => { const v = await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(800); return v; };
85
+ const toastIs = (p, re) => until(() => p.evaluate((s) => { const t = document.querySelector('#toast'); return t.classList.contains('on') && new RegExp(s).test(t.textContent) ? t.textContent : null; }, re.source));
86
+ const H = await T.pressHeaders(BASE);
87
+ const nonce = H['x-pmos-nonce'];
88
+
89
+ /* B the Board reader */
90
+ const P = await open('/premium-board.html'), p = P.page;
91
+ ok('B1 a board document with a file is a button that opens the reader', await until(() => p.evaluate((k) => !!document.querySelector(`#docBody [data-doc="${k}"]`), bkey)));
92
+ ok('B1 a document with no file is not', await p.evaluate((k) => !document.querySelector('#docBody .dmo:not(button)') || [...document.querySelectorAll('#docBody .dmo:not(button)')].every((x) => !x.closest('.dmr').querySelector(`[data-doc="${k}"]`)), bkey));
93
+ await p.click(`#docBody [data-doc="${bkey}"]`); await dlgOn(p);
94
+ ok('B2 the reader shows the file\'s text and path, and the bar says nothing is sent', await until(() => p.evaluate((pt) => { const o = document.querySelector('#oMain'); return /Why this board exists/.test(o.textContent) && o.textContent.includes(pt) && !!o.querySelector('[data-issue-bar="draft"]') && /Nothing is sent/.test(o.querySelector('[data-issue-bar]').textContent) && !!o.querySelector('[data-rd="issue"]'); }, d1.path)), await p.evaluate(() => document.querySelector('#oMain').textContent));
95
+ ok('B2 the reader has no Edit tab', await p.evaluate(() => !document.querySelector('#oMain [data-sh]')));
96
+ const n0 = ledger().filter((l) => l.ev === 'issue').length;
97
+ await p.click('[data-rd="issue"]');
98
+ ok('B3 Issue it says it sent nothing', !!(await toastIs(p, /Issued\. Nothing was sent to anyone/)));
99
+ const sent = P.posts.filter((x) => x.path === '/api/core-docs/issue');
100
+ ok('B4 it posted the workspace, the scope, the key and the slot, and nothing else, with the launch nonce', sent.length === 1 && Object.keys(sent[0].body).sort().join() === 'key,scope,slot,ws' && sent[0].body.scope === bscope && sent[0].body.key === bkey && sent[0].body.slot === d1.slot && sent[0].body.ws === B.ws && sent[0].headers['x-pmos-nonce'] === nonce && !!nonce, JSON.stringify(sent));
101
+ const il = ledger().filter((l) => l.ev === 'issue');
102
+ ok('B5 the ledger has one new issue line for that draft, written by the PM', il.length === n0 + 1 && il[il.length - 1].slot === d1.slot && il[il.length - 1].scope === bscope && /pm/.test(String(il[il.length - 1].by)), JSON.stringify(il));
103
+ ok('B5 the file now says state: issued', /^state: issued$/m.test(fs.readFileSync(path.join(team, d1.path), 'utf8')));
104
+ ok('B6 the reader says it is issued, the Issue it press is gone, and the row reads Up to date', await until(() => p.evaluate(() => { const o = document.querySelector('#oMain'); return !!o.querySelector('[data-issue-bar="done"]') && !o.querySelector('[data-rd="issue"]') && /state: issued|issued/.test(o.textContent); })) && await until(() => p.evaluate((k) => { const r = document.querySelector(`#docBody [data-doc="${k}"]`); return r && /Up to date/.test(r.textContent); }, bkey)));
105
+ await p.screenshot({ path: path.join(R.base, 'board-issued.png') });
106
+ await P.ctx.close();
107
+
108
+ /* I the initiative sheet */
109
+ const I = await open('/premium-initiative.html' + iq), ip = I.page;
110
+ await until(() => ip.evaluate((k) => !!document.querySelector(`#dmList [data-doc="${k}"]`), ikey), 60000);
111
+ await ip.click(`#dmList [data-doc="${ikey}"]`); await dlgOn(ip);
112
+ ok('I1 the Read tab of a draft has the Issue it bar above the text', await until(() => ip.evaluate(() => { const o = document.querySelector('#oMain'); const b = o.querySelector('[data-issue-bar="draft"]'); return !!b && /Nothing is sent/.test(b.textContent) && /Why this board exists/.test(o.textContent) && b.compareDocumentPosition(o.querySelector('.dsbody')) & Node.DOCUMENT_POSITION_FOLLOWING; })));
113
+ await ip.click('[data-sh="edit"]');
114
+ await until(() => ip.evaluate(() => !!document.querySelector('#dsEd')));
115
+ await ip.fill('#dsEd', BODY + '\n## Added\n\nUnsaved line.\n');
116
+ await ip.click('[data-sh="read"]');
117
+ await until(() => ip.evaluate(() => !!document.querySelector('[data-ds="issue"]')));
118
+ const nI = I.posts.length;
119
+ await ip.click('[data-ds="issue"]');
120
+ ok('I2 Issue it with unsaved edits posts nothing and says to save or cancel first', await until(() => ip.evaluate(() => /unsaved changes.*Save or cancel/.test((document.querySelector('#dsErr') || {}).textContent || ''))) && I.posts.length === nI);
121
+ ok('I2 the ledger has no issue line for that draft yet', !ledger().some((l) => l.ev === 'issue' && l.slot === d2.slot && l.scope === iscope));
122
+ await ip.click('[data-sh="edit"]'); await until(() => ip.evaluate(() => !!document.querySelector('[data-ds="discard"]')));
123
+ await ip.click('[data-ds="discard"]'); await ip.click('[data-sh="read"]');
124
+ await until(() => ip.evaluate(() => !!document.querySelector('[data-ds="issue"]')));
125
+ /* a refusal: someone else issues the same draft first (the console, a second tab) */
126
+ const raced = await fetch(BASE + '/api/core-docs/issue', { method: 'POST', headers: H, body: JSON.stringify({ ws: B.ws, scope: iscope, key: ikey, slot: d2.slot }) });
127
+ ok('I3 setup the draft is issued behind the page\'s back', raced.status === 200);
128
+ await ip.click('[data-ds="issue"]');
129
+ ok('I3 a refused press shows the server\'s words and the sheet changes nothing else', await until(() => ip.evaluate(() => /already/.test((document.querySelector('#dsErr') || {}).textContent || ''))));
130
+ ok('I3 the refusal wrote no second issue line', ledger().filter((l) => l.ev === 'issue' && l.slot === d2.slot && l.scope === iscope).length === 1);
131
+ await ip.click('#dlg [data-act="close"], #dClose').catch(() => {});
132
+ await I.ctx.close();
133
+
134
+ /* I4 a fresh page: press Issue it on the third draft */
135
+ const J = await open('/premium-initiative.html' + iq), jp = J.page;
136
+ const k3 = d3.path.split('/').slice(-2)[0];
137
+ await until(() => jp.evaluate((k) => !!document.querySelector(`#dmList [data-doc="${k}"]`), k3), 60000);
138
+ await jp.click(`#dmList [data-doc="${k3}"]`); await dlgOn(jp);
139
+ await until(() => jp.evaluate(() => !!document.querySelector('[data-ds="issue"]')));
140
+ await jp.click('[data-ds="issue"]');
141
+ ok('I4 Issue it works from the sheet: the toast, the issued bar, and the row reads Up to date', !!(await toastIs(jp, /Issued\. Nothing was sent to anyone/)) && await until(() => jp.evaluate(() => !!document.querySelector('#oMain [data-issue-bar="done"]') && !document.querySelector('[data-ds="issue"]'))) && await until(() => jp.evaluate((k) => /Up to date/.test((document.querySelector(`#dmList [data-doc="${k}"]`) || {}).textContent || ''), k3)));
142
+ ok('I4 the file says state: issued and the ledger has its issue line', /^state: issued$/m.test(fs.readFileSync(path.join(team, d3.path), 'utf8')) && ledger().some((l) => l.ev === 'issue' && l.slot === d3.slot && l.scope === iscope));
143
+ await jp.screenshot({ path: path.join(R.base, 'ini-issued.png') });
144
+
145
+ /* P the POST allow-list and the refusals */
146
+ const all = P.posts.concat(I.posts, J.posts);
147
+ const other = all.filter((x) => !ALLOWED.test(x.path));
148
+ ok('P1 the pages post only to the issue route (and the conversation note)', all.length >= 3 && !other.length, JSON.stringify(other));
149
+ const sentAll = all.filter((x) => x.path === '/api/core-docs/issue');
150
+ ok('P2 every issue press carried the nonce and no writer field', sentAll.length >= 3 && sentAll.every((x) => x.headers['x-pmos-nonce'] === nonce && !['by', 'via', 'at', 'actor', 'pm', 'nonce'].some((k) => k in x.body)));
151
+ const bare = await fetch(BASE + '/api/core-docs/issue', { method: 'POST', headers: { 'Content-Type': 'application/json', Origin: BASE }, body: JSON.stringify({ ws: B.ws, scope: bscope, key: bkey, slot: d1.slot }) });
152
+ ok('P3 a press without the launch nonce is refused', bare.status === 403);
153
+ const agent = await fetch(BASE + '/api/core-docs/issue', { method: 'POST', headers: { ...H, 'x-pmos-session': 's1' }, body: JSON.stringify({ ws: B.ws, scope: bscope, key: bkey, slot: d1.slot }) });
154
+ ok('P4 an agent session gets 403', agent.status === 403);
155
+ ok('P5 no script error on any page', !P.errors.length && !I.errors.length && !J.errors.length, P.errors.concat(I.errors, J.errors).join(' | '));
156
+ await J.ctx.close();
157
+
158
+ /* F floors and fidelity: a fresh draft, at 390 and 1280, light and dark */
159
+ const d4 = CD.writeDraft(team, { scope: bscope, key: (board2.model.docs.rows.filter((d) => d.act && d.act.kind === 'draft' && d.st === 'missing' && d.key !== bkey)[0] || {}).key, markdown: BODY, by: 'agent:test', now: Date.now() });
160
+ const k4 = d4.path.split('/').slice(-2)[0];
161
+ for (const [w, h, theme] of [[390, 844, 'light'], [390, 844, 'dark'], [1280, 900, 'dark']]) {
162
+ const S = await open('/premium-board.html', { w, h, theme });
163
+ await until(() => S.page.evaluate((k) => !!document.querySelector(`#docBody [data-doc="${k}"]`), k4), 60000);
164
+ await S.page.click(`#docBody [data-doc="${k4}"]`); await dlgOn(S.page);
165
+ await until(() => S.page.evaluate(() => !!document.querySelector('[data-rd="issue"]')));
166
+ const f = await S.page.evaluate(() => ({ wide: document.documentElement.scrollWidth > innerWidth + 1, small: [...document.querySelectorAll('#oMain [data-rd]')].filter((b) => b.getBoundingClientRect().height < 44 || b.getBoundingClientRect().width < 44).map((b) => b.dataset.rd), bg: getComputedStyle(document.querySelector('[data-issue-bar]')).backgroundColor }));
167
+ ok(`F1 ${w} px ${theme}: no sideways scroll and the bar's buttons are at least 44 px`, !f.wide && !f.small.length, JSON.stringify(f));
168
+ await S.page.screenshot({ path: path.join(R.base, `bar-${w}-${theme}.png`) });
169
+ await S.ctx.close();
170
+ }
171
+ if (process.env.KEEP_SHOTS) { for (const f of fs.readdirSync(R.base).filter((x) => /\.png$/.test(x))) fs.copyFileSync(path.join(R.base, f), path.join(process.env.KEEP_SHOTS, f)); }
172
+ finish();
173
+ })();