create-pmos 0.665.0 → 0.667.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/package.json +28 -22
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/changelog.json +27 -2
  7. package/workspace/guide/cli.md +13 -0
  8. package/workspace/guide/jira.md +19 -0
  9. package/workspace/guide/layout.md +1 -1
  10. package/workspace/lib/forecast.js +5 -2
  11. package/workspace/lib/headless.js +4 -1
  12. package/workspace/lib/jira-cli.js +36 -2
  13. package/workspace/lib/jira-status.js +32 -10
  14. package/workspace/lib/jira-tickets.js +101 -0
  15. package/workspace/lib/kind-control.js +10 -0
  16. package/workspace/lib/pmos-verbs.js +3 -0
  17. package/workspace/lib/question-batch.js +22 -8
  18. package/workspace/lib/refresh-run.js +9 -3
  19. package/workspace/lib/routes-boards.js +37 -2
  20. package/workspace/lib/routes-kind-control.js +7 -1
  21. package/workspace/lib/routes-your-move.js +23 -4
  22. package/workspace/lib/signoff-cli.js +87 -0
  23. package/workspace/lib/signoffs.js +112 -0
  24. package/workspace/lib/task-jira.js +138 -0
  25. package/workspace/lib/ticket-dry-run.js +164 -0
  26. package/workspace/package-lock.json +2 -2
  27. package/workspace/package.json +1 -1
  28. package/workspace/public/pm/cozy-library.css +1 -0
  29. package/workspace/public/pm/premium-library.js +9 -3
  30. package/workspace/run-tests.js +43 -1
  31. package/workspace/skills/initiative-drive.skill +8 -1
  32. package/workspace/skills/jira-sync.skill +1 -1
  33. package/workspace/test-lists/dry-run-tickets-before-build.json +11 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.665.0",
3
+ "version": "0.667.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,27 @@
34
34
  ],
35
35
  "pmosChanges": [
36
36
  {
37
- "v": "0.665.0",
38
- "at": "2026-11-22T04:21:42.729Z",
37
+ "v": "0.667.0",
38
+ "at": "2026-11-22T04:39:52.182Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1456,
43
+ "t": "Library draws 40 rows a group and hides every Final badge",
44
+ "s": "Library draws 40 rows a group and hides every Final badge",
45
+ "k": "fix"
46
+ },
47
+ {
48
+ "n": 1447,
49
+ "t": "Dry-run each ticket before it is built, and outside sign-offs on the same question card",
50
+ "s": "Dry-run each ticket before it is built, and outside sign-offs on the same question card",
51
+ "k": "new"
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ "v": "0.666.0",
57
+ "at": "2026-11-22T04:26:58.946Z",
39
58
  "f": 4,
40
59
  "prs": [
41
60
  {
@@ -49,6 +68,12 @@
49
68
  "t": "A task opened from a place is the full popup from design system blocks",
50
69
  "s": "A task opened from a place is the full popup from design system blocks",
51
70
  "k": "new"
71
+ },
72
+ {
73
+ "n": 1453,
74
+ "t": "Read the tracker daily for all products, never forecast from a stale state",
75
+ "s": "Read the tracker daily for all products, never forecast from a stale state",
76
+ "k": "new"
52
77
  }
53
78
  ]
54
79
  },
@@ -321,25 +346,6 @@
321
346
  "k": "new"
322
347
  }
323
348
  ]
324
- },
325
- {
326
- "v": "0.635.0",
327
- "at": "2026-11-19T14:42:50.865Z",
328
- "f": 4,
329
- "prs": [
330
- {
331
- "n": 1416,
332
- "t": "Read repo identity off the event loop (stops the 15 s freezes)",
333
- "s": "Read repo identity off the event loop (stops the 15 s freezes)",
334
- "k": "fix"
335
- },
336
- {
337
- "n": 1417,
338
- "t": "One line per brief item or Jira ticket; Jira Work shows its key",
339
- "s": "One line per brief item or Jira ticket; Jira Work shows its key",
340
- "k": "fix"
341
- }
342
- ]
343
349
  }
