create-pmos 0.544.0 → 0.546.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 +27 -57
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/scripts/workflow-state.js +33 -2
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/changelog.json +26 -0
- package/workspace/guide/cli.md +4 -0
- package/workspace/lib/artefacts-cli.js +105 -0
- package/workspace/lib/artefacts.js +369 -0
- package/workspace/lib/autonomy.js +1 -0
- package/workspace/lib/driver-cli.js +1 -1
- package/workspace/lib/driver-decide.js +15 -1
- package/workspace/lib/driver-facts.js +11 -2
- package/workspace/lib/driver.js +9 -1
- package/workspace/lib/engine/workflow-state.js +33 -2
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-artefacts.js +48 -0
- package/workspace/lib/routes-core-docs.js +4 -2
- package/workspace/lib/vendor/scripts/workflow-state.js +33 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/run-tests.js +22 -1
- package/workspace/skills/initiative-drive.skill +12 -11
- package/workspace/test-lists/seven-artefacts.json +9 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* artefacts.js — the seven artefacts of an agent-run workspace (requirement R18, decision D107).
|
|
3
|
+
* THE ONE WRITER and THE ONE FOLD of <state>/artefacts.jsonl.
|
|
4
|
+
*
|
|
5
|
+
* R18 (agreed by PM wawan 2026-11-09, "Yes to all"): exactly seven artefacts and no form. They replace the 36 core documents
|
|
6
|
+
* (lib/core-docs.js SETS and the workflow stage documents), the 9 driver proposal kinds (lib/driver.js WHATS.initiative), the 5 report
|
|
7
|
+
* cadences and the 6 lanes. Readings, sources, memory and agent ledgers are machinery, not artefacts, and stay as they are.
|
|
8
|
+
*
|
|
9
|
+
* ARTEFACTS · KEYS · EXECUTORS · FROM_DOCS · FROM_WHATS · FROM_CADENCES · FROM_LANES
|
|
10
|
+
* parseScope(scope) → { kind, id, scope } | null portfolio · board:<id> · goal:<id> · experiment:<id> (initiative:<id> is an alias)
|
|
11
|
+
* targetOfDoc(level, key) · targetOfWhat(what, data) → { artefact, field, note } | { artefact: null, note }
|
|
12
|
+
* file(dir) · readLines(file) · fold(lines) → Map scope → Map artefact → { fields: { name: value|[values] }, carried: [line] }
|
|
13
|
+
* set(file, { scope, artefact, field, text, sources }, actor, { now }) → { ok, line } | { ok: false, status, error }
|
|
14
|
+
* undo(file, { ref }, actor, { now }) → { ok, line } | refusal a set goes back; carry lines cannot be undone (they point at records)
|
|
15
|
+
* viewOf(state, scope) → { scope, artefacts: [{ key, title, owner, for, fields, carried, empty }] } always all seven that fit the scope
|
|
16
|
+
* migrate({ dir, coreDocs, driverLines, reports }, { now }) → { ok, carried, already, lines } idempotent; deletes nothing
|
|
17
|
+
*
|
|
18
|
+
* THE LINES. Every line is { v: 1, ev, id, scope, at, by }.
|
|
19
|
+
* set { artefact, field, text, sources: [{ label, ref }] } a value. A `one` field: the newest set wins. A `list` field: every set is a line.
|
|
20
|
+
* undo { ref } the set with id `ref` no longer counts
|
|
21
|
+
* carry { artefact, field, from: { kind, ref, path?, title?, state?, text? } } an older record (a core document, a kept driver proposal,
|
|
22
|
+
* a report draft) that now lives under this artefact. The old record stays where it is: a carry is a pointer, never a copy that
|
|
23
|
+
* could drift. Idempotent on from.kind + from.ref.
|
|
24
|
+
*
|
|
25
|
+
* WHO WRITES. `by` is the call path (lib/actor.js). Intent is the PM's: a set on it from anything but the PM is refused, so an agent's
|
|
26
|
+
* Intent change waits for the PM as a driver proposal. Goal is derived (from OKRs, health budgets and readings): it takes carry lines only.
|
|
27
|
+
* Every other artefact is agent-written (D98, D106): a set is reversible, and Undo is a correction.
|
|
28
|
+
*/
|
|
29
|
+
const fs = require('fs');
|
|
30
|
+
const path = require('path');
|
|
31
|
+
const crypto = require('crypto');
|
|
32
|
+
|
|
33
|
+
const LEDGER = 'artefacts.jsonl';
|
|
34
|
+
const EVENTS = Object.freeze(['set', 'undo', 'carry']);
|
|
35
|
+
const EXECUTORS = Object.freeze(['factory', 'team', 'team-agents']);
|
|
36
|
+
const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$/;
|
|
37
|
+
const REF_RE = /^a-[0-9a-f]{10}$/;
|
|
38
|
+
const MAX_TEXT = 4000;
|
|
39
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
40
|
+
|
|
41
|
+
const f = (name, mode, label) => Object.freeze({ name, mode, label });
|
|
42
|
+
/* The seven. `scopes` are where a set may land; `owner` is pm (the PM writes it), derived (no set) or agent. */
|
|
43
|
+
const ARTEFACTS = Object.freeze([
|
|
44
|
+
Object.freeze({ key: 'intent', title: 'Intent', owner: 'pm', scopes: ['portfolio', 'board'],
|
|
45
|
+
for: 'What we want, the limits agents work inside, and what we will not do. The PM owns it; agents propose changes to it.',
|
|
46
|
+
fields: Object.freeze([f('want', 'one', 'What we want'), f('limits', 'one', 'Limits and budgets'), f('not', 'one', 'What we will not do')]) }),
|
|
47
|
+
Object.freeze({ key: 'goal', title: 'Goal', owner: 'derived', scopes: ['portfolio', 'goal'],
|
|
48
|
+
for: 'An outcome with a live reading and the experiments on it. Read from the OKRs, health budgets and readings; never typed.',
|
|
49
|
+
fields: Object.freeze([f('reading', 'one', 'Reading'), f('experiments', 'list', 'Experiments')]) }),
|
|
50
|
+
Object.freeze({ key: 'narrative', title: 'Narrative', owner: 'agent', scopes: ['portfolio', 'board', 'goal'],
|
|
51
|
+
for: 'The standing, as-of story of a goal: where it stands, what changed this week, what is next. The only report.',
|
|
52
|
+
fields: Object.freeze([f('now', 'one', 'Where it stands'), f('week', 'list', 'This week'), f('asks', 'list', 'Stakeholder asks')]) }),
|
|
53
|
+
Object.freeze({ key: 'experiment', title: 'Experiment', owner: 'agent', scopes: ['experiment'],
|
|
54
|
+
for: 'The unit of work: a hypothesis, the kill condition, the budget and who builds it. "Initiative" is the stakeholder word for it.',
|
|
55
|
+
fields: Object.freeze([f('hypothesis', 'one', 'Hypothesis'), f('why', 'one', 'Problem'), f('evidence', 'list', 'Evidence'), f('kill', 'one', 'Kill condition'),
|
|
56
|
+
f('budget', 'one', 'Budget'), f('executor', 'one', 'Built by'), f('risks', 'list', 'Risks'), f('people', 'list', 'People'), f('related', 'list', 'Related experiments')]) }),
|
|
57
|
+
Object.freeze({ key: 'specimens', title: 'Specimens', owner: 'agent', scopes: ['experiment'],
|
|
58
|
+
for: 'Working attempts made against one done test, before any spec. The PM sees the winner.',
|
|
59
|
+
fields: Object.freeze([f('specimen', 'list', 'Attempts'), f('kept', 'one', 'Kept specimen')]) }),
|
|
60
|
+
Object.freeze({ key: 'done-test', title: 'Done test', owner: 'agent', scopes: ['experiment'],
|
|
61
|
+
for: 'The checks that say the experiment is done. A team that builds it gets the kept specimen and this test, not a PRD.',
|
|
62
|
+
fields: Object.freeze([f('check', 'list', 'Checks'), f('result', 'one', 'Result')]) }),
|
|
63
|
+
Object.freeze({ key: 'lessons', title: 'Lessons', owner: 'agent', scopes: ['portfolio', 'board', 'goal', 'experiment'],
|
|
64
|
+
for: 'One line per thing learned, kept or killed, with its pointer. The OS evolves its own process from these.',
|
|
65
|
+
fields: Object.freeze([f('line', 'list', 'Lessons')]) }),
|
|
66
|
+
]);
|
|
67
|
+
const KEYS = Object.freeze(ARTEFACTS.map((a) => a.key));
|
|
68
|
+
const BY_KEY = new Map(ARTEFACTS.map((a) => [a.key, a]));
|
|
69
|
+
const fieldOf = (artefact, field) => { const a = BY_KEY.get(artefact); return a ? a.fields.find((x) => x.name === field) || null : null; };
|
|
70
|
+
|
|
71
|
+
/* ── what the old shapes become ─────────────────────────────────────────────────────────────────────────────────────────────────
|
|
72
|
+
* Every one of the 36 core documents, keyed level:key (lib/core-docs.js SETS, plus initiative:wf-* for a workflow stage's document). */
|
|
73
|
+
const t = (artefact, field, note) => Object.freeze({ artefact, field, note });
|
|
74
|
+
const FROM_DOCS = Object.freeze({
|
|
75
|
+
'portfolio:strategy': t('intent', 'want', 'Vision and where we play is the PM\'s intent; what we will not do is its `not` line.'),
|
|
76
|
+
'portfolio:okrs': t('goal', 'reading', 'Goals are read from the OKRs and health budgets.'),
|
|
77
|
+
'portfolio:roadmap': t('goal', 'experiments', 'The goal portfolio replaces the roadmap: each goal lists its experiments and budgets.'),
|
|
78
|
+
'portfolio:invest': t('goal', 'experiments', 'The investment mix is the sum of the experiment budgets per goal.'),
|
|
79
|
+
'portfolio:scan': t('lessons', 'line', 'Horizon scans are sources (machinery); what they teach lands as lessons.'),
|
|
80
|
+
'portfolio:status': t('narrative', 'now', 'The status report is the standing narrative, as of today.'),
|
|
81
|
+
'portfolio:decisions': t('lessons', 'line', 'A decision and its reason is a lesson line.'),
|
|
82
|
+
'portfolio:kill': t('experiment', 'kill', 'Every experiment carries its own kill condition.'),
|
|
83
|
+
'portfolio:prisks': t('experiment', 'risks', 'Risks live on the experiment; the narrative names the ones that matter.'),
|
|
84
|
+
'portfolio:quarter': t('lessons', 'line', 'The quarterly review is the lessons of the quarter and the narrative as of its end.'),
|
|
85
|
+
'portfolio:context': t('lessons', 'line', 'Market and user research are sources; what they teach is a lesson.'),
|
|
86
|
+
'board:charter': t('intent', 'want', 'A board\'s purpose and scope is the intent of that area.'),
|
|
87
|
+
'board:backlog': t('goal', 'experiments', 'The ranked list is the experiments on each goal.'),
|
|
88
|
+
'board:intake': t('lessons', 'line', 'An ask declined, and why, is a lesson; an ask accepted becomes an experiment.'),
|
|
89
|
+
'board:bstatus': t('narrative', 'now', 'The board status report is the narrative of its goals.'),
|
|
90
|
+
'board:capacity': t('experiment', 'budget', 'Capacity is the experiment budgets and who builds each one.'),
|
|
91
|
+
'board:metrics': t('goal', 'reading', 'The numbers a board moves are its goals\' readings.'),
|
|
92
|
+
'board:brisks': t('experiment', 'risks', 'Risks live on the experiment.'),
|
|
93
|
+
'board:sprint': t('narrative', 'week', 'What a sprint finished is a weekly narrative line.'),
|
|
94
|
+
'board:release': t('narrative', 'week', 'A release is a weekly narrative line, every line cited.'),
|
|
95
|
+
'board:retro': t('lessons', 'line', 'A retro is the lessons across a board\'s experiments.'),
|
|
96
|
+
'initiative:record': t('experiment', 'hypothesis', 'The initiative record is the experiment.'),
|
|
97
|
+
'initiative:problem': t('experiment', 'why', 'The problem statement is the experiment\'s problem.'),
|
|
98
|
+
'initiative:research': t('experiment', 'evidence', 'Research notes are the experiment\'s evidence.'),
|
|
99
|
+
'initiative:rice': t('experiment', 'budget', 'Priority is the budget and the expected effect, compared across the goal.'),
|
|
100
|
+
'initiative:prd': t('done-test', 'check', 'Specimens before specs: the PRD\'s done criteria become the done test; the rest is the kept specimen.'),
|
|
101
|
+
'initiative:rubric': t('done-test', 'check', 'The rubric is the done test.'),
|
|
102
|
+
'initiative:design': t('specimens', 'specimen', 'A design or mockup is a specimen.'),
|
|
103
|
+
'initiative:stories': t('done-test', 'check', 'Stories become checks of the done test; a technical decision is a lesson.'),
|
|
104
|
+
'initiative:risks': t('experiment', 'risks', 'Risks live on the experiment.'),
|
|
105
|
+
'initiative:launch': t('done-test', 'check', 'What must be true to ship is part of the done test. Messages out still wait for the PM.'),
|
|
106
|
+
'initiative:review': t('done-test', 'result', 'The review verdict is the done test\'s result.'),
|
|
107
|
+
'initiative:update': t('narrative', 'week', 'A status update is a narrative line.'),
|
|
108
|
+
'initiative:explainer': t('narrative', 'now', 'An explainer is the narrative in plain words.'),
|
|
109
|
+
'initiative:outcome': t('lessons', 'line', 'An outcome review is a lesson, and the reading on the goal.'),
|
|
110
|
+
'initiative:wf-*': t('specimens', 'specimen', 'What a workflow stage produces is a specimen of the experiment.'),
|
|
111
|
+
});
|
|
112
|
+
/* The 9 driver proposal kinds of an initiative (lib/driver.js WHATS.initiative). `move` is not an artefact: R11, a stage is derived. */
|
|
113
|
+
const FROM_WHATS = Object.freeze({
|
|
114
|
+
problem: t('experiment', 'why', 'The problem.'),
|
|
115
|
+
evidence: t('experiment', 'evidence', 'One evidence line per item, each with its pointer.'),
|
|
116
|
+
sizing: t('experiment', 'budget', 'Reach and impact are the budget\'s expected effect.'),
|
|
117
|
+
assumption: t('experiment', 'hypothesis', 'The riskiest assumption is the hypothesis; its test is the kill condition.'),
|
|
118
|
+
stakeholders: t('experiment', 'people', 'Who to ask.'),
|
|
119
|
+
move: t(null, null, 'A stage is derived from the work, never declared (R11): a move is not an artefact.'),
|
|
120
|
+
note: t('lessons', 'line', 'A note is a lesson line.'),
|
|
121
|
+
doc: t(null, null, 'A document proposal goes where its document goes (FROM_DOCS).'),
|
|
122
|
+
overlap: t('experiment', 'related', 'An overlap is a related experiment.'),
|
|
123
|
+
});
|
|
124
|
+
/* The 5 report cadences (lib/report-setups.js CADENCES plus quarterly). R9: the narrative is the only report. */
|
|
125
|
+
const FROM_CADENCES = Object.freeze({
|
|
126
|
+
daily: t('narrative', 'week', 'No daily report: a change shows where the work is (R7).'),
|
|
127
|
+
weekly: t('narrative', 'week', 'One weekly line on the standing narrative.'),
|
|
128
|
+
'bi-weekly': t('narrative', 'week', 'The narrative is standing: read it as of any date.'),
|
|
129
|
+
monthly: t('narrative', 'now', 'The narrative is standing: read it as of any date.'),
|
|
130
|
+
quarterly: t('lessons', 'line', 'A quarter is its lessons and the narrative as of its end.'),
|
|
131
|
+
});
|
|
132
|
+
/* The 6 lanes (D56, D58, D60). R12: everything is an experiment; the lane's one difference becomes a field or another artefact. */
|
|
133
|
+
const FROM_LANES = Object.freeze({
|
|
134
|
+
feature: t('experiment', 'hypothesis', 'A feature is an experiment with a hypothesis, a kill condition and a done test.'),
|
|
135
|
+
discovery: t('experiment', 'hypothesis', 'A spike is an experiment whose done test is the question answered.'),
|
|
136
|
+
chore: t('experiment', 'budget', 'A chore is an experiment anchored to a health budget, with a done test and no hypothesis to argue.'),
|
|
137
|
+
incident: t('lessons', 'line', 'An incident is a lesson written after the fact, and an experiment only when there is work to do.'),
|
|
138
|
+
content: t('specimens', 'specimen', 'Content is an experiment whose specimens are the drafts.'),
|
|
139
|
+
prototype: t('specimens', 'specimen', 'A prototype is the specimens of an experiment (R13: specimens before specs, always).'),
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
function targetOfDoc(level, key) {
|
|
143
|
+
const k = String(key || '');
|
|
144
|
+
return FROM_DOCS[`${level}:${k}`] || (level === 'initiative' && /^wf-/.test(k) ? FROM_DOCS['initiative:wf-*'] : null);
|
|
145
|
+
}
|
|
146
|
+
function targetOfWhat(what, data) {
|
|
147
|
+
if (what === 'doc' && isObj(data) && data.key) return targetOfDoc('initiative', data.key) || FROM_WHATS.doc;
|
|
148
|
+
return FROM_WHATS[what] || null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// ── scopes ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
152
|
+
function parseScope(scope) {
|
|
153
|
+
const s = String(scope || '');
|
|
154
|
+
if (s === 'portfolio') return { kind: 'portfolio', id: null, scope: 'portfolio' };
|
|
155
|
+
const m = /^(board|goal|experiment|initiative):(.+)$/.exec(s);
|
|
156
|
+
if (!m || !ID_RE.test(m[2])) return null;
|
|
157
|
+
const kind = m[1] === 'initiative' ? 'experiment' : m[1];
|
|
158
|
+
return { kind, id: m[2], scope: `${kind}:${m[2]}` };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// ── the ledger ───────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
162
|
+
const file = (dir) => (dir ? path.join(dir, LEDGER) : null);
|
|
163
|
+
function readLines(f) {
|
|
164
|
+
let text = '';
|
|
165
|
+
try { text = fs.readFileSync(f, 'utf8'); } catch { return []; }
|
|
166
|
+
const out = [];
|
|
167
|
+
for (const raw of text.split('\n')) {
|
|
168
|
+
if (!raw.trim()) continue;
|
|
169
|
+
try { const l = JSON.parse(raw); if (isObj(l) && EVENTS.includes(l.ev)) out.push(l); } catch { /* a torn line is skipped */ }
|
|
170
|
+
}
|
|
171
|
+
return out;
|
|
172
|
+
}
|
|
173
|
+
const newId = () => `a-${crypto.randomBytes(5).toString('hex')}`;
|
|
174
|
+
/** THE SINGLE WRITER of artefacts.jsonl. `v`, `id` (when absent) and `at` are set here. */
|
|
175
|
+
function append(f, line, { now } = {}) {
|
|
176
|
+
if (!isObj(line) || !EVENTS.includes(line.ev)) throw new Error(`artefacts: unknown event ${JSON.stringify(line && line.ev)}`);
|
|
177
|
+
const out = { v: 1, ev: line.ev, id: line.id || newId(), ...line, at: new Date(now == null ? Date.now() : now).toISOString() };
|
|
178
|
+
out.v = 1;
|
|
179
|
+
fs.mkdirSync(path.dirname(f), { recursive: true });
|
|
180
|
+
fs.appendFileSync(f, JSON.stringify(out) + '\n');
|
|
181
|
+
return out;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** Map scope → Map artefact → { sets: [line], carried: [line] }, with undone sets removed. Pure. */
|
|
185
|
+
function fold(lines) {
|
|
186
|
+
const undone = new Set();
|
|
187
|
+
for (const l of lines || []) if (l && l.ev === 'undo' && typeof l.ref === 'string') undone.add(l.ref);
|
|
188
|
+
const m = new Map();
|
|
189
|
+
const seen = new Set();
|
|
190
|
+
const slot = (scope, artefact) => {
|
|
191
|
+
if (!m.has(scope)) m.set(scope, new Map());
|
|
192
|
+
const s = m.get(scope);
|
|
193
|
+
if (!s.has(artefact)) s.set(artefact, { sets: [], carried: [] });
|
|
194
|
+
return s.get(artefact);
|
|
195
|
+
};
|
|
196
|
+
for (const l of lines || []) {
|
|
197
|
+
if (!isObj(l) || typeof l.scope !== 'string' || !BY_KEY.has(l.artefact)) continue;
|
|
198
|
+
if (l.ev === 'set' && !undone.has(l.id) && fieldOf(l.artefact, l.field)) slot(l.scope, l.artefact).sets.push(l);
|
|
199
|
+
else if (l.ev === 'carry' && isObj(l.from)) {
|
|
200
|
+
const k = `${l.from.kind}|${l.from.ref}`;
|
|
201
|
+
if (seen.has(k)) continue;
|
|
202
|
+
seen.add(k);
|
|
203
|
+
slot(l.scope, l.artefact).carried.push(l);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return m;
|
|
207
|
+
}
|
|
208
|
+
const carriedKeys = (lines) => new Set((lines || []).filter((l) => l && l.ev === 'carry' && isObj(l.from)).map((l) => `${l.from.kind}|${l.from.ref}`));
|
|
209
|
+
|
|
210
|
+
/** The seven artefacts of one scope, the ones that fit it, each with its current fields and what was carried into it. Pure. */
|
|
211
|
+
function viewOf(state, scope) {
|
|
212
|
+
const p = parseScope(scope);
|
|
213
|
+
if (!p) return null;
|
|
214
|
+
const here = (state && state.get(p.scope)) || new Map();
|
|
215
|
+
const artefacts = ARTEFACTS.filter((a) => a.scopes.includes(p.kind) || here.has(a.key)).map((a) => {
|
|
216
|
+
const x = here.get(a.key) || { sets: [], carried: [] };
|
|
217
|
+
const fields = {};
|
|
218
|
+
for (const fd of a.fields) {
|
|
219
|
+
const sets = x.sets.filter((l) => l.field === fd.name).map((l) => ({ id: l.id, text: l.text, sources: l.sources || [], by: l.by || null, at: l.at || null }));
|
|
220
|
+
fields[fd.name] = fd.mode === 'one' ? (sets.length ? sets[sets.length - 1] : null) : sets;
|
|
221
|
+
}
|
|
222
|
+
const carried = x.carried.map((l) => ({ field: l.field || null, ...l.from, at: l.at || null }));
|
|
223
|
+
const empty = !carried.length && Object.values(fields).every((v) => (Array.isArray(v) ? !v.length : !v));
|
|
224
|
+
return { key: a.key, title: a.title, owner: a.owner, for: a.for, labels: Object.fromEntries(a.fields.map((fd) => [fd.name, fd.label])), fields, carried, empty };
|
|
225
|
+
});
|
|
226
|
+
return { scope: p.scope, kind: p.kind, artefacts };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// ── writes ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
230
|
+
const refuse = (status, error) => ({ ok: false, status, error });
|
|
231
|
+
const oneLine = (v, max) => typeof v === 'string' && v.trim().length >= 1 && v.trim().length <= max && !/[\r\n\x00-\x08\x0b-\x1f]/.test(v);
|
|
232
|
+
const validBy = (actor) => isObj(actor) && typeof actor.by === 'string' && /^(pm|agent):/.test(actor.by);
|
|
233
|
+
const isPmActor = (actor) => validBy(actor) && actor.by.startsWith('pm:');
|
|
234
|
+
|
|
235
|
+
/** Check a set without writing it. → { ok, line } | refusal. */
|
|
236
|
+
function checkSet({ scope, artefact, field, text, sources } = {}, actor) {
|
|
237
|
+
if (!validBy(actor)) return refuse(403, 'only the PM or an agent session writes an artefact');
|
|
238
|
+
const p = parseScope(scope);
|
|
239
|
+
if (!p) return refuse(400, 'scope must be portfolio, board:<id>, goal:<id> or experiment:<id>');
|
|
240
|
+
const a = BY_KEY.get(artefact);
|
|
241
|
+
if (!a) return refuse(400, `artefact must be one of ${KEYS.join(', ')}`);
|
|
242
|
+
if (a.owner === 'derived') return refuse(409, `${a.title} is read from the OKRs, health budgets and readings; it is never typed`);
|
|
243
|
+
if (a.owner === 'pm' && !isPmActor(actor)) return refuse(403, `${a.title} is the PM's: propose the change and the PM keeps it`);
|
|
244
|
+
if (!a.scopes.includes(p.kind)) return refuse(400, `${a.title} lives on ${a.scopes.join(' or ')}, not on ${p.kind}`);
|
|
245
|
+
const fd = field ? fieldOf(a.key, field) : a.fields[0];
|
|
246
|
+
if (!fd) return refuse(400, `field must be one of ${a.fields.map((x) => x.name).join(', ')}`);
|
|
247
|
+
if (typeof text !== 'string' || !text.trim() || text.length > MAX_TEXT) return refuse(400, `text is 1 to ${MAX_TEXT} characters`);
|
|
248
|
+
if (a.key === 'experiment' && fd.name === 'executor' && !EXECUTORS.includes(text.trim())) return refuse(400, `executor is one of ${EXECUTORS.join(', ')}`);
|
|
249
|
+
const src = [];
|
|
250
|
+
for (const s of Array.isArray(sources) ? sources : []) {
|
|
251
|
+
if (!isObj(s) || !oneLine(s.label, 80) || !oneLine(s.ref, 500)) return refuse(400, 'each source needs a label (up to 80 characters) and a ref (up to 500)');
|
|
252
|
+
src.push({ label: s.label.trim(), ref: s.ref.trim() });
|
|
253
|
+
}
|
|
254
|
+
return { ok: true, line: { ev: 'set', scope: p.scope, artefact: a.key, field: fd.name, text: text.trim(), sources: src, by: actor.by } };
|
|
255
|
+
}
|
|
256
|
+
function set(f, input, actor, { now } = {}) {
|
|
257
|
+
if (!f) return refuse(409, 'this repository has no state folder for the artefacts');
|
|
258
|
+
const c = checkSet(input, actor);
|
|
259
|
+
if (!c.ok) return c;
|
|
260
|
+
return { ok: true, line: append(f, c.line, { now }) };
|
|
261
|
+
}
|
|
262
|
+
function undo(f, { ref } = {}, actor, { now } = {}) {
|
|
263
|
+
if (!f) return refuse(409, 'this repository has no state folder for the artefacts');
|
|
264
|
+
if (!validBy(actor)) return refuse(403, 'only the PM or an agent session undoes an artefact line');
|
|
265
|
+
if (!REF_RE.test(String(ref || ''))) return refuse(400, 'ref is the id of a set line (a-<10 hex>)');
|
|
266
|
+
const lines = readLines(f);
|
|
267
|
+
const hit = lines.find((l) => l.ev === 'set' && l.id === ref);
|
|
268
|
+
if (!hit) return refuse(404, `no artefact line ${ref}`);
|
|
269
|
+
if (lines.some((l) => l.ev === 'undo' && l.ref === ref)) return refuse(409, 'that line is undone already');
|
|
270
|
+
if (BY_KEY.get(hit.artefact).owner === 'pm' && !isPmActor(actor)) return refuse(403, 'Intent is the PM\'s: only the PM undoes it');
|
|
271
|
+
return { ok: true, line: append(f, { ev: 'undo', scope: hit.scope, artefact: hit.artefact, ref, by: actor.by }, { now }) };
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// ── migration: the old records, carried into the seven ───────────────────────────────────────────────────────────────────────
|
|
275
|
+
const short = (v, n = 500) => { const s = String(v == null ? '' : v).replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1) + '…' : s; };
|
|
276
|
+
function proposalText(p) {
|
|
277
|
+
const d = p.data;
|
|
278
|
+
if (!isObj(d)) return short(d);
|
|
279
|
+
if (typeof d.text === 'string') return short(d.text);
|
|
280
|
+
if (p.what === 'assumption') return short([d.assumption, d.test && `Test: ${d.test}`].filter(Boolean).join(' · '));
|
|
281
|
+
if (p.what === 'sizing') return short([d.reach && `Reach: ${d.reach}`, d.impact && `Impact: ${d.impact}`].filter(Boolean).join(' · '));
|
|
282
|
+
if (p.what === 'evidence' && Array.isArray(d.items)) return short(d.items.map((x) => isObj(x) ? `${x.text} (${x.ref})` : String(x)).join(' · '));
|
|
283
|
+
if (p.what === 'overlap') return short(`With ${d.with}${d.text ? `: ${d.text}` : ''}`);
|
|
284
|
+
return short(JSON.stringify(d));
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* The carry lines that put every older record under its artefact. Pure: the caller reads and writes.
|
|
288
|
+
* coreDocs: core-docs.js fold() (Map 'scope|key' → { scope, key, issued, draft, issues, drafts })
|
|
289
|
+
* driverLines: driver.js readLines() of driver.jsonl; a kept proposal is carried (open, returned, dropped and undone ones are not the record)
|
|
290
|
+
* reports: [{ cadence, slot, path }] the report drafts on disk
|
|
291
|
+
* have: the from-keys already carried
|
|
292
|
+
* → [carry line without v/at]
|
|
293
|
+
*/
|
|
294
|
+
function planMigration({ coreDocs = new Map(), driverLines = [], reports = [], have = new Set() } = {}) {
|
|
295
|
+
const out = [];
|
|
296
|
+
const push = (scope, tg, from) => {
|
|
297
|
+
if (!tg || !tg.artefact) return;
|
|
298
|
+
const k = `${from.kind}|${from.ref}`;
|
|
299
|
+
if (have.has(k)) return;
|
|
300
|
+
have.add(k);
|
|
301
|
+
out.push({ ev: 'carry', scope, artefact: tg.artefact, field: tg.field, from, by: 'migrate' });
|
|
302
|
+
};
|
|
303
|
+
for (const x of coreDocs.values()) {
|
|
304
|
+
const p = /^(portfolio)$|^(board|initiative):(.+)$/.exec(String(x.scope || ''));
|
|
305
|
+
if (!p) continue;
|
|
306
|
+
const level = p[1] || p[2];
|
|
307
|
+
const scope = level === 'initiative' ? `experiment:${p[3]}` : x.scope;
|
|
308
|
+
const tg = targetOfDoc(level, x.key);
|
|
309
|
+
const docs = [...(x.issues || []), ...(x.draft ? [x.draft] : [])];
|
|
310
|
+
for (const d of docs) push(scope, tg, { kind: 'core-doc', ref: `${x.scope}|${x.key}|${d.slot}`, path: d.path || null, title: x.key, state: d.ev === 'issue' ? 'issued' : 'draft' });
|
|
311
|
+
}
|
|
312
|
+
const D = require('./driver.js');
|
|
313
|
+
const st = D.fold(driverLines);
|
|
314
|
+
for (const id of st.order) {
|
|
315
|
+
const pr = st.proposals.get(id);
|
|
316
|
+
if (!pr || pr.state !== 'kept' || pr.target.kind !== 'initiative') continue;
|
|
317
|
+
if (pr.what === 'artefact') continue; // written to this ledger already when it was kept
|
|
318
|
+
push(`experiment:${pr.target.id}`, targetOfWhat(pr.what, pr.data), { kind: 'proposal', ref: pr.id, title: pr.what, text: proposalText(pr), state: 'kept' });
|
|
319
|
+
}
|
|
320
|
+
for (const r of reports) {
|
|
321
|
+
const tg = FROM_CADENCES[r.cadence] || FROM_CADENCES.weekly;
|
|
322
|
+
push('portfolio', tg, { kind: 'report', ref: `${r.cadence}/${r.slot}`, path: r.path || null, title: `${r.cadence} report`, state: 'draft' });
|
|
323
|
+
}
|
|
324
|
+
return out;
|
|
325
|
+
}
|
|
326
|
+
/** Write the carry lines that are not written yet. Idempotent: a second run carries nothing. Nothing is deleted or moved. */
|
|
327
|
+
function migrate({ dir, coreDocs, driverLines, reports } = {}, { now } = {}) {
|
|
328
|
+
const f = file(dir);
|
|
329
|
+
if (!f) return refuse(409, 'this repository has no state folder for the artefacts');
|
|
330
|
+
const before = readLines(f);
|
|
331
|
+
const have = carriedKeys(before);
|
|
332
|
+
const already = have.size;
|
|
333
|
+
const plan = planMigration({ coreDocs, driverLines, reports, have });
|
|
334
|
+
const lines = plan.map((l) => append(f, l, { now }));
|
|
335
|
+
return { ok: true, carried: lines.length, already, lines };
|
|
336
|
+
}
|
|
337
|
+
/** The report drafts on disk under <state>/reports/<cadence>/<slot>.md (definitions excluded). */
|
|
338
|
+
function reportDrafts(stateAbs, rel) {
|
|
339
|
+
const base = path.join(stateAbs, 'reports');
|
|
340
|
+
const out = [];
|
|
341
|
+
let cads = [];
|
|
342
|
+
try { cads = fs.readdirSync(base, { withFileTypes: true }).filter((d) => d.isDirectory() && d.name !== 'definitions').map((d) => d.name); } catch { return out; }
|
|
343
|
+
for (const c of cads.sort()) {
|
|
344
|
+
let files = [];
|
|
345
|
+
try { files = fs.readdirSync(path.join(base, c)).filter((n) => /\.md$/.test(n)).sort(); } catch { continue; }
|
|
346
|
+
for (const n of files) out.push({ cadence: c, slot: n.replace(/\.md$/, ''), path: `${rel}/reports/${c}/${n}` });
|
|
347
|
+
}
|
|
348
|
+
return out;
|
|
349
|
+
}
|
|
350
|
+
/** Where a repository keeps this ledger: the core documents' state folder (pmos/state in a kit repository, planning in PMOS-self). */
|
|
351
|
+
function dirOf(root) {
|
|
352
|
+
const CD = require('./core-docs.js');
|
|
353
|
+
return path.dirname(CD.ledgerFile(root));
|
|
354
|
+
}
|
|
355
|
+
/** Read every older record of a repository and carry it. */
|
|
356
|
+
function migrateRepo(root, { now } = {}) {
|
|
357
|
+
const CD = require('./core-docs.js');
|
|
358
|
+
const D = require('./driver.js');
|
|
359
|
+
const dir = dirOf(root);
|
|
360
|
+
const rel = path.relative(path.resolve(String(root)), dir).split(path.sep).join('/');
|
|
361
|
+
const sd = D.stateDirOf(root);
|
|
362
|
+
return migrate({ dir, coreDocs: CD.fold(CD.readLines(CD.ledgerFile(root))), driverLines: sd ? D.readLines(D.ledgerFile(sd)) : [], reports: reportDrafts(dir, rel) }, { now });
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
module.exports = {
|
|
366
|
+
LEDGER, EVENTS, ARTEFACTS, KEYS, EXECUTORS, FROM_DOCS, FROM_WHATS, FROM_CADENCES, FROM_LANES,
|
|
367
|
+
parseScope, targetOfDoc, targetOfWhat, fieldOf, file, readLines, append, fold, viewOf, checkSet, set, undo,
|
|
368
|
+
planMigration, migrate, migrateRepo, reportDrafts, dirOf, proposalText,
|
|
369
|
+
};
|
|
@@ -57,6 +57,7 @@ const one = (s, n) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().sli
|
|
|
57
57
|
const DRIVER_CLASS = Object.freeze({
|
|
58
58
|
note: 'A',
|
|
59
59
|
problem: 'B', evidence: 'B', sizing: 'B', assumption: 'B', stakeholders: 'B', overlap: 'B', doc: 'B', 'next-step': 'B',
|
|
60
|
+
artefact: 'B', // R18: a field of one of the seven artefacts; Intent is the PM's and its Keep refuses an agent (lib/artefacts.js)
|
|
60
61
|
move: 'C', // a stage move shows on boards others read (D103) and can move a Jira ticket (D100)
|
|
61
62
|
'follow-up': 'C', // a message to a person
|
|
62
63
|
});
|
|
@@ -32,7 +32,7 @@ const COMMANDS = { driver: ['propose', 'status', 'keep', 'return', 'drop', 'undo
|
|
|
32
32
|
const USAGE = [
|
|
33
33
|
'usage: pmos driver propose|status|keep|return|drop|undo|pause|resume|mode — the Initiative Driver',
|
|
34
34
|
' pmos driver propose <initiative|work> <id> --what <what> (--file <json|md> | --data "<text>") --why "<one line>" [--source label=ref …] [--confidence 0..1] [--recommended "<what you suggest>"] [--reversible true|false] [--effort S|M|L]',
|
|
35
|
-
' what: problem, evidence, sizing, assumption, stakeholders, move, note, doc, overlap (initiative) · next-step, follow-up, note (Work task)',
|
|
35
|
+
' what: problem, evidence, sizing, assumption, stakeholders, move, note, doc, overlap, artefact (initiative) · next-step, follow-up, note (Work task)',
|
|
36
36
|
' pmos driver status <initiative|work> <id>',
|
|
37
37
|
' pmos driver keep <proposal> PM only',
|
|
38
38
|
' pmos driver return <proposal> --note "<what to change>" PM only',
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* move → the board move route's own function (lib/routes-boards.js move): its validation and warnings apply
|
|
22
22
|
* next-step → lib/pm-items.js appendEvent: a step (lib/item-steps.js) and, when the proposal names a date, an `edited` due
|
|
23
23
|
* doc → lib/core-docs.js issue: the draft the run wrote is issued (one `issue` line, `state: issued` in its file), as the PM
|
|
24
|
+
* artefact → lib/artefacts.js set: one field of one of the seven artefacts (R18), with Undo. Intent refuses an agent's Keep
|
|
24
25
|
* Every other kind (evidence, sizing, assumption, stakeholders, follow-up, note) is kept as a decision only: the PM's choice to
|
|
25
26
|
* rely on it. A follow-up is never sent: the PM sends it from their own session. The driver never moves a stage by itself (D3).
|
|
26
27
|
* RETURN needs a note and DROP may carry one; each logs one correction (the north star counts it) and a return wakes a run.
|
|
@@ -60,6 +61,15 @@ async function writeRecord(p, actor, ctx, now) {
|
|
|
60
61
|
if (!r.ok) return refuse(r.status || 409, r.error);
|
|
61
62
|
return { ok: true, wrote: 'doc' };
|
|
62
63
|
}
|
|
64
|
+
if (p.what === 'artefact') {
|
|
65
|
+
// R18 (D107): one field of one of the seven artefacts. Intent is the PM's: an agent's Keep of it is refused and it waits.
|
|
66
|
+
if (!ctx.root) return refuse(409, 'this repository has no folder for the artefacts');
|
|
67
|
+
const A = require('./artefacts.js');
|
|
68
|
+
const d = p.data || {};
|
|
69
|
+
const r = A.set(A.file(A.dirOf(ctx.root)), { scope: d.scope, artefact: d.artefact, field: d.field, text: d.text, sources: p.sources }, actor, { now });
|
|
70
|
+
if (!r.ok) return refuse(r.status || 409, r.error);
|
|
71
|
+
return { ok: true, wrote: 'artefact', undo: { op: 'artefact', ref: r.line.id } };
|
|
72
|
+
}
|
|
63
73
|
if (p.what === 'next-step') {
|
|
64
74
|
if (!ctx.itemsDir) return refuse(409, 'no folder for the Work items');
|
|
65
75
|
const paths = itemsPaths(ctx.itemsDir);
|
|
@@ -79,7 +89,7 @@ async function writeRecord(p, actor, ctx, now) {
|
|
|
79
89
|
|
|
80
90
|
/* D106 "no Undo, no auto": the kinds whose Keep has an Undo. A decision-only kind (evidence, sizing, …) is undone in the ledger alone.
|
|
81
91
|
* `doc` issues a document and `move` moves a stage: neither has an Undo writer, so neither is applied by itself. */
|
|
82
|
-
const UNDOABLE = new Set(['problem', 'next-step', 'evidence', 'sizing', 'assumption', 'stakeholders', 'note', 'overlap']);
|
|
92
|
+
const UNDOABLE = new Set(['problem', 'next-step', 'evidence', 'sizing', 'assumption', 'stakeholders', 'note', 'overlap', 'artefact']);
|
|
83
93
|
|
|
84
94
|
async function decide(verb, { file, proposal, note, actor, ctx = {}, now, auto = false } = {}) {
|
|
85
95
|
if (!['keep', 'return', 'drop'].includes(verb)) return refuse(500, `driver: ${JSON.stringify(verb)} is not a decision`);
|
|
@@ -151,6 +161,10 @@ async function undo({ file, proposal, actor, ctx = {}, now, stateDir, product =
|
|
|
151
161
|
if (!now2 || JSON.stringify(now2.data) !== JSON.stringify(u.to)) back = false; // edited since: it keeps its edit
|
|
152
162
|
else if (u.from) stageTools.appendTool(ctx.stageFile, { initiative: p.target.id, tool: 'problem', data: u.from }, actor, { now: t });
|
|
153
163
|
else stageTools.clearTool(ctx.stageFile, { initiative: p.target.id, tool: 'problem' }, actor, { now: t });
|
|
164
|
+
} else if (p.what === 'artefact' && u.op === 'artefact' && ctx.root) {
|
|
165
|
+
const A = require('./artefacts.js');
|
|
166
|
+
const r = A.undo(A.file(A.dirOf(ctx.root)), { ref: u.ref }, actor, { now: t });
|
|
167
|
+
if (!r.ok) back = false;
|
|
154
168
|
} else if (p.what === 'next-step' && u.op === 'next-step' && ctx.itemsDir) {
|
|
155
169
|
const paths = itemsPaths(ctx.itemsDir);
|
|
156
170
|
pmItems.appendEvent(paths.steps, { event: 'step_removed', id: u.step }, new Date(t));
|
|
@@ -57,6 +57,14 @@ function initiativeFacts(w, ctx, { driverState, stateDir, now = Date.now() }) {
|
|
|
57
57
|
try { jiraStatus = require('./jira-status.js'); } catch { jiraStatus = null; }
|
|
58
58
|
const keptEvidence = new Set();
|
|
59
59
|
for (const p of driverState.proposals.values()) if (p.state === 'kept' && p.what === 'evidence' && p.target.kind === 'initiative') keptEvidence.add(p.target.id);
|
|
60
|
+
// D107: the experiment's artefacts count as the problem, the evidence and the done test (lib/artefacts.js). Unreadable: none.
|
|
61
|
+
let artState = new Map();
|
|
62
|
+
try { const A = require('./artefacts.js'); artState = A.fold(A.readLines(A.file(A.dirOf(w.root)))); } catch { artState = new Map(); }
|
|
63
|
+
const artOf = (id) => {
|
|
64
|
+
const m = artState.get(`experiment:${id}`) || new Map();
|
|
65
|
+
const has = (artefact, field) => { const x = m.get(artefact); return !!x && (x.sets.some((l) => l.field === field) || x.carried.some((l) => l.field === field)); };
|
|
66
|
+
return { problem: has('experiment', 'why'), evidence: has('experiment', 'evidence'), doneTest: has('done-test', 'check') };
|
|
67
|
+
};
|
|
60
68
|
const out = [];
|
|
61
69
|
// core-documents: each active initiative's core set with its state, read once for the sweep (lib/core-docs.js). A set that cannot be
|
|
62
70
|
// read gives empty lists: the doc rules then stay quiet instead of guessing.
|
|
@@ -76,8 +84,9 @@ function initiativeFacts(w, ctx, { driverState, stateDir, now = Date.now() }) {
|
|
|
76
84
|
out.push({
|
|
77
85
|
ws: w.id, board: board.id, id: base.id, title: base.title || base.id, cat: row.cat, active: true,
|
|
78
86
|
last_activity: ms(base.updated),
|
|
79
|
-
has_problem: !!rec.problem, has_evidence: keptEvidence.has(base.id),
|
|
80
|
-
|
|
87
|
+
has_problem: !!rec.problem || artOf(base.id).problem, has_evidence: keptEvidence.has(base.id) || artOf(base.id).evidence,
|
|
88
|
+
// D107: a done test (an artefact check, or done_test_path on the record) stands in for the PRD and its done-criteria
|
|
89
|
+
has_prd: !!base.hasSpec || artOf(base.id).doneTest || !!(fm && fm.done_test_path), has_done_criteria: doneCriteriaOf(w.root, fm) || artOf(base.id).doneTest || !!(fm && fm.done_test_path), has_anchor: !!(base.anchor && String(base.anchor).trim()),
|
|
81
90
|
has_tickets: tickets.length > 0, last_ticket_move: resolved.length ? Math.max(...resolved) : null,
|
|
82
91
|
blocked_tickets: tickets.filter((t) => t.flagged).map((t) => t.key),
|
|
83
92
|
check_by: placed && placed.ok && placed.byInit[base.id] ? placed.byInit[base.id].check_by || null : null,
|
package/workspace/lib/driver.js
CHANGED
|
@@ -52,7 +52,7 @@ const crypto = require('crypto');
|
|
|
52
52
|
const LEDGER = 'driver.jsonl';
|
|
53
53
|
const KINDS = Object.freeze(['initiative', 'work']);
|
|
54
54
|
const WHATS = Object.freeze({
|
|
55
|
-
initiative: Object.freeze(['problem', 'evidence', 'sizing', 'assumption', 'stakeholders', 'move', 'note', 'doc', 'overlap']),
|
|
55
|
+
initiative: Object.freeze(['problem', 'evidence', 'sizing', 'assumption', 'stakeholders', 'move', 'note', 'doc', 'overlap', 'artefact']),
|
|
56
56
|
work: Object.freeze(['next-step', 'follow-up', 'note']),
|
|
57
57
|
});
|
|
58
58
|
// A claim without a pointer is not a proposal (PRD section 2: "Nothing without a pointer").
|
|
@@ -185,6 +185,14 @@ function checkProposal(input) {
|
|
|
185
185
|
const c = checkOverlap(data, t.target.id);
|
|
186
186
|
if (!c.ok) return c;
|
|
187
187
|
data = c.data;
|
|
188
|
+
} else if (i.what === 'artefact') {
|
|
189
|
+
// R18 (D107): one field of one of the seven artefacts (lib/artefacts.js). Keep writes it to artefacts.jsonl, with Undo.
|
|
190
|
+
// The scope is this experiment unless data.scope names the portfolio or a board (Intent, Narrative, Lessons).
|
|
191
|
+
const A = require('./artefacts.js');
|
|
192
|
+
const scope = typeof data.scope === 'string' && data.scope ? data.scope : `experiment:${t.target.id}`;
|
|
193
|
+
const c = A.checkSet({ scope, artefact: data.artefact, field: data.field, text: data.text }, { by: 'pm:check' });
|
|
194
|
+
if (!c.ok) return { ok: false, error: `an artefact proposal: ${c.error}` };
|
|
195
|
+
data = { scope: c.line.scope, artefact: c.line.artefact, field: c.line.field, text: c.line.text };
|
|
188
196
|
} else if (i.what === 'next-step') {
|
|
189
197
|
if (!oneLine(data.text, 500)) return { ok: false, error: 'a next step needs data.text: one line of up to 500 characters' };
|
|
190
198
|
if (data.due != null && !(typeof data.due === 'string' && DATE_RE.test(data.due))) return { ok: false, error: 'data.due is YYYY-MM-DD' };
|
|
@@ -667,6 +667,10 @@ function computeWorkflowDerived(id, opts) {
|
|
|
667
667
|
}
|
|
668
668
|
const fm = readFrontmatter(recAbs) || {};
|
|
669
669
|
const profile = profileOf(root);
|
|
670
|
+
// D107 (seven artefacts): an experiment record names its Done test (done_test_path) and its kill condition (kill:). It needs no PRD
|
|
671
|
+
// and no lane: the done test is the spec, written before the build (D13 as amended). A record with no done_test_path keeps its lane rules.
|
|
672
|
+
const doneTest = String(fm.done_test_path || '').trim();
|
|
673
|
+
const killCond = String(fm.kill || '').trim();
|
|
670
674
|
const pmProfile = profile === 'pm-artifacts';
|
|
671
675
|
const lane = laneDefs.declaredLane(profile, fm) || (pmProfile ? 'prd' : 'feature');
|
|
672
676
|
const knownLane = pmProfile ? laneNames('pm-artifacts').includes(lane)
|
|
@@ -770,6 +774,9 @@ function computeWorkflowDerived(id, opts) {
|
|
|
770
774
|
// Batch 25 item 6: an initiative on a workflow is routed. The workflow's stages say what comes first, and PMOS proposes a
|
|
771
775
|
// switch when the BRD says another workflow fits, so the two intake questions are not asked of it again.
|
|
772
776
|
steps.push(step('route', 'route', 'done', `${onWf ? `runs the ${onWf} workflow` : 'runs its board\'s workflow'} — the workflow routes it`));
|
|
777
|
+
} else if (doneTest) {
|
|
778
|
+
// D107: an experiment's specimens and done test route it; the two intake questions are not asked of it.
|
|
779
|
+
steps.push(step('route', 'route', 'done', 'experiment — its done test and specimens route it (D107)'));
|
|
773
780
|
} else if (effLane !== 'feature') {
|
|
774
781
|
// The routing questions are asked of feature work only.
|
|
775
782
|
steps.push(step('route', 'route', 'done', `${lane} lane — routing questions are for features only (${CUT_NOTE})`));
|
|
@@ -932,7 +939,29 @@ function computeWorkflowDerived(id, opts) {
|
|
|
932
939
|
// A feature PRD's done-criteria section can serve as its rubric (sdlc-step-cuts), so a separate
|
|
933
940
|
// rubric file is optional in every lane. One that is declared must still exist.
|
|
934
941
|
const needsRubric = false;
|
|
935
|
-
|
|
942
|
+
// D107: an experiment's spec is its Done test, in any lane or none, with its kill condition stated. Same order rule (O1).
|
|
943
|
+
const orderOf = (names, specIdx, rule) => {
|
|
944
|
+
if (specIdx === undefined) return step('spec', 'spec', 'unknown', `${names} present — order vs the build undecidable (${range.reason || 'no usable history'})`);
|
|
945
|
+
if (build.unknown) return step('spec', 'spec', 'unknown', `${names} present — order vs the build undecidable (${range.reason})`);
|
|
946
|
+
if (build.first === null) return step('spec', 'spec', 'done', `${names} present — no implementation commits in this range, so nothing can precede them`);
|
|
947
|
+
if (specIdx <= build.first) return step('spec', 'spec', 'done', `${names} — first-appeared at or before the first build commit`);
|
|
948
|
+
return step('spec', 'spec', legacy ? 'unknown' : 'blocked',
|
|
949
|
+
`ORDER VIOLATION — implementation (${build.sample}) was committed BEFORE ${names} first appeared`,
|
|
950
|
+
'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',
|
|
951
|
+
{ blocking: !legacy, rule });
|
|
952
|
+
};
|
|
953
|
+
if (doneTest) {
|
|
954
|
+
const dtIdx = firstAppearance(root, range, doneTest);
|
|
955
|
+
if (dtIdx === null) {
|
|
956
|
+
steps.push(step('spec', 'spec', 'blocked', `done_test_path '${doneTest}' does not exist in the repo`,
|
|
957
|
+
'create the done test the record points at, or correct done_test_path', { blocking: true, rule: 'R2' }));
|
|
958
|
+
} else if (!killCond) {
|
|
959
|
+
steps.push(step('spec', 'spec', 'blocked', 'no kill condition — an experiment states what would stop it (D107)',
|
|
960
|
+
`write kill: "<the result that would make us stop>" in ${recRel}`, { blocking: true, rule: 'R2' }));
|
|
961
|
+
} else {
|
|
962
|
+
steps.push(orderOf(`done test ${doneTest}`, dtIdx, 'O1'));
|
|
963
|
+
}
|
|
964
|
+
} else {
|
|
936
965
|
const wants = {
|
|
937
966
|
feature: 'a PRD', discovery: 'a spike brief', incident: 'an incident record',
|
|
938
967
|
content: 'a content brief', prototype: 'a quick prototype brief',
|
|
@@ -1001,7 +1030,9 @@ function computeWorkflowDerived(id, opts) {
|
|
|
1001
1030
|
// blocked: the PM's approval of the PRD and the acceptance at the end are the sign-offs that count.
|
|
1002
1031
|
const approved = runs.find((r) => r.pre_run_contract && r.pre_run_contract.PM_approved === true);
|
|
1003
1032
|
{
|
|
1004
|
-
if (approved) {
|
|
1033
|
+
if (doneTest && !approved) {
|
|
1034
|
+
steps.push(step('contract', 'contract', 'na', 'experiment — the done test, written before the build, is the agreement (D107)'));
|
|
1035
|
+
} else if (approved) {
|
|
1005
1036
|
steps.push(step('contract', 'contract', 'done',
|
|
1006
1037
|
`PM-approved pre_run_contract on run ${approved.run_id}${approved.pre_run_contract.approved_by ? ` (by ${approved.pre_run_contract.approved_by})` : ''}`));
|
|
1007
1038
|
} else if (effLane !== 'feature') {
|
|
@@ -122,6 +122,9 @@ const VERBS = Object.freeze({
|
|
|
122
122
|
// Not a pm-os-absorb verb (run: null): initiative horizon-scan added it through the same table; horizon-scan-portfolio added section, propose, setting and --boards.
|
|
123
123
|
scan: Object.freeze({ module: 'scan-cli.js', run: null, guide: 'cli.md',
|
|
124
124
|
help: 'pmos scan file|section|propose|list [--sections]|match|suggest [--boards]|status|setting|cadence|watch [--boards] … — the Horizon scan: the portfolio watch list, the findings, the report sections and the proposals the PM approves, changes or dismisses (pmos scan help)' }),
|
|
125
|
+
// Not a pm-os-absorb verb (run: null): R18 (D107), the seven artefacts, added it through the same table.
|
|
126
|
+
artefacts: Object.freeze({ module: 'artefacts-cli.js', run: null, guide: 'cli.md',
|
|
127
|
+
help: 'pmos artefacts show|map|migrate|set|undo — the seven artefacts (Intent, Goal, Narrative, Experiment, Specimens, Done test, Lessons) and what the older documents became (pmos artefacts help)' }),
|
|
125
128
|
// Not a pm-os-absorb verb (run: null): initiative core-documents added it through the same table.
|
|
126
129
|
coredoc: Object.freeze({ module: 'coredoc-cli.js', run: null, guide: 'cli.md',
|
|
127
130
|
help: 'pmos coredoc write --scope <scope> --key <key> --file <path|-> — write one draft of a core document; the PM issues it on the page (pmos coredoc help)' }),
|
|
@@ -104,6 +104,7 @@ const MODULES = Object.freeze([
|
|
|
104
104
|
'routes-driver', // initiative-driver: the Agent strip's data, Keep, Send back, Drop, Pause and the board mode (driver.jsonl)
|
|
105
105
|
'routes-scan', // horizon-scan-portfolio: one scan for the workspace: the watch list and setting, Scan now and Stop, report documents and their proposals (approve, change, dismiss, undo), plus the first scan's per-board and Briefing reads (scan.jsonl)
|
|
106
106
|
'routes-report-setups', // report-workspace: recurring reports, the Ask box, the finder, the report documents and their export (report-setups.jsonl)
|
|
107
|
+
'routes-artefacts', // R18 (D107): the seven artefacts, read-only, and the lossless carry of the older records (artefacts.jsonl)
|
|
107
108
|
'routes-core-docs', // core-documents: the core documents of each level, Draft it (a core-doc run), Issue it and Drop (core-docs.jsonl)
|
|
108
109
|
'routes-custom-docs', // briefing-premium-adddoc: the documents the PM adds beyond the core set, Add a document (custom-docs.jsonl)
|
|
109
110
|
'routes-premium-dashboards', // briefing-premium-reports: the dashboards the PM makes on premium Insights (premium-dashboards.jsonl; page-press POST save)
|