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
@@ -155,7 +155,7 @@ const recentOf = (m) => ({ ...m, recent: [...m.toread, ...m.answered] });
155
155
  // wait for the fold to land too: the list draws before the split, and a slow runner read it in between (CI, batch 20)
156
156
  const L1 = (await until(() => listOf(p).then((l) => (l && l.move.length && l.split ? l : null)))) || (await listOf(p));
157
157
  ok('M3 the row opens the Mentions Viewer, wide on a desktop, the list and the conversation side by side', !!L1 && L1.split, JSON.stringify(L1 && L1.secs));
158
- ok('M3 Adler opens on who waits and what Claude drafted, plainly; no button on a light day', !!L1 && L1.face && L1.open === 'Four people wait on you. I drafted one reply; Maya and Dion’s needs you.' && !L1.go.length, JSON.stringify(L1 && [L1.open, L1.go]));
158
+ ok('M3 Adler opens on who waits and what PMOS drafted, plainly; no button on a light day', !!L1 && L1.face && L1.open === 'Four people wait on you. I drafted one reply; Maya and Dion’s needs you.' && !L1.go.length, JSON.stringify(L1 && [L1.open, L1.go]));
159
159
  ok('M3 Your move open with 3; To read closed with 3; Answered this week closed with 2 and a stack of faces', !!L1 && JSON.stringify(L1.secs) === JSON.stringify([['Your move', '3', 'true'], ['To read', '3', 'false'], ['Answered this week', '2', 'false']]) && L1.stack === 2, JSON.stringify(L1 && [L1.secs, L1.stack]));
160
160
  const mv = L1 ? L1.move : [];
161
161
  ok('M3 one row per conversation, oldest first: first names, "Maya and Dion", the place, the message count', mv.map((x) => x.nm + mx(x)).join(';') === 'Samuel· #tech-team-cem3;Maya and Dion· #idpf-launch5;Jason· DM', JSON.stringify(mv));
@@ -170,14 +170,14 @@ const recentOf = (m) => ({ ...m, recent: [...m.toread, ...m.answered] });
170
170
  const C1 = await until(() => convOf(p).then((c) => (c && c.ak ? c : null)));
171
171
  ok('M4 the oldest conversation shows beside the list: full name, place, messages since when, ↗', !!C1 && /^Samuel Chandra#tech-team-cem · 3 messages since (Mon|Tue|Wed|Thu|Fri|Sat|Sun)$/.test(C1.head) && C1.out, JSON.stringify(C1 && C1.head));
172
172
  ok('M4 the ask first: "Asks you · 2 days", the ask, the drafted reply', !!C1 && C1.ak === 'Asks you · 2 days' && C1.aq === 'Which build goes to UAT, 2.4.1 or 2.4.2?' && C1.draft === '2.4.2, please. It has the login fix the ST team asked for.', JSON.stringify(C1));
173
- ok('M4 four one-tap acts, then ✎ and send', !!C1 && C1.four.join('|') === 'Mark answered|Remind me at 09:00|Make it a task|Not an ask' && C1.right.join('|') === 'Change it with Claude|Copy it and open Slack. PMOS never posts.', JSON.stringify(C1 && [C1.four, C1.right]));
173
+ ok('M4 four one-tap acts, then ✎ and send', !!C1 && C1.four.join('|') === 'Mark answered|Remind me at 09:00|Make it a task|Not an ask' && C1.right.join('|') === 'Change it with PMOS|Copy it and open Slack. PMOS never posts.', JSON.stringify(C1 && [C1.four, C1.right]));
174
174
  ok('M4 Where it stands: what is settled, then what is open', !!C1 && C1.stands.join('|') === 'ok:UAT keyword agreed: PSLE Companion 2027.|ok:Release notes reviewed.|open:The tag waits on your answer above.', JSON.stringify(C1 && C1.stands));
175
- ok('M4 Claude offers to watch the dated promise, ✓ ×', !!C1 && C1.watch.join('|') === 'I’ll watch for the tag and nudge Samuel at 09:00 if it’s still missing.|No, don’t watch|Yes, watch for it', JSON.stringify(C1 && C1.watch));
175
+ ok('M4 PMOS offers to watch the dated promise, ✓ ×', !!C1 && C1.watch.join('|') === 'I’ll watch for the tag and nudge Samuel at 09:00 if it’s still missing.|No, don’t watch|Yes, watch for it', JSON.stringify(C1 && C1.watch));
176
176
  ok('M4 the messages last, open on the desktop, by day, the PM\'s on the right', !!C1 && C1.msgsOpen === 'true' && C1.msgs.join('|') === 'The UAT keyword is PSLE Companion 2027.|me:Confirmed, go ahead.|Which one for UAT?' && C1.days.length >= 1, JSON.stringify(C1 && [C1.msgs, C1.days]));
177
177
  await shot(p, 'mentions-1440');
178
178
  await p.click('#czViewer [data-mn-row="aaaaaaaaaaa2"] [data-mn="open"]');
179
179
  const C2 = await until(() => convOf(p).then((c) => (c && /^Maya Tan and Dion Lee/.test(c.head) ? c : null)));
180
- ok('M4 a press on a row shows that conversation beside the list; no draft: ✎ "Write it with Claude" only', !!C2 && C2.right.join('|') === 'Write it with Claude' && !C2.stands.length && !C2.watch.length, JSON.stringify(C2));
180
+ ok('M4 a press on a row shows that conversation beside the list; no draft: ✎ "Write it with PMOS" only', !!C2 && C2.right.join('|') === 'Write it with PMOS' && !C2.stands.length && !C2.watch.length, JSON.stringify(C2));
181
181
  await p.click('#czViewer [data-mn-row="aaaaaaaaaaa1"] [data-mn="open"]');
182
182
  await until(() => convOf(p).then((c) => (c && /^Samuel/.test(c.head) ? c : null)));
183
183
 
@@ -213,7 +213,7 @@ const recentOf = (m) => ({ ...m, recent: [...m.toread, ...m.answered] });
213
213
  ok('M6 the pencil opens the chat "Reply to Samuel" and the Viewer stays beside it', !!ch && ch.vw, JSON.stringify(ch));
214
214
  A.men.cur = JSON.parse(JSON.stringify(A.men.cur)); A.men.cur.waiting[0].draft = '2.4.2, please. It has the login fix.';
215
215
  const nd = await until(() => p.evaluate(() => (document.querySelector('#czViewer [data-mn-conv] [data-mn-draft]') || {}).textContent === '2.4.2, please. It has the login fix.'), 14000, 300);
216
- ok('M6 a reply Claude saves shows while the conversation is open', !!nd);
216
+ ok('M6 a reply PMOS saves shows while the conversation is open', !!nd);
217
217
 
218
218
  /* T: To read */
219
219
  await p.click('#czViewer .czs-sec[data-czs-id="toread"] [data-czs-fold]');
@@ -354,8 +354,8 @@ const recentOf = (m) => ({ ...m, recent: [...m.toread, ...m.answered] });
354
354
  const pl = await until(() => listOf(P.page).then((l) => (l && l.move.length ? l : null)));
355
355
  ok('F on a phone the list is one column, no conversation beside it', !!pl && !pl.split, JSON.stringify(pl && pl.split));
356
356
  const pm = pl ? pl.move : [];
357
- ok('F a calm day on a phone: a drafted reply shows on its row with ✎ and send only', !!pm[0] && /I drafted your reply2\.4\.2, please/.test(pm[0].extra) && pm[0].btns.join('|') === 'Change it with Claude|Copy it and open Slack. PMOS never posts.', JSON.stringify(pm[0]));
358
- ok('F no draft: why, in one line, and ✎ "Write it with Claude" is the only button', !!pm[1] && pm[1].extra === 'I can’t draft this oneThe cap isn’t in the PRD or the last review.' && pm[1].btns.join('|') === 'Write it with Claude', JSON.stringify(pm[1]));
357
+ ok('F a calm day on a phone: a drafted reply shows on its row with ✎ and send only', !!pm[0] && /I drafted your reply2\.4\.2, please/.test(pm[0].extra) && pm[0].btns.join('|') === 'Change it with PMOS|Copy it and open Slack. PMOS never posts.', JSON.stringify(pm[0]));
358
+ ok('F no draft: why, in one line, and ✎ "Write it with PMOS" is the only button', !!pm[1] && pm[1].extra === 'I can’t draft this oneThe cap isn’t in the PRD or the last review.' && pm[1].btns.join('|') === 'Write it with PMOS', JSON.stringify(pm[1]));
359
359
  ok('F after send: "Sent from Slack? I’ll see it at the next read."', !!pm[2] && pm[2].extra === 'Sent from Slack? I’ll see it at the next read.' && !pm[2].btns.length, JSON.stringify(pm[2]));
360
360
  await P.page.click('#czViewer [data-mn-row="aaaaaaaaaaa1"] [data-mn="open"]');
361
361
  const pc = await until(() => vw(P.page).then((v) => (v && v.title === 'Samuel Chandra' ? v : null)));
@@ -166,7 +166,7 @@ const FINDING = { id: 'rf-0123456789', name: 'Partner numbers to Lee', why: 'You
166
166
 
167
167
  /* ── P: the ✦ strip proposes a report ── */
168
168
  const pageTo = async () => { for (let i = 0; i < 6; i++) { const has = await p.evaluate(() => !!document.querySelector('#insAct [data-rp="see"]')); if (has) return true; const dots = await p.$$('#insPg button:not([hidden])'); if (!dots.length) return false; await dots[dots.length - 1].click(); await sleep(120); } return false; };
169
- ok('P the strip holds a report Claude proposes', await until(pageTo, 4000));
169
+ ok('P the strip holds a report PMOS proposes', await until(pageTo, 4000));
170
170
  const pr = await p.evaluate(() => ({ text: document.querySelector('#brief').textContent, acts: [...document.querySelectorAll('#insAct [data-rp]')].map((b) => ({ k: b.dataset.rp, label: b.getAttribute('aria-label'), text: b.textContent.trim(), solid: b.classList.contains('solid') })), ask: document.querySelector('#askWhy').hidden, askShown: getComputedStyle(document.querySelector('#askWhy')).display }));
171
171
  ok('P it says the pattern in plain words', /^You send Lee these numbers every Monday\. Shall I make it a report that drafts itself\?$/.test(pr.text), pr.text);
172
172
  ok('P See the draft, Not now and a solid ✓ Set it up, icon-only, and no Ask why', pr.acts.map((a) => a.label).join() === 'See the draft,Not now,Set it up for Lee' && pr.acts.every((a) => !a.text) && pr.acts[2].solid && pr.ask && pr.askShown === 'none', JSON.stringify(pr));
@@ -121,7 +121,7 @@ const WEEKLY = { view: 'view', weeks: 3, day: 'Mon', opens: 4 };
121
121
  await openEd();
122
122
  const e0 = await until(() => p.evaluate(() => { const r = document.querySelector('#czViewer [data-gc-ed]'); return r ? { f: [...r.querySelectorAll('input')].map((x) => x.name + '=' + x.value), acts: [...r.querySelectorAll('.gc-foot a, .gc-foot button')].map((b) => b.getAttribute('aria-label') + (b.textContent.trim() ? '!' : '')), focus: document.activeElement && document.activeElement.name } : null; }), 3000);
123
123
  ok('E ✎ turns the panel into fields: name, target, source; ask in Home, ×, ✓, all icon-only; the name has the focus', !!e0 && e0.f.join('|') === 'name=Weekly signed-in shoppers|target=45000|source=Amplitude'
124
- && e0.acts.join() === 'Ask Claude in Home to change how it is counted,Cancel the edit,Save' && e0.focus === 'name', JSON.stringify(e0));
124
+ && e0.acts.join() === 'Ask PMOS in Home to change how it is counted,Cancel the edit,Save' && e0.focus === 'name', JSON.stringify(e0));
125
125
  await shot(p, 'gap2-draft-edit', '#czViewer');
126
126
  await p.click('#czViewer [data-gc="edit-x"]');
127
127
  ok('E × puts the check back', await until(() => p.evaluate(() => !document.querySelector('#czViewer [data-gc-ed]') && !!document.querySelector('#czViewer [data-gc="edit"]')), 2000));
@@ -149,7 +149,7 @@ const WEEKLY = { view: 'view', weeks: 3, day: 'Mon', opens: 4 };
149
149
  return { was, f, acts: [...host.querySelectorAll('.md-ft .md-ib')].map((b) => b.getAttribute('aria-label')) };
150
150
  }, MODEL.board.ws);
