create-pmos 0.538.0 → 0.539.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.
Files changed (36) hide show
  1. package/package.json +14 -26
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/changelog.json +13 -0
  7. package/workspace/guide/agent-capabilities.md +7 -5
  8. package/workspace/guide/agents-act.md +68 -0
  9. package/workspace/guide/index.md +2 -1
  10. package/workspace/guide/initiative-driver.md +16 -7
  11. package/workspace/lib/agent-inbox.js +2 -2
  12. package/workspace/lib/ai-guard.js +16 -6
  13. package/workspace/lib/auto-keep.js +33 -0
  14. package/workspace/lib/autonomy-cli.js +53 -0
  15. package/workspace/lib/autonomy.js +234 -0
  16. package/workspace/lib/bg-queue.js +2 -1
  17. package/workspace/lib/driver-cli.js +26 -10
  18. package/workspace/lib/driver-decide.js +76 -8
  19. package/workspace/lib/driver.js +15 -4
  20. package/workspace/lib/goal-loop.js +221 -0
  21. package/workspace/lib/job-graph.js +3 -0
  22. package/workspace/lib/loop-cli.js +84 -0
  23. package/workspace/lib/pm-lines-needs.js +3 -0
  24. package/workspace/lib/pmos-verbs.js +6 -1
  25. package/workspace/lib/route-modules.js +1 -0
  26. package/workspace/lib/routes-autonomy.js +95 -0
  27. package/workspace/lib/routes-proposals.js +101 -46
  28. package/workspace/lib/stage-tools.js +11 -1
  29. package/workspace/lib/today.js +2 -8
  30. package/workspace/package-lock.json +2 -2
  31. package/workspace/package.json +1 -1
  32. package/workspace/public/pm/home-around.js +2 -2
  33. package/workspace/replaced-tests.json +17 -0
  34. package/workspace/server.js +26 -14
  35. package/workspace/test-lists/full-autonomy.json +11 -0
  36. package/workspace/test-run.js +3 -0
@@ -68,6 +68,101 @@ const W = {
68
68
  return RB.taskEdit(ctx, body, g);
69
69
  },
70
70
  };
