create-pmos 0.563.0 → 0.565.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.563.0",
3
+ "version": "0.565.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -33,6 +33,32 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.565.0",
38
+ "at": "2026-11-12T04:27:46.732Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1296,
43
+ "t": "Every surface shows the one stage; pmos workflow check finds a disagreement",
44
+ "s": "Every surface shows the one stage; pmos workflow check finds a disagreement",
45
+ "k": "fix"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "v": "0.564.0",
51
+ "at": "2026-11-11T14:08:23.553Z",
52
+ "f": 4,
53
+ "prs": [
54
+ {
55
+ "n": 1295,
56
+ "t": "Pmos blueprint on a shallow clone warns and shows Unknown, never a merged PR as In build",
57
+ "s": "Pmos blueprint on a shallow clone warns and shows Unknown, never a merged PR as In build",
58
+ "k": "fix"
59
+ }
60
+ ]
61
+ },
36
62
  {
37
63
  "v": "0.563.0",
38
64
  "at": "2026-11-11T12:32:19.496Z",
@@ -278,32 +304,6 @@
278
304
  "k": "new"
279
305
  }
280
306
  ]
281
- },
282
- {
283
- "v": "0.545.0",
284
- "at": "2026-11-09T10:45:44.000Z",
285
- "f": 4,
286
- "prs": [
287
- {
288
- "n": 1273,
289
- "t": "Seven artefacts — model, map, lossless carry, and proposed D107",
290
- "s": "Seven artefacts — model, map, lossless carry, and proposed D107",
291
- "k": "new"
292
- }
293
- ]
294
- },
295
- {
296
- "v": "0.544.0",
297
- "at": "2026-11-08T14:45:01.680Z",
298
- "f": 4,
299
- "prs": [
300
- {
301
- "n": 1272,
302
- "t": "Claude calls and sign-in advice follow the chosen Claude profile; a session stuck at sign-in ends",
303
- "s": "Claude calls and sign-in advice follow the chosen Claude profile; a session stuck at sign-in ends",
304
- "k": "fix"
305
- }
306
- ]
307
307
  }
308
308
  ]