344
350
  ]
345
351
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@6d64f247
1
+ kernel-source: pmos@09022054
2
2
  assembled: 2026-11-22
3
3
  mode: vendor
@@ -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:21:39Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T04:39:48Z"}
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:21:39Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T04:39:48Z"}
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:21:39Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T04:39:48Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,7 +1,26 @@
1
1
  [
2
2
  {
3
- "v": "0.665.0",
4
- "at": "2026-11-22T04:21:42.729Z",
3
+ "v": "0.667.0",
4
+ "at": "2026-11-22T04:39:52.182Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1456,
9
+ "t": "Library draws 40 rows a group and hides every Final badge",
10
+ "s": "Library draws 40 rows a group and hides every Final badge",
11
+ "k": "fix"
12
+ },
13
+ {
14
+ "n": 1447,
15
+ "t": "Dry-run each ticket before it is built, and outside sign-offs on the same question card",
16
+ "s": "Dry-run each ticket before it is built, and outside sign-offs on the same question card",
17
+ "k": "new"
18
+ }
19
+ ]
20
+ },
21
+ {
22
+ "v": "0.666.0",
23
+ "at": "2026-11-22T04:26:58.946Z",
5
24
  "f": 4,
6
25
  "prs": [
7
26
  {
@@ -15,6 +34,12 @@
15
34
  "t": "A task opened from a place is the full popup from design system blocks",
16
35
  "s": "A task opened from a place is the full popup from design system blocks",
17
36
  "k": "new"
37
+ },
38
+ {
39
+ "n": 1453,
40
+ "t": "Read the tracker daily for all products, never forecast from a stale state",
41
+ "s": "Read the tracker daily for all products, never forecast from a stale state",
42
+ "k": "new"
18
43
  }
19
44
  ]
20
45
  },
@@ -620,9 +620,22 @@ The benchmark needs a signed-in agent CLI. It never pushes and never opens a pul
620
620
  - `pmos jira which <KEY>`
621
621
  - `pmos jira moves`
622
622
  - `pmos jira moved <move id> --status "<Jira status>"` or `--refused "<why>"`
623
+ - `pmos jira guesses <initiative> [--from <file|->]`
624
+ - `pmos jira answer <initiative> <ticket> <n> --text "<answer>"`
623
625
 
624
626
  Every command takes `--json` and `--root <dir>`.
625
627
 
628
+ ### pmos signoff
629
+
630
+ An outside sign-off is a yes that someone outside the team must give before the work can go on: a scope from Marketing, a price from Finance, a go or no-go. One line records each one.
631
+
632
+ - `pmos signoff ask <initiative> --who "<name or team>" --what "<what they must say yes to>" [--asked <date>] [--due <date>] [--source <pointer>]` records a sign-off the initiative waits on.
633
+ - `pmos signoff answer <id> --answer "<what they said>" --source <pointer>` records the answer. It needs a pointer to where it was given.
634
+ - `pmos signoff drop <id> [--why "<reason>"]` closes a sign-off that is no longer needed.
635
+ - `pmos signoff list [<initiative>] [--all]` lists the open sign-offs. `--all` lists the answered and dropped ones too.
636
+
637
+ An open sign-off that waited 3 days, or is past its due date, goes on your question list for the day, on the same card as the dry-run gaps of your tickets ([Jira tickets](jira.md)). Nothing is sent. Every command takes `--json` and `--root <dir>`.
638
+
626
639
  ## Intelligence and reports
627
640
 
628
641
  ### pmos forecast
@@ -92,6 +92,25 @@ To see every ticket in the terminal:
92
92
  pmos jira show <initiative>