71
+ /** Keep these proposals: their writes, then one `keep` line. extra: D106 { auto: true, group } for a change an agent applied by itself. */
72
+ function keepCore(ctx, p, g, f, ini, want, choices = {}, extra = {}) {
73
+ const dir = dirOf(ctx, p.w), wrote = [], keptIds = [], outbox = [];
74
+ let plans = 0;
75
+ for (const x of want) {
76
+ if (x.group === 'links') {
77
+ const r = TLR.acceptFor ? TLR.acceptFor(ctx, p, g, ini, [x.link.id]) : null;
78
+ if (r && r.linked) for (const l of r.linked) wrote.push({ op: 'link', from: l.from, to: l.to, why: x.why });
79
+ continue;
80
+ }
81
+ const w = applyOne(ctx, p, g, f, ini, x, choices, outbox);
82
+ wrote.push(...w);
83
+ if (x.group === 'dates' && x.plan && w.some((y) => y.op === 'dates')) plans++;
84
+ keptIds.push(x.group === 'dates' ? x.id + ':' + x.sig : x.id);
85
+ }
86
+ for (const a of outbox) { const id = toOutbox(ctx, a); if (id) wrote.push({ op: 'outbox', task: a.task, entry: id, why: a.text }); }
87
+ const batch = PR.newBatch();
88
+ PR.append(dir, g.actor, { kind: 'keep', ini, board: p.board.id, batch, ids: keptIds, wrote, ...extra });
89
+ return { batch, wrote, plans, keptIds };
90
+ }
91
+
92
+ /** Undo one kept batch. → { ok, back, kept } | { ok: false, status, error }. A task changed since keeps its change. */
93
+ function undoCore(ctx, p, g, id) {
94
+ const dir = dirOf(ctx, p.w), F = PR.read(dir);
95
+ const k = F.kept.find((x) => x.batch === id);
96
+ if (!k || F.undone.has(id)) return { ok: false, status: 409, error: 'Nothing to undo' };
97
+ const f = TLR.frame(ctx, p.w, p.board);
98
+ if (!f) return { ok: false, status: 202, error: 'The board is still being read. Try again in a moment.' };
99
+ let back = 0, kept = 0;
100
+ for (const w of k.wrote.slice().reverse()) {
101
+ const xi = w.task ? f.byUid.get(w.task) : null, t = w.task ? f.T.get(w.task) : null;
102
+ let r = null;
103
+ if (w.op === 'add') { if (xi && (xi.status || 'To do') === 'To do') r = RB.taskDelete(ctx, { ws: p.w.id, board: p.board.id, task: w.task, why: 'Undo: Claude ✦ added it' }, g); }
104
+ // a task changed since keeps its change: Undo never overwrites a later edit
105
+ else if (w.op === 'dates') { if (xi && (xi.end || '') === (w.to.due || xi.end || '')) r = W.dates(ctx, p, g, w.task, xi, { start: w.from.start, due: w.from.due }); }
106
+ else if (w.op === 'state') { if (t && t.status === w.to) r = RB.taskState(ctx, { ws: p.w.id, board: p.board.id, task: w.task, state: w.from || 'To do', why: 'Undo' }, g); }
107
+ else if (w.op === 'rename') { if (t && t.title === w.to) r = RB.writeAs(ctx, '/api/boards/tasks/rename', { ws: p.w.id, board: p.board.id, task: w.task, title: w.from }, g); }
108
+ else if (w.op === 'notes') { if (xi && (xi.notes || '') === w.to) r = RB.taskEdit(ctx, { ws: p.w.id, board: p.board.id, task: w.task, notes: w.from || '' }, g); }
109
+ else if (w.op === 'stage') { const row = rowOf(f, k.ini); if (row && row.stage === w.to && w.from) r = RB.move(ctx, { ws: p.w.id, board: p.board.id, id: k.ini, to: w.from, why: 'Undo: Claude ✦ moved it' }, g); }
110
+ else if (w.op === 'epics') r = RB.writeAs(ctx, '/api/boards/ini-epics', { ws: p.w.id, board: p.board.id, id: k.ini, epics: w.from }, g);
111
+ else if (w.op === 'unlink') { TL.append(dir, g.actor, { kind: 'link', board: p.board.id, ini: k.ini, from: w.from, to: w.to, type: w.link.type, lag: w.link.lag, source: w.link.source }); back++; continue; }
112
+ else if (w.op === 'link') { TL.append(dir, g.actor, { kind: 'unlink', from: w.from, to: w.to }); back++; continue; }
113
+ else if (w.op === 'prd') { try { const file = path.resolve(p.w.root, w.file), text = fs.readFileSync(file, 'utf8'); if (text.includes(w.to)) { fs.writeFileSync(file, text.split(w.to).join(w.from)); back++; } else kept++; } catch { kept++; } continue; }
114
+ else if (w.op === 'doc' || w.op === 'linked' || w.op === 'ran') { back++; continue; } // the fold leaves an undone batch out
115
+ else if (w.op === 'outbox') { kept++; continue; } // a drafted comment waits in the outbox, where the PM drops it
116
+ else if (w.op === 'description') { const r2 = require('./initiative-writer.js').restoreDescription(p.w.root, k.ini, w.from || '', w.to || '', { actor: g.actor }); if (r2.ok && !r2.kept) back++; else kept++; continue; } // a record edited since keeps its edit
117
+ else if (w.op === 'outcome') { const r2 = require('./initiative-writer.js').restoreOutcome(p.w.root, k.ini, w.from || {}, w.to || {}, { actor: g.actor }); if (r2.ok && !r2.kept) back++; else kept++; continue; } // a record edited since keeps its edit
118
+ if (r && r.body && r.body.ok) back++; else kept++;
119
+ }
120
+ PR.append(dir, g.actor, { kind: 'undo', batch: id });
121
+ // D106: the Undo of a change an agent applied by itself is a setback of its job (lib/autonomy.js), which may demote the job
122
+ const line = PR.readLines(PR.ledgerFile(dir)).find((l) => l.kind === 'keep' && l.batch === id);
123
+ let demoted = null;
124
+ if (line && line.auto === true && line.group) {
125
+ const A = require('./autonomy.js');
126
+ demoted = A.recordSetback(dir, { job: `propose:${line.group}`, product: p.w.id, ref: id, kind: 'undo' }).demoted;
127
+ try { fs.mkdirSync(ctx.runtimeDir || dir, { recursive: true }); fs.appendFileSync(path.join(ctx.runtimeDir || dir, 'corrections.jsonl'), JSON.stringify({ type: 'correction', kind: 'reject', reason: 'propose:undo', run: null, counted: true, at: new Date().toISOString(), record: { kind: 'correction', reason: 'propose:undo', by: g.actor && g.actor.by } }) + '\n'); } catch { /* the ledger holds the undo */ }
128
+ }
129
+ return { ok: true, back, kept, demoted };
130
+ }
131
+
132
+ /** D106: apply by itself every open class A or B proposal on one board of a workspace, one batch per proposal, each with Undo.
133
+ * Class C (a stage found elsewhere, a maybe, a duplicate, the state of a Jira ticket), a job that is demoted and a board whose Driver
134
+ * mode is not auto stay for the PM. → { applied: [{ ini, batch, group, title }], held: n } */
135
+ function autoKeep(ctx, w, { modeOf = () => 'auto', now } = {}) {
136
+ const A = require('./autonomy.js');
137
+ const dir = dirOf(ctx, w);
138
+ const out = { applied: [], held: 0 };
139
+ if (!dir) return out;
140
+ const g = { ok: true, actor: { by: 'agent:auto' } };
141
+ const fr = RB.frameFor(ctx, w);
142
+ for (const board of fr.boards || []) {
143
+ const p = { w, fr, board, file: null };
144
+ const f = TLR.frame(ctx, w, board, { derive: true });
145
+ if (!f) continue;
146
+ for (const row of f.rows || []) {
147
+ const ini = row.id;
148
+ if (!ini) continue;
149
+ const v = view(ctx, p, ini, f, { grillAll: true });
150
+ if (!v) continue;
151
+ for (const x of v.groups.flatMap((gr) => gr.props)) {
152
+ const cls = A.classOfProposal(x);
153
+ const d = A.decide({ stateDir: dir, job: `propose:${x.group}`, product: w.id, cls, mode: modeOf(board.id), undoable: true, now, settingsDir: ctx.runtimeDir || null });
154
+ if (!d.apply) { out.held++; continue; }
155
+ try {
156
+ const r = keepCore(ctx, p, g, f, ini, [x], {}, { auto: true, group: x.group });
157
+ A.recordApplied(dir, { job: `propose:${x.group}`, product: w.id, ref: r.batch, title: x.title || x.why || x.group, cls }, { now });
158
+ out.applied.push({ ini, batch: r.batch, group: x.group, title: x.title || x.why || '' });
159
+ } catch { out.held++; }
160
+ }
161
+ }
162
+ }
163
+ return out;
164
+ }
165
+
71
166
  /** The writes of one proposal. → [write] (each { op, ... } that landed). sk: the item ids the PM left out (✕ on one item). */
