create-pmos 0.567.0 → 0.569.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 (40) hide show
  1. package/package.json +27 -27
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/scripts/gate-initiative.sh +29 -0
  6. package/payload/scripts/workflow-state.js +36 -1
  7. package/payload/state/discoveries.md +1 -1
  8. package/payload/state/log.md +1 -1
  9. package/workspace/changelog.json +26 -0
  10. package/workspace/guide/cli.md +1 -1
  11. package/workspace/guide/initiatives-and-next-steps.md +20 -1
  12. package/workspace/lib/artefact-mirror.js +121 -0
  13. package/workspace/lib/artefacts-cli.js +15 -1
  14. package/workspace/lib/driver-decide.js +2 -0
  15. package/workspace/lib/engine/workflow-state.js +36 -1
  16. package/workspace/lib/engine/workflows.js +71 -7
  17. package/workspace/lib/jira-cli.js +1 -0
  18. package/workspace/lib/jira-tickets.js +23 -0
  19. package/workspace/lib/kind-control.js +232 -0
  20. package/workspace/lib/outcome-props.js +21 -1
  21. package/workspace/lib/rehearse-read.js +7 -3
  22. package/workspace/lib/rehearse.js +30 -2
  23. package/workspace/lib/route-modules.js +1 -0
  24. package/workspace/lib/routes-artefacts.js +4 -1
  25. package/workspace/lib/routes-boards.js +50 -2
  26. package/workspace/lib/routes-initiatives.js +3 -1
  27. package/workspace/lib/routes-kind-control.js +95 -0
  28. package/workspace/lib/today-cli.js +19 -0
  29. package/workspace/lib/vendor/scripts/workflow-state.js +36 -1
  30. package/workspace/lib/work-kind.js +16 -4
  31. package/workspace/lib/workflows-store.js +2 -2
  32. package/workspace/package-lock.json +2 -2
  33. package/workspace/package.json +1 -1
  34. package/workspace/public/pm/ini-agent.js +16 -6
  35. package/workspace/public/pm/ini-kind.js +59 -0
  36. package/workspace/public/pm/ini-view.css +23 -0
  37. package/workspace/public/pm/ini-view.js +5 -2
  38. package/workspace/run-tests.js +9 -0
  39. package/workspace/test-lists/kind-workflows.json +5 -0
  40. package/workspace/test-lists/launch-rerun-gaps.json +4 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.567.0",
3
+ "version": "0.569.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.569.0",
38
+ "at": "2026-11-15T17:07:37.237Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1301,
43
+ "t": "Close the five gaps the launch rerun found (launch simulation W6)",
44
+ "s": "Close the five gaps the launch rerun found (launch simulation W6)",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "v": "0.568.0",
51
+ "at": "2026-11-12T05:06:58.936Z",
52
+ "f": 4,
53
+ "prs": [
54
+ {
55
+ "n": 1300,
56
+ "t": "Project and Full SDLC get their own workflows and gates (launch simulation W5)",
57
+ "s": "Project and Full SDLC get their own workflows and gates (launch simulation W5)",
58
+ "k": "new"
59
+ }
60
+ ]
61
+ },
36
62
  {
37
63
  "v": "0.567.0",
38
64
  "at": "2026-11-12T04:54:34.259Z",
@@ -284,32 +310,6 @@
284
310
  "k": "new"
285
311
  }
286
312
  ]
287
- },
288
- {
289
- "v": "0.549.0",
290
- "at": "2026-11-10T07:06:56.286Z",
291
- "f": 4,
292
- "prs": [
293
- {
294
- "n": 1277,
295
- "t": "The story so far on the product page and shared Board; Settings › Claude says how Claude decides",
296
- "s": "The story so far on the product page and shared Board; Settings › Claude says how Claude decides",
297
- "k": "new"
298
- }
299
- ]
300
- },
301
- {
302
- "v": "0.548.0",
303
- "at": "2026-11-10T02:35:02.323Z",
304
- "f": 4,
305
- "prs": [
306
- {
307
- "n": 1276,
308
- "t": "Agent-run Your day and initiative Viewer",
309
- "s": "Agent-run Your day and initiative Viewer",
310
- "k": "new"
311
- }
312
- ]
313
313
  }
314
314
  ]
315
315
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@b9606359
2
- assembled: 2026-11-12
1
+ kernel-source: pmos@7305a765
2
+ assembled: 2026-11-15
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-12T04:54:30Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-15T17:07:33Z"}
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-12T04:54:30Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-15T17:07:33Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -86,6 +86,35 @@ anchor="$(frontval parent_kr)"
86
86
  # file IS the row, so the gate is where the same rule lands. A KR or health:<id> — never blank.
87
87
  [ -n "$anchor" ] || fail "initiative '$id' has no parent_kr in $init_file — anchor it to a KR, or to a declared health budget (parent_kr: health:<id> from $KIT_ROOT/planning/okrs/health-budgets.md, D59). Unanchored work is rejected (D21)."
