create-pmos 0.558.0 → 0.560.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.
Files changed (38) hide show
  1. package/package.json +27 -39
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-adddoc-test.js +8 -6
  7. package/workspace/briefing-premium-calendar-3-test.js +18 -6
  8. package/workspace/changelog.json +26 -0
  9. package/workspace/fixtures/board-premium-facts.js +2 -12
  10. package/workspace/guide/programs.md +2 -2
  11. package/workspace/lib/board-premium.js +3 -22
  12. package/workspace/lib/core-docs-needs.js +12 -16
  13. package/workspace/lib/core-docs.js +27 -214
  14. package/workspace/lib/coredoc-cli.js +6 -6
  15. package/workspace/lib/custom-docs.js +3 -1
  16. package/workspace/lib/job-graph.js +2 -2
  17. package/workspace/lib/notes-capture.js +15 -1
  18. package/workspace/lib/refresh.js +2 -2
  19. package/workspace/lib/route-modules.js +0 -1
  20. package/workspace/lib/routes-board-premium.js +5 -11
  21. package/workspace/lib/routes-core-docs.js +23 -113
  22. package/workspace/lib/routes-custom-docs.js +8 -6
  23. package/workspace/lib/routes-notes.js +9 -2
  24. package/workspace/package-lock.json +2 -2
  25. package/workspace/package.json +1 -1
  26. package/workspace/premium-core-doc-issue-test.js +11 -18
  27. package/workspace/public/pm/bd-acts.js +5 -77
  28. package/workspace/public/pm/bd-prog.js +4 -5
  29. package/workspace/public/pm/bd-views.js +4 -56
  30. package/workspace/public/pm/cozy-board.css +2 -24
  31. package/workspace/public/pm/home-app.js +2 -3
  32. package/workspace/public/pm/premium-board.js +6 -24
  33. package/workspace/public/pm/premium-shell.js +3 -33
  34. package/workspace/public/pm/prog-page.js +1 -1
  35. package/workspace/ready-dash-ui-test.js +1 -1
  36. package/workspace/server.js +3 -12
  37. package/workspace/test-lists/uncovered-board.json +1 -1
  38. package/workspace/lib/routes-board-docs.js +0 -46
@@ -1,8 +1,11 @@
1
1
  'use strict';
2
- /* core-docs.js — the core documents of each level: Portfolio, Board and Initiative (initiative core-documents, PRD sections 1 to 4).
2
+ /* core-docs.js — the core documents of an initiative (initiative core-documents, PRD sections 1 to 4).
3
+ * PORTFOLIO AND BOARD DOCUMENTS ARE RETIRED (feedback batch 29 item 8, Wawan 2026-11-10): their 21 kinds are gone from SETS, and a
4
+ * write, a gather or a draft on a portfolio or board scope is refused (410). The documents already written stay readable: the ledger keeps
5
+ * their lines, fold() and storeOf() still read them, and their files under <state>/core-docs/portfolio and board-<id> are never touched.
3
6
  * THE ONE WRITER and THE ONE FOLD of <state>/core-docs.jsonl and of the documents under <state>/core-docs/.
4
7
  *
5
- * LEVELS · LEVEL · SETS · CATS · BY · KINDS
8
+ * LEVELS · RETIRED_LEVELS · RETIRED · LEVEL · SETS · CATS · BY · KINDS
6
9
  * entryOf(level, key) · levelOfScope(scope) · parseScope(scope) · scopeDir(scope) · draftable(entry)
7
10
  * setFor(level, { build, wfTpl, has }) the entries of one level, after the build-only and research-only filters
8
11
  * stateOf(entry, facts) → { st, when, due, flag, staleWhy, open, draft } PURE: `facts.now` is the clock
@@ -17,15 +20,14 @@
17
20
  *
18
21
  * THE SETS are the approved mockup's (mockup-c3-doc-levels 43-doc-levels.js): every title, `for`, reader, cadence, `by` and `isNew` is its copy.
19
22
  * `kind` says where the document lives: doc (a core document of its own, in this store), derived (read from a source PMOS already keeps),
20
- * live (a tab of the board), report (a recurring report on a dashboard). `days` is the cadence of a doc in days; `rollup` names the initiative
21
- * documents a rolled-up document collects.
23
+ * report (a recurring report on a dashboard). `days` is the cadence of a doc in days.
22
24
  *
23
25
  * STATE. Nothing is guessed: an entry with no source and no document is `missing`, with no date. `when` is the day of the last change, `due` the
24
26
  * next due day, both YYYY-MM-DD. `flag` is one short warning a source gives (a tripped kill condition, an agent's check), never invented. `open`
25
- * is where a press goes: { path } (document sheet), { tab } (board tab), { tool } (initiative Overview tool), { reports: true }, or null.
27
+ * is where a press goes: { path } (document sheet), { tool } (initiative Overview tool), { reports: true }, or null.
26
28
  *
27
29
  * THE LEDGER. <state>/core-docs.jsonl, <state> = report-draft.js stateRel(root). Lines { v: 1, ev: draft|issue|drop, scope, key, slot, path, by, at }.
28
- * `scope` is portfolio, board:<id> or initiative:<id>; `by` is the actor of the call path (lib/actor.js), never an argument. The documents are
30
+ * `scope` is initiative:<id> (portfolio and board:<id> on the retired lines); `by` is the actor of the call path (lib/actor.js), never an argument. The documents are
29
31
  * <state>/core-docs/<scope with : as ->/<key>/<slot>.md with frontmatter type, title, timestamp, core_doc, scope, state (draft | issued).
30
32
  * A draft is never sent anywhere. Only a PM press issues or drops one (lib/routes-core-docs.js, lib/driver-decide.js Keep).
31
33
  */
@@ -34,45 +36,21 @@ const path = require('path');
34
36
 
35
37
  const LEDGER = 'core-docs.jsonl';
36
38
  const DIR = 'core-docs';
37
- const LEVELS = Object.freeze(['portfolio', 'board', 'initiative']);
39
+ const LEVELS = Object.freeze(['initiative']);
40
+ /** The levels whose documents are retired: their scopes still parse (old ledger lines), but nothing writes or derives them. */
41
+ const RETIRED_LEVELS = Object.freeze(['portfolio', 'board']);
42
+ const RETIRED = 'PMOS no longer drafts portfolio or board documents. The product page\'s story, Intent and goals cover them, and the ones already written stay readable.';
38
43
  const CATS = Object.freeze(['Discover', 'Plan', 'Do', 'Learn']);
39
- const KINDS = Object.freeze(['doc', 'derived', 'live', 'report']);
44
+ const KINDS = Object.freeze(['doc', 'derived', 'report']);
40
45
  const EVENTS = Object.freeze(['draft', 'issue', 'drop']);
41
46
  const BY = Object.freeze({ you: 'You write it', proposes: 'PMOS proposes', drafts: 'PMOS drafts it', files: 'PMOS files it', watches: 'PMOS watches it',
42
47
  keeps: 'PMOS keeps it current', live: 'Live view', reviews: 'PMOS reviews, you accept' });
43
48
  const LEVEL = Object.freeze({
44
- portfolio: Object.freeze({ question: 'Are we betting on the right things?', reader: 'leadership', rhythm: 'quarterly, with a monthly pulse' }),
45
- board: Object.freeze({ question: 'Is this area moving, and what comes next?', reader: 'the board owner, the team and the engineering lead', rhythm: 'every sprint or two weeks' }),
46
49
  initiative: Object.freeze({ question: 'What are we building, why, and did it work?', reader: 'the PM, the builders and the reviewers', rhythm: 'at each stage' }),
47
50
  });
48
51
 
49
52
  const e = (level, o) => Object.freeze({ level, reader: null, cadence: null, build: false, cat: null, isNew: false, days: null, rollup: null, tool: null, store: false, ...o });
