create-pmos 0.760.0 → 0.762.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 (43) hide show
  1. package/package.json +39 -33
  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 +38 -0
  7. package/workspace/guide/cli.md +7 -1
  8. package/workspace/guide/home.md +1 -1
  9. package/workspace/guide/notes.md +15 -0
  10. package/workspace/lib/actor.js +8 -3
  11. package/workspace/lib/contradictions.js +137 -0
  12. package/workspace/lib/jira-cli.js +7 -2
  13. package/workspace/lib/jira-tiers.js +75 -10
  14. package/workspace/lib/meeting-focus.js +14 -1
  15. package/workspace/lib/open-questions.js +23 -5
  16. package/workspace/lib/outcome-judge.js +1 -1
  17. package/workspace/lib/outcome-props.js +51 -5
  18. package/workspace/lib/outcomes-cli.js +49 -3
  19. package/workspace/lib/plan-baseline.js +106 -0
  20. package/workspace/lib/proposal-runs.js +1 -1
  21. package/workspace/lib/proposals.js +1 -1
  22. package/workspace/lib/propose-cli.js +16 -7
  23. package/workspace/lib/routes-drift.js +30 -0
  24. package/workspace/lib/routes-meeting-focus.js +6 -1
  25. package/workspace/lib/routes-open-questions.js +9 -2
  26. package/workspace/lib/tracker-digest.js +23 -3
  27. package/workspace/lib/week-moves.js +8 -2
  28. package/workspace/package-lock.json +2 -2
  29. package/workspace/package.json +1 -1
  30. package/workspace/premium-rec-tab-test.js +2 -1
  31. package/workspace/public/pm/buddy-core.js +162 -0
  32. package/workspace/public/pm/buddy-float.js +63 -0
  33. package/workspace/public/pm/cozy-buddy.css +26 -0
  34. package/workspace/public/pm/cozy-buddy.js +59 -7
  35. package/workspace/public/pm/cozy-rec-tab.js +10 -2
  36. package/workspace/public/pm/moves-view.js +11 -1
  37. package/workspace/public/pm/open-questions-view.js +1 -0
  38. package/workspace/public/premium-buddy.html +4 -0
  39. package/workspace/skills/initiative-propose.skill +2 -2
  40. package/workspace/skills/jira-sync.skill +1 -1
  41. package/workspace/test-lists/outcome-checks-finish.json +9 -0
  42. package/workspace/test-lists/slip-baseline-contradictions.json +9 -0
  43. package/workspace/test-lists/tracker-digest.json +7 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.760.0",
3
+ "version": "0.762.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,44 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.762.0",
38
+ "at": "2026-11-24T05:23:23.423Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1717,
43
+ "t": "Every slip against the first plan, and records that disagree become one question (1c A102, A140)",
44
+ "s": "Every slip against the first plan, and records that disagree become one question (1c A102, A140)",
45
+ "k": "new"
46
+ },
47
+ {
48
+ "n": 1718,
49
+ "t": "The meeting buddy floats over any call app, with a wide topic view, a room view and a walk-in card",
50
+ "s": "The meeting buddy floats over any call app, with a wide topic view, a room view and a walk-in card",
51
+ "k": "new"
52
+ },
53
+ {
54
+ "n": 1715,
55
+ "t": "Outcome checks finish by themselves",
56
+ "s": "Outcome checks finish by themselves",
57
+ "k": "new"
58
+ }
59
+ ]
60
+ },
61
+ {
62
+ "v": "0.761.0",
63
+ "at": "2026-11-24T04:56:21.207Z",
64
+ "f": 4,
65
+ "prs": [
66
+ {
67
+ "n": 1716,
68
+ "t": "The standup digest sees every status change, from one daily search",
69
+ "s": "The standup digest sees every status change, from one daily search",
70
+ "k": "new"
71
+ }
72
+ ]
73
+ },
36
74
  {
37
75
  "v": "0.760.0",
38
76
  "at": "2026-11-24T02:57:16.535Z",
@@ -350,38 +388,6 @@
350
388
  "k": "new"
351
389
  }
352
390
  ]
353
- },
354
- {
355
- "v": "0.741.0",
356
- "at": "2026-11-23T09:00:39.651Z",
357
- "f": 4,
358
- "prs": [
359
- {
360
- "n": 1657,
361
- "t": "Initiative artefacts move into ⋯; Stages and Work breakdown take the full width",
362
- "s": "Initiative artefacts move into ⋯; Stages and Work breakdown take the full width",
363
- "k": "new"
364
- },
365
- {
366
- "n": 1658,
367
- "t": "Every Jira task in a work breakdown can be changed the same way",
368
- "s": "Every Jira task in a work breakdown can be changed the same way",
369
- "k": "fix"
370
- }
371
- ]
372
- },
373
- {
374
- "v": "0.740.0",
375
- "at": "2026-11-23T08:20:40.488Z",
376
- "f": 4,
377
- "prs": [
378
- {
379
- "n": 1654,
380
- "t": "A product's own words show their meaning on hover, on every page (A386)",
381
- "s": "A product's own words show their meaning on hover, on every page (A386)",
382
- "k": "new"
383
- }
384
- ]
385
391
  }
386
392
  ]
