create-pmos 0.654.0 → 0.656.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.654.0",
3
+ "version": "0.656.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.656.0",
38
+ "at": "2026-11-22T02:59:28.675Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1440,
43
+ "t": "Act alone only with a source, ask the rest once a day",
44
+ "s": "Act alone only with a source, ask the rest once a day",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "v": "0.655.0",
51
+ "at": "2026-11-22T02:03:29.259Z",
52
+ "f": 4,
53
+ "prs": [
54
+ {
55
+ "n": 1439,
56
+ "t": "Outcome checks that run themselves",
57
+ "s": "Outcome checks that run themselves",
58
+ "k": "new"
59
+ }
60
+ ]
61
+ },
36
62
  {
37
63
  "v": "0.654.0",
38
64
  "at": "2026-11-22T01:23:23.116Z",
@@ -290,32 +316,6 @@
290
316
  "k": "new"
291
317
  }
292
318
  ]
293
- },
294
- {
295
- "v": "0.630.0",
296
- "at": "2026-11-19T08:05:45.827Z",
297
- "f": 4,
298
- "prs": [
299
- {
300
- "n": 1411,
301
- "t": "Backlog shows names not ids, the product's name, and no empty columns",
302
- "s": "Backlog shows names not ids, the product's name, and no empty columns",
303
- "k": "fix"
304
- }
305
- ]
306
- },
307
- {
308
- "v": "0.629.0",
309
- "at": "2026-11-19T07:37:18.343Z",
310
- "f": 4,
311
- "prs": [
312
- {
313
- "n": 1410,
314
- "t": "Jira read goes where the tickets are, and the sprint read no longer sticks on an old sprint",
315
- "s": "Jira read goes where the tickets are, and the sprint read no longer sticks on an old sprint",
316
- "k": "fix"
317
- }
318
- ]
319
319
  }
320
320
  ]
