create-pmos 0.817.0 → 0.819.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.817.0",
3
+ "version": "0.819.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": {
@@ -34,8 +34,8 @@
34
34
  ],
35
35
  "pmosChanges": [
36
36
  {
37
- "v": "0.817.0",
38
- "at": "2026-11-25T08:16:43.538Z",
37
+ "v": "0.819.0",
38
+ "at": "2026-11-25T08:28:20.856Z",
39
39
  "f": 4,
40
40
  "prs": [
41
41
  {
@@ -53,6 +53,54 @@
53
53
  "open": "/premium-board.html"
54
54
  },
55
55
  "i": "approver-memory"
56
+ },
57
+ {
58
+ "n": 1867,
59
+ "t": "Each report draft in each reader's language",
60
+ "s": "Each report draft in each reader's language",
61
+ "k": "new",
62
+ "i": "report-reader-language",
63
+ "try": {
64
+ "steps": [
65
+ "On Today, ask the chat: Dita reads the weekly report in Indonesian.",
66
+ "Open that report from Today, press Redraft, then open ⋯ and press Also in Indonesian.",
67
+ "Compare a number and an initiative id with the original."
68
+ ],
69
+ "see": "The copy opens in the Viewer, says it is a translation for Dita, and every number and id matches the original.",
70
+ "open": "/today.html"
71
+ }
72
+ },
73
+ {
74
+ "n": 1868,
75
+ "t": "The factory numbers snapshot per station (job #1862)",
76
+ "s": "The factory numbers snapshot per station (job #1862)",
77
+ "k": "new",
78
+ "h": "The factory numbers snapshot per station (job #1862)",
79
+ "try": {
80
+ "steps": [
81
+ "On Today, open Ask PMOS and ask: what did each factory station make this week?",
82
+ "Open Work and compare the initiatives it names as waiting with their rows."
83
+ ],
84
+ "see": "PMOS answers per station (Intake, Shape, Plan, Track, Evaluate, Check, You) with what waits, what it made this week, its PMOS time and what you undid; tokens and money say not recorded yet.",
85
+ "open": "/today.html"
86
+ },
87
+ "i": "factory-floor-snapshot"
88
+ },
89
+ {
90
+ "n": 1875,
91
+ "t": "I have N minutes — one pick in Ctrl K, the chat and pmos pick (job #1873)",
92
+ "s": "I have N minutes — one pick in Ctrl K, the chat and pmos pick (job #1873)",
93
+ "k": "new",
94
+ "i": "time-box-pick-chat",
95
+ "try": {
96
+ "steps": [
97
+ "On Today, press Ctrl K and type: I have 30 minutes",
98
+ "Read the first row, then press it",
99
+ "On Today, ask the chat: I have 15 minutes, what should I do?"
100
+ ],
101
+ "see": "The first row names one thing from Your move or Waiting on others that fits in the time, about how long it takes and how many others it unblocks. Pressing it opens that item. The chat gives the same…",
102
+ "open": "/today.html"
103
+ }
56
104
  }
57
105
  ]
58
106
  },
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@66f8f6661
1
+ kernel-source: pmos@106b1695f
2
2
  assembled: 2026-11-25
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-25T08:16:39Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T08:28:18Z"}
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-25T08:16:39Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T08:28:18Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -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-25T08:16:39Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T08:28:18Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,7 +1,7 @@
1
1
  [
2
2
  {
3
- "v": "0.817.0",
4
- "at": "2026-11-25T08:16:43.538Z",
3
+ "v": "0.819.0",
4
+ "at": "2026-11-25T08:28:20.856Z",
5
5
  "f": 4,
6
6
  "prs": [
7
7
  {
@@ -19,6 +19,54 @@
19
19
  "open": "/premium-board.html"
20
20
  },
21
21
  "i": "approver-memory"
22
+ },
23
+ {
24
+ "n": 1867,
25
+ "t": "Each report draft in each reader's language",
26
+ "s": "Each report draft in each reader's language",
27
+ "k": "new",
28
+ "i": "report-reader-language",
29
+ "try": {
30
+ "steps": [
31
+ "On Today, ask the chat: Dita reads the weekly report in Indonesian.",
32
+ "Open that report from Today, press Redraft, then open ⋯ and press Also in Indonesian.",
33
+ "Compare a number and an initiative id with the original."
34
+ ],
35
+ "see": "The copy opens in the Viewer, says it is a translation for Dita, and every number and id matches the original.",
36
+ "open": "/today.html"
37
+ }
38
+ },
39
+ {
40
+ "n": 1868,
41
+ "t": "The factory numbers snapshot per station (job #1862)",
42
+ "s": "The factory numbers snapshot per station (job #1862)",
43
+ "k": "new",
44
+ "h": "The factory numbers snapshot per station (job #1862)",
45
+ "try": {
46
+ "steps": [
47
+ "On Today, open Ask PMOS and ask: what did each factory station make this week?",
48
+ "Open Work and compare the initiatives it names as waiting with their rows."
49
+ ],
50
+ "see": "PMOS answers per station (Intake, Shape, Plan, Track, Evaluate, Check, You) with what waits, what it made this week, its PMOS time and what you undid; tokens and money say not recorded yet.",
51
+ "open": "/today.html"
52
+ },
53
+ "i": "factory-floor-snapshot"
54
+ },
55
+ {
56
+ "n": 1875,
57
+ "t": "I have N minutes — one pick in Ctrl K, the chat and pmos pick (job #1873)",
58
+ "s": "I have N minutes — one pick in Ctrl K, the chat and pmos pick (job #1873)",
59
+ "k": "new",
60
+ "i": "time-box-pick-chat",
61
+ "try": {
62
+ "steps": [
63
+ "On Today, press Ctrl K and type: I have 30 minutes",
64
+ "Read the first row, then press it",
65
+ "On Today, ask the chat: I have 15 minutes, what should I do?"
66
+ ],
67
+ "see": "The first row names one thing from Your move or Waiting on others that fits in the time, about how long it takes and how many others it unblocks. Pressing it opens that item. The chat gives the same…",
68
+ "open": "/today.html"
69
+ }
22
70
  }
23
71
  ]
24
72
  },