387
393
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@e8e8ef03
1
+ kernel-source: pmos@4b157acc
2
2
  assembled: 2026-11-24
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-24T02:57:14Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-24T05:23:19Z"}
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-24T02:57:14Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-24T05:23:19Z"}
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-24T02:57:14Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-24T05:23:19Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,42 @@
1
1
  [
2
+ {
3
+ "v": "0.762.0",
4
+ "at": "2026-11-24T05:23:23.423Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1717,
9
+ "t": "Every slip against the first plan, and records that disagree become one question (1c A102, A140)",
10
+ "s": "Every slip against the first plan, and records that disagree become one question (1c A102, A140)",
11
+ "k": "new"
12
+ },
13
+ {
14
+ "n": 1718,
15
+ "t": "The meeting buddy floats over any call app, with a wide topic view, a room view and a walk-in card",
16
+ "s": "The meeting buddy floats over any call app, with a wide topic view, a room view and a walk-in card",
17
+ "k": "new"
18
+ },
19
+ {
20
+ "n": 1715,
21
+ "t": "Outcome checks finish by themselves",
22
+ "s": "Outcome checks finish by themselves",
23
+ "k": "new"
24
+ }
25
+ ]
26
+ },
27
+ {
28
+ "v": "0.761.0",
29
+ "at": "2026-11-24T04:56:21.207Z",
30
+ "f": 4,
31
+ "prs": [
32
+ {
33
+ "n": 1716,
34
+ "t": "The standup digest sees every status change, from one daily search",
35
+ "s": "The standup digest sees every status change, from one daily search",
36
+ "k": "new"
37
+ }
38
+ ]
39
+ },
2
40
  {
3
41
  "v": "0.760.0",
4
42
  "at": "2026-11-24T02:57:16.535Z",
@@ -321,9 +321,14 @@ Run it in the product's repository, or pass `--root <dir>`. It changes nothing,
321
321
 
322
322
  - `pmos questions` lists every unanswered question across all initiatives, oldest first: one line per person and initiative. Each line says who can answer, how many days it has waited, and what PMOS does if nobody answers and by when. A question that has no safe default says why it waits for an answer.
323
323
  - The list holds the plan changes PMOS holds for want of a source, a drafted ticket's open questions, the outside sign-offs and the open drafts from PMOS's Driver. A draft changes nothing until you keep it, so its default is to drop it, 14 days after it was filed.
324
+ - It also holds records that disagree with each other, one line per initiative: an initiative that is closed or accepted while tasks are still open, a due date moved after the task was done, and an initiative whose tasks have all been closed for 14 days or more while it is still live. These lines have no default, because only you know which record is wrong. PMOS changes neither record. `node workspace/lib/contradictions.js list` in a product's repository shows each one with the ledger lines it comes from.
324
325
  - With the workspace running, the list is the same one the workspace reads. Without it, `pmos questions` reads the records on disk and says that held plan changes were not read.
325
326
  - `pmos questions age` prints the median age in days of the lines. Its last line is the number, so a script can read it.
326
327
 
328
+ ### Slip against the first plan
329
+
330
+ The first due date a task ever had is its baseline. PMOS reads it from the task's history, so you do not keep it by hand. `node workspace/lib/plan-baseline.js list` in a product's repository lists, per initiative, the open tasks now due later than their baseline, the task-days behind, and how many of those days rest on a move with no source. `node workspace/lib/plan-baseline.js count` prints the task-days with no source on its last line. It changes nothing.
331
+
327
332
  ### pmos press-release: a press release and FAQ for a bet
328
333
 
329
334
  Write the press release before the build ("working backwards"). Run it in the product's repository, or pass `--root <dir>`. No running workspace is needed.
@@ -363,6 +368,7 @@ Run them in the product's repository, or pass `--root <dir>`.
363
368
  - `pmos outcomes record <id> <worked|didnt-work|cant-tell> --evidence "<text>"` records your verdict on a due check.
364
369
  - `pmos outcomes test <id> --test "<text>" [--method data-count|fake-door|concierge|other] [--result planned|holds|fails|unclear] [--evidence "<text>"]` records the smallest test that could kill a ranked bet before it is built, and what the test showed. A result other than `planned` needs evidence. When the bet already has a named test, `--test` can be left out.
365
370
  - `pmos outcomes tests [--count]` lists the ranked bets with no smallest test, the tests that wait for a result, and the results. `--count` prints the number of bets with a result in the last 14 days.
371
+ - `pmos outcomes rate [--days <n>]` shows how many outcome checks came due in the last n days (30 by default) and at least 2 days ago, how many got a verdict within 2 days of their check date, and how many of those PMOS recorded by itself. The last line is that percent. It changes nothing.
366
372
  - `pmos outcomes live --where <place> --version <version>` records the version a place runs now, for example after a deploy. When a record says `shipped_in: "<version>"` and `measured_on: "<place>"`, and that place still runs an older version, its outcome check shows as blocked with the step to fix it. PMOS does not ask for a verdict until the place runs the change.
367
373
  - When you record `didnt-work`, the initiative shows **At risk** on every page, with the check as the reason. PMOS compares the evidence with the kill condition and files one next step under the initiative's ✦. If the evidence meets the kill condition, PMOS suggests that you stop the initiative. If this is the second check that did not work, it suggests a new experiment. Otherwise it suggests one more round with a new check date. The Board's Next column asks you the same question. Nothing happens until you press ✓. Undo reverses the step.
368
374
  - `pmos outcomes propose` also reads the experiment's hypothesis. When the hypothesis names a different KR from the initiative's anchor, the draft tells you.
@@ -851,7 +857,7 @@ The benchmark needs a signed-in agent CLI. It never pushes and never opens a pul
851
857
  - `pmos jira criteria-asks [--direct|--draft|--health]` lists the criteria asks that wait for Jira, prints the draft by owner, or prints the health number.
852
858
  - `pmos jira criteria-done <ask id>` or `--refused "<why>"` records the answer for one criteria ask.
853
859
  - `pmos jira criteria <initiative>`: the done-test checks each ticket carries as acceptance criteria, and the checks on no ticket
854
- - `pmos jira digest [--since <YYYY-MM-DD or time>]`: what moved in the tracker since the last working day, who moved it, the moved tickets with no task in PMOS, and what is worth a question (blocked, reopened, nobody assigned, stuck, not in the last read). It reads only the stored Jira reads.
860
+ - `pmos jira digest [--since <YYYY-MM-DD or time>]`: what moved in the tracker since the last working day, who moved it, the moved tickets with no task in PMOS, and what is worth a question (blocked, reopened, nobody assigned, stuck, not in the last read). It reads only the stored Jira reads. The daily Jira read also asks Jira for every status change in the projects PMOS reads, so a ticket no initiative or task names is in the digest too, under "Not in PMOS yet".
855
861
 
856
862
  Every command takes `--json` and `--root <dir>`.
857
863
 
@@ -54,7 +54,7 @@ Home, the Board, Insights and the Viewer use one typeface, Plus Jakarta Sans, wi
54
54
  - **One press per initiative.** An initiative's proposals are one row, for example "Checkout: 6 changes to keep" with "3 dates, 2 names, 1 link" under it. Press it to see them grouped as Dates, Names, Done and Links. ✓ keeps all of them, with one Undo for the batch. ✕ drops them, then offers three reasons and **Say why**. A proposal that needs your own check keeps its own ✓ and ✕. **See every change** opens the full list on the initiative.
55
55
  - **An ask expires after 14 days with no answer.** PMOS leaves it as it was and writes why in the initiative's History. Your move says it once: "2 asks expired after 14 days with no answer." Dates computed from your tasks never expire: PMOS reads them again each time.
56
56
  - **Done** lists what PMOS finished by itself in the last 14 days, one line each with Undo.
57
- - **What moved last week.** Once a week, one row says how many dates and scope changes (tasks added, removed or put back) happened last week on all your products, and how many have no source, for example "Last week: 14 moves in dates and scope" with "3 with no source. See who to ask." under it. Press it to see one list, grouped by product, with the moves that have no source first. Each move shows its source (your own change, the tracker, or the Jira ticket, meeting note or document it names), or **No source** and the owner to ask. A move PMOS made with no reason is always **No source**. After you open the list, the row goes away until next week. In a week with no moves, there is no row. From a terminal: `node workspace/lib/week-moves.js list` in a product's repository, or `--week <Monday>` for an earlier week.
57
+ - **What moved last week.** Once a week, one row says how many dates and scope changes (tasks added, removed or put back) happened last week on all your products, and how many have no source, for example "Last week: 14 moves in dates and scope" with "3 with no source. See who to ask." under it. Press it to see one list, grouped by product, with the moves that have no source first. Each move shows its source (your own change, the tracker, or the Jira ticket, meeting note or document it names), or **No source** and the owner to ask. A move PMOS made with no reason is always **No source**. A moved date also says how far it is from the task's first plan, for example "30 days behind the first plan (due 1 Nov)", so a slip stays in sight after the date moves. After you open the list, the row goes away until next week. In a week with no moves, there is no row. From a terminal: `node workspace/lib/week-moves.js list` in a product's repository, or `--week <Monday>` for an earlier week.
58
58
  - An outbox draft opens with who it is for and the words. **Copy** puts the words on the clipboard, so you send them from your own tool. ✕ discards it, with Undo. Nothing leaves PMOS by itself.
59
59
 
60
60
  ## Mentions
@@ -500,3 +500,18 @@ The panel over Meet is PMOS's meeting buddy. Only you see it. The same card show
500
500
  - **A draft for the call chat.** Sometimes PMOS drafts one short message for the call chat, for example a link the room asked for. PMOS never posts it: press the copy icon and paste it yourself, or press ✗.
501
501
  - **Ask PMOS.** Type a question in the box at the bottom. The answer shows in the panel only.
502
502
 
503
+ #### Float PMOS over any call app
504
+
505
+ The meeting buddy can float in a small window on top of Zoom, Google Meet or Microsoft Teams, in the browser or the desktop app. The call app stays as it is. You need Chrome or Edge on a computer. In other browsers the icon does not show.
506
+
507
+ 1. Start recording a meeting. The recording tab opens.
508
+ 2. Press the **Float** icon in the bar at the bottom of the recording tab. A small PMOS window opens and stays on top of other windows. Move it where you want.
509
+ 3. Use the icons in its head:
510
+ - **Fold** shrinks it to a pill. The pill shows the head only.
511
+ - **Open wide** shows two columns. **For this topic** shows the work and its goal, what blocks it, what was decided before, and the documents of the meeting. It changes when the topic changes. **People** shows who is in the invite and what they owe you. **Filed** shows every row PMOS filed, each with undo.
512
+ - **Room view** is for the whole meeting. Share the PMOS window in the call. When someone in the room asks a question, PMOS shows the answer and where it came from. It also shows what is on the table and what was agreed. Your private rows do not show: drafts, the line to tell the room, undo, your own questions and People. Press it again to go back to your own view.
513
+
514
+ The window remembers the size you left it at. It closes when the recording tab closes or the meeting stops.
515
+
516
+ **Walk-in card.** From 2 minutes before a meeting until PMOS listens, the buddy starts with a short card: the work the meeting is for, what someone owes you and what you owe, the last decision, and one thing to settle. A folded pill opens to a card for it once. A row with nothing behind it does not show.
517
+
@@ -51,11 +51,16 @@ function fromCli({ isTTY = !!(process.stdin.isTTY && process.stdout.isTTY), env
51
51
  return { by: 'agent:unknown', via: 'cli' };
52
52
  }
53
53
 
54
- const valid = (a) => !!a && typeof a.by === 'string' && BY_RE.test(a.by) && VIA.includes(a.via);
54
+ /* The server's own auto apply (lib/routes-proposals.js autoKeep and the 2-day defaults) acts as `{ by: 'agent:auto' }`: no page and no
55
+ * terminal, so it has no `via`. It is an agent, never the PM. Without it here every record writer refused the auto apply's writes in silence
56
+ * (initiative outcome-checks-finish: on idpf 10 kept outcomes and 8 kept descriptions wrote nothing). BY_RE is unchanged: no ledger that
57
+ * checks a line's `by` against it takes agent:auto. */
58
+ const AUTO_BY = 'agent:auto';
59
+ const valid = (a) => !!a && typeof a.by === 'string' && (a.by === AUTO_BY ? (a.via === undefined || VIA.includes(a.via)) : BY_RE.test(a.by) && VIA.includes(a.via));
55
60
  const isPm = (a) => valid(a) && a.by.startsWith('pm:');
56
61
  const isAgent = (a) => valid(a) && a.by.startsWith('agent:');
57
62
  /** The session token of an agent actor, or null. */
58
- const sessionOf = (a) => (isAgent(a) && a.by !== 'agent:unknown' ? a.by.slice('agent:'.length) : null);
63
+ const sessionOf = (a) => (isAgent(a) && a.by !== 'agent:unknown' && a.by !== AUTO_BY ? a.by.slice('agent:'.length) : null);
59
64
 
60
65
  /** The name the page may show. Strips the session token's secret suffix; anything else passes through. */
61
66
  function pageName(by) {
@@ -88,4 +93,4 @@ function sessionForToken(token, { sessDir } = {}) {
88
93
  return { session: id, initiative: str(meta.initiative), plan_item: str(meta.plan_item) };
89
94
  }
90
95
 
91
- module.exports = { tokenHash, sessionForToken, PM_SLUG, SESSION_RE, BY_RE, VIA, fromUi, fromCli, valid, isPm, isAgent, sessionOf, pageName };
96
+ module.exports = { tokenHash, sessionForToken, PM_SLUG, SESSION_RE, BY_RE, VIA, AUTO_BY, fromUi, fromCli, valid, isPm, isAgent, sessionOf, pageName };
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* contradictions.js — records that notice they are wrong (initiative slip-baseline-contradictions; bet A140). READ-ONLY: it writes nothing.
4
+ *
5
+ * Proof A140: a plain script found 12 contradictions in 7 of 29 idpf initiatives, each with the edit to propose. No model is needed: the
6
+ * product's own records are checked against each other. Each contradiction becomes ONE question to the PM per initiative in the open-questions
7
+ * register (lib/open-questions.js, kind `record`). PMOS changes no record by itself: which record is wrong is the PM's call.
8
+ *
9
+ * contradictionsOf(facts, { now }) PURE → [item] facts: one lib/drift-facts.js factsOf result, or a list of them
10
+ * forRepo(root, { now, rows }) → { notRead, items } one checkout; `rows` are the initiative rows as already read (no derive)
11
+ *
12
+ * THE KINDS (records only; a source that cannot be read is named in notRead, never guessed):
13
+ * closed-open the initiative is closed (set to Won't do, or stopped) and tasks are still open
14
+ * accepted-open the initiative is accepted and tasks are still open
15
+ * moved-done a task's due date moved after the task was done (PMOS or a person still planning finished work)
16
+ * done-live every task is done or won't do, the last for DONE_DAYS days or more, and the initiative is still live
17
+ *
18
+ * AN ITEM: { kind, product, name, ini, title, n, at (ISO, when it began), say, ask, sources: [{ label, ref, quote }] }. `ref` is path:line
19
+ * from the repository root and `quote` that line's own text (lib/drift-facts.js), so the Checker can read each one.
20
+ *
21
+ * CLI: node lib/contradictions.js list|count [<root>] [--json]. `count` ends with the number of contradictions on its last line.
22
+ * Every log line carries [contradictions]. */
23
+ const path = require('path');
24
+
25
+ const TAG = '[contradictions]';
26
+ const DAY = 86400000;
27
+ const DONE_DAYS = 14;
28
+ const MAX_SOURCES = 3;
29
+ const CLOSED = /^(done|won'?t do|cancel+ed|closed)$/i;
30
+ const DONE = /^done$/i;
31
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
32
+ const isDate = (s) => /^\d{4}-\d{2}-\d{2}/.test(String(s || ''));
33
+ const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).trimEnd() + '…' : t; };
34
+ const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
35
+ const short = (ms) => { const d = new Date(ms); return d.getUTCDate() + ' ' + MON[d.getUTCMonth()]; };
36
+ const pad = (n) => String(n).padStart(2, '0');
37
+ const localDay = (ms) => { const d = new Date(ms); return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()); };
38
+ const src = (label, s) => (s && s.ref && s.quote ? { label: clip(label, 60), ref: s.ref, quote: s.quote } : null);
39
+
40
+ /** A task's state now, whether it is removed, its last line and its date moves made while it was done. PURE. */
41
+ function taskNow(t) {
42
+ const lines = (t.lines || []).filter((l) => Number.isFinite(l.at)).slice().sort((a, b) => a.at - b.at);
43
+ let state = '', removed = false, due, closedAt = null, closedLine = null, last = null;
44
+ const movedDone = [];
45
+ for (const l of lines) {
46
+ last = l;
47
+ if (l.kind === 'task-remove') removed = true;
48
+ if (l.kind === 'task-restore') removed = false;
49
+ if (l.due !== undefined) {
50
+ const next = isDate(l.due) ? String(l.due).slice(0, 10) : '';
51
+ // a date that moved on a line that does not itself change the state, while the task stood done
52
+ if (due !== undefined && next !== due && DONE.test(state) && !(typeof l.state === 'string' && l.state && !DONE.test(l.state))) movedDone.push(l);
53
+ due = next;
54
+ }
55
+ if (typeof l.state === 'string' && l.state && l.state !== state) {
56
+ state = l.state;
57
+ if (CLOSED.test(state)) { closedAt = l.at; closedLine = l; } else { closedAt = null; closedLine = null; }
58
+ }
59
+ }
60
+ return { state, open: !CLOSED.test(state), removed, closedAt, closedLine, last, movedDone, due };
61
+ }
62
+
63
+ /** Every contradiction in the records. PURE. */
64
+ function contradictionsOf(facts, { now = Date.now() } = {}) {
65
+ const out = [];
66
+ for (const f of (Array.isArray(facts) ? facts : [facts]).filter(Boolean)) {
67
+ const byIni = new Map();
68
+ for (const t of f.tasks || []) {
69
+ const s = taskNow(t);
70
+ if (s.removed) continue;
71
+ if (!byIni.has(t.initiative)) byIni.set(t.initiative, []);
72
+ byIni.get(t.initiative).push({ t, s });
73
+ }
74
+ for (const i of f.initiatives || []) {
75
+ const ts = byIni.get(i.id) || [];
76
+ if (!ts.length) continue;
77
+ const base = { product: f.ws, name: f.name || f.ws, ini: i.id, title: i.title || i.id };
78
+ const open = ts.filter((x) => x.s.open);
79
+ const today = localDay(now);
80
+ const late = open.filter((x) => x.s.due && x.s.due < today).length;
81
+ const openSources = open.slice(0, MAX_SOURCES - 1).map((x) => src('Open task: ' + x.t.title, x.s.last && x.s.last.src));
82
+ if (!i.live && Number.isFinite(i.closedAt) && open.length) {
83
+ const accepted = i.closedWhy === 'accepted';
84
+ const why = accepted ? 'accepted' : i.closedWhy === 'stopped' ? 'stopped' : "set to Won't do";
85
+ out.push({ ...base, kind: accepted ? 'accepted-open' : 'closed-open', n: open.length, at: new Date(i.closedAt).toISOString(),
86
+ say: `${base.title} is ${why}, but ${plural(open.length, 'task is', 'tasks are')} still open${late ? ` (${late} past due)` : ''}.`,
87
+ ask: accepted ? `Is it delivered? Then close the ${plural(open.length, 'task', 'tasks')}; if not, reopen it.` : `Close the ${plural(open.length, 'task', 'tasks')}, or move them to a live initiative?`,
88
+ sources: [src('The initiative is ' + why, i.closedSrc || i.src), ...openSources].filter(Boolean) });
89
+ }
90
+ const moved = ts.filter((x) => x.s.movedDone.length);
91
+ if (moved.length) {
92
+ const first = Math.min(...moved.map((x) => x.s.movedDone[0].at));
93
+ out.push({ ...base, kind: 'moved-done', n: moved.length, at: new Date(first).toISOString(),
94
+ say: `${plural(moved.length, 'done task', 'done tasks')} on ${base.title} had ${moved.length === 1 ? 'its' : 'their'} due date moved after ${moved.length === 1 ? 'it was' : 'they were'} done.`,
95
+ ask: moved.length === 1 ? 'Keep it done and stop planning it, or reopen it?' : 'Keep them done and stop planning them, or reopen them?',
96
+ sources: moved.slice(0, MAX_SOURCES).map((x) => src('Date moved on done task: ' + x.t.title, x.s.movedDone[x.s.movedDone.length - 1].src)).filter(Boolean) });
97
+ }
98
+ if (i.live && !open.length) {
99
+ const lastDone = ts.reduce((a, x) => (x.s.closedAt && (!a || x.s.closedAt > a.s.closedAt) ? x : a), null);
100
+ if (lastDone && now - lastDone.s.closedAt >= DONE_DAYS * DAY) {
101
+ out.push({ ...base, kind: 'done-live', n: ts.length, at: new Date(lastDone.s.closedAt + DONE_DAYS * DAY).toISOString(),
102
+ say: `Every task on ${base.title} is closed (the last on ${short(lastDone.s.closedAt)}), but it is still live.`,
103
+ ask: 'Accept it or close it, or add the work that is left?',
104
+ sources: [src('The initiative', i.src), src('Last task closed: ' + lastDone.t.title, lastDone.s.closedLine && lastDone.s.closedLine.src)].filter(Boolean) });
105
+ }
106
+ }
107
+ }
108
+ }
109
+ return out.sort((a, b) => (a.at < b.at ? -1 : a.at > b.at ? 1 : 0) || String(a.title).localeCompare(String(b.title)));
110
+ }
111
+
112
+ /** One checkout's contradictions. rows: the initiative rows as already read; without them they are derived now (the CLI). */
113
+ function forRepo(root, { now = Date.now(), name, rows, stateDir, id } = {}) {
114
+ const Dr = require('./driver.js');
115
+ const f = require('./drift-facts.js').factsOf({ id: id || Dr.wsIdOf(root), name: name || path.basename(root), root }, { stateDir: stateDir || Dr.stateDirOf(root), rows });
116
+ return { notRead: f.notRead, items: contradictionsOf(f, { now }) };
117
+ }
118
+
119
+ function main(argv, { say = (s) => console.log(s), cwd = process.cwd(), now = Date.now() } = {}) {
120
+ const pos = [], flags = {};
121
+ for (const a of argv) { if (a === '--json') flags.json = true; else pos.push(a); }
122
+ const [sub = 'list', rootArg] = pos;
123
+ if (!['list', 'count'].includes(sub)) { say('usage: node lib/contradictions.js list|count [<root>] [--json] — records of a product that disagree with each other'); return 2; }
124
+ const root = path.resolve(cwd, rootArg || '.');
125
+ let r;
126
+ try { r = forRepo(root, { now }); } catch (e) { say(`${TAG} could not read ${root}: ${(e && e.message) || e}`); return 1; }
127
+ if (flags.json) { say(JSON.stringify(sub === 'count' ? { count: r.items.length, notRead: r.notRead } : r)); return 0; }
128
+ if (sub === 'list') for (const x of r.items) say(`- ${x.say} ${x.ask} [${x.sources.map((s) => s.ref).join(', ')}]`);
129
+ const inis = new Set(r.items.map((x) => x.ini)).size;
130
+ say(`${TAG} ${plural(r.items.length, 'contradiction', 'contradictions')} across ${plural(inis, 'initiative', 'initiatives')}${r.notRead.length ? ' (not read: ' + r.notRead.join(', ') + ')' : ''}`);
131
+ if (sub === 'count') say(String(r.items.length));
132
+ return 0;
133
+ }
134
+
135
+ module.exports = { contradictionsOf, taskNow, forRepo, main, TAG, DONE_DAYS };
136
+
137
+ if (require.main === module) process.exitCode = main(process.argv.slice(2));
@@ -164,7 +164,11 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
164
164
  if (!p.linked) lines.push('no initiative has a ticket in Jira yet');
165
165
  if (p.change.length) {
166
166
  lines.push(`changed · ${p.checked} tracked ${p.checked === 1 ? 'ticket' : 'tickets'} in ${p.change.length} ${p.change.length === 1 ? 'initiative' : 'initiatives'} · since ${p.since} (the last ${p.minutes} minutes)`);
167
- for (const q of p.searches) lines.push(`search\t${q}`);
167
+ for (const q of p.searches) if (!p.standup || q !== p.standup.search) lines.push(`search\t${q}`);
168
+ }
169
+ if (p.standup) {
170
+ lines.push(`standup · every status change in ${p.standup.projects.join(', ')} (the last ${p.standup.minutes} minutes), for the standup digest`);
171
+ lines.push(`search\t${p.standup.search}`);
168
172
  }
169
173
  for (const f of p.full) lines.push(`full\t${f.initiative}\t${f.query}\t(${f.why})`);
170
174
  return out(p, lines);
@@ -181,7 +185,8 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
181
185
  if (x.error) { lines.push(` ${x.initiative} · ${x.error}`); continue; }
182
186
  for (const c of x.changes) lines.push(` ${x.initiative} ${c.key} · ${c.what}${c.from !== undefined ? `: ${c.from} → ${c.to}` : c.status ? `: ${c.status}` : ''}${c.reason ? ` (${c.reason})` : ''}`);
183
187
  }
184
- if (!r.kept) lines.push('no tracked ticket changed: if no initiative was read in full, run pmos refresh same jira');
188
+ if (r.untracked && r.untracked.length) lines.push(`${require('./jira-tiers.js').TAG} ${r.untracked.length} status ${r.untracked.length === 1 ? 'move' : 'moves'} of tickets no initiative holds kept for the standup digest${r.dryRun ? ' (dry run, not kept)' : ''}`);
189
+ if (!r.kept && !(r.untracked && r.untracked.length)) lines.push('no tracked ticket changed: if no initiative was read in full, run pmos refresh same jira');
185
190
  lines.push(r.sprintNeeded ? 'sprint read: needed, a live ticket changed' : 'sprint read: not needed for these changes');
186
191
  return out(r, lines);
187
192
  }