72
167
  function applyOne(ctx, p, g, f, ini, x, choices, outbox) {
73
168
  const wrote = [], why = x.why, source = srcText(x);
@@ -254,23 +349,8 @@ const WRITES = {
254
349
  // ✓ in the header keeps all Claude is sure of: Check these, Not placed and Jira-only proposals wait for their own ✓
255
350
  const want = body.all === true ? all.filter((x) => x.section === 'sure') : all.filter((x) => ids.includes(x.id));
256
351
  if (!want.length) return fail(ctx, res, 409, 'Those proposals are no longer open');
257
- const dir = dirOf(ctx, p.w), wrote = [], keptIds = [], outbox = [];
258
- let plans = 0;
259
- const choices = isObj(body.choices) ? body.choices : {};
260
- for (const x of want) {
261
- if (x.group === 'links') {
262
- const r = TLR.acceptFor ? TLR.acceptFor(ctx, p, g, ini, [x.link.id]) : null;
263
- if (r && r.linked) for (const l of r.linked) wrote.push({ op: 'link', from: l.from, to: l.to, why: x.why });
264
- continue;
265
- }
266
- const w = applyOne(ctx, p, g, f, ini, x, choices, outbox);
267
- wrote.push(...w);
268
- if (x.group === 'dates' && x.plan && w.some((y) => y.op === 'dates')) plans++;
269
- keptIds.push(x.group === 'dates' ? x.id + ':' + x.sig : x.id);
270
- }
271
- for (const a of outbox) { const id = toOutbox(ctx, a); if (id) wrote.push({ op: 'outbox', task: a.task, entry: id, why: a.text }); }
272
- const batch = PR.newBatch();
273
- PR.append(dir, g.actor, { kind: 'keep', ini, board: p.board.id, batch, ids: keptIds, wrote });
352
+ const dir = dirOf(ctx, p.w);
353
+ const { batch, wrote, plans } = keepCore(ctx, p, g, f, ini, want, isObj(body.choices) ? body.choices : {});
274
354
  const v2 = view(ctx, p, ini);
275
355
  const left = v2 ? v2.groups.flatMap((x) => x.props).filter((x) => x.section === 'check').length : 0;
276
356
  ctx.json(res, { ok: true, batch, said: saidOf(wrote, plans, body.all === true ? left : 0), counts: { wrote: wrote.length }, props: v2, found: PR.foundOf(PR.read(dir), ini) });
@@ -298,34 +378,9 @@ const WRITES = {
298
378
  ctx.json(res, { ok: true });
299
379
  },
300
380
  '/api/proposals/undo': (ctx, res, body, g, p) => {
301
- const dir = dirOf(ctx, p.w), F = PR.read(dir), id = String(body.batch || '');
302
- const k = F.kept.find((x) => x.batch === id);
303
- if (!k || F.undone.has(id)) return fail(ctx, res, 409, 'Nothing to undo');
304
- const f = TLR.frame(ctx, p.w, p.board);
305
- if (!f) return fail(ctx, res, 202, 'The board is still being read. Try again in a moment.');
306
- let back = 0, kept = 0;
307
- for (const w of k.wrote.slice().reverse()) {
308
- const xi = w.task ? f.byUid.get(w.task) : null, t = w.task ? f.T.get(w.task) : null;
309
- let r = null;
310
- if (w.op === 'add') { if (xi && (xi.status || 'To do') === 'To do') r = RB.taskDelete(ctx, { ws: p.w.id, board: p.board.id, task: w.task, why: 'Undo: Claude ✦ added it' }, g); }
311
- // a task changed since keeps its change: Undo never overwrites a later edit
312
- else if (w.op === 'dates') { if (xi && (xi.end || '') === (w.to.due || xi.end || '')) r = W.dates(ctx, p, g, w.task, xi, { start: w.from.start, due: w.from.due }); }
313
- else if (w.op === 'state') { if (t && t.status === w.to) r = RB.taskState(ctx, { ws: p.w.id, board: p.board.id, task: w.task, state: w.from || 'To do', why: 'Undo' }, g); }
314
- else if (w.op === 'rename') { if (t && t.title === w.to) r = RB.writeAs(ctx, '/api/boards/tasks/rename', { ws: p.w.id, board: p.board.id, task: w.task, title: w.from }, g); }
315
- else if (w.op === 'notes') { if (xi && (xi.notes || '') === w.to) r = RB.taskEdit(ctx, { ws: p.w.id, board: p.board.id, task: w.task, notes: w.from || '' }, g); }
316
- else if (w.op === 'stage') { const row = rowOf(f, k.ini); if (row && row.stage === w.to && w.from) r = RB.move(ctx, { ws: p.w.id, board: p.board.id, id: k.ini, to: w.from, why: 'Undo: Claude ✦ moved it' }, g); }
317
- else if (w.op === 'epics') r = RB.writeAs(ctx, '/api/boards/ini-epics', { ws: p.w.id, board: p.board.id, id: k.ini, epics: w.from }, g);
318
- else if (w.op === 'unlink') { TL.append(dir, g.actor, { kind: 'link', board: p.board.id, ini: k.ini, from: w.from, to: w.to, type: w.link.type, lag: w.link.lag, source: w.link.source }); back++; continue; }
319
- else if (w.op === 'link') { TL.append(dir, g.actor, { kind: 'unlink', from: w.from, to: w.to }); back++; continue; }
320
- else if (w.op === 'prd') { try { const file = path.resolve(p.w.root, w.file), text = fs.readFileSync(file, 'utf8'); if (text.includes(w.to)) { fs.writeFileSync(file, text.split(w.to).join(w.from)); back++; } else kept++; } catch { kept++; } continue; }
321
- else if (w.op === 'doc' || w.op === 'linked' || w.op === 'ran') { back++; continue; } // the fold leaves an undone batch out
322
- else if (w.op === 'outbox') { kept++; continue; } // a drafted comment waits in the outbox, where the PM drops it
323
- else if (w.op === 'description') { const r2 = require('./initiative-writer.js').restoreDescription(p.w.root, k.ini, w.from || '', w.to || '', { actor: g.actor }); if (r2.ok && !r2.kept) back++; else kept++; continue; } // a record edited since keeps its edit
324
- else if (w.op === 'outcome') { const r2 = require('./initiative-writer.js').restoreOutcome(p.w.root, k.ini, w.from || {}, w.to || {}, { actor: g.actor }); if (r2.ok && !r2.kept) back++; else kept++; continue; } // a record edited since keeps its edit
325
- if (r && r.body && r.body.ok) back++; else kept++;
326
- }
327
- PR.append(dir, g.actor, { kind: 'undo', batch: id });
328
- ctx.json(res, { ok: true, back, kept });
381
+ const r = undoCore(ctx, p, g, String(body.batch || ''));
382
+ if (!r.ok) return fail(ctx, res, r.status, r.error);
383
+ ctx.json(res, { ok: true, back: r.back, kept: r.kept, ...(r.demoted ? { demoted: r.demoted } : {}) });
329
384
  },
330
385
  '/api/proposals/stop': (ctx, res, body, g, p) => {
331
386
  const ini = String(body.initiative || '');
@@ -348,7 +403,7 @@ const WRITES = {
348
403
 
349
404
  module.exports = {
350
405
  prefixes: ['/api/proposals'],
351
- viewFor, saidOf, prdRename,
406
+ viewFor, saidOf, prdRename, keepCore, undoCore, autoKeep,
352
407
  handle: async (req, res, url, ctx) => {
353
408
  const p0 = url.pathname;
354
409
  if (req.method === 'GET') {
@@ -80,6 +80,8 @@ function readLedger(file) {
80
80
  if (!raw.trim()) continue;
81
81
  let e;
82
82
  try { e = JSON.parse(raw); } catch { continue; }
83
+ // D106: a `clear` line takes a tool's record away again (the Undo of a record an agent wrote where there was none before)
84
+ if (isObj(e) && e.ev === 'clear' && typeof e.initiative === 'string' && out.has(e.initiative)) { out.get(e.initiative).delete(e.tool); continue; }
83
85
  if (!isObj(e) || e.ev !== 'tool' || typeof e.initiative !== 'string' || !e.initiative) continue;
84
86
  const c = checkData(e.tool, e.data);
85
87
  if (!c.ok) continue;
@@ -89,6 +91,14 @@ function readLedger(file) {
89
91
  return out;
90
92
  }
91
93
 
94
+ /** D106: take a tool's record away (the Undo of an agent's first record of it). One `clear` line; the fold drops the record. */
95
+ function clearTool(file, { initiative, tool }, actor, { now } = {}) {
96
+ const line = { v: 1, at: new Date(now == null ? Date.now() : now).toISOString(), by: (actor && actor.by) || 'pm:unknown', ev: 'clear', initiative, tool };
97
+ fs.mkdirSync(path.dirname(file), { recursive: true });
98
+ fs.appendFileSync(file, JSON.stringify(line) + '\n');
99
+ return line;
100
+ }
101
+
92
102
  function riceScore(d) {
93
103
  if (!d || !num(d.effort) || d.effort <= 0) return null;
94
104
  return Math.round((d.reach * d.impact * (d.confidence / 100) / d.effort) * 10) / 10;
@@ -205,4 +215,4 @@ function burndown(tickets, { sprint: name, today } = {}) {
205
215
  };
206
216
  }
207
217
 
208
- module.exports = { LEDGER, TOOLS, IMPACTS, KILL_STATES, LIMITS, checkData, readLedger, recordsOf, appendTool, riceScore, riceRank, buildDeliverOn, burndown, pickSprint };
218
+ module.exports = { LEDGER, TOOLS, IMPACTS, KILL_STATES, LIMITS, checkData, readLedger, recordsOf, appendTool, clearTool, riceScore, riceRank, buildDeliverOn, burndown, pickSprint };
@@ -262,14 +262,8 @@ function gather(w, { stateDir = stateDirOf(w.root), sessions = [], registered }
262
262
  const seen = new Set(queue.map((n) => n.run_id));
263
263
  for (const n of queue) rows.push(n);
264
264
  if (stateDir) {
265
- const settled = new Set();
266
- for (const a of readLedger(w, stateDir, 'acceptances.jsonl')) if (a && a.run_id) settled.add(a.run_id);
267
- for (const e of readLedger(w, stateDir, 'evals.jsonl')) {
268
- if (!e || !e.run_id || settled.has(e.run_id) || seen.has(e.run_id)) continue;
269
- rows.push({ run_id: e.run_id, initiative_id: e.initiative_id || null, kind: 'accept', derived: true,
270
- question: 'Acceptance Gate open', doc: e.rubric_path || e.rubric || null,
271
- detail: { verdict: e.verdict ? String(e.verdict) : null, score: e.score != null ? e.score : null } });
272
- }
265
+ // D94 retired the Acceptance Gate as a step before each merge, and D106 lets agents act: an eval with no acceptance is not a card
266
+ // (on 2 Nov 33 of 176 Today items were "Acceptance is owed"). A run the PM RETURNED still shows, below.
273
267
  const disposed = new Set();
274
268
  for (const c of readLedger(w, stateDir, 'outcome_checks.jsonl')) if (c && c.initiative_id) disposed.add(c.initiative_id);
275
269
  const today = new Date().toISOString().slice(0, 10);
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.538.0",
3
+ "version": "0.539.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.538.0",
9
+ "version": "0.539.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.538.0",
3
+ "version": "0.539.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",
@@ -57,7 +57,7 @@ async function readProps(P) {
57
57
  await Promise.all(P.flatMap((p) => ['initiative', 'work'].map(async (kind) => {
58
58
  const r = await getj('/api/driver/open?target_kind=' + kind + (p.ws ? '&' + wq(p.ws) : ''));
59
59
  if (!r.ok) { errs.push(r.error); return; }
60
- if (r.mode !== 'approve') return; // Off and Shadow raise nothing here (the console draws the same)
60
+ if (r.mode !== 'approve' && r.mode !== 'auto') return; // Off and Shadow raise nothing here (the console draws the same). D106: in Auto, what is still open waits for the PM (class C, or a demoted job)
61
61
  for (const [tid, list] of Object.entries(r.targets || {})) for (const pr of list) items.push({ id: pr.id, ws: r.ws, pname: P.length > 1 ? p.name : '', kind, tid, p: pr, title: '' });
62
62
  })));
63
63
  items.sort((a, b) => String(a.p.at).localeCompare(String(b.p.at)) || a.id.localeCompare(b.id));
@@ -198,7 +198,7 @@ const propSel = (L) => { const w = L.filter((it) => !DEC.has(it.id)); return (w.
198
198
  function propsHtml() {
199
199
  const a = A.prop; if (!a || !a.ok) return `<p class="nodef err" role="alert">Agent proposals ${esc(said(a))}</p>`;
200
200
  const L = a.items.concat([...DEC.values()].map((d) => d.item).filter((it) => !a.items.some((o) => o.id === it.id))), sel = propSel(L), it = L.find((x) => x.id === sel);
201
- const notes = [it ? pKeep(it.p) + ' Drop counts as a correction. Send back starts a new run with your note. None of the three can be undone.' : '', 'The agent mode (Off, Shadow, Approve) stays in Settings. This list shows a kind only when its mode is Approve.', a.errs.length ? 'Not read: ' + a.errs[0] : ''].filter(Boolean);
201
+ const notes = [it ? pKeep(it.p) + ' Drop counts as a correction. Send back starts a new run with your note. None of the three can be undone.' : '', 'The agent mode (Off, Shadow, Approve, Auto) stays in Settings. This list shows a kind only when its mode is Approve or Auto; in Auto it shows what still waits for you.', a.errs.length ? 'Not read: ' + a.errs[0] : ''].filter(Boolean);
202
202
  const info = `<div class="pc-info"><button type="button" class="hx-b alt" data-bda="pinfo" aria-expanded="${PINFO}" aria-controls="pcNotes"><i class="pc-i" aria-hidden="true">i</i>Nothing changes a record until you keep it</button><div id="pcNotes"${PINFO ? '' : ' hidden'}>${notes.map((t) => `<p class="bd-why">${esc(t)}</p>`).join('')}</div></div>`;
203
203
  const back = it && PBACK.has(it.id), id = it ? esc(it.id) : '';
204
204
  const note = back ? `<label class="bd-l" for="bdn-${id}">What should the agent change?</label><textarea id="bdn-${id}" data-bdn="${id}" maxlength="500" rows="2">${esc(PNOTE[it.id] || '')}</textarea>${bdFail(it.id, PERR)}` : '';
@@ -3639,6 +3639,23 @@
3639
3639
  "names": [
3640
3640
  "C5 the runner is called from the existing 60-second interval and nowhere else is a second timer made"
3641
3641
  ]
3642
+ },
3643
+ {
3644
+ "id": "E82",
3645
+ "group": "E",
3646
+ "file": "workspace/test.js",
3647
+ "section": "E3 / E3b derived needs",
3648
+ "change": "replaced",
3649
+ "slice": "full-autonomy-d106",
3650
+ "reason": "D94 (agents merge on green CI; acceptance is the PM's standing instruction) and D106 (Full autonomy now, PM wawan 2026-11-08): an eval with no acceptance no longer derives an Acceptance Gate needs row. It was 33 of the cards `pmos today` showed, none of them a call the PM still makes.",
3651
+ "replacement": "test.js 'D94/D106: an eval with no acceptance derives no needs row' and 'D94/D106: an eval recorded ONLY in planning/runs/ derives no Acceptance Gate row'; today.test.js 3 asserts the same for `pmos today`; routes-today.test.js 1 and 4.",
3652
+ "pm_approval": null,
3653
+ "names": [
3654
+ "an eval with no acceptance derives an open Acceptance Gate (D12)",
3655
+ "E3b: an eval recorded ONLY in planning/runs/ derives an open Acceptance Gate",
3656
+ "E3b: an acceptance recorded ONLY in planning/runs/ settles its run",
3657
+ "E3b: doc resolves from the LEGACY `rubric` key, not only `rubric_path`"
3658
+ ]
3642
3659
  }
3643
3660
  ]
3644
3661
  }
@@ -2965,7 +2965,21 @@ const proposalRuns = require('./lib/proposal-runs.js').create({
2965
2965
  homeWs: () => homeWorkspace(),
2966
2966
  warn: (what, e) => warnWriteFail(what, e),
2967
2967
  });
2968
- const proposalTick = () => { try { proposalRuns.tick({}); } catch (e) { warnWriteFail('proposal tick', e); } };
2968
+ // D106 (Full autonomy now): after the runs, every open class A or B ✦ proposal is applied by itself, with Undo (lib/auto-keep.js).
2969
+ const autoKeeper = require('./lib/auto-keep.js').create({
2970
+ workspaces: () => workspaces.values(),
2971
+ // a server whose runtime state is redirected (PMOS_STATE_DIR: a suite, a sandbox) never applies into the checkout it runs from: that
2972
+ // checkout's workspace/state is tracked, and a suite's server must not write it
2973
+ isLead: (w) => isPlanNeedsTree(w) && !(process.env.PMOS_STATE_DIR && path.resolve(w.root) === PARENT_DIR),
2974
+ stateDirFor: (w) => stateDirFor(w),
2975
+ proposalCtx: () => proposalCtx(),
2976
+ settingsDir: () => STATE,
2977
+ warn: (what, e) => warnWriteFail(what, e),
2978
+ });
2979
+ const proposalTick = () => {
2980
+ try { proposalRuns.tick({}); } catch (e) { warnWriteFail('proposal tick', e); }
2981
+ autoKeeper.tick();
2982
+ };
2969
2983
  // Grill and Forecast, part G-A (lib/grill.js, lib/grill-runs.js): Claude grills an initiative by itself before it leaves a stage, when its
2970
2984
  // forecast turns at risk or will miss (lib/forecast.js), when its scope or dates move a lot, and monthly on every running initiative with open work.
2971
2985
  // Each finding is a proposal under its ✦; only the PM's ✓ writes. Settings grill.mode and grill.cap (a monthly credit cap). PMOS_GRILL=off.
@@ -3314,6 +3328,16 @@ bgQueue.register('refresh', () => { try { refreshRun.tick(); } catch (e) { warnW
3314
3328
  bgQueue.register('reports', () => dashboardScheduleTick());
3315
3329
  bgQueue.register('sync', gated('sync', () => autoSync.tick().catch(() => {})));
3316
3330
  bgQueue.register('driver', gated('driver', driverTick));
3331
+ // D106: long-running goals (lib/goal-loop.js, `pmos loop`): each tick closes a round whose run is gone (a restart) and starts the next round
3332
+ // of every running goal, through the capacity governor. `pmos ai off` and PMOS_AUTONOMY=off stop every loop.
3333
+ const goalLoops = require('./lib/goal-loop.js').create({
3334
+ dir: () => STATE,
3335
+ getWs: (id) => getWs(id),
3336
+ killed: () => require('./lib/autonomy.js').killed({ env: process.env, settingsDir: STATE }) || (headlessLib.switchedOff(process.env) ? 'background runs are off' : null),
3337
+ spawn: (spec) => orchSpawn.spawn({ name: spec.name, agent: 'claude', ws: spec.ws, origin: spec.origin, initialInput: spec.initialInput, autoDelete: undefined, onDone: spec.onDone }),
3338
+ warn: (what, e) => warnWriteFail(what, e),
3339
+ });
3340
+ bgQueue.register('goal-loops', () => { try { goalLoops.tick(); } catch (e) { warnWriteFail('goal loop tick', e); } });
3317
3341
  bgQueue.register('finder', gated('finder', reportFinderTick));
3318
3342
  bgQueue.register('coredocs', gated('coredocs', coreDocsTick));
3319
3343
  bgQueue.register('milestones', () => msReviewTick());
@@ -6130,19 +6154,7 @@ function deriveNeeds(w) {
6130
6154
  needs = needs.concat(needsProviders.rowsFor(w, { lead: isPlanNeedsTree(w) }));
6131
6155
  const dir = stateDirFor(w);
6132
6156
  if (!dir) return needs;
6133
- const settled = new Set();
6134
- for (const a of readLedger(w, 'acceptances.jsonl')) if (a.run_id) settled.add(a.run_id);
6135
- for (const e of readLedger(w, 'evals.jsonl')) {
6136
- if (!e.run_id || settled.has(e.run_id)) continue;
6137
- const verdict = e.verdict ? String(e.verdict) : 'no verdict';
6138
- needs.push({
6139
- run_id: e.run_id, initiative_id: e.initiative_id || null, kind: 'accept', derived: true,
6140
- question: `Acceptance Gate open — evaluator says ${verdict}${e.score != null ? ` (${e.score})` : ''}`,
6141
- // `rubric` is the deprecated alias every one of the 26 legacy rows uses; scripts/record-eval.js
6142
- // requires `rubric_path` going forward. Read both, write only the new one.
6143
- doc: e.rubric_path || e.rubric || null,
6144
- });
6145
- }
6157
+ // D94/D106: an eval with no acceptance is no needs row (lib/today.js gather agrees, row by row).
6146
6158
  const disposed = new Set();
6147
6159
  for (const c of readLedger(w, 'outcome_checks.jsonl')) if (c.initiative_id) disposed.add(c.initiative_id);
6148
6160
  const today = nowISO().slice(0, 10);
@@ -0,0 +1,11 @@
1
+ {
2
+ "_comment": "D106 Full autonomy now: lib/autonomy.js (the three classes, the setback ledger, automatic demotion, the Done group, the stop switches) and lib/goal-loop.js (long-running goals). Pure, node.",
3
+ "modules": [
4
+ "autonomy.test.js",
5
+ "goal-loop.test.js"
6
+ ],
7
+ "seconds": {
8
+ "autonomy.test.js": 1,
9
+ "goal-loop.test.js": 1
10
+ }
11
+ }
@@ -110,6 +110,9 @@ function configure({ name = 'run', port = null } = {}) {
110
110
  process.env.PMOS_FORECAST = 'off';
111
111
  // No suite's server grills by itself (Grill and Forecast, part G-A): a run would take the one grill slot and spend. grill.test.js drives it.
112
112
  process.env.PMOS_GRILL = 'off';
113
+ // No suite's server applies ✦ proposals by itself (D106 auto-keep): it would write the checkout's own workspace/state. proposals.test.js
114
+ // and autonomy.test.js drive autoKeep in-process with their own env.
115
+ process.env.PMOS_AUTONOMY = 'off';
113
116
  // A private tmux socket, never the PM's own ('pmos'), so a suite cannot reach their sessions.
114
117
  const tmuxSock = `pmos-${name}-${process.pid}`;
115
118
  process.env.PMOS_TMUX_SOCK = tmuxSock;