create-pmos 0.491.0 → 0.493.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/mods/pmos-cockpit/README.md +1 -1
- package/payload/mods/pmos-cockpit/hooks/lib/guard.mjs +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +26 -0
- package/workspace/fixtures/initiatives-api/list.json +0 -4
- package/workspace/fixtures/initiatives-api/roadmap.json +255 -275
- package/workspace/fixtures/initiatives-api/sheet.json +2 -3
- package/workspace/fixtures/report-api/draft.json +4 -4
- package/workspace/fixtures/reports-page/draft-biweekly-2026-10-16.md +4 -4
- package/workspace/guide/board.md +2 -2
- package/workspace/guide/home.md +1 -0
- package/workspace/guide/index.md +2 -2
- package/workspace/guide/initiative-boards.md +2 -2
- package/workspace/guide/initiatives-roadmap.md +38 -39
- package/workspace/guide/initiatives-screen.md +20 -20
- package/workspace/guide/initiatives-timeline.md +7 -9
- package/workspace/guide/integrated-work.md +7 -8
- package/workspace/guide/layout.md +2 -2
- package/workspace/guide/lifecycle.md +2 -2
- package/workspace/guide/notes.md +1 -1
- package/workspace/guide/pm-only-acts.md +5 -5
- package/workspace/guide/pm-only-lines.md +3 -3
- package/workspace/guide/reports.md +2 -2
- package/workspace/guide/today.md +2 -2
- package/workspace/lib/board-cli.js +1 -1
- package/workspace/lib/board-fold.js +6 -6
- package/workspace/lib/board-premium.js +3 -3
- package/workspace/lib/calendar-tidy.js +1 -1
- package/workspace/lib/core-docs.js +2 -2
- package/workspace/lib/engine/boards.js +11 -11
- package/workspace/lib/engine/signals/detectors.js +13 -13
- package/workspace/lib/engine/signals/facts.js +5 -3
- package/workspace/lib/health-rules-factory.js +13 -14
- package/workspace/lib/health-rules-plan.js +8 -7
- package/workspace/lib/initiative-cli.js +59 -63
- package/workspace/lib/initiative-needs.js +6 -6
- package/workspace/lib/initiative-premium.js +2 -2
- package/workspace/lib/initiative-writer.js +2 -2
- package/workspace/lib/lifecycle-stage.js +39 -0
- package/workspace/lib/placements.js +117 -95
- package/workspace/lib/plan-rules.js +7 -5
- package/workspace/lib/pm-guard.js +1 -3
- package/workspace/lib/pm-lines-needs.js +1 -1
- package/workspace/lib/report-draft.js +17 -16
- package/workspace/lib/report-slides-data.js +11 -7
- package/workspace/lib/routes-boards.js +8 -7
- package/workspace/lib/routes-initiatives.js +29 -43
- package/workspace/lib/routes-notes.js +24 -15
- package/workspace/lib/routes-onboard.js +13 -2
- package/workspace/lib/split-merge.js +2 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/home-app.js +3 -2
- package/workspace/public/pm/http.js +1 -1
- package/workspace/public/pm/view-notes.js +8 -8
- package/workspace/replaced-tests.json +14 -0
|
@@ -1,62 +1,65 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
/* placements.js — THE ONE WRITER and THE ONE FOLD of placements.jsonl: where each initiative
|
|
3
|
-
*
|
|
2
|
+
/* placements.js — THE ONE WRITER and THE ONE FOLD of placements.jsonl: where each initiative ranks on the Roadmap, and
|
|
3
|
+
* its check-by date (pm-os-absorb, PRD R20 A, R23, R24, R26; D86; D105).
|
|
4
|
+
*
|
|
5
|
+
* D105 (2026-11-02) retired Now / Next / Later. The Roadmap is ONE ranked list: Prioritize's output, "Ranked on the
|
|
6
|
+
* roadmap". The lifecycle stage (Triage … Evaluate) says where an initiative is; the rank says what comes first.
|
|
4
7
|
*
|
|
5
8
|
* readPlacements(root, { now, rules, records }) → {
|
|
6
9
|
* ok: true,
|
|
7
|
-
* byInit: { [id]: {
|
|
8
|
-
*
|
|
9
|
-
* proposals: [{ eid, init,
|
|
10
|
-
* moves: [{ init, from, to, at, by, via }], every
|
|
10
|
+
* byInit: { [id]: { rank, after, check_by, confirmed, dormant, source } },
|
|
11
|
+
* ranked: [id…], the one Roadmap order, first is top
|
|
12
|
+
* proposals: [{ eid, init, after, by, at }], agent lines (proposed:true) not yet adopted or dropped
|
|
13
|
+
* moves: [{ init, from, to, at, by, via }], every applied line, oldest first: rank before and after (1 = top)
|
|
11
14
|
* flags: [{ kind, eid, init, why }],
|
|
12
15
|
* }
|
|
13
|
-
*
|
|
16
|
+
* rankOf(result, id) → the initiative's rank (0 = top), or null when it has no place
|
|
14
17
|
* appendFromUi(root, events, { actor, now }) → { ok, written, lines } | { ok: false, status, error, index }
|
|
15
18
|
* appendFromCli(root, events, { actor, now }) → the same
|
|
16
19
|
*
|
|
17
20
|
* `records` is the list of workflow rows ({ id, lane, last_activity, accepted, stopped, group? }, scripts/workflow-state.js
|
|
18
|
-
* --json) the day-one derivation (R26) reads; `rules` is lib/plan-rules.js readRules(root).
|
|
19
|
-
*
|
|
21
|
+
* --json) the day-one derivation (R26) reads; `rules` is lib/plan-rules.js readRules(root).
|
|
22
|
+
*
|
|
23
|
+
* The actor is never chosen by the caller of a route: the route takes it from actor.js (or pm-guard.js for adopt); the
|
|
24
|
+
* CLI from actor.fromCli or requirePmCli. D98: an agent's line applies like the PM's and keeps the agent's `by`, so the
|
|
25
|
+
* PM sees who moved what and can move it back.
|
|
20
26
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
27
|
+
* THE `ranked` LINE (D105; what the writer writes now):
|
|
28
|
+
* { v: 1, eid, ev: 'ranked', initiative, after: <initiative id> | null, check_by?: 'YYYY-MM-DD' | null, by, via, at }
|
|
29
|
+
* `after: null` is the top of the Roadmap; an `after` that is not on the Roadmap puts it at the end. A line without
|
|
30
|
+
* `check_by` keeps the previous one; `check_by: null` clears it.
|
|
25
31
|
*
|
|
26
|
-
* THE `placed` LINE (
|
|
27
|
-
* { v: 1, eid, ev: 'placed', initiative, horizon: 'now'|'next'|'later', after
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* `
|
|
32
|
+
* THE OLD `placed` LINE (before D105; read, never written again, never rewritten):
|
|
33
|
+
* { v: 1, eid, ev: 'placed', initiative, horizon: 'now'|'next'|'later', after, check_by?, proposed?, by, via, at }
|
|
34
|
+
* The fold keeps the order such a line gave: every row carries the band of the horizon it was last placed in (Now 0,
|
|
35
|
+
* Next 1, Later 2) and the one list stays sorted by band, so the old Now rows come first, then Next, then Later, each
|
|
36
|
+
* in its old order. A `placed` line goes where it went before inside its band. A `ranked` line takes the band of the
|
|
37
|
+
* row it comes after (the top is band 0), so it never breaks that order. Nothing in the ledger changes: the mapping is
|
|
38
|
+
* made at read time, and nothing that was ranked is lost. The writer refuses a new `placed` line.
|
|
31
39
|
*
|
|
32
|
-
* THE EVENTS
|
|
33
|
-
* { ev: 'created', initiative, from?: 'capture-YYYY-MM-DD-<n>' } the initiative writer's landing line:
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* { ev: 'adopted', proposal: <eid> } the PM or an agent keeps an open proposal: its placement applies.
|
|
40
|
+
* THE OTHER EVENTS (each with the same envelope):
|
|
41
|
+
* { ev: 'created', initiative, from?: 'capture-YYYY-MM-DD-<n>' } the initiative writer's landing line: the end of
|
|
42
|
+
* the Roadmap (R16, R23). Any actor; only for an initiative with no line yet. `from` names the capture it came from.
|
|
43
|
+
* { ev: 'adopted', proposal: <eid> } the PM keeps an open proposal (written before D98): its placement applies.
|
|
37
44
|
* { ev: 'dropped', proposal: <eid> } the proposal is closed unapplied (the PM or any agent, D98).
|
|
38
|
-
* pmOnly(rec) → true for a line that was PM-only
|
|
39
|
-
*
|
|
45
|
+
* pmOnly(rec) → true for a line that was PM-only: an old `placed` line into Now, and `adopted`. The checker
|
|
46
|
+
* (scripts/check-pm-lines.js) asks this function and never reads the schema itself.
|
|
40
47
|
*
|
|
41
|
-
* DAY ONE (R26), with no migration. An initiative of a work lane with no line in the ledger is
|
|
42
|
-
* active within `stall_days`
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* `
|
|
48
|
-
* lane filter: the fold answers the ledger alone.
|
|
48
|
+
* DAY ONE (R26), with no migration. An initiative of a work lane with no line in the ledger is ranked by its activity:
|
|
49
|
+
* the ones active within `stall_days` first (`confirmed: false`, `source: 'day-one'`), then the rest, newest activity
|
|
50
|
+
* first. Day one's rows are seeded before the ledger lines apply: a line with `after: null` goes above them, and a line
|
|
51
|
+
* whose `after` names a day-one row lands right after it. A finished initiative (accepted, or stopped by a lifecycle
|
|
52
|
+
* line) goes to the end of the Roadmap by itself (R3). An open initiative untouched for `dormant_days` that no line
|
|
53
|
+
* ranked is `dormant: true` (the page folds it behind "N dormant"); one a line ranked stays in view. Without
|
|
54
|
+
* `records` there is no day one and no lane filter.
|
|
49
55
|
*
|
|
50
56
|
* WORK LANES ONLY (D86 point 4). With `records`, an initiative whose lane is not in the `work` group of
|
|
51
|
-
* scripts/lane-defs.js
|
|
52
|
-
*
|
|
57
|
+
* scripts/lane-defs.js is left out of every answer, and so are its proposals. A placement of an initiative that has no
|
|
58
|
+
* record any more is left out with a flag.
|
|
53
59
|
*
|
|
54
60
|
* THE FOLD IS ORDER-FREE, like lib/plan-items.js: byte-identical duplicate lines (a union merge leaves them) count
|
|
55
61
|
* once, lines apply in (at, eid) order, and one eid with two contents keeps the first and flags the second. A later
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* HONEST LIMIT. The fold tells an agent's line by its `by`, and since D98 applies it either way; the `by` is the
|
|
59
|
-
* record of who acted. A forged `pm:` line is caught only by scripts/check-pm-lines.js (2B), not here.
|
|
62
|
+
* line for an initiative closes that initiative's open proposals (they are superseded, not adopted).
|
|
60
63
|
*
|
|
61
64
|
* The ledger is one per repository: lib/plan-ledgers.js ledgerPath(root, 'placements'). Nothing is cached (D33).
|
|
62
65
|
*/
|
|
@@ -68,8 +71,11 @@ const planTree = require('./plan-tree.js');
|
|
|
68
71
|
const actorLib = require('./actor.js');
|
|
69
72
|
const { createSinkGuard } = require('./sink.js');
|
|
70
73
|
|
|
71
|
-
|
|
72
|
-
const
|
|
74
|
+
/** The retired horizons (D105), read from old `placed` lines only. Their index is the band. */
|
|
75
|
+
const LEGACY_HORIZONS = Object.freeze(['now', 'next', 'later']);
|
|
76
|
+
const EVENTS = Object.freeze(['ranked', 'placed', 'created', 'adopted', 'dropped']);
|
|
77
|
+
/** What the writer still writes: an old `placed` line is read, never written. */
|
|
78
|
+
const WRITABLE = Object.freeze(['ranked', 'created', 'adopted', 'dropped']);
|
|
73
79
|
const MAX_LINES = 50;
|
|
74
80
|
const DAY = 86400000;
|
|
75
81
|
const INIT_RE = planTree.INIT_RE;
|
|
@@ -81,6 +87,7 @@ const CAPTURE_RE = /^capture-\d{4}-\d{2}-\d{2}-[1-9]\d{0,3}$/;
|
|
|
81
87
|
const WRITER_SET = Object.freeze(['v', 'eid', 'by', 'via', 'at', 'override', 'pm', 'actor', 'nonce', 'proposed']);
|
|
82
88
|
/** What a caller may send, per event (besides `ev`). */
|
|
83
89
|
const CALLER_KEYS = Object.freeze({
|
|
90
|
+
ranked: ['initiative', 'after', 'check_by'],
|
|
84
91
|
placed: ['initiative', 'horizon', 'after', 'check_by'],
|
|
85
92
|
created: ['initiative', 'from'],
|
|
86
93
|
adopted: ['proposal'],
|
|
@@ -88,6 +95,7 @@ const CALLER_KEYS = Object.freeze({
|
|
|
88
95
|
});
|
|
89
96
|
const ENVELOPE = ['v', 'eid', 'ev', 'by', 'via', 'at'];
|
|
90
97
|
const STORED_KEYS = Object.freeze({
|
|
98
|
+
ranked: [...ENVELOPE, ...CALLER_KEYS.ranked],
|
|
91
99
|
placed: [...ENVELOPE, ...CALLER_KEYS.placed, 'proposed'],
|
|
92
100
|
created: [...ENVELOPE, ...CALLER_KEYS.created],
|
|
93
101
|
adopted: [...ENVELOPE, ...CALLER_KEYS.adopted],
|
|
@@ -126,11 +134,11 @@ function lineErr(r) {
|
|
|
126
134
|
if (!isStr(r.at) || !AT_RE.test(r.at)) return 'at must be an ISO UTC time';
|
|
127
135
|
const extra = Object.keys(r).filter((k) => !STORED_KEYS[r.ev].includes(k));
|
|
128
136
|
if (extra.length) return `a ${r.ev} line has no field ${extra.join(', ')}`;
|
|
129
|
-
if (r.ev === 'placed' || r.ev === 'created') {
|
|
137
|
+
if (r.ev === 'placed' || r.ev === 'ranked' || r.ev === 'created') {
|
|
130
138
|
if (!isStr(r.initiative) || !INIT_RE.test(r.initiative)) return 'initiative must be a record name';
|
|
131
139
|
}
|
|
132
|
-
if (r.ev === 'placed')
|
|
133
|
-
|
|
140
|
+
if (r.ev === 'placed' && !LEGACY_HORIZONS.includes(r.horizon)) return 'horizon must be now, next or later';
|
|
141
|
+
if (r.ev === 'placed' || r.ev === 'ranked') {
|
|
134
142
|
if (r.after !== null && !(isStr(r.after) && INIT_RE.test(r.after))) return 'after must be an initiative id or null';
|
|
135
143
|
if (r.after === r.initiative) return 'an initiative cannot come after itself';
|
|
136
144
|
if (has(r, 'check_by') && r.check_by !== null && !dateOk(r.check_by)) return 'check_by must be YYYY-MM-DD or null';
|
|
@@ -143,7 +151,7 @@ function lineErr(r) {
|
|
|
143
151
|
|
|
144
152
|
// ── the fold ────────────────────────────────────────────────────────────────────────────────────────
|
|
145
153
|
function emptyResult() {
|
|
146
|
-
return { ok: true, byInit: {},
|
|
154
|
+
return { ok: true, byInit: {}, ranked: [], proposals: [], moves: [], flags: [] };
|
|
147
155
|
}
|
|
148
156
|
|
|
149
157
|
/** Sort, de-duplicate and validate the raw lines: [{ rec }] in (at, eid) order. Flags go into `out.flags`. */
|
|
@@ -169,32 +177,50 @@ function orderLines(lines, out) {
|
|
|
169
177
|
return outLines;
|
|
170
178
|
}
|
|
171
179
|
|
|
172
|
-
|
|
180
|
+
/** Where a row goes in the one list. `band` is a number (an old `placed` line: its horizon's band) or null (a `ranked`
|
|
181
|
+
* line: the band of the row it comes after; the top is band 0; the end is the last band). The list stays sorted by band. */
|
|
182
|
+
function place(out, bands, id, band, after, checkBy, { confirmed, source, rec }) {
|
|
173
183
|
// A row seeded only as an anchor (it has a ledger line of its own, below) was never placed: its first line is its
|
|
174
184
|
// first placement, as when it was not seeded.
|
|
175
185
|
const prev = out.byInit[id] && !out.byInit[id].anchorOnly ? out.byInit[id] : null;
|
|
176
|
-
|
|
177
|
-
const list = out.
|
|
178
|
-
|
|
179
|
-
if (
|
|
186
|
+
const from = prev ? out.ranked.indexOf(id) : -1;
|
|
187
|
+
const list = out.ranked.filter((x) => x !== id);
|
|
188
|
+
let k;
|
|
189
|
+
if (band === null) {
|
|
190
|
+
const j = after ? list.indexOf(after) : -1;
|
|
191
|
+
if (!after) { k = 0; band = 0; }
|
|
192
|
+
else if (j === -1) { k = list.length; band = LEGACY_HORIZONS.length - 1; }
|
|
193
|
+
else { k = j + 1; band = bands.get(after); }
|
|
194
|
+
} else {
|
|
195
|
+
const j = after ? list.indexOf(after) : -1;
|
|
196
|
+
if (j !== -1 && bands.get(after) === band) k = j + 1;
|
|
197
|
+
else if (!after) { k = list.findIndex((x) => bands.get(x) >= band); if (k === -1) k = list.length; }
|
|
198
|
+
else { k = list.findIndex((x) => bands.get(x) > band); if (k === -1) k = list.length; }
|
|
199
|
+
}
|
|
200
|
+
list.splice(k, 0, id);
|
|
201
|
+
out.ranked = list;
|
|
202
|
+
bands.set(id, band);
|
|
180
203
|
out.byInit[id] = {
|
|
181
|
-
|
|
204
|
+
rank: 0, after: after || null,
|
|
182
205
|
check_by: checkBy === undefined ? (prev ? prev.check_by : null) : checkBy,
|
|
183
206
|
confirmed, dormant: false, source,
|
|
184
207
|
};
|
|
185
|
-
if (rec && (!prev ||
|
|
208
|
+
if (rec && (!prev || from !== k)) out.moves.push({ init: id, from: prev ? from + 1 : null, to: k + 1, at: rec.at, by: rec.by, via: rec.via });
|
|
186
209
|
}
|
|
210
|
+
const bandOfLine = (rec) => (rec.ev === 'placed' ? LEGACY_HORIZONS.indexOf(rec.horizon) : null);
|
|
187
211
|
|
|
188
212
|
/** Every line applied in order. `open` is the map of open proposals by eid (the writer reads it). `seed` is day one's
|
|
189
|
-
* rows ({ now: [id…], later: [id…] }, initiatives with no ledger line
|
|
190
|
-
* `after` names a day-one row finds it
|
|
213
|
+
* rows ({ now: [id…], later: [id…] }, initiatives with no ledger line; `now` is the active ones), placed BEFORE the
|
|
214
|
+
* lines apply, so a line whose `after` names a day-one row finds it. Without `seed` it is the ledger alone. */
|
|
191
215
|
function foldLines(lines, seed) {
|
|
192
216
|
const out = emptyResult();
|
|
217
|
+
const bands = new Map();
|
|
193
218
|
if (seed) {
|
|
194
|
-
for (const h of
|
|
219
|
+
for (const [band, h] of [[0, 'now'], [LEGACY_HORIZONS.length - 1, 'later']]) {
|
|
195
220
|
for (const id of seed[h] || []) {
|
|
196
|
-
out.
|
|
197
|
-
|
|
221
|
+
out.ranked.push(id);
|
|
222
|
+
bands.set(id, band);
|
|
223
|
+
out.byInit[id] = { rank: 0, after: null, check_by: null, confirmed: false, dormant: false, source: 'day-one' };
|
|
198
224
|
if (seed.anchorOnly && seed.anchorOnly.has(id)) out.byInit[id].anchorOnly = true;
|
|
199
225
|
}
|
|
200
226
|
}
|
|
@@ -203,19 +229,20 @@ function foldLines(lines, seed) {
|
|
|
203
229
|
const touched = new Set();
|
|
204
230
|
const created = new Map(); // initiative -> capture id it came from (or null)
|
|
205
231
|
for (const { n, rec } of orderLines(lines, out)) {
|
|
206
|
-
if (rec.ev === 'placed') {
|
|
232
|
+
if (rec.ev === 'placed' || rec.ev === 'ranked') {
|
|
207
233
|
const agentLine = !isPmBy(rec.by);
|
|
208
234
|
if (rec.proposed === true || agentLine) {
|
|
209
235
|
if (agentLine && rec.proposed !== true) out.flags.push({ kind: 'agent-not-proposed', eid: rec.eid, init: rec.initiative, why: `line ${n}: an agent's placement is a proposal; this one moved nothing` });
|
|
210
|
-
open.set(rec.eid, { eid: rec.eid, init: rec.initiative,
|
|
236
|
+
open.set(rec.eid, { eid: rec.eid, init: rec.initiative, band: bandOfLine(rec), after: rec.after || null, check_by: has(rec, 'check_by') ? rec.check_by : undefined, by: rec.by, at: rec.at });
|
|
211
237
|
continue;
|
|
212
238
|
}
|
|
213
|
-
for (const [eid, p] of open) if (p.init === rec.initiative) open.delete(eid); // superseded by
|
|
214
|
-
place(out, rec.initiative, rec
|
|
239
|
+
for (const [eid, p] of open) if (p.init === rec.initiative) open.delete(eid); // superseded by a later line
|
|
240
|
+
place(out, bands, rec.initiative, bandOfLine(rec), rec.after, has(rec, 'check_by') ? rec.check_by : undefined, { confirmed: true, source: 'ledger', rec });
|
|
215
241
|
touched.add(rec.initiative);
|
|
216
242
|
} else if (rec.ev === 'created') {
|
|
217
243
|
if (touched.has(rec.initiative)) { out.flags.push({ kind: 'created-twice', eid: rec.eid, init: rec.initiative, why: `line ${n}: ${rec.initiative} already had a placement; this landing line moved nothing` }); continue; }
|
|
218
|
-
|
|
244
|
+
// The end of the Roadmap (an `after` that is on no list); the old line said "top of Later", which was a band, not a place.
|
|
245
|
+
place(out, bands, rec.initiative, LEGACY_HORIZONS.length - 1, null, undefined, { confirmed: isPmBy(rec.by), source: 'created', rec });
|
|
219
246
|
touched.add(rec.initiative);
|
|
220
247
|
created.set(rec.initiative, rec.from || null);
|
|
221
248
|
} else {
|
|
@@ -225,7 +252,7 @@ function foldLines(lines, seed) {
|
|
|
225
252
|
if (!isPmBy(rec.by)) { out.flags.push({ kind: 'adopt-not-pm', eid: rec.eid, init: p.init, why: `line ${n}: only the PM adopts a proposal; this line moved nothing` }); continue; }
|
|
226
253
|
open.delete(rec.proposal);
|
|
227
254
|
for (const [eid, q] of open) if (q.init === p.init) open.delete(eid);
|
|
228
|
-
place(out, p.init, p.
|
|
255
|
+
place(out, bands, p.init, p.band, p.after, p.check_by, { confirmed: true, source: 'ledger', rec });
|
|
229
256
|
touched.add(p.init);
|
|
230
257
|
} else {
|
|
231
258
|
if (!isPmBy(rec.by) && rec.by !== p.by) { out.flags.push({ kind: 'drop-not-allowed', eid: rec.eid, init: p.init, why: `line ${n}: only the PM or the agent that proposed it drops a proposal` }); continue; }
|
|
@@ -235,6 +262,8 @@ function foldLines(lines, seed) {
|
|
|
235
262
|
}
|
|
236
263
|
return { out, open, created };
|
|
237
264
|
}
|
|
265
|
+
const proposalOut = (p) => ({ eid: p.eid, init: p.init, after: p.after, by: p.by, at: p.at });
|
|
266
|
+
const numberRanks = (out) => { out.ranked.forEach((id, i) => { out.byInit[id].rank = i; }); };
|
|
238
267
|
|
|
239
268
|
const activityMs = (r) => {
|
|
240
269
|
const v = r && r.last_activity;
|
|
@@ -264,8 +293,8 @@ function readPlacements(root, { now, rules, records } = {}) {
|
|
|
264
293
|
if (!Array.isArray(records)) {
|
|
265
294
|
const { out, open } = ledgerOnly;
|
|
266
295
|
for (const b of bad) out.flags.unshift({ kind: 'unreadable', eid: null, init: null, why: `line ${b.n}: ${b.why}` });
|
|
267
|
-
out.proposals = [...open.values()].map(
|
|
268
|
-
|
|
296
|
+
out.proposals = [...open.values()].map(proposalOut);
|
|
297
|
+
numberRanks(out);
|
|
269
298
|
return out;
|
|
270
299
|
}
|
|
271
300
|
|
|
@@ -279,15 +308,15 @@ function readPlacements(root, { now, rules, records } = {}) {
|
|
|
279
308
|
for (const r of records) if (r && isStr(r.id) && r.ok !== false) rows.set(r.id, r);
|
|
280
309
|
const isWork = (id) => rows.has(id) && groupOf(rows.get(id)) === 'work';
|
|
281
310
|
|
|
282
|
-
// Day one's rows: a work initiative with no line the ledger applied,
|
|
283
|
-
//
|
|
311
|
+
// Day one's rows: a work initiative with no line the ledger applied, ranked by its activity (the active ones first).
|
|
312
|
+
// They are seeded before the ledger lines apply, so a line placed `after` a day-one row (the page and the CLI send the
|
|
284
313
|
// displayed order) lands next to it. A ledger line with `after: null` still goes above them.
|
|
285
314
|
const byActivity = (a, b) => ((activityMs(rows.get(b)) || 0) - (activityMs(rows.get(a)) || 0)) || (a < b ? -1 : 1);
|
|
286
315
|
// A row that has a line of its own is seeded too, as an ANCHOR only: a line written while it was still a day-one row
|
|
287
316
|
// named it as `after`, and that line must find it where it stood then. Its own line moves it when it applies. Seeding
|
|
288
317
|
// only the rows with no line lost that anchor the moment the row got a line (the earlier line then appended its row
|
|
289
|
-
// at the end of the
|
|
290
|
-
const seed = { now: [],
|
|
318
|
+
// at the end of the list), so one reorder could scramble rows it never touched.
|
|
319
|
+
const seed = { now: [], later: [], anchorOnly: new Set() };
|
|
291
320
|
for (const id of [...rows.keys()].filter((x) => isWork(x)).sort(byActivity)) {
|
|
292
321
|
const r = rows.get(id);
|
|
293
322
|
const ms = activityMs(r);
|
|
@@ -297,32 +326,25 @@ function readPlacements(root, { now, rules, records } = {}) {
|
|
|
297
326
|
const { out, open } = foldLines(lines, seed);
|
|
298
327
|
for (const id of Object.keys(out.byInit)) if (out.byInit[id].anchorOnly) delete out.byInit[id].anchorOnly;
|
|
299
328
|
for (const b of bad) out.flags.unshift({ kind: 'unreadable', eid: null, init: null, why: `line ${b.n}: ${b.why}` });
|
|
300
|
-
const proposalsOf = (keep) => [...open.values()].filter((p) => keep(p.init))
|
|
301
|
-
.map((p) => ({ eid: p.eid, init: p.init, horizon: p.horizon, after: p.after, by: p.by, at: p.at }));
|
|
329
|
+
const proposalsOf = (keep) => [...open.values()].filter((p) => keep(p.init)).map(proposalOut);
|
|
302
330
|
|
|
303
331
|
for (const id of Object.keys(out.byInit)) {
|
|
304
332
|
if (isWork(id)) continue;
|
|
305
333
|
if (!rows.has(id)) out.flags.push({ kind: 'no-record', eid: null, init: id, why: `${id} has a placement but no initiative record; it is left out` });
|
|
306
334
|
delete out.byInit[id];
|
|
307
|
-
|
|
335
|
+
out.ranked = out.ranked.filter((x) => x !== id);
|
|
308
336
|
}
|
|
309
337
|
out.moves = out.moves.filter((m) => isWork(m.init));
|
|
310
338
|
out.proposals = proposalsOf(isWork);
|
|
311
339
|
|
|
312
|
-
// A finished initiative
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
out.order.now = out.order.now.filter((x) => x !== id);
|
|
316
|
-
out.order.later.push(id);
|
|
317
|
-
out.byInit[id].horizon = 'later';
|
|
318
|
-
}
|
|
319
|
-
// Finished initiatives sit at the end of Later, in the order they were in.
|
|
320
|
-
out.order.later = [...out.order.later.filter((id) => !finished(rows.get(id))), ...out.order.later.filter((id) => finished(rows.get(id)))];
|
|
321
|
-
for (const id of out.order.later) {
|
|
340
|
+
// A finished initiative goes to the end of the Roadmap by itself (R3), in the order it was in.
|
|
341
|
+
out.ranked = [...out.ranked.filter((id) => !finished(rows.get(id))), ...out.ranked.filter((id) => finished(rows.get(id)))];
|
|
342
|
+
for (const id of out.ranked) {
|
|
322
343
|
const ms = activityMs(rows.get(id));
|
|
323
|
-
|
|
344
|
+
// A row a line ranked never folds away: the PM (or an agent) put it there. Day one's and a landing line's rows do.
|
|
345
|
+
out.byInit[id].dormant = !finished(rows.get(id)) && out.byInit[id].source !== 'ledger' && ms !== null && t - ms >= dormantMs;
|
|
324
346
|
}
|
|
325
|
-
|
|
347
|
+
numberRanks(out);
|
|
326
348
|
return out;
|
|
327
349
|
}
|
|
328
350
|
|
|
@@ -332,9 +354,10 @@ function pmOnly(rec) {
|
|
|
332
354
|
return rec.ev === 'placed' && rec.horizon === 'now' && rec.proposed !== true;
|
|
333
355
|
}
|
|
334
356
|
|
|
335
|
-
|
|
357
|
+
/** The initiative's rank on the Roadmap (0 = top), or null when it has no place. */
|
|
358
|
+
function rankOf(result, id) {
|
|
336
359
|
const p = result && result.byInit && Object.prototype.hasOwnProperty.call(result.byInit, id) ? result.byInit[id] : null;
|
|
337
|
-
return p &&
|
|
360
|
+
return p && Number.isInteger(p.rank) ? p.rank : null;
|
|
338
361
|
}
|
|
339
362
|
|
|
340
363
|
/** The capture notes an initiative was created from: { [captureId]: initiativeId } (lib/triage.js reads it). */
|
|
@@ -354,21 +377,20 @@ function buildRecord(root, ev, i, actor, state) {
|
|
|
354
377
|
if (!ev || typeof ev !== 'object' || Array.isArray(ev)) return refuse(400, 'each line must be a JSON object', i);
|
|
355
378
|
const sent = WRITER_SET.find((k) => has(ev, k));
|
|
356
379
|
if (sent) return refuse(400, `the writer sets "${sent}"; do not send it`, i);
|
|
357
|
-
if (
|
|
380
|
+
if (ev.ev === 'placed') return refuse(400, 'Now, Next and Later are retired (D105): send a ranked line { ev: "ranked", initiative, after } instead', i);
|
|
381
|
+
if (!WRITABLE.includes(ev.ev)) return refuse(400, `ev must be one of ${WRITABLE.join(', ')}`, i);
|
|
358
382
|
const extra = Object.keys(ev).filter((k) => k !== 'ev' && !CALLER_KEYS[ev.ev].includes(k));
|
|
359
383
|
if (extra.length) return refuse(400, `a ${ev.ev} line has no field ${extra.join(', ')}`, i);
|
|
360
384
|
const rec = { ev: ev.ev };
|
|
361
|
-
if (ev.ev === '
|
|
385
|
+
if (ev.ev === 'ranked' || ev.ev === 'created') {
|
|
362
386
|
if (!isStr(ev.initiative) || !INIT_RE.test(ev.initiative)) return refuse(400, 'initiative must be an initiative id', i);
|
|
363
387
|
if (!planTree.recordPath(root, ev.initiative)) return refuse(404, `no initiative ${ev.initiative} in this repository`, i);
|
|
364
388
|
rec.initiative = ev.initiative;
|
|
365
389
|
}
|
|
366
|
-
if (ev.ev === '
|
|
367
|
-
if (!HORIZONS.includes(ev.horizon)) return refuse(400, 'horizon must be now, next or later', i);
|
|
390
|
+
if (ev.ev === 'ranked') {
|
|
368
391
|
const after = ev.after == null ? null : ev.after;
|
|
369
392
|
if (after !== null && !(isStr(after) && INIT_RE.test(after))) return refuse(400, 'after must be an initiative id or null', i);
|
|
370
393
|
if (after === ev.initiative) return refuse(400, 'an initiative cannot come after itself', i);
|
|
371
|
-
rec.horizon = ev.horizon;
|
|
372
394
|
rec.after = after;
|
|
373
395
|
if (has(ev, 'check_by')) {
|
|
374
396
|
if (ev.check_by !== null && !dateOk(ev.check_by)) return refuse(400, 'check_by must be YYYY-MM-DD, or null to clear it', i);
|
|
@@ -427,12 +449,12 @@ function append(root, events, actor, { now } = {}) {
|
|
|
427
449
|
return { ok: true, written: recs.length, lines: recs.map((r) => ({ eid: r.eid, ev: r.ev, initiative: r.initiative || null, proposed: r.proposed === true })) };
|
|
428
450
|
}
|
|
429
451
|
|
|
430
|
-
/** A page press. The actor is the guard's (requirePmPress for
|
|
452
|
+
/** A page press. The actor is the guard's (requirePmPress for adopt, requirePagePress otherwise). */
|
|
431
453
|
function appendFromUi(root, events, { actor, now } = {}) { return append(root, events, actor, { now }); }
|
|
432
|
-
/** `pmos initiative`. The actor is requirePmCli's (
|
|
454
|
+
/** `pmos initiative`. The actor is requirePmCli's (adopt) or actor.fromCli's. */
|
|
433
455
|
function appendFromCli(root, events, { actor, now } = {}) { return append(root, events, actor, { now }); }
|
|
434
456
|
|
|
435
457
|
module.exports = {
|
|
436
|
-
|
|
437
|
-
readPlacements,
|
|
458
|
+
LEGACY_HORIZONS, EVENTS, WRITABLE, MAX_LINES, CAPTURE_RE,
|
|
459
|
+
readPlacements, rankOf, pmOnly, createdFrom, lineErr, appendFromUi, appendFromCli,
|
|
438
460
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* plan-rules.js — the numbers the planning layer reads (pm-os-absorb, PRD R24): planning/plan-rules.json.
|
|
3
3
|
*
|
|
4
|
-
* readRules(root) → { stall_days, dormant_days, report_cycle_days,
|
|
4
|
+
* readRules(root) → { stall_days, dormant_days, report_cycle_days, via_required_from, …other keys }
|
|
5
5
|
* readRulesDetail(root) → { rules, path, errors, unknown } the same read, with what was wrong with the file
|
|
6
6
|
*
|
|
7
7
|
* One reader, so the Today ranking, the health rules, day one and the report window cannot each keep their own copy
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* A value that is not valid reads its default, and the reason is in `errors`; readRules never throws, because a
|
|
13
13
|
* typo in a rules file must not take the Today count or a report down with it. A key this reader does not know is
|
|
14
14
|
* passed through unchanged and named in `unknown` (a run that adds a key adds it to KEYS with its check). Keys that
|
|
15
|
-
* start with `_` are comments.
|
|
15
|
+
* start with `_` are comments. A RETIRED key is read past in silence: `now_cap`, the cap on Now, went with the horizons
|
|
16
|
+
* (D105), so an older file that still has it is not an error and the key reaches no caller. Nothing is cached (D33).
|
|
16
17
|
*/
|
|
17
18
|
const fs = require('fs');
|
|
18
19
|
const path = require('path');
|
|
@@ -20,7 +21,9 @@ const path = require('path');
|
|
|
20
21
|
// via_required_from (Run 2, R25(4), map-spec X10): the ISO UTC time from which a PM-only line must carry `via`.
|
|
21
22
|
// scripts/check-pm-lines.js fails a newer line without one and reports each older line once, never failing it.
|
|
22
23
|
// null means no time is set yet: every PM-only line is older, so none fails for a missing via.
|
|
23
|
-
const DEFAULTS = Object.freeze({ stall_days: 5, dormant_days: 45, report_cycle_days: 14,
|
|
24
|
+
const DEFAULTS = Object.freeze({ stall_days: 5, dormant_days: 45, report_cycle_days: 14, via_required_from: null });
|
|
25
|
+
/** Keys a rules file may still carry from before a decision retired them. */
|
|
26
|
+
const RETIRED = Object.freeze(['now_cap']);
|
|
24
27
|
const posInt = (v) => Number.isInteger(v) && v > 0;
|
|
25
28
|
const isoUtc = (v) => typeof v === 'string' && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z$/.test(v) && !Number.isNaN(Date.parse(v));
|
|
26
29
|
/** Each known key and the check its value must pass. */
|
|
@@ -28,7 +31,6 @@ const KEYS = Object.freeze({
|
|
|
28
31
|
stall_days: { ok: posInt, want: 'a whole number of days, 1 or more' },
|
|
29
32
|
dormant_days: { ok: posInt, want: 'a whole number of days, 1 or more' },
|
|
30
33
|
report_cycle_days: { ok: posInt, want: 'a whole number of days, 1 or more' },
|
|
31
|
-
now_cap: { ok: (v) => v === null || posInt(v), want: 'null (no cap) or a whole number, 1 or more' },
|
|
32
34
|
via_required_from: { ok: (v) => v === null || isoUtc(v), want: 'null (not set yet) or an ISO UTC time such as 2026-10-20T09:00:00Z' },
|
|
33
35
|
});
|
|
34
36
|
const CANDIDATES = [['planning', 'plan-rules.json'], ['pmos', 'state', 'plan-rules.json']];
|
|
@@ -49,7 +51,7 @@ function validate(obj) {
|
|
|
49
51
|
const unknown = [];
|
|
50
52
|
if (!obj || typeof obj !== 'object' || Array.isArray(obj)) return { rules, errors: ['the rules file is not a JSON object'], unknown };
|
|
51
53
|
for (const [k, v] of Object.entries(obj)) {
|
|
52
|
-
if (k.startsWith('_')) continue;
|
|
54
|
+
if (k.startsWith('_') || RETIRED.includes(k)) continue;
|
|
53
55
|
const spec = KEYS[k];
|
|
54
56
|
if (!spec) { unknown.push(k); rules[k] = v; continue; }
|
|
55
57
|
if (spec.ok(v)) rules[k] = v;
|
|
@@ -55,8 +55,7 @@ const PM_ONLY_ACTS = Object.freeze([
|
|
|
55
55
|
'accept', // the Acceptance Gate, the review approve and return, a document approval (/api/gate)
|
|
56
56
|
'lifecycle', // hold, close, cancel, reopen (/api/lifecycle)
|
|
57
57
|
'keep', // Keep on an agent batch (/api/plan-items kept)
|
|
58
|
-
'
|
|
59
|
-
'adopt', // adopt an agent's placement proposal
|
|
58
|
+
'adopt', // adopt an agent's placement proposal (Move to Now, act 'now', was retired with the horizons: D105)
|
|
60
59
|
'anchor', // change parent_kr (the record, /api/doc/save, /api/align/apply, /api/ingest/confirm)
|
|
61
60
|
'bind', // bind a session to an initiative (/api/session/initiative)
|
|
62
61
|
'issue', // Issue a report (issues.jsonl)
|
|
@@ -68,7 +67,6 @@ const ACT_PHRASE = Object.freeze({
|
|
|
68
67
|
accept: 'accept or return work',
|
|
69
68
|
lifecycle: 'hold, close, cancel or reopen an initiative',
|
|
70
69
|
keep: 'keep an agent\'s items',
|
|
71
|
-
now: 'move an item to Now',
|
|
72
70
|
adopt: 'adopt a proposal',
|
|
73
71
|
anchor: 'change an anchor',
|
|
74
72
|
bind: 'bind a session to an initiative',
|
|
@@ -70,7 +70,7 @@ const QUESTION = 'A PM-only line is not attested';
|
|
|
70
70
|
|
|
71
71
|
const what = {
|
|
72
72
|
'plan-items': () => 'A Keep line',
|
|
73
|
-
placements: (r) => `
|
|
73
|
+
placements: (r) => (r.ev === 'adopted' ? 'An adopted proposal' : `An old line into ${r.horizon === 'now' ? 'Now' : String(r.horizon || 'a horizon')} (before D105)`),
|
|
74
74
|
measurements: () => 'A measured line',
|
|
75
75
|
issues: () => 'An issued line',
|
|
76
76
|
acceptances: () => 'An acceptance line',
|
|
@@ -32,10 +32,11 @@
|
|
|
32
32
|
* WHAT draftOf FOLDS (Run 5, slice 5A). Local files only, no git fetch and no model (X18):
|
|
33
33
|
* - the window: since the last issue of this cadence before the slot (lib/issues.js), else report_cycle_days back
|
|
34
34
|
* from `now` (X20). Two calls with the same inputs and `now` give the same draft; another `now`, another window;
|
|
35
|
-
* - one block per work-lane initiative active in the window (scripts/lane-defs.js group `work`, D86 point 4):
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
35
|
+
* - one block per work-lane initiative active in the window (scripts/lane-defs.js group `work`, D86 point 4): not
|
|
36
|
+
* dormant and either ranked by a line or under way (past its spec, not accepted; lib/lifecycle-stage.js), or with an
|
|
37
|
+
* item line, a Roadmap move, a gate or a lifecycle line in the window. Off track and at risk first, then the
|
|
38
|
+
* Roadmap rank (D105: was "in Now" and the Now, Next, Later order). Stage from initiative-display.js displayOf;
|
|
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
|
|
39
40
|
* at its level refuses the whole draft (422);
|
|
40
41
|
* - progress from plan-items (proposed items never count; an item the factory join marks integrated counts done);
|
|
41
42
|
* a measured value only from a measurements line whose source is `<path>@<sha>` (no KR is computed here);
|
|
@@ -54,6 +55,7 @@ const consoleState = require('./console-state');
|
|
|
54
55
|
const planItems = require('./plan-items.js');
|
|
55
56
|
const planTree = require('./plan-tree.js');
|
|
56
57
|
const placements = require('./placements.js');
|
|
58
|
+
const lifecycle = require('./lifecycle-stage.js');
|
|
57
59
|
const measurements = require('./measurements.js');
|
|
58
60
|
const issues = require('./issues.js');
|
|
59
61
|
const factoryJoin = require('./factory-join.js');
|
|
@@ -102,8 +104,6 @@ const SOURCE_RE = /^[^@\s]+@[0-9a-f]{7,40}$/;
|
|
|
102
104
|
const DAY = 86400000;
|
|
103
105
|
const SEVERITY = { off: 3, 'at-risk': 2, unknown: 1, on: 0 };
|
|
104
106
|
const LEVEL_WORD = { off: 'Off track', 'at-risk': 'At risk', unknown: 'Unknown', on: 'On track' };
|
|
105
|
-
const HORIZON_WORD = { now: 'Now', next: 'Next', later: 'Later' };
|
|
106
|
-
const HORIZONS = ['now', 'next', 'later'];
|
|
107
107
|
const LIFECYCLE_WORD = { 'on-hold': 'put on hold', held: 'put on hold', closed: 'closed', cancelled: 'cancelled', active: 'reopened' };
|
|
108
108
|
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
109
109
|
|
|
@@ -289,7 +289,6 @@ function draftOf(root, { cadence, slot, now, health } = {}) {
|
|
|
289
289
|
const id = row.id;
|
|
290
290
|
const its = itemsOf(id);
|
|
291
291
|
const placement = has(plc.byInit, id) ? plc.byInit[id] : null;
|
|
292
|
-
const horizon = placements.horizonOf(plc, id);
|
|
293
292
|
const moves = plc.moves.filter((m) => m.init === id && inWin(m.at));
|
|
294
293
|
const gates = [
|
|
295
294
|
...acc.rows.filter((a) => a.initiative_id === id && a.accepted === true && inWin(a.accepted_at || a.at)).map((a) => ({ gate: 'acceptance', at: String(a.accepted_at || a.at) })),
|
|
@@ -300,7 +299,9 @@ function draftOf(root, { cadence, slot, now, health } = {}) {
|
|
|
300
299
|
const lifeHere = life.rows.filter((l) => l.initiative_id === id && inWin(l.at));
|
|
301
300
|
const touched = its.some((it) => it.history.some((h) => inWin(h.at)));
|
|
302
301
|
if (row.stopped && Number.isFinite(toMs(row.stopped.at)) && toMs(row.stopped.at) <= fromMs) continue;
|
|
303
|
-
|
|
302
|
+
// D105: was "in Now". Now: not dormant, and either a line ranked it on the Roadmap or its work is under way.
|
|
303
|
+
const committed = !!placement && !placement.dormant && (placement.source === 'ledger' || lifecycle.underway(row));
|
|
304
|
+
const active = committed || touched || moves.length || gates.length || lifeHere.length;
|
|
304
305
|
if (!active) continue;
|
|
305
306
|
|
|
306
307
|
const narrowed = { items: Object.fromEntries(its.map((it) => [it.id, it])), order: its.map((it) => it.id),
|
|
@@ -325,7 +326,7 @@ function draftOf(root, { cadence, slot, now, health } = {}) {
|
|
|
325
326
|
const doneNow = real.filter((it) => it.state === 'done' && inWin(it.doneAt));
|
|
326
327
|
const done = real.filter(isDone).length;
|
|
327
328
|
const today = dayOf(nowMs);
|
|
328
|
-
const
|
|
329
|
+
const cycleEnd = dayOf(nowMs + cycle * DAY);
|
|
329
330
|
const open = real.filter((it) => !isDone(it));
|
|
330
331
|
const carried = open.filter((it) => it.due && it.due < today)
|
|
331
332
|
.sort((a, b) => byText(a.due, b.due) || byText(a.id, b.id)).map((it) => ({ id: it.id, title: it.title, due: it.due }));
|
|
@@ -333,7 +334,7 @@ function draftOf(root, { cadence, slot, now, health } = {}) {
|
|
|
333
334
|
const stageIdx = (s) => { const k = stageIds.indexOf(s); return k === -1 ? stageIds.length : k; };
|
|
334
335
|
const ordered = open.slice().sort((a, b) => (stageIdx(a.stage) - stageIdx(b.stage)) || (a.order - b.order)
|
|
335
336
|
|| byText(String(a.createdAt), String(b.createdAt)) || byText(a.id, b.id));
|
|
336
|
-
const dated = ordered.filter((it) => [it.start, it.due].some((d) => d && d >= today && d <=
|
|
337
|
+
const dated = ordered.filter((it) => [it.start, it.due].some((d) => d && d >= today && d <= cycleEnd));
|
|
337
338
|
const coming = dated.length ? { basis: 'dates', list: dated } : { basis: 'order', list: ordered.slice(0, 3) };
|
|
338
339
|
const m = measurement && SOURCE_RE.test(String(measurement.source)) ? measurement : null;
|
|
339
340
|
|
|
@@ -352,11 +353,11 @@ function draftOf(root, { cadence, slot, now, health } = {}) {
|
|
|
352
353
|
},
|
|
353
354
|
coming_cycle: { basis: coming.basis, items: coming.list.map((it) => ({ id: it.id, title: it.title, start: it.start || null, due: it.due || null })) },
|
|
354
355
|
note: has(notes, id) ? notes[id] : '',
|
|
355
|
-
_order: [SEVERITY[h.level],
|
|
356
|
+
_order: [SEVERITY[h.level], placement ? placement.rank : Infinity],
|
|
356
357
|
});
|
|
357
358
|
}
|
|
358
|
-
// Off track and at risk first; then
|
|
359
|
-
blocks.sort((a, b) => (b._order[0] - a._order[0]) || (a._order[1] - b._order[1]) ||
|
|
359
|
+
// Off track and at risk first; then the Roadmap rank; then the id.
|
|
360
|
+
blocks.sort((a, b) => (b._order[0] - a._order[0]) || (a._order[1] - b._order[1]) || byText(a.id, b.id));
|
|
360
361
|
for (const b of blocks) delete b._order;
|
|
361
362
|
|
|
362
363
|
// The Timeline strip, frozen at fold time: one row per block with dated items, one span per stage.
|
|
@@ -390,7 +391,7 @@ function draftOf(root, { cadence, slot, now, health } = {}) {
|
|
|
390
391
|
const decided = [];
|
|
391
392
|
const plcRel = relMain(ledgers.ledgerPath(abs, 'placements'));
|
|
392
393
|
for (const mv of plc.moves) {
|
|
393
|
-
if (work.has(mv.init) && inWin(mv.at) && isStr(mv.by) && mv.by.startsWith('pm:')) decided.push({ text: `${titleOf.get(mv.init)}
|
|
394
|
+
if (work.has(mv.init) && inWin(mv.at) && isStr(mv.by) && mv.by.startsWith('pm:')) decided.push({ text: `${titleOf.get(mv.init)} ranked #${mv.to} on the Roadmap`, at: mv.at, source: plcRel });
|
|
394
395
|
}
|
|
395
396
|
for (const l of life.rows) {
|
|
396
397
|
if (work.has(l.initiative_id) && inWin(l.at) && has(LIFECYCLE_WORD, l.state)) decided.push({ text: `${titleOf.get(l.initiative_id)} ${LIFECYCLE_WORD[l.state]}`, at: String(l.at), source: relHere(path.join(L.runsDir, 'lifecycle.jsonl')) });
|
|
@@ -493,7 +494,7 @@ function draftOf(root, { cadence, slot, now, health } = {}) {
|
|
|
493
494
|
const slides = slidesData({
|
|
494
495
|
product: def.product || path.basename(main), cadence, slot: theSlot, nowMs, window, cycleDays: cycle,
|
|
495
496
|
blocks, rows, itemsOf,
|
|
496
|
-
stageLabel,
|
|
497
|
+
stageLabel, lifecycleOf: (id) => lifecycle.labelOf(rows.find((r) => r.id === id)),
|
|
497
498
|
rankOf: (id) => (has(plc.byInit, id) && Number.isFinite(plc.byInit[id].rank) ? plc.byInit[id].rank : Infinity),
|
|
498
499
|
isDone: (it) => it.state === 'done' || integratedAll.has(it.id),
|
|
499
500
|
});
|
|
@@ -552,7 +553,7 @@ function render(draft, { notes, name: given, purpose } = {}) {
|
|
|
552
553
|
const lc = b.last_cycle;
|
|
553
554
|
push(`- Done: ${lc.done.length ? lc.done.map((x) => `${x.title} (${x.id})`).join('; ') : 'none'}`);
|
|
554
555
|
push(`- Gates passed: ${lc.gates.length ? lc.gates.map((g) => `${g.gate}, ${short(g.at)}`).join('; ') : 'none'}`);
|
|
555
|
-
push(`-
|
|
556
|
+
push(`- Roadmap moves: ${lc.moves.length ? lc.moves.map((m) => `${m.from == null ? 'added' : '#' + m.from} to #${m.to}, ${short(m.at)}`).join('; ') : 'none'}`);
|
|
556
557
|
push(`- Overdue, carried over: ${lc.carried.length ? lc.carried.map((x) => `${x.title}, due ${short(x.due)}`).join('; ') : 'none'}`);
|
|
557
558
|
push('', `**Coming cycle** (${b.coming_cycle.basis === 'dates' ? 'items that start or fall due' : 'the next 3 by order'})`, '');
|
|
558
559
|
if (!b.coming_cycle.items.length) push('- none');
|