@@ -22,8 +22,14 @@
22
22
  * THE TIER IS NEVER STORED. It is derived from the stored reading on each run, so a ticket moves tier as soon as its reading does.
23
23
  *
24
24
  * FILE. <state>/tracker/jira/_tiers.json, local runtime state:
25
- * { checked: { <ini>: iso }, full: { <ini>: iso }, pins: [ini], sprint_dirty: bool, sprint_read_at: iso,
26
- * run: { asked_at, mode, change: [ini], full_due: [ini], checked, fetched, tiers: [n] } }
25
+ * { checked: { <ini>: iso }, full: { <ini>: iso }, pins: [ini], sprint_dirty: bool, sprint_read_at: iso, standup_at: iso,
26
+ * run: { asked_at, mode, change: [ini], full_due: [ini], checked, fetched, tiers: [n], standup?: true } }
27
+ *
28
+ * THE STANDUP SEARCH (initiative standup-from-one-read, bet A23). The searches above ask only about tickets PMOS already holds, so a new
29
+ * ticket, or a sprint ticket no initiative names, moves without PMOS seeing it (13 of 20 status changes missed on idpf, microsites and
30
+ * Scarlet, 20 to 24 Nov). One more search asks for every status change in the projects of the stored readings since the last time it
31
+ * asked: `project in (…) AND status changed AFTER -<N>m`. applyChanged keeps a move (`u: 1`) for each returned ticket no initiative
32
+ * holds, for the standup digest (lib/tracker-digest.js). Read-only on Jira, like every search here.
27
33
  */
