create-pmos 0.704.0 → 0.706.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 +15 -3
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +14 -2
- package/workspace/guide/cli.md +2 -1
- package/workspace/guide/settings-and-switches.md +1 -0
- package/workspace/lib/coming-up.js +4 -0
- package/workspace/lib/correction-kinds.js +213 -0
- package/workspace/lib/corrections-memory.js +5 -0
- package/workspace/lib/idle-lab.js +14 -3
- package/workspace/lib/outcome-props.js +19 -0
- package/workspace/lib/outcomes-cli.js +21 -6
- package/workspace/lib/outcomes.js +67 -4
- package/workspace/lib/pmos-verbs.js +1 -1
- package/workspace/lib/routes-lab.js +21 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/ini-agent.js +3 -1
- package/workspace/test-files.json +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.706.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.
|
|
38
|
-
"at": "2026-11-22T11:
|
|
37
|
+
"v": "0.706.0",
|
|
38
|
+
"at": "2026-11-22T11:09:53.829Z",
|
|
39
39
|
"f": 4,
|
|
40
40
|
"prs": [
|
|
41
41
|
{
|
|
@@ -43,6 +43,18 @@
|
|
|
43
43
|
"t": "A weekly what-moved list in Your move (A441)",
|
|
44
44
|
"s": "A weekly what-moved list in Your move (A441)",
|
|
45
45
|
"k": "new"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"n": 1532,
|
|
49
|
+
"t": "A blocked outcome check shows as blocked, with the step to fix it (A451)",
|
|
50
|
+
"s": "A blocked outcome check shows as blocked, with the step to fix it (A451)",
|
|
51
|
+
"k": "new"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"n": 1535,
|
|
55
|
+
"t": "Corrections become standing rules (A464)",
|
|
56
|
+
"s": "Corrections become standing rules (A464)",
|
|
57
|
+
"k": "new"
|
|
46
58
|
}
|
|
47
59
|
]
|
|
48
60
|
},
|
package/payload/KIT-VERSION
CHANGED
|
@@ -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-22T11:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T11:09:50Z"}
|
|
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-22T11:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T11:09:50Z"}
|
|
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-22T11:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T11:09:50Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"v": "0.
|
|
4
|
-
"at": "2026-11-22T11:
|
|
3
|
+
"v": "0.706.0",
|
|
4
|
+
"at": "2026-11-22T11:09:53.829Z",
|
|
5
5
|
"f": 4,
|
|
6
6
|
"prs": [
|
|
7
7
|
{
|
|
@@ -9,6 +9,18 @@
|
|
|
9
9
|
"t": "A weekly what-moved list in Your move (A441)",
|
|
10
10
|
"s": "A weekly what-moved list in Your move (A441)",
|
|
11
11
|
"k": "new"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"n": 1532,
|
|
15
|
+
"t": "A blocked outcome check shows as blocked, with the step to fix it (A451)",
|
|
16
|
+
"s": "A blocked outcome check shows as blocked, with the step to fix it (A451)",
|
|
17
|
+
"k": "new"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"n": 1535,
|
|
21
|
+
"t": "Corrections become standing rules (A464)",
|
|
22
|
+
"s": "Corrections become standing rules (A464)",
|
|
23
|
+
"k": "new"
|
|
12
24
|
}
|
|
13
25
|
]
|
|
14
26
|
},
|
package/workspace/guide/cli.md
CHANGED
|
@@ -276,10 +276,11 @@ The idle lab run uses only the first three commands:
|
|
|
276
276
|
|
|
277
277
|
Run them in the product's repository, or pass `--root <dir>`.
|
|
278
278
|
|
|
279
|
-
- `pmos outcomes list` shows the checks that are due, the outcomes with no date and the initiatives with no outcome. It changes nothing.
|
|
279
|
+
- `pmos outcomes list` shows the checks that are due or blocked, the outcomes with no date and the initiatives with no outcome. It changes nothing.
|
|
280
280
|
- `pmos outcomes propose [<id>]` shows PMOS's drafts, each with the lines it cites. Before the first draft of a repository it replays them on that repository's records, and shows nothing unless the replay passes.
|
|
281
281
|
- `pmos outcomes declare <id> --metric "<text>" --horizon <YYYY-MM-DD>` writes the outcome and its check date, after you said yes.
|
|
282
282
|
- `pmos outcomes record <id> <worked|didnt-work|cant-tell> --evidence "<text>"` records your verdict on a due check.
|
|
283
|
+
- `pmos outcomes live --where <place> --version <version>` records the version a place runs now, for example after a deploy. When a record says `shipped_in: "<version>"` and `measured_on: "<place>"`, and that place still runs an older version, its outcome check shows as blocked with the step to fix it. PMOS does not ask for a verdict until the place runs the change.
|
|
283
284
|
- When you record `didnt-work`, the initiative shows **At risk** on every page, with the check as the reason. PMOS compares the evidence with the kill condition and files one next step under the initiative's ✦. If the evidence meets the kill condition, PMOS suggests that you stop the initiative. If this is the second check that did not work, it suggests a new experiment. Otherwise it suggests one more round with a new check date. The Board's Next column asks you the same question. Nothing happens until you press ✓. Undo reverses the step.
|
|
284
285
|
- `pmos outcomes propose` also reads the experiment's hypothesis. When the hypothesis names a different KR from the initiative's anchor, the draft tells you.
|
|
285
286
|
|
|
@@ -159,6 +159,7 @@ An "off" switch accepts `off`, `0`, `false` or `no` unless the row says a differ
|
|
|
159
159
|
| `PMOS_LEAN_JOBS` | How background runs start. `off` starts every run with all tools, skills and settings. `all` also starts the runs that read your connectors lean. By default a run that reads no connector starts lean, with only its own tools. | lean for runs with no connector | — |
|
|
160
160
|
| `PMOS_RUN_MEMORY` | `off` stops adding the repository's curated memory (what PMOS remembers about you and the product) to each background run, and stops each team role's notebook (what became of its earlier work). A web run never gets it. | on | — |
|
|
161
161
|
| `PMOS_CORRECTION_MEMORY` | `off` stops your ✕ reasons from becoming memory. By default a reason of 12 characters or more is remembered as one unconfirmed entry for 30 days, at most 6 at once. | on | — |
|
|
162
|
+
| `PMOS_CORRECTION_RULES` | `off` stops PMOS from recording each ✕ reason with a kind and offering a kind that repeats 3 times in 30 days as a standing rule in the Lab. | on | — |
|
|
162
163
|
| `PMOS_FACTORY_LESSONS` | `off` stops factory lessons. By default each factory setback (a failed check, a revert or rollback, a pull request the guardrail sent to a person, your Undo of one, a reviewer FAIL) becomes one Lessons line on its initiative and one line in the Builder's notebook. The Builder prompt carries the last 5. The same setback 3 times in 14 days files one proposal, "Change the factory harness", for your ✓. | on | — |
|
|
163
164
|
| `PMOS_CLAUDE_HOME` | The one folder where PMOS looks for PMOS transcripts. | the PMOS config folders | — |
|
|
164
165
|
| `PMOS_HEADLESS_TIMEOUT_MS` | The longest time a background run may take. | 20 minutes | — |
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* aheadOf(root, ini, { today, schedules, now }) → { outcome: { date, metric, src } | null, jobs: [{ date, name, src }] }
|
|
7
7
|
* outcome the record's outcome check (outcome_metric + outcome_horizon, lib/outcomes.js), only while it is still ahead and nobody
|
|
8
8
|
* recorded a verdict. A check that is due is Your move on Home, so it is not repeated here.
|
|
9
|
+
* A blocked check (bet A451: the place it is measured runs an older version than the one that shipped the change) is shown
|
|
10
|
+
* whether or not its date passed, with blocked: { why, step }: nobody else says it, and it needs one step from someone.
|
|
9
11
|
* jobs PMOS's scheduled jobs that name this initiative (its id or its title, in the schedule's name or its request), enabled,
|
|
10
12
|
* each with its next run in the next 30 days (lib/schedule-logic.js nextRun: what is shown is what fires).
|
|
11
13
|
* Nothing here writes.
|
|
@@ -19,6 +21,8 @@ function outcomeOf(root, ini, today) {
|
|
|
19
21
|
try {
|
|
20
22
|
const O = require('./outcomes.js');
|
|
21
23
|
const S = O.scan(root, { today });
|
|
24
|
+
const b = (S.blocked || []).find((x) => x.id === ini);
|
|
25
|
+
if (b && b.horizon && b.metric) return { date: b.horizon < today ? today : b.horizon, metric: b.metric, src: b.record + ' · shipped_in', blocked: { why: b.blocked.why, step: b.blocked.step } };
|
|
22
26
|
const it = (S.pending || []).find((x) => x.id === ini);
|
|
23
27
|
if (!it || !it.horizon || !it.metric) return null;
|
|
24
28
|
return { date: it.horizon, metric: it.metric, src: it.record + ' · outcome_horizon' };
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* correction-kinds.js — teach PMOS once: corrections become standing rules (bet A464, initiative correction-rules).
|
|
3
|
+
*
|
|
4
|
+
* The PM's ✕ reasons repeat, but nothing could see the repeat: run records hold a count, and each reason became one memory line that goes
|
|
5
|
+
* stale in 30 days. Here every reason is recorded WITH A KIND, and a kind that repeats becomes a ✦ in the Lab: "make this a standing rule".
|
|
6
|
+
* ✓ (lib/routes-lab.js) writes it as a confirmed memory entry by the PM, so every later run reads it and it never goes stale. Undo removes it.
|
|
7
|
+
*
|
|
8
|
+
* KINDS. A fixed word list, no model: sources, dates, scope, wording, duplicates, owners, priority, tests, design, numbers. A reason that
|
|
9
|
+
* matches no word is `other` and is never offered. The kind with the most matching words wins; a tie goes to the earlier kind in the list.
|
|
10
|
+
*
|
|
11
|
+
* LEDGER. corrections.jsonl in the product's PMOS state folder (pmos/state, state or .pmos under the repository), one line per correction:
|
|
12
|
+
* { at, kind, why, source, ini? }
|
|
13
|
+
* A repository with no state folder records nothing (and says nothing). PMOS_CORRECTION_RULES=off stops all of it.
|
|
14
|
+
*
|
|
15
|
+
* OFFERS. A kind with MIN_REPEAT or more corrections from MIN_REPEAT different sources in WINDOW_DAYS, counted after its last drop or undo,
|
|
16
|
+
* is offered (most corrections first, at most MAX_OPEN open at once). A kept rule is never offered again. Each offer logs one line with TAG.
|
|
17
|
+
*
|
|
18
|
+
* kindOf(text) → kind id ('other' when no word matches)
|
|
19
|
+
* stateDir(root) → the state folder, or null
|
|
20
|
+
* readLines(dir) · append(dir, line) the ledger
|
|
21
|
+
* offersOf(lines, lab, { now }) PURE → [{ kind, n, latest, sources }] to file now
|
|
22
|
+
* propLine(offer) PURE → the idle-lab propose line for an offer
|
|
23
|
+
* note(root, { why, source, ini, env, now, log }) → { ok, kind?, offered?: [kind] } never throws
|
|
24
|
+
* countRecent(lines, now, days) · effectOf(lines, lab, now) PURE (the health number and the outcome check)
|
|
25
|
+
*/
|
|
26
|
+
const fs = require('fs');
|
|
27
|
+
const path = require('path');
|
|
28
|
+
|
|
29
|
+
const DAY = 86400000;
|
|
30
|
+
const LEDGER = 'corrections.jsonl';
|
|
31
|
+
const TAG = '[correction-rules]';
|
|
32
|
+
const MIN_WHY = 12;
|
|
33
|
+
const MIN_REPEAT = 3;
|
|
34
|
+
const WINDOW_DAYS = 30;
|
|
35
|
+
const MAX_OPEN = 3;
|
|
36
|
+
const PREFIX = 'rule-';
|
|
37
|
+
|
|
38
|
+
/* Each kind: the words that place a reason in it, and the standing rule PMOS offers for it. Plain, for any product. */
|
|
39
|
+
const KINDS = Object.freeze([
|
|
40
|
+
{ id: 'sources', label: 'Sources', words: /\b(sources?|sourced|cite[sd]?|citations?|evidence|references?|proofs?|unsourced|where (?:is|does) (?:this|that|it) come from)\b/gi,
|
|
41
|
+
rule: 'Cite the source of every claim or change you propose.' },
|
|
42
|
+
{ id: 'dates', label: 'Dates', words: /\b(dates?|deadlines?|due|overdue|schedule[sd]?|timeline|sprints?|moved?|reschedul\w*|postpone\w*|delay\w*|slip\w*|end date|start date)\b/gi,
|
|
43
|
+
rule: 'Move a date only with a cited reason, and say what it moved from.' },
|
|
44
|
+
{ id: 'scope', label: 'Scope', words: /\b(scope|out of scope|too (?:big|much|broad)|not (?:now|needed|asked)|later|unrelated|off[- ]topic|nobody asked|stick to)\b/gi,
|
|
45
|
+
rule: 'Keep each proposal to what was asked. Put extra ideas on a line of their own.' },
|
|
46
|
+
{ id: 'wording', label: 'Wording', words: /\b(word(?:s|ing)?|tone|jargon|phras\w*|wordy|verbose|too long|rename|naming|named?|label|copy|plain|spelling|typo)\b/gi,
|
|
47
|
+
rule: 'Use the product\'s own words, and keep text short and plain.' },
|
|
48
|
+
{ id: 'duplicates', label: 'Duplicates', words: /\b(duplicates?|duplicated|already (?:exists?|have|there|done)|same as|again|twice|repeat\w*|copy of)\b/gi,
|
|
49
|
+
rule: 'Check for an existing item before you propose a new one.' },
|
|
50
|
+
{ id: 'owners', label: 'Owners', words: /\b(owners?|ownership|assign\w*|assignee|who owns|reassign\w*|not (?:his|hers|theirs|mine)|wrong person)\b/gi,
|
|
51
|
+
rule: 'Name the owner, and do not change an owner without asking.' },
|
|
52
|
+
{ id: 'priority', label: 'Priority', words: /\b(priorit\w*|rank\w*|urgent|important|less important|more important|p[0-3])\b/gi,
|
|
53
|
+
rule: 'Follow the agreed ranking, and say why before you change a priority.' },
|
|
54
|
+
{ id: 'tests', label: 'Tests', words: /\b(tests?|tested|untested|testing|checks?|verif\w*|qa|regression|broke|broken|breaks)\b/gi,
|
|
55
|
+
rule: 'Say how each change was checked, and test what it touches.' },
|
|
56
|
+
{ id: 'design', label: 'Design', words: /\b(design|layout|colou?rs?|spacing|font|icons?|buttons?|style|looks?|ui|ux|mockup|pixel)\b/gi,
|
|
57
|
+
rule: 'Follow the design system, and change no layout or style beyond the ask.' },
|
|
58
|
+
{ id: 'numbers', label: 'Numbers', words: /\b(numbers?|counts?|figures?|totals?|wrong (?:number|count|data)|data|stale|outdated|out of date|percent\w*|metrics?)\b/gi,
|
|
59
|
+
rule: 'Read numbers from current data, and say where and when they were read.' },
|
|
60
|
+
]);
|
|
61
|
+
const IDS = Object.freeze(KINDS.map((k) => k.id));
|
|
62
|
+
const byId = new Map(KINDS.map((k) => [k.id, k]));
|
|
63
|
+
|
|
64
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
65
|
+
const one = (s, n) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
66
|
+
const off = (env) => /^(off|0|false|no)$/i.test(String((env || process.env).PMOS_CORRECTION_RULES || '').trim());
|
|
67
|
+
|
|
68
|
+
function kindOf(text) {
|
|
69
|
+
const t = String(text || '');
|
|
70
|
+
let best = 'other', most = 0;
|
|
71
|
+
for (const k of KINDS) {
|
|
72
|
+
const n = (t.match(k.words) || []).length;
|
|
73
|
+
if (n > most) { most = n; best = k.id; }
|
|
74
|
+
}
|
|
75
|
+
return best;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function stateDir(root) {
|
|
79
|
+
if (!root) return null;
|
|
80
|
+
for (const rel of [['pmos', 'state'], ['state'], ['.pmos']]) {
|
|
81
|
+
const d = path.join(root, ...rel);
|
|
82
|
+
try { if (fs.statSync(d).isDirectory()) return d; } catch { /* next */ }
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function readLines(dir) {
|
|
88
|
+
if (!dir) return [];
|
|
89
|
+
let text = '';
|
|
90
|
+
try { text = fs.readFileSync(path.join(dir, LEDGER), 'utf8'); } catch { return []; }
|
|
91
|
+
const out = [];
|
|
92
|
+
for (const raw of text.split('\n')) { if (!raw.trim()) continue; try { const l = JSON.parse(raw); if (isObj(l) && l.kind && l.at) out.push(l); } catch { /* a torn line is skipped */ } }
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
95
|
+
function append(dir, line) { fs.appendFileSync(path.join(dir, LEDGER), JSON.stringify(line) + '\n'); return line; }
|
|
96
|
+
|
|
97
|
+
/* What the Lab ledger (lib/idle-lab.js fold) says about each rule id: open, kept (not undone), and since when its count restarts. */
|
|
98
|
+
function labState(L) {
|
|
99
|
+
const st = new Map();
|
|
100
|
+
if (!L) return st;
|
|
101
|
+
const get = (id) => { if (!st.has(id)) st.set(id, { open: false, kept: null, since: 0 }); return st.get(id); };
|
|
102
|
+
const keptBatches = new Map();
|
|
103
|
+
for (const k of L.kept || []) if (String(k.id).startsWith(PREFIX)) {
|
|
104
|
+
if (L.undone && L.undone.has(k.batch)) { const s = get(k.id); s.since = Math.max(s.since, Date.parse(k.at) || 0); } // counted again from the keep
|
|
105
|
+
else get(k.id).kept = k.at;
|
|
106
|
+
keptBatches.set(k.batch, k.id);
|
|
107
|
+
}
|
|
108
|
+
for (const [id, d] of L.drops || []) if (String(id).startsWith(PREFIX)) { const s = get(id); s.since = Math.max(s.since, Date.parse(d.at) || 0); }
|
|
109
|
+
for (const [id, p] of L.props || []) if (String(id).startsWith(PREFIX)) {
|
|
110
|
+
const s = get(id);
|
|
111
|
+
if (!s.kept && !(L.drops && L.drops.has(id))) s.open = true;
|
|
112
|
+
s.proposed = Math.max(s.proposed || 0, Date.parse(p.at) || 0);
|
|
113
|
+
}
|
|
114
|
+
return st;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** PURE. The offers to file now: kinds that repeat, not open, not kept, counted after their last drop or undo. */
|
|
118
|
+
function offersOf(lines, L, { now = Date.now() } = {}) {
|
|
119
|
+
const st = labState(L), since = now - WINDOW_DAYS * DAY;
|
|
120
|
+
const open = [...st.values()].filter((s) => s.open).length;
|
|
121
|
+
const room = Math.max(0, MAX_OPEN - open);
|
|
122
|
+
if (!room) return [];
|
|
123
|
+
const groups = new Map();
|
|
124
|
+
for (const l of lines || []) {
|
|
125
|
+
if (!IDS.includes(l.kind)) continue;
|
|
126
|
+
const at = Date.parse(l.at) || 0, s = st.get(PREFIX + l.kind);
|
|
127
|
+
if (at < since || at > now || (s && (s.open || s.kept || at <= s.since))) continue;
|
|
128
|
+
if (!groups.has(l.kind)) groups.set(l.kind, []);
|
|
129
|
+
groups.get(l.kind).push(l);
|
|
130
|
+
}
|
|
131
|
+
const out = [];
|
|
132
|
+
for (const [kind, ls] of groups) {
|
|
133
|
+
const sources = [...new Set(ls.map((l) => String(l.source || '') || 'at:' + l.at))];
|
|
134
|
+
if (ls.length < MIN_REPEAT || sources.length < MIN_REPEAT) continue;
|
|
135
|
+
ls.sort((a, b) => String(a.at).localeCompare(String(b.at)));
|
|
136
|
+
const latest = ls[ls.length - 1];
|
|
137
|
+
out.push({ kind, n: ls.length, latest: one(latest.why, 140), at: latest.at, sources: sources.slice(-3) });
|
|
138
|
+
}
|
|
139
|
+
out.sort((a, b) => b.n - a.n || String(b.at).localeCompare(String(a.at)) || IDS.indexOf(a.kind) - IDS.indexOf(b.kind));
|
|
140
|
+
return out.slice(0, room);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** PURE. The idle-lab propose line for an offer (lib/idle-lab.js loose type 'rule'). */
|
|
144
|
+
function propLine(o) {
|
|
145
|
+
const k = byId.get(o.kind);
|
|
146
|
+
return { kind: 'propose', id: PREFIX + o.kind, type: 'rule', title: k.rule,
|
|
147
|
+
why: one(`You corrected this ${o.n} times in ${WINDOW_DAYS} days. Latest: "${o.latest}"`, 300),
|
|
148
|
+
sources: o.sources.map((ref) => ({ label: 'Your correction', ...(ref.startsWith('at:') ? {} : { ref }) })),
|
|
149
|
+
data: { kind: o.kind, n: o.n } };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Record one correction with its kind and file any offer it completes. Never throws. */
|
|
153
|
+
function note(root, { why = '', source = '', ini = null, env = process.env, now = Date.now(), log = console.log } = {}) {
|
|
154
|
+
try {
|
|
155
|
+
const reason = one(why, 300);
|
|
156
|
+
if (!root || reason.length < MIN_WHY || off(env)) return { ok: true };
|
|
157
|
+
const dir = stateDir(root);
|
|
158
|
+
if (!dir) return { ok: true };
|
|
159
|
+
const kind = kindOf(reason);
|
|
160
|
+
append(dir, { at: new Date(now).toISOString(), kind, why: reason, source: one(source, 120), ...(ini ? { ini: one(ini, 80) } : {}) });
|
|
161
|
+
if (kind === 'other') return { ok: true, kind, offered: [] };
|
|
162
|
+
const LAB = require('./idle-lab.js');
|
|
163
|
+
const offers = offersOf(readLines(dir), LAB.read(dir), { now });
|
|
164
|
+
for (const o of offers) {
|
|
165
|
+
const line = propLine(o), v = LAB.loose('rule', line);
|
|
166
|
+
if (v.error) continue;
|
|
167
|
+
LAB.append(dir, { by: 'agent:corrections' }, { kind: 'propose', ...v.prop });
|
|
168
|
+
try { log(`${TAG} offered a standing rule for ${o.kind} (${o.n} corrections in ${WINDOW_DAYS} days)`); } catch { /* the line is filed */ }
|
|
169
|
+
}
|
|
170
|
+
return { ok: true, kind, offered: offers.map((o) => o.kind) };
|
|
171
|
+
} catch (e) { return { ok: false, why: String((e && e.message) || e).slice(0, 160) }; }
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** PURE. Corrections recorded in the last `days` days (the health number). */
|
|
175
|
+
function countRecent(lines, now = Date.now(), days = 7) {
|
|
176
|
+
const since = now - days * DAY;
|
|
177
|
+
return (lines || []).filter((l) => { const at = Date.parse(l.at) || 0; return at >= since && at <= now; }).length;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** PURE. Per kept rule: corrections of its kind in the 30 days before it was kept and the 30 days after (the outcome check). */
|
|
181
|
+
function effectOf(lines, L, now = Date.now()) {
|
|
182
|
+
const out = [];
|
|
183
|
+
for (const [id, s] of labState(L)) {
|
|
184
|
+
if (!s.kept) continue;
|
|
185
|
+
const kind = id.slice(PREFIX.length), t = Date.parse(s.kept) || 0, W = WINDOW_DAYS * DAY;
|
|
186
|
+
const of = (lines || []).filter((l) => l.kind === kind).map((l) => Date.parse(l.at) || 0);
|
|
187
|
+
out.push({ kind, kept: s.kept, before: of.filter((a) => a >= t - W && a < t).length, after: of.filter((a) => a >= t && a < t + W).length,
|
|
188
|
+
complete: now >= t + W });
|
|
189
|
+
}
|
|
190
|
+
return out.sort((a, b) => String(a.kept).localeCompare(String(b.kept)));
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
module.exports = { KINDS, IDS, LEDGER, TAG, MIN_WHY, MIN_REPEAT, WINDOW_DAYS, MAX_OPEN, PREFIX, kindOf, stateDir, readLines, append, offersOf, propLine, note, countRecent, effectOf, ruleOf: (kind) => (byId.get(kind) || {}).rule || '' };
|
|
194
|
+
|
|
195
|
+
/* node correction-kinds.js count|effect [--root <repo>] [--json] */
|
|
196
|
+
if (require.main === module) {
|
|
197
|
+
const argv = process.argv.slice(2), cmd = argv[0];
|
|
198
|
+
const opt = (k) => { const i = argv.indexOf(k); return i >= 0 ? argv[i + 1] : null; };
|
|
199
|
+
const root = path.resolve(opt('--root') || '.'), dir = stateDir(root), lines = readLines(dir);
|
|
200
|
+
if (cmd === 'count') {
|
|
201
|
+
const n = countRecent(lines);
|
|
202
|
+
if (argv.includes('--json')) process.stdout.write(JSON.stringify({ dir, last7: n }) + '\n');
|
|
203
|
+
else process.stdout.write(`${dir ? '' : 'No PMOS state folder here, so no corrections are recorded.\n'}${n}\n`);
|
|
204
|
+
} else if (cmd === 'effect') {
|
|
205
|
+
const e = effectOf(lines, require('./idle-lab.js').read(dir));
|
|
206
|
+
if (argv.includes('--json')) process.stdout.write(JSON.stringify({ dir, rules: e }) + '\n');
|
|
207
|
+
else if (!e.length) process.stdout.write('No standing rule kept yet.\n');
|
|
208
|
+
else for (const r of e) process.stdout.write(`${r.kind}: kept ${String(r.kept).slice(0, 10)}, ${r.before} corrections in the 30 days before, ${r.after} after${r.complete ? '' : ' (so far)'}\n`);
|
|
209
|
+
} else {
|
|
210
|
+
process.stdout.write('usage: node correction-kinds.js count|effect [--root <repo>] [--json]\n');
|
|
211
|
+
process.exitCode = cmd ? 1 : 0;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
* live at once: the oldest is removed first. A full memory is never forced: the write is skipped and the reason stays on the ✕ line.
|
|
11
11
|
* The same text twice is written once. PMOS_CORRECTION_MEMORY=off stops it.
|
|
12
12
|
*
|
|
13
|
+
* KINDS (bet A464): every reason is also recorded with a kind (lib/correction-kinds.js), so a repeat can become a standing rule the PM
|
|
14
|
+
* keeps once. PMOS_CORRECTION_RULES=off stops that part only.
|
|
15
|
+
*
|
|
13
16
|
* SCOPE (chief-unit-owners ✦4): with `ini` the entry is written at initiative scope (initiative:<id>), so only runs on that initiative read
|
|
14
17
|
* it until the unit's tick sees the same lesson on a second initiative and promotes it (lib/unit-memory.js). The KEEP bound is per scope.
|
|
15
18
|
*
|
|
@@ -33,6 +36,8 @@ function remember(root, { what = '', why = '', source = '', ini = null, env = pr
|
|
|
33
36
|
try {
|
|
34
37
|
const reason = one(why, 300);
|
|
35
38
|
if (!root || reason.length < MIN_WHY) return { ok: true, wrote: false, why: 'no reason to learn from' };
|
|
39
|
+
// the same reason, recorded with its kind: a kind that repeats becomes a standing-rule ✦ in the Lab (lib/correction-kinds.js, bet A464)
|
|
40
|
+
require('./correction-kinds.js').note(root, { why: reason, source, ini, env, now });
|
|
36
41
|
if (off(env)) return { ok: true, wrote: false, why: 'PMOS_CORRECTION_MEMORY=off' };
|
|
37
42
|
const c = require('./memory.js').core();
|
|
38
43
|
if (!c.ok) return { ok: true, wrote: false, why: c.error };
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* in Intelligence › Lab only the ✦ that fit no initiative, in <state>/idle-lab.jsonl (THE ONE WRITER and THE ONE FOLD of that file):
|
|
17
17
|
* start start an initiative from a scan finding. data { title, board, anchor, stage? } ✓ starts it through the Board (Add an ask, Accept)
|
|
18
18
|
* scan a finding worth knowing that no initiative holds yet. ✓ keeps it (writes nothing else)
|
|
19
|
+
* rule a correction the PM keeps giving, offered as a standing rule (lib/correction-kinds.js, bet A464). data { kind, n }
|
|
20
|
+
* ✓ writes it to memory as the PM's own confirmed entry; Undo removes that entry (lib/routes-lab.js)
|
|
19
21
|
*
|
|
20
22
|
* THE LAB LEDGER, <state>/idle-lab.jsonl, one line per event { at, by, kind, ... }:
|
|
21
23
|
* propose { id, type: 'start' | 'scan', title, why, sources: [{ label, ref }], data } the last line for an id wins
|
|
@@ -46,7 +48,7 @@ const LEDGER = 'idle-lab.jsonl';
|
|
|
46
48
|
const KINDS = new Set(['propose', 'drop', 'keep', 'undo', 'run', 'next']);
|
|
47
49
|
const GROUPS = Object.freeze(['prototyped', 'improved', 'scanned']);
|
|
48
50
|
const TITLES = Object.freeze({ prototyped: 'PMOS prototyped it', improved: 'PMOS improved it', scanned: 'PMOS scanned for it' });
|
|
49
|
-
const LOOSE = Object.freeze(['start', 'scan']);
|
|
51
|
+
const LOOSE = Object.freeze(['start', 'scan', 'rule']);
|
|
50
52
|
const PROVEN = Object.freeze({ production: false, design: false });
|
|
51
53
|
const WEEK = 7 * 864e5;
|
|
52
54
|
const LIM = { title: 140, why: 300, label: 80, ref: 500, caption: 120, file: 200, changed: 200, checked: 200 };
|
|
@@ -140,6 +142,11 @@ function loose(type, input) {
|
|
|
140
142
|
if (!one(d.title, LIM.title) || !ID_RE.test(str(d.board)) || !one(d.anchor, 80)) return { error: 'start needs data { title, board, anchor }: the new initiative, its board and what it counts toward' };
|
|
141
143
|
Object.assign(data, { title: one(d.title, LIM.title), board: d.board, anchor: one(d.anchor, 80), ...(str(d.stage) ? { stage: one(d.stage, 40) } : {}) });
|
|
142
144
|
}
|
|
145
|
+
if (type === 'rule') {
|
|
146
|
+
const K = require('./correction-kinds.js');
|
|
147
|
+
if (!K.IDS.includes(str(d.kind))) return { error: 'rule needs data { kind }: one of ' + K.IDS.join(', ') };
|
|
148
|
+
Object.assign(data, { kind: d.kind, n: Math.max(0, Math.floor(Number(d.n) || 0)) });
|
|
149
|
+
}
|
|
143
150
|
if (str(d.refreshed)) data.refreshed = one(d.refreshed, LIM.checked);
|
|
144
151
|
const id = ID_RE.test(str(input.id)) ? input.id : 'lab-' + hash([type, title].join('|'));
|
|
145
152
|
return { prop: { id, type, title, why, sources: s.v, data } };
|
|
@@ -215,16 +222,20 @@ function labOf({ P, L, extra = [], now = Date.now(), titleOf = () => '' } = {})
|
|
|
215
222
|
if (!inWeek(p.at)) continue;
|
|
216
223
|
const state = keptL.has(p.id) ? 'kept' : L.drops.has(p.id) ? 'dropped' : 'open';
|
|
217
224
|
tally.scan[1]++; if (state === 'kept') tally.scan[0]++;
|
|
218
|
-
|
|
225
|
+
const rule = p.type === 'rule';
|
|
226
|
+
record.push({ kind: 'loose', id: p.id, at: p.at, state, why: state === 'dropped' ? (L.drops.get(p.id).why || '') : '', title: (rule ? 'Standing rule · ' : 'Scan · ') + p.title,
|
|
227
|
+
meta: rule ? plural((p.data && p.data.n) || (p.sources || []).length, 'correction', 'corrections') : plural((p.sources || []).length, 'page', 'pages') + ' read' });
|
|
219
228
|
}
|
|
220
229
|
for (const x of extra || []) if (x && inWeek(x.at) && one(x.title, LIM.title)) record.push({ kind: 'job', job: one(x.job, 40), at: x.at, state: 'done', title: one(x.title, LIM.title), meta: one(x.meta, LIM.why), ...(x.ini ? { ini: x.ini, board: x.board || '' } : {}) });
|
|
221
230
|
record.sort((a, b) => String(b.at).localeCompare(String(a.at)));
|
|
222
231
|
const next = L.next && L.next.items.length ? L.next.items : [];
|
|
223
232
|
if (!record.length && !open.length && !next.length) return null;
|
|
224
233
|
const filed = tally.proto[1] + tally.scan[1], kept = tally.proto[0] + tally.scan[0];
|
|
234
|
+
const nRule = open.filter((p) => p.type === 'rule').length, nFind = open.length - nRule;
|
|
225
235
|
const idle = L.runs.filter((r) => inWeek(r.at)).reduce((s, r) => s + r.ms, 0);
|
|
226
236
|
const say = [idle ? 'This week I used ' + fmtMs(idle) + ' of your idle time.' : '', filed ? 'You kept ' + kept + ' of ' + filed + '.' : '',
|
|
227
|
-
|
|
237
|
+
nFind ? plural(nFind, 'finding fits', 'findings fit') + ' no initiative yet.' : '',
|
|
238
|
+
nRule ? plural(nRule, 'correction repeats', 'corrections repeat') + ': keep ' + (nRule === 1 ? 'it' : 'them') + ' as a standing rule?' : ''].filter(Boolean).join(' ');
|
|
228
239
|
return { say, loose: open.map((p) => ({ id: p.id, type: p.type, title: p.title, why: p.why, sources: p.sources, data: p.data, at: p.at })),
|
|
229
240
|
record: record.slice(0, 12), more: Math.max(0, record.length - 12),
|
|
230
241
|
kept: filed ? { kept, filed, proto: tally.proto, scan: tally.scan } : null, next };
|
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
* itself with Undo); a goal PMOS failed to read twice the same way files ONE ask (class C); else one short run per initiative and check date
|
|
29
29
|
* reads the records (deps.startRun, <state>/outcome-runs.jsonl). What none of these can tell stays due, and Your move asks the PM once.
|
|
30
30
|
*
|
|
31
|
+
* A BLOCKED CHECK (bet A451). A check whose place of measure runs an older version than the one that shipped the change (lib/outcomes.js
|
|
32
|
+
* scan `blocked`) is not due: it is never judged and starts no run. The pass logs one `[outcome-blocked]` line when a check becomes blocked
|
|
33
|
+
* (per check and version pair) and one when it clears, so the health number and its dates can be read from the server log.
|
|
34
|
+
*
|
|
31
35
|
* deps: { workspaces() → [w], isLead(w), stateDirFor(w), boardOf(w, id) → board id | null, runtime() → the per-user state folder, open(now),
|
|
32
36
|
* env, every (ms, its own timer), mayRun(), warn(what, err),
|
|
33
37
|
* recordsDir(w)? → the goal records folder, startRun(w, { ini, board, it, why, now })? → { ok, run } | { ok: false, held?, error } }
|
|
@@ -79,6 +83,8 @@ function cases(S, list) {
|
|
|
79
83
|
|
|
80
84
|
function create(deps) {
|
|
81
85
|
const warn = deps.warn || (() => {});
|
|
86
|
+
const log = deps.log || ((s) => console.log(s));
|
|
87
|
+
const blockedSeen = new Map(); // ws id → Map ini → the logged `shipped|runs` pair
|
|
82
88
|
const lastDay = new Map(); // ws id → the local day it ran
|
|
83
89
|
let busy = false;
|
|
84
90
|
|
|
@@ -159,6 +165,7 @@ function create(deps) {
|
|
|
159
165
|
const dir = deps.stateDirFor(w); if (!dir) return { ws: w.id, filed: 0, runs: 0 };
|
|
160
166
|
const S = O.scan(w.root, { today: localDay(now) });
|
|
161
167
|
const F = PR.read(dir), kept = PR.keptIds(F);
|
|
168
|
+
logBlocked(w, S);
|
|
162
169
|
const dueBy = new Map(S.due.map((it) => [it.id, it]));
|
|
163
170
|
// a verdict or ask whose check is no longer due on its date (the PM answered it, or moved the date) goes: zero is silence
|
|
164
171
|
for (const p of F.props.values()) {
|
|
@@ -214,6 +221,18 @@ function create(deps) {
|
|
|
214
221
|
return { ws: w.id, filed, held, runs };
|
|
215
222
|
}
|
|
216
223
|
|
|
224
|
+
/** One log line when a check becomes blocked (or blocked on another version pair), and one when it clears. */
|
|
225
|
+
function logBlocked(w, S) {
|
|
226
|
+
const seen = blockedSeen.get(w.id) || new Map(), now = new Map();
|
|
227
|
+
for (const it of S.blocked || []) {
|
|
228
|
+
const pair = it.blocked.shipped + '|' + it.blocked.runs;
|
|
229
|
+
now.set(it.id, pair);
|
|
230
|
+
if (seen.get(it.id) !== pair) log(`${O.LIVE_TAG} ${w.id} ${it.id} blocked: ${it.blocked.why}. ${it.blocked.step}.`);
|
|
231
|
+
}
|
|
232
|
+
for (const id of seen.keys()) if (!now.has(id)) log(`${O.LIVE_TAG} ${w.id} ${id} cleared`);
|
|
233
|
+
blockedSeen.set(w.id, now);
|
|
234
|
+
}
|
|
235
|
+
|
|
217
236
|
async function tick({ now = Date.now() } = {}) {
|
|
218
237
|
if (off(deps.env) || busy) return { off: off(deps.env), running: busy };
|
|
219
238
|
busy = true;
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
/* outcomes-cli.js — `pmos outcomes`: no initiative without an expected outcome (initiative outcome-for-every-initiative; lib/outcomes.js, D57).
|
|
3
3
|
*
|
|
4
4
|
* pmos outcomes list [--json] every initiative's outcome state in this repository: checks due, outcomes with no
|
|
5
|
-
* date, initiatives with no outcome, pending and checked. Reads only.
|
|
5
|
+
* date, initiatives with no outcome, blocked, pending and checked. Reads only.
|
|
6
|
+
* pmos outcomes live --where <place> --version <v> the version a place runs now (bet A451), appended to live_versions.jsonl. A check
|
|
7
|
+
* whose record says shipped_in a newer version and measured_on that place is blocked.
|
|
6
8
|
* pmos outcomes propose [<id>] [--max <n>] [--json] Claude's ✦ drafts, each claim cited path:line, through the shared guard
|
|
7
9
|
* (lib/ai-guard.js). Before the first draft of a repository it replays them on its real
|
|
8
10
|
* records. Writes only the guard's audit, in the per-user folder.
|
|
@@ -20,13 +22,14 @@ const path = require('path');
|
|
|
20
22
|
const { execFileSync } = require('child_process');
|
|
21
23
|
const O = require('./outcomes.js');
|
|
22
24
|
|
|
23
|
-
const COMMANDS = { outcomes: ['list', 'propose', 'declare', 'record'] };
|
|
25
|
+
const COMMANDS = { outcomes: ['list', 'propose', 'declare', 'record', 'live'] };
|
|
24
26
|
const USAGE = [
|
|
25
|
-
'usage: pmos outcomes list|propose|declare|record — every initiative has an expected outcome and a date to check it',
|
|
27
|
+
'usage: pmos outcomes list|propose|declare|record|live — every initiative has an expected outcome and a date to check it',
|
|
26
28
|
' pmos outcomes list [--json] checks due, outcomes with no date, initiatives with no outcome; reads only',
|
|
27
29
|
' pmos outcomes propose [<id>] [--max <n>] [--json] PMOS\'s ✦ drafts from the PRD and the KR, each one cited',
|
|
28
30
|
' pmos outcomes declare <id> --metric "<text>" --horizon <YYYY-MM-DD> the PM said yes: write the outcome and its check date',
|
|
29
31
|
' pmos outcomes record <id> <worked|didnt-work|cant-tell> --evidence "<text>" the PM\'s verdict on a due check',
|
|
32
|
+
' pmos outcomes live --where <place> --version <v> the version a place runs now; a check measured there waits until it runs the shipped one',
|
|
30
33
|
'Run it in the product\'s repository, or pass --root <dir>. Show each ✦ to the PM and write only after a yes.',
|
|
31
34
|
];
|
|
32
35
|
const VERDICT = { worked: 'validated', validated: 'validated', 'didnt-work': 'refuted', "didn't-work": 'refuted', refuted: 'refuted', 'cant-tell': 'inconclusive', "can't-tell": 'inconclusive', inconclusive: 'inconclusive' };
|
|
@@ -57,7 +60,7 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
|
|
|
57
60
|
if (!sub || ['help', '--help', '-h'].includes(sub)) { for (const l of USAGE) say(l); return sub ? 0 : 1; }
|
|
58
61
|
if (!COMMANDS.outcomes.includes(sub)) { say(`unknown outcomes command "${sub}". Use one of: ${COMMANDS.outcomes.join(', ')}`); return 2; }
|
|
59
62
|
const { pos, flags } = parse(args.slice(1));
|
|
60
|
-
const allowed = { list: ['json', 'root'], propose: ['json', 'root', 'max'], declare: ['json', 'root', 'metric', 'horizon'], record: ['json', 'root', 'evidence'] }[sub];
|
|
63
|
+
const allowed = { list: ['json', 'root'], propose: ['json', 'root', 'max'], declare: ['json', 'root', 'metric', 'horizon'], record: ['json', 'root', 'evidence'], live: ['json', 'root', 'where', 'version'] }[sub];
|
|
61
64
|
for (const k of Object.keys(flags)) if (!allowed.includes(k)) { say(`✗ --${k} is not an option of pmos outcomes ${sub}`); return 2; }
|
|
62
65
|
const root = path.resolve(flags.root || repoRoot(cwd));
|
|
63
66
|
const today = O.todayOf(now);
|
|
@@ -67,10 +70,12 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
|
|
|
67
70
|
if (pos.length) return fail('pmos outcomes list takes no argument', 2);
|
|
68
71
|
const S = O.scan(root, { today });
|
|
69
72
|
const pick = (a) => a.map((it) => ({ id: it.id, title: it.title, lane: it.lane, metric: it.metric || null, horizon: it.horizon || null }));
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
const blocked = S.blocked.map((it) => ({ ...pick([it])[0], where: it.blocked.where, runs: it.blocked.runs, shipped: it.blocked.shipped, step: it.blocked.step }));
|
|
74
|
+
if (flags.json) { say(JSON.stringify({ ok: true, total: S.subjects.length, due: pick(S.due), undated: pick(S.undated), missing: pick(S.missing), recent: S.recent, pending: pick(S.pending), blocked, disposed: S.disposed.map((d) => ({ id: d.id, disposition: d.disposition })), shippedWithout: S.shippedWithout, notRead: S.notRead })); return 0; }
|
|
75
|
+
const named = S.due.length + S.undated.length + S.pending.length + S.blocked.length + S.disposed.length;
|
|
72
76
|
say(`${S.subjects.length} initiatives · ${named} name an expected outcome · ${named - S.undated.length} of those have a check date · ${S.disposed.length} checked`);
|
|
73
77
|
if (S.due.length) say(`\n${S.due.length} check${S.due.length === 1 ? '' : 's'} due:\n` + S.due.map((it) => ` ${it.id} — since ${O.short(it.horizon)} · ${it.metric}`).join('\n'));
|
|
78
|
+
if (S.blocked.length) say(`\n${S.blocked.length} check${S.blocked.length === 1 ? '' : 's'} blocked (no verdict until the place it is measured runs the change):\n` + S.blocked.map((it) => ` ${it.id} — ${it.blocked.why}. ${it.blocked.step}, then: pmos outcomes live --where ${JSON.stringify(it.blocked.where)} --version <version>`).join('\n'));
|
|
74
79
|
if (S.undated.length) say(`\n${S.undated.length} with no check date:\n` + S.undated.map((it) => ` ${it.id} — ${it.metric}`).join('\n'));
|
|
75
80
|
if (S.missing.length) say(`\n${S.missing.length} under way with no expected outcome${S.recent ? ` (${S.recent} edited in the last 30 days)` : ''}:\n` + S.missing.slice(0, 15).map((it) => ` ${it.id} — ${it.title}`).join('\n') + (S.missing.length > 15 ? `\n … and ${S.missing.length - 15} more (--json lists all)` : ''));
|
|
76
81
|
if (S.shippedWithout) say(`\n${S.shippedWithout} accepted with no outcome: too late to declare, counted only.`);
|
|
@@ -113,6 +118,16 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
|
|
|
113
118
|
return 0;
|
|
114
119
|
}
|
|
115
120
|
|
|
121
|
+
if (sub === 'live') {
|
|
122
|
+
if (pos.length) return fail('usage: pmos outcomes live --where <place> --version <version>', 2);
|
|
123
|
+
const r = O.recordLive(root, { where: flags.where, version: flags.version, by: 'cli' }, { now });
|
|
124
|
+
if (!r.ok) return fail(r.error, 2);
|
|
125
|
+
if (flags.json) { say(JSON.stringify({ ok: true, file: r.file, line: r.line })); return 0; }
|
|
126
|
+
const still = O.scan(root, { today }).blocked.filter((it) => it.blocked.where.toLowerCase() === r.line.where.toLowerCase()).length;
|
|
127
|
+
say(`✓ ${r.line.where} runs ${r.line.version} (${r.file}).${still ? ` ${still} outcome check${still === 1 ? ' is' : 's are'} still blocked there.` : ''} Commit it to keep it.`);
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
116
131
|
const id = pos[0];
|
|
117
132
|
const actor = require('./actor.js').fromCli({ isTTY: isTTY === undefined ? !!(process.stdin.isTTY && process.stdout.isTTY) : isTTY, env });
|
|
118
133
|
|
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
* outcome ledger takes the PM's verdict. On real data almost nothing used it (2026-11-03: 10 of 62 product initiatives named an outcome,
|
|
7
7
|
* 8 had a date, 0 were checked; 3 checks were overdue). The field was optional and nothing asked for it. This module makes Claude ask:
|
|
8
8
|
*
|
|
9
|
-
* scan(root, { today }) → { subjects, missing (newest first), recent (how many of them were edited in the last 30 days), undated, due, pending, disposed, shippedWithout, notRead }
|
|
9
|
+
* scan(root, { today }) → { subjects, missing (newest first), recent (how many of them were edited in the last 30 days), undated, due, pending, blocked, disposed, shippedWithout, notRead }
|
|
10
|
+
* blocked (bet A451) is an outcome check that cannot be read yet: the record names the version that ships the change (`shipped_in`) and
|
|
11
|
+
* the place its outcome is read (`measured_on`), and that place's newest line in live_versions.jsonl is an older version. It is in
|
|
12
|
+
* neither `due` nor `pending`, so nobody is asked for a verdict and no check run starts; it.blocked says why and the one step to fix it.
|
|
13
|
+
* recordLive(root, { where, version, by }) → { ok, file, line } the one writer of live_versions.jsonl (`pmos outcomes live`)
|
|
10
14
|
* every WORK initiative of the repository (document lanes are files, D86) that is not stopped. `missing` is a live one (not accepted)
|
|
11
15
|
* with no outcome_metric; `shippedWithout` counts the accepted ones with none (too late to declare, only counted).
|
|
12
16
|
* drafts(root, S, { today, only? }) → [proposal] ranked: due checks, then undated outcomes, then missing outcomes
|
|
@@ -114,7 +118,8 @@ function scan(root, { today = todayOf() } = {}) {
|
|
|
114
118
|
const disposedBy = new Map();
|
|
115
119
|
for (const c of liveChecks(ledger(root, L, 'outcome_checks.jsonl'))) if (c && c.initiative_id && DISPOSITIONS.includes(c.disposition)) disposedBy.set(String(c.initiative_id), c);
|
|
116
120
|
|
|
117
|
-
const
|
|
121
|
+
const live = liveOf(root, L);
|
|
122
|
+
const subjects = [], missing = [], undated = [], due = [], pending = [], blocked = [], disposed = [];
|
|
118
123
|
let shippedWithout = 0;
|
|
119
124
|
for (const f of files) {
|
|
120
125
|
const file = path.join(L.initiatives, f);
|
|
@@ -139,17 +144,75 @@ function scan(root, { today = todayOf() } = {}) {
|
|
|
139
144
|
const checked = d && !reopened(it, d);
|
|
140
145
|
if (checked) disposed.push({ ...it, disposition: d.disposition });
|
|
141
146
|
else if (!it.horizon) undated.push(it);
|
|
147
|
+
else if ((it.blocked = blockedOf(root, it, live, today))) blocked.push(it);
|
|
142
148
|
else if (it.horizon <= today) due.push(it);
|
|
143
149
|
else pending.push(it);
|
|
144
150
|
}
|
|
145
151
|
due.sort((a, b) => (a.horizon < b.horizon ? -1 : 1));
|
|
152
|
+
blocked.sort((a, b) => (a.horizon < b.horizon ? -1 : 1));
|
|
146
153
|
// newest first: the record's timestamp is its last edit. `recent` is what was touched in the last RECENT_DAYS days, where a backfill
|
|
147
154
|
// starts (an old record with no acceptance line may well have shipped long ago: D94 merges need none).
|
|
148
155
|
const stamp = (it) => String((it.fm.timestamp || {}).value || '').slice(0, 10);
|
|
149
156
|
missing.sort((a, b) => stamp(b).localeCompare(stamp(a)) || a.id.localeCompare(b.id));
|
|
150
157
|
const since = addDays(today, -RECENT_DAYS);
|
|
151
158
|
const recent = missing.filter((it) => stamp(it) >= since).length;
|
|
152
|
-
return { root, layout: L, today, subjects, recent, missing, undated, due, pending, disposed, shippedWithout, notRead };
|
|
159
|
+
return { root, layout: L, today, subjects, recent, missing, undated, due, pending, blocked, disposed, shippedWithout, notRead };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* ── a check the place it is measured cannot answer yet (bet A451) ─────────────────────────────────────────────────── */
|
|
163
|
+
|
|
164
|
+
const LIVE = 'live_versions.jsonl';
|
|
165
|
+
const LIVE_TAG = '[outcome-blocked]';
|
|
166
|
+
const placeKey = (s) => String(s || '').replace(/\s+/g, ' ').trim().toLowerCase();
|
|
167
|
+
/** Dotted numbers compared (a leading v and a pre-release tail are ignored). → -1 | 0 | 1, or null when either does not compare. */
|
|
168
|
+
function cmpVersion(a, b) {
|
|
169
|
+
const parts = (v) => { const m = /^v?(\d+(?:\.\d+)*)(?:[-+].*)?$/i.exec(String(v || '').trim()); return m ? m[1].split('.').map(Number) : null; };
|
|
170
|
+
const x = parts(a), y = parts(b);
|
|
171
|
+
if (!x || !y) return null;
|
|
172
|
+
for (let i = 0; i < Math.max(x.length, y.length); i++) { const d = (x[i] || 0) - (y[i] || 0); if (d) return d < 0 ? -1 : 1; }
|
|
173
|
+
return 0;
|
|
174
|
+
}
|
|
175
|
+
/** The newest live version of each place, from every live_versions.jsonl of the repository. → Map placeKey → { where, version, at, ref, quote } */
|
|
176
|
+
function liveOf(root, L) {
|
|
177
|
+
const out = new Map();
|
|
178
|
+
const files = [...new Set([path.join(L.runsDir, LIVE), path.join(root, 'pmos', 'state', LIVE), path.join(root, 'planning', 'runs', LIVE)])];
|
|
179
|
+
for (const f of files) (linesOf(f) || []).forEach((l, i) => {
|
|
180
|
+
let o = null; try { o = JSON.parse(l); } catch { return; }
|
|
181
|
+
if (!o || typeof o.where !== 'string' || typeof o.version !== 'string' || !o.where.trim() || !o.version.trim()) return;
|
|
182
|
+
const k = placeKey(o.where), prev = out.get(k), at = String(o.at || '');
|
|
183
|
+
if (!prev || at >= prev.at) out.set(k, { where: o.where.trim(), version: o.version.trim(), at, ref: rel(root, f) + ':' + (i + 1), quote: cut(l) });
|
|
184
|
+
});
|
|
185
|
+
return out;
|
|
186
|
+
}
|
|
187
|
+
/** Why this outcome check cannot be read yet, or null. → { where, runs, shipped, due, step, sources } */
|
|
188
|
+
function blockedOf(root, it, live, today) {
|
|
189
|
+
const sh = it.fm.shipped_in, on = it.fm.measured_on;
|
|
190
|
+
if (!sh || !on || !sh.value || !on.value) return null;
|
|
191
|
+
const now = live.get(placeKey(on.value));
|
|
192
|
+
if (!now || cmpVersion(now.version, sh.value) !== -1) return null;
|
|
193
|
+
const where = now.where;
|
|
194
|
+
return {
|
|
195
|
+
where, runs: now.version, shipped: sh.value, due: it.horizon <= today,
|
|
196
|
+
why: `${where} runs ${now.version}, the change shipped in ${sh.value}`,
|
|
197
|
+
step: `Update ${where} to ${sh.value} or later`,
|
|
198
|
+
sources: [src(root, path.join(root, it.record), sh.n, sh.text, 'Shipped in'), { label: `What ${where} runs`, ref: now.ref, quote: now.quote }],
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/** The one writer of live_versions.jsonl: the version a place runs now (`pmos outcomes live`, or a deploy script). → { ok, file, line } | { ok: false, error } */
|
|
202
|
+
function recordLive(root, { where, version, by }, { now = Date.now() } = {}) {
|
|
203
|
+
root = path.resolve(root);
|
|
204
|
+
const w = String(where == null ? '' : where).replace(/\s+/g, ' ').trim(), v = String(version == null ? '' : version).trim();
|
|
205
|
+
if (!w || w.length > 80) return { ok: false, error: 'name the place it runs (--where, up to 80 characters), for example production or test bed' };
|
|
206
|
+
if (!v || v.length > 40 || /\s/.test(v)) return { ok: false, error: 'give the version it runs now (--version), for example 2.4.0' };
|
|
207
|
+
const L = layoutOf(root), file = path.join(L.runsDir, LIVE);
|
|
208
|
+
try {
|
|
209
|
+
fs.mkdirSync(L.runsDir, { recursive: true });
|
|
210
|
+
const st = (() => { try { return fs.lstatSync(file); } catch { return null; } })();
|
|
211
|
+
if (st && !st.isFile()) return { ok: false, error: 'the live versions ledger is not a plain file — nothing was saved' };
|
|
212
|
+
const line = { where: w, version: v, at: new Date(now).toISOString(), by: by || 'cli' };
|
|
213
|
+
fs.appendFileSync(file, JSON.stringify(line) + '\n');
|
|
214
|
+
return { ok: true, file: rel(root, file), line };
|
|
215
|
+
} catch (e) { return { ok: false, error: 'the live versions ledger could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
|
|
153
216
|
}
|
|
154
217
|
|
|
155
218
|
/* ── sources ──────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
@@ -511,4 +574,4 @@ function undoCheck(root, { initiative, at, by, via }, { now = Date.now() } = {})
|
|
|
511
574
|
}
|
|
512
575
|
|
|
513
576
|
module.exports = { VERSION, undoCheck, liveChecks, JOB, DAYS_AFTER, DEFAULT_DAYS, DISPOSITIONS, scan, drafts, prdMetric, anchorMetric, horizonFor, recordCheck, todayOf, short, frontOf,
|
|
514
|
-
experimentField, krMismatch, killMet, anyRefuted, verdictsOf, rowOutcomes, outcomeOfRow, refutedDrafts, setLife, NEXT_WORDS };
|
|
577
|
+
experimentField, krMismatch, killMet, anyRefuted, verdictsOf, rowOutcomes, outcomeOfRow, refutedDrafts, setLife, NEXT_WORDS, cmpVersion, recordLive, LIVE, LIVE_TAG };
|
|
@@ -135,7 +135,7 @@ const VERBS = Object.freeze({
|
|
|
135
135
|
help: 'pmos pages [show|check] — each page\'s fixes, reverts and restores in the last 14 days, and a feature change that adds to a page that keeps breaking (pmos pages help)' }),
|
|
136
136
|
// Not a pm-os-absorb verb (run: null): initiative outcome-for-every-initiative added it through the same table.
|
|
137
137
|
outcomes: Object.freeze({ module: 'outcomes-cli.js', run: null, guide: 'cli.md',
|
|
138
|
-
help: 'pmos outcomes list|propose|declare|record — every initiative\'s expected outcome and check date: Claude\'s cited drafts, the PM\'s yes,
|
|
138
|
+
help: 'pmos outcomes list|propose|declare|record|live — every initiative\'s expected outcome and check date: Claude\'s cited drafts, the PM\'s yes, the verdict when a check is due, and the version a place runs (pmos outcomes help)' }),
|
|
139
139
|
// Not a pm-os-absorb verb (run: null): initiative decision-journal-outcome-checks added it through the same table.
|
|
140
140
|
decisions: Object.freeze({ module: 'decisions-cli.js', run: null, guide: 'cli.md',
|
|
141
141
|
help: 'pmos decisions add|list|show|check|record — a decision journal: what you decided, what you expect, a date to check, and how your calls turned out (pmos decisions help)' }),
|
|
@@ -190,6 +190,14 @@ const WRITES = {
|
|
|
190
190
|
if (r.error) return fail(ctx, res, 409, r.error);
|
|
191
191
|
wrote.push(r.write); said = 'Started ' + p.data.title + '.';
|
|
192
192
|
}
|
|
193
|
+
if (p.type === 'rule') {
|
|
194
|
+
// a standing rule (lib/correction-kinds.js, bet A464): the PM's own memory entry, so it is confirmed and never goes stale
|
|
195
|
+
const by = humanOf(g.actor);
|
|
196
|
+
if (!by) return fail(ctx, res, 403, 'Only the PM keeps a standing rule');
|
|
197
|
+
const r = ruleWrite(w.root, { op: 'add', text: p.title, by, source: 'rule:' + ((p.data && p.data.kind) || '') });
|
|
198
|
+
if (!r.ok) return fail(ctx, res, 409, 'The rule was not saved: ' + r.error);
|
|
199
|
+
wrote.push({ op: 'memory', text: p.title }); said = 'PMOS will follow this from now on.';
|
|
200
|
+
}
|
|
193
201
|
const batch = PR.newBatch();
|
|
194
202
|
LAB.append(dir, g.actor, { kind: 'keep', id: p.id, batch, wrote });
|
|
195
203
|
ctx.json(res, { ok: true, batch, said });
|
|
@@ -209,6 +217,11 @@ const WRITES = {
|
|
|
209
217
|
const F = LAB.read(dir), b = String(body.batch || '');
|
|
210
218
|
const known = F.kept.some((k) => k.batch === b) || readsDrop(dir, b);
|
|
211
219
|
if (!known || F.undone.has(b)) return fail(ctx, res, 409, 'Nothing to undo');
|
|
220
|
+
// a kept standing rule: take its memory entry out again
|
|
221
|
+
for (const k of F.kept) if (k.batch === b) for (const x of k.wrote) if (x.op === 'memory' && x.text) {
|
|
222
|
+
const r = ruleWrite(w.root, { op: 'remove', old: x.text, by: humanOf(g.actor) || 'agent:corrections' });
|
|
223
|
+
if (!r.ok && !/no (?:entry|match)|not found/i.test(String(r.error))) return fail(ctx, res, 409, 'The rule was not removed: ' + r.error);
|
|
224
|
+
}
|
|
212
225
|
LAB.append(dir, g.actor, { kind: 'undo', batch: b });
|
|
213
226
|
ctx.json(res, { ok: true });
|
|
214
227
|
return true;
|
|
@@ -253,6 +266,14 @@ const WRITES = {
|
|
|
253
266
|
},
|
|
254
267
|
};
|
|
255
268
|
const COMMENTS = 'lab-comments.jsonl';
|
|
269
|
+
/* The PM's press as the memory ledger names a person ('pm:<slug>' → 'human:<slug>', lib/pm-slug.js), or null. */
|
|
270
|
+
const humanOf = (actor) => { const by = String((actor && actor.by) || ''); return /^pm:[A-Za-z0-9_-]{1,40}$/.test(by) ? 'human:' + by.slice(3) : /^human:/.test(by) ? by : null; };
|
|
271
|
+
/* One memory write for a standing rule (D72 ledger through lib/memory.js). */
|
|
272
|
+
function ruleWrite(root, req) {
|
|
273
|
+
const c = require('./memory.js').core();
|
|
274
|
+
if (!c.ok) return { ok: false, error: c.error };
|
|
275
|
+
try { return c.core.write(root, { target: 'memory', ...req }); } catch (e) { return { ok: false, error: String((e && e.message) || e).slice(0, 160) }; }
|
|
276
|
+
}
|
|
256
277
|
/* ── delete a prototype version (batch 31 item 9, Wawan 2026-11-18: "should be able to delete the prototype") ──
|
|
257
278
|
* Asked in the chat ("delete version 1"), the chat's agent runs `pmos lab delete`; in the Viewer, the trash in the version bar. No
|
|
258
279
|
* confirm: Undo is the safety (the delete-task rule). The version's folder (<round>/<key>/: the prototype, its flow, lanes, copy, tweaks and
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.706.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.706.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -172,7 +172,9 @@ export function comingUp(v, M) {
|
|
|
172
172
|
for (const g of (st && st.gates && st.gates.open) || []) if (!g.late && g.iso) add('due', g.iso, stop(g.name + ' is due'), 'From the milestone task' + (g.owner ? ', owner ' + g.owner : ''));
|
|
173
173
|
if (st && st.endIso && st.dates && !st.dates.over) add('due', st.endIso, 'The plan ends.', 'From the initiative’s end date');
|
|
174
174
|
const A = M && M.ahead;
|
|
175
|
-
|
|
175
|
+
// bet A451: a check the place it is measured cannot answer yet says so, with the one step that fixes it
|
|
176
|
+
if (A && A.outcome && A.outcome.date && A.outcome.blocked) add('outcome', A.outcome.date < today ? today : A.outcome.date, stop('Outcome check blocked: ' + A.outcome.blocked.why) + ' ' + stop(A.outcome.blocked.step), 'From the version on the record and the version that place runs');
|
|
177
|
+
else if (A && A.outcome && A.outcome.date) add('outcome', A.outcome.date, stop('Outcome check: ' + (A.outcome.metric || 'the outcome')), 'From the outcome check date on the record');
|
|
176
178
|
if (M && M.kill) {
|
|
177
179
|
const k = dateIn(M.kill, today), b = k ? '' : dateIn(M.budget, today);
|
|
178
180
|
if (k || b) add('kill', k || b, stop('Kill check: ' + M.kill), k ? 'From the experiment’s stop line' : 'From the end of the experiment’s budget');
|