309
309
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@677aafe4
2
- assembled: 2026-11-11
1
+ kernel-source: pmos@334d2b91
2
+ assembled: 2026-11-12
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-11-11T12:32:15Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-12T04:27:43Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-11-11T12:32:15Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-12T04:27:43Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -351,6 +351,14 @@ function buildRange(root, { spec, whole }) {
351
351
  * ordering rule; "I cannot tell" is not, and collapsing the second into the first is exactly how a
352
352
  * shallow clone would turn every order check into a silent pass.
353
353
  */
354
+ /** The unix seconds of the commit that first added `rel`, or null when git cannot say. */
355
+ function addedDate(root, rel) {
356
+ const out = git(root, ['log', '--diff-filter=A', '--format=%ct', '--', rel]);
357
+ const lines = out ? out.split('\n').map((x) => x.trim()).filter(Boolean) : [];
358
+ const t = lines.length ? Number(lines[lines.length - 1]) : NaN;
359
+ return Number.isFinite(t) ? t : null;
360
+ }
361
+
354
362
  function firstAppearance(root, range, rel) {
355
363
  const onDisk = fs.existsSync(path.join(root, rel));
356
364
  if (!range.ok) return onDisk ? undefined : null;
@@ -685,7 +693,12 @@ function computeWorkflowDerived(id, opts) {
685
693
  // would suddenly be enforced. So the commit DATE decides whenever the range can supply it, and
686
694
  // -1 keeps its meaning for the gate's range. Same question, asked of evidence that survives both.
687
695
  const recIdx = firstAppearance(root, range, recRel);
688
- const recAt = (range.dates && typeof recIdx === 'number' && recIdx >= 0) ? range.dates[recIdx] : null;
696
+ // An EMPTY range (a branch level with main, a fresh clone, a kit repository on its trunk) gates nothing, so -1 there only means "committed
697
+ // before HEAD". It used to read every record as legacy, a record written today too, which turned the order rules off on the ladder
698
+ // (launch simulation W1, 2026-11-12). With nothing to gate, the record's own first commit dates it.
699
+ const emptyRange = range.ok && Array.isArray(range.shas) && range.shas.length === 0;
700
+ const addedAt = (recIdx === -1 && emptyRange) ? addedDate(root, recRel) : null;
701
+ const recAt = (range.dates && typeof recIdx === 'number' && recIdx >= 0) ? range.dates[recIdx] : addedAt;
689
702
  /*
690
703
  * `reconstructed_from` — the merge date of work whose record was written afterwards.
691
704
  *
@@ -698,7 +711,7 @@ function computeWorkflowDerived(id, opts) {
698
711
  * genuinely skipped the loop still reports blocked, which is the point of writing it down.
699
712
  */
700
713
  const recon = String(fm.reconstructed_from || '').trim().slice(0, 10);
701
- const legacy = recIdx === -1 ? true
714
+ const legacy = (recIdx === -1 && !addedAt) ? true
702
715
  : /^\d{4}-\d{2}-\d{2}$/.test(recon) ? recon < ENFORCED_FROM
703
716
  : recAt ? new Date(recAt * 1000).toISOString().slice(0, 10) < ENFORCED_FROM
704
717
  : String(fm.timestamp || generatedAt(fm.generated) || '').slice(0, 10) < ENFORCED_FROM; // fallback — see ENFORCED_FROM; D74: OKF v0.2 `generated.at` stands in for `timestamp`
@@ -1735,7 +1748,11 @@ function renderLadder(w) {
1735
1748
  const head = `${c(1, w.id)} · ${w.lane}${w.laneKnown ? '' : c(33, ' (unknown lane — enforcing feature)')} · ${w.anchor ? brief(w.anchor, 46) : c(31, 'unanchored')}`;
1736
1749
  out.push('');
1737
1750
  out.push(` ${head}`);
1738
- out.push(` ${c(90, 'stage')} ${c(1, w.stage)}${w.legacy ? c(33, ` legacy — record predates ${w.enforced_from}, order rules report but do not fail`) : ''}`);
1751
+ // The gate rung, not the initiative's stage: the stage the pages and `pmos initiative list` show is the Board's one stage (PM moves,
1752
+ // Jira, dated plan items, then these files; workspace/lib/stage-read.js). Printing the rung as "stage" gave one record four stages
1753
+ // (launch simulation W1, 2026-11-12). The engine never reads the Board (X29), so it names the rung and says where the stage is.
1754
+ out.push(` ${c(90, 'gate')} ${c(1, w.stage)}${w.legacy ? c(33, ` legacy — record predates ${w.enforced_from}, order rules report but do not fail`) : ''}`);
1755
+ out.push(` ${c(90, 'stage')} ${c(90, `pmos workflow of ${w.id} — the stage every page shows`)}`);
1739
1756
  out.push(` ${c(90, '─'.repeat(78))}`);
1740
1757
  for (const s of w.steps) {
1741
1758
  const label = s.label.padEnd(11);
@@ -1901,7 +1918,7 @@ function main(argv) {
1901
1918
  }
1902
1919
  if (w.legacy) process.stdout.write(`ℹ️ '${w.id}' is LEGACY (record predates ${ENFORCED_FROM}) — order rules reported, not enforced.\n`);
1903
1920
  if (w.range.error) process.stdout.write(`⚠️ order checks degraded — ${w.range.error}\n`);
1904
- process.stdout.write(`✅ workflow gate PASSED — '${w.id}' (${w.lane}) at stage ${w.stage}.\n`);
1921
+ process.stdout.write(`✅ workflow gate PASSED — '${w.id}' (${w.lane}) at gate rung ${w.stage}.\n`);
1905
1922
  return 0;
1906
1923
  }
1907
1924
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-11-11T12:32:15Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-12T04:27:43Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  Newest first, ISO dates.
4
4
 
5
- ## 2026-11-11
5
+ ## 2026-11-12
6
6
 
7
7
  - Adopted OKF v0.2 (D73).
@@ -1,4 +1,30 @@
1
1
  [
2
+ {
3
+ "v": "0.565.0",
4
+ "at": "2026-11-12T04:27:46.732Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1296,
9
+ "t": "Every surface shows the one stage; pmos workflow check finds a disagreement",
10
+ "s": "Every surface shows the one stage; pmos workflow check finds a disagreement",
11
+ "k": "fix"
12
+ }
13
+ ]
14
+ },
15
+ {
16
+ "v": "0.564.0",
17
+ "at": "2026-11-11T14:08:23.553Z",
18
+ "f": 4,
19
+ "prs": [
20
+ {
21
+ "n": 1295,
22
+ "t": "Pmos blueprint on a shallow clone warns and shows Unknown, never a merged PR as In build",
23
+ "s": "Pmos blueprint on a shallow clone warns and shows Unknown, never a merged PR as In build",
24
+ "k": "fix"
25
+ }
26
+ ]
27
+ },
2
28
  {
3
29
  "v": "0.563.0",
4
30
  "at": "2026-11-11T12:32:19.496Z",
@@ -353,6 +353,7 @@ An agent writes a draft or a reading with these commands, and moves an initiativ
353
353
  - `pmos workflow of <initiative>` shows the workflow the initiative runs, its current stage, and each stage numbered as done, current or skipped. It reads the same row as the Board.
354
354
  - `pmos workflow move <initiative> --stage <key|name|number>` moves the initiative to a stage of its own workflow. A number counts from 1 in the workflow's order, so `--stage 5` is the fifth stage. `--why` adds the reason. The move writes the same line as a move on the Board, under the agent's name. On a board whose columns join two stages, such as **Build & Deliver**, the initiative still goes to the stage you name, and the joined column name means its first stage.
355
355
  - `pmos workflow switch <initiative> --to <workflow id>` puts the initiative on another workflow. `--stage` picks the stage it lands in; without it, the stage is the one the Board's switch picks.
356
+ - `pmos workflow check [<initiative>]` compares the stage that each surface shows: the Board, the Viewer and `pmos workflow of`, `pmos initiative list`, and the notes and report slides. It exits 1 and names the surfaces when two of them show different stages for one initiative. `scripts/workflow-state.js` shows the CI gate rung (`gate`), not the stage.
356
357
 
357
358
  ### pmos board
358
359
 
@@ -602,13 +603,15 @@ The fields of a schedule:
602
603
 
603
604
  | Command | What it does |
604
605
  |---|---|
605
- | `pmos blueprint list [--surface <id>] [--status <status>]` | Lists every feature with its status: Idea, Exploring, Agreed, In build, Live <version> or Retired. `pmos blueprint` alone does the same. |
606
+ | `pmos blueprint list [--surface <id>] [--status <status>]` | Lists every feature with its status: Idea, Exploring, Agreed, In build, Live <version> or Retired, and Unknown on a shallow clone. `pmos blueprint` alone does the same. |
606
607
  | `pmos blueprint show <feature-id>` | Prints one feature: its status and why, its PRs, files, record, guide sections and design. |
607
608
  | `pmos blueprint unplaced [--all]` | Lists the guide sections and the feature changes since the first release of the range that no feature cites. `--all` also lists the fixes, chores and docs. |
608
609
  | `pmos blueprint check` | Checks the registry: no `status` key anywhere, known surfaces, known guide sections, one id each. The exit code is 1 when it finds a problem. |
609
610
 
610
611
  Every command takes `--json`, `--root <dir>` and `--offline`. Live <version> is the first version whose `gitHead` contains the feature. The command reads the versions from npm and saves the read. With `--offline`, or when npm does not answer, it uses the saved read and says so. With no saved read, a merged feature shows `Live ?`.
611
612
 
613
+ On a shallow clone (a cloud session, CI, `git clone --depth`) the command warns that the history is shallow. A status that depends on the missing history shows Unknown, and a Live version that may be earlier shows as `Live ≤<version>`. Run `git fetch --unshallow`, then the command again, for the full answer.
614
+
612
615
  ### pmos kg: find knowledge without reading whole files
613
616
 
614
617
  | Command | What it does |
@@ -6,7 +6,8 @@
6
6
  * pmos blueprint unplaced [--all] [--json] guide sections and release changes no feature cites
7
7
  * pmos blueprint check [--json] the registry's own rules (no status key, known surfaces, …)
8
8
  * every command: [--offline] [--root <dir>]
9
- * Exit codes: 0 done, 1 refused (no registry, unknown feature, check found problems), 2 usage. Reads only; writes nothing
9
+ * On a shallow clone every command but check warns, and a status the missing history decides shows Unknown (lib/blueprint.js).
10
+ * The command never fetches: git's network verbs live only in lib/sync.js (D70), so the warning names `git fetch --unshallow`. Exit codes: 0 done, 1 refused (no registry, unknown feature, check found problems), 2 usage. Reads only; writes nothing
10
11
  * but the saved read of the releases (pmos/state/blueprint-releases.json, gitignored).
11
12
  */
12
13
  const path = require('path');
@@ -21,7 +22,7 @@ const USAGE = [
21
22
  ' pmos blueprint unplaced [--all] [--json] guide sections and release changes that no feature cites',
22
23
  ' pmos blueprint check [--json] the registry\'s own rules',
23
24
  ' every command: [--offline] (no npm read; use the saved one) [--root <dir>]',
24
- 'Statuses: Idea, Exploring, Agreed, In build, Live <version>, Retired. The registry is planning/blueprint/features.json.',
25
+ 'Statuses: Idea, Exploring, Agreed, In build, Live <version>, Retired, and Unknown on a shallow clone. The registry is planning/blueprint/features.json.',
25
26
  ];
26
27
 
27
28
  function parse(args) {
@@ -43,6 +44,10 @@ function releaseLine(r) {
43
44
  return `Releases: unknown (${r.error}). A merged feature shows "Live ?": its version cannot be worked out.`;
44
45
  }
45
46
 
47
+ function shallowLine(d, unknown) {
48
+ return `⚠ This clone's git history is shallow (${d.commits} commit${d.commits === 1 ? '' : 's'}), so ${unknown} status${unknown === 1 ? ' is' : 'es are'} Unknown and a Live version marked ≤ may be earlier. Run \`git fetch --unshallow\`, then this command again, for the full answer.`;
49
+ }
50
+
46
51
  function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), readReleases = B.readReleases, git } = {}) {
47
52
  const args = argv[0] === 'blueprint' ? argv.slice(1) : argv.slice();
48
53
  if (['help', '--help', '-h'].includes(args[0])) { for (const l of USAGE) say(l); return 0; }
@@ -66,12 +71,15 @@ function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), readRelea
66
71
  if (problems.length) { say('✗ the registry breaks its own rules; run `pmos blueprint check`.'); for (const p of problems) say(' ' + p); return 1; }
67
72
  const rels = { ...readReleases({ root, pkg: reg.package, offline: !!flags.offline }), offline: !!flags.offline };
68
73
  const opts = { root, releases: rels.list }; if (git) opts.git = git;
69
- const { features } = B.derive(reg, opts);
74
+ const derived = B.derive(reg, opts);
75
+ const { features } = derived;
76
+ const nUnknown = features.filter((f) => f.status === 'Unknown').length;
77
+ const shallowJson = { shallow: !!derived.shallow, commits: derived.commits };
70
78
 
71
79
  if (verb === 'show') {
72
80
  const f = features.find((x) => x.id === pos[0]);
73
81
  if (!f) { say(pos[0] ? `✗ no feature "${pos[0]}" — \`pmos blueprint\` lists them` : 'usage: pmos blueprint show <feature-id>'); return pos[0] ? 1 : 2; }
74
- if (flags.json) { say(JSON.stringify({ ok: true, releases: rels.source, feature: f })); return 0; }
82
+ if (flags.json) { say(JSON.stringify({ ok: true, releases: rels.source, ...shallowJson, feature: f })); return 0; }
75
83
  const surface = reg.surfaces.find((s) => s.id === f.surface);
76
84
  say(`${f.name} (${f.id})`);
77
85
  say(` Status: ${B.label(f)} — ${f.why.join('; ')}`);
@@ -85,15 +93,17 @@ function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), readRelea
85
93
  for (const d of f.design || []) say(` Design: ${d}`);
86
94
  if (f.note) say(` Note: ${f.note}`);
87
95
  say(' ' + releaseLine(rels));
96
+ if (derived.shallow) say(' ' + shallowLine(derived, nUnknown));
88
97
  return 0;
89
98
  }
90
99
 
91
100
  if (verb === 'unplaced') {
92
101
  const u = B.unplaced(reg, opts);
93
- if (flags.json) { say(JSON.stringify({ ok: true, releases: rels.source, range: u.range, guide: u.guide, changes: u.changes, other: flags.all ? u.other : u.other.length })); return 0; }
102
+ if (flags.json) { say(JSON.stringify({ ok: true, releases: rels.source, ...shallowJson, range: u.range, guide: u.guide, changes: u.changes, other: flags.all ? u.other : u.other.length })); return 0; }
94
103
  say(`Guide sections no feature cites: ${u.guide.length}`);
95
104
  for (const g of u.guide) say(' ' + g);
96
- if (!u.range) say('Release changes: not checked — no release data, so the first release of the range is unknown.');
105
+ if (!u.range) say(derived.shallow ? 'Release changes: not checked — this shallow clone does not hold the release the range starts from. Run `git fetch --unshallow` first.'
106
+ : 'Release changes: not checked — no release data, so the first release of the range is unknown.');
97
107
  else {
98
108
  say(`Feature changes since ${u.range.from} that no feature cites: ${u.changes.length}`);
99
109
  for (const c of u.changes) say(` ${c.sha} ${c.subject}`);
@@ -110,13 +120,14 @@ function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), readRelea
110
120
  const u = B.unplaced(reg, opts);
111
121
  const counts = {}; for (const s of B.STATUSES) counts[s] = features.filter((f) => f.status === s).length;
112
122
  if (flags.json) {
113
- say(JSON.stringify({ ok: true, what: reg.what, releases: { source: rels.source, at: rels.at, count: rels.list.length },
123
+ say(JSON.stringify({ ok: true, what: reg.what, releases: { source: rels.source, at: rels.at, count: rels.list.length }, ...shallowJson,
114
124
  counts, unplaced: { guide: u.guide.length, changes: u.range ? u.changes.length : null },
115
- features: shown.map((f) => ({ id: f.id, name: f.name, surface: f.surface, status: f.status, version: f.version, why: f.why })) }));
125
+ features: shown.map((f) => ({ id: f.id, name: f.name, surface: f.surface, status: f.status, version: f.version, ...(f.atMost ? { version_at_most: true } : {}), why: f.why })) }));
116
126
  return 0;
117
127
  }
118
128
  say(`${reg.name || 'Product'} blueprint — ${features.length} features`);
119
129
  say(' ' + B.STATUSES.filter((s) => counts[s]).map((s) => `${s} ${counts[s]}`).join(' · '));
130
+ if (derived.shallow) say(shallowLine(derived, nUnknown));
120
131
  for (const s of reg.surfaces) {
121
132
  const rows = shown.filter((f) => f.surface === s.id);
122
133
  if (!rows.length) continue;
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * load(root) → { ok, registry, file } | { ok:false, error }
6
6
  * check(registry, { root }) → [problem] the registry's own rules (no status key, known surfaces, …)
7
- * derive(registry, { root, releases }) → { features, releases } every feature with { status, version, why }
7
+ * derive(registry, { root, releases }) → { features, releases, shallow, commits } every feature with { status, version, why }
8
8
  * unplaced(registry, { root, releases }) → { guide, changes, other, range }
9
9
  * readReleases({ root, pkg, npmView, offline, now }) → { list, source, at, error } npm `gitHead` per version, cached
10
10
  * STATUSES
@@ -20,6 +20,10 @@
20
20
  * Agreed its experiment record has a done test (D107: the done test is the agreed spec)
21
21
  * Exploring its experiment record has no done test yet, or a cited prototype/ path exists
22
22
  * Idea nothing above: the entry alone
23
+ * Unknown a SHALLOW clone (cloud sessions, CI, `git clone --depth`) lacks the history the status depends on: a cited
24
+ * PR whose merge is older than the clone's first commit reads as "not merged" there, so it would show In build
25
+ * although it shipped long ago. derive() never guesses in that case. It never fetches the history itself:
26
+ * git's network verbs live only in lib/sync.js (D70), so the CLI names `git fetch --unshallow` instead. A Live version that older, missing releases could precede is marked `atMost` (≤).
23
27
  *
24
28
  * "In a release" means: the release's gitHead (from `npm view <pkg> version gitHead`) has the commit as an ancestor, or
25
29
  * has the file in its tree. Without release data (no network and no saved read) a merged feature says `Live ?`.
@@ -28,7 +32,7 @@ const fs = require('fs');
28
32
  const path = require('path');
29
33
  const cp = require('child_process');
30
34
 
31
- const STATUSES = Object.freeze(['Idea', 'Exploring', 'Agreed', 'In build', 'Live', 'Retired']);
35
+ const STATUSES = Object.freeze(['Idea', 'Exploring', 'Agreed', 'In build', 'Live', 'Retired', 'Unknown']);
32
36
  const REGISTRY = path.join('planning', 'blueprint', 'features.json');
33
37
  const CACHE = path.join('pmos', 'state', 'blueprint-releases.json');
34
38
  const FORBIDDEN_KEYS = ['status', 'stage', 'state'];
@@ -103,9 +107,16 @@ function gitIn(root) {
103
107
  const lines = out.split('\n');
104
108
  return shas.map((_, i) => / commit \d+$/.test(lines[i] || ''));
105
109
  };
106
- return { mainLine, contains, present, knownAll };
110
+ /** Is this a shallow clone? Its history stops at a cut-off, so a merge older than that is invisible here. */
111
+ let shallowAns = null;
112
+ const shallow = () => {
113
+ if (shallowAns === null) shallowAns = (run(['rev-parse', '--is-shallow-repository']) || '').trim() === 'true';
114
+ return shallowAns;
115
+ };
116
+ return { mainLine, contains, present, knownAll, shallow };
107
117
  }
108
118
 
119
+
109
120
  /* ---------- releases (npm gitHead) ---------- */
110
121
 
111
122
  function semverCmp(a, b) {
@@ -219,7 +230,11 @@ function derive(registry, { root, releases = [], git = gitIn(root) } = {}) {
219
230
  const known = git.knownAll(releases.map((r) => r.gitHead));
220
231
  const rel = releases.filter((_, i) => known[i]);
221
232
  const L = git.mainLine();
233
+ const shallow = typeof git.shallow === 'function' && git.shallow();
234
+ const relMissing = shallow && rel.length < releases.length; // older releases whose commits this clone does not hold
235
+ const cut = 'older than this shallow clone\'s history';
222
236
  const firstReleaseWith = (sha) => { for (const r of rel) if (git.contains(r.gitHead, sha)) return r.version; return null; };
237
+ const unknown = (out, reason) => { out.status = 'Unknown'; out.version = null; out.why.push(reason); return out; };
223
238
  const feats = (registry.features || []).map((f) => {
224
239
  const why = [];
225
240
  const prs = (f.prs || []).map((n) => ({ n, c: L.byPr.get(n) || null }));
@@ -229,9 +244,13 @@ function derive(registry, { root, releases = [], git = gitIn(root) } = {}) {
229
244
  const protos = (f.files || []).filter((p) => p.startsWith('prototype/'));
230
245
  const headHas = git.present(files.map((p) => ['HEAD', p]));
231
246
  const out = { ...f, status: 'Idea', version: null, why };
247
+ const missing = shallow ? open : []; // on a shallow clone a PR not found may simply be merged before the cut-off
248
+ const list = (ps) => ps.map((p) => '#' + p.n).join(', ');
232
249
 
233
250
  // Retired: a retiring PR is merged, or every cited file is gone now and was in a release.
234
- const retiring = (f.retired_by || []).map((n) => ({ n, c: L.byPr.get(n) || null })).filter((p) => p.c);
251
+ const retiringAll = (f.retired_by || []).map((n) => ({ n, c: L.byPr.get(n) || null }));
252
+ const retiring = retiringAll.filter((p) => p.c);
253
+ if (!retiring.length && shallow && retiringAll.length) return unknown(out, `retiring ${list(retiringAll)} not found: it may be ${cut}`);
235
254
  if (retiring.length) {
236
255
  const first = retiring.sort((a, b) => b.c.idx - a.c.idx)[0];
237
256
  out.status = 'Retired'; out.version = rel.length ? firstReleaseWith(first.c.sha) : null;
@@ -247,10 +266,12 @@ function derive(registry, { root, releases = [], git = gitIn(root) } = {}) {
247
266
  return out;
248
267
  }
249
268
  }
269
+ if (shallow && files.length && headHas.every((x) => !x) && relMissing) return unknown(out, `its files are gone and in no release this clone holds: they may have shipped ${cut}`);
250
270
 
251
271
  // Live / In build: merged PRs and files present now.
252
272
  const built = merged.length > 0 || headHas.some(Boolean);
253
273
  if (built) {
274
+ if (!rel.length && relMissing) return unknown(out, 'merged, but this shallow clone holds none of the releases, so release or build cannot be told');
254
275
  if (!rel.length) { out.status = 'Live'; out.version = '?'; why.push('merged; no release data, so the version is unknown'); return out; }
255
276
  let best = null;
256
277
  for (const p of merged) { const v = firstReleaseWith(p.c.sha); if (v && (!best || semverCmp(v, best.v) < 0)) best = { v, by: `#${p.n}` }; }
@@ -261,14 +282,18 @@ function derive(registry, { root, releases = [], git = gitIn(root) } = {}) {
261
282
  }
262
283
  if (best) {
263
284
  out.status = 'Live'; out.version = best.v; why.push(`${best.by} first shipped in ${best.v}`);
285
+ // Older releases are missing here: a cited PR outside the history, or a file, may have shipped in one of them.
286
+ if (relMissing && (missing.length || files.length)) { out.atMost = true; why.push(`it may have shipped earlier, in a release ${cut}`); }
264
287
  const later = merged.filter((p) => !firstReleaseWith(p.c.sha)).map((p) => '#' + p.n);
265
288
  if (later.length) why.push(`${later.join(', ')} merged, not released yet`);
266
- if (open.length) why.push(`${open.map((p) => '#' + p.n).join(', ')} not merged yet`);
289
+ if (open.length) why.push(shallow ? `${list(open)} not in this clone's history` : `${list(open)} not merged yet`);
267
290
  return out;
268
291
  }
292
+ if (missing.length) return unknown(out, `${list(merged) || 'its files'} merged, in no release yet; ${list(missing)} not found: it may be ${cut}`);
269
293
  out.status = 'In build'; why.push(`${merged.map((p) => '#' + p.n).join(', ') || 'its files'} merged, in no release yet`);
270
294
  return out;
271
295
  }
296
+ if (missing.length) return unknown(out, `${list(missing)} not found: it may be merged ${cut}`);
272
297
  if (open.length) { out.status = 'In build'; why.push(`${open.map((p) => '#' + p.n).join(', ')} not merged yet`); return out; }
273
298
 
274
299
  // Agreed / Exploring: the experiment record, or a prototype.
@@ -279,10 +304,10 @@ function derive(registry, { root, releases = [], git = gitIn(root) } = {}) {
279
304
  why.push('no record, PR or file yet');
280
305
  return out;
281
306
  });
282
- return { features: feats, releases: rel };
307
+ return { features: feats, releases: rel, shallow, commits: L.list.length };
283
308
  }
284
309
 
285
- function label(f) { return f.status === 'Live' || (f.status === 'Retired' && f.version) ? `${f.status} ${f.version || ''}`.trim() : f.status; }
310
+ function label(f) { return f.status === 'Live' || (f.status === 'Retired' && f.version) ? `${f.status} ${f.atMost ? '≤' : ''}${f.version || ''}`.trim() : f.status; }
286
311
 
287
312
  /** What no feature cites: guide sections, and feature changes on the default line since the release before `from`. */
288
313
  function unplaced(registry, { root, releases = [], git = gitIn(root) } = {}) {
@@ -25,7 +25,7 @@ const USAGE = [
25
25
  ' pmos board --mine your own items',
26
26
  ' pmos board --init <initiative> one initiative',
27
27
  ' pmos board --json the answer of GET /api/board, for scripts',
28
- 'Done shows the last 14 days. Breakdown items only: tasks are in `pmos task list <initiative>`, and they also set the initiative\'s bar on the Board timeline.',
28
+ 'Done shows the last 14 days. Tasks and breakdown items both show; `pmos task list <initiative>` lists one initiative\'s tasks with their dates.',
29
29
  ];
30
30
  const BOOL = new Set(['json', 'mine', 'help']);
31
31
  const VALUE = new Set(['init', 'root']);
@@ -63,6 +63,36 @@ function line(it, titleOf) {
63
63
  return bits.join(' · ');
64
64
  }
65
65
 
66
+ /* The initiative's tasks (launch simulation W1, 2026-11-12). The fold above holds the breakdown items only, so `pmos board` printed 0 items
67
+ * while `pmos task list` printed 4. Each Board task joins its column as the Board page shows it: To do → Todo, In progress → Doing,
68
+ * Done → Done (the last 14 days; older ones are counted). Won't do and Archived are not on the Board. The breakdown items are already in
69
+ * the fold, so only the Board tasks are added here (lib/stage-read.js tasksOf, the reader of `pmos task list`). */
70
+ const TASK_COL = { 'To do': 'todo', 'In progress': 'doing', Done: 'done' };
71
+ const DONE_WINDOW_MS = 14 * 86400000;
72
+ function addTasks(out, root, now) {
73
+ let SR, sw, sctx;
74
+ try { SR = require('./stage-read.js'); ({ w: sw, ctx: sctx } = SR.cliCtx(root)); } catch { return; }
75
+ if (!sctx.stateDirFor()) return;
76
+ const at = Number.isFinite(now) ? now : Date.parse(out.now) || Date.now();
77
+ const only = out.filter.startsWith('init:') ? out.filter.slice(5) : null;
78
+ for (const ini of out.initiatives) {
79
+ if (only && ini.id !== only) continue;
80
+ let tasks = [];
81
+ try { tasks = SR.tasksOf(sctx, sw, ini.id).filter((t) => t.store !== 'item'); } catch { tasks = []; }
82
+ for (const t of tasks) {
83
+ const col = TASK_COL[t.state];
84
+ if (!col) continue;
85
+ if (out.filter === 'mine' && t.owner !== 'you') continue;
86
+ const last = Math.max(Date.parse(t.at) || 0, ...(t.history || []).map((h) => Date.parse(h && h.at) || 0));
87
+ if (col === 'done' && at - last > DONE_WINDOW_MS) { out.board.doneOlder++; continue; }
88
+ out.items[t.id] = { id: t.id, initiative: ini.id, title: t.title, state: col, owner: t.owner || '', stageLabel: t.stage || 'task', due: t.due || null, task: true };
89
+ out.board[col].push(t.id);
90
+ ini.shown = (ini.shown || 0) + 1;
91
+ }
92
+ }
93
+ out.counts = { todo: out.board.todo.length, doing: out.board.doing.length, review: out.board.review.length, done: out.board.done.length, doneOlder: out.board.doneOlder };
94
+ }
95
+
66
96
  async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now } = {}) {
67
97
  const args = argv[0] === 'board' ? argv.slice(1) : argv.slice();
68
98
  const { pos, flags } = parse(args);
@@ -87,6 +117,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now
87
117
  try { out = boardFold.boardFor({ id: 'cli', root }, { filter, now }); }
88
118
  catch (e) { return fail('the Board could not be read: ' + String((e && e.message) || e).slice(0, 200)); }
89
119
  if (!out.ok) return fail(out.error, out.status === 400 ? 2 : 1);
120
+ addTasks(out, root, now);
90
121
  if (json) { say(JSON.stringify(out)); return 0; }
91
122
  const titleOf = Object.fromEntries(out.initiatives.map((i) => [i.id, i.title]));
92
123
  const label = out.filter === 'active' ? 'Active' : out.filter === 'mine' ? 'Mine' : out.filter.slice(5);
@@ -351,6 +351,14 @@ function buildRange(root, { spec, whole }) {
351
351
  * ordering rule; "I cannot tell" is not, and collapsing the second into the first is exactly how a
352
352
  * shallow clone would turn every order check into a silent pass.
353
353
  */
354
+ /** The unix seconds of the commit that first added `rel`, or null when git cannot say. */
355
+ function addedDate(root, rel) {
356
+ const out = git(root, ['log', '--diff-filter=A', '--format=%ct', '--', rel]);
357
+ const lines = out ? out.split('\n').map((x) => x.trim()).filter(Boolean) : [];
358
+ const t = lines.length ? Number(lines[lines.length - 1]) : NaN;
359
+ return Number.isFinite(t) ? t : null;
360
+ }
361
+
354
362
  function firstAppearance(root, range, rel) {
355
363
  const onDisk = fs.existsSync(path.join(root, rel));
356
364
  if (!range.ok) return onDisk ? undefined : null;
@@ -685,7 +693,12 @@ function computeWorkflowDerived(id, opts) {
685
693
  // would suddenly be enforced. So the commit DATE decides whenever the range can supply it, and
686
694
  // -1 keeps its meaning for the gate's range. Same question, asked of evidence that survives both.
687
695
  const recIdx = firstAppearance(root, range, recRel);
688
- const recAt = (range.dates && typeof recIdx === 'number' && recIdx >= 0) ? range.dates[recIdx] : null;
696
+ // An EMPTY range (a branch level with main, a fresh clone, a kit repository on its trunk) gates nothing, so -1 there only means "committed
697
+ // before HEAD". It used to read every record as legacy, a record written today too, which turned the order rules off on the ladder
698
+ // (launch simulation W1, 2026-11-12). With nothing to gate, the record's own first commit dates it.
699
+ const emptyRange = range.ok && Array.isArray(range.shas) && range.shas.length === 0;
700
+ const addedAt = (recIdx === -1 && emptyRange) ? addedDate(root, recRel) : null;
701
+ const recAt = (range.dates && typeof recIdx === 'number' && recIdx >= 0) ? range.dates[recIdx] : addedAt;
689
702
  /*
690
703
  * `reconstructed_from` — the merge date of work whose record was written afterwards.
691
704
  *
@@ -698,7 +711,7 @@ function computeWorkflowDerived(id, opts) {
698
711
  * genuinely skipped the loop still reports blocked, which is the point of writing it down.
699
712
  */
700
713
  const recon = String(fm.reconstructed_from || '').trim().slice(0, 10);
701
- const legacy = recIdx === -1 ? true
714
+ const legacy = (recIdx === -1 && !addedAt) ? true
702
715
  : /^\d{4}-\d{2}-\d{2}$/.test(recon) ? recon < ENFORCED_FROM
703
716
  : recAt ? new Date(recAt * 1000).toISOString().slice(0, 10) < ENFORCED_FROM
704
717
  : String(fm.timestamp || generatedAt(fm.generated) || '').slice(0, 10) < ENFORCED_FROM; // fallback — see ENFORCED_FROM; D74: OKF v0.2 `generated.at` stands in for `timestamp`
@@ -1735,7 +1748,11 @@ function renderLadder(w) {
1735
1748
  const head = `${c(1, w.id)} · ${w.lane}${w.laneKnown ? '' : c(33, ' (unknown lane — enforcing feature)')} · ${w.anchor ? brief(w.anchor, 46) : c(31, 'unanchored')}`;
1736
1749
  out.push('');
1737
1750
  out.push(` ${head}`);
1738
- out.push(` ${c(90, 'stage')} ${c(1, w.stage)}${w.legacy ? c(33, ` legacy — record predates ${w.enforced_from}, order rules report but do not fail`) : ''}`);
1751
+ // The gate rung, not the initiative's stage: the stage the pages and `pmos initiative list` show is the Board's one stage (PM moves,
1752
+ // Jira, dated plan items, then these files; workspace/lib/stage-read.js). Printing the rung as "stage" gave one record four stages
1753
+ // (launch simulation W1, 2026-11-12). The engine never reads the Board (X29), so it names the rung and says where the stage is.
1754
+ out.push(` ${c(90, 'gate')} ${c(1, w.stage)}${w.legacy ? c(33, ` legacy — record predates ${w.enforced_from}, order rules report but do not fail`) : ''}`);
1755
+ out.push(` ${c(90, 'stage')} ${c(90, `pmos workflow of ${w.id} — the stage every page shows`)}`);
1739
1756
  out.push(` ${c(90, '─'.repeat(78))}`);
1740
1757
  for (const s of w.steps) {
1741
1758
  const label = s.label.padEnd(11);
@@ -1901,7 +1918,7 @@ function main(argv) {
1901
1918
  }
1902
1919
  if (w.legacy) process.stdout.write(`ℹ️ '${w.id}' is LEGACY (record predates ${ENFORCED_FROM}) — order rules reported, not enforced.\n`);
1903
1920
  if (w.range.error) process.stdout.write(`⚠️ order checks degraded — ${w.range.error}\n`);
1904
- process.stdout.write(`✅ workflow gate PASSED — '${w.id}' (${w.lane}) at stage ${w.stage}.\n`);
1921
+ process.stdout.write(`✅ workflow gate PASSED — '${w.id}' (${w.lane}) at gate rung ${w.stage}.\n`);
1905
1922
  return 0;
1906
1923
  }
1907
1924
 
@@ -161,7 +161,11 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
161
161
  const o = order();
162
162
  if (o.error) return fail(o.error);
163
163
  const byRow = new Map(o.rows.map((r) => [r.id, r]));
164
- const stage = (id) => lifecycle.labelOf(byRow.get(id), root); // W1: the one stage
164
+ // the one stage, as the Board row holds it (lib/stage-read.js): a workflow move and the PM's word count, as on every page
165
+ const SR = require('./stage-read.js');
166
+ const { w: sw, ctx: sctx } = SR.cliCtx(root);
167
+ const read = SR.stagesOf(sctx, sw, o.placed.ranked);
168
+ const stage = (id) => { const a = read.get(id); return a ? a.label : lifecycle.labelOf(byRow.get(id), root); };
165
169
  if (json) {
166
170
  say(JSON.stringify({ ok: true, ranked: o.placed.ranked, byInit: o.placed.byInit, stages: Object.fromEntries(o.placed.ranked.map((id) => [id, stage(id)])),
167
171
  proposals: o.placed.proposals.map((p) => ({ ...p, by: actorLib.pageName(p.by) })), documents: documentsOf(o.rows) }));
@@ -489,12 +489,13 @@ function draftOf(root, { cadence, slot, now, health } = {}) {
489
489
  const lab = stageCache.get(id).get(sid);
490
490
  return lab || cap(String(sid || ''));
491
491
  };
492
+ const oneStage = require('./stage-read.js').labelReader(main, (id) => lifecycle.labelOf(rows.find((r) => r.id === id), main));
492
493
  const integratedAll = new Set();
493
494
  for (const r of rows) for (const w of ((factoryJoin.factoryOf(fj, r.id) || {}).items || [])) if (w && w.integrated && w.plan_item) integratedAll.add(w.plan_item);
494
495
  const slides = slidesData({
495
496
  product: def.product || path.basename(main), cadence, slot: theSlot, nowMs, window, cycleDays: cycle,
496
497
  blocks, rows, itemsOf,
497
- stageLabel, lifecycleOf: (id) => lifecycle.labelOf(rows.find((r) => r.id === id), main), // W1: the one stage
498
+ stageLabel, lifecycleOf: oneStage, // W1: the one stage, as the Board row holds it (lib/stage-read.js)
498
499
  rankOf: (id) => (has(plc.byInit, id) && Number.isFinite(plc.byInit[id].rank) ? plc.byInit[id].rank : Infinity),
499
500
  isDone: (it) => it.state === 'done' || integratedAll.has(it.id),
500
501
  });
@@ -384,13 +384,15 @@ function openInitiativesOf(w) {
384
384
  else if (got.ok) {
385
385
  const rm = ri.roadmapOf(w, ri.frameOf(w, got.rows, { now: Date.now() }));
386
386
  const byId = new Map(got.rows.map((r) => [r.id, r]));
387
+ // the one stage the Board row holds (lib/stage-read.js): a workflow move counts, as on every page
388
+ const stageLabel = require('./stage-read.js').labelReader(w.root, (id) => lifecycle.labelOf(byId.get(id), w.root));
387
389
  let top = 0;
388
390
  const add = (r, dormant) => {
389
391
  const rec = byId.get(r.id);
390
392
  if (rec && (rec.stopped || rec.accepted)) return;
391
393
  const isTop = !dormant && top < PICKER_TOP;
392
394
  if (isTop) top++;
393
- ranked.push({ id: r.id, title: r.title, anchor: r.anchor, intent: '', stage: lifecycle.labelOf(rec, w.root), dormant, top: isTop });
395
+ ranked.push({ id: r.id, title: r.title, anchor: r.anchor, intent: '', stage: stageLabel(r.id), dormant, top: isTop });
394
396
  };
395
397
  for (const r of rm.rows) add(r, false);
396
398
  for (const r of rm.dormant) add(r, true);
@@ -0,0 +1,155 @@
1
+ 'use strict';
2
+ /* stage-read.js — the ONE stage and the tasks of an initiative outside HTTP, read the way the Board reads them (launch simulation W1,
3
+ * 2026-11-12).
4
+ *
5
+ * The launch simulation found four answers for one record: `pmos workflow of` and the Board said Evaluate, `pmos initiative list` said
6
+ * Triage, and the Viewer's gate line and the ladder said something else again. The Board row (lib/routes-boards.js boardRow) already
7
+ * holds the one stage (row.oneStage, lib/one-stage.js stageOf): the PM's word, a Board or workflow move, Jira, dated plan items, then
8
+ * the spec files. Every terminal reader now takes it from there, so a terminal line and a page cannot disagree.
9
+ *
10
+ * cliCtx(root, stateDir?) → { w, ctx } the Board's routes outside HTTP: this repository as the one workspace
11
+ * rowOf(ctx, w, id) → initiativeWorkflow's answer, deriving the rows first when they are still being read
12
+ * stageOf(ctx, w, id) → { label, stage, step, setBy, source, readAt, wf: { stage, n, of } | null } | null
13
+ * label is what every surface prints (row.oneStage.label); wf is the workflow's own stage beside it
14
+ * stagesOf(ctx, w, ids) → Map id → stageOf answer
15
+ * labelReader(root, fallback) → (id) → label for a server surface: never starts a read, falls back while the records are read
16
+ * tasksOf(ctx, w, id) → every task of an initiative: its Board tasks and its breakdown items (what `pmos task list` lists)
17
+ * disagreements(answers) → [{ id, surfaces: { name: label } }] the initiatives two surfaces name different stages for
18
+ * check(root, { ids }) → { ok, checked, disagree, stages } every surface's stage, compared (`pmos workflow check`)
19
+ *
20
+ * The CI Initiative Gate is not a stage: scripts/workflow-state.js reports the gate rung (spec, contract, build …), and the engine
21
+ * never requires this file (X29).
22
+ */
23
+ const path = require('path');
24
+
25
+ function cliCtx(root, stateDir) {
26
+ const driver = require('./driver.js');
27
+ const dir = stateDir === undefined ? driver.stateDirOf(root) : stateDir;
28
+ const w = { id: driver.wsIdOf(root), name: path.basename(root), root };
29
+ return { w, ctx: { getWs: () => w, workspaceList: () => [w], stateDirFor: () => dir, selfRoot: path.resolve(__dirname, '..', '..') } };
30
+ }
31
+
32
+ function rowOf(ctx, w, id) {
33
+ const boards = require('./routes-boards.js');
34
+ const rowsLib = require('./initiative-rows.js');
35
+ const was = rowsLib.setBackground(false);
36
+ try {
37
+ let r = boards.initiativeWorkflow(ctx, w, id);
38
+ if (r.pending) { try { rowsLib.deriveNow(w.root); } catch { /* answered below */ } r = boards.initiativeWorkflow(ctx, w, id); }
39
+ return r;
40
+ } finally { rowsLib.setBackground(was); }
41
+ }
42
+
43
+ /** The stage a Board row shows → the stageOf answer. The same rule the stage card and the chip draw. */
44
+ function fromRow(row) {
45
+ if (!row) return null;
46
+ const one = row.oneStage || null;
47
+ const st = row.wfStage || null;
48
+ const wf = st && st.name ? { stage: st.name, key: st.key, n: st.n, of: st.of } : null;
49
+ if (row.ended) return { label: row.ended.as === 'wontdo' ? "Won't do" : 'Archived', stage: 'ended', step: one ? one.step : null, setBy: 'pm', source: 'the workflow', readAt: null, wf };
50
+ // the chip, the stage card and the Viewer's stage words all print row.oneStage.label (public/pm/stage-chip.js, lib/initiative-premium.js)
51
+ if (one && one.label) return { label: one.label, stage: one.stage, step: one.step, setBy: one.setBy, source: one.source, readAt: one.readAt, wf };
52
+ if (wf) return { label: wf.stage, stage: null, step: null, setBy: 'pm', source: 'the workflow', readAt: null, wf };
53
+ return null;
54
+ }
55
+
56
+ function stageOf(ctx, w, id) {
57
+ const r = rowOf(ctx, w, id);
58
+ return r && r.ok ? fromRow(r.row) : null;
59
+ }
60
+ function stagesOf(ctx, w, ids) {
61
+ const out = new Map();
62
+ const pass = { ...ctx, boardsPass: new Map() }; // one fold of the Board ledger for the whole list
63
+ for (const id of ids || []) { try { out.set(id, stageOf(pass, w, id)); } catch { out.set(id, null); } }
64
+ return out;
65
+ }
66
+
67
+ /** A reader for a surface that holds only a repository root and its workflow rows (the notes picker, a report's slides): id → the
68
+ * one stage's label. It never starts a read of the records: while they are still being read it answers with `fallback(id)`. */
69
+ function labelReader(root, fallback) {
70
+ let pass = null, w = null;
71
+ try { const c = cliCtx(root); w = c.w; pass = { ...c.ctx, boardsPass: new Map() }; } catch { pass = null; }
72
+ const boards = require('./routes-boards.js');
73
+ return (id) => {
74
+ if (pass && pass.stateDirFor()) {
75
+ try { const r = boards.initiativeWorkflow(pass, w, id); const a = r && r.ok ? fromRow(r.row) : null; if (a) return a.label; } catch { /* the fallback answers */ }
76
+ }
77
+ return fallback ? fallback(id) : '';
78
+ };
79
+ }
80
+
81
+ /** Every task of an initiative: its Board tasks (on any board of this workspace) and its breakdown items. */
82
+ function tasksOf(ctx, w, id) {
83
+ const boards = require('./routes-boards.js');
84
+ const TI = require('./task-items.js');
85
+ const r = rowOf(ctx, w, id);
86
+ const board = r.ok ? r.board.id : null;
87
+ const F = boards.foldOf(ctx, w), S = F.sections || new Map(), MS = F.milestones || new Map(), PN = F.pins || new Map();
88
+ const pinOf = (tid) => (PN.has(tid) ? { pinned: PN.get(tid) } : {}); // the PM's pin on the Board timeline (batch 13 item 4); unset = the rule
89
+ const msOf = (tid, own) => (MS.has(tid) ? MS.get(tid) : !!own); // the PM's ◇ flag (feedback batch 11 item 3)
90
+ // the group the Tasks section shows it under: a stage of the workflow it ran before a switch reads as the stage that switch put it in
91
+ // (row.wfMap, batch 24 item 5), as on the page
92
+ const keys = r.ok ? (r.row.wfStages || []).map((s) => s.key) : [], M = (r.ok && r.row.wfMap) || {};
93
+ const placed = (k) => (k && !keys.includes(k) && keys.includes(M[k]) ? M[k] : k);
94
+ const sec = (tid, from) => placed(S.has(tid) ? S.get(tid) : (from && from.stage) || '');
95
+ const own = [...(F.tasks || new Map()).values()].filter((t) => t.initiative === id).map((t) => ({ ...t, stage: sec(t.id, t.from), milestone: msOf(t.id), ...pinOf(t.id) }));
96
+ const items = TI.rowsOf(w.root, new Set([id]), board).map((x) => ({ id: x.uid, board, kind: 'Task', title: x.title, state: x.status, owner: x.owner, start: x.start || null, due: x.end, store: 'item', stage: sec(x.uid), milestone: msOf(x.uid, x.milestone), ...pinOf(x.uid) }));
97
+ return own.concat(items);
98
+ }
99
+
100
+ /** answers: { <surface name>: Map id → label } → the initiatives whose surfaces name different stages. A surface with no answer for
101
+ * an id is left out of that id's comparison (it has not read it), never counted as a disagreement. */
102
+ function disagreements(answers) {
103
+ const ids = new Set();
104
+ for (const m of Object.values(answers || {})) for (const id of m.keys()) ids.add(id);
105
+ const out = [];
106
+ for (const id of ids) {
107
+ const surfaces = {};
108
+ for (const [name, m] of Object.entries(answers)) { const v = m.get(id); if (v) surfaces[name] = v; }
109
+ if (new Set(Object.values(surfaces)).size > 1) out.push({ id, surfaces });
110
+ }
111
+ return out;
112
+ }
113
+
114
+ /** Every surface's stage for the initiatives of a repository, compared (`pmos workflow check`). → { ok, checked, disagree: [{ id, surfaces }] }
115
+ * Surfaces: the Board's list of rows (the Board page and its chip), the one-initiative read (the Viewer, the stage card, `pmos workflow of`),
116
+ * `pmos initiative list`, and the notes picker and report slides. The Board's column name joins when it is one of the eight lifecycle
117
+ * words (a workflow of its own names its columns as it likes). The CI gate rung (scripts/workflow-state.js) is not a stage and is not read. */
118
+ function check(root, { ids: only } = {}) {
119
+ const boards = require('./routes-boards.js');
120
+ const OS = require('./one-stage.js');
121
+ const rowsLib = require('./initiative-rows.js');
122
+ const { w, ctx } = cliCtx(root);
123
+ if (!ctx.stateDirFor()) return { ok: false, error: 'this repository has no PMOS state folder (pmos/state, state or .pmos)' };
124
+ const was = rowsLib.setBackground(false);
125
+ try {
126
+ try { rowsLib.deriveNow(root); } catch { /* baseRows says what could not be read */ }
127
+ const pass = { ...ctx, boardsPass: new Map() };
128
+ const base = boards.baseRows(w, pass);
129
+ if (!base.ok) return { ok: false, error: base.error || 'the initiative records could not be read' };
130
+ const fr = boards.frameFor(pass, w);
131
+ const ids = base.rows.map((r) => r.id).filter((id) => !only || only.includes(id));
132
+ if (only) for (const id of only) if (!ids.includes(id)) return { ok: false, error: `no initiative ${id} on a board of this workspace` };
133
+ const board = new Map(), column = new Map();
134
+ for (const b of fr.boards) {
135
+ for (const r of boards.rowsOfBoard(fr, b, base.rows)) {
136
+ if (!ids.includes(r.id)) continue;
137
+ const a = fromRow(r);
138
+ if (a) board.set(r.id, a.label);
139
+ // a column joins when it names one of the eight steps and no PM word (Shipped, On hold, Cancelled) stands over it: a shipped
140
+ // initiative sits in its last column by design
141
+ const word = a && ['shipped', 'on-hold', 'cancelled', 'ended'].includes(a.stage);
142
+ if (!word && r.stage && OS.STEPS.some((k) => OS.LABELS[k] === r.stage) && !r.ended) column.set(r.id, r.stage);
143
+ }
144
+ }
145
+ const one = new Map();
146
+ for (const id of ids) { const r = boards.initiativeWorkflow(pass, w, id); const a = r && r.ok ? fromRow(r.row) : null; if (a) one.set(id, a.label); }
147
+ const list = new Map([...stagesOf(ctx, w, ids)].filter(([, a]) => a).map(([id, a]) => [id, a.label]));
148
+ const reader = labelReader(root, () => '');
149
+ const notes = new Map(ids.map((id) => [id, reader(id)]).filter(([, v]) => v));
150
+ const disagree = disagreements({ Board: board, 'Board column': column, 'Viewer and pmos workflow of': one, 'pmos initiative list': list, 'notes and reports': notes });
151
+ return { ok: true, checked: ids.length, disagree, stages: Object.fromEntries(ids.map((id) => [id, one.get(id) || board.get(id) || null])) };
152
+ } finally { rowsLib.setBackground(was); }
153
+ }
154
+
155
+ module.exports = { cliCtx, rowOf, fromRow, stageOf, stagesOf, labelReader, tasksOf, disagreements, check };
@@ -143,22 +143,8 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
143
143
 
144
144
  const cli = { isTTY: isTTY === undefined ? !!(process.stdin.isTTY && process.stdout.isTTY) : isTTY, env: env === undefined ? process.env : env };
145
145
  const g = { ok: true, actor: actorLib.fromCli(cli), cli };
146
- /** Every task of an initiative: its Board tasks (on any board of this workspace) and its breakdown items. */
147
- const tasksOf = (id) => {
148
- const r = rowOf(boards, ctx, w, id);
149
- const board = r.ok ? r.board.id : null;
150
- const F = boards.foldOf(ctx, w), S = F.sections || new Map(), MS = F.milestones || new Map(), PN = F.pins || new Map();
151
- const pinOf = (tid) => (PN.has(tid) ? { pinned: PN.get(tid) } : {}); // the PM's pin on the Board timeline (batch 13 item 4); unset = the rule
152
- const msOf = (tid, own) => (MS.has(tid) ? MS.get(tid) : !!own); // the PM's ◇ flag (feedback batch 11 item 3)
153
- // the group the Tasks section shows it under: a stage of the workflow it ran before a switch reads as the stage that switch put it in
154
- // (row.wfMap, batch 24 item 5), as on the page
155
- const keys = r.ok ? (r.row.wfStages || []).map((s) => s.key) : [], M = (r.ok && r.row.wfMap) || {};
156
- const placed = (k) => (k && !keys.includes(k) && keys.includes(M[k]) ? M[k] : k);
157
- const stageOf = (tid, from) => placed(S.has(tid) ? S.get(tid) : (from && from.stage) || '');
158
- const own = [...(F.tasks || new Map()).values()].filter((t) => t.initiative === id).map((t) => ({ ...t, stage: stageOf(t.id, t.from), milestone: msOf(t.id), ...pinOf(t.id) }));
159
- const items = TI.rowsOf(root, new Set([id]), board).map((x) => ({ id: x.uid, board, kind: 'Task', title: x.title, state: x.status, owner: x.owner, start: x.start || null, due: x.end, store: 'item', stage: stageOf(x.uid), milestone: msOf(x.uid, x.milestone), ...pinOf(x.uid) }));
160
- return own.concat(items);
161
- };
146
+ /** Every task of an initiative: its Board tasks and its breakdown items (lib/stage-read.js, which `pmos board` reads too). */
147
+ const tasksOf = (id) => require('./stage-read.js').tasksOf(ctx, w, id);
162
148
 
163
149
  if (verb === 'add') {
164
150
  const [id, title] = pos;
@@ -25,12 +25,22 @@ const USAGE = [
25
25
  'Without a server it reads the repository and prints the Today cards, ranked by kind (1 a gate is owed, 2 a session is',
26
26
  'waiting, 3 a step was returned to you, 4 work to check, 5 a breakdown to keep, 6 a capture, 7 a cycle review, 8 needs',
27
27
  'repair). It does not read sessions then.',
28
- 'Without a server the Cycle review and missing-anchor cards need the initiative records read, which takes time: they show',
29
- 'as pending. Add --wait to read them now (about a quarter of a second per record).',
28
+ 'Without a server it reads the initiative records first when there are up to 100. With more, the Cycle review and',
29
+ 'missing-anchor cards show as pending: add --wait to read them now (about 5 s for 500 records).',
30
30
  ];
31
31
  const BOOL = new Set(['json', 'help', 'wait']);
32
32
  const VALUE = new Set(['ws', 'root']);
33
33
 
34
+ const AUTO_READ = 100;
35
+ /** How many initiative records the repository holds (the engine's layout), or Infinity when it cannot say. */
36
+ function recordCount(root) {
37
+ try {
38
+ const loaded = require('./console-state').loadEngine();
39
+ if (!loaded.ok) return Infinity;
40
+ return fs.readdirSync(loaded.engine.layout(root).initiatives).filter((n) => n.endsWith('.md') && n !== 'README.md').length;
41
+ } catch { return Infinity; }
42
+ }
43
+
34
44
  function isDir(d) { try { return fs.statSync(d).isDirectory(); } catch { return false; } }
35
45
 
36
46
  function repoRoot(cwd) {
@@ -85,7 +95,8 @@ function print(say, out, { sessions }) {
85
95
  say(` ${c.act.label}${c.act.cli ? ' · ' + c.act.cli : ''}${c.initiative_id ? ' · ' + c.initiative_id : ''}`);
86
96
  }
87
97
  for (const b of out.banner || []) say(`! ${b.source}: ${b.error}`);
88
- if (!out.count) say(out.next ? `Nothing needs you. Next: ${out.next.label}.` : 'Nothing needs you.');
98
+ const unread = (out.banner || []).length > 0;
99
+ if (!out.count) say(unread ? 'Nothing needs you in what was read. The lines marked ! were not read.' : out.next ? `Nothing needs you. Next: ${out.next.label}.` : 'Nothing needs you.');
89
100
  if (!sessions) say('No server is running, so waiting sessions were not read.');
90
101
  }
91
102
 
@@ -125,11 +136,13 @@ async function run(argv, { say, call }) {
125
136
  }
126
137
  }
127
138
  if (!out || !out.ok) {
128
- // a local read: nothing in this process would read a background derivation, so none starts; --wait derives now
139
+ // a local read: nothing in this process would read a background derivation, so none starts. A repository of up to AUTO_READ
140
+ // records is read now (a product repository, a fresh kit): without that it stopped at "still reading the initiative records"
141
+ // (launch simulation W1, 2026-11-12). A larger one answers at once with the pending line; --wait reads it (574 records, ~5 s).
129
142
  const rowsLib = require('./initiative-rows.js');
130
143
  const was = rowsLib.setBackground(false);
131
144
  try {
132
- if (f.wait) rowsLib.deriveNow(root);
145
+ if (f.wait || recordCount(root) <= AUTO_READ) { try { rowsLib.deriveNow(root); } catch { /* the banner says what could not be read */ } }
133
146
  out = today.todayFor({ id: 'local', root }, {});
134
147
  } finally { rowsLib.setBackground(was); }
135
148
  }
@@ -351,6 +351,14 @@ function buildRange(root, { spec, whole }) {
351
351
  * ordering rule; "I cannot tell" is not, and collapsing the second into the first is exactly how a
352
352
  * shallow clone would turn every order check into a silent pass.
353
353
  */
354
+ /** The unix seconds of the commit that first added `rel`, or null when git cannot say. */
355
+ function addedDate(root, rel) {
356
+ const out = git(root, ['log', '--diff-filter=A', '--format=%ct', '--', rel]);
357
+ const lines = out ? out.split('\n').map((x) => x.trim()).filter(Boolean) : [];
358
+ const t = lines.length ? Number(lines[lines.length - 1]) : NaN;
359
+ return Number.isFinite(t) ? t : null;
360
+ }
361
+
354
362
  function firstAppearance(root, range, rel) {
355
363
  const onDisk = fs.existsSync(path.join(root, rel));
356
364
  if (!range.ok) return onDisk ? undefined : null;
@@ -685,7 +693,12 @@ function computeWorkflowDerived(id, opts) {
685
693
  // would suddenly be enforced. So the commit DATE decides whenever the range can supply it, and
686
694
  // -1 keeps its meaning for the gate's range. Same question, asked of evidence that survives both.
687
695
  const recIdx = firstAppearance(root, range, recRel);
688
- const recAt = (range.dates && typeof recIdx === 'number' && recIdx >= 0) ? range.dates[recIdx] : null;
696
+ // An EMPTY range (a branch level with main, a fresh clone, a kit repository on its trunk) gates nothing, so -1 there only means "committed
697
+ // before HEAD". It used to read every record as legacy, a record written today too, which turned the order rules off on the ladder
698
+ // (launch simulation W1, 2026-11-12). With nothing to gate, the record's own first commit dates it.
699
+ const emptyRange = range.ok && Array.isArray(range.shas) && range.shas.length === 0;
700
+ const addedAt = (recIdx === -1 && emptyRange) ? addedDate(root, recRel) : null;
701
+ const recAt = (range.dates && typeof recIdx === 'number' && recIdx >= 0) ? range.dates[recIdx] : addedAt;
689
702
  /*
690
703
  * `reconstructed_from` — the merge date of work whose record was written afterwards.
691
704
  *
@@ -698,7 +711,7 @@ function computeWorkflowDerived(id, opts) {
698
711
  * genuinely skipped the loop still reports blocked, which is the point of writing it down.
699
712
  */
700
713
  const recon = String(fm.reconstructed_from || '').trim().slice(0, 10);
701
- const legacy = recIdx === -1 ? true
714
+ const legacy = (recIdx === -1 && !addedAt) ? true
702
715
  : /^\d{4}-\d{2}-\d{2}$/.test(recon) ? recon < ENFORCED_FROM
703
716
  : recAt ? new Date(recAt * 1000).toISOString().slice(0, 10) < ENFORCED_FROM
704
717
  : String(fm.timestamp || generatedAt(fm.generated) || '').slice(0, 10) < ENFORCED_FROM; // fallback — see ENFORCED_FROM; D74: OKF v0.2 `generated.at` stands in for `timestamp`
@@ -1735,7 +1748,11 @@ function renderLadder(w) {
1735
1748
  const head = `${c(1, w.id)} · ${w.lane}${w.laneKnown ? '' : c(33, ' (unknown lane — enforcing feature)')} · ${w.anchor ? brief(w.anchor, 46) : c(31, 'unanchored')}`;
1736
1749
  out.push('');
1737
1750
  out.push(` ${head}`);
1738
- out.push(` ${c(90, 'stage')} ${c(1, w.stage)}${w.legacy ? c(33, ` legacy — record predates ${w.enforced_from}, order rules report but do not fail`) : ''}`);
1751
+ // The gate rung, not the initiative's stage: the stage the pages and `pmos initiative list` show is the Board's one stage (PM moves,
1752
+ // Jira, dated plan items, then these files; workspace/lib/stage-read.js). Printing the rung as "stage" gave one record four stages
1753
+ // (launch simulation W1, 2026-11-12). The engine never reads the Board (X29), so it names the rung and says where the stage is.
1754
+ out.push(` ${c(90, 'gate')} ${c(1, w.stage)}${w.legacy ? c(33, ` legacy — record predates ${w.enforced_from}, order rules report but do not fail`) : ''}`);
1755
+ out.push(` ${c(90, 'stage')} ${c(90, `pmos workflow of ${w.id} — the stage every page shows`)}`);
1739
1756
  out.push(` ${c(90, '─'.repeat(78))}`);
1740
1757
  for (const s of w.steps) {
1741
1758
  const label = s.label.padEnd(11);
@@ -1901,7 +1918,7 @@ function main(argv) {
1901
1918
  }
1902
1919
  if (w.legacy) process.stdout.write(`ℹ️ '${w.id}' is LEGACY (record predates ${ENFORCED_FROM}) — order rules reported, not enforced.\n`);
1903
1920
  if (w.range.error) process.stdout.write(`⚠️ order checks degraded — ${w.range.error}\n`);
1904
- process.stdout.write(`✅ workflow gate PASSED — '${w.id}' (${w.lane}) at stage ${w.stage}.\n`);
1921
+ process.stdout.write(`✅ workflow gate PASSED — '${w.id}' (${w.lane}) at gate rung ${w.stage}.\n`);
1905
1922
  return 0;
1906
1923
  }
1907
1924
 
@@ -42,9 +42,9 @@ const { repoScript } = require('./repo-script.js');
42
42
  const WF = require(repoScript('workflows.js'));
43
43
  const stateRoot = require('./state-root.js');
44
44
 
45
- const COMMANDS = { workflow: ['list', 'show', 'draft', 'show-draft', 'judge', 'of', 'move', 'switch'] };
45
+ const COMMANDS = { workflow: ['list', 'show', 'draft', 'show-draft', 'judge', 'of', 'move', 'switch', 'check'] };
46
46
  const USAGE = [
47
- 'usage: pmos workflow list|show|draft|show-draft|judge|of|move|switch — the workflows each kind of initiative goes through (D99)',
47
+ 'usage: pmos workflow list|show|draft|show-draft|judge|of|move|switch|check — the workflows each kind of initiative goes through (D99)',
48
48
  ' pmos workflow list every workflow the PM can pick: this repository\'s and the ones saved in Settings',
49
49
  ' pmos workflow show <id> one workflow, its stages numbered',
50
50
  ' The workflows are not files in the repository: never search the files for one, and never use a lane (feature, chore…) instead.',
@@ -59,6 +59,8 @@ const USAGE = [
59
59
  ' Move the initiative to a stage of its own workflow, when the PM asks. The stage card and the Board show it at once.',
60
60
  ' pmos workflow switch <initiative> --to <workflow id> [--stage <key|name>] [--why <text>]',
61
61
  ' Put the initiative on another workflow, when the PM asks. Without --stage it lands where the Board\'s switch puts it.',
62
+ ' pmos workflow check [<initiative>] every surface\'s stage (Board, Viewer, initiative list, notes and reports) compared;',
63
+ ' exits 1 and names the surfaces when two of them show different stages for one initiative',
62
64
  ' These are the initiative\'s workflow stages. They are not task stages: a task\'s only stage is its state (To do, In progress,',
63
65
  ' Done, Won\'t do, Archived), and moving the initiative never changes a task.',
64
66
  ' every command: [--json] [--root <dir>]. Nothing is sent.',
@@ -192,6 +194,20 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
192
194
  else say(`✓ drafted ${r.draft.name} with ${r.draft.stages.length} stages. The Workflows page shows it beside the chat; the PM presses Create workflow. Nothing was sent.`);
193
195
  return 0;
194
196
  }
197
+ if (verb === 'check') {
198
+ if (pos.length > 1) { say('usage: pmos workflow check [<initiative>]'); return 2; }
199
+ const r = require('./stage-read.js').check(root, pos.length ? { ids: [pos[0]] } : {});
200
+ if (!r.ok) return fail(r.error);
201
+ if (json) { say(JSON.stringify(r)); return r.disagree.length ? 1 : 0; }
202
+ if (!r.disagree.length) {
203
+ say(`✓ every surface shows the same stage for ${r.checked === 1 ? 'the initiative' : 'all ' + r.checked + ' initiatives'}.`);
204
+ if (pos.length && r.stages[pos[0]]) say(` ${pos[0]} · ${r.stages[pos[0]]}`);
205
+ return 0;
206
+ }
207
+ say(`✗ ${r.disagree.length} of ${r.checked} initiatives show different stages on different surfaces:`);
208
+ for (const d of r.disagree) say(` ${d.id} · ` + Object.entries(d.surfaces).map(([k, v]) => `${k}: ${v}`).join(' · '));
209
+ return 1;
210
+ }
195
211
  if (verb === 'of' || verb === 'move' || verb === 'switch') return onInitiative(verb, { pos, flags, json, say, fail, root, stateDir, actor, others });
196
212
  // judge
197
213
  if (!flags.board || !flags.id || !flags.stage) { say('usage: pmos workflow judge --board <id> --id <initiative> --stage <key> --runs yes|no|unsure --why <reason> [--cite <where>]'); return 2; }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.563.0",
3
+ "version": "0.565.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.563.0",
9
+ "version": "0.565.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.563.0",
3
+ "version": "0.565.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",
@@ -0,0 +1,5 @@
1
+ {
2
+ "_comment": "launch simulation W1 (2026-11-12): one stage on every surface (Board, Viewer, initiative list, notes and reports) and pmos workflow check; pmos board lists tasks; the ladder names its gate rung; an empty range dates a record by its own commit.",
3
+ "modules": ["stage-everywhere.test.js"],
4
+ "seconds": { "stage-everywhere.test.js": 3 }
5
+ }