28
34
  const fs = require('fs');
29
35
  const path = require('path');
@@ -32,6 +38,10 @@ const FILE = '_tiers.json';
32
38
  const CHUNK = 100;
33
39
  const SPARE_MIN = 5; // minutes added to each "updated since" window, as the refresh probe does
34
40
  const LIVE_STATUS = /block|impediment|on hold/i;
41
+ const STANDUP_FIRST_MIN = 72 * 60; // the first standup search looks 72 hours back, so a Monday digest has Friday in it
42
+ const STANDUP_MAX_MIN = 7 * 24 * 60; // never more than a week back
43
+ const KEY_RE = /^([A-Z][A-Z0-9_]*)-\d+$/;
44
+ const TAG = '[standup-from-one-read]';
35
45
 
36
46
  const S = () => require('./jira-status.js');
37
47
  const T = () => require('./jira-tickets.js');
@@ -45,7 +55,8 @@ function readFile(f) {
45
55
  function read(root) {
46
56
  const v = readFile(fileOf(root));
47
57
  return { checked: { ...(v.checked || {}) }, full: { ...(v.full || {}) }, pins: Array.isArray(v.pins) ? v.pins.filter((x) => typeof x === 'string') : [],
48
- sprint_dirty: v.sprint_dirty === true, sprint_read_at: typeof v.sprint_read_at === 'string' ? v.sprint_read_at : null, run: v.run && typeof v.run === 'object' ? v.run : null };
58
+ sprint_dirty: v.sprint_dirty === true, sprint_read_at: typeof v.sprint_read_at === 'string' ? v.sprint_read_at : null,
59
+ standup_at: typeof v.standup_at === 'string' ? v.standup_at : null, run: v.run && typeof v.run === 'object' ? v.run : null };
49
60
  }
