create-pmos 0.553.0 → 0.555.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 (184) hide show
  1. package/package.json +33 -27
  2. package/payload/KIT-VERSION +2 -2
  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/payload/state/log.md +1 -1
  7. package/workspace/briefing-premium-board-test.js +4 -4
  8. package/workspace/briefing-premium-initiative-test.js +2 -2
  9. package/workspace/briefing-premium-test.js +1 -1
  10. package/workspace/changelog.json +32 -0
  11. package/workspace/chat-asks-test.js +5 -5
  12. package/workspace/ev-everywhere-test.js +2 -2
  13. package/workspace/goals-clear-ui-test.js +1 -1
  14. package/workspace/guide/agent-capabilities.md +33 -31
  15. package/workspace/guide/claude-proposes.md +68 -68
  16. package/workspace/guide/cli.md +23 -22
  17. package/workspace/guide/cloud.md +3 -3
  18. package/workspace/guide/home.md +38 -38
  19. package/workspace/guide/index.md +5 -5
  20. package/workspace/guide/intelligence-okr-goals.md +4 -4
  21. package/workspace/guide/layout.md +23 -23
  22. package/workspace/guide/notes.md +8 -8
  23. package/workspace/guide/programs.md +17 -17
  24. package/workspace/guide/reports.md +16 -16
  25. package/workspace/guide/settings-and-switches.md +40 -37
  26. package/workspace/guide/statuses.md +3 -3
  27. package/workspace/home-other-product-test.js +8 -8
  28. package/workspace/home-pill-test.js +3 -3
  29. package/workspace/home-rows-test.js +7 -7
  30. package/workspace/intel-report-ui-test.js +1 -1
  31. package/workspace/intelligence-gaps-ui-test.js +2 -2
  32. package/workspace/lib/agent-roles.js +1 -1
  33. package/workspace/lib/autonomy-cli.js +16 -2
  34. package/workspace/lib/autonomy.js +84 -11
  35. package/workspace/lib/bg-queue.js +1 -1
  36. package/workspace/lib/briefing-premium-agent.js +2 -2
  37. package/workspace/lib/decision-memory.js +2 -2
  38. package/workspace/lib/driver-decide.js +6 -3
  39. package/workspace/lib/driver.js +6 -2
  40. package/workspace/lib/folder-needs.js +1 -1
  41. package/workspace/lib/goal-chat.js +5 -5
  42. package/workspace/lib/goal-watch.js +1 -1
  43. package/workspace/lib/grill-runs.js +5 -5
  44. package/workspace/lib/headless.js +5 -2
  45. package/workspace/lib/idle-lab.js +5 -5
  46. package/workspace/lib/impact-runs.js +2 -2
  47. package/workspace/lib/job-graph.js +6 -3
  48. package/workspace/lib/metric-draft-runs.js +4 -4
  49. package/workspace/lib/metric-read-runs.js +5 -5
  50. package/workspace/lib/news-for-you.js +1 -1
  51. package/workspace/lib/proposal-runs.js +6 -6
  52. package/workspace/lib/refresh.js +1 -1
  53. package/workspace/lib/routes-artefacts.js +10 -4
  54. package/workspace/lib/routes-autonomy.js +1 -1
  55. package/workspace/lib/routes-board-premium.js +1 -1
  56. package/workspace/lib/routes-goal-status.js +4 -4
  57. package/workspace/lib/routes-impact.js +1 -1
  58. package/workspace/lib/routes-insight-moves.js +1 -1
  59. package/workspace/lib/routes-loose.js +2 -2
  60. package/workspace/lib/routes-mentions.js +1 -1
  61. package/workspace/lib/routes-metric-drafts.js +9 -9
  62. package/workspace/lib/routes-proposals.js +9 -9
  63. package/workspace/lib/routes-ready-reports.js +1 -1
  64. package/workspace/lib/routes-slash.js +1 -1
  65. package/workspace/lib/source-heal.js +3 -3
  66. package/workspace/lib/state-root.js +22 -1
  67. package/workspace/lib/story-seed.js +95 -0
  68. package/workspace/lib/task-items.js +1 -1
  69. package/workspace/lib/task-links.js +2 -2
  70. package/workspace/lib/team-cli.js +1 -1
  71. package/workspace/lib/today.js +2 -2
  72. package/workspace/lib/verify-runs.js +87 -3
  73. package/workspace/live-pill-round-test.js +1 -1
  74. package/workspace/metric-drafts-ui-test.js +1 -1
  75. package/workspace/milestone-suggest-test.js +5 -5
  76. package/workspace/news-viewers-test.js +3 -3
  77. package/workspace/okr-goals-ui-test.js +1 -1
  78. package/workspace/package-lock.json +2 -2
  79. package/workspace/package.json +1 -1
  80. package/workspace/premium-chat-chart-tab-test.js +1 -1
  81. package/workspace/premium-chat-context-test.js +4 -4
  82. package/workspace/premium-chat-goal-setup-test.js +3 -3
  83. package/workspace/premium-chat-goal-view-test.js +1 -1
  84. package/workspace/premium-chat-line-test.js +6 -6
  85. package/workspace/premium-chat-notes-test.js +4 -4
  86. package/workspace/premium-chat-report-tab-test.js +4 -4
  87. package/workspace/premium-rec-now-test.js +2 -2
  88. package/workspace/public/pm/batch-press.js +4 -4
  89. package/workspace/public/pm/bd-fc-card.js +1 -1
  90. package/workspace/public/pm/bd-next.js +10 -10
  91. package/workspace/public/pm/bd-prog-panel.js +5 -5
  92. package/workspace/public/pm/chat-ask.js +1 -1
  93. package/workspace/public/pm/chat-context.js +3 -3
  94. package/workspace/public/pm/cozy-evmodel.js +1 -1
  95. package/workspace/public/pm/cozy-home.css +1 -1
  96. package/workspace/public/pm/cozy-lab-ins.js +4 -4
  97. package/workspace/public/pm/cozy-lab.js +1 -1
  98. package/workspace/public/pm/cozy-news.js +2 -2
  99. package/workspace/public/pm/cozy-onboard.js +2 -2
  100. package/workspace/public/pm/cozy-rec-now.js +5 -5
  101. package/workspace/public/pm/cozy-rec-present.js +1 -1
  102. package/workspace/public/pm/cozy-reveal.js +2 -2
  103. package/workspace/public/pm/cozy-settings.js +19 -19
  104. package/workspace/public/pm/cozy-steps.js +2 -2
  105. package/workspace/public/pm/cozy-viewer.js +1 -1
  106. package/workspace/public/pm/ctx-wedge.js +1 -1
  107. package/workspace/public/pm/dash-view.js +1 -1
  108. package/workspace/public/pm/goal-chat.js +6 -6
  109. package/workspace/public/pm/good-morning.js +2 -2
  110. package/workspace/public/pm/grill-words.js +1 -1
  111. package/workspace/public/pm/home-app.js +19 -19
  112. package/workspace/public/pm/home-ask.js +1 -1
  113. package/workspace/public/pm/home-chat.js +6 -6
  114. package/workspace/public/pm/home-data.js +2 -2
  115. package/workspace/public/pm/home-day.js +3 -3
  116. package/workspace/public/pm/home-drift.js +1 -1
  117. package/workspace/public/pm/home-goal.js +1 -1
  118. package/workspace/public/pm/home-impact.js +1 -1
  119. package/workspace/public/pm/home-ini.js +1 -1
  120. package/workspace/public/pm/home-line.js +5 -5
  121. package/workspace/public/pm/home-mentions.js +4 -4
  122. package/workspace/public/pm/home-moment.js +1 -1
  123. package/workspace/public/pm/home-need.js +1 -1
  124. package/workspace/public/pm/home-phone-card.js +1 -1
  125. package/workspace/public/pm/home-stage-card.js +2 -2
  126. package/workspace/public/pm/home-sweep.js +1 -1
  127. package/workspace/public/pm/home-today.js +2 -2
  128. package/workspace/public/pm/ini-about.js +2 -2
  129. package/workspace/public/pm/ini-agent.js +5 -5
  130. package/workspace/public/pm/ini-links.js +5 -5
  131. package/workspace/public/pm/ini-props.js +11 -11
  132. package/workspace/public/pm/ini-view-model.js +1 -1
  133. package/workspace/public/pm/ini-view.js +2 -2
  134. package/workspace/public/pm/intent.js +3 -3
  135. package/workspace/public/pm/loose-props.js +5 -5
  136. package/workspace/public/pm/metric-drafts.js +1 -1
  137. package/workspace/public/pm/ms-suggest.js +3 -3
  138. package/workspace/public/pm/next-prompt-ui.js +2 -2
  139. package/workspace/public/pm/okr-list.js +1 -1
  140. package/workspace/public/pm/page-chat.js +2 -2
  141. package/workspace/public/pm/premium-attach.js +1 -1
  142. package/workspace/public/pm/premium-initiative-head.js +1 -1
  143. package/workspace/public/pm/premium-insights.js +3 -3
  144. package/workspace/public/pm/premium-meeting.js +1 -1
  145. package/workspace/public/pm/premium-mtg-replay.js +1 -1
  146. package/workspace/public/pm/premium-notes.js +2 -2
  147. package/workspace/public/pm/premium-report-read.js +6 -6
  148. package/workspace/public/pm/premium-report-tab.js +7 -7
  149. package/workspace/public/pm/premium-shell.js +18 -18
  150. package/workspace/public/pm/premium-vw-ctx.js +3 -3
  151. package/workspace/public/pm/premium-vw-jira.js +1 -1
  152. package/workspace/public/pm/premium-welcome.js +1 -1
  153. package/workspace/public/pm/prog-order.js +2 -2
  154. package/workspace/public/pm/program-charter.js +3 -3
  155. package/workspace/public/pm/program-model.js +1 -1
  156. package/workspace/public/pm/ready-lib.js +4 -4
  157. package/workspace/public/pm/report-flow.js +7 -7
  158. package/workspace/public/pm/report-orders-ui.js +2 -2
  159. package/workspace/public/pm/split-merge.js +5 -5
  160. package/workspace/public/pm/story.js +1 -1
  161. package/workspace/public/pm/task-card.js +1 -1
  162. package/workspace/public/pm/tk-draft.js +1 -1
  163. package/workspace/public/pm/tk-send.js +2 -2
  164. package/workspace/public/pm/wf-page.js +2 -2
  165. package/workspace/ready-dash-ui-test.js +1 -1
  166. package/workspace/rec-present-test.js +2 -2
  167. package/workspace/server.js +14 -8
  168. package/workspace/session-names-test.js +3 -3
  169. package/workspace/skills/doc-check.skill +2 -0
  170. package/workspace/skills/idle-lab-prototype.skill +2 -0
  171. package/workspace/skills/measure.skill +2 -0
  172. package/workspace/skills/metric-read.skill +2 -0
  173. package/workspace/skills/milestone-review.skill +2 -0
  174. package/workspace/skills/report-biweekly.skill +2 -0
  175. package/workspace/skills/report-daily.skill +2 -0
  176. package/workspace/skills/report-design.skill +2 -0
  177. package/workspace/skills/report-monthly.skill +2 -0
  178. package/workspace/skills/report-weekly.skill +2 -0
  179. package/workspace/skills/story-first.skill +23 -0
  180. package/workspace/split-merge-ui-test.js +3 -3
  181. package/workspace/stage-card-test.js +4 -4
  182. package/workspace/task-links-test.js +1 -1
  183. package/workspace/task-views-test.js +7 -7
  184. package/workspace/tk-tasks-test.js +2 -2
