create-pmos 0.570.0 → 0.572.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.570.0",
3
+ "version": "0.572.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,32 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.572.0",
38
+ "at": "2026-11-16T04:39:30.480Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1305,
43
+ "t": "A Project's dated tasks with a ◇ milestone are its dated plan",
44
+ "s": "A Project's dated tasks with a ◇ milestone are its dated plan",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "v": "0.571.0",
51
+ "at": "2026-11-16T04:26:43.356Z",
52
+ "f": 4,
53
+ "prs": [
54
+ {
55
+ "n": 1303,
56
+ "t": "The factory merges behind a guardrail, and rolls out behind a flag",
57
+ "s": "The factory merges behind a guardrail, and rolls out behind a flag",
58
+ "k": "new"
59
+ }
60
+ ]
61
+ },
36
62
  {
37
63
  "v": "0.570.0",
38
64
  "at": "2026-11-15T17:32:20.370Z",
@@ -284,32 +310,6 @@
284
310
  "k": "new"
285
311
  }
286
312
  ]
287
- },
288
- {
289
- "v": "0.552.0",
290
- "at": "2026-11-10T22:15:08.780Z",
291
- "f": 4,
292
- "prs": [
293
- {
294
- "n": 1280,
295
- "t": "Phone menu button clears the chat box; the PM can clear an Intent line",
296
- "s": "Phone menu button clears the chat box; the PM can clear an Intent line",
297
- "k": "fix"
298
- }
299
- ]
300
- },
301
- {
302
- "v": "0.551.0",
303
- "at": "2026-11-10T11:25:58.991Z",
304
- "f": 4,
305
- "prs": [
306
- {
307
- "n": 1279,
308
- "t": "Intent card on the product page; the Board by goal, and a Next column that says what Claude does next",
309
- "s": "Intent card on the product page; the Board by goal, and a Next column that says what Claude does next",
310
- "k": "new"
311
- }
312
- ]
313
313
  }
314
314
  ]
315
315
  }