50
61
  function write(root, st) {
51
62
  const f = fileOf(root);
@@ -123,15 +134,61 @@ function plan(root, { now = Date.now(), record = true } = {}) {
123
134
  ...chunks(all, CHUNK).map((ks) => `key in (${ks.join(', ')})${win} ORDER BY key`),
124
135
  ...chunks([...epics].sort(), CHUNK).map((es) => `parent in (${es.join(', ')})${win} ORDER BY key`),
125
136
  ] : [];
137
+ const standup = standupSearch(root, st, linked, now);
138
+ if (standup) searches.push(standup.search);
126
139
  const out = { ok: true, mode: full.length && !change.length ? 'full' : 'changed', since: since ? iso(since) : null, minutes, checked: all.length,
127
- change, searches, full, linked: linked.length };
140
+ change, searches, full, linked: linked.length, standup };
128
141
  if (record) {
129
- st.run = { asked_at: iso(now), mode: full.length ? 'full' : 'changed', change, full_due: full.map((x) => x.initiative), checked: all.length, fetched: 0, tiers: [] };
142
+ st.run = { asked_at: iso(now), mode: full.length ? 'full' : 'changed', change, full_due: full.map((x) => x.initiative), checked: all.length, fetched: 0, tiers: [],
143
+ ...(standup ? { standup: true } : {}) };
130
144
  write(root, st);
131
145
  }