@@ -117,6 +117,7 @@ A loop never sends a message, moves a Jira ticket, merges into a product reposit
117
117
  | [You decided this before](claude-proposes.md) | You add an initiative that repeats an earlier decision | `DECISIONS.md`, the decision records, the PM journal, `planning/out-of-scope/` and the initiative records | The initiative's ✦ | `pmos ai off past-repeat` |
118
118
  | [✦ drafts](claude-proposes.md#drafts-from-a-) | You press ✓ on a ✦ that offers a draft: a line of the Overview, a program's For or Goal, the documents a gate needs, a goal or initiatives from the strategy, an outcome verdict or a goal's name. One short run for each press. | The records in the product's folder. It writes nothing and sends nothing. | The row you pressed: "PMOS is drafting it", then the draft | Press ✕ on the draft. Nothing is kept until you keep it. |
119
119
  | [Report readers](claude-proposes.md) | A report draft is written | The draft, read as the CFO, the engineering lead and the sceptic | The ✦ of each initiative the question quotes | `pmos ai off report-readers` |
120
+ | [Report translations](reports.md) | A report draft is written and its definition names `languages:` | The draft | A translated copy beside the draft, written only when every number and name is unchanged | `pmos ai off report-translate` |
120
121
  | [Stuck work](claude-proposes.md) | Each time you open an initiative's ✦. No run, no model. | The tasks' own state days, and the last change of each Jira ticket | "Stuck" under the initiative's ✦: a drafted note to the owner, or Park | Press ✕ on the step. Nothing is sent: a note waits in the Outbox. |
121
122
  | [Initiative descriptions](claude-proposes.md) | Once a day. At most 3 drafts a day for each product. | The PRD's first Problem or Why paragraph, or the record's own first paragraph | "Description" under the initiative's ✦ | `pmos ai off descriptions`. `PMOS_DESCRIPTIONS=off` |
122
123
  | [Expected outcomes](claude-proposes.md) | Once a day. At most 3 drafts a day for each product. When a check date passes: the verdict, from the goal's reading or one short run. | The PRD's success criteria, or the anchored key result. For a verdict: the goal's reading, or the lines the run cites | "Expected outcome" under the initiative's ✦. A verdict is recorded with Undo. Your move when PMOS cannot tell. | `pmos ai off outcomes`. `PMOS_OUTCOMES=off` |
@@ -167,7 +168,7 @@ When you ask an agent session to do a piece of work, it can finish it, including
167
168
  - `pmos ai log [<job>]`: the last audit lines. Each dropped proposal shows why.
168
169
  - `pmos ai off [<job>]` and `pmos ai on [<job>]`: turn every AI job, or one job, off or on. `PMOS_AI=off` in the environment wins over the setting.
169
170
 
170
- The AI jobs are `past-repeat`, `report-readers`, `decision-memory`, `outcomes`, `descriptions`, `drift`, `rehearse`, `next-prompt`, `sharpen-prompt`, `idle-lab` and `live-round` (`pmos ai off live-round` stops new live rounds; one that runs ends by itself). The switch also covers each job in the queue by its queue name: `schedules`, `proactive`, `prepare`, `day`, `refresh`, `reports`, `meeting-prewarm`, `driver`, `goal-loops`, `finder`, `coredocs`, `milestones`, `propose`, `grill`, `metric-drafts`, `impact`, `metric-reads`, `forecast`, `report-design`, `report-structure`, `team`, `scan` and `idle-lab`. `pmos ai off` with no job stops all of them. Git sync uses no model, so the switch does not stop it. A background run cannot change the switch.
171
+ The AI jobs are `past-repeat`, `report-readers`, `report-translate`, `decision-memory`, `outcomes`, `descriptions`, `drift`, `rehearse`, `next-prompt`, `sharpen-prompt`, `idle-lab` and `live-round` (`pmos ai off live-round` stops new live rounds; one that runs ends by itself). The switch also covers each job in the queue by its queue name: `schedules`, `proactive`, `prepare`, `day`, `refresh`, `reports`, `meeting-prewarm`, `driver`, `goal-loops`, `finder`, `coredocs`, `milestones`, `propose`, `grill`, `metric-drafts`, `impact`, `metric-reads`, `forecast`, `report-design`, `report-structure`, `team`, `scan` and `idle-lab`. `pmos ai off` with no job stops all of them. Git sync uses no model, so the switch does not stop it. A background run cannot change the switch.
171
172
 
172
173
  ## The team of role agents
173
174
 
@@ -158,6 +158,18 @@ The session commands must name who read or wrote. In a workspace session that is
158
158
 
159
159
  Nothing here writes a record, sends anything or calls a model.
160
160
 
161
+ ### pmos pick
162
+
163
+ `pmos pick --minutes 30` picks the one ask from Your move and Waiting on others that fits in 30 minutes and unblocks the most others. It prints one line: what to do, about how long it takes, and why. When nothing fits, it names the shortest ask and its time. The chat can run it when you tell it how long you have.
164
+
165
+ ```
166
+ pmos pick --minutes 30 # the repository you are in
167
+ pmos pick --minutes 15 --json # the pick as JSON
168
+ pmos pick --minutes 60 --root <dir> # read a repository folder without a server
169
+ ```
170
+
171
+ It calls no model, sends nothing and changes nothing. It exits with 0 when it read the asks, 1 when it could not read them, and 2 when `--minutes` is missing.
172
+
161
173
  ## PMOS's proposals and checks
162
174
 
163
175
  ### pmos propose: the one ✦ on each initiative
@@ -1032,6 +1044,8 @@ pmos report issue biweekly 2026-10-16
1032
1044
 
1033
1045
  `pmos report finder` shows the report finder setting, or changes it.
1034
1046
 
1047
+ `pmos report language <cadence> "<Language>[ for <reader>]"` adds a reader who reads the report in another language. After each draft, PMOS writes a translated copy beside it with every number and name unchanged. Add `--off` to remove the language. With no language, the command lists the languages. Nothing is sent.
1048
+
1035
1049
  `pmos report library` writes one page with every slide layout of the report library, filled with placeholder words. Open it in a browser to see the layouts a report can use. Add `--out <file>` to choose the file. `pmos report library --template <id>` draws one template with placeholder words.
1036
1050
 
1037
1051
  Every command accepts `--root <dir>` to name the repository. `draft` and `list` also accept `--json`.
@@ -310,6 +310,8 @@ When the words you type in Search point clearly to one thing, the first row is t
310
310
 
311
311
  When you type a question, such as "why do some customers still use a spreadsheet instead of the app?", and no one sentence holds all your words, the first row says "Finding an answer in your work…". After a few seconds it shows a short answer, written only from passages of your own files, and the names of the files it used. Press Enter on the answer to open the first of them. To go deeper, pick "Ask PMOS" in the next row. When your files do not answer the question, the row goes away and the matches stay.
312
312
 
313
+ When you say how long you have, such as "I have 30 minutes" or "half an hour", the first row is one pick: the ask from Your move or Waiting on others that fits in that time and unblocks the most others, about how long it takes, and why. Press Enter on it to open its initiative, or Today when it has none. PMOS counts a fixed time for each kind of ask (2 minutes to name an owner or send a nudge, 5 for a session that asks, 10 for a gate, 15 for work to check, 30 for a cycle review). When nothing fits, the row names the shortest ask and its time. The chat can give the same pick when you tell it "I have 30 minutes". PMOS calls no model to pick, and it sends and changes nothing.
314
+
313
315
  ## Ask about what you point at
314
316
 
315
317
  Right-click any part of a page to ask PMOS about it. On a phone, press and hold it. A small Ask card opens next to it.
@@ -352,6 +352,14 @@ If a block is off track or at risk and has no reason, the script stops and write
352
352
 
353
353
  The definition file tells the script and the agent what the report is for. For PMOS itself it is `planning/reports/definitions/biweekly.md`. In a kit repository it is `pmos/state/reports/definitions/biweekly.md`. Its frontmatter gives the `cadence`, the `audience` and the `sections`. If the definition names no audience, Needs your call stays empty.
354
354
 
355
+ ### In each reader's language
356
+
357
+ A definition can name readers who read the report in another language: `languages: "Indonesian for Dita; Japanese"`. Ask PMOS in the chat, or run `pmos report language <cadence> "Indonesian for Dita"`. Add `--off` to stop one language.
358
+
359
+ After each draft, PMOS writes one translated copy per language beside the draft, for example `2026-11-20.id.md`. The copy opens with one line that says it is a translation, for whom, and that PMOS checked the numbers and names. PMOS writes a copy only when every number, initiative id, note, link and acronym of the original is in it. If one is missing, PMOS writes no copy and the server log says why. A draft whose text did not change is not translated again.
360
+
361
+ To read a copy, open the report and press **⋯ › Also in Indonesian**. The copy is not a cycle, so it has no Issue. Nothing is sent: share the copy yourself. `pmos ai off report-translate` stops the translations.
362
+
355
363
  ### Notes
356
364
 
357
365
  Each block has a note between two markers:
@@ -143,7 +143,7 @@ function create(deps) {
143
143
  session = deps.spawn({
144
144
  name: `Driver · ${kind} ${group.target.id}`, ws: w.id, origin: `drive:${kind}:${group.target.id}`, initialInput: prompt + '\r',
145
145
  initiative: kind === 'initiative' ? group.target.id : undefined,
146
- onDone: (r) => endRun(file, runId, group.target, r, group.wakes),
146
+ onDone: (r) => endRun(file, runId, group.target, r, group.wakes, w),
147
147
  });
148
148
  } catch (e) { warn('driver run', e); }
149
149
  D.append(file, { ev: 'run-start', run: runId, target: group.target, board, wakes: group.wakes, session: session ? session.id : null }, { now });
@@ -166,7 +166,7 @@ function create(deps) {
166
166
  // The task ledger is bookkeeping for the restart: a failed write is reported and never stops or fails a run.
167
167
  function taskLedger(fn) { try { fn(); } catch (e) { warn('orchestrator task ledger', e); } }
168
168
 
169
- function endRun(file, runId, target, r, wakeKeys) {
169
+ function endRun(file, runId, target, r, wakeKeys, w) {
170
170
  active.delete(runId);
171
171
  const res = (r && r.result) || {};
172
172
  const ok = !!(r && !r.timedOut && !r.stopped && r.code === 0 && res.ok && !res.isError);
@@ -178,6 +178,8 @@ function create(deps) {
178
178
  agent_run: agentRun(runId, target, ok) });
179
179
  } catch (e) { warn('driver run end', e); }
180
180
  taskLedger(() => tasksEnd(path.dirname(file), wakeKeys, { ok, reason }));
181
+ // factory-floor-snapshot: the factory's numbers are saved after each run, so the Factory page reads one file (lib/factory-floor.js)
182
+ if (w && w.root) { try { require('./factory-floor.js').save(w.root, { stateDir: path.dirname(file), runtimeDir: deps.runtimeDir || null, ws: w.id, name: w.name || w.id }); } catch (e) { warn('[factory-floor] snapshot', e); } }
181
183
  }
182
184
 
183
185
  /* `sweepNow` (Refresh now, data-refresh-settings R8) runs the unblock sweep at once, inside or outside the window. */
@@ -1,5 +1,10 @@
1
1
  'use strict';
2
2
  /* factory-cli.js — `pmos factory`: one view of everything PMOS changed by itself (initiative one-change-record-no-source-no-auto).
3
+ *
4
+ * pmos factory [--json] [--root <dir>]
5
+ * The factory floor (initiative factory-floor-snapshot): per station (Intake, Shape, Plan, Track, Evaluate, Check, You) what waits now,
6
+ * what it made in the last 7 days, PMOS minutes and how many changes were undone (lib/factory-floor.js). It folds the ledgers fresh;
7
+ * the Factory page reads the copy the Driver saves after each run. --json prints the snapshot.
3
8
  *
4
9
  * pmos factory today [--days N] [--json] [--unsourced] [--root <dir>]
5
10
  * Per line (product, project, SDLC) and station: changes, applied by PMOS, kept, undone, ignored, applied with no source, and
@@ -13,6 +18,7 @@ const CR = require('./change-record.js');
13
18
 
14
19
  const COMMANDS = { factory: ['today'] };
15
20
  const USAGE = [
21
+ 'usage: pmos factory [--json] — per station: what waits, what it made in 7 days, PMOS minutes and what was undone',
16
22
  'usage: pmos factory today [--days N] [--json] [--unsourced] — everything PMOS changed by itself, in one record',
17
23
  ' pmos factory today per line and station: changes, applied, kept, undone, ignored, with no source, runs (today)',
18
24
  ' pmos factory today --days 7 the same over the last 7 days',
@@ -27,7 +33,8 @@ const num = (v, n = 6) => String(v).padStart(n);
27
33
  function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), env = process.env, now = Date.now(), runtimeDir } = {}) {
28
34
  const args = argv[0] === 'factory' ? argv.slice(1) : argv.slice();
29
35
  const verb = args[0];
30
- if (!verb || ['help', '--help', '-h'].includes(verb)) { for (const l of USAGE) say(l); return verb ? 0 : 2; }
36
+ if (['help', '--help', '-h'].includes(verb)) { for (const l of USAGE) say(l); return 0; }
37
+ if (!verb || verb.startsWith('--')) return floor(args, { say, cwd, env, now, runtimeDir });
31
38
  if (!COMMANDS.factory.includes(verb)) { say(`unknown factory command "${verb}" — one of ${COMMANDS.factory.join(', ')}`); return 2; }
32
39
  const d = flag(args, 'days');
33
40
  const days = d === undefined ? 1 : Number(d);
@@ -55,4 +62,21 @@ function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), env = pro
55
62
  return 0;
56
63
  }
57
64
 
65
+ /** `pmos factory [--json]`: the factory floor of this repository, folded now (lib/factory-floor.js). */
66
+ function floor(args, { say, cwd, env, now, runtimeDir }) {
67
+ const FF = require('./factory-floor.js');
68
+ const root = typeof flag(args, 'root') === 'string' ? path.resolve(cwd, flag(args, 'root')) : repoRoot(cwd);
69
+ let rt = runtimeDir;
70
+ if (rt === undefined) { try { rt = require('./state-root.js').defaultRoot({ env }); } catch { rt = null; } }
71
+ const S = FF.build(root, { runtimeDir: rt, now });
72
+ if (!S) { say('✗ this repository has no PMOS state folder (pmos/state, state or .pmos)'); return 1; }
73
+ if (flag(args, 'json')) { say(JSON.stringify({ ok: true, ...S })); return 0; }
74
+ say(`The factory, last ${S.days} days: ${S.runs} Driver ${S.runs === 1 ? 'run' : 'runs'}`);
75
+ say(' ' + pad('Station', 10) + ['waiting', 'made', 'undone', 'minutes'].map((h) => h.padStart(9)).join(''));
76
+ for (const s of S.stations) say(' ' + pad(s.name, 10) + [s.waiting, s.made, s.undone, s.minutes].map((v) => num(v, 9)).join(''));
77
+ if (S.unplaced.made || S.unplaced.minutes) say(` not placed: ${S.unplaced.made} made, ${S.unplaced.minutes} minutes`);
78
+ say(` tokens and money: ${FF.NOT_RECORDED}`);
79
+ return 0;
80
+ }
81
+
58
82
  module.exports = { run, COMMANDS, USAGE };
@@ -0,0 +1,245 @@
1
+ 'use strict';
2
+ /* factory-floor.js — the factory's numbers per product and per station, saved ahead so the Factory page opens in 200 ms or less
3
+ * (initiative factory-floor-snapshot, slice B of the Factory page; brief agreed by the PM 2026-11-25).
4
+ *
5
+ * THE MODEL (keep the two apart): the work is what gets made (goals, programs, initiatives, their breakdown); the factory is who makes it.
6
+ * PMOS's stations, in flow order: Intake (asks become initiatives), Shape (problem, evidence, assumptions, PRD), Plan (milestones, tasks,
7
+ * owners, dates), Track (tracker, follow-ups, slips, moves), Evaluate (outcome reading, lessons), Check (PMOS checking its own work) and
8
+ * You (only what no record can decide).
9
+ *
10
+ * STATIONS · WHAT_STATION the stations and the Driver proposal kinds each one makes
11
+ * stationOfJob(job) PURE → a station key | null a change-record job (`driver:<what>`, `propose:<group>`, `ai:<role>`, `outbox`)
12
+ * stationOfCode(code) PURE → a station key | null a Driver blocker code: the station the item waits at
13
+ * compute(input, { now, days, ws, name }) PURE → the snapshot (below). input: read(root, …)
14
+ * read(root, { runtimeDir }) → the ledgers of one repository; no write
15
+ * build(root, { runtimeDir, now, ws, name }) → compute(read(root)) for one repository
16
+ * fileOf(stateDir) → <state folder>/factory-floor.json
17
+ * save(root, { … }) → { ok, file, snapshot } | { ok: false, error } THE ONLY WRITER of the snapshot
18
+ * load(root) → the saved snapshot | null reads one file, folds nothing
19
+ * ageMinutes(root, now) → whole minutes since the snapshot was saved, or -1 (the health number)
20
+ *
21
+ * THE SNAPSHOT { v: 1, at, ws, name, days, from, stations: [{ key, name, waiting, made, undone, minutes, items }], unplaced: { made, minutes },
22
+ * runs, tokens: null, money: null, usage: 'not recorded yet' }
23
+ * waiting what waits at the station now. Intake to Evaluate: the initiatives and Work tasks whose agent blocker of the latest sweep day
24
+ * belongs to it (one per target). Check: the Driver drafts of ended runs the Checker has not graded yet. You: the open sign-offs
25
+ * and the Driver drafts that have waited on the PM for a day (pm-open).
26
+ * made what the station made in the last `days` days, whatever happened to it next (one row per change, lib/change-record.js, so a change
27
+ * PMOS applied by itself is counted once), plus its background runs (tracker reads, outcome runs, lessons, milestone reviews).
28
+ * Check: the Checker's verdicts. You: sign-offs answered and Driver drafts the PM decided.
29
+ * undone of what it made, how many were undone.
30
+ * minutes PMOS minutes of the Driver's runs that ended in the window (run-start to run-end), split evenly over the stations of what each
31
+ * run filed; a run that filed nothing counts for the station of the blocker that woke it; else it is unplaced.
32
+ * items up to MAX_ITEMS waiting items: { kind, id, title, code, text }, what each one waits on.
33
+ * tokens and money stay null ("not recorded yet") until each run records its usage (a later slice). An honest gap, never a guess.
34
+ *
35
+ * Every log line carries [factory-floor]. Nothing here sends anything, and the factory graph never writes it (D65): the server writes it
36
+ * after a Driver run. */
37
+ const fs = require('fs');
38
+ const path = require('path');
39
+
40
+ const FILE = 'factory-floor.json';
41
+ const DAY = 86400000;
42
+ const DAYS = 7;
43
+ const MAX_ITEMS = 50;
44
+ const LOG = '[factory-floor]';
45
+ const NOT_RECORDED = 'not recorded yet';
46
+ const STATIONS = Object.freeze([
47
+ { key: 'intake', name: 'Intake' }, { key: 'shape', name: 'Shape' }, { key: 'plan', name: 'Plan' }, { key: 'track', name: 'Track' },
48
+ { key: 'evaluate', name: 'Evaluate' }, { key: 'check', name: 'Check' }, { key: 'you', name: 'You' },
49
+ ]);
50
+ // The brief's map of Driver proposal kinds. `note` is a remark, not a made thing: an initiative note is Shape's, a Work task note is Track's.
51
+ const WHAT_STATION = Object.freeze({
52
+ overlap: 'intake',
53
+ problem: 'shape', evidence: 'shape', assumption: 'shape', doc: 'shape', artefact: 'shape',
54
+ sizing: 'plan', stakeholders: 'plan', 'next-step': 'plan',
55
+ 'follow-up': 'track', move: 'track',
56
+ });
57
+ // The ✦ groups (lib/proposals.js GROUPS) and the rest of the change record.
58
+ const GROUP_STATION = Object.freeze({ found: 'intake', description: 'shape', dates: 'plan', status: 'track', names: 'track', links: 'track', tidy: 'track',
59
+ default: 'track', ask: 'track', outcome: 'evaluate' });
60
+ // The background runs that make something of their own (lib/bg-queue.js JOBS): tracker reads, outcome runs, lessons, milestone reviews.
61
+ const RUN_STATION = Object.freeze({ refresh: 'track', outcomes: 'evaluate', impact: 'evaluate', 'metric-reads': 'evaluate', improve: 'evaluate', milestones: 'plan' });
62
+ // The Driver's blocker codes (lib/driver.js detect, lib/line-driver.js blockerOf): the station each waiting item stands at.
63
+ const CODE_STATION = Object.freeze({
64
+ 'no-anchor': 'intake',
65
+ 'no-problem': 'shape', 'no-evidence': 'shape', 'no-prd': 'shape', 'no-done-criteria': 'shape', 'doc-due': 'shape', 'doc-stale': 'shape',
66
+ 'work-no-next-step': 'plan',
67
+ 'no-ticket-movement': 'track', 'ticket-blocked': 'track', stalled: 'track', 'work-overdue': 'track', 'work-waiting': 'track', 'work-untouched': 'track',
68
+ 'exit-missing': 'track',
69
+ 'check-by-passed': 'evaluate', 'kill-tripped': 'evaluate',
70
+ });
71
+ const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
72
+ const ms = (iso) => { const t = Date.parse(iso || ''); return Number.isFinite(t) ? t : null; };
73
+ const one = (s, n) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
74
+
75
+ function stationOfJob(job, { kind } = {}) {
76
+ const [k, name = ''] = String(job || '').split(':');
77
+ if (k === 'driver') return name === 'note' ? (kind === 'work' ? 'track' : 'shape') : WHAT_STATION[name] || null;
78
+ if (k === 'propose') return GROUP_STATION[name] || null;
79
+ if (k === 'ai') return name === 'improve' ? 'evaluate' : null;
80
+ if (k === 'outbox') return 'track';
81
+ return null;
82
+ }
83
+ const stationOfCode = (code) => CODE_STATION[String(code || '')] || null;
84
+
85
+ /* ── the fold ── */
86
+ function compute(input = {}, { now = Date.now(), days = DAYS, ws = null, name = null } = {}) {
87
+ const D = require('./driver.js');
88
+ const CR = require('./change-record.js');
89
+ const from = now - days * DAY;
90
+ const inWin = (at) => { const t = ms(at); return t != null && t >= from && t <= now + 60000; };
91
+ const st = new Map(STATIONS.map((s) => [s.key, { key: s.key, name: s.name, waiting: 0, made: 0, undone: 0, minutes: 0, items: [], _targets: new Set() }]));
92
+ const unplaced = { made: 0, minutes: 0 };
93
+ const wait = (key, item) => {
94
+ const s = st.get(key);
95
+ const tk = `${item.kind}:${item.id}`;
96
+ if (s._targets.has(tk)) return;
97
+ s._targets.add(tk); s.waiting++;
98
+ if (s.items.length < MAX_ITEMS) s.items.push(item);
99
+ };
100
+ const driverLines = Array.isArray(input.driver) ? input.driver : [];
101
+ const state = D.fold(driverLines);
102
+
103
+ // MADE and UNDONE: one row per change (lib/change-record.js), placed by its job
104
+ const { rows } = CR.rows(input, { now });
105
+ for (const r of rows) {
106
+ if (!inWin(r.at)) continue;
107
+ const dp = r.ref ? state.proposals.get(r.ref) : null;
108
+ const key = stationOfJob(r.job, { kind: dp ? dp.target.kind : 'initiative' });
109
+ if (!key) { unplaced.made++; continue; }
110
+ const s = st.get(key);
111
+ s.made++;
112
+ if (r.state === 'undone') s.undone++;
113
+ }
114
+ for (const l of Array.isArray(input.bgQueue) ? input.bgQueue : []) {
115
+ if (!isObj(l) || l.kind !== 'done' || !inWin(l.at) || (ws && l.ws && l.ws !== ws)) continue;
116
+ const key = RUN_STATION[String(l.job || '')];
117
+ if (key) st.get(key).made++;
118
+ }
119
+
120
+ // WAITING at a working station: the agent blockers of the latest sweep day, one per target
121
+ let lastDay = null;
122
+ for (const b of state.blockers) if (b.owner === 'agent' && (!lastDay || b.day > lastDay)) lastDay = b.day;
123
+ for (const b of state.blockers) {
124
+ if (b.owner !== 'agent' || b.day !== lastDay || !b.target) continue;
125
+ const key = stationOfCode(b.code);
126
+ if (key) wait(key, { kind: b.target.kind, id: b.target.id, title: one(b.title || b.target.id, 120), code: b.code, text: one(b.text, 200) });
127
+ }
128
+
129
+ // CHECK: the Checker's verdicts made; the drafts of ended runs it has not graded yet wait
130
+ const checks = Array.isArray(input.checker) ? input.checker : [];
131
+ const checked = new Map();
132
+ for (const c of checks) {
133
+ if (!isObj(c) || typeof c.proposal !== 'string' || !['pass', 'flag', 'none'].includes(c.verdict)) continue;
134
+ if (!checked.has(c.proposal)) checked.set(c.proposal, c);
135
+ if (c.verdict !== 'none' && inWin(c.at)) st.get('check').made++;
136
+ }
137
+ for (const d of require('./orchestrator-checker.js').due(state, checked, { now })) {
138
+ wait('check', { kind: d.target.kind, id: d.target.id, title: d.target.id, code: 'unchecked', text: `${d.proposals.length} ${d.proposals.length === 1 ? 'draft' : 'drafts'} not checked yet` });
139
+ }
140
+
141
+ // YOU: open sign-offs and Driver drafts that waited a day (pm-open); answered sign-offs and the PM's decisions are what You made
142
+ const SO = require('./signoffs.js');
143
+ for (const s of SO.fold(Array.isArray(input.signoffs) ? input.signoffs : [])) {
144
+ if (s.state === 'open') { const you = st.get('you'); you.waiting++; if (you.items.length < MAX_ITEMS) you.items.push({ kind: 'signoff', id: s.id, title: one(s.what, 120), code: 'signoff', text: one(`${s.who}: ${s.what}`, 200), ini: s.ini || null }); }
145
+ else if (s.state === 'answered' && inWin(s.answeredAt)) st.get('you').made++;
146
+ }
147
+ for (const p of D.openProposals(state)) {
148
+ if (!p.at || now - Date.parse(p.at) < D.PM_WAIT_MS) continue;
149
+ wait('you', { kind: p.target.kind, id: p.target.id, title: p.target.id, code: 'pm-open', text: `Drafts have waited on you since ${p.at.slice(0, 10)}` });
150
+ }
151
+ for (const p of state.proposals.values()) {
152
+ if (p.decided_by && String(p.decided_by).startsWith('pm:') && !p.auto && inWin(p.decided_at)) st.get('you').made++;
153
+ }
154
+
155
+ // MINUTES: the Driver's runs that ended in the window
156
+ const wakeOf = new Map(state.wakes.map((w) => [w.key, w]));
157
+ let runs = 0;
158
+ for (const r of state.runs.values()) {
159
+ if (!r.end || !inWin(r.end)) continue;
160
+ const t0 = ms(r.start), t1 = ms(r.end);
161
+ if (t0 == null || t1 == null || t1 < t0) continue;
162
+ runs++;
163
+ const mins = (t1 - t0) / 60000;
164
+ let keys = [...new Set([...state.proposals.values()].filter((p) => p.run === r.run).map((p) => stationOfJob('driver:' + p.what, { kind: p.target.kind })).filter(Boolean))];
165
+ if (!keys.length) {
166
+ for (const k of r.wakes) {
167
+ const w = wakeOf.get(k);
168
+ const key = w && (w.blocker ? stationOfCode(w.blocker) : w.reason === 'created' ? 'intake' : w.reason === 'moved' ? 'track' : null);
169
+ if (key) { keys = [key]; break; }
170
+ }
171
+ }
172
+ if (!keys.length) { unplaced.minutes += mins; continue; }
173
+ for (const k of keys) st.get(k).minutes += mins / keys.length;
174
+ }
175
+
176
+ const stations = [...st.values()].map(({ _targets, ...s }) => ({ ...s, minutes: Math.round(s.minutes) }));
177
+ return { v: 1, at: new Date(now).toISOString(), ws, name, days, from: new Date(from).toISOString(), stations,
178
+ unplaced: { made: unplaced.made, minutes: Math.round(unplaced.minutes) }, runs, tokens: null, money: null, usage: NOT_RECORDED };
179
+ }
180
+
181
+ /* ── the read (no write) ── */
182
+ function linesOf(file) {
183
+ let text = '';
184
+ try { text = fs.readFileSync(file, 'utf8'); } catch { return []; }
185
+ const out = [];
186
+ for (const raw of text.split('\n')) { if (!raw.trim()) continue; try { const l = JSON.parse(raw); if (isObj(l)) out.push(l); } catch { /* a torn line is skipped */ } }
187
+ return out;
188
+ }
189
+ /** The ledgers of one repository. `stateDir` is the state folder the caller already knows (the Driver's ledger folder); else the rule
190
+ * lib/driver.js stateDirOf uses. No write. */
191
+ function read(root, { runtimeDir = null, stateDir = null } = {}) {
192
+ const dir = stateDir || require('./driver.js').stateDirOf(root);
193
+ const pick = (name) => [dir, runtimeDir].filter(Boolean).map((d) => path.join(d, name)).find((f) => fs.existsSync(f)) || null;
194
+ const ob = runtimeDir ? path.join(runtimeDir, 'outbox', 'outbox.jsonl') : null;
195
+ const at = (name) => (dir ? linesOf(path.join(dir, name)) : []);
196
+ return {
197
+ stateDir: dir,
198
+ autonomy: at('autonomy.jsonl'), proposals: at('proposals.jsonl'), driver: at('driver.jsonl'), checker: at('checker.jsonl'),
199
+ signoffs: dir ? linesOf(require('./signoffs.js').fileOf(dir)) : [],
200
+ bgQueue: pick('bg-queue.jsonl') ? linesOf(pick('bg-queue.jsonl')) : [],
201
+ outbox: ob && fs.existsSync(ob) ? linesOf(ob) : [],
202
+ checks: require('./change-record.js').checksOf(root),
203
+ };
204
+ }
205
+ function build(root, { runtimeDir = null, stateDir = null, now = Date.now(), days = DAYS, ws, name = null } = {}) {
206
+ const input = read(root, { runtimeDir, stateDir });
207
+ if (!input.stateDir) return null;
208
+ const id = ws || require('./driver.js').wsIdOf(root);
209
+ input.outbox = input.outbox.filter((l) => !l.ws || l.ws === id);
210
+ return compute(input, { now, days, ws: id, name });
211
+ }
212
+
213
+ const fileOf = (stateDir) => path.join(stateDir, FILE);
214
+ /** THE ONLY WRITER of the snapshot: build it and write it whole (a temporary file renamed over the old one, so a read never sees half). */
215
+ function save(root, opts = {}) {
216
+ const dir = opts.stateDir || require('./driver.js').stateDirOf(root);
217
+ if (!dir) return { ok: false, error: 'no PMOS state folder' };
218
+ const snapshot = build(root, { ...opts, stateDir: dir });
219
+ const file = fileOf(dir);
220
+ const tmp = `${file}.${process.pid}.tmp`;
221
+ fs.writeFileSync(tmp, JSON.stringify(snapshot) + '\n');
222
+ fs.renameSync(tmp, file);
223
+ return { ok: true, file, snapshot };
224
+ }
225
+ /** The saved snapshot, or null. It reads one file and folds nothing. */
226
+ function load(root, { stateDir = null } = {}) {
227
+ const dir = stateDir || require('./driver.js').stateDirOf(root);
228
+ if (!dir) return null;
229
+ try { const s = JSON.parse(fs.readFileSync(fileOf(dir), 'utf8')); return isObj(s) && s.v === 1 ? s : null; } catch { return null; }
230
+ }
231
+ function ageMinutes(root, now = Date.now()) {
232
+ const s = load(root);
233
+ const t = s && ms(s.at);
234
+ return t == null ? -1 : Math.max(0, Math.floor((now - t) / 60000));
235
+ }
236
+
237
+ module.exports = { STATIONS, WHAT_STATION, GROUP_STATION, RUN_STATION, CODE_STATION, FILE, DAYS, LOG, NOT_RECORDED, MAX_ITEMS,
238
+ stationOfJob, stationOfCode, compute, read, build, fileOf, save, load, ageMinutes };
239
+
240
+ // `node lib/factory-floor.js age <checkout>`: the health number, minutes since the snapshot was saved (-1 when there is none)
241
+ if (require.main === module) {
242
+ const [verb, root = '.'] = process.argv.slice(2);
243
+ if (verb !== 'age') { console.log('usage: node lib/factory-floor.js age <checkout>'); process.exit(2); }
244
+ console.log(String(ageMinutes(path.resolve(root))));
245
+ }
@@ -171,6 +171,7 @@ const JOBS = Object.freeze([
171
171
  q('meeting-prewarm', 'lib/live-round-meeting.js', ['<runtime>/idle-lab/meeting-prewarm.jsonl'], [props, 'calendar', '<runtime>/meeting-material.jsonl'], 'round 1 itself is filed by lib/live-round.js (W1)'),
172
172
  ai('past-repeat', 'lib/past-repeat.js', [props], ['repo:DECISIONS.md']),
173
173
  ai('report-readers', 'lib/report-readers.js', [props, '<runtime>/spec-critic.jsonl'], ['report drafts']), // report-reader-review: each report draft read as the CFO, the engineer and the sceptic
174
+ ai('report-translate', 'lib/report-translate.js', [], ['report drafts', 'report definitions']), // report-reader-language: a translated copy beside each draft, numbers and names checked
174
175
  ai('decision-memory', 'lib/decision-memory.js', [props], ['repo:DECISIONS.md']),
175
176
  ai('outcomes', 'lib/outcome-props.js', [props, '<state>/outcome-runs.jsonl'], ['initiative records', 'repo:planning/runs/outcome_checks.jsonl', '<state>/metric-reads.jsonl']),
176
177
  ai('descriptions', 'lib/description-props.js', [props], ['initiative records']),