create-pmos 0.565.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 +33 -27
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/scripts/gate-initiative.sh +6 -3
- package/payload/scripts/workflow-state.js +18 -7
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +32 -0
- package/workspace/fixtures/initiatives-api/list.json +2 -1
- package/workspace/guide/cli.md +5 -3
- package/workspace/guide/initiatives-and-next-steps.md +4 -4
- package/workspace/guide/jira.md +3 -1
- package/workspace/lib/agent-team.js +1 -1
- package/workspace/lib/autonomy.js +1 -0
- package/workspace/lib/board-premium.js +2 -0
- package/workspace/lib/description-props.js +53 -2
- package/workspace/lib/engine/workflow-state.js +18 -7
- package/workspace/lib/grill-cli.js +4 -4
- package/workspace/lib/impact-cli.js +3 -3
- package/workspace/lib/initiative-cli.js +7 -4
- package/workspace/lib/jira-cli.js +2 -0
- package/workspace/lib/jira-tickets.js +78 -5
- package/workspace/lib/lab-cli.js +1 -1
- package/workspace/lib/lead-cli.js +1 -1
- package/workspace/lib/measure-cli.js +13 -7
- package/workspace/lib/measurements.js +34 -11
- package/workspace/lib/metrics-cli.js +4 -4
- package/workspace/lib/outcome-props.js +58 -4
- package/workspace/lib/outcomes-cli.js +9 -3
- package/workspace/lib/outcomes.js +188 -11
- package/workspace/lib/program-cli.js +2 -2
- package/workspace/lib/proposals.js +12 -3
- package/workspace/lib/propose-cli.js +2 -2
- package/workspace/lib/report-draft.js +5 -5
- package/workspace/lib/report-engine.js +1 -1
- package/workspace/lib/routes-artefacts.js +3 -2
- package/workspace/lib/routes-board-premium.js +2 -0
- package/workspace/lib/routes-boards.js +12 -6
- package/workspace/lib/routes-initiatives.js +1 -1
- package/workspace/lib/routes-proposals.js +26 -0
- package/workspace/lib/routes-stage-tools.js +1 -1
- package/workspace/lib/status-signal.js +6 -2
- package/workspace/lib/team-cli.js +4 -1
- package/workspace/lib/today-cli.js +1 -1
- package/workspace/lib/vendor/scripts/workflow-state.js +18 -7
- package/workspace/lib/work-kind.js +16 -4
- package/workspace/lib/workflow-cli.js +23 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-asks.js +1 -1
- package/workspace/public/pm/bd-ini-panel.js +1 -1
- package/workspace/public/pm/bd-next.js +17 -5
- package/workspace/public/pm/bd-views.js +1 -1
- package/workspace/public/pm/ini-agent.js +14 -7
- package/workspace/public/pm/premium-board.js +1 -1
- package/workspace/public/pm/work-kind.js +10 -6
- package/workspace/skills/measure.skill +6 -6
|
@@ -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
|
-
|
|
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
|
-
|
|
197
|
-
|
|
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
|
-
|
|
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
|
|
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 &&
|
|
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 =
|
|
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 };
|
|
@@ -13,7 +13,7 @@ const MS = require('./milestone-suggest.js');
|
|
|
13
13
|
|
|
14
14
|
const COMMANDS = { program: ['suggest'] };
|
|
15
15
|
const USAGE = [
|
|
16
|
-
'usage: pmos program suggest —
|
|
16
|
+
'usage: pmos program suggest — PMOS\'s milestone suggestions for a program',
|
|
17
17
|
' pmos program suggest --json <file|->',
|
|
18
18
|
' File one suggestion (a JSON object) or a list of them, in a milestone review run only. Each one:',
|
|
19
19
|
' { "op": "add|move|rename|drop|risk", "milestone": "<id, not for add>", "name": "<add, rename>", "date": "YYYY-MM-DD (add, move)",',
|
|
@@ -30,7 +30,7 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, stdin
|
|
|
30
30
|
const i = args.indexOf('--json'), src = i >= 0 ? args[i + 1] : null;
|
|
31
31
|
if (!src) { say('usage: pmos program suggest --json <file|->'); return 2; }
|
|
32
32
|
const file = env.PMOS_MS_REVIEW_FILE, runId = env.PMOS_MS_REVIEW_RUN, program = env.PMOS_MS_REVIEW_PROGRAM;
|
|
33
|
-
if (!file || !runId || !program) { say('✗ pmos program suggest is for
|
|
33
|
+
if (!file || !runId || !program) { say('✗ pmos program suggest is for PMOS\'s milestone review run. The PM changes milestones in the charter'); return 1; }
|
|
34
34
|
let text;
|
|
35
35
|
try { text = src === '-' ? (stdin !== undefined ? String(stdin) : fs.readFileSync(0, 'utf8')) : fs.readFileSync(src, 'utf8'); } catch (e) { say(`✗ could not read ${src}: ${String((e && e.message) || e).slice(0, 120)}`); return 1; }
|
|
36
36
|
let body;
|
|
@@ -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).
|
|
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' };
|
|
@@ -21,7 +21,7 @@ const LP = require('./loose-proposals.js');
|
|
|
21
21
|
|
|
22
22
|
const COMMANDS = { propose: ['look', 'found', 'date', 'done', 'name', 'status', 'loose'] };
|
|
23
23
|
const USAGE = [
|
|
24
|
-
'usage: pmos propose look|found|date|done|name|status — what
|
|
24
|
+
'usage: pmos propose look|found|date|done|name|status — what PMOS proposes on an initiative, under its ✦',
|
|
25
25
|
' pmos propose look <source> --reading | --found <n> --what "<5 documents>" | --none',
|
|
26
26
|
' source: ' + PR.SOURCES.join(', ') + '. Say --reading when you start a source and --found or --none when you finish it.',
|
|
27
27
|
' pmos propose found <stage|docs|tasks|link|maybe|unplaced> --json <file|->',
|
|
@@ -88,7 +88,7 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, stdin
|
|
|
88
88
|
if (!verb || verb === 'help' || verb === '--help' || verb === '-h') { for (const l of USAGE) say(l); return verb ? 0 : 1; }
|
|
89
89
|
if (!COMMANDS.propose.includes(verb)) { say(`unknown propose command "${verb}" — one of ${COMMANDS.propose.join(', ')}`); return 2; }
|
|
90
90
|
const file = env.PMOS_PROPOSE_FILE, runId = env.PMOS_PROPOSE_RUN, ini = env.PMOS_PROPOSE_INI, board = env.PMOS_PROPOSE_BOARD || '';
|
|
91
|
-
if (!file || !runId || !ini) { say('✗ pmos propose is for
|
|
91
|
+
if (!file || !runId || !ini) { say('✗ pmos propose is for PMOS\'s proposal run. The PM keeps and drops proposals on the page, under the initiative\'s ✦'); return 1; }
|
|
92
92
|
if ((verb === 'loose') !== (ini === '~loose')) { say(verb === 'loose' ? '✗ pmos propose loose is for Home\'s clean-up run' : '✗ this is Home\'s clean-up run: file with pmos propose loose'); return 1; }
|
|
93
93
|
if (verb === 'loose') return loose(args, { say, stdin, file, runId });
|
|
94
94
|
const F = PR.fold(PR.readLines(file));
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
* health from `health` (a function of the health ctx, or a map by id; tests inject it) else lib/health.js healthOf. An off-track or at-risk block with no reason
|
|
40
40
|
* at its level refuses the whole draft (422);
|
|
41
41
|
* - progress from plan-items (proposed items never count; an item the factory join marks integrated counts done);
|
|
42
|
-
* a measured value only from a measurements line
|
|
42
|
+
* a measured value only from a measurements line with a source the writer accepts (`<path>@<sha>`, or a connector or
|
|
43
|
+
* document with how it was read; no KR is computed here);
|
|
43
44
|
* - the Timeline strip from item-spans.js, the PM's own acts under Decided this cycle (a pending proposal never),
|
|
44
45
|
* Needs your call from the asks note, for the definition's audience only (X23), and the sources.
|
|
45
46
|
* The definition `<state>/reports/definitions/<cadence>.md` gives `audience` and `sections` (readDefinition). Besides
|
|
@@ -100,7 +101,6 @@ const SLIDES_CLOSE = '-->';
|
|
|
100
101
|
const FRAME = Object.freeze(['headline', 'timeline', 'initiatives', 'new', 'decided', 'needs', 'sources']);
|
|
101
102
|
const CADENCE_RE = /^[a-z][a-z0-9-]{0,39}$/;
|
|
102
103
|
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
103
|
-
const SOURCE_RE = /^[^@\s]+@[0-9a-f]{7,40}$/;
|
|
104
104
|
const DAY = 86400000;
|
|
105
105
|
const SEVERITY = { off: 3, 'at-risk': 2, unknown: 1, on: 0 };
|
|
106
106
|
const LEVEL_WORD = { off: 'Off track', 'at-risk': 'At risk', unknown: 'Unknown', on: 'On track' };
|
|
@@ -336,7 +336,7 @@ function draftOf(root, { cadence, slot, now, health } = {}) {
|
|
|
336
336
|
|| byText(String(a.createdAt), String(b.createdAt)) || byText(a.id, b.id));
|
|
337
337
|
const dated = ordered.filter((it) => [it.start, it.due].some((d) => d && d >= today && d <= cycleEnd));
|
|
338
338
|
const coming = dated.length ? { basis: 'dates', list: dated } : { basis: 'order', list: ordered.slice(0, 3) };
|
|
339
|
-
const m = measurement &&
|
|
339
|
+
const m = measurement && measurements.sourceKind(measurement.source) ? measurement : null;
|
|
340
340
|
|
|
341
341
|
blocks.push({
|
|
342
342
|
id, title: titleOf.get(id),
|
|
@@ -344,7 +344,7 @@ function draftOf(root, { cadence, slot, now, health } = {}) {
|
|
|
344
344
|
health: { level: h.level, reasons: h.reasons },
|
|
345
345
|
progress: { done, total: real.length, delta: doneNow.length,
|
|
346
346
|
label: real.length ? `${done} of ${real.length} (+${doneNow.length})` : planTree.progressLabel(0, 0, its.length - real.length) },
|
|
347
|
-
measure: m ? { anchor: String(row.anchor).split(' ')[0], value: m.value, target: m.target, unit: m.unit, as_of: m.as_of, source: m.source } : null,
|
|
347
|
+
measure: m ? { anchor: String(row.anchor).split(' ')[0], value: m.value, target: m.target, unit: m.unit, as_of: m.as_of, source: m.source, how: m.how || null } : null,
|
|
348
348
|
last_cycle: {
|
|
349
349
|
done: doneNow.map((it) => ({ id: it.id, title: it.title })),
|
|
350
350
|
gates,
|
|
@@ -549,7 +549,7 @@ function render(draft, { notes, name: given, purpose } = {}) {
|
|
|
549
549
|
push(`### ${b.title} (${b.id})`, '');
|
|
550
550
|
const reason = b.health.reasons.find((r) => r.level === b.health.level);
|
|
551
551
|
push(`Stage: ${b.stage} · ${LEVEL_WORD[b.health.level]}${reason ? `: ${reason.text}` : ''} · ${b.progress.label}`);
|
|
552
|
-
if (b.measure) push('', `Measured: ${b.measure.anchor} ${b.measure.value}${b.measure.unit || ''}${b.measure.target == null ? '' : ` of ${b.measure.target}${b.measure.unit || ''}`}, as of ${b.measure.as_of} (${b.measure.source})`);
|
|
552
|
+
if (b.measure) push('', `Measured: ${b.measure.anchor} ${b.measure.value}${b.measure.unit || ''}${b.measure.target == null ? '' : ` of ${b.measure.target}${b.measure.unit || ''}`}, as of ${b.measure.as_of} (${b.measure.source}${b.measure.how ? `, ${b.measure.how}` : ''})`);
|
|
553
553
|
push('', '**Last cycle**', '');
|
|
554
554
|
const lc = b.last_cycle;
|
|
555
555
|
push(`- Done: ${lc.done.length ? lc.done.map((x) => `${x.title} (${x.id})`).join('; ') : 'none'}`);
|
|
@@ -341,7 +341,7 @@ function ledgerReadings(root, brief, now) {
|
|
|
341
341
|
const base = `${b.id}`.toLowerCase().replace(/[^a-z0-9._-]/g, '-');
|
|
342
342
|
if (b.progress && b.progress.total) out.push({ id: `${base}.done`, value: b.progress.done, of: b.progress.total, unit: 'items', at, source: 'pmos', how: 'plan items done of total', label: `${b.title}: items done` });
|
|
343
343
|
if (b.health && b.health.level) out.push({ id: `${base}.health`, value: { off: 'off track', 'at-risk': 'at risk', unknown: 'unknown', on: 'on track' }[b.health.level] || b.health.level, at, source: 'pmos', how: 'lib/health.js', label: `${b.title}: health`, ...(b.health.level === 'off' || b.health.level === 'at-risk' ? { flag: (b.health.reasons || []).map((x) => x.text).join('; ') || b.health.level } : {}) });
|
|
344
|
-
if (b.measure && typeof b.measure.value === 'number') out.push({ id: `${base}.${String(b.measure.anchor || 'kr').toLowerCase()}`, value: b.measure.value, unit: b.measure.unit || null, ...(typeof b.measure.target === 'number' ? { target: b.measure.target } : {}), at: b.measure.as_of || at, source: 'pmos', how: `measurement ${b.measure.source}`, label: `${b.title}: ${b.measure.anchor}` });
|
|
344
|
+
if (b.measure && typeof b.measure.value === 'number') out.push({ id: `${base}.${String(b.measure.anchor || 'kr').toLowerCase()}`, value: b.measure.value, unit: b.measure.unit || null, ...(typeof b.measure.target === 'number' ? { target: b.measure.target } : {}), at: b.measure.as_of || at, source: 'pmos', how: `measurement ${b.measure.source}${b.measure.how ? `, ${b.measure.how}` : ''}`, label: `${b.title}: ${b.measure.anchor}` });
|
|
345
345
|
const carried = (b.last_cycle && b.last_cycle.carried) || [];
|
|
346
346
|
const overdue = carried.filter((c) => c.due && c.due < brief.slot);
|
|
347
347
|
if (overdue.length) out.push({ id: `${base}.overdue`, value: overdue.length, unit: 'items', at, source: 'pmos', how: 'carried plan items past their due date', label: `${b.title}: items overdue`, flag: overdue.map((c) => `${c.title}, due ${full(c.due)}`).join('; ') });
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* routes-artefacts.js — the seven artefacts (R18, D107, lib/artefacts.js).
|
|
3
3
|
*
|
|
4
|
-
* GET /api/artefacts?ws&scope → { ok, ws, scope, kind, artefacts: [{ key, title, owner, for, labels, fields, carried, empty }] }
|
|
4
|
+
* GET /api/artefacts?ws&scope → { ok, ws, scope, kind, factory, artefacts: [{ key, title, owner, for, labels, fields, carried, empty }] }
|
|
5
|
+
* factory: a D65 factory runs in this repository (lib/work-kind.js factoryRuns), so "PMOS builds it" is true
|
|
5
6
|
* scope: portfolio (default), board:<id>, goal:<id>, experiment:<id> (initiative:<id> is an alias)
|
|
6
7
|
* GET /api/artefacts/story?ws → { ok, ws, story: { scope, at, lines: [{ text, sources }] } | null, seeding? } "The story so far" on the
|
|
7
8
|
* product page (board AwE): the Narrative of board:<ws>, else of the portfolio (lib/artefacts.js storyOf). A
|
|
@@ -122,7 +123,7 @@ async function handle(req, res, url, ctx) {
|
|
|
122
123
|
const v = A.viewOf(A.fold(A.readLines(A.file(dir))), scope);
|
|
123
124
|
const artefacts = v.artefacts.map((a) => ({ ...a,
|
|
124
125
|
fields: Object.fromEntries(Object.entries(a.fields).map(([k, val]) => [k, Array.isArray(val) ? val.map(pageBy) : pageBy(val)])) }));
|
|
125
|
-
return send(200, { ok: true, ws: w.id, scope: v.scope, kind: v.kind, artefacts });
|
|
126
|
+
return send(200, { ok: true, ws: w.id, scope: v.scope, kind: v.kind, factory: require('./work-kind.js').factoryRuns(w.root), artefacts });
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
module.exports = { prefixes: ['/api/artefacts'], handle, _migrated: migrated };
|
|
@@ -113,6 +113,8 @@ module.exports = {
|
|
|
113
113
|
rows: rowsNow, members, columns: c ? c.columns : [], sprints: s || { source: 'none', sprints: [] },
|
|
114
114
|
items: its && its.body && its.body.ok !== false && Array.isArray(its.body.items) ? its.body.items : [], held: hd ? hd.rows : [], cancelled: cn ? cn.rows : [], archived: ar ? ar.rows : [], asks: ak ? ak.asks || [] : null,
|
|
115
115
|
});
|
|
116
|
+
// W3: Full SDLC says "PMOS builds" only where a factory runs (lib/work-kind.js factoryRuns); elsewhere the team's agents build
|
|
117
|
+
try { const w = ctx.getWs ? ctx.getWs(pick.ws) : null; if (model.board) model.board.factory = !!(w && w.id === pick.ws && require('./work-kind.js').factoryRuns(w.root)); } catch { /* no factory said */ }
|
|
116
118
|
// workspace grill W2: a row nothing read for says No signal (grey), with where its status came from (r.signal: from, why, source,
|
|
117
119
|
// readAt); the header and the Needs a look menu count them apart from on track, from the board's own count (scripts/boards.js counts)
|
|
118
120
|
try {
|
|
@@ -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
|
-
|
|
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);
|
|
@@ -266,7 +266,7 @@ function listOf(w, F) {
|
|
|
266
266
|
if (!g.anchors.has(a.key)) {
|
|
267
267
|
const raw = String(F.byId.get(r.id).anchor || '').trim();
|
|
268
268
|
const m = (a.token && measurements.latest(F.meas, a.token)) || (a.anchor && measurements.latest(F.meas, a.anchor)) || (raw && measurements.latest(F.meas, raw)) || null;
|
|
269
|
-
g.anchors.set(a.key, { anchor: a.anchor, kind: a.kind, title: a.title, measurement: m ? { value: m.value, target: m.target, unit: m.unit, as_of: m.as_of, source: m.source } : null, rows: [] });
|
|
269
|
+
g.anchors.set(a.key, { anchor: a.anchor, kind: a.kind, title: a.title, measurement: m ? { value: m.value, target: m.target, unit: m.unit, as_of: m.as_of, source: m.source, how: m.how || null } : null, rows: [] });
|
|
270
270
|
}
|
|
271
271
|
g.anchors.get(a.key).rows.push(r);
|
|
272
272
|
}
|
|
@@ -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
|
}
|
|
@@ -116,7 +116,7 @@ function measurementsOf(root, anchor) {
|
|
|
116
116
|
try {
|
|
117
117
|
const M = require('./measurements.js');
|
|
118
118
|
const r = M.readMeasurements(root);
|
|
119
|
-
const series = ((r.byAnchor || {})[anchor] || []).map((m) => ({ value: m.value, target: m.target == null ? null : m.target, unit: m.unit || null, as_of: m.as_of, source: m.source }));
|
|
119
|
+
const series = ((r.byAnchor || {})[anchor] || []).map((m) => ({ value: m.value, target: m.target == null ? null : m.target, unit: m.unit || null, as_of: m.as_of, source: m.source, how: m.how || null }));
|
|
120
120
|
return { anchor, latest: M.latest(r, anchor), series };
|
|
121
121
|
} catch { return { anchor, latest: null, series: [] }; }
|
|
122
122
|
}
|
|
@@ -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));
|