@@ -0,0 +1,95 @@
1
+ 'use strict';
2
+ /* story-seed.js — PMOS writes a product's first story so far itself (feedback batch 29 item 5).
3
+ *
4
+ * off(env) → true when PMOS_STORY_SEED=off, or on a scratch server (PMOS_STATE_DIR set) unless PMOS_STORY_SEED=1
5
+ * due(last, now) PURE → true when no seed started for the product in the last RETRY_MS (last: ISO time | null)
6
+ * create(deps) → { seed(w, { now }) → { started, why } }
7
+ *
8
+ * WHY. The product page shows "The story so far" (D107 Narrative, board AwE) only after the weekly report writes it, so a new product had
9
+ * no card for up to a week. When the story route finds no story, it calls seed(w): ONE lean background run of the `story-first` skill
10
+ * (headless kind `skill`, `claude -p`), whose only write is `pmos artefacts set portfolio narrative now` with one source per line. The card
11
+ * shows once the line lands; the weekly report keeps it current from then on.
12
+ *
13
+ * At most one start per product per RETRY_MS (kept in <state folder>/story-seed.json, so a restart does not start it again), and one run at
14
+ * a time per product. Off with PMOS_STORY_SEED=off, `pmos ai off story-seed`, PMOS_HEADLESS=off, or on a scratch server.
15
+ *
16
+ * forCtx(ctx) builds the server's one seed from the route context; tests pass their own deps to create().
17
+ *
18
+ * deps: { env, headlessOff() → bool, aiOff() → reason | null, stateDirFor(w) → dir | null, start(w) → { ok, session?, error? }, warn(what, err) }
19
+ */
20
+ const fs = require('fs');
21
+ const path = require('path');
22
+
23
+ const FILE = 'story-seed.json';
24
+ const RETRY_MS = 24 * 3600000;
25
+ const flagOff = (v) => /^(off|0|false|no)$/i.test(String(v || '').trim());
26
+ function off(env) {
27
+ const e = env || process.env;
28
+ const v = String(e.PMOS_STORY_SEED || '').trim();
29
+ if (/^(1|on|true|yes)$/i.test(v)) return false;
30
+ return flagOff(v) || !!String(e.PMOS_STATE_DIR || '').trim();
31
+ }
32
+ function due(last, now) {
33
+ const t = Date.parse(last || '');
34
+ return !Number.isFinite(t) || now - t >= RETRY_MS;
35
+ }
36
+
37
+ function create(deps) {
38
+ const warn = deps.warn || (() => {});
39
+ const running = new Set(); // product ids with a seed run in flight
40
+ const fileOf = (w) => { const d = deps.stateDirFor ? deps.stateDirFor(w) : null; return d ? path.join(d, FILE) : null; };
41
+ function readLast(f, id) { try { const o = JSON.parse(fs.readFileSync(f, 'utf8')); return o && typeof o === 'object' ? o[id] || null : null; } catch { return null; } }
42
+ function writeLast(f, id, at) {
43
+ let o = {};
44
+ try { o = JSON.parse(fs.readFileSync(f, 'utf8')) || {}; } catch { o = {}; }
45
+ o[id] = at;
46
+ fs.mkdirSync(path.dirname(f), { recursive: true });
47
+ fs.writeFileSync(f, JSON.stringify(o) + '\n');
48
+ }
49
+
50
+ function seed(w, { now = Date.now() } = {}) {
51
+ if (!w || !w.id) return { started: false, why: 'no product' };
52
+ if (off(deps.env)) return { started: false, why: 'off' };
53
+ if (deps.headlessOff && deps.headlessOff()) return { started: false, why: 'background runs are off' };
54
+ let ai = null; try { ai = deps.aiOff ? deps.aiOff() : null; } catch { ai = null; }
55
+ if (ai) return { started: false, why: ai };
56
+ if (running.has(w.id)) return { started: false, why: 'running' };
57
+ const f = fileOf(w);
58
+ if (!f) return { started: false, why: 'no state folder' };
59
+ if (!due(readLast(f, w.id), now)) return { started: false, why: 'tried in the last day' };
60
+ try { writeLast(f, w.id, new Date(now).toISOString()); } catch (e) { warn('story-seed.json', e); return { started: false, why: 'could not record the start' }; }
61
+ let r = null;
62
+ try { r = deps.start(w, { onDone: () => running.delete(w.id) }); } catch (e) { warn('story seed', e); }
63
+ if (!r || !r.ok) return { started: false, why: (r && r.error) || 'the run could not start' };
64
+ running.add(w.id);
65
+ return { started: true, session: r.session || null };
66
+ }
67
+ return { seed };
68
+ }
69
+
70
+ /* The one seed of a server, built from the route context (lib/route-modules.js ctx: spawnSession, stateDirFor, runtimeDir), so server.js
71
+ * needs no wiring of its own. The run's prompt is the built-in story-first skill's body. null when the context cannot start a run. */
72
+ const SKILL = path.join(__dirname, '..', 'skills', 'story-first.skill');
73
+ let shared = null;
74
+ function forCtx(ctx) {
75
+ if (shared) return shared;
76
+ if (!ctx || typeof ctx.spawnSession !== 'function' || typeof ctx.stateDirFor !== 'function') return null;
77
+ shared = create({
78
+ env: process.env,
79
+ headlessOff: () => require('./headless.js').switchedOff(process.env),
80
+ aiOff: () => require('./ai-guard.js').off('story-seed', { settingsDir: ctx.runtimeDir || null }),
81
+ stateDirFor: (w) => ctx.stateDirFor(w, { create: true }),
82
+ start: (w, { onDone } = {}) => {
83
+ let prompt = '';
84
+ try { prompt = require('./skill-store.js').parseSkill(fs.readFileSync(SKILL, 'utf8')).body || ''; } catch { prompt = ''; }
85
+ if (!prompt) return { ok: false, error: 'the story-first skill is not installed' };
86
+ const s = ctx.spawnSession({ name: 'Writing the first story', agent: 'claude', ws: w.id, origin: 'story-first:' + w.id, initialInput: prompt + '\r', autoDelete: undefined, onDone,
87
+ modelAsk: { scheduleTier: null, skillTier: null, skill: 'story-first' } });
88
+ if (!s || s.state === 'exited') return { ok: false, error: (s && s.note) || 'the run could not start' };
89
+ return { ok: true, session: s.id };
90
+ },
91
+ });
92
+ return shared;
93
+ }
94
+
95
+ module.exports = { off, due, create, forCtx, FILE, RETRY_MS };
@@ -28,7 +28,7 @@ const isItemId = (id) => typeof id === 'string' && !/^task-/.test(id) && planIte
28
28
  /** An item's owner in the words the Board uses for a task's owner. */