132
146
  return out;
133
147
  }
134
148
 
149
+ /** The projects of every stored reading (each initiative's read and the whole-sprint read), sorted. */
150
+ function projectsOf(root, linked) {
151
+ const out = new Set();
152
+ const add = (snap) => { if (snap) for (const k of snap.tickets.keys()) { const m = KEY_RE.exec(k); if (m) out.add(m[1]); } };
153
+ for (const q of linked) add(S().readSnapshot(root, q.initiative));
154
+ try { add(S().readSprints(root)); } catch { /* no sprint read */ }
155
+ return [...out].sort();
156
+ }
157
+ /** The standup search: every status change in those projects since it last asked (72 hours the first time, 7 days at most). */
158
+ function standupSearch(root, st, linked, now) {
159
+ const projects = projectsOf(root, linked);
160
+ if (!projects.length) return null;
161
+ const last = ms(st.standup_at);
162
+ const minutes = last ? Math.min(STANDUP_MAX_MIN, Math.max(1, Math.ceil((now - last) / 60000)) + SPARE_MIN) : STANDUP_FIRST_MIN;
163
+ return { projects, minutes, search: `project in (${projects.join(', ')}) AND status changed AFTER -${minutes}m ORDER BY key` };
164
+ }
165
+
166
+ /**
167
+ * The returned tickets no initiative holds: a move (`u: 1`) when the status differs from what PMOS last knew of the ticket (the
168
+ * whole-sprint read, else its last kept move); a ticket PMOS never saw moves from an unknown state. PURE apart from the reads.
169
+ */
170
+ function untrackedMoves(root, issues, held, at) {
171
+ const TD = require('./tracker-digest.js');
172
+ let sprints = null; try { sprints = S().readSprints(root); } catch { sprints = null; }
173
+ const last = new Map();
174
+ for (const m of TD.readMoves(root)) last.set(m.k, m); // the file is in time order: the last line wins
175
+ const lines = []; const sprintKeys = []; const seen = new Set();
176
+ for (const i of issues) {
177
+ if (!i || !i.key || held.has(i.key) || seen.has(i.key)) continue;
178
+ seen.add(i.key);
179
+ const inSprint = sprints ? sprints.tickets.get(i.key) : null;
180
+ const mv = last.get(i.key);
181
+ // what PMOS last knew: the newer of the sprint read and the last kept move (a move kept after the sprint read is newer)
182
+ const was = mv && (!inSprint || ms(mv.at) >= ms(sprints.fetchedAt)) ? { status: mv.s, category: mv.c || null }
183
+ : inSprint ? { status: inSprint.status, category: inSprint.category || null } : null;
184
+ if (was && was.status === i.status) continue;
185
+ lines.push({ at, k: i.key, n: i.summary || '', f: was ? was.status : null, fc: was ? was.category : null, s: i.status, c: i.category || null,
186
+ ...(i.assignee ? { w: i.assignee } : {}), u: 1 });
187
+ if (inSprint) sprintKeys.push(i.key);
188
+ }
189
+ return { lines, sprintKeys };
190
+ }
191
+
135
192
  /** The time this run asked (plan), or now when no plan was made. */