package/payload/AGENTS.md CHANGED
@@ -125,10 +125,11 @@ This kit carries the factory: `pmos/scripts/work-item.js` (the one writer of `pm
125
125
 
126
126
  1. `pmos build claim <item>` claims one declared work item. The work happens on a new branch `pmos/<item>`, in a worktree outside the repository folder.
127
127
  2. `pmos build propose <item> "<what it does>" --evidence "<the check that passed>"` commits with the repository's own git identity (`pmos git-identity`) and the line `Work-Item: <item>`, marks the item verified, and files "Open a draft pull request" for the PM.
128
- 3. Only the PM opens the pull request: the ✓ on that proposal, or `pmos build open <item>`. It pushes the one branch and runs `gh pr create --draft`.
129
- 4. After the merge, `pmos verify-work` marks the item integrated.
128
+ 3. PMOS opens the pull request by itself (D108): the workspace applies the proposal, pushes the one branch and runs `gh pr create --draft`. Undo closes it. With `pmos ai off` it waits for the PM's ✓. The Builder's own run never pushes.
129
+ 4. Who merges is the product's own check, `pmos-guardrail` (copy `pmos/templates/pmos-guardrail.yml` to `.github/workflows/`; D108). It runs the default branch's `pmos/scripts/factory-guardrail.js` on the pull request's diff and reads AUTO or HUMAN. On AUTO it turns on GitHub auto-merge with the workflow's own token, so GitHub merges when every required check is green. On HUMAN the PM merges. The triggers that always read HUMAN are listed in that script and in the workspace guide (`pmos build policy <item>` shows the answer).
130
+ 5. After the merge, `pmos verify-work` marks the item integrated, and the item's flag rolls out 5% → 50% → 100% through the commands in `pmos/factory.json`. A metric over its budget turns the flag off, opens a revert pull request and puts the factory back to propose-only for 7 days.
130
131
 
131
- The audit for this path: a Builder run reads private code and untrusted content, so it holds no outward channel. It has no `git push`, no `gh` and no merge, and `pmos build open` refuses a role run. A commit that touches `pmos/`, `.github/`, `CLAUDE.md` or `AGENTS.md` is refused. The compensating gate is the product's own CI and branch protection on the default branch: protect it before you use the Builder.
132
+ The audit for this path: a Builder run reads private code and untrusted content, so it holds no outward channel. It has no `git push`, no `gh` and no merge, and `pmos build open` refuses a role run. A commit that touches `pmos/`, `.github/`, `CLAUDE.md` or `AGENTS.md` is refused. The guardrail workflow holds a write token and reads untrusted content (the diff), so it never runs the pull request's code: `pull_request_target` runs the default branch's workflow and script, and the head is only fetched and diffed. A pull request that changes CI, the guardrail or its own tests reads HUMAN. The compensating gate is the product's own CI and branch protection on the default branch: protect it, and make your CI required, before you use the guardrail.
132
133
 
133
134
  ## Escalation (stop and ask the PM)
134
135
 
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@32443ddf
2
- assembled: 2026-11-15
1
+ kernel-source: pmos@3421561f
2
+ assembled: 2026-11-16
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-15T17:32:16Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-16T04:39:26Z"}
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-15T17:32:16Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-16T04:39:26Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -0,0 +1,267 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* factory-guardrail.js — when a factory pull request may merge with no person (D108, initiative factory-guardrail-merge).
4
+ *
5
+ * Deterministic: it reads the diff, the work item and git history. No model call, no network except the two gh calls below.
6
+ * It is vendored with the factory into the kit (pmos/scripts/), and the product repository's workflow `pmos-guardrail`
7
+ * (kit/templates/pmos-guardrail.yml, on pull_request_target) runs THE DEFAULT BRANCH'S COPY of this file on the pull request's
8
+ * diff. The pull request's own code never runs, so a pull request cannot rewrite the rule that judges it.
9
+ *
10
+ * classify({ cwd, base, head, branch, body, ledgerText, now }) → { factory, item, verdict: 'auto'|'human'|'none', reasons, files }
11
+ *
12
+ * `none` not a factory pull request (no branch pmos/<item> and no line `Work-Item: <id>`): PMOS does nothing.
13
+ * `auto` ALL of: the item is verified in the default branch's ledger; every changed file is inside the item's declared scope;
14
+ * the change sits behind the item's flag (its name appears in the added lines) or the item is declared with no
15
+ * user-facing effect; and no trigger below fires. Required CI is GitHub's part: auto-merge waits for every required check.
16
+ * `human` any trigger, or any `auto` condition missing. Every reason is named.
17
+ *
18
+ * TRIGGERS (any one → human): migrations or data deletion · auth, permissions, payments, personal data or secrets · CI, gates,
19
+ * the guardrail, PMOS records or branch protection · a new dependency (a manifest line or a lock file) · a public API or contract ·
20
+ * anything sent outward · a new agent path · a changed existing test, test configuration or the item's own check reference ·
21
+ * the D11 triggers: the item failed before, a revert on the default branch in the last 14 days, a subsystem untouched 90 days ·
22
+ * the line `PMOS-Merge: human` (PMOS writes it when autonomy is off or the factory is demoted; the PM may add it to stop a merge) ·
23
+ * a pull request from a fork (a branch named pmos/… elsewhere is not PMOS's).
24
+ *
25
+ * CLI (the workflow's one step):
26
+ * node pmos/scripts/factory-guardrail.js --base <ref> --head <ref> [--branch <name>] [--body-file <f>] [--head-repo o/r --base-repo o/r] [--json]
27
+ * [--github --pr <number>] in GitHub Actions only: write verdict to GITHUB_OUTPUT and the step summary; on auto run
28
+ * `gh pr ready` and `gh pr merge --auto --squash` with the workflow's own token; on human turn
29
+ * auto-merge off. The agent never runs this: the Builder has no node, gh or push.
30
+ * Exit 0 for every verdict (the check reports, it does not block). A failure to read anything is `human`, never `auto`.
31
+ */
32
+ const fs = require('fs');
33
+ const path = require('path');
34
+ const cp = require('child_process');
35
+
36
+ const DAY = 86400000;
37
+ const REVERT_DAYS = 14;
38
+ const STALE_DAYS = 90;
39
+ const ITEM_RE = /^[a-z0-9][a-z0-9_-]*\.[0-9]+$/;
40
+
41
+ /* ---- the trigger list. Paths are matched lower case on their segments, so "controller" is not "role". ---- */
42
+ const seg = (f) => String(f).toLowerCase().split(/[\/._-]+/).filter(Boolean);
43
+ const segHas = (f, words) => seg(f).some((s) => words.includes(s));
44
+ const SENSITIVE = ['auth', 'authn', 'authz', 'oauth', 'login', 'logout', 'signin', 'session', 'sessions', 'permission', 'permissions', 'rbac', 'acl',
45
+ 'role', 'roles', 'payment', 'payments', 'billing', 'stripe', 'checkout', 'invoice', 'invoices', 'pii', 'gdpr', 'privacy', 'secret', 'secrets',
46
+ 'credential', 'credentials', 'password', 'passwords', 'vault', 'kms', 'env', 'keystore'];
47
+ const MIGRATION = ['migration', 'migrations', 'migrate', 'alembic', 'flyway', 'liquibase', 'sql'];
48
+ const API = ['openapi', 'swagger', 'proto', 'graphql', 'gql', 'wsdl'];
49
+ const AGENT_PATH = ['agents', 'claude', 'prompts', 'prompt', 'skills', 'mcp'];
50
+ const MANIFESTS = ['requirements.txt', 'requirements-dev.txt', 'pyproject.toml', 'pipfile', 'setup.py', 'setup.cfg', 'go.mod', 'cargo.toml', 'gemfile',
51
+ 'pom.xml', 'build.gradle', 'build.gradle.kts', 'composer.json', 'mix.exs', 'pubspec.yaml', 'package.swift', 'podfile', 'deno.json'];
52
+ const LOCKS = ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb', 'poetry.lock', 'pipfile.lock', 'cargo.lock',
53
+ 'go.sum', 'gemfile.lock', 'composer.lock', 'mix.lock', 'pubspec.lock', 'podfile.lock', 'uv.lock'];
54
+ const TEST_CONFIG = /(^|\/)(jest|vitest|playwright|cypress|karma|mocha|ava|babel|tsconfig)[^/]*\.(js|cjs|mjs|ts|json)$|(^|\/)(\.mocharc[^/]*|pytest\.ini|tox\.ini|conftest\.py|\.nycrc[^/]*|phpunit\.xml[^/]*)$/;
55
+ const TEST_FILE = /(^|\/)(tests?|__tests__|specs?|e2e|testdata|fixtures|__snapshots__)\//;
56
+ const TEST_NAME = /\.(test|spec)\.[a-z0-9]+$|_test\.(go|py|rb)$|(^|\/)test_[^/]*\.py$|\.snap$/;
57
+ const CI = /^(\.github\/|\.gitlab-ci\.yml$|\.gitlab\/|\.circleci\/|\.buildkite\/|\.drone\.yml$|azure-pipelines|bitbucket-pipelines\.yml$|jenkinsfile$|\.travis\.yml$|codeowners$|docs\/codeowners$|\.pre-commit-config\.yaml$|\.husky\/|lefthook\.yml$|pmos\/|\.pmos-profile$)/;
58
+ const GUARD_NAME = /(^|\/)(factory-guardrail\.js|pmos-guardrail\.ya?ml)$/;
59
+ const AGENT_FILES = /(^|\/)(agents\.md|claude\.md|gemini\.md|\.cursorrules|\.claude\/|\.cursor\/|\.codex\/)/;
60
+
61
+ const ADDED = [
62
+ { rule: 'data-deletion', re: /\b(drop\s+(table|column|database|schema|index)|truncate\s+(table\s+)?\w|delete\s+from\s|alter\s+table\b[^;]*\bdrop\b)/i, why: 'deletes data or changes a schema' },
63
+ { rule: 'data-deletion', re: /\.(deleteMany|dropCollection|dropDatabase|drop_table|remove_column|drop_column)\s*\(|\brm\s+-rf?\s+\//, why: 'deletes data' },
64
+ { rule: 'secrets', re: /(api[_-]?key|secret[_-]?key|client[_-]?secret|private[_-]?key|access[_-]?token|auth[_-]?token|password\s*[:=]|BEGIN [A-Z ]*PRIVATE KEY|aws_secret|xox[abp]-|gh[pousr]_[A-Za-z0-9]{20,}|sk-[A-Za-z0-9]{20,})/i, why: 'names a secret or a credential' },
65
+ { rule: 'outward', re: /\b(fetch\s*\(|axios\b|XMLHttpRequest|https?\.request\s*\(|https?\.get\s*\(|new\s+WebSocket\s*\(|navigator\.sendBeacon|sendMail|nodemailer|smtplib|smtp\b|webhook|twilio|sendgrid|mailgun|requests\.(get|post|put|delete|patch)\s*\(|urllib\.request|net\/http|http\.Post|curl\s|wget\s)/i, why: 'sends something outward' },
66
+ { rule: 'agent-path', re: /(@anthropic-ai\/|\banthropic\b|\bopenai\b|\bclaude\s+-p\b|\blangchain\b|\bllm\b|child_process|\bexecSync\s*\(|\bexecFile(Sync)?\s*\(|\bspawn(Sync)?\s*\(|\beval\s*\(|new\s+Function\s*\(|subprocess\.|os\.system\s*\()/i, why: 'adds a model call or runs a program (a new agent path)' },
67
+ ];
68
+
69
+ function git(cwd, args) {
70
+ const r = cp.spawnSync('git', args, { cwd, encoding: 'utf8', maxBuffer: 256 * 1024 * 1024, env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } });
71
+ return { ok: !r.error && r.status === 0, out: String(r.stdout || ''), err: String(r.stderr || (r.error && r.error.message) || '').trim() };
72
+ }
73
+ const one = (s, n) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
74
+
75
+ /** The ledger as the base has it: `git show <base>:<path>`, so a local preview reads exactly what CI reads. */
76
+ function baseLedger(cwd, base) {
77
+ const top = git(cwd, ['rev-parse', '--show-toplevel']).out.trim() || cwd;
78
+ const file = path.join(__dirname, '..', 'planning', 'work-items.jsonl');
79
+ const rel = path.relative(top, file).split(path.sep).join('/');
80
+ if (!rel.startsWith('..')) { const r = git(top, ['show', `${base}:${rel}`]); if (r.ok) return { text: r.out, rel }; }
81
+ return { text: null, rel };
82
+ }
83
+
84
+ /** Files and added lines of base...head (three dots: what the pull request adds to its merge base). */
85
+ function diffOf(cwd, base, head) {
86
+ const ns = git(cwd, ['diff', '--name-status', '-M', '--no-color', `${base}...${head}`]);
87
+ if (!ns.ok) return { error: `git could not diff ${base}...${head}: ${one(ns.err, 200)}` };
88
+ const files = [];
89
+ for (const l of ns.out.split('\n').filter(Boolean)) {
90
+ const p = l.split('\t');
91
+ const st = p[0][0];
92
+ files.push({ status: st, path: p[p.length - 1], from: st === 'R' || st === 'C' ? p[1] : null });
93
+ }
94
+ const u = git(cwd, ['diff', '-U0', '--no-color', '--no-ext-diff', `${base}...${head}`]);
95
+ const added = new Map();
96
+ let cur = null;
97
+ for (const l of u.out.split('\n')) {
98
+ if (l.startsWith('+++ ')) { cur = l.slice(4).replace(/^b\//, ''); if (!added.has(cur)) added.set(cur, []); continue; }
99
+ if (l.startsWith('+') && cur && cur !== '/dev/null') added.get(cur).push(l.slice(1));
100
+ }
101
+ return { files, added };
102
+ }
103
+
104
+ function depsOf(text) {
105
+ try {
106
+ const j = JSON.parse(text);
107
+ const out = new Set();
108
+ for (const k of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies', 'bundledDependencies']) {
109
+ const v = j[k];
110
+ if (Array.isArray(v)) v.forEach((x) => out.add(k + ':' + x));
111
+ else if (v && typeof v === 'object') Object.keys(v).forEach((x) => out.add(k + ':' + x));
112
+ }
113
+ return out;
114
+ } catch { return null; }
115
+ }
116
+
117
+ /** Was a merge reverted on the base lately? → days ago | null */
118
+ function recentRevert(cwd, base, nowMs) {
119
+ const r = git(cwd, ['log', `--since=${new Date(nowMs - REVERT_DAYS * DAY).toISOString()}`, '--format=%ct%x09%s', base]);
120
+ if (!r.ok) return null;
121
+ for (const l of r.out.split('\n').filter(Boolean)) {
122
+ const [ct, s] = l.split('\t');
123
+ if (/^revert\b/i.test(s || '')) return Math.max(0, Math.floor((nowMs - Number(ct) * 1000) / DAY));
124
+ }
125
+ return null;
126
+ }
127
+
128
+ /** The touched folders whose last change on the base is older than 90 days (D11: a subsystem untouched ~3 months). */
129
+ function staleDirs(cwd, base, files, nowMs) {
130
+ const dirs = [...new Set(files.filter((f) => f.status !== 'A').map((f) => path.posix.dirname(f.from || f.path)).filter((d) => d && d !== '.'))];
131
+ const out = [];
132
+ for (const d of dirs.slice(0, 40)) {
133
+ const r = git(cwd, ['log', '-1', '--format=%ct', base, '--', d]);
134
+ const ct = Number(r.out.trim());
135
+ if (ct && nowMs - ct * 1000 > STALE_DAYS * DAY) out.push({ dir: d, days: Math.floor((nowMs - ct * 1000) / DAY) });
136
+ }
137
+ return out;
138
+ }
139
+
140
+ const pathsIn = (ref) => String(ref || '').split(/\s+/).map((t) => t.replace(/^['"]|['"]$/g, '').replace(/^\.\//, '')).filter((t) => /[\/]|\.[a-z0-9]+$/i.test(t) && !t.startsWith('-'));
141
+ const inScope = (f, scope) => scope.some((s) => { const p = s.replace(/^\.\//, ''); return p.endsWith('/') ? f.startsWith(p) : f === p || f.startsWith(p + '/'); });
142
+
143
+ /** The verdict. Pure but for git reads in `cwd`. */
144
+ function classify({ cwd = process.cwd(), base, head, branch = '', body = '', ledgerText, now, headRepo = null, baseRepo = null } = {}) {
145
+ const nowMs = now == null ? Date.now() : (typeof now === 'number' ? now : Date.parse(now));
146
+ const fromBranch = /^(?:refs\/heads\/)?pmos\/(?:revert-)?([a-z0-9][a-z0-9_-]*\.[0-9]+)$/.exec(String(branch || ''));
147
+ const fromBody = /^Work-Item:\s*(\S+)\s*$/m.exec(String(body || ''));
148
+ const item = fromBranch ? fromBranch[1] : fromBody && ITEM_RE.test(fromBody[1]) ? fromBody[1] : null;
149
+ const isRevert = /^(?:refs\/heads\/)?pmos\/revert-/.test(String(branch || ''));
150
+ if (!item && !isRevert) return { factory: false, item: null, verdict: 'none', reasons: [{ rule: 'not-factory', detail: 'not a factory pull request (no branch pmos/<item>, no Work-Item line)' }], files: [] };
151
+ const reasons = [];
152
+ const human = (rule, detail) => reasons.push({ rule, detail });
153
+ if (isRevert) human('revert', 'a revert pull request opened by the rollout: the flag is already off, and the PM merges the revert');
154
+ if (headRepo && baseRepo && String(headRepo).toLowerCase() !== String(baseRepo).toLowerCase()) human('fork', `the pull request comes from ${one(headRepo, 100)}, not from this repository: PMOS pushes only here`);
155
+ if (/^PMOS-Merge:\s*human\s*$/mi.test(String(body || ''))) human('pmos-merge-human', 'PMOS asked for a person (autonomy is off, or the factory is back to propose-only)');
156
+ if (!base || !head) { human('unreadable', 'no base or head to compare'); return { factory: true, item, verdict: 'human', reasons, files: [] }; }
157
+
158
+ const d = diffOf(cwd, base, head);
159
+ if (d.error) { human('unreadable', d.error); return { factory: true, item, verdict: 'human', reasons, files: [] }; }
160
+ const files = d.files;
161
+ if (!files.length) human('empty', 'the pull request changes nothing');
162
+
163
+ // ---- the work item, as the default branch's ledger has it
164
+ let it = null;
165
+ const lt = ledgerText !== undefined ? { text: ledgerText } : baseLedger(cwd, base);
166
+ if (item) {
167
+ if (lt.text == null) human('no-ledger', 'the default branch has no work-item ledger');
168
+ else {
169
+ try {
170
+ const W = require('./work-item.js');
171
+ it = (W.deriveItems(lt.text, { now: new Date(nowMs).toISOString() }).items || []).find((x) => x.item_id === item) || null;
172
+ } catch (e) { human('unreadable', 'the ledger could not be read: ' + one(e.message, 160)); }
173
+ if (!it) human('not-declared', `${item} is not in the default branch's ledger. Push the PMOS records (Sync), then run this check again`);
174
+ }
175
+ }
176
+ const hist = (it && it.history) || [];
177
+ if (it && !hist.includes('verified')) human('not-verified', `${item} is ${it.state} on the default branch, not verified: its check has not passed there. Push the PMOS records (Sync), then run this check again`);
178
+ if (hist.includes('failed')) human('d11-failed', `${item} failed before (D11)`);
179
+ const g = (it && it.guard) || null;
180
+ const scope = g && Array.isArray(g.scope) ? g.scope.filter((s) => typeof s === 'string' && s.trim()) : [];
181
+ if (it && !scope.length) human('no-scope', `${item} declares no scope, so PMOS cannot tell whether the change stayed inside it`);
182
+
183
+ // ---- per file
184
+ const all = [];
185
+ for (const f of files) {
186
+ const p = f.path, l = p.toLowerCase(), base_ = path.posix.basename(l);
187
+ const add = d.added.get(p) || [];
188
+ all.push(...add.map((t) => [p, t]));
189
+ if (scope.length && !inScope(p, scope) && !(f.from && inScope(f.from, scope) && inScope(p, scope))) human('out-of-scope', `${p} is outside the declared scope (${scope.join(', ')})`);
190
+ if (CI.test(l) || GUARD_NAME.test(l)) human('ci-gates', `${p} is CI, a gate, the guardrail, a PMOS record or branch protection`);
191
+ if (AGENT_FILES.test(l) || segHas(p, AGENT_PATH)) human('agent-path', `${p} is an agent rule, prompt or skill (a new agent path)`);
192
+ if (segHas(p, MIGRATION) || /schema\.prisma$|(^|\/)db\/schema\./.test(l)) human('migration', `${p} is a migration or a schema`);
193
+ if (segHas(p, SENSITIVE) || /(^|\/)\.env(\.|$)|\.(pem|key|p12|pfx|jks)$/.test(l)) human('sensitive', `${p} touches auth, permissions, payments, personal data or secrets`);
194
+ if (segHas(p, API) || /(^|\/)index\.d\.ts$/.test(l)) human('public-api', `${p} is a public API or contract`);
195
+ if (LOCKS.includes(base_)) human('dependency', `${p} changes a lock file (a dependency may be new)`);
196
+ if (MANIFESTS.includes(base_) && add.some((t) => t.trim())) human('dependency', `${p} changes a dependency manifest`);
197
+ if (base_ === 'package.json') {
198
+ const before = git(cwd, ['show', `${base}:${f.from || p}`]), after = git(cwd, ['show', `${head}:${p}`]);
199
+ const a = before.ok ? depsOf(before.out) : new Set(), b = after.ok ? depsOf(after.out) : null;
200
+ if (!a || !b) human('dependency', `${p} could not be read`);
201
+ else { const added = [...b].filter((x) => !a.has(x)); if (added.length) human('dependency', `${p} adds ${added.map((x) => x.split(':')[1]).join(', ')}`); }
202
+ }
203
+ if (f.status !== 'A' && (TEST_FILE.test(l) || TEST_NAME.test(l))) human('self-test', `${p} changes an existing test (a pull request may not change what judges it)`);
204
+ if (TEST_CONFIG.test(l)) human('self-test', `${p} changes the test configuration`);
205
+ if (it && it.criterion) for (const r of pathsIn(it.criterion.ref)) if (p === r || p.startsWith(r.replace(/\/?$/, '/'))) human('self-test', `${p} is the item's own check (${it.criterion.ref})`);
206
+ }
207
+
208
+ // ---- added lines
209
+ const code = all.filter(([p]) => !/\.(md|mdx|txt|rst|adoc)$/i.test(p) && !TEST_FILE.test(p.toLowerCase()) && !TEST_NAME.test(p.toLowerCase()));
210
+ for (const t of ADDED) {
211
+ const hit = code.find(([, line]) => t.re.test(line));
212
+ if (hit) human(t.rule, `${hit[0]} ${t.why}: "${one(hit[1], 100)}"`);
213
+ }
214
+
215
+ // ---- the flag, or no user-facing effect
216
+ if (it && g) {
217
+ if (g.user_facing === false) { /* declared with no user-facing effect: no flag needed */ }
218
+ else if (!g.flag || !g.flag.name) human('no-flag', `${item} is user-facing and declares no flag. Declare --flag <name>, or --no-user-facing`);
219
+ else if (!code.some(([, line]) => line.includes(g.flag.name))) human('not-flagged', `the change does not read its flag ${g.flag.name}, so it would reach users at once`);
220
+ } else if (it) human('no-flag', `${item} declares neither a flag nor --no-user-facing`);
221
+
222
+ // ---- D11: history
223
+ const rv = recentRevert(cwd, base, nowMs);
224
+ if (rv !== null) human('d11-revert', `a merge was reverted on the default branch ${rv === 0 ? 'today' : rv + ' days ago'} (D11)`);
225
+ for (const s of staleDirs(cwd, base, files, nowMs)) human('d11-stale', `${s.dir} was last changed ${s.days} days ago (D11: a subsystem untouched about 3 months)`);
226
+
227
+ const seen = new Set();
228
+ const uniq = reasons.filter((r) => { const k = r.rule + '|' + r.detail; if (seen.has(k)) return false; seen.add(k); return true; });
229
+ return { factory: true, item, verdict: uniq.length ? 'human' : 'auto', reasons: uniq, files: files.map((f) => f.path) };
230
+ }
231
+
232
+ function summaryOf(v) {
233
+ if (v.verdict === 'none') return 'pmos-guardrail: not a factory pull request. Nothing to do.';
234
+ if (v.verdict === 'auto') return `pmos-guardrail: AUTO for ${v.item}. Auto-merge is on: GitHub merges when every required check is green. The change reaches users only through its flag.`;
235
+ return [`pmos-guardrail: HUMAN for ${v.item || 'this revert'}. A person merges this pull request, because:`, ...v.reasons.map((r) => `- ${r.detail}`)].join('\n');
236
+ }
237
+
238
+ /** GitHub Actions only: act on the verdict with the workflow's own token. The agent never reaches this. → [{ args, status }] */
239
+ function actOnGitHub(v, { pr, env = process.env } = {}) {
240
+ if (env.GITHUB_ACTIONS !== 'true') throw new Error('--github runs only inside GitHub Actions');
241
+ if (!/^[0-9]+$/.test(String(pr || ''))) throw new Error('--github needs --pr <number>');
242
+ const run = (args) => { const r = cp.spawnSync('gh', args, { encoding: 'utf8', env }); return { args, status: r.status, out: one(r.stdout || r.stderr || (r.error && r.error.message), 300) }; };
243
+ if (env.GITHUB_OUTPUT) fs.appendFileSync(env.GITHUB_OUTPUT, `verdict=${v.verdict}\nitem=${v.item || ''}\n`);
244
+ if (env.GITHUB_STEP_SUMMARY) fs.appendFileSync(env.GITHUB_STEP_SUMMARY, summaryOf(v) + '\n');
245
+ if (v.verdict === 'auto') return [run(['pr', 'ready', String(pr)]), run(['pr', 'merge', String(pr), '--auto', '--squash'])];
246
+ if (v.verdict === 'human') return [run(['pr', 'merge', String(pr), '--disable-auto'])];
247
+ return [];
248
+ }
249
+
250
+ function cliMain(argv, { say = (s) => console.log(s), env = process.env, cwd = process.cwd() } = {}) {
251
+ const opt = (k) => { const i = argv.indexOf(k); return i !== -1 && argv[i + 1] !== undefined && !argv[i + 1].startsWith('--') ? argv[i + 1] : undefined; };
252
+ const base = opt('--base'), head = opt('--head');
253
+ if (!base || !head) { say('usage: node factory-guardrail.js --base <ref> --head <ref> [--branch <name>] [--body-file <f>] [--json] [--github --pr <n>]'); return 2; }
254
+ let body = '';
255
+ if (opt('--body-file')) { try { body = fs.readFileSync(opt('--body-file'), 'utf8'); } catch { body = 'PMOS-Merge: human'; } }
256
+ let v;
257
+ try { v = classify({ cwd, base, head, branch: opt('--branch') || '', body, headRepo: opt('--head-repo') || null, baseRepo: opt('--base-repo') || null }); }
258
+ catch (e) { v = { factory: true, item: null, verdict: 'human', reasons: [{ rule: 'unreadable', detail: 'the guardrail failed: ' + one(e.message, 200) }], files: [] }; }
259
+ say(argv.includes('--json') ? JSON.stringify(v) : summaryOf(v));
260
+ if (argv.includes('--github')) {
261
+ for (const r of actOnGitHub(v, { pr: opt('--pr'), env })) say(`gh ${r.args.join(' ')} → ${r.status}${r.out ? ' ' + r.out : ''}`);
262
+ }
263
+ return 0;
264
+ }
265
+
266
+ module.exports = { classify, summaryOf, actOnGitHub, cliMain, REVERT_DAYS, STALE_DAYS };
267
+ if (require.main === module) process.exitCode = cliMain(process.argv.slice(2));
@@ -90,7 +90,7 @@ anchor="$(frontval parent_kr)"
90
90
  # In both profiles, as .github/scripts/initiative-gate.sh does for PMOS itself: a record that names its done test and kill condition is