321
321
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@27d1037a
1
+ kernel-source: pmos@d0f61d65
2
2
  assembled: 2026-11-22
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-22T01:23:19Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T02:59:25Z"}
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-22T01:23:19Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T02:59:25Z"}
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-22T01:23:19Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T02:59:25Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,30 @@
1
1
  [
2
+ {
3
+ "v": "0.656.0",
4
+ "at": "2026-11-22T02:59:28.675Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1440,
9
+ "t": "Act alone only with a source, ask the rest once a day",
10
+ "s": "Act alone only with a source, ask the rest once a day",
11
+ "k": "new"
12
+ }
13
+ ]
14
+ },
15
+ {
16
+ "v": "0.655.0",
17
+ "at": "2026-11-22T02:03:29.259Z",
18
+ "f": 4,
19
+ "prs": [
20
+ {
21
+ "n": 1439,
22
+ "t": "Outcome checks that run themselves",
23
+ "s": "Outcome checks that run themselves",
24
+ "k": "new"
25
+ }
26
+ ]
27
+ },
2
28
  {
3
29
  "v": "0.654.0",
4
30
  "at": "2026-11-22T01:23:23.116Z",
@@ -42,6 +42,17 @@ PMOS agents finish work without waiting for you. A change that can be undone is
42
42
 
43
43
  A change with no Undo waits too, whatever its class. A "maybe" or a possible duplicate that PMOS found elsewhere waits, because it is a question for you.
44
44
 
45
+ ### Only with a source
46
+
47
+ PMOS changes a plan by itself only when the change cites a source. These changes wait for an answer instead:
48
+
49
+ - A date move, a task marked done, a name change, a task or document found elsewhere, or a task link that cites no source. This includes a late task where PMOS found no reason.
50
+ - A task closed, a name changed from outside text (Slack, mail, a meeting, Jira), or a date moved by more than 30 days, that cites only one kind of source. Two different kinds are needed, for example Jira and a meeting note. Two Slack messages are one kind.
51
+
52
+ A tidy name that uses only the task's own words is not a name change from a source. It still applies by itself.
53
+
54
+ The changes that wait come together in one list of questions a day: one question for each owner and initiative. The owner is the person the plan names on the task, or you. The list is fixed for the day. A change that waits later that day goes on the next day's list. A question for a teammate is a draft. PMOS does not send it. When you keep or drop the change, its question leaves the list.
55
+
45
56
  ### Undo
46
57
 
47
58
  Each change an agent applies is listed for 14 days with Undo. Undo puts the record back as it was. If someone changed the record since, Undo keeps that change.
@@ -97,7 +108,7 @@ A loop never sends a message, moves a Jira ticket, merges into a product reposit
97
108
  | [Grill](claude-proposes.md) | Before an initiative leaves a stage, when a forecast turns at risk, when scope or dates move a lot, and once a month on running work with late work. Also when you write "grill this" in the initiative's chat. | The initiative, your stored research, your meeting notes and the decisions that stand | "PMOS grilled it" under the initiative's ✦ | Settings › PMOS › Checks: Off. `PMOS_GRILL=off` |
98
109
  | [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` |
99
110
  | [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` |
100
- | [Expected outcomes](claude-proposes.md) | Once a day. At most 3 drafts a day for each product. | The PRD's success criteria, or the anchored key result | "Expected outcome" under the initiative's ✦. Today when a check is due. | `pmos ai off outcomes`. `PMOS_OUTCOMES=off` |
111
+ | [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` |
101
112
  | [Metric drafts](claude-proposes.md) | A product with no North Star, the first 14 days of a quarter, a program with no goal, and an initiative that gets a PRD | The last 8 weeks of real readings | The page of that product, program or initiative | `PMOS_METRIC_DRAFT=off` |
102
113
  | [Horizon scan](intelligence-okr-goals.md) | Daily by default, at most once a day, the first time you step away after 09:00. Scan now: at most 3 a day. | The public web for your kept watch list, and your repository | Report documents and proposals you approve | Cadence: Off. `PMOS_SCAN=off` |
103
114
  | Live round | When you press ✓ on its ✦ ask, or run `pmos lab round`. Three runs at once. No time limit: you see its progress and can stop it. | The initiative's name, the product's Intent and the PMOS design system; a feedback round also reads the last version. | "PMOS prototyped it" or "PMOS improved it" under the initiative's ✦, each version as soon as it renders. | ✕ on its ✦ ask; Undo after ✓ |
@@ -131,7 +142,7 @@ Sync by itself is on by default. `PMOS_AUTO_SYNC=0` stops the sync, the repair a
131
142
 
132
143
  - It sends, posts, replies, pushes and merges nothing. A message to a person is a draft that you send. A Jira change is a drafted comment in your outbox. These are class C: they always wait for you.
133
144
  - It does not create an initiative. The Horizon scan proposes one, and you approve it.
134
- - It does not record a verdict on an outcome. The verdict is always yours.
145
+ - It records a verdict on an outcome only from evidence it cites: the goal's own reading, or the lines a short outcome run read. Each verdict is listed with Undo. When it cannot tell, it records nothing and Your move asks you. A goal it fails to read twice the same way becomes one question for you, not a silent failure.
135
146
 
136
147
  When you ask an agent session to do a piece of work, it can finish it, including acts that were yours alone. Each line it writes names the agent, so you see who did it. See **PM-only acts**.
137
148
 
@@ -160,6 +160,7 @@ PMOS's background run files proposals with these commands. The server pins the i
160
160
  - `pmos propose date --json <file|->`: new dates for late or at-risk tasks, with the reason.
161
161
  - `pmos propose done --json <file|->`: a task that looks done, with the evidence.
162
162
  - `pmos propose name --json <file|->`: tidy names.
163
+ - `pmos propose verdict --json <file|->`: whether an initiative's expected outcome worked, once its check date has passed, with cited evidence. Only the outcome check run can file it. `cant-tell` files nothing, and the check stays with you.
163
164
  - `pmos propose status`: what is open, kept and dropped.
164
165
  - `pmos propose loose <link|merge|finish|start> --json <file|->`: the clean-up of the work that is not in an initiative. Only the clean-up run can file these, and that run files nothing else. `pmos propose loose status` shows what is open and kept.
165
166
 
@@ -283,7 +283,7 @@ PMOS sets these in the environment of a terminal session or a background run. Do
283
283
  | `PMOS_CHECK` | Set to `1` inside each product check that `pmos build check` and `pmos build propose` run in a work item's worktree, with no network. A check can read it. | none | — |
284
284
  | `PMOS_TEAM_FILE`, `PMOS_TEAM_ROOT`, `PMOS_TEAM_WS`, `PMOS_TEAM_ROLE`, `PMOS_TEAM_RUN`, `PMOS_TEAM_INI`, `PMOS_TEAM_MODE` | Set inside a role agent's run: its ledger, product folder, workspace, role, run, initiative, and whether it proposes or applies (`auto`). | none | — |
285
285
  | `PMOS_GRILL_FILE`, `PMOS_GRILL_LOG`, `PMOS_GRILL_ROOT`, `PMOS_GRILL_BOARD`, `PMOS_GRILL_INI`, `PMOS_GRILL_RUN`, `PMOS_GRILL_BUDGET`, `PMOS_GRILL_WS` | Pin a grill run to its ledger, log, repository, board, initiative, run id and budget. No command reads `PMOS_GRILL_WS`. | none | — |
286
- | `PMOS_PROPOSE_FILE`, `PMOS_PROPOSE_BOARD`, `PMOS_PROPOSE_INI`, `PMOS_PROPOSE_RUN`, `PMOS_PROPOSE_WS` | Pin a proposal run to its ledger, board, initiative and run id. No command reads `PMOS_PROPOSE_WS`. | none | — |
286
+ | `PMOS_PROPOSE_FILE`, `PMOS_PROPOSE_BOARD`, `PMOS_PROPOSE_INI`, `PMOS_PROPOSE_RUN`, `PMOS_PROPOSE_WS`, `PMOS_PROPOSE_ROOT` | Pin a proposal run to its ledger, board, initiative and run id. `PMOS_PROPOSE_ROOT` is the repository an outcome run's verdict citations are checked in. No command reads `PMOS_PROPOSE_WS`. | none | — |
287
287
  | `PMOS_METRIC_DRAFT_FILE`, `PMOS_METRIC_DRAFT_SCOPE`, `PMOS_METRIC_DRAFT_ID`, `PMOS_METRIC_DRAFT_RUN`, `PMOS_METRIC_DRAFT_WS` | Pin a metric draft run to its ledger, scope, id and run id. No command reads `PMOS_METRIC_DRAFT_WS`. | none | — |
288
288
  | `PMOS_METRIC_READ_FILE`, `PMOS_METRIC_READ_RECORDS`, `PMOS_METRIC_READ_DRAFTS`, `PMOS_METRIC_READ_WS`, `PMOS_METRIC_READ_RUN`, `PMOS_METRIC_READ_RIDS`, `PMOS_METRIC_READ_TEST` | Pin a goal reading run to its ledger, records, drafts, workspace, run id, goals and test mode. | none | — |
289
289
  | `PMOS_IMPACT_FILE`, `PMOS_IMPACT_RUN` | Pin an impact run to its ledger and run id. | none | — |
@@ -33,9 +33,11 @@
33
33
  *
34
34
  * off(job, { env, settingsDir }) → null | reason
35
35
  * check(p, { root, stateDir }) → { ok, p, errors }
36
- * replay(job, version, cases, { root, stateDir }) → Promise<{ ok, failed: [{ name, why }] }>
36
+ * replay(job, version, cases, { root, stateDir, refDir? }) → Promise<{ ok, failed: [{ name, why }] }>
37
+ * refDir: the folder `state:` refs resolve in, when it is not stateDir (a product's own state folder, while the audit and the replay
38
+ * record stay in the per-user runtime folder: lib/outcome-props.js)
37
39
  * ready(stateDir, job, version) → bool
38
- * file({ job, version, run, root, stateDir, settingsDir?, env?, max? }, proposals, deliver) → Promise<{ filed, dropped, held?, off? }>
40
+ * file({ job, version, run, root, stateDir, refDir?, settingsDir?, env?, max? }, proposals, deliver) → Promise<{ filed, dropped, held?, off? }>
39
41
  * audit(stateDir, line) · readAudit(stateDir, { job?, limit? }) → [line] · status({ stateDir, settingsDir, env }) → summary
40
42
  * setOff(settingsDir, job | null, off) → { ok } | { ok: false, error }
41
43
  */
@@ -258,7 +260,7 @@ function expectFails(name, expect, got) {
258
260
  }
259
261
 
260
262
  /** Run a job's replay cases plus the guard's negatives; record the result for (job, version). */
261
- async function replay(job, version, cases, { root, stateDir, max = MAX } = {}) {
263
+ async function replay(job, version, cases, { root, stateDir, refDir = null, max = MAX } = {}) {
262
264
  const failed = [];
263
265
  let seed = null;
264
266
  if (!JOB_ID.test(String(job || ''))) return { ok: false, failed: [{ name: 'job', why: 'the job id is not valid' }] };
@@ -267,13 +269,13 @@ async function replay(job, version, cases, { root, stateDir, max = MAX } = {}) {
267
269
  const name = one(c && c.name, 120) || '(unnamed)';
268
270
  let list;
269
271
  try { list = await c.run(); } catch (e) { failed.push({ name, why: 'the case threw: ' + one(e && e.message, 200) }); continue; }
270
- const got = sift(list, { root, stateDir, max });
272
+ const got = sift(list, { root, stateDir: refDir || stateDir, max });
271
273
  const why = expectFails(name, c.expect, got);
272
274
  if (why) failed.push({ name, why });
273
275
  if (!seed) seed = got.filed.find((p) => p.claims.length) || null;
274
276
  }
275
277
  if (seed) for (const n of negatives(seed)) {
276
- const got = sift([n.p], { root, stateDir, max });
278
+ const got = sift([n.p], { root, stateDir: refDir || stateDir, max });
277
279
  if (got.filed.length) failed.push({ name: n.name, why: 'the guard filed it' });
278
280
  } else if (!failed.length) failed.push({ name: '(negatives)', why: 'no case filed a cited proposal, so the guard could not test its own drops; add a case that files one' });
279
281
  const ok = !failed.length;
@@ -289,7 +291,7 @@ async function replay(job, version, cases, { root, stateDir, max = MAX } = {}) {
289
291
  /* ── the door ────────────────────────────────────────────────────────────────────────────── */
290
292
 
291
293
  async function file(o, proposals, deliver) {
292
- const { job, version, run = null, root, stateDir, settingsDir = stateDir, env = process.env, max = MAX } = o || {};
294
+ const { job, version, run = null, root, stateDir, refDir = null, settingsDir = stateDir, env = process.env, max = MAX } = o || {};
293
295
  const base = { job, version: String(version), ...(run ? { run } : {}) };
294
296
  if (!JOB_ID.test(String(job || ''))) return { filed: [], dropped: [], error: 'the job id is not valid' };
295
297
  const why = off(job, { env, settingsDir });
@@ -299,7 +301,7 @@ async function file(o, proposals, deliver) {
299
301
  audit(stateDir, { ...base, event: 'held', n: list.length, why: 'no passing replay for this version' });
300
302
  return { filed: [], dropped: [], held: true };
301
303
  }
302
- const got = sift(list, { root, stateDir, max });
304
+ const got = sift(list, { root, stateDir: refDir || stateDir, max });
303
305
  for (const d of got.dropped) audit(stateDir, { ...base, event: 'dropped', id: d.id, why: one(d.why, 400) });
304
306
  if (!got.filed.length) { audit(stateDir, { ...base, event: 'end', filed: 0, dropped: got.dropped.length }); return { filed: [], dropped: got.dropped }; }
305
307
  try { await deliver(got.filed); } catch (e) {
@@ -91,7 +91,7 @@ const KIND_LIST = Object.freeze([
91
91
  k('notes', 'Notes on where work stands', ['driver:note']),
92
92
  k('problem', 'Problem statements and evidence', ['driver:problem', 'driver:evidence', 'driver:sizing', 'driver:assumption', 'driver:stakeholders', 'driver:overlap']),
93
93
  k('experiment', 'The experiment and its next step', ['driver:artefact', 'driver:doc', 'driver:next-step']),
94
- k('outcome', 'Expected outcomes and check dates', ['propose:outcome']),
94
+ k('outcome', 'Expected outcomes, check dates and whether they worked', ['propose:outcome']),
95
95
  k('names', 'Task names', ['propose:names']),
96
96
  k('dates', 'Dates moved by evidence', ['propose:dates']),
97
97
  k('status', 'Closing tasks Jira marked Done', ['propose:status']),
@@ -118,8 +118,11 @@ const classOfDriver = (what) => DRIVER_CLASS[what] || 'C';
118
118
  function classOfProposal(p) {
119
119
  if (!isObj(p)) return 'C';
120
120
  const c = PROPOSAL_CLASS[p.group] || 'C';
121
+ // act-alone-only-with-a-source: a plan change with no source, or a close, rename or big date move on one kind of source, is the owner's
122
+ // question (lib/source-guard.js); it joins the day's question list instead of applying by itself
123
+ if (c !== 'C' && require('./source-guard.js').holdOf(p)) return 'C';
121
124
  if (p.group === 'status' && (p.items || []).some((x) => x && x.jira)) return 'C';
122
- if (p.group === 'outcome' && p.type === 'refuted') return 'C';
125
+ if (p.group === 'outcome' && (p.type === 'refuted' || p.type === 'source')) return 'C'; // a next step, or the one ask for a source PMOS cannot read
123
126
  // D108 as amended 2026-11-16 (Wawan: "Open them automatically"): the factory's pull request opens by itself, from the server (never the
124
127
  // Builder's run), and Undo closes it. The guardrail and CI decide merge or review. `pmos ai off` or a demotion returns it to the ✓.
125
128
  // a live round's prototype (lib/live-round.js, data.live) is the PM's to keep: PMOS never keeps one by itself (2026-11-18: a test round it
@@ -84,6 +84,7 @@ const JOBS = Object.freeze([
84
84
  { id: 'verify', step: 4, label: 'Verifier after merge' },
85
85
  { id: 'metric-reads', step: 4, label: 'Metric reads' },
86
86
  { id: 'forecast', step: 4, label: 'Forecast' },
87
+ { id: 'outcomes', step: 4, label: 'Outcome checks' }, // outcome-checks-run-themselves: a due check's verdict, and one short run when no reading decides it (lib/outcome-props.js)
87
88
  { id: 'report-design', step: 4, label: 'Report design' },
88
89
  { id: 'report-structure', step: 4, label: 'Report structure' },
89
90
  { id: 'team', step: 4, label: 'Role agents' },
@@ -679,7 +679,7 @@ const RUN_ENV = Object.freeze(['PMOS_SCAN_FILE', 'PMOS_SCAN_ORIGIN', 'PMOS_SCAN_
679
679
  'PMOS_CORE_DOC_SCOPE', 'PMOS_CORE_DOC_KEY', 'PMOS_CORE_DOC_KEYS',
680
680
  'PMOS_METRIC_DRAFT_FILE', 'PMOS_METRIC_DRAFT_WS', 'PMOS_METRIC_DRAFT_SCOPE', 'PMOS_METRIC_DRAFT_ID', 'PMOS_METRIC_DRAFT_RUN',
681
681
  'PMOS_METRIC_READ_FILE', 'PMOS_METRIC_READ_RECORDS', 'PMOS_METRIC_READ_DRAFTS', 'PMOS_METRIC_READ_WS', 'PMOS_METRIC_READ_RUN', 'PMOS_METRIC_READ_RIDS', 'PMOS_METRIC_READ_TEST',
682
- 'PMOS_PROPOSE_FILE', 'PMOS_PROPOSE_WS', 'PMOS_PROPOSE_BOARD', 'PMOS_PROPOSE_INI', 'PMOS_PROPOSE_RUN',
682
+ 'PMOS_PROPOSE_FILE', 'PMOS_PROPOSE_WS', 'PMOS_PROPOSE_BOARD', 'PMOS_PROPOSE_INI', 'PMOS_PROPOSE_RUN', 'PMOS_PROPOSE_ROOT',
683
683
  'PMOS_GRILL_FILE', 'PMOS_GRILL_LOG', 'PMOS_GRILL_WS', 'PMOS_GRILL_BOARD', 'PMOS_GRILL_INI', 'PMOS_GRILL_RUN', 'PMOS_GRILL_BUDGET',
684
684
  'PMOS_IMPACT_FILE', 'PMOS_IMPACT_RUN', 'PMOS_VERIFY_RUN', 'PMOS_REVIEW_RUN', 'PMOS_IMPROVE_RUN', 'PMOS_IMPROVE_WS', 'PMOS_IMPROVE_AREA', 'PMOS_IMPROVE_STATE', 'PMOS_IMPROVE_ROOT', 'PMOS_CHECK_REF', 'PMOS_CHECK_DIR', 'PMOS_MS_REVIEW_FILE', 'PMOS_MS_REVIEW_RUN', 'PMOS_MS_REVIEW_PROGRAM',
685
685
  'PMOS_TEAM_FILE', 'PMOS_TEAM_ROOT', 'PMOS_TEAM_WS', 'PMOS_TEAM_ROLE', 'PMOS_TEAM_RUN', 'PMOS_TEAM_INI', 'PMOS_TEAM_MODE',
@@ -67,6 +67,10 @@ const LEDGERS = Object.freeze({
67
67
  r('lib/routes-forecast.js', null, 'the forecast on the Board and Intelligence')] },
68
68
  '<state>/scan.jsonl': { concept: 'horizon-scan', owner: 'lib/scan.js', readers: [
69
69
  r('lib/routes-scan.js', null, 'the Horizon scan results')] },
70
+ '<state>/outcome-runs.jsonl': { concept: 'outcome-runs', owner: 'lib/outcome-props.js', readers: [
71
+ r('lib/outcome-props.js', 'runsOf', 'one outcome run per initiative and check date')] },
72
+ '<state>/question-days.jsonl': { concept: 'question-days', owner: 'lib/question-batch.js', readers: [
73
+ r('lib/routes-your-move.js', null, "the day's question list in Your move")] },
70
74
  '<state>/drift.jsonl': { concept: 'drift', owner: 'lib/drift.js', readers: [
71
75
  r('lib/routes-drift.js', null, "What you might have missed, in Home's chat")] },
72
76
  '<runtime>/idle-lab.jsonl': { concept: 'idle-lab', owner: 'lib/idle-lab.js', readers: [
@@ -164,7 +168,7 @@ const JOBS = Object.freeze([
164
168
  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)'),
165
169
  ai('past-repeat', 'lib/past-repeat.js', [props], ['repo:DECISIONS.md']),
166
170
  ai('decision-memory', 'lib/decision-memory.js', [props], ['repo:DECISIONS.md']),
167
- ai('outcomes', 'lib/outcome-props.js', [props], ['initiative records']),
171
+ ai('outcomes', 'lib/outcome-props.js', [props, '<state>/outcome-runs.jsonl'], ['initiative records', 'repo:planning/runs/outcome_checks.jsonl', '<state>/metric-reads.jsonl']),
168
172
  ai('descriptions', 'lib/description-props.js', [props], ['initiative records']),
169
173
  ai('drift', 'lib/drift-runs.js', ['<state>/drift.jsonl'], ['<state>/boards.jsonl']),
170
174
  ai('rehearse', 'lib/rehearse-guard.js', [], ['task links']),
@@ -0,0 +1,162 @@
1
+ 'use strict';
2
+ /* outcome-judge.js — PMOS checks an outcome by itself when its check date passes (initiative outcome-checks-run-themselves; bet 1 of the
3
+ * factory line, proof A3). Pure apart from reading the product's own ledgers; no model, no clock of its own (`today` comes in).
4
+ *
5
+ * judge({ root, it, src, recordsDir, stateDir, today }) → one of
6
+ * { kind: 'verdict', disposition: validated | refuted, evidence, reading, rec, claims } the anchor goal's own reading decides it
7
+ * { kind: 'cant', rid, goal, why, repeats, claims } PMOS could not read that goal; repeats = the identical failures in a row
8
+ * { kind: 'none', why } nothing here decides it: a short run reads the records (lib/proposal-runs.js `outcome`)
9
+ * drafts(S, { src, recordsDir, stateDir, refDir, only }) → [{ judged, draft }] the ai-guard drafts (lib/ai-guard.js) of the due outcomes
10
+ * verdict class B: recorded by itself with Undo (lib/routes-proposals.js applyOne → lib/outcomes.js recordCheck)
11
+ * source class C: ONE ask to the PM, filed at the second identical "can't read" of the goal the outcome rests on
12
+ * barOf(text) → { lt, inclusive, v, pct } | null the number and direction an expected outcome names ("at least 70%", "≤ 2 hours")
13
+ * ASK_AFTER identical failures before the one ask (2)
14
+ *
15
+ * WHAT DECIDES (nothing else does; a reading never says more than it read):
16
+ * 1. The initiative's anchor (parent_kr) resolves to a goal record (lib/goal-source.js resolve) with a reading taken no earlier than the check
17
+ * date less the goal's own staleness window (lib/goal-status.js staleDays), and no later than today.
18
+ * 2. The expected outcome names a number with a direction: the reading meets it → validated, misses it → refuted.
19
+ * It names none: the goal's own target. Reached → validated. Not reached → no verdict (the initiative may move only part of it).
20
+ * A limit goal (Stay within) is never judged from its target here: the run reads it.
21
+ * 3. No fresh reading, and the goal's reads failed since its last good one → `cant`, with the failures cited.
22
+ * Every verdict cites the reading's own line in kr-metrics.jsonl and the record's outcome_metric line. With no citable line there is no verdict.
23
+ */
24
+ const fs = require('fs');
25
+ const path = require('path');
26
+ const O = require('./outcomes.js');
27
+
28
+ const ASK_AFTER = 2;
29
+ const DAY = 864e5;
30
+ const fin = (v) => typeof v === 'number' && Number.isFinite(v);
31
+ const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length <= n ? t : t.slice(0, n - 1).replace(/[,;:\s]+$/, '') + '…'; };
32
+ const rel = (root, f) => path.relative(root, f).split(path.sep).join('/');
33
+ const inside = (base, f) => { const b = path.resolve(base), a = path.resolve(f); return a === b || a.startsWith(b + path.sep); };
34
+ const dayMs = (d) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(d || '')); return m ? Date.UTC(+m[1], +m[2] - 1, +m[3]) : null; };
35
+ const addDays = (d, n) => new Date(dayMs(d) + n * DAY).toISOString().slice(0, 10);
36
+ const linesOf = (f) => { try { return fs.readFileSync(f, 'utf8').split('\n'); } catch { return null; } };
37
+ const parse = (s) => { try { const o = JSON.parse(s); return o && typeof o === 'object' ? o : null; } catch { return null; } };
38
+ const fmt = (v, unit) => { const r = Math.abs(v) >= 100 ? Math.round(v) : Math.round(v * 100) / 100, s = Math.abs(r) >= 1000 ? r.toLocaleString('en-US') : String(r), u = String(unit || '').trim(); return u ? (/^[A-Za-z]/.test(u) ? s + ' ' + u : s + u) : s; };
39
+ const norm = (s) => String(s || '').toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim();
40
+
41
+ /* ── the number an expected outcome names ─────────────────────────────────────────────────────────────────── */
42
+
43
+ const N = '(\\d{1,3}(?:,\\d{3})+|\\d+(?:\\.\\d+)?)\\s*(%)?';
44
+ const LT_U = new RegExp('(≤|<=|<|fewer than|less than|lower than|below|under|at most|no more than|drops? (?:to|below)|falls? (?:to|below))\\s*' + N, 'i');
45
+ const GT_U = new RegExp('(≥|>=|>|more than|greater than|higher than|above|over|at least|exceeds?|rises? (?:to|above))\\s*' + N, 'i');
46
+ const INCL = /at most|no more than|at least|≤|≥|<=|>=/i;
47
+ /** The number and direction an expected outcome names. → { lt, inclusive, v, pct } | null (no number with a direction: the goal's target decides) */
48
+ function barOf(text) {
49
+ const t = String(text || '');
50
+ const lt = LT_U.exec(t), gt = GT_U.exec(t);
51
+ const m = lt && gt ? (lt.index <= gt.index ? lt : gt) : lt || gt;
52
+ if (!m) return null;
53
+ return { lt: m === lt, inclusive: INCL.test(m[1]), v: Number(m[2].replace(/,/g, '')), pct: !!m[3] };
54
+ }
55
+ const meets = (bar, v) => (bar.lt ? (bar.inclusive ? v <= bar.v : v < bar.v) : (bar.inclusive ? v >= bar.v : v > bar.v));
56
+
57
+ /* ── where each fact sits (path:line and its text, for the citation guard) ───────────────────────────────── */
58
+
59
+ /** A cited source for line n of file f: repository-relative when it is inside the repository, else `state:` relative to refDir. → source | null */
60
+ function srcOf(root, refDir, f, n, text, label) {
61
+ const quote = clip(String(text || '').trim(), 400);
62
+ if (inside(root, f)) return { label, ref: rel(root, f) + ':' + n, quote };
63
+ if (refDir && inside(refDir, f)) return { label, ref: 'state:' + rel(refDir, f) + ':' + n, quote };
64
+ return null;
65
+ }
66
+ /** The newest line of kr-metrics.jsonl that holds this reading. → { n, text } | null */
67
+ function readingLine(file, rid, reading) {
68
+ const L = linesOf(file); if (!L) return null;
69
+ for (let i = L.length - 1; i >= 0; i--) {
70
+ const e = parse(L[i]);
71
+ if (e && e.kind === 'reading' && e.rid === rid && e.fields && e.fields.at === reading.at && e.fields.value === reading.value) return { n: i + 1, text: L[i] };
72
+ }
73
+ return null;
74
+ }
75
+ /** The goal's failed reads since its last good one, oldest first, from metric-reads.jsonl (a test read never counts). → [{ n, text, why }] */
76
+ function cantsOf(file, rid) {
77
+ const L = linesOf(file); if (!L) return [];
78
+ let out = [];
79
+ L.forEach((raw, i) => {
80
+ const e = parse(raw); if (!e || e.rid !== rid || e.test) return;
81
+ if (e.kind === 'read') out = [];
82
+ else if (e.kind === 'cant') out.push({ n: i + 1, text: raw, why: String(e.why || '').trim() });
83
+ });
84
+ return out;
85
+ }
86
+
87
+ /* ── the judgement ───────────────────────────────────────────────────────────────────────────────────────── */
88
+
89
+ function judge({ root, it, src, recordsDir, stateDir, refDir = stateDir, today }) {
90
+ root = path.resolve(root);
91
+ if (!it || !it.horizon) return { kind: 'none', why: 'It has no check date.' };
92
+ const GS = require('./goal-source.js'), ST = require('./goal-status.js');
93
+ const rec = it.anchor ? GS.resolve(src, it.anchor) : null;
94
+ if (!rec) return { kind: 'none', why: it.anchor ? `Its anchor ${it.anchor} has no goal that PMOS reads.` : 'It has no anchor goal.' };
95
+ const goal = clip(rec.title || rec.metric || rec.rid, 80);
96
+ const from = addDays(it.horizon, -ST.staleDays(rec));
97
+ const fresh = (Array.isArray(rec.readings) ? rec.readings : []).filter((x) => x && fin(x.value) && String(x.at || '') >= from && String(x.at || '').slice(0, 10) <= today);
98
+ const metricSrc = it.fm && it.fm.outcome_metric ? srcOf(root, refDir, path.join(root, it.record), it.fm.outcome_metric.n, it.fm.outcome_metric.text, 'Expected outcome') : null;
99
+
100
+ if (!fresh.length) {
101
+ const cants = stateDir ? cantsOf(path.join(stateDir, 'metric-reads.jsonl'), rec.rid) : [];
102
+ if (!cants.length) return { kind: 'none', why: `"${goal}" has no reading since ${from}.` };
103
+ const last = cants[cants.length - 1];
104
+ let repeats = 0;
105
+ for (let i = cants.length - 1; i >= 0 && norm(cants[i].why) === norm(last.why); i--) repeats++;
106
+ const file = path.join(stateDir, 'metric-reads.jsonl');
107
+ const sources = cants.slice(-repeats).slice(-3).map((c) => srcOf(root, refDir, file, c.n, c.text, 'PMOS could not read it')).filter(Boolean);
108
+ return { kind: 'cant', rid: rec.rid, goal, why: last.why || 'no reason given', repeats, claims: sources.length ? [{ text: `PMOS could not read "${goal}" ${repeats} time${repeats === 1 ? '' : 's'} in a row: ${clip(last.why, 160)}`, sources }] : [] };
109
+ }
110
+
111
+ const reading = fresh[fresh.length - 1], v = reading.value;
112
+ const bar = barOf(it.metric);
113
+ let disposition = null, said = '';
114
+ if (bar) {
115
+ disposition = meets(bar, v) ? 'validated' : 'refuted';
116
+ said = `${disposition === 'validated' ? 'meets' : 'misses'} the ${bar.lt ? (bar.inclusive ? 'at most' : 'below') : (bar.inclusive ? 'at least' : 'above')} ${fmt(bar.v, bar.pct ? '%' : '')} it expected`;
117
+ } else if (!ST.isLimit(rec) && fin(Number(rec.target)) && fin(Number(rec.baseline)) && Number(rec.target) !== Number(rec.baseline)) {
118
+ const target = Number(rec.target), up = target > Number(rec.baseline);
119
+ if (up ? v >= target : v <= target) { disposition = 'validated'; said = `reached its target of ${fmt(target, rec.unit)}`; }
120
+ else return { kind: 'none', why: `"${goal}" reads ${fmt(v, rec.unit)}, short of its target of ${fmt(target, rec.unit)}, and the expected outcome names no number of its own.` };
121
+ } else return { kind: 'none', why: 'The expected outcome names no number, and the goal has no target PMOS can compare with.' };
122
+
123
+ const file = path.join(recordsDir || GS.recordsDirOf(root), 'kr-metrics.jsonl');
124
+ const line = readingLine(file, rec.rid, reading);
125
+ const rsrc = line ? srcOf(root, refDir, file, line.n, line.text, 'The goal\'s reading') : null;
126
+ if (!rsrc) return { kind: 'none', why: 'The reading could not be cited by its line.' };
127
+ const evidence = clip(`"${goal}" read ${fmt(v, rec.unit)} on ${String(reading.at).slice(0, 10)}${reading.source ? ' (' + reading.source + ')' : ''}, which ${said}. Source: ${rsrc.ref}`, 600);
128
+ const claims = [{ text: `"${goal}" read ${fmt(v, rec.unit)} on ${String(reading.at).slice(0, 10)}`, sources: [rsrc] }];
129
+ if (metricSrc) claims.push({ text: `It expected: ${clip(it.metric, 160)}`, sources: [metricSrc] });
130
+ return { kind: 'verdict', disposition, evidence, reading, rec, claims };
131
+ }
132
+
133
+ const WORDS = Object.freeze({ validated: 'It worked', refuted: 'It did not work' });
134
+
135
+ /** The drafts of the due outcomes of one scan (lib/outcomes.js scan). → [{ judged, it, draft | null }] (draft null: nothing to file now) */
136
+ function drafts(S, { src, recordsDir, stateDir, refDir = stateDir, only = null } = {}) {
137
+ const out = [];
138
+ for (const it of S.due) {
139
+ if (only && it.id !== only) continue;
140
+ const j = judge({ root: S.root, it, src, recordsDir, stateDir, refDir, today: S.today });
141
+ let draft = null;
142
+ if (j.kind === 'verdict') {
143
+ draft = {
144
+ id: `outcome-verdict:${it.id}:${it.horizon}`, cls: 'B', confidence: 'medium', claims: j.claims,
145
+ title: `${WORDS[j.disposition]}: ${clip(it.title, 80)}`,
146
+ say: `Its check date was ${O.short(it.horizon)}. ${j.evidence.replace(/ Source: .*$/, '')} PMOS recorded "${j.disposition === 'validated' ? 'worked' : 'didn\'t work'}". Undo takes it back.`,
147
+ data: { kind: 'verdict', initiative: it.id, disposition: j.disposition, evidence: j.evidence, horizon: it.horizon },
148
+ };
149
+ } else if (j.kind === 'cant' && j.repeats >= ASK_AFTER && j.claims.length) {
150
+ draft = {
151
+ id: `outcome-source:${it.id}:${j.rid}`, cls: 'C', confidence: 'medium', claims: j.claims,
152
+ title: `PMOS can't read "${clip(j.goal, 60)}"`,
153
+ say: `PMOS tried to read "${j.goal}" ${j.repeats} times and could not: ${clip(j.why, 200)}. Until it can, the outcome of ${clip(it.title, 80)} can't be checked. Connect the source, or pick another number to steer by. ✓ adds this as a task for you.`,
154
+ data: { kind: 'source', initiative: it.id, rid: j.rid, goal: j.goal, why: clip(j.why, 300), repeats: j.repeats, horizon: it.horizon },
155
+ };
156
+ }
157
+ out.push({ judged: j, it, draft });
158
+ }
159
+ return out;
160
+ }
161
+
162
+ module.exports = { judge, drafts, barOf, ASK_AFTER, WORDS };