88
88
 
89
+ # ---- D107 and the kind of work (launch simulation W6) --------------------------
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
+ # 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
+ # 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
94
+ # set experiment:<id> done-test …` writes done_test_path and kill: for you (lib/artefact-mirror.js).
95
+ done_test="$(frontval done_test_path)"
96
+ kill_cond="$(frontval kill)"
97
+ kind="$(frontval kind | tr -d "\"'")"
98
+ if [ -n "$done_test" ]; then
99
+ [ -f "$done_test" ] || fail "done_test_path '$done_test' (from $init_file) does not exist in the repo."
100
+ [ -n "$kill_cond" ] || fail "initiative '$id' names a done test but no kill condition — write kill: \"<the result that would make us stop>\" in $init_file (D107)."
101
+ echo "✅ initiative gate PASSED — '$id' (experiment, D107): $init_file exists, done test ($done_test) and kill condition present."
102
+ exit 0
103
+ fi
104
+ had_spec="$prd$(frontval brief_path)"
105
+ if [ "$kind" = sdlc ] && [ -z "$had_spec" ]; then
106
+ fail "initiative '$id' is Full SDLC: it needs a done test and a kill condition before the first pull request, never a PRD or a brief. Set done_test_path and kill: in $init_file (pmos artefacts set experiment:$id done-test check --text \"…\" writes both)."
107
+ fi
108
+ if [ "$kind" = project ]; then
109
+ plan="$(frontval plan_path)"
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."
112
+ [ -f "$plan" ] || fail "plan_path '$plan' (from $init_file) does not exist in the repo."
113
+ echo "✅ initiative gate PASSED — '$id' (Project): $init_file exists and the dated plan ($plan) is present."
114
+ exit 0
115
+ fi
116
+ fi
117
+
89
118
  # ---- D68: the pm-artifacts profile ------------------------------------------
90
119
  # A repository whose root holds `.pmos-profile` reading `pm-artifacts` is a PM's documents repo: its
91
120
  # work lanes are new-feature | improvement | bug-fix | discovery | chore and its document lanes are
@@ -963,7 +963,26 @@ function computeWorkflowDerived(id, opts) {
963
963
  'the done test is the spec (D13 as amended by D107). Land it in an earlier commit than the build, or split this PR so it lands first',
964
964
  { blocking: !legacy, rule });
965
965
  };
