create-pmos 0.566.0 → 0.567.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.566.0",
3
+ "version": "0.567.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -33,6 +33,19 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.567.0",
38
+ "at": "2026-11-12T04:54:34.259Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1298,
43
+ "t": "A refuted outcome reads at risk and files its next step under the ✦",
44
+ "s": "A refuted outcome reads at risk and files its next step under the ✦",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
36
49
  {
37
50
  "v": "0.566.0",
38
51
  "at": "2026-11-12T04:39:13.320Z",
@@ -297,19 +310,6 @@
297
310
  "k": "new"
298
311
  }
299
312
  ]
300
- },
301
- {
302
- "v": "0.547.0",
303
- "at": "2026-11-09T23:58:24.564Z",
304
- "f": 4,
305
- "prs": [
306
- {
307
- "n": 1275,
308
- "t": "A Mac running PMOS keeps working unattended — minute check + Remote Control keeper",
309
- "s": "A Mac running PMOS keeps working unattended — minute check + Remote Control keeper",
310
- "k": "new"
311
- }
312
- ]
313
313
  }
314
314
  ]
315
315
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@862ddccd
1
+ kernel-source: pmos@b9606359
2
2
  assembled: 2026-11-12
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-11-12T04:39:10Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-12T04:54:30Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-11-12T04:39:10Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-12T04:54:30Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-11-12T04:39:10Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-12T04:54:30Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,17 @@
1
1
  [
2
+ {
3
+ "v": "0.567.0",
4
+ "at": "2026-11-12T04:54:34.259Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1298,
9
+ "t": "A refuted outcome reads at risk and files its next step under the ✦",
10
+ "s": "A refuted outcome reads at risk and files its next step under the ✦",
11
+ "k": "new"
12
+ }
13
+ ]
14
+ },
2
15
  {
3
16
  "v": "0.566.0",
4
17
  "at": "2026-11-12T04:39:13.320Z",
@@ -231,6 +231,8 @@ Run them in the product's repository, or pass `--root <dir>`.
231
231
  - `pmos outcomes propose [<id>]` shows PMOS's drafts, each with the lines it cites. Before the first draft of a repository it replays them on that repository's records, and shows nothing unless the replay passes.
232
232
  - `pmos outcomes declare <id> --metric "<text>" --horizon <YYYY-MM-DD>` writes the outcome and its check date, after you said yes.
233
233
  - `pmos outcomes record <id> <worked|didnt-work|cant-tell> --evidence "<text>"` records your verdict on a due check.
234
+ - When you record `didnt-work`, the initiative shows **At risk** on every page, with the check as the reason. PMOS compares the evidence with the kill condition and files one next step under the initiative's ✦. If the evidence meets the kill condition, PMOS suggests that you stop the initiative. If this is the second check that did not work, it suggests a new experiment. Otherwise it suggests one more round with a new check date. The Board's Next column asks you the same question. Nothing happens until you press ✓. Undo reverses the step.
235
+ - `pmos outcomes propose` also reads the experiment's hypothesis. When the hypothesis names a different KR from the initiative's anchor, the draft tells you.
234
236
 
235
237
  ### pmos rehearse: rehearse a change
236
238
 
@@ -351,7 +353,7 @@ An agent writes a draft or a reading with these commands, and moves an initiativ
351
353
  - `pmos workflow show-draft` shows the draft that is open.
352
354
  - `pmos workflow judge --board <id> --id <initiative> --stage <key> --runs yes|no|unsure --why <reason> --cite <where>` records PMOS's reading of an Only when stage. **unsure** makes PMOS ask you. `--undo` takes a reading back.
353
355
  - `pmos workflow of <initiative>` shows the workflow the initiative runs, its current stage, and each stage numbered as done, current or skipped. It reads the same row as the Board.
354
- - `pmos workflow move <initiative> --stage <key|name|number>` moves the initiative to a stage of its own workflow. A number counts from 1 in the workflow's order, so `--stage 5` is the fifth stage. `--why` adds the reason. The move writes the same line as a move on the Board, under the agent's name. On a board whose columns join two stages, such as **Build & Deliver**, the initiative still goes to the stage you name, and the joined column name means its first stage.
356
+ - `pmos workflow move <initiative> --stage <key|name|number>` moves the initiative to a stage of its own workflow. A number counts from 1 in the workflow's order, so `--stage 5` is the fifth stage. `--why` adds the reason. When the initiative passes stages that still have open tasks, the move lists those tasks. It does not close them. The move writes the same line as a move on the Board, under the agent's name. On a board whose columns join two stages, such as **Build & Deliver**, the initiative still goes to the stage you name, and the joined column name means its first stage.
355
357
  - `pmos workflow switch <initiative> --to <workflow id>` puts the initiative on another workflow. `--stage` picks the stage it lands in; without it, the stage is the one the Board's switch picks.
356
358
  - `pmos workflow check [<initiative>]` compares the stage that each surface shows: the Board, the Viewer and `pmos workflow of`, `pmos initiative list`, and the notes and report slides. It exits 1 and names the surfaces when two of them show different stages for one initiative. `scripts/workflow-state.js` shows the CI gate rung (`gate`), not the stage.
357
359
 
@@ -119,6 +119,7 @@ function classOfProposal(p) {
119
119
  if (!isObj(p)) return 'C';
120
120
  const c = PROPOSAL_CLASS[p.group] || 'C';
121
121
  if (p.group === 'status' && (p.items || []).some((x) => x && x.jira)) return 'C';
122
+ if (p.group === 'outcome' && p.type === 'refuted') return 'C'; // stopping or replacing an experiment is the PM's call (launch simulation W2)
122
123
  // a maybe, or a duplicate already in another initiative (type link, or an item with `other`), is a question for the PM, not a change
123
124
  // found type stage moves the initiative's stage: a stage move is C (as the Driver's `move`)
124
125
  if (p.group === 'found' && (p.type === 'stage' || p.type === 'maybe' || p.type === 'link' || (p.items || []).some((x) => x && x.other))) return 'C';
@@ -287,6 +287,8 @@ function rowOf(r0, wf, today) {
287
287
  finish: r.end ? shortDate(r.end) : 'Not planned', over: !!over, start: r.start || null, end: r.end || null,
288
288
  owner: r.owner || null, lane: r.lane || null, kind: KINDS.includes(r.kind) ? r.kind : 'product', anchor: r.anchor || null, kr: krShort(r.anchor), rank: Number.isInteger(r.rank) ? r.rank : null, warnings: (r.warnings || []).filter((w) => typeof w === 'string').slice(0, 12), epics: Array.isArray(r.epics) ? r.epics.filter((e) => typeof e === 'string').slice(0, 6) : [], updated: r.updated || null, reading: r.reading || null, overDays: over ? days(r.end, today) : 0,
289
289
  acts: actsOf(r, names),
290
+ // the PM's standing verdict on the outcome (launch simulation W2): the Next cell stops asking "did it work?" once it is answered
291
+ outcome: r.outcome && r.outcome.verdict ? { verdict: r.outcome.verdict, current: !!r.outcome.current, ...(r.outcome.next ? { next: r.outcome.next } : {}) } : null,
290
292
  holds: holdsOf(r), gaps: gapsOf(r), stageSpans: stageSpansOf(r),
291
293
  // D99: the workflow it runs and where it stands in it (lib/routes-boards.js workflowRowOf); Product feature when the server sends none
292
294
  ...wfFields(r),
@@ -19,6 +19,10 @@
19
19
  * takes a few weeks of mornings, or `pmos outcomes propose` in a sitting). A draft the PM dropped (✕) or kept is not filed again. When a
20
20
  * record has its outcome by another way (`pmos outcomes declare`, an edit), the open draft is dropped. It never writes a record: only the PM's ✓.
21
21
  *
22
+ * A REFUTED OUTCOME (launch simulation W2). Every tick (not once a day) the server reads each product's outcome ledger, and for a verdict
23
+ * that says it did not work, files PMOS's next step under the ✦ (lib/outcomes.js refutedDrafts): stop it when the evidence meets the
24
+ * kill condition, a new experiment after a second refuted check, else one more round. Class C (lib/autonomy.js): only the PM's ✓ does it.
25
+ *
22
26
  * deps: { workspaces() → [w], isLead(w), stateDirFor(w), boardOf(w, id) → board id | null, runtime() → the per-user state folder, open(now),
23
27
  * env, every (ms, its own timer), mayRun(), warn(what, err) }
24
28
  */
@@ -32,12 +36,17 @@ const off = (env) => flagOff((env || process.env).PMOS_OUTCOMES);
32
36
  const localDay = (ms) => { const d = new Date(ms); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
33
37
  const guardLib = () => { try { return require('./ai-guard.js'); } catch { return null; } };
34
38
  const versionOf = (w) => O.VERSION + ':' + w.id;
35
- const typeOf = (d) => (d.data.kind === 'undated' ? 'date' : 'new');
39
+ const typeOf = (d) => (d.data.kind === 'undated' ? 'date' : d.data.kind === 'refuted' ? 'refuted' : 'new');
36
40
 
37
41
  /** The proposals line a draft becomes. */
38
42
  function lineOf(d, board, run) {
39
43
  const type = typeOf(d), ini = d.data.initiative;
40
44
  const sources = d.claims.flatMap((c) => c.sources).map((s) => ({ label: s.label, ref: s.ref }));
45
+ if (type === 'refuted') {
46
+ // one per check: a later refuted check files again (its key is the check's own line)
47
+ const c = PR.clean('outcome', 'refuted', { title: d.title, why: d.say, sources, items: [{ id: 'next', title: O.NEXT_WORDS[d.data.next], ...(d.data.horizon ? { due: d.data.horizon } : {}) }], data: d.data });
48
+ return c.error ? null : { kind: 'propose', ini, board, run, id: PR.idOf(ini, 'outcome', type, d.data.ref || d.data.check), ...c.prop };
49
+ }
41
50
  const c = PR.clean('outcome', type, { title: type === 'date' ? 'A date to check the outcome' : 'What should change once it ships', why: d.say, sources,
42
51
  items: [{ id: 'outcome', title: d.data.metric, due: d.data.horizon }], data: { metric: d.data.metric, horizon: d.data.horizon } });
43
52
  if (c.error) return null;
@@ -47,7 +56,7 @@ function lineOf(d, board, run) {
47
56
  /** One product's replay cases: its own drafts must all pass, and an initiative with nothing to cite gets no draft. */
48
57
  function cases(S, list) {
49
58
  const out = [{ name: 'the drafts of ' + S.root.split(/[\\/]/).pop(), run: async () => list.slice(0, PER_DAY), expect: { filed: Math.min(PER_DAY, list.length) } }];
50
- out.push({ name: 'nothing to cite, no draft', run: async () => O.drafts({ ...S, due: [], undated: [], missing: [{ id: 'zz-no-source', title: 'No source', fm: {}, prd: '', anchor: '' }] }, { tasks: [] }).drafts, expect: { none: true } });
59
+ out.push({ name: 'nothing to cite, no draft', run: async () => O.drafts({ ...S, subjects: [], due: [], undated: [], missing: [{ id: 'zz-no-source', title: 'No source', fm: {}, prd: '', anchor: '' }] }, { tasks: [] }).drafts, expect: { none: true } });
51
60
  return out;
52
61
  }
53
62
 
@@ -64,7 +73,7 @@ function create(deps) {
64
73
  // a record that has its outcome now: its open draft goes (zero is silence)
65
74
  const has = new Map(S.subjects.map((it) => [it.id, it]));
66
75
  for (const p of F.props.values()) {
67
- if (p.group !== 'outcome' || kept.has(p.id)) continue;
76
+ if (p.group !== 'outcome' || p.type === 'refuted' || kept.has(p.id)) continue; // a refuted outcome's next step: refutedPass keeps it
68
77
  const it = has.get(p.ini), sig = PR.sigOf(p);
69
78
  if (F.drops.has(sig)) continue;
70
79
  if (!it || (it.metric && (p.type === 'new' || it.horizon))) PR.append(dir, { by: 'pmos:outcomes' }, { kind: 'drop', ini: p.ini, sig });
@@ -92,8 +101,53 @@ function create(deps) {
92
101
  return { ws: w.id, filed: (r.filed || []).length, held: !!r.held, off: r.off || null };
93
102
  }
94
103
 
104
+ /** A refuted outcome's next step (launch simulation W2): filed at the tick after the PM's verdict, not once a day. Quiet hours do not
105
+ * hold it back: the PM just recorded the verdict. One ✦ per check; a ✦ the PM kept or dropped is not filed again. */
106
+ async function refutedPass(w, { now = Date.now() } = {}) {
107
+ const dir = deps.stateDirFor(w); if (!dir) return { ws: w.id, filed: 0 };
108
+ if (!O.anyRefuted(w.root)) return { ws: w.id, filed: 0 }; // most products: no refuted check, so no scan every tick
109
+ const S = O.scan(w.root, { today: localDay(now) });
110
+ const D = O.refutedDrafts(S);
111
+ const F = PR.read(dir), kept = PR.keptIds(F), fresh = [];
112
+ const live = new Set(D.map((d) => d.data.initiative + '|' + d.data.ref));
113
+ for (const p of F.props.values()) {
114
+ if (p.group !== 'outcome' || p.type !== 'refuted' || kept.has(p.id) || F.drops.has(PR.sigOf(p))) continue;
115
+ if (!live.has(p.ini + '|' + ((p.data && (p.data.ref || p.data.check)) || ''))) PR.append(dir, { by: 'pmos:outcomes' }, { kind: 'drop', ini: p.ini, sig: PR.sigOf(p) }); // answered another way: zero is silence
116
+ }
117
+ for (const d of D) {
118
+ const board = deps.boardOf(w, d.data.initiative); if (!board) continue;
119
+ const l = lineOf(d, board, ''); if (!l) continue;
120
+ const prev = F.props.get(l.id);
121
+ if (kept.has(l.id) || (prev && (F.drops.has(PR.sigOf(prev)) || prev.data.next === l.data.next))) continue;
122
+ fresh.push({ d, board });
123
+ }
124
+ if (!fresh.length) return { ws: w.id, filed: 0 };
125
+ const AG = guardLib(); if (!AG) return { ws: w.id, filed: 0, why: 'the shared guard is not installed' };
126
+ const rt = deps.runtime && deps.runtime(), version = versionOf(w), run = 'or' + now.toString(36) + crypto.randomBytes(3).toString('hex');
127
+ if (!AG.off(O.JOB, { env: deps.env || process.env, settingsDir: rt }) && !AG.ready(rt, O.JOB, version)) {
128
+ const rep = await AG.replay(O.JOB, version, cases(S, fresh.map((x) => x.d)), { root: w.root, stateDir: rt, max: PER_DAY });
129
+ if (!rep.ok) { warn('outcomes replay ' + w.id, new Error(rep.failed.map((f) => f.name + ': ' + f.why).join('; '))); return { ws: w.id, filed: 0, replay: rep }; }
130
+ }
131
+ const byId = new Map(fresh.map((x) => [x.d.id, x]));
132
+ const r = await AG.file({ job: O.JOB, version, run, root: w.root, stateDir: rt, settingsDir: rt, env: deps.env || process.env, max: PER_DAY }, fresh.map((x) => x.d),
133
+ async (acc) => { for (const p of acc) { const x = byId.get(p.id); const l = x && lineOf(x.d, x.board, run); if (l) PR.append(dir, { by: 'agent:outcomes' }, l); } });
134
+ return { ws: w.id, filed: (r.filed || []).length, held: !!r.held, off: r.off || null };
135
+ }
136
+
95
137
  async function tick({ now = Date.now() } = {}) {
96
138
  if (off(deps.env) || busy) return { off: off(deps.env), running: busy };
139
+ busy = true;
140
+ const refuted = [];
141
+ try {
142
+ for (const w of deps.workspaces()) {
143
+ try { if (deps.isLead && !deps.isLead(w)) continue; } catch { continue; }
144
+ try { refuted.push(await refutedPass(w, { now })); } catch (e) { warn('outcomes refuted ' + w.id, e); }
145
+ }
146
+ } finally { busy = false; }
147
+ const r = await dailyTick({ now });
148
+ return { ...r, refuted };
149
+ }
150
+ async function dailyTick({ now = Date.now() } = {}) {
97
151
  let open = true;
98
152
  try { open = deps.open ? !!deps.open(now) : true; } catch { open = true; }
99
153
  if (!open) return { closed: true };
@@ -114,7 +168,7 @@ function create(deps) {
114
168
  const t = setInterval(() => { try { if (deps.mayRun && !deps.mayRun()) return; } catch { /* no lock: run */ } tick({}).catch((e) => warn('outcomes tick', e)); }, deps.every);
115
169
  if (t.unref) t.unref();
116
170
  }
117
- return { tick, runProduct };
171
+ return { tick, runProduct, refutedPass };
118
172
  }
119
173
 
120
174
  module.exports = { create, cases, lineOf, off, PER_DAY };
@@ -47,7 +47,8 @@ function repoRoot(cwd) {
47
47
  }
48
48
  const wsIdOf = (root) => { try { return require('./driver.js').wsIdOf(root); } catch { return require('crypto').createHash('sha1').update(path.resolve(root)).digest('hex').slice(0, 10); } };
49
49
  const draftText = (p) => `✦ ${p.title}\n ${p.say}\n${p.claims.map((c) => ' · ' + c.text + ' [' + c.sources.map((s) => s.ref).join(', ') + ']').join('\n')}`
50
- + (p.data && p.data.kind !== 'due' ? `\n Yes → pmos outcomes declare ${p.data.initiative} --metric ${JSON.stringify(p.data.metric)} --horizon ${p.data.horizon}`
50
+ + (p.data && p.data.kind === 'refuted' ? `\n It waits under the initiative's ✦ for the PM's ✓ (${O.NEXT_WORDS[p.data.next]}); a ✕ with a reason leaves it as it is.`
51
+ : p.data && p.data.kind !== 'due' ? `\n Yes → pmos outcomes declare ${p.data.initiative} --metric ${JSON.stringify(p.data.metric)} --horizon ${p.data.horizon}`
51
52
  : p.data ? `\n Verdict → pmos outcomes record ${p.data.initiative} worked|didnt-work|cant-tell --evidence "<what shows it>"` : '');
52
53
 
53
54
  async function run(argv, { say = (s) => console.log(s), env = process.env, cwd = process.cwd(), now = Date.now(), isTTY, runtime } = {}) {
@@ -132,6 +133,11 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
132
133
  if (!r.ok) return fail(r.error);
133
134
  if (flags.json) { say(JSON.stringify({ ok: true, file: r.file, line: r.line })); return 0; }
134
135
  say(`✓ ${id}: ${disposition} — ${r.line.evidence} (${r.file}). Commit it to keep it.`);
136
+ // launch simulation W2: a refuted outcome reads at risk on every surface now, and PMOS says the next step it files under the ✦
137
+ if (disposition === 'refuted') {
138
+ const d = O.refutedDrafts(O.scan(root, { today }), { only: id })[0];
139
+ if (d) { say(` Its status reads at risk until you pick the next step. PMOS suggests: ${O.NEXT_WORDS[d.data.next]}.`); say(' ' + d.say); say(' The workspace files it under the initiative\'s ✦ for your ✓.'); }
140
+ }
135
141
  return 0;
136
142
  }
137
143
 
@@ -78,6 +78,10 @@ function ledger(root, L, name) {
78
78
  return files.flatMap(jsonRows);
79
79
  }
80
80
 
81
+ /** The record's check date moved past the one a check answered: the check line's own horizon (written since launch simulation W2), else its
82
+ * date. Then the outcome is open again. */
83
+ const reopened = (it, row) => !!(it.horizon && it.horizon > String(row.horizon || row.date || String(row.at || '').slice(0, 10)));
84
+
81
85
  const STOPPED = new Set(['paused', 'cancelled', 'canceled', 'stopped', 'dropped', 'archived', 'killed']);
82
86
  function workGroup(root) { try { return require('./initiative-rows.js').workGroupOf(root) || {}; } catch { return {}; } }
83
87
 
@@ -123,7 +127,9 @@ function scan(root, { today = todayOf() } = {}) {
123
127
  subjects.push(it);
124
128
  if (!it.metric) { if (it.accepted) shippedWithout++; else missing.push(it); continue; }
125
129
  const d = disposedBy.get(id);
126
- if (d) disposed.push({ ...it, disposition: d.disposition });
130
+ // a check date moved past the one the last check answered (the PM chose one more round on a refuted outcome) opens the outcome again
131
+ const checked = d && !reopened(it, d);
132
+ if (checked) disposed.push({ ...it, disposition: d.disposition });
127
133
  else if (!it.horizon) undated.push(it);
128
134
  else if (it.horizon <= today) due.push(it);
129
135
  else pending.push(it);
@@ -193,8 +199,11 @@ function anchorMetric(root, it) {
193
199
  if (i < 0) continue;
194
200
  const text = Ls[i];
195
201
  const cells = text.split('|').map((c) => c.trim()).filter(Boolean);
196
- const words = cells.length > 1 ? cells.filter((c) => !c.includes(token)).sort((p, q) => q.length - p.length)[0] : text.replace(token, '');
197
- const m = metricText(String(words || '').replace(/^[:\s—–-]+/, ''));
202
+ // the KR's own words, without its list marker, its bold and its id: "- **KR1** — 2,000 …" and "- **KR1 —** 2,000 …" read "2,000 …"
203
+ // (the launch simulation drafted "Moves KR1: — 2,000 …")
204
+ const bare = text.replace(/^\s*(?:[-*+]|\d+[.)])\s+/, '').replace(/\*\*/g, '').replace(/`/g, '');
205
+ const words = cells.length > 1 ? cells.filter((c) => !c.includes(token)).sort((p, q) => q.length - p.length)[0] : bare.replace(token, '');
206
+ const m = metricText(String(words || '').replace(/^[:\s—–.-]+/, ''));
198
207
  if (m.replace(/[^A-Za-z0-9]/g, '').length < 12) continue;
199
208
  return { metric: 'Moves ' + a + ': ' + m, source: src(root, f, i + 1, text, 'Anchor ' + clip(a, 40)) };
200
209
  }
@@ -257,15 +266,21 @@ function undatedDraft(S, it, tasks) {
257
266
  }
258
267
 
259
268
  function missingDraft(S, it, tasks) {
260
- const m = prdMetric(S.root, it) || anchorMetric(S.root, it);
269
+ // the experiment's hypothesis is its predicted outcome (D107): read it beside the anchor, and say when the two name different KRs
270
+ const hyp = experimentField(S.root, it, 'hypothesis');
271
+ const other = hyp ? krMismatch(hyp.text, it.anchor) : null;
272
+ const m = prdMetric(S.root, it) || (hyp && !other ? { metric: metricText(hyp.text), source: hyp.source, hyp: true } : null) || anchorMetric(S.root, it);
261
273
  if (!m) return null; // nothing to cite: the PM names it (proven-only)
262
274
  const h = horizonFor(S, it, tasks);
263
- const claims = [claim(`${m.source.label.startsWith('PRD') ? 'Its PRD' : 'Its anchor'} says: ${m.metric}`, [m.source])];
275
+ const said = m.hyp ? 'Its hypothesis' : m.source.label.startsWith('PRD') ? 'Its PRD' : 'Its anchor';
276
+ const claims = [claim(`${said} says: ${m.metric}`, [m.source])];
277
+ if (hyp && !m.hyp) claims.push(claim(`Its hypothesis: ${clip(hyp.text, 160)}`, [hyp.source]));
264
278
  if (h.source) claims.push(claim(`Its last task is due on ${short(h.lastDue)}`, [h.source]));
279
+ const flag = other ? ` Its hypothesis names ${other}, but it is anchored to ${it.anchor}: check which one it should move before you say yes.` : '';
265
280
  return {
266
- id: `outcome-new:${it.id}`, title: `Expected outcome for ${clip(it.title, 80)}`, confidence: claims.length > 1 && m.source.label.startsWith('PRD') ? 'medium' : 'low', claims,
267
- say: `It has no expected outcome yet. I suggest: "${m.metric}", checked on ${short(h.horizon)} (${h.why}).`,
268
- data: { kind: 'missing', initiative: it.id, metric: m.metric, horizon: h.horizon },
281
+ id: `outcome-new:${it.id}`, title: `Expected outcome for ${clip(it.title, 80)}`, confidence: other ? 'low' : claims.length > 1 && !said.endsWith('anchor') ? 'medium' : 'low', claims,
282
+ say: `It has no expected outcome yet. I suggest: "${m.metric}", checked on ${short(h.horizon)} (${h.why}).${flag}`,
283
+ data: { kind: 'missing', initiative: it.id, metric: m.metric, horizon: h.horizon, ...(other ? { mismatch: other } : {}) },
269
284
  };
270
285
  }
271
286
 
@@ -273,7 +288,7 @@ function missingDraft(S, it, tasks) {
273
288
  function drafts(S, { only = null, tasks } = {}) {
274
289
  const T = tasks || tasksOf(S.root);
275
290
  const pick = (list) => (only ? list.filter((it) => it.id === only) : list);
276
- const out = [], ask = [];
291
+ const out = refutedDrafts(S, { only }), ask = []; // a refuted outcome's next step comes first: the status already reads at risk
277
292
  for (const it of pick(S.due)) out.push(dueDraft(S, it));
278
293
  for (const it of pick(S.undated)) out.push(undatedDraft(S, it, T));
279
294
  for (const it of pick(S.missing)) {
@@ -283,6 +298,167 @@ function drafts(S, { only = null, tasks } = {}) {
283
298
  return { drafts: out, ask };
284
299
  }
285
300
 
301
+ /* ── the experiment (D107): its hypothesis and kill condition, from the record or the Experiment artefact ───────────────────────── */
302
+
303
+ /** The newest set of one Experiment field in the product's artefact ledger, with its path:line. → { text, file, n, line } | null */
304
+ function artefactField(root, id, field) {
305
+ let dir = null; try { dir = require('./driver.js').stateDirOf(root); } catch { dir = null; }
306
+ if (!dir) return null;
307
+ const file = path.join(dir, 'artefacts.jsonl'), Ls = linesOf(file);
308
+ if (!Ls) return null;
309
+ const scopes = new Set(['experiment:' + id, 'initiative:' + id]);
310
+ let best = null; const undone = new Set();
311
+ Ls.forEach((l, i) => {
312
+ let o = null; try { o = JSON.parse(l); } catch { return; }
313
+ if (!o || !scopes.has(o.scope)) return;
314
+ if (o.ev === 'undo' && o.ref) undone.add(o.ref);
315
+ if (o.ev === 'set' && o.artefact === 'experiment' && o.field === field && typeof o.text === 'string') best = { text: o.text, file, n: i + 1, line: l, id: o.id };
316
+ });
317
+ return best && !undone.has(best.id) && best.text.trim() ? best : null;
318
+ }
319
+ /** The experiment's hypothesis or kill condition: the record's own line (`hypothesis:`, `kill:`) wins, else the Experiment artefact.
320
+ * → { text, source: { label, ref, quote } } | null */
321
+ function experimentField(root, it, field) {
322
+ const label = field === 'kill' ? 'Kill condition' : 'Hypothesis';
323
+ const e = it.fm && it.fm[field];
324
+ if (e && String(e.value || '').trim()) return { text: String(e.value).trim(), source: src(root, path.join(root, it.record), e.n, e.text, label) };
325
+ const a = artefactField(root, it.id, field);
326
+ return a ? { text: a.text.trim(), source: src(root, a.file, a.n, a.line, label) } : null;
327
+ }
328
+ const KR_IN = /\bKR-?[A-Z]?\d+(?:\.\d+)*\b/gi;
329
+ const norm = (k) => k.toUpperCase().replace(/-/g, '');
330
+ const krOf = (s) => [...new Set((String(s || '').match(KR_IN) || []).map(norm))];
331
+ /** A hypothesis that names a KR the anchor does not: the draft says so (launch simulation, proposal 2). → 'KR-A2' (as written) | null */
332
+ function krMismatch(hypothesis, anchor) {
333
+ const named = String(hypothesis || '').match(KR_IN) || [], a = krOf(anchor);
334
+ if (!named.length || !a.length || named.some((k) => a.includes(norm(k)))) return null;
335
+ return [...new Set(named)].join(', ');
336
+ }
337
+
338
+ /* ── a refuted outcome: the kill condition, the next step, the status ─────────────────────────────────────────────────────────── */
339
+
340
+ const NUM = /(\d{1,3}(?:,\d{3})+|\d+(?:\.\d+)?)\s*(%)?/g;
341
+ const numbersIn = (s) => {
342
+ const M = '(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\\.?';
343
+ const t = String(s || '').replace(/\b\d{4}-\d{2}-\d{2}\b/g, ' ') // a date is not a reading: 2026-11-11, 11 Nov, Nov 11, Q4, week 3
344
+ .replace(new RegExp('\\b\\d{1,2}(?:st|nd|rd|th)?\\s+' + M, 'gi'), ' ').replace(new RegExp('\\b' + M + '\\s+\\d{1,2}\\b', 'gi'), ' ').replace(/\b(?:q[1-4]|week\s*\d+|w\d+)\b/gi, ' ');
345
+ const out = [];
346
+ for (const m of t.matchAll(NUM)) {
347
+ if (!m[2] && !m[1].includes(',') && /^(19|20)\d\d$/.test(m[1])) continue; // a year
348
+ out.push({ v: Number(m[1].replace(/,/g, '')), pct: !!m[2] });
349
+ }
350
+ return out;
351
+ };
352
+ const LT = /(fewer than|less than|lower than|below|under|at most|no more than|drops? (?:to|below)|falls? (?:to|below)|<=?)\s*(\d{1,3}(?:,\d{3})+|\d+(?:\.\d+)?)\s*(%)?/i;
353
+ const GT = /(more than|greater than|higher than|above|over|at least|exceeds?|rises? (?:to|above)|>=?)\s*(\d{1,3}(?:,\d{3})+|\d+(?:\.\d+)?)\s*(%)?/i;
354
+ /** Does the evidence meet the kill condition? Only a number on the same side of the condition's own number counts, so a condition with no
355
+ * number, or evidence with none, is not judged (null): the PM judges it. → { met: true|false|null, why } */
356
+ function killMet(kill, evidence) {
357
+ if (!String(kill || '').trim()) return { met: null, why: 'It names no kill condition to compare with.' };
358
+ const lt = LT.exec(kill), gt = lt ? null : GT.exec(kill), m = lt || gt;
359
+ if (!m) return { met: null, why: 'Its kill condition has no number I can compare with.' };
360
+ const bar = Number(m[2].replace(/,/g, '')), pct = !!m[3];
361
+ const seen = numbersIn(evidence).filter((x) => x.pct === pct && x.v !== bar);
362
+ if (!seen.length) return { met: null, why: 'The evidence has no number to compare with its kill condition.' };
363
+ const hit = seen.find((x) => (lt ? (/at most|no more than|<=/i.test(m[1]) ? x.v <= bar : x.v < bar) : (/at least|>=/i.test(m[1]) ? x.v >= bar : x.v > bar)));
364
+ const fmt = (x) => x.v.toLocaleString('en-US') + (x.pct ? '%' : '');
365
+ return hit ? { met: true, why: `The evidence reads ${fmt(hit)}, which meets its kill condition.` }
366
+ : { met: false, why: `The evidence reads ${fmt(seen[0])}, which does not meet its kill condition.` };
367
+ }
368
+
369
+ /** Does any outcome ledger of the repository hold a refuted check? A cheap read before a scan. */
370
+ function anyRefuted(root) {
371
+ const L = layoutOf(path.resolve(root));
372
+ return [...new Set([path.join(L.runsDir, 'outcome_checks.jsonl'), path.join(root, 'pmos', 'state', 'outcome_checks.jsonl'), path.join(root, 'planning', 'runs', 'outcome_checks.jsonl')])]
373
+ .some((f) => { try { return fs.readFileSync(f, 'utf8').includes('"refuted"'); } catch { return false; } });
374
+ }
375
+ /** Every outcome check of the repository with its path:line, oldest first. → [{ row, ref, quote, file, n }] */
376
+ function checkLines(root, L) {
377
+ const files = [...new Set([path.join(L.runsDir, 'outcome_checks.jsonl'), path.join(root, 'pmos', 'state', 'outcome_checks.jsonl'), path.join(root, 'planning', 'runs', 'outcome_checks.jsonl')])];
378
+ const out = [];
379
+ for (const f of files) (linesOf(f) || []).forEach((l, i) => { let o = null; try { o = JSON.parse(l); } catch { return; } if (o && o.initiative_id && DISPOSITIONS.includes(o.disposition)) out.push({ row: o, file: f, n: i + 1, ref: rel(root, f) + ':' + (i + 1), quote: cut(l) }); });
380
+ return out.sort((a, b) => String(a.row.at || a.row.date || '').localeCompare(String(b.row.at || b.row.date || '')));
381
+ }
382
+
383
+ /** The verdict that stands on each initiative: its newest outcome check. A refuted one is CURRENT until the PM chose what next: a check date
384
+ * after the check (iterate), or a stop (lifecycle, which drops it from the scan). → Map id → { it, verdict, date, evidence, check, refutes,
385
+ * current, kill, killMet, hypothesis, next } where next is PMOS's recommendation for a current refuted one: kill | iterate | new */
386
+ function verdictsOf(S) {
387
+ const by = new Map(), refutes = new Map();
388
+ for (const c of checkLines(S.root, S.layout)) {
389
+ const id = String(c.row.initiative_id);
390
+ by.set(id, c);
391
+ if (c.row.disposition === 'refuted') refutes.set(id, (refutes.get(id) || 0) + 1);
392
+ }
393
+ const out = new Map();
394
+ for (const it of S.subjects) {
395
+ const c = by.get(it.id); if (!c) continue;
396
+ const date = String(c.row.date || String(c.row.at || '').slice(0, 10));
397
+ const v = { it, verdict: c.row.disposition, date, evidence: String(c.row.evidence || ''), check: c, refutes: refutes.get(it.id) || 0 };
398
+ v.current = v.verdict === 'refuted' && !reopened(it, c.row);
399
+ if (v.current) {
400
+ v.kill = experimentField(S.root, it, 'kill');
401
+ v.hypothesis = experimentField(S.root, it, 'hypothesis');
402
+ v.killMet = killMet(v.kill && v.kill.text, v.evidence);
403
+ v.next = v.killMet.met === true ? 'kill' : v.refutes >= 2 ? 'new' : 'iterate';
404
+ }
405
+ out.set(it.id, v);
406
+ }
407
+ return out;
408
+ }
409
+ /** What a row carries for the status signal and the Board's Next cell. → { verdict, date, evidence, current, next } | null */
410
+ const outcomeOfRow = (v) => (v ? { verdict: v.verdict, date: v.date, evidence: clip(v.evidence, 300), current: !!v.current, ...(v.current ? { next: v.next } : {}) } : null);
411
+ /** The verdicts of a repository for the rows (lib/routes-boards.js), in one read. → Map id → outcomeOfRow */
412
+ function rowOutcomes(root, { today = todayOf() } = {}) {
413
+ const out = new Map();
414
+ try { for (const [id, v] of verdictsOf(scan(root, { today }))) out.set(id, outcomeOfRow(v)); } catch { /* no verdicts read: rows say nothing */ }
415
+ return out;
416
+ }
417
+
418
+ const NEXT_WORDS = { kill: 'Stop it', iterate: 'One more round, then check again', new: 'Start a new experiment and stop this one' };
419
+ /** The ✦ for a current refuted outcome: PMOS's next step, with what it rests on. */
420
+ function refutedDraft(S, v) {
421
+ // one more round: a new check DAYS_AFTER days out, and always past the date the refuted check answered (so the outcome opens again)
422
+ const it = v.it, answered = String(v.check.row.horizon || v.date), h0 = addDays(S.today, DAYS_AFTER), h = h0 > answered ? h0 : addDays(answered, DAYS_AFTER);
423
+ const claims = [claim(`The check on ${short(v.date)} said it did not work: ${clip(v.evidence, 160)}`, [{ label: 'Outcome check', ref: v.check.ref, quote: v.check.quote }])];
424
+ if (v.kill) claims.push(claim(`Its kill condition: ${clip(v.kill.text, 160)}`, [v.kill.source]));
425
+ if (v.hypothesis) claims.push(claim(`Its hypothesis: ${clip(v.hypothesis.text, 160)}`, [v.hypothesis.source]));
426
+ const said = `The check on ${short(v.date)} said "${clip(v.it.metric, 100)}" did not happen: ${clip(v.evidence, 140)}.`;
427
+ const say = v.next === 'kill' ? `${said} ${v.killMet.why} I suggest stopping it. ✓ cancels it with this reason; Undo brings it back.`
428
+ : v.next === 'new' ? `${said} This is check ${v.refutes} that said it did not work, so I suggest a new experiment on ${it.anchor || 'the same goal'} and stopping this one. ${v.killMet.met === null ? v.killMet.why + ' ' : ''}✓ adds the new experiment and cancels this one; Undo puts both back.`
429
+ : `${said} ${v.killMet.why} I suggest one more round: a task to change what the check showed, and a new check on ${short(h)}. ✓ does both; Undo takes them back.`;
430
+ return {
431
+ id: `outcome-refuted:${it.id}:${v.check.n}`, title: `${NEXT_WORDS[v.next]}: ${clip(it.title, 80)}`, confidence: v.killMet.met === null ? 'low' : 'medium', claims, say,
432
+ data: { kind: 'refuted', initiative: it.id, next: v.next, check: v.date, ref: v.check.ref, evidence: clip(v.evidence, 300), metric: it.metric, horizon: v.next === 'iterate' ? h : null,
433
+ killMet: v.killMet.met, anchor: it.anchor || '', title: it.title, lane: it.lane, work: (it.fm.kind && it.fm.kind.value) || '' },
434
+ };
435
+ }
436
+ /** The ✦ next steps of every current refuted outcome (or of one initiative). → [proposal] */
437
+ function refutedDrafts(S, { only = null } = {}) {
438
+ const out = [];
439
+ for (const v of verdictsOf(S).values()) if (v.current && (!only || v.it.id === only)) out.push(refutedDraft(S, v));
440
+ return out;
441
+ }
442
+
443
+ /** The PM's stop of an experiment, as the Board's ⋯ Cancel writes it (D70 lifecycle line, POST /api/lifecycle): the ✓ of a "Stop it" or
444
+ * "Start a new experiment" ✦, and its Undo (state active). → { ok, file, from } | { ok: false, error } */
445
+ function setLife(root, id, state, reason, actor) {
446
+ root = path.resolve(root);
447
+ if (!ID_RE.test(String(id || ''))) return { ok: false, error: 'name the initiative by its id' };
448
+ if (!['cancelled', 'active'].includes(state)) return { ok: false, error: 'state is cancelled or active' };
449
+ const L = layoutOf(root), dir = L.runsDir, file = path.join(dir, 'lifecycle.jsonl');
450
+ let from = null;
451
+ for (const r of jsonRows(file)) if (r && r.initiative_id === id && r.state) from = String(r.state);
452
+ try {
453
+ fs.mkdirSync(dir, { recursive: true });
454
+ const st = (() => { try { return fs.lstatSync(file); } catch { return null; } })();
455
+ if (st && !st.isFile()) return { ok: false, error: 'the lifecycle ledger is not a plain file — nothing was saved' };
456
+ let pm = 'pm'; try { pm = require('./actor.js').PM_SLUG || pm; } catch { /* default */ }
457
+ fs.appendFileSync(file, JSON.stringify({ initiative_id: id, state, reason: String(reason || '').slice(0, 500), pm, by: (actor && actor.by) || 'agent:unknown', via: (actor && actor.via) || 'ui', at: new Date().toISOString() }) + '\n');
458
+ return { ok: true, file: rel(root, file), from };
459
+ } catch (e) { return { ok: false, error: 'the lifecycle ledger could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
460
+ }
461
+
286
462
  /* ── the outcome ledger: the one writer behind `pmos outcomes record` ───────────────────────────────────────── */
287
463
 
288
464
  /** Append the PM's verdict. Evidence is required for all three (an `inconclusive` with no reason is the cheapest lie). */
@@ -303,10 +479,11 @@ function recordCheck(root, { initiative, disposition, evidence, by, via }, { now
303
479
  fs.mkdirSync(dir, { recursive: true });
304
480
  const st = (() => { try { return fs.lstatSync(file); } catch { return null; } })();
305
481
  if (st && !st.isFile()) return { ok: false, error: 'the outcome ledger is not a plain file — nothing was saved' };
306
- const line = { initiative_id: initiative, disposition, evidence: ev, date: todayOf(now), at: new Date(now).toISOString(), by: by || 'agent:unknown', via: via || 'cli' };
482
+ const line = { initiative_id: initiative, disposition, evidence: ev, date: todayOf(now), ...(it.horizon ? { horizon: it.horizon } : {}), at: new Date(now).toISOString(), by: by || 'agent:unknown', via: via || 'cli' };
307
483
  fs.appendFileSync(file, JSON.stringify(line) + '\n');
308
484
  return { ok: true, file: rel(root, file), line };
309
485
  } catch (e) { return { ok: false, error: 'the outcome ledger could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
310
486
  }
311
487
 
312
- module.exports = { VERSION, JOB, DAYS_AFTER, DEFAULT_DAYS, DISPOSITIONS, scan, drafts, prdMetric, anchorMetric, horizonFor, recordCheck, todayOf, short, frontOf };
488
+ module.exports = { VERSION, JOB, DAYS_AFTER, DEFAULT_DAYS, DISPOSITIONS, scan, drafts, prdMetric, anchorMetric, horizonFor, recordCheck, todayOf, short, frontOf,
489
+ experimentField, krMismatch, killMet, anyRefuted, verdictsOf, rowOutcomes, outcomeOfRow, refutedDrafts, setLife, NEXT_WORDS };
@@ -16,7 +16,8 @@
16
16
  * status "looks done": the evidence says the work happened
17
17
  * names tidy names, before → after; the detail cut moves to the task's notes
18
18
  * outcome the expected outcome and its check date (D57; lib/outcomes.js, filed by lib/outcome-props.js): type new (no outcome yet) or date
19
- * (an outcome with no date). data { metric, horizon }; one item { id: 'outcome', title: the metric, due: the date }. Always section
19
+ * (an outcome with no date). Type refuted (launch simulation W2): the check said it did not work, and PMOS recommends the next
20
+ * step, data { next: kill | iterate | new, check, evidence, horizon (iterate) }; class C, so only the PM's ✓ does it. data { metric, horizon }; one item { id: 'outcome', title: the metric, due: the date }. Always section
20
21
  * 'check': its own ✓, never Keep all. ✓ writes the record's outcome_metric and outcome_horizon lines (lib/initiative-writer.js)
21
22
  * description the record's own description (initiative-description-field; filed by lib/description-props.js): type new (none yet) or
22
23
  * enrich (the PRD says more). data { text, from? }; one item { id: 'description', title: the text cut }. Always section 'check'.
@@ -72,7 +73,7 @@ const KINDS = new Set(['epoch', 'look', 'src', 'end', 'propose', 'drop', 'keep',
72
73
  const EXPIRE_DAYS = 14;
73
74
  const EXPIRE_WHY = 'No answer in 14 days, so I left it as it was.';
74
75
  const GROUPS = ['found', 'dates', 'status', 'names', 'outcome', 'description'];
75
- const TYPES = { found: ['stage', 'docs', 'tasks', 'link', 'maybe', 'unplaced'], dates: ['stage', 'task'], status: ['done'], names: ['tidy'], outcome: ['new', 'date'], description: ['new', 'enrich'] };
76
+ const TYPES = { found: ['stage', 'docs', 'tasks', 'link', 'maybe', 'unplaced'], dates: ['stage', 'task'], status: ['done'], names: ['tidy'], outcome: ['new', 'date', 'refuted'], description: ['new', 'enrich'] };
76
77
  const SOURCES = ['drive', 'docs', 'sheets', 'slides', 'jira', 'calendar', 'notes', 'mail', 'slack', 'confluence', 'chat', 'repo'];
77
78
  const SOURCE_NAMES = { drive: 'Drive and Slides', docs: 'Docs', sheets: 'Sheets', slides: 'Slides', jira: 'Jira', calendar: 'Calendar and meeting notes', notes: 'Meeting notes',
78
79
  mail: 'Gmail', slack: 'Slack', confluence: 'Confluence', chat: 'Chat', repo: 'This repository' };
@@ -164,7 +165,15 @@ function clean(group, type, input) {
164
165
  if (input.since != null) { if (!DAY_RE.test(String(input.since))) return { error: 'since is YYYY-MM-DD' }; data.since = String(input.since); }
165
166
  }
166
167
  if (group === 'dates' && str(input.stage)) data.stage = one(input.stage, 60);
167
- if (group === 'outcome') {
168
+ if (group === 'outcome' && type === 'refuted') {
169
+ // a refuted outcome's next step (launch simulation W2; lib/outcomes.js refutedDrafts): PMOS recommends one, the PM's ✓ does it
170
+ const d = isObj(input.data) ? input.data : {};
171
+ if (!['kill', 'iterate', 'new'].includes(d.next)) return { error: 'data.next is kill, iterate or new' };
172
+ if (!DAY_RE.test(str(d.check))) return { error: 'data.check is the date of the outcome check, YYYY-MM-DD' };
173
+ if (d.next === 'iterate' && !DAY_RE.test(str(d.horizon))) return { error: 'data.horizon is the new check date, YYYY-MM-DD' };
174
+ Object.assign(data, { next: d.next, check: str(d.check), ref: one(d.ref, 200), evidence: one(d.evidence, 300), metric: one(d.metric, 300), anchor: one(d.anchor, 120), title: one(d.title, LIM.title),
175
+ lane: one(d.lane, 40), work: one(d.work, 20), killMet: d.killMet === true ? true : d.killMet === false ? false : null, ...(d.next === 'iterate' ? { horizon: str(d.horizon) } : {}) });
176
+ } else if (group === 'outcome') {
168
177
  const d = isObj(input.data) ? input.data : {};
169
178
  const metric = one(d.metric, 300), horizon = str(d.horizon);
170
179
  if (metric.length < 8) return { error: 'data.metric is what should move once it ships' };
@@ -307,10 +307,11 @@ function frontmatter(root, rel) {
307
307
  }
308
308
 
309
309
  /* workspace grill W2: the status says only what PMOS knows (lib/status-signal.js decides it; this keeps the inputs). */
310
- const statusIn = (rec, health, end, day, jira) => ({ accepted: !!rec.accepted, stopped: rec.stopped ? { state: rec.stopped.state } : null,
310
+ const statusIn = (rec, health, end, day, jira, outcome) => ({ accepted: !!rec.accepted, stopped: rec.stopped ? { state: rec.stopped.state } : null,
311
+ outcome: outcome && outcome.current ? { verdict: outcome.verdict, date: outcome.date, evidence: outcome.evidence } : null, // launch simulation W2
311
312
  reasons: health && Array.isArray(health.reasons) ? health.reasons.map((x) => ({ level: x.level, code: x.code, text: x.text, source: x.source })) : [],
312
313
  end: end || null, day, jira: jira ? { fetchedAt: jira.fetchedAt, tickets: [...jira.tickets.values()].map((t) => ({ key: t.key, status: t.status, category: t.category, sprint: t.sprint, flagged: !!t.flagged })) } : null });
313
- function statusOf(rec, health, end, day, jira) { return SS.statusOf(statusIn(rec, health, end, day, jira)).status; }
314
+ function statusOf(rec, health, end, day, jira, outcome) { return SS.statusOf(statusIn(rec, health, end, day, jira, outcome)).status; }
314
315
 
315
316
  /** The board-independent part of every work row of a repository, cached by the read signature. */
316
317
  /* A READ PASS (ctx.boardsPass, a Map): a page that asks several of these routes for one answer (GET /api/board-premium asks ten)
@@ -334,6 +335,7 @@ function baseRowsRead(w) {
334
335
  // every lifecycle line, not only the latest: a hold is a gap on the timeline (feedback batch 9 item 8)
335
336
  let lcFile = null;
336
337
  try { lcFile = path.join(ledgers.runsDir(w.root), 'lifecycle.jsonl'); const st = fs.statSync(lcFile); sig.lifecycle = st.size + ':' + st.mtimeMs; } catch { sig.lifecycle = 'none'; }
338
+ try { const st = fs.statSync(path.join(ledgers.runsDir(w.root), 'outcome_checks.jsonl')); sig.outcomes = st.size + ':' + st.mtimeMs; } catch { sig.outcomes = 'none'; }
337
339
  try { const jd = jiraTickets.jiraDir(w.root); sig.jira = fs.readdirSync(jd).filter((n) => n.endsWith('.md')).map((n) => { const st = fs.statSync(path.join(jd, n)); return n + ':' + st.mtimeMs; }).join(','); } catch { sig.jira = 'none'; }
338
340
  const cacheKey = JSON.stringify(sig) + day;
339
341
  const hit = rowCache.get(w.root);
@@ -346,6 +348,8 @@ function baseRowsRead(w) {
346
348
  itemsBy.get(it.initiative).push(it);
347
349
  }
348
350
  const holds = lcFile ? holdSpans.readHolds(lcFile) : new Map();
351
+ // the PM's verdict on each outcome (launch simulation W2): a refuted one reads at risk until the PM picks the next step
352
+ const verdicts = require('./outcomes.js').rowOutcomes(w.root, { today: day });
349
353
  const rows = [];
350
354
  const seen = new Set();
351
355
  for (const id of F.placed.ranked) {
@@ -367,8 +371,9 @@ function baseRowsRead(w) {
367
371
  id, title: r.title, lane: r.lane || null, kind: WK.kindOf(fm.kind), // batch 29 item 11: no line reads as Product management
368
372
  owner: fm.owner ? String(fm.owner) : null,
369
373
  anchor: r.anchor || null, rank: Number.isInteger(r.rank) ? r.rank : null, dormant: !!r.dormant,
370
- status: statusOf(rec, r.health, end, day, jiraOf(w.root, id)),
371
- statusIn: statusIn(rec, r.health, end, day, jiraOf(w.root, id)),
374
+ status: statusOf(rec, r.health, end, day, jiraOf(w.root, id), verdicts.get(id)),
375
+ statusIn: statusIn(rec, r.health, end, day, jiraOf(w.root, id), verdicts.get(id)),
376
+ outcome: verdicts.get(id) || null,
372
377
  health: r.health ? r.health.level : null,
373
378
  start: span ? span.start || null : null, end,
374
379
  progress: r.progress && r.progress.total ? Math.round((r.progress.done / r.progress.total) * 100) / 100 : null, // a fraction 0..1, as the PRD row reads
@@ -538,7 +543,7 @@ function boardRow(board, base, folded, lib) {
538
543
  id: base.id, title: base.title, lane: base.lane, kind: WK.kindOf(base.kind), stage: s.stage, cat, owner: base.owner, anchor: base.anchor,
539
544
  status: base.status, start: ts ? minDay(base.start, ts.start) : base.start, end: ts ? maxDay(base.end, ts.end) : base.end, progress: base.progress, warnings: [],
540
545
  rank: base.rank, health: B.isActive(base) ? base.health : null, updated: base.updated, reading: base.reading, stageSource: s.source, lifecycle: base.lifecycle,
541
- stopped: base.stopped || null, archived: archivedOf(folded, base.id),
546
+ stopped: base.stopped || null, archived: archivedOf(folded, base.id), outcome: base.outcome || null,
542
547
  // feedback batch 9 item 8: every hold of the initiative, and the stretches of 2 weeks or more that no dated work-item or task covers (batch 11
543
548
  // item 13); stageSpans: where the dated work of each stage runs, so a skipped stage between two of them is marked » (XgapAGrill)
544
549
  holds: base.holds || [], ...gapFields((base.workSpans || []).concat(taskSpansOf(folded, base.id))),
@@ -564,7 +569,8 @@ function boardRow(board, base, folded, lib) {
564
569
  }
565
570
  row.closed = closedOf(row, wx);
566
571
  // a finished initiative is never late, at risk or without a signal: its last stage is the PM's own move (batch 26 item 5)
567
- if (row.closed && ['late', 'at risk', 'no signal'].includes(row.status)) { row.status = 'on track'; row.signal = { from: 'pm', why: 'In its last stage', source: 'the workflow', readAt: new Date().toISOString() }; }
572
+ // …except a refuted outcome: its check said it did not work, and that stays at risk until the PM picks the next step (launch simulation W2)
573
+ if (row.closed && ['late', 'at risk', 'no signal'].includes(row.status) && !(row.signal && row.signal.from === 'outcome')) { row.status = 'on track'; row.signal = { from: 'pm', why: 'In its last stage', source: 'the workflow', readAt: new Date().toISOString() }; }
568
574
  const w = [];
569
575
  if (s.source === 'move') {
570
576
  const last = [...folded.moves].reverse().find((m) => m.board === board.id && m.id === base.id);
@@ -114,6 +114,9 @@ function undoCore(ctx, p, g, id) {
114
114
  else if (w.op === 'doc' || w.op === 'linked' || w.op === 'ran') { back++; continue; } // the fold leaves an undone batch out
115
115
  else if (w.op === 'outbox') { kept++; continue; } // a drafted comment waits in the outbox, where the PM drops it
116
116
  else if (w.op === 'description') { const r2 = require('./initiative-writer.js').restoreDescription(p.w.root, k.ini, w.from || '', w.to || '', { actor: g.actor }); if (r2.ok && !r2.kept) back++; else kept++; continue; } // a record edited since keeps its edit
117
+ else if (w.op === 'life') { const r2 = require('./outcomes.js').setLife(p.w.root, k.ini, w.from === 'cancelled' ? 'cancelled' : 'active', 'Undo: PMOS ✦ stopped it', g.actor); if (r2.ok) back++; else kept++; continue; }
118
+ // a new experiment the ✦ made goes from every list (the Board's own Delete: the record file stays, a restore brings it back)
119
+ else if (w.op === 'created') { r = RB.writeAs(ctx, '/api/boards/ini-delete', { ws: p.w.id, board: p.board.id, id: w.id }, g); }
117
120
  else if (w.op === 'outcome') { const r2 = require('./initiative-writer.js').restoreOutcome(p.w.root, k.ini, w.from || {}, w.to || {}, { actor: g.actor }); if (r2.ok && !r2.kept) back++; else kept++; continue; } // a record edited since keeps its edit
118
121
  if (r && r.body && r.body.ok) back++; else kept++;
119
122
  }
@@ -228,6 +231,25 @@ function applyOne(ctx, p, g, f, ini, x, choices, outbox) {
228
231
  if (was) { TL.append(dir, g.actor, { kind: 'unlink', from: l.from, to: l.to }); add({ op: 'unlink', from: l.from, to: l.to, link: { type: was.type, lag: was.lag, source: was.source } }); }
229
232
  }
230
233
  }
234
+ } else if (x.group === 'outcome' && x.type === 'refuted') {
235
+ // a refuted outcome's next step (launch simulation W2; lib/outcomes.js refutedDrafts). Class C: only the PM's ✓ reaches here.
236
+ // kill the experiment is cancelled with the check as its reason (the D70 lifecycle line the Board's ⋯ Cancel writes)
237
+ // iterate a task to change what the check showed, and a new check date (the outcome is open again, so the status reads again)
238
+ // new a new experiment on the same anchor, and this one cancelled
239
+ const O = require('./outcomes.js'), IW = require('./initiative-writer.js'), d = x.data || {};
240
+ const reason = `The outcome check on ${d.check} said it did not work: ${String(d.evidence || '').replace(/[.\s]+$/, '')}.`.slice(0, 440);
241
+ const stop = (why) => { const r = O.setLife(p.w.root, ini, 'cancelled', why, g.actor); if (r.ok) add({ op: 'life', from: r.from || 'active', to: 'cancelled' }); };
242
+ if (d.next === 'kill') stop(reason);
243
+ else if (d.next === 'iterate') {
244
+ const t = RB.taskAdd(ctx, { ws: p.w.id, board: p.board.id, initiative: ini, title: 'Change what the outcome check showed, then check again', notes: [reason, source ? 'From ' + source : ''].filter(Boolean).join('\n').slice(0, 1900) }, g);
245
+ if (W.ok(t)) add({ op: 'add', task: t.body.item && (t.body.item.uid || t.body.item.id), title: 'Change what the outcome check showed, then check again', to: { start: '', due: '' } });
246
+ const r = IW.setOutcome(p.w.root, ini, { metric: d.metric, horizon: d.horizon }, { actor: g.actor });
247
+ if (r.ok && !r.same) add({ op: 'outcome', from: r.from, to: { metric: r.metric, horizon: r.horizon } });
248
+ } else if (d.next === 'new') {
249
+ const c = IW.createInitiative(p.w.root, { title: ('Next experiment: ' + (d.title || ini)).slice(0, 120), lane: d.lane || 'feature', anchor: d.anchor, ...(d.work ? { kind: d.work } : {}),
250
+ intent: `Follows ${ini}, which did not work: ${d.evidence || ''}`.slice(0, 400) }, { actor: g.actor });
251
+ if (c.ok) { add({ op: 'created', id: c.id, path: c.path }); stop(reason + ` The next experiment is ${c.id}.`); }
252
+ }
231
253
  } else if (x.group === 'outcome') {
232
254
  // the expected outcome and its check date (lib/outcomes.js): ✓ writes the record's two D57 lines, Undo puts back what was there
233
255
  const d = x.data || {};
@@ -314,6 +336,10 @@ function saidOf(wrote, plans, left) {
314
336
  if (n('state')) bits.push((bits.length ? 'ticked ' : 'Ticked ') + n('state') + ' done');
315
337
  if (n('rename')) bits.push((bits.length ? 'renamed ' : 'Renamed ') + n('rename'));
316
338
  if (n('outbox')) bits.push(plural(n('outbox'), 'Jira comment', 'Jira comments') + ' drafted');
339
+ // a refuted outcome's next step (launch simulation W2)
340
+ if (n('created')) bits.push((bits.length ? 'started ' : 'Started ') + 'the next experiment');
341
+ if (wrote.some((w) => w.op === 'life' && w.to === 'cancelled')) bits.push((bits.length ? 'stopped ' : 'Stopped ') + 'this one');
342
+ if (n('outcome')) bits.push((bits.length ? 'set ' : 'Set ') + 'the outcome and its check date');
317
343
  if (!bits.length) bits.push('Nothing changed');
318
344
  return bits.join(', ') + '.' + (left ? ' ' + left + ' still ' + (left === 1 ? 'asks' : 'ask') + ' you.' : '');
319
345
  }
@@ -15,7 +15,7 @@
15
15
  * done · cancelled · on hold the PM's word on the record (accepted, closed, cancelled, on-hold in lifecycle.jsonl); a stage the PM set to
16
16
  * shipped (W1's stageOf, setBy 'pm') reads on track: it stays open for Monitor and Evaluate
17
17
  * late only from a date that passed: the planned finish of the dated plan items, or an overdue milestone
18
- * at risk only from a read (an overdue plan item, an idle initiative under way, a passed check-by date, a failed factory item, an
18
+ * at risk a refuted outcome (the PM's verdict that it did not work, until the PM picks the next step), or only from a read (an overdue plan item, an idle initiative under way, a passed check-by date, a failed factory item, an
19
19
  * open Jira ticket past its due date or its sprint's end, a ticket flagged blocked) or from a risk the PM confirmed (✓ on Claude's "Mark … at risk")
20
20
  * on track only from a read: a Jira reading of the initiative's tickets in the last READ_DAYS with none past its due date, or dated
21
21
  * plan items whose finish is still ahead
@@ -25,7 +25,8 @@
25
25
  *
26
26
  * x = { accepted, stopped: { state }, reasons: [{ level, code, text, source }] (lib/health.js), end ('YYYY-MM-DD', the planned finish),
27
27
  * day (today, 'YYYY-MM-DD'), now (ms), jira: { fetchedAt, tickets: Map|[] of { key, status, category, due } } | null,
28
- * stage: W1's { stage, setBy, source, readAt } | null, confirmed: { why, name } | null }
28
+ * stage: W1's { stage, setBy, source, readAt } | null, confirmed: { why, name } | null,
29
+ * outcome: { verdict, date, evidence } | null (the standing verdict, lib/outcomes.js rowOutcomes) }
29
30
  * Pure: no I/O, no clock beyond x.now.
30
31
  */
31
32
  const STATUSES = Object.freeze(['on track', 'at risk', 'late', 'no signal', 'on hold', 'done', 'cancelled']);
@@ -68,6 +69,9 @@ function statusOf(x = {}) {
68
69
  if (x.accepted || st === 'closed') return out('done', 'pm', '', 'the record');
69
70
  if (st === 'cancelled') return out('cancelled', 'pm', '', 'lifecycle.jsonl');
70
71
  if (st === 'on-hold') return out('on hold', 'pm', '', 'lifecycle.jsonl');
72
+ // the PM's verdict on the outcome (launch simulation W2): a check that said it did not work is at risk, whatever else reads well, until the
73
+ // PM picks the next step under the ✦ (stop it, one more round with a new check date, or a new experiment). Honest state: never On track.
74
+ if (x.outcome && x.outcome.verdict === 'refuted') return out('at risk', 'outcome', 'The outcome check' + (x.outcome.date ? ' on ' + x.outcome.date : '') + ' said it did not work' + (x.outcome.evidence ? ': ' + String(x.outcome.evidence).slice(0, 200) : ''), 'outcome_checks.jsonl');
71
75
  // shipped by the PM's word: never late or at risk, but still open on the Board (Monitor and Evaluate follow), so on track, not done
72
76
  if (S && S.setBy === 'pm' && S.stage === 'shipped') return out('on track', 'pm', 'Shipped', S.source || 'lifecycle.jsonl', S.readAt);
73
77
  const reasons = (Array.isArray(x.reasons) ? x.reasons : []).filter((r) => r && (r.level === 'off' || r.level === 'at-risk') && !NOT_READS.has(r.code));
@@ -257,6 +257,27 @@ function ofLines(r) {
257
257
  }
258
258
  const ofJson = (r) => ({ initiative: { id: r.row.id, title: r.row.title }, board: { id: r.board.id, name: r.board.name }, wf: r.row.wf, stage: r.row.wfStage, stages: r.row.wfStages, ended: r.row.ended, oneStage: r.row.oneStage || null });
259
259
 
260
+ /** A move past stages that still hold open tasks (launch simulation W2): the tasks stay open and the move goes ahead (no block), but the
261
+ * PM hears which ones, by stage. Only a forward move on the same workflow passes stages. → [{ id, title, state, stage, stageName }] */
262
+ function openPassed(verb, before, after, ctx, w, root, id) {
263
+ if (verb !== 'move' || !after || !after.ok) return [];
264
+ const list = before.row.wfStages || [], from = list.findIndex((s) => s.key === (before.row.wfStage || {}).key);
265
+ const to = list.findIndex((s) => s.key === (after.row.wfStage || {}).key);
266
+ if (from < 0 || to <= from) return [];
267
+ const passed = new Map(list.slice(from, to).map((s) => [s.key, s.name]));
268
+ let tasks = [];
269
+ // lib/stage-read.js is the one reader of an initiative's tasks outside HTTP (W1); open is To do or In progress, as pmos task list says
270
+ try { tasks = require('./stage-read.js').tasksOf(ctx, w, id).filter((t) => t.state === 'To do' || t.state === 'In progress'); } catch { return []; }
271
+ return tasks.filter((t) => passed.has(t.stage)).map((t) => ({ id: t.id, title: t.title, state: t.state, stage: t.stage, stageName: passed.get(t.stage) }));
272
+ }
273
+ function openBehind(verb, before, after, ctx, w, root, id) {
274
+ const open = openPassed(verb, before, after, ctx, w, root, id);
275
+ if (!open.length) return [];
276
+ const head = open.length === 1 ? '1 task stays open in a stage it passed:' : `${open.length} tasks stay open in the stages it passed:`;
277
+ return [head, ...open.slice(0, 12).map((t) => ` ${t.id} · ${t.state} · ${t.title} · under ${t.stageName}`), ...(open.length > 12 ? [` … and ${open.length - 12} more (pmos task list ${id})`] : []),
278
+ `Close them with pmos task state <task> --to Done (or "Won't do"), or leave them open on purpose.`];
279
+ }
280
+
260
281
  function onInitiative(verb, { pos, flags, json, say, fail, root, stateDir, actor, others }) {
261
282
  const id = pos[0];
262
283
  const usage = { of: 'pmos workflow of <initiative>', move: 'pmos workflow move <initiative> --stage <key|name|number> [--why <text>]', switch: 'pmos workflow switch <initiative> --to <workflow id> [--stage <key|name>] [--why <text>]' }[verb];
@@ -293,11 +314,12 @@ function onInitiative(verb, { pos, flags, json, say, fail, root, stateDir, actor
293
314
  if (!r.body || r.body.ok !== true) return fail((r.body && r.body.error) || 'the write was refused');
294
315
  const after = rowOf(ctx, w, id);
295
316
  const warnings = r.body.warnings || [];
296
- if (json) { say(JSON.stringify({ ok: true, ...(after.ok ? ofJson(after) : {}), warnings })); return 0; }
317
+ if (json) { say(JSON.stringify({ ok: true, ...(after.ok ? ofJson(after) : {}), warnings, stillOpen: openPassed(verb, before, after, ctx, w, root, id) })); return 0; }
297
318
  const row = after.ok ? after.row : before.row;
298
319
  say(verb === 'move' ? `✓ moved ${row.title} to ${row.wfStage.name}, stage ${row.wfStage.n} of ${row.wfStage.of} of ${row.wf.name}.`
299
320
  : `✓ ${row.title} now runs ${row.wf.name}, in ${row.wfStage.name} (stage ${row.wfStage.n} of ${row.wfStage.of}).`);
300
321
  for (const x of warnings) say(' ' + x);
322
+ for (const l of openBehind(verb, before, after, ctx, w, root, id)) say(' ' + l);
301
323
  say(' The stage card and the Board show it. No task was moved. Nothing was sent.');
302
324
  return 0;
303
325
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.566.0",
3
+ "version": "0.567.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.566.0",
9
+ "version": "0.567.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.566.0",
3
+ "version": "0.567.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -37,6 +37,8 @@ const KIND_WORDS = {
37
37
  const SDLC_NO_FACTORY = { build: 'PMOS writes the pull request plan for the team’s agents' };
38
38
  const kindWords = (r, key, ctx) => { const w = r && r.kind === 'sdlc' && !(ctx && ctx.factory) ? SDLC_NO_FACTORY : KIND_WORDS[r && r.kind]; return (w && w[key]) || null; };
39
39
  const ANCHOR = 'PMOS anchors it to a goal';
40
+ // a refuted outcome: the next step PMOS recommends under the ✦ (lib/outcomes.js refutedDrafts), as the PM's call
41
+ const NEXT_ASK = { kill: "it didn't work: stop it?", iterate: "it didn't work: one more round?", new: "it didn't work: a new experiment?" };
40
42
  const OPEN_TK = ['In review', 'In progress', 'To do'];
41
43
  const CLOSED = new Set(['Done', "Won't do", 'Archived']);
42
44
 
@@ -74,6 +76,12 @@ export function nextOf(r, ctx = {}) {
74
76
  }
75
77
  const key = t.key;
76
78
  if (!key) return null;
79
+ // the PM answered "did it work?" (launch simulation W2): a refuted outcome asks for the next step PMOS recommends under the ✦; a
80
+ // validated one leaves the lessons to PMOS; can't tell yet asks nothing new
81
+ const oc = r.outcome;
82
+ if (oc && oc.verdict === 'refuted' && oc.current) return yours(NEXT_ASK[oc.next] || NEXT_ASK.iterate);
83
+ if (oc && oc.verdict === 'validated' && (key === 'monitor' || key === 'evaluate')) return claude('PMOS writes the lessons');
84
+ if (oc && oc.verdict === 'inconclusive' && (key === 'monitor' || key === 'evaluate')) return claude('PMOS reads the outcome again');
77
85
  if (key === 'build' || key === 'deliver') {
78
86
  const tk = t.tickets || [];
79
87
  if (tk.length) {