create-pmos 0.576.0 → 0.577.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.576.0",
3
+ "version": "0.577.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,19 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.577.0",
38
+ "at": "2026-11-17T01:37:16.629Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1310,
43
+ "t": "Improvement signals ledger, 183 feedback items, honest shallow clone, verifier that runs anywhere",
44
+ "s": "Improvement signals ledger, 183 feedback items, honest shallow clone, verifier that runs anywhere",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
36
49
  {
37
50
  "v": "0.576.0",
38
51
  "at": "2026-11-16T11:57:06.812Z",
@@ -291,19 +304,6 @@
291
304
  "k": "new"
292
305
  }
293
306
  ]
294
- },
295
- {
296
- "v": "0.557.0",
297
- "at": "2026-11-11T01:38:47.040Z",
298
- "f": 4,
299
- "prs": [
300
- {
301
- "n": 1286,
302
- "t": "Coming up is a short dated list of five kinds, each with its source",
303
- "s": "Coming up is a short dated list of five kinds, each with its source",
304
- "k": "new"
305
- }
306
- ]
307
307
  }
308
308
  ]
309
309
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@ad84cd2c
2
- assembled: 2026-11-16
1
+ kernel-source: pmos@e611ba9b
2
+ assembled: 2026-11-17
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-16T11:57:03Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-17T01:37:13Z"}
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-16T11:57:03Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-17T01:37:13Z"}
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-16T11:57:03Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-17T01:37:13Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  Newest first, ISO dates.
4
4
 
5
- ## 2026-11-16
5
+ ## 2026-11-17
6
6
 
7
7
  - Adopted OKF v0.2 (D73).
