create-pmos 0.751.0 → 0.753.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/package.json +45 -77
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/changelog.json +44 -0
  8. package/workspace/guide/cli.md +28 -1
  9. package/workspace/guide/home.md +3 -1
  10. package/workspace/guide/settings-and-switches.md +2 -2
  11. package/workspace/lib/autonomy.js +2 -1
  12. package/workspace/lib/driver-decide.js +8 -0
  13. package/workspace/lib/driver-needs.js +3 -20
  14. package/workspace/lib/driver-run.js +16 -1
  15. package/workspace/lib/driver.js +23 -11
  16. package/workspace/lib/line-cli.js +99 -0
  17. package/workspace/lib/line.js +231 -0
  18. package/workspace/lib/never-wait.js +144 -0
  19. package/workspace/lib/pmos-verbs.js +4 -1
  20. package/workspace/lib/program-cli.js +165 -10
  21. package/workspace/lib/program-line.js +380 -0
  22. package/workspace/lib/routes-today-log.js +6 -3
  23. package/workspace/lib/today-log.js +21 -3
  24. package/workspace/package-lock.json +2 -2
  25. package/workspace/package.json +1 -1
  26. package/workspace/public/pm/cozy-today-app.js +17 -2
  27. package/workspace/public/pm/cozy-today-model.js +21 -3
  28. package/workspace/public/pm/cozy-today-view.js +4 -2
  29. package/workspace/public/pm/quiet-batch.js +111 -0
  30. package/workspace/public/pm/quiet-rows.js +130 -0
  31. package/workspace/public/pm/wf-page.css +2 -0
  32. package/workspace/public/pm/wf-page.js +38 -8
  33. package/workspace/test-lists/line.json +9 -0
  34. package/workspace/test-lists/never-wait-on-drafts.json +9 -0
  35. package/workspace/test-lists/program-line.json +9 -0
  36. package/workspace/test-lists/quiet-rows.json +9 -0
