create-pmos 0.411.0 → 0.413.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 +25 -25
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/scripts/pmos-log.sh +6 -3
- package/payload/state/discoveries.md +1 -1
- package/workspace/board-programs-test.js +2 -2
- package/workspace/briefing-premium-adddoc-test.js +1 -1
- package/workspace/briefing-premium-insights-test.js +2 -2
- package/workspace/briefing-premium-test.js +3 -3
- package/workspace/changelog.json +24 -0
- package/workspace/core-docs-workflow-test.js +144 -0
- package/workspace/guide/board.md +1 -1
- package/workspace/guide/breakdown.md +6 -13
- package/workspace/guide/index.md +1 -1
- package/workspace/guide/initiative-driver.md +1 -1
- package/workspace/guide/initiatives-screen.md +1 -1
- package/workspace/guide/pm-only-acts.md +23 -24
- package/workspace/guide/today.md +1 -1
- package/workspace/guide/workflows.md +8 -1
- package/workspace/lib/board-premium.js +7 -2
- package/workspace/lib/briefing-premium-agent.js +16 -4
- package/workspace/lib/briefing-premium-writes.js +5 -4
- package/workspace/lib/core-docs.js +79 -14
- package/workspace/lib/coredoc-cli.js +1 -1
- package/workspace/lib/driver-cli.js +2 -1
- package/workspace/lib/driver-decide.js +3 -2
- package/workspace/lib/driver.js +2 -1
- package/workspace/lib/engine/boards.js +20 -12
- package/workspace/lib/grant-mint.js +3 -2
- package/workspace/lib/initiative-chat.js +49 -0
- package/workspace/lib/initiative-cli.js +9 -9
- package/workspace/lib/initiative-premium.js +17 -7
- package/workspace/lib/issues.js +5 -4
- package/workspace/lib/item-cli.js +7 -2
- package/workspace/lib/people-store.js +1 -1
- package/workspace/lib/people.js +3 -1
- package/workspace/lib/placements.js +13 -15
- package/workspace/lib/plan-items.js +18 -49
- package/workspace/lib/pm-guard.js +18 -5
- package/workspace/lib/pm-lines-needs.js +9 -5
- package/workspace/lib/pmos-verbs.js +1 -1
- package/workspace/lib/program-chat.js +1 -1
- package/workspace/lib/programs.js +21 -5
- package/workspace/lib/report-cli.js +2 -2
- package/workspace/lib/routes-board-metric-targets.js +0 -1
- package/workspace/lib/routes-boards.js +75 -13
- package/workspace/lib/routes-briefing-premium.js +20 -6
- package/workspace/lib/routes-core-docs.js +3 -2
- package/workspace/lib/routes-custom-docs.js +0 -1
- package/workspace/lib/routes-driver.js +0 -1
- package/workspace/lib/routes-home-desk.js +1 -1
- package/workspace/lib/routes-home-review.js +1 -1
- package/workspace/lib/routes-initiative-layout.js +1 -1
- package/workspace/lib/routes-insights-records.js +0 -1
- package/workspace/lib/routes-meeting-material.js +0 -1
- package/workspace/lib/routes-onboarding.js +3 -1
- package/workspace/lib/routes-orchestrator.js +0 -1
- package/workspace/lib/routes-premium-charts.js +0 -1
- package/workspace/lib/routes-premium-dashboards.js +0 -1
- package/workspace/lib/routes-programs.js +13 -2
- package/workspace/lib/routes-records.js +1 -1
- package/workspace/lib/routes-report-design.js +7 -3
- package/workspace/lib/routes-report-setups.js +0 -1
- package/workspace/lib/routes-report-structure.js +0 -1
- package/workspace/lib/routes-runs.js +2 -5
- package/workspace/lib/routes-scan.js +0 -1
- package/workspace/lib/routes-sources.js +1 -1
- package/workspace/lib/run-answers.js +14 -5
- package/workspace/lib/scan-cli.js +2 -1
- package/workspace/lib/scan.js +2 -1
- package/workspace/lib/vendor/scripts/onboarding/proposals.js +7 -3
- package/workspace/lib/workflow-chat.js +1 -0
- package/workspace/lib/workflow-cli.js +91 -6
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-chat-line-test.js +9 -0
- package/workspace/premium-core-doc-issue-test.js +1 -1
- package/workspace/premium-viewer-share-test.js +5 -2
- package/workspace/premium-vw-item-test.js +3 -3
- package/workspace/premium-vw-jira-test.js +2 -1
- package/workspace/program-order-test.js +180 -0
- package/workspace/public/pm/bd-prog.js +3 -3
- package/workspace/public/pm/cozy-viewer.js +8 -3
- package/workspace/public/pm/goal-chat.js +1 -1
- package/workspace/public/pm/home-app.js +22 -8
- package/workspace/public/pm/home-chat.js +6 -1
- package/workspace/public/pm/home-ini-model.js +42 -29
- package/workspace/public/pm/home-ini.css +1 -0
- package/workspace/public/pm/home-ini.js +26 -34
- package/workspace/public/pm/home-list.js +2 -1
- package/workspace/public/pm/home-stage-card.js +3 -1
- package/workspace/public/pm/home-task.js +41 -65
- package/workspace/public/pm/home-today.js +7 -5
- package/workspace/public/pm/premium-board.js +12 -6
- package/workspace/public/pm/premium-initiative-head.js +21 -11
- package/workspace/public/pm/premium-viewer.js +1 -0
- package/workspace/public/pm/premium-vw-item-model.js +13 -7
- package/workspace/public/pm/premium-vw-item.js +49 -5
- package/workspace/public/pm/prog-order.css +47 -0
- package/workspace/public/pm/prog-order.js +188 -0
- package/workspace/public/pm/program-model.js +75 -0
- package/workspace/public/pm/task-card.css +108 -0
- package/workspace/public/pm/task-card.js +271 -0
- package/workspace/replaced-tests.json +101 -0
- package/workspace/server.js +8 -9
- package/workspace/skills/workflow-setup.skill +14 -5
- package/workspace/stage-card-test.js +11 -0
- package/workspace/task-card-test.js +248 -0
- package/workspace/test-lists/core-documents-backend.json +15 -3
- package/workspace/test-lists/program-order.json +6 -0
- package/workspace/test-lists/task-card.json +6 -0
- package/workspace/test-lists/workflow-stage.json +5 -0
|
@@ -6,19 +6,19 @@
|
|
|
6
6
|
* pmos initiative new --from capture-YYYY-MM-DD-<n> [--anchor …] [--lane …] [--title "…"]
|
|
7
7
|
* pmos initiative now <id> PM only: type the id to confirm
|
|
8
8
|
* pmos initiative next|later <id> [--top] to the end of that horizon, or its top
|
|
9
|
-
* pmos initiative top|up|down <id> reorder inside its horizon
|
|
9
|
+
* pmos initiative top|up|down <id> reorder inside its horizon
|
|
10
10
|
* pmos initiative check-by <id> <YYYY-MM-DD|none>
|
|
11
|
-
* pmos initiative adopt <proposal-eid> PM
|
|
11
|
+
* pmos initiative adopt <proposal-eid> the PM types the eid to confirm; an agent passes (D98)
|
|
12
12
|
* pmos initiative drop <proposal-eid>
|
|
13
13
|
* pmos initiative list
|
|
14
14
|
* pmos initiative export <id> the breakdown as markdown on stdout; nothing is written
|
|
15
15
|
* every command: [--json] [--root <dir>]
|
|
16
16
|
*
|
|
17
17
|
* The SAME writers the workspace page uses (lib/initiative-writer.js, lib/placements.js) — no server is needed. Who
|
|
18
|
-
* wrote a line comes from the call path, never from an argument:
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* PMOS_SESSION, `agent:unknown` otherwise. An agent's placement
|
|
18
|
+
* wrote a line comes from the call path, never from an argument: Move to Now, adopt, and any line into Now go through
|
|
19
|
+
* lib/pm-guard.js requirePmCli — the PM types the confirmation at a terminal, and an agent session passes with its own
|
|
20
|
+
* actor (D98); every other command takes lib/actor.js fromCli: the PM at a terminal, the bound agent session from
|
|
21
|
+
* PMOS_SESSION, `agent:unknown` otherwise. An agent's placement applies at once and its line names the agent (D98).
|
|
22
22
|
* Work lanes only (D86 point 4): `list` and `export` leave document-lane initiatives out.
|
|
23
23
|
* Exit codes: 0 done, 1 refused, 2 usage.
|
|
24
24
|
*/
|
|
@@ -43,12 +43,12 @@ const USAGE = [
|
|
|
43
43
|
' pmos initiative next|later <id> [--top] move it to the end of Next or Later, or to its top',
|
|
44
44
|
' pmos initiative top|up|down <id> reorder it inside its horizon',
|
|
45
45
|
' pmos initiative check-by <id> <YYYY-MM-DD|none>',
|
|
46
|
-
' pmos initiative adopt <proposal> keep an
|
|
47
|
-
' pmos initiative drop <proposal> close an
|
|
46
|
+
' pmos initiative adopt <proposal> keep an open proposal (you type the proposal to confirm)',
|
|
47
|
+
' pmos initiative drop <proposal> close an open proposal',
|
|
48
48
|
' pmos initiative list Now, Next and Later, in order',
|
|
49
49
|
' pmos initiative export <id> the breakdown as markdown on stdout',
|
|
50
50
|
' every command: [--json] [--root <dir>]',
|
|
51
|
-
'An agent session
|
|
51
|
+
'An agent session\'s placement applies at once and names the agent. A new initiative lands in Later.',
|
|
52
52
|
];
|
|
53
53
|
const BOOL = new Set(['json', 'top', 'help']);
|
|
54
54
|
const VALUE = new Set(['lane', 'anchor', 'intent', 'id', 'from', 'title', 'root']);
|
|
@@ -45,8 +45,15 @@ function build(f) {
|
|
|
45
45
|
const row = f.row || {}, sheet = f.sheet || null, ini = (sheet && sheet.initiative) || {}, board = f.board || {};
|
|
46
46
|
const missing = (f.missing || []).slice();
|
|
47
47
|
if (!f.ladder && !missing.includes('workflow steps')) missing.push('workflow steps');
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
// D99: the stages are the initiative's own workflow (row.wfStages, routes-boards workflowRowOf): the strip and the phase read them, and on a
|
|
49
|
+
// library workflow so does a move (bug 2026-10-25: a Tender initiative offered the old board stages Discover, Plan, Build & Deliver,
|
|
50
|
+
// Monitor & Evaluate). A move on Product feature still names the board's stages, which POST /api/boards/move checks. Tasks have no stage.
|
|
51
|
+
const boardWf = (row.workflow && row.workflow.length ? row.workflow : board.workflow) || [];
|
|
52
|
+
const own = Array.isArray(row.wfStages) && row.wfStages.length && row.wfStage ? row.wfStages.filter((s) => s.status !== 'skipped' || s.key === row.wfStage.key) : null;
|
|
53
|
+
const ownWf = !!(own && row.wf && row.wf.id && row.wf.id !== 'product-feature');
|
|
54
|
+
const names = own ? own.map((s) => s.name) : boardWf.map((s) => s.name);
|
|
55
|
+
const cur = own ? own.findIndex((s) => s.key === row.wfStage.key) : names.indexOf(row.stage);
|
|
56
|
+
const moveNames = own && !ownWf ? boardWf.map((s) => s.name) : names;
|
|
50
57
|
const id = row.id || '';
|
|
51
58
|
const key = 'init:' + id;
|
|
52
59
|
|
|
@@ -84,7 +91,7 @@ function build(f) {
|
|
|
84
91
|
|
|
85
92
|
// ── tasks: PRD requirements (no result per requirement) and the board's tracker items ──
|
|
86
93
|
const items = (f.items || []).filter((t) => t && t.ini === id).slice(0, MAX_TASKS);
|
|
87
|
-
const tracker = items.map((t, n) => ({ key: 'task:' + (t.uid || t.key || n), uid: t.uid || '', pmos: t.src === 'pmos', ref: t.key || t.ref || '', title: clip(t.title, 160), state: t.status || 'To do', src: t.src === 'jira' ? 'Jira (read-only)' : 'PMOS task', owner: t.owner || '', start: t.start || '', end: t.end || '', blocked: !!t.blocked, kind: t.kind || 'Task' }));
|
|
94
|
+
const tracker = items.map((t, n) => ({ key: 'task:' + (t.uid || t.key || n), uid: t.uid || '', pmos: t.src === 'pmos', ref: t.key || t.ref || '', title: clip(t.title, 160), state: t.status || 'To do', src: t.src === 'jira' ? 'Jira (read-only)' : 'PMOS task', owner: t.owner || '', start: t.start || '', end: t.end || '', blocked: !!t.blocked, kind: t.kind || 'Task', notes: t.notes || '', readAt: t.readAt || '' }));
|
|
88
95
|
const dv = sheet && sheet.derived;
|
|
89
96
|
const reqs = dv && Array.isArray(dv.items) ? dv.items.slice(0, MAX_TASKS).map((x) => ({ key: 'req:' + x.id, ref: x.ref || x.id, title: clip(x.title, 160), state: null, src: 'PRD requirement' })) : [];
|
|
90
97
|
const prog = ini.progress || null;
|
|
@@ -102,9 +109,11 @@ function build(f) {
|
|
|
102
109
|
|
|
103
110
|
// ── documents ──
|
|
104
111
|
const dd = f.docs || null;
|
|
112
|
+
// D99: an initiative on a library workflow groups its documents under its own stages (dd.phases), not Discover/Plan/Build/Evaluate
|
|
113
|
+
const phases = dd && Array.isArray(dd.phases) && dd.phases.length ? dd.phases.slice() : null;
|
|
105
114
|
const all = dd ? (dd.docs || []).map((d) => ({
|
|
106
115
|
key: d.key, title: d.title, what: d.for || '', st: d.st, state: d.kind === 'live' ? 'Live' : DOC_STATE[d.st] || d.st || '', by: BY[d.by] || d.by || '', byKey: d.by || '',
|
|
107
|
-
when: d.when ? shortDate(d.when) : '', cat: d.cat === 'Do' ? 'Build' : d.cat === 'Learn' ? 'Evaluate' : d.cat || 'Board', path: d.open && d.open.path ? d.open.path : null, slot: d.st === 'draft' && d.draft && d.draft.slot ? d.draft.slot : '', running: !!d.running, tech: TECH.has(d.key), kind: d.kind || '', reader: d.reader || '', cadence: d.cadence || '', sections: ((GUIDE[d.key] || {}).sections || []).slice(),
|
|
116
|
+
when: d.when ? shortDate(d.when) : '', cat: phases ? (d.other ? null : d.cat || null) : d.cat === 'Do' ? 'Build' : d.cat === 'Learn' ? 'Evaluate' : d.cat || 'Board', ...(d.other ? { other: true } : {}), path: d.open && d.open.path ? d.open.path : null, slot: d.st === 'draft' && d.draft && d.draft.slot ? d.draft.slot : '', running: !!d.running, tech: TECH.has(d.key), kind: d.kind || '', reader: d.reader || '', cadence: d.cadence || '', sections: ((GUIDE[d.key] || {}).sections || []).slice(),
|
|
108
117
|
act: d.act && d.act.do === 'draft' ? { kind: 'draft', label: d.running ? 'Drafting' : d.act.label || 'Draft it' } : null,
|
|
109
118
|
from: d.from && d.from.text ? { path: d.from.path, heading: d.from.heading, text: d.from.text, cut: !!d.from.cut } : null,
|
|
110
119
|
})) : [];
|
|
@@ -116,13 +125,14 @@ function build(f) {
|
|
|
116
125
|
if (nLinked) cnt.linked = nLinked; // a key only when an added document is linked
|
|
117
126
|
const docs = dd || custom.length ? { rows, counts: cnt, techCount: rows.length - core.length,
|
|
118
127
|
cap: core.length ? [cnt.draft ? cnt.draft + ' ' + plural(cnt.draft, 'draft', 'drafts') + ' to review' : '', cnt.none ? cnt.none + ' not started' : '', cnt.ok ? cnt.ok + ' up to date' : '', nLinked ? nLinked + ' linked' : ''].filter(Boolean).join(' · ') : '',
|
|
119
|
-
scope: (dd && dd.scope) || 'initiative:' + id, missing: !dd } : { rows: [], counts: { all: 0, none: 0, draft: 0, ok: 0 }, techCount: 0, cap: '', missing: true };
|
|
128
|
+
scope: (dd && dd.scope) || 'initiative:' + id, missing: !dd, ...(phases ? { phases, cur: dd.cat || phases[0] } : {}) } : { rows: [], counts: { all: 0, none: 0, draft: 0, ok: 0 }, techCount: 0, cap: '', missing: true };
|
|
120
129
|
if (!dd && !missing.includes('core documents')) missing.push('core documents');
|
|
121
130
|
|
|
122
131
|
// ── PMOS can help: only things a press can really do. A draft of a core document the initiative has not started (the existing read-only draft run), and a question for the read-only agent ──
|
|
123
132
|
const phase = Math.max(0, PHASE_OF_CAT[row.cat] != null ? PHASE_OF_CAT[row.cat] : Math.max(0, cur >= 0 && names.length ? Math.floor(cur / Math.max(1, names.length) * 4) : 0));
|
|
124
133
|
const help = [];
|
|
125
|
-
const
|
|
134
|
+
const docAt = (d) => (docs.phases ? docs.phases.indexOf(d.cat) <= docs.phases.indexOf(docs.cur) && docs.phases.includes(d.cat) : DOC_CAT_ORDER.indexOf(d.cat) <= phase);
|
|
135
|
+
const nd = docs.rows.find((d) => d.st === 'missing' && !d.tech && d.act && d.act.kind === 'draft' && docAt(d));
|
|
126
136
|
if (nd) help.push({ label: 'Draft the ' + nd.title.toLowerCase(), kind: 'draft', key: nd.key });
|
|
127
137
|
const wantsOptions = bad || (lad && lad.next && /^(review|accept)$/.test(lad.next.step));
|
|
128
138
|
if (wantsOptions) help.push({ label: lad ? 'Summarise the review findings' : 'Lay out the options', kind: 'ask', q: lad ? 'Summarise the review findings for this initiative, from the evidence you can read in this repository. Say what you could not find.' : 'Lay out the options for this initiative, from what you can read in this repository, and say what you could not find. Do not recommend one unless the records do.' });
|
|
@@ -143,7 +153,7 @@ function build(f) {
|
|
|
143
153
|
id, key, title: clip(row.title || id, 160), lane: row.lane || '', anchor: row.anchor || '',
|
|
144
154
|
// the bar's presses (initiative premium-board-actions): the workflow, the lifecycle and the archive entry the row holds
|
|
145
155
|
acts: {
|
|
146
|
-
self: !!board.self, stages:
|
|
156
|
+
self: !!board.self, stages: moveNames, stage: (ownWf ? names[cur] : row.stage) || null,
|
|
147
157
|
life: status === 'on hold' ? 'hold' : status === 'cancelled' ? 'cancelled' : null,
|
|
148
158
|
reason: (status === 'on hold' || status === 'cancelled') && row.stopped ? clip(row.stopped.reason || '', 300) : '',
|
|
149
159
|
back: status === 'on hold' && row.stopped && row.stopped.back ? shortDate(row.stopped.back) : '', backDay: status === 'on hold' && row.stopped && row.stopped.back ? String(row.stopped.back).slice(0, 10) : null,
|
package/workspace/lib/issues.js
CHANGED
|
@@ -99,7 +99,8 @@ function readIssues(root) {
|
|
|
99
99
|
}
|
|
100
100
|
const why = lineErr(rec);
|
|
101
101
|
if (why) { out.flags.push({ kind: 'invalid', eid: rec.eid || null, why: `line ${n}: ${why}` }); continue; }
|
|
102
|
-
|
|
102
|
+
// D98: the PM or an agent session issues a report; the line keeps who issued it.
|
|
103
|
+
if (!actorLib.valid({ by: rec.by, via: rec.via })) { out.flags.push({ kind: 'not-pm', eid: rec.eid, why: `line ${n}: ${rec.by} issued ${rec.cadence} ${rec.slot}, but the line names no PM or agent session, so it has no effect` }); continue; }
|
|
103
104
|
const key = `${rec.cadence}\u0000${rec.slot}`;
|
|
104
105
|
if (seen.has(key)) { out.flags.push({ kind: 'duplicate-slot', eid: rec.eid, why: `line ${n}: ${rec.cadence} ${rec.slot} was issued on line ${seen.get(key)}; the later line has no effect` }); continue; }
|
|
105
106
|
seen.set(key, n);
|
|
@@ -133,12 +134,12 @@ function randomChars(n) {
|
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
/**
|
|
136
|
-
* One `issued` line per event. The actor is the caller's guard result (pm-guard.js), never a field;
|
|
137
|
-
* issues, and the call path must match the actor (`ui` from the page, `cli` from a terminal). Each event names a file
|
|
137
|
+
* One `issued` line per event. The actor is the caller's guard result (pm-guard.js), never a field; the PM or an agent
|
|
138
|
+
* session issues (D98), and the call path must match the actor (`ui` from the page, `cli` from a terminal). Each event names a file
|
|
138
139
|
* that exists in `root` with exactly the sha sent, so a line can never freeze bytes nobody read.
|
|
139
140
|
*/
|
|
140
141
|
function append(root, events, actor, via, { now } = {}) {
|
|
141
|
-
if (!actorLib.
|
|
142
|
+
if (!actorLib.valid(actor) || actor.via !== via) return refuse(403, `a report is issued by the PM or an agent session, from the ${via === 'ui' ? 'page' : 'terminal'}; nothing was written`, null);
|
|
142
143
|
if (!Array.isArray(events) || !events.length) return refuse(400, 'send at least one line', null);
|
|
143
144
|
if (events.length > MAX_LINES) return refuse(413, `send at most ${MAX_LINES} lines at once`, null);
|
|
144
145
|
let read;
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
* pmos item list <initiative> [--json]
|
|
11
11
|
* common: [--root <dir>]
|
|
12
12
|
*
|
|
13
|
+
* --stage is the group of the breakdown an item sits in (lib/plan-tree.js stagesFor). It is not the initiative's workflow stage, which the
|
|
14
|
+
* stage card and the Board show and `pmos workflow of|move` read and move (bug 2026-10-25: an agent asked to move an initiative along its
|
|
15
|
+
* workflow changed 47 items' --stage instead). Progress is an item's state: `pmos item move`.
|
|
16
|
+
*
|
|
13
17
|
* The SAME writer and the SAME fold the workspace page uses (lib/plan-items.js) — no server is needed, and
|
|
14
18
|
* the terminal and the page cannot disagree about an item. Who wrote a line is decided by the call path,
|
|
15
19
|
* never by an argument: `pm:wawan` at an interactive terminal, the bound session from PMOS_SESSION, and
|
|
@@ -32,7 +36,8 @@ const USAGE = [
|
|
|
32
36
|
' pmos item withdraw <item>',
|
|
33
37
|
' pmos item list <initiative>',
|
|
34
38
|
' every command: [--json] [--root <dir>]',
|
|
35
|
-
'An item id is <initiative>.<10 characters>.
|
|
39
|
+
'An item id is <initiative>.<10 characters>. --stage is the group of the breakdown the item sits in, not a workflow stage.',
|
|
40
|
+
'To report progress, set the item\'s state with pmos item move. To see or move the initiative\'s workflow stage, use pmos workflow of|move.',
|
|
36
41
|
'Who wrote each line comes from where the command runs: you at a terminal, the agent session otherwise.',
|
|
37
42
|
'Keep is pressed on the workspace page (Breakdown or Today). This command does not write it.',
|
|
38
43
|
];
|
|
@@ -128,7 +133,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
128
133
|
if (!planItems.INIT_RE.test(initiative) || !planTree.recordPath(root, initiative)) return fail(`no initiative ${initiative} in this repository`);
|
|
129
134
|
if (!flags.stage) {
|
|
130
135
|
const stages = planTree.stagesFor(root, initiative);
|
|
131
|
-
say(`--stage is required — the
|
|
136
|
+
say(`--stage is required — the breakdown groups of ${initiative} are: ${stages.map((s) => `${s.id} (${s.label})`).join(', ')}. The initiative's workflow stage is pmos workflow of ${initiative}.`);
|
|
132
137
|
return 2;
|
|
133
138
|
}
|
|
134
139
|
const ev = { ev: 'planned', initiative, title, stage: flags.stage };
|
|
@@ -128,7 +128,7 @@ const noteId = () => 'n-' + crypto.randomBytes(6).toString('base64').replace(/[^
|
|
|
128
128
|
*/
|
|
129
129
|
function decide(root, { actor, body, now = Date.now() } = {}) {
|
|
130
130
|
const by = actor && typeof actor.by === 'string' ? actor.by : null;
|
|
131
|
-
if (!by || !/^pm:/.test(by)) return { ok: false, error: 'only the PM decides who is a person' };
|
|
131
|
+
if (!by || !/^(?:pm|agent):/.test(by)) return { ok: false, error: 'only the PM or an agent session decides who is a person' }; // D98
|
|
132
132
|
const b = body && typeof body === 'object' ? { ...body } : {};
|
|
133
133
|
if (b.act === 'note' && !b.id) b.id = noteId();
|
|
134
134
|
const c = P.checkDecision(b);
|
package/workspace/lib/people.js
CHANGED
|
@@ -36,6 +36,7 @@ const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
|
36
36
|
const ID_RE = /^[a-z0-9][a-z0-9-]{0,59}$/;
|
|
37
37
|
const NOTE_ID_RE = /^n-[0-9a-z]{4,16}$/;
|
|
38
38
|
const PM_BY_RE = /^pm:[a-z0-9_-]{1,40}$/;
|
|
39
|
+
const AGENT_BY_RE = /^agent:(?:unknown|sess-\d+\.[0-9a-f]{8})$/;
|
|
39
40
|
const TONE_WINDOW = 10;
|
|
40
41
|
|
|
41
42
|
const isObj = (x) => !!x && typeof x === 'object' && !Array.isArray(x);
|
|
@@ -221,7 +222,8 @@ function matchPeople(people, hay) {
|
|
|
221
222
|
|
|
222
223
|
const sightKey = (r) => [handleKey(r.handle), r.interaction ? r.interaction.date : '', r.interaction ? r.interaction.pointer : '', r.interaction ? r.interaction.text : ''].join('\u0000');
|
|
223
224
|
const pairKey = (a, b) => [handleKey(a), handleKey(b)].sort().join('\u0000');
|
|
224
|
-
|
|
225
|
+
// D98: a decision by the PM or an agent session takes effect; the row keeps who decided.
|
|
226
|
+
const isPm = (r) => typeof r.by === 'string' && (PM_BY_RE.test(r.by) || AGENT_BY_RE.test(r.by));
|
|
225
227
|
const DECISION_KINDS = new Set(['add', 'ignore', 'remove', 'merge', 'keep-separate', 'edit', 'tone', 'note', 'note-remove', 'setting']);
|
|
226
228
|
|
|
227
229
|
/**
|
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
* --json) the day-one derivation (R26) reads; `rules` is lib/plan-rules.js readRules(root). A consumer that needs a
|
|
19
19
|
* horizon reads it through horizonOf, never from the file.
|
|
20
20
|
*
|
|
21
|
-
* The actor is never chosen by the caller of a route: the route takes it from pm-guard.js (Move to Now, adopt
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* The actor is never chosen by the caller of a route: the route takes it from pm-guard.js (Move to Now, adopt) or
|
|
22
|
+
* actor.js (every other press); the CLI from actor.fromCli or requirePmCli. D98: an agent's line applies like the PM's
|
|
23
|
+
* (Now and adopt included) and keeps the agent's `by`, so the PM sees who moved what and can move it back. The writer
|
|
24
|
+
* no longer writes `proposed: true`; such a line from before D98 stays a proposal until it is adopted or dropped.
|
|
24
25
|
*
|
|
25
26
|
* THE `placed` LINE (the shared contract; 2C may add events, never change this one):
|
|
26
27
|
* { v: 1, eid, ev: 'placed', initiative, horizon: 'now'|'next'|'later', after: <initiative id> | null,
|
|
@@ -32,10 +33,10 @@
|
|
|
32
33
|
* { ev: 'created', initiative, from?: 'capture-YYYY-MM-DD-<n>' } the initiative writer's landing line: top of
|
|
33
34
|
* Later, so a new record never reads Now through day one (R16, R23: what an agent creates lands in Later).
|
|
34
35
|
* Any actor; only for an initiative with no line yet. `from` names the capture it came from (triage reads it).
|
|
35
|
-
* { ev: 'adopted', proposal: <eid> } the PM
|
|
36
|
-
* { ev: 'dropped', proposal: <eid> } the proposal is closed unapplied (the PM
|
|
37
|
-
* pmOnly(rec) → true for a line
|
|
38
|
-
* (scripts/check-pm-lines.js, 2B) asks this function and never reads the schema itself.
|
|
36
|
+
* { ev: 'adopted', proposal: <eid> } the PM or an agent keeps an open proposal: its placement applies.
|
|
37
|
+
* { ev: 'dropped', proposal: <eid> } the proposal is closed unapplied (the PM or any agent, D98).
|
|
38
|
+
* pmOnly(rec) → true for a line that was PM-only before D98: a non-proposed `placed` into Now, and `adopted`. The
|
|
39
|
+
* checker (scripts/check-pm-lines.js, 2B) asks this function and never reads the schema itself.
|
|
39
40
|
*
|
|
40
41
|
* DAY ONE (R26), with no migration. An initiative of a work lane with no line in the ledger is placed by its activity:
|
|
41
42
|
* active within `stall_days` reads Now, unconfirmed (`confirmed: false`, `source: 'day-one'`, outside any cap); every
|
|
@@ -54,9 +55,8 @@
|
|
|
54
55
|
* once, lines apply in (at, eid) order, and one eid with two contents keeps the first and flags the second. A later
|
|
55
56
|
* PM `placed` line for an initiative closes that initiative's open proposals (they are superseded, not adopted).
|
|
56
57
|
*
|
|
57
|
-
* HONEST LIMIT. The fold tells an agent's line by its `by
|
|
58
|
-
*
|
|
59
|
-
* agent is ignored and flagged. A forged `pm:` line is caught only by scripts/check-pm-lines.js (2B), not here.
|
|
58
|
+
* HONEST LIMIT. The fold tells an agent's line by its `by`, and since D98 applies it either way; the `by` is the
|
|
59
|
+
* record of who acted. A forged `pm:` line is caught only by scripts/check-pm-lines.js (2B), not here.
|
|
60
60
|
*
|
|
61
61
|
* The ledger is one per repository: lib/plan-ledgers.js ledgerPath(root, 'placements'). Nothing is cached (D33).
|
|
62
62
|
*/
|
|
@@ -97,7 +97,9 @@ const ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz';
|
|
|
97
97
|
|
|
98
98
|
const isStr = (v) => typeof v === 'string';
|
|
99
99
|
const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
|
100
|
-
|
|
100
|
+
// D98: a line by the PM or an agent session takes effect (placed, adopted, dropped); the line keeps who wrote it.
|
|
101
|
+
// A line marked `proposed` (written before D98) is still a proposal until someone adopts or drops it.
|
|
102
|
+
const isPmBy = (by) => isStr(by) && (by.startsWith('pm:') || by.startsWith('agent:'));
|
|
101
103
|
const dateOk = (v) => isStr(v) && DATE_RE.test(v) && !Number.isNaN(Date.parse(v + 'T00:00:00Z'))
|
|
102
104
|
&& new Date(v + 'T00:00:00Z').toISOString().slice(0, 10) === v;
|
|
103
105
|
|
|
@@ -355,7 +357,6 @@ function buildRecord(root, ev, i, actor, state) {
|
|
|
355
357
|
if (!has(CALLER_KEYS, ev.ev)) return refuse(400, `ev must be one of ${EVENTS.join(', ')}`, i);
|
|
356
358
|
const extra = Object.keys(ev).filter((k) => k !== 'ev' && !CALLER_KEYS[ev.ev].includes(k));
|
|
357
359
|
if (extra.length) return refuse(400, `a ${ev.ev} line has no field ${extra.join(', ')}`, i);
|
|
358
|
-
const agent = !actorLib.isPm(actor);
|
|
359
360
|
const rec = { ev: ev.ev };
|
|
360
361
|
if (ev.ev === 'placed' || ev.ev === 'created') {
|
|
361
362
|
if (!isStr(ev.initiative) || !INIT_RE.test(ev.initiative)) return refuse(400, 'initiative must be an initiative id', i);
|
|
@@ -373,7 +374,6 @@ function buildRecord(root, ev, i, actor, state) {
|
|
|
373
374
|
if (ev.check_by !== null && !dateOk(ev.check_by)) return refuse(400, 'check_by must be YYYY-MM-DD, or null to clear it', i);
|
|
374
375
|
rec.check_by = ev.check_by;
|
|
375
376
|
}
|
|
376
|
-
if (agent) rec.proposed = true; // an agent's placement is a proposal, whatever it names (R23)
|
|
377
377
|
} else if (ev.ev === 'created') {
|
|
378
378
|
if (has(ev, 'from')) {
|
|
379
379
|
if (!(isStr(ev.from) && CAPTURE_RE.test(ev.from))) return refuse(400, 'from must name a capture note, like capture-2026-10-04-1', i);
|
|
@@ -384,8 +384,6 @@ function buildRecord(root, ev, i, actor, state) {
|
|
|
384
384
|
if (!isStr(ev.proposal) || !EID_RE.test(ev.proposal)) return refuse(400, 'proposal must be the eid of a proposal', i);
|
|
385
385
|
const p = state.open.get(ev.proposal);
|
|
386
386
|
if (!p) return refuse(404, `${ev.proposal} is not an open proposal`, i);
|
|
387
|
-
if (ev.ev === 'adopted' && agent) return refuse(403, 'only the PM adopts a proposal', i);
|
|
388
|
-
if (ev.ev === 'dropped' && agent && actor.by !== p.by) return refuse(403, 'an agent drops only its own proposal', i);
|
|
389
387
|
rec.proposal = ev.proposal;
|
|
390
388
|
}
|
|
391
389
|
return { ok: true, rec };
|
|
@@ -16,11 +16,10 @@
|
|
|
16
16
|
*
|
|
17
17
|
* WHO IS WHO COMES FROM lib/actor.js (Run 2, slice 2A). The server route runs lib/pm-guard.js first (Origin, the
|
|
18
18
|
* per-launch nonce, writer fields; act `keep` when the call carries a Keep) and passes the guard's actor on;
|
|
19
|
-
* `pmos item` takes actor.fromCli.
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* evidence (R23 "finishes"). Item-change proposals are not built (deferred, named in the run PR).
|
|
19
|
+
* `pmos item` takes actor.fromCli. D98 (amends R23): an agent finishes the work it was asked to do. Its items are live
|
|
20
|
+
* at once (never proposed, so there is nothing to Keep), and it may set, flag, move and withdraw any item, the PM's
|
|
21
|
+
* included. Every line keeps the agent's own `by`, so the PM sees who acted and can move or withdraw it back. Keep
|
|
22
|
+
* lines written before D98 name items that are already live; the fold skips them silently.
|
|
24
23
|
*
|
|
25
24
|
* HONEST LIMIT (rubric anti-optimism). A process that runs as the PM's own user can still read the nonce from the
|
|
26
25
|
* page, or fake a terminal with no PMOS_SESSION, and be recorded as the PM. The fold flags a `kept` line whose `via`
|
|
@@ -36,7 +35,6 @@ const { createSinkGuard } = require('./sink.js');
|
|
|
36
35
|
const planTree = require('./plan-tree.js');
|
|
37
36
|
const consoleState = require('./console-state');
|
|
38
37
|
const actorLib = require('./actor.js');
|
|
39
|
-
const stateRoot = require('./state-root');
|
|
40
38
|
|
|
41
39
|
const LEDGER = 'plan-items.jsonl';
|
|
42
40
|
const EVENTS = ['planned', 'set', 'moved', 'flagged', 'withdrawn', 'kept'];
|
|
@@ -268,7 +266,7 @@ function freshItem(rec) {
|
|
|
268
266
|
after: rec.after.slice(), start: rec.start, due: rec.due, milestone: rec.milestone, note: rec.note == null ? '' : rec.note,
|
|
269
267
|
state: 'todo', blocked: null, evidence: null, noEvidence: false, doneAt: null,
|
|
270
268
|
movedBy: null, movedVia: null, override: false, overrideShown: false,
|
|
271
|
-
proposed:
|
|
269
|
+
proposed: false, kept: false, // D98: an agent's item is live at once; nothing waits for a Keep
|
|
272
270
|
createdBy: rec.by, createdVia: rec.via, createdAt: rec.at,
|
|
273
271
|
updatedBy: rec.by, updatedVia: rec.via, updatedAt: rec.at,
|
|
274
272
|
history: [],
|
|
@@ -303,9 +301,10 @@ function applyLine(S, rec, n) {
|
|
|
303
301
|
}
|
|
304
302
|
if (rec.ev === 'kept') {
|
|
305
303
|
if (rec.via !== 'ui') { flag(S, 'kept-not-ui', rec, n, `a Keep line was written with via "${rec.via}", not from the workspace page — it has no effect`); return; }
|
|
306
|
-
if (!rec.by.startsWith('pm:')) { flag(S, 'kept-not-pm', rec, n, `a Keep line was written by ${rec.by}, not the PM — it has no effect`); return; }
|
|
307
304
|
for (const id of rec.items) {
|
|
308
305
|
const it = S.items.get(id);
|
|
306
|
+
// A Keep written before D98: the item is already live (agent items are no longer proposed), so it needs nothing.
|
|
307
|
+
if (it && !it.proposed && it.createdBy === rec.batch && it.initiative === rec.initiative) continue;
|
|
309
308
|
if (!it || !it.proposed || it.createdBy !== rec.batch || it.initiative !== rec.initiative) {
|
|
310
309
|
S.flags.push({ kind: 'kept-mismatch', line: n == null ? null : n, eid: rec.eid, item: id, initiative: rec.initiative,
|
|
311
310
|
message: `${id} is not a proposed item of ${rec.batch} on ${rec.initiative} — this part of the Keep has no effect` });
|
|
@@ -482,8 +481,6 @@ function actorFromCli(opts = {}) {
|
|
|
482
481
|
|
|
483
482
|
// ── the writer ────────────────────────────────────────────────────────────────────────────────────
|
|
484
483
|
const refuse = (status, error, index) => ({ ok: false, status, error, index: index == null ? null : index });
|
|
485
|
-
const PM_ITEM_HINT = 'this item is the PM\'s (owner you) — an agent does not change it; ask the PM';
|
|
486
|
-
const PM_MOVE_HINT = 'this item is the PM\'s (owner you) and the PM did not hand it to this session — ask the PM to hand it to you';
|
|
487
484
|
|
|
488
485
|
/** Does adding `from → each of after` make a loop in the predecessor graph of `items`? */
|
|
489
486
|
function makesLoop(items, from, after) {
|
|
@@ -505,7 +502,7 @@ function makesLoop(items, from, after) {
|
|
|
505
502
|
* The record's keys are emitted common-first, then the payload, in the order of the plan's §1.2.
|
|
506
503
|
*/
|
|
507
504
|
function buildRecord(ctx, ev, index) {
|
|
508
|
-
const { S, actor, allowKept, root, stagesCache, nextAt
|
|
505
|
+
const { S, actor, allowKept, root, stagesCache, nextAt } = ctx;
|
|
509
506
|
if (!ev || typeof ev !== 'object' || Array.isArray(ev)) return refuse(400, 'each line must be an object', index);
|
|
510
507
|
for (const k of WRITER_FIELDS) if (k in ev) return refuse(400, `field ${k} is set by the writer`, index);
|
|
511
508
|
if (!EVENTS.includes(ev.ev)) return refuse(400, `unknown event ${JSON.stringify(ev.ev)} — one of ${EVENTS.join(', ')}`, index);
|
|
@@ -529,8 +526,6 @@ function buildRecord(ctx, ev, index) {
|
|
|
529
526
|
Object.assign(rec, { initiative, by: actor.by, via: actor.via, at: nextAt(floor) });
|
|
530
527
|
return rec;
|
|
531
528
|
};
|
|
532
|
-
// R23 (X35): the PM's items (owner `you`) are the PM's to change. An agent asks; it does not set or flag them.
|
|
533
|
-
const agentOnPmItem = (it) => actor.by.startsWith('agent:') && it.owner === 'you';
|
|
534
529
|
const stagesOf = (initiative) => {
|
|
535
530
|
if (!stagesCache.has(initiative)) stagesCache.set(initiative, planTree.stagesFor(root, initiative));
|
|
536
531
|
return stagesCache.get(initiative);
|
|
@@ -539,7 +534,7 @@ function buildRecord(ctx, ev, index) {
|
|
|
539
534
|
const stages = stagesOf(initiative);
|
|
540
535
|
const want = String(v == null ? '' : v).toLowerCase().replace(/\s+/g, ' ').trim();
|
|
541
536
|
const hit = stages.find((s) => s.id === want || String(s.label).toLowerCase() === want);
|
|
542
|
-
if (!hit) return refuse(400, `unknown stage ${JSON.stringify(v)} — the stages of ${initiative} are ${stages.map((s) => s.id).join(', ')}`, index2);
|
|
537
|
+
if (!hit) return refuse(400, `unknown stage ${JSON.stringify(v)} — the stages of ${initiative} are ${stages.map((s) => s.id).join(', ')}. They group the breakdown; the initiative's workflow stage is pmos workflow of ${initiative}`, index2);
|
|
543
538
|
return { id: hit.id };
|
|
544
539
|
};
|
|
545
540
|
/* Only the predecessors a call ADDS are checked: an item whose predecessor was withdrawn later must still be able to
|
|
@@ -603,7 +598,6 @@ function buildRecord(ctx, ev, index) {
|
|
|
603
598
|
case 'set': {
|
|
604
599
|
const ex = existing(); if (ex.ok === false) return ex;
|
|
605
600
|
const { it, init } = ex;
|
|
606
|
-
if (agentOnPmItem(it)) return refuse(403, PM_ITEM_HINT, index);
|
|
607
601
|
const f = ev.fields;
|
|
608
602
|
if (!f || typeof f !== 'object' || Array.isArray(f) || !Object.keys(f).length) return refuse(400, 'fields must name at least one of ' + SET_FIELDS.join(', '), index);
|
|
609
603
|
const out = {};
|
|
@@ -629,7 +623,6 @@ function buildRecord(ctx, ev, index) {
|
|
|
629
623
|
const ex = existing(); if (ex.ok === false) return ex;
|
|
630
624
|
const { it, init } = ex;
|
|
631
625
|
if (!STATES.includes(ev.to)) return refuse(400, `to must be one of ${STATES.join(', ')}`, index);
|
|
632
|
-
if (agentOnPmItem(it) && !handedTo(it.id)) return refuse(403, PM_MOVE_HINT, index);
|
|
633
626
|
/* done → done with evidence attaches it to an item that reads Done without evidence: the way to correct an agent
|
|
634
627
|
* Done that forgot --evidence, from the CLI or the item sheet. Any other same-state move is refused. */
|
|
635
628
|
const attach = ev.to === 'done' && it.state === 'done' && ev.evidence != null && (it.noEvidence || !it.evidence);
|
|
@@ -652,7 +645,6 @@ function buildRecord(ctx, ev, index) {
|
|
|
652
645
|
case 'flagged': {
|
|
653
646
|
const ex = existing(); if (ex.ok === false) return ex;
|
|
654
647
|
const { it, init } = ex;
|
|
655
|
-
if (agentOnPmItem(it)) return refuse(403, PM_ITEM_HINT, index);
|
|
656
648
|
if (ev.blocked === true) {
|
|
657
649
|
if (!oneLine(ev.reason, 200)) return refuse(400, 'a block reason is 1 to 200 characters on one line', index);
|
|
658
650
|
const rec = common(init, it.id, it.updatedAt);
|
|
@@ -670,11 +662,7 @@ function buildRecord(ctx, ev, index) {
|
|
|
670
662
|
}
|
|
671
663
|
case 'withdrawn': {
|
|
672
664
|
const ex = existing(); if (ex.ok === false) return ex;
|
|
673
|
-
|
|
674
|
-
* The PM's items, and another session's, are the PM's to withdraw. */
|
|
675
|
-
if (actor.by.startsWith('agent:') && ex.it.createdBy !== actor.by) {
|
|
676
|
-
return refuse(403, 'an agent withdraws only the items it planned — the PM withdraws the rest', index);
|
|
677
|
-
}
|
|
665
|
+
// D98: any actor withdraws any item; the line names who did it.
|
|
678
666
|
return { rec: common(ex.init, ex.it.id, ex.it.updatedAt) };
|
|
679
667
|
}
|
|
680
668
|
case 'kept': {
|
|
@@ -714,7 +702,7 @@ function parseEvidence(s) {
|
|
|
714
702
|
return { kind: m[1], ref: m[2] };
|
|
715
703
|
}
|
|
716
704
|
|
|
717
|
-
function append(root, events, actor, { now, allowKept
|
|
705
|
+
function append(root, events, actor, { now, allowKept }) {
|
|
718
706
|
if (!Array.isArray(events) || !events.length) return refuse(400, 'send at least one line', null);
|
|
719
707
|
if (events.length > MAX_LINES) return refuse(413, `send at most ${MAX_LINES} lines at once`, null);
|
|
720
708
|
let read;
|
|
@@ -744,7 +732,7 @@ function append(root, events, actor, { now, allowKept, handedTo = () => false })
|
|
|
744
732
|
last = t;
|
|
745
733
|
return new Date(t).toISOString();
|
|
746
734
|
};
|
|
747
|
-
const ctx = { S, actor, allowKept, root, stagesCache: new Map(), nextAt
|
|
735
|
+
const ctx = { S, actor, allowKept, root, stagesCache: new Map(), nextAt };
|
|
748
736
|
const recs = [];
|
|
749
737
|
for (let i = 0; i < events.length; i++) {
|
|
750
738
|
let r;
|
|
@@ -772,37 +760,20 @@ function append(root, events, actor, { now, allowKept, handedTo = () => false })
|
|
|
772
760
|
|
|
773
761
|
/**
|
|
774
762
|
* The workspace page's route. The only path that accepts `kept`. The route passes the actor lib/pm-guard.js answered;
|
|
775
|
-
* with none, actor.fromUi().
|
|
763
|
+
* with none, actor.fromUi(). D98: an agent session's call through the route keeps its own `by`; the line says `ui`.
|
|
776
764
|
*/
|
|
777
765
|
function appendFromUi(root, events, { now, actor } = {}) {
|
|
778
766
|
const who = actor === undefined ? actorLib.fromUi() : actor;
|
|
779
|
-
if (!actorLib.
|
|
767
|
+
if (!actorLib.valid(who)) return refuse(403, 'the page writes only after the guard', null);
|
|
780
768
|
return append(root, events, { by: who.by, via: 'ui' }, { now, allowKept: true });
|
|
781
769
|
}
|
|
782
770
|
/** `pmos item`. The actor comes from the terminal and PMOS_SESSION, never from an argument. Refuses `kept`. */
|
|
783
|
-
function appendFromCli(root, events, { now, isTTY, env
|
|
771
|
+
function appendFromCli(root, events, { now, isTTY, env } = {}) {
|
|
784
772
|
const opts = {};
|
|
785
773
|
if (isTTY !== undefined) opts.isTTY = isTTY;
|
|
786
774
|
if (env !== undefined) opts.env = env;
|
|
787
775
|
const who = actorFromCli(opts);
|
|
788
|
-
return append(root, events, who, { now, allowKept: false
|
|
789
|
-
}
|
|
790
|
-
/**
|
|
791
|
-
* itemId → true when the PM handed that item to the actor's session (R23). The session meta lives in the workspace's
|
|
792
|
-
* runtime state (`<state root>/sessions`), resolved from the environment the way the server resolves it; a test passes
|
|
793
|
-
* `sessDir`. The meta is read at most once per call.
|
|
794
|
-
*/
|
|
795
|
-
function handedToSession(who, env, sessDir) {
|
|
796
|
-
const token = actorLib.sessionOf(who);
|
|
797
|
-
if (!token) return () => false;
|
|
798
|
-
let s;
|
|
799
|
-
return (itemId) => {
|
|
800
|
-
if (s === undefined) {
|
|
801
|
-
const dir = sessDir || path.join(stateRoot.defaultRoot({ env: env || process.env }), 'sessions');
|
|
802
|
-
s = actorLib.sessionForToken(token, { sessDir: dir });
|
|
803
|
-
}
|
|
804
|
-
return !!s && s.plan_item === itemId;
|
|
805
|
-
};
|
|
776
|
+
return append(root, events, who, { now, allowKept: false });
|
|
806
777
|
}
|
|
807
778
|
|
|
808
779
|
// ── needs-you rows (Keep cards, agent Done with no evidence, forged Keep lines) ─────────────────────
|
|
@@ -823,11 +794,9 @@ function needsFor(root, { now } = {}) {
|
|
|
823
794
|
question: `"${it.title}" reads Done with no evidence`, doc: null, item: id });
|
|
824
795
|
}
|
|
825
796
|
for (const f of r.flags) {
|
|
826
|
-
if (f.kind !== 'kept-not-ui'
|
|
797
|
+
if (f.kind !== 'kept-not-ui') continue;
|
|
827
798
|
rows.push({ run_id: `plan-flag:${f.eid}`, initiative_id: f.initiative, kind: 'plan-flag', derived: true,
|
|
828
|
-
question:
|
|
829
|
-
? 'A Keep line in plan-items.jsonl was not written from the workspace page. It has no effect.'
|
|
830
|
-
: 'A Keep line in plan-items.jsonl was not written by the PM. It has no effect.',
|
|
799
|
+
question: 'A Keep line in plan-items.jsonl was not written from the workspace page. It has no effect.',
|
|
831
800
|
doc: null, flag: { kind: f.kind, eid: f.eid, line: f.line } });
|
|
832
801
|
}
|
|
833
802
|
return rows;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
/* pm-guard.js — THE GUARDED WRITER'S FRONT DOOR: every act
|
|
3
|
-
* R25, D86 point 2).
|
|
2
|
+
/* pm-guard.js — THE GUARDED WRITER'S FRONT DOOR: every act that was PM-only passes here first (pm-os-absorb, PRD
|
|
3
|
+
* R25, D86 point 2, amended by D98).
|
|
4
|
+
*
|
|
5
|
+
* D98: an agent session finishes the work it was asked to do. It may take every act below without a typed
|
|
6
|
+
* confirmation, and the guard answers with the agent's own actor, so every line it writes says `by: agent:…` and the PM
|
|
7
|
+
* sees who acted and can return or undo it. What stays: the Origin and launch-nonce checks (another website cannot
|
|
8
|
+
* write), the writer fields, and the PM's own typed confirmation at a terminal.
|
|
4
9
|
*
|
|
5
10
|
* requirePmPress(req, body, { act }) → { ok: true, actor } | { ok: false, status, error }
|
|
6
11
|
* requirePmCli({ act, expect, isTTY, env, ask }) → Promise of the same shape
|
|
@@ -33,8 +38,10 @@
|
|
|
33
38
|
* another port, so another launch): 403. A socket request with no Host header is refused too, because there is
|
|
34
39
|
* nothing to match. Only a caller with no socket and no Host (a unit test's plain object) skips the Host match;
|
|
35
40
|
* - once server.js has called setLaunchNonce, a missing or wrong x-pmos-nonce header: 403.
|
|
36
|
-
* The terminal side
|
|
37
|
-
* that does not match
|
|
41
|
+
* The terminal side lets an agent session through at once with its own actor (D98). The PM at a terminal types `expect`;
|
|
42
|
+
* a typed text that does not match is 403, and with no `ask` function there is no way to confirm, so it is refused (X12).
|
|
43
|
+
* A request that carries an `x-pmos-session` token (an agent's hook or curl) and passes the Origin and nonce checks is
|
|
44
|
+
* answered with that agent's actor, never the PM's.
|
|
38
45
|
*
|
|
39
46
|
* RESIDUAL (named, not closed). A process that runs as the PM's own user can read the nonce from GET / and send it with
|
|
40
47
|
* an Origin that matches. A process that fakes a terminal (`script`) and types the expected id is the PM to this file.
|
|
@@ -73,6 +80,7 @@ const ACT_PHRASE = Object.freeze({
|
|
|
73
80
|
const WRITER_FIELDS = Object.freeze(['v', 'eid', 'by', 'via', 'at', 'override', 'pm', 'actor', 'nonce', 'grant']);
|
|
74
81
|
|
|
75
82
|
const NONCE_HEADER = 'x-pmos-nonce';
|
|
83
|
+
const SESSION_HEADER = 'x-pmos-session';
|
|
76
84
|
const NONCE_META = 'pmos-nonce';
|
|
77
85
|
let NONCE = '';
|
|
78
86
|
/** server.js calls this once at start (2A). The value never goes into a PTY environment or a log (D08). */
|
|
@@ -109,6 +117,10 @@ function pageChecks(req, who) {
|
|
|
109
117
|
// A wrong value is almost always a page from an earlier start of the workspace; a missing one is not the page at all.
|
|
110
118
|
if (NONCE && !h[NONCE_HEADER]) return refuse(403, `${who}; this request does not come from the workspace page`);
|
|
111
119
|
if (NONCE && h[NONCE_HEADER] !== NONCE) return refuse(403, `${who}; the workspace restarted, so reload the page, then try again`);
|
|
120
|
+
// D98: an agent session's call is allowed and keeps the agent's name on the line it writes.
|
|
121
|
+
const tok = Array.isArray(h[SESSION_HEADER]) ? h[SESSION_HEADER][0] : h[SESSION_HEADER];
|
|
122
|
+
// A header that is not a well-formed token is still an agent's call: it is agent:unknown, never the PM.
|
|
123
|
+
if (typeof tok === 'string' && tok) return { ok: true, actor: { by: actor.SESSION_RE.test(tok) ? `agent:${tok}` : 'agent:unknown', via: 'ui' } };
|
|
112
124
|
return { ok: true, actor: actor.fromUi() };
|
|
113
125
|
}
|
|
114
126
|
|
|
@@ -149,7 +161,8 @@ async function requirePmCli({ act, expect, isTTY, env, ask } = {}) {
|
|
|
149
161
|
if (!knownAct(act)) return refuse(500, `pm-guard: ${JSON.stringify(act)} is not a PM-only act`);
|
|
150
162
|
if (typeof expect !== 'string' || !expect.trim()) return refuse(500, 'pm-guard: a PM-only verb needs the text the PM must type');
|
|
151
163
|
const who = actor.fromCli({ isTTY, env });
|
|
152
|
-
|
|
164
|
+
// D98: an agent does what it was asked, with no typed confirmation; the line it writes names the agent.
|
|
165
|
+
if (actor.isAgent(who)) return { ok: true, actor: who };
|
|
153
166
|
if (!actor.isPm(who)) return refuse(403, `only the PM can ${ACT_PHRASE[act]}, at an interactive terminal`);
|
|
154
167
|
if (typeof ask !== 'function') return refuse(403, `to ${ACT_PHRASE[act]}, type a confirmation at the terminal`);
|
|
155
168
|
let typed;
|
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
* grant-mismatch a PM-only line that cites a grant that does not cover it: a lifecycle line needs a lifecycle-bulk
|
|
15
15
|
* grant whose target names its state and its initiative, and every line's `at` falls inside the grant's
|
|
16
16
|
* window (at to expires_at). A copied id of a merge grant, or of another batch, is flagged;
|
|
17
|
-
* not-pm a
|
|
18
|
-
*
|
|
17
|
+
* not-pm a line in a D86 ledger whose `by` names neither the PM nor an agent session (D98 lets an agent write
|
|
18
|
+
* these lines; its `by` is the record of who acted);
|
|
19
|
+
* agent-commit a line that claims the PM (not an agent's own `by`, D98) and arrived in an agent-authored commit (a Co-Authored-By trailer that names an agent,
|
|
19
20
|
* a session trailer, or an agent's address). This catches a line written by a script and then committed
|
|
20
21
|
* (bypass e) and a patch applied with `git apply` (bypass f).
|
|
21
22
|
* agent-basis an agent's acceptance (D87) that the Review Gate does not back: no eval row for its run, a verdict that
|
|
@@ -256,10 +257,13 @@ function scan(root, { runsDir, rules, rulesFile, now = Date.now(), arrival = tru
|
|
|
256
257
|
const why = grantMismatch(src.ledger, rec, grants.get(cites));
|
|
257
258
|
if (why) say('grant-mismatch', `${what[src.ledger](rec)} cites a grant that does not cover it`, why);
|
|
258
259
|
}
|
|
259
|
-
|
|
260
|
-
|
|
260
|
+
// D98: an agent session may write these lines; its `by` is the record of who acted, so it is not flagged.
|
|
261
|
+
if (D86.has(src.ledger) && typeof rec.by === 'string' && !/^(?:pm|agent):/.test(rec.by)) {
|
|
262
|
+
say('not-pm', `${what[src.ledger](rec)} names no PM or agent session`, 'a line whose by is neither the PM nor an agent session');
|
|
261
263
|
}
|
|
262
|
-
|
|
264
|
+
// An agent's own line (D98) arrives in an agent's commit by design; a line that claims the PM there is still flagged.
|
|
265
|
+
const ownAgentLine = typeof rec.by === 'string' && rec.by.startsWith('agent:');
|
|
266
|
+
if (a && !a.boundary && a.agent && !isOlder && !ownAgentLine) {
|
|
263
267
|
say('agent-commit', `${what[src.ledger](rec)} arrived in an agent-authored commit`, `arrived in the agent-authored commit ${a.sha.slice(0, 8)}`);
|
|
264
268
|
}
|
|
265
269
|
if (isOlder && viaMissing && src.viaChecked) olderCount++;
|
|
@@ -64,7 +64,7 @@ const VERBS = Object.freeze({
|
|
|
64
64
|
help: 'pmos lead put|show|due — Claude\'s short lead for a popup, written ahead from stored reads (pmos lead help)' }),
|
|
65
65
|
// Not a pm-os-absorb verb (run: null): workflows-per-initiative (D99) added it through the same table.
|
|
66
66
|
workflow: Object.freeze({ module: 'workflow-cli.js', run: null, guide: 'workflows.md',
|
|
67
|
-
help: 'pmos workflow list|show|draft|show-draft|judge … — the workflows of this repository, the New workflow draft,
|
|
67
|
+
help: 'pmos workflow list|show|draft|show-draft|judge|of|move|switch … — the workflows of this repository, the New workflow draft, a reading of an Only-when stage, and an initiative\'s workflow stage (pmos workflow help)' }),
|
|
68
68
|
// Not a pm-os-absorb verb (run: null): c3-meet-extension added it through the same table.
|
|
69
69
|
extension: Object.freeze({ module: 'extension-cli.js', run: null, guide: 'console-calendar.md',
|
|
70
70
|
help: 'pmos extension — the folder of the Chrome extension for Google Meet, and the three steps to load it' }),
|
|
@@ -16,7 +16,7 @@ const isAsk = (text) => ASK_RE.test(String(text == null ? '' : text)) && !String
|
|
|
16
16
|
|
|
17
17
|
const RULE = [
|
|
18
18
|
'PMOS has programs. A program is the level above initiatives (Program > Initiative > Epic) and can span products. It has no stages of its own: its state, products and stage spread come from its initiatives.',
|
|
19
|
-
'A program is a record in programs.jsonl in a workspace state folder (pmos/state/ or the workspace state folder), one JSON line each: {"kind":"program",…} is the charter, {"kind":"member","program":"<id>","initiative":"<id>"} puts an initiative in it, and "leave", "task", "check" and "archive" lines follow the same pattern. A program id is its title in lower case with dashes, for example project-ascent.',
|
|
19
|
+
'A program is a record in programs.jsonl in a workspace state folder (pmos/state/ or the workspace state folder), one JSON line each: {"kind":"program",…} is the charter, {"kind":"member","program":"<id>","initiative":"<id>"} puts an initiative in it, and "leave", "task", "check", "order" (the PM\'s sequence of its initiatives) and "archive" lines follow the same pattern. A program id is its title in lower case with dashes, for example project-ascent.',
|
|
20
20
|
'A program is NOT a key on an initiative. Never add kind, program, programme, parent_program or parent_programme to an initiative record or any front matter: nothing reads them.',
|
|
21
21
|
'You never make, change, join, leave or archive a program yourself, and you never write programs.jsonl: the routes refuse an agent session, and the PM presses on the Board.',
|
|
22
22
|
'Tell the PM which press does what they asked:',
|