create-pmos 0.567.0 → 0.569.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 (40) hide show
  1. package/package.json +27 -27
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/scripts/gate-initiative.sh +29 -0
  6. package/payload/scripts/workflow-state.js +36 -1
  7. package/payload/state/discoveries.md +1 -1
  8. package/payload/state/log.md +1 -1
  9. package/workspace/changelog.json +26 -0
  10. package/workspace/guide/cli.md +1 -1
  11. package/workspace/guide/initiatives-and-next-steps.md +20 -1
  12. package/workspace/lib/artefact-mirror.js +121 -0
  13. package/workspace/lib/artefacts-cli.js +15 -1
  14. package/workspace/lib/driver-decide.js +2 -0
  15. package/workspace/lib/engine/workflow-state.js +36 -1
  16. package/workspace/lib/engine/workflows.js +71 -7
  17. package/workspace/lib/jira-cli.js +1 -0
  18. package/workspace/lib/jira-tickets.js +23 -0
  19. package/workspace/lib/kind-control.js +232 -0
  20. package/workspace/lib/outcome-props.js +21 -1
  21. package/workspace/lib/rehearse-read.js +7 -3
  22. package/workspace/lib/rehearse.js +30 -2
  23. package/workspace/lib/route-modules.js +1 -0
  24. package/workspace/lib/routes-artefacts.js +4 -1
  25. package/workspace/lib/routes-boards.js +50 -2
  26. package/workspace/lib/routes-initiatives.js +3 -1
  27. package/workspace/lib/routes-kind-control.js +95 -0
  28. package/workspace/lib/today-cli.js +19 -0
  29. package/workspace/lib/vendor/scripts/workflow-state.js +36 -1
  30. package/workspace/lib/work-kind.js +16 -4
  31. package/workspace/lib/workflows-store.js +2 -2
  32. package/workspace/package-lock.json +2 -2
  33. package/workspace/package.json +1 -1
  34. package/workspace/public/pm/ini-agent.js +16 -6
  35. package/workspace/public/pm/ini-kind.js +59 -0
  36. package/workspace/public/pm/ini-view.css +23 -0
  37. package/workspace/public/pm/ini-view.js +5 -2
  38. package/workspace/run-tests.js +9 -0
  39. package/workspace/test-lists/kind-workflows.json +5 -0
  40. package/workspace/test-lists/launch-rerun-gaps.json +4 -0
@@ -4,7 +4,9 @@
4
4
  *
5
5
  * CATS · ENDS · OUTPUT_KINDS · WHEN_MODES · DECIDE · ICONS · PRODUCT_FEATURE_ID · PRODUCT_FEATURE
6
6
  * check(wf, { existing }) → { ok, workflow } | { ok:false, status, error } validate and normalise one workflow
7
- * fold(lines) → { byId: Map, draft, defaultId } the library (Product feature first)
7
+ * PROJECT · FULL_SDLC · BUILTIN · KIND_WF the two workflows the kind of work starts on (W5, boards WfA/WfB/WfC), built in like Product feature
8
+ * forKind(folded, kind) · isKindDefault(folded, kind, wfId) the workflow a kind starts on; whether an initiative still runs it
9
+ * fold(lines) → { byId: Map, draft, defaultId } the library (the built-ins first)
8
10
  * list(folded, counts?) → [workflow + { count, default? }] Product feature first, archived last
9
11
  * defaultOf(folded) → the workflow a new initiative starts on (Product feature when none is set or it is archived)
10
12
  * resolve(folded, id) → the workflow (Product feature when the id is unknown or missing)
@@ -59,6 +61,53 @@ const PRODUCT_FEATURE = Object.freeze({
59
61
  }))),
60
62
  });
61
63
 
64
+ // The kind of work sets the default workflow (launch simulation W5, main canvas boards WfA, WfB, WfC; agreed by Wawan 2026-11-12). Two more
65
+ // workflows are built in beside Product feature and, like it, cannot be edited (copy one to make your own). Every workflow starts with the
66
+ // key `triage` (the first stage, in To do); these two name it for their work: Initiate, and Done test.
67
+ const st = (key, name, cat, out, kind, o = {}) => Object.freeze({ key, name, cat, output: Object.freeze({ name: out, kind }), finish: Object.freeze(o.finish || []),
68
+ milestone: !!o.milestone, auto: false, when: Object.freeze({ mode: 'always' }), then: null, unless: Object.freeze([]) });
69
+ const PROJECT_ID = 'project', FULL_SDLC_ID = 'full-sdlc';
70
+ const PROJECT = Object.freeze({
71
+ id: PROJECT_ID, name: 'Project', icon: 'flag', builtin: true, decide: 'pmos', kind: 'project',
72
+ stages: Object.freeze([
73
+ st('triage', 'Initiate', 'todo', 'The charter: the goal, the date and who owns it', 'doc'),
74
+ st('plan', 'Plan', 'doing', 'A dated plan: milestones with owners from People, go-live matching the KR date', 'checklist', { milestone: true }),
75
+ st('execute', 'Execute', 'doing', 'The tasks done against the baseline', 'checklist'),
76
+ st('monitor', 'Monitor', 'doing', 'Go-live reached; the dates watched against the baseline', 'checklist', { milestone: true }),
77
+ st('close', 'Close', 'done', 'The lessons, and the outcome check', 'signoff'),
78
+ ]),
79
+ });
80
+ const FULL_SDLC = Object.freeze({
81
+ id: FULL_SDLC_ID, name: 'Full SDLC', icon: 'build', builtin: true, decide: 'pmos', kind: 'sdlc',
82
+ stages: Object.freeze([
83
+ st('triage', 'Done test', 'todo', 'The done test and the kill condition, dated before the first pull request', 'doc'),
84
+ st('pulls', 'Pull requests', 'doing', 'The pull requests of the PR plan', 'checklist'),
85
+ st('ci', 'CI', 'doing', 'Green required checks on every pull request of the plan', 'checklist'),
86
+ st('merge', 'Merge', 'doing', 'Every pull request merged; the done test passes on the merged branch', 'checklist', { milestone: true }),
87
+ st('release', 'Release', 'done', 'Released; the outcome check starts', 'signoff', { milestone: true }),
88
+ ]),
89
+ });
90
+ const BUILTIN = Object.freeze({ [PRODUCT_FEATURE_ID]: PRODUCT_FEATURE, [PROJECT_ID]: PROJECT, [FULL_SDLC_ID]: FULL_SDLC });
91
+ const isBuiltin = (id) => Object.prototype.hasOwnProperty.call(BUILTIN, id);
92
+ /** The workflow each kind of work starts on (lib/work-kind.js KINDS). Product management: the workspace's default (defaultOf). */
93
+ const KIND_WF = Object.freeze({ product: PRODUCT_FEATURE_ID, sdlc: FULL_SDLC_ID, project: PROJECT_ID });
94
+ /* Switching between the built-in workflows maps stages BY MEANING (WfC): Plan to Plan, Build to Execute, Release to Close. The proposal
95
+ * (proposeBridge) cannot know that Deliver is a release, so the three are mapped here and mapOf reads this before the proposal. */
96
+ const MEANING = Object.freeze({
97
+ 'product-feature>project': { triage: 'triage', discover: 'triage', plan: 'plan', prioritize: 'plan', build: 'execute', deliver: 'close', monitor: 'close', evaluate: 'close' },
98
+ 'product-feature>full-sdlc': { triage: 'triage', discover: 'triage', plan: 'triage', prioritize: 'triage', build: 'pulls', deliver: 'release', monitor: 'release', evaluate: 'release' },
99
+ 'project>product-feature': { triage: 'triage', plan: 'plan', execute: 'build', monitor: 'deliver', close: 'evaluate' },
100
+ 'project>full-sdlc': { triage: 'triage', plan: 'triage', execute: 'pulls', monitor: 'merge', close: 'release' },
101
+ 'full-sdlc>product-feature': { triage: 'plan', pulls: 'build', ci: 'build', merge: 'build', release: 'deliver' },
102
+ 'full-sdlc>project': { triage: 'plan', pulls: 'execute', ci: 'execute', merge: 'monitor', release: 'close' },
103
+ });
104
+ /** What a gate of each kind asks before work leaves planning, said once (the switch line names what the new kind adds). */
105
+ const KIND_GATE = Object.freeze({
106
+ product: 'the Build gate reads the done test and kill condition, or a PRD',
107
+ sdlc: 'the first pull request now needs a done test and a kill condition, dated before the build',
108
+ project: 'the Plan gate now needs a dated plan, milestones with owners and a go-live date that matches the KR',
109
+ });
110
+
62
111
  const bad = (error, status = 400) => ({ ok: false, status, error });