@@ -0,0 +1,380 @@
1
+ 'use strict';
2
+ /* program-line.js — the program line: where each program stands, and what moves it next (product line plan, slice 5; initiative program-line).
3
+ * A program is the level above initiatives, across products (lib/programs.js). Its line has four stations, each with an exit test read from
4
+ * records only (doc Ejs4HXyqpenvaiqiRMtzoF, tab Plan, "Setup line and program line"):
5
+ *
6
+ * Charter exit: goal, target date and owner set. PMOS drafts the missing ones from the members.
7
+ * Sequence exit: every member ordered; milestones dated (one at least). PMOS proposes the order (predecessors, then dates), drafts
8
+ * milestones from the members' dates, and limits Build entry to each team's capacity.
9
+ * Track exit: the forecast is inside the target, or a decision is recorded for this forecast. PMOS names the member that slips
10
+ * and the milestones that move.
11
+ * Land exit: every member passed Implementation (Build on Product feature); the outcome read. Asks only to close the program.
12
+ * The program stands at the first station whose exit fails; past Land it is Landed. Each member stays on its own product's line and
13
+ * workflow (lib/line.js); the program line only reads them. A program across products joins every product's rows into ONE forecast.
14
+ *
15
+ * lineOf(program, members, o) PURE → { id, title, home, station: { key, name, n, of } | null, landed, stations: [{ key, name, passed,
16
+ * missing: [text] }], next, forecast: { date, state, cantTell: [id], slips: [{ id, date, why }], moves: [{ id,
17
+ * name, from, to }] }, target, order: { set, proposed: [id], differs }, drafts: { charter, milestones, cantTell },
18
+ * build: { waits: [{ id, team, behind }] }, members: [member], decision }
19
+ * program lib/programs.js merge's answer (with the extra `decisions`, `outcome` from extrasOf)
20
+ * members [{ ws, product, id, title, live, ended, station, flag, next, passedImpl, inImpl, nextIsImpl, end, owner, team, after }]
21
+ * (factsOf builds one from a pmos line row and the Board row; a member no product read holds is { ws, id, missing: true })
22
+ * o { now, capacity: { [team]: n }, busy: { [team]: [member key] } (members in Build outside this program) }
23
+ * clashesOf(lines, o) PURE → [decision row] a team more than one product needs in Build beyond its capacity: ONE row each,
24
+ * with a recommendation (the member whose program lands first goes first)
25
+ * draftsOf(line) → [milestone-suggest item] the Sequence milestone drafts, as `pmos program suggest` items
26
+ * extrasOf(lines) PURE → { capacity: { team: n }, decisions: { [program]: [line] }, outcome: { [program]: line }, teamFirst }
27
+ * read(roots, o) → { programs: [line], clashes: [row], products: [{ ws, root, product, ok, error? }] } every registered workspace
28
+ * health(o) · CLI `node program-line.js health` the percent of open programs placed with a next move (the done test's health number)
29
+ *
30
+ * RULE 1 OF THE PLAN: "can't tell" beats a guess. A member with no date is never given one: it is listed under cantTell, and a program
31
+ * forecast with such a member says so. Nothing here writes; lib/program-cli.js holds the writes (draft, order, capacity, decide, charter). */
32
+ const fs = require('fs');
33
+ const path = require('path');
34
+
35
+ const DAY = 86400000;
36
+ const CLUSTER_DAYS = 14; // members finishing within this many days of the first share one drafted milestone
37
+ const DEFAULT_CAPACITY = 2; // initiatives one team builds at once, until the user sets one (`pmos program capacity`)
38
+ const MAX_MS = 12;
39
+ const STATIONS = [
40
+ { key: 'charter', name: 'Charter' }, { key: 'sequence', name: 'Sequence' }, { key: 'track', name: 'Track' }, { key: 'land', name: 'Land' },
41
+ ];
42
+ const IMPL = /^(implementation|build)$/i;
43
+ const DONE_ENDS = new Set(['Shipped', 'Closed']);
44
+ const DROPPED_ENDS = new Set(["Won't do", 'Cancelled', 'Archived']);
45
+ const DAY_RE = /^\d{4}-\d{2}-\d{2}$/;
46
+
47
+ const lc = (s) => String(s || '').trim().toLowerCase();
48
+ const dayOf = (iso) => (DAY_RE.test(String(iso || '').slice(0, 10)) ? String(iso).slice(0, 10) : '');
49
+ const todayOf = (now) => new Date(now).toISOString().slice(0, 10);
50
+ const addDays = (day, n) => new Date(Date.parse(day + 'T00:00:00Z') + n * DAY).toISOString().slice(0, 10);
51
+ const gap = (a, b) => Math.round((Date.parse(b + 'T00:00:00Z') - Date.parse(a + 'T00:00:00Z')) / DAY);
52
+ const keyOf = (m) => (m.ws || '') + ':' + m.id;
53
+ const clip = (s, n) => { const t = String(s || '').replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).trimEnd() + '…' : t; };
54
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
55
+ const short = (day) => (day ? MON[+day.slice(5, 7) - 1] + ' ' + (+day.slice(8, 10)) + ' ' + day.slice(0, 4) : '');
56
+
57
+ /** One member's facts from its pmos line row (lib/line.js place) and its Board row (lib/stage-read.js rowOf().row), plus its record's
58
+ * front matter (`team:`, `predecessor:`). Passed Implementation: its workflow's Implementation (or Build) stage is done, or it ended as
59
+ * Shipped or Closed. A workflow with neither stage reads the lifecycle step: past Build. */
60
+ function factsOf({ ws, product, line, row, front }) {
61
+ const r = row || {}, l = line || {}, f = front || {};
62
+ const st = Array.isArray(r.wfStages) ? r.wfStages : [];
63
+ const impl = st.find((s) => s && (IMPL.test(lc(s.name)) || IMPL.test(lc(s.key))));
64
+ const ended = l.ended || null;
65
+ let passedImpl = DONE_ENDS.has(ended);
66
+ if (!passedImpl && impl) passedImpl = impl.status === 'done';
67
+ else if (!passedImpl && !impl && r.oneStage && r.oneStage.step) passedImpl = ['deliver', 'monitor', 'evaluate'].includes(r.oneStage.step);
68
+ const cur = l.station || null;
69
+ const inImpl = !passedImpl && !!cur && (IMPL.test(lc(cur.name)) || IMPL.test(lc(cur.key)));
70
+ const ci = cur ? st.findIndex((s) => s && (s.key === cur.key || s.name === cur.name)) : -1;
71
+ const nextIsImpl = !passedImpl && !inImpl && !!impl && ci >= 0 && st.indexOf(impl) === ci + 1;
72
+ const after = String(f.predecessor || '').split(/[,\s]+/).map((x) => x.trim()).filter(Boolean);
73
+ return {
74
+ ws, product, id: l.id || r.id, title: l.title || r.title || l.id || r.id, live: l.live !== false && !ended, ended,
75
+ station: cur, flag: l.flag || null, next: l.next || '', passedImpl, inImpl, nextIsImpl,
76
+ end: dayOf(r.end), owner: String(r.owner || f.owner || '').trim(), team: String(f.team || '').trim() || product || ws || '', after,
77
+ };
78
+ }
79
+
80
+ /** The proposed order: a predecessor before the one that names it, then the earlier end date, then A to Z. Ids only of `list`. */
81
+ function proposeOrder(list) {
82
+ const ids = list.map((m) => m.id);
83
+ const by = new Map(list.map((m) => [m.id, m]));
84
+ const cmp = (a, b) => (by.get(a).end || '9999').localeCompare(by.get(b).end || '9999') || a.localeCompare(b);
85
+ const out = [], done = new Set(), seen = new Set();
86
+ const visit = (id) => {
87
+ if (done.has(id) || seen.has(id)) return; // a loop in predecessors: the date order decides
88
+ seen.add(id);
89
+ for (const p of (by.get(id).after || []).filter((x) => by.has(x)).sort(cmp)) visit(p);
90
+ done.add(id); out.push(id);
91
+ };
92
+ for (const id of ids.slice().sort(cmp)) visit(id);
93
+ return out;
94
+ }
95
+
96
+ /** Milestone drafts from the members' dates: members finishing within CLUSTER_DAYS of the first share one, dated at the latest end. */
97
+ function draftMilestones(list) {
98
+ const dated = list.filter((m) => !m.passedImpl && m.end).sort((a, b) => a.end.localeCompare(b.end) || a.id.localeCompare(b.id));
99
+ const out = [];
100
+ for (const m of dated) {
101
+ const last = out[out.length - 1];
102
+ if (last && gap(last.first, m.end) <= CLUSTER_DAYS) { last.members.push(m); last.date = m.end; } else out.push({ first: m.end, date: m.end, members: [m] });
103
+ }
104
+ return out.slice(0, MAX_MS).map((c) => {
105
+ const t = c.members.map((m) => clip(m.title, 40));
106
+ const name = t.length === 1 ? `${t[0]} delivered` : t.length === 2 ? `${t[0]} and ${t[1]} delivered` : `${t[0]} and ${t.length - 1} more delivered`;
107
+ return { name: clip(name, 80), date: c.date, waits: c.members.map((m) => m.id),
108
+ why: c.members.length === 1 ? `${c.members[0].id} ends ${short(c.date)} on its plan` : `${c.members.length} initiatives end between ${short(c.first)} and ${short(c.date)} on their plans`,
109
+ src: { kind: 'deliver', label: clip(`plan ends, ${c.members.map((m) => m.id + ' ' + m.end).join(', ')}`, 80) } };
110
+ });
111
+ }
112
+
113
+ function lineOf(program, members, o = {}) {
114
+ const p = program || {};
115
+ const now = o.now || Date.now(), today = todayOf(now);
116
+ const cap = (team) => { const n = (o.capacity || {})[team]; return Number.isInteger(n) && n > 0 ? n : DEFAULT_CAPACITY; };
117
+ const all = members || [];
118
+ const missingRead = all.filter((m) => m.missing).map((m) => m.id);
119
+ const list = all.filter((m) => !m.missing && !DROPPED_ENDS.has(m.ended));
120
+ const live = list.filter((m) => !m.passedImpl);
121
+ const target = dayOf(p.target);
122
+ const ms = Array.isArray(p.milestones) ? p.milestones : [];
123
+
124
+ // Charter
125
+ const charterMissing = [];
126
+ if (!String(p.goal || '').trim()) charterMissing.push('goal');
127
+ if (!target) charterMissing.push('target date');
128
+ if (!String(p.owner || '').trim()) charterMissing.push('owner');
129
+ const ends = list.map((m) => m.end).filter(Boolean).sort();
130
+ const owners = {};
131
+ for (const m of list) if (m.owner) owners[m.owner] = (owners[m.owner] || 0) + 1;
132
+ const topOwner = Object.entries(owners).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))[0];
133
+ const charter = {};
134
+ if (charterMissing.includes('target date') && ends.length && !list.some((m) => !m.passedImpl && !m.end)) charter.target = ends[ends.length - 1];
135
+ if (charterMissing.includes('owner') && topOwner) charter.owner = topOwner[0];
136
+ if (charterMissing.includes('goal') && list.length) charter.goal = clip('Deliver ' + list.slice(0, 3).map((m) => clip(m.title, 40)).join(', ') + (list.length > 3 ? ` and ${list.length - 3} more` : ''), 160);
137
+
138
+ // Sequence
139
+ const proposed = proposeOrder(list);
140
+ const set = Array.isArray(p.order) ? p.order : [];
141
+ const unordered = list.filter((m) => !set.includes(m.id)).map((m) => m.id);
142
+ const seqMissing = [];
143
+ if (unordered.length) seqMissing.push(`order of ${unordered.length} of ${list.length} initiatives`);
144
+ const undated = ms.filter((m) => !dayOf(m.date));
145
+ if (!ms.length) seqMissing.push('milestones');
146
+ else if (undated.length) seqMissing.push(`dates of ${undated.length} milestones`);
147
+ const msDrafts = ms.length ? [] : draftMilestones(list);
148
+ const cantTell = live.filter((m) => !m.end).map((m) => m.id);
149
+ // Build limit: per team, members in Implementation now (here and elsewhere) against capacity; the ones next in line wait in order
150
+ const seq = set.length ? set.concat(proposed.filter((x) => !set.includes(x))) : proposed;
151
+ const pos = (id) => { const i = seq.indexOf(id); return i < 0 ? 999 : i; };
152
+ const waits = [];
153
+ const teams = [...new Set(list.map((m) => m.team).filter(Boolean))];
154
+ for (const team of teams) {
155
+ const mine = list.filter((m) => m.team === team);
156
+ const busy = new Set([...((o.busy || {})[team] || []), ...mine.filter((m) => m.inImpl).map(keyOf)]);
157
+ let free = cap(team) - busy.size;
158
+ for (const m of mine.filter((x) => x.nextIsImpl).sort((a, b) => pos(a.id) - pos(b.id))) {
159
+ if (free > 0) { free--; continue; }
160
+ waits.push({ id: m.id, team, capacity: cap(team), behind: [...busy].map((k) => k.split(':').slice(1).join(':')) });
161
+ }
162
+ }
163
+
164
+ // Track: one forecast from every product's rows
165
+ const slips = [];
166
+ let fc = '';
167
+ for (const m of live) {
168
+ if (!m.end) continue;
169
+ let d = m.end, why = '';
170
+ if (m.end < today) { d = today; why = `its plan ended ${short(m.end)} and it has not passed Implementation`; }
171
+ else if (m.flag === 'stuck') why = 'stuck at ' + ((m.station && m.station.name) || 'its station');
172
+ if (target && d > target && !why) why = `ends ${short(d)}, after the target`;
173
+ if (why) slips.push({ id: m.id, product: m.product, date: d, why });
174
+ if (d > fc) fc = d;
175
+ }
176
+ const fcState = !live.length ? 'done' : cantTell.length ? 'cant-tell' : !target ? 'no-target' : fc <= target ? 'inside' : 'past';
177
+ const moves = [];
178
+ for (const s of slips) for (const m of ms) if ((m.waits || []).includes(s.id) && dayOf(m.date) && s.date > m.date) moves.push({ id: m.id, name: m.name, from: m.date, to: s.date });
179
+ const decision = ((p.decisions || [])).filter((d) => d.forecast === fc && d.target === target).pop() || null;
180
+ const trackMissing = [];
181
+ if (fcState === 'past' && !decision) trackMissing.push(`a decision: the forecast ${short(fc)} is past the target ${short(target)}`);
182
+ if (fcState === 'cant-tell' && !decision) trackMissing.push(`dates of ${cantTell.length} initiatives (can't tell the forecast)`);
183
+
184
+ // Land
185
+ const landMissing = [];
186
+ const notYet = list.filter((m) => !m.passedImpl);
187
+ if (notYet.length) landMissing.push(`${notYet.length} of ${list.length} initiatives past Implementation`);
188
+ if (!p.outcome) landMissing.push('the outcome read');
189
+ if (!list.length) landMissing.unshift('initiatives in the program');
190
+
191
+ const stations = [
192
+ { ...STATIONS[0], missing: charterMissing }, { ...STATIONS[1], missing: seqMissing },
193
+ { ...STATIONS[2], missing: trackMissing }, { ...STATIONS[3], missing: landMissing },
194
+ ].map((s) => ({ ...s, passed: !s.missing.length }));
195
+ const at = stations.findIndex((s) => !s.passed);
196
+ const station = at < 0 ? null : { key: stations[at].key, name: stations[at].name, n: at + 1, of: stations.length };
197
+
198
+ let next = '';
199
+ if (!station) next = 'Landed: every initiative passed Implementation and the outcome is read. Close the program when you are ready.';
200
+ else if (station.key === 'charter') {
201
+ const d = Object.entries(charter).map(([k, v]) => `${k === 'target' ? 'target ' + v : k === 'owner' ? 'owner ' + v : 'goal "' + v + '"'}`);
202
+ next = d.length ? `PMOS drafts ${d.join(', ')}; agree or change them.` : `Set the ${charterMissing.join(', ')}; no member record says ${charterMissing.length > 1 ? 'them' : 'it'}.`;
203
+ if (charter.target === undefined && charterMissing.includes('target date') && cantTell.length) next += ` Can't tell a target: ${cantTell.length} initiatives have no date.`;
204
+ } else if (station.key === 'sequence') {
205
+ const parts = [];
206
+ if (unordered.length) parts.push(`PMOS proposes the order ${proposed.join(' → ')}`);
207
+ if (msDrafts.length) parts.push(`PMOS drafts ${msDrafts.length} dated milestone${msDrafts.length > 1 ? 's' : ''} (keep or decline them on the program)`);
208
+ else if (!ms.length) parts.push("can't draft milestones: no initiative has a date");
209
+ if (undated.length) parts.push(`date ${undated.map((m) => m.name).join(', ')}`);
210
+ next = parts.join('; ') + '.';
211
+ } else if (station.key === 'track') {
212
+ if (fcState === 'past') next = `${slips.map((s) => s.id).join(', ')} slip${slips.length === 1 ? 's' : ''}: the forecast is ${short(fc)}, target ${short(target)}.` + (moves.length ? ` Moves ${moves.map((m) => `${m.name} to ${short(m.to)}`).join(', ')}.` : '') + ' Decide: move the target, or cut or reorder the work.';
213
+ else next = `Can't tell the forecast: ${cantTell.join(', ')} ${cantTell.length === 1 ? 'has' : 'have'} no date. Give each a plan end.`;
214
+ } else {
215
+ next = notYet.length ? `${list.length - notYet.length} of ${list.length} initiatives past Implementation; forecast ${fc ? short(fc) : 'none'}${target ? ', target ' + short(target) : ''}.` : 'Every initiative passed Implementation. Read the outcome against the goal.';
216
+ }
217
+ if (waits.length) next += ` ${waits.map((w) => `${w.id} waits for ${w.team} (builds ${w.capacity} at once)`).join('; ')}.`;
218
+ if (missingRead.length) next += ` Not read: ${missingRead.join(', ')}.`;
219
+
220
+ return {
221
+ id: p.id, title: p.title || p.id, home: p.home || '', station, landed: !station, stations, next: next.trim(), target,
222
+ forecast: { date: fc, state: fcState, cantTell, slips, moves },
223
+ order: { set: set.length > 0, proposed, differs: set.length > 0 && proposed.join() !== set.filter((x) => proposed.includes(x)).join() },
224
+ drafts: { charter, milestones: msDrafts, cantTell }, build: { waits },
225
+ members: list, missing: missingRead, decision, products: [...new Set(list.map((m) => m.product).filter(Boolean))],
226
+ };
227
+ }
228
+
229
+ /** The Sequence milestone drafts as `pmos program suggest` items (lib/milestone-suggest.js validItem: op add). */
230
+ const draftsOf = (line) => ((line && line.drafts && line.drafts.milestones) || []).map((d) => ({ op: 'add', name: d.name, date: d.date, waits: d.waits, why: d.why, src: d.src }));
231
+
232
+ /** A team more than one product needs in Build beyond its capacity: ONE decision row each. Members in Implementation hold their places;
233
+ * the ones next in line are ranked by their program's target (earlier first), then their place in its order. The first free places
234
+ * are the recommendation. A team whose contenders all come from one product is that product's own Build limit, not a clash. */
235
+ function clashesOf(lines, o = {}) {
236
+ const cap = (team) => { const n = (o.capacity || {})[team]; return Number.isInteger(n) && n > 0 ? n : DEFAULT_CAPACITY; };
237
+ const seen = new Map();
238
+ for (const L of lines || []) {
239
+ L.members.forEach((m) => {
240
+ const k = keyOf(m);
241
+ const prev = seen.get(k);
242
+ const rank = { target: L.target || '9999', pos: L.order.proposed.indexOf(m.id), program: L.id, title: L.title };
243
+ if (!prev || rank.target < prev.rank.target) seen.set(k, { m, rank });
244
+ });
245
+ }
246
+ const byTeam = new Map();
247
+ for (const { m, rank } of seen.values()) {
248
+ if (!m.team || (!m.inImpl && !m.nextIsImpl)) continue;
249
+ if (!byTeam.has(m.team)) byTeam.set(m.team, []);
250
+ byTeam.get(m.team).push({ m, rank });
251
+ }
252
+ const out = [];
253
+ for (const [team, xs] of byTeam) {
254
+ const busy = xs.filter((x) => x.m.inImpl), want = xs.filter((x) => x.m.nextIsImpl);
255
+ const free = cap(team) - busy.length;
256
+ const products = new Set(xs.map((x) => x.m.product || x.m.ws));
257
+ if (want.length <= Math.max(0, free) || products.size < 2) continue;
258
+ const chosen = (o.teamFirst || {})[team];
259
+ want.sort((a, b) => (chosen === a.m.id ? -1 : chosen === b.m.id ? 1 : 0) || a.rank.target.localeCompare(b.rank.target) || a.rank.pos - b.rank.pos || a.m.id.localeCompare(b.m.id));
260
+ const go = want.slice(0, Math.max(0, free)), wait = want.slice(Math.max(0, free));
261
+ const first = want[0];
262
+ out.push({
263
+ kind: 'clash', team, capacity: cap(team), decided: !!chosen,
264
+ busy: busy.map((x) => ({ id: x.m.id, product: x.m.product, program: x.rank.program })),
265
+ want: want.map((x) => ({ id: x.m.id, product: x.m.product, program: x.rank.program, target: x.rank.target === '9999' ? '' : x.rank.target })),
266
+ recommend: { go: go.map((x) => x.m.id), wait: wait.map((x) => x.m.id), first: first.m.id,
267
+ why: free > 0 ? `${first.m.id} goes first: its program ${first.rank.title} has the earliest target${first.rank.target !== '9999' ? ' (' + short(first.rank.target) + ')' : ''}.`
268
+ : `${team} builds ${cap(team)} at once and ${busy.length} ${busy.length === 1 ? 'is' : 'are'} in Implementation. When one passes, ${first.m.id} goes first: its program ${first.rank.title} has the earliest target${first.rank.target !== '9999' ? ' (' + short(first.rank.target) + ')' : ''}.` },
269
+ text: `${team} is needed in Build by ${[...products].join(' and ')}: ${want.length} want${want.length === 1 ? 's' : ''} to start, ${Math.max(0, free)} place${free === 1 ? '' : 's'} free.`,
270
+ });
271
+ }
272
+ return out;
273
+ }
274
+
275
+ /** The extra program lines this file reads, beside lib/programs.js fold: team capacity, decisions, outcome reads, a team's chosen first. */
276
+ function extrasOf(lines) {
277
+ const out = { capacity: {}, decisions: {}, outcome: {}, teamFirst: {} };
278
+ for (const l of lines || []) {
279
+ if (!l || typeof l !== 'object') continue;
280
+ if (l.kind === 'team-capacity' && l.team && Number.isInteger(l.n) && l.n > 0) out.capacity[String(l.team)] = l.n;
281
+ else if (l.kind === 'decision' && l.program) (out.decisions[l.program] = out.decisions[l.program] || []).push(l);
282
+ else if (l.kind === 'decision' && l.team && l.first) out.teamFirst[String(l.team)] = String(l.first);
283
+ else if (l.kind === 'outcome' && l.program) out.outcome[l.program] = l;
284
+ }
285
+ return out;
286
+ }
287
+
288
+ /** A record's front matter keys this line reads (team, predecessor, owner). */
289
+ function frontOf(file) {
290
+ let t = '';
291
+ try { t = fs.readFileSync(file, 'utf8'); } catch { return {}; }
292
+ const m = /^---\n([\s\S]*?)\n---/.exec(t);
293
+ const out = {};
294
+ if (!m) return out;
295
+ for (const k of ['team', 'predecessor', 'owner']) { const r = new RegExp('^' + k + ':\\s*(.*)$', 'm').exec(m[1]); if (r) out[k] = r[1].replace(/^["']|["']$/g, '').trim(); }
296
+ return out;
297
+ }
298
+
299
+ /** The roots to read: the given ones, then (registry true) the server's registry (workspaces.json), each once, only those with a PMOS
300
+ * state folder. */
301
+ function rootsOf(given, env = process.env, registry = true) {
302
+ const driver = require('./driver.js');
303
+ const out = [], seen = new Set();
304
+ const add = (r) => { const a = path.resolve(r); if (seen.has(a)) return; seen.add(a); if (driver.stateDirOf(a)) out.push(a); };
305
+ for (const r of given || []) add(r);
306
+ if (registry) {
307
+ let reg = [];
308
+ try { reg = JSON.parse(fs.readFileSync(path.join(require('./state-root.js').defaultRoot({ env }), 'workspaces.json'), 'utf8')); } catch { reg = []; }
309
+ if (Array.isArray(reg)) for (const x of reg) if (x && typeof x.root === 'string') { try { if (fs.statSync(x.root).isDirectory()) add(x.root); } catch { /* gone */ } }
310
+ }
311
+ return out;
312
+ }
313
+
314
+ /** Every program of the roots, placed on its line, and the clashes between products. Read-only. o: { now, only, env, lineOf (tests) } */
315
+ function read(roots, o = {}) {
316
+ const driver = require('./driver.js');
317
+ const P = require('./programs.js');
318
+ const pmItems = require('./pm-items.js');
319
+ const now = o.now || Date.now();
320
+ const products = [], perWs = [], extraLines = [];
321
+ const facts = new Map(); // ws → Map id → member
322
+ for (const root of roots) {
323
+ const ws = driver.wsIdOf(root), product = path.basename(root);
324
+ const dir = driver.stateDirOf(root);
325
+ const lines = dir ? pmItems.readLines(path.join(dir, 'programs.jsonl')).filter(Boolean) : [];
326
+ perWs.push({ ws, lines });
327
+ extraLines.push(...lines);
328
+ products.push({ ws, root, product, ok: true, dir });
329
+ }
330
+ const programs = P.merge(perWs).filter((p) => !o.only || p.id === o.only);
331
+ const need = new Set(programs.flatMap((p) => p.members.map((m) => m.ws)));
332
+ for (const pr of products) {
333
+ if (!need.has(pr.ws)) continue;
334
+ const L = (o.lineOf || require('./line.js').lineOf)(pr.root, { now });
335
+ if (!L.ok) { pr.ok = false; pr.error = L.error; continue; }
336
+ const SR = require('./stage-read.js');
337
+ const { w, ctx } = SR.cliCtx(pr.root);
338
+ const map = new Map();
339
+ const wanted = new Set(programs.flatMap((p) => p.members.filter((m) => m.ws === pr.ws).map((m) => m.initiative)));
340
+ for (const row of L.rows) {
341
+ if (!wanted.has(row.id)) continue;
342
+ let b = null;
343
+ try { const r = (o.rowOf || SR.rowOf)(ctx, w, row.id); b = r && r.ok ? r.row : null; } catch { b = null; }
344
+ const rec = b && typeof b.record === 'string' ? path.resolve(pr.root, b.record) : null;
345
+ map.set(row.id, factsOf({ ws: pr.ws, product: pr.product, line: row, row: b, front: rec ? frontOf(rec) : {} }));
346
+ }
347
+ facts.set(pr.ws, map);
348
+ }
349
+ const X = extrasOf(extraLines);
350
+ const membersOf = (p) => p.members.map((m) => { const f = facts.get(m.ws) && facts.get(m.ws).get(m.initiative); return f || { ws: m.ws, id: m.initiative, missing: true }; });
351
+ // members in Implementation, by team, across every program: a team's capacity is the team's, not one program's
352
+ const inImplBy = {};
353
+ const all = programs.map((p) => ({ p, ms: membersOf(p) }));
354
+ for (const { ms } of all) for (const m of ms) if (!m.missing && m.inImpl && m.team) (inImplBy[m.team] = inImplBy[m.team] || new Set()).add(keyOf(m));
355
+ const lines = all.map(({ p, ms }) => {
356
+ const own = new Set(ms.map(keyOf));
357
+ const busy = {};
358
+ for (const [t, s] of Object.entries(inImplBy)) busy[t] = [...s].filter((k) => !own.has(k));
359
+ return lineOf({ ...p, decisions: X.decisions[p.id] || [], outcome: X.outcome[p.id] || null }, ms, { now, capacity: X.capacity, busy });
360
+ });
361
+ return { programs: lines, clashes: clashesOf(lines, { capacity: X.capacity, teamFirst: X.teamFirst }), products: products.map(({ dir, ...x }) => x) };
362
+ }
363
+
364
+ function health(o = {}) {
365
+ const r = read(rootsOf(o.roots || [process.cwd()], o.env, !o.roots), o);
366
+ const open = r.programs.filter((l) => !l.landed);
367
+ const placed = open.filter((l) => l.station && l.next).length;
368
+ return { open: open.length, placed, percent: open.length ? Math.round((placed / open.length) * 1000) / 10 : 100 };
369
+ }
370
+
371
+ module.exports = { lineOf, clashesOf, draftsOf, extrasOf, factsOf, proposeOrder, draftMilestones, read, rootsOf, frontOf, health, STATIONS, DEFAULT_CAPACITY, CLUSTER_DAYS };
372
+
373
+ if (require.main === module) {
374
+ const [cmd, ...rest] = process.argv.slice(2);
375
+ if (cmd !== 'health') { console.log('usage: node program-line.js health [--root <dir> …]'); process.exit(2); }
376
+ const roots = []; for (let i = 0; i < rest.length; i++) if (rest[i] === '--root') roots.push(rest[++i]);
377
+ const h = health(roots.length ? { roots } : {});
378
+ console.log(`[program-line] ${h.placed} of ${h.open} open programs placed with a next move`);
379
+ console.log(String(h.percent));
380
+ }
@@ -4,6 +4,8 @@
4
4
  * GET /api/today-log?day=YYYY-MM-DD → { ok, day, entries, marks } the PM's own entries and the marks on the rows of that day
5
5
  * POST /api/today-log/add { text, day, bullet?, first? } → { ok, entry } a task, an event or a note typed in the first line
6
6
  * POST /api/today-log/mark { key, act, day, until?, snap? } → { ok } done, undone, later (until a later day), now (back to today), drop, undrop, keep
7
+ * POST /api/today-log/fix { day, ws, keys } → { ok } quiet-rows: the line rows Your move shows that day for one product
8
+ * (at most 3); GET returns them as `fixed: { [ws]: keys }`
7
9
  *
8
10
  * The day is the PM's local day, sent by the page. Every POST passes pm-guard requirePagePress: the page only. A mark changes only the
9
11
  * log: done on a task or an item of the PM is sent to that record's own route by the page, and the mark is the log's line beside it.
@@ -26,19 +28,20 @@ module.exports = {
26
28
  const day = url.searchParams.get('day') || localDay();
27
29
  if (!TL.DAY_RE.test(day)) { ctx.json(res, { ok: false, error: 'day is YYYY-MM-DD' }, 400); return true; }
28
30
  const f = TL.fold(TL.readLines(fileOf(ctx)), day);
29
- ctx.json(res, { ok: true, day, entries: f.entries, marks: f.marks });
31
+ ctx.json(res, { ok: true, day, entries: f.entries, marks: f.marks, fixed: f.fixed });
30
32
  return true;
31
33
  }
32
- if (req.method !== 'POST' || (p !== '/api/today-log/add' && p !== '/api/today-log/mark')) return false;
34
+ if (req.method !== 'POST' || (p !== '/api/today-log/add' && p !== '/api/today-log/mark' && p !== '/api/today-log/fix')) return false;
33
35
  const got = await ctx.readJson(req);
34
36
  if (!got.ok) { ctx.json(res, { ok: false, error: 'invalid JSON body' }, 400); return true; }
35
37
  const body = got.body || {};
36
38
  const g = guard.requirePagePress(req, body);
37
39
  if (!g.ok) { ctx.json(res, { ok: false, error: g.error }, g.status); return true; }
38
40
  const day = String(body.day || '');
39
- const r = p === '/api/today-log/add' ? TL.addEvent(body, day, 'tl-' + crypto.randomBytes(6).toString('hex')) : TL.markEvent(body, day);
41
+ const r = p === '/api/today-log/add' ? TL.addEvent(body, day, 'tl-' + crypto.randomBytes(6).toString('hex')) : p === '/api/today-log/fix' ? TL.fixEvent(body, day) : TL.markEvent(body, day);
40
42
  if (r.error) { ctx.json(res, { ok: false, error: r.error }, 400); return true; }
41
43
  TL.appendLine(fileOf(ctx), r.event);
44
+ if (p === '/api/today-log/fix') console.info('[quiet-rows] fixed day=' + day + ' rows=' + r.event.keys.length);
42
45
  if (p === '/api/today-log/add') {
43
46
  const e = r.event;
44
47
  ctx.json(res, { ok: true, entry: { id: e.id, key: 'own:' + e.id, bullet: e.bullet, text: e.text, first: e.first, time: e.time, day: e.day, done: false } });
@@ -16,6 +16,8 @@
16
16
  * (carried), and the ones done on `day`; marks: { [key]: { done?, until?, dropped?, kept? } }
17
17
  * addEvent(body, day, id) → { event } | { error } PURE: the line POST /api/today-log/add appends
18
18
  * markEvent(body, day) → { event } | { error } PURE: the line POST /api/today-log/mark appends
19
+ * fixEvent(body, day) → { event } | { error } PURE: the line POST /api/today-log/fix appends (quiet-rows: the day
20
+ * ledger of Your move's line rows, one product's at most FIX_MAX keys; fold returns them as `fixed`)
19
21
  * readLines(file) · appendLine(file, line, now) the one file, append-only, <runtime>/today-log/log.jsonl
20
22
  *
21
23
  * SINGLE WRITER: appendLine() is the only function that writes the file. `at` is set there. The day is the PM's local day, sent by
@@ -31,6 +33,8 @@ const BULLETS = ['task', 'event', 'note'];
31
33
  const ACTS = ['done', 'undone', 'later', 'now', 'drop', 'undrop', 'keep'];
32
34
  const MAX_TEXT = 240;
33
35
  const SNAP = ['title', 'work', 'job'];
36
+ const FIX_MAX = 3; // quiet-rows: at most 3 line rows a day per product
37
+ const WS_RE = /^[A-Za-z0-9._:@/+-]{0,120}$/;
34
38
 
35
39
  /** One line the PM typed. A leading "!" marks it first; "o " or "○ " makes it an event, "- " or "– " a note, "• " or nothing a task.
36
40
  * An event's time ("10:30", "9.15", "14:00") is read from its words and kept apart. */
@@ -83,15 +87,29 @@ function markEvent(body, day) {
83
87
  return { event: ev };
84
88
  }
85
89
 
90
+ /** The line POST /api/today-log/fix appends (quiet-rows, the day ledger). body: { ws (the product, '' for the one workspace), keys: the
91
+ * line rows Your move shows that day, at most FIX_MAX }. The latest line of a product and a day wins: a new ship-date blocker that takes the
92
+ * lowest row's place writes the product's keys again. */
93
+ function fixEvent(body, day) {
94
+ const b = body || {};
95
+ if (!DAY_RE.test(String(day || ''))) return { error: 'day is YYYY-MM-DD' };
96
+ const ws = b.ws == null ? '' : String(b.ws);
97
+ if (!WS_RE.test(ws)) return { error: 'ws names the product' };
98
+ if (!Array.isArray(b.keys) || b.keys.length > FIX_MAX || !b.keys.every((k) => KEY_RE.test(String(k || '')))) return { error: 'keys is a list of at most ' + FIX_MAX + ' row keys' };
99
+ return { event: { event: 'fix', day, ws, keys: [...new Set(b.keys.map(String))] } };
100
+ }
101
+
86
102
  /** Fold the lines for one day. An own entry shows on its day and every day after until it is done or dropped (carried); a done
87
103
  * entry shows only on the day it was done. A mark holds by key: the last done/undone wins, a later day hides the row until then,
88
104
  * a drop hides it until an undrop, a keep is remembered with its day (PMOS suggests a drop again only a while after it). */
89
105
  function fold(lines, day) {
90
106
  const d = DAY_RE.test(String(day || '')) ? day : '9999-12-31';
91
- const own = new Map(), marks = {};
107
+ const own = new Map(), marks = {}, fixed = {};
92
108
  const M = (k) => (marks[k] = marks[k] || {});
93
109
  for (const ev of lines || []) {
94
110
  if (!ev || typeof ev !== 'object' || !DAY_RE.test(String(ev.day || '')) || ev.day > d) continue;
111
+ // quiet-rows: the day's line rows per product; only the day asked for, the latest line of a product wins
112
+ if (ev.event === 'fix') { if (ev.day === d && Array.isArray(ev.keys) && WS_RE.test(String(ev.ws == null ? '' : ev.ws))) fixed[String(ev.ws || '')] = ev.keys.filter((k) => KEY_RE.test(String(k))).slice(0, FIX_MAX); continue; }
95
113
  if (ev.event === 'added' && ID_RE.test(String(ev.id || '')) && BULLETS.includes(ev.bullet)) {
96
114
  own.set(ev.id, { id: ev.id, key: 'own:' + ev.id, bullet: ev.bullet, text: String(ev.text || ''), first: !!ev.first, time: ev.time || null, day: ev.day, at: ev.at || null });
97
115
  continue;
@@ -115,7 +133,7 @@ function fold(lines, day) {
115
133
  if (m.doneBefore && !m.done) continue;
116
134
  entries.push({ ...e, done: !!m.done });
117
135
  }
118
- return { entries, marks };
136
+ return { entries, marks, fixed };
119
137
  }
120
138
 
121
139
  function readLines(file) {
@@ -128,4 +146,4 @@ function appendLine(file, line, now = new Date()) {
128
146
  fs.appendFileSync(file, JSON.stringify({ ...line, at: now.toISOString() }) + '\n');
129
147
  }
130
148
 
131
- module.exports = { DAY_RE, KEY_RE, BULLETS, ACTS, parseEntry, addEvent, markEvent, fold, readLines, appendLine };
149
+ module.exports = { DAY_RE, KEY_RE, BULLETS, ACTS, FIX_MAX, parseEntry, addEvent, markEvent, fixEvent, fold, readLines, appendLine };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.751.0",
3
+ "version": "0.753.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.751.0",
9
+ "version": "0.753.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.751.0",
3
+ "version": "0.753.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -20,6 +20,7 @@ import * as TP from './cozy-today-view.js';
20
20
  import * as OM from './mention-one-model.js'; // the one mention's title and the self check's proof line (Today round 3)
21
21
  import { wireSwipe } from './cozy-phone-swipe.js';
22
22
  import { noteUse } from './use-log.js'; // your-move (A468): each press on a Your move row is one ym-act line in the local use log (its health number)
23
+ import * as QB from './quiet-batch.js'; // quiet-rows: Today's batch, the popup (Approve, Skip, Change it first; nothing sent without a press)
23
24
  import * as CC from './change-cues.js'; // idea A313: a short cue on the row that is done, moved or dropped, before the log draws again // the phone: rows and the proposal swipe (phone design, Ph2_today)
24
25
 
25
26
  const ASK_SEND = new Set(['session']);
@@ -34,7 +35,7 @@ export function mountToday(ctx) {
34
35
 
35
36
  async function read() {
36
37
  const r = await ctx.pmGet('/api/today-log?day=' + day()).catch(() => null);
37
- if (r && r.ok) X.log = { entries: r.entries || [], marks: r.marks || {} };
38
+ if (r && r.ok) X.log = { entries: r.entries || [], marks: r.marks || {}, fixed: r.fixed || {} };
38
39
  X.read = true;
39
40
  draw();
40
41
  readReports();
@@ -49,6 +50,7 @@ export function mountToday(ctx) {
49
50
  const lines = [];
50
51
  got.forEach((r, i) => { if (r && r.ok && Array.isArray(r.lines)) for (const l of r.lines) lines.push({ ...l, ws: r.ws || L[i] }); });
51
52
  console.info('[open-questions-today] products=' + L.length + ' lines=' + lines.length);
53
+ if (!X.qRead) { X.qRead = true; draw(); } // quiet-rows: the day's line rows are fixed only once the questions are in
52
54
  if (JSON.stringify(lines) === JSON.stringify(X.questions || [])) return;
53
55
  X.questions = lines;
54
56
  draw();
@@ -83,7 +85,7 @@ export function mountToday(ctx) {
83
85
  const R = ctx.review();
84
86
  const lab = (S.lab || []).flatMap((l) => (l.items || []).map((f) => ({ ...f, ws: l.ws, board: l.board })));
85
87
  const L = TM.logModel({ rank: ctx.rank(), move, items: tdItems(), drafts, review: R && R.open && !R.done ? { title: 'Your weekly review' } : null,
86
- own: X.log.entries, marks: X.log.marks, lab, questions: X.questions || [], titleOf: ctx.titleOf, productOf, now,
88
+ own: X.log.entries, marks: X.log.marks, lab, questions: X.questions || [], titleOf: ctx.titleOf, productOf, now, fixed: X.log.fixed || {},
87
89
  // your-move (A468): an initiative's ship date is its board end date; a line with no default on work that ships soon blocks it
88
90
  shipOf: (id) => { const r = byId.get('i:' + id); return (r && r.board && r.board.end) || ''; } });
89
91
  if (L.move.length !== X.ymN) { X.ymN = L.move.length; console.info('[your-move] rows=' + L.move.length + ' shown=' + L.first.length + (L.move[0] ? ' first-tier=' + L.move[0].tier : '')); }
@@ -102,6 +104,7 @@ export function mountToday(ctx) {
102
104
  if (!ctx.S.ready) { if (!el.firstChild) el.innerHTML = '<p class="td-none">Reading your day.</p>'; return; }
103
105
  const { L, A, O } = models();
104
106
  X.model = L; X.agenda = A; X.overview = O;
107
+ if (L.toFix && X.read && X.qRead) fixDay(L.toFix, L.today);
105
108
  autoClosed();
106
109
  // the rail's number on every place: the lines for today (Your move and what waits today), the number the Overview says; kept for the
107
110
  // other places with its day (pm/cozy-nav.js reads it there)
@@ -196,9 +199,21 @@ export function mountToday(ctx) {
196
199
  const next = list[i < 0 ? 0 : i + d]; if (!next) return false;
197
200
  open(next); return true;
198
201
  }
202
+ /* quiet-rows: the day ledger. The first read of a day that has line rows writes each product's (at most 3) once; a new ship-date blocker
203
+ * that takes the lowest row's place writes them again. POST /api/today-log/fix; until it lands the page shows the same rows. */
204
+ function fixDay(toFix, today) {
205
+ X.fixSent = X.fixSent || new Set();
206
+ for (const [ws, keys] of Object.entries(toFix)) {
207
+ const k = today + '|' + ws + '|' + keys.join(','); if (X.fixSent.has(k)) continue;
208
+ X.fixSent.add(k);
209
+ X.log.fixed = { ...(X.log.fixed || {}), [ws]: keys };
210
+ ctx.pmPost('/api/today-log/fix', { day: today, ws, keys }).then((r) => { if (r && r.ok) console.info('[quiet-rows] day fixed rows=' + keys.length); }).catch(() => {});
211
+ }
212
+ }
199
213
  function open(r) {
200
214
  if (!r) return;
201
215
  const ref = r.ref || {};
216
+ if (r.src === 'batch') { pop(r); QB.openBatch(r.batch, { pmPost: ctx.pmPost, toast: ctx.toast, toastUndo: ctx.toastUndo, reload: ctx.reload, isPhone: ctx.isPhone, noteUse, onSwipe: (root, act) => wireSwipe(root, { act }) }); return; }
202
217
  if (r.members) { if (X.sopen.has(r.key)) X.sopen.delete(r.key); else X.sopen.add(r.key); draw(); return; } // the same step for N initiatives: list them
203
218
  X.last = r.key; // ↑ ↓ (j k) step from here (round 3 point 6)
204
219
  if (r.src === 'ask') {
@@ -30,7 +30,8 @@
30
30
  * FIRST ("!"). What the PM marked first, a verdict or a grill finding on shipped or late work (move-rank's ranks 1 and 2), and a send that
31
31
  * goes out today. The rest follow in the rank's order. Done rows close the table. */
32
32
  import { rowsOf as questionRows, overviewSay as questionsSay } from './open-questions-view.js'; // open-questions-today (A420): the register in the Decide tab
33
- import { didLeft, notASentence, asWritten, askTitle, proofText } from './mention-one-model.js'; // what PMOS did on an ask, from records (round 3 point 13); the title when no sentence can be made
33
+ import { didLeft, notASentence, asWritten, askTitle, proofText } from './mention-one-model.js';
34
+ import * as QR from './quiet-rows.js'; // quiet-rows: at most 3 line rows a day per product, and one batch row for what others will see // what PMOS did on an ask, from records (round 3 point 13); the title when no sentence can be made
34
35
 
35
36
  export const CARRY_DROP = 30; // days carried before PMOS suggests to drop it
36
37
  export const LATE_DAYS = 14; // a row carried this long reads late (the one colour in the When column)
@@ -158,7 +159,10 @@ function typeOf(r) {
158
159
  * o: { rank: { rows, wait } (rankMove), move: home-list move rows, items: my-work-premium Today rows ({ key, id, title, ini, at, due?, overdue }),
159
160
  * drafts: [{ id, title, ini? }], review: { title } | null, own: today-log entries, marks: today-log marks, lab: [{ ws, board, id, title, why }],
160
161
  * questions: GET /api/open-questions lines, each with its ws (open-questions-today), titleOf(ini) → the initiative's name,
161
- * shipOf(ini) → its ship date 'YYYY-MM-DD' or '' (Your move: a line with no default on work that ships soon blocks it), now }
162
+ * shipOf(ini) → its ship date 'YYYY-MM-DD' or '' (Your move: a line with no default on work that ships soon blocks it), now,
163
+ * fixed: GET /api/today-log fixed ({ [ws]: keys }, quiet-rows: the line rows Your move shows today per product) }
164
+ * quiet-rows: the drafts in the outbox are one row, Today's batch (pm/quiet-rows.js batchRow); Your move keeps at most 3 line rows a day per
165
+ * product (capLine), the rest wait under Later (`held`), and `toFix` is what the page writes once to the day ledger.
162
166
  * A row: { key, src, bullet, first, title, work, ini, ws, job, when, late, carried, done, dates: 'task' | 'item' | 'mark', drop, ref }
163
167
  */
164
168
  export function logModel(o = {}) {
@@ -262,6 +266,15 @@ export function logModel(o = {}) {
262
266
  const ex = (rank.expired || []).length;
263
267
  if (ex) out.push({ key: 'expired:' + today, keys: ['expired:' + today], src: 'note', bullet: 'note', type: 'Note', first: false, title: plural(ex, 'ask', 'asks') + ' expired after 14 days with no answer. PMOS wrote why in History',
264
268
  work: '', ini: null, ws: '', job: 'Note', when: '', late: false, carried: 0, done: false, drop: false, dates: 'mark', ref: null });
269
+ // quiet-rows: everything other people will see is one row, Today's batch; a draft left 7 days lapses as not sent and leaves it
270
+ const obRows = out.filter((r) => !r.done && r.src === 'ask' && r.ref && r.ref.kind === 'outbox' && r.ref.outbox);
271
+ let batch = null;
272
+ if (obRows.length) {
273
+ batch = QR.batchOf(obRows.map((r) => ({ ...r.ref.outbox, ws: r.ref.outbox.ws || r.ws || '' })), today, { productOf });
274
+ for (const r of obRows) out.splice(out.indexOf(r), 1);
275
+ const bm = batch ? marks['batch:' + today] || {} : {};
276
+ if (batch && !bm.dropped && !(bm.until && bm.until > today)) out.push(QR.batchRow(batch, today));
277
+ }
265
278
  sameJob(out, marks);
266
279
  const open = out.filter((r) => !r.done), done = out.filter((r) => r.done);
267
280
  const n = (j) => open.filter((r) => r.job === j).length;
@@ -271,12 +284,16 @@ export function logModel(o = {}) {
271
284
  const line = [counts.decide && counts.decide + ' to decide', counts.do && counts.do + ' to do', counts.reply && counts.reply + ' to reply', counts.send && counts.send + ' to send'].filter(Boolean).join(' · ');
272
285
  const types = {}; for (const r of open) types[r.type] = (types[r.type] || 0) + 1;
273
286
  const G = groupLog(open, today, { shipOf: o.shipOf });
287
+ // quiet-rows: at most 3 line rows a day per product, fixed on the first read; the rest wait under Later and come back tomorrow
288
+ const C = QR.capLine(G.move, o.fixed || {});
289
+ for (const r of C.held) { delete r.tier; delete r.why; r.held = true; r.reason = 'Waits for tomorrow: today has 3 for its product'; }
290
+ if (C.held.length) { G.move = C.move; G.first = C.move.slice(0, YM_CAP); G.more = C.move.slice(YM_CAP); G.wait = C.held.concat(G.wait); }
274
291
  // every row says why it is on Today, in a short phrase after its title (round 3 point 12); a Your move row also has its ✦ why (its place)
275
292
  for (const r of open) if (!r.reason) { const w = whyOf(r, today); if (w) r.reason = w; }
276
293
  for (const r of G.first) r.group = 'first'; for (const r of G.more) r.group = 'more'; for (const r of G.today) r.group = 'today'; for (const r of G.wait) r.group = 'wait';
277
294
  for (const r of done) r.group = 'today';
278
295
  const merged = open.reduce((k, r) => k + (r.merged ? r.merged - 1 : 0), 0);
279
- return { rows: G.first.concat(G.more, G.today, done, G.wait), move: G.move, first: G.first, more: G.more, todayRows: G.today.concat(done), wait: G.wait, open: open.length, done: done.length, counts, types, merged, line, today, old,
296
+ return { toFix: C.toFix, batch, held: C.held, rows: G.first.concat(G.more, G.today, done, G.wait), move: G.move, first: G.first, more: G.more, todayRows: G.today.concat(done), wait: G.wait, open: open.length, done: done.length, counts, types, merged, line, today, old,
280
297
  questions: { mine: Q.mine, others: Q.others } };
281
298
  }
282
299
  /** ONE THING, ONE LINE (Wawan's live Today, 2026-11-19): the lines of one brief item or one Jira ticket (srcOf) are one line, with every key
@@ -412,6 +429,7 @@ function lateDays(r, today) {
412
429
  export function costOf(r, today, shipOf = () => '') {
413
430
  if (!r || r.done || r.drop || r.looks || r.bullet !== 'task' || r.src === 'gone' || r.src === 'note' || r.src === 'lab') return null;
414
431
  if (r.type === 'Ask' && !(r.who && r.who.length)) return null; // nobody waits on the answer
432
+ if (r.src === 'batch') return [2, r.left == null ? QR.LAPSE_DAYS : r.left, r.why]; // quiet-rows: Today's batch, a send today, soonest lapse first
415
433
  const ref = r.ref || {}, c = ref.call || null, ld = lateDays(r, today);
416
434
  const waits = r.src === 'ask' || r.src === 'question' || r.src === 'draft' || r.src === 'review' || (r.src === 'own' && r.first) || ld > 0;
417
435
  if (!waits) return null;