create-pmos 0.432.0 → 0.434.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +25 -25
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-insights-test.js +63 -58
- package/workspace/changelog.json +24 -0
- package/workspace/guide/home.md +1 -1
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/metric-drafts.md +21 -1
- package/workspace/guide/programs.md +1 -1
- package/workspace/guide/your-impact.md +58 -0
- package/workspace/impact-screens-test.js +149 -0
- package/workspace/intel-report-ui-test.js +1 -1
- package/workspace/intelligence-gaps-ui-test.js +13 -9
- package/workspace/lib/engine/outbox.js +1 -1
- package/workspace/lib/engine/records/index.js +11 -3
- package/workspace/lib/goal-status.js +199 -0
- package/workspace/lib/goal-watch.js +71 -0
- package/workspace/lib/headless.js +24 -2
- package/workspace/lib/impact-cli.js +72 -0
- package/workspace/lib/impact-runs.js +114 -0
- package/workspace/lib/impact.js +195 -0
- package/workspace/lib/insights-premium.js +43 -4
- package/workspace/lib/metric-draft-runs.js +33 -10
- package/workspace/lib/metric-drafts.js +118 -15
- package/workspace/lib/metric-read-runs.js +132 -0
- package/workspace/lib/metric-reads.js +129 -0
- package/workspace/lib/metrics-cli.js +100 -5
- package/workspace/lib/pmos-verbs.js +4 -1
- package/workspace/lib/route-modules.js +3 -0
- package/workspace/lib/routes-goal-status.js +111 -0
- package/workspace/lib/routes-impact-views.js +58 -0
- package/workspace/lib/routes-impact.js +91 -0
- package/workspace/lib/routes-insights-premium.js +20 -0
- package/workspace/lib/routes-metric-drafts.js +55 -4
- package/workspace/lib/routes-records.js +2 -0
- package/workspace/lib/settings-store.js +3 -0
- package/workspace/milestone-pins-test.js +8 -3
- package/workspace/okr-goals-ui-test.js +175 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/product-lane-test.js +5 -5
- package/workspace/public/pm/bd-ini-panel.js +10 -2
- package/workspace/public/pm/bd-span.js +5 -4
- package/workspace/public/pm/cozy-adler.css +5 -0
- package/workspace/public/pm/cozy-adler.js +17 -9
- package/workspace/public/pm/cozy-insights.css +84 -0
- package/workspace/public/pm/cozy-settings.js +11 -1
- package/workspace/public/pm/home-app.js +61 -8
- package/workspace/public/pm/home-impact.css +16 -0
- package/workspace/public/pm/home-impact.js +72 -0
- package/workspace/public/pm/home-today.js +4 -2
- package/workspace/public/pm/impact.css +37 -0
- package/workspace/public/pm/impact.js +201 -0
- package/workspace/public/pm/okr-list.js +249 -0
- package/workspace/public/pm/premium-insights.js +222 -238
- package/workspace/public/pm/premium-vw-mtg.js +4 -1
- package/workspace/public/pm/stage-line.js +4 -3
- package/workspace/public/premium-intelligence.html +3 -2
- package/workspace/public/premium.html +1 -0
- package/workspace/server.js +56 -2
- package/workspace/skills/impact-detect.skill +46 -0
- package/workspace/skills/metric-read.skill +32 -0
- package/workspace/task-milestones-test.js +4 -3
- package/workspace/test-lists/goal-watch.json +9 -0
- package/workspace/test-lists/impact-screens.json +5 -0
- package/workspace/test-lists/impact-ui.json +9 -0
- package/workspace/test-lists/impact.json +9 -0
- package/workspace/test-lists/okr-goals-ui.json +5 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: Guide
|
|
3
|
+
title: "Your impact"
|
|
4
|
+
description: "What Your impact is, what counts and what never counts, the weekly check in Home's chat, the switch in Settings, and the pmos impact commands."
|
|
5
|
+
timestamp: 2026-10-28
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Your impact
|
|
9
|
+
|
|
10
|
+
Your impact shows you what happened because of your work: a thanks, a ticket that moved after your decision, a spec another team used, a key result that moved after your initiative delivered. It is private. Only you see it, and nothing leaves PMOS.
|
|
11
|
+
|
|
12
|
+
## What counts
|
|
13
|
+
|
|
14
|
+
An item counts only when a person or a system outside you reacted to your work, and Claude can link the source. Claude reads Slack, mail, Jira, your meeting notes, your documents and your key results.
|
|
15
|
+
|
|
16
|
+
These never count: logins, ticks, time spent, messages you sent, documents you wrote, and anything Claude or an agent did on its own.
|
|
17
|
+
|
|
18
|
+
There are no numbers. You see no points, scores, counts, streaks, levels or ranks.
|
|
19
|
+
|
|
20
|
+
## The weekly check
|
|
21
|
+
|
|
22
|
+
Once a day, Claude reads your sources and files what it found. After the week ends, Claude lists that week's items in Home's chat and asks whether each one is real:
|
|
23
|
+
|
|
24
|
+
- ✓ keeps one item. Only a kept item counts.
|
|
25
|
+
- ✕ drops it. Claude does not file anything like it again.
|
|
26
|
+
- ✓✓ keeps every item that is not checked yet.
|
|
27
|
+
|
|
28
|
+
Each row has its source, so you can open the message or the ticket before you choose.
|
|
29
|
+
|
|
30
|
+
Adler's sprout and your impact log stay hidden until two weekly checks show that at least 9 of 10 items are real. Then Adler's sprout grows a leaf for each week's kept items, and the log in the Viewer shows your weeks, newest first. A quiet week says "A quiet week". Nothing wilts and nothing resets.
|
|
31
|
+
|
|
32
|
+
## Where you see it
|
|
33
|
+
|
|
34
|
+
When the check has passed, Your impact shows in these places. Each item opens its source.
|
|
35
|
+
|
|
36
|
+
- **Home.** Adler's face next to "Good morning" is a press of its own. His sprout grows with your kept items. Press it to open "Your impact this week" in the Viewer. The list icon in its header opens your impact log.
|
|
37
|
+
- **Your impact log.** This week is open. Past weeks fold. A quiet week says "A quiet week".
|
|
38
|
+
- **Once, on a real event.** Adler's newest leaf grows once. A thanks also shows in a toast, for example "Chen thanked you". Then the item is marked as read. Settings › Adler › Celebrations: Never stops this.
|
|
39
|
+
- **A meeting.** Under the decisions: "Recorded. If it unblocks someone, it goes in your impact log."
|
|
40
|
+
- **Intelligence.** A key result that moved after your work is one more ✦ line, with its source.
|
|
41
|
+
- **The Board.** An initiative with a milestone delivered in the last 30 days names the people on its tickets, by name, each with its ticket. There is no thank-you press, and nothing is sent.
|
|
42
|
+
- **Your day, on a Friday.** When a stage of one of your initiatives closed this week, a card shows where it started and where it is now, with a link to it.
|
|
43
|
+
|
|
44
|
+
## Turn it off
|
|
45
|
+
|
|
46
|
+
Settings › General › Your impact. Off hides the leaf, the log and the weekly check, and Claude stops reading. `PMOS_IMPACT=off` also stops the daily read.
|
|
47
|
+
|
|
48
|
+
## Where it is kept
|
|
49
|
+
|
|
50
|
+
In your own runtime folder, `impact/impact.jsonl`, outside every repository. No commit, sync or teammate reads it.
|
|
51
|
+
|
|
52
|
+
## Commands
|
|
53
|
+
|
|
54
|
+
Only Claude's impact run uses these. The server pins each run to your ledger. Outside such a run, they refuse.
|
|
55
|
+
|
|
56
|
+
- `pmos impact add --json <file|->` files one item or a list: `{ "kind", "text", "who", "at", "source": { "url", "type", "label" } }`. The kind is thanks, unblock, used or kr. An item with no source, or with a count in its text, is refused.
|
|
57
|
+
- `pmos impact end` ends the run. `--error "<why>"` says why it could not finish.
|
|
58
|
+
- `pmos impact status` lists what is filed for this week and the last.
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* impact-screens-test.js — Your impact in the real pages (feedback batch 16 item 7, Phases 2 to 4; canvas GmA1Home, GmA3Garden, GmA2Board).
|
|
4
|
+
* The real Home and Board from the real server; GET /api/impact/week and /weeks are stubbed in the contract's shape (7-impact-api.md), and
|
|
5
|
+
* every POST is recorded so the test can say nothing left for anywhere but /api/impact/seen.
|
|
6
|
+
* H1 Home: the greeting's Adler is its own press, beside "Good morning", which still opens Your day
|
|
7
|
+
* H2 the one celebration: a thanks says itself in the toast once and is marked read
|
|
8
|
+
* H3 a press opens "Your impact this week" in the Viewer: a row per item, each with its source to open, and the lock line; no digit
|
|
9
|
+
* H4 the log icon opens "Your impact": this week open, a quiet week in plain words, past weeks folded
|
|
10
|
+
* H5 off (or gated): no face press; the greeting is as it was
|
|
11
|
+
* B1 Board: an initiative with a milestone delivered this month shows who made it happen, unranked, each with a ticket; no send press
|
|
12
|
+
* N every POST went to /api/impact/seen, and no page error
|
|
13
|
+
* PMOS_SHOTS=<dir> also saves the screenshots. */
|
|
14
|
+
const path = require('path');
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const { spawn } = require('child_process');
|
|
17
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
18
|
+
const T = require('./test-run').configure({ name: 'impact-screens' });
|
|
19
|
+
const BP = require('./lib/board-premium.js');
|
|
20
|
+
const BF = require('./fixtures/board-premium-facts.js');
|
|
21
|
+
const BRP = require('./lib/briefing-premium.js');
|
|
22
|
+
const BRF = require('./fixtures/briefing-premium-facts.js');
|
|
23
|
+
|
|
24
|
+
const BASE = T.BASE;
|
|
25
|
+
const SHOTS = process.env.PMOS_SHOTS || '';
|
|
26
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
27
|
+
const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { let v; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
28
|
+
const results = [];
|
|
29
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
|
|
30
|
+
let srv = null; let browser = null;
|
|
31
|
+
const finish = async (code) => {
|
|
32
|
+
if (browser) await browser.close().catch(() => {});
|
|
33
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
34
|
+
T.killTmux();
|
|
35
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
36
|
+
console.log(`\n${results.length - bad}/${results.length} impact-screens assertions passed`);
|
|
37
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
38
|
+
};
|
|
39
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
40
|
+
|
|
41
|
+
const item = (id, kind, text, who, type, label, url, at) => ({ id, week: '2026-10-26', kind, text, who, source: { type, label, url }, at, real: true, read: false });
|
|
42
|
+
const ITEMS = [
|
|
43
|
+
item('a', 'thanks', 'Chen: “the drop-off spec saved us a day”', 'Chen', 'slack', 'Slack · #idpf-data', 'https://acme.slack.com/archives/C1/p1', '2026-10-27T09:12:00Z'),
|
|
44
|
+
item('b', 'unblock', 'Your scope call unblocked the login team', '', 'jira', 'Jira ticket moved to In progress', 'https://acme.atlassian.net/browse/IDPF-212', '2026-10-28T10:00:00Z'),
|
|
45
|
+
item('c', 'used', 'Descope rollout delivered from your PRD', '', 'initiative', 'Deliver', '/premium.html?ini=descope', '2026-10-29T10:00:00Z'),
|
|
46
|
+
];
|
|
47
|
+
const WEEK = (o = {}) => ({ ok: true, on: true, live: true, week: '2026-10-26', label: 'This week', grow: 'full', celebrate: 'a', quiet: false, items: ITEMS, ...o });
|
|
48
|
+
const WEEKS = { ok: true, on: true, live: true, weeks: [
|
|
49
|
+
{ week: '2026-10-26', label: 'This week', quiet: false, items: ITEMS },
|
|
50
|
+
{ week: '2026-10-19', label: 'Last week', quiet: false, items: [item('d', 'used', 'Your Scarlet PRD was signed off', '', 'doc', 'PRD · Scarlet', '/premium.html?ini=scarlet', '2026-10-21T10:00:00Z')] },
|
|
51
|
+
{ week: '2026-10-12', label: 'Week of Oct 12', quiet: true, items: [] },
|
|
52
|
+
] };
|
|
53
|
+
|
|
54
|
+
(async () => {
|
|
55
|
+
const exe = process.env.PMOS_CHROME || findBrowser();
|
|
56
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the impact-screens suite cannot run'); return finish(1); }
|
|
57
|
+
let chromium;
|
|
58
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
59
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
|
|
60
|
+
await T.waitForServer(BASE);
|
|
61
|
+
browser = await chromium.launch({ executablePath: exe });
|
|
62
|
+
if (SHOTS) fs.mkdirSync(SHOTS, { recursive: true });
|
|
63
|
+
const shot = async (p, name) => { if (SHOTS) { await sleep(500); await p.screenshot({ path: path.join(SHOTS, name + '.png') }); } };
|
|
64
|
+
const BRIEF = BRP.build(BRF.facts());
|
|
65
|
+
const BOARD = BP.build(BF.facts());
|
|
66
|
+
{ // a milestone delivered five days before the board's today, and the people on its tickets
|
|
67
|
+
const r = BOARD.rows.find((x) => x.id === 'self-serve-v2'), t = new Date(BOARD.today + 'T00:00:00'); t.setDate(t.getDate() - 5);
|
|
68
|
+
const d = t.getFullYear() + '-' + String(t.getMonth() + 1).padStart(2, '0') + '-' + String(t.getDate()).padStart(2, '0');
|
|
69
|
+
r.milestones = [{ id: 'm1', name: 'Self-serve launch', date: d, done: true }];
|
|
70
|
+
r.track.tickets = (r.track.tickets || []).concat([
|
|
71
|
+
{ key: 'SS-31', title: 'Ran the release on Thursday', status: 'Done', assignee: 'Suhas', url: 'https://acme.atlassian.net/browse/SS-31' },
|
|
72
|
+
{ key: 'SS-12', title: 'Wrote the drop-off query', status: 'Done', assignee: 'Chen', url: 'https://acme.atlassian.net/browse/SS-12' },
|
|
73
|
+
{ key: 'SS-20', title: 'Fixed the login test', status: 'Done', assignee: 'Lee', url: 'https://acme.atlassian.net/browse/SS-20' },
|
|
74
|
+
]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const open = async ({ w = 1440, h = 900, week = WEEK(), url = '/premium.html' } = {}) => {
|
|
78
|
+
const ctx = await browser.newContext({ viewport: { width: w, height: h }, hasTouch: w < 500 });
|
|
79
|
+
const page = await ctx.newPage();
|
|
80
|
+
const errors = [], posts = [];
|
|
81
|
+
page.on('pageerror', (e) => errors.push(String(e)));
|
|
82
|
+
page.on('request', (rq) => { if (rq.method() === 'POST') posts.push(new URL(rq.url()).pathname); });
|
|
83
|
+
const json = (rq, b) => rq.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(b) });
|
|
84
|
+
await page.route(/\/api\/board-premium(\?.*)?$/, (rq) => json(rq, { ok: true, state: 'ready', model: BOARD, as_of: Date.now() }));
|
|
85
|
+
await page.route(/\/api\/briefing-premium(\?.*)?$/, (rq) => json(rq, { ok: true, state: 'ready', model: BRIEF, as_of: Date.now() }));
|
|
86
|
+
await page.route('**/api/briefing-premium/**', (rq) => json(rq, { ok: true, turns: [], working: false }));
|
|
87
|
+
await page.route(/\/api\/impact\/week(\?.*)?$/, (rq) => json(rq, week));
|
|
88
|
+
await page.route(/\/api\/impact\/weeks(\?.*)?$/, (rq) => json(rq, WEEKS));
|
|
89
|
+
await page.route(/\/api\/impact\/seen$/, (rq) => json(rq, { ok: true }));
|
|
90
|
+
await page.route(/\/api\/impact-views\/chapter(\?.*)?$/, (rq) => json(rq, { ok: true, week: '2026-10-26', chapters: [] }));
|
|
91
|
+
await page.goto(BASE + url);
|
|
92
|
+
return { ctx, page, errors, posts };
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/* H1-H4 */
|
|
96
|
+
{
|
|
97
|
+
const { ctx, page, errors, posts } = await open();
|
|
98
|
+
const face = await until(() => page.evaluate(() => { const b = document.querySelector('#hmList [data-hm-impact]'); return b ? { label: b.getAttribute('aria-label'), next: !!(b.nextElementSibling && b.nextElementSibling.matches('[data-hm-day]')), dayFace: !!document.querySelector('#hmList [data-hm-day] .ad-svg') } : null; }), 30000);
|
|
99
|
+
ok('H1 the greeting\'s Adler is its own press, "Your impact this week", right before "Good morning"', face && face.label === 'Your impact this week' && face.next && !face.dayFace, JSON.stringify(face));
|
|
100
|
+
const toastSaid = await until(() => page.evaluate(() => { const t = document.getElementById('toast'); return t && /thanked you/.test(t.textContent) ? t.textContent : null; }));
|
|
101
|
+
ok('H2 the one celebration: Chen\'s thanks says itself in the toast, and it is marked read', /Chen thanked you · Chen: “the drop-off spec saved us a day”/.test(toastSaid || '') && (await until(() => posts.includes('/api/impact/seen'))), toastSaid);
|
|
102
|
+
await shot(page, 'home-face');
|
|
103
|
+
await page.click('#hmList [data-hm-impact]');
|
|
104
|
+
const vw = await until(() => page.evaluate(() => { const v = document.querySelector('#czViewer'); const c = window.czViewer && window.czViewer.current(); if (!v || v.hidden || !c || c.id !== 'impact-week') return null; const rows = [...v.querySelectorAll('.im-row')]; return rows.length ? { title: c.title, rows: rows.map((r) => ({ t: r.querySelector('.im-t').textContent, href: r.querySelector('a.im-ib') && r.querySelector('a.im-ib').getAttribute('href') })), text: v.querySelector('.cz-vw-body').innerText } : null; }));
|
|
105
|
+
ok('H3 the Viewer "Your impact this week": a row per item, each opening its own source', vw && vw.title === 'Your impact this week' && vw.rows.length === 3 && vw.rows[0].href === 'https://acme.slack.com/archives/C1/p1' && vw.rows[2].href === '/premium.html?ini=descope', JSON.stringify(vw));
|
|
106
|
+
const chrome = vw ? vw.text.replace(/IDPF-\d+/g, '') : '';
|
|
107
|
+
ok('H3 the lock line, and no digit anywhere on the page body (no count, no score)', /Only you see this\. Nothing leaves PMOS\./.test(chrome) && !/\d/.test(chrome), chrome);
|
|
108
|
+
await shot(page, 'impact-week');
|
|
109
|
+
await page.click('#czViewer [data-cz-vw-p="log"]');
|
|
110
|
+
const log = await until(() => page.evaluate(() => { const c = window.czViewer && window.czViewer.current(); const b = document.querySelector('#czViewer .cz-vw-body'); if (!c || c.id !== 'impact-log' || !b || !b.querySelector('.im-wk')) return null; return { sections: b.querySelectorAll('section.im-wk').length, folded: [...b.querySelectorAll('details.im-wk')].map((d) => d.open), quiet: [...b.querySelectorAll('.im-wk.quiet')].map((q) => q.innerText.replace(/\s+/g, ' ').trim()), adler: !!b.querySelector('.im-log .ad-svg') }; }));
|
|
111
|
+
ok('H4 the log: this week open, last week folded, a quiet week in plain words, Adler at the top', log && log.sections === 1 && log.folded.length === 1 && log.folded[0] === false && log.quiet[0] === 'Week of Oct 12 A quiet week' && log.adler, JSON.stringify(log));
|
|
112
|
+
await shot(page, 'impact-log');
|
|
113
|
+
ok('N Home: every POST went to /api/impact/seen or the page\'s own reads, and no page error', !posts.some((p) => /slack|mail|jira|outbox|share|send/i.test(p)) && !errors.length, JSON.stringify({ posts, errors }));
|
|
114
|
+
await ctx.close();
|
|
115
|
+
}
|
|
116
|
+
/* H5 */
|
|
117
|
+
for (const [name, week] of [['off', { ok: true, on: false }], ['gated', WEEK({ live: false, items: [], grow: 'rest', celebrate: null })]]) {
|
|
118
|
+
const { ctx, page } = await open({ week });
|
|
119
|
+
await until(() => page.evaluate(() => !!document.querySelector('#hmList [data-hm-day]')), 30000);
|
|
120
|
+
await sleep(800);
|
|
121
|
+
const st = await page.evaluate(() => ({ face: !!document.querySelector('#hmList [data-hm-impact]'), dayFace: !!document.querySelector('#hmList [data-hm-day] .ad-svg') }));
|
|
122
|
+
ok(`H5 ${name}: no impact press; the greeting keeps its own face`, !st.face && st.dayFace, JSON.stringify(st));
|
|
123
|
+
await ctx.close();
|
|
124
|
+
}
|
|
125
|
+
/* H6 a phone */
|
|
126
|
+
{
|
|
127
|
+
const { ctx, page } = await open({ w: 390, h: 844, week: WEEK({ celebrate: null }) });
|
|
128
|
+
await until(() => page.evaluate(() => !!document.querySelector('#hmList [data-hm-impact]')), 30000);
|
|
129
|
+
await shot(page, 'home-face-phone');
|
|
130
|
+
await page.click('#hmList [data-hm-impact]');
|
|
131
|
+
const full = await until(() => page.evaluate(() => { const v = document.querySelector('#czViewer'); return v && !v.hidden && v.querySelectorAll('.im-row').length === 3 ? v.getBoundingClientRect().width : null; }));
|
|
132
|
+
ok('H6 a phone: the press opens the week full screen', full >= 380, String(full));
|
|
133
|
+
await shot(page, 'impact-week-phone');
|
|
134
|
+
await ctx.close();
|
|
135
|
+
}
|
|
136
|
+
/* B1 */
|
|
137
|
+
{
|
|
138
|
+
const { ctx, page, errors, posts } = await open({ url: '/premium-board.html' });
|
|
139
|
+
await until(() => page.evaluate(() => !!document.querySelector('#ibBody .ini2[data-key="board:self-serve-v2"]')), 30000);
|
|
140
|
+
await page.click('#ibBody .ini2[data-key="board:self-serve-v2"]');
|
|
141
|
+
const made = await until(() => page.evaluate(() => { const s = document.querySelector('#czViewer .im-made'); return s ? { head: s.querySelector('.im-mh b').textContent, people: [...s.querySelectorAll('.im-row b')].map((b) => b.textContent), links: [...s.querySelectorAll('a.im-ib')].map((a) => a.getAttribute('href')), buttons: s.querySelectorAll('button').length, text: s.innerText } : null; }), 15000);
|
|
142
|
+
ok('B1 the Board: "Self-serve launch delivered on …", then who made it happen, by name, each with a ticket to open', made && /^Self-serve launch delivered on [A-Z][a-z]{2} \d{1,2}\.$/.test(made.head) && made.people.join(',') === 'Chen,Lee,Suhas' && made.links[0] === 'https://acme.atlassian.net/browse/SS-12', JSON.stringify(made));
|
|
143
|
+
ok('B1 private: no press in the section at all (no thanks, no send), and the lock line', made && made.buttons === 0 && /Only you see this\. Nothing leaves PMOS\./.test(made.text));
|
|
144
|
+
await shot(page, 'board-made');
|
|
145
|
+
ok('N Board: no send, no page error', !posts.some((p) => /slack|mail|outbox|share|send/i.test(p)) && !errors.length, JSON.stringify({ posts, errors }));
|
|
146
|
+
await ctx.close();
|
|
147
|
+
}
|
|
148
|
+
return finish();
|
|
149
|
+
})();
|
|
@@ -158,7 +158,7 @@ const FINDING = { id: 'rf-0123456789', name: 'Partner numbers to Lee', why: 'You
|
|
|
158
158
|
await vClose(p);
|
|
159
159
|
|
|
160
160
|
/* ── G: a key result's Viewer carries the press ── */
|
|
161
|
-
await p.click('#goalTbl .
|
|
161
|
+
await p.click('#goalTbl .okr-main');
|
|
162
162
|
const gp = await until(() => p.evaluate(() => { const b = document.querySelector('#czViewer:not([hidden]) [data-cz-vw-p="report"]'); return b ? { label: b.getAttribute('aria-label'), text: b.textContent.trim() } : null; }), 4000);
|
|
163
163
|
ok('G a key result\'s Viewer has the report icon', !!gp && gp.label === 'Make a report from this' && !gp.text, JSON.stringify(gp));
|
|
164
164
|
if (gp) { await p.click('#czViewer [data-cz-vw-p="report"]'); await until(() => A.gets.some((g) => /^goal:/.test(g.scope)), 3000); ok('G it opens the draft for that one goal', A.gets.some((g) => /^goal:/.test(g.scope))); }
|
|
@@ -82,13 +82,15 @@ const WEEKLY = { view: 'view', weeks: 3, day: 'Mon', opens: 4 };
|
|
|
82
82
|
});
|
|
83
83
|
await page.route('**/api/report-setups?*', (r) => json(r, { setups: [], findings: [], asks: [], finder: {} }));
|
|
84
84
|
await page.goto(BASE + '/premium-intelligence.html');
|
|
85
|
-
await until(() => page.evaluate(() => document.querySelectorAll('#goalTbl .ins-row').length > 0), 20000);
|
|
85
|
+
await until(() => page.evaluate(() => document.querySelectorAll('#goalTbl .okr-row, #goalTbl .ins-row').length > 0), 20000);
|
|
86
86
|
return { page, ctx: c, errors, posts, st };
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
/* ── S: the strip's drafted move ── */
|
|
90
90
|
const A = await open();
|
|
91
91
|
const p = A.page;
|
|
92
|
+
// the ✦ line about the goals comes first (batch 16 item 6, GsM1–M5); the finding with its drafted move is the next page
|
|
93
|
+
await until(() => p.evaluate(() => !!document.querySelector('#insPg [data-ins="1"]')), 5000); await p.click('#insPg [data-ins="1"]');
|
|
92
94
|
const s0 = await until(() => p.evaluate(() => { const m = document.querySelector('#insMv'); const b = document.querySelector('#insAct [data-mv="apply"]'); return m && !m.hidden && b ? { mv: m.textContent, label: b.getAttribute('aria-label'), text: b.textContent.trim(), solid: b.classList.contains('solid'), two: document.querySelector('#insHero').classList.contains('mv') } : null; }), 5000);
|
|
93
95
|
ok('S the drafted move is said under the finding, with a solid ✓ that is icon-only', !!s0 && s0.mv === MOVE.text && s0.label === MOVE.label && !s0.text && s0.solid && s0.two, JSON.stringify(s0));
|
|
94
96
|
await shot(p, 'gap1-strip-move', '#insHero');
|
|
@@ -113,18 +115,19 @@ const WEEKLY = { view: 'view', weeks: 3, day: 'Mon', opens: 4 };
|
|
|
113
115
|
await shot(p, 'gap3-strip-weekly', '#insHero');
|
|
114
116
|
|
|
115
117
|
/* ── E: a drafted metric edited in place ── */
|
|
116
|
-
|
|
117
|
-
await p.
|
|
118
|
-
|
|
118
|
+
// a drafted North Star is the North Star card's hollow row now (batch 16 item 6), its ✎ beside its ✓
|
|
119
|
+
await until(() => p.evaluate(() => !!document.querySelector('#nsRow [data-okd="edit"][data-row="md-ns"]')), 4000);
|
|
120
|
+
await p.click('#nsRow [data-okd="edit"][data-row="md-ns"]');
|
|
121
|
+
const e0 = await p.evaluate(() => { const r = document.querySelector('[data-dred="md-ns"]'); return r ? { f: [...r.querySelectorAll('[data-drf]')].map((x) => x.dataset.drf + '=' + x.value), acts: [...r.querySelectorAll('.acts a, .acts button')].map((b) => b.getAttribute('aria-label') + (b.textContent.trim() ? '!' : '')), focus: document.activeElement && document.activeElement.dataset.drf } : null; });
|
|
119
122
|
ok('E ✎ turns the row 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'
|
|
120
123
|
&& e0.acts.join() === 'Ask Claude in Home to change something else,Cancel the edit,Save Weekly signed-in shoppers' && e0.focus === 'name', JSON.stringify(e0));
|
|
121
|
-
await shot(p, 'gap2-draft-edit', '#
|
|
124
|
+
await shot(p, 'gap2-draft-edit', '#nsRow');
|
|
122
125
|
await p.keyboard.press('Escape');
|
|
123
|
-
ok('E Escape puts the row back', await until(() => p.evaluate(() => !document.querySelector('[data-dred]') && !!document.querySelector('#
|
|
124
|
-
await p.click('#
|
|
126
|
+
ok('E Escape puts the row back', await until(() => p.evaluate(() => !document.querySelector('[data-dred]') && !!document.querySelector('#nsRow [data-okd="edit"][data-row="md-ns"]')), 2000));
|
|
127
|
+
await p.click('#nsRow [data-okd="edit"][data-row="md-ns"]');
|
|
125
128
|
await p.fill('[data-dred="md-ns"] [data-drf="name"]', 'Weekly shoppers');
|
|
126
129
|
await p.fill('[data-dred="md-ns"] [data-drf="target"]', '48000');
|
|
127
|
-
await p.click('[data-dred="md-ns"] [data-
|
|
130
|
+
await p.click('[data-dred="md-ns"] [data-okd="save"]');
|
|
128
131
|
const ed = await until(() => A.posts.find((x) => x.path === '/api/metric-drafts/edit'), 3000);
|
|
129
132
|
ok('E ✓ posts the edit with what was typed', !!ed && ed.body.row === 'md-ns' && ed.body.name === 'Weekly shoppers' && ed.body.target === '48000' && ed.body.source === 'Amplitude' && ed.body.scope === 'product', JSON.stringify(ed));
|
|
130
133
|
|
|
@@ -153,12 +156,13 @@ const WEEKLY = { view: 'view', weeks: 3, day: 'Mon', opens: 4 };
|
|
|
153
156
|
|
|
154
157
|
/* ── T: the type scale ── */
|
|
155
158
|
const SCALE = new Set(['11px', '12px', '14px', '16px', '20px', '28px']);
|
|
156
|
-
const sizes = await p.evaluate(() => [...new Set([...document.querySelectorAll('#insHero, #insHero *, #
|
|
159
|
+
const sizes = await p.evaluate(() => [...new Set([...document.querySelectorAll('#insHero, #insHero *, #nsRow, #nsRow *')].filter((e) => e.childNodes.length && [...e.childNodes].some((n) => n.nodeType === 3 && n.textContent.trim())).map((e) => getComputedStyle(e).fontSize))]);
|
|
157
160
|
ok('T the strip and the drafts use the type scale only', sizes.every((s) => SCALE.has(s)), sizes.join());
|
|
158
161
|
ok('no page errors', !A.errors.length, A.errors.join(' | '));
|
|
159
162
|
|
|
160
163
|
/* ── M: on a phone ── */
|
|
161
164
|
const B = await open({ w: 390, h: 844 });
|
|
165
|
+
await until(() => B.page.evaluate(() => !!document.querySelector('#insPg [data-ins="1"]')), 5000); await B.page.click('#insPg [data-ins="1"]');
|
|
162
166
|
const m = await until(() => B.page.evaluate(() => { const m0 = document.querySelector('#insMv'); return m0 && !m0.hidden && !!document.querySelector('#insAct [data-mv="apply"]'); }), 5000);
|
|
163
167
|
ok("M on a phone the move and its ✓ show, the move in full", !!m && await B.page.evaluate(() => { const r = document.querySelector("#insMv").getBoundingClientRect(), t = document.querySelector("#insText").getBoundingClientRect(); return r.height > 0 && r.bottom <= t.bottom + 1; }));
|
|
164
168
|
ok('M no sideways scroll', await B.page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth + 1));
|
|
@@ -9,7 +9,7 @@ const T = require('./trust/outbox.js');
|
|
|
9
9
|
const { checkReport } = require('./trust/trust.js');
|
|
10
10
|
const RULES = require('./trust/claim-rules.json');
|
|
11
11
|
|
|
12
|
-
const CHANNELS = ['jira-write', 'calendar-hold', 'customer-note'];
|
|
12
|
+
const CHANNELS = ['jira-write', 'calendar-hold', 'customer-note', 'team-note']; // team-note: a note to a teammate (batch 16 item 6: the thankful chase to a goal's owner)
|
|
13
13
|
const ORIGINS = ['agent', 'pm'];
|
|
14
14
|
const SENDERS = {}; // channel -> function. Empty on purpose.
|
|
15
15
|
const BASES = Object.keys(RULES.basis);
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* EVENTS. Every line is written by scripts/trust/ledger.js append (the PM's validated writer; this file has no appender of
|
|
11
11
|
* its own). A line is { id (ULID), kind: 'add'|'edit'|'reading', rid, fields, why, by, via }.
|
|
12
12
|
* add creates record `rid` with `fields` edit merges `fields` into it (latest edit wins per field)
|
|
13
|
-
* reading (kr-metrics only) one actual reading { at, value } of the KR metric `rid
|
|
13
|
+
* reading (kr-metrics only) one actual reading { at, value } of the KR metric `rid`, with where it was read when the caller knows it:
|
|
14
|
+
* source (one line: "Amplitude · checkout_login_success / checkout_view"), via (run | csv | pm), read_at (ISO time of the read)
|
|
14
15
|
* The actor comes from the call path (ledger.actorFrom), never from a field.
|
|
15
16
|
*
|
|
16
17
|
* LINKS. ideas, hypotheses, decisions and bets carry `initiative` (initiative id) and `parent_kr`; signals link by those.
|
|
@@ -66,7 +67,11 @@ function fold(kind, lines) {
|
|
|
66
67
|
if (!e || !e.rid) continue;
|
|
67
68
|
if (e.kind === 'add') by.set(e.rid, { rid: e.rid, ...e.fields, created: e.id, updated: e.id, readings: [] });
|
|
68
69
|
else if (e.kind === 'edit' && by.has(e.rid)) Object.assign(by.get(e.rid), e.fields, { updated: e.id });
|
|
69
|
-
else if (e.kind === 'reading' && by.has(e.rid) && e.fields)
|
|
70
|
+
else if (e.kind === 'reading' && by.has(e.rid) && e.fields) {
|
|
71
|
+
const x = { at: e.fields.at, value: e.fields.value };
|
|
72
|
+
for (const k of PROVENANCE) if (typeof e.fields[k] === 'string' && e.fields[k]) x[k] = e.fields[k];
|
|
73
|
+
by.get(e.rid).readings.push(x);
|
|
74
|
+
}
|
|
70
75
|
}
|
|
71
76
|
const out = [...by.values()];
|
|
72
77
|
if (kind !== 'kr-metrics') out.forEach((r) => delete r.readings);
|
|
@@ -98,10 +103,13 @@ function edit(root, kind, rid, fields, actor, why) {
|
|
|
98
103
|
if (!v.ok) return { ok: false, reasons: v.reasons };
|
|
99
104
|
return write(root, kind, { kind: 'edit', rid, fields, why: why || 'edited' }, actor);
|
|
100
105
|
}
|
|
106
|
+
const PROVENANCE = ['source', 'via', 'read_at'];
|
|
101
107
|
function addReading(root, rid, reading, actor, why) {
|
|
102
108
|
if (!reading || !DATE.test(String(reading.at)) || !num(reading.value)) return { ok: false, reasons: ['a reading needs at (YYYY-MM-DD) and value (number)'] };
|
|
103
109
|
if (!list(root, 'kr-metrics').some((r) => r.rid === rid)) return { ok: false, reasons: ['no such KR metric: ' + rid] };
|
|
104
|
-
|
|
110
|
+
const fields = { at: reading.at, value: reading.value };
|
|
111
|
+
for (const k of PROVENANCE) if (typeof reading[k] === 'string' && reading[k].trim()) fields[k] = reading[k].replace(/\s+/g, ' ').trim().slice(0, 200);
|
|
112
|
+
return write(root, 'kr-metrics', { kind: 'reading', rid, fields, why: why || 'reading' }, actor);
|
|
105
113
|
}
|
|
106
114
|
|
|
107
115
|
/** All five folds for nineStages and readRepoFacts. Missing files give empty lists. */
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* goal-status.js — THE ONE STATUS of a goal, from its readings (feedback batch 16 item 6, "Claude runs the OKRs", gap 2). Intelligence's goal list,
|
|
3
|
+
* the goal Viewer and the product page's Goals line all read it from here, so a goal says the same thing everywhere. PURE: no I/O and no clock of
|
|
4
|
+
* its own; `today` (YYYY-MM-DD) comes in. Initiative delivery status never sets a goal's dot: only a reading does.
|
|
5
|
+
*
|
|
6
|
+
* readingOf(rec, today) → { dot, at, ageDays, stale, txt, line, value, source, via } one kr-metrics record (scripts/records fold)
|
|
7
|
+
* dot on the latest reading is on its line (or reached, or a limit with room left)
|
|
8
|
+
* behind behind the straight line from baseline to target by the early-warning share (10% of the span) or more
|
|
9
|
+
* close a limit goal inside its close band: within the limit, near it
|
|
10
|
+
* broken a limit goal over its ceiling (under its floor)
|
|
11
|
+
* none no reading yet: a hollow dot and no status
|
|
12
|
+
* stale the reading is older than its cadence allows (daily 3 days, weekly 14, monthly 45; 14 with no recipe). A stale reading keeps its
|
|
13
|
+
* dot and says its age.
|
|
14
|
+
* isLimit(rec) · bandOf(rec) · staleDays(rec) · CADENCE_DAYS
|
|
15
|
+
* whoOf(rec) → { name, initials, from: jira | pm } | null the goal's owner
|
|
16
|
+
* summaryOf(goals) → { on, behind: [title], broken: [title], close: [title], none, dots: [{ id, title, dot }], line } the product page
|
|
17
|
+
* lineOf(o) → { head, sub, tone: calm | behind | crit | drafts, keepAll } the ✦ line. o: { goals, drafts, alert, today }
|
|
18
|
+
* metricsOf(goals) → [{ id, title, meta, dot, role, parent }] Intelligence ⋯ › Metrics: goal metrics first, then the watched ones
|
|
19
|
+
* ownerFixes(goals, ws) → [fix input] an owner for a goal with none: the person who holds the most of the work anchored to it (Jira)
|
|
20
|
+
* chaseFixes(goals) → [fix input] a goal behind with an owner: a thankful note to the owner, sent only on the PM's ✓
|
|
21
|
+
* ticketFixes(goals) → [fix input] a broken limit: the drafted rollback (tracking) ticket for its owner
|
|
22
|
+
* noun(n, one, many)
|
|
23
|
+
*
|
|
24
|
+
* NOTHING HERE MAKES A NUMBER UP. A reading is a value a record holds; the line is the straight line from baseline to target; a band is the record's
|
|
25
|
+
* own close_band, else a tenth of the room between the baseline and the limit, said as that. */
|
|
26
|
+
|
|
27
|
+
const EARLY = 0.10; // the repository's early-warning share (scripts/calendar-model.js EARLY_WARNING, lib/routes-c3-strategy.js)
|
|
28
|
+
const CADENCE_DAYS = Object.freeze({ daily: 3, weekly: 14, monthly: 45 });
|
|
29
|
+
const NO_RECIPE_DAYS = 14;
|
|
30
|
+
const DAY = 864e5;
|
|
31
|
+
const fin = (v) => typeof v === 'number' && Number.isFinite(v);
|
|
32
|
+
const ms = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? Date.UTC(+m[1], +m[2] - 1, +m[3]) : null; };
|
|
33
|
+
const r2 = (v) => Math.round(v * 100) / 100;
|
|
34
|
+
const num = (v, unit) => { const u = String(unit || '').trim(), s = String(r2(v)); return u ? (/^[A-Za-z]/.test(u) ? s + ' ' + u : s + u) : s; };
|
|
35
|
+
const clip = (s, n) => { s = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
36
|
+
const noun = (n, one, many) => n + ' ' + (n === 1 ? one : many);
|
|
37
|
+
const first = (s) => String(s || '').trim().split(/\s+/)[0] || '';
|
|
38
|
+
const lower1 = (s) => (s ? s[0].toLowerCase() + s.slice(1) : s);
|
|
39
|
+
|
|
40
|
+
/** A goal that must stay within a limit: the record says so (type Stay within, or a limit), or it is a guardrail with a limit. */
|
|
41
|
+
const isLimit = (rec) => !!rec && (rec.type === 'Stay within' || rec.limit === 'ceiling' || rec.limit === 'floor');
|
|
42
|
+
const ceilingOf = (rec) => (rec.limit === 'floor' ? false : rec.limit === 'ceiling' ? true : !(fin(Number(rec.target)) && fin(Number(rec.baseline)) && Number(rec.target) > Number(rec.baseline)));
|
|
43
|
+
/** The close band of a limit: the record's own, else a tenth of the room between baseline and limit (a tenth of the limit when they are equal). */
|
|
44
|
+
function bandOf(rec) {
|
|
45
|
+
if (fin(Number(rec.close_band)) && Number(rec.close_band) > 0) return Number(rec.close_band);
|
|
46
|
+
const lim = Number(rec.target), base = Number(rec.baseline);
|
|
47
|
+
if (!fin(lim)) return 0;
|
|
48
|
+
const room = fin(base) ? Math.abs(lim - base) : 0;
|
|
49
|
+
return room > 0 ? room * EARLY : Math.abs(lim) * EARLY;
|
|
50
|
+
}
|
|
51
|
+
const staleDays = (rec) => CADENCE_DAYS[rec && rec.recipe && rec.recipe.cadence] || NO_RECIPE_DAYS;
|
|
52
|
+
const readingsOf = (rec) => ((rec && rec.readings) || []).filter((x) => x && fin(Number(x.value)) && ms(x.at) !== null)
|
|
53
|
+
.map((x) => ({ ...x, at: String(x.at).slice(0, 10), value: Number(x.value) })).sort((a, b) => a.at.localeCompare(b.at));
|
|
54
|
+
|
|
55
|
+
function readingOf(rec, today) {
|
|
56
|
+
const rs = readingsOf(rec), t = ms(today);
|
|
57
|
+
if (!rs.length) return { dot: 'none', at: null, ageDays: null, stale: false, txt: '', line: '', value: null, source: '', via: '' };
|
|
58
|
+
const last = rs[rs.length - 1], v = last.value, u = rec.unit || '';
|
|
59
|
+
const ageDays = t !== null ? Math.max(0, Math.round((t - ms(last.at)) / DAY)) : null;
|
|
60
|
+
const out = { dot: 'on', at: last.at, ageDays, stale: ageDays !== null && ageDays > staleDays(rec), txt: num(v, u), line: '', value: v, source: last.source || '', via: last.via || '' };
|
|
61
|
+
const tgt = Number(rec.target), base = Number(rec.baseline);
|
|
62
|
+
if (isLimit(rec) && fin(tgt)) {
|
|
63
|
+
const ceil = ceilingOf(rec), band = bandOf(rec);
|
|
64
|
+
const over = ceil ? v > tgt : v < tgt, close = !over && (ceil ? v >= tgt - band : v <= tgt + band);
|
|
65
|
+
out.dot = over ? 'broken' : close ? 'close' : 'on';
|
|
66
|
+
out.line = (ceil ? 'limit ' : 'floor ') + num(tgt, u);
|
|
67
|
+
out.limit = tgt; out.band = r2(band); out.ceiling = ceil;
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
if (rec.type === 'Done or not' && fin(tgt)) {
|
|
71
|
+
const done = v >= tgt;
|
|
72
|
+
out.txt = done ? 'Done' : 'Not yet';
|
|
73
|
+
out.dot = done || ms(rec.by) === null || t === null || ms(rec.by) >= t ? 'on' : 'behind';
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
if (!fin(tgt) || !fin(base) || tgt === base || ms(rec.by) === null) { out.line = ''; return out; }
|
|
77
|
+
const dir = Math.sign(tgt - base);
|
|
78
|
+
out.txt = num(v, u) + ' of ' + num(tgt, u);
|
|
79
|
+
if ((v - tgt) * dir >= 0) { out.line = 'target reached'; return out; }
|
|
80
|
+
const t0 = ms(rec.start) !== null ? ms(rec.start) : ms(rs[0].at), t1 = ms(rec.by);
|
|
81
|
+
const frac = t1 > t0 && t !== null ? Math.max(0, Math.min(1, (t - t0) / (t1 - t0))) : 1;
|
|
82
|
+
const expected = base + (tgt - base) * frac, shortfall = (expected - v) / Math.abs(tgt - base) * dir;
|
|
83
|
+
out.line = 'its line says ' + num(Math.abs(expected) >= 10 ? Math.round(expected) : Math.round(expected * 10) / 10, u); // a pace in whole units from 10 up (lib/insights-premium.js)
|
|
84
|
+
out.expected = r2(expected);
|
|
85
|
+
out.dot = shortfall >= EARLY ? 'behind' : 'on';
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const initials = (name) => String(name || '').trim().split(/\s+/).filter(Boolean).slice(0, 2).map((w) => w[0].toUpperCase()).join('');
|
|
90
|
+
function whoOf(rec) {
|
|
91
|
+
const name = clip(rec && rec.owner, 60);
|
|
92
|
+
return name ? { name, initials: initials(name), from: rec.owner_from === 'jira' ? 'jira' : 'pm' } : null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** The product page's Goals line: "3 on their line · checkout sign-in is behind". goals: [{ id, title, reading }] */
|
|
96
|
+
function summaryOf(goals) {
|
|
97
|
+
const G = (goals || []).filter((g) => g && g.reading);
|
|
98
|
+
const by = (d) => G.filter((g) => g.reading.dot === d).map((g) => g.title);
|
|
99
|
+
const on = by('on').length, behind = by('behind'), broken = by('broken'), close = by('close'), none = by('none').length;
|
|
100
|
+
const parts = [];
|
|
101
|
+
if (on) parts.push(on + ' on ' + (on === 1 ? 'its line' : 'their line'));
|
|
102
|
+
for (const t of broken) parts.push(lower1(t) + ' broke its limit');
|
|
103
|
+
for (const t of behind) parts.push(lower1(t) + ' is behind');
|
|
104
|
+
for (const t of close) parts.push(lower1(t) + ' is close to its limit');
|
|
105
|
+
if (none) parts.push(noun(none, 'not read yet', 'not read yet'));
|
|
106
|
+
return { on, behind, broken, close, none, dots: G.map((g) => ({ id: g.id, title: g.title, dot: g.reading.dot })), line: parts.join(' · ') };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** The ✦ line: the one thing that matters this week. It never says there is no insight: with no readings it says what Claude drafted.
|
|
110
|
+
* o: { goals: [{ id, title, role, reading, who }], drafts: n open drafts, alert: { title, txt, line } | null, moved: { title, txt } | null } */
|
|
111
|
+
function lineOf(o = {}) {
|
|
112
|
+
const G = (o.goals || []).filter((g) => g && g.reading), drafts = Math.max(0, o.drafts || 0);
|
|
113
|
+
const keepAll = drafts > 1 ? drafts : 0;
|
|
114
|
+
const draftSub = drafts ? (drafts === 1 ? 'I drafted one fix under it.' : 'I drafted ' + drafts + ' fixes. Keep them all at once, or one by one.') : '';
|
|
115
|
+
if (o.alert) return { head: o.alert.title + ' broke its limit: ' + o.alert.txt + ' against its ' + o.alert.line + '.', sub: draftSub || 'I will say when it is back under.', tone: 'crit', keepAll };
|
|
116
|
+
const behind = G.filter((g) => g.reading.dot === 'behind');
|
|
117
|
+
if (behind.length) {
|
|
118
|
+
const g = behind[0];
|
|
119
|
+
return { head: g.title + ' is behind its line: ' + g.reading.txt + (g.reading.line ? ', ' + g.reading.line : '') + '.' + (behind.length > 1 ? ' ' + noun(behind.length - 1, 'other goal is', 'other goals are') + ' behind too.' : ''),
|
|
120
|
+
sub: draftSub || (g.who ? g.who.name + ' owns it.' : 'It has no owner yet.'), tone: 'behind', keepAll };
|
|
121
|
+
}
|
|
122
|
+
const read = G.filter((g) => g.reading.dot !== 'none');
|
|
123
|
+
if (!read.length) {
|
|
124
|
+
if (drafts) return { head: 'I drafted ' + noun(drafts, 'fix', 'fixes') + ' so every goal can be read.', sub: 'Keep them all at once, or one by one. I test-read each one first.', tone: 'drafts', keepAll };
|
|
125
|
+
return { head: G.length ? 'I have not read a goal yet. I read each one when it has a way to be read.' : 'This product has no goal yet. I draft a North Star when the next check runs.', sub: '', tone: 'drafts', keepAll: 0 };
|
|
126
|
+
}
|
|
127
|
+
if (drafts) return { head: 'I drafted ' + noun(drafts, 'fix', 'fixes') + ' for your goals.', sub: 'Keep them all at once, or one by one.', tone: 'drafts', keepAll };
|
|
128
|
+
const close = G.filter((g) => g.reading.dot === 'close');
|
|
129
|
+
if (close.length) return { head: close[0].title + ' is close to its limit: ' + close[0].reading.txt + ', ' + close[0].reading.line + '.', sub: 'I keep reading it. Nothing needs you yet.', tone: 'calm', keepAll: 0 };
|
|
130
|
+
if (o.moved) return { head: o.moved.head, sub: o.moved.sub, tone: 'calm', keepAll: 0 };
|
|
131
|
+
const stale = read.filter((g) => g.reading.stale);
|
|
132
|
+
return { head: read.length === G.length && !stale.length ? 'Every goal was read and is on its line. Nothing needs you.' : noun(read.length - stale.length, 'goal is', 'goals are') + ' read and on their line.',
|
|
133
|
+
sub: stale.length ? noun(stale.length, 'reading is', 'readings are') + ' old: ' + stale.map((g) => g.title).slice(0, 2).join(', ') + '.' : '', tone: 'calm', keepAll: 0 };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** When the North Star moved since its reading before, the input that moved the same way the most (relative to its own span). null when none did. */
|
|
137
|
+
function movedOf(goals) {
|
|
138
|
+
const ns = (goals || []).find((g) => g.role === 'north-star');
|
|
139
|
+
const step = (g) => { const s = g && g.series; if (!s || s.length < 2) return null; const a = s[s.length - 2].v, b = s[s.length - 1].v; return { d: b - a, rel: Math.abs(a) > 0 ? (b - a) / Math.abs(a) : 0 }; };
|
|
140
|
+
const n = step(ns); if (!n || n.d === 0) return null;
|
|
141
|
+
const ins = (goals || []).filter((g) => g.role === 'input').map((g) => ({ g, s: step(g) })).filter((x) => x.s && Math.sign(x.s.d) === Math.sign(n.d));
|
|
142
|
+
if (!ins.length) return null;
|
|
143
|
+
const top = ins.sort((a, b) => Math.abs(b.s.rel) - Math.abs(a.s.rel))[0];
|
|
144
|
+
const sign = (d, u) => (d > 0 ? '+' : '') + num(d, u);
|
|
145
|
+
return { head: ns.title + ' moved ' + sign(n.d, ns.unit) + ' since its last reading.', sub: top.g.title + ' moved the same way, ' + sign(top.s.d, top.g.unit) + '.' };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Intelligence ⋯ › Metrics: the goal metrics first (North Star, inputs, guardrails, key results, budgets), then what Claude only watches. */
|
|
149
|
+
const ORDER = ['north-star', 'input', 'guardrail', 'kr', 'budget', 'program-goal', 'rollup', 'success', 'signal', 'watch'];
|
|
150
|
+
function metricsOf(goals) {
|
|
151
|
+
const ns = (goals || []).find((g) => g.role === 'north-star');
|
|
152
|
+
return (goals || []).map((g) => {
|
|
153
|
+
const role = g.role === 'watch' ? 'watch' : g.budget ? 'budget' : g.role || 'kr';
|
|
154
|
+
const r = g.reading || { dot: 'none' };
|
|
155
|
+
const meta = [r.txt, r.at ? (r.ageDays === 0 ? 'today' : r.ageDays === 1 ? '1 day ago' : r.ageDays + ' days ago') : 'not read yet', g.recipe ? g.recipe.connector : ''].filter(Boolean).join(' · ');
|
|
156
|
+
return { id: g.id, title: g.title, meta, dot: role === 'watch' ? 'none' : r.dot, role, parent: (role === 'input' || role === 'guardrail') && ns ? ns.id : null };
|
|
157
|
+
}).sort((a, b) => ORDER.indexOf(a.role) - ORDER.indexOf(b.role));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* ── the fixes the goal watch drafts by itself, from the records alone: each is a cleanFix input (lib/metric-drafts.js), filed standing ── */
|
|
161
|
+
/** goals: [{ id, title, who, moves: [{ owner, title }] }]. The person who holds the most of the work anchored to a goal with no owner. Two with as
|
|
162
|
+
* many is a guess: none is drafted. */
|
|
163
|
+
function ownerFixes(goals) {
|
|
164
|
+
const out = [];
|
|
165
|
+
for (const g of goals || []) {
|
|
166
|
+
if (!g || g.who || g.role === 'watch') continue;
|
|
167
|
+
const n = new Map();
|
|
168
|
+
for (const m of g.moves || []) if (m && m.owner) n.set(m.owner, (n.get(m.owner) || 0) + 1);
|
|
169
|
+
const top = [...n.entries()].sort((a, b) => b[1] - a[1]);
|
|
170
|
+
if (!top.length || (top[1] && top[1][1] === top[0][1])) continue;
|
|
171
|
+
const [name, k] = top[0], all = (g.moves || []).length;
|
|
172
|
+
out.push({ kind: 'owner', goal: g.id, text: name + ' owns ' + clip(g.title, 80) + '.', why: name + ' is the assignee of ' + k + ' of the ' + noun(all, 'initiative', 'initiatives') + ' that move it (Jira).', owner: { name, from: 'jira' } });
|
|
173
|
+
}
|
|
174
|
+
return out;
|
|
175
|
+
}
|
|
176
|
+
/** A goal behind its line with an owner: a thankful note that names the reading. It goes only on the PM's ✓, and then only to the outbox. */
|
|
177
|
+
function chaseFixes(goals) {
|
|
178
|
+
const out = [];
|
|
179
|
+
for (const g of goals || []) {
|
|
180
|
+
if (!g || !g.who || !g.reading || g.reading.dot !== 'behind') continue;
|
|
181
|
+
const body = 'Hi ' + first(g.who.name) + ', thank you for the work on ' + clip(g.title, 80) + '. It reads ' + g.reading.txt + (g.reading.line ? ' and ' + g.reading.line : '') + ' on '
|
|
182
|
+
+ g.reading.at + '. What would help it catch up? I can take anything off your plate that is not yours to carry.';
|
|
183
|
+
out.push({ kind: 'chase', goal: g.id, to: g.who.name, body, text: 'Thank ' + g.who.name + ' and ask what would help ' + clip(g.title, 60) + ' catch up.', why: 'It reads ' + g.reading.txt + ', ' + (g.reading.line || 'behind its line') + '.' });
|
|
184
|
+
}
|
|
185
|
+
return out;
|
|
186
|
+
}
|
|
187
|
+
/** A limit that broke: the rollback (tracking) ticket for its owner, sent to Jira only on the PM's ✓. */
|
|
188
|
+
function ticketFixes(goals) {
|
|
189
|
+
const out = [];
|
|
190
|
+
for (const g of goals || []) {
|
|
191
|
+
if (!g || !g.reading || g.reading.dot !== 'broken') continue;
|
|
192
|
+
const who = g.who ? g.who.name : 'the owner';
|
|
193
|
+
out.push({ kind: 'ticket', goal: g.id, text: 'Send ' + who + ' a ticket to roll back or fix what broke ' + clip(g.title, 60) + '.', why: 'It reads ' + g.reading.txt + ' against its ' + g.reading.line + ' on ' + g.reading.at + '.',
|
|
194
|
+
ticket: { title: clip(g.title, 80) + ' is over its limit', text: clip(g.title, 80) + ' read ' + g.reading.txt + ' on ' + g.reading.at + ', past its ' + g.reading.line + (g.reading.source ? ' (' + g.reading.source + ')' : '') + '. Roll back the last change that moved it, or fix it, and say which.' } });
|
|
195
|
+
}
|
|
196
|
+
return out;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
module.exports = { EARLY, CADENCE_DAYS, NO_RECIPE_DAYS, readingOf, readingsOf, isLimit, bandOf, staleDays, whoOf, summaryOf, lineOf, movedOf, metricsOf, ownerFixes, chaseFixes, ticketFixes, noun, initials };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* goal-watch.js — what happens around a reading (feedback batch 16 item 6, gaps 7 and 8): the limit alert, the bell, and the fixes Claude files by
|
|
3
|
+
* itself from the records alone (an owner, a thankful chase note, a rollback ticket). The I/O around the pure parts in lib/goal-status.js,
|
|
4
|
+
* lib/metric-reads.js and lib/metric-drafts.js. Nothing here is sent: a chase or a ticket is a draft until the PM's ✓, and then it waits in the outbox.
|
|
5
|
+
*
|
|
6
|
+
* afterRead(o) o: { dir, ws, records, rids, today, at, tell(rec, reading) } after readings of `rids` landed (a run ended, a CSV, a typed reading):
|
|
7
|
+
* for each limit goal, open the episode when it breaks (ONE bell line when its notify is push: the push) and close it when it is back;
|
|
8
|
+
* a goal that reads again clears its standing connect and recipe fixes. → [{ kind: broke | back, rid }]
|
|
9
|
+
* syncFixes(o) o: { dir, ws, goals, at } the owner, chase and ticket fixes the goals call for now (lib/goal-status.js), filed standing (src
|
|
10
|
+
* watch) when new; a standing watch fix whose reason is gone is cleared. A fix the PM kept or dropped is never filed again.
|
|
11
|
+
* → { filed, cleared }
|
|
12
|
+
* historyOf(lines, rid) → [{ at, text }] the record's own ledger: what Claude changed and what the PM kept (newest first, at most 12)
|
|
13
|
+
*/
|
|
14
|
+
const MD = require('./metric-drafts.js');
|
|
15
|
+
const MR = require('./metric-reads.js');
|
|
16
|
+
const GS = require('./goal-status.js');
|
|
17
|
+
|
|
18
|
+
function afterRead(o) {
|
|
19
|
+
const out = [];
|
|
20
|
+
if (!o || !o.dir) return out;
|
|
21
|
+
const F = MR.read(o.dir), D = MD.read(o.dir).scopes.get(MD.keyOf('product', o.ws));
|
|
22
|
+
for (const rid of o.rids || []) {
|
|
23
|
+
const rec = (o.records || []).find((r) => r && r.rid === rid && r.retired !== true); if (!rec) continue;
|
|
24
|
+
const reading = GS.readingOf(rec, o.today);
|
|
25
|
+
if (GS.isLimit(rec)) {
|
|
26
|
+
const step = MR.alertStep(F, rid, reading);
|
|
27
|
+
if (step) {
|
|
28
|
+
MR.append(o.dir, null, step, o.at);
|
|
29
|
+
out.push({ kind: step.kind, rid });
|
|
30
|
+
if (step.kind === 'broke' && (rec.notify || 'intel') === 'push' && typeof o.tell === 'function') { try { o.tell(rec, reading); } catch { /* the line on Intelligence still says it */ } }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const x = F.rids.get(rid);
|
|
34
|
+
if (D && reading.dot !== 'none' && x && x.last && x.last.ok) for (const r of D.rows.values()) {
|
|
35
|
+
if (r.state === 'open' && r.standing === 'read' && r.goal === rid && (r.kind === 'connect' || r.kind === 'recipe')) MD.append(o.dir, null, { kind: 'clear', scope: 'product', id: o.ws, row: r.id }, o.at);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function syncFixes(o) {
|
|
42
|
+
const res = { filed: 0, cleared: 0 };
|
|
43
|
+
if (!o || !o.dir || !o.ws) return res;
|
|
44
|
+
const goals = (o.goals || []).filter((g) => g && g.role !== 'watch');
|
|
45
|
+
const want = [...GS.ownerFixes(goals), ...GS.chaseFixes(goals), ...GS.ticketFixes(goals)].map((x) => MD.cleanFix('product', o.ws, x)).filter((c) => c.row).map((c) => c.row);
|
|
46
|
+
const S = MD.read(o.dir).scopes.get(MD.keyOf('product', o.ws));
|
|
47
|
+
const ids = new Set(want.map((r) => r.id));
|
|
48
|
+
for (const row of want) {
|
|
49
|
+
const was = S && S.rows.get(row.id);
|
|
50
|
+
if (was) continue; // open already, or the PM answered it: filed once
|
|
51
|
+
MD.append(o.dir, null, { kind: 'fix', scope: 'product', id: o.ws, row, src: 'watch' }, o.at); res.filed++;
|
|
52
|
+
}
|
|
53
|
+
if (S) for (const r of S.rows.values()) if (r.state === 'open' && r.standing === 'watch' && !ids.has(r.id)) { MD.append(o.dir, null, { kind: 'clear', scope: 'product', id: o.ws, row: r.id }, o.at); res.cleared++; }
|
|
54
|
+
return res;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The ULID of a records line carries its time (scripts/trust/ledger.js newId): the first 10 characters, base 32. */
|
|
58
|
+
const B = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
|
|
59
|
+
const timeOf = (id) => { let t = 0; for (const c of String(id || '').slice(0, 10)) { const k = B.indexOf(c); if (k < 0) return null; t = t * 32 + k; } return t ? new Date(t).toISOString() : null; };
|
|
60
|
+
function historyOf(lines, rid) {
|
|
61
|
+
const out = [];
|
|
62
|
+
for (const l of lines || []) {
|
|
63
|
+
if (!l || l.rid !== rid || l.kind === 'reading') continue;
|
|
64
|
+
const who = String(l.by || '').startsWith('human:') ? 'You' : 'Claude';
|
|
65
|
+
const what = l.kind === 'add' ? 'added it' : 'changed ' + Object.keys(l.fields || {}).filter((k) => k !== 'retired').join(', ');
|
|
66
|
+
out.push({ at: timeOf(l.id), text: who + ' ' + what + (l.why ? ': ' + String(l.why).slice(0, 120) : '') });
|
|
67
|
+
}
|
|
68
|
+
return out.reverse().slice(0, 12);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = { afterRead, syncFixes, historyOf, timeOf };
|