63
112
 
64
113
  /** Validate and normalise one workflow. `existing` (the library's ids) only matters for a new id clashing with Product feature. */
@@ -68,7 +117,7 @@ function check(wf) {
68
117
  const name = wf.name.trim();
69
118
  const id = typeof wf.id === 'string' && wf.id ? slug(wf.id) : slug(name);
70
119
  if (!id) return bad('the name needs at least one letter or digit');
71
- if (id === PRODUCT_FEATURE_ID) return bad('Product feature is built in and cannot be changed. Copy it to make your own.', 409);
120
+ if (isBuiltin(id)) return bad(`${BUILTIN[id].name} is built in and cannot be changed. Copy it to make your own.`, 409);
72
121
  const icon = ICONS.includes(wf.icon) ? wf.icon : 'flag';
73
122
  const decide = wf.decide == null ? 'pmos' : wf.decide;
74
123
  if (!DECIDE.includes(decide)) return bad(`decide is one of ${DECIDE.join(', ')}`);
@@ -136,7 +185,7 @@ function check(wf) {
136
185
 
137
186
  /** Fold workflows.jsonl (objects or JSON strings), oldest first. */
138
187
  function fold(lines) {
139
- const byId = new Map([[PRODUCT_FEATURE_ID, PRODUCT_FEATURE]]);
188
+ const byId = new Map(Object.entries(BUILTIN));
140
189
  let draft = null, defaultId = null;
141
190
  for (const raw of lines || []) {
142
191
  let e = raw;
@@ -150,7 +199,7 @@ function fold(lines) {
150
199
  // the initiatives over reads it (batch 20 item 3)
151
200
  const cf = typeof e.copiedFrom === 'string' ? e.copiedFrom : was && was.copiedFrom ? was.copiedFrom : null;
152
201
  byId.set(c.workflow.id, { ...c.workflow, ...(was && was.archived ? { archived: true } : {}), ...(cf ? { copiedFrom: cf } : {}), at: e.at || null });
153
- } else if (e.kind === 'wf-archive' && typeof e.id === 'string' && byId.has(e.id) && e.id !== PRODUCT_FEATURE_ID) {
202
+ } else if (e.kind === 'wf-archive' && typeof e.id === 'string' && byId.has(e.id) && !isBuiltin(e.id)) {
154
203
  const w = { ...byId.get(e.id) };
155
204
  if (e.archived) w.archived = true; else delete w.archived;
156
205
  byId.set(e.id, w);
@@ -174,7 +223,8 @@ function defaultOf(folded) {
174
223
  function list(folded, counts = {}) {
175
224
  const def = defaultOf(folded).id;
176
225
  const all = [...folded.byId.values()].map((w) => ({ ...w, count: counts[w.id] || 0, ...(w.id === def ? { default: true } : {}) }));
177
- const rank = (w) => (w.id === PRODUCT_FEATURE_ID ? 0 : w.archived ? 2 : 1);
226
+ const order = [PRODUCT_FEATURE_ID, PROJECT_ID, FULL_SDLC_ID];
227
+ const rank = (w) => (isBuiltin(w.id) ? order.indexOf(w.id) : w.archived ? 4 : 3);
178
228
  return all.sort((a, b) => rank(a) - rank(b) || a.name.localeCompare(b.name));
179
229
  }
180
230
  const resolve = (folded, id) => (id && folded && folded.byId.get(id)) || PRODUCT_FEATURE;
@@ -229,7 +279,7 @@ function proposeBridge(from, to) {
229
279
  /** Every stage of `from` and where it lands in `to`: the PM's own pick (override), the bridge saved with `to`, else Claude's proposal. */
230
280
  function mapOf(from, to, override) {
231
281
  const p = proposeBridge(from, to);
232
- const br = to && to.bridge && from && to.bridge.from === from.id ? to.bridge.map : {};
282
+ const br = to && to.bridge && from && to.bridge.from === from.id ? to.bridge.map : (from && to && MEANING[from.id + '>' + to.id]) || {};
233
283
  const ok = (k) => !!k && !!(to.stages || []).find((s) => s.key === k);
234
284
  const out = {};
235
285
  for (const s of (from && from.stages) || []) {
@@ -273,14 +323,28 @@ function stagesOf(wf, { judged = {}, current = null } = {}) {
273
323
  function copyOf(wf, name, taken) {
274
324
  const n = oneLine(name, NAME_MAX) ? name.trim() : 'Copy of ' + wf.name;
275
325
  let id = slug(n) || 'workflow', k = 2;
276
- while ((taken && taken.has(id)) || id === PRODUCT_FEATURE_ID) id = slug(n) + '-' + k++;
326
+ while ((taken && taken.has(id)) || isBuiltin(id)) id = slug(n) + '-' + k++;
277
327
  return { id, name: n, icon: wf.icon, decide: wf.decide || 'pmos', stages: wf.stages.map((s) => ({ ...s, output: { ...s.output }, finish: [...s.finish], when: { ...s.when }, unless: s.unless.map((u) => ({ ...u })) })) };
278
328
  }
279
329
 
330
+ /** The workflow a kind of work starts on: Project and Full SDLC their own; Product management the workspace's default (defaultOf). */
331
+ function forKind(folded, kind) {
332
+ const id = KIND_WF[kind];
333
+ if (!id || id === PRODUCT_FEATURE_ID) return defaultOf(folded);
334
+ return BUILTIN[id];
335
+ }
336
+ /** Whether an initiative on workflow `wfId` runs its kind's default: the kind's built-in, or for Product management Product feature or the
337
+ * workspace default. A workflow the PM picked by hand is not a kind's default, so a kind change leaves it alone. */
338
+ function isKindDefault(folded, kind, wfId) {
339
+ if (kind === 'product') return wfId === PRODUCT_FEATURE_ID || wfId === defaultOf(folded).id;
340
+ return wfId === KIND_WF[kind];
341
+ }
342
+
280
343
  /** The ◆ stages of a workflow: what a program milestone may wait on (D99 point 7). Product feature: Deliver first. */
281
344
  const milestonesOf = (wf) => (wf || PRODUCT_FEATURE).stages.filter((s) => s.milestone).map((s) => ({ key: s.key, name: s.name }));
282
345
 
283
346
  module.exports = {
284
347
  CATS, CAT_LABEL, ENDS, OUTPUT_KINDS, WHEN_MODES, DECIDE, ICONS, PRODUCT_FEATURE_ID, PRODUCT_FEATURE,
348
+ PROJECT_ID, PROJECT, FULL_SDLC_ID, FULL_SDLC, BUILTIN, KIND_WF, KIND_GATE, MEANING, isBuiltin, forKind, isKindDefault,
285
349
  slug, check, fold, list, defaultOf, resolve, stageByRef, switchTarget, proposeBridge, mapOf, removedInUse, stagesOf, copyOf, milestonesOf,
286
350
  };
@@ -190,6 +190,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
190
190
  if (!r.ok) return fail(r.error);
191
191
  const lines = [`${initiative} · ${r.tickets} ${r.tickets === 1 ? 'ticket' : 'tickets'} in ${r.draft}${r.changed ? '' : ' · no change'}${flags['dry-run'] ? ' · dry run, nothing written' : ''}`];
192
192
  if (r.from === 'done-test' || r.from === 'tasks') lines.push(` From ${r.from === 'done-test' ? 'the done test\'s checks' : 'the open tasks'} (${r.sources.join(', ')}): the PRD has no stories section.`);
193
+ else if (r.from === 'plan') lines.push(' From the plan: each milestone is an epic, with the tasks that end before it. A Project has no PRD.');
193
194
  for (const c of r.changes) lines.push(` ${c.what.padEnd(9)} ${c.ticket} · ${c.summary}${c.why ? ` (${c.why})` : ''}`);
194
195
  lines.push('Read them on the Jira tickets tab, or with pmos jira show. Select the ready ones there, or with pmos jira approve.');
195
196
  return out(r, lines);
@@ -306,6 +306,12 @@ function items(root, initiative) {
306
306
  const s = dt ? itemsFromDoneTest(dt, title) : [];
307
307
  if (s.length) { found.push(...s); sources.push(dt.path); from = 'done-test'; }
308
308
  }
309
+ // W5 (board WfA): a Project has no PRD. With no done test either, its plan is the draft: each ◇ milestone an epic, and under it the
310
+ // tasks that end on or before it (lib/kind-control.js wbsOf), a work breakdown. Nothing is sent: the draft waits for the PM as any other.
311
+ if (!found.length && String(fm.kind || '').replace(/["']/g, '').trim() === 'project') {
312
+ const w = wbsItems(root, initiative);
313
+ if (w.length) { found.push(...w); sources.push('the plan: milestones and tasks'); from = 'plan'; }
314
+ }
309
315
  if (!found.length) {
310
316
  const s = itemsFromTasks(root, initiative, title);
311
317
  if (s.length) { found.push(...s); sources.push(s[0].source); from = 'tasks'; }
@@ -324,6 +330,23 @@ function items(root, initiative) {
324
330
  return { ok: true, initiative, items: found, sources, prd: prd || null, from };
325
331
  }
326
332
 
333
+ /** A Project's milestones and tasks as ticket items (W5): the milestone is the epic; each task a Task with its due day and owner. */
334
+ function wbsItems(root, initiative) {
335
+ let tasks = [];
336
+ try {
337
+ const SR = require('./stage-read.js'), { w, ctx } = SR.cliCtx(root);
338
+ tasks = (SR.tasksOf(ctx, w, initiative) || []).map((t) => ({ uid: t.id, title: t.title, end: t.due || null, owner: t.owner || null, milestone: !!t.milestone, kind: t.kind, status: t.state }));
339
+ } catch { return []; }
340
+ const done = /^(done|won't do|archived)$/i;
341
+ const out = [];
342
+ for (const g of require('./kind-control.js').wbsOf(tasks.filter((t) => !done.test(String(t.status || ''))))) {
343
+ const epic = g.milestone ? clip(oneLine('◇ ' + g.milestone.title + (g.milestone.due ? ' · ' + g.milestone.due : '')), MAX_EPIC) : 'After the last milestone';
344
+ for (const t of g.tasks) out.push({ id: null, title: t.title, epic, source: 'plan', body: ['Due ' + (t.due || 'not set') + '.', t.owner ? 'Owner ' + t.owner + '.' : 'No owner yet.'].join(' ') });
345
+ if (g.milestone) out.push({ id: null, title: g.milestone.title, epic, source: 'plan', body: 'Milestone, due ' + (g.milestone.due || 'not set') + '.' + (g.milestone.owner ? ' Owner ' + g.milestone.owner + '.' : '') });
346
+ }
347
+ return out;
348
+ }
349
+
327
350
  // ── J2 · one item in the PM's template ─────────────────────────────────────────────────────────────
328
351
  const sectionKey = (line) => {
329
352
  const t = String(line).replace(/^#{1,6}\s+/, '').replace(/\*\*/g, '').replace(/:\s*$/, '').trim().toLowerCase();
@@ -0,0 +1,232 @@
1
+ 'use strict';
2
+ /* kind-control.js — what the Viewer shows for a Project and a Full SDLC initiative (launch simulation W5; main canvas boards WfA and WfB,
3
+ * agreed by Wawan 2026-11-12). PURE: no file, no clock, no network. lib/routes-kind-control.js reads the inputs through the pmos readers.
4
+ *
5
+ * project(input) → { kind: 'project', gate, rows, critical, ontrack, proposal, baselineAt }
6
+ * sdlc(input) → { kind: 'sdlc', gate }
7
+ * baselineOf(lines, uids, at) → Map uid → { start, due } each task's dates as they stood when the plan was set (or its first dates)
8
+ * dateIn(text, today) → 'YYYY-MM-DD' | '' a date a title or a KR names ("launch 15 Dec", "by Dec 15", "2026-12-15")
9
+ * wbsOf(tasks) → [{ milestone, tasks }] a Project's milestones with the tasks that end before each (pmos jira draft)
10
+ *
11
+ * PROJECT CONTROL. Everything here comes from task dates and task links. A status someone typed is never read: a task's colour, the critical
12
+ * path and the on-track answer are worked out, so they cannot drift from the plan (the design principle "honest state").
13
+ * baseline each task's start and due when the initiative left Plan (the ini-wf line that moved it out of `plan`), else its first dates.
14
+ * The outline in the Viewer is the baseline; the filled bar is now (the forecast).
15
+ * forecast an open task that is past its due ends today at the earliest; then the approved links (lib/task-links.js settle) push what
16
+ * waits on it. Go-live is the initiative's last ◇ milestone, else its last task.
17
+ * critical walked back from go-live through the links that hold each task tight (the predecessor that sets its start or its due).
18
+ * With no links into go-live there is no critical path to name, and the Viewer says nothing about it.
19
+ * colour done: done. Red: it ends later than its baseline, it is on the critical path and go-live misses the goal date. Amber: it ends
20
+ * later than its baseline otherwise, or it has not started and its start has passed. Green: on its baseline. None: no dates.
21
+ * on track "On track for <goal date>?" Yes when the forecast go-live is on or before the goal date; No with the slip and the first
22
+ * slipping task on the critical path (the cause); unknown with the reason when a date is missing.
23
+ * proposal on a No: a ✦ that moves the go-live milestone to its forecast. It never changes the goal, the KR or the title: those are
24
+ * Wawan's, and `pmos rehearse end` names each one that the new date breaks.
25
+ * THE GATE TO LEAVE PLAN (WfA): a dated plan (every milestone has a due day, or plan_path is set), every milestone owned by someone in People,
26
+ * and the go-live date matching the goal date and the date in the title. Each part says what is missing.
27
+ * FULL SDLC (WfB): the gate before the first pull request is the done test plus the kill condition, written in the record. Who builds is
28
+ * the Experiment's line (pm/ini-agent.js kindRows), the one wording the honest-copy work keeps true per repository. */
29
+ const TL = require('./task-links.js');
30
+
31
+ const MON = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
32
+ const ALL = { has: () => true };
33
+ const str = (v) => (typeof v === 'string' ? v : '');
34
+ const days = (n) => (Math.abs(n) === 1 ? '1 day' : Math.abs(n) + ' days');
35
+ const iso = TL.isoN, md = TL.md, dn = TL.dn;
36
+ const listOf = (a) => (a.length < 2 ? a.join('') : a.slice(0, -1).join(', ') + ' and ' + a[a.length - 1]);
37
+
38
+ /** A date a line names, as YYYY-MM-DD; a day with no year is this year's, or next year's when this year's has passed. '' when none. */
39
+ function dateIn(text, today) {
40
+ const t = str(text), y0 = +str(today).slice(0, 4) || new Date().getUTCFullYear();
41
+ let m = /\b(\d{4})-(\d{2})-(\d{2})\b/.exec(t);
42
+ if (m) return m[0];
43
+ let d = 0, k = -1, y = 0;
44
+ m = /\b(\d{1,2})\s+(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\.?(?:,?\s+(\d{4}))?/i.exec(t);
45
+ if (m) { d = +m[1]; k = MON.indexOf(m[2].toLowerCase()); y = m[3] ? +m[3] : 0; }
46
+ else {
47
+ m = /\b(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\.?\s+(\d{1,2})\b(?:,?\s+(\d{4}))?/i.exec(t);
48
+ if (m) { d = +m[2]; k = MON.indexOf(m[1].toLowerCase()); y = m[3] ? +m[3] : 0; }
49
+ }
50
+ if (!m || k < 0 || d < 1 || d > 31) return '';
51
+ const at = (yy) => yy + '-' + String(k + 1).padStart(2, '0') + '-' + String(d).padStart(2, '0');
52
+ return y ? at(y) : at(y0) >= str(today) ? at(y0) : at(y0 + 1);
53
+ }
54
+
55
+ /** Each task's dates as they stood at `at` (ISO time), read from task ledger lines of either shape: a Board task ({ kind: 'task' |
56
+ * 'task-update', task, start?, due? }) or a breakdown item ({ ev, item, start?, due?, fields: { start?, due? } }). A task first dated after
57
+ * `at` keeps its first dates. No `at`: every task's first dates. → Map uid → { start, due } */
58
+ function baselineOf(lines, uids, at) {
59
+ const first = new Map(), asOf = new Map();
60
+ for (const e of lines || []) {
61
+ if (!e || typeof e !== 'object') continue;
62
+ const id = typeof e.task === 'string' ? e.task : typeof e.item === 'string' ? e.item : null;
63
+ if (!id || (uids && !uids.has(id))) continue;
64
+ const f = e.fields && typeof e.fields === 'object' ? e.fields : e;
65
+ const s = typeof f.start === 'string' ? f.start : undefined, d = typeof f.due === 'string' ? f.due : undefined;
66
+ if (s === undefined && d === undefined) continue;
67
+ const cur = { ...(first.get(id) || { start: null, due: null }) };
68
+ if (!first.has(id) || first.get(id).start == null || first.get(id).due == null) {
69
+ if (cur.start == null && s !== undefined) cur.start = s;
70
+ if (cur.due == null && d !== undefined) cur.due = d;
71
+ first.set(id, cur);
72
+ }
73
+ if (at && e.at && String(e.at) <= String(at)) {
74
+ const a = { ...(asOf.get(id) || { start: null, due: null }) };
75
+ if (s !== undefined) a.start = s;
76
+ if (d !== undefined) a.due = d;
77
+ asOf.set(id, a);
78
+ }
79
+ }
80
+ const out = new Map();
81
+ for (const [id, f] of first) out.set(id, asOf.get(id) || f);
82
+ return out;
83
+ }
84
+
85
+ /** The forecast: open past-due tasks end today at the earliest, then the links push what waits on them. → Map uid → task (TL shape) */
86
+ function forecastOf(tasks, links, today) {
87
+ const T = new Map();
88
+ for (const x of tasks) {
89
+ const t = TL.taskOf(x);
90
+ if (!t.closed && t.e != null && today != null && t.e < today) { const len = t.s != null ? t.e - t.s : 0; t.e = today; if (t.s != null && t.status === 'To do') t.s = Math.max(t.s, today - len); }
91
+ T.set(t.uid, t);
92
+ }
93
+ const L = (links || []).filter((l) => l && T.has(l.from) && T.has(l.to));
94
+ const S = TL.settle(T, L, { today, ini: '', mode: 'quiet', allow: ALL });
95
+ for (const m of S.moves || []) { const t = T.get(m.uid); if (t) T.set(m.uid, { ...t, s: m.to.s, e: m.to.e }); }
96
+ return { T, links: L };
97
+ }
98
+
99
+ /** Walk back from `end` through the links that hold each task tight. → [uid] oldest first */
100
+ function criticalOf(T, links, end, today) {
101
+ if (!end) return [];
102
+ const path = [end.uid], seen = new Set(path);
103
+ let cur = end;
104
+ for (let guard = 0; guard < 200; guard++) {
105
+ let best = null;
106
+ for (const l of links) {
107
+ if (l.to !== cur.uid || seen.has(l.from)) continue;
108
+ const a = T.get(l.from); if (!a) continue;
109
+ const need = TL.needOf(l, a, today);
110
+ const tight = (need.start != null && cur.s != null && need.start >= cur.s) || (need.due != null && cur.e != null && need.due >= cur.e);
111
+ if (tight && (!best || (a.e || 0) > (best.e || 0))) best = a;
112
+ }
113
+ if (!best) break;
114
+ path.unshift(best.uid); seen.add(best.uid); cur = best;
115
+ }
116
+ return path.length > 1 ? path : [];
117
+ }
118
+
119
+ /** People's names and handles, lower case, for "owner linked to People". */
120
+ function peopleSet(people) {
121
+ const S = new Set();
122
+ for (const p of people || []) {
123
+ if (!p) continue;
124
+ if (p.name) S.add(String(p.name).toLowerCase().trim());
125
+ for (const h of p.handles || []) S.add(String(h).toLowerCase().replace(/^person:/, '').trim());
126
+ }
127
+ return S;
128
+ }
129
+ const ownerName = (o) => str(o).replace(/^person:/, '').trim();
130
+
131
+ /**
132
+ * input: { today, title, goal: { id, title, byAt } | null, end (the committed end) | null, record: { plan_path? },
133
+ * tasks: [{ uid, title, start, end, status, milestone, owner }] (this initiative's), links, baseline: Map, baselineAt, people }
134
+ */
135
+ function project(input) {
136
+ const I = input || {}, today = dn(I.today);
137
+ const tasks = (I.tasks || []).filter((x) => x && (x.uid || x.key) && x.kind !== 'Epic');
138
+ const base = I.baseline instanceof Map ? I.baseline : new Map();
139
+ const { T, links } = forecastOf(tasks, I.links, today);
140
+ const ms = [...T.values()].filter((t) => t.ms);
141
+ const pickEnd = (L) => L.filter((t) => t.e != null).sort((a, b) => b.e - a.e)[0] || null;
142
+ const goLive = pickEnd(ms) || pickEnd([...T.values()]);
143
+ const crit = criticalOf(T, links, goLive, today);
144
+ const critSet = new Set(crit);
145
+ // the goal date: the KR's by-date, else the committed end, else the date the title names
146
+ const titleDate = dateIn(I.title, I.today);
147
+ const goalIso = (I.goal && I.goal.byAt ? str(I.goal.byAt).slice(0, 10) : '') || (I.end ? str(I.end).slice(0, 10) : '') || titleDate;
148
+ const goalN = dn(goalIso), fgo = goLive ? goLive.e : null;
149
+ const misses = goalN != null && fgo != null && fgo > goalN;
150
+
151
+ const raw = new Map(tasks.map((x) => [x.uid || x.key, x]));
152
+ const rows = [];
153
+ for (const t of T.values()) {
154
+ const b = base.get(t.uid) || null, bs = b ? dn(b.start || b.due) : null, be = b ? dn(b.due || b.start) : null;
155
+ const slip = be != null && t.e != null ? t.e - be : 0;
156
+ const startLate = !t.closed && t.status === 'To do' && t.s != null && today != null && dn((raw.get(t.uid) || {}).start) != null && dn(raw.get(t.uid).start) < today;
157
+ let rag = 'g';
158
+ if (t.closed) rag = 'done';
159
+ else if (t.s == null && t.e == null) rag = 'n';
160
+ else if (slip > 0 && critSet.has(t.uid) && misses) rag = 'r';
161
+ else if (slip > 0 || startLate) rag = 'a';
162
+ const owner = ownerName((raw.get(t.uid) || {}).owner);
163
+ rows.push({ uid: t.uid, title: t.title, milestone: t.ms, owner: owner || null, ownerLinked: !!owner && peopleSet(I.people).has(owner.toLowerCase()),
164
+ rag, critical: critSet.has(t.uid), base: { start: iso(bs), due: iso(be) }, now: { start: iso(t.s), due: iso(t.e) }, slip: slip > 0 ? slip : 0,
165
+ words: t.closed ? 'done' : rag === 'n' ? 'no dates' : slip > 0 ? days(slip) + ' late' : startLate ? 'start passed' : 'on time' });
166
+ }
167
+ rows.sort((a, b) => (dn(a.now.start || a.now.due) || 0) - (dn(b.now.start || b.now.due) || 0) || a.title.localeCompare(b.title));
168
+
169
+ // on track for the goal date?
170
+ let ontrack;
171
+ const src = 'Read from ' + tasks.length + (tasks.length === 1 ? ' task date' : ' task dates') + (links.length ? ' and ' + links.length + (links.length === 1 ? ' link' : ' links') : '');
172
+ if (!goLive) ontrack = { answer: 'unknown', words: 'No task has a date yet, so PMOS cannot say.', src };
173
+ else if (goalN == null) ontrack = { answer: 'unknown', forecast: iso(fgo), words: 'Go-live forecasts ' + md(fgo) + '. No goal date to compare: the KR, the end and the title name none.', src };
174
+ else if (!misses) ontrack = { answer: 'yes', date: goalIso, forecast: iso(fgo), words: 'Yes. Go-live forecasts ' + md(fgo) + (fgo < goalN ? ', ' + days(goalN - fgo) + ' early' : '') + '.', src };
175
+ else {
176
+ const cause = crit.map((u) => rows.find((r) => r.uid === u)).find((r) => r && r.slip > 0) || rows.filter((r) => r.slip > 0).sort((a, b) => b.slip - a.slip)[0] || null;
177
+ const after = cause ? crit.slice(crit.indexOf(cause.uid) + 1).map((u) => (T.get(u) || {}).title).filter(Boolean) : [];
178
+ ontrack = { answer: 'no', date: goalIso, forecast: iso(fgo), slip: fgo - goalN,
179
+ words: 'No. Forecast ' + md(fgo) + ', ' + days(fgo - goalN) + ' late.', cause: cause ? { uid: cause.uid, title: cause.title, slip: cause.slip } : null,
180
+ why: cause ? '"' + cause.title + '" ends ' + days(cause.slip) + ' after its baseline' + (cause.critical ? ' and sits on the critical path' + (after.length ? ', so ' + listOf(after.map((x) => '"' + x + '"')) + (after.length === 1 ? ' moves' : ' move') : '') : '') + '.' : 'Open work is past its due day.', src };
181
+ }
182
+ // the ✦: move the go-live milestone to its forecast. Never the goal, the KR or the title.
183
+ let proposal = null;
184
+ if (ontrack.answer === 'no' && goLive && goLive.ms) {
185
+ const raw0 = raw.get(goLive.uid) || {}, was = dn(raw0.end != null ? raw0.end : raw0.due);
186
+ if (was != null && was < fgo) proposal = { kind: 'milestone-date', task: goLive.uid, title: goLive.title, from: iso(was), to: iso(fgo),
187
+ text: 'Move ◇ "' + goLive.title + '" to its forecast, ' + md(fgo) + '. Its baseline stays. ' + (I.goal && I.goal.title ? 'The goal "' + I.goal.title + '"' : 'The goal date') + ' and the title stay until you change them.' };
188
+ }
189
+ // the gate to leave Plan
190
+ const dated = ms.length ? ms.every((t) => t.e != null) : !!str((I.record || {}).plan_path) || tasks.some((x) => x.end || x.due);
191
+ const msRows = rows.filter((r) => r.milestone);
192
+ const owned = msRows.length > 0 && msRows.every((r) => r.ownerLinked);
193
+ const goIso = goLive ? iso(dn((raw.get(goLive.uid) || {}).end != null ? raw.get(goLive.uid).end : (raw.get(goLive.uid) || {}).due) || goLive.e) : '';
194
+ const krIso = I.goal && I.goal.byAt ? str(I.goal.byAt).slice(0, 10) : '';
195
+ const matches = !!goIso && (!krIso || krIso === goIso) && (!titleDate || titleDate === goIso) && !!(krIso || titleDate || I.end);
196
+ const unowned = msRows.filter((r) => !r.ownerLinked).map((r) => r.title);
197
+ const gate = { label: 'Gate to leave Plan', parts: [
198
+ { text: 'dated plan', ok: dated, ...(dated ? {} : { note: ms.length ? 'A milestone has no due day' : 'No milestone and no plan_path yet' }) },
199
+ { text: 'owners in People', ok: owned, ...(owned ? {} : { note: msRows.length ? 'No owner in People: ' + unowned.slice(0, 3).join(', ') + (unowned.length > 3 ? ' and ' + (unowned.length - 3) + ' more' : '') : 'No milestone yet' }) },
200
+ { text: 'go-live matches the goal', ok: matches, ...(matches ? {} : { note: !goIso ? 'Go-live has no date' : [krIso && krIso !== goIso ? 'KR says ' + md(dn(krIso)) : '', titleDate && titleDate !== goIso ? 'title says ' + md(dn(titleDate)) : '', !(krIso || titleDate || I.end) ? 'no KR date, end or title date to match' : ''].filter(Boolean).join('; ') + (goIso ? ' (go-live ' + md(dn(goIso)) + ')' : '') }) },
201
+ ] };
202
+ return { kind: 'project', gate, rows, critical: crit.map((u) => (T.get(u) || {}).title).filter(Boolean), goLive: goLive ? { uid: goLive.uid, title: goLive.title, due: iso(goLive.e) } : null,
203
+ ontrack, proposal, baselineAt: I.baselineAt || null };
204
+ }
205
+
206
+ /** Full SDLC: the gate before the first pull request reads the record's done test and kill condition (WfB). */
207
+ function sdlc(input) {
208
+ const r = (input && input.record) || {};
209
+ const dt = !!str(r.done_test_path).trim(), kill = !!str(r.kill).trim();
210
+ return { kind: 'sdlc', gate: { label: 'Gate to the first pull request', parts: [
211
+ { text: 'done test', ok: dt, ...(dt ? {} : { note: 'No done test is written yet' }) },
212
+ { text: 'kill condition', ok: kill, ...(kill ? {} : { note: 'No kill condition is written yet' }) },
213
+ ] } };
214
+ }
215
+
216
+ /** A Project as a work breakdown (pmos jira draft): each ◇ milestone in date order with the open tasks that end on or before it and after
217
+ * the milestone before; tasks after the last milestone go under "After the last milestone". → [{ milestone: { uid, title, due } | null, tasks }] */
218
+ function wbsOf(tasks) {
219
+ const T = (tasks || []).filter((x) => x && x.kind !== 'Epic').map((x) => ({ uid: x.uid || x.key, title: str(x.title), due: str(x.end || x.due).slice(0, 10) || null, owner: ownerName(x.owner) || null, milestone: !!x.milestone }));
220
+ const ms = T.filter((t) => t.milestone).sort((a, b) => String(a.due || '9').localeCompare(String(b.due || '9')));
221
+ const rest = T.filter((t) => !t.milestone);
222
+ const out = ms.map((m) => ({ milestone: m, tasks: [] }));
223
+ const tail = { milestone: null, tasks: [] };
224
+ for (const t of rest) {
225
+ const g = out.find((x) => t.due && x.milestone.due && t.due <= x.milestone.due) || (out.length && !t.due ? out[out.length - 1] : null);
226
+ (g || tail).tasks.push(t);
227
+ }
228
+ if (tail.tasks.length) out.push(tail);
229
+ return out;
230
+ }
231
+
232
+ module.exports = { project, sdlc, baselineOf, dateIn, wbsOf, forecastOf, criticalOf };
@@ -171,4 +171,24 @@ function create(deps) {
171
171
  return { tick, runProduct, refutedPass };
172
172
  }
173
173
 
174
- module.exports = { create, cases, lineOf, off, PER_DAY };
174
+ /** The refuted outcomes whose ✦ next step still waits for the PM (launch simulation W6): every current refuted verdict, less the ones whose
175
+ * ✦ the PM kept (✓) or dropped (✕). Read without a server (`pmos today --root`), so a ✦ the server has not filed yet is listed too.
176
+ * → [{ ini, title, next, say, id }] */
177
+ function waiting(root, stateDir, { today } = {}) {
178
+ if (!O.anyRefuted(root)) return [];
179
+ const D = O.refutedDrafts(O.scan(root, today ? { today } : {}));
180
+ if (!D.length) return [];
181
+ let F = null;
182
+ try { F = stateDir ? PR.read(stateDir) : null; } catch { F = null; }
183
+ const kept = F ? PR.keptIds(F) : new Set();
184
+ const out = [];
185
+ for (const d of D) {
186
+ const id = PR.idOf(d.data.initiative, 'outcome', 'refuted', d.data.ref || d.data.check);
187
+ const prev = F && F.props.get(id);
188
+ if (kept.has(id) || (prev && F.drops.has(PR.sigOf(prev)))) continue;
189
+ out.push({ ini: d.data.initiative, title: d.data.title || d.data.initiative, next: d.data.next, say: d.say, id });
190
+ }
191
+ return out;
192
+ }
193
+
194
+ module.exports = { create, cases, lineOf, off, waiting, PER_DAY };
@@ -64,7 +64,7 @@ function snapshotOf(root, o = {}) {
64
64
  try { const got = rowsLib.rowsFor(root); if (got && got.ok) for (const r of got.rows) recOf.set(r.id, r.record || null); } catch { /* no record paths */ }
65
65
  if (base.ok) {
66
66
  for (const r of base.rows) {
67
- snap.rows.push({ id: r.id, title: r.title || r.id, end: r.end || null, anchor: r.anchor || null });
67
+ snap.rows.push({ id: r.id, title: r.title || r.id, end: r.end || null, anchor: r.anchor || null, kind: require('./work-kind.js').kindOf(r.kind) });
68
68
  if (recOf.get(r.id)) files.records[r.id] = path.resolve(root, recOf.get(r.id));
69
69
  }
70
70
  } else missing.push('initiatives');
@@ -81,6 +81,8 @@ function snapshotOf(root, o = {}) {
81
81
  files.links = TL.ledgerFile(stateDir);
82
82
  files.board = safe(() => RB.ledgerFile(ctx, w));
83
83
  files.items = safe(() => require('./plan-ledgers.js').ledgerPath(root, 'plan-items'));
84
+ // an initiative's own tasks (D104, `pmos task add`) live in its task ledger, not the Board's: a milestone made there is cited there (W6)
85
+ files.tasks = safe(() => require('./task-store.js').storeFor(root).file);
84
86
  snap.links = TL.linksOf(TL.read(stateDir));
85
87
 
86
88
  // the goals, each with today's forecast
@@ -112,7 +114,7 @@ function snapshotOf(root, o = {}) {
112
114
  }
113
115
 
114
116
  /** The sources an effect cites: the line of each link, initiative record, goal record, program charter and ◇ milestone flag.
115
- * files: { links, board?, krs?, programs?, records: { [initiative]: file } } (absolute paths). */
117
+ * files: { links, board?, items?, tasks?, krs?, programs?, records: { [initiative]: file } } (absolute paths). */
116
118
  function refsOf(root, snap, files) {
117
119
  const R = { links: {}, rows: {}, goals: {}, programs: {}, tasks: {} }, F = files || {};
118
120
  const after = (k) => (line) => (line.includes(k) ? line.slice(line.indexOf(k)) : null);
@@ -126,13 +128,15 @@ function refsOf(root, snap, files) {
126
128
  if (a) R.rows[ini + ':anchor'] = a;
127
129
  const idl = lineRef(root, file, (l) => /^id:/.test(l), ini + ' record (its end is the Board\'s, from its tasks)');
128
130
  if (idl) R.rows[ini + ':end'] = idl;
131
+ const tl = lineRef(root, file, (l) => /^title:/.test(l), ini + ' title'); // W5: the date a title names
132
+ if (tl) R.rows[ini + ':title'] = tl;
129
133
  }
130
134
  for (const g of snap.goals || []) { const s = F.krs && lineRef(root, F.krs, after(jsonHas('rid', g.id)), 'goal ' + g.id); if (s) R.goals[g.id] = s; }
131
135
  for (const p of snap.programs || []) { const s = F.programs && lineRef(root, F.programs, (line) => (line.includes('"kind":"program"') ? after(jsonHas('id', p.id))(line) : null), 'program ' + p.id); if (s) R.programs[p.id] = s; }
132
136
  // each task's date: the last line of the Board or breakdown ledger that names the task and its due day (a ◇ flag line for a milestone
133
137
  // with no date line). A ledger outside the repository (a worktree's main tree) is not cited: the guard reads only inside the root.
134
138
  const inside = (f) => !!f && !path.relative(root, f).startsWith('..') && !path.isAbsolute(path.relative(root, f));
135
- const ledgers = [F.board, F.items].filter(inside).map((f) => ({ f, lines: safe(() => fs.readFileSync(f, 'utf8').split('\n')) || [] }));
139
+ const ledgers = [F.tasks, F.board, F.items].filter(inside).map((f) => ({ f, lines: safe(() => fs.readFileSync(f, 'utf8').split('\n')) || [] }));
136
140
  for (const t of snap.tasks || []) {
137
141
  const uid = t.uid || t.key, due = String(t.end || t.due || '').slice(0, 10), id = JSON.stringify(uid);
138
142
  if (!uid) continue;
@@ -13,7 +13,7 @@
13
13
  * SNAPSHOT. { today: 'YYYY-MM-DD',
14
14
  * tasks: [{ uid, title, ini, status, start, end, milestone, src }] the shape lib/task-links.js taskOf reads
15
15
  * links: [{ from, to, type, lag }] the approved links
16
- * rows: [{ id, title, end, anchor }] the initiatives (end = the committed end)
16
+ * rows: [{ id, title, end, anchor, kind? }] the initiatives (end = the committed end; kind: lib/work-kind.js)
17
17
  * goals: [{ id, title, byAt, moves: [initiative id], forecast: { state, likely } | null }] lib/forecast.js goalForecast
18
18
  * programs: [{ id, title, milestones: [{ id, name, date, waits: [initiative id], done }] }]
19
19
  * refs: { links: { 'from>to': src }, rows: { 'ini:end' | 'ini:anchor': src }, goals: { id: src }, programs: { id: src }, tasks: { uid: src } }
@@ -30,6 +30,7 @@
30
30
  const TL = require('./task-links.js');
31
31
  const FC = require('./forecast.js');
32
32
 
33
+ const KC = () => require('./kind-control.js'); // dateIn: the date a title or a KR names (W5)
33
34
  const KINDS = Object.freeze(['move', 'end', 'cut']);
34
35
  const MAX_LIST = 8;
35
36
  const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
@@ -198,6 +199,31 @@ function rehearse(snap, change) {
198
199
  if (!late0 && late1) add({ tone: 'breaks', kind: 'end', ini, text: q(iniTitle(ini)) + "'s last task would end " + TL.md(f1) + ', ' + days(f1 - end1) + ' after its committed end, ' + TL.md(end1) + '.', evidence: ev });
199
200
  else if (late0 && !late1 && f1 != null) add({ tone: 'helps', kind: 'end', ini, text: q(iniTitle(ini)) + "'s last task would end " + TL.md(f1) + ', back inside its committed end, ' + TL.md(end1) + '.', evidence: ev });
200
201
  }
202
+ // W5 (board WfC): a new end is checked against the dates the plan already promises: the date the title names, the KR's date and the
203
+ // initiative's own ◇ milestones. Each break names what to change; nothing here estimates a number.
204
+ let msChecked = 0;
205
+ if (c.kind === 'end') {
206
+ const to = TL.dn(c.to), row = rows.get(c.ini) || {}, was = row.end ? TL.dn(row.end) : null;
207
+ const td = KC().dateIn(row.title, S.today);
208
+ if (td && TL.dn(td) !== to) add({ tone: 'breaks', kind: 'title', ini: c.ini, text: 'The title ' + q(row.title) + ' says ' + TL.md(TL.dn(td)) + '. Change it to ' + TL.md(to) + ', or keep the end.', evidence: [refRow(c.ini, 'title')] });
209
+ // the KR's date and the milestones are a Project's promises (its go-live is the end); on other kinds a later end alone moves nothing
210
+ // the work still meets (Wawan's Mac, 2026-11-03), so they are read only for a Project
211
+ const proj = row.kind === 'project';
212
+ for (const g of proj ? S.goals || [] : []) {
213
+ if (!(g.moves || []).includes(c.ini)) continue;
214
+ const by = TL.dn(g.byAt), gd = KC().dateIn(g.title, S.today);
215
+ if (by != null && to > by) add({ tone: 'breaks', kind: 'goal', ini: c.ini, goal: g.id, text: 'Goal ' + q(g.title) + ' is due ' + TL.md(by) + '. The new end, ' + TL.md(to) + ', is after it. Change the goal\'s date, or keep the end.', evidence: [(R.goals || {})[g.id], refRow(c.ini, 'anchor')] });
216
+ else if (gd && TL.dn(gd) !== to && (by == null || TL.dn(gd) !== by)) add({ tone: 'breaks', kind: 'goal', ini: c.ini, goal: g.id, text: 'Goal ' + q(g.title) + ' says ' + TL.md(TL.dn(gd)) + '. Change it to ' + TL.md(to) + ', or keep the end.', evidence: [(R.goals || {})[g.id], refRow(c.ini, 'anchor')] });
217
+ }
218
+ const ms = proj ? [...base.T.values()].filter((t) => t.ini === c.ini && t.ms && !t.closed && t.e != null) : [];
219
+ msChecked = ms.length;
220
+ const last = ms.slice().sort((a, b) => b.e - a.e)[0];
221
+ for (const m of ms) {
222
+ if (!(m.e < to && (m === last || (was != null && m.e === was)))) continue;
223
+ add({ tone: 'breaks', kind: 'milestone', ini: c.ini, task: m.uid, text: '◇ ' + q(m.title) + ' is ' + TL.md(m.e) + ', before the new end. Its baseline stays; its forecast moves to ' + TL.md(to) + ' when you approve.', evidence: [refT(m.uid)] });
224
+ }
225
+ }
226
+
201
227
  // goals and program milestones: when each initiative's work lands, before and after
202
228
  const land0 = new Map(), land1 = new Map();
203
229
  for (const ini of new Set([...rows.keys(), ...inis])) { land0.set(ini, landOf(base.T, rows.get(ini), ini)); if (ini !== cutIni) land1.set(ini, landOf(TA, rowsA.get(ini), ini)); }
@@ -211,6 +237,7 @@ function rehearse(snap, change) {
211
237
  const ev = [(R.goals || {})[g.id], refRow(ini, 'anchor')];
212
238
  if (ini === cutIni) { add({ tone: 'breaks', kind: 'goal', ini, goal: g.id, text: 'Goal ' + q(g.title) + ' loses ' + q(iniTitle(ini)) + ', ' + ((g.moves || []).length === 1 ? 'the only initiative that moves it' : 'one of the ' + g.moves.length + ' initiatives that move it') + '.' + fc, evidence: ev }); continue; }
213
239
  const a = land0.get(ini), b = land1.get(ini); if (a == null || b == null) continue;
240
+ if (effects.some((e) => e.kind === 'goal' && e.goal === g.id && e.ini === ini)) continue; // said once (W5's end check above)
214
241
  if (a <= by && b > by) add({ tone: 'breaks', kind: 'goal', ini, goal: g.id, text: 'Goal ' + q(g.title) + ' is due ' + TL.md(by) + '. ' + q(iniTitle(ini)) + ', which moves it, would land ' + TL.md(b) + ', after that.' + fc, evidence: ev.concat([refRow(ini, 'end'), lastRef(ini)]) });
215
242
  else if (a > by && b <= by) add({ tone: 'helps', kind: 'goal', ini, goal: g.id, text: 'Goal ' + q(g.title) + ' is due ' + TL.md(by) + '. ' + q(iniTitle(ini)) + ', which moves it, would land ' + TL.md(b) + ', in time.' + fc, evidence: ev.concat([refRow(ini, 'end'), lastRef(ini)]) });
216
243
  }
@@ -233,7 +260,7 @@ function rehearse(snap, change) {
233
260
  const order = { breaks: 0, helps: 1, moves: 2 };
234
261
  effects.sort((x, y) => order[x.tone] - order[y.tone]);
235
262
  const counts = { breaks: 0, helps: 0, moves: 0 }; for (const e of effects) counts[e.tone]++;
236
- return { ok: true, change: c, effects, counts, checked: { tasks: T0.size, links: links0.length, goals: (S.goals || []).length, programs: (S.programs || []).length }, missing: S.missing || [], unsourced, stale, note };
263
+ return { ok: true, change: c, effects, counts, checked: { tasks: T0.size, links: links0.length, goals: (S.goals || []).length, programs: (S.programs || []).length, ...(c.kind === 'end' ? { title: true, milestones: msChecked, project: (rows.get(c.ini) || {}).kind === 'project' } : {}) }, missing: S.missing || [], unsourced, stale, note };
237
264
  }
238
265
 
239
266
  function moveDelta(T0, T1, uid) { const a = T0.get(uid), b = T1.get(uid); return a && b && a.e != null && b.e != null ? b.e - a.e : a && b && a.s != null && b.s != null ? b.s - a.s : 0; }
@@ -263,6 +290,7 @@ function dedupe(ev) { const seen = new Set(); return ev.filter((s) => { const k
263
290
  function textOf(r) {
264
291
  if (!r.ok) return ['✗ ' + r.error];
265
292
  const out = [];
293
+ if (r.checked && r.checked.title) out.push(r.checked.project ? 'Checked: the title date, the goal dates and ' + (r.checked.milestones === 1 ? '1 milestone' : (r.checked.milestones || 0) + ' milestones') + '.' : 'Checked: the date the title names.');
266
294
  if (!r.effects.length) out.push('Nothing else moves: no other task, initiative, goal or program milestone changes.');
267
295
  for (const e of r.effects) {
268
296
  out.push((e.tone === 'breaks' ? '✗ Breaks: ' : e.tone === 'helps' ? '✓ Helps: ' : '· Moves: ') + e.text);
@@ -96,6 +96,7 @@ const MODULES = Object.freeze([
96
96
  'routes-meeting-replay', // meeting-material-replay: the note, the Focus state and the shots joined for the Replay page (GET, read-only)
97
97
  'routes-meeting-material', // meeting-material-replay: the material the PM links to a meeting (GET list and suggest; page-press POST add and remove; meeting-material.jsonl)
98
98
  'routes-meeting-points', // premium-uncovered-features (meetings): the Replay's Confirm and Not right on a meeting's key points (meeting-points.jsonl)
99
+ 'routes-kind-control', // launch simulation W5: the Viewer's Project control (gate, colours, critical path, on track) and Full SDLC gate (GET, read-only)
99
100
  'routes-viewer', // premium-agreed-design (viewer): agenda minutes, what recording listens to, a next step made a drafted ticket, the report's Issue checks
100
101
  'routes-report-confirm', // premium-uncovered-features (reports): the Brief tab's Confirm and Use it (report-confirms.jsonl in the runtime folder)
101
102
  'routes-stage-tools', // stage-tools-records: the records the PM edits per stage, what PMOS holds per stage, the sprint burndown
@@ -55,7 +55,10 @@ async function handle(req, res, url, ctx) {
55
55
  let dir;
56
56
  try { dir = A.dirOf(w.root); } catch (e) { return send(409, { ok: false, error: String((e && e.message) || e) }); }
57
57
  const r = A.set(A.file(dir), { scope: b.scope, artefact: b.artefact, field: b.field, text: typeof b.text === 'string' ? b.text : '' }, g.actor);
58
- return r.ok ? send(200, { ok: true, line: pageBy(r.line) }) : send(r.status, { ok: false, error: r.error });
58
+ if (!r.ok) return send(r.status, { ok: false, error: r.error });
59
+ // a done test or kill condition lands on the record too, so the gates count it (launch simulation W6, lib/artefact-mirror.js)
60
+ const mirror = require('./artefact-mirror.js').after(w.root, r.line, A.file(dir));
61
+ return send(200, { ok: true, line: pageBy(r.line), ...(mirror ? { mirror } : {}) });
59
62
  }
60
63
  if (req.method !== 'GET') return send(405, { ok: false, error: 'the artefacts are read here; the PM edits a line with POST /api/artefacts/set' });
61
64
  if (sub === 'map') return send(200, { ok: true, artefacts: A.KEYS, rows: require('./artefacts-cli.js').mapRows() });