136
193
  const askedAt = (st, now) => (st.run && st.run.asked_at ? st.run.asked_at : iso(now));
137
194
  const addRun = (st, { fetched = 0, checked = 0, tiers = [] }) => {
@@ -178,8 +235,9 @@ function applyChanged(root, raw, { now = Date.now(), dryRun = false } = {}) {
178
235
  const n = S().normalize(raw);
179
236
  if (n.error) return { ok: false, error: n.error };
180
237
  const st = read(root);
181
- const group = st.run && Array.isArray(st.run.change) && st.run.change.length ? st.run.change
182
- : S().linkedInitiatives(root).filter((x) => x.linked).map((x) => x.initiative);
238
+ const linked = S().linkedInitiatives(root).filter((x) => x.linked).map((x) => x.initiative);
239
+ // a plan that read every initiative in full patches none of them here: the standup search may still have returned their tickets
240
+ const group = st.run && Array.isArray(st.run.change) && (st.run.change.length || st.run.standup) ? st.run.change : linked;
183
241
  const at = askedAt(st, now);
184
242
  const per = []; const kept = new Set(); let tiers = []; let dirty = false;
185
243
  for (const ini of group) {
@@ -195,10 +253,17 @@ function applyChanged(root, raw, { now = Date.now(), dryRun = false } = {}) {
195
253
  tiers = tiers.concat(f.tiers); dirty = dirty || f.dirty;
196
254
  per.push({ initiative: ini, read: r.read, changes: r.changes });
197
255
  }
198
- const result = { ok: true, fetched: n.issues.length, kept: kept.size, ignored: n.issues.length - kept.size, skipped: n.skipped, initiatives: per,
199
- tiers: [...new Set(tiers)].sort(), sprintNeeded: dirty, dryRun: !!dryRun };
256
+ // the standup search: a ticket an initiative holds is that initiative's (its own read keeps its moves); every other one is kept here
257
+ const held = new Set(kept);
258
+ for (const ini of linked) { const s = S().readSnapshot(root, ini); if (s) for (const k of s.tickets.keys()) held.add(k); }
259
+ const un = untrackedMoves(root, n.issues, held, at);
260
+ if (un.sprintKeys.length) dirty = true;
261
+ const result = { ok: true, fetched: n.issues.length, kept: kept.size, ignored: Math.max(0, n.issues.length - kept.size - un.lines.length), skipped: n.skipped, initiatives: per,
262
+ untracked: un.lines.map((l) => ({ key: l.k, from: l.f, to: l.s })), tiers: [...new Set(tiers)].sort(), sprintNeeded: dirty, dryRun: !!dryRun };
200
263
  if (dryRun) return result;
264
+ require('./tracker-digest.js').append(root, un.lines);
201
265
  for (const ini of group) st.checked[ini] = at;
266
+ if (st.run && st.run.standup) st.standup_at = at;
202
267
  if (dirty) st.sprint_dirty = true;
203
268
  addRun(st, { fetched: n.issues.length, tiers });
204
269
  write(root, st);
@@ -263,4 +328,4 @@ function fullDue(jiraDir) {
263
328
  return v.run && Array.isArray(v.run.full_due) ? v.run.full_due : null;
264
329
  }
265
330
 
266
- module.exports = { FILE, CHUNK, tierOf, mondayOf, plan, applyChanged, noteFull, sprintDue, sprintRead, pin, counts, runStats, fullDue, read, fileOf };
331
+ module.exports = { TAG, projectsOf, standupSearch, untrackedMoves, FILE, CHUNK, tierOf, mondayOf, plan, applyChanged, noteFull, sprintDue, sprintRead, pin, counts, runStats, fullDue, read, fileOf };
@@ -14,6 +14,7 @@
14
14
  * shouldRun(now, state, note, opts) → { run, reason } the rules of when the companion may run
15
15
  * pickNow(events, { now, meet, title }) → { ok, event, date, by } | { ok:false, status:404, error, choices } which meeting a Google Meet call is (the Chrome extension, c3-meet-extension)
16
16
  * callLinkOf(event) → { url, app: 'meet'|'zoom'|'teams' } | null the address of the meeting's call (meeting-buddy: the play icon, the buddy)
17
+ * goalOf(anchor, resolve) → { kind: 'kr'|'objective'|'health', title } | null the goal an initiative's anchor names (meeting-float)
17
18
  *
18
19
  * Nothing here reads a file or starts a process; lib/routes-meeting-focus.js does both.
19
20
  *
@@ -467,4 +468,16 @@ function callLinkOf(e) {
467
468
  return null;
468
469
  }
469
470
 
470
- module.exports = { CATS, REF_TYPES, RAISE_KINDS, RAISE_MAX, FROM, MIN_GAP_MS, TAIL_MINUTES, TAIL_MAX, topicsFrom, tailOf, capturedFrom, screenOf, companionPrompt, parseCompanion, showIntent, showLine, foldState, outLine, moveLine, raiseLine, shouldRun, pickNow, meetTitle, callLinkOf, norm, str, off };
471
+ /** The goal an initiative's anchor (parent_kr) names, for the brief (meeting-float: the walk-in card, the wide view, room view).
472
+ * resolve = lib/initiative-rows.js anchorsOf(root).resolve. A key result or objective that resolves gives its name; a health budget
473
+ * gives "<name> health"; an anchor that does not resolve, or none, gives null (zero is silence). Pure. */
474
+ function goalOf(anchor, resolve) {
475
+ const raw = str(anchor, 120); if (!raw || typeof resolve !== 'function') return null;
476
+ let r = null; try { r = resolve(raw); } catch { return null; }
477
+ if (!r || !r.title) return null;
478
+ if (r.kind === 'health' && r.status === 'resolved') return { kind: 'health', title: str(r.title, 120) };
479
+ if ((r.kind === 'kr' || r.kind === 'objective') && r.status === 'resolved' && r.title !== raw) return { kind: r.kind, title: str(r.title, 120) };
480
+ return null;
481
+ }
482
+
483
+ module.exports = { goalOf, CATS, REF_TYPES, RAISE_KINDS, RAISE_MAX, FROM, MIN_GAP_MS, TAIL_MINUTES, TAIL_MAX, topicsFrom, tailOf, capturedFrom, screenOf, companionPrompt, parseCompanion, showIntent, showLine, foldState, outLine, moveLine, raiseLine, shouldRun, pickNow, meetTitle, callLinkOf, norm, str, off };