151
151
  ok('C the program card\'s ✎ is a press now, and opens each draft\'s fields in place with ask, ×, ✓', !!c0 && c0.was === 'BUTTON' && c0.f.join() === 'md-ns:name,md-ns:target,md-ns:source,md-g:name,md-g:target,md-g:source'
152
- && c0.acts.join() === 'Ask Claude in Home to change something else,Cancel the edit,Save the edit', JSON.stringify(c0));
152
+ && c0.acts.join() === 'Ask PMOS in Home to change something else,Cancel the edit,Save the edit', JSON.stringify(c0));
153
153
  await p.fill('#mdHost [data-md-row="md-g"][data-md-f="target"]', '1.5');
154
154
  await p.click('#mdHost [data-md="save"]');
155
155
  const ce = await until(() => A.posts.filter((x) => x.path === '/api/metric-drafts/edit' && x.body.scope === 'program'), 3000);
@@ -13,7 +13,7 @@
13
13
  * Pure: the client imports the same table through GET /api/home-desk (roles), so both sides say the same name. */
14
14
 
15
15
  const ROLES = Object.freeze({
16
- claude: { key: 'claude', name: 'Claude', initial: 'C' },
16
+ claude: { key: 'claude', name: 'PMOS', initial: 'P' },
17
17
  spec: { key: 'spec', name: 'Spec writer', initial: 'Sp' },
18
18
  eval: { key: 'eval', name: 'Evaluator', initial: 'Ev' },
19
19
  strategy: { key: 'strategy', name: 'Strategist', initial: 'St' },
@@ -3,6 +3,9 @@
3
3
  *
4
4
  * pmos autonomy status [--json] [--root <dir>] the changes applied by agents in the last 14 days, and the jobs back to propose
5
5
  * pmos autonomy restore <job> [--product <ws>] end a job's demotion early (PM or agent, D98)
6
+ * pmos autonomy check <ref> --verdict PASS|FAIL --why "<one line>" the verifier's grade of one applied change (batch 29 item 9).
7
+ * Only inside the check run the server started for that change: PMOS_CHECK_REF and PMOS_CHECK_DIR pin the change and its
8
+ * ledger (lib/verify-runs.js). A FAIL sends the job back to asking, like an Undo.
6
9
  *
7
10
  * Undo a change on its page, or with `pmos driver undo <proposal>` for a Driver change. Exit codes: 0 done, 1 refused, 2 usage. */
8
11
  const path = require('path');
@@ -11,11 +14,12 @@ const A = require('./autonomy.js');
11
14
  const D = require('./driver.js');
12
15
  const actorLib = require('./actor.js');
13
16
 
14
- const COMMANDS = { autonomy: ['status', 'restore'] };
17
+ const COMMANDS = { autonomy: ['status', 'restore', 'check'] };
15
18
  const USAGE = [
16
- 'usage: pmos autonomy status|restore — what agents do by themselves (class A and B, with Undo)',
19
+ 'usage: pmos autonomy status|restore|check — what agents do by themselves (class A and B, with Undo)',
17
20
  ' pmos autonomy status [--json] the changes agents applied in the last 14 days, and the jobs back to propose',
18
21
  ' pmos autonomy restore <job> [--product <ws>] end a job\'s demotion early',
22
+ ' pmos autonomy check <ref> --verdict PASS|FAIL --why "<one line>" inside a check run only: the grade of the change it checks',
19
23
  'Class C (a message to a person, a Jira move others see, a merge into a product repository, a delete, spend) always waits for you.',
20
24
  ];
21
25
  const flag = (args, k) => { const i = args.indexOf('--' + k); return i >= 0 ? (args[i + 1] === undefined || args[i + 1].startsWith('--') ? true : args[i + 1]) : undefined; };
@@ -26,6 +30,16 @@ function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), env = pro
26
30
  const verb = args[0];
27
31
  if (!verb || ['help', '--help', '-h'].includes(verb)) { for (const l of USAGE) say(l); return verb ? 0 : 1; }
28
32
  if (!COMMANDS.autonomy.includes(verb)) { say(`unknown autonomy command "${verb}" — one of ${COMMANDS.autonomy.join(', ')}`); return 2; }
33
+ if (verb === 'check') {
34
+ const ref = args[1] && !args[1].startsWith('--') ? args[1] : null;
35
+ const verdict = flag(args, 'verdict'), why = flag(args, 'why');
36
+ if (!ref || typeof verdict !== 'string' || typeof why !== 'string') { say('usage: pmos autonomy check <ref> --verdict PASS|FAIL --why "<one line>"'); return 2; }
37
+ if (!env.PMOS_CHECK_DIR || env.PMOS_CHECK_REF !== ref) { say('✗ a check is recorded only inside the check run PMOS started for that change'); return 1; }
38
+ const r = A.recordCheck(env.PMOS_CHECK_DIR, { ref, verdict, why }, { now, by: 'agent:verifier' });
39
+ if (!r.ok) { say('✗ ' + r.error); return 1; }
40
+ say(`✓ ${ref}: ${verdict.toUpperCase()}` + (r.demoted ? ` — the job asks first until ${r.demoted.until.slice(0, 10)}` : ''));
41
+ return 0;
42
+ }
29
43
  const root = typeof flag(args, 'root') === 'string' ? path.resolve(cwd, flag(args, 'root')) : repoRoot(cwd);
30
44
  const dir = D.stateDirOf(root);
31
45
  if (!dir) { say('✗ this repository has no PMOS state folder (pmos/state, state or .pmos)'); return 1; }
@@ -10,12 +10,15 @@
10
10
  * A change with no Undo writer is never applied by itself, whatever its class ("no Undo, no auto"): it waits like C.
11
11
  *
12
12
  * THE LEDGER: <state folder>/autonomy.jsonl, append-only, THIS FILE IS ITS ONE WRITER. One line per event { v: 1, at, ev, ... }:
13
- * applied { job, product, ref, title, cls, ini?, why? } an agent applied a change by itself (ref: the proposal id or the ✦ batch;
14
- * ini: the initiative it changed; why: the evidence it acted on, one line)
13
+ * applied { job, product, ref, title, cls, ini?, why?, run?, way, kept, set? } an agent applied a change by itself (ref: the proposal
14
+ * id or the ✦ batch; ini: the initiative it changed; why: the evidence it acted on, one line;
15
+ * run: the agent run that made it; way/kept/set: how it acted then, quiet or show, the
16
+ * changes of its job kept before it, and whether the PM set that way)
15
17
  * setback { job, product, ref?, kind } kind: undo (the PM pressed Undo) · revert (a revert of the change) ·
16
18
  * verifier-fail (the T4 verifier failed it; counts like an Undo)
17
19
  * demote { job, product, until, why } the job falls back to propose for this product until `until`
18
20
  * seen { job, product, until } Home said so once; it does not say it again for this demotion
21
+ * checked { job, product, ref, verdict, why, by? } the verifier graded one applied change (PASS | FAIL; a FAIL also writes a setback)
19
22
  * A job is `driver:<what>` for the Initiative Driver and `propose:<group>` for a ✦ group. A product is the workspace id.
20
23
  *
21
24
  * AUTOMATIC DEMOTION (a safety net, not a gate). A job on a product falls back to propose for 7 days when:
@@ -27,7 +30,8 @@
27
30
  * CLASSES · DRIVER_CLASS · PROPOSAL_CLASS · DEMOTE_DAYS · UNDO_DAYS · RATE_LIMIT · RATE_MIN
28
31
  * classOfDriver(what) · classOfProposal(p) → 'A' | 'B' | 'C'
29
32
  * file(stateDir) · read(stateDir) → lines · fold(lines, { now }) → state the ledger
30
- * recordApplied(stateDir, { job, product, ref, title, cls }, { now })
33
+ * recordApplied(stateDir, { job, product, ref, title, cls, ini?, why?, run? }, { now, settingsDir }) writes the way the job acted with
34
+ * (wayAt: quiet or show, the kept count, the PM's setting), so the line can say why it was quiet
31
35
  * recordSetback(stateDir, { job, product, ref?, kind }, { now }) → { demoted: null | { until, why } } the hook T4 calls on a FAIL
32
36
  * decide({ stateDir, job, product, cls, mode, undoable, now, env, settingsDir }) → { apply: bool, why } killed() first
33
37
  * autoFor(cls, { stateDir?, job?, product?, undoable? }) → bool for callers with no mode: does `cls` apply by itself now
@@ -59,7 +63,7 @@ const RATE_DAYS = 7;
59
63
  const RATE_LIMIT = 0.3;
60
64
  const RATE_MIN = 4;
61
65
  const KINDS = Object.freeze(['undo', 'revert', 'verifier-fail']);
62
- const EVENTS = Object.freeze(['applied', 'setback', 'demote', 'seen', 'restore']);
66
+ const EVENTS = Object.freeze(['applied', 'setback', 'demote', 'seen', 'restore', 'checked']);
63
67
  const JOB_RE = /^(driver|propose|ai|goal):[a-z0-9][a-z0-9-]{0,40}$/;
64
68
  const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
65
69
  const WAYS = Object.freeze(['quiet', 'show', 'ask']);
@@ -92,7 +96,7 @@ const KIND_LIST = Object.freeze([
92
96
  k('dates', 'Dates moved by evidence', ['propose:dates']),
93
97
  k('status', 'Closing tasks Jira marked Done', ['propose:status']),
94
98
  k('description', 'Descriptions and links', ['propose:description', 'propose:links']),
95
- k('found', 'What Claude found elsewhere', ['propose:found', 'propose:scanned', 'propose:improved', 'propose:prototyped']),
99
+ k('found', 'What PMOS found elsewhere', ['propose:found', 'propose:scanned', 'propose:improved', 'propose:prototyped']),
96
100
  k('grill', 'Fixes from a check', ['propose:grill']),
97
101
  ]);
98
102
  const KIND_OF_JOB = new Map(KIND_LIST.flatMap((x) => x.jobs.map((j) => [j, x.key])));
@@ -155,13 +159,17 @@ function fold(lines) {
155
159
  if (!isObj(l) || typeof l.job !== 'string') continue;
156
160
  const j = get(l.job, l.product);
157
161
  if (l.ev === 'applied') {
158
- const a = { ref: l.ref || null, title: l.title || '', cls: l.cls || null, job: l.job, product: l.product || null, ini: l.ini || null, why: l.why || '', at: l.at, undone: false, undoneAt: null };
162
+ const a = { ref: l.ref || null, title: l.title || '', cls: l.cls || null, job: l.job, product: l.product || null, ini: l.ini || null, why: l.why || '', at: l.at, undone: false, undoneAt: null,
163
+ run: l.run || null, rec: WAYS.includes(l.way) && Number.isInteger(l.kept) ? { way: l.way, kept: l.kept, set: l.set === true } : null, checked: null };
159
164
  j.applied.push(a);
160
165
  if (a.ref) applied.set(a.ref, a);
161
166
  } else if (l.ev === 'setback') {
162
167
  j.setbacks.push({ kind: l.kind, ref: l.ref || null, at: l.at });
163
168
  const a = l.ref ? applied.get(l.ref) : null;
164
169
  if (a && (l.kind === 'undo' || l.kind === 'verifier-fail' || l.kind === 'revert')) { a.undone = true; a.undoneAt = l.at; }
170
+ } else if (l.ev === 'checked') {
171
+ const a = l.ref ? applied.get(l.ref) : null;
172
+ if (a) a.checked = { verdict: l.verdict, why: l.why || '', at: l.at };
165
173
  } else if (l.ev === 'demote') j.demote = { until: l.until, why: l.why || '', at: l.at };
166
174
  else if (l.ev === 'seen') j.seen = l.until || null;
167
175
  else if (l.ev === 'restore') j.demote = null;
@@ -191,10 +199,22 @@ function trip(j, now) {
191
199
  return null;
192
200
  }
193
201
 
194
- function recordApplied(stateDir, { job, product, ref, title, cls, ini, why }, { now } = {}) {
202
+ /** How the job acts on this product at this moment: the PM's way for its kind (Ask first aside), else the automatic one from the changes
203
+ * of the job nobody undid. → { way: 'quiet' | 'show', kept, set } (set: the PM chose the way). Read when a change is applied, so the
204
+ * change keeps the reason it was made with (batch 29 item 6: a later setting or Undo does not rewrite why an earlier change was quiet). */
205
+ function wayAt(stateDir, job, product, { settingsDir = null } = {}) {
206
+ const j = fold(read(stateDir)).jobs.get(keyOf(job, product));
207
+ const kept = j ? j.applied.filter((a) => !a.undone).length : 0;
208
+ const own = waysSet(settingsDir)[kindOf(job)];
209
+ return own && own !== 'ask' ? { way: own, kept, set: true } : { way: autoWay({ kept }), kept, set: false };
210
+ }
211
+
212
+ function recordApplied(stateDir, { job, product, ref, title, cls, ini, why, run }, { now, settingsDir = null } = {}) {
195
213
  if (!JOB_RE.test(String(job || ''))) return null;
214
+ const w = wayAt(stateDir, job, product, { settingsDir });
196
215
  return append(stateDir, { ev: 'applied', job, product: product || null, ref: ref ? one(ref, 120) : null, title: one(title, 200), cls: CLASSES.includes(cls) ? cls : null,
197
- ...(ini ? { ini: one(ini, 80) } : {}), ...(why ? { why: one(why, 200) } : {}) }, { now });
216
+ ...(ini ? { ini: one(ini, 80) } : {}), ...(why ? { why: one(why, 200) } : {}), ...(run ? { run: one(run, 80) } : {}),
217
+ way: w.way, kept: w.kept, ...(w.set ? { set: true } : {}) }, { now });
198
218
  }
199
219
 
200
220
  /** THE HOOK for an Undo, a revert or a verifier FAIL. Writes the setback and, when it trips, the demotion. */
@@ -278,8 +298,10 @@ function done(stateDir, { now, days = UNDO_DAYS, settingsDir = null } = {}) {
278
298
  const own = set[kindOf(j.job)] || null;
279
299
  for (const a of j.applied) {
280
300
  if (!a.undone && Date.parse(a.at) >= since) {
281
- const way = own && own !== 'ask' ? own : autoWay({ kept });
282
- out.push({ ...a, kept, way, reason: reasonOf({ cls: a.cls, why: a.why, kept, way: own }) });
301
+ const { rec, ...rest } = a;
302
+ // a change applied since batch 29 carries the way it was made with; an older line is read with today's way, as before
303
+ if (rec) out.push({ ...rest, kept: rec.kept, way: rec.way, reason: reasonOf({ cls: a.cls, why: a.why, kept: rec.kept, way: rec.set ? rec.way : null }) });
304
+ else out.push({ ...rest, kept, way: own && own !== 'ask' ? own : autoWay({ kept }), reason: reasonOf({ cls: a.cls, why: a.why, kept, way: own }) });
283
305
  }
284
306
  if (!a.undone) kept++;
285
307
  }
@@ -311,6 +333,57 @@ function kindsOf(dirs, { now, settingsDir = null } = {}) {
311
333
  }).filter((x) => x.made || x.set).sort((p, q) => q.made - p.made);
312
334
  }
313
335
 
336
+ /* ── batch 29 item 9: a verifier FAIL or a revert sends the job back to asking (D106) ──
337
+ * Jobs that change records open no pull request, so the merged-run verifier never sees them. Two routes reach recordSetback:
338
+ * the applied-change check the verifier job grades one applied change (toCheck) in a read-only run, whose one write is
339
+ * `pmos autonomy check <ref> --verdict PASS|FAIL` (recordCheck). A FAIL is a `verifier-fail` setback.
340
+ * a PR-backed run an applied line that names its run: a verifier FAIL on that run (evals.jsonl), or a revert of its merge
341
+ * (scripts/run-corrections.js), is a setback of every change the run applied (fromRuns). */
342
+ const VERDICTS = Object.freeze(['PASS', 'FAIL']);
343
+ const CHECK_MIN_AGE = 3600000; // a change settles for an hour before it is checked, so an Undo the PM presses at once is not graded
344
+
345
+ /** The next applied change the check should grade: class B (a judgment; class A is upkeep with one right answer), not undone, not
346
+ * checked, older than an hour and still inside its Undo window; oldest first. skip: refs tried already. → applied entry | null */
347
+ function toCheck(stateDir, { now, skip = [] } = {}) {
348
+ const t = now == null ? Date.now() : now;
349
+ const out = [];
350
+ for (const a of fold(read(stateDir)).applied.values()) {
351
+ const age = t - Date.parse(a.at);
352
+ if (a.cls !== 'B' || a.undone || a.checked || !a.ref || skip.includes(a.ref) || !(age >= CHECK_MIN_AGE) || age > UNDO_DAYS * DAY) continue;
353
+ out.push(a);
354
+ }
355
+ out.sort((x, y) => Date.parse(x.at) - Date.parse(y.at));
356
+ if (!out.length) return null;
357
+ const { rec, ...a } = out[0];
358
+ return a;
359
+ }
360
+ /** Record the check of one applied change. A FAIL is a verifier-fail setback of its job (it counts like an Undo). → { ok, demoted } */
361
+ function recordCheck(stateDir, { ref, verdict, why = '' }, { now, by = null } = {}) {
362
+ const v = String(verdict || '').toUpperCase();
363
+ if (!VERDICTS.includes(v)) return { ok: false, error: 'the verdict is PASS or FAIL' };
364
+ if (!one(why, 300)) return { ok: false, error: 'say why in one line (--why "…")' };
365
+ const a = fold(read(stateDir)).applied.get(ref);
366
+ if (!a) return { ok: false, error: 'no change was applied by an agent under that id' };
367
+ if (a.checked) return { ok: false, error: 'that change is checked already' };
368
+ append(stateDir, { ev: 'checked', job: a.job, product: a.product, ref: a.ref, verdict: v, why: one(why, 300), ...(by ? { by } : {}) }, { now });
369
+ if (v === 'PASS' || a.undone) return { ok: true, demoted: null };
370
+ return { ok: true, demoted: recordSetback(stateDir, { job: a.job, product: a.product, ref: a.ref, kind: 'verifier-fail' }, { now }).demoted };
371
+ }
372
+ /** PR-backed runs: failed and reverted are run ids. Every applied change of such a run that is not undone yet becomes a setback, once.
373
+ * → [{ job, product, ref, kind, demoted }] */
374
+ function fromRuns(stateDir, { failed = [], reverted = [] } = {}, { now } = {}) {
375
+ const f = new Set(failed), r = new Set(reverted), out = [];
376
+ if (!f.size && !r.size) return out;
377
+ for (const a of fold(read(stateDir)).applied.values()) {
378
+ if (!a.run || a.undone || !a.ref) continue;
379
+ const kind = r.has(a.run) ? 'revert' : f.has(a.run) ? 'verifier-fail' : null;
380
+ if (!kind) continue;
381
+ const s = recordSetback(stateDir, { job: a.job, product: a.product, ref: a.ref, kind }, { now });
382
+ out.push({ job: a.job, product: a.product, ref: a.ref, kind, demoted: s.demoted || null });
383
+ }
384
+ return out;
385
+ }
386
+
314
387
  /** May this applied change still be undone (within 14 days, not undone yet)? */
315
388
  function undoOpen(stateDir, ref, { now } = {}) {
316
389
  const a = fold(read(stateDir)).applied.get(ref);
@@ -327,7 +400,7 @@ function restore(stateDir, { job, product }, actor, { now } = {}) {
327
400
  }
328
401
 
329
402
  module.exports = {
330
- WAYS, SHOW_UNTIL, KIND_LIST, kindOf, waysSet, autoWay, kindsOf,
403
+ wayAt, toCheck, recordCheck, fromRuns, VERDICTS, WAYS, SHOW_UNTIL, KIND_LIST, kindOf, waysSet, autoWay, kindsOf,
331
404
  LEDGER, CLASSES, DRIVER_CLASS, PROPOSAL_CLASS, DEMOTE_DAYS, UNDO_DAYS, RATE_LIMIT, RATE_MIN, KINDS,
332
405
  classOfDriver, classOfProposal, killed, autoFor, file, read, fold, recordApplied, reasonOf, recordSetback, decide, demotedNow, notices, markSeen, done, undoOpen, restore,
333
406
  };
@@ -108,7 +108,7 @@ function plan({ jobs = JOBS, now = Date.now(), idleMs = 0, idleLimit = 30 * 60 *
108
108
  if (j.step < 5) return row(true);
109
109
  if (quiet) return row(false, 'quiet hours');
110
110
  if (!away) return row(false, 'waiting for you to step away');
111
- if (spend && spend.atCap) return row(false, spend.why || "the spend limit in Settings › Claude's checks is reached");
111
+ if (spend && spend.atCap) return row(false, spend.why || "the spend limit in Settings › PMOS's checks is reached");
112
112
  if (live >= cap) return row(false, `${live} background runs are live (limit ${cap})`);
113
113
  live++; // a step-5 job may start one run: the next one sees it
114
114
  return row(true);
@@ -206,7 +206,7 @@ function chat({ runtimeDir, key, text, model, context, sessions, wsId, iniInfo,
206
206
  if (!runtimeDir) return fail(409, 'this workspace has no state folder to keep the conversation in');
207
207
  if (!KEY_RE.test(String(key || ''))) return fail(400, 'key must name a row');
208
208
  const q = String(text == null ? '' : text).trim();
209
- if (!q) return fail(400, 'Write a message for Claude.');
209
+ if (!q) return fail(400, 'Write a message for PMOS.');
210
210
  if (q.length > MAX_Q * 4) return fail(400, 'The message is too long (' + MAX_Q * 4 + ' characters at most).');
211
211
  if (!sessions || typeof sessions.spawn !== 'function') return fail(409, 'this workspace cannot start sessions');
212
212
  const live = chatSessionOf(runtimeDir, key);
@@ -256,7 +256,7 @@ function chat({ runtimeDir, key, text, model, context, sessions, wsId, iniInfo,
256
256
  // chief-of-staff C1/C6: the opening of Home's own chat carries the chief-of-staff rule (lib/cos-chat.js)
257
257
  const cosRule = CosChat.isKey(key) && !goal ? [CosChat.RULE] : [];
258
258
  try { s = sessions.spawn({ name, agent: 'claude', ws: wsId, origin: 'chat:' + key, chatClaude: { id: claude, resume }, initialInput: (resume ? msg : openingFor(row, msg, [...iniRule, ...cosRule])) + '\r', ...(resume && /^\/[A-Za-z0-9]/.test(msg) ? { typedByPm: true } : {}) }); } catch (e) { s = { state: 'exited', note: String((e && e.message) || e).slice(0, 120) }; }
259
- if (!s || s.state === 'exited' || !s.id) return fail(409, 'Claude could not start: ' + ((s && s.note) || 'no session'));
259
+ if (!s || s.state === 'exited' || !s.id) return fail(409, 'PMOS could not start: ' + ((s && s.note) || 'no session'));
260
260
  fs.mkdirSync(runtimeDir, { recursive: true });
261
261
  fs.appendFileSync(path.join(runtimeDir, CHATS), JSON.stringify({ key, session: s.id, claude, name, at: now.toISOString() }) + '\n');
262
262
  return { status: 200, body: { ok: true, session: s.id, started: true, ...(resume ? { resumed: true } : {}), ...extra } };
@@ -110,7 +110,7 @@ function checkFinding(L, input, { root = '.', read = (f) => fs.readFileSync(f, '
110
110
  const prop = {
111
111
  id: 'pr-' + hash([ini, 'grill', 'decision', id, pfile].join('|')),
112
112
  title: one(`Earlier decision: ${conflict}`, 200),
113
- say: one(`${id}${d.date ? ' (' + d.date + ')' : ''} says "${quote}". ${one(plan.label, LIM.label)} says "${pquote}". Keep ${id} and change the plan, change ${id}, or drop it. Claude suggests: ${RECOMMEND[rec].replace('{D}', id)}.`, 900),
113
+ say: one(`${id}${d.date ? ' (' + d.date + ')' : ''} says "${quote}". ${one(plan.label, LIM.label)} says "${pquote}". Keep ${id} and change the plan, change ${id}, or drop it. PMOS suggests: ${RECOMMEND[rec].replace('{D}', id)}.`, 900),
114
114
  confidence: conf,
115
115
  claims: [
116
116
  { text: `${id} · ${d.title}`, sources: [{ label: id, ...dsrc }] },
@@ -167,7 +167,7 @@ function replayCases(L, { root = '.', read } = {}) {
167
167
  const before = DL.asOf(L, newer), was = before.decisions.get(older);
168
168
  // an older decision already superseded before N (D64 replaced D24 before D66 did) is refused before N too, naming the earlier successor
169
169
  if (was && was.status === 'superseded') cases.push({ name: `${newer} → ${older}: before ${newer}, ${older} was already superseded by ${was.supersededBy.join(', ')}`, run: refused(before, finding, was.supersededBy), expect: { none: true } });
170
- else cases.push({ name: `${newer} → ${older}: before ${newer}, Claude pushes back`, run: filed(before, finding), expect: { filed: 1, cites: [O.path] } });
170
+ else cases.push({ name: `${newer} → ${older}: before ${newer}, PMOS pushes back`, run: filed(before, finding), expect: { filed: 1, cites: [O.path] } });
171
171
  cases.push({ name: `${newer} → ${older}: after ${newer}, ${older} is not quoted as live`, run: refused(L, finding, [newer]), expect: { none: true } });
172
172
  }
173
173
  return cases;
@@ -143,15 +143,18 @@ async function autoApply({ file, proposal, actor, ctx = {}, now, stateDir, produ
143
143
  const d = A.decide({ stateDir, job: jobOf(p), product, cls, mode: m, undoable: UNDOABLE.has(p.what), now, settingsDir: ctx.settingsDir || null });
144
144
  if (!d.apply) return { applied: false, why: d.why, cls };
145
145
  // board AwI: Intent is the PM's; Claude's change to it is a ✦ proposal on the product page and never applies by itself
146
- if (p.what === 'artefact' && p.data && p.data.artefact === 'intent') return { applied: false, why: 'Intent is the PM\'s, so Claude only proposes', cls };
146
+ if (p.what === 'artefact' && p.data && p.data.artefact === 'intent') return { applied: false, why: 'Intent is the PM\'s, so PMOS only proposes', cls };
147
147
  // board AwB: a line of an artefact the PM edited is the PM's now; Claude's change to it waits as a proposal
148
148
  if (p.what === 'artefact' && ctx.root) {
149
149
  const AR = require('./artefacts.js');
150
- try { if (AR.pmEdited(AR.fold(AR.readLines(AR.file(AR.dirOf(ctx.root)))), p.data || {})) return { applied: false, why: 'the PM edited this line, so Claude asks first', cls }; } catch { /* no artefacts yet: nothing edited */ }
150
+ try { if (AR.pmEdited(AR.fold(AR.readLines(AR.file(AR.dirOf(ctx.root)))), p.data || {})) return { applied: false, why: 'the PM edited this line, so PMOS asks first', cls }; } catch { /* no artefacts yet: nothing edited */ }
151
151
  }
152
152
  const r = await decide('keep', { file, proposal, actor, ctx, now, auto: true });
153
153
  if (!r.ok) return { applied: false, why: r.error, cls };
154
- A.recordApplied(stateDir, { job: jobOf(p), product, ref: p.id, title: `${p.what}: ${p.why}`, cls, ini: p.target && p.target.kind === 'initiative' ? p.target.id : null }, { now });
154
+ // batch 29 item 6: the line keeps what the change was read from (its sources) and the run that made it, so "PMOS did" can say why
155
+ const from = (p.sources || []).map((x) => x && x.label).filter(Boolean).slice(0, 3);
156
+ A.recordApplied(stateDir, { job: jobOf(p), product, ref: p.id, title: `${p.what}: ${p.why}`, cls, ini: p.target && p.target.kind === 'initiative' ? p.target.id : null,
157
+ why: from.length ? 'From ' + from.join(', ') : '', run: p.run || null }, { now, settingsDir: ctx.settingsDir || null });
155
158
  return { applied: true, why: d.why, cls, wrote: r.wrote };
156
159
  } catch (e) { return { applied: false, why: 'the apply failed: ' + String((e && e.message) || e).slice(0, 160) }; }
157
160
  }
@@ -95,14 +95,18 @@ function localDay(ms) {
95
95
  // ── where the ledger lives ───────────────────────────────────────────────────────────────────────────
96
96
  const isDir = (d) => { try { return fs.statSync(d).isDirectory(); } catch { return false; } };
97
97
  /** The repository's state folder, by the rule server.js stateDirFor uses; the checkout this file ships in falls back to
98
- * workspace/state, as the server does for PMOS-self. Null when there is none (and `create` is off). */
98
+ * lib/state-root.js#selfRecordsDir, as the server does for PMOS-self. Null when there is none (and `create` is off). */
99
99
  function stateDirOf(root, { create = false } = {}) {
100
100
  if (!root) return null;
101
101
  for (const rel of [['pmos', 'state'], ['state'], ['.pmos']]) {
102
102
  const d = path.join(root, ...rel);
103
103
  if (isDir(d)) return d;
104
104
  }
105
- if (path.resolve(root) === path.resolve(__dirname, '..', '..') && isDir(path.join(__dirname, '..', 'state'))) return path.join(__dirname, '..', 'state');
105
+ if (path.resolve(root) === path.resolve(__dirname, '..', '..')) {
106
+ // PMOS-self with no pmos/state/: the per-user records folder (lib/state-root.js#selfRecordsDir), never the app folder.
107
+ const d = require('./state-root.js').selfRecordsDir({ legacy: path.join(__dirname, '..', 'state') });
108
+ try { fs.mkdirSync(d, { recursive: true }); return d; } catch { return null; }
109
+ }
106
110
  if (create) {
107
111
  const d = path.join(root, 'pmos', 'state');
108
112
  try { fs.mkdirSync(d, { recursive: true }); return d; } catch { return null; }
@@ -21,7 +21,7 @@ function rowsFor(w, { lead } = {}) {
21
21
  const evidence = a.files.length ? a.files.join(', ') : '';
22
22
  return [{
23
23
  run_id: `${NAME}:${w.id}`, kind: 'folder-attention', initiative_id: null, question: a.message, doc: null, ws: w.id,
24
- today: { kind: 8, source: NAME, cause: a.message, evidence, act: { label: 'Ask Claude to sort it out', cli: null } },
24
+ today: { kind: 8, source: NAME, cause: a.message, evidence, act: { label: 'Ask PMOS to sort it out', cli: null } },
25
25
  }];
26
26
  }
27
27
  function sig(w) {
@@ -233,7 +233,7 @@ function resume({ runtimeDir, key, now = new Date() }) {
233
233
  * One row per conversation (key goal:<conversation key>); chatKey names the conversation, so pressing the row opens it and its goal card.
234
234
  * A row goes when the PM writes in the conversation, starts a new /goal there, or after ROW_DAYS. */
235
235
  const ROW_DAYS = 7;
236
- const ROW_TITLE = { done: 'Check the goal Claude finished', waiting: 'Claude needs you on a goal', stopped: 'A goal stopped before it was done' };
236
+ const ROW_TITLE = { done: 'Check the goal PMOS finished', waiting: 'PMOS needs you on a goal', stopped: 'A goal stopped before it was done' };
237
237
  function briefingRows(runtimeDir, now = Date.now()) { return goalRowsAt(runtimeDir, now).map(({ at, goalState, ...r }) => r); }
238
238
  /** briefingRows with each row's `at` (ms of the goal's last event) and `goalState` (done, stopped, waiting) kept: the bell's inbox orders and marks new by it (premium-agent-inbox). */
239
239
  function goalRowsAt(runtimeDir, now = Date.now()) {
@@ -247,17 +247,17 @@ function goalRowsAt(runtimeDir, now = Date.now()) {
247
247
  const at = Date.parse(g.at || '');
248
248
  if (Number.isFinite(at) && now - at > ROW_DAYS * 86400000) continue;
249
249
  const all = requiredOf(g), met = (g.met || []).filter((x) => all.includes(x)).length;
250
- const why = g.state === 'stopped' ? (REASON[g.reason] || 'It stopped.') : g.state === 'waiting' ? (g.reason === 'issue' ? REASON.issue : 'Claude asked you something in the conversation.') : 'Claude reports every done point met. It checked its own work.';
250
+ const why = g.state === 'stopped' ? (REASON[g.reason] || 'It stopped.') : g.state === 'waiting' ? (g.reason === 'issue' ? REASON.issue : 'PMOS asked you something in the conversation.') : 'PMOS reports every done point met. It checked its own work.';
251
251
  out.push({
252
252
  kind: 'goal', key: 'goal:' + key, chatKey: key, goalState: g.state, title: ROW_TITLE[g.state], subject: clip(g.draft.goal, 90),
253
- prepared: met + ' of ' + all.length + ' done points met, as Claude reports it. ' + why,
253
+ prepared: met + ' of ' + all.length + ' done points met, as PMOS reports it. ' + why,
254
254
  skip: g.state === 'waiting' ? 'If you skip: the goal waits and nothing more is done on it.' : 'If you skip: nobody checks the work before it is relied on.',
255
255
  at,
256
256
  dialog: {
257
257
  eye: 'Goal', logTitle: 'Read from the goal record', log: ['Read goal-runs.jsonl in the state folder', 'Kept the latest state of this goal', 'Changed nothing'],
258
258
  say: clip(g.draft.goal, 200) + ': ' + why, head: 'The goal',
259
259
  facts: [['State', ROW_TITLE[g.state]], ['Done points', met + ' of ' + all.length + ' met, unverified'], ['By', g.draft.by], ['Rounds', String(g.rounds || 0)]].filter((x) => x[1]),
260
- opts: [], sel: null, nodef: 'The goal card is in the conversation beside this. Write there to answer Claude or to go on.',
260
+ opts: [], sel: null, nodef: 'The goal card is in the conversation beside this. Write there to answer PMOS or to go on.',
261
261
  pane: { label: 'Goal', file: 'goal-runs.jsonl', h: clip(g.draft.goal, 90), intro: why, rows: (g.draft.done || []).map((x) => [(g.skipped || []).includes(x) ? 'Skipped' : (g.met || []).includes(x) ? 'Met' : 'Open', x]), paras: [] },
262
262
  },
263
263
  });
@@ -341,7 +341,7 @@ function decide({ runtimeDir, key, id, act, draft, point, session, sessions, now
341
341
  if (act === 'skip' && (skipped.includes(p) || (g.met || []).includes(p))) return fail(409, 'That point is already ' + (skipped.includes(p) ? 'skipped.' : 'met.'));
342
342
  if (act === 'skip' && requiredOf(g).length <= 1) return fail(409, 'A goal keeps at least one done point. Stop it instead.');
343
343
  if (act === 'unskip' && !skipped.includes(p)) return fail(409, 'That point is not skipped.');
344
- if (act === 'unskip' && Date.parse((g.skipAt || {})[p] || '') <= Date.parse(g.roundAt || '')) return fail(409, 'Claude has already dropped that point. Tell Claude to pick it up again.');
344
+ if (act === 'unskip' && Date.parse((g.skipAt || {})[p] || '') <= Date.parse(g.roundAt || '')) return fail(409, 'PMOS has already dropped that point. Tell PMOS to pick it up again.');
345
345
  // a queued instruction: typed while Claude works, so Claude reads it after its current step
346
346
  if (!alive || !sessions.type(session, act === 'skip' ? skipMessage(p) : unskipMessage(p))) return fail(409, 'The message did not reach the session. Open it in Sessions.');
347
347
  append(runtimeDir, { event: act, point: p, id, key, at });
@@ -61,7 +61,7 @@ function historyOf(lines, rid) {
61
61
  const out = [];
62
62
  for (const l of lines || []) {
63
63
  if (!l || l.rid !== rid || l.kind === 'reading') continue;
64
- const who = String(l.by || '').startsWith('human:') ? 'You' : 'Claude';
64
+ const who = String(l.by || '').startsWith('human:') ? 'You' : 'PMOS';
65
65
  const what = l.kind === 'add' ? 'added it' : 'changed ' + Object.keys(l.fields || {}).filter((k) => k !== 'retired').join(', ');
66
66
  out.push({ at: timeOf(l.id), text: who + ' ' + what + (l.why ? ': ' + String(l.why).slice(0, 120) : '') });
67
67
  }
@@ -85,8 +85,8 @@ function create(deps) {
85
85
 
86
86
  /** Start one run now. → { ok, run, budget } | { ok: false, error, paused?, held? } */
87
87
  function start({ ws, board, ini, why = 'monthly', key = '', detail = '', now = Date.now() } = {}) {
88
- if (isOff()) return { ok: false, error: 'Claude\'s grill runs are off (Settings grill.mode, PMOS_GRILL or PMOS_HEADLESS)' };
89
- if (active.size >= MAX) return { ok: false, held: true, error: 'Claude is already grilling one initiative' };
88
+ if (isOff()) return { ok: false, error: 'PMOS\'s grill runs are off (Settings grill.mode, PMOS_GRILL or PMOS_HEADLESS)' };
89
+ if (active.size >= MAX) return { ok: false, held: true, error: 'PMOS is already grilling one initiative' };
90
90
  const rt = runtime(); if (!rt) return { ok: false, error: 'no runtime state folder' };
91
91
  const w = (deps.workspaces() || []).find((x) => x.id === ws);
92
92
  if (!w) return { ok: false, error: 'no such workspace' };
@@ -96,7 +96,7 @@ function create(deps) {
96
96
  const month = G.monthOf(now);
97
97
  // at the cap Claude pauses and says so once a month
98
98
  if (!F.paused.has(month)) try { G.append(rt, { kind: 'paused', month, spent: b.spent, cap: cap() }, now); } catch (e) { warn('grill pause', e); }
99
- return { ok: false, paused: true, error: `Claude paused grilling: this month spent $${b.spent} of the $${cap()} cap` };
99
+ return { ok: false, paused: true, error: `PMOS paused grilling: this month spent $${b.spent} of the $${cap()} cap` };
100
100
  }
101
101
  const skill = deps.promptFor('grill');
102
102
  if (!skill) return { ok: false, error: 'the grill skill is not installed' };
@@ -130,12 +130,12 @@ function create(deps) {
130
130
  env,
131
131
  onDone: (r) => ended(run, r) });
132
132
  } catch (e) { warn('grill run', e); }
133
- if (session && session.held) { active.delete(run); return { ok: false, held: true, error: 'Claude is busy with other runs; it grills in a minute' }; }
133
+ if (session && session.held) { active.delete(run); return { ok: false, held: true, error: 'PMOS is busy with other runs; it grills in a minute' }; }
134
134
  G.append(rt, { kind: 'start', run, ws, ini, board: board || '', why, key, budget: b.budget }, now);
135
135
  if (!session || session.state === 'exited' || session.headless !== 'grill') {
136
136
  if (session && session.headless !== 'grill' && session.state !== 'exited' && deps.stop) { try { deps.stop(session); } catch { /* best effort */ } }
137
137
  ended(run, { code: 1, note: (session && session.note) || 'the run could not start in the background', result: { costUsd: 0 } }, now);
138
- return { ok: false, error: (session && session.note) || 'Claude could not start grilling' };
138
+ return { ok: false, error: (session && session.note) || 'PMOS could not start grilling' };
139
139
  }
140
140
  active.get(run).session = session;
141
141
  return { ok: true, run, budget: b.budget };
@@ -86,6 +86,7 @@ const path = require('path');
86
86
  const HEADLESS_SKILLS = Object.freeze([
87
87
  'day-check', 'calendar-sync', 'jira-sync', 'my-work-read', 'report-biweekly', 'report-template',
88
88
  'tracker-refresh', 'measure', 'memory-groom', 'backlog-triage',
89
+ 'story-first', // batch 29 item 5: the first story so far, once, when a product has none (lib/story-seed.js)
89
90
  ]);
90
91
  // The note passes that run headless, by the origin prefix lib/routes-notes.js gives them.
91
92
  const HEADLESS_ORIGINS = Object.freeze(['notes-bullets:', 'notes-summary:']);
@@ -208,8 +209,10 @@ const TOOLS = Object.freeze({
208
209
  'Bash(pmos initiative export *)', 'Bash(git log *)', 'Bash(date *)']),
209
210
  // The verifier run (lib/verify-runs.js): read and search the repository and its history, and the one command that records the verdict for
210
211
  // the run it was started for. No Write, no Edit, no web, no connector, nothing that sends; `git` only to read.
212
+ // Batch 29 item 9: the same kind grades one change an agent applied by itself (origin `verify:change:<ref>:<token>`); its one write there
213
+ // is `pmos autonomy check`, pinned by PMOS_CHECK_REF and PMOS_CHECK_DIR to that change. The read verbs show the record it changed.
211
214
  verify: Object.freeze(['Read', 'Glob', 'Grep', 'Bash(git show *)', 'Bash(git log *)', 'Bash(git diff *)', 'Bash(node scripts/verifier.js record *)',
212
- 'Bash(node scripts/workflow-state.js *)', 'Bash(date *)']),
215
+ 'Bash(node scripts/workflow-state.js *)', 'Bash(pmos autonomy check *)', 'Bash(pmos initiative export *)', 'Bash(pmos artefacts show *)', 'Bash(date *)']),
213
216
  // The reading run (lib/metric-read-runs.js): read and search, and the one verb that files a reading. The PM's analytics and Jira are read through
214
217
  // the PM's own connectors only where the PM's settings allow it. No Write, no Edit, no web fetch, nothing that sends.
215
218
  'metric-read': Object.freeze(['Read', 'Glob', 'Grep', 'Bash(pmos metrics reading *)', 'Bash(pmos source show *)', 'Bash(pmos source status *)', 'Bash(date *)']),
@@ -647,7 +650,7 @@ const RUN_ENV = Object.freeze(['PMOS_SCAN_FILE', 'PMOS_SCAN_ORIGIN', 'PMOS_SCAN_
647
650
  'PMOS_METRIC_READ_FILE', 'PMOS_METRIC_READ_RECORDS', 'PMOS_METRIC_READ_DRAFTS', 'PMOS_METRIC_READ_WS', 'PMOS_METRIC_READ_RUN', 'PMOS_METRIC_READ_RIDS', 'PMOS_METRIC_READ_TEST',
648
651
  'PMOS_PROPOSE_FILE', 'PMOS_PROPOSE_WS', 'PMOS_PROPOSE_BOARD', 'PMOS_PROPOSE_INI', 'PMOS_PROPOSE_RUN',
649
652
  'PMOS_GRILL_FILE', 'PMOS_GRILL_LOG', 'PMOS_GRILL_WS', 'PMOS_GRILL_BOARD', 'PMOS_GRILL_INI', 'PMOS_GRILL_RUN', 'PMOS_GRILL_BUDGET',
650
- 'PMOS_IMPACT_FILE', 'PMOS_IMPACT_RUN', 'PMOS_VERIFY_RUN', 'PMOS_MS_REVIEW_FILE', 'PMOS_MS_REVIEW_RUN', 'PMOS_MS_REVIEW_PROGRAM',
653
+ 'PMOS_IMPACT_FILE', 'PMOS_IMPACT_RUN', 'PMOS_VERIFY_RUN', 'PMOS_CHECK_REF', 'PMOS_CHECK_DIR', 'PMOS_MS_REVIEW_FILE', 'PMOS_MS_REVIEW_RUN', 'PMOS_MS_REVIEW_PROGRAM',
651
654
  'PMOS_TEAM_FILE', 'PMOS_TEAM_ROOT', 'PMOS_TEAM_WS', 'PMOS_TEAM_ROLE', 'PMOS_TEAM_RUN', 'PMOS_TEAM_INI', 'PMOS_TEAM_MODE',
652
655
  'PMOS_LAB_RUN', 'PMOS_LAB_KIND', 'PMOS_LAB_PENDING', 'PMOS_LAB_INI', 'PMOS_LAB_BUDGET', 'PMOS_LAB_PAGES', 'PMOS_LAB_SPECIMENS']);
653
656
  function runEnvOf(extra) {
@@ -44,7 +44,7 @@ const crypto = require('crypto');
44
44
  const LEDGER = 'idle-lab.jsonl';
45
45
  const KINDS = new Set(['propose', 'drop', 'keep', 'undo', 'run', 'next']);
46
46
  const GROUPS = Object.freeze(['prototyped', 'improved', 'scanned']);
47
- const TITLES = Object.freeze({ prototyped: 'Claude prototyped it', improved: 'Claude improved it', scanned: 'Claude scanned for it' });
47
+ const TITLES = Object.freeze({ prototyped: 'PMOS prototyped it', improved: 'PMOS improved it', scanned: 'PMOS scanned for it' });
48
48
  const LOOSE = Object.freeze(['start', 'scan']);
49
49
  const PROVEN = Object.freeze({ production: false, design: false });
50
50
  const WEEK = 7 * 864e5;
@@ -85,7 +85,7 @@ function result(group, input) {
85
85
  if (!GROUPS.includes(group)) return { error: 'group is one of ' + GROUPS.join(', ') };
86
86
  if (!isObj(input)) return { error: 'the result is a JSON object' };
87
87
  const why = one(input.why, LIM.why);
88
- if (!why) return { error: 'why is one line: what Claude did and from what' };
88
+ if (!why) return { error: 'why is one line: what PMOS did and from what' };
89
89
  const s = srcList(input.sources, 1); if (s.error) return s;
90
90
  const data = {};
91
91
  if (group === 'prototyped') {
@@ -114,7 +114,7 @@ function result(group, input) {
114
114
  }
115
115
  if (group !== 'scanned') {
116
116
  const checked = one(input.checked, LIM.checked);
117
- if (!checked) return { error: 'checked says how Claude proved it (for example: all three open and render in the Viewer)' };
117
+ if (!checked) return { error: 'checked says how PMOS proved it (for example: all three open and render in the Viewer)' };
118
118
  data.checked = checked;
119
119
  }
120
120
  if (isObj(input.compare)) data.compare = compareData(input.compare);
@@ -258,9 +258,9 @@ function compareOf(P, id, { key = '', titleOf = () => '', proven = PROVEN } = {}
258
258
  const c = (p.data && p.data.compare) || {};
259
259
  const cols = [];
260
260
  cols.push(proven.production && c.production ? { id: 'production', title: 'Production', meta: 'main, today', file: c.production.file, read: c.production.read }
261
- : { id: 'production', title: 'Production', left: 'Left out: Claude cannot render production from the product repo yet. It shows here once that is proven.' });
261
+ : { id: 'production', title: 'Production', left: 'Left out: PMOS cannot render production from the product repo yet. It shows here once that is proven.' });
262
262
  cols.push(proven.design && c.design ? { id: 'design', title: 'Design', meta: 'the design for this screen', file: c.design.file, read: c.design.read }
263
- : { id: 'design', title: 'Design', left: 'Left out: Claude cannot read the design from Figma or a canvas yet. It shows here once that is proven.' });
263
+ : { id: 'design', title: 'Design', left: 'Left out: PMOS cannot read the design from Figma or a canvas yet. It shows here once that is proven.' });
264
264
  cols.push({ id: 'prototype', title: 'Prototype', meta: 'round ' + round + (spec ? ' · ' + spec.key : ''), file, read: (p.data && p.data.checked) || '' });
265
265
  const shown = new Set(cols.filter((x) => !x.left).map((x) => x.id));
266
266
  const pins = (c.pins || []).filter((x) => shown.has(x.vs)).map((x, i) => ({ n: i + 1, vs: x.vs, text: x.text }));
@@ -81,12 +81,12 @@ function create(deps) {
81
81
  session = go({ name: 'Reading your impact', ws: w.id, origin: 'impact:' + run, initialInput: prompt + '\r',
82
82
  env: { PMOS_IMPACT_FILE: IM.ledgerFile(dir), PMOS_IMPACT_RUN: run }, onDone: (r) => ended(run, r) });
83
83
  } catch (e) { warn('impact run', e); }
84
- if (session && session.held) { active = null; return { ok: false, held: true, error: 'Claude is busy with other runs. It tries again later.' }; }
84
+ if (session && session.held) { active = null; return { ok: false, held: true, error: 'PMOS is busy with other runs. It tries again later.' }; }
85
85
  IM.append(dir, null, { kind: 'run', run }, new Date(now).toISOString());
86
86
  if (!session || session.state === 'exited' || session.headless !== 'impact') {
87
87
  if (session && session.headless !== 'impact' && session.state !== 'exited' && deps.stop) { try { deps.stop(session); } catch { /* best effort */ } }
88
88
  ended(run, { code: 1, note: (session && session.note) || 'the run could not start in the background', result: {} }, now);
89
- return { ok: false, error: (session && session.note) || 'Claude could not start reading.' };
89
+ return { ok: false, error: (session && session.note) || 'PMOS could not start reading.' };
90
90
  }
91
91
  if (active) active.session = session;
92
92
  return { ok: true, run };