create-pmos 0.665.0 → 0.666.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 +9 -3
- 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 +8 -2
- package/workspace/lib/forecast.js +5 -2
- package/workspace/lib/jira-status.js +32 -10
- package/workspace/lib/kind-control.js +10 -0
- package/workspace/lib/refresh-run.js +9 -3
- package/workspace/lib/routes-boards.js +37 -2
- package/workspace/lib/routes-kind-control.js +7 -1
- package/workspace/lib/task-jira.js +138 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/skills/jira-sync.skill +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.666.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": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
36
|
{
|
|
37
|
-
"v": "0.
|
|
38
|
-
"at": "2026-11-22T04:
|
|
37
|
+
"v": "0.666.0",
|
|
38
|
+
"at": "2026-11-22T04:26:58.946Z",
|
|
39
39
|
"f": 4,
|
|
40
40
|
"prs": [
|
|
41
41
|
{
|
|
@@ -49,6 +49,12 @@
|
|
|
49
49
|
"t": "A task opened from a place is the full popup from design system blocks",
|
|
50
50
|
"s": "A task opened from a place is the full popup from design system blocks",
|
|
51
51
|
"k": "new"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"n": 1453,
|
|
55
|
+
"t": "Read the tracker daily for all products, never forecast from a stale state",
|
|
56
|
+
"s": "Read the tracker daily for all products, never forecast from a stale state",
|
|
57
|
+
"k": "new"
|
|
52
58
|
}
|
|
53
59
|
]
|
|
54
60
|
},
|
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-22T04:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T04:26:55Z"}
|
|
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-22T04:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T04:26:55Z"}
|
|
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-22T04:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T04:26:55Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"v": "0.
|
|
4
|
-
"at": "2026-11-22T04:
|
|
3
|
+
"v": "0.666.0",
|
|
4
|
+
"at": "2026-11-22T04:26:58.946Z",
|
|
5
5
|
"f": 4,
|
|
6
6
|
"prs": [
|
|
7
7
|
{
|
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
"t": "A task opened from a place is the full popup from design system blocks",
|
|
16
16
|
"s": "A task opened from a place is the full popup from design system blocks",
|
|
17
17
|
"k": "new"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"n": 1453,
|
|
21
|
+
"t": "Read the tracker daily for all products, never forecast from a stale state",
|
|
22
|
+
"s": "Read the tracker daily for all products, never forecast from a stale state",
|
|
23
|
+
"k": "new"
|
|
18
24
|
}
|
|
19
25
|
]
|
|
20
26
|
},
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* decorateInsights(model, F) puts g.forecast on each goal and b.burn on each budget of an Insights model; answers the items to record
|
|
17
17
|
*
|
|
18
18
|
* STATES. on-track (every line reaches the target), at-risk (some do), will-miss (none do), too-early (under 3 weeks or under 3 readings: no
|
|
19
|
-
* number at all), held (the source was not read for more than 7 days: the range stands as it was read and is never carried forward). A delivery's
|
|
19
|
+
* number at all), held (the source was not read for more than 7 days, or Jira for more than a day: the range stands as it was read and is never carried forward). A delivery's
|
|
20
20
|
* state comes from its range against the promise; with no promised date it has no state (null) and says why.
|
|
21
21
|
*
|
|
22
22
|
* THE LEDGER: <state>/forecast.jsonl, append-only, one line per event { at, by, kind, ... }:
|
|
@@ -38,6 +38,9 @@ const KINDS = new Set(['seen', 'turned', 'baseline', 'baseline-off']);
|
|
|
38
38
|
const STATES = Object.freeze(['on-track', 'at-risk', 'will-miss', 'too-early', 'held']);
|
|
39
39
|
const DAY = 864e5, WEEK = 7 * DAY;
|
|
40
40
|
const MIN_WEEKS = 3, MIN_READINGS = 3, HELD_DAYS = 7, BURN_WEEKS = 8;
|
|
41
|
+
// tracker-daily (bet 1, proofs A77): Jira is read every day, so a delivery range never rests on a read older than yesterday's. It is held
|
|
42
|
+
// the day after a missed read, where a goal (read weekly or less) waits HELD_DAYS.
|
|
43
|
+
const READ_DAYS = 1;
|
|
41
44
|
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
42
45
|
const fin = (v) => typeof v === 'number' && Number.isFinite(v);
|
|
43
46
|
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
@@ -87,7 +90,7 @@ function deliveryForecast(r, J, o = {}) {
|
|
|
87
90
|
const likely = F.hi ? addDays(F.lo, Math.round((dayMs(F.hi) - dayMs(F.lo)) / DAY / 2)) : F.lo;
|
|
88
91
|
const state = F.finished ? 'on-track' : promised ? DOT_STATE[F.dot] || null : null;
|
|
89
92
|
const out = { ...base, state, likely, low: F.lo, high: F.hi, why: F.finished ? 'Every ticket is done.' : !promised ? 'No promised date to read the range against.' : F.why || 'The tickets left at the fastest and the slowest closing rate.' };
|
|
90
|
-
if (!F.finished && asOf && dayMs(today) - dayMs(asOf) >
|
|
93
|
+
if (!F.finished && asOf && dayMs(today) - dayMs(asOf) > READ_DAYS * DAY) return Object.assign(out, { state: 'held', was: state, why: 'Jira not read since ' + asOf + ', so the range is held where it was.' });
|
|
91
94
|
if (state && state !== 'on-track' && o.driftFrom) out.driftFrom = o.driftFrom;
|
|
92
95
|
return out;
|
|
93
96
|
}
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* no plan item, no record, no ledger line (D88: the Breakdown is the handoff checklist, not a copy of Jira).
|
|
8
8
|
*
|
|
9
9
|
* queryFor(root, initiative) → { linked, mode, query } the JQL for the tickets this initiative pushed, or, when it
|
|
10
|
-
* pushed none, for its Jira epics and their children (mode 'epic', jira-epic-items)
|
|
10
|
+
* pushed none, for its Jira epics and their children (mode 'epic', jira-epic-items). In every
|
|
11
|
+
* mode it adds the tickets the initiative's tasks name at the start of their titles; with
|
|
12
|
+
* nothing else it reads only those (mode 'tasks', tracker-daily: lib/task-jira.js)
|
|
11
13
|
* linkedInitiatives(root) → [{ initiative, query }]
|
|
12
14
|
* normalize(raw) → { issues, skipped } | { error }
|
|
13
15
|
* sync(root, initiative, raw, opts) → the snapshot, written to <state>/tracker/jira/<initiative>.md
|
|
@@ -28,11 +30,15 @@
|
|
|
28
30
|
* stale. Titles and statuses only: never a description or a comment. The one person a reading carries is the assignee's display name, with
|
|
29
31
|
* the time of the last update (`assignee`, `updated`): Waiting on others names who a stale ticket waits on (home-your-move-waiting).
|
|
30
32
|
*
|
|
33
|
+
* A task that names a key follows its reading: lib/task-jira.js trackerLines sets its state in memory when the read is newer (no
|
|
34
|
+
* plan item or ledger line is written, D88 still holds).
|
|
35
|
+
*
|
|
31
36
|
* BOUNDARY (J15). No network module, no child process. The only write is the snapshot file.
|
|
32
37
|
*/
|
|
33
38
|
const fs = require('fs');
|
|
34
39
|
const path = require('path');
|
|
35
40
|
const jiraTickets = require('./jira-tickets.js');
|
|
41
|
+
const taskJira = require('./task-jira.js');
|
|
36
42
|
|
|
37
43
|
const KEY_RE = /^[A-Za-z][A-Za-z0-9_]*-\d+$/;
|
|
38
44
|
const isStr = (v) => typeof v === 'string';
|
|
@@ -41,18 +47,29 @@ const clip = (s, n) => (s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s);
|
|
|
41
47
|
const nowIso = (now) => new Date(now == null ? Date.now() : now).toISOString().replace(/\.\d{3}Z$/, 'Z');
|
|
42
48
|
|
|
43
49
|
// ── the query ──────────────────────────────────────────────────────────────────────────────────────
|
|
44
|
-
|
|
50
|
+
/** The Jira keys the initiative's own tasks name in their titles (lib/task-jira.js): imported tasks follow their tickets. */
|
|
51
|
+
function taskKeysOf(root, initiative, byIni) {
|
|
52
|
+
const m = byIni || taskJira.readKeys(root);
|
|
53
|
+
return m.get(initiative) || [];
|
|
54
|
+
}
|
|
55
|
+
function queryFor(root, initiative, byIni) {
|
|
45
56
|
if (!jiraTickets.recordFm(root, initiative)) return { ok: false, error: `no initiative ${initiative} in this repository` };
|
|
46
|
-
const
|
|
47
|
-
|
|
57
|
+
const pushed = [...jiraTickets.pushedTickets(root, initiative).tickets.keys()];
|
|
58
|
+
const tasks = taskKeysOf(root, initiative, byIni).filter((k) => !pushed.includes(k));
|
|
59
|
+
const keys = [...pushed, ...tasks];
|
|
60
|
+
if (pushed.length) return { ok: true, initiative, linked: true, mode: 'pushed', keys, ...(tasks.length ? { tasks } : {}), query: `key in (${keys.join(', ')}) ORDER BY key` };
|
|
48
61
|
// EPIC MODE (jira-epic-items): no ticket pushed, but the initiative has Jira epics. Read each epic and its children.
|
|
49
62
|
const epics = jiraTickets.epicKeysOf(root, initiative);
|
|
50
|
-
|
|
63
|
+
const extra = tasks.filter((k) => !epics.includes(k));
|
|
64
|
+
if (epics.length) return { ok: true, initiative, linked: true, mode: 'epic', keys: [...epics, ...extra], epics, ...(extra.length ? { tasks: extra } : {}), query: `key in (${[...epics, ...extra].join(', ')}) OR parent in (${epics.join(', ')}) ORDER BY key` };
|
|
65
|
+
// TASK MODE (tracker-daily): no ticket pushed and no epic, but tasks that name Jira tickets. Read those tickets.
|
|
66
|
+
if (tasks.length) return { ok: true, initiative, linked: true, mode: 'tasks', keys: tasks, tasks, query: `key in (${tasks.join(', ')}) ORDER BY key` };
|
|
51
67
|
return { ok: true, initiative, linked: false, keys: [], query: null };
|
|
52
68
|
}
|
|
53
69
|
function linkedInitiatives(root) {
|
|
54
|
-
const
|
|
55
|
-
|
|
70
|
+
const byIni = taskJira.readKeys(root);
|
|
71
|
+
const ids = [...new Set([...jiraTickets.draftedInitiatives(root), ...jiraTickets.epicInitiatives(root), ...byIni.keys()])].sort();
|
|
72
|
+
return ids.map((id) => queryFor(root, id, byIni)).filter((q) => q.ok);
|
|
56
73
|
}
|
|
57
74
|
|
|
58
75
|
// ── reading a saved search result ──────────────────────────────────────────────────────────────────
|
|
@@ -307,16 +324,21 @@ function sync(root, initiative, raw, { query, dryRun = false, now } = {}) {
|
|
|
307
324
|
if (n.error) return { ok: false, error: n.error };
|
|
308
325
|
const pushed = jiraTickets.pushedTickets(root, initiative).tickets;
|
|
309
326
|
const epics = pushed.size ? [] : jiraTickets.epicKeysOf(root, initiative);
|
|
310
|
-
|
|
327
|
+
const tasks = new Set(taskKeysOf(root, initiative)); // tracker-daily: the tickets the initiative's tasks name
|
|
328
|
+
if (!pushed.size && !epics.length && !tasks.size) return { ok: false, error: `${initiative} has no ticket in Jira yet — push its tickets first, link its Jira epic, or name a ticket key at the start of a task` };
|
|
311
329
|
const prev = readSnapshot(root, initiative);
|
|
312
330
|
// Pushed mode keeps the pushed keys. Epic mode keeps the epics and the issues under them; an issue the search returned
|
|
313
331
|
// with no parent field is kept, since the search was scoped to the epics; one under another parent is ignored.
|
|
314
|
-
|
|
332
|
+
// In every mode the tickets the tasks name are kept too.
|
|
333
|
+
const keep = pushed.size ? (i) => pushed.has(i.key) || tasks.has(i.key)
|
|
334
|
+
: epics.length ? (i) => tasks.has(i.key) || epics.includes(i.key) || !i.parent || epics.includes(i.parent)
|
|
335
|
+
: (i) => tasks.has(i.key);
|
|
315
336
|
const got = new Map(n.issues.filter(keep).map((i) => [i.key, i]));
|
|
316
337
|
const ignored = n.issues.length - got.size;
|
|
317
338
|
const ids = new Map([...pushed].map(([k, v]) => [k, v.id]));
|
|
318
339
|
const readings = []; const changes = []; const missing = [];
|
|
319
|
-
const expected = pushed.size
|
|
340
|
+
const expected = pushed.size || !epics.length ? [...new Set([...pushed.keys(), ...tasks])]
|
|
341
|
+
: [...new Set([...epics, ...tasks, ...got.keys(), ...(prev ? [...prev.tickets.keys()].filter((k) => { const r = prev.tickets.get(k); return epics.includes(k) || !r.parent || epics.includes(r.parent); }) : [])])];
|
|
320
342
|
for (const key of expected) {
|
|
321
343
|
const r = got.get(key);
|
|
322
344
|
const was = prev ? prev.tickets.get(key) : null;
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
* With no links into go-live there is no critical path to name, and the Viewer says nothing about it.
|
|
19
19
|
* colour done: done. Red: it ends later than its baseline, it is on the critical path and go-live misses the goal date. Amber: it ends
|
|
20
20
|
* later than its baseline otherwise, or it has not started and its start has passed. Green: on its baseline. None: no dates.
|
|
21
|
+
* stale input `stale` (lib/task-jira.js staleOf): the tasks that name Jira tickets rest on a read older than a day. Then on track is
|
|
22
|
+
* unknown, says when Jira was last read, and no ✦ is made (tracker-daily, bet 1).
|
|
21
23
|
* on track "On track for <goal date>?" Yes when the forecast go-live is on or before the goal date; No with the slip and the first
|
|
22
24
|
* slipping task on the critical path (the cause); unknown with the reason when a date is missing.
|
|
23
25
|
* proposal on a No: a ✦ that moves the go-live milestone to its forecast. It never changes the goal, the KR or the title: those are
|
|
@@ -179,6 +181,14 @@ function project(input) {
|
|
|
179
181
|
words: 'No. Forecast ' + md(fgo) + ', ' + days(fgo - goalN) + ' late.', cause: cause ? { uid: cause.uid, title: cause.title, slip: cause.slip } : null,
|
|
180
182
|
why: cause ? '"' + cause.title + '" ends ' + days(cause.slip) + ' after its baseline' + (cause.critical ? ' and sits on the critical path' + (after.length ? ', so ' + listOf(after.map((x) => '"' + x + '"')) + (after.length === 1 ? ' moves' : ' move') : '') : '') + '.' : 'Open work is past its due day.', src };
|
|
181
183
|
}
|
|
184
|
+
// tracker-daily (bet 1): never forecast from a stale tracker state. When the tasks that name Jira tickets rest on a read older than a
|
|
185
|
+
// day (or one that did not return them), the answer waits for the next read and no ✦ moves a date.
|
|
186
|
+
const ST = I.stale && I.stale.stale ? I.stale : null;
|
|
187
|
+
if (ST && (ontrack.answer === 'yes' || ontrack.answer === 'no')) {
|
|
188
|
+
const n = (ST.keys || []).length;
|
|
189
|
+
ontrack = { answer: 'unknown', stale: true, staleSince: ST.since || null, forecast: ontrack.forecast,
|
|
190
|
+
words: (ST.since ? 'Jira not read since ' + md(dn(String(ST.since).slice(0, 10))) : 'Jira not read yet') + ', so PMOS does not forecast from it. ' + n + (n === 1 ? ' task waits' : ' tasks wait') + ' on the next read.', src };
|
|
191
|
+
}
|
|
182
192
|
// the ✦: move the go-live milestone to its forecast. Never the goal, the KR or the title.
|
|
183
193
|
let proposal = null;
|
|
184
194
|
if (ontrack.answer === 'no' && goLive && goLive.ms) {
|
|
@@ -49,6 +49,7 @@ const LOST_MS = 6 * 3600 * 1000; // a run with no live session and no end afte
|
|
|
49
49
|
const READ_MS = 30 * 60 * 1000; // batch 31 item 6: a read of a tool (how 'tool') is stopped after this long, with the reason, so the next slot can run
|
|
50
50
|
const SLOW_MS = 15 * 60 * 1000; // a read still working after this long shows as slow on its row
|
|
51
51
|
const ALL_MS = 3 * 3600 * 1000; // a Refresh all that has not ended after this long is over: a new press starts a new one
|
|
52
|
+
const DAILY_MS = 20 * 3600 * 1000; // tracker-daily: a product workspace the pinned Jira read does not cover is read again once its last read is this old
|
|
52
53
|
const DERIVED = Object.freeze(['leads', 'brief']); // what Refresh all writes again after the sources, in this order
|
|
53
54
|
const DERIVED_LIST = Object.freeze(['scan', 'coredocs', 'leads', 'brief']); // what Sources lists as derived content: built from stored reads, never a tool
|
|
54
55
|
const AUTH_RETRY_MS = 2 * 60 * 1000;
|
|
@@ -129,11 +130,16 @@ function create(host) {
|
|
|
129
130
|
* initiative has a Jira ticket. It failed every morning ("The shared refresh session did not save a new read of it", "No initiative
|
|
130
131
|
* has a Jira ticket or linked epic yet") while the workspace that holds the tickets was never read.
|
|
131
132
|
*/
|
|
132
|
-
function wsFor(id, first) {
|
|
133
|
+
function wsFor(id, first, { only = false } = {}) {
|
|
133
134
|
let list = null;
|
|
134
135
|
if (host.sourceWs) { try { const l = host.sourceWs(id); if (Array.isArray(l)) list = [...new Set(l.filter(Boolean))]; } catch (e) { warn('source workspaces', e); } }
|
|
135
136
|
if (!list) return first ? [first] : [];
|
|
136
|
-
|
|
137
|
+
if (!first || !list.includes(first)) return list;
|
|
138
|
+
if (only) return [first];
|
|
139
|
+
// tracker-daily (bet 1, proofs A77, 2026-11-22): a pinned workspace kept the read to one product, so the other products' tickets were
|
|
140
|
+
// never read again after their import. The pinned one keeps its rhythm; every other one is read when its last read is a day old.
|
|
141
|
+
const t = now();
|
|
142
|
+
return [first, ...list.filter((w) => w !== first && !readSince(id, w, t - DAILY_MS))];
|
|
137
143
|
}
|
|
138
144
|
const NOTHING_TO_READ = 'No initiative in any workspace has a Jira ticket or a linked epic yet, so there is nothing to read.';
|
|
139
145
|
|
|
@@ -590,7 +596,7 @@ function create(host) {
|
|
|
590
596
|
R.writeState(dir, state);
|
|
591
597
|
return { ok: true, source: id, waiting: busy, inputs: startedInputs };
|
|
592
598
|
}
|
|
593
|
-
const wss = wsFor(id, ws || (set.sources[id] && set.sources[id].ws) || host.homeWs());
|
|
599
|
+
const wss = wsFor(id, ws || (set.sources[id] && set.sources[id].ws) || host.homeWs(), { only: !!ws }); // a press in a workspace reads that one
|
|
594
600
|
if (!wss.length) return { ok: false, status: 409, error: NOTHING_TO_READ };
|
|
595
601
|
let r = null;
|
|
596
602
|
for (const w of wss) { const r1 = start(src, w, { trigger: 'pressed' }); if (!r || (!r.ok && r1.ok)) r = r1; }
|
|
@@ -99,6 +99,7 @@ const B = require(repoScript('boards.js'));
|
|
|
99
99
|
const WF = require(repoScript('workflows.js'));
|
|
100
100
|
const WS = require('./workflows-store.js');
|
|
101
101
|
const TI = require('./task-items.js');
|
|
102
|
+
const TJ = require('./task-jira.js'); // tracker-daily: imported tasks follow their Jira tickets
|
|
102
103
|
const SW = require('./status-when.js');
|
|
103
104
|
const TS = require('./task-store.js');
|
|
104
105
|
const holdSpans = require('./hold-spans.js');
|
|
@@ -142,7 +143,7 @@ function readLedger(ctx, w) {
|
|
|
142
143
|
const store = TS.storeFor(w && w.root);
|
|
143
144
|
const key = statKey(f) + '|' + (store ? statKey(store.file) : 'none');
|
|
144
145
|
const hit = ledgerMemo.get(f);
|
|
145
|
-
if (hit && hit.key === key) return hit.lines
|
|
146
|
+
if (hit && hit.key === key) return withTracker(w, f, key, hit.lines);
|
|
146
147
|
const board = readBoardLines(f);
|
|
147
148
|
let lines = board;
|
|
148
149
|
if (store) {
|
|
@@ -158,7 +159,26 @@ function readLedger(ctx, w) {
|
|
|
158
159
|
}
|
|
159
160
|
if (ledgerMemo.size > 100) ledgerMemo.clear();
|
|
160
161
|
ledgerMemo.set(f, { key: statKey(f) + '|' + (store ? statKey(store.file) : 'none'), lines });
|
|
161
|
-
return lines
|
|
162
|
+
return withTracker(w, f, key, lines);
|
|
163
|
+
}
|
|
164
|
+
/* tracker-daily (bet 1, proofs A77): a task whose title names a Jira key takes the state of the last Jira read when that read is newer
|
|
165
|
+
* (lib/task-jira.js trackerLines). The lines are added in memory, after the ledger's own lines, and never written; they change again
|
|
166
|
+
* with each read. Kept per ledger and per set of Jira snapshots. */
|
|
167
|
+
const trackerMemo = new Map();
|
|
168
|
+
function jiraSig(w) {
|
|
169
|
+
try { const d = jiraTickets.jiraDir(w.root); return fs.readdirSync(d).filter((n) => n.endsWith('.md') && !n.endsWith('-tickets.md') && !n.startsWith('_')).sort().map((n) => n + ':' + fs.statSync(path.join(d, n)).mtimeMs).join(','); } catch { return 'none'; }
|
|
170
|
+
}
|
|
171
|
+
function withTracker(w, f, key, lines) {
|
|
172
|
+
if (!w || !w.root) return lines.slice();
|
|
173
|
+
const k = key + '|' + jiraSig(w);
|
|
174
|
+
const hit = trackerMemo.get(f);
|
|
175
|
+
if (hit && hit.key === k) return hit.lines.slice();
|
|
176
|
+
let extra = [];
|
|
177
|
+
try { extra = TJ.trackerLines(lines, (ini) => jiraStatus.readSnapshot(w.root, ini)); } catch { extra = []; }
|
|
178
|
+
const all = extra.length ? lines.concat(extra) : lines;
|
|
179
|
+
if (trackerMemo.size > 100) trackerMemo.clear();
|
|
180
|
+
trackerMemo.set(f, { key: k, lines: all });
|
|
181
|
+
return all.slice();
|
|
162
182
|
}
|
|
163
183
|
function append(file, actor, ev) {
|
|
164
184
|
const line = { at: new Date().toISOString(), by: actor.by, ...ev };
|
|
@@ -797,6 +817,7 @@ function itemsOf(w, fr, board, rows) {
|
|
|
797
817
|
}
|
|
798
818
|
for (const t of fr.folded.tasks.values()) if (t.board === board.id && ids.has(t.initiative)) out.push(B.taskItem(t));
|
|
799
819
|
out.push(...TI.rowsOf(w.root, ids, board.id)); // one kind of task: an initiative's breakdown items show as its tasks (lib/task-items.js)
|
|
820
|
+
trackerMarks(w, out);
|
|
800
821
|
for (const x of out) if (x.src === 'jira') x.notes = (fr.folded.ticketNotes && fr.folded.ticketNotes.get(board.id + '\u0000' + x.key)) || ''; // the PM's notes (canvas XetX1Jira)
|
|
801
822
|
// the PM's own days for a Jira ticket (batch 11 item 23): kept in PMOS, they win over Jira's, and the row says so
|
|
802
823
|
const TD = fr.folded.ticketDates || new Map();
|
|
@@ -841,6 +862,20 @@ function itemsOf(w, fr, board, rows) {
|
|
|
841
862
|
return B.rollupItems(out);
|
|
842
863
|
}
|
|
843
864
|
|
|
865
|
+
/** tracker-daily: a PMOS task that names a Jira key carries `tracker` { key, status, readAt, stale }: Jira's status at the last read, and
|
|
866
|
+
* stale when that read is older than a day or did not return the ticket (lib/task-jira.js staleOf). Its state is already the read's
|
|
867
|
+
* (readLedger). A page or a forecast says "not read since" instead of trusting a stale state. */
|
|
868
|
+
function trackerMarks(w, items) {
|
|
869
|
+
const snaps = new Map(), now = Date.now();
|
|
870
|
+
for (const x of items) {
|
|
871
|
+
if (x.src !== 'pmos' || x.kind === 'Epic') continue;
|
|
872
|
+
const key = TJ.keyOf(x.title);
|
|
873
|
+
if (!key) continue;
|
|
874
|
+
if (!snaps.has(x.ini)) { let sn = null; try { sn = jiraStatus.readSnapshot(w.root, x.ini); } catch { sn = null; } snaps.set(x.ini, sn); }
|
|
875
|
+
const sn = snaps.get(x.ini), rd = sn && sn.tickets ? sn.tickets.get(key) : null;
|
|
876
|
+
x.tracker = { key, status: (rd && rd.status) || null, readAt: (sn && sn.fetchedAt) || null, stale: TJ.staleOf([key], sn, now).stale };
|
|
877
|
+
}
|
|
878
|
+
}
|
|
844
879
|
/** The Jira items of an initiative PMOS pushed nothing for: its linked epics and the issues under them, from the last
|
|
845
880
|
* read of the Jira status check (lib/jira-status.js, epic mode). An issue under no linked epic hangs under the first. */
|
|
846
881
|
function epicItems(row, board, snap, seen, out) {
|
|
@@ -77,8 +77,14 @@ function control(ctx, q, o = {}) {
|
|
|
77
77
|
try { const f = require('./routes-boards.js').ledgerFile(ctx, w); if (f) lines.push(...readJsonl(f).filter((e) => e && (e.kind === 'task' || e.kind === 'task-update'))); } catch { /* none */ }
|
|
78
78
|
lines.sort((a, b) => String(a.at || '').localeCompare(String(b.at || '')));
|
|
79
79
|
const baseline = KC.baselineOf(lines, new Set(tasks.map((x) => x.uid || x.key)), baselineAt);
|
|
80
|
+
// tracker-daily: whether the tasks that name Jira tickets rest on a stale read (lib/task-jira.js)
|
|
81
|
+
let stale = null;
|
|
82
|
+
try {
|
|
83
|
+
const TJ = require('./task-jira.js'), keys = tasks.filter((x) => x.status !== 'Done' && x.status !== "Won't do" && x.status !== 'Archived').map((x) => TJ.keyOf(x.title)).filter(Boolean);
|
|
84
|
+
if (keys.length) stale = TJ.staleOf(keys, require('./jira-status.js').readSnapshot(w.root, id), o.now || Date.now());
|
|
85
|
+
} catch { stale = null; }
|
|
80
86
|
const m = KC.project({ today, title: fm.title || (row && row.title) || id, goal: goal ? { id: goal.id, title: goal.title, byAt: goal.byAt } : null, end: row && row.end,
|
|
81
|
-
record: fm, tasks, links: snap.links || [], baseline, baselineAt, people });
|
|
87
|
+
record: fm, tasks, links: snap.links || [], baseline, baselineAt, people, stale });
|
|
82
88
|
return okBody({ ...m, ...(line ? { line } : {}) });
|
|
83
89
|
}
|
|
84
90
|
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* task-jira.js — a PMOS task that names a Jira ticket follows the ticket's state (bet 1, "read the tracker daily and never forecast
|
|
3
|
+
* from stale states"; proofs A77-states and A77-five-products, 2026-11-22).
|
|
4
|
+
*
|
|
5
|
+
* WHY. Tasks imported from Jira carry the ticket key at the start of their title ("IDPF-2746 · Send verification email"). PMOS read
|
|
6
|
+
* Jira only for the tickets it pushed itself or the issues under a linked epic, so these tasks kept the state of the day they were
|
|
7
|
+
* imported. On 22 Nov PMOS showed as open 69 of 109 such Scarlet tasks, 5 of 16 on OOH Digital and 142 of 359 on idpf that Jira had
|
|
8
|
+
* closed, and forecast from them. CAS matched (0 of 13). Here such a task joins the Jira read, and the read sets its state.
|
|
9
|
+
*
|
|
10
|
+
* keyOf(title) → 'IDPF-2746' | null the Jira key a title starts with
|
|
11
|
+
* keyedTasks(lines) PURE → Map task id → { task, initiative, key, state, stateAt } from task ledger lines
|
|
12
|
+
* keysByInitiative(lines) PURE → Map initiative → [key] the keys a Jira read must cover (lib/jira-status.js queryFor)
|
|
13
|
+
* readKeys(root) → the same, from the repository's task ledger (lib/task-store.js)
|
|
14
|
+
* stateOf(reading) PURE → 'To do' | 'In progress' | 'Done' | "Won't do" a Jira reading as a task state
|
|
15
|
+
* trackerLines(lines, snapOf) PURE → [task-update line] the state changes the last Jira read makes (see THE RULE). They are
|
|
16
|
+
* added to the folded lines in memory (lib/routes-boards.js readLedger) and never written to a file
|
|
17
|
+
* staleOf(keys, snap, now) PURE → { stale, since, keys } whether the read these keys rest on is older than STALE_MS
|
|
18
|
+
*
|
|
19
|
+
* THE RULE. The read sets the state of a task nobody changed since it was made or imported. When someone changed the state in PMOS, the
|
|
20
|
+
* read wins only when it is newer and Jira moved the ticket after that change (its last update or its resolution day); a read with
|
|
21
|
+
* neither time may only close the task. So a task the PM reopened stays open until Jira moves. A reading the search did not return
|
|
22
|
+
* (marked stale) changes nothing.
|
|
23
|
+
* STALE. The Jira read is due every day: a read older than 26 hours (lib/freshness.js, jira stale_after_ms) is stale, and so is a task
|
|
24
|
+
* key no read has covered yet. A forecast never rests on a stale read (lib/forecast.js, lib/kind-control.js).
|
|
25
|
+
*
|
|
26
|
+
* BOUNDARY. No network, no write: the only input is the ledger lines and the stored Jira snapshots.
|
|
27
|
+
*/
|
|
28
|
+
const H = 3600 * 1000;
|
|
29
|
+
const STALE_MS = 26 * H;
|
|
30
|
+
const BY = 'tracker:jira';
|
|
31
|
+
const LEAD_KEY = /^\s*\[?([A-Z][A-Z0-9_]{0,19}-\d{1,7})\]?(?![A-Za-z0-9-])/;
|
|
32
|
+
const CLOSED_NOT_DONE = /invalid|not an issue|won'?t|cancel|duplicate|reject|obsolete|not (?:needed|required|a bug)|declined|abandon/i;
|
|
33
|
+
const TASK_KINDS = new Set(['task', 'task-update', 'task-remove', 'task-restore']);
|
|
34
|
+
|
|
35
|
+
/** The Jira key a task title starts with, upper case; null when it names none. */
|
|
36
|
+
const NOT_TICKETS = /^(CVE|CWE|GHSA|RFC|ISO|SOC|PCI|COVID|ES|TLS|SHA|UTF|AES|RSA|HTTP)-/; // advisory, standard and version ids, not tickets
|
|
37
|
+
function keyOf(title) {
|
|
38
|
+
const m = LEAD_KEY.exec(String(title == null ? '' : title));
|
|
39
|
+
return m && !NOT_TICKETS.test(m[1]) ? m[1] : null;
|
|
40
|
+
}
|
|
41
|
+
const ms = (s) => { const t = Date.parse(String(s || '')); return Number.isFinite(t) ? t : 0; };
|
|
42
|
+
|
|
43
|
+
/** Every task of the ledger lines whose title names a Jira key, folded the way scripts/boards.js folds tasks (first `task` line wins,
|
|
44
|
+
* `task-update` changes it, `task-remove` takes it out and `task-restore` puts it back). */
|
|
45
|
+
function keyedTasks(lines) {
|
|
46
|
+
const all = new Map(); const removed = new Map();
|
|
47
|
+
for (const e of lines || []) {
|
|
48
|
+
if (!e || typeof e !== 'object' || !TASK_KINDS.has(e.kind) || typeof e.task !== 'string') continue;
|
|
49
|
+
if (e.kind === 'task') {
|
|
50
|
+
if (all.has(e.task) || typeof e.initiative !== 'string') continue;
|
|
51
|
+
// stateAt is the time someone CHANGED the state: the state a task was created (or imported) with is no decision
|
|
52
|
+
all.set(e.task, { task: e.task, initiative: e.initiative, title: String(e.title || ''), state: e.state || 'To do', stateAt: null });
|
|
53
|
+
} else if (e.kind === 'task-update') {
|
|
54
|
+
const t = all.get(e.task); if (!t) continue;
|
|
55
|
+
if (typeof e.initiative === 'string' && e.initiative) t.initiative = e.initiative;
|
|
56
|
+
if (typeof e.title === 'string' && e.title.trim()) t.title = e.title.trim();
|
|
57
|
+
if (typeof e.state === 'string' && e.state) { t.state = e.state === 'In review' ? 'In progress' : e.state; t.stateAt = e.at || t.stateAt; }
|
|
58
|
+
} else if (e.kind === 'task-remove') {
|
|
59
|
+
if (all.has(e.task)) { removed.set(e.task, all.get(e.task)); all.delete(e.task); }
|
|
60
|
+
} else if (e.kind === 'task-restore') {
|
|
61
|
+
if (removed.has(e.task) && !all.has(e.task)) { all.set(e.task, removed.get(e.task)); removed.delete(e.task); }
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const out = new Map();
|
|
65
|
+
for (const t of all.values()) { const key = keyOf(t.title); if (key) out.set(t.task, { ...t, key }); }
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The keys each initiative's tasks name, sorted. Archived tasks are left out: nobody plans them. */
|
|
70
|
+
function keysByInitiative(lines) {
|
|
71
|
+
const by = new Map();
|
|
72
|
+
for (const t of keyedTasks(lines).values()) {
|
|
73
|
+
if (t.state === 'Archived') continue;
|
|
74
|
+
if (!by.has(t.initiative)) by.set(t.initiative, new Set());
|
|
75
|
+
by.get(t.initiative).add(t.key);
|
|
76
|
+
}
|
|
77
|
+
return new Map([...by].map(([k, v]) => [k, [...v].sort()]));
|
|
78
|
+
}
|
|
79
|
+
/** keysByInitiative from the repository's own task ledger; an empty Map when it cannot be read. */
|
|
80
|
+
function readKeys(root) {
|
|
81
|
+
let raw = null;
|
|
82
|
+
try { raw = require('./task-store.js').readStore(root); } catch { raw = null; }
|
|
83
|
+
const lines = [];
|
|
84
|
+
for (const x of raw || []) { if (typeof x !== 'string') { lines.push(x); continue; } try { lines.push(JSON.parse(x)); } catch { /* a torn line */ } }
|
|
85
|
+
return keysByInitiative(lines);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** A Jira reading as a task state. */
|
|
89
|
+
function stateOf(rd) {
|
|
90
|
+
if (!rd) return null;
|
|
91
|
+
const s = String(rd.status || ''), cat = String(rd.category || '').toLowerCase();
|
|
92
|
+
const done = cat === 'done' || /\b(done|closed|resolved|released|complete|shipped|deployed)\b/i.test(s) || CLOSED_NOT_DONE.test(s);
|
|
93
|
+
if (done) return CLOSED_NOT_DONE.test(s) ? "Won't do" : 'Done';
|
|
94
|
+
if (cat === 'doing' || cat === 'indeterminate' || /progress|doing|review|\bqa\b|test|block|started|verif|\buat\b/i.test(s)) return 'In progress';
|
|
95
|
+
return 'To do';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The task-update lines the last Jira read makes. snapOf(initiative) → { fetchedAt, tickets: Map } | null (lib/jira-status.js
|
|
100
|
+
* readSnapshot). Each line is { at: the read's time, by: 'tracker:jira', kind: 'task-update', task, state, why, tracker: true }.
|
|
101
|
+
*/
|
|
102
|
+
function trackerLines(lines, snapOf) {
|
|
103
|
+
const out = []; const snaps = new Map();
|
|
104
|
+
const snap = (ini) => { if (!snaps.has(ini)) { let s = null; try { s = snapOf(ini) || null; } catch { s = null; } snaps.set(ini, s); } return snaps.get(ini); };
|
|
105
|
+
for (const t of keyedTasks(lines).values()) {
|
|
106
|
+
if (t.state === 'Archived') continue;
|
|
107
|
+
const s = snap(t.initiative);
|
|
108
|
+
if (!s || !s.fetchedAt || !s.tickets || !s.tickets.get) continue;
|
|
109
|
+
const rd = s.tickets.get(t.key);
|
|
110
|
+
if (!rd || rd.stale) continue;
|
|
111
|
+
const want = stateOf(rd);
|
|
112
|
+
if (!want || want === t.state) continue;
|
|
113
|
+
const readAt = ms(s.fetchedAt), changed = ms(t.stateAt);
|
|
114
|
+
if (!readAt || readAt <= changed) continue; // the PM (or an agent) changed the task after the read
|
|
115
|
+
if (changed) {
|
|
116
|
+
// someone changed the state in PMOS: Jira wins only when it moved after that (its last update or resolution), or, when the read
|
|
117
|
+
// carries neither time, only to close the task
|
|
118
|
+
const jiraAt = Math.max(ms(rd.updated), ms(rd.resolved));
|
|
119
|
+
const closes = want === 'Done' || want === "Won't do";
|
|
120
|
+
if (jiraAt ? jiraAt <= changed : !closes) continue;
|
|
121
|
+
}
|
|
122
|
+
out.push({ at: s.fetchedAt, by: BY, kind: 'task-update', task: t.task, state: want, tracker: true,
|
|
123
|
+
why: `Jira says ${String(rd.status || want).slice(0, 40)} (${t.key}, read ${String(s.fetchedAt).slice(0, 16).replace('T', ' ')} UTC)` });
|
|
124
|
+
}
|
|
125
|
+
return out.sort((a, b) => String(a.at).localeCompare(String(b.at)));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Whether the read `keys` rest on is stale: no read, a read older than STALE_MS, or keys the read did not return. */
|
|
129
|
+
function staleOf(keys, snap, now = Date.now()) {
|
|
130
|
+
const list = [...new Set((keys || []).filter(Boolean))];
|
|
131
|
+
if (!list.length) return { stale: false, since: null, keys: [] };
|
|
132
|
+
if (!snap || !snap.fetchedAt) return { stale: true, since: null, keys: list };
|
|
133
|
+
const old = now - ms(snap.fetchedAt) > STALE_MS;
|
|
134
|
+
const missing = list.filter((k) => { const r = snap.tickets && snap.tickets.get ? snap.tickets.get(k) : null; return !r || r.stale; });
|
|
135
|
+
return { stale: old || missing.length > 0, since: snap.fetchedAt, keys: old ? list : missing };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
module.exports = { STALE_MS, BY, keyOf, keyedTasks, keysByInitiative, readKeys, stateOf, trackerLines, staleOf };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.666.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.666.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -24,7 +24,7 @@ Rules that always hold:
|
|
|
24
24
|
Procedure:
|
|
25
25
|
0. Ask first, when the task names no initiative. Run `pmos refresh since jira`. If it says "read in full", go to step 1. If it says "ask first", note the number of minutes it prints. Run `pmos jira query` and `pmos jira query --sprints`, and run each search they print with ` AND updated >= -<minutes>m` added (put the search in brackets first), asking only for the key field and one result. If no search returns an issue, run `pmos refresh same jira`, finish with "Checked: no change in Jira in the last <minutes> minutes", and stop. If any search returns an issue, or a search fails, go to step 1 and read in full.
|
|
26
26
|
0a. One sprint, when the task names it ("This check: sprint …"): the PM asked PMOS to read a closed sprint it never saw. Run `pmos jira query --sprint "<the sprint's name>"`, run that search with the fields of step 2, fetch every page, save the result in the scratch folder in the shape of step 3, run `pmos jira sync --sprint "<the sprint's name>" --from <the file>`, finish with "Checked: <the sprint's name>, <N> tickets kept", and stop. Do nothing else in that run.
|
|
27
|
-
1. If the task names one initiative ("This check: initiative …"), check that one only: run `pmos jira query <initiative>`. Otherwise run `pmos jira query`: each line is an initiative id, a tab and the Jira search (JQL) to run for it. An initiative PMOS pushed no ticket for, but which is linked to Jira epics, gets a search for those epics and the issues under them. If no initiative has a ticket or an epic in Jira, say so in one line and stop.
|
|
27
|
+
1. If the task names one initiative ("This check: initiative …"), check that one only: run `pmos jira query <initiative>`. Otherwise run `pmos jira query`: each line is an initiative id, a tab and the Jira search (JQL) to run for it. An initiative PMOS pushed no ticket for, but which is linked to Jira epics, gets a search for those epics and the issues under them. An initiative whose tasks start with a Jira key (tasks imported from Jira, such as "IDPF-2746 · Send verification email") gets those tickets in its search too: PMOS sets each task's state from what you read. If no initiative has a ticket or an epic in Jira, say so in one line and stop.
|
|
28
28
|
2. For each initiative, run its search with the Jira search tool and the fields in rule 3, at most 50 issues per page. The sprint is a custom field named "Sprint" whose id differs per site (often `customfield_10020`, on some sites `customfield_10004`). If the first page comes back with no Sprint field, ask once for every field of one issue (`*all`), find the field whose value is a list of sprints (each with a name and a state), and ask for that id from then on. Story points are also a custom field, named "Story Points" or "Story point estimate" (often `customfield_10016`); ask for it by name. Fetch every page.
|
|
29
29
|
3. Save the result as JSON in the scratch folder, for example `<scratch>/jira-<initiative>.json`, as a list with one object per issue:
|
|
30
30
|
`{"key", "summary", "status", "category", "type", "parent", "sprint", "subtasks", "points", "resolved", "flagged", "reason", "url"}`
|