29
29
  function ownerName(o) {
30
30
  if (o === 'you') return 'pm:' + actorLib.PM_SLUG;
31
- if (o === 'agent') return 'Claude';
31
+ if (o === 'agent') return 'PMOS';
32
32
  const m = /^(?:person|tracker):(.+)$/s.exec(String(o || ''));
33
33
  return m ? m[1] : null;
34
34
  }
@@ -377,7 +377,7 @@ function viewOf(F, ini, o) {
377
377
  if (F.drops.has(id)) continue;
378
378
  const word = a.why === 'milestone' ? 'It is a milestone (' + md(b.e) + ')' : a.why === 'other' ? 'It is in another initiative' : 'It would end after the committed date';
379
379
  asks.push({ id, kind: 'promise', why: a.why, task: a.uid, title: b.title, ms: b.ms, days: a.days, to: { start: isoN(a.to.s), due: isoN(a.to.e) }, after: a.after,
380
- text: word + '. Claude recommends moving it ' + (a.days === 1 ? 'a day' : a.days + ' days') + '; ' + clip((T.get(a.after) || {}).title, 40) + ' needs it.' });
380
+ text: word + '. PMOS recommends moving it ' + (a.days === 1 ? 'a day' : a.days + ' days') + '; ' + clip((T.get(a.after) || {}).title, 40) + ' needs it.' });
381
381
  }
382
382
  for (const c of S.clashes) {
383
383
  if (c.kind !== 'jira') continue;
@@ -386,7 +386,7 @@ function viewOf(F, ini, o) {
386
386
  const want = c.need.start != null ? c.need.start : b.s + c.days;
387
387
  asks.push({ id, kind: 'jira', task: c.uid, title: b.title, days: c.days, after: c.after, sent: F.sent.has(id),
388
388
  head: c.uid + ' starts ' + md(b.s) + ', ' + (c.days === 1 ? 'a day' : c.days + ' days') + ' too early',
389
- text: 'Jira, so PMOS can’t move it. Claude drafted a comment asking to start ' + md(want) + '.',
389
+ text: 'Jira, so PMOS can’t move it. PMOS drafted a comment asking to start ' + md(want) + '.',
390
390
  comment: 'Could ' + c.uid + ' start on ' + md(want) + ' or later? It waits on "' + clip(a ? a.title : c.after, 80) + '", which finishes ' + md(effOf(a, today).e) + '.' });
391
391
  }
392
392
  // the proposals: Claude's links, Pull N tasks in, and (with the quiet moves off) the moves Claude would have made
@@ -123,7 +123,7 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
123
123
  if (!v.ok) return fail(`the ${role.name} may not write ${pos[0] || '(nothing)'}: ${v.why}`);
124
124
  if (!fs.existsSync(path.join(root, v.rel))) return fail(`${v.rel} is not on disk; write it first`);
125
125
  R.append(dir, { kind: 'write', run: runId, role: role.key, session, rel: v.rel, ini, mode }, now);
126
- try { const A = require('./autonomy.js'); if (typeof A.recordApplied === 'function') A.recordApplied(dir, { job: 'ai:' + role.key, product: ini || null, ref: v.rel, title: `${role.name} wrote ${v.rel}`, cls: role.cls }); } catch { /* the autonomy build is not here yet */ }
126
+ try { const A = require('./autonomy.js'); if (typeof A.recordApplied === 'function') A.recordApplied(dir, { job: 'ai:' + role.key, product: ini || null, ref: v.rel, title: `${role.name} wrote ${v.rel}`, cls: role.cls, run: runId }); } catch { /* the autonomy build is not here yet */ }
127
127
  return ok({ rel: v.rel }, `✓ recorded: the ${role.name} wrote ${v.rel}`);
128
128
  }
129
129
  if (verb === 'done') {
@@ -133,8 +133,8 @@ function stateDirOf(root) {
133
133
  const d = path.join(root, ...rel);
134
134
  if (isDir(d)) return d;
135
135
  }
136
- // PMOS-self with no pmos/state/: the checkout's own workspace/state/ (server.js returns LEGACY_STATE for the same tree)
137
- if (SELF.embedded && path.resolve(root) === SELF.root) return path.join(SELF.appDir, 'state');
136
+ // PMOS-self with no pmos/state/: lib/state-root.js#selfRecordsDir, the same answer server.js stateDirFor gives
137
+ if (SELF.embedded && path.resolve(root) === SELF.root) return require('./state-root.js').selfRecordsDir({ legacy: path.join(SELF.appDir, 'state') });
138
138
  return null;
139
139
  }
140
140
 
@@ -21,8 +21,16 @@
21
21
  *
22
22
  * Off: PMOS_VERIFY=off, a scratch server (PMOS_STATE_DIR set, unless PMOS_VERIFY=1), PMOS_HEADLESS=off, `pmos ai off verify` (the bg-queue switch). Runs only when deep work may run (open(now)).
23
23
  *
24
+ * THE APPLIED-CHANGE CHECK (batch 29 item 9, D106). Jobs that change records by themselves open no pull request, so step 2 never grades
25
+ * them. When no merged run is started, one turn may instead grade ONE change an agent applied by itself (lib/autonomy.js toCheck: class B,
26
+ * an hour old, inside its Undo window): headless kind `verify`, origin `verify:change:<ref>:<token>`, with PMOS_CHECK_REF and PMOS_CHECK_DIR
27
+ * pinned to that change. Its one write is `pmos autonomy check <ref> --verdict PASS|FAIL`; a FAIL sends the job back to asking for 7 days.
28
+ * At most CHECKS_PER_DAY a day; a change tried once is not tried again that day. Off with PMOS_VERIFY_CHANGES=off.
29
+ * PR-BACKED RUNS: an applied line that names its run is a setback when the verifier FAILs that run (evals.jsonl) or its merge is reverted
30
+ * (`node scripts/run-corrections.js --json`, at most every SWEEP_MS per repository, and only while such a line exists).
31
+ *
24
32
  * deps: { roots() → [{ id, root }], open(now) → bool, headlessOff() → bool, env, spawn(spec), stop(session), warn(what, err),
25
- * run(root, args) → { code, stdout } (default: spawnSync node), perDay? }
33
+ * run(root, args) → { code, stdout } (default: spawnSync node), perDay?, stateDirs(w) → [the autonomy ledgers of a workspace] }
26
34
  */
27
35
  const fs = require('fs');
28
36
  const path = require('path');
@@ -30,6 +38,29 @@ const crypto = require('crypto');
30
38
  const { spawnSync } = require('child_process');
31
39
 
32
40
  const PER_DAY = 4;
41
+ const CHECKS_PER_DAY = 4;
42
+ const SWEEP_MS = 6 * 3600000;
43
+ const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
44
+ /** The prompt of one applied-change check. a: the applied entry (lib/autonomy.js). */
45
+ function changePrompt(a) {
46
+ const ini = a.ini ? `initiative ${a.ini}` : 'the record it names';
47
+ return 'You check ONE change that PMOS made by itself, without asking the PM. Grade only this change. Read only; change nothing.\n\n'
48
+ + `- Change: ${one(a.title, 200)}\n- Job: ${a.job} (class ${a.cls || 'B'}), on ${ini}, made ${a.at}\n`
49
+ + `- What it was read from: ${one(a.why, 200) || 'not recorded'}\n\n`
50
+ + `1. Read the record it changed${a.ini ? `: \`pmos initiative export ${a.ini}\` (and \`pmos artefacts show experiment:${a.ini}\` for a line of the experiment)` : ''}, and the sources it names.\n`
51
+ + '2. Decide: is the change true to what it was read from, about this record, not a duplicate and not invented? A change you cannot confirm from what you can read is a FAIL.\n'
52
+ + `3. Record it once: \`pmos autonomy check ${a.ref} --verdict PASS|FAIL --why "<one line>"\`. Then stop. Send nothing.`;
53
+ }
54
+ /** The run ids a repository's own evidence turns against their changes: verifier FAILs and reverted merges. PURE on its inputs. */
55
+ function runEvidence(evalsText, corrections) {
56
+ const failed = new Set(), reverted = new Set();
57
+ for (const l of String(evalsText || '').split('\n')) {
58
+ if (!l.includes('FAIL')) continue;
59
+ try { const o = JSON.parse(l); if (o && o.run_id && o.source === 'verifier-after-merge' && String(o.verdict || '').toUpperCase() === 'FAIL') failed.add(String(o.run_id)); } catch { /* a torn line */ }
60
+ }
61
+ for (const r of (corrections && corrections.rows) || []) if ((r.components || []).some((c) => c.kind === 'revert')) reverted.add(String(r.run_id));
62
+ return { failed: [...failed], reverted: [...reverted] };
63
+ }
33
64
  const flagOff = (v) => /^(off|0|false|no)$/i.test(String(v || '').trim());
