create-pmos 0.705.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 +9 -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 +8 -2
- package/workspace/guide/settings-and-switches.md +1 -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/routes-lab.js +21 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -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
|
{
|
|
@@ -49,6 +49,12 @@
|
|
|
49
49
|
"t": "A blocked outcome check shows as blocked, with the step to fix it (A451)",
|
|
50
50
|
"s": "A blocked outcome check shows as blocked, with the step to fix it (A451)",
|
|
51
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"
|
|
52
58
|
}
|
|
53
59
|
]
|
|
54
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
|
{
|
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
"t": "A blocked outcome check shows as blocked, with the step to fix it (A451)",
|
|
16
16
|
"s": "A blocked outcome check shows as blocked, with the step to fix it (A451)",
|
|
17
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"
|
|
18
24
|
}
|
|
19
25
|
]
|
|
20
26
|
},
|
|
@@ -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 | — |
|
|
@@ -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 };
|
|
@@ -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