93
93
  ```
94
94
 
95
+ ## The dry run: where a builder would guess
96
+
97
+ A ticket points to the PRD, but the builder holds only the ticket. Before you select the tickets, PMOS dry-runs them: the initiative's background run reads each drafted ticket as a builder would, and lists every point where it would have to guess. For each guess it quotes the PRD lines that answer it.
98
+
99
+ - PMOS keeps a quote only when it finds it word for word in the PRD, the done test or the initiative record. A quote it cannot find is dropped.
100
+ - The quoted lines go into the ticket's Additional Context, under **From the PRD (dry run)**. A ticket you edited, selected or pushed is not changed: your text wins.
101
+ - A guess that no document answers is a gap. The gaps go on your question list for the day, one card per initiative, beside the changes PMOS held and the outside sign-offs with no answer ([pmos signoff](cli.md)).
102
+ - When you answer a gap, the answer goes into the ticket and the question leaves the list. When the PRD item of a ticket changes, its dry run is out of date and its gaps leave the list until the dry run runs again.
103
+
104
+ In the terminal:
105
+
106
+ ```
107
+ pmos jira guesses <initiative>
108
+ pmos jira guesses <initiative> --from guesses.json
109
+ pmos jira answer <initiative> <ticket> <n> --text "Fail closed: show the paywall"
110
+ ```
111
+
112
+ The file has one entry for each ticket: `{"tickets": [{"id": "018", "guesses": [{"question": "If the flag lookup times out, is the article free or locked?", "prd": ["<a line quoted from the PRD>"], "answered": "yes|partly|no"}]}]}`.
113
+
95
114
  ## Choose the epic
96
115
 
97
116
  The **Send to Jira** sheet shows the epic of each group. Press **Change** to choose **Create a new epic** (named after the group, or after the initiative for the tickets in no group) or to paste the link or key of an existing epic. After the first push the epic of a group is fixed. In the terminal:
@@ -203,7 +203,7 @@ A Jira date and the planned finish of an initiative get no ✓: PMOS cannot writ
203
203
 
204
204
  ## Library
205
205
 
206
- **Library** in the navigation is a catalogue of everything that was made for your work, from every product: documents, links, meeting notes and prototypes. Each thing is one row: its kind icon, its name, a grey line with its kind, product (when you have two or more), what it is about, who made it and the day, and its state when it is not Final. Reports are not here: a report repeats, so it lives in Routine.
206
+ **Library** in the navigation is a catalogue of everything that was made for your work, from every product: documents, links, meeting notes and prototypes. Each thing is one row: its kind icon, its name, a grey line with its kind, product (when you have two or more), what it is about, who made it and the day, and its state when it is not Final (a Final edition, such as v2, shows no state either). A long group shows its first 40 rows; **Show 40 more** under them shows the next ones. Reports are not here: a report repeats, so it lives in Routine.
207
207
 
208
208
  - **Kind** says what the thing is: PRD, Strategic brief, Design brief, Done test, Meeting notes, Prototype, Link · Confluence, and so on. PMOS reads it from the file's `type` first, then from its title ("Brief: …") and its file name. When the title only repeats the kind, the name leaves it out: "Brief: Scarlet lucky draw" shows as "Scarlet lucky draw", Kind Strategic brief.
209
209
  - **About** is the program and the initiative ("Project Ascent › Tender new CIAM"). It is empty when it repeats the name.
@@ -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) > HELD_DAYS * DAY) return Object.assign(out, { state: 'held', was: state, why: 'Jira not read since ' + asOf + ', so the range is held where it was.' });
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
  }
@@ -175,7 +175,10 @@ const TOOLS = Object.freeze({
175
175
  ask: Object.freeze(['Read', 'Glob', 'Grep']),
176
176
  // core-documents: the driver drafts a current-stage document that is due with `pmos coredoc write` (a draft only; Keep issues it).
177
177
  drive: Object.freeze(['Read', 'Glob', 'Grep', 'Bash(pmos driver *)', 'Bash(pmos initiative list *)', 'Bash(pmos initiative export *)',
178
- 'Bash(pmos coredoc write *)', 'Bash(git log *)', 'Bash(ls *)', 'Bash(date *)']),
178
+ 'Bash(pmos coredoc write *)', 'Bash(git log *)', 'Bash(ls *)', 'Bash(date *)',
179
+ // dry-run-tickets-before-build: the dry run of drafted tickets and the outside sign-offs. PMOS-local records only: nothing is sent,
180
+ // and the PM's answer to a gap (`pmos jira answer`) is not in the list.
181
+ 'Bash(pmos jira show *)', 'Bash(pmos jira guesses *)', 'Bash(pmos signoff ask *)', 'Bash(pmos signoff answer *)', 'Bash(pmos signoff list *)']),
179
182
  // The web run: WebSearch, WebFetch and the one verb that files a finding. No Read, no Glob, no Grep, no repository path in its prompt or its add-dirs.
180
183
  // `pmos scan section` writes a section of a report document; the web run gives each web claim a URL it read.
181
184
  'scan-web': Object.freeze(['WebSearch', 'WebFetch', 'Bash(pmos scan file *)', 'Bash(pmos scan section *)']),
@@ -18,6 +18,8 @@
18
18
  * pmos jira which <KEY> [<KEY> …] the initiative a Jira key belongs to
19
19
  * pmos jira moves the status moves the PM asked in PMOS, not answered yet (lib/jira-moves.js)
20
20
  * pmos jira moved <move id> --status "<Jira status>" | --refused "<why>" the agent's answer for one move
21
+ * pmos jira guesses <initiative> [--from <file|->] a ticket dry run (lib/ticket-dry-run.js), recorded or shown
22
+ * pmos jira answer <initiative> <ticket> <n> --text "<answer>" the PM's answer to one dry-run gap
21
23
  * every command: [--json] [--root <dir>]
22
24
  *
23
25
  * This command never talks to Jira. An agent session does, with the PM's own Atlassian connection (D53, D88), and
@@ -33,12 +35,16 @@ const jiraMoves = require('./jira-moves.js');
33
35
  const planItems = require('./plan-items.js');
34
36
  const guard = require('./pm-guard.js');
35
37
 
36
- const COMMANDS = { jira: ['draft', 'show', 'epic', 'approve', 'pending', 'record', 'query', 'sync', 'summary', 'which', 'moves', 'moved'] };
38
+ const COMMANDS = { jira: ['draft', 'show', 'epic', 'approve', 'pending', 'record', 'query', 'sync', 'summary', 'which', 'moves', 'moved', 'guesses', 'answer'] };
37
39
  const USAGE = [
38
40
  'usage: pmos jira draft|show|epic|approve|pending|record|query|sync|summary|which — Jira tickets from the PRD, and their status',
39
41
  ' pmos jira draft <initiative> [--dry-run] draft one ticket per PRD item, in the ticket template',
40
42
  ' With no PRD stories section: one ticket per done-test check, else one per open task.',
41
43
  ' pmos jira show <initiative> every ticket, what needs you, and its status in Jira',
44
+ ' pmos jira guesses <initiative> --from <file|-> record a dry run: each ticket\'s guesses, with the PRD lines that answer them',
45
+ ' Quotes not found word for word in the PRD, done test or record are dropped. Gaps go to the day\'s question list.',
46
+ ' pmos jira guesses <initiative> the dry run so far: the guesses of each ticket and the open gaps',
47
+ ' pmos jira answer <initiative> <ticket> <n> --text "<answer>" the PM\'s answer to gap n: it goes into the ticket',
42
48
  ' pmos jira epic <initiative> new|<KEY or link> [--group <g>] create a new epic at the first push, or use an existing one',
43
49
  ' pmos jira approve <initiative> <ID> … select tickets to push (you, in your own terminal)',
44
50
  ' pmos jira pending <initiative> what the push creates or updates in Jira',
@@ -58,7 +64,7 @@ const USAGE = [
58
64
  'This command never calls Jira. Your agent reads and writes Jira with your own connection.',
59
65
  ];
60
66
  const BOOL = new Set(['json', 'dry-run', 'help', 'sprints']);
61
- const VALUE = new Set(['from', 'query', 'root', 'epic', 'updated', 'group', 'status', 'refused', 'sprint']);
67
+ const VALUE = new Set(['from', 'query', 'root', 'epic', 'updated', 'group', 'status', 'refused', 'sprint', 'text']);
62
68
  const FLAG_TEXT = { 'prd-changed': 'PRD changed', removed: 'Removed from PRD', blocked: 'Blocked', incomplete: 'Missing text', pushing: 'Selected, waiting for the push', edited: 'Edited, not in Jira yet' };
63
69
 
64
70
  function parse(argv) {
@@ -216,6 +222,34 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
216
222
  lines.push('Read them on the Jira tickets tab, or with pmos jira show. Select the ready ones there, or with pmos jira approve.');
217
223
  return out(r, lines);
218
224
  }
225
+ if (verb === 'guesses') {
226
+ if (flags.from == null) {
227
+ const gaps = jiraTickets.dryRunGaps(root, initiative);
228
+ const v = jiraTickets.dryRunView(root, initiative);
229
+ if (!v) return fail(`no ticket draft for ${initiative} — press Draft tickets, or run pmos jira draft ${initiative}`);
230
+ const done = v.filter((t) => t.dryRun);
231
+ const lines = [`${initiative} · ${done.length} of ${v.length} ${v.length === 1 ? 'ticket' : 'tickets'} dry-run · ${gaps.length} open ${gaps.length === 1 ? 'gap' : 'gaps'}`];
232
+ for (const t of done) lines.push(` ${t.id} · ${t.dryRun.guesses} ${t.dryRun.guesses === 1 ? 'guess' : 'guesses'} · ${t.dryRun.answered} answered · ${t.dryRun.partly} partly · ${t.dryRun.gaps} ${t.dryRun.gaps === 1 ? 'gap' : 'gaps'}${t.dryRun.stale ? ' · PRD changed since: run it again' : ''}`);
233
+ for (const g of gaps) lines.push(` gap ${g.ticket} ${g.n} · ${g.q}`);
234
+ return out({ ok: true, initiative, tickets: done.map((t) => ({ id: t.id, ...t.dryRun })), gaps }, lines);
235
+ }
236
+ const r = jiraTickets.dryRun(root, initiative, readInput(flags.from, cwd, stdin), { now });
237
+ if (!r.ok) return fail(r.error);
238
+ const lines = [`${initiative} · ${r.tickets.length} ${r.tickets.length === 1 ? 'ticket' : 'tickets'} · ${r.guesses} guesses: ${r.answered} answered, ${r.partly} partly, ${r.gaps} not in any document`];
239
+ if (r.written.length) lines.push(` PRD lines copied into ${r.written.join(', ')}`);
240
+ for (const k of r.kept) lines.push(` ${k.id} not changed: ${k.why}`);
241
+ if (r.unverified) lines.push(` ${r.unverified} ${r.unverified === 1 ? 'quote was' : 'quotes were'} not found word for word and dropped`);
242
+ if (r.unknown.length) lines.push(` not in the draft: ${r.unknown.join(', ')}`);
243
+ if (r.gaps) lines.push(` The ${r.gaps === 1 ? 'gap goes' : r.gaps + ' gaps go'} to the PM's question list for today or tomorrow.`);
244
+ return out(r, lines);
245
+ }
246
+ if (verb === 'answer') {
247
+ const [, ticket, n] = pos;
248
+ if (!ticket || !n || !flags.text) return need('<initiative> <ticket> <n> --text "<the answer>"');
249
+ const r = jiraTickets.answerDryRun(root, initiative, ticket, n, flags.text, { now });
250
+ if (!r.ok) return fail(r.error);
251
+ return out(r, [`${initiative} ${ticket} gap ${r.n} answered${r.written.length ? ' and added to the ticket' : ''}${r.kept.length ? ` · the ticket was not changed: ${r.kept[0].why}` : ''}`]);
252
+ }
219
253
  if (verb === 'show') {
220
254
  const r = jiraTickets.view(root, initiative, { snapshot: jiraStatus.readSnapshot(root, initiative) });
221
255
  if (!r.ok) return fail(r.error);
@@ -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
- function queryFor(root, initiative) {
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 keys = [...jiraTickets.pushedTickets(root, initiative).tickets.keys()];
47
- if (keys.length) return { ok: true, initiative, linked: true, mode: 'pushed', keys, query: `key in (${keys.join(', ')}) ORDER BY key` };
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
- if (epics.length) return { ok: true, initiative, linked: true, mode: 'epic', keys: epics, epics, query: `key in (${epics.join(', ')}) OR parent in (${epics.join(', ')}) ORDER BY key` };
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 ids = [...new Set([...jiraTickets.draftedInitiatives(root), ...jiraTickets.epicInitiatives(root)])].sort();
55
- return ids.map((id) => queryFor(root, id)).filter((q) => q.ok);
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
- if (!pushed.size && !epics.length) return { ok: false, error: `${initiative} has no ticket in Jira yet — push its tickets first, or link its Jira epic` };
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
- const keep = pushed.size ? (i) => pushed.has(i.key) : (i) => epics.includes(i.key) || !i.parent || epics.includes(i.parent);
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 ? [...pushed.keys()] : [...new Set([...epics, ...got.keys(), ...(prev ? [...prev.tickets.keys()].filter((k) => { const r = prev.tickets.get(k); return epics.includes(k) || !r.parent || epics.includes(r.parent); }) : [])])];
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;
@@ -549,6 +549,106 @@ function draft(root, initiative, { dryRun = false, now } = {}) {
549
549
  return result;
550
550
  }
551
551
 
552
+ // ── the dry run (initiative dry-run-tickets-before-build; A194) ─────────────────────────────────────
553
+ /** The dry-run helpers, loaded when a dry run is read or written. */
554
+ /** The state folder of the repository: <state>/tracker/ holds the ticket drafts, dry runs and sign-offs. */
555
+ function stateDirOf(root) { return stateDir(root); }
556
+ function DRm() { return require('./ticket-dry-run.js'); }
557
+ function dryRunPath(root, initiative) { return path.join(jiraDir(root), `${initiative}-dryrun.json`); }
558
+ /** The text a dry-run quote must be found in: the PRD, the story files, the done test and the record. */
559
+ function dryRunHaystack(root, initiative, st) {
560
+ const parts = [];
561
+ const rfm = recordFm(root, initiative) || {};
562
+ const prd = prdOf(rfm);
563
+ if (prd) { const t = readPrd(root, prd); if (t != null) parts.push(t); }
564
+ for (const rel of (st && st.ok ? st.sources : []) || []) { if (rel === prd) continue; const t = readPrd(root, rel); if (t != null) parts.push(t); }
565
+ const dt = readDoneTest(root, rfm); if (dt) parts.push(dt.text);
566
+ const file = planTree.recordPath(root, initiative);
567
+ if (file) { try { parts.push(fs.readFileSync(file, 'utf8')); } catch { /* no record text */ } }
568
+ return parts.join('\n');
569
+ }
570
+ /** A ticket the dry run may write into: drafted by PMOS, not edited, not selected, not in Jira. The PM's text always wins. */
571
+ function dryRunWritable(t) { return !t.jira && !t.approved && (!t.drafted || t.drafted === contentHash(t)); }
572
+ /** Put each ticket's dry-run block into its Additional Context. → { written: [id], kept: [{ id, why }] } */
573
+ function applyDryRun(d, file, only) {
574
+ const written = [], kept = [];
575
+ for (const t of d.tickets) {
576
+ const e = file.tickets[t.id];
577
+ if (!e || (only && !only.has(t.id))) continue;
578
+ if (e.source && t.source && e.source !== t.source) { kept.push({ id: t.id, why: 'its PRD item changed since the dry run: run it again' }); continue; }
579
+ if (!dryRunWritable(t)) { kept.push({ id: t.id, why: t.jira ? 'it is in Jira' : t.approved ? 'it is selected for a push' : 'you edited it' }); continue; }
580
+ const next = DRm().withBlock(t.sections.context, DRm().blockOf(e));
581
+ if (next === (t.sections.context || '')) continue;
582
+ t.sections.context = next; t.drafted = contentHash(t); written.push(t.id);
583
+ }
584
+ return { written, kept };
585
+ }
586
+ /**
587
+ * Record an agent's dry run of the drafted tickets: keep the quotes found in the documents, copy them into each ticket, and keep the
588
+ * gaps for the owner's question list. raw: the agent's JSON (lib/ticket-dry-run.js parse). → { ok, tickets, guesses, answered, partly,
589
+ * gaps, unverified, unknown, written, kept }
590
+ */
591
+ function dryRun(root, initiative, raw, { now } = {}) {
592
+ const { d, error } = mustDraft(root, initiative);
593
+ if (error) return { ok: false, status: 404, error };
594
+ const p = DRm().parse(raw);
595
+ if (!p.ok) return { ok: false, status: 400, error: p.error };
596
+ const st = items(root, initiative);
597
+ const byId = new Map(d.tickets.map((t) => [t.id, t]));
598
+ const c = DRm().check(p, { ids: new Set(byId.keys()), sourceOf: (id) => byId.get(id).source, haystack: dryRunHaystack(root, initiative, st), now });
599
+ if (!Object.keys(c.tickets).length) return { ok: false, status: 400, error: `no ticket of the draft is in the dry run (${c.unknown.join(', ') || 'none named'})` };
600
+ const file = DRm().merge(DRm().read(dryRunPath(root, initiative)), c, { initiative, now });
601
+ DRm().write(dryRunPath(root, initiative), file);
602
+ const ap = applyDryRun(d, file, new Set(Object.keys(c.tickets)));
603
+ if (ap.written.length) writeDraft(root, initiative, d, { now, prd: prdOf(recordFm(root, initiative)) });
604
+ const sum = { guesses: 0, answered: 0, partly: 0, gaps: 0 };
605
+ for (const e of Object.values(c.tickets)) { const k = DRm().countsOf(e); sum.guesses += k.guesses; sum.answered += k.answered; sum.partly += k.partly; sum.gaps += k.gaps; }
606
+ return { ok: true, initiative, tickets: Object.keys(c.tickets), ...sum, unverified: c.unverified, unknown: c.unknown, written: ap.written, kept: ap.kept, file: relOf(root, dryRunPath(root, initiative)) };
607
+ }
608
+ /** The PM's answer to a gap: it goes into the ticket and the question leaves the list. */
609
+ function answerDryRun(root, initiative, ticket, n, text, { now } = {}) {
610
+ const file = DRm().read(dryRunPath(root, initiative));
611
+ if (!file) return { ok: false, status: 404, error: `no dry run for ${initiative}: run the dry run first` };
612
+ const a = DRm().answer(file, ticket, n, text, now);
613
+ if (!a.ok) return { ok: false, status: 400, error: a.error };
614
+ DRm().write(dryRunPath(root, initiative), file);
615
+ const d = readDraft(root, initiative);
616
+ let ap = { written: [], kept: [] };
617
+ if (d) { ap = applyDryRun(d, file, new Set([ticket])); if (ap.written.length) writeDraft(root, initiative, d, { now, prd: prdOf(recordFm(root, initiative)) }); }
618
+ return { ok: true, initiative, ticket, n: a.guess.n, q: a.guess.q, answer: a.guess.answer, written: ap.written, kept: ap.kept };
619
+ }
620
+ /** The gaps of an initiative's dry run that nobody answered: [{ ticket, n, q }]. Stale and removed tickets are left out. */
621
+ function dryRunGaps(root, initiative) {
622
+ const file = DRm().read(dryRunPath(root, initiative));
623
+ if (!file) return [];
624
+ const d = readDraft(root, initiative);
625
+ const st = items(root, initiative);
626
+ const now = new Map((st.ok ? st.items : []).map((x) => [x.id, x.hash]));
627
+ // the PRD item as it is now (a ticket the PM edited keeps its old source hash, so the item says whether the PRD moved)
628
+ const src = new Map(((d && d.tickets) || []).map((t) => [t.id, now.get(t.id) || t.source || null]));
629
+ return DRm().gapsOf(file, (id) => (src.has(id) ? src.get(id) : undefined));
630
+ }
631
+ /** Each drafted ticket's dry run: [{ id, summary, dryRun: { guesses, answered, partly, gaps, open, stale } | null }]. stale: its PRD item
632
+ * changed since the dry run. null when no draft. */
633
+ function dryRunView(root, initiative) {
634
+ const d = readDraft(root, initiative);
635
+ if (!d) return null;
636
+ const file = DRm().read(dryRunPath(root, initiative));
637
+ const st = items(root, initiative);
638
+ const cur = new Map((st.ok ? st.items : []).map((x) => [x.id, x.hash]));
639
+ return d.tickets.map((t) => {
640
+ const e = file && file.tickets[t.id];
641
+ const now = cur.get(t.id) || t.source || null;
642
+ return { id: t.id, summary: t.summary, dryRun: e ? { ...DRm().countsOf(e), stale: !!(e.source && now && e.source !== now) } : null };
643
+ });
644
+ }
645
+ /** The initiatives with a dry-run file in this repository. */
646
+ function dryRunInitiatives(root) {
647
+ let names = [];
648
+ try { names = fs.readdirSync(jiraDir(root)); } catch { return []; }
649
+ return names.filter((n) => n.endsWith('-dryrun.json')).map((n) => n.slice(0, -'-dryrun.json'.length)).sort();
650
+ }
651
+
552
652
  // ── J4, J5, J10, J12 · what the tab draws ──────────────────────────────────────────────────────────
553
653
  function epicOf(d, rfm) {
554
654
  const fm = (d && d.fm) || {};
@@ -910,4 +1010,5 @@ module.exports = {
910
1010
  items, itemsInPrd, itemsInFile, fromItem, draft, view, edit, resolvePrd, setEpic, approve, pushPlan, record, groupsOf, groupId,
911
1011
  readDraft, parseDraft, pushedTickets, draftedInitiatives, epicInitiatives, epicKeysOf, linkedEpics, anchorOf, missingOf, contentHash, describe,
912
1012
  draftPath, draftRel, jiraDir, relOf, recordFm, prdOf,
1013
+ dryRun, answerDryRun, dryRunGaps, dryRunView, dryRunInitiatives, dryRunPath, stateDirOf,
913
1014
  };
@@ -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) {
@@ -48,6 +48,9 @@ const VERBS = Object.freeze({
48
48
  // Not a pm-os-absorb verb (run: null): people-directory added it through the same table.
49
49
  people: Object.freeze({ module: 'people-cli.js', run: null, guide: 'cli.md',
50
50
  help: 'pmos people list|show|record|settings … — the people you work with in this repository (pmos people help)' }),
51
+ // Not a pm-os-absorb verb (run: null): initiative dry-run-tickets-before-build added it through the same table.
52
+ signoff: Object.freeze({ module: 'signoff-cli.js', run: null, guide: 'cli.md',
53
+ help: 'pmos signoff ask|answer|drop|list … — the outside sign-offs an initiative waits on; open ones go on your question list (pmos signoff help)' }),
51
54
  // Not a pm-os-absorb verb (run: null): initiative my-work added it through the same table.
52
55
  'my-work': Object.freeze({ module: 'my-work-cli.js', run: null, guide: 'cli.md',
53
56
  help: 'pmos my-work list|show|submit … — the Jira tickets and WBS items assigned to you, ranked (pmos my-work help)' }),