50
53
  const SETS = Object.freeze({
51
- portfolio: Object.freeze([
52
- e('portfolio', { key: 'strategy', title: 'Product strategy', ic: 'target', for: 'Vision, where we play and what we will not do. Every board and key result traces to it.', reader: 'Leadership, every PM', cadence: 'Yearly, reviewed each quarter', by: 'proposes', kind: 'doc', days: 91, isNew: true }),
53
- e('portfolio', { key: 'okrs', title: 'OKRs and health budgets', ic: 'flag', for: 'The key results initiatives anchor to, and the budgets maintenance work runs on.', reader: 'Leadership, PMs', cadence: 'Quarterly', by: 'proposes', kind: 'derived', store: true, days: 91 }),
54
- e('portfolio', { key: 'roadmap', title: 'Portfolio roadmap', ic: 'cal', for: 'Bets by quarter (Now, Next, Later) and the key result each serves. A sendable copy of the Roadmap.', reader: 'Leadership, stakeholders', cadence: 'Monthly', by: 'drafts', kind: 'doc', days: 30 }),
55
- e('portfolio', { key: 'invest', title: 'Investment mix', ic: 'cols', for: 'Where the effort goes: by board, by key result, and feature work against upkeep.', reader: 'Leadership', cadence: 'Quarterly', by: 'drafts', kind: 'doc', days: 91, isNew: true }),
56
- e('portfolio', { key: 'scan', title: 'Horizon scan reports', ic: 'search', for: 'Benchmark, competitive, insight and productivity reports, each with proposals.', reader: 'PMs, leadership', cadence: 'Weekly scan', by: 'drafts', kind: 'derived' }),
57
- e('portfolio', { key: 'status', title: 'Portfolio status report', ic: 'report', for: 'One page: progress on key results, what changed, what needs a decision.', reader: 'Leadership', cadence: 'Every two weeks', by: 'drafts', kind: 'report' }),
58
- e('portfolio', { key: 'decisions', title: 'Decision log', ic: 'scale', for: 'Decisions that cross boards, and why they were made.', reader: 'Everyone', cadence: 'As decided', by: 'files', kind: 'derived', store: true }),
59
- e('portfolio', { key: 'kill', title: 'Kill conditions', ic: 'x', for: 'The result that would make us stop a bet.', reader: 'Leadership', cadence: 'Quarterly', by: 'watches', kind: 'derived', store: true }),
60
- e('portfolio', { key: 'prisks', title: 'Cross-board risks', ic: 'alert', for: 'The few risks that span boards, rolled up from the risks each initiative records.', reader: 'Leadership, board owners', cadence: 'Monthly', by: 'drafts', kind: 'doc', days: 30, rollup: 'risks', isNew: true }),
61
- e('portfolio', { key: 'quarter', title: 'Quarterly review', ic: 'up', for: 'What landed, what moved the key results, and what we learned. Built from outcome reviews.', reader: 'Leadership', cadence: 'Quarterly', by: 'drafts', kind: 'doc', days: 91, rollup: 'outcome', isNew: true }),
62
- e('portfolio', { key: 'context', title: 'Market and user context', ic: 'notes', for: 'Jobs to be done, the market map and the research behind them.', reader: 'PMs', cadence: 'When research lands', by: 'keeps', kind: 'derived', store: true }),
63
- ]),
64
- board: Object.freeze([
65
- e('board', { key: 'charter', title: 'Board charter', ic: 'flag', for: 'Why this board exists: purpose, owner, the key results it serves, scope in and out, how work flows.', reader: 'Owner, team, new joiners', cadence: 'When the board changes', by: 'drafts', kind: 'doc', isNew: true }),
66
- e('board', { key: 'backlog', title: 'Roadmap and backlog', ic: 'todo', for: 'Initiatives by rank, stage and owner.', reader: 'Team, stakeholders', cadence: 'Live', by: 'live', kind: 'live' }),
67
- e('board', { key: 'intake', title: 'Intake log', ic: 'inbox', for: 'Asks received, accepted or declined, and why.', reader: 'Owner, requesters', cadence: 'Live', by: 'live', kind: 'live' }),
68
- e('board', { key: 'bstatus', title: 'Board status report', ic: 'report', for: 'Progress, slips, asks and what needs a decision, for the owner\'s manager.', reader: 'Stakeholders', cadence: 'Every two weeks', by: 'drafts', kind: 'report' }),
69
- e('board', { key: 'capacity', title: 'Capacity plan', ic: 'user', for: 'Who works on the board, their points a week, and whether the plan fits.', reader: 'Owner, eng lead', cadence: 'Each sprint', by: 'drafts', kind: 'doc', days: 14, isNew: true }),
70
- e('board', { key: 'metrics', title: 'Board metrics', ic: 'up', for: 'The few numbers this board moves, with one definition each.', reader: 'Team', cadence: 'Quarterly', by: 'keeps', kind: 'doc', days: 91 }),
71
- e('board', { key: 'brisks', title: 'Board risks', ic: 'alert', for: 'Risks on this board\'s initiatives and the waits on other boards. Written on each initiative, collected here.', reader: 'Owner', cadence: 'Every two weeks', by: 'drafts', kind: 'doc', days: 14, rollup: 'risks', isNew: true }),
72
- e('board', { key: 'sprint', title: 'Sprint review', ic: 'clock', for: 'What the sprint committed and finished, what slipped and why.', reader: 'Team, stakeholders', cadence: 'Each sprint', by: 'drafts', kind: 'doc', days: 14, build: true, isNew: true }),
73
- e('board', { key: 'release', title: 'Release notes', ic: 'out', for: 'What each release holds, every line cited.', reader: 'Team, support, customers', cadence: 'Each release', by: 'drafts', kind: 'derived', build: true }),
74
- e('board', { key: 'retro', title: 'Board retro', ic: 'undo', for: 'Patterns across this board\'s initiatives, from their learnings and outcome reviews.', reader: 'Team', cadence: 'Quarterly', by: 'drafts', kind: 'doc', days: 91, rollup: 'outcome', isNew: true }),
75
- ]),
76
54
  initiative: Object.freeze([
77
55
  e('initiative', { key: 'record', title: 'Initiative record', ic: 'init', cat: 'Discover', for: 'Identity, anchor, lane and stage, with links to everything else. The gate checks it.', by: 'drafts', kind: 'derived' }),
78
56
  e('initiative', { key: 'problem', title: 'Problem statement', ic: 'notes', cat: 'Discover', for: 'The problem, who has it and the evidence.', by: 'drafts', kind: 'derived', tool: 'problem' }),
@@ -138,9 +116,6 @@ const draftable = (entry) => !!entry && entry.kind === 'doc' && entry.by !== 'yo
138
116
  /** A derived entry with `store` (the OKRs, the decision log, kill conditions, market context) is read from its own source, and PMOS may propose
139
117
  * it as a core document while that source is absent. */
140
118
  const storable = (entry) => !!entry && (entry.kind === 'doc' || !!entry.store);
141
- /** A derived entry that fills as the work goes: with no source yet it is "none", not missing (portfolio and board only). */
142
- const FILLS = Object.freeze(['files', 'watches', 'keeps']);
143
-
144
119
  /** D99: an initiative's document plan. Product feature (or no library workflow): null, and the fixed set with its categories applies.
145
120
  * A library workflow: one entry per stage whose output is a document, under that stage; the initiative record (under the first stage)
146
121
  * and the status update (under the first In progress stage) stay for every workflow. Entries of a skipped stage are left out unless
@@ -174,7 +149,6 @@ function WF() { return WF_MOD || (WF_MOD = require(require('./repo-script.js').r
174
149
  * initiative already has that document (a build-only entry it has stays). */
175
150
  function setFor(level, { build = true, wfTpl = null, has = () => false } = {}) {
176
151
  const list = SETS[level] || [];
177
- if (level === 'board') return list.filter((x) => !x.build || build);
178
152
  if (level === 'initiative') {
179
153
  return list.filter((x) => (wfTpl !== 'research' || RESEARCH_KEEP.includes(x.key)) && (build || !BUILD_ONLY_INI.includes(x.key) || has(x.key)));
180
154
  }
@@ -182,8 +156,8 @@ function setFor(level, { build = true, wfTpl = null, has = () => false } = {}) {
182
156
  }
183
157
 
184
158
  // ── the state of one entry (pure) ────────────────────────────────────────────────────────────────────
185
- /* facts: { now, scope, level, store: fold(), cat (initiative: the current category), board: { changedAt } | null, movedAt (ms|null),
186
- * sources: { [key]: { when, open, flag, draft, next, nextDue, issued } | null }, rollups: { risks: [ms], outcome: [ms] }, flags: { [key]: text } } */
159
+ /* facts: { now, scope, level, store: fold(), cat (the current category), movedAt (ms|null),
160
+ * sources: { [key]: { when, open, flag, draft, next, nextDue, issued } | null }, flags: { [key]: text } } */
187
161
  function catState(entry, facts) {
188
162
  const order = facts.order || CATS;
189
163
  const cur = order.indexOf(facts.cat);
@@ -210,13 +184,6 @@ function docState(entry, facts) {
210
184
  if (entry.level === 'initiative' && STALE_ON_MOVE.includes(entry.key) && facts.movedAt != null && facts.movedAt > issuedAt) {
211
185
  return { ...base, st: 'stale', staleWhy: 'Stale since the stage move' };
212
186
  }
213
- if (entry.rollup) {
214
- const later = ((facts.rollups && facts.rollups[entry.rollup]) || []).filter((t) => t > issuedAt);
215
- if (later.length) return { ...base, st: 'stale', staleWhy: entry.rollup === 'risks' ? 'Stale since an initiative issued its risks' : 'Stale since an initiative issued its outcome review' };
216
- }
217
- if (entry.key === 'charter' && facts.board && facts.board.changedAt != null && facts.board.changedAt > issuedAt) {
218
- return { ...base, st: 'stale', staleWhy: 'Stale since the board settings changed' };
219
- }
220
187
  const due = dueOf();
221
188
  if (due && localDay(facts.now) >= due) return { ...base, st: 'due', due };
222
189
  return { ...base, st: 'ok', due };
@@ -225,7 +192,6 @@ function docState(entry, facts) {
225
192
  function sourceState(entry, facts) {
226
193
  const out = blank();
227
194
  const src = (facts.sources && facts.sources[entry.key]) || null;
228
- if (entry.kind === 'live') return { ...out, st: 'ok', open: { tab: entry.key === 'backlog' ? 'initiatives' : 'triage' } };
229
195
  if (entry.kind === 'report') {
230
196
  const open = { reports: true };
231
197
  if (!src) return { ...out, st: absent(entry, facts), open: entry.level === 'initiative' && catState(entry, facts) === 'later' ? null : open };
@@ -240,7 +206,6 @@ function sourceState(entry, facts) {
240
206
  }
241
207
  // derived
242
208
  if (!src && entry.store) return docState(entry, facts);
243
- if (!src && entry.level !== 'initiative' && FILLS.includes(entry.by)) return { ...out, st: 'none' };
244
209
  if (!src) return { ...out, st: absent(entry, facts), open: entry.tool && entry.level === 'initiative' && catState(entry, facts) !== 'later' ? { tool: entry.tool } : null };
245
210
  const res = { ...out, st: src.st || 'ok', when: src.when || null, due: src.due || null, flag: src.flag || null, open: src.open || null };
246
211
  if (entry.level === 'initiative' && STALE_ON_MOVE.includes(entry.key) && src.atMs != null && facts.movedAt != null && facts.movedAt > src.atMs) {
@@ -303,13 +268,14 @@ const refuse = (status, error) => ({ ok: false, status, error });
303
268
  /** Check a scope and key for a write: a known scope form, a key of that level, a doc entry. */
304
269
  function checkEntry(scope, key) {
305
270
  const p = parseScope(scope);
306
- if (!p) return refuse(400, 'scope must be portfolio, board:<id> or initiative:<id>');
271
+ if (!p) return refuse(400, 'scope must be initiative:<id>');
272
+ if (RETIRED_LEVELS.includes(p.level)) return refuse(410, RETIRED);
307
273
  const entry = entryOf(p.level, key);
308
274
  if (!entry) return refuse(400, `key must be one of ${SETS[p.level].map((x) => x.key).join(', ')} for the ${p.level} level`);
309
275
  if (!storable(entry)) return refuse(400, `${entry.title} is not a document PMOS keeps here: it is read from its own source`);
310
276
  return { ok: true, entry, level: p.level, id: p.id };
311
277
  }
312
- const scopeLabel = (scope, label) => { const p = parseScope(scope); return !p ? String(scope) : p.level === 'portfolio' ? 'Portfolio' : (label || p.id); };
278
+ const scopeLabel = (scope, label) => { const p = parseScope(scope); return !p ? String(scope) : (label || p.id); };
313
279
  const yamlStr = (s) => JSON.stringify(String(s));
314
280
  function frontmatterOf(text) {
315
281
  const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(String(text || ''));
@@ -383,31 +349,6 @@ function drop(root, { scope, key, slot } = {}, actor, { now } = {}) {
383
349
  // ── the sources (I/O) ────────────────────────────────────────────────────────────────────────────────
384
350
  const statOf = (abs) => { try { return fs.statSync(abs); } catch { return null; } };
385
351
  const fileDay = (abs) => { const s = statOf(abs); return s && s.isFile() ? localDay(s.mtimeMs) : null; };
386
- /** The newest markdown file under one of `dirs` (relative), or null. */
387
- function newestMd(root, dirs) {
388
- let best = null;
389
- const walk = (rel, depth) => {
390
- let list = [];
391
- try { list = fs.readdirSync(path.join(root, rel), { withFileTypes: true }); } catch { return; }
392
- for (const d of list) {
393
- const r = `${rel}/${d.name}`;
394
- if (d.isDirectory() && depth < 3) walk(r, depth + 1);
395
- else if (d.isFile() && /\.md$/.test(d.name) && d.name !== 'index.md' && d.name !== 'log.md') {
396
- const s = statOf(path.join(root, r));
397
- if (s && (!best || s.mtimeMs > best.ms)) best = { rel: r, ms: s.mtimeMs };
398
- }
399
- }
400
- };
401
- for (const d of dirs) walk(d, 0);
402
- return best;
403
- }
404
- function readJsonl(file) {
405
- let text = '';
406
- try { text = fs.readFileSync(file, 'utf8'); } catch { return []; }
407
- const out = [];
408
- for (const raw of text.split('\n')) { if (!raw.trim()) continue; try { const l = JSON.parse(raw); if (isObj(l)) out.push(l); } catch { /* torn */ } }
409
- return out;
410
- }
411
352
 
412
353
  /** The recurring report on `source` (dashboard:<key>): its newest document, its last issue and its next draft. Null when none is set up. */
413
354
  function reportSource(root, source, now, cache) {
@@ -440,17 +381,6 @@ function flagsOf(root, store, scope) {
440
381
  return out;
441
382
  }
442
383
 
443
- /** The ms of each issue of an initiative document `key` (risks, outcome), optionally only for the initiatives in `ids`. */
444
- function rollupOf(store, key, ids) {
445
- const out = [];
446
- for (const x of store.values()) {
447
- if (x.key !== key || !x.scope.startsWith('initiative:')) continue;
448
- if (ids && !ids.has(x.scope.slice('initiative:'.length))) continue;
449
- for (const l of x.issues) out.push(msOf(l.at));
450
- }
451
- return out;
452
- }
453
-
454
384
  function stateDirOf(ctx, w) { try { return ctx.stateDirFor ? ctx.stateDirFor(w) : null; } catch { return null; } }
455
385
  function stageToolsOf(ctx, w) {
456
386
  const dir = stateDirOf(ctx, w);
@@ -458,77 +388,6 @@ function stageToolsOf(ctx, w) {
458
388
  const st = require('./stage-tools.js');
459
389
  return st.readLedger(path.join(dir, st.LEDGER));
460
390
  }
461
- function releasesOf(ctx) {
462
- if (!ctx.runtimeDir) return [];
463
- try {
464
- const { repoScript } = require('./repo-script.js');
465
- return require(repoScript('releases.js')).foldReleases(fs.readFileSync(path.join(ctx.runtimeDir, 'releases', 'releases.jsonl'), 'utf8').split('\n').filter(Boolean));
466
- } catch { return []; }
467
- }
468
-
469
- function portfolioSources(ctx, w, store, now) {
470
- const root = w.root;
471
- const cache = {};
472
- const src = {};
473
- const okr = newestMd(root, ['planning/okrs']);
474
- src.okrs = okr ? { when: localDay(okr.ms), open: { path: okr.rel } } : null;
475
- const ctxDoc = newestMd(root, ['planning/radar', 'planning/research']);
476
- src.context = ctxDoc ? { when: localDay(ctxDoc.ms), open: { path: ctxDoc.rel } } : null;
477
- src.decisions = null;
478
- for (const rel of ['DECISIONS.md', 'planning/records/decisions.jsonl', 'pmos/state/records/decisions.jsonl']) {
479
- const d = fileDay(path.join(root, rel));
480
- if (d) { src.decisions = { when: d, open: /\.md$/.test(rel) ? { path: rel } : null }; break; }
481
- }
482
- try { cache.reports = require('./report-needs.js').reportsOf(root).reports; } catch { cache.reports = []; }
483
- const scans = cache.reports.filter((r) => /^scan-/.test(r.cadence)).sort((a, b) => (a.slot < b.slot ? 1 : -1));
484
- src.scan = scans.length ? { when: scans[0].slot.slice(0, 10), open: { reports: true } } : null;
485
- const tools = stageToolsOf(ctx, w);
486
- let killAt = null; let tripped = 0;
487
- for (const m of tools.values()) {
488
- const k = m.get('kill');
489
- if (!k) continue;
490
- if (k.at && (!killAt || k.at > killAt)) killAt = k.at;
491
- tripped += ((k.data && k.data.items) || []).filter((i) => i.status === 'tripped').length;
492
- }
493
- src.kill = killAt ? { when: localDay(msOf(killAt)), flag: tripped ? `${tripped} tripped` : null } : null;
494
- src.status = reportSource(root, 'dashboard:portfolio', now, cache);
495
- return { sources: src, rollups: { risks: rollupOf(store, 'risks', null), outcome: rollupOf(store, 'outcome', null) } };
496
- }
497
-
498
- /** The ids of the initiatives on a board, or null while the rows are still being read. */
499
- function boardIds(ctx, w, fr, boardId) {
500
- const boards = require('./routes-boards.js');
501
- let got;
502
- try { got = boards.baseRows(w); } catch { return null; }
503
- if (!got || !got.ok) return null;
504
- return new Set(got.rows.filter((r) => boards.boardIdOf(r, fr.boards, fr.folded, w) === boardId).map((r) => r.id));
505
- }
506
- function boardChangedAt(ctx, w, boardId) {
507
- const dir = stateDirOf(ctx, w);
508
- if (!dir) return null;
509
- let at = null;
510
- for (const l of readJsonl(path.join(dir, 'boards.jsonl'))) {
511
- if (l.board !== boardId || !['board', 'workflow'].includes(l.kind)) continue;
512
- const t = msOf(l.at);
513
- if (Number.isFinite(t) && (at == null || t > at)) at = t;
514
- }
515
- return at;
516
- }
517
- function boardSources(ctx, w, board, ids, store, now) {
518
- const src = {};
519
- src.bstatus = reportSource(w.root, `dashboard:board:${board.id}`, now, {});
520
- if (board.build) {
521
- const mine = ids ? releasesOf(ctx).filter((r) => (r.initiative_ids || []).some((x) => ids.has(x))) : [];
522
- const today = localDay(now);
523
- const dayOf = (r) => { const at = r.release_at || r.deploy_at; return at ? String(at).slice(0, 10) : null; };
524
- const past = mine.filter((r) => dayOf(r) && dayOf(r) <= today).sort((a, b) => (dayOf(a) < dayOf(b) ? 1 : -1));
525
- const next = mine.filter((r) => dayOf(r) && dayOf(r) > today && !(r.summary || []).length).sort((a, b) => (dayOf(a) < dayOf(b) ? -1 : 1))[0] || null;
526
- // Notes are due before a release that has none yet; with no release at all there is nothing to write notes for.
527
- src.release = past.length || next ? { st: next ? 'due' : 'ok', when: past.length ? dayOf(past[0]) : null, due: next ? dayOf(next) : null, open: { tab: 'releases' } } : null;
528
- }
529
- return { sources: src, rollups: { risks: rollupOf(store, 'risks', ids || new Set()), outcome: rollupOf(store, 'outcome', ids || new Set()) } };
530
- }
531
-
532
391
  /** What an initiative has, from its record, the stage tools, its artifacts and the report setups. → sources by key. */
533
392
  function initiativeSources(ctx, w, base, extra, now) {
534
393
  const root = w.root;
@@ -603,7 +462,7 @@ function initiativeSet(w, { row, base, board, folded, store, extra, now, ctx })
603
462
  const has = (k) => !!sources[k] || !!(store.get(`${scope}|${k}`) && (store.get(`${scope}|${k}`).issued || store.get(`${scope}|${k}`).draft));
604
463
  // D99: an initiative on a library workflow lists its own stages' documents; the record always exists, so it never counts as "had" here
605
464
  const plan = row.wf && row.wf.id ? workflowPlan(WF().resolve(folded && folded.wfLib, row.wf.id), row, (k) => k !== 'record' && has(k)) : null;
606
- const facts = { now, scope, level: 'initiative', store, cat: plan ? plan.cur : row.cat, order: plan ? plan.order : null, movedAt: lastMoveOf(folded, row.id), sources, rollups: {}, flags: flagsOf(w.root, store, scope) };
465
+ const facts = { now, scope, level: 'initiative', store, cat: plan ? plan.cur : row.cat, order: plan ? plan.order : null, movedAt: lastMoveOf(folded, row.id), sources, flags: flagsOf(w.root, store, scope) };
607
466
  const prdRel = sources.prd && sources.prd.open ? sources.prd.open.path : null, memo = new Map();
608
467
  const list = plan ? plan.entries : setFor('initiative', { build: !!board.build, wfTpl: row.template || null, has });
609
468
  const out = list.map((x) => {
@@ -617,23 +476,11 @@ function initiativeSet(w, { row, base, board, folded, store, extra, now, ctx })
617
476
 
618
477
  /** The facts of one level. → { ok, facts } | { pending: true } | { ok: false, status, error } */
619
478
  function gather(ctx, w, { level, board: boardId, id, now = Date.now() } = {}) {
620
- if (!LEVELS.includes(level)) return refuse(400, 'level must be portfolio, board or initiative');
479
+ if (RETIRED_LEVELS.includes(level)) return refuse(410, RETIRED);
480
+ if (!LEVELS.includes(level)) return refuse(400, 'level must be initiative');
621
481
  const store = storeOf(w.root);
622
- if (level === 'portfolio') {
623
- const p = portfolioSources(ctx, w, store, now);
624
- return { ok: true, facts: { level, scope: 'portfolio', now, store, ...p, flags: flagsOf(w.root, store, 'portfolio'), entries: setFor('portfolio') } };
625
- }
626
482
  const RB = require('./routes-boards.js');
627
483
  const fr = RB.frameFor(ctx, w);
628
- if (level === 'board') {
629
- const board = fr.boards.find((b) => b.id === boardId);
630
- if (!board) return refuse(404, `no board ${String(boardId || '').slice(0, 80)} in this workspace`);
631
- const ids = boardIds(ctx, w, fr, board.id);
632
- const scope = `board:${board.id}`;
633
- const p = boardSources(ctx, w, board, ids, store, now);
634
- return { ok: true, facts: { level, scope, now, store, ...p, board: { id: board.id, name: board.name, build: !!board.build, changedAt: boardChangedAt(ctx, w, board.id) },
635
- flags: flagsOf(w.root, store, scope), entries: setFor('board', { build: !!board.build }) } };
636
- }
637
484
  if (!id || !ID_RE.test(String(id))) return refuse(400, 'id must be an initiative id');
638
485
  const got = RB.baseRows(w);
639
486
  if (got.pending) return { pending: true };
@@ -653,28 +500,24 @@ function actOf(entry, st) {
653
500
  if ((st === 'stale' || st === 'due') && draftable(entry)) return { label: 'Draft it', do: 'draft' };
654
501
  if (st !== 'missing' && st !== 'later') return null; // a document that does not exist yet can be drafted now, in its stage or ahead of it (testing fixes)
655
502
  if (draftable(entry)) return { label: 'Draft it', do: 'draft' };
656
- if (entry.store && entry.by !== 'you') return { label: entry.key === 'okrs' ? 'Propose them' : 'Propose it', do: 'draft' };
657
- if (entry.key === 'scan') return { label: 'Run a scan', go: 'scan' };
658
- if (entry.kind === 'report' && entry.level !== 'initiative') return { label: 'Set it up', go: 'reports' };
659
503
  return null;
660
504
  }
661
505
 
662
506
  /** The GET body. `running(scope, key)` → true while a core-doc run drafts that entry. */
663
507
  function answer(facts, { running = () => false } = {}) {
664
508
  const L = LEVEL[facts.level];
665
- const list = facts.level === 'initiative' ? facts.list : facts.entries.map((x) => ({ entry: x, ...stateOf(x, facts) }));
509
+ const list = facts.list;
666
510
  const docs = list.map(({ entry: x, st, when, due, flag, staleWhy, open, draft, from }) => ({
667
511
  key: x.key, title: x.title, ic: x.ic, for: x.for, reader: x.reader, cadence: x.cadence, by: x.by, kind: x.kind, cat: x.cat, isNew: !!x.isNew, ...(x.other ? { other: true } : {}),
668
512
  st, when: when || null, due: due || null, flag: flag || null, staleWhy: staleWhy || null, open: open || null, draft: draft || null,
669
513
  act: actOf(x, st), running: !!running(facts.scope, x.key), ...(from ? { from } : {}),
670
514
  }));
671
- const ini = facts.level === 'initiative';
672
515
  return {
673
516
  ok: true, level: facts.level, scope: facts.scope, question: L.question, reader: L.reader, rhythm: L.rhythm,
674
- build: facts.level === 'portfolio' ? null : !!(facts.board && facts.board.build),
675
- wfTpl: ini ? (facts.row.template || null) : null, stage: ini ? (facts.row.stage || null) : null, cat: ini ? (facts.plan ? facts.plan.cur : facts.row.cat || null) : null,
517
+ build: !!(facts.board && facts.board.build),
518
+ wfTpl: facts.row.template || null, stage: facts.row.stage || null, cat: facts.plan ? facts.plan.cur : facts.row.cat || null,
676
519
  // D99: the stage names the documents group under, in order (null: Product feature, grouped by CATS)
677
- ...(ini ? { phases: facts.plan ? facts.plan.order : null } : {}),
520
+ phases: facts.plan ? facts.plan.order : null,
678
521
  summary: summaryOf(docs), docs,
679
522
  };
680
523
  }
@@ -706,36 +549,6 @@ function driverLists(set) {
706
549
  // ── the core-doc run's prompt ────────────────────────────────────────────────────────────────────────
707
550
  const S = '<state>'; // the state folder, named in the prompt as the run sees it
708
551
  const GUIDE = Object.freeze({
709
- strategy: { sources: ['The issued product strategy, if any, under <state>/core-docs/portfolio/strategy/', 'planning/okrs/ (the key results and health budgets)', 'The board charters under <state>/core-docs/board-*/charter/', 'The boards and their initiatives with their anchors (`pmos board`, `pmos initiative list`)', 'The Horizon scan reports and the research under planning/radar/ and planning/research/, if any'],
710
- sections: ['A short line: this is a proposal for the PM to change, keep or drop; the PM issues the strategy', 'Where we are going', 'Where we play (one line per pillar, with its boards)', 'What we will not do', 'How we will know (a table: Pillar, Key results, Boards)'] },
711
- roadmap: { sources: ['`pmos initiative list` (every initiative with its Roadmap rank, lifecycle stage and anchor)', 'planning/okrs/ (the key results the bets serve)', 'The issued portfolio roadmap before this one, if any'],
712
- sections: ['Now (each bet, its board and the key result it serves)', 'Next', 'Later', 'What changed since the last roadmap'] },
713
- invest: { sources: ['`pmos initiative list` (anchors: key result or health budget)', 'The plan items and their points on every board (`pmos board`)', 'The people and their points a week (`pmos people list`)', 'The Jira snapshots under the state folder, if any (read-only)'],
714
- sections: ['Headline (two sentences: where the effort goes and the one thing to look at)', 'By board (a share of the effort per board)', 'Feature work against upkeep (key results against health budgets)', 'By pillar, when a product strategy is issued', 'Worth a look (key results with no effort, effort with no key result)'] },
715
- prisks: { sources: ['The issued risks of every initiative: <state>/core-docs/initiative-*/risks/', 'The issued board risks: <state>/core-docs/board-*/brisks/', 'Dependencies between plan items on different boards'],
716
- sections: ['One line: how many risks reach past one board', 'A table: Risk, Boards, From (the initiative ids), Owner, Since', 'What changed since the last month'] },
717
- quarter: { sources: ['The issued outcome reviews of this quarter: <state>/core-docs/initiative-*/outcome/', 'The key result readings (`pmos measure` records, planning/okrs/)', 'The learnings in the stage tools and the issued board retros: <state>/core-docs/board-*/retro/'],
718
- sections: ['Headline', 'Key results (a table: Key result, Start, End of quarter, Planned, Call)', 'What landed (a table: Initiative, Outcome, Moved)', 'What we learned', 'For next quarter'] },
719
- charter: { sources: ['The board settings in the boards ledger (<state>/boards.jsonl: Build and deliver, Jira projects, workflows offered)', 'The issued product strategy, if any', 'The anchors of the initiatives on this board (`pmos initiative list`)'],
720
- sections: ['Purpose', 'Owner and team (a table: Role, Person; write "not known" where the sources do not say)', 'Serves (pillar, key results, health budgets)', 'Scope (a table: In, Out)', 'How work flows (workflow, Build and deliver, Jira, how asks arrive)', 'Rhythm (status report, sprint review, retro)'] },
721
- capacity: { sources: ['The people and their points a week (`pmos people list`)', 'The plan items with points this sprint (`pmos board`)', 'The Jira sprint snapshot under the state folder, if any (read-only)'],
722
- sections: ['One line: the points the sprint holds against the points available', 'One line per person: points planned against points available, as a percentage', 'Proposal (moves that make the plan fit; each is a proposal only)', 'A last line: changes to Jira items are proposals, and nothing moves in Jira until the PM accepts them there'] },
723
- metrics: { sources: ['planning/okrs/ (the key results this board serves)', 'The KR metric records and their readings (planning/records/kr-metrics.jsonl, `pmos measure`)'],
724
- sections: ['The numbers this board moves (a table: Metric, Definition, Now, Target, Source)', 'Definitions that differ from another board, if any'] },
725
- brisks: { sources: ['The issued risks of the initiatives on this board: <state>/core-docs/initiative-<id>/risks/', 'Waits on other boards from the plan items'],
726
- sections: ['A table: Risk, Initiative, Impact, Next step, Owner', 'Waiting on other boards'] },
727
- sprint: { sources: ['The Jira sprint snapshot under the state folder (read-only)', 'The burndown of the sprint (the initiative Overview tool reads the same snapshot)', 'The plan items and PMOS tasks on this board (`pmos board`)'],
728
- sections: ['Headline (points committed and finished, as a percentage)', 'Finished', 'Carried over (a table: Item, Points, Why)', 'For the next sprint'] },
729
- retro: { sources: ['The learnings of the closed initiatives on this board (the stage tools)', 'Their issued outcome reviews: <state>/core-docs/initiative-<id>/outcome/', 'The issued sprint reviews: <state>/core-docs/board-<id>/sprint/'],
730
- sections: ['Patterns (each with the initiatives it comes from)', 'Keep, change, try (a table)'] },
731
- okrs: { sources: ['The product strategy, if one is issued: <state>/core-docs/portfolio/strategy/', 'The boards and their initiatives with their anchors (`pmos board`)', 'planning/okrs/health-budgets.md, if any', 'The KR metric records and their readings (planning/records/kr-metrics.jsonl, `pmos measure`), if any'],
732
- sections: ['A short line: these are proposals for the PM to change, keep or drop', 'Objectives, each with two to four key results (a table: Key result, Metric, Now, Target, Initiatives that serve it); write "not known" where no reading exists', 'Health budgets for upkeep work (a table: Budget, What it covers, Limit)', 'Initiatives with no key result to anchor to, if any'] },
733
- decisions: { sources: ['Meeting notes and their summaries in the state folder (decisions, agreed, chose, will not)', 'The initiative records and their stage moves, holds, cancels and merges (`pmos initiative list`)', 'The proposals the PM kept or dropped (the driver ledger), if any', 'The issued decision log before this one, if any: <state>/core-docs/portfolio/decisions/'],
734
- sections: ['A short line: these are decisions found in the sources, for the PM to keep, correct or drop', 'A table: Date, Decision, Why, Boards, Who decided, Source', 'Open questions that look like decisions still to make'] },
735
- kill: { sources: ['Every initiative with its bet, its anchor and its kill conditions, if any (`pmos initiative list`, the stage tools)', 'planning/okrs/ and the key result readings (`pmos measure` records), if any', 'The issued kill conditions before these, if any: <state>/core-docs/portfolio/kill/'],
736
- sections: ['A short line: these are proposed kill conditions for the PM to change, keep or drop; the PM writes them onto each initiative', 'A table: Initiative, Bet, Key result, Kill condition (a number and a date), Reading now', 'Bets with no key result to measure, if any'] },
737
- context: { sources: ['The research under planning/research/ and the Horizon scan reports under planning/radar/, if any', 'Meeting notes that name users, customers, competitors or the market', 'The problem statements and research notes of the initiatives (the stage tools)', 'The issued market and user context before this one, if any: <state>/core-docs/portfolio/context/'],
738
- sections: ['A short line: this is a proposal built from what PMOS has read, for the PM to change, keep or drop', 'Jobs to be done (a table: Who, Job, Evidence)', 'The market map (a table: Player, What they offer, Where we differ)', 'What we do not know yet'] },
739
552
  risks: { sources: ['The initiative record and every file it names (PRD, design, rubric)', 'The Jira snapshot of the initiative, if any (blocked and late tickets)', 'Meeting notes and requirement notes that name the initiative'],
740
553
  sections: ['A table: Risk, Impact (High, Medium, Low), Likelihood, Next step, Owner, Since', 'Waits on other boards, if any'] },
741
554
  outcome: { sources: ['The key result readings since the release (`pmos measure` records)', 'The release that shipped it (the releases ledger)', 'The initiative bet, its kill conditions and its learnings (the stage tools)', 'Support tickets and notes that name it, if any'],
@@ -827,8 +640,8 @@ function batchPrompt(entries, scope, { today, label } = {}) {
827
640
  }
828
641
 
829
642
  module.exports = {
830
- LEDGER, DIR, LEVELS, LEVEL, SETS, CATS, KINDS, EVENTS, BY, RESEARCH_KEEP, BUILD_ONLY_INI, STALE_ON_MOVE, ID_RE, SLOT_RE, GUIDE,
831
- entryOf, parseScope, levelOfScope, scopeDir, scopeLabel, draftable, storable, actOf, FILLS, setFor, stateOf, summaryOf, localDay, addDays,
643
+ LEDGER, DIR, LEVELS, RETIRED_LEVELS, RETIRED, LEVEL, SETS, CATS, KINDS, EVENTS, BY, RESEARCH_KEEP, BUILD_ONLY_INI, STALE_ON_MOVE, ID_RE, SLOT_RE, GUIDE,
644
+ entryOf, parseScope, levelOfScope, scopeDir, scopeLabel, draftable, storable, actOf, setFor, stateOf, summaryOf, localDay, addDays,
832
645
  ledgerFile, readLines, append, fold, storeOf, checkEntry, writeDraft, issue, drop, frontmatterOf,
833
646
  gather, answer, initiativeDocs, initiativeSet, workflowPlan, stageEntry, WF_KEY_RE, prdSection, driverLists, runPrompt, batchPrompt,
834
647
  };
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
- /* coredoc-cli.js — `pmos coredoc …`: the core documents of each level from a terminal (initiative core-documents, PRD sections 3 and 4).
2
+ /* coredoc-cli.js — `pmos coredoc …`: the core documents of an initiative from a terminal (initiative core-documents, PRD sections 3 and 4).
3
3
  *
4
- * pmos coredoc write --scope <portfolio|board:<id>|initiative:<id>> --key <key> --file <path|-> [--json] [--root <dir>]
4
+ * pmos coredoc write --scope initiative:<id> --key <key> --file <path|-> [--json] [--root <dir>]
5
5
  * writes ONE draft of a core document under <state>/core-docs/<scope>/<key>/<slot>.md and one `draft` line. Agent-callable: it is the
6
6
  * only write of a core-doc run (lib/headless.js kind core-doc) and the driver's way to draft a due document. It writes a draft and
7
7
  * nothing else: only the PM issues or drops it, on the page. Nothing is sent.
8
8
  *
9
- * REFUSALS (exit 1): an unknown scope form, a key that is not a document of that level, an entry PMOS does not keep as a document (a derived,
9
+ * REFUSALS (exit 1): a portfolio or board scope (retired, feedback batch 29 item 8: PMOS no longer drafts those), an unknown scope form, a key that is not a document of that level, an entry PMOS does not keep as a document (a derived,
10
10
  * live or report entry), an entry the PM writes (`by: you`) from an agent session, and a scope or key other than the one the server pinned for
11
11
  * this run (PMOS_CORE_DOC_SCOPE, and PMOS_CORE_DOC_KEY or a batch run's PMOS_CORE_DOC_KEYS). Who wrote the draft is the call path (lib/actor.js), never an argument.
12
12
  * Exit codes: 0 done, 1 refused, 2 usage.
@@ -19,8 +19,8 @@ const CD = require('./core-docs.js');
19
19
 
20
20
  const COMMANDS = { coredoc: ['write'] };
21
21
  const USAGE = [
22
- 'usage: pmos coredoc write — the core documents of a portfolio, a board or an initiative',
23
- ' pmos coredoc write --scope <portfolio|board:<id>|initiative:<id>> --key <key> --file <path|->',
22
+ 'usage: pmos coredoc write — the core documents of an initiative',
23
+ ' pmos coredoc write --scope initiative:<id> --key <key> --file <path|->',
24
24
  ' Write ONE draft of a core document (the markdown from the file, or standard input with -). It waits for the PM, who issues it.',
25
25
  ' Keys: ' + CD.LEVELS.map((l) => `${l}: ${CD.SETS[l].filter(CD.storable).map((x) => x.key).join(', ')}`).join(' · '),
26
26
  ' A workflow stage\'s document (the stage cards on the initiative page) is initiative key wf-<stage key>, for example wf-technical-poc; `pmos workflow of <initiative>` lists the stage keys.',
@@ -68,7 +68,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
68
68
  if (VALUE.has(k) && flags[k] === '') { say(`--${k} needs a value`); return 2; }
69
69
  }
70
70
  const fail = (error, code = 1) => { if (json) say(JSON.stringify({ ok: false, error })); else say(`✗ ${error}`); return code; };
71
- if (!flags.scope || !flags.key || !flags.file) { say('usage: pmos coredoc write --scope <portfolio|board:<id>|initiative:<id>> --key <key> --file <path|->'); return 2; }
71
+ if (!flags.scope || !flags.key || !flags.file) { say('usage: pmos coredoc write --scope initiative:<id> --key <key> --file <path|->'); return 2; }
72
72
  const e = env === undefined ? process.env : env;
73
73
  const c = CD.checkEntry(flags.scope, flags.key);
74
74
  if (!c.ok) return fail(c.error);
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
- /* custom-docs.js — the documents the PM adds to a board or an initiative, beyond the core set (initiative briefing-premium-adddoc).
2
+ /* custom-docs.js — the documents the PM adds to an initiative, beyond the core set (initiative briefing-premium-adddoc).
3
+ * A board scope is retired (feedback batch 29 item 8): add() refuses it (410), and list() still reads the board documents added before.
3
4
  * THE ONE WRITER and THE ONE FOLD of <state>/custom-docs.jsonl.
4
5
  *
5
6
  * KINDS · PHASES · WRITERS · TITLE_MAX · URL_MAX
@@ -146,6 +147,7 @@ function add(root, input, actor, { now } = {}) {
146
147
  const c = check(input);
147
148
  if (!c.ok) return c;
148
149
  const v = c.value;
150
+ if (v.scope.startsWith('board:')) return refuse(410, require('./core-docs.js').RETIRED);
149
151
  const file = ledgerFile(root);
150
152
  const have = readLines(file).filter((l) => l.scope === v.scope);
151
153
  if (have.some((l) => norm(l.title) === norm(v.title))) return refuse(409, `“${v.title}” is already on this ${v.scope.startsWith('board:') ? 'board' : 'initiative'}.`);
@@ -55,7 +55,7 @@ const LEDGERS = Object.freeze({
55
55
  r('lib/driver-needs.js', null, 'Needs you')] },
56
56
  '<state>/core-docs.jsonl': { concept: 'core-doc-drafts', owner: 'lib/core-docs.js', readers: [
57
57
  r('lib/routes-core-docs.js', null, 'the core documents of an initiative'),
58
- r('lib/core-docs-needs.js', null, 'Needs you')] },
58
+ r('lib/core-docs-needs.js', null, 'Needs you (initiative drafts only)')] },
59
59
  '<state>/metric-drafts.jsonl': { concept: 'metric-drafts', owner: 'lib/metric-drafts.js', readers: [
60
60
  r('lib/routes-metric-drafts.js', null, 'the metric ✦ on a product, program or initiative page')] },
61
61
  '<state>/metric-reads.jsonl': { concept: 'metric-readings', owner: 'lib/metric-reads.js', readers: [
@@ -123,7 +123,7 @@ const JOBS = Object.freeze([
123
123
  q('driver', 'lib/driver.js', ['<state>/driver.jsonl'], ['initiative records', 'jira']),
124
124
  q('goal-loops', 'lib/goal-loop.js', ['<runtime>/goal-loops.jsonl'], ['<runtime>/goal-loops.jsonl'], 'D106: each round is a run started through the capacity governor; the run writes its own records'),
125
125
  q('finder', 'lib/report-finder.js', ['<state>/report-setups.jsonl'], ['connectors']),
126
- q('coredocs', 'lib/core-docs.js', ['<state>/core-docs.jsonl'], ['initiative records']),
126
+ q('coredocs', 'lib/routes-core-docs.js', [], [], 'retired (batch 29 item 8): it drafted portfolio and board documents and now drafts nothing; an initiative document is drafted by Draft it or the driver'),
127
127
  q('milestones', 'lib/milestone-review.js', ['<state>/milestone-reviews.jsonl'], ['program charters']),
128
128
  q('propose', 'lib/proposal-runs.js', [props], ['connectors', props]),
129
129
  q('grill', 'lib/grill-runs.js', [props, '<runtime>/grill-runs.jsonl'], [props, 'repo:DECISIONS.md']),
@@ -6,6 +6,7 @@
6
6
  * mark(runtimeDir, id, { source, seq, now }) the chunk is written: a second copy of it is a duplicate
7
7
  * setCut(runtimeDir, id, { source, sample }) · untranscribed(runtimeDir, id, { source, before }) → { from, to } | null
8
8
  * the live transcription's progress, so a restart transcribes what it had buffered
9
+ * uncovered({ from, to }, lines) → [{ from, to }] PURE: the parts of that stretch no written line holds yet
9
10
  * close(runtimeDir, id) Pause or Stop: the capture ends, and the next Listen starts a new one
10
11
  * tokened(runtimeDir, id) → true when the live capture has sent a chunk with its token
11
12
  * owns(runtimeDir, id, { token }) → { ok, base_ms } | { ok: false, status: 409, error } is this the live, not-closed capture's token
@@ -113,6 +114,19 @@ function untranscribed(runtimeDir, id, { source, before } = {}) {
113
114
  const to = Math.min(before, (s.fed || {})[source] || 0);
114
115
  return to > from ? { from, to } : null;
115
116
  }
117
+ /** PURE. The parts of a stretch [from, to) (16 kHz samples) that no written line covers. lines: [{ t, t_end }] in meeting ms, the
118
+ * source's own transcript lines. A server stopped between writing a cut's line and saving the cut's progress (setCut) left that
119
+ * line inside the stretch untranscribed() hands back; transcribing it again wrote its words twice (notes-duplication.test.js,
120
+ * restart). So only what no line holds yet is transcribed again. A line with no end is taken to end where it starts. */
121
+ function uncovered({ from, to } = {}, lines = []) {
122
+ const ms2s = (ms) => Math.round(ms * 16);
123
+ const spans = (lines || []).filter((l) => l && Number.isFinite(l.t)).map((l) => [ms2s(l.t), ms2s(Number.isFinite(l.t_end) ? l.t_end : l.t)])
124
+ .filter(([a, b]) => b > a && b > from && a < to).sort((x, y) => x[0] - y[0]);
125
+ const out = []; let at = from;
126
+ for (const [a, b] of spans) { if (a > at) out.push({ from: at, to: Math.min(a, to) }); at = Math.max(at, b); if (at >= to) break; }
127
+ if (at < to) out.push({ from: at, to });
128
+ return out.filter((x) => x.to > x.from);
129
+ }
116
130
  /** Does this token belong to the note's live capture, one that was not closed by Pause or Stop? Changes nothing. */
117
131
  function owns(runtimeDir, id, { token } = {}) {
118
132
  const s = load(runtimeDir, id);
@@ -133,4 +147,4 @@ function remove(runtimeDir, id) {
133
147
  try { fs.unlinkSync(f); } catch { /* none */ }
134
148
  }
135
149
 
136
- module.exports = { start, busy, check, mark, setCut, untranscribed, close, tokened, owns, remove, LIVE_MS };
150
+ module.exports = { start, busy, check, mark, setCut, untranscribed, uncovered, close, tokened, owns, remove, LIVE_MS };
@@ -74,8 +74,8 @@ const SOURCES = Object.freeze([
74
74
  { id: 'scan', label: 'Horizon scan', group: 'pmos', ic: 'search', run: 'job', how: 'bg', setIn: 'Initiatives, Horizon scan',
75
75
  what: 'Reads the web and your repositories for changes that matter to your initiatives.', uses: ['repo'],
76
76
  impact: 'Core documents cite the older scan.' },
77
- { id: 'coredocs', label: 'Core documents', group: 'pmos', ic: 'doc', run: 'job', how: 'bg', fixed: 'At night, or when you are away for 30 min; each document at most once a day',
78
- what: 'Drafts the portfolio, board and initiative documents that are due, old or missing.', uses: ['repo', 'jira', 'scan'],
77
+ { id: 'coredocs', label: 'Core documents', group: 'pmos', ic: 'doc', run: 'job', how: 'bg', fixed: 'When you press Draft it on an initiative, or the driver asks for a document',
78
+ what: 'Drafts the initiative documents that are due, old or missing. Portfolio and board documents are retired.', uses: ['repo', 'jira', 'scan'],
79
79
  impact: 'The initiative driver no longer sees documents that are due or old.' },
80
80
  { id: 'driver', label: 'Initiative driver', group: 'pmos', ic: 'bolt', run: 'job', how: 'bg', fixed: 'Every 30 min in working hours, and when an initiative moves',
81
81
  what: 'Checks each driven initiative for its next step and unblocks what it can.', uses: ['repo', 'jira', 'coredocs'],
@@ -54,7 +54,6 @@ const MODULES = Object.freeze([
54
54
  'routes-my-work-premium', // briefing-premium-work: the premium My work page's model from the Work page's own list (read-only)
55
55
  'routes-board-premium', // briefing-premium-board: the premium Board page's model from the Initiatives page's own routes (read-only)
56
56
  'routes-board-trail', // premium-agreed-design: what the Agreed Board draws beside each initiative, derived from the repository (read-only)
57
- 'routes-board-docs', // premium-uncovered-features (Board): when each document of the Documents tab changed and by whom, from git (read-only)
58
57
  'routes-board-grill', // premium-uncovered-features (Board): a new initiative's Why, material and first questions (page press; file mode)
59
58
  'routes-insights-premium', // briefing-premium-insights: the premium Insights page's model from the KR metric records and report files (read-only)
60
59
  'routes-forecast', // build brief Grill and Forecast F-A: a goal forecast's kept baseline, and the forecasts that turned
@@ -3,9 +3,9 @@
3
3
  *
4
4
  * 200 { ok, state: 'ready', model, as_of } | 202 { ok, state: 'reading' } | 500 { ok: false, state: 'error', error }
5
5
  * model is lib/board-premium.js build(), made from the answers of the routes the production Initiatives page reads: /api/boards, /api/boards/board,
6
- * /backlog, /columns, /sprints and /api/core-docs?level=board. Those routes derive the initiatives in the background and answer 202 while they do, so
6
+ * /backlog, /columns and /sprints. Those routes derive the initiatives in the background and answer 202 while they do, so
7
7
  * this route answers 202 too and the page asks again: no request waits for the read. Read-only: the page's presses go from the page to the
8
- * console's own routes (POST /api/core-docs/draft, /api/boards/asks/*, /api/boards/move, /api/lifecycle, /api/boards/archive).
8
+ * console's own routes (POST /api/boards/asks/*, /api/boards/move, /api/lifecycle, /api/boards/archive).
9
9
  * initiative premium-board-actions adds the open asks (/api/boards/asks), the on-hold rows and the cancelled and archived rows (/backlog).
10
10
  * Build brief F-A adds each open row's delivery forecast (r.forecast), the programs' milestones at risk (model.programForecasts) and writes a
11
11
  * changed forecast state to <state>/forecast.jsonl (lib/forecast.js). */
@@ -13,8 +13,6 @@ const BoardPremium = require('./board-premium.js');
13
13
  const BoardP = BoardPremium;
14
14
  const Rows = require('./initiative-rows.js');
15
15
  const boards = require('./routes-boards.js');
16
- const coreDocs = require('./routes-core-docs.js');
17
- const Custom = require('./custom-docs.js');
18
16
  const path = require('path');
19
17
  const fs = require('fs');
20
18
  const Metrics = require('./board-metrics-premium.js');
@@ -83,12 +81,11 @@ module.exports = {
83
81
  const missing = [];
84
82
  // the late and at-risk initiatives first (the board's own `risk` view, late before at risk), then its `now` view, each initiative once
85
83
  const listOf = (a, n) => { const seen = new Set(), out = []; const rank = (r) => (r.status === 'late' ? 0 : 1); for (const r of [...((a && a.rows) || [])].sort((x, y) => rank(x) - rank(y))) { if (!seen.has(r.id)) { seen.add(r.id); out.push(r); } } for (const r of (n && n.rows) || []) if (!seen.has(r.id)) { seen.add(r.id); out.push(r); } return out.slice(0, 100); };
86
- const [risk, now, cols, spr, docs, held, can, arc, asks, its] = await Promise.all([
84
+ const [risk, now, cols, spr, held, can, arc, asks, its] = await Promise.all([
87
85
  via(boards, '/api/boards/backlog' + q + '&view=risk&limit=100', req, ctx),
88
86
  via(boards, '/api/boards/backlog' + q + '&view=now&limit=100', req, ctx),
89
87
  via(boards, '/api/boards/columns' + q, req, ctx),
90
88
  via(boards, '/api/boards/sprints' + q, req, ctx),
91
- via(coreDocs, '/api/core-docs' + qs({ level: 'board', ws: pick.ws, board: pick.id }), req, ctx),
92
89
  via(boards, '/api/boards/backlog' + q + '&view=all&status=' + encodeURIComponent('on hold') + '&limit=100', req, ctx),
93
90
  via(boards, '/api/boards/backlog' + q + '&view=all&status=cancelled&limit=100', req, ctx),
94
91
  via(boards, '/api/boards/backlog' + q + '&archived=1&limit=100', req, ctx),
@@ -96,11 +93,8 @@ module.exports = {
96
93
  via(boards, '/api/boards/items' + q, req, ctx), // the Jira tickets of each initiative, for the stage track (premium-agreed-design B1)
97
94
  ]);
98
95
  const ok = (r, name) => { if (r.status === 202 || !r.body || r.body.ok === false || r.body.pending) { missing.push(name); return null; } return r.body; };
99
- const rk = ok(risk, 'initiatives'), nw = ok(now, 'initiatives'), c = ok(cols, 'stages'), s = ok(spr, 'sprints'), d = ok(docs, 'core documents');
96
+ const rk = ok(risk, 'initiatives'), nw = ok(now, 'initiatives'), c = ok(cols, 'stages'), s = ok(spr, 'sprints');
100
97
  const hd = ok(held, 'on-hold initiatives'), cn = ok(can, 'cancelled initiatives'), ar = ok(arc, 'archived initiatives'), ak = ok(asks, 'new asks');
101
- // the documents the PM added (lib/custom-docs.js): one file read, no route
102
- let custom = [];
103
- try { const w = ctx.getWs ? ctx.getWs(pick.ws) : null; custom = w ? Custom.list(w.root, 'board:' + pick.id) : []; } catch { custom = []; missing.push('added documents'); }
104
98
  // the initiatives of this workspace that a program holds (GET /api/programs): the list above is the `now` and `risk` views, so a member
105
99
  // on a later horizon is not in it, and the program page would call it unread. Their rows come from the board's own `all` view.
106
100
  const rowsNow = listOf(rk, nw);
@@ -116,7 +110,7 @@ module.exports = {
116
110
  const model = BoardPremium.build({
117
111
  now: Date.now(), pending: false, missing: missing.filter((m) => m !== 'core documents'), boards: all.map((x) => ({ ws: x.ws, id: x.id, name: x.name })),
118
112
  board: head.body.board, counts: head.body.counts, nextRelease: head.body.nextRelease || null, pastReleases: head.body.pastReleases || [],
119
- rows: rowsNow, members, columns: c ? c.columns : [], sprints: s || { source: 'none', sprints: [] }, docs: d, custom,
113
+ rows: rowsNow, members, columns: c ? c.columns : [], sprints: s || { source: 'none', sprints: [] },
120
114
  items: its && its.body && its.body.ok !== false && Array.isArray(its.body.items) ? its.body.items : [], held: hd ? hd.rows : [], cancelled: cn ? cn.rows : [], archived: ar ? ar.rows : [], asks: ak ? ak.asks || [] : null,
121
115
  });
122
116
  // workspace grill W2: a row nothing read for says No signal (grey), with where its status came from (r.signal: from, why, source,