create-pmos 0.671.0 → 0.674.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.671.0",
3
+ "version": "0.674.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.671.0",
38
- "at": "2026-11-22T05:13:23.112Z",
37
+ "v": "0.674.0",
38
+ "at": "2026-11-22T05:18:00.036Z",
39
39
  "f": 4,
40
40
  "prs": [
41
41
  {
@@ -49,6 +49,24 @@
49
49
  "t": "Plain ✓ actions write directly, with Undo and no agent turn",
50
50
  "s": "Plain ✓ actions write directly, with Undo and no agent turn",
51
51
  "k": "new"
52
+ },
53
+ {
54
+ "n": 1450,
55
+ "t": "Default decisions with a deadline, and the cost of waiting",
56
+ "s": "Default decisions with a deadline, and the cost of waiting",
57
+ "k": "new"
58
+ },
59
+ {
60
+ "n": 1461,
61
+ "t": "Every dry-run question carries a default answer, and the PM can keep it",
62
+ "s": "Every dry-run question carries a default answer, and the PM can keep it",
63
+ "k": "new"
64
+ },
65
+ {
66
+ "n": 1462,
67
+ "t": "Before a PM shares a document, PMOS lists the hardest questions a sceptical reviewer would ask",
68
+ "s": "Before a PM shares a document, PMOS lists the hardest questions a sceptical reviewer would ask",
69
+ "k": "new"
52
70
  }
53
71
  ]
