create-pmos 0.674.0 → 0.676.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 +33 -39
- 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/changelog.json +32 -0
- package/workspace/lib/mention-store.js +78 -3
- package/workspace/lib/metric-drafts.js +1 -0
- package/workspace/lib/metric-read-runs.js +23 -2
- package/workspace/lib/metric-source.js +86 -0
- package/workspace/lib/task-jira.js +3 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/skills/metric-draft.skill +3 -2
- package/workspace/test-lists/metric-source.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.676.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -33,6 +33,38 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.676.0",
|
|
38
|
+
"at": "2026-11-22T06:16:08.626Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1464,
|
|
43
|
+
"t": "An ask marked Done in Today stays done, re-worded copies included",
|
|
44
|
+
"s": "An ask marked Done in Today stays done, re-worded copies included",
|
|
45
|
+
"k": "fix"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"n": 1458,
|
|
49
|
+
"t": "A task Jira closed carries the resolution day as its finish day",
|
|
50
|
+
"s": "A task Jira closed carries the resolution day as its finish day",
|
|
51
|
+
"k": "new"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"v": "0.675.0",
|
|
57
|
+
"at": "2026-11-22T05:53:46.914Z",
|
|
58
|
+
"f": 4,
|
|
59
|
+
"prs": [
|
|
60
|
+
{
|
|
61
|
+
"n": 1460,
|
|
62
|
+
"t": "Read one goal metric per product from the query its source names",
|
|
63
|
+
"s": "Read one goal metric per product from the query its source names",
|
|
64
|
+
"k": "new"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
36
68
|
{
|
|
37
69
|
"v": "0.674.0",
|
|
38
70
|
"at": "2026-11-22T05:18:00.036Z",
|
|
@@ -338,44 +370,6 @@
|
|
|
338
370
|
"k": "new"
|
|
339
371
|
}
|
|
340
372
|
]
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
"v": "0.643.0",
|
|
344
|
-
"at": "2026-11-20T02:02:59.828Z",
|
|
345
|
-
"f": 4,
|
|
346
|
-
"prs": [
|
|
347
|
-
{
|
|
348
|
-
"n": 1425,
|
|
349
|
-
"t": "The Work page moves to the PMOS design system",
|
|
350
|
-
"s": "The Work page moves to the PMOS design system",
|
|
351
|
-
"k": "new"
|
|
352
|
-
}
|
|
353
|
-
]
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
"v": "0.642.0",
|
|
357
|
-
"at": "2026-11-20T01:43:00.385Z",
|
|
358
|
-
"f": 4,
|
|
359
|
-
"prs": [
|
|
360
|
-
{
|
|
361
|
-
"n": 1423,
|
|
362
|
-
"t": "Welcome, capture and the meeting pages on the PMOS design system",
|
|
363
|
-
"s": "Welcome, capture and the meeting pages on the PMOS design system",
|
|
364
|
-
"k": "new"
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
"n": 1420,
|
|
368
|
-
"t": "The rail of places is the design system's Navigation part",
|
|
369
|
-
"s": "The rail of places is the design system's Navigation part",
|
|
370
|
-
"k": "new"
|
|
371
|
-
},
|
|
372
|
-
{
|
|
373
|
-
"n": 1421,
|
|
374
|
-
"t": "Library, Present and the Viewer page on the PMOS design system",
|
|
375
|
-
"s": "Library, Present and the Viewer page on the PMOS design system",
|
|
376
|
-
"k": "new"
|
|
377
|
-
}
|
|
378
|
-
]
|
|
379
373
|
}
|
|
380
374
|
]
|
|
381
375
|
}
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T06:16:05Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T06:16:05Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T06:16:05Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.676.0",
|
|
4
|
+
"at": "2026-11-22T06:16:08.626Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1464,
|
|
9
|
+
"t": "An ask marked Done in Today stays done, re-worded copies included",
|
|
10
|
+
"s": "An ask marked Done in Today stays done, re-worded copies included",
|
|
11
|
+
"k": "fix"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"n": 1458,
|
|
15
|
+
"t": "A task Jira closed carries the resolution day as its finish day",
|
|
16
|
+
"s": "A task Jira closed carries the resolution day as its finish day",
|
|
17
|
+
"k": "new"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"v": "0.675.0",
|
|
23
|
+
"at": "2026-11-22T05:53:46.914Z",
|
|
24
|
+
"f": 4,
|
|
25
|
+
"prs": [
|
|
26
|
+
{
|
|
27
|
+
"n": 1460,
|
|
28
|
+
"t": "Read one goal metric per product from the query its source names",
|
|
29
|
+
"s": "Read one goal metric per product from the query its source names",
|
|
30
|
+
"k": "new"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
2
34
|
{
|
|
3
35
|
"v": "0.674.0",
|
|
4
36
|
"at": "2026-11-22T05:18:00.036Z",
|
|
@@ -479,6 +479,49 @@ function convRow(id, list, j, mk, reads, now, me) {
|
|
|
479
479
|
return r;
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
+
/* ── the same ask in other words ── */
|
|
483
|
+
const ASK_STOP = new Set(['the', 'and', 'for', 'you', 'your', 'ask', 'asks', 'whether', 'does', 'did', 'can', 'could', 'what', 'when', 'with', 'that', 'this',
|
|
484
|
+
'from', 'pm', 'is', 'are', 'be', 'to', 'of', 'on', 'or', 'in', 'a', 'an', 'it', 'its', 'if', 'by', 'at', 'as', 'do', 'say', 'says', 'yes', 'no', 'not', 'please',
|
|
485
|
+
'need', 'needs', 'needed', 'has', 'have', 'had', 'been', 'was', 'were', 'wawan', 'will', 'would', 'should', 'there', 'their', 'they', 'them', 'any', 'some', 'about', 'which', 'who', 'how', 'why', 'since']);
|
|
486
|
+
/** The words that carry an ask: lower case, no small words, a plain stem ("numbers" and "number" are one word). Pure. */
|
|
487
|
+
function askTokens(t) {
|
|
488
|
+
const out = new Set();
|
|
489
|
+
for (let w of String(t || '').toLowerCase().replace(/[^\p{L}\p{N}\s]+/gu, ' ').split(/\s+/)) {
|
|
490
|
+
if (w.length < 2 || ASK_STOP.has(w)) continue;
|
|
491
|
+
if (w.length > 4) w = w.replace(/(?:ing|ed|es|s)$/, ''); else if (w.length > 3) w = w.replace(/s$/, '');
|
|
492
|
+
if (w.length >= 2 && !ASK_STOP.has(w)) out.add(w);
|
|
493
|
+
}
|
|
494
|
+
return out;
|
|
495
|
+
}
|
|
496
|
+
/** Two asks say the same thing in other words: at least two carrying words shared, and most of the shorter ask's words. Pure.
|
|
497
|
+
* "Does the microsite need KB numbers" and "Yes or no on KB numbers for the microsite" are one ask. */
|
|
498
|
+
function sameAskLoose(a, b) {
|
|
499
|
+
const A = askTokens(a), B = askTokens(b);
|
|
500
|
+
if (!A.size || !B.size) return false;
|
|
501
|
+
let n = 0; for (const w of A) if (B.has(w)) n++;
|
|
502
|
+
return n >= 2 && n / Math.min(A.size, B.size) >= 0.6;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/** The PM's Done on an ask in Today's log (POST /api/today-log/mark, key 'mn:<conversation id>') is the PM covering that ask: Done
|
|
506
|
+
* holds a day in the log, so without this the ask came back the next morning. The last done or undone of a key wins; done reads as
|
|
507
|
+
* Mark answered at the time it was pressed. lines: today-log/log.jsonl. → mention marks. Pure. */
|
|
508
|
+
function todayDoneMarks(lines) {
|
|
509
|
+
const last = new Map();
|
|
510
|
+
for (const ev of lines || []) {
|
|
511
|
+
if (!ev || ev.event !== 'mark' || (ev.act !== 'done' && ev.act !== 'undone')) continue;
|
|
512
|
+
const m = /^mn:([0-9a-f]{12})$/.exec(String(ev.key || '')); if (!m) continue;
|
|
513
|
+
last.set(m[1], ev);
|
|
514
|
+
}
|
|
515
|
+
const out = [];
|
|
516
|
+
for (const [id, ev] of last) {
|
|
517
|
+
if (ev.act !== 'done') continue;
|
|
518
|
+
const at = T(ev.at) || T(ev.day ? ev.day + 'T23:59:00' : '');
|
|
519
|
+
if (at) out.push({ id, act: 'answered', by: 'pm', at: new Date(at).toISOString(), from: 'today' });
|
|
520
|
+
}
|
|
521
|
+
return out;
|
|
522
|
+
}
|
|
523
|
+
const todayLogFile = (rt) => path.join(rt, 'today-log', 'log.jsonl');
|
|
524
|
+
|
|
482
525
|
/** The pure view. entries: the store's mentions; marks: marks.jsonl lines; o: { now, me: [lower-case names], reads: Map id → read }.
|
|
483
526
|
* → { waiting (Your move, oldest first), toread (newest first), answered (newest first), recent (toread + answered, newest first),
|
|
484
527
|
* watching, landed } */
|
|
@@ -495,11 +538,42 @@ function build(entries, marks, o = {}) {
|
|
|
495
538
|
groups.get(id).push(e);
|
|
496
539
|
}
|
|
497
540
|
const waiting = [], toread = [], answered = [];
|
|
541
|
+
const judged = [];
|
|
498
542
|
for (const [id, list] of groups) {
|
|
499
543
|
const mk = marksFor([...list.map((e) => e.id), id], mks);
|
|
500
544
|
const j = judgeConv(list, mk, now, me);
|
|
501
545
|
if (j.snoozed) continue; // Remind me at 09:00: hidden until then
|
|
502
|
-
|
|
546
|
+
judged.push({ id, list, j, r: convRow(id, list, j, mk, o.reads, now, me) });
|
|
547
|
+
}
|
|
548
|
+
// THE SAME ASK, READ AGAIN (Wawan 2026-11-22: Done asks kept coming back, Jin's one ask three times). A brief re-states an ask in new
|
|
549
|
+
// words, with no link and often no message time, so each day's copy is a new conversation. A copy is the same ask when the same person
|
|
550
|
+
// asks it in most of the same words (sameAskLoose). It is covered when the PM already covered that ask and the copy carries no message
|
|
551
|
+
// newer than the cover; open copies of one ask are one row, the oldest, with the others under it (`dups`).
|
|
552
|
+
const asksOf = (list) => list.filter((e) => e.reply_needed && !e.broadcast).map((e) => e.ask || e.gist || e.text).filter(Boolean);
|
|
553
|
+
const peopleOf = (r) => new Set((r.people && r.people.length ? r.people : [r.who]).map((w) => String(w || '').trim().split(/\s+/)[0].toLowerCase()).filter(Boolean));
|
|
554
|
+
const realLast = (list) => Math.max(0, ...list.flatMap((e) => [T(e.at), ...(e.thread || []).filter((m) => !isMe(m.who, me)).map((m) => T(m.at))]));
|
|
555
|
+
const same = (a, b) => { const pa = peopleOf(a.r), pb = peopleOf(b.r); if (![...pa].some((n) => pb.has(n))) return false;
|
|
556
|
+
const xa = asksOf(a.list), xb = asksOf(b.list); return xa.some((x) => xb.some((y) => sameAskLoose(x, y))); };
|
|
557
|
+
const covers = judged.filter((c) => c.j.ask && !c.j.waiting && c.j.upto > 0);
|
|
558
|
+
for (const w of judged) {
|
|
559
|
+
if (!w.j.waiting) continue;
|
|
560
|
+
const real = realLast(w.list);
|
|
561
|
+
const c = covers.find((x) => x !== w && real <= x.j.upto + 60000 && same(w, x));
|
|
562
|
+
if (!c) continue;
|
|
563
|
+
w.j = { ...w.j, waiting: false, how: c.j.how || 'answered', sinceReply: false, last: Math.max(w.j.last, c.j.upto) };
|
|
564
|
+
delete w.r.since; w.r.waiting = false; w.r.status = c.j.how || 'answered'; w.r.same_as = c.id; delete w.r.check;
|
|
565
|
+
}
|
|
566
|
+
const open = judged.filter((x) => x.j.waiting).sort((a, b) => a.j.since - b.j.since);
|
|
567
|
+
for (let i = 0; i < open.length; i++) {
|
|
568
|
+
const keep = open[i]; if (keep.gone) continue;
|
|
569
|
+
for (let k = i + 1; k < open.length; k++) {
|
|
570
|
+
const d = open[k]; if (d.gone || !same(keep, d)) continue;
|
|
571
|
+
d.gone = true; keep.r.dups = (keep.r.dups || []).concat(d.id, d.r.dups || []);
|
|
572
|
+
keep.r.count = (keep.r.count || 0) + (d.r.count || 0);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
for (const { j, r, gone } of judged) {
|
|
576
|
+
if (gone) continue;
|
|
503
577
|
if (j.waiting) waiting.push(r);
|
|
504
578
|
else if (j.last < start.getTime() && !r.watch && !r.landed) continue;
|
|
505
579
|
else if (j.ask && !j.sinceReply) answered.push(r);
|
|
@@ -536,7 +610,8 @@ function view(rt, o = {}) {
|
|
|
536
610
|
if (o.brief) { try { ingestBrief(rt, o.brief, { me: o.me }); } catch { /* the same */ } }
|
|
537
611
|
const reads = new Map();
|
|
538
612
|
for (const l of lines(readsFile(rt))) if (l && ID_RE.test(String(l.id || '')) && typeof l.read === 'boolean') reads.set(l.id, l.read);
|
|
539
|
-
|
|
613
|
+
// Today's Done on an ask counts as Mark answered, before the mention's own marks so a later Undo or a new ask still wins
|
|
614
|
+
const B = build(Object.values(load(rt)), todayDoneMarks(lines(todayLogFile(rt))).concat(lines(marksFile(rt))).sort((a, b) => T(a.at) - T(b.at)), { now, me: o.me, reads });
|
|
540
615
|
// honest gaps, said once at the end: a mention source not reached, and a check that has not run today
|
|
541
616
|
const gaps = [];
|
|
542
617
|
for (const m of o.missing || []) if (MENTION_SOURCES.includes(m.source) && m.state !== 'off') gaps.push({ kind: 'source', source: m.source, state: m.state });
|
|
@@ -552,4 +627,4 @@ function view(rt, o = {}) {
|
|
|
552
627
|
return { ok: true, ...B, count: B.waiting.length, gaps, as_of, sources, reads_at, now: new Date(now).toISOString() };
|
|
553
628
|
}
|
|
554
629
|
|
|
555
|
-
module.exports = { MENTION_SOURCES, ACTS, AGENT_ACTS, VIAS, keyOf, convKeyOf, convIdOf, judgeConv, nextNine, isMention, namesMe, timeOf, entryOf, briefExtras, merge, ingestRead, ingestBrief, mark, foldMarks, judge, build, prune, view, nineTomorrow, _files: { storeFile, marksFile } };
|
|
630
|
+
module.exports = { sameAskLoose, askTokens, todayDoneMarks, MENTION_SOURCES, ACTS, AGENT_ACTS, VIAS, keyOf, convKeyOf, convIdOf, judgeConv, nextNine, isMention, namesMe, timeOf, entryOf, briefExtras, merge, ingestRead, ingestBrief, mark, foldMarks, judge, build, prune, view, nineTomorrow, _files: { storeFile, marksFile } };
|
|
@@ -395,6 +395,7 @@ function keepFields(scope, id, row, o = {}) {
|
|
|
395
395
|
if (scope === 'initiative') { f.initiative = id; f.window = WINDOW; }
|
|
396
396
|
if (scope === 'product') f.product = id;
|
|
397
397
|
if (row.recipe) f.recipe = row.recipe;
|
|
398
|
+
else { const d = require('./metric-source.js').trackerRecipeOf({ source: f.source, metric: f.metric, type, why: f.why }); if (d) f.recipe = d; } // A3-pre: the query its own source names
|
|
398
399
|
f.draft = row.id;
|
|
399
400
|
return { fields: f, reading: now != null && DAY_RE.test(String(o.today || '')) ? { at: o.today, value: now } : null };
|
|
400
401
|
}
|
|
@@ -20,13 +20,19 @@
|
|
|
20
20
|
* _RUN, _RIDS, _TEST). A value lands on the record with its source and time; a test value lands only in the ledger. Nothing is sent.
|
|
21
21
|
* When the run ends, a goal it neither read nor said it could not read is filed as not read ("the run ended before it read this").
|
|
22
22
|
*
|
|
23
|
+
* A3-pre (one-goal-read-per-product): before a scan, a product with no goal PMOS can read gets the cheapest query one of its goals names
|
|
24
|
+
* (lib/metric-source.js pickOf), saved on that goal's record (deps.saveRecipe, else scripts/records edit by `pmos:metric-source`). It is due
|
|
25
|
+
* at once and read daily after. The PM changes or removes it on the goal page (POST /api/goal-status/recipe).
|
|
26
|
+
*
|
|
23
27
|
* deps: { workspaces(), isLead(w), stateDirFor(w), recordsDir(w), records(w) → [kr-metrics record], open(now), workOpen(now), hours() → { start, end },
|
|
24
28
|
* headlessOff(), env,
|
|
25
29
|
* promptFor(skillId), spawn(spec), spawnNow(spec), stop(session), afterRead(w, rids) (the alert check and the bell), warn(what, err),
|
|
26
|
-
* draftsFile(w) → the metric-drafts ledger, testItems(w, rids) → [{ rid, title, unit, recipe }] for drafted rows
|
|
30
|
+
* draftsFile(w) → the metric-drafts ledger, testItems(w, rids) → [{ rid, title, unit, recipe }] for drafted rows,
|
|
31
|
+
* saveRecipe(w, rid, recipe) → { ok } (optional) }
|
|
27
32
|
*/
|
|
28
33
|
const crypto = require('crypto');
|
|
29
34
|
const MR = require('./metric-reads.js');
|
|
35
|
+
const MS = require('./metric-source.js');
|
|
30
36
|
|
|
31
37
|
const flagOff = (v) => /^(off|0|false|no)$/i.test(String(v || '').trim());
|
|
32
38
|
const off = (env) => flagOff((env || process.env).PMOS_METRIC_READ);
|
|
@@ -107,6 +113,19 @@ function create(deps) {
|
|
|
107
113
|
return { ok: true, run, rids: ids };
|
|
108
114
|
}
|
|
109
115
|
|
|
116
|
+
/** A3-pre: a product with no goal PMOS can read gets the cheapest query its own goals name, saved on that one goal (lib/metric-source.js).
|
|
117
|
+
* → true when a query was saved (the records are read again). */
|
|
118
|
+
function saveCheapest(w, recs, F) {
|
|
119
|
+
const pick = MS.pickOf(recs, F);
|
|
120
|
+
if (!pick) return false;
|
|
121
|
+
try {
|
|
122
|
+
const save = deps.saveRecipe || ((ws, rid, recipe) => require(require('./repo-script.js').repoScript('records/index.js'))
|
|
123
|
+
.edit(deps.recordsDir(ws), 'kr-metrics', rid, { recipe }, { by: 'pmos:metric-source', via: 'server' }, MS.WHY));
|
|
124
|
+
const r = save(w, pick.rid, pick.recipe);
|
|
125
|
+
return !!(r && r.ok);
|
|
126
|
+
} catch (e) { warn('metric source save', e); return false; }
|
|
127
|
+
}
|
|
128
|
+
|
|
110
129
|
function stop(run) { const a = active.get(run); if (a && a.session && deps.stop) deps.stop(a.session); }
|
|
111
130
|
|
|
112
131
|
function tick({ now = Date.now(), env } = {}) {
|
|
@@ -124,7 +143,9 @@ function create(deps) {
|
|
|
124
143
|
const dir = deps.stateDirFor(w); if (!dir) continue;
|
|
125
144
|
lastScan.set(w.id, now);
|
|
126
145
|
let recs = []; try { recs = deps.records(w) || []; } catch (e) { warn('metric read records', e); continue; }
|
|
127
|
-
const
|
|
146
|
+
const F = MR.read(dir);
|
|
147
|
+
if (saveCheapest(w, recs, F)) { try { recs = deps.records(w) || []; } catch (e) { warn('metric read records', e); continue; } }
|
|
148
|
+
const due = MR.dueOf(recs, F, now, { only, hours });
|
|
128
149
|
if (!due.length) continue;
|
|
129
150
|
const r = start({ ws: w.id, rids: due.slice(0, PER_RUN), why: 'due', now });
|
|
130
151
|
if (r.ok) return { started: w.id, rids: r.rids };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* metric-source.js — the cheapest way to read one goal (bet A3-pre, initiative one-goal-read-per-product; critic F2: 0 readings on 5 of 5
|
|
3
|
+
* test products). PURE: no file, no clock, no network. lib/metric-read-runs.js saves what it picks; lib/metric-drafts.js keepFields uses it
|
|
4
|
+
* when the PM keeps a draft that names its source and has no recipe.
|
|
5
|
+
*
|
|
6
|
+
* trackerRecipeOf(goal) → recipe | null the query a goal's own words name, in the recipe shape of lib/metric-drafts.js recipeOf.
|
|
7
|
+
* goal: { source, metric | name, type, why? }. Only a tracker source (Jira) gives one:
|
|
8
|
+
* a "Done or not" goal that names an issue key key = ABC-123, counted 1 when done, 0 while open
|
|
9
|
+
* a Count goal that names a project, no issue project = ABC AND created >= -<window>d [AND issuetype = Bug]
|
|
10
|
+
* The window is the goal's own ("per 8 weeks" → 56 days, "30 days" → 30), else 28 days. Analytics, a sheet,
|
|
11
|
+
* a typed goal or any other type gets null: the review run (lib/metric-draft-runs.js gapsOf) drafts its fix.
|
|
12
|
+
* pickOf(records, F) → { rid, recipe } | null the ONE goal of a product to save a query on. null when a live goal already has a
|
|
13
|
+
* query that has not failed its last try (F: lib/metric-reads.js fold, optional), or when no goal's source
|
|
14
|
+
* gives one. Order: north-star, kr, program-goal, success, input, the rest; a retired or watch goal never.
|
|
15
|
+
* WHY the why on the record's edit line
|
|
16
|
+
*
|
|
17
|
+
* Why the tracker first: the read is one saved query through the PM's own tracker connection. It needs no event, no analytics setup and no
|
|
18
|
+
* PM time (proof pmos-ideas/proofs/A3-pre: three goals that named Jira read in one query each).
|
|
19
|
+
*/
|
|
20
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
21
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
22
|
+
const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
23
|
+
|
|
24
|
+
const WHY = 'PMOS saved the cheapest query this goal names, so it is read every day';
|
|
25
|
+
const ORDER = ['north-star', 'kr', 'program-goal', 'success', 'input'];
|
|
26
|
+
const DEFAULT_DAYS = 28;
|
|
27
|
+
const TRACKER_RE = /\bjira\b/i;
|
|
28
|
+
const KEY_RE = /\b([A-Z][A-Z0-9_]{1,9})-(\d{1,7})\b/;
|
|
29
|
+
const PROJECT_RE = /^[\s:·,-]*(?:project\s+)?([A-Z][A-Z0-9_]{1,9})\b(?!-\d)/i; // right after the word Jira
|
|
30
|
+
const BUG_RE = /\bbugs?\b|\bdefects?\b/i;
|
|
31
|
+
|
|
32
|
+
/** The days a goal counts over, from its own words; DEFAULT_DAYS when it names none. */
|
|
33
|
+
function windowDays(text) {
|
|
34
|
+
const t = str(text);
|
|
35
|
+
let m = /(\d{1,3})\s*weeks?\b/i.exec(t); if (m && +m[1] > 0) return Math.min(+m[1] * 7, 366);
|
|
36
|
+
m = /(\d{1,3})\s*days?\b/i.exec(t); if (m && +m[1] > 0) return Math.min(+m[1], 366);
|
|
37
|
+
if (/\bper\s+(?:a\s+)?week\b|\bweekly\b/i.test(t)) return 7;
|
|
38
|
+
if (/\bper\s+(?:a\s+)?month\b|\bmonthly\b/i.test(t)) return 30;
|
|
39
|
+
return DEFAULT_DAYS;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function trackerRecipeOf(goal) {
|
|
43
|
+
if (!isObj(goal)) return null;
|
|
44
|
+
const source = str(goal.source), name = one(goal.metric || goal.name, 120), type = str(goal.type);
|
|
45
|
+
if (!TRACKER_RE.test(source)) return null;
|
|
46
|
+
const key = KEY_RE.exec(source);
|
|
47
|
+
if (type === 'Done or not' || (!type && str(goal.unit) === 'done')) {
|
|
48
|
+
if (!key) return null;
|
|
49
|
+
const k = key[0];
|
|
50
|
+
return { connector: 'Jira', query: `key = ${k}`, cadence: 'daily',
|
|
51
|
+
counts: { what: `1 when ${k} is in a done status, 0 while it is open`, num_label: '', den_label: '' } };
|
|
52
|
+
}
|
|
53
|
+
if (type === 'Count') {
|
|
54
|
+
if (key) return null; // one ticket is not a count
|
|
55
|
+
const after = source.slice(source.search(TRACKER_RE) + 4), p = PROJECT_RE.exec(after);
|
|
56
|
+
if (p && !/^[A-Z][A-Z0-9_]*$/.test(p[1])) return null; // a project key is upper case: "Jira board" names none
|
|
57
|
+
if (!p) return null;
|
|
58
|
+
const days = windowDays([name, source, str(goal.why)].join(' ')), bugs = BUG_RE.test(name);
|
|
59
|
+
return { connector: 'Jira', query: `project = ${p[1]}${bugs ? ' AND issuetype = Bug' : ''} AND created >= -${days}d`, cadence: 'daily',
|
|
60
|
+
counts: { what: `${bugs ? 'Bugs' : 'Issues'} created in ${p[1]} in the last ${days} days${name ? ` that match the goal "${name}"` : ''}`, num_label: '', den_label: '' } };
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const live = (r) => isObj(r) && r.retired !== true && r.role !== 'watch';
|
|
66
|
+
const rank = (r) => { const i = ORDER.indexOf(r.role); return i < 0 ? ORDER.length : i; };
|
|
67
|
+
/** A goal whose query has not failed its last try reads already. */
|
|
68
|
+
function reads(rec, F) {
|
|
69
|
+
if (!(isObj(rec.recipe) && rec.recipe.connector && rec.recipe.query)) return false;
|
|
70
|
+
const x = F && F.rids && F.rids.get(rec.rid);
|
|
71
|
+
return !(x && x.last && x.last.ok === false);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function pickOf(records, F) {
|
|
75
|
+
const R = (records || []).filter(live);
|
|
76
|
+
if (R.some((r) => reads(r, F))) return null;
|
|
77
|
+
const order = R.map((r, i) => ({ r, i })).sort((a, b) => rank(a.r) - rank(b.r) || a.i - b.i);
|
|
78
|
+
for (const { r } of order) {
|
|
79
|
+
if (isObj(r.recipe) && r.recipe.connector) continue; // its own query failed: its fix is drafted, never overwritten here
|
|
80
|
+
const recipe = trackerRecipeOf(r);
|
|
81
|
+
if (recipe) return { rid: r.rid, recipe };
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
module.exports = { trackerRecipeOf, pickOf, windowDays, WHY, DEFAULT_DAYS };
|
|
@@ -119,7 +119,9 @@ function trackerLines(lines, snapOf) {
|
|
|
119
119
|
const closes = want === 'Done' || want === "Won't do";
|
|
120
120
|
if (jiraAt ? jiraAt <= changed : !closes) continue;
|
|
121
121
|
}
|
|
122
|
-
|
|
122
|
+
// happened: Jira's resolution day when it closed the ticket, so a done task carries its real finish day, not the read's (A67)
|
|
123
|
+
const happened = (want === 'Done' || want === "Won't do") && /^\d{4}-\d{2}-\d{2}$/.test(String(rd.resolved || '')) ? { happened: rd.resolved } : {};
|
|
124
|
+
out.push({ at: s.fetchedAt, by: BY, kind: 'task-update', task: t.task, state: want, tracker: true, ...happened,
|
|
123
125
|
why: `Jira says ${String(rd.status || want).slice(0, 40)} (${t.key}, read ${String(s.fetchedAt).slice(0, 16).replace('T', ' ')} UTC)` });
|
|
124
126
|
}
|
|
125
127
|
return out.sort((a, b) => String(a.at).localeCompare(String(b.at)));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.676.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.676.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -21,7 +21,8 @@ Rules that always hold:
|
|
|
21
21
|
6. NO EVENT, NO NUMBER. When no event counts a metric, file it with `"now": null` and a ticket: `"ticket": { "key": "<PROJECT>-<n> drafted", "text": "<the event to add, its name and its properties>" }`. Say it in `why`, for example "No event to count it. Ticket MS-212 drafted."
|
|
22
22
|
7. A TARGET HAS A REASON. Base it on the baseline and on past launches (what the same kind of change did before). `why` says that reason in one line.
|
|
23
23
|
8. DO NOT DRAFT AGAIN what the PM kept or dropped, unless the evidence is new.
|
|
24
|
-
9.
|
|
24
|
+
9. SAVE THE QUERY. Every row whose source can be queried carries `"recipe": { "connector", "query", "cadence": "daily" }`, so PMOS reads it every day from the PM's ✓. Use the cheapest source that measures the same thing: the tracker first (a Jira query: `key = ABC-123` for a done-or-not goal, `project = ABC AND created >= -56d` for a count), then analytics, then a sheet. Name the source in `source` the same way ("Jira ABC-123 status", "Jira ABC"). A row with no source that can be queried has no recipe.
|
|
25
|
+
10. PLAIN WORDS. First person, short sentences, no praise and no blame. Name a metric in a few words, the way a PM says it: "Weekly signed-in shoppers", not "WSS (7d)".
|
|
25
26
|
|
|
26
27
|
Procedure:
|
|
27
28
|
1. Run `pmos metrics draft read "<source>" --found "<what it says, one line>"` for each source as you read it. Read in this order, and skip what does not exist:
|
|
@@ -31,7 +32,7 @@ Procedure:
|
|
|
31
32
|
- a quarter start: last quarter's key results, their readings and how each one ended.
|
|
32
33
|
Use `--state now` while you read a source and `--state done` when you finish it. A source you cannot read: `--state wait`, and say so in your answer.
|
|
33
34
|
2. Run `pmos metrics draft step shape`. Decide the rows. File each with `pmos metrics draft row --json -`:
|
|
34
|
-
`{ "group", "name", "type", "now", "nowTxt", "target", "targetTxt", "by", "why", "source", "ticket", "direction" }`.
|
|
35
|
+
`{ "group", "name", "type", "now", "nowTxt", "target", "targetTxt", "by", "why", "source", "recipe", "ticket", "direction" }`.
|
|
35
36
|
- type is one of Count, Percentage, Amount, Duration, Done or not, Stay within. A guardrail that must not get worse is Stay within, with the limit as its target and `"direction": "down"` for a ceiling or `"up"` for a floor.
|
|
36
37
|
- nowTxt and targetTxt are short: "38.8k", "94.1%", "45k by Dec 31", "Stays under 1.2 s".
|
|
37
38
|
- by is YYYY-MM-DD. For an initiative, "Proves it worked" is read 4 weeks after release: the release day from the plan plus 28 days. With no release day, use the last day of this quarter and say so in why.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "A3-pre one goal read per product (pure, node): lib/metric-source.js, its save step in lib/metric-read-runs.js tick, and keepFields in lib/metric-drafts.js.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"metric-source.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"metric-source.test.js": 1
|
|
8
|
+
}
|
|
9
|
+
}
|