@@ -1,4 +1,17 @@
1
1
  [
2
+ {
3
+ "v": "0.577.0",
4
+ "at": "2026-11-17T01:37:16.629Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1310,
9
+ "t": "Improvement signals ledger, 183 feedback items, honest shallow clone, verifier that runs anywhere",
10
+ "s": "Improvement signals ledger, 183 feedback items, honest shallow clone, verifier that runs anywhere",
11
+ "k": "new"
12
+ }
13
+ ]
14
+ },
2
15
  {
3
16
  "v": "0.576.0",
4
17
  "at": "2026-11-16T11:57:06.812Z",
@@ -102,6 +102,7 @@ An "off" switch accepts `off`, `0`, `false` or `no` unless the row says a differ
102
102
  | `PMOS_FACTORY_GH_TOKEN` | The factory's own GitHub token, when `pmos/factory.json` names it in `identity.token_env`. The name must start with `PMOS_FACTORY_`. PMOS gives it to gh for its own calls and removes it from every agent run. Never put it in a file. | not set: your gh login | — |
103
103
  | `PMOS_VERIFY` | `off` stops the verifier that checks each merged pull request. | on | `pmos ai off verify` |
104
104
  | `PMOS_VERIFY_CHANGES` | `off` stops the check of the changes PMOS made by itself. A failed check sends that kind of change back to asking. | on | `pmos ai off verify` |
105
+ | `PMOS_SIGNALS` | `off` stops the hourly harvest of improvement signals (feedback, Undo, reverts, verifier failures) into the signals ledger. | on | `PMOS_SIGNALS=off` |
105
106
  | `PMOS_CHECK_REF`, `PMOS_CHECK_DIR` | Set by PMOS for one check run only. They name the change it checks and the ledger it writes to. Do not set them yourself. | — | — |
106
107
  | `PMOS_FACTORY_REVIEW` | `off` stops the independent review of factory pull requests. With no review, the guardrail reads HUMAN and you merge. | on | `pmos ai off verify` |
107
108
  | `PMOS_STORY_SEED` | `off` stops PMOS from writing the first story so far for a product that has none. | on | `pmos ai off story-seed` |
@@ -100,6 +100,11 @@ const LEDGERS = Object.freeze({
100
100
  'repo:planning/runs/evals.jsonl': { concept: 'review-verdicts', owner: 'repo:scripts/record-eval.js', readers: [
101
101
  r('repo:scripts/check-calibration.js', 'evals.jsonl', 'κ per evaluator model against the PM\'s labels'),
102
102
  r('repo:scripts/verifier.js', 'verdictOracle', 'a verdict closes its queue entry')] },
103
+ // improve-signals: one ledger per repository (lib/signals.js); the loop engine (lib/improve-*.js) reads it through signals.readSignals
104
+ 'repo:planning/improve/signals.jsonl': { concept: 'improve-signals', owner: 'lib/signals.js', readers: [
105
+ r('repo:scripts/signals.js', 'readSignals', '`node scripts/signals.js list`: the signals of PMOS itself')] },
106
+ '<state>/improve-signals.jsonl': { concept: 'improve-signals-product', owner: 'lib/signals.js', readers: [
107
+ r('repo:scripts/signals.js', 'productFile', "`node scripts/signals.js list --state <dir>`: a product's signals, counts and links only")] },
103
108
  'repo:planning/work-items.jsonl': { concept: 'work-items', owner: 'repo:scripts/work-item.js', readers: [
104
109
  r('lib/factory-join.js', 'work-items.jsonl', 'a plan item reads Done once its work item is integrated')] },
105
110
  // goals (one goal source, T2): the OKR files are the only goal list; lib/goal-source.js joins each key result to the kr-metrics record that reads it,
@@ -129,7 +134,10 @@ const JOBS = Object.freeze([
129
134
  q('grill', 'lib/grill-runs.js', [props, '<runtime>/grill-runs.jsonl'], [props, 'repo:DECISIONS.md']),
130
135
  q('metric-drafts', 'lib/metric-draft-runs.js', ['<state>/metric-drafts.jsonl'], ['<state>/metric-reads.jsonl']),
131
136
  q('impact', 'lib/impact-runs.js', ['<runtime>/impact.jsonl'], ['connectors']),
132
- q('verify', 'lib/verify-runs.js', ['repo:planning/runs/evals.jsonl', 'repo:planning/runs/verify-queue.jsonl', 'repo:planning/work-items.jsonl', '<state>/autonomy.jsonl'], ['repo:planning/runs/verify-queue.jsonl', '<state>/autonomy.jsonl', 'git']),
137
+ // improve-signals: the verify tick also harvests the improvement signals (lib/signals.js) into one ledger per repository, at most hourly
138
+ q('verify', 'lib/verify-runs.js', ['repo:planning/runs/evals.jsonl', 'repo:planning/runs/verify-queue.jsonl', 'repo:planning/work-items.jsonl', '<state>/autonomy.jsonl',
139
+ 'repo:planning/improve/signals.jsonl', '<state>/improve-signals.jsonl'],
140
+ ['repo:planning/runs/verify-queue.jsonl', '<state>/autonomy.jsonl', 'git', 'repo:discoveries.md', 'repo:planning/runs/outcome_checks.jsonl', props]),
133
141
  q('metric-reads', 'lib/metric-read-runs.js', ['<state>/metric-reads.jsonl'], ['connectors']),
134
142
  q('forecast', 'lib/forecast-tick.js', ['<state>/forecast.jsonl'], ['<state>/boards.jsonl']),
135
143
  q('report-design', 'lib/routes-report-design.js', ['<state>/design.jsonl']),
@@ -0,0 +1,272 @@
1
+ 'use strict';
2
+ /* signals.js — the improvement signals ledger (self-improvement loop, stage 0; initiative improve-signals).
3
+ *
4
+ * The loop (proposal doc GHwqMY9jM8cf3ZkNZ1MNnr) ranks what to fix by how often and how much a problem costs. This file reads every
5
+ * source PMOS already keeps into ONE shape, so the loop engine (lib/improve-*.js, W3) reads one file and needs no new instrumentation.
6
+ *
7
+ * THE TWO LEDGERS (append-only JSON lines; a reader tolerates extra keys):
8
+ * PMOS itself <root>/planning/improve/signals.jsonl tracked; words are kept (Wawan's own words about PMOS)
9
+ * a product <state>/improve-signals.jsonl gitignored runtime state; words is ALWAYS null (counts, ids and links only:
10
+ * customer text stays where it was written, never in a ledger the loop reads)
11
+ *
12
+ * ONE LINE: { v: 1, id, at, source, kind, area, words, link, ref, ...extra }
13
+ * id 'sg_' + 12 hex of sha1(kind + ref): the same source event read twice is one line
14
+ * source wawan | data | product | agent | outside (who the signal comes from)
15
+ * kind see KINDS
16
+ * area a short slug to cluster on (areaOf), or null
17
+ * words Wawan's words or the one-line evidence (≤ MAX_WORDS), or null
18
+ * link a commit, a file path, a URL, or null
19
+ * ref the stable source pointer the id is made from
20
+ * extra batch, n (feedback items), lead_only: true (friction: a lead, never a score), run_id, product
21
+ * The loop engine writes only loop-own numbers (source agent, kind loop); every other line is written here.
22
+ *
23
+ * HARVESTERS (pure on their inputs, each → [signal]):
24
+ * fromFeedback(text, { batch, file }) a feedback batch file (issues.md / briefs.md): one line per numbered item
25
+ * fromCorrections(rc) `run-corrections.js --json`: revert, fix-after-merge (none when the clone is shallow)
26
+ * fromEvals(text) evals.jsonl: verifier-fail (a verifier-after-merge FAIL)
27
+ * fromVerifyStall(queueText, evalsText, now) verifier-stalled: verdicts are owed and no claim or verdict for STALL_HOURS
28
+ * fromFriction(text) discoveries.md #friction entries (lead_only)
29
+ * fromOutcomes(text) outcome_checks.jsonl: outcome-missed (refuted or missed)
30
+ * fromStateDir(sd, { root }) ✕ reasons (x-reason), Undo / revert / verifier FAIL setbacks, factory setbacks
31
+ * fromReleaseReport(text, { version, file }) a release-check report.md: one release-check-fail per ✗ row
32
+ * harvestSelf(root, { run, stateDirs, now }) → the PMOS-self lines from the repo's own records
33
+ * harvestProduct(root, stateDir, { now }) → a product's lines (words dropped on write)
34
+ *
35
+ * readSignals(file) · appendSignals(file, rows, { product }) → { added } · pmosSelfFile(root) · productFile(stateDir)
36
+ * idOf(kind, ref) · areaOf(text) · SOURCES · KINDS · MAX_WORDS · STALL_HOURS
37
+ */
38
+ const fs = require('fs');
39
+ const path = require('path');
40
+ const crypto = require('crypto');
41
+
42
+ const SOURCES = Object.freeze(['wawan', 'data', 'product', 'agent', 'outside']);
43
+ const KINDS = Object.freeze(['feedback', 'x-reason', 'undo', 'revert', 'fix-after-merge', 'ci-fail', 'release-check-fail', 'verifier-fail',
44
+ 'verifier-stalled', 'factory-setback', 'outcome-missed', 'friction', 'loop']);
45
+ const MAX_WORDS = 400;
46
+ const STALL_HOURS = 24;
47
+ const SELF = path.join('planning', 'improve', 'signals.jsonl');
48
+ const PRODUCT = 'improve-signals.jsonl';
49
+
50
+ const one = (s, n) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
51
+ const idOf = (kind, ref) => 'sg_' + crypto.createHash('sha1').update(String(kind) + '\0' + String(ref)).digest('hex').slice(0, 12);
52
+ const pmosSelfFile = (root) => (root ? path.join(root, SELF) : null);
53
+ const productFile = (sd) => (sd ? path.join(sd, PRODUCT) : null);
54
+ const iso = (t) => { const n = Date.parse(t); return Number.isFinite(n) ? new Date(n).toISOString() : null; };
55
+
56
+ /* Area slugs to cluster on: the first that matches. The same map the replay of the 183 items used (self-improvement-sim/classify.py),
57
+ * with ui-copy (a standing rule, W2) first and tests last. */
58
+ const AREAS = [
59
+ ['ui-copy', /"Claude[^"]{0,30}"|\bClaude\b.{0,40}\bPMOS\b|wording|copy\b|label/i],
60
+ ['phone-layout', /phone|mobile/i], ['home', /\bhome\b/i], ['board', /\bboard\b/i], ['viewer', /viewer/i],
61
+ ['timeline', /timeline|gantt/i], ['chat', /\bchat\b|session|composer/i], ['intelligence', /intelligence|report|metric|goal/i],
62
+ ['settings', /settings|sign.in|connector/i], ['menu', /menu|⋯|button/i], ['jira', /jira|ticket/i], ['meeting', /meeting|recording|calendar/i],
63
+ ['workflow', /workflow|stage|lane/i], ['tests', /\btest suite|\bsuites?\b|\bCI\b|\btests? (fail|failed|red)/i],
64
+ ];
65
+ function areaOf(text) {
66
+ const t = String(text || '');
67
+ for (const [a, re] of AREAS) if (re.test(t)) return a;
68
+ return null;
69
+ }
70
+ /* the area of a set of changed files: the workspace page or the top folder */
71
+ function areaOfFiles(files) {
72
+ const c = new Map();
73
+ for (const f of files || []) {
74
+ const m = /^workspace\/public\/pm\/([a-z-]+)/.exec(f) || /^workspace\/lib\/([a-z]+)/.exec(f) || /^([a-z-]+)\//.exec(f);
75
+ const a = m ? m[1].replace(/\.(js|css|html)$/, '') : null;
76
+ if (a) c.set(a, (c.get(a) || 0) + 1);
77
+ }
78
+ let best = null, n = 0;
79
+ for (const [a, k] of c) if (k > n) { best = a; n = k; }
80
+ return best;
81
+ }
82
+
83
+ function sig(kind, source, ref, { at, area = null, words = null, link = null, ...extra } = {}) {
84
+ return { v: 1, id: idOf(kind, ref), at: iso(at) || null, source, kind, area, words: words == null ? null : one(words, MAX_WORDS) || null, link: link || null, ref: String(ref), ...extra };
85
+ }
86
+
87
+ function jsonl(text) {
88
+ const out = [];
89
+ for (const l of String(text || '').split('\n')) { if (!l.trim()) continue; try { const o = JSON.parse(l); if (o && typeof o === 'object') out.push(o); } catch { /* a torn line */ } }
90
+ return out;
91
+ }
92
+ const readText = (f) => { try { return fs.readFileSync(f, 'utf8'); } catch { return ''; } };
93
+ function readSignals(file) { return file ? jsonl(readText(file)) : []; }
94
+
95
+ /** Append the rows not already in the ledger (by id). A product ledger keeps no words. → { added, file } */
96
+ function appendSignals(file, rows, { product = false } = {}) {
97
+ if (!file) return { added: 0, file };
98
+ const have = new Set(readSignals(file).map((r) => r.id));
99
+ const add = [];
100
+ for (const r of rows || []) {
101
+ if (!r || !r.id || have.has(r.id)) continue;
102
+ have.add(r.id);
103
+ add.push(product ? { ...r, words: null } : r);
104
+ }
105
+ if (add.length) {
106
+ fs.mkdirSync(path.dirname(file), { recursive: true });
107
+ fs.appendFileSync(file, add.map((r) => JSON.stringify(r)).join('\n') + '\n');
108
+ }
109
+ return { added: add.length, file };
110
+ }
111
+
112
+ /* ---- harvesters ---- */
113
+
114
+ /* A feedback batch file. An item is a numbered line ("3. …", "### 3) …") at the start of a line; the lines under it are its text.
115
+ * The item's time is the first ISO date in its text, else the file's frontmatter timestamp. */
116
+ const ITEM_RE = /^(?:#{2,3}\s+)?(\d{1,2})[.)]\s+(.*)/;
117
+ function fromFeedback(text, { batch, file = '' } = {}) {
118
+ const body = String(text || '');
119
+ const fm = /^---\n[\s\S]*?timestamp:\s*([^\n]+)\n[\s\S]*?---/.exec(body);
120
+ // the file's own date: its frontmatter timestamp, else the first date in its head ("# Feedback batch 20 (started 2026-11-01)")
121
+ const head = body.split('\n').slice(0, 8).join('\n');
122
+ const hd = /(20\d\d-\d\d-\d\d)/.exec(head);
123
+ const fileAt = fm ? fm[1].trim().replace(/^["']|["']$/g, '') : hd ? hd[1] : null;
124
+ const items = [];
125
+ let cur = null;
126
+ for (const line of body.split('\n')) {
127
+ const m = ITEM_RE.exec(line);
128
+ if (m && (line.startsWith('#') || !line.startsWith(' '))) { cur = { n: Number(m[1]), text: m[2].trim() }; items.push(cur); }
129
+ else if (cur && !line.startsWith('#')) cur.text += ' ' + line.trim();
130
+ }
131
+ const seen = new Set(), out = [];
132
+ for (const i of items) {
133
+ if (seen.has(i.n)) continue;
134
+ seen.add(i.n);
135
+ const t = one(i.text, 1800);
136
+ // an item's own stamp ("(Wawan, 2026-10-25 00:19 UTC"); any other date in the text may name something else
137
+ const d = /Wawan,?\s+(20\d\d-\d\d-\d\d)(?:[ T](\d\d:\d\d))?/.exec(t);
138
+ const at = d ? `${d[1]}T${d[2] || '00:00'}:00Z` : fileAt;
139
+ out.push(sig('feedback', 'wawan', `feedback:${batch}:${i.n}`, { at, area: areaOf(t), words: t, link: file || null, batch, n: i.n }));
140
+ }
141
+ return out;
142
+ }
143
+
144
+ /* run-corrections.js --json. A shallow clone has no counts (summary.shallow): no signals, never a false zero. */
145
+ function fromCorrections(rc) {
146
+ if (!rc || !Array.isArray(rc.rows) || (rc.summary && rc.summary.shallow)) return [];
147
+ const out = [];
148
+ for (const r of rc.rows) {
149
+ for (const c of r.components || []) {
150
+ if (c.kind === 'revert') out.push(sig('revert', 'data', `revert:${c.sha}`, { at: c.at || r.merged_at, area: areaOfFiles(r.files), words: c.subject, link: c.sha, run_id: r.run_id }));
151
+ else if (c.kind === 'fix') out.push(sig('fix-after-merge', 'data', `fix:${c.sha}:${r.run_id}`, { at: c.at || r.merged_at, area: areaOfFiles(c.shared), words: c.subject, link: c.sha, run_id: r.run_id }));
152
+ }
153
+ }
154
+ return out;
155
+ }
156
+
157
+ function fromEvals(text) {
158
+ const out = [];
159
+ for (const o of jsonl(text)) {
160
+ if (o.source !== 'verifier-after-merge' || String(o.verdict || '').toUpperCase() !== 'FAIL' || !o.run_id) continue;
161
+ out.push(sig('verifier-fail', 'data', `verifier-fail:${o.run_id}`, { at: o.recorded_at, words: o.notes, link: 'planning/runs/evals.jsonl', run_id: o.run_id }));
162
+ }
163
+ return out;
164
+ }
165
+
166
+ /* The verifier is stalled when verdicts are owed and nothing (a claim or a verdict) happened for STALL_HOURS. One signal per day. */
167
+ function fromVerifyStall(queueText, evalsText, now = Date.now()) {
168
+ const asked = new Set(), graded = new Set();
169
+ let last = 0;
170
+ for (const o of jsonl(queueText)) {
171
+ if (o.event === 'requested' && o.run_id) asked.add(o.run_id);
172
+ if ((o.event === 'claimed' || o.event === 'verdict-recorded') && Date.parse(o.at) > last) last = Date.parse(o.at);
173
+ }
174
+ for (const o of jsonl(evalsText)) {
175
+ if (o.run_id) graded.add(o.run_id);
176
+ if (o.source === 'verifier-after-merge' && Date.parse(o.recorded_at) > last) last = Date.parse(o.recorded_at);
177
+ }
178
+ let owed = 0; for (const id of asked) if (!graded.has(id)) owed++;
179
+ if (!owed || now - last < STALL_HOURS * 3600000) return [];
180
+ const day = new Date(now).toISOString().slice(0, 10);
181
+ const since = last ? new Date(last).toISOString().slice(0, 10) : 'never';
182
+ return [sig('verifier-stalled', 'data', `verifier-stalled:${day}`, { at: new Date(now).toISOString(), area: 'verifier',
183
+ words: `${owed} merged run(s) owe a verdict; last verifier activity: ${since}`, link: 'planning/runs/verify-queue.jsonl', owed })];
184
+ }
185
+
186
+ /* discoveries.md: an entry "## <date> — <title>" whose type line names friction */
187
+ function fromFriction(text) {
188
+ const out = [];
189
+ const parts = String(text || '').split(/\n(?=## \d{4}-\d\d-\d\d)/);
190
+ for (const p of parts) {
191
+ const h = /^## (\d{4}-\d\d-\d\d)\s*[—-]\s*(.+)/.exec(p);
192
+ if (!h || !/^- type:.*friction/im.test(p)) continue;
193
+ const note = (/^- note:\s*(.+)$/m.exec(p) || [])[1] || '';
194
+ const run = (/^- run:\s*(.+)$/m.exec(p) || [])[1] || '';
195
+ out.push(sig('friction', 'agent', `friction:${h[1]}:${one(h[2], 80)}`, { at: h[1], area: areaOf(h[2] + ' ' + note), words: h[2].trim() + ': ' + note, link: 'discoveries.md', lead_only: true, ...(run ? { run: one(run, 120) } : {}) }));
196
+ }
197
+ return out;
198
+ }
199
+
200
+ function fromOutcomes(text) {
201
+ const out = [];
202
+ for (const o of jsonl(text)) {
203
+ const d = String(o.disposition || o.result || '').toLowerCase();
204
+ if (!/refuted|missed|failed|not met/.test(d) || !o.initiative_id) continue;
205
+ out.push(sig('outcome-missed', 'data', `outcome:${o.initiative_id}:${o.checked_at || ''}`, { at: o.checked_at, words: `${o.initiative_id}: ${d}`, link: 'planning/runs/outcome_checks.jsonl' }));
206
+ }
207
+ return out;
208
+ }
209
+
210
+ /* A product's (or PMOS's own) runtime state folder. No words leave it: the product writer drops them; the words kept here are
211
+ * the PM's own ✕ reasons, for PMOS-self only. */
212
+ function fromStateDir(sd, { root = null } = {}) {
213
+ if (!sd) return [];
214
+ const out = [];
215
+ for (const l of jsonl(readText(path.join(sd, 'proposals.jsonl')))) {
216
+ if (l.kind !== 'drop' || !one(l.why, 400)) continue;
217
+ out.push(sig('x-reason', 'wawan', `x:${l.ini || ''}:${l.sig || l.id || ''}:${l.at || ''}`, { at: l.at, area: l.group || areaOf(l.why), words: l.why, link: null, ...(l.ini ? { ini: l.ini } : {}) }));
218
+ }
219
+ for (const l of jsonl(readText(path.join(sd, 'autonomy.jsonl')))) {
220
+ if (l.ev !== 'setback') continue;
221
+ const kind = l.kind === 'undo' ? 'undo' : l.kind === 'revert' ? 'revert' : l.kind === 'verifier-fail' ? 'verifier-fail' : null;
222
+ if (!kind) continue;
223
+ out.push(sig(kind, kind === 'undo' ? 'wawan' : 'data', `setback:${l.job}:${l.product || ''}:${l.ref || ''}:${l.at}`, { at: l.at, area: String(l.job || '').split(':')[0] || null, words: null, link: null, job: l.job }));
224
+ }
225
+ if (root) {
226
+ try {
227
+ for (const e of require('./factory-lessons.js').eventsOf(root, sd)) {
228
+ out.push(sig('factory-setback', 'product', `factory:${e.key}`, { at: e.at, area: String(e.failure || '').split(':')[0] || null, words: e.text, link: (e.source && e.source.ref) || null, item: e.item }));
229
+ }
230
+ } catch { /* no factory here */ }
231
+ }
232
+ return out;
233
+ }
234
+
235
+ /* release-check report.md: a table row "| <check> | ✗ | <detail> |" is a failed check */
236
+ function fromReleaseReport(text, { version = '', file = '' } = {}) {
237
+ const out = [];
238
+ const at = (/^timestamp:\s*(\S+)/m.exec(String(text || '')) || [])[1] || null;
239
+ for (const line of String(text || '').split('\n')) {
240
+ const m = /^\|\s*([^|]+?)\s*\|\s*(✗|✕|FAIL)\s*\|\s*([^|]*)\|/.exec(line);
241
+ if (!m) continue;
242
+ out.push(sig('release-check-fail', 'data', `release:${version}:${m[1]}`, { at, area: areaOf(m[1]), words: `${version} ${m[1]}: ${m[3].trim()}`, link: file || null, version }));
243
+ }
244
+ return out;
245
+ }
246
+
247
+ const rd = (root, ...p) => readText(path.join(root, ...p));
248
+ /** PMOS-self: every source in the repository's own records. run(root, args) → { stdout } runs a repo script (run-corrections). */
249
+ function harvestSelf(root, { run = null, stateDirs = [], now = Date.now() } = {}) {
250
+ const out = [];
251
+ if (run) {
252
+ try {
253
+ const r = run(root, ['scripts/run-corrections.js', '--json']);
254
+ const rc = JSON.parse(String(r.stdout || '').trim().split('\n').pop());
255
+ out.push(...fromCorrections(rc));
256
+ } catch { /* no evidence today */ }
257
+ }
258
+ const evals = rd(root, 'planning', 'runs', 'evals.jsonl');
259
+ out.push(...fromEvals(evals));
260
+ out.push(...fromVerifyStall(rd(root, 'planning', 'runs', 'verify-queue.jsonl'), evals, now));
261
+ out.push(...fromFriction(rd(root, 'discoveries.md')));
262
+ out.push(...fromOutcomes(rd(root, 'planning', 'runs', 'outcome_checks.jsonl')));
263
+ for (const sd of stateDirs || []) out.push(...fromStateDir(sd, { root }));
264
+ return out;
265
+ }
266
+ /** A product: its state folder only. The writer drops words (appendSignals product: true). */
267
+ function harvestProduct(root, stateDir) {
268
+ return fromStateDir(stateDir, { root }).map((r) => ({ ...r, words: null }));
269
+ }
270
+
271
+ module.exports = { SOURCES, KINDS, MAX_WORDS, STALL_HOURS, idOf, areaOf, areaOfFiles, pmosSelfFile, productFile, readSignals, appendSignals,
272
+ fromFeedback, fromCorrections, fromEvals, fromVerifyStall, fromFriction, fromOutcomes, fromStateDir, fromReleaseReport, harvestSelf, harvestProduct };
@@ -35,6 +35,10 @@
35
35
  * check and posts the commit status pmos-review; each turn also posts the verdicts still waiting. At most REVIEWS_PER_DAY a day; a head tried once
36
36
  * is not tried again that day. Off with PMOS_FACTORY_REVIEW=off. The review comes before the verifier, because a merge waits for it.
37
37
  *
38
+ * THE SIGNALS HARVEST (initiative improve-signals). Each tick, at most every HARVEST_MS per repository and before anything else, the
39
+ * improvement signals of each open repository are read into its ledger (lib/signals.js harvestSelf / harvestProduct). No model, no
40
+ * network. Off with PMOS_SIGNALS=off.
41
+ *
38
42
  * deps: { roots() → [{ id, root }], open(now) → bool, headlessOff() → bool, env, spawn(spec), stop(session), warn(what, err),
39
43
  * run(root, args) → { code, stdout } (default: spawnSync node), perDay?, stateDirs(w) → [the autonomy ledgers of a workspace] }
40
44
  */
@@ -46,6 +50,7 @@ const { spawnSync } = require('child_process');
46
50
  const PER_DAY = 4;
47
51
  const CHECKS_PER_DAY = 4;
48
52
  const SWEEP_MS = 6 * 3600000;
53
+ const HARVEST_MS = 3600000;
49
54
  const REVIEWS_PER_DAY = 8;
50
55
  const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
51
56
  /** The prompt of one applied-change check. a: the applied entry (lib/autonomy.js). */
@@ -177,6 +182,27 @@ function create(deps) {
177
182
  return null;
178
183
  }
179
184
 
185
+ /* improve-signals: each open repository's signals into its ledger, at most every HARVEST_MS (no model). A PMOS checkout reads its own
186
+ * records into planning/improve/signals.jsonl; any other repository reads its state folders into <state>/improve-signals.jsonl,
187
+ * which keeps no words (lib/signals.js). */
188
+ const harvested = new Map(); // root → when
189
+ function harvest(roots, now) {
190
+ const e = deps.env || process.env;
191
+ if (/^(off|0|false|no)$/i.test(String(e.PMOS_SIGNALS || '').trim())) return 0;
192
+ const S = require('./signals.js');
193
+ let added = 0;
194
+ for (const w of roots) {
195
+ if (!w || !w.root || now - (harvested.get(w.root) || 0) < HARVEST_MS) continue;
196
+ harvested.set(w.root, now);
197
+ const dirs = dirsOf(w);
198
+ try {
199
+ if (isCheckout(w.root)) added += S.appendSignals(S.pmosSelfFile(w.root), S.harvestSelf(w.root, { run, stateDirs: dirs, now })).added;
200
+ else for (const d of dirs) added += S.appendSignals(S.productFile(d), S.harvestProduct(w.root, d), { product: true }).added;
201
+ } catch (err) { warn('signals', err); }
202
+ }
203
+ return added;
204
+ }
205
+
180
206
  /* factory-premerge-reviewer: one review of a factory pull request's head, before it may merge by itself */
181
207
  const reviewed = new Map(); // day → [item@sha tried]
182
208
  function reviewOne(roots, now, day) {
@@ -247,6 +273,7 @@ function create(deps) {
247
273
  function tick({ now = Date.now() } = {}) {
248
274
  if (off(deps.env) || (deps.headlessOff && deps.headlessOff())) return { off: true };
249
275
  const rolled = factory(now);
276
+ harvest((deps.roots && deps.roots()) || [], now);
250
277
  if (active) return { running: active.run_id, ...(rolled.length ? { rolled } : {}) };
251
278
  let open = true;
252
279
  try { open = deps.open ? !!deps.open(now) : true; } catch { open = true; }
@@ -291,4 +318,4 @@ function create(deps) {
291
318
  return { tick, active: () => (active ? active.run_id : null) };
292
319
  }
293
320
 
294
- module.exports = { off, startsToday, create, isCheckout, PER_DAY, REVIEWS_PER_DAY, CHECKS_PER_DAY, statusOf, changePrompt, runEvidence };
321
+ module.exports = { off, startsToday, create, isCheckout, PER_DAY, HARVEST_MS, REVIEWS_PER_DAY, CHECKS_PER_DAY, statusOf, changePrompt, runEvidence };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.576.0",
3
+ "version": "0.577.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.576.0",
9
+ "version": "0.577.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.576.0",
3
+ "version": "0.577.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -129,7 +129,8 @@
129
129
  "claude-readiness.test.js",
130
130
  "setup-routes.test.js",
131
131
  "project-onboard.test.js",
132
- "loop-telemetry.test.js"
132
+ "loop-telemetry.test.js",
133
+ "signals.test.js"
133
134
  ],
134
135
  "panels": [
135
136
  "pm-r7-test.js",