54
72
  },
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@6f129580
1
+ kernel-source: pmos@917c7088
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-22T05:13:19Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T05:17:56Z"}
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-22T05:13:19Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T05:17:56Z"}
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-22T05:13:19Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T05:17:56Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,7 +1,7 @@
1
1
  [
2
2
  {
3
- "v": "0.671.0",
4
- "at": "2026-11-22T05:13:23.112Z",
3
+ "v": "0.674.0",
4
+ "at": "2026-11-22T05:18:00.036Z",
5
5
  "f": 4,
6
6
  "prs": [
7
7
  {
@@ -15,6 +15,24 @@
15
15
  "t": "Plain ✓ actions write directly, with Undo and no agent turn",
16
16
  "s": "Plain ✓ actions write directly, with Undo and no agent turn",
17
17
  "k": "new"
18
+ },
19
+ {
20
+ "n": 1450,
21
+ "t": "Default decisions with a deadline, and the cost of waiting",
22
+ "s": "Default decisions with a deadline, and the cost of waiting",
23
+ "k": "new"
24
+ },
25
+ {
26
+ "n": 1461,
27
+ "t": "Every dry-run question carries a default answer, and the PM can keep it",
28
+ "s": "Every dry-run question carries a default answer, and the PM can keep it",
29
+ "k": "new"
30
+ },
31
+ {
32
+ "n": 1462,
33
+ "t": "Before a PM shares a document, PMOS lists the hardest questions a sceptical reviewer would ask",
34
+ "s": "Before a PM shares a document, PMOS lists the hardest questions a sceptical reviewer would ask",
35
+ "k": "new"
18
36
  }
19
37
  ]
20
38
  },
@@ -53,6 +53,14 @@ A tidy name that uses only the task's own words is not a name change from a sour
53
53
 
54
54
  The changes that wait come together in one list of questions a day: one question for each owner and initiative. The owner is the person the plan names on the task, or you. The list is fixed for the day. A change that waits later that day goes on the next day's list. A question for a teammate is a draft. PMOS does not send it. When you keep or drop the change, its question leaves the list.
55
55
 
56
+ ### Defaults when nobody answers
57
+
58
+ Each question on the list says what PMOS does if nobody answers, and by when. For a change that waits for a source, the default is to leave the plan as it is. The deadline is 2 days after the change first joined the list. When the deadline passes and nobody answered, PMOS takes the default and lists it in "PMOS did" with Undo. Undo brings the question back, and PMOS does not take a default on it again.
59
+
60
+ These changes never take a default, because other people see them or they cannot be undone: the state of a Jira ticket, a stage move, a message to a person, a pull request, a merge, a delete, spending money, and the next step for an outcome that did not work. They wait for you. Each question says how many days it has waited and how many tasks stay as they are until someone answers.
61
+
62
+ To stop defaults, set "Defaults when nobody answers" to Ask first in Settings, or turn PMOS's agents off.
63
+
56
64
  ### Undo
57
65
 
58
66
  Each change an agent applies is listed for 14 days with Undo. Undo puts the record back as it was. If someone changed the record since, Undo keeps that change.
@@ -229,6 +237,7 @@ What each part does:
229
237
  - **What the canvas can do.** The prototype runs in a sandboxed frame. It cannot reach PMOS. The canvas talks to it only to show a screen, point, pin, play and apply your edits.
230
238
  - **Your prototype rules.** After a version renders and before it opens, PMOS checks it against your prototype rules: no device or browser frame, no instructions on the screen, no sample copy, and each rule PMOS learns from your corrections. When a correction is true of every prototype (for example "no device frame"), the chat adds it as a rule (`pmos lab rule add`). PMOS keeps a rule only when it fails a bad example and passes a good one, so a button such as "See the week" is never read as an instruction. A change to one version ("make the alert orange") or a taste ("calmer") never becomes a rule. A version that breaks a rule gets one fix run, given only the lines that broke it. You see only the fixed version, with one quiet line: "PMOS fixed 3 things before showing you this." When the fix does not reach a rule, the version still opens and the line names the rule it breaks. When nothing was fixed, there is no line. Settings › Prototype rules lists the rules with Undo.
231
239
  - **The design critic.** After the prototype rules, a separate read-only session reads the version's desk and phone screenshots and its page against every standing design rule of your product. Each rule is a named check: each numbered principle in your design principles and each rule in your `design-rules.json`. A finding must name the rule it breaks, so the critic reports broken rules, not taste. Its findings go into the same one fix run. After the fix it reads only those rules again, so "PMOS fixed n things" is never claimed unchecked. A critic that cannot run never holds the version. `pmos lab critic` runs it on any screenshots, and `PMOS_CRITIC=off` turns it off.
240
+ - **The sceptical reviewer.** Before you share a document, the chat's agent runs `pmos critic <file>`: a separate read-only session reads it as a sceptical reviewer and lists at most 3 hard questions. Each names its lens, quotes the document and gives the smallest fix; a question whose quote is not in the document is dropped. `pmos critic stats` shows how many you called real, and the gaps that repeat across documents.
232
241
  - **No time limit.** A version takes as long as the ask needs. While PMOS makes it, the Viewer shows what it is doing now (for example "Building screen 3 of 7"), the steps done, a progress bar and the time so far, with a Stop press. A run that writes nothing for 10 minutes is stuck: PMOS stops it. A version that does not render, that is stuck or that you stop is "not made" with the reason, and the chat says so. The Viewer still opens it: it says why and shows the version it was made from. While a version is being made, a new ask on the same initiative waits: PMOS says what is running.
233
242
  - **Lessons.** Each change sentence, ✓ and ✕ is a Lessons line of the experiment (`pmos artefacts show`). Each version that rendered is a Specimens line. The one you keep is the kept specimen.
234
243
  - **The grill runs after the session, not during it.** When you keep a version, the grill runs once on the kept specimen, as the Review step. Its findings wait under the ✦ (D60 as amended on 2026-11-17).
@@ -184,6 +184,18 @@ PMOS's grill run files with these commands, which refuse outside that run:
184
184
  - `pmos grill voices --sources <n>`: how many stored sources Voices can use.
185
185
  - `pmos grill status`: what is open, kept and dropped.
186
186
 
187
+ ### pmos critic: questions before you share a document
188
+
189
+ Before you share a spec, a strategy, a roadmap or a report, PMOS reads it as a sceptical reviewer would and lists the hardest questions that reviewer would ask. Each question names its lens (evidence, outcome, trade-off, scope, risk, owner, contradiction or unverified claim), quotes the words of the document it rests on, and gives the smallest fix. A question whose quote is not in the document is dropped. The chat's agent runs it when you say you are about to share a document. Nothing is sent and the document is not changed.
190
+
191
+ - `pmos critic <file> [--ws <id>]`: one pass on a markdown, text or HTML document. It prints at most 3 questions, the hardest first. The running PMOS server starts one read-only session.
192
+ - `pmos critic show <file> [--ws <id>]`: the newest pass on that file, and whether the file changed since.
193
+ - `pmos critic lenses [--root <dir>]`: the lenses. Add your product's own reviewer questions in `pmos/review-questions.json` (or `okf/products/<slug>/references/review-questions.json`): `{ "questions": [{ "id", "title", "rule" }] }`. An id that is a base lens replaces it. No server is needed.
194
+ - `pmos critic label <run> <n> real|noise`: your word on question `n` of a run.
195
+ - `pmos critic stats`: the runs, the questions, how many you called real or noise, how many were dropped for a quote not in the document, and the gaps that repeat across documents. When the same gap is in several documents, fix the template or the generator that makes them.
196
+
197
+ `PMOS_CRITIC=off` turns this critic and the design critic off.
198
+
187
199
  ### pmos ai: the AI jobs, their kill switch and audit
188
200
 
189
201
  - `pmos ai status`: whether each AI job is on, whether its replay passed, and what its last run filed. It also shows the keep rate of each job that files under ✦ for the last 14 days, and each product.
@@ -621,7 +633,7 @@ The benchmark needs a signed-in agent CLI. It never pushes and never opens a pul
621
633
  - `pmos jira moves`
622
634
  - `pmos jira moved <move id> --status "<Jira status>"` or `--refused "<why>"`
623
635
  - `pmos jira guesses <initiative> [--from <file|->]`
624
- - `pmos jira answer <initiative> <ticket> <n> --text "<answer>"`
636
+ - `pmos jira answer <initiative> <ticket> <n> --text "<answer>"` or `--keep-default`
625
637
 
626
638
  Every command takes `--json` and `--root <dir>`.
627
639
 
@@ -99,6 +99,7 @@ A ticket points to the PRD, but the builder holds only the ticket. Before you se
99
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
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
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
+ - Each question comes with a default: the answer a builder would assume, taken from the PRD line where there is one. The ticket says "Unless the PM says otherwise: <default>", and the list asks "<question>? Unless you say otherwise: <default>." To accept it, keep the default; to change it, type your answer.
102
103
  - 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
 
104
105
  In the terminal:
@@ -107,9 +108,10 @@ In the terminal:
107
108
  pmos jira guesses <initiative>
108
109
  pmos jira guesses <initiative> --from guesses.json
109
110
  pmos jira answer <initiative> <ticket> <n> --text "Fail closed: show the paywall"
111
+ pmos jira answer <initiative> <ticket> <n> --keep-default
110
112
  ```
111
113
 
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"}]}]}`.
114
+ 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", "default": "<the answer a builder would assume>"}]}]}`.
113
115
 
114
116
  ## Choose the epic
115
117
 
@@ -112,7 +112,7 @@ An "off" switch accepts `off`, `0`, `false` or `no` unless the row says a differ
112
112
  | `PMOS_HEADLESS` | `off` sends every background job back to a terminal pane. | on | — |
113
113
  | `PMOS_AI` | `off` turns every AI job off (the kill switch of [what agents may do](agent-capabilities.md)). | on | `pmos ai off` (the `ai.on` setting) |
114
114
  | `PMOS_AI_<JOB>` | `off` turns one AI job off. The names are `PMOS_AI_PAST_REPEAT`, `PMOS_AI_DECISION_MEMORY`, `PMOS_AI_OUTCOMES`, `PMOS_AI_DESCRIPTIONS`, `PMOS_AI_DRIFT`, `PMOS_AI_REHEARSE`, `PMOS_AI_NEXT_PROMPT`, `PMOS_AI_SHARPEN_PROMPT` and `PMOS_AI_IDLE_LAB`. | on | `pmos ai off <job>` (the `ai.off` setting) |
115
- | `PMOS_CRITIC` | `off` stops the design critic: no critic reads a prototype version before it opens, and `pmos lab critic` refuses. The prototype rules still run. | on | — |
115
+ | `PMOS_CRITIC` | `off` stops the design critic and the sceptical reviewer: no critic reads a prototype version before it opens, and `pmos lab critic` and `pmos critic` refuse. The prototype rules still run. | on | — |
116
116
  | `PMOS_AUTONOMY` | `off` stops every change PMOS applies by itself (D106) and every goal loop; proposals still wait for your ✓. | on | `pmos ai off` |
117
117
  | `PMOS_BUILD_SANDBOX` | `docker` or `podman` runs `pmos build check` in a container with no network (the image is `check.image` in `pmos/factory.json`). Without it the check runs in the worktree, and only you can run it. | off | — |
118
118
  | `PMOS_FACTORY_GH_TOKEN` | The factory's own GitHub token, when `pmos/factory.json` names it in `identity.token_env`. The name must start with `PMOS_FACTORY_`. PMOS gives it to gh for its own calls and removes it from every agent run. Never put it in a file. | not set: your gh login | — |
@@ -2,6 +2,8 @@
2
2
  /* auto-keep.js — the ✦ half of D106 ("Full autonomy now"): after the proposal runs, every open class A or B ✦ proposal of a lead
3
3
  * workspace is applied by itself, one batch each, with Undo (lib/routes-proposals.js autoKeep, lib/autonomy.js). A workspace is
4
4
  * read again only when its proposals ledger changed. `pmos ai off` and PMOS_AUTONOMY=off stop it (autonomy.killed).
5
+ * DEFAULTS (default-decisions-with-a-deadline): once a local day per lead workspace, the day's question list is read the way Your move
6
+ * reads it (lib/routes-your-move.js questions), which takes the defaults due that day, so a question nobody opened still closes.
5
7
  *
6
8
  * create({ workspaces, isLead, stateDirFor, proposalCtx, settingsDir, env?, warn? }) → { tick() }
7
9
  */
@@ -10,6 +12,8 @@ const path = require('path');
10
12
 
11
13
  function create({ workspaces, isLead, stateDirFor, proposalCtx, settingsDir, env = process.env, warn = () => {} }) {
12
14
  const seen = new Map();
15
+ const daySeen = new Map();
16
+ const localDay = (ms = Date.now()) => { const d = new Date(ms); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
13
17
  const mtimeOf = (dir) => { try { return fs.statSync(path.join(dir, 'proposals.jsonl')).mtimeMs; } catch { return null; } };
14
18
  function tick() {
15
19
  if (require('./autonomy.js').killed({ env, settingsDir: settingsDir() })) return;
@@ -19,6 +23,10 @@ function create({ workspaces, isLead, stateDirFor, proposalCtx, settingsDir, env
19
23
  try {
20
24
  if (!isLead(w)) continue;
21
25
  const dir = stateDirFor(w); if (!dir) continue;
26
+ const day = localDay();
27
+ if (daySeen.get(w.id) !== day) {
28
+ try { require('./routes-your-move.js').questions(proposalCtx(), w, day); daySeen.set(w.id, day); } catch (e) { warn('default decisions tick', e); }
29
+ }
22
30
  const mt = mtimeOf(dir);
23
31
  if (mt == null || seen.get(w.id) === mt) continue;
24
32
  const state = D.fold(D.readLines(D.ledgerFile(D.stateDirOf(w.root) || dir)));
@@ -98,6 +98,8 @@ const KIND_LIST = Object.freeze([
98
98
  k('description', 'Descriptions and links', ['propose:description', 'propose:links']),
99
99
  k('found', 'What PMOS found elsewhere', ['propose:found', 'propose:scanned', 'propose:improved', 'propose:prototyped']),
100
100
  k('grill', 'Fixes from a check', ['propose:grill']),
101
+ // default-decisions-with-a-deadline: the day's questions nobody answered by their deadline (lib/default-decisions.js)
102
+ k('defaults', 'Defaults when nobody answers', ['propose:default']),
101
103
  ]);
102
104
  const KIND_OF_JOB = new Map(KIND_LIST.flatMap((x) => x.jobs.map((j) => [j, x.key])));
103
105
  const kindOf = (job) => KIND_OF_JOB.get(String(job || '')) || null;
@@ -0,0 +1,99 @@
1
+ 'use strict';
2
+ /* critic-cli.js — `pmos critic`: before you share a document, the hardest questions a sceptical reviewer would ask (initiative spec-critic;
3
+ * lib/spec-critic.js, POST and GET /api/spec-critic in lib/routes-spec-critic.js).
4
+ *
5
+ * pmos critic <file> [--ws <id>] one pass through the running server: at most 3 questions, each with its lens, the quoted words and
6
+ * the smallest fix. The chat's agent runs it when the PM says they are about to share a document.
7
+ * pmos critic show <file> [--ws <id>] the newest pass on that file, and whether the file changed since (through the server)
8
+ * pmos critic lenses [--root <dir>] the lenses: the base set plus the product's review-questions.json (no server)
9
+ * pmos critic label <run> <n> real|noise the PM's word on question n of a run (no server)
10
+ * pmos critic stats runs, questions, real, noise, dropped for a missing quote, and the gaps that repeat across documents
11
+ *
12
+ * Nothing is sent and no document is changed. Exit codes: 0 done, 1 refused, 2 usage. */
13
+ const path = require('path');
14
+ const SC = require('./spec-critic.js');
15
+
16
+ const COMMANDS = { critic: ['show', 'lenses', 'label', 'stats'] };
17
+ const USAGE = [
18
+ 'usage: pmos critic <file> [--ws <id>] — before you share a document, the hardest questions a sceptical reviewer would ask',
19
+ ' pmos critic <file> [--ws <id>] a markdown, text or HTML document: at most 3 questions, each quoting the document, with the smallest fix',
20
+ ' pmos critic show <file> [--ws <id>] the newest pass on that file, and whether the file changed since',
21
+ ' pmos critic lenses [--root <dir>] the lenses the critic asks through: the base set plus the product\'s review-questions.json',
22
+ ' pmos critic label <run> <n> real|noise your word on question n of a run',
23
+ ' pmos critic stats runs, questions, real, noise, and the gaps that repeat across documents',
24
+ 'A question whose quote is not in the document is dropped. Nothing is sent. PMOS_CRITIC=off turns the critic off.',
25
+ ];
26
+ const flag = (args, k) => { const i = args.indexOf('--' + k); return i >= 0 ? (args[i + 1] === undefined || args[i + 1].startsWith('--') ? true : args[i + 1]) : undefined; };
27
+ const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
28
+ const plural = (n, w) => `${n} ${w}${n === 1 ? '' : 's'}`;
29
+ const fileArg = (args, from) => { for (let i = from; i < args.length; i++) { if (args[i] === '--ws' || args[i] === '--root') { i++; continue; } if (!args[i].startsWith('--')) return args[i]; } return ''; };
30
+ const pathFor = (f) => (path.isAbsolute(f) ? f : path.resolve(f));
31
+
32
+ function printQuestions(say, qs) {
33
+ qs.forEach((q, i) => {
34
+ say(` ${i + 1}. [${q.lens}] ${q.question}`);
35
+ say(` quotes: "${one(q.quote, 200)}"`);
36
+ if (q.why) say(` why it is hard: ${q.why}`);
37
+ if (q.fix) say(` fix before sharing: ${q.fix}`);
38
+ });
39
+ }
40
+
41
+ async function run(argv, { say = (s) => console.log(s), call = null, env = process.env } = {}) {
42
+ const args = argv.slice(1);
43
+ const sub = args[0];
44
+ if (!sub || ['help', '--help', '-h'].includes(sub)) { for (const l of USAGE) say(l); return sub ? 0 : 2; }
45
+ const rt = () => require('./state-root.js').defaultRoot({ env });
46
+
47
+ if (sub === 'lenses') {
48
+ const root = typeof flag(args, 'root') === 'string' ? path.resolve(flag(args, 'root')) : process.cwd();
49
+ const K = SC.lensesFor(root);
50
+ say(K.added ? `${K.lenses.length} lenses: the base set and ${plural(K.added, 'question')} from ${K.from.join(' and ')}` : `${K.lenses.length} base lenses (add your own in pmos/review-questions.json):`);
51
+ for (const l of K.lenses) say(` [${l.id}] ${l.title} ${one(l.rule, 160)}`);
52
+ return 0;
53
+ }
54
+ if (sub === 'stats') {
55
+ const st = SC.stats(rt());
56
+ say(`${plural(st.runs, 'critic run')}${st.notRun ? ` (${st.notRun} did not run)` : ''} on ${plural(st.files, 'document')} · ${plural(st.questions, 'question')}: ${st.real} real, ${st.noise} noise, ${st.unlabelled} not labelled · ${st.dropped} dropped for a quote not in the document`);
57
+ for (const r of st.repeats) say(` the same gap in ${r.files.length} documents: [${r.lens}] ${r.files.map((f) => path.basename(f)).join(', ')}. Fix the template or the generator that makes them.`);
58
+ return 0;
59
+ }
60
+ if (sub === 'label') {
61
+ const [id, n, lab] = args.slice(1);
62
+ if (!id || !n || !lab) { say('usage: pmos critic label <run> <n> real|noise'); return 2; }
63
+ let by = ''; try { by = require('./actor.js').fromCli({ env }).by || ''; } catch { by = ''; }
64
+ const r = SC.label(rt(), id, n, lab, { by: by || 'pm:cli' });
65
+ if (!r.ok) { say('✗ ' + r.error); return 1; }
66
+ say(`✓ question ${n} of ${id} is ${lab}: [${r.question.lens}] ${r.question.question}`);
67
+ return 0;
68
+ }
69
+ const ws = flag(args, 'ws');
70
+ const wsq = typeof ws === 'string' ? ws : undefined;
71
+ if (sub === 'show') {
72
+ const f = fileArg(args, 1);
73
+ if (!f) { say('usage: pmos critic show <file> [--ws <id>]'); return 2; }
74
+ if (typeof call !== 'function') { say('✗ no PMOS server answers: start PMOS, then ask again'); return 1; }
75
+ let r = null; try { r = await call('GET', `/api/spec-critic?path=${encodeURIComponent(pathFor(f))}${wsq ? '&ws=' + encodeURIComponent(wsq) : ''}`); } catch { r = null; }
76
+ if (!r) { say('✗ no PMOS server answers: start PMOS, then ask again'); return 1; }
77
+ if (!r.ok) { say('✗ ' + (r.error || 'the critic could not read it')); return 1; }
78
+ if (!r.run) { say(`No critic pass on ${path.basename(r.file)} yet: pmos critic ${f}`); return 0; }
79
+ const x = r.run;
80
+ say(`${x.at.slice(0, 16).replace('T', ' ')} · run ${x.id}${r.changed ? ' · the document changed since: run it again before you share' : ''}`);
81
+ if (!x.ok) { say('✗ it did not run: ' + (x.why || 'no answer')); return 0; }
82
+ if (!x.questions.length) say('✓ no hard question'); else printQuestions(say, x.questions);
83
+ return 0;
84
+ }
85
+ const f = fileArg(args, 0);
86
+ if (!f) { for (const l of USAGE) say(l); return 2; }
87
+ if (typeof call !== 'function') { say('✗ no PMOS server answers: start PMOS, then ask again'); return 1; }
88
+ let r = null; try { r = await call('POST', '/api/spec-critic', { path: pathFor(f), ...(wsq ? { ws: wsq } : {}) }); } catch { r = null; }
89
+ if (!r) { say('✗ no PMOS server answers: start PMOS, then ask again'); return 1; }
90
+ if (!r.ok) { say('✗ ' + (r.error || 'the critic did not run')); return 1; }
91
+ say(r.questions.length
92
+ ? `${plural(r.questions.length, 'hard question')} a sceptical reviewer would ask of ${path.basename(r.file)} · run ${r.run}`
93
+ : `✓ no hard question on ${path.basename(r.file)} (${r.lenses} lenses) · run ${r.run}`);
94
+ printQuestions(say, r.questions);
95
+ if (r.questions.length) say(`Label each: pmos critic label ${r.run} <n> real|noise`);
96
+ return 0;
97
+ }
98
+
99
+ module.exports = { run, COMMANDS, USAGE };
@@ -0,0 +1,199 @@
1
+ 'use strict';
2
+ /* default-decisions.js — default decisions with a deadline (initiative default-decisions-with-a-deadline; bet 2 in pmos-ideas/bets.md,
3
+ * proofs A26 + A27). Every question on the day's list (lib/question-batch.js) says what PMOS does if nobody answers, and by when. When the
4
+ * deadline passes with no answer, PMOS takes that default by itself, with Undo. A kind that others see or that cannot be taken back has
5
+ * no default: it waits for the PM, and the list says how long it has waited.
6
+ *
7
+ * DEFAULT_DAYS · JOB · WHY
8
+ * defaultOf(p) PURE → { choice: 'leave', say } | { choice: null, waits } the default of one held change
9
+ * firstDays(dayLines) PURE → Map id → the first day it was on the list (question-days.jsonl lines)
10
+ * defaultedOf(lines) PURE → { taken: Map id → batch, undone: Set id, batches: Map batch → [drop line] } from proposals.jsonl
11
+ * annotate(questions, held, { dayLines, lines, today, extra }) PURE → the questions, each with default | null, waits | null, waiting (days),
12
+ * cost (A27, costOf: what the wait holds up)
13
+ * dueOf(held, { dayLines, lines, today }) PURE → the held changes whose default is due today and was never taken or undone
14
+ * take(dir, held, { dayLines, today, product, pm, now, env, settingsDir }) → { taken: [{ batch, ini, board, ids, title }], why? }
15
+ * undo(dir, batch, { product, actor, now }) → { ok, back } | { ok: false, error }
16
+ *
17
+ * THE DEFAULT. A held change is a plan change PMOS has no source for (lib/source-guard.js), so the safe answer is the one that changes
18
+ * nothing: `leave`, PMOS leaves the plan as it is. Its due day is DEFAULT_DAYS after the day the change first joined the list. Taking it
19
+ * writes one drop line per change in proposals.jsonl, marked `default: true` with the batch (by `pmos:default`, so no job learns from it as
20
+ * from the PM's ✕), and one `applied` line for the job `propose:default` in autonomy.jsonl, so "PMOS did" lists it with Undo. The plan
21
+ * itself is not written; nothing is sent.
22
+ * NEVER A DEFAULT (NEVER below): a Jira ticket's state, a stage move, a message to a person, a pull request, a merge, a delete, spend, and
23
+ * a refuted outcome's next step. They wait for the PM, however long.
24
+ * UNDO. An undo line for the batch (lib/proposals.js fold then reads its drops as never written) brings the question back. An undone id is
25
+ * never defaulted again: it waits for the PM. The Undo is a setback of `propose:default` (two in a row demote it for 7 days).
26
+ * STOPS. `pmos ai off`, PMOS_AUTONOMY=off, a demotion, and the Settings kind "Defaults when nobody answers" set to Ask first
27
+ * (lib/autonomy.js decide). */
28
+
29
+ const DEFAULT_DAYS = 2;
30
+ const JOB = 'propose:default';
31
+ const BY = 'pmos:default';
32
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
33
+ const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
34
+ const str = (v) => (typeof v === 'string' ? v : '');
35
+ const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
36
+ const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
37
+ const dn = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? Math.round(Date.UTC(+m[1], +m[2] - 1, +m[3]) / 864e5) : null; };
38
+ const isoOf = (d) => new Date(d * 864e5).toISOString().slice(0, 10);
39
+ const addDays = (day, n) => { const d = dn(day); return d == null ? '' : isoOf(d + n); };
40
+ const md = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] : ''; };
41
+ const WHY = (due) => `No answer by ${md(due)}, so PMOS left the plan as it was.`;
42
+
43
+ /* The kinds that never default, each with the reason the list shows. `test(p)` reads a ✦ proposal (group, type, items) or a Driver
44
+ * proposal (`what`). */
45
+ const NEVER = [
46
+ { key: 'jira', test: (p) => p.group === 'status' && (p.items || []).some((x) => isObj(x) && x.jira), waits: "It changes a Jira ticket's state, which others see." },
47
+ { key: 'stage', test: (p) => (p.group === 'found' && p.type === 'stage') || p.what === 'move' || (p.items || []).some((x) => isObj(x) && x.op === 'stage'), waits: 'It moves the stage on a board others read.' },
48
+ { key: 'message', test: (p) => p.what === 'follow-up' || p.group === 'message' || (isObj(p.data) && (p.data.send === true || p.data.to)), waits: 'It sends a message to a person.' },
49
+ { key: 'pr', test: (p) => p.group === 'build', waits: 'It opens a pull request.' },
50
+ { key: 'merge', test: (p) => p.group === 'merge' || (isObj(p.data) && p.data.merge === true), waits: 'It merges into a product repository.' },
51
+ { key: 'delete', test: (p) => p.group === 'delete' || (isObj(p.data) && p.data.delete === true), waits: 'It deletes something.' },
52
+ { key: 'spend', test: (p) => p.group === 'spend' || (isObj(p.data) && p.data.spend != null), waits: 'It spends money.' },
53
+ { key: 'next', test: (p) => p.group === 'outcome' && (p.type === 'refuted' || p.type === 'source'), waits: 'What the work should be next is your call.' },
54
+ // the other asks on the same card (dry-run-tickets-before-build): a ticket's dry-run gap, and an outside sign-off
55
+ { key: 'ticket', test: (p) => p.group === 'ask' && /^dry:/.test(String(p.id || '')), waits: 'What the ticket should say is your call.' },
56
+ { key: 'signoff', test: (p) => p.group === 'ask', waits: 'It needs an answer from someone outside the team.' },
57
+ ];
58
+ const LEAVE_GROUPS = new Set(['dates', 'status', 'names', 'found', 'links']);
59
+
60
+ /** The default of one held change. PURE. */
61
+ function defaultOf(p) {
62
+ if (!isObj(p)) return { choice: null, waits: 'PMOS cannot read this change.' };
63
+ const never = NEVER.find((n) => { try { return n.test(p); } catch { return false; } });
64
+ if (never) return { choice: null, waits: never.waits, never: never.key };
65
+ if (!LEAVE_GROUPS.has(p.group)) return { choice: null, waits: 'PMOS has no safe default for this kind of change.' };
66
+ return { choice: 'leave', say: 'PMOS leaves the plan as it is' };
67
+ }
68
+
69
+ /** id → the first day it was on the list. PURE. dayLines: the lines of question-days.jsonl, { day, ids }. */
70
+ function firstDays(dayLines) {
71
+ const out = new Map();
72
+ for (const l of dayLines || []) {
73
+ if (!isObj(l) || typeof l.day !== 'string' || !Array.isArray(l.ids)) continue;
74
+ for (const id of l.ids) { const k = String(id); const was = out.get(k); if (!was || l.day < was) out.set(k, l.day); }
75
+ }
76
+ return out;
77
+ }
78
+
79
+ /** What PMOS defaulted, from the proposals ledger. PURE. A batch with an undo line is undone: its ids are never defaulted again. */
80
+ function defaultedOf(lines) {
81
+ const undoneB = new Set(), batches = new Map();
82
+ for (const l of lines || []) if (isObj(l) && l.kind === 'undo' && str(l.batch)) undoneB.add(l.batch);
83
+ for (const l of lines || []) {
84
+ if (!isObj(l) || l.kind !== 'drop' || l.default !== true || !str(l.batch)) continue;
85
+ if (!batches.has(l.batch)) batches.set(l.batch, []);
86
+ batches.get(l.batch).push(l);
87
+ }
88
+ const taken = new Map(), undone = new Set();
89
+ for (const [b, ls] of batches) for (const l of ls) { const id = str(l.id); if (!id) continue; if (undoneB.has(b)) undone.add(id); else taken.set(id, b); }
90
+ return { taken, undone, batches, undoneBatches: undoneB };
91
+ }
92
+
93
+ /** One held change's state against the list and the ledger. */
94
+ function stateOf(h, first, D, today) {
95
+ const p = h.prop, id = String(p.id);
96
+ const d = defaultOf(p);
97
+ const since = first.get(id) || '';
98
+ const waiting = since && dn(today) != null ? Math.max(0, dn(today) - dn(since)) : 0;
99
+ if (!d.choice) return { id, d, since, waiting, due: '', open: false };
100
+ if (D.undone.has(id)) return { id, d: { choice: null, waits: 'You undid PMOS\'s default, so it waits for you.' }, since, waiting, due: '', open: false };
101
+ const due = since ? addDays(since, DEFAULT_DAYS) : '';
102
+ return { id, d, since, waiting, due, open: !D.taken.has(id) };
103
+ }
104
+
105
+ /** Each question with its default, the reason when it has none, and how long it has waited. PURE. */
106
+ function annotate(questions, held, { dayLines = [], lines = [], today = '', extra = [] } = {}) {
107
+ const first = firstDays(dayLines), D = defaultedOf(lines);
108
+ const byId = new Map((held || []).filter((h) => isObj(h) && isObj(h.prop)).map((h) => [String(h.prop.id), h]));
109
+ // the other asks on the card (dry-run gaps, sign-offs) never default; they still say why they wait and how long they have waited
110
+ for (const x of extra || []) if (isObj(x) && x.id && !byId.has(String(x.id))) byId.set(String(x.id), { ini: x.ini, prop: { id: String(x.id), group: 'ask', items: [] } });
111
+ return (questions || []).map((q) => {
112
+ const st = (q.ids || []).map((id) => byId.get(String(id))).filter(Boolean).map((h) => stateOf(h, first, D, today));
113
+ const yes = st.filter((s) => s.d.choice && s.due), no = st.filter((s) => !s.d.choice);
114
+ const due = yes.map((s) => s.due).sort()[0] || '';
115
+ const part = yes.length && yes.length < st.length ? ` for ${yes.length} of these ${st.length} changes` : '';
116
+ const def = yes.length ? { choice: 'leave', due, n: yes.length, say: `If nobody answers by ${md(due)}, PMOS leaves the plan as it is${part}. You can undo it.` } : null;
117
+ const reasons = [...new Set(no.map((s) => s.d.waits))];
118
+ const waits = no.length ? (reasons.join(' ') + ' So ' + (no.length === st.length ? 'it waits' : plural(no.length, 'change waits', 'changes wait')) + ' for you.') : null;
119
+ const waiting = Math.max(0, ...st.map((s) => s.waiting));
120
+ return { ...q, default: def, waits, waiting, cost: costOf(st.map((s) => byId.get(s.id)), waiting) };
121
+ });
122
+ }
123
+
124
+ /** A27, the cost of waiting: what the question holds up and for how long. PURE. → { days, tasks, taskDays, say } | null (zero is silence).
125
+ * tasks: the plan's tasks the held changes name; taskDays: tasks × days waited, the slip the plan does not show while nobody answers. */
126
+ function costOf(hs, days) {
127
+ const tasks = new Set();
128
+ for (const h of hs || []) for (const x of (h && h.prop && h.prop.items) || []) if (isObj(x)) tasks.add(String(x.task || x.id || x.title || ''));
129
+ tasks.delete('');
130
+ if (!days) return null;
131
+ const n = tasks.size;
132
+ const say = n ? `Waiting ${plural(days, 'day', 'days')}: ${plural(n, 'task stays', 'tasks stay')} as ${n === 1 ? 'it is' : 'they are'} until someone answers (${plural(n * days, 'task-day', 'task-days')}).`
133
+ : `Waiting ${plural(days, 'day', 'days')}.`;
134
+ return { days, tasks: n, taskDays: n * days, say };
135
+ }
136
+
137
+ /** The held changes whose default is due on `today`, never taken and never undone. PURE. */
138
+ function dueOf(held, { dayLines = [], lines = [], today = '' } = {}) {
139
+ if (!today) return [];
140
+ const first = firstDays(dayLines), D = defaultedOf(lines);
141
+ return (held || []).filter((h) => {
142
+ if (!isObj(h) || !isObj(h.prop) || !h.prop.id || !h.ini) return false;
143
+ const s = stateOf(h, first, D, today);
144
+ return s.open && s.d.choice === 'leave' && s.due && s.due <= today;
145
+ });
146
+ }
147
+
148
+ /** Take the defaults due today: one batch per question (owner and initiative). → { taken: [...], why? } */
149
+ function take(dir, held, { dayLines = [], today = '', product = '', pm, now, env = process.env, settingsDir = null } = {}) {
150
+ const out = { taken: [] };
151
+ if (!dir || !today) return out;
152
+ const PR = require('./proposals.js');
153
+ const A = require('./autonomy.js');
154
+ const lines = PR.readLines(PR.ledgerFile(dir));
155
+ const due = dueOf(held, { dayLines, lines, today });
156
+ if (!due.length) return out;
157
+ const dec = A.decide({ stateDir: dir, job: JOB, product, cls: 'B', mode: 'auto', undoable: true, now, env, settingsDir });
158
+ if (!dec.apply) { out.why = dec.why; return out; }
159
+ const first = firstDays(dayLines);
160
+ const groups = require('./question-batch.js').questionsOf(due, { pm });
161
+ const byId = new Map(due.map((h) => [String(h.prop.id), h]));
162
+ for (const q of groups) {
163
+ const batch = PR.newBatch();
164
+ const hs = q.ids.map((id) => byId.get(String(id))).filter(Boolean);
165
+ const dueDay = hs.map((h) => addDays(first.get(String(h.prop.id)), DEFAULT_DAYS)).sort()[0];
166
+ const why = WHY(dueDay);
167
+ for (const h of hs) {
168
+ const p = h.prop;
169
+ const facts = PR.factsOf({ ...p, ini: h.ini });
170
+ PR.append(dir, { by: BY }, { kind: 'drop', ini: h.ini, board: h.board || '', sig: p.sig || PR.sigOf(p), id: String(p.id), group: str(p.group), type: str(p.type),
171
+ ...(facts.length ? { facts } : {}), why, default: true, batch });
172
+ }
173
+ const title = `Left the plan as it was on ${one(q.title, 80)}: ${plural(hs.length, 'change', 'changes')} nobody answered by ${md(dueDay)}`;
174
+ A.recordApplied(dir, { job: JOB, product, ref: batch, title, cls: 'B', ini: q.ini, why }, { now, settingsDir });
175
+ out.taken.push({ batch, ini: q.ini, board: q.board, ids: hs.map((h) => String(h.prop.id)), title });
176
+ }
177
+ return out;
178
+ }
179
+
180
+ /** Undo one default PMOS took: its question comes back and waits for the PM. */
181
+ function undo(dir, batch, { product = '', actor = { by: 'pm' }, now } = {}) {
182
+ if (!dir || !/^pk-[0-9a-f]{10}$/.test(String(batch || ''))) return { ok: false, error: 'batch is a pk-… id' };
183
+ const PR = require('./proposals.js');
184
+ const D = defaultedOf(PR.readLines(PR.ledgerFile(dir)));
185
+ if (!D.batches.has(batch)) return { ok: false, status: 404, error: 'no default was taken under that id' };
186
+ if (D.undoneBatches.has(batch)) return { ok: false, status: 409, error: 'Nothing to undo' };
187
+ PR.append(dir, actor, { kind: 'undo', batch });
188
+ const r = require('./autonomy.js').recordSetback(dir, { job: JOB, product, ref: batch, kind: 'undo' }, { now });
189
+ return { ok: true, back: true, ...(r.demoted ? { demoted: r.demoted } : {}) };
190
+ }
191
+
192
+ /** Is `batch` a default PMOS took (not a ✓ keep)? */
193
+ function isDefaultBatch(dir, batch) {
194
+ if (!dir) return false;
195
+ const PR = require('./proposals.js');
196
+ return defaultedOf(PR.readLines(PR.ledgerFile(dir))).batches.has(String(batch || ''));
197
+ }
198
+
199
+ module.exports = { DEFAULT_DAYS, JOB, BY, WHY, NEVER, defaultOf, firstDays, defaultedOf, annotate, costOf, dueOf, take, undo, isDefaultBatch, addDays };
@@ -29,7 +29,7 @@
29
29
  * parse(text, checks) PURE → [finding] | null (null: the answer could not be read)
30
30
  * asFailed(findings, checks) PURE → [{ id: 'critic:<check>', critic: true, check, title, words, lines }] (lib/prototype-rules.js run() shape)
31
31
  * critique(ask, { root?, checks?, targets, only?, product? }) → Promise<{ ok, findings, checks, ms } | { ok: false, why, off? }>
32
- * askVia(spawnSession, { timeoutMs? }) → ask(prompt, { key, addDirs }) → Promise<text | null>
32
+ * askVia(spawnSession, { timeoutMs?, name?, origin?, model? }) → ask(prompt, { key, addDirs }) → Promise<text | null>
33
33
  * file(rt) · record(rt, run) → id · label(rt, run, n, label, { by }) → { ok } | { ok: false, error } · read(rt) → [run + { labels }] · stats(rt) */
34
34
  const fs = require('fs');
35
35
  const path = require('path');
@@ -192,16 +192,17 @@ async function critique(ask, { root = '', checks = null, targets = [], only = nu
192
192
  if (!findings) return { ok: false, why: 'the critic\'s answer could not be read', ms };
193
193
  return { ok: true, findings, checks: list.map((c) => c.id), ms };
194
194
  }
195
- /** The ask path through the server's spawnSession: a read-only `briefing-ask:` run (kind ask), its answer text or null. */
196
- function askVia(spawnSession, { timeoutMs = TIMEOUT_MS, name = 'design critic' } = {}) {
195
+ /** The ask path through the server's spawnSession: a read-only `briefing-ask:` run (kind ask), its answer text or null. The spec critic
196
+ * (lib/spec-critic.js) uses it with its own origin under `briefing-ask:`. */
197
+ function askVia(spawnSession, { timeoutMs = TIMEOUT_MS, name = 'design critic', origin = ORIGIN, model = MODEL } = {}) {
197
198
  if (typeof spawnSession !== 'function') return null;
198
199
  return (prompt, { key = '', addDirs = [] } = {}) => new Promise((resolve) => {
199
200
  let settled = false; const done = (v) => { if (settled) return; settled = true; clearTimeout(t); resolve(v); };
200
201
  const t = setTimeout(() => done(null), timeoutMs);
201
202
  let s = null;
202
203
  try {
203
- s = spawnSession({ name, agent: 'claude', origin: ORIGIN + (key || Date.now().toString(36)), initialInput: prompt, addDirs,
204
- modelAsk: { explicit: { model: MODEL, effort: 'medium' } }, launchFlags: LEAN.map((f) => ({ ...f })),
204
+ s = spawnSession({ name, agent: 'claude', origin: origin + (key || Date.now().toString(36)), initialInput: prompt, addDirs,
205
+ modelAsk: { explicit: { model, effort: 'medium' } }, launchFlags: LEAN.map((f) => ({ ...f })),
205
206
  onDone: (d) => { const r = d && d.result; done(r && r.ok && !r.isError ? String(r.text || '') : null); } });
206
207
  } catch { s = null; }
207
208
  if (!s || s.state === 'exited') done(null);