966
- if (doneTest) {
966
+ // W5 (boards WfA/WfB/WfC, agreed 2026-11-12): the kind of work sets the gate. Full SDLC: a done test and a kill condition before the first
967
+ // pull request. Project: a dated plan (plan_path), never a PRD. Product management (and a record with no kind:) keeps the rules below. A
968
+ // PRD already on the record still satisfies the spec rung after a kind change: a gate already passed stays passed.
969
+ const workKind = (() => { const k = String(fm.kind || '').trim().replace(/^["']|["']$/g, ''); return k === 'sdlc' || k === 'project' ? k : 'product'; })();
970
+ const planPath = String(fm.plan_path || '').trim();
971
+ if (!doneTest && workKind === 'sdlc' && !prd) {
972
+ steps.push(step('spec', 'spec', 'blocked', 'Full SDLC needs a done test and a kill condition before the first pull request — never a PRD',
973
+ `write the done test (okf/core/templates/done-test-template.md), set done_test_path and kill: in ${recRel}`, { blocking: true, rule: 'R2' }));
974
+ } else if (!doneTest && workKind === 'project' && (planPath || !prd)) {
975
+ const planIdx = planPath ? firstAppearance(root, range, planPath) : null;
976
+ if (!planPath) {
977
+ 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' }));
979
+ } else if (planIdx === null) {
980
+ steps.push(step('spec', 'spec', 'blocked', `plan_path '${planPath}' does not exist in the repo`,
981
+ 'create the plan the record points at, or correct plan_path', { blocking: true, rule: 'R2' }));
982
+ } else {
983
+ steps.push(orderOf(`plan ${planPath}`, planIdx, 'O1'));
984
+ }
985
+ } else if (doneTest) {
967
986
  const dtIdx = firstAppearance(root, range, doneTest);
968
987
  if (dtIdx === null) {
969
988
  steps.push(step('spec', 'spec', 'blocked', `done_test_path '${doneTest}' does not exist in the repo`,
@@ -1580,7 +1599,21 @@ function pmLadder({ id, fm, lane, effLane, knownLane, legacy, steps, root, L, re
1580
1599
  : briefPath ? firstAppearance(root, range, briefPath) : null;
1581
1600
  const docIdx = docPath ? firstAppearance(root, range, docPath) : null;
1582
1601
 
1602
+ // W6 (launch simulation rerun, 2026-11-15): the kind of work sets this ladder too, as it sets the product-code gate (W5) and the kit gate.
1603
+ // Full SDLC: a done test and a kill condition, never a brief. Project: a dated plan (plan_path), never a brief. A brief already on the
1604
+ // record still passes (a gate passed stays passed). Their deliverable is not a document: the pull requests, or the plan's milestones.
1605
+ const workKind = (() => { const k = String(fm.kind || '').trim().replace(/^["']|["']$/g, ''); return k === 'sdlc' || k === 'project' ? k : 'product'; })();
1606
+ const planPath = String(fm.plan_path || '').trim();
1607
+ const kindSpec = !doneTest && !exists(briefPath) && !foundBrief && (workKind === 'sdlc' || (workKind === 'project'));
1583
1608
  if (doneTest && dtPresent && killCond) steps.push(step('brief', def.brief_label, 'done', `done test ${doneTest} + kill condition (D107)`));
1609
+ else if (kindSpec && workKind === 'sdlc') steps.push(step('brief', 'done test', legacy ? 'pending' : 'blocked',
1610
+ 'Full SDLC needs a done test and a kill condition before the first pull request — never a brief or a PRD',
1611
+ `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
+ else if (kindSpec && exists(planPath)) steps.push(step('brief', 'dated plan', 'done', `plan ${planPath} present`));
1613
+ else if (kindSpec) steps.push(step('brief', 'dated plan', legacy ? 'pending' : 'blocked',
1614
+ 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`,
1616
+ { blocking: !legacy, rule: 'R2' }));
1584
1617
  else if (doneTest && dtPresent) steps.push(step('brief', def.brief_label, 'blocked', 'no kill condition — an experiment states what would stop it (D107)',
1585
1618
  `write kill: "<the result that would make us stop>" in ${recRel}`, { blocking: !legacy, rule: 'R2' }));
1586
1619
  else if (doneTest) steps.push(step('brief', def.brief_label, 'blocked', `done_test_path '${doneTest}' does not exist in the repo`,
@@ -1594,6 +1627,8 @@ function pmLadder({ id, fm, lane, effLane, knownLane, legacy, steps, root, L, re
1594
1627
  { blocking: enforce, rule: 'P1' }));
1595
1628
 
1596
1629
  if (!flows('draft')) steps.push(skipped('draft', def.draft_label));
1630
+ else if (workKind !== 'product' && !exists(docPath) && !foundDraft) steps.push(step('draft', 'deliverable', 'na',
1631
+ workKind === 'sdlc' ? 'Full SDLC — the pull requests are the deliverable, not a document' : 'Project — the plan\'s milestones are the deliverable, not a document'));
1597
1632
  else if (foundDraft) steps.push(step('draft', def.draft_label, 'done', `${foundDraft} — found by the repository scan`));
1598
1633
  else if (exists(docPath)) {
1599
1634
  const inOrder = briefIdx == null || docIdx == null ? null : docIdx >= briefIdx;
@@ -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-12T04:54:30Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-15T17:07:33Z"}
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-12
5
+ ## 2026-11-15
6
6
 
7
7
  - Adopted OKF v0.2 (D73).
@@ -1,4 +1,30 @@
1
1
  [
2
+ {
3
+ "v": "0.569.0",
4
+ "at": "2026-11-15T17:07:37.237Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1301,
9
+ "t": "Close the five gaps the launch rerun found (launch simulation W6)",
10
+ "s": "Close the five gaps the launch rerun found (launch simulation W6)",
11
+ "k": "new"
12
+ }
13
+ ]
14
+ },
15
+ {
16
+ "v": "0.568.0",
17
+ "at": "2026-11-12T05:06:58.936Z",
18
+ "f": 4,
19
+ "prs": [
20
+ {
21
+ "n": 1300,
22
+ "t": "Project and Full SDLC get their own workflows and gates (launch simulation W5)",
23
+ "s": "Project and Full SDLC get their own workflows and gates (launch simulation W5)",
24
+ "k": "new"
25
+ }
26
+ ]
27
+ },
2
28
  {
3
29
  "v": "0.567.0",
4
30
  "at": "2026-11-12T04:54:34.259Z",
@@ -393,7 +393,7 @@ The ledger is `driver.jsonl` in the state folder of the repository (`pmos/state`
393
393
 
394
394
  ### pmos artefacts: the seven artefacts
395
395
 
396
- `pmos artefacts show [<scope>]` lists the seven artefacts of a scope: Intent, Goal, Narrative, Experiment, Specimens, Done test and Lessons. The scope is `portfolio` (the default), `board:<id>`, `goal:<id>` or `experiment:<id>`. `pmos artefacts map` lists what each older core document, driver proposal kind, report cadence and lane becomes. `pmos artefacts migrate` puts every older record under its artefact as a pointer: issued and draft core documents, kept driver proposals and report drafts. It deletes and moves nothing, and a second run carries nothing new. `pmos artefacts set <scope> <artefact> [<field>] --text "<text>"` writes one field, and `pmos artefacts undo <id>` takes it back. Intent is yours: an agent proposes a change to it and waits for you. Goal is read from the OKRs, health budgets and readings, so you cannot type it.
396
+ `pmos artefacts show [<scope>]` lists the seven artefacts of a scope: Intent, Goal, Narrative, Experiment, Specimens, Done test and Lessons. The scope is `portfolio` (the default), `board:<id>`, `goal:<id>` or `experiment:<id>`. `pmos artefacts map` lists what each older core document, driver proposal kind, report cadence and lane becomes. `pmos artefacts migrate` puts every older record under its artefact as a pointer: issued and draft core documents, kept driver proposals and report drafts. It deletes and moves nothing, and a second run carries nothing new. `pmos artefacts set <scope> <artefact> [<field>] --text "<text>"` writes one field, and `pmos artefacts undo <id>` takes it back. A Done test check on `experiment:<id>` is also written to the experiment's done test file (`planning/done-tests/<id>.md`, or the file the record names), and the record gets `done_test_path:`; an Experiment kill condition becomes the record's `kill:`. So the ladder, the gates and `pmos jira draft` count it. A done test file you wrote by hand is left alone. Intent is yours: an agent proposes a change to it and waits for you. Goal is read from the OKRs, health budgets and readings, so you cannot type it.
397
397
 
398
398
  ### pmos coredoc: core documents
399
399
 
@@ -140,7 +140,26 @@ The writer makes the record in `planning/initiatives/<id>.md` with its type, tit
140
140
 
141
141
  PMOS picks a kind from the name as you type, and a blue line says so. Tap another kind to change it. After you tap a kind, PMOS does not change it. When the name gives no hint, the kind is Product.
142
142
 
143
- The kind is saved as `kind:` in the record (`product`, `sdlc` or `project`). An older record with no `kind:` line reads as Product. Use `pmos initiative new --kind <kind>` to set it from a terminal. The kind is not a lane: the Initiative Gate and the stages do not read it.
143
+ The kind is saved as `kind:` in the record (`product`, `sdlc` or `project`). An older record with no `kind:` line reads as Product. Use `pmos initiative new --kind <kind>` to set it from a terminal. The kind is not a lane, but it sets the workflow and the gate that the initiative starts on:
144
+
145
+ | Kind | Workflow | Gate |
146
+ |---|---|---|
147
+ | Product | The workspace default (Product feature unless you set another) | A done test and a kill condition, or a PRD |
148
+ | Full SDLC | Done test, Pull requests, CI, Merge, Release | A done test and a kill condition, dated before the first pull request. Never a PRD. |
149
+ | Project | Initiate, Plan, Execute, Monitor, Close | A dated plan (`plan_path`, or milestones with due days), every milestone owned by someone in People, and a go-live date that matches the KR date and the title. Never a PRD. |
150
+
151
+ Project and Full SDLC are built in, beside Product feature, under **Settings › Workflows**. You cannot edit them; copy one to make your own. Each initiative can still switch to another workflow.
152
+
153
+ When you change the kind, an initiative that runs its old kind's workflow moves to the new kind's. Its stage maps by meaning: Plan to Plan, Build to Execute, Deliver or Release to Close. A gate that it passed stays passed. One line in the initiative says what changed, for example "Kind changed to Project from Product: the Plan gate now needs milestone dates, owners and a go-live that matches the KR." An initiative on a workflow that you picked yourself stays on it.
154
+
155
+ **Project control.** A Project initiative shows **Project control** at the top of the initiative:
156
+
157
+ - **On track for <date>?** The answer comes from the task dates and the task links. The date is the KR's date, else the end, else the date in the title. On a No, it names the forecast, the slip and the task that causes it.
158
+ - **PMOS proposes** moving the go-live milestone to its forecast. Approve or dismiss it with the icons. It never changes the KR, the goal or the title: change those yourself. `pmos rehearse end <initiative> --to <date>` names each one that a new date breaks.
159
+ - **The critical path**: the tasks that hold go-live, walked back through the task links. With no links, PMOS names none.
160
+ - **Each task** with its colour, its owner and a bar. The outline is the baseline (the dates when the initiative left Plan, else the first dates). The filled bar is now. Red: late, on the critical path, and go-live misses the date. Amber: later than its baseline, or its start has passed. Green: on its baseline. The colour never reads a status that someone typed.
161
+
162
+ `pmos jira draft <initiative>` on a Project with no PRD drafts its milestones and tasks as a work breakdown: each milestone is an epic, with the tasks that end before it. Nothing is sent until you approve it.
144
163
 
145
164
  - **On the Board.** A small icon before each initiative's name shows its kind. The **Next** column follows the kind. For example, Full SDLC says "PMOS builds the first pull request" where a factory runs, and "PMOS writes the pull request plan for the team's agents" where none runs. Project says "PMOS writes the status line".
146
165
  - **In the initiative.** The same icon is in the header, before **Discuss in chat**. Tap it to change the kind. The toast has **Undo**. The Experiment names the kind once. Until someone writes **Who builds**, it comes from the kind: PMOS for Full SDLC where a factory runs, else the team's agents; the team for Product and Project. Project says **Who does it** and needs no specimens. A line that you or PMOS wrote stays as written.
@@ -0,0 +1,121 @@
1
+ 'use strict';
2
+ /* artefact-mirror.js — a Done test written with `pmos artefacts` counts everywhere a done test counts (launch simulation W6, gap 1).
3
+ *
4
+ * sync(root, scope, { actor, ledger }) → { ok, id, wrote: [what], note } | { ok: true, skipped: why } | refusal
5
+ *
6
+ * D107 lets an agent write an experiment's Done test checks and its kill condition into the artefact ledger (lib/artefacts.js). The ladder
7
+ * (scripts/workflow-state.js), the two gates (.github/scripts/initiative-gate.sh, kit/scripts/gate-initiative.sh), `pmos jira draft` and the
8
+ * Viewer gate read the record's `done_test_path:` and `kill:` instead, and the order rule (done test before the build) reads the git history of
9
+ * the done test FILE. So the ledger is mirrored onto the record, and no reader needs a second done-test source:
10
+ *
11
+ * - the checks (done-test.check, and done-test.result) go to a done test file, `planning/done-tests/<id>.md` (`pmos/planning/…` in a kit
12
+ * repository), or the file the record already names. The file carries MARK: a file without it was written by hand and is never touched.
13
+ * - the record gets `done_test_path:` when it has none, and `kill:` from the newest experiment.kill line. An undo writes back the kill the
14
+ * ledger holds then; when none is left the record keeps its line (it may have been written by hand).
15
+ *
16
+ * Nothing here runs a model, and nothing is committed: the CLI says to commit the two files, like every record write.
17
+ */
18
+ const fs = require('fs');
19
+ const path = require('path');
20
+
21
+ const MARK = '<!-- written by PMOS from the Done test artefact (pmos artefacts set). Edit the checks with pmos artefacts; a file without this line is left alone. -->';
22
+ const ID_RE = /^[a-z0-9][a-z0-9._-]*$/;
23
+ const refuse = (status, error) => ({ ok: false, status, error });
24
+ const q = (s) => '"' + String(s).replace(/\s+/g, ' ').trim().replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
25
+ const unquote = (v) => { const t = String(v || '').trim(); return /^".*"$/.test(t) ? t.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\') : /^'.*'$/.test(t) ? t.slice(1, -1).replace(/''/g, "'") : t; };
26
+ const cell = (s) => String(s).replace(/\s+/g, ' ').trim().replace(/\|/g, '\\|');
27
+
28
+ /** True for a set or undo the mirror cares about: an experiment's done test lines or its kill condition. */
29
+ function touches(line) {
30
+ if (!line || typeof line.scope !== 'string' || !/^experiment:/.test(line.scope)) return false;
31
+ return line.artefact === 'done-test' || (line.artefact === 'experiment' && (line.field === 'kill' || line.ev === 'undo'));
32
+ }
33
+
34
+ /** The done test file's text: front matter (D63), the mark, and one row per check. */
35
+ function fileText(id, title, checks, result, today) {
36
+ const out = ['---', 'type: Rubric', `title: ${q('Done test — ' + (title || id))}`, `timestamp: ${today}`, `initiative: ${id}`, '---', '', MARK, '',
37
+ `# Done test: ${id}`, '', 'Every check must pass. PMOS keeps this file in step with the Done test artefact.', ''];
38
+ if (checks.length) {
39
+ out.push('| # | Check |', '|---|---|');
40
+ checks.forEach((c, i) => out.push(`| ${i + 1} | ${cell(c)} |`));
41
+ } else out.push('No checks yet.');
42
+ if (result) out.push('', `Result: ${String(result).replace(/\s+/g, ' ').trim()}`);
43
+ return out.join('\n') + '\n';
44
+ }
45
+
46
+ function sync(root, scope, { ledger } = {}) {
47
+ const m = /^experiment:(.+)$/.exec(String(scope || ''));
48
+ if (!m || !ID_RE.test(m[1])) return { ok: true, skipped: 'not an experiment' };
49
+ const id = m[1];
50
+ const A = require('./artefacts.js');
51
+ const loaded = require('./console-state').loadEngine();
52
+ if (!loaded.ok) return refuse(500, loaded.error);
53
+ const L = loaded.engine.layout(root);
54
+ const rec = path.join(L.initiatives, `${id}.md`);
55
+ let text;
56
+ try { if (!fs.lstatSync(rec).isFile()) return { ok: true, skipped: 'the record is not a plain file' }; text = fs.readFileSync(rec, 'utf8'); }
57
+ catch { return { ok: true, skipped: `no initiative record ${id}` }; }
58
+ const fm = /^---\r?\n([\s\S]*?)\r?\n---(\r?\n|$)/.exec(text);
59
+ if (!fm) return { ok: true, skipped: 'the record has no front matter' };
60
+ const lines = fm[1].split(/\r?\n/);
61
+ const val = (key) => { const l = lines.find((x) => x.startsWith(key + ':')); return l ? unquote(l.slice(key.length + 1)) : ''; };
62
+
63
+ const v = A.viewOf(A.fold(A.readLines(ledger)), `experiment:${id}`);
64
+ const art = (k) => (v && v.artefacts.find((a) => a.key === k)) || { fields: {} };
65
+ const dt = art('done-test').fields, ex = art('experiment').fields;
66
+ // a list field holds one line per set; a set may hold several lines (withLine), each one check
67
+ const checks = (dt.check || []).flatMap((x) => String(x.text || '').split(/\n+/)).map((s) => s.trim()).filter(Boolean);
68
+ const result = dt.result && dt.result.text ? dt.result.text : '';
69
+ const kill = ex.kill && ex.kill.text ? String(ex.kill.text).replace(/\s+/g, ' ').trim() : '';
70
+
71
+ const wrote = [];
72
+ let note = '';
73
+ // the done test file
74
+ const named = val('done_test_path');
75
+ const relDefault = (L.kit ? 'pmos/planning/done-tests/' : 'planning/done-tests/') + id + '.md';
76
+ const rel = named || relDefault;
77
+ const abs = path.resolve(root, rel);
78
+ const inside = !path.relative(path.resolve(root), abs).startsWith('..');
79
+ let setPath = false;
80
+ if (!inside) note = `done_test_path '${rel}' is outside the repository: PMOS left it`;
81
+ else if (checks.length || result || fs.existsSync(abs)) {
82
+ let cur = null;
83
+ try { cur = fs.readFileSync(abs, 'utf8'); } catch { cur = null; }
84
+ if (cur != null && !cur.includes(MARK)) note = `the done test ${rel} was written by hand: PMOS left it as it is`;
85
+ else if (cur == null && !checks.length && !result) { /* nothing to write yet */ }
86
+ else {
87
+ const title = val('title');
88
+ const day = new Date().toISOString().slice(0, 10);
89
+ const next = fileText(id, title, checks, result, day);
90
+ // the timestamp alone never rewrites the file
91
+ const same = cur != null && cur.replace(/^timestamp: .*$/m, '') === next.replace(/^timestamp: .*$/m, '');
92
+ if (!same) {
93
+ try { fs.mkdirSync(path.dirname(abs), { recursive: true }); fs.writeFileSync(abs, next); } catch { return refuse(500, `the done test ${rel} could not be written`); }
94
+ wrote.push(rel);
95
+ }
96
+ if (!named) setPath = true;
97
+ }
98
+ }
99
+ // the record's two lines
100
+ let changed = false;
101
+ if (setPath) { lines.push(`done_test_path: ${rel}`); changed = true; }
102
+ if (kill && val('kill') !== kill) {
103
+ const at = lines.findIndex((l) => l.startsWith('kill:'));
104
+ if (at >= 0) lines[at] = 'kill: ' + q(kill); else lines.push('kill: ' + q(kill));
105
+ changed = true;
106
+ }
107
+ if (changed) {
108
+ try { fs.writeFileSync(rec, '---\n' + lines.join('\n') + '\n---' + fm[2] + text.slice(fm[0].length)); } catch { return refuse(500, 'the record could not be written'); }
109
+ wrote.push(path.relative(root, rec).split(path.sep).join('/'));
110
+ }
111
+ return { ok: true, id, wrote, note };
112
+ }
113
+
114
+ /** After a set or undo through lib/artefacts.js (called by its three writers: the CLI, POST /api/artefacts/set and the driver's Keep and
115
+ * Undo): mirror it when it touches a done test or a kill condition. Never throws. → the sync answer, or null when it touches neither. */
116
+ function after(root, line, ledger) {
117
+ if (!root || !touches(line)) return null;
118
+ try { return sync(root, line.scope, { ledger }); } catch (e) { return refuse(500, String((e && e.message) || e)); }
119
+ }
120
+
121
+ module.exports = { MARK, touches, sync, after, fileText };
@@ -12,6 +12,7 @@
12
12
  const path = require('path');
13
13
  const { execFileSync } = require('child_process');
14
14
  const A = require('./artefacts.js');
15
+ const MIRROR = require('./artefact-mirror.js');
15
16
  const actorLib = require('./actor.js');
16
17
 
17
18
  const COMMANDS = { artefacts: ['show', 'map', 'migrate', 'set', 'undo'] };
@@ -92,14 +93,27 @@ function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), env = pro
92
93
  for (const s of flags.source) { const i = s.indexOf('='); if (i < 1) { say('✗ --source is label=ref'); return 2; } sources.push({ label: s.slice(0, i), ref: s.slice(i + 1) }); }
93
94
  const r = A.set(f, { scope: pos[0], artefact: pos[1], field: pos[2], text: flags.text, sources }, actor, { now });
94
95
  if (!r.ok) { say('✗ ' + r.error); return 1; }
95
- say(flags.json ? JSON.stringify({ ok: true, id: r.line.id }) : `✓ ${r.line.artefact}.${r.line.field} on ${r.line.scope} (${r.line.id}; pmos artefacts undo ${r.line.id})`);
96
+ r.mirror = MIRROR.after(root, r.line, f); // a done test or kill condition lands on the record too (launch simulation W6)
97
+ if (flags.json) { say(JSON.stringify({ ok: true, id: r.line.id, ...(r.mirror ? { mirror: r.mirror } : {}) })); return 0; }
98
+ say(`✓ ${r.line.artefact}.${r.line.field} on ${r.line.scope} (${r.line.id}; pmos artefacts undo ${r.line.id})`);
99
+ mirrorSay(say, r.mirror);
96
100
  return 0;
97
101
  }
98
102
  if (!pos[0]) { say(USAGE[5]); return 2; }
99
103
  const r = A.undo(f, { ref: pos[0] }, actor, { now });
100
104
  if (!r.ok) { say('✗ ' + r.error); return 1; }
105
+ r.mirror = MIRROR.after(root, r.line, f);
101
106
  say(`✓ ${pos[0]} undone`);
107
+ mirrorSay(say, r.mirror);
102
108
  return 0;
103
109
  }
104
110
 
111
+ /** What the mirror wrote (lib/artefact-mirror.js): the done test file and the record, so the ladder and the gates count it. */
112
+ function mirrorSay(say, m) {
113
+ if (!m) return;
114
+ if (!m.ok) { say(' ! the record was not updated: ' + m.error); return; }
115
+ if (m.wrote && m.wrote.length) say(` ✓ wrote ${m.wrote.join(' and ')}: the ladder, the gates and pmos jira draft count it. Commit them to keep them.`);
116
+ if (m.note) say(' ' + m.note);
117
+ }
118
+
105
119
  module.exports = { run, COMMANDS, USAGE, mapRows };
@@ -73,6 +73,7 @@ async function writeRecord(p, actor, ctx, now) {
73
73
  }
74
74
  const r = A.set(f, { scope: d.scope, artefact: d.artefact, field: d.field, text, sources: p.sources }, actor, { now });
75
75
  if (!r.ok) return refuse(r.status || 409, r.error);
76
+ require('./artefact-mirror.js').after(ctx.root, r.line, f); // a done test or kill condition lands on the record too (W6)
76
77
  return { ok: true, wrote: 'artefact', undo: { op: 'artefact', ref: r.line.id } };
77
78
  }
78
79
  if (p.what === 'next-step') {
@@ -180,6 +181,7 @@ async function undo({ file, proposal, actor, ctx = {}, now, stateDir, product =
180
181
  const A = require('./artefacts.js');
181
182
  const r = A.undo(A.file(A.dirOf(ctx.root)), { ref: u.ref }, actor, { now: t });
182
183
  if (!r.ok) back = false;
184
+ else require('./artefact-mirror.js').after(ctx.root, r.line, A.file(A.dirOf(ctx.root)));
183
185
  } else if (p.what === 'next-step' && u.op === 'next-step' && ctx.itemsDir) {
184
186
  const paths = itemsPaths(ctx.itemsDir);
185
187
  pmItems.appendEvent(paths.steps, { event: 'step_removed', id: u.step }, new Date(t));
@@ -963,7 +963,26 @@ function computeWorkflowDerived(id, opts) {
963
963
  'the done test is the spec (D13 as amended by D107). Land it in an earlier commit than the build, or split this PR so it lands first',
964
964
  { blocking: !legacy, rule });
965
965
  };
966
- if (doneTest) {
966
+ // W5 (boards WfA/WfB/WfC, agreed 2026-11-12): the kind of work sets the gate. Full SDLC: a done test and a kill condition before the first
967
+ // pull request. Project: a dated plan (plan_path), never a PRD. Product management (and a record with no kind:) keeps the rules below. A
968
+ // PRD already on the record still satisfies the spec rung after a kind change: a gate already passed stays passed.
969
+ const workKind = (() => { const k = String(fm.kind || '').trim().replace(/^["']|["']$/g, ''); return k === 'sdlc' || k === 'project' ? k : 'product'; })();
970
+ const planPath = String(fm.plan_path || '').trim();
971
+ if (!doneTest && workKind === 'sdlc' && !prd) {
972
+ steps.push(step('spec', 'spec', 'blocked', 'Full SDLC needs a done test and a kill condition before the first pull request — never a PRD',
973
+ `write the done test (okf/core/templates/done-test-template.md), set done_test_path and kill: in ${recRel}`, { blocking: true, rule: 'R2' }));
974
+ } else if (!doneTest && workKind === 'project' && (planPath || !prd)) {
975
+ const planIdx = planPath ? firstAppearance(root, range, planPath) : null;
976
+ if (!planPath) {
977
+ 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' }));
979
+ } else if (planIdx === null) {
980
+ steps.push(step('spec', 'spec', 'blocked', `plan_path '${planPath}' does not exist in the repo`,
981
+ 'create the plan the record points at, or correct plan_path', { blocking: true, rule: 'R2' }));
982
+ } else {
983
+ steps.push(orderOf(`plan ${planPath}`, planIdx, 'O1'));
984
+ }
985
+ } else if (doneTest) {
967
986
  const dtIdx = firstAppearance(root, range, doneTest);
968
987
  if (dtIdx === null) {
969
988
  steps.push(step('spec', 'spec', 'blocked', `done_test_path '${doneTest}' does not exist in the repo`,
@@ -1580,7 +1599,21 @@ function pmLadder({ id, fm, lane, effLane, knownLane, legacy, steps, root, L, re
1580
1599
  : briefPath ? firstAppearance(root, range, briefPath) : null;
1581
1600
  const docIdx = docPath ? firstAppearance(root, range, docPath) : null;
1582
1601
 
1602
+ // W6 (launch simulation rerun, 2026-11-15): the kind of work sets this ladder too, as it sets the product-code gate (W5) and the kit gate.
1603
+ // Full SDLC: a done test and a kill condition, never a brief. Project: a dated plan (plan_path), never a brief. A brief already on the
1604
+ // record still passes (a gate passed stays passed). Their deliverable is not a document: the pull requests, or the plan's milestones.
1605
+ const workKind = (() => { const k = String(fm.kind || '').trim().replace(/^["']|["']$/g, ''); return k === 'sdlc' || k === 'project' ? k : 'product'; })();
1606
+ const planPath = String(fm.plan_path || '').trim();
1607
+ const kindSpec = !doneTest && !exists(briefPath) && !foundBrief && (workKind === 'sdlc' || (workKind === 'project'));
1583
1608
  if (doneTest && dtPresent && killCond) steps.push(step('brief', def.brief_label, 'done', `done test ${doneTest} + kill condition (D107)`));
1609
+ else if (kindSpec && workKind === 'sdlc') steps.push(step('brief', 'done test', legacy ? 'pending' : 'blocked',
1610
+ 'Full SDLC needs a done test and a kill condition before the first pull request — never a brief or a PRD',
1611
+ `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
+ else if (kindSpec && exists(planPath)) steps.push(step('brief', 'dated plan', 'done', `plan ${planPath} present`));
1613
+ else if (kindSpec) steps.push(step('brief', 'dated plan', legacy ? 'pending' : 'blocked',
1614
+ 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`,
1616
+ { blocking: !legacy, rule: 'R2' }));
1584
1617
  else if (doneTest && dtPresent) steps.push(step('brief', def.brief_label, 'blocked', 'no kill condition — an experiment states what would stop it (D107)',
1585
1618
  `write kill: "<the result that would make us stop>" in ${recRel}`, { blocking: !legacy, rule: 'R2' }));
1586
1619
  else if (doneTest) steps.push(step('brief', def.brief_label, 'blocked', `done_test_path '${doneTest}' does not exist in the repo`,
@@ -1594,6 +1627,8 @@ function pmLadder({ id, fm, lane, effLane, knownLane, legacy, steps, root, L, re
1594
1627
  { blocking: enforce, rule: 'P1' }));
1595
1628
 
1596
1629
  if (!flows('draft')) steps.push(skipped('draft', def.draft_label));
1630
+ else if (workKind !== 'product' && !exists(docPath) && !foundDraft) steps.push(step('draft', 'deliverable', 'na',
1631
+ workKind === 'sdlc' ? 'Full SDLC — the pull requests are the deliverable, not a document' : 'Project — the plan\'s milestones are the deliverable, not a document'));
1597
1632
  else if (foundDraft) steps.push(step('draft', def.draft_label, 'done', `${foundDraft} — found by the repository scan`));
1598
1633
  else if (exists(docPath)) {
1599
1634
  const inOrder = briefIdx == null || docIdx == null ? null : docIdx >= briefIdx;