91
91
  # an experiment and passes in any lane (the done test is the spec, D13 as amended by D107). The kind of work sets the gate (W5): Full
92
92
  # SDLC needs a done test and a kill condition, never a PRD or a brief; a Project needs a dated plan (plan_path: milestones with dates
93
- # and owners), never a PRD or a brief. A PRD or brief already on the record still passes: a gate passed stays passed. `pmos artefacts
93
+ # and owners, or dated tasks with a ◇ milestone in the task store), never a PRD or a brief. A PRD or brief already on the record still passes: a gate passed stays passed. `pmos artefacts
94
94
  # set experiment:<id> done-test …` writes done_test_path and kill: for you (lib/artefact-mirror.js).
95
95
  done_test="$(frontval done_test_path)"
96
96
  kill_cond="$(frontval kill)"
@@ -108,7 +108,17 @@ fi
108
108
  if [ "$kind" = project ]; then
109
109
  plan="$(frontval plan_path)"
110
110
  if [ -n "$plan" ] || [ -z "$had_spec" ]; then
111
- [ -n "$plan" ] || fail "initiative '$id' is a Project: it needs a dated plan, never a PRD or a brief. Set plan_path in $init_file to the plan (milestones with dates and owners), or give it a done test."
111
+ if [ -z "$plan" ]; then
112
+ # Dated tasks with a dated ◇ milestone in the task store ARE the dated plan (pmos task add --due … / pmos task set --milestone): the
113
+ # reader is workflow-state.js --task-plan, shipped next to this script (scripts/ in the PMOS repository itself).
114
+ here="$(cd "$(dirname "$0")" && pwd)"; ws=""; tp=""
115
+ for c in "$here/workflow-state.js" "$here/../../scripts/workflow-state.js"; do [ -f "$c" ] && { ws="$c"; break; }; done
116
+ if [ -n "$ws" ] && command -v node >/dev/null 2>&1 && tp="$(node "$ws" --task-plan "$id" --root . 2>/dev/null)"; then
117
+ echo "✅ initiative gate PASSED — '$id' (Project): $init_file exists and the dated plan is in the task store ($tp)."
118
+ exit 0
119
+ fi
120
+ fail "initiative '$id' is a Project: it needs a dated plan, never a PRD or a brief. Add dated tasks with at least one dated ◇ milestone (pmos task add --due …, pmos task set <task> --milestone), or set plan_path in $init_file to the plan (milestones with dates and owners), or give it a done test.${tp:+ The task store has $tp.}"
121
+ fi
112
122
  [ -f "$plan" ] || fail "plan_path '$plan' (from $init_file) does not exist in the repo."