34
65
  /* Off when PMOS_VERIFY says so, and on a scratch server unless asked (PMOS_VERIFY=1): a server given its own state directory (every suite
35
66
  * does, through test-run.js) must never claim real queue entries or start a model, the same rule lib/auto-sync.js enabledFor keeps. */
@@ -85,9 +116,60 @@ function create(deps) {
85
116
  const run = deps.run || nodeRun;
86
117
  const perDay = Number(deps.perDay) > 0 ? Number(deps.perDay) : PER_DAY;
87
118
  let active = null; // { run_id, token, root, session }
119
+ const tried = new Map(); // day → [refs a check started for]
120
+ const swept = new Map(); // root → when its runs were last swept
88
121
 
89
122
  function ended(token) { if (active && active.token === token) active = null; }
90
123
 
124
+ const dirsOf = (w) => { try { return (deps.stateDirs && deps.stateDirs(w)) || []; } catch { return []; } };
125
+ /* PR-backed runs: a FAIL or a revert of a run is a setback of the changes it applied (lib/autonomy.js fromRuns) */
126
+ function sweepRuns(roots, now) {
127
+ const A = require('./autonomy.js');
128
+ const out = [];
129
+ for (const w of roots) {
130
+ const dirs = dirsOf(w);
131
+ if (!isCheckout(w.root) || !dirs.length || now - (swept.get(w.root) || 0) < SWEEP_MS) continue;
132
+ if (!dirs.some((d) => [...A.fold(A.read(d)).applied.values()].some((a) => a.run && !a.undone))) continue;
133
+ swept.set(w.root, now);
134
+ let ev = '', corr = null;
135
+ try { ev = fs.readFileSync(path.join(w.root, 'planning', 'runs', 'evals.jsonl'), 'utf8'); } catch { ev = ''; }
136
+ try { if (fs.existsSync(path.join(w.root, 'scripts', 'run-corrections.js'))) corr = parse(run(w.root, ['scripts/run-corrections.js', '--json']).stdout); } catch (e) { warn('run-corrections', e); }
137
+ const rs = runEvidence(ev, corr);
138
+ for (const d of dirs) { try { out.push(...A.fromRuns(d, rs, { now })); } catch (e) { warn('autonomy setback', e); } }
139
+ }
140
+ return out;
141
+ }
142
+ /* one applied-change check, when the day's cap allows */
143
+ function checkChange(roots, now, day) {
144
+ const e = deps.env || process.env;
145
+ if (/^(off|0|false|no)$/i.test(String(e.PMOS_VERIFY_CHANGES || '').trim())) return null;
146
+ const A = require('./autonomy.js');
147
+ const today = tried.get(day) || [];
148
+ if (today.length >= CHECKS_PER_DAY) return null;
149
+ for (const w of roots) {
150
+ for (const dir of dirsOf(w)) {
151
+ const a = A.toCheck(dir, { now, skip: today });
152
+ if (!a) continue;
153
+ today.push(a.ref); tried.clear(); tried.set(day, today);
154
+ const token = 'vc' + now.toString(36) + crypto.randomBytes(3).toString('hex');
155
+ active = { run_id: 'change:' + a.ref, token, root: w.root, session: null };
156
+ let session = null;
157
+ try {
158
+ session = deps.spawn({ name: 'Checking a change PMOS made', ws: w.id, origin: `verify:change:${a.ref}:${token}`, initialInput: changePrompt(a) + '\r',
159
+ env: { PMOS_CHECK_REF: a.ref, PMOS_CHECK_DIR: dir }, onDone: () => ended(token) });
160
+ } catch (err) { warn('change check', err); }
161
+ if (!session || session.held || session.state === 'exited' || session.headless !== 'verify') {
162
+ if (session && !session.held && session.headless !== 'verify' && session.state !== 'exited' && deps.stop) { try { deps.stop(session); } catch { /* best effort */ } }
163
+ active = null;
164
+ return { checked: null, held: !!(session && session.held) };
165
+ }
166
+ active.session = session;
167
+ return { checked: a.ref };
168
+ }
169
+ }
170
+ return null;
171
+ }
172
+
91
173
  function tick({ now = Date.now() } = {}) {
92
174
  if (off(deps.env) || (deps.headlessOff && deps.headlessOff())) return { off: true };
93
175
  if (active) return { running: active.run_id };
@@ -124,10 +206,12 @@ function create(deps) {
124
206
  active.session = session;
125
207
  return { started: e.run_id, integrated };
126
208
  }
127
- return { started: null, integrated };
209
+ const setbacks = sweepRuns(roots, now);
210
+ const c = checkChange(roots, now, day);
211
+ return { started: null, integrated, ...(setbacks.length ? { setbacks } : {}), ...(c ? c : {}) };
128
212
  }
129
213
 
130
214
  return { tick, active: () => (active ? active.run_id : null) };
131
215
  }
132
216
 
