create-pmos 0.566.0 → 0.568.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 +27 -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/workflow-state.js +20 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +26 -0
- package/workspace/guide/cli.md +3 -1
- package/workspace/guide/initiatives-and-next-steps.md +20 -1
- package/workspace/lib/autonomy.js +1 -0
- package/workspace/lib/board-premium.js +2 -0
- package/workspace/lib/engine/workflow-state.js +20 -1
- package/workspace/lib/engine/workflows.js +71 -7
- package/workspace/lib/jira-cli.js +1 -0
- package/workspace/lib/jira-tickets.js +23 -0
- package/workspace/lib/kind-control.js +232 -0
- package/workspace/lib/outcome-props.js +58 -4
- package/workspace/lib/outcomes-cli.js +7 -1
- package/workspace/lib/outcomes.js +188 -11
- package/workspace/lib/proposals.js +12 -3
- package/workspace/lib/rehearse-read.js +3 -1
- package/workspace/lib/rehearse.js +30 -2
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-boards.js +56 -8
- package/workspace/lib/routes-initiatives.js +3 -1
- package/workspace/lib/routes-kind-control.js +95 -0
- package/workspace/lib/routes-proposals.js +26 -0
- package/workspace/lib/status-signal.js +6 -2
- package/workspace/lib/vendor/scripts/workflow-state.js +20 -1
- package/workspace/lib/work-kind.js +16 -4
- package/workspace/lib/workflow-cli.js +23 -1
- package/workspace/lib/workflows-store.js +2 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-next.js +8 -0
- package/workspace/public/pm/ini-agent.js +16 -6
- package/workspace/public/pm/ini-kind.js +59 -0
- package/workspace/public/pm/ini-view.css +23 -0
- package/workspace/public/pm/ini-view.js +5 -2
- package/workspace/test-lists/kind-workflows.json +5 -0
|
@@ -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' };
|
|
@@ -64,7 +64,7 @@ function snapshotOf(root, o = {}) {
|
|
|
64
64
|
try { const got = rowsLib.rowsFor(root); if (got && got.ok) for (const r of got.rows) recOf.set(r.id, r.record || null); } catch { /* no record paths */ }
|
|
65
65
|
if (base.ok) {
|
|
66
66
|
for (const r of base.rows) {
|
|
67
|
-
snap.rows.push({ id: r.id, title: r.title || r.id, end: r.end || null, anchor: r.anchor || null });
|
|
67
|
+
snap.rows.push({ id: r.id, title: r.title || r.id, end: r.end || null, anchor: r.anchor || null, kind: require('./work-kind.js').kindOf(r.kind) });
|
|
68
68
|
if (recOf.get(r.id)) files.records[r.id] = path.resolve(root, recOf.get(r.id));
|
|
69
69
|
}
|
|
70
70
|
} else missing.push('initiatives');
|
|
@@ -126,6 +126,8 @@ function refsOf(root, snap, files) {
|
|
|
126
126
|
if (a) R.rows[ini + ':anchor'] = a;
|
|
127
127
|
const idl = lineRef(root, file, (l) => /^id:/.test(l), ini + ' record (its end is the Board\'s, from its tasks)');
|
|
128
128
|
if (idl) R.rows[ini + ':end'] = idl;
|
|
129
|
+
const tl = lineRef(root, file, (l) => /^title:/.test(l), ini + ' title'); // W5: the date a title names
|
|
130
|
+
if (tl) R.rows[ini + ':title'] = tl;
|
|
129
131
|
}
|
|
130
132
|
for (const g of snap.goals || []) { const s = F.krs && lineRef(root, F.krs, after(jsonHas('rid', g.id)), 'goal ' + g.id); if (s) R.goals[g.id] = s; }
|
|
131
133
|
for (const p of snap.programs || []) { const s = F.programs && lineRef(root, F.programs, (line) => (line.includes('"kind":"program"') ? after(jsonHas('id', p.id))(line) : null), 'program ' + p.id); if (s) R.programs[p.id] = s; }
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* SNAPSHOT. { today: 'YYYY-MM-DD',
|
|
14
14
|
* tasks: [{ uid, title, ini, status, start, end, milestone, src }] the shape lib/task-links.js taskOf reads
|
|
15
15
|
* links: [{ from, to, type, lag }] the approved links
|
|
16
|
-
* rows: [{ id, title, end, anchor }]
|
|
16
|
+
* rows: [{ id, title, end, anchor, kind? }] the initiatives (end = the committed end; kind: lib/work-kind.js)
|
|
17
17
|
* goals: [{ id, title, byAt, moves: [initiative id], forecast: { state, likely } | null }] lib/forecast.js goalForecast
|
|
18
18
|
* programs: [{ id, title, milestones: [{ id, name, date, waits: [initiative id], done }] }]
|
|
19
19
|
* refs: { links: { 'from>to': src }, rows: { 'ini:end' | 'ini:anchor': src }, goals: { id: src }, programs: { id: src }, tasks: { uid: src } }
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
const TL = require('./task-links.js');
|
|
31
31
|
const FC = require('./forecast.js');
|
|
32
32
|
|
|
33
|
+
const KC = () => require('./kind-control.js'); // dateIn: the date a title or a KR names (W5)
|
|
33
34
|
const KINDS = Object.freeze(['move', 'end', 'cut']);
|
|
34
35
|
const MAX_LIST = 8;
|
|
35
36
|
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
@@ -198,6 +199,31 @@ function rehearse(snap, change) {
|
|
|
198
199
|
if (!late0 && late1) add({ tone: 'breaks', kind: 'end', ini, text: q(iniTitle(ini)) + "'s last task would end " + TL.md(f1) + ', ' + days(f1 - end1) + ' after its committed end, ' + TL.md(end1) + '.', evidence: ev });
|
|
199
200
|
else if (late0 && !late1 && f1 != null) add({ tone: 'helps', kind: 'end', ini, text: q(iniTitle(ini)) + "'s last task would end " + TL.md(f1) + ', back inside its committed end, ' + TL.md(end1) + '.', evidence: ev });
|
|
200
201
|
}
|
|
202
|
+
// W5 (board WfC): a new end is checked against the dates the plan already promises: the date the title names, the KR's date and the
|
|
203
|
+
// initiative's own ◇ milestones. Each break names what to change; nothing here estimates a number.
|
|
204
|
+
let msChecked = 0;
|
|
205
|
+
if (c.kind === 'end') {
|
|
206
|
+
const to = TL.dn(c.to), row = rows.get(c.ini) || {}, was = row.end ? TL.dn(row.end) : null;
|
|
207
|
+
const td = KC().dateIn(row.title, S.today);
|
|
208
|
+
if (td && TL.dn(td) !== to) add({ tone: 'breaks', kind: 'title', ini: c.ini, text: 'The title ' + q(row.title) + ' says ' + TL.md(TL.dn(td)) + '. Change it to ' + TL.md(to) + ', or keep the end.', evidence: [refRow(c.ini, 'title')] });
|
|
209
|
+
// the KR's date and the milestones are a Project's promises (its go-live is the end); on other kinds a later end alone moves nothing
|
|
210
|
+
// the work still meets (Wawan's Mac, 2026-11-03), so they are read only for a Project
|
|
211
|
+
const proj = row.kind === 'project';
|
|
212
|
+
for (const g of proj ? S.goals || [] : []) {
|
|
213
|
+
if (!(g.moves || []).includes(c.ini)) continue;
|
|
214
|
+
const by = TL.dn(g.byAt), gd = KC().dateIn(g.title, S.today);
|
|
215
|
+
if (by != null && to > by) add({ tone: 'breaks', kind: 'goal', ini: c.ini, goal: g.id, text: 'Goal ' + q(g.title) + ' is due ' + TL.md(by) + '. The new end, ' + TL.md(to) + ', is after it. Change the goal\'s date, or keep the end.', evidence: [(R.goals || {})[g.id], refRow(c.ini, 'anchor')] });
|
|
216
|
+
else if (gd && TL.dn(gd) !== to && (by == null || TL.dn(gd) !== by)) add({ tone: 'breaks', kind: 'goal', ini: c.ini, goal: g.id, text: 'Goal ' + q(g.title) + ' says ' + TL.md(TL.dn(gd)) + '. Change it to ' + TL.md(to) + ', or keep the end.', evidence: [(R.goals || {})[g.id], refRow(c.ini, 'anchor')] });
|
|
217
|
+
}
|
|
218
|
+
const ms = proj ? [...base.T.values()].filter((t) => t.ini === c.ini && t.ms && !t.closed && t.e != null) : [];
|
|
219
|
+
msChecked = ms.length;
|
|
220
|
+
const last = ms.slice().sort((a, b) => b.e - a.e)[0];
|
|
221
|
+
for (const m of ms) {
|
|
222
|
+
if (!(m.e < to && (m === last || (was != null && m.e === was)))) continue;
|
|
223
|
+
add({ tone: 'breaks', kind: 'milestone', ini: c.ini, task: m.uid, text: '◇ ' + q(m.title) + ' is ' + TL.md(m.e) + ', before the new end. Its baseline stays; its forecast moves to ' + TL.md(to) + ' when you approve.', evidence: [refT(m.uid)] });
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
201
227
|
// goals and program milestones: when each initiative's work lands, before and after
|
|
202
228
|
const land0 = new Map(), land1 = new Map();
|
|
203
229
|
for (const ini of new Set([...rows.keys(), ...inis])) { land0.set(ini, landOf(base.T, rows.get(ini), ini)); if (ini !== cutIni) land1.set(ini, landOf(TA, rowsA.get(ini), ini)); }
|
|
@@ -211,6 +237,7 @@ function rehearse(snap, change) {
|
|
|
211
237
|
const ev = [(R.goals || {})[g.id], refRow(ini, 'anchor')];
|
|
212
238
|
if (ini === cutIni) { add({ tone: 'breaks', kind: 'goal', ini, goal: g.id, text: 'Goal ' + q(g.title) + ' loses ' + q(iniTitle(ini)) + ', ' + ((g.moves || []).length === 1 ? 'the only initiative that moves it' : 'one of the ' + g.moves.length + ' initiatives that move it') + '.' + fc, evidence: ev }); continue; }
|
|
213
239
|
const a = land0.get(ini), b = land1.get(ini); if (a == null || b == null) continue;
|
|
240
|
+
if (effects.some((e) => e.kind === 'goal' && e.goal === g.id && e.ini === ini)) continue; // said once (W5's end check above)
|
|
214
241
|
if (a <= by && b > by) add({ tone: 'breaks', kind: 'goal', ini, goal: g.id, text: 'Goal ' + q(g.title) + ' is due ' + TL.md(by) + '. ' + q(iniTitle(ini)) + ', which moves it, would land ' + TL.md(b) + ', after that.' + fc, evidence: ev.concat([refRow(ini, 'end'), lastRef(ini)]) });
|
|
215
242
|
else if (a > by && b <= by) add({ tone: 'helps', kind: 'goal', ini, goal: g.id, text: 'Goal ' + q(g.title) + ' is due ' + TL.md(by) + '. ' + q(iniTitle(ini)) + ', which moves it, would land ' + TL.md(b) + ', in time.' + fc, evidence: ev.concat([refRow(ini, 'end'), lastRef(ini)]) });
|
|
216
243
|
}
|
|
@@ -233,7 +260,7 @@ function rehearse(snap, change) {
|
|
|
233
260
|
const order = { breaks: 0, helps: 1, moves: 2 };
|
|
234
261
|
effects.sort((x, y) => order[x.tone] - order[y.tone]);
|
|
235
262
|
const counts = { breaks: 0, helps: 0, moves: 0 }; for (const e of effects) counts[e.tone]++;
|
|
236
|
-
return { ok: true, change: c, effects, counts, checked: { tasks: T0.size, links: links0.length, goals: (S.goals || []).length, programs: (S.programs || []).length }, missing: S.missing || [], unsourced, stale, note };
|
|
263
|
+
return { ok: true, change: c, effects, counts, checked: { tasks: T0.size, links: links0.length, goals: (S.goals || []).length, programs: (S.programs || []).length, ...(c.kind === 'end' ? { title: true, milestones: msChecked, project: (rows.get(c.ini) || {}).kind === 'project' } : {}) }, missing: S.missing || [], unsourced, stale, note };
|
|
237
264
|
}
|
|
238
265
|
|
|
239
266
|
function moveDelta(T0, T1, uid) { const a = T0.get(uid), b = T1.get(uid); return a && b && a.e != null && b.e != null ? b.e - a.e : a && b && a.s != null && b.s != null ? b.s - a.s : 0; }
|
|
@@ -263,6 +290,7 @@ function dedupe(ev) { const seen = new Set(); return ev.filter((s) => { const k
|
|
|
263
290
|
function textOf(r) {
|
|
264
291
|
if (!r.ok) return ['✗ ' + r.error];
|
|
265
292
|
const out = [];
|
|
293
|
+
if (r.checked && r.checked.title) out.push(r.checked.project ? 'Checked: the title date, the goal dates and ' + (r.checked.milestones === 1 ? '1 milestone' : (r.checked.milestones || 0) + ' milestones') + '.' : 'Checked: the date the title names.');
|
|
266
294
|
if (!r.effects.length) out.push('Nothing else moves: no other task, initiative, goal or program milestone changes.');
|
|
267
295
|
for (const e of r.effects) {
|
|
268
296
|
out.push((e.tone === 'breaks' ? '✗ Breaks: ' : e.tone === 'helps' ? '✓ Helps: ' : '· Moves: ') + e.text);
|
|
@@ -96,6 +96,7 @@ const MODULES = Object.freeze([
|
|
|
96
96
|
'routes-meeting-replay', // meeting-material-replay: the note, the Focus state and the shots joined for the Replay page (GET, read-only)
|
|
97
97
|
'routes-meeting-material', // meeting-material-replay: the material the PM links to a meeting (GET list and suggest; page-press POST add and remove; meeting-material.jsonl)
|
|
98
98
|
'routes-meeting-points', // premium-uncovered-features (meetings): the Replay's Confirm and Not right on a meeting's key points (meeting-points.jsonl)
|
|
99
|
+
'routes-kind-control', // launch simulation W5: the Viewer's Project control (gate, colours, critical path, on track) and Full SDLC gate (GET, read-only)
|
|
99
100
|
'routes-viewer', // premium-agreed-design (viewer): agenda minutes, what recording listens to, a next step made a drafted ticket, the report's Issue checks
|
|
100
101
|
'routes-report-confirm', // premium-uncovered-features (reports): the Brief tab's Confirm and Use it (report-confirms.jsonl in the runtime folder)
|
|
101
102
|
'routes-stage-tools', // stage-tools-records: the records the PM edits per stage, what PMOS holds per stage, the sprint burndown
|
|
@@ -226,11 +226,23 @@ function createAndPlace(ctx, w, boardId, input, actor, tie) {
|
|
|
226
226
|
* (Settings opens on home), and that workflow is adopted into this workspace's library first, as a switch does. PMOS still reads the BRD
|
|
227
227
|
* and proposes a switch. Never throws: a new initiative is made even when this line cannot be written.
|
|
228
228
|
* boardId: the board the initiative is on; else its domain board (products/<domain>/) or the workspace board. → the workflow id | null */
|
|
229
|
-
function startOnDefault(ctx, w, iniId, actor, { boardId = null, recordPath = null } = {}) {
|
|
229
|
+
function startOnDefault(ctx, w, iniId, actor, { boardId = null, recordPath = null, kind = null } = {}) {
|
|
230
230
|
try {
|
|
231
231
|
const file = ledgerFile(ctx, w);
|
|
232
232
|
const dir = ctx.stateDirFor ? ctx.stateDirFor(w) : null;
|
|
233
233
|
if (!file || !dir || isSelf(ctx, w)) return null;
|
|
234
|
+
// W5: the kind of work sets the default. Project and Full SDLC start on their own built-in workflow; Product management on the default.
|
|
235
|
+
const k = WK.valid(kind) ? kind : recordKind(w.root, recordPath);
|
|
236
|
+
if (k !== 'product') {
|
|
237
|
+
const def = WF.forKind(WS.library(dir), k);
|
|
238
|
+
const fr = frameFor(ctx, w);
|
|
239
|
+
const dm = recordPath ? /^products\/([^/]+)\//.exec(recordPath) : null;
|
|
240
|
+
const bid = boardId || (dm && fr.boards.some((b) => b.id === dm[1] && b.kind === 'domain') ? dm[1] : w.id);
|
|
241
|
+
const board = fr.boards.find((b) => b.id === bid);
|
|
242
|
+
if (!board || board.self) return null;
|
|
243
|
+
append(file, actor, { kind: 'ini-wf', board: board.id, id: iniId, wf: def.id, why: 'the ' + WK.LABEL[k] + ' workflow: the kind of work sets it', start: true });
|
|
244
|
+
return def.id;
|
|
245
|
+
}
|
|
234
246
|
let lib = WS.library(dir), from = null;
|
|
235
247
|
if (!lib.defaultId) {
|
|
236
248
|
const home = ctx.getWs ? ctx.getWs(null) : null;
|
|
@@ -251,6 +263,36 @@ function startOnDefault(ctx, w, iniId, actor, { boardId = null, recordPath = nul
|
|
|
251
263
|
} catch { return null; }
|
|
252
264
|
}
|
|
253
265
|
|
|
266
|
+
/** The `kind:` of an initiative record (lib/work-kind.js kindOf: no line or no file reads as Product management). */
|
|
267
|
+
function recordKind(root, recordPath) {
|
|
268
|
+
if (!root || !recordPath) return 'product';
|
|
269
|
+
try {
|
|
270
|
+
const text = fs.readFileSync(path.resolve(root, recordPath), 'utf8');
|
|
271
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text);
|
|
272
|
+
const line = m ? m[1].split(/\r?\n/).find((l) => /^kind:/.test(l)) : null;
|
|
273
|
+
return WK.kindOf(line ? line.slice(5) : '');
|
|
274
|
+
} catch { return 'product'; }
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** A kind change (POST /api/initiatives/kind, `pmos initiative set … --kind`): an initiative that runs its OLD kind's default workflow moves to
|
|
278
|
+
* the new kind's, its stage mapped by meaning (scripts/workflows.js MEANING: Plan to Plan, Build to Execute, Release to Close). The switch line
|
|
279
|
+
* says what changed in one sentence. A workflow the PM picked by hand is left alone. Never throws. → { switched, wf?, line } */
|
|
280
|
+
function kindSwitch(ctx, w, id, from, to, actor) {
|
|
281
|
+
const line = WK.switchLine(from, to);
|
|
282
|
+
try {
|
|
283
|
+
if (!w || isSelf(ctx, w) || WK.kindOf(from) === WK.kindOf(to)) return { switched: false, line };
|
|
284
|
+
const r = initiativeWorkflow(ctx, w, id);
|
|
285
|
+
if (!r.ok) return { switched: false, line };
|
|
286
|
+
const lib = libOf(foldOf(ctx, w));
|
|
287
|
+
const cur = (r.row.wf && r.row.wf.id) || WF.PRODUCT_FEATURE_ID;
|
|
288
|
+
if (!WF.isKindDefault(lib, WK.kindOf(from), cur)) return { switched: false, line, kept: cur };
|
|
289
|
+
const target = WF.forKind(lib, WK.kindOf(to));
|
|
290
|
+
if (target.id === cur) return { switched: false, line };
|
|
291
|
+
const out = switchWorkflow(ctx, { ws: w.id, board: r.board.id, id, wf: target.id, why: line, pmos: true }, { ok: true, actor });
|
|
292
|
+
return out.body && out.body.ok ? { switched: true, wf: target.id, moved: out.body.moved, line } : { switched: false, line, error: out.body && out.body.error };
|
|
293
|
+
} catch (e) { return { switched: false, line, error: String((e && e.message) || e).slice(0, 200) }; }
|
|
294
|
+
}
|
|
295
|
+
|
|
254
296
|
// ── boards of a workspace ─────────────────────────────────────────────────────────────────────────
|
|
255
297
|
const isSelf = (ctx, w) => !!(ctx.selfRoot && w && path.resolve(w.root) === path.resolve(ctx.selfRoot));
|
|
256
298
|
|
|
@@ -307,10 +349,11 @@ function frontmatter(root, rel) {
|
|
|
307
349
|
}
|
|
308
350
|
|
|
309
351
|
/* 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,
|
|
352
|
+
const statusIn = (rec, health, end, day, jira, outcome) => ({ accepted: !!rec.accepted, stopped: rec.stopped ? { state: rec.stopped.state } : null,
|
|
353
|
+
outcome: outcome && outcome.current ? { verdict: outcome.verdict, date: outcome.date, evidence: outcome.evidence } : null, // launch simulation W2
|
|
311
354
|
reasons: health && Array.isArray(health.reasons) ? health.reasons.map((x) => ({ level: x.level, code: x.code, text: x.text, source: x.source })) : [],
|
|
312
355
|
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; }
|
|
356
|
+
function statusOf(rec, health, end, day, jira, outcome) { return SS.statusOf(statusIn(rec, health, end, day, jira, outcome)).status; }
|
|
314
357
|
|
|
315
358
|
/** The board-independent part of every work row of a repository, cached by the read signature. */
|
|
316
359
|
/* 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 +377,7 @@ function baseRowsRead(w) {
|
|
|
334
377
|
// every lifecycle line, not only the latest: a hold is a gap on the timeline (feedback batch 9 item 8)
|
|
335
378
|
let lcFile = null;
|
|
336
379
|
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'; }
|
|
380
|
+
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
381
|
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
382
|
const cacheKey = JSON.stringify(sig) + day;
|
|
339
383
|
const hit = rowCache.get(w.root);
|
|
@@ -346,6 +390,8 @@ function baseRowsRead(w) {
|
|
|
346
390
|
itemsBy.get(it.initiative).push(it);
|
|
347
391
|
}
|
|
348
392
|
const holds = lcFile ? holdSpans.readHolds(lcFile) : new Map();
|
|
393
|
+
// the PM's verdict on each outcome (launch simulation W2): a refuted one reads at risk until the PM picks the next step
|
|
394
|
+
const verdicts = require('./outcomes.js').rowOutcomes(w.root, { today: day });
|
|
349
395
|
const rows = [];
|
|
350
396
|
const seen = new Set();
|
|
351
397
|
for (const id of F.placed.ranked) {
|
|
@@ -367,8 +413,9 @@ function baseRowsRead(w) {
|
|
|
367
413
|
id, title: r.title, lane: r.lane || null, kind: WK.kindOf(fm.kind), // batch 29 item 11: no line reads as Product management
|
|
368
414
|
owner: fm.owner ? String(fm.owner) : null,
|
|
369
415
|
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)),
|
|
416
|
+
status: statusOf(rec, r.health, end, day, jiraOf(w.root, id), verdicts.get(id)),
|
|
417
|
+
statusIn: statusIn(rec, r.health, end, day, jiraOf(w.root, id), verdicts.get(id)),
|
|
418
|
+
outcome: verdicts.get(id) || null,
|
|
372
419
|
health: r.health ? r.health.level : null,
|
|
373
420
|
start: span ? span.start || null : null, end,
|
|
374
421
|
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 +585,7 @@ function boardRow(board, base, folded, lib) {
|
|
|
538
585
|
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
586
|
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
587
|
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),
|
|
588
|
+
stopped: base.stopped || null, archived: archivedOf(folded, base.id), outcome: base.outcome || null,
|
|
542
589
|
// 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
590
|
// item 13); stageSpans: where the dated work of each stage runs, so a skipped stage between two of them is marked » (XgapAGrill)
|
|
544
591
|
holds: base.holds || [], ...gapFields((base.workSpans || []).concat(taskSpansOf(folded, base.id))),
|
|
@@ -564,7 +611,8 @@ function boardRow(board, base, folded, lib) {
|
|
|
564
611
|
}
|
|
565
612
|
row.closed = closedOf(row, wx);
|
|
566
613
|
// 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
|
-
|
|
614
|
+
// …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)
|
|
615
|
+
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
616
|
const w = [];
|
|
569
617
|
if (s.source === 'move') {
|
|
570
618
|
const last = [...folded.moves].reverse().find((m) => m.board === board.id && m.id === base.id);
|
|
@@ -1898,4 +1946,4 @@ function meetingBoards(ctx) {
|
|
|
1898
1946
|
return { list, detail };
|
|
1899
1947
|
}
|
|
1900
1948
|
|
|
1901
|
-
module.exports = { prefixes: ['/api/boards'], handle, tasksOfIni, postFrame, needRows, itemsOf, readLedger, foldOf, epicsOf, rowsOfBoard, invalidateRows: (w) => { rowsLib.invalidate(w.root); rowCache.delete(w.root); }, move, switchWorkflow, taskState, taskAdd, taskEdit, writeAs, taskDelete, taskRestore, initiativeWorkflow, seedInitiative, stageTasks, boardIndex, appendScanAsk, scanDeclineSignal, createAndPlace, startOnDefault, ledgerFile, append, frameFor, boardIdOf, meetingBoards, boardsOf, baseRows, boardRow, taskSpanOf, workflowRowOf, closedOf, foldOf, portfolio, SELF_REFUSAL, NO_STATE };
|
|
1949
|
+
module.exports = { prefixes: ['/api/boards'], handle, tasksOfIni, postFrame, needRows, itemsOf, readLedger, foldOf, epicsOf, rowsOfBoard, invalidateRows: (w) => { rowsLib.invalidate(w.root); rowCache.delete(w.root); }, move, switchWorkflow, taskState, taskAdd, taskEdit, writeAs, taskDelete, taskRestore, initiativeWorkflow, seedInitiative, stageTasks, boardIndex, appendScanAsk, scanDeclineSignal, createAndPlace, startOnDefault, kindSwitch, recordKind, ledgerFile, append, frameFor, boardIdOf, meetingBoards, boardsOf, baseRows, boardRow, taskSpanOf, workflowRowOf, closedOf, foldOf, portfolio, SELF_REFUSAL, NO_STATE };
|
|
@@ -655,9 +655,11 @@ async function handle(req, res, url, ctx) {
|
|
|
655
655
|
if (!g.ok) return answer(ctx, res, g), true;
|
|
656
656
|
const r = writer.setKind(w.root, body.id, body.kind, { actor: g.actor });
|
|
657
657
|
if (!r.ok) { ctx.json(res, { ok: false, status: r.status, error: r.error, field: r.field }, r.status); return true; }
|
|
658
|
+
// W5: the kind sets the default workflow, so an initiative on its old kind's default moves to the new kind's (stages mapped by meaning)
|
|
659
|
+
const sw = r.same ? null : require('./routes-boards.js').kindSwitch(ctx, w, r.id, r.from, r.kind, g.actor);
|
|
658
660
|
rowsLib.invalidate(w.root);
|
|
659
661
|
if (ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg(w.id);
|
|
660
|
-
ctx.json(res, { ok: true, id: r.id, from: r.from, kind: r.kind, sig: sigOf(w.root) });
|
|
662
|
+
ctx.json(res, { ok: true, id: r.id, from: r.from, kind: r.kind, ...(sw ? { workflow: sw } : {}), sig: sigOf(w.root) });
|
|
661
663
|
return true;
|
|
662
664
|
}
|
|
663
665
|
// split or merge initiatives (feedback batch 11 item 14; lib/split-merge.js): the editor's button or ✓ on Claude's card, Undo, and ✕ Not now
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-kind-control.js — the Viewer's Project and Full SDLC section (launch simulation W5; boards WfA and WfB). READ ONLY.
|
|
3
|
+
*
|
|
4
|
+
* GET /api/kind-control?ws=&ini=<id>
|
|
5
|
+
* → { ok, kind: 'product' } Product management: the Viewer shows what it shows today
|
|
6
|
+
* → { ok, kind: 'sdlc', gate, line? } lib/kind-control.js sdlc
|
|
7
|
+
* → { ok, kind: 'project', gate, rows, critical, ontrack, proposal, goLive, baselineAt, line? } lib/kind-control.js project
|
|
8
|
+
* line: the last kind change on the initiative's workflow ("Kind changed to Project …"), written by routes-boards.js kindSwitch.
|
|
9
|
+
*
|
|
10
|
+
* Every value comes through the readers the pmos verbs use (lib/rehearse-read.js snapshotOf for tasks, links, the committed end and the goals;
|
|
11
|
+
* lib/people-store.js for People; the task ledgers for the baseline), never a typed status. A reader that fails leaves its part out. */
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const KC = require('./kind-control.js');
|
|
15
|
+
const WK = require('./work-kind.js');
|
|
16
|
+
|
|
17
|
+
const fail = (status, error) => ({ status, body: { ok: false, error } });
|
|
18
|
+
const okBody = (body) => ({ status: 200, body: { ok: true, ...body } });
|
|
19
|
+
const ID_RE = /^[a-z0-9][a-z0-9._-]{0,120}$/;
|
|
20
|
+
|
|
21
|
+
function readJsonl(file) {
|
|
22
|
+
let text = '';
|
|
23
|
+
try { text = fs.readFileSync(file, 'utf8'); } catch { return []; }
|
|
24
|
+
const out = [];
|
|
25
|
+
for (const raw of text.split('\n')) { if (!raw.trim()) continue; try { out.push(JSON.parse(raw)); } catch { /* a torn line */ } }
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
/** The record's front matter keys this section reads. */
|
|
29
|
+
function recordOf(root, id) {
|
|
30
|
+
const file = path.join(root, 'planning', 'initiatives', id + '.md');
|
|
31
|
+
let text = '';
|
|
32
|
+
try { text = fs.readFileSync(file, 'utf8'); } catch {
|
|
33
|
+
try { const got = require('./initiative-rows.js').rowsFor(root); const r = got && got.ok ? got.rows.find((x) => x.id === id) : null; if (r && r.record) text = fs.readFileSync(path.resolve(root, r.record), 'utf8'); } catch { return null; }
|
|
34
|
+
}
|
|
35
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text);
|
|
36
|
+
if (!m) return null;
|
|
37
|
+
const fm = {};
|
|
38
|
+
for (const l of m[1].split(/\r?\n/)) { const k = /^([a-z_]+):\s*(.*)$/.exec(l); if (k && !(k[1] in fm)) fm[k[1]] = k[2].trim().replace(/^"(.*)"$/, '$1').replace(/^'(.*)'$/, '$1'); }
|
|
39
|
+
return fm;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** One initiative's section. o: { today?, snapshot?, people? } for a test. */
|
|
43
|
+
function control(ctx, q, o = {}) {
|
|
44
|
+
const w = ctx && ctx.getWs ? ctx.getWs(q.ws || null) : null;
|
|
45
|
+
if (!w || !w.root) return fail(404, 'no such workspace');
|
|
46
|
+
const id = String(q.ini || '');
|
|
47
|
+
if (!ID_RE.test(id)) return fail(400, 'ini is an initiative id');
|
|
48
|
+
const fm = recordOf(w.root, id);
|
|
49
|
+
if (!fm) return fail(404, 'no initiative record for ' + id);
|
|
50
|
+
const kind = WK.kindOf(fm.kind);
|
|
51
|
+
if (kind === 'product') return okBody({ kind });
|
|
52
|
+
const stateDir = ctx.stateDirFor ? ctx.stateDirFor(w) : null;
|
|
53
|
+
// the last kind change on the workflow, said once
|
|
54
|
+
let line = null, baselineAt = null;
|
|
55
|
+
try {
|
|
56
|
+
const RB = require('./routes-boards.js'), f = RB.ledgerFile(ctx, w);
|
|
57
|
+
for (const e of f ? readJsonl(f) : []) {
|
|
58
|
+
if (!e || e.kind !== 'ini-wf' || e.id !== id) continue;
|
|
59
|
+
if (typeof e.why === 'string' && /^Kind changed to /.test(e.why)) line = e.why;
|
|
60
|
+
if (!baselineAt && e.moved && e.moved.from === 'plan' && e.moved.to !== 'plan') baselineAt = e.at || null;
|
|
61
|
+
}
|
|
62
|
+
} catch { /* no workflow ledger */ }
|
|
63
|
+
if (kind === 'sdlc') return okBody({ ...KC.sdlc({ record: fm }), ...(line ? { line } : {}) });
|
|
64
|
+
|
|
65
|
+
const today = o.today || new Date().toISOString().slice(0, 10);
|
|
66
|
+
let snap;
|
|
67
|
+
try { snap = o.snapshot || require('./rehearse-read.js').snapshotOf(w.root, { today, stateDir: stateDir || undefined }); } catch { snap = { tasks: [], links: [], rows: [], goals: [] }; }
|
|
68
|
+
const tasks = (snap.tasks || []).filter((x) => x && x.ini === id);
|
|
69
|
+
const row = (snap.rows || []).find((r) => r.id === id) || null;
|
|
70
|
+
const goal = (snap.goals || []).find((g) => (g.moves || []).includes(id)) || null;
|
|
71
|
+
let people = o.people;
|
|
72
|
+
if (!people) { try { const v = require('./people-store.js').view(w.root); people = v && v.ok ? v.people : []; } catch { people = []; } }
|
|
73
|
+
// the baseline: each task's dates when the initiative left Plan, read from both task ledgers
|
|
74
|
+
const lines = [];
|
|
75
|
+
try { const TS = require('./task-store.js'), s = TS.storeFor(w.root); if (s) lines.push(...readJsonl(s.file)); } catch { /* none */ }
|
|
76
|
+
try { lines.push(...readJsonl(require('./plan-ledgers.js').ledgerPath(w.root, 'plan-items'))); } catch { /* none */ }
|
|
77
|
+
try { const f = require('./routes-boards.js').ledgerFile(ctx, w); if (f) lines.push(...readJsonl(f).filter((e) => e && (e.kind === 'task' || e.kind === 'task-update'))); } catch { /* none */ }
|
|
78
|
+
lines.sort((a, b) => String(a.at || '').localeCompare(String(b.at || '')));
|
|
79
|
+
const baseline = KC.baselineOf(lines, new Set(tasks.map((x) => x.uid || x.key)), baselineAt);
|
|
80
|
+
const m = KC.project({ today, title: fm.title || (row && row.title) || id, goal: goal ? { id: goal.id, title: goal.title, byAt: goal.byAt } : null, end: row && row.end,
|
|
81
|
+
record: fm, tasks, links: snap.links || [], baseline, baselineAt, people });
|
|
82
|
+
return okBody({ ...m, ...(line ? { line } : {}) });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const respond = (ctx, res, r) => { ctx.json(res, r.body, r.status); return true; };
|
|
86
|
+
|
|
87
|
+
module.exports = {
|
|
88
|
+
prefixes: ['/api/kind-control'],
|
|
89
|
+
control, recordOf,
|
|
90
|
+
handle: async (req, res, url, ctx) => {
|
|
91
|
+
if (url.pathname !== '/api/kind-control') return false;
|
|
92
|
+
if (req.method !== 'GET') return respond(ctx, res, fail(405, 'GET only'));
|
|
93
|
+
return respond(ctx, res, control(ctx, Object.fromEntries(url.searchParams)));
|
|
94
|
+
},
|
|
95
|
+
};
|
|
@@ -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));
|
|
@@ -963,7 +963,26 @@ function computeWorkflowDerived(id, opts) {
|
|
|
963
963
|
'the done test is the spec (D13 as amended by D107). Land it in an earlier commit than the build, or split this PR so it lands first',
|
|
964
964
|
{ blocking: !legacy, rule });
|
|
965
965
|
};
|
|
966
|
-
|
|
966
|
+
// W5 (boards WfA/WfB/WfC, agreed 2026-11-12): the kind of work sets the gate. Full SDLC: a done test and a kill condition before the first
|
|
967
|
+
// pull request. Project: a dated plan (plan_path), never a PRD. Product management (and a record with no kind:) keeps the rules below. A
|
|
968
|
+
// PRD already on the record still satisfies the spec rung after a kind change: a gate already passed stays passed.
|
|
969
|
+
const workKind = (() => { const k = String(fm.kind || '').trim().replace(/^["']|["']$/g, ''); return k === 'sdlc' || k === 'project' ? k : 'product'; })();
|
|
970
|
+
const planPath = String(fm.plan_path || '').trim();
|
|
971
|
+
if (!doneTest && workKind === 'sdlc' && !prd) {
|
|
972
|
+
steps.push(step('spec', 'spec', 'blocked', 'Full SDLC needs a done test and a kill condition before the first pull request — never a PRD',
|
|
973
|
+
`write the done test (okf/core/templates/done-test-template.md), set done_test_path and kill: in ${recRel}`, { blocking: true, rule: 'R2' }));
|
|
974
|
+
} else if (!doneTest && workKind === 'project' && (planPath || !prd)) {
|
|
975
|
+
const planIdx = planPath ? firstAppearance(root, range, planPath) : null;
|
|
976
|
+
if (!planPath) {
|
|
977
|
+
steps.push(step('spec', 'spec', 'blocked', 'Project needs a dated plan before Execute — never a PRD',
|
|
978
|
+
`write the plan (milestones with dates and owners, go-live matching the KR date) and set plan_path in ${recRel}, or a done test`, { blocking: true, rule: 'R2' }));
|
|
979
|
+
} else if (planIdx === null) {
|
|
980
|
+
steps.push(step('spec', 'spec', 'blocked', `plan_path '${planPath}' does not exist in the repo`,
|
|
981
|
+
'create the plan the record points at, or correct plan_path', { blocking: true, rule: 'R2' }));
|
|
982
|
+
} else {
|
|
983
|
+
steps.push(orderOf(`plan ${planPath}`, planIdx, 'O1'));
|
|
984
|
+
}
|
|
985
|
+
} else if (doneTest) {
|
|
967
986
|
const dtIdx = firstAppearance(root, range, doneTest);
|
|
968
987
|
if (dtIdx === null) {
|
|
969
988
|
steps.push(step('spec', 'spec', 'blocked', `done_test_path '${doneTest}' does not exist in the repo`,
|
|
@@ -14,9 +14,14 @@
|
|
|
14
14
|
* (the factory, D65: propose-only, the PM merges) where a factory runs, else the team's agents (PMOS writes
|
|
15
15
|
* the done test and the pull request plan); Product and Project → the team
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* (
|
|
17
|
+
* switchLine(from, to) → string the one line a kind change writes on the workflow switch (the Viewer shows it)
|
|
18
|
+
*
|
|
19
|
+
* NOT A LANE (D107). The kind sits on the record beside the lane; it does not replace the lane. No model call: the pre-pick is the small
|
|
20
|
+
* word table below, and when it cannot tell it says so (cue '') instead of guessing.
|
|
21
|
+
* THE KIND SETS THE DEFAULT WORKFLOW AND GATE (launch simulation W5, boards WfA, WfB, WfC, agreed by Wawan 2026-11-12; this amends the
|
|
22
|
+
* batch-29 note that the kind was a hint only). Project starts on the Project workflow, Full SDLC on Full SDLC, Product management on the
|
|
23
|
+
* workspace default (scripts/workflows.js forKind). The Initiative Gate reads it too (scripts/workflow-state.js). Each initiative can still
|
|
24
|
+
* switch workflow; a kind change switches only an initiative that runs its old kind's default (routes-boards.js kindSwitch). */
|
|
20
25
|
|
|
21
26
|
const KINDS = Object.freeze(['product', 'sdlc', 'project']);
|
|
22
27
|
const LABEL = Object.freeze({ product: 'Product management', sdlc: 'Full SDLC', project: 'Project management' });
|
|
@@ -57,4 +62,11 @@ const factoryRuns = (root) => {
|
|
|
57
62
|
};
|
|
58
63
|
const executorOf = (kind, factory) => (kindOf(kind) !== 'sdlc' ? 'team' : factory ? 'factory' : 'team-agents');
|
|
59
64
|
|
|
60
|
-
|
|
65
|
+
/** The line a kind change writes: what the kind now is and what its gate adds (WfC: "Kind changed to Project, Plan gate now needs …"). */
|
|
66
|
+
function switchLine(from, to) {
|
|
67
|
+
const GATE = { product: 'the Build gate reads the done test and kill condition, or a PRD', sdlc: 'the first pull request now needs a done test and a kill condition', project: 'the Plan gate now needs milestone dates, owners and a go-live that matches the KR' };
|
|
68
|
+
const k = kindOf(to);
|
|
69
|
+
return 'Kind changed to ' + SHORT[k] + (from && kindOf(from) !== k ? ' from ' + SHORT[kindOf(from)] : '') + ': ' + GATE[k] + '.';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
module.exports = { KINDS, LABEL, SHORT, DEFAULT, valid, kindOf, fromName, executorOf, factoryRuns, switchLine };
|
|
@@ -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
|
}
|
|
@@ -76,7 +76,7 @@ function copy(stateDir, id, name, actor) {
|
|
|
76
76
|
/** An initiative here switches to a workflow saved in another workspace's library: the same definition (same id) is saved here. */
|
|
77
77
|
function adopt(stateDir, wf, actor, fromWs) {
|
|
78
78
|
if (!stateDir) return { ok: false, status: 409, error: NO_STATE };
|
|
79
|
-
if (!wf || wf.id
|
|
79
|
+
if (!wf || W.isBuiltin(wf.id)) return { ok: true, workflow: wf }; // built in everywhere (W5: Project and Full SDLC too)
|
|
80
80
|
const c = W.check({ id: wf.id, name: wf.name, icon: wf.icon, decide: wf.decide, stages: wf.stages });
|
|
81
81
|
if (!c.ok) return c;
|
|
82
82
|
append(fileOf(stateDir), actor, { kind: 'wf-save', wf: c.workflow, ...(fromWs ? { adoptedFrom: fromWs } : {}) });
|
|
@@ -85,7 +85,7 @@ function adopt(stateDir, wf, actor, fromWs) {
|
|
|
85
85
|
|
|
86
86
|
function archive(stateDir, id, archived, actor, { inUse = [] } = {}) {
|
|
87
87
|
if (!stateDir) return { ok: false, status: 409, error: NO_STATE };
|
|
88
|
-
if (
|
|
88
|
+
if (W.isBuiltin(id)) return { ok: false, status: 409, error: `${W.BUILTIN[id].name} is built in and stays.` };
|
|
89
89
|
const lib = library(stateDir);
|
|
90
90
|
if (!lib.byId.has(id)) return { ok: false, status: 404, error: 'That workflow could not be found. It may have been removed.' };
|
|
91
91
|
if (archived && inUse.length) return { ok: false, status: 409, error: `${inUse.length} ${inUse.length === 1 ? 'initiative runs' : 'initiatives run'} this workflow. Move ${inUse.length === 1 ? 'it' : 'them'} to another workflow first.`, inUse };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.568.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.568.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|