113
123
  echo "✅ initiative gate PASSED — '$id' (Project): $init_file exists and the dated plan ($plan) is present."
114
124
  exit 0
@@ -453,6 +453,7 @@ function deriveItems(input, opts) {
453
453
  blast: obj.blast,
454
454
  criterion: obj.criterion,
455
455
  ...(obj.plan_item !== undefined ? { plan_item: obj.plan_item } : {}), // D86 point 1; absent stays absent
456
+ ...(obj.guard !== undefined ? { guard: obj.guard } : {}), // D108: scope, flag, user_facing, kr — what the merge guardrail reads
456
457
  state: 'declared',
457
458
  claim: null,
458
459
  evidence: null,
@@ -1382,6 +1383,26 @@ module.exports = {
1382
1383
  * prints the trailer line for the PR body: `Work-Item: <id>`. `verify` appends `verified` once the criterion's check passed.
1383
1384
  * After the PR merges, `verify-work.js` (or `pmos verify-work`) finds the line in the squash commit and appends `integrated`.
1384
1385
  * Every append goes through appendEvent, so every rule above still decides; a refusal prints its reason and exits 1. */
1386
+ /** D108: what the merge guardrail (scripts/factory-guardrail.js) reads from a declared item. → guard | null | { error }
1387
+ * --scope <prefix[,prefix]> the paths the item may change (no scope: its pull request always waits for the PM)
1388
+ * --flag <name> [--metric <name in factory.json metrics> --budget <max>] the flag the change sits behind, and its guard metric
1389
+ * --no-user-facing the change has no user-facing effect, so it needs no flag
1390
+ * --kr the item moves a key result: its rollout waits for the PM before 100% */
1391
+ function guardOf(argv, opt) {
1392
+ const has = (k) => argv.includes(k);
1393
+ if (!['--scope', '--flag', '--no-user-facing', '--kr', '--metric', '--budget'].some(has)) return null;
1394
+ const scope = String(opt('--scope') || '').split(',').map((x) => x.trim().replace(/^\.\//, '')).filter(Boolean);
1395
+ if (scope.some((x) => x.startsWith('/') || x.split('/').includes('..'))) return { error: '--scope takes paths inside the repository' };
1396
+ const g = { scope, user_facing: !has('--no-user-facing'), kr: has('--kr') };
1397
+ if (opt('--flag')) {
1398
+ if (!/^[A-Za-z0-9_.:-]{2,80}$/.test(opt('--flag'))) return { error: '--flag is one name: letters, digits, _ . : -' };
1399
+ g.flag = { name: opt('--flag') };
1400
+ if (opt('--metric')) { if (!/^[A-Za-z0-9_.:-]{1,80}$/.test(opt('--metric'))) return { error: '--metric names a metric in factory.json' }; g.flag.metric = opt('--metric'); }
1401
+ if (opt('--budget') !== undefined) { const b = Number(opt('--budget')); if (!Number.isFinite(b)) return { error: '--budget is a number' }; g.flag.budget = b; }
1402
+ } else if (has('--metric') || has('--budget')) return { error: '--metric and --budget belong to a --flag' };
1403
+ return g;
1404
+ }
1405
+
1385
1406
  function cliMain(argv) {
1386
1407
  const opt = (k) => { const i = argv.indexOf(k); return i !== -1 && argv[i + 1] && !argv[i + 1].startsWith('--') ? argv[i + 1] : undefined; };
1387
1408
  const [verb, target] = argv;
@@ -1389,6 +1410,7 @@ function cliMain(argv) {
1389
1410
  const read = () => { try { return readLedgerSafely(ledger); } catch (e) { if (e && e.code === 'ENOENT') return ''; throw e; } };
1390
1411
  const usage = () => {
1391
1412
  console.log('usage: node scripts/work-item.js declare <initiative> --type <t> --blast <b> --criterion "<text>" --check <kind> --ref "<ref>" [--plan-item <id>] [--agent <who>] [--hours N]');
1413
+ console.log(' [--scope <path,…>] [--flag <name> [--metric <name> --budget <max>] | --no-user-facing] [--kr] (D108: what the merge guardrail reads)');
1392
1414
  console.log(' node scripts/work-item.js verify <item> --evidence "<what passed>"');
1393
1415
  console.log(' node scripts/work-item.js claim <item> [--agent <who>] [--hours N]');
1394
1416
  console.log(' node scripts/work-item.js show [<initiative>] [--json]');
@@ -1410,8 +1432,10 @@ function cliMain(argv) {
1410
1432
  const id = `${target}.${n}`;
1411
1433
  const at = writerNow();
1412
1434
  const criterion = { text: opt('--criterion') || '', check: opt('--check') || 'test', ref: opt('--ref') || '' };
1435
+ const guard = guardOf(argv, opt);
1436
+ if (guard && guard.error) { console.log(`✗ ${guard.error}`); return 2; }
1413
1437
  const declared = { item_id: id, initiative_id: target, event: 'declared', at, type: opt('--type') || 'feature-slice', blast: opt('--blast') || 'low', criterion,
1414
- ...(opt('--plan-item') ? { plan_item: opt('--plan-item') } : {}) };
1438
+ ...(opt('--plan-item') ? { plan_item: opt('--plan-item') } : {}), ...(guard ? { guard } : {}) };
1415
1439
  if (!append(declared)) return 1;
1416
1440
  if (argv.includes('--no-claim')) {
1417
1441
  console.log(`✓ ${id} declared → planning/work-items.jsonl (not claimed; a Builder claims it)`);
@@ -231,6 +231,48 @@ function layout(root) {
231
231
  };
232
232
  }
233
233
 
234
+ // ── A Project's dated plan in the task store (launch simulation W6 follow-up) ─────────────────────
235
+ // `pmos task add/link/set --milestone` writes a Project's plan as task lines in <runsDir>/initiative-tasks.jsonl (lib/task-store.js; lines
236
+ // not yet moved there still sit in boards.jsonl). Dated tasks with at least one dated ◇ milestone ARE the dated plan, so plan_path is not
237
+ // needed: the gate (kit/scripts/gate-initiative.sh, through --task-plan) and both ladders read them here. The fold is the task part of
238
+ // scripts/boards.js fold: the first task line makes the task, task-update moves or re-dates it, task-remove and task-restore take it out and
239
+ // back, and the last task-milestone line wins. → { ok, dated, milestones, file, evidence }
240
+ const DAY_RE = /^\d{4}-\d{2}-\d{2}$/;
241
+ function taskPlanOf(root, id) {
242
+ const L = layout(root);
243
+ const files = ['boards.jsonl', 'initiative-tasks.jsonl'].map((f) => path.join(L.runsDir, f));
244
+ const tasks = new Map(); const removed = new Map(); const milestones = new Map();
245
+ for (const file of files) {
246
+ let text = '';
247
+ try { text = fs.readFileSync(file, 'utf8'); } catch { continue; }
248
+ for (const raw of text.split('\n')) {
249
+ const t = raw.trim();
250
+ if (!t || t[0] !== '{' || !t.includes('"task')) continue;
251
+ let e; try { e = JSON.parse(t); } catch { continue; }
252
+ if (!e || typeof e.task !== 'string' || !e.task) continue;
253
+ if (e.kind === 'task' && typeof e.initiative === 'string' && !tasks.has(e.task) && !removed.has(e.task)) {
254
+ tasks.set(e.task, { initiative: e.initiative, due: typeof e.due === 'string' ? e.due : '' });
255
+ } else if (e.kind === 'task-update' && tasks.has(e.task)) {
256
+ const x = tasks.get(e.task);
257
+ if (typeof e.initiative === 'string' && e.initiative) x.initiative = e.initiative;
258
+ if (typeof e.due === 'string') x.due = e.due;
259
+ } else if (e.kind === 'task-milestone' && typeof e.milestone === 'boolean') milestones.set(e.task, e.milestone);
260
+ else if (e.kind === 'task-remove' && tasks.has(e.task)) { removed.set(e.task, tasks.get(e.task)); tasks.delete(e.task); }
261
+ else if (e.kind === 'task-restore' && removed.has(e.task) && !tasks.has(e.task)) { tasks.set(e.task, removed.get(e.task)); removed.delete(e.task); }
262
+ }
263
+ }
264
+ let dated = 0; let ms = 0;
265
+ for (const [tid, x] of tasks) {
266
+ if (x.initiative !== id || !DAY_RE.test(x.due)) continue;
267
+ dated++;
268
+ if (milestones.get(tid) === true) ms++;
269
+ }
270
+ const file = path.relative(root, path.join(L.runsDir, 'initiative-tasks.jsonl')).split(path.sep).join('/');
271
+ const ok = ms > 0;
272
+ const evidence = `${dated} dated task${dated === 1 ? '' : 's'}, ${ms} dated milestone${ms === 1 ? '' : 's'} in ${file}`;
273
+ return { ok, dated, milestones: ms, file, evidence };
274
+ }
275
+
234
276
  // ── Git ────────────────────────────────────────────────────────────────────────────────────────
235
277
  function git(root, args) {
236
278
  try {
@@ -973,9 +1015,12 @@ function computeWorkflowDerived(id, opts) {
973
1015
  `write the done test (okf/core/templates/done-test-template.md), set done_test_path and kill: in ${recRel}`, { blocking: true, rule: 'R2' }));
974
1016
  } else if (!doneTest && workKind === 'project' && (planPath || !prd)) {
975
1017
  const planIdx = planPath ? firstAppearance(root, range, planPath) : null;
976
- if (!planPath) {
1018
+ const taskPlan = planPath ? null : taskPlanOf(root, id);
1019
+ if (taskPlan && taskPlan.ok) {
1020
+ steps.push(step('spec', 'spec', 'done', `dated plan in the task store: ${taskPlan.evidence}`));
1021
+ } else if (!planPath) {
977
1022
  steps.push(step('spec', 'spec', 'blocked', 'Project needs a dated plan before Execute — never a PRD',
978
- `write the plan (milestones with dates and owners, go-live matching the KR date) and set plan_path in ${recRel}, or a done test`, { blocking: true, rule: 'R2' }));
1023
+ `write the plan (milestones with dates and owners, go-live matching the KR date) and set plan_path in ${recRel}, or add dated tasks with a ◇ milestone (pmos task add --due … / pmos task set --milestone), or a done test`, { blocking: true, rule: 'R2' }));
979
1024
  } else if (planIdx === null) {
980
1025
  steps.push(step('spec', 'spec', 'blocked', `plan_path '${planPath}' does not exist in the repo`,
981
1026
  'create the plan the record points at, or correct plan_path', { blocking: true, rule: 'R2' }));
@@ -1605,14 +1650,16 @@ function pmLadder({ id, fm, lane, effLane, knownLane, legacy, steps, root, L, re
1605
1650
  const workKind = (() => { const k = String(fm.kind || '').trim().replace(/^["']|["']$/g, ''); return k === 'sdlc' || k === 'project' ? k : 'product'; })();
1606
1651
  const planPath = String(fm.plan_path || '').trim();
1607
1652
  const kindSpec = !doneTest && !exists(briefPath) && !foundBrief && (workKind === 'sdlc' || (workKind === 'project'));
1653
+ const tasksPlan = kindSpec && workKind === 'project' && !planPath ? taskPlanOf(root, id) : null;
1608
1654
  if (doneTest && dtPresent && killCond) steps.push(step('brief', def.brief_label, 'done', `done test ${doneTest} + kill condition (D107)`));
1609
1655
  else if (kindSpec && workKind === 'sdlc') steps.push(step('brief', 'done test', legacy ? 'pending' : 'blocked',
1610
1656
  'Full SDLC needs a done test and a kill condition before the first pull request — never a brief or a PRD',
1611
1657
  `write the done test, set done_test_path and kill: in ${recRel} (pmos artefacts set experiment:${id} done-test check --text "…" writes both)`, { blocking: !legacy, rule: 'R2' }));
1612
1658
  else if (kindSpec && exists(planPath)) steps.push(step('brief', 'dated plan', 'done', `plan ${planPath} present`));
1659
+ else if (kindSpec && !planPath && tasksPlan && tasksPlan.ok) steps.push(step('brief', 'dated plan', 'done', `dated plan in the task store: ${tasksPlan.evidence}`));
1613
1660
  else if (kindSpec) steps.push(step('brief', 'dated plan', legacy ? 'pending' : 'blocked',
1614
1661
  planPath ? `plan_path '${planPath}' does not exist in the repo` : 'Project needs a dated plan before Execute — never a brief or a PRD',
1615
- planPath ? 'create the plan the record points at, or correct plan_path' : `write the plan (milestones with dates and owners, go-live matching the KR date) and set plan_path in ${recRel}, or a done test`,
1662
+ planPath ? 'create the plan the record points at, or correct plan_path' : `write the plan (milestones with dates and owners, go-live matching the KR date) and set plan_path in ${recRel}, or add dated tasks with a ◇ milestone (pmos task add --due … / pmos task set --milestone), or a done test`,
1616
1663
  { blocking: !legacy, rule: 'R2' }));
1617
1664
  else if (doneTest && dtPresent) steps.push(step('brief', def.brief_label, 'blocked', 'no kill condition — an experiment states what would stop it (D107)',
1618
1665
  `write kill: "<the result that would make us stop>" in ${recRel}`, { blocking: !legacy, rule: 'R2' }));
@@ -1896,7 +1943,7 @@ function listInitiatives(root) {
1896
1943
  // ── CLI ────────────────────────────────────────────────────────────────────────────────────────
1897
1944
  function main(argv) {
1898
1945
  const args = argv.slice(2);
1899
- let root = process.cwd(); let json = false; let gate = false; let all = false; let lanes = false;
1946
+ let root = process.cwd(); let json = false; let gate = false; let all = false; let lanes = false; let taskPlan = null;
1900
1947
  const rest = [];
1901
1948
  for (let i = 0; i < args.length; i++) {
1902
1949
  const a = args[i];
@@ -1905,6 +1952,7 @@ function main(argv) {
1905
1952
  if (a === '--gate') { gate = true; continue; }
1906
1953
  if (a === '--all') { all = true; continue; }
1907
1954
  if (a === '--lanes') { lanes = true; continue; }
1955
+ if (a === '--task-plan') { taskPlan = args[++i] || ''; continue; }
1908
1956
  if (a === '--open') { continue; } // the board is in-flight-only by default now
1909
1957
  if (a === '--help' || a === '-h') {
1910
1958
  process.stdout.write([
@@ -1914,12 +1962,19 @@ function main(argv) {
1914
1962
  ' --gate <id> CI mode — exit 1 on a blocking order violation, with the next action',
1915
1963
  ' --all the board without the 12-row cap',
1916
1964
  ' --lanes every lane this repository offers: when to use it, input, output, done',
1965
+ ' --task-plan <id> exit 0 when the task store holds a Project\'s dated plan (dated tasks with a ◇ milestone)',
1917
1966
  ' --json machine-readable (what an agent reads at session start)', '',
1918
1967
  ].join('\n') + '\n');
1919
1968
  return 0;
1920
1969
  }
1921
1970
  rest.push(a);
1922
1971
  }
1972
+ if (taskPlan !== null) {
1973
+ if (!/^[a-z0-9][a-z0-9._-]*$/.test(taskPlan)) { process.stdout.write('--task-plan needs an initiative id\n'); return 2; }
1974
+ const tp = taskPlanOf(root, taskPlan);
1975
+ process.stdout.write(json ? JSON.stringify(tp) + '\n' : tp.evidence + '\n');
1976
+ return tp.ok ? 0 : 1;
1977
+ }
1923
1978
  if (lanes) {
1924
1979
  const info = lanesFor(root);
1925
1980
  if (json) { process.stdout.write(JSON.stringify(info, null, 2) + '\n'); return 0; }
@@ -1987,7 +2042,7 @@ function main(argv) {
1987
2042
  }
1988
2043
 
1989
2044
  module.exports = {
1990
- computeWorkflow, declaredLane: laneDefs.declaredLane, readLifecycle, STOPPED_STATES, renderLadder, renderBoard, listInitiatives, layout, inFlight, BOARD_CAP,
2045
+ computeWorkflow, taskPlanOf, declaredLane: laneDefs.declaredLane, readLifecycle, STOPPED_STATES, renderLadder, renderBoard, listInitiatives, layout, inFlight, BOARD_CAP,
1991
2046
  parseLeadingFrontmatter, specimenRoute, surfaceRoute, priorsCitation, isBuildPath, commitRange,
1992
2047
  // the board's trunk range, exported so the suite can assert the split: the same record is legacy
1993
2048
  // under BOTH ranges, and `in this change` is false under the trunk one.
@@ -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-15T17:32:16Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-16T04:39:26Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  Newest first, ISO dates.
4
4
 
5
- ## 2026-11-15
5
+ ## 2026-11-16
6
6
 
7
7
  - Adopted OKF v0.2 (D73).