133
- module.exports = { off, startsToday, create, isCheckout, PER_DAY, statusOf };
217
+ module.exports = { off, startsToday, create, isCheckout, PER_DAY, CHECKS_PER_DAY, statusOf, changePrompt, runEvidence };
@@ -80,7 +80,7 @@ const ASKS = () => RUNNING().concat([{ id: 'b', name: 'Redistribute plan items',
80
80
  /* L3 */
81
81
  live = ASKS(); await kick();
82
82
  const l3 = await until(() => page.evaluate(() => { const l = document.getElementById('czLive'); return l && l.classList.contains('asks') ? { text: l.textContent.trim(), bg: getComputedStyle(l).backgroundColor, card: getComputedStyle(document.body).getPropertyValue('--cz-card') } : null; }));
83
- ok('L3 Claude asks: the pill turns blue, with the count', l3 && l3.text === '3' && !/255, 255, 255/.test(l3.bg), JSON.stringify(l3));
83
+ ok('L3 PMOS asks: the pill turns blue, with the count', l3 && l3.text === '3' && !/255, 255, 255/.test(l3.bg), JSON.stringify(l3));
84
84
  await shot(page, 'pill-asks');
85
85
 
86
86
  /* L4 */
@@ -121,7 +121,7 @@ const INITIATIVE = () => ({
121
121
  ok('P checkpoint chips at its milestones, and the guardrail', !!c && c.cps.join(' / ') === '40% at Legacy IdP off · Feb 27 / 85% at All microsites · Mar 20 / Guardrail: Sign-in success · stays above 99%', c && c.cps.join(' / '));
122
122
  ok('P Built from: Now and Target, a drafted ticket as a pill', !!c && c.built.join(' / ') === 'idpf · sign-ins on CIAM | 15% | 100% by Feb 27 / Microsites · sign-ins on CIAM | — | Ticket MS-212 drafted'
123
123
  && await p.evaluate(() => !!document.querySelector('#czViewer .md-card .md-ru .md-pill')), c && c.built.join(' / '));
124
- ok('P one line of why, in Claude\'s words', !!c && c.why === 'idpf is 80% of all sign-ins, so it carries the goal. I check it every morning once you keep it.', c && c.why);
124
+ ok('P one line of why, in PMOS\'s words', !!c && c.why === 'idpf is 80% of all sign-ins, so it carries the goal. I check it every morning once you keep it.', c && c.why);
125
125
  ok('P Discuss in Home, Edit (in place, batch 16) and a solid ✓ Keep this goal: icon-only, each with a label and a title', !!c && c.presses.map((x) => x.label).join() === 'Discuss the proposed goal in Home,Edit the proposed goal,Keep this goal'
126
126
  && c.presses.every((x) => x.title && !x.text && x.svg) && c.presses[2].solid && /ask=program%3Aproject-ascent/.test(c.presses[0].href) && !c.presses[1].href, JSON.stringify(c && c.presses));
127
127
  ok('P the read names the program and its product', D.gets.some((g) => g.scope === 'program' && g.id === 'project-ascent' && g.ws === 'idpf'), JSON.stringify(D.gets));
@@ -87,7 +87,7 @@ const withReview = (open, o = {}) => F.programs().map((p) => ({ ...p, ...(o.empt
87
87
  const N = await open({ programs: withReview(FIRST, { empty: true }) });
88
88
  const f = await rows(N.page, '#czViewer .msg-box');
89
89
  const fh = await N.page.evaluate(() => ({ head: (document.querySelector('#czViewer .msg-box .msg-hd .msg-ht') || {}).textContent || '', ghost: !!document.querySelector('#czViewer [data-pp="first"]'), all: [...document.querySelectorAll('#czViewer .msg-hd [data-ms-act]')].map((b) => b.dataset.msAct) }));
90
- ok('F a program with no milestones: Claude\'s first suggestions take the place of "Add the first milestone"', f.length === 4 && !fh.ghost && fh.head === 'Claude suggests 4 milestones from a task, the initiatives\' ◆ dates and the target date', JSON.stringify(fh));
90
+ ok('F a program with no milestones: PMOS\'s first suggestions take the place of "Add the first milestone"', f.length === 4 && !fh.ghost && fh.head === 'PMOS suggests 4 milestones from a task, the initiatives\' ◆ dates and the target date', JSON.stringify(fh));
91
91
  ok('F each row: its name, date, why and source; ✓ ✎ ✕ icon-only with a label', f[0].t === 'Vendor contract signed' && f[0].d === 'Oct 28' && /order form is due Oct 28/.test(f[0].why) && f[0].src === 'Task, due Oct 28'
92
92
  && f.every((r) => r.presses.join() === 'keep,edit,drop'), JSON.stringify(f[0]));
93
93
  await shot(N.page, 'XmsgB-first-built');
@@ -111,7 +111,7 @@ const withReview = (open, o = {}) => F.programs().map((p) => ({ ...p, ...(o.empt
111
111
  ok('W the changes lead the proposals, in plain words, each with why and its source', w.map((r) => r.t).join('|') === 'Move Pilot live to Dec 2|Partner SSO cut-over|Mark Legacy IdP off at risk' && w[0].src === 'Jira, read 2h ago' && /DSC-41/.test(w[0].why), JSON.stringify(w));
112
112
  ok('W the proposals count includes them', /^\d+$/.test(cnt.trim()) && Number(cnt) >= 3, cnt);
113
113
  ok('W the track stays as it is until the PM keeps a change', await p.evaluate(() => !!document.querySelector('#czViewer .pp-mt') && !document.querySelector('#czViewer .msg-box')));
114
- ok('K the ◆ dates the page reads are reported once, so a moved date asks Claude for a review', await until(() => D.posts.filter((x) => x.path === '/api/programs/facts').length === 1, 4000) && /descope-parity:\d{4}-\d{2}-\d{2}/.test((D.posts.find((x) => x.path === '/api/programs/facts') || { body: {} }).body.fp || ''), JSON.stringify(D.posts.filter((x) => x.path === '/api/programs/facts')));
114
+ ok('K the ◆ dates the page reads are reported once, so a moved date asks PMOS for a review', await until(() => D.posts.filter((x) => x.path === '/api/programs/facts').length === 1, 4000) && /descope-parity:\d{4}-\d{2}-\d{2}/.test((D.posts.find((x) => x.path === '/api/programs/facts') || { body: {} }).body.fp || ''), JSON.stringify(D.posts.filter((x) => x.path === '/api/programs/facts')));
115
115
  await shot(p, 'XmsgB-asks-built');
116
116
  await p.click('#czViewer [data-ms-act="keep"][data-key="k-move"]');
117
117
  await until(() => D.posts.some((x) => x.path === '/api/programs/suggestion'), 4000);
@@ -126,8 +126,8 @@ const withReview = (open, o = {}) => F.programs().map((p) => ({ ...p, ...(o.empt
126
126
  await p.click('#czViewer [data-ms-act="edit"][data-key="k-move"]');
127
127
  ok('C the pencil opens the charter', await charterShown(p));
128
128
  const cv = await p.evaluate(() => { const r = document.querySelector('#czViewer .pc-lnw.msg-on'); return { day: r && r.querySelector('.pc-fd span').textContent, note: r && (r.querySelector('.msg-chg') || {}).textContent, save: !!document.querySelector('#czViewer .cz-vw-hd .cz-vw-pri'), chk: (document.querySelector('#czViewer .msg-chk span') || {}).textContent || '', now: !!document.querySelector('#czViewer [data-pc="checknow"][aria-label="Check now"]') }; });
129
- ok('C the change is filled in, unsaved: the row says what it was, and Save shows', cv.day === 'Dec 2' && /^Claude's change, was Nov 18, ready to save\. Edit it, then Save\.$/.test(cv.note || '') && cv.save, JSON.stringify(cv));
130
- ok('C the charter says when Claude last checked, with Check now', /^Claude checks every Monday and when a date, Jira or a meeting changes\. Last checked today, \d\d:\d\d\.$/.test(cv.chk) && cv.now, cv.chk);
129
+ ok('C the change is filled in, unsaved: the row says what it was, and Save shows', cv.day === 'Dec 2' && /^PMOS's change, was Nov 18, ready to save\. Edit it, then Save\.$/.test(cv.note || '') && cv.save, JSON.stringify(cv));
130
+ ok('C the charter says when PMOS last checked, with Check now', /^PMOS checks every Monday and when a date, Jira or a meeting changes\. Last checked today, \d\d:\d\d\.$/.test(cv.chk) && cv.now, cv.chk);
131
131
  await shot(p, 'XmsgB-charter-built');
132
132
  await p.click('#czViewer .cz-vw-hd .cz-vw-pri');
133
133
  await until(() => D.posts.some((x) => x.body.key === 'k-move' && x.body.answer === 'edit'), 5000);
@@ -135,7 +135,7 @@ const withReview = (open, o = {}) => F.programs().map((p) => ({ ...p, ...(o.empt
135
135
  ok('C Save writes the charter with the new date (ids kept) and answers the suggestion', !!sv && sv.body.program.milestones.find((m) => m.id === 'pilot-live').date === '2026-12-02' && D.posts.some((x) => x.body.key === 'k-move' && x.body.answer === 'edit'), JSON.stringify(sv && sv.body.program.milestones.map((m) => m.id + ':' + m.date)));
136
136
  await p.click('#czViewer [data-pc="checknow"]');
137
137
  await until(() => D.posts.some((x) => x.path === '/api/programs/review'), 4000);
138
- ok('C Check now asks Claude to review', D.posts.some((x) => x.path === '/api/programs/review' && x.body.program === 'project-ascent'));
138
+ ok('C Check now asks PMOS to review', D.posts.some((x) => x.path === '/api/programs/review' && x.body.program === 'project-ascent'));
139
139
  ok('0 no page error (desk)', D.errors.length === 0, D.errors.join(' | '));
140
140
  await D.ctx.close();
141
141
 
@@ -54,7 +54,7 @@ const ROWS = { 'psle-article-paywall-lock': { title: 'PSLE Article Paywall Lock'
54
54
  const p = await ctx.newPage(), posts = [], errs = [];
55
55
  p.on('pageerror', (e) => errs.push(String(e)));
56
56
  const news = () => { const o = items.filter((x) => x.kind === 'overlap'), t = items.filter((x) => x.kind === 'task');
57
- const groups = [o.length && { key: 'propose', label: 'Claude proposes', items: o }, t.length && { key: 'given', label: 'Given to you', items: t }].filter(Boolean);
57
+ const groups = [o.length && { key: 'propose', label: 'PMOS proposes', items: o }, t.length && { key: 'given', label: 'Given to you', items: t }].filter(Boolean);
58
58
  return { ok: true, count: o.length + t.length, groups, read: { inbox: true, work: true } }; };
59
59
  await p.route('**/api/news-for-you', (r) => json(r, news()));
60
60
  await p.route('**/api/news-for-you?*', (r) => json(r, news()));
@@ -78,13 +78,13 @@ const ROWS = { 'psle-article-paywall-lock': { title: 'PSLE Article Paywall Lock'
78
78
  await openItem(p, OVERLAP.id);
79
79
  const shown = await until(() => p.evaluate(() => /Plan · Mei’s/.test((document.querySelector('#czViewer') || {}).textContent || '')));
80
80
  const t = await vwText(p);
81
- ok('O1 the overlap opens as its own Viewer: one header named "Possible overlap", Claude noticed, no second back press', shown && /Possible overlap/.test(await p.evaluate(() => document.querySelector('#czVwTitle').textContent)) && /Claude noticed/.test(t)
81
+ ok('O1 the overlap opens as its own Viewer: one header named "Possible overlap", PMOS noticed, no second back press', shown && /Possible overlap/.test(await p.evaluate(() => document.querySelector('#czVwTitle').textContent)) && /PMOS noticed/.test(t)
82
82
  && !(await p.evaluate(() => !!document.querySelector('#czViewer [data-ev-back]'))), t.slice(0, 300));
83
83
  ok('O2 both initiatives by name with stage and owner, first and second; never a slug or "a source"', /PSLE Article Paywall Lock/.test(t) && /Discover · yours/.test(t) && /Plan · Mei’s/.test(t) && /1st/.test(t) && /2nd/.test(t)
84
84
  && !/psle-companion-addon-follow-on|a source|Open in Home/.test(t), t);
85
85
  ok('O3 the summary: "2 of 6 parts overlap", the sentence and how sure', /2 of 6 parts overlap/.test(t) && /The rest is separate/.test(t) && /How sure: high\. Both plans name the same checkout screens/.test(t), t);
86
86
  const picks = await p.evaluate(() => [...document.querySelectorAll('#czViewer [data-nv-pick]')].map((b) => b.getAttribute('aria-checked') + ':' + b.textContent.trim().slice(0, 60)));
87
- ok('O4 the pick: Keep both, in this order (Claude\'s, checked), Merge into the first, Not an overlap', picks.length === 3 && /^true:Keep both, in this order/.test(picks[0]) && /Merge into PSLE Article Paywall Lock/.test(picks[1]) && /^false:Not an overlap/.test(picks[2]), picks);
87
+ ok('O4 the pick: Keep both, in this order (PMOS\'s, checked), Merge into the first, Not an overlap', picks.length === 3 && /^true:Keep both, in this order/.test(picks[0]) && /Merge into PSLE Article Paywall Lock/.test(picks[1]) && /^false:Not an overlap/.test(picks[2]), picks);
88
88
  const fold = await p.evaluate(() => { const b = document.querySelector('#czViewer .czs-row[data-czs-fold="parts"]'); return b ? b.textContent : ''; });
89
89
  ok('O5 the parts that overlap fold under the pick', /The 2 parts that overlap/.test(fold), fold);
90
90
  const tight = await p.evaluate(() => { const s = document.scrollingElement; return s.scrollWidth <= s.clientWidth + 1 && [...document.querySelectorAll('#czViewer .nv-opt, #czViewer .nv-ini, #czViewer .nv-pri')].every((b) => b.getBoundingClientRect().height >= 44); });
@@ -115,7 +115,7 @@ const ROWS = [
115
115
  ok('D2 a draft has ✕ / ✎ / ✓, and ✓ says its act (Send)', under.acts.join('|') === 'Not now|Edit|Send', under.acts.join('|'));
116
116
  ok('D3 an outcome draft says what it was', under.old === 'Was “Time to first call”', under.old);
117
117
  const line = await p.evaluate(() => ({ t: document.querySelector('#brief').textContent + ' ' + document.querySelector('#insWhy').textContent, all: !!document.querySelector('#insAct [data-okl="keep-all"]') }));
118
- ok('D4 the ✦ line says what Claude drafted, with ✓✓ to keep them all, and never "no insight"', /I drafted 3 (changes|fixes)/.test(line.t) && line.all && !/no insight/i.test(line.t), JSON.stringify(line));
118
+ ok('D4 the ✦ line says what PMOS drafted, with ✓✓ to keep them all, and never "no insight"', /I drafted 3 (changes|fixes)/.test(line.t) && line.all && !/no insight/i.test(line.t), JSON.stringify(line));
119
119
  await p.click('[data-draft="d-chase"] [data-okd="keep"]');
120
120
  ok('D5 ✓ posts that draft\'s row', await until(() => R.posts.some((x) => x.path === '/api/metric-drafts/keep' && x.body.row === 'd-chase')));
121
121
  await p.click('#insAct [data-okl="keep-all"]');
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.553.0",
3
+ "version": "0.555.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.553.0",
9
+ "version": "0.555.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.553.0",
3
+ "version": "0.555.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",
@@ -92,7 +92,7 @@ const look = () => {
92
92
 
93
93
  { const { p, ctx, errs } = await open(1280, [ASK('chart partner activation as bars'), { role: 'assistant', text: 'Partner activation is at 33%.\n\n' + block(CHART) }]);
94
94
  const s0 = await p.evaluate(look);
95
- ok('C1 the chart block is a chip under Claude\'s words', /Partners activating/.test(s0.chip || '') && /New chart/.test(s0.chip || ''), JSON.stringify(s0));
95
+ ok('C1 the chart block is a chip under PMOS\'s words', /Partners activating/.test(s0.chip || '') && /New chart/.test(s0.chip || ''), JSON.stringify(s0));
96
96
  await p.click('#hmLog [data-report-open]');
97
97
  const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane && v.tiles.length ? v : null; }) || await p.evaluate(look);
98
98
  ok('C1 the Chart view draws the measure from its five readings as bars, as proposed: three stat tiles, the newest bar in ember', s1.tabs.includes('Chart') && /New chart/.test(s1.pane || '') && s1.bars === 5 && s1.form === 'Bars' && s1.kpis === 3 && s1.ember === 1 && !(await p.$('#czViewer .rt, #czViewer .obody, #czViewer .mt1')), JSON.stringify(s1));
@@ -77,12 +77,12 @@ const second = (k) => [
77
77
  { const { p, ctx, errs, conv } = await open(1280);
78
78
  await sleep(2500); // a read after the first: an answer already there opens nothing
79
79
  const s0 = await p.evaluate(look);
80
- ok('C1 the answer that was there has its chips, the file Claude wrote first and the file it read after', JSON.stringify(s0.chips) === JSON.stringify([['file:signup-drop.md*', 'file:signup-fix.md']]), JSON.stringify(s0.chips));
80
+ ok('C1 the answer that was there has its chips, the file PMOS wrote first and the file it read after', JSON.stringify(s0.chips) === JSON.stringify([['file:signup-drop.md*', 'file:signup-fix.md']]), JSON.stringify(s0.chips));
81
81
  ok('C1 it opens nothing by itself: the viewer stays closed', s0.shut && s0.out === 0 && s0.tabs.length === 0, JSON.stringify(s0));
82
82
  await answer(p, conv, 1, true);
83
83
  await sleep(2600);
84
84
  const s1 = await p.evaluate(look);
85
- ok('C2 while Claude still works, the new answer has no chips and nothing opens', s1.shut && s1.chips.length === 1, JSON.stringify(s1));
85
+ ok('C2 while PMOS still works, the new answer has no chips and nothing opens', s1.shut && s1.chips.length === 1, JSON.stringify(s1));
86
86
  conv.turn = 'user';
87
87
  const s2 = await until(async () => { const v = await p.evaluate(look); return !v.shut && v.tabs.length ? v : null; }, 6000) || await p.evaluate(look);
88
88
  ok('C2 when it has finished, its main item (the file it changed) opens in the viewer', !s2.shut && s2.out > 300 && JSON.stringify(s2.tabs) === JSON.stringify(['signup-plan1.md']), JSON.stringify(s2));
@@ -112,7 +112,7 @@ const second = (k) => [
112
112
  { role: 'assistant', text: 'I summed them up.', at: '2026-10-21T08:02:20Z' }];
113
113
  const fold = () => p.evaluate(() => { const c = [...document.querySelectorAll('#hmLog .ctxc[role=list]')].pop(); if (!c) return null; const d = c.querySelector('details.ctxmore'); const vis = [...c.querySelectorAll('.ctxchip')].filter((b) => b.getBoundingClientRect().height > 0).map((b) => b.querySelector('b').textContent); return { vis, more: d ? d.querySelector('summary').textContent : null, open: !!(d && d.open), n: document.querySelectorAll('#hmLog .ctxc[role=list]').length }; });
114
114
  const f0 = await until(async () => { const v = await fold(); return v && v.n >= 2 && v.more ? v : null; }, 6000) || await fold();
115
- ok('C7 three files Claude only read fold into "+3 read"; the file it wrote stays in sight', !!f0 && JSON.stringify(f0.vis) === JSON.stringify(['summary.md']) && f0.more === '+3 read', JSON.stringify(f0));
115
+ ok('C7 three files PMOS only read fold into "+3 read"; the file it wrote stays in sight', !!f0 && JSON.stringify(f0.vis) === JSON.stringify(['summary.md']) && f0.more === '+3 read', JSON.stringify(f0));
116
116
  ok('C7 the first answer\'s one read file is not folded', JSON.stringify((await p.evaluate(look)).chips[0]) === JSON.stringify(['file:signup-drop.md*', 'file:signup-fix.md']));
117
117
  await p.click('#hmLog details.ctxmore > summary');
118
118
  const f1 = await fold();
@@ -129,7 +129,7 @@ const second = (k) => [
129
129
  await sleep(2500);
130
130
  await answer(p, conv, 2, false);
131
131
  const s0 = await until(async () => { const v = await p.evaluate(look); return v.peek ? v : null; }, 6000) || await p.evaluate(look);
132
- ok(`C5 at 390 (${scheme}) a new answer shows a bar over the message box and leaves the conversation uncovered`, /Claude wrote this · signup-plan2\.md\s*View/.test(s0.peek || '') && !s0.layer && s0.tab === 'chat', JSON.stringify(s0));
132
+ ok(`C5 at 390 (${scheme}) a new answer shows a bar over the message box and leaves the conversation uncovered`, /PMOS wrote this · signup-plan2\.md\s*View/.test(s0.peek || '') && !s0.layer && s0.tab === 'chat', JSON.stringify(s0));
133
133
  if (shots) await p.screenshot({ path: `${shots}/chat-context-390-${scheme}.png` });
134
134
  await p.click('#hmPeek');
135
135
  const s1 = await until(async () => { const v = await p.evaluate(look); return v.tab === 'out' && v.tabs.length ? v : null; }) || await p.evaluate(look);
@@ -109,7 +109,7 @@ const look = () => {
109
109
  if (shots) await p.screenshot({ path: `${shots}/plan-${width}-${scheme}.png` });
110
110
  await p.click('#hmLog .gplan [data-goal="change"]');
111
111
  const s1 = await poll(p, (v) => v.ed);
112
- ok(`E1 ${tag} Change turns the card into the editor in place, one field per point`, s1.ed && s1.fields.length === 4 && s1.fields[2] === DRAFT.done[2] && s1.ph === 'Or tell Claude what to change', JSON.stringify(s1));
112
+ ok(`E1 ${tag} Change turns the card into the editor in place, one field per point`, s1.ed && s1.fields.length === 4 && s1.fields[2] === DRAFT.done[2] && s1.ph === 'Or tell PMOS what to change', JSON.stringify(s1));
113
113
  const f3 = '#hmLog [data-goal-ed] .edl li:nth-child(3) textarea';
114
114
  await p.fill(f3, 'Out-of-scope list, with SSO and Okta on it');
115
115
  await p.click('#hmLog [data-goal-ed] [data-goal-add]');
@@ -153,13 +153,13 @@ const look = () => {
153
153
  await p.evaluate(() => import('/pm/premium-viewer.js').then(() => document.querySelector('#hmLog [data-goal-open]') && document.querySelector('#hmLog [data-goal-open]').click()));
154
154
  let s0 = await poll(p, (v) => v.view, 3000);
155
155
  if (!s0.view) { await p.evaluate(() => { const b = document.querySelector('.hm-pl [data-pl="toggle"], #hmLog [data-goal-open]'); if (b) b.click(); }); s0 = await poll(p, (v) => v.view, 3000); }
156
- ok(`K1 ${tag} the Goal view has × on a point that has not started, none on the point Claude is on`, s0.skips.includes(DRAFT.done[2]) && s0.skips.includes(DRAFT.done[3]) && !s0.skips.includes(DRAFT.done[1]) && !s0.skips.includes(DRAFT.done[0]), JSON.stringify(s0));
156
+ ok(`K1 ${tag} the Goal view has × on a point that has not started, none on the point PMOS is on`, s0.skips.includes(DRAFT.done[2]) && s0.skips.includes(DRAFT.done[3]) && !s0.skips.includes(DRAFT.done[1]) && !s0.skips.includes(DRAFT.done[0]), JSON.stringify(s0));
157
157
  await p.click(`#czViewer [data-goal-skip="${DRAFT.done[2]}"]`);
158
158
  const sk = await until(() => st.posts.find((x) => x.act === 'skip'));
159
159
  ok(`K1 ${tag} × sends the skip for that point`, sk && sk.point === DRAFT.done[2] && sk.id === 'g2', JSON.stringify(st.posts));
160
160
  st.goal = started({ skipped: [DRAFT.done[2]], skipAt: { [DRAFT.done[2]]: '2026-10-25T02:00:00Z' } });
161
161
  const s1 = await poll(p, (v) => v.unskip.length);
162
- ok(`K1 ${tag} the skipped point is struck through with Undo, and the count leaves it out`, s1.unskip[0] === DRAFT.done[2] && /Skipped by you · Claude drops it after this step/.test(s1.view || '') && /1 of 3 (done )?points met/.test(s1.view || ''), JSON.stringify(s1));
162
+ ok(`K1 ${tag} the skipped point is struck through with Undo, and the count leaves it out`, s1.unskip[0] === DRAFT.done[2] && /Skipped by you · PMOS drops it after this step/.test(s1.view || '') && /1 of 3 (done )?points met/.test(s1.view || ''), JSON.stringify(s1));
163
163
  await p.click(`#czViewer [data-goal-unskip="${DRAFT.done[2]}"]`);
164
164
  const un = await until(() => st.posts.find((x) => x.act === 'unskip'));
165
165
  ok(`K1 ${tag} Undo sends the point back`, un && un.point === DRAFT.done[2], JSON.stringify(st.posts));
@@ -96,7 +96,7 @@ const look = () => {
96
96
  const posted = await until(() => st.posts.find((x) => x.act === 'stop'));
97
97
  ok('G4 Stop reaches the server for this goal', posted && posted.id === 'g1', JSON.stringify(st.posts));
98
98
  st.goal = goalOf('done', { met: DRAFT.done });
99
- const s3 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Done, as Claude reports it/.test(v.pane) ? v : null; }) || await p.evaluate(look);
99
+ const s3 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Done, as PMOS reports it/.test(v.pane) ? v : null; }) || await p.evaluate(look);
100
100
  ok('G2 the open Goal tab follows the next change; the line goes and "Goal done" stays where it finished', /3 of 3 done points met/.test(s3.pane || '') && !s3.stop && !s3.line && /Goal done/.test(s3.divider || ''), JSON.stringify(s3));
101
101
  ok('F1 no page error and no sideways scroll', !errs.length && !s3.wide, errs.join(' | '));
102
102
  await ctx.close(); }
@@ -93,7 +93,7 @@ const look = () => {
93
93
  ok('P1 a goal at work: one line with the point it is on, "1 of 4 done" and Stop', /Open questions, each with an owner/.test(s0.line || '') && /1 of 4 done/.test(s0.line || '') && s0.stop && !s0.open, JSON.stringify(s0));
94
94
  ok('P1 the line replaces the run strip, the live card, the goal chip and the goal bar', !s0.strip && !s0.live && !s0.chip && !s0.peek, JSON.stringify(s0));
95
95
  ok('P1 the box has no @ and no / button, and a phone chat has no floating menu', !s0.at && !s0.slash && !s0.fab, JSON.stringify(s0));
96
- ok('P1 a message sent while it works says Claude reads it after this tool call, with × to take it back', /reads it after this tool call, in seconds/.test(s0.queued || '') && s0.qx, JSON.stringify(s0));
96
+ ok('P1 a message sent while it works says PMOS reads it after this tool call, with × to take it back', /reads it after this tool call, in seconds/.test(s0.queued || '') && s0.qx, JSON.stringify(s0));
97
97
  const s7 = await until(async () => { const v = await p.evaluate(look); return v.rec ? v : null; }) || await p.evaluate(look);
98
98
  ok('P7 a meeting records: the pill with its clock is in the chat\'s top bar, which shows the title only', /^\d+:\d\d/.test(s7.rec || '') && s7.sub === 'none', JSON.stringify(s7));
99
99
  if (shots) await p.screenshot({ path: `${shots}/line-390.png` });
@@ -117,7 +117,7 @@ const look = () => {
117
117
  { const st = { conv: { turn: 'agent', messages: BASE } };
118
118
  const { p, ctx, errs } = await open(390, st);
119
119
  const s0 = await until(async () => { const v = await p.evaluate(look); return v.line ? v : null; }) || await p.evaluate(look);
120
- ok('P3 a session with no step list: Claude\'s newest status line and the clock, never the raw call or an invented count (batch 25 item 14)', /SSO goes on the out-of-scope list; the date stays\.\s*\d+:\d\d/.test(s0.line || '') && !/Edit · planning/.test(s0.line || '') && !/ of \d+ done/.test(s0.line || ''), JSON.stringify(s0));
120
+ ok('P3 a session with no step list: PMOS\'s newest status line and the clock, never the raw call or an invented count (batch 25 item 14)', /SSO goes on the out-of-scope list; the date stays\.\s*\d+:\d\d/.test(s0.line || '') && !/Edit · planning/.test(s0.line || '') && !/ of \d+ done/.test(s0.line || ''), JSON.stringify(s0));
121
121
  st.conv = { turn: 'agent', messages: BASE, steps: [{ text: 'Read the funnel export', state: 'done' }, { text: 'Find the step that moved', state: 'now', call: 'Read · funnel.csv' }, { text: 'Write it up', state: 'next' }] };
122
122
  const s1 = await until(async () => { const v = await p.evaluate(look); return /Find the step/.test(v.line || '') ? v : null; }) || await p.evaluate(look);
123
123
  ok('P3 a session with its own steps: its step and "1 of 3 done"', /Find the step that moved/.test(s1.line || '') && /1 of 3 done/.test(s1.line || ''), JSON.stringify(s1));
@@ -134,13 +134,13 @@ const look = () => {
134
134
  { const st = { goal: goal('waiting'), conv: { turn: 'pm', messages: LONG.concat(BASE, [{ role: 'assistant', text: 'Is the draft ready for Dita?', at: ago(0.5) }]) } };
135
135
  const { p, ctx, errs } = await open(390, st);
136
136
  const s0 = await until(async () => { const v = await p.evaluate(look); return v.line ? v : null; }) || await p.evaluate(look);
137
- ok('P4 Claude needs the PM: the line is blue and says "Claude asks before it goes on", Stop stays', /\byou\b/.test(s0.cls) && /Claude asks before it goes on/.test(s0.line || '') && s0.stop && !/ of \d+ done/.test(s0.line || ''), JSON.stringify(s0));
137
+ ok('P4 PMOS needs the PM: the line is blue and says "PMOS asks before it goes on", Stop stays', /\byou\b/.test(s0.cls) && /PMOS asks before it goes on/.test(s0.line || '') && s0.stop && !/ of \d+ done/.test(s0.line || ''), JSON.stringify(s0));
138
138
  if (shots) await p.screenshot({ path: `${shots}/line-390-ask.png` });
139
139
  await p.click('#hmPl [data-pl="toggle"]'); await sleep(500);
140
140
  const s1 = await p.evaluate(look);
141
141
  ok('P4 a tap goes to the ask in the conversation, not to a panel', !s1.open && !s1.vw, JSON.stringify(s1));
142
142
  const fl = await p.evaluate(() => { const f = document.querySelector('#hmLog .hm-flash'); return f ? f.textContent : ''; });
143
- ok('P4b the tap is never silent: Claude\'s newest message, where the goal asks, pulses once (feedback batch 4, item 3)', /Is the draft ready for Dita\?/.test(fl), fl);
143
+ ok('P4b the tap is never silent: PMOS\'s newest message, where the goal asks, pulses once (feedback batch 4, item 3)', /Is the draft ready for Dita\?/.test(fl), fl);
144
144
  ok('F1 (ask) no page error', !errs.length, errs.join(' | '));
145
145
  await ctx.close(); }
146
146
 
@@ -148,10 +148,10 @@ const look = () => {
148
148
  { const st = { goal: goal('done', { met: DRAFT.done, at: ago(0.2) }), conv: { turn: 'pm', messages: BASE.concat([{ role: 'assistant', text: 'The draft is ready for Dita; 2 open questions have owners.', at: ago(0.5) }]) } };
149
149
  const { p, ctx, errs } = await open(1280, st);
150
150
  const s0 = await until(async () => { const v = await p.evaluate(look); return v.divider ? v : null; }) || await p.evaluate(look);
151
- ok('P5 a goal that is done: no line; "Goal done" sits over Claude\'s result', !s0.line && /Goal done/.test(s0.divider || '') && /The draft is ready for Dita/.test(s0.dividerNext || ''), JSON.stringify(s0));
151
+ ok('P5 a goal that is done: no line; "Goal done" sits over PMOS\'s result', !s0.line && /Goal done/.test(s0.divider || '') && /The draft is ready for Dita/.test(s0.dividerNext || ''), JSON.stringify(s0));
152
152
  await p.click('#hmLog .pl-dv [data-goal-open]');
153
153
  const s1 = await until(async () => { const v = await p.evaluate(look); return v.vw ? v : null; }) || await p.evaluate(look);
154
- ok('P5 a tap opens the points, with the note that Claude checked them itself', /4 of 4 done points met/.test(s1.vw || '') && /Claude checked its own points/.test(s1.vw || ''), JSON.stringify(s1));
154
+ ok('P5 a tap opens the points, with the note that PMOS checked them itself', /4 of 4 done points met/.test(s1.vw || '') && /PMOS checked its own points/.test(s1.vw || ''), JSON.stringify(s1));
155
155
  st.goal = goal('stopped', { reason: 'deadline', at: ago(0.2) });
156
156
  const s2 = await until(async () => { const v = await p.evaluate(look); return /Goal stopped/.test(v.divider || '') ? v : null; }) || await p.evaluate(look);
157
157
  ok('P6 a goal that stopped: the amber divider says why, and the box says how to go on', /Goal stopped: the deadline passed/.test(s2.divider || '') && s2.ph === 'Reply to go on, or /goal for a new goal' && !s2.line, JSON.stringify(s2));
@@ -92,7 +92,7 @@ const notes = (key = KEY) => lib.listNotes({ runtimeDir: T.STATE_DIR, key }).not
92
92
  await page.click('#ntM [data-ntgo]:nth-child(2)');
93
93
  ok('N4 picking a note shows it', /call Dana/.test(await page.textContent('#ntEd')) && (await page.textContent('#ntSw')).trim() === 'call Dana');
94
94
  /* N5 */
95
- ok('N5 New note, Add selection and Share with Claude are icons with a name and a tooltip, no words', await page.evaluate(() => ['new', 'sel', 'share'].every((k) => { const b = document.querySelector(`[data-nt="${k}"]`); return b && !b.textContent.trim() && b.querySelector('svg') && b.getAttribute('aria-label') && b.title; })));
95
+ ok('N5 New note, Add selection and Share with PMOS are icons with a name and a tooltip, no words', await page.evaluate(() => ['new', 'sel', 'share'].every((k) => { const b = document.querySelector(`[data-nt="${k}"]`); return b && !b.textContent.trim() && b.querySelector('svg') && b.getAttribute('aria-label') && b.title; })));
96
96
  /* N6 */
97
97
  await page.evaluate(() => { const p = [...document.querySelectorAll('#ntEd p')].find((x) => /ask about/.test(x.textContent)); const r = document.createRange(); r.selectNodeContents(p); getSelection().removeAllRanges(); getSelection().addRange(r); });
98
98
  await page.click('[data-nt="sel"]');
@@ -102,14 +102,14 @@ const notes = (key = KEY) => lib.listNotes({ runtimeDir: T.STATE_DIR, key }).not
102
102
  await page.fill('#hmIn', 'Plan the deck from my note');
103
103
  await page.click('#ntSw'); await page.click('#ntM [data-ntgo]:nth-child(1)');
104
104
  await page.click('[data-nt="share"]');
105
- ok('N7 Share with Claude puts the note on the message as a chip', !!(await until(async () => page.evaluate(() => { const c = document.querySelector('#hmFiles .hm-att'); return c && /Q4 review prep/.test(c.textContent) && /Note/.test(c.textContent); }))));
105
+ ok('N7 Share with PMOS puts the note on the message as a chip', !!(await until(async () => page.evaluate(() => { const c = document.querySelector('#hmFiles .hm-att'); return c && /Q4 review prep/.test(c.textContent) && /Note/.test(c.textContent); }))));
106
106
  await shot(page, 'shared-1280-light');
107
107
  await page.click('#hmForm [type=submit]');
108
108
  const ask = await until(async () => asks.find((a) => a.path.endsWith('/ask')));
109
109
  const q4 = notes().find((x) => x.title === 'Q4 review prep');
110
110
  ok('N7 send names the note as notes/<id>.md', !!ask && ask.body.text === 'Plan the deck from my note' && JSON.stringify(ask.body.files) === JSON.stringify(['notes/' + q4.id + '.md']), JSON.stringify(ask && ask.body));
111
111
  const paths = lib.pathsOf({ runtimeDir: T.STATE_DIR, key: KEY, names: ask.body.files });
112
- ok('N7 the name resolves to the note file Claude reads', paths.ok && paths.paths[0] === q4.path);
112
+ ok('N7 the name resolves to the note file PMOS reads', paths.ok && paths.paths[0] === q4.path);
113
113
  ok('N7 the note stays after the send', notes().length === 2);
114
114
  /* N8 */
115
115
  st.messages = [{ role: 'user', text: lib.withFiles('Plan the deck from my note', paths.paths), at: '2026-10-21T08:00:00Z' }]; st.session = 's-notes';
@@ -134,7 +134,7 @@ const notes = (key = KEY) => lib.listNotes({ runtimeDir: T.STATE_DIR, key }).not
134
134
  await until(async () => page.evaluate(() => !document.getAnimations().some((a) => a.playState === 'running'))); // the popup's entrance scales it: measure once it has settled
135
135
  { const ic = await page.evaluate(() => [...document.querySelectorAll('.ntic')].map((b) => (b.dataset.nt || b.id || b.className) + ':' + Math.round(b.getBoundingClientRect().height))); ok(`N10 ${scheme}: the icon buttons are 44px targets`, ic.length > 0 && ic.every((x) => +x.split(':').pop() >= 44), ic.join()); }
136
136
  await page.click('[data-nt="share"]');
137
- ok(`N10 ${scheme}: Share with Claude goes back to the conversation with the chip`, !!(await until(async () => (await page.isVisible('#hmFiles .hm-att')) && (await page.$('#czViewer:not([hidden])')) === null)));
137
+ ok(`N10 ${scheme}: Share with PMOS goes back to the conversation with the chip`, !!(await until(async () => (await page.isVisible('#hmFiles .hm-att')) && (await page.$('#czViewer:not([hidden])')) === null)));
138
138
  ok(`N10 ${scheme}: no page errors`, errors.length === 0, errors.join(' | '));
139
139
  await ctx.close();
140
140
  }