create-pmos 0.820.0 → 0.821.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 +10 -3
- 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/workflows.js +26 -6
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +9 -2
- package/workspace/guide/cli.md +3 -0
- package/workspace/lib/driver.js +2 -0
- package/workspace/lib/engine/workflows.js +26 -6
- package/workspace/lib/line-driver.js +40 -12
- package/workspace/lib/line.js +30 -8
- package/workspace/lib/pmos-verbs.js +1 -1
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-boards.js +1 -1
- package/workspace/lib/routes-stage-signoffs.js +71 -0
- package/workspace/lib/routes-your-move.js +10 -1
- package/workspace/lib/signoff-cli.js +13 -3
- package/workspace/lib/signoffs.js +24 -4
- package/workspace/lib/stage-signoffs.js +207 -0
- package/workspace/lib/vendor/scripts/workflows.js +26 -6
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-today-app.js +61 -1
- package/workspace/public/pm/cozy-today-model.js +20 -4
- package/workspace/public/pm/cozy-today-view.js +17 -2
- package/workspace/public/pm/home-app.js +1 -1
- package/workspace/test-lists/factory-signoffs-reach-you.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.821.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
36
|
{
|
|
37
|
-
"v": "0.
|
|
38
|
-
"at": "2026-11-25T09:
|
|
37
|
+
"v": "0.821.0",
|
|
38
|
+
"at": "2026-11-25T09:15:25.533Z",
|
|
39
39
|
"f": 4,
|
|
40
40
|
"prs": [
|
|
41
41
|
{
|
|
@@ -54,6 +54,13 @@
|
|
|
54
54
|
"open": "/today.html"
|
|
55
55
|
},
|
|
56
56
|
"i": "next-hire-draft"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"n": 1869,
|
|
60
|
+
"t": "A stage's sign-offs reach You on Today (job #1861, Factory page slice A)",
|
|
61
|
+
"s": "A stage's sign-offs reach You on Today (job #1861, Factory page slice A)",
|
|
62
|
+
"k": "new",
|
|
63
|
+
"i": "factory-signoffs-reach-you"
|
|
57
64
|
}
|
|
58
65
|
]
|
|
59
66
|
},
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-25T09:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-25T09:15:20Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-25T09:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-25T09:15:20Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
* A WORKFLOW is { id, name, icon, builtin?, decide, archived?, stages: [STAGE], bridge? }.
|
|
23
23
|
* bridge { from, map: { [fromStageKey]: stageKey } }: where each stage of the workflow it replaces lands (batch 20 item 3, canvas WmB).
|
|
24
24
|
* It is saved with the new workflow, so every later switch from `from` uses it. Many old stages may land in one new stage.
|
|
25
|
-
* A STAGE is { key, name, cat, output: { name, kind, template? }, finish: [text], milestone, auto, when: { mode, text? }, then, unless: [{ text, to }] }.
|
|
25
|
+
* A STAGE is { key, name, cat, output: { name, kind, template? }, finish: [text], by?, milestone, auto, when: { mode, text? }, then, unless: [{ text, to }] }.
|
|
26
|
+
* by { [finish line]: who }: the To finish lines only a person can give, and who gives each (factory-signoffs-reach-you). A line with
|
|
27
|
+
* `by` is a sign-off: PMOS asks for it and never works it. A line may be written "PRD Aligned (by: PM)"; check() splits it.
|
|
26
28
|
* cat ∈ CATS (To do, In progress, Done). Won't do and Archived (ENDS) are in every workflow and are not stages.
|
|
27
29
|
* The first stage is always `triage`, in To do. `then` null means the next stage in the list. `unless` sends the initiative elsewhere
|
|
28
30
|
* when PMOS judges its plain words true. A key is the slug of the stage's first name and survives a rename.
|
|
@@ -45,7 +47,16 @@ const WHEN_MODES = Object.freeze(['always', 'optional', 'only']);
|
|
|
45
47
|
const DECIDE = Object.freeze(['pmos', 'confirm']);
|
|
46
48
|
const ICONS = Object.freeze(['feature', 'doc', 'cart', 'swap', 'people', 'shield', 'box', 'flag', 'build', 'chart']);
|
|
47
49
|
const PRODUCT_FEATURE_ID = 'product-feature';
|
|
48
|
-
const NAME_MAX = 60, TEXT_MAX = 300, FINISH_MAX = 20, STAGES_MAX = 30;
|
|
50
|
+
const NAME_MAX = 60, TEXT_MAX = 300, FINISH_MAX = 20, STAGES_MAX = 30, BY_MAX = 80;
|
|
51
|
+
// "PRD Aligned (by: PM)" or "PRD Aligned — by: PM": the line and who signs it off
|
|
52
|
+
const BY_IN_LINE = /\s*(?:\(\s*by:\s*([^()]+?)\s*\)|[—–-]+\s*by:\s*(.+?))\s*$/i;
|
|
53
|
+
/** A To finish line written with its sign-off: → { line, by } (by '' when the line names nobody). PURE. */
|
|
54
|
+
function splitBy(text) {
|
|
55
|
+
const t = String(text == null ? '' : text).trim();
|
|
56
|
+
const m = BY_IN_LINE.exec(t);
|
|
57
|
+
if (!m || m.index === 0) return { line: t, by: '' };
|
|
58
|
+
return { line: t.slice(0, m.index).trim(), by: String(m[1] || m[2] || '').trim() };
|
|
59
|
+
}
|
|
49
60
|
|
|
50
61
|
const slug = (s) => String(s || '').toLowerCase().normalize('NFKD').replace(/[^\x00-\x7f]/g, '').replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40).replace(/-+$/, '');
|
|
51
62
|
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
@@ -143,6 +154,15 @@ function check(wf) {
|
|
|
143
154
|
if (o.template != null && o.template !== '' && !oneLine(o.template, 120)) return bad(`stage "${sname}": the template is one line of at most 120 characters`);
|
|
144
155
|
const finish = s.finish == null ? [] : s.finish;
|
|
145
156
|
if (!Array.isArray(finish) || finish.length > FINISH_MAX || finish.some((x) => !oneLine(x, 200))) return bad(`stage "${sname}": To finish is a list of at most ${FINISH_MAX} lines of at most 200 characters`);
|
|
157
|
+
const by = {};
|
|
158
|
+
const lines = finish.map((x) => { const sp = splitBy(x); if (sp.by) by[sp.line] = sp.by; return sp.line; });
|
|
159
|
+
if (s.by != null && !isObj(s.by)) return bad(`stage "${sname}": by is { "<To finish line>": "<who signs it off>" }`);
|
|
160
|
+
for (const [k, v] of Object.entries(s.by || {})) {
|
|
161
|
+
if (!lines.includes(String(k).trim())) return bad(`stage "${sname}": by names "${k}", which is not one of its To finish lines`);
|
|
162
|
+
if (v == null || v === '') continue;
|
|
163
|
+
if (!oneLine(v, BY_MAX) || !/\p{L}/u.test(v)) return bad(`stage "${sname}": who signs off "${k}" is a person or a role, one line of at most ${BY_MAX} characters`);
|
|
164
|
+
if (!by[String(k).trim()]) by[String(k).trim()] = v.trim();
|
|
165
|
+
}
|
|
146
166
|
const w = isObj(s.when) ? s.when : { mode: 'always' };
|
|
147
167
|
if (!WHEN_MODES.includes(w.mode)) return bad(`stage "${sname}": When it runs is one of ${WHEN_MODES.join(', ')}`);
|
|
148
168
|
if (w.mode === 'only' && !oneLine(w.text, TEXT_MAX)) return bad(`stage "${sname}": Only when needs the condition in your words (at most ${TEXT_MAX} characters)`);
|
|
@@ -152,7 +172,7 @@ function check(wf) {
|
|
|
152
172
|
stages.push({
|
|
153
173
|
key, name: sname, cat: s.cat,
|
|
154
174
|
output: { name: o.name ? o.name.trim() : '', kind, ...(o.template ? { template: o.template.trim() } : {}) },
|
|
155
|
-
finish:
|
|
175
|
+
finish: lines, ...(Object.keys(by).length ? { by } : {}), milestone: s.milestone === true, auto: s.auto === true,
|
|
156
176
|
when: w.mode === 'only' ? { mode: 'only', text: w.text.trim() } : { mode: w.mode },
|
|
157
177
|
then: typeof s.then === 'string' && s.then ? s.then : null,
|
|
158
178
|
unless: unless.map((u) => ({ text: u.text.trim(), to: u.to })),
|
|
@@ -338,7 +358,7 @@ function stagesOf(wf, { judged = {}, current = null } = {}) {
|
|
|
338
358
|
const j = judged && judged[s.key] ? judged[s.key] : null;
|
|
339
359
|
const skipped = !!j && j.runs === false;
|
|
340
360
|
const status = skipped ? 'skipped' : at < 0 ? (i === 0 ? 'current' : 'next') : i < at ? 'done' : i === at ? 'current' : 'next';
|
|
341
|
-
return { key: s.key, name: s.name, cat: s.cat, milestone: s.milestone, auto: s.auto, output: s.output, finish: s.finish, when: s.when,
|
|
361
|
+
return { key: s.key, name: s.name, cat: s.cat, milestone: s.milestone, auto: s.auto, output: s.output, finish: s.finish, ...(s.by ? { by: { ...s.by } } : {}), when: s.when,
|
|
342
362
|
then: s.then, unless: s.unless, n: i + 1, of: w.stages.length, status, reading: j ? { runs: j.runs, why: j.why || '', cite: j.cite || null } : null };
|
|
343
363
|
});
|
|
344
364
|
}
|
|
@@ -348,7 +368,7 @@ function copyOf(wf, name, taken) {
|
|
|
348
368
|
const n = oneLine(name, NAME_MAX) ? name.trim() : 'Copy of ' + wf.name;
|
|
349
369
|
let id = slug(n) || 'workflow', k = 2;
|
|
350
370
|
while ((taken && taken.has(id)) || isBuiltin(id)) id = slug(n) + '-' + k++;
|
|
351
|
-
return { id, name: n, icon: wf.icon, decide: wf.decide || 'pmos', ...(WORK_KINDS.includes(wf.kind) ? { kind: wf.kind } : {}), stages: wf.stages.map((s) => ({ ...s, output: { ...s.output }, finish: [...s.finish], when: { ...s.when }, unless: s.unless.map((u) => ({ ...u })) })) };
|
|
371
|
+
return { id, name: n, icon: wf.icon, decide: wf.decide || 'pmos', ...(WORK_KINDS.includes(wf.kind) ? { kind: wf.kind } : {}), stages: wf.stages.map((s) => ({ ...s, output: { ...s.output }, finish: [...s.finish], ...(s.by ? { by: { ...s.by } } : {}), when: { ...s.when }, unless: s.unless.map((u) => ({ ...u })) })) };
|
|
352
372
|
}
|
|
353
373
|
|
|
354
374
|
/** The workflow a kind of work starts on: Project and Full SDLC their own; Product management the workspace's default (defaultOf). */
|
|
@@ -370,5 +390,5 @@ const milestonesOf = (wf) => (wf || PRODUCT_FEATURE).stages.filter((s) => s.mile
|
|
|
370
390
|
module.exports = {
|
|
371
391
|
CATS, CAT_LABEL, ENDS, OUTPUT_KINDS, WHEN_MODES, DECIDE, ICONS, PRODUCT_FEATURE_ID, PRODUCT_FEATURE,
|
|
372
392
|
PROJECT_ID, PROJECT, FULL_SDLC_ID, FULL_SDLC, BUILTIN, KIND_WF, KIND_GATE, MEANING, isBuiltin, forKind, isKindDefault,
|
|
373
|
-
WORK_KINDS, kindOf, slug, check, fold, list, defaultOf, resolve, stageByRef, switchTarget, proposeBridge, mapOf, removedInUse, stagesOf, copyOf, milestonesOf,
|
|
393
|
+
WORK_KINDS, kindOf, slug, check, fold, list, defaultOf, resolve, stageByRef, switchTarget, proposeBridge, mapOf, removedInUse, stagesOf, copyOf, milestonesOf, splitBy,
|
|
374
394
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-25T09:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-25T09:15:20Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"v": "0.
|
|
4
|
-
"at": "2026-11-25T09:
|
|
3
|
+
"v": "0.821.0",
|
|
4
|
+
"at": "2026-11-25T09:15:25.533Z",
|
|
5
5
|
"f": 4,
|
|
6
6
|
"prs": [
|
|
7
7
|
{
|
|
@@ -20,6 +20,13 @@
|
|
|
20
20
|
"open": "/today.html"
|
|
21
21
|
},
|
|
22
22
|
"i": "next-hire-draft"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"n": 1869,
|
|
26
|
+
"t": "A stage's sign-offs reach You on Today (job #1861, Factory page slice A)",
|
|
27
|
+
"s": "A stage's sign-offs reach You on Today (job #1861, Factory page slice A)",
|
|
28
|
+
"k": "new",
|
|
29
|
+
"i": "factory-signoffs-reach-you"
|
|
23
30
|
}
|
|
24
31
|
]
|
|
25
32
|
},
|
package/workspace/guide/cli.md
CHANGED
|
@@ -971,10 +971,13 @@ An outside sign-off is a yes that someone outside the team must give before the
|
|
|
971
971
|
- `pmos signoff ask <initiative> --who "<name or team>" --what "<what they must say yes to>" [--asked <date>] [--due <date>] [--source <pointer>]` records a sign-off the initiative waits on.
|
|
972
972
|
- `pmos signoff answer <id> --answer "<what they said>" --source <pointer>` records the answer. It needs a pointer to where it was given.
|
|
973
973
|
- `pmos signoff drop <id> [--why "<reason>"]` closes a sign-off that is no longer needed.
|
|
974
|
+
- `pmos signoff evidence <id> --ref <file or Jira key> --quote "<the line, word for word>" [--doc <the document it agrees to>]` records where the yes is written. It also says whether Today can record it.
|
|
974
975
|
- `pmos signoff list [<initiative>] [--all]` lists the open sign-offs. `--all` lists the answered and dropped ones too.
|
|
975
976
|
|
|
976
977
|
An open sign-off that waited 3 days, or is past its due date, goes on your question list for the day, on the same card as the dry-run gaps of your tickets ([Jira tickets](jira.md)). Nothing is sent. Every command takes `--json` and `--root <dir>`.
|
|
977
978
|
|
|
979
|
+
A workflow stage can name its own sign-offs. Write a To finish line as `PRD Aligned (by: PM)`, or give the stage `"by": { "PRD Aligned": "PM" }`. A line with `by:` is a sign-off: PMOS asks for it and never works it, and the Driver does not wake for it. Each open one is a Your move row on Today, with who gives it and the stage that waits. ✓ records it only when its source has the quoted line and is newer than the document it agrees to. Otherwise the row opens the source. A row with no source drafts the question for the tracker, and it goes to the outbox only when you press it. Recording the last missing sign-off moves the stage in the same press, and one Undo puts both back. A workflow with no `by:` lines gets one ✦ row per stage that suggests them, with Keep or Change.
|
|
980
|
+
|
|
978
981
|
### pmos approver
|
|
979
982
|
|
|
980
983
|
Walk into a sign-off with what that person asked last time. PMOS reads the sign-offs above and the decision journal, and groups what each approver had to say yes to, what they answered, and what they objected to. It writes nothing.
|
package/workspace/lib/driver.js
CHANGED
|
@@ -434,6 +434,8 @@ function detect(facts, state, { now, stalledDays } = {}) {
|
|
|
434
434
|
if (i.last_activity != null && t - i.last_activity >= stall) b('stalled', 'agent', null, `Nothing changed for ${Math.floor((t - i.last_activity) / DAY)} days`);
|
|
435
435
|
// product line slice 3 (lib/line-driver.js): the station's missing exit items, as `pmos line` reads them, wake the Driver to work them
|
|
436
436
|
{ const x = require('./line-driver.js').blockerOf(i.exit, state, { now: t }); if (x) { add(target, i.board || null, title, x.code, 'agent', i.cat || null, x.text, iniKey(i, x.key)); out[out.length - 1].exit = x.items; } }
|
|
437
|
+
// factory-signoffs-reach-you: the stage's missing sign-offs are the PM's blocker, never an agent wake (Today › Your move asks for them)
|
|
438
|
+
{ const x = require('./line-driver.js').signoffBlockerOf(i.exit); if (x) { b('signoff-missing', 'pm', i.cat || null, x.text); out[out.length - 1].exit = x.items; } }
|
|
437
439
|
}
|
|
438
440
|
for (const w of facts.work || []) {
|
|
439
441
|
if (!w || w.done) continue;
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
* A WORKFLOW is { id, name, icon, builtin?, decide, archived?, stages: [STAGE], bridge? }.
|
|
23
23
|
* bridge { from, map: { [fromStageKey]: stageKey } }: where each stage of the workflow it replaces lands (batch 20 item 3, canvas WmB).
|
|
24
24
|
* It is saved with the new workflow, so every later switch from `from` uses it. Many old stages may land in one new stage.
|
|
25
|
-
* A STAGE is { key, name, cat, output: { name, kind, template? }, finish: [text], milestone, auto, when: { mode, text? }, then, unless: [{ text, to }] }.
|
|
25
|
+
* A STAGE is { key, name, cat, output: { name, kind, template? }, finish: [text], by?, milestone, auto, when: { mode, text? }, then, unless: [{ text, to }] }.
|
|
26
|
+
* by { [finish line]: who }: the To finish lines only a person can give, and who gives each (factory-signoffs-reach-you). A line with
|
|
27
|
+
* `by` is a sign-off: PMOS asks for it and never works it. A line may be written "PRD Aligned (by: PM)"; check() splits it.
|
|
26
28
|
* cat ∈ CATS (To do, In progress, Done). Won't do and Archived (ENDS) are in every workflow and are not stages.
|
|
27
29
|
* The first stage is always `triage`, in To do. `then` null means the next stage in the list. `unless` sends the initiative elsewhere
|
|
28
30
|
* when PMOS judges its plain words true. A key is the slug of the stage's first name and survives a rename.
|
|
@@ -45,7 +47,16 @@ const WHEN_MODES = Object.freeze(['always', 'optional', 'only']);
|
|
|
45
47
|
const DECIDE = Object.freeze(['pmos', 'confirm']);
|
|
46
48
|
const ICONS = Object.freeze(['feature', 'doc', 'cart', 'swap', 'people', 'shield', 'box', 'flag', 'build', 'chart']);
|
|
47
49
|
const PRODUCT_FEATURE_ID = 'product-feature';
|
|
48
|
-
const NAME_MAX = 60, TEXT_MAX = 300, FINISH_MAX = 20, STAGES_MAX = 30;
|
|
50
|
+
const NAME_MAX = 60, TEXT_MAX = 300, FINISH_MAX = 20, STAGES_MAX = 30, BY_MAX = 80;
|
|
51
|
+
// "PRD Aligned (by: PM)" or "PRD Aligned — by: PM": the line and who signs it off
|
|
52
|
+
const BY_IN_LINE = /\s*(?:\(\s*by:\s*([^()]+?)\s*\)|[—–-]+\s*by:\s*(.+?))\s*$/i;
|
|
53
|
+
/** A To finish line written with its sign-off: → { line, by } (by '' when the line names nobody). PURE. */
|
|
54
|
+
function splitBy(text) {
|
|
55
|
+
const t = String(text == null ? '' : text).trim();
|
|
56
|
+
const m = BY_IN_LINE.exec(t);
|
|
57
|
+
if (!m || m.index === 0) return { line: t, by: '' };
|
|
58
|
+
return { line: t.slice(0, m.index).trim(), by: String(m[1] || m[2] || '').trim() };
|
|
59
|
+
}
|
|
49
60
|
|
|
50
61
|
const slug = (s) => String(s || '').toLowerCase().normalize('NFKD').replace(/[^\x00-\x7f]/g, '').replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40).replace(/-+$/, '');
|
|
51
62
|
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
@@ -143,6 +154,15 @@ function check(wf) {
|
|
|
143
154
|
if (o.template != null && o.template !== '' && !oneLine(o.template, 120)) return bad(`stage "${sname}": the template is one line of at most 120 characters`);
|
|
144
155
|
const finish = s.finish == null ? [] : s.finish;
|
|
145
156
|
if (!Array.isArray(finish) || finish.length > FINISH_MAX || finish.some((x) => !oneLine(x, 200))) return bad(`stage "${sname}": To finish is a list of at most ${FINISH_MAX} lines of at most 200 characters`);
|
|
157
|
+
const by = {};
|
|
158
|
+
const lines = finish.map((x) => { const sp = splitBy(x); if (sp.by) by[sp.line] = sp.by; return sp.line; });
|
|
159
|
+
if (s.by != null && !isObj(s.by)) return bad(`stage "${sname}": by is { "<To finish line>": "<who signs it off>" }`);
|
|
160
|
+
for (const [k, v] of Object.entries(s.by || {})) {
|
|
161
|
+
if (!lines.includes(String(k).trim())) return bad(`stage "${sname}": by names "${k}", which is not one of its To finish lines`);
|
|
162
|
+
if (v == null || v === '') continue;
|
|
163
|
+
if (!oneLine(v, BY_MAX) || !/\p{L}/u.test(v)) return bad(`stage "${sname}": who signs off "${k}" is a person or a role, one line of at most ${BY_MAX} characters`);
|
|
164
|
+
if (!by[String(k).trim()]) by[String(k).trim()] = v.trim();
|
|
165
|
+
}
|
|
146
166
|
const w = isObj(s.when) ? s.when : { mode: 'always' };
|
|
147
167
|
if (!WHEN_MODES.includes(w.mode)) return bad(`stage "${sname}": When it runs is one of ${WHEN_MODES.join(', ')}`);
|
|
148
168
|
if (w.mode === 'only' && !oneLine(w.text, TEXT_MAX)) return bad(`stage "${sname}": Only when needs the condition in your words (at most ${TEXT_MAX} characters)`);
|
|
@@ -152,7 +172,7 @@ function check(wf) {
|
|
|
152
172
|
stages.push({
|
|
153
173
|
key, name: sname, cat: s.cat,
|
|
154
174
|
output: { name: o.name ? o.name.trim() : '', kind, ...(o.template ? { template: o.template.trim() } : {}) },
|
|
155
|
-
finish:
|
|
175
|
+
finish: lines, ...(Object.keys(by).length ? { by } : {}), milestone: s.milestone === true, auto: s.auto === true,
|
|
156
176
|
when: w.mode === 'only' ? { mode: 'only', text: w.text.trim() } : { mode: w.mode },
|
|
157
177
|
then: typeof s.then === 'string' && s.then ? s.then : null,
|
|
158
178
|
unless: unless.map((u) => ({ text: u.text.trim(), to: u.to })),
|
|
@@ -338,7 +358,7 @@ function stagesOf(wf, { judged = {}, current = null } = {}) {
|
|
|
338
358
|
const j = judged && judged[s.key] ? judged[s.key] : null;
|
|
339
359
|
const skipped = !!j && j.runs === false;
|
|
340
360
|
const status = skipped ? 'skipped' : at < 0 ? (i === 0 ? 'current' : 'next') : i < at ? 'done' : i === at ? 'current' : 'next';
|
|
341
|
-
return { key: s.key, name: s.name, cat: s.cat, milestone: s.milestone, auto: s.auto, output: s.output, finish: s.finish, when: s.when,
|
|
361
|
+
return { key: s.key, name: s.name, cat: s.cat, milestone: s.milestone, auto: s.auto, output: s.output, finish: s.finish, ...(s.by ? { by: { ...s.by } } : {}), when: s.when,
|
|
342
362
|
then: s.then, unless: s.unless, n: i + 1, of: w.stages.length, status, reading: j ? { runs: j.runs, why: j.why || '', cite: j.cite || null } : null };
|
|
343
363
|
});
|
|
344
364
|
}
|
|
@@ -348,7 +368,7 @@ function copyOf(wf, name, taken) {
|
|
|
348
368
|
const n = oneLine(name, NAME_MAX) ? name.trim() : 'Copy of ' + wf.name;
|
|
349
369
|
let id = slug(n) || 'workflow', k = 2;
|
|
350
370
|
while ((taken && taken.has(id)) || isBuiltin(id)) id = slug(n) + '-' + k++;
|
|
351
|
-
return { id, name: n, icon: wf.icon, decide: wf.decide || 'pmos', ...(WORK_KINDS.includes(wf.kind) ? { kind: wf.kind } : {}), stages: wf.stages.map((s) => ({ ...s, output: { ...s.output }, finish: [...s.finish], when: { ...s.when }, unless: s.unless.map((u) => ({ ...u })) })) };
|
|
371
|
+
return { id, name: n, icon: wf.icon, decide: wf.decide || 'pmos', ...(WORK_KINDS.includes(wf.kind) ? { kind: wf.kind } : {}), stages: wf.stages.map((s) => ({ ...s, output: { ...s.output }, finish: [...s.finish], ...(s.by ? { by: { ...s.by } } : {}), when: { ...s.when }, unless: s.unless.map((u) => ({ ...u })) })) };
|
|
352
372
|
}
|
|
353
373
|
|
|
354
374
|
/** The workflow a kind of work starts on: Project and Full SDLC their own; Product management the workspace's default (defaultOf). */
|
|
@@ -370,5 +390,5 @@ const milestonesOf = (wf) => (wf || PRODUCT_FEATURE).stages.filter((s) => s.mile
|
|
|
370
390
|
module.exports = {
|
|
371
391
|
CATS, CAT_LABEL, ENDS, OUTPUT_KINDS, WHEN_MODES, DECIDE, ICONS, PRODUCT_FEATURE_ID, PRODUCT_FEATURE,
|
|
372
392
|
PROJECT_ID, PROJECT, FULL_SDLC_ID, FULL_SDLC, BUILTIN, KIND_WF, KIND_GATE, MEANING, isBuiltin, forKind, isKindDefault,
|
|
373
|
-
WORK_KINDS, kindOf, slug, check, fold, list, defaultOf, resolve, stageByRef, switchTarget, proposeBridge, mapOf, removedInUse, stagesOf, copyOf, milestonesOf,
|
|
393
|
+
WORK_KINDS, kindOf, slug, check, fold, list, defaultOf, resolve, stageByRef, switchTarget, proposeBridge, mapOf, removedInUse, stagesOf, copyOf, milestonesOf, splitBy,
|
|
374
394
|
};
|
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
* workOf(row) PURE → { act, why, station, missing, next, flag } whether the Driver works this row's exit items
|
|
8
8
|
* exitFact(row) PURE → the `exit` fact lib/driver-facts.js adds to one initiative (null when there is no row)
|
|
9
9
|
* blockerOf(fact, state, { now }) PURE → null | { code: 'exit-missing', text, items, key } for lib/driver.js detect: a wake when the
|
|
10
|
-
* missing set is new, and again each REWAKE_DAYS while it stays the same
|
|
10
|
+
* missing set is new, and again each REWAKE_DAYS while it stays the same. Sign-offs are left out.
|
|
11
|
+
* signoffBlockerOf(fact) PURE → null | { code: 'signoff-missing', text, items } the PM's blocker for the stage's sign-offs
|
|
11
12
|
* checkExits(data) PURE → { ok, exits } | { ok: false, error } the shape of a move's `exits` list
|
|
12
13
|
* quoteCheck(exits, readText) PURE → { ok, checks: [{ item, ok, why }] } every exit quotes a line that is really in its record
|
|
13
|
-
* moveGate({ row, exits, from, readText }) PURE → { ok, why, checks } the Checker's gate before PMOS moves a stage by itself
|
|
14
|
+
* moveGate({ row, exits, from, readText, done }) PURE → { ok, why, checks } the Checker's gate before PMOS moves a stage by itself
|
|
15
|
+
* (done: the To finish lines a Done task finished; they need no quote)
|
|
14
16
|
* readerOf(root, initiative) → readText(ref) → text | null a file inside the repository, or a Jira key in the initiative's read
|
|
15
17
|
* trackerOf(root, initiative) → [{ key, summary, assignee, sprint, start, end }] who holds each ticket and in which sprint
|
|
16
18
|
* linesFor(row, tracker) PURE → [text] the work list a Driver run reads (`pmos driver exits <id>`)
|
|
@@ -59,13 +61,18 @@ function workOf(row) {
|
|
|
59
61
|
function exitFact(row) {
|
|
60
62
|
if (!row) return null;
|
|
61
63
|
const w = workOf(row);
|
|
62
|
-
|
|
64
|
+
const so = Array.isArray(row.signoffs) ? row.signoffs.filter((x) => x && x.item).slice(0, 12) : [];
|
|
65
|
+
return { station: w.station ? w.station.name : null, missing: (w.missing || []).slice(0, 12), ...(so.length ? { signoffs: so } : {}), next: w.next, flag: w.flag, act: w.act, why: w.why };
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
/** lib/driver.js detect: one exit-missing blocker while the Driver can act on missing items. It wakes a run when the missing set is new
|
|
66
69
|
* for this station, and again every REWAKE_DAYS while it stays the same (state.blockerDays holds `key|day` of every blocker line). */
|
|
67
|
-
function blockerOf(
|
|
68
|
-
if (!
|
|
70
|
+
function blockerOf(fact0, state, { now = Date.now() } = {}) {
|
|
71
|
+
if (!fact0 || !fact0.act || !Array.isArray(fact0.missing) || !fact0.missing.length) return null;
|
|
72
|
+
// factory-signoffs-reach-you: a sign-off (a To finish line with by:) is the person's to give; the Driver never wakes for it
|
|
73
|
+
const signed = new Set((fact0.signoffs || []).map((x) => lc(x.item)));
|
|
74
|
+
const fact = signed.size ? { ...fact0, missing: fact0.missing.filter((m) => !signed.has(lc(m))) } : fact0;
|
|
75
|
+
if (!fact.missing.length) return null;
|
|
69
76
|
const key = `exit-missing:${hash(`${fact.station}|${fact.missing.join('|')}`)}`;
|
|
70
77
|
const seen = state && state.blockerDays instanceof Set ? state.blockerDays : new Set();
|
|
71
78
|
for (const k of seen) {
|
|
@@ -78,6 +85,15 @@ function blockerOf(fact, state, { now = Date.now() } = {}) {
|
|
|
78
85
|
return { code: 'exit-missing', key, items, text: `${fact.station}: missing ${items.join('; ')}${fact.missing.length > 5 ? ` (+${fact.missing.length - 5} more)` : ''}` };
|
|
79
86
|
}
|
|
80
87
|
|
|
88
|
+
/** lib/driver.js detect: the PM's blocker for the stage's missing sign-offs (factory-signoffs-reach-you). It is owned by the PM, so it never
|
|
89
|
+
* wakes a run; Today › Your move shows one row per sign-off (lib/stage-signoffs.js). PURE → null | { code: 'signoff-missing', text, items } */
|
|
90
|
+
function signoffBlockerOf(fact) {
|
|
91
|
+
if (!fact || !fact.act || !Array.isArray(fact.signoffs) || !fact.signoffs.length) return null;
|
|
92
|
+
const items = fact.signoffs.slice(0, 5);
|
|
93
|
+
return { code: 'signoff-missing', items: items.map((x) => x.item),
|
|
94
|
+
text: `${fact.station}: waits on ${items.map((x) => `${x.by}'s yes on "${x.item}"`).join('; ')}${fact.signoffs.length > 5 ? ` (+${fact.signoffs.length - 5} more)` : ''}` };
|
|
95
|
+
}
|
|
96
|
+
|
|
81
97
|
/** The shape of a move's exits: [{ item, quote, ref }], at most 20. */
|
|
82
98
|
function checkExits(data) {
|
|
83
99
|
const list = isObj(data) ? data.exits : undefined;
|
|
@@ -118,21 +134,27 @@ function exitItemsOf(boardRow) {
|
|
|
118
134
|
}
|
|
119
135
|
|
|
120
136
|
/** The Checker's gate before PMOS moves a stage by itself. row: the line row; boardRow: the Board's row (its stage's To finish lines). */
|
|
121
|
-
function moveGate({ row, boardRow, exits, from, readText }) {
|
|
137
|
+
function moveGate({ row, boardRow, exits, from, readText, done = [] }) {
|
|
122
138
|
const w = workOf(row);
|
|
123
139
|
if (!row || !row.live) return { ok: false, why: 'the initiative is not on the line', checks: [] };
|
|
124
140
|
if (row.flag === 'cant-tell') return { ok: false, why: `can't tell where it stands (${row.why}), so PMOS does not move it`, checks: [] };
|
|
125
141
|
const here = row.station;
|
|
126
142
|
if (!here) return { ok: false, why: 'it has no station', checks: [] };
|
|
127
143
|
if (from && lc(from) !== lc(here.key) && lc(from) !== lc(here.name)) return { ok: false, why: `it moved to ${here.name} since (you or the tracker moved it): the move from ${from} no longer applies`, checks: [] };
|
|
128
|
-
|
|
144
|
+
// done: the To finish lines a Done task already finished (the line's own record; factory-signoffs-reach-you). They need no quote, and the
|
|
145
|
+
// checks say so; every other line, a sign-off included, still needs its quote found in its record.
|
|
146
|
+
const byTask = new Set((done || []).map(lc));
|
|
147
|
+
const need = exitItemsOf(boardRow).filter((n) => !byTask.has(lc(n)));
|
|
129
148
|
const given = new Map((exits || []).map((x) => [lc(x.item), x]));
|
|
130
149
|
const absent = need.filter((n) => !given.has(lc(n)));
|
|
131
150
|
if (absent.length) return { ok: false, why: `every exit item of ${here.name} needs a quote: missing ${absent.join('; ')}`, checks: [] };
|
|
151
|
+
const taskChecks = exitItemsOf(boardRow).filter((n) => byTask.has(lc(n))).map((n) => ({ item: n, ref: null, ok: true, why: 'its task is Done' }));
|
|
152
|
+
if (!need.length && taskChecks.length) return { ok: true, why: `every exit item of ${here.name} has a Done task`, checks: taskChecks };
|
|
132
153
|
const q = quoteCheck(need.map((n) => given.get(lc(n))), readText);
|
|
133
|
-
|
|
154
|
+
const checks = taskChecks.concat(q.checks);
|
|
155
|
+
if (!q.ok) return { ok: false, why: q.checks.filter((c) => !c.ok).map((c) => `${c.item}: ${c.why}`).join('; '), checks };
|
|
134
156
|
void w;
|
|
135
|
-
return { ok: true, why: `${q.checks.length} of ${q.checks.length} exit items of ${here.name} quote a real record line
|
|
157
|
+
return { ok: true, why: `${q.checks.length} of ${q.checks.length} exit items of ${here.name} quote a real record line${taskChecks.length ? `; ${taskChecks.length} have a Done task` : ''}`, checks };
|
|
136
158
|
}
|
|
137
159
|
|
|
138
160
|
/** readText for one repository: a path inside it, or a Jira key the initiative's last read holds (its summary, status and sprint). */
|
|
@@ -173,8 +195,14 @@ function linesFor(row, tracker = []) {
|
|
|
173
195
|
if (!row) return ['Not on the line: `pmos line` does not list this initiative.'];
|
|
174
196
|
out.push(`Station: ${w.station ? `${w.station.name} (${w.station.n} of ${w.station.of})` : 'none'} · flag: ${w.flag || 'none'}${row.why ? ` (${row.why})` : ''}.`);
|
|
175
197
|
if (!w.act) { out.push(`Do not work its exit items and do not propose a stage move: ${w.why}.`); return out; }
|
|
176
|
-
|
|
177
|
-
|
|
198
|
+
const so = Array.isArray(row.signoffs) ? row.signoffs : [];
|
|
199
|
+
if (so.length) {
|
|
200
|
+
out.push(`Sign-offs (a person gives these; do not work them): ${so.map((x) => `"${x.item}" by ${x.by}`).join('; ')}. When you find where the yes is written, run \`pmos signoff list ${row.id}\` for its id, then \`pmos signoff evidence <id> --ref <file or Jira key> --quote "<the line, word for word>" [--doc <the document it agrees to>]\`. The PM records it on Today.`);
|
|
201
|
+
}
|
|
202
|
+
const work = so.length ? w.missing.filter((m) => !so.some((x) => lc(x.item) === lc(m))) : w.missing;
|
|
203
|
+
if (so.length && !work.length && w.missing.length) return out;
|
|
204
|
+
if (work.length) {
|
|
205
|
+
out.push(`Missing exit items (the station's To finish lines): ${work.map((m) => `"${m}"`).join('; ')}.`);
|
|
178
206
|
out.push('Work these items first, in this order. For each, file the proposal that gets it done, with its source.');
|
|
179
207
|
} else {
|
|
180
208
|
out.push(`Every exit item is done. Next move: ${w.next}. Propose it with --what move and data {"to": "<stage>", "from": "${w.station.key}", "exits": [{"item": "<each To finish line>", "quote": "<a line copied word for word>", "ref": "<the file path or Jira key it is in>"}]}.`);
|
|
@@ -220,5 +248,5 @@ function countChecks(stateDir, now = Date.now()) {
|
|
|
220
248
|
return { pass, flag };
|
|
221
249
|
}
|
|
222
250
|
|
|
223
|
-
module.exports = { countChecks, boardRowOf, boardMove, stationNow, sameStage, workOf, exitFact, blockerOf, checkExits, quoteCheck, exitItemsOf, moveGate, readerOf, trackerOf, linesFor, CHECKER_REASON, REWAKE_DAYS, MIN_QUOTE };
|
|
251
|
+
module.exports = { countChecks, boardRowOf, boardMove, stationNow, sameStage, workOf, exitFact, blockerOf, signoffBlockerOf, checkExits, quoteCheck, exitItemsOf, moveGate, readerOf, trackerOf, linesFor, CHECKER_REASON, REWAKE_DAYS, MIN_QUOTE };
|
|
224
252
|
|
package/workspace/lib/line.js
CHANGED
|
@@ -55,13 +55,22 @@ function limitOf(st) {
|
|
|
55
55
|
return CAT_LIMIT[st.cat] != null ? CAT_LIMIT[st.cat] : 15;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
/**
|
|
59
|
-
function
|
|
58
|
+
/** Who signs off each To finish line of a stage: { [line in lower case]: who }. The stage's own `by:` wins over a kept suggestion. PURE. */
|
|
59
|
+
function byOf(st, kept = null) {
|
|
60
|
+
const out = {};
|
|
61
|
+
for (const src of [kept, st && st.by]) if (src && typeof src === 'object') for (const [k, v] of Object.entries(src)) if (typeof v === 'string' && v.trim()) out[lc(k)] = v.trim();
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The exit items still missing on the current stage. → [text]
|
|
66
|
+
* answered: the To finish lines (lower case) whose sign-off is answered in lib/signoffs.js (factory-signoffs-reach-you): they are done. */
|
|
67
|
+
function missingOf(st, row, tasks, jira, answered = null) {
|
|
60
68
|
const finish = Array.isArray(st.finish) ? st.finish.filter((f) => typeof f === 'string' && f.trim()) : [];
|
|
61
69
|
if (finish.length) {
|
|
62
70
|
const map = row.wfMap || {};
|
|
63
71
|
const mine = (k) => k === st.key || map[k] === st.key;
|
|
64
|
-
|
|
72
|
+
const signed = answered instanceof Set ? answered : new Set();
|
|
73
|
+
return finish.filter((f) => !signed.has(lc(f)) && !(tasks || []).some((t) => t && t.from && mine(t.from.stage) && t.from.finish === f && DONE_STATES.has(lc(t.state))));
|
|
65
74
|
}
|
|
66
75
|
const out = st.output || {};
|
|
67
76
|
if (out.kind === 'jira' && jira && Array.isArray(jira.tickets) && jira.tickets.length) {
|
|
@@ -75,7 +84,7 @@ function missingOf(st, row, tasks, jira) {
|
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
function place(input, now = Date.now()) {
|
|
78
|
-
const { row, tasks = [], moves = [], jira = null, activity = [] } = input || {};
|
|
87
|
+
const { row, tasks = [], moves = [], jira = null, activity = [], signoffs = [], byKept = null } = input || {};
|
|
79
88
|
const one = row.oneStage || {};
|
|
80
89
|
const base = { id: row.id, title: row.title || row.id, workflow: row.wf ? row.wf.name : null };
|
|
81
90
|
const endWord = row.ended ? (row.ended.as === 'wontdo' ? "Won't do" : 'Archived') : row.archived ? 'Archived'
|
|
@@ -102,7 +111,15 @@ function place(input, now = Date.now()) {
|
|
|
102
111
|
const quietDays = last != null ? days(last, now) : null;
|
|
103
112
|
const clock = daysThere != null ? daysThere : quietDays;
|
|
104
113
|
|
|
105
|
-
|
|
114
|
+
// factory-signoffs-reach-you: the stage's sign-offs (its `by:` lines, and the ones the PM kept from PMOS's suggestion); one answered in
|
|
115
|
+
// the sign-off ledger is done, and a missing one is the person's to give, never the Driver's to work
|
|
116
|
+
const by = byOf(st, byKept);
|
|
117
|
+
const answered = new Set((signoffs || []).filter((x) => x && x.state === 'answered' && by[lc(x.what)] != null).map((x) => lc(x.what)));
|
|
118
|
+
const missing = missingOf(st, row, tasks, jira, answered);
|
|
119
|
+
const signoffList = missing.filter((m) => by[lc(m)] != null).map((m) => ({ item: m, by: by[lc(m)] }));
|
|
120
|
+
// a stage with no sign-off lines and no answer to PMOS's suggestion yet: the lines that read as a person's yes (board LnBy4)
|
|
121
|
+
let suggestBy = null;
|
|
122
|
+
if (!Object.keys(by).length && byKept == null && row.wf && row.wf.id) { try { const g = require('./stage-signoffs.js').suggestOf(st); if (Object.keys(g).length) suggestBy = { wf: row.wf.id, stage: st.key, stageName: st.name, by: g }; } catch { suggestBy = null; } }
|
|
106
123
|
const stages = row.wfStages || [];
|
|
107
124
|
const idx = stages.findIndex((s) => s.key === st.key);
|
|
108
125
|
const nextStage = stages.slice(idx + 1).find((s) => s.status !== 'skipped');
|
|
@@ -115,7 +132,7 @@ function place(input, now = Date.now()) {
|
|
|
115
132
|
else next = nextStage ? `move to ${nextStage.name}` : 'close it';
|
|
116
133
|
|
|
117
134
|
const out = { ...base, station, live: true, ended: null, daysThere, since: since != null ? new Date(since).toISOString() : null, setBy,
|
|
118
|
-
quietDays, clock, missing, next, limit: limit === 'tickets' ? `${TICKET_QUIET_WORKDAYS} working days with no ticket change` : limit };
|
|
135
|
+
quietDays, clock, missing, ...(signoffList.length ? { signoffs: signoffList } : {}), ...(suggestBy ? { suggestBy } : {}), next, limit: limit === 'tickets' ? `${TICKET_QUIET_WORKDAYS} working days with no ticket change` : limit };
|
|
119
136
|
const flag = (f, why) => ({ ...out, flag: f, why });
|
|
120
137
|
|
|
121
138
|
if (one.stage === 'on-hold') return flag('waiting', 'on hold: the clock is stopped');
|
|
@@ -245,6 +262,8 @@ function lineOf(root, { only = null, now = Date.now(), derive = true } = {}) {
|
|
|
245
262
|
const liveIds = new Set(base.rows.filter((x) => !(x.status === 'done' || x.lifecycle)).map((x) => x.id));
|
|
246
263
|
let JS = null; try { JS = require('./jira-status.js'); } catch { JS = null; }
|
|
247
264
|
let JT = null; try { JT = require('./jira-tickets.js'); } catch { JT = null; }
|
|
265
|
+
let SO = null, SS = null, soFile = null, kept = null;
|
|
266
|
+
try { SO = require('./signoffs.js'); SS = require('./stage-signoffs.js'); const soDir = JT ? JT.stateDirOf(root) : stateDir; soFile = SO.fileOf(soDir); kept = SS.keptLedger(soDir); } catch { SO = null; SS = null; }
|
|
248
267
|
const rows = [];
|
|
249
268
|
for (const id of ids) {
|
|
250
269
|
const r = boards.initiativeWorkflow(pass, w, id);
|
|
@@ -266,7 +285,10 @@ function lineOf(root, { only = null, now = Date.now(), derive = true } = {}) {
|
|
|
266
285
|
const recRel = typeof b0.record === 'string' ? path.relative(root, path.resolve(root, b0.record)) : null;
|
|
267
286
|
const activity = (acts.get(id) || []).concat(gitTimes(root, recRel, real));
|
|
268
287
|
const deps = depsOf(root, recRel).filter((d) => d !== id && liveIds.has(d));
|
|
269
|
-
|
|
288
|
+
// factory-signoffs-reach-you: this initiative's sign-offs, and the sign-off lines the PM kept from PMOS's suggestion for its stage
|
|
289
|
+
const signoffs = SO ? SO.list(soFile, { ini: id }) : [];
|
|
290
|
+
const byKept = SS && r.row.wf && r.row.wfStage ? SS.keptFor(kept, r.row.wf.id, r.row.wfStage.key) : null;
|
|
291
|
+
rows.push({ deps, doubt: doubtOf(r.row, derived.get(id)), p: place({ row: r.row, tasks, moves, jira, activity, signoffs, byKept }, now) });
|
|
270
292
|
}
|
|
271
293
|
// a dependency counts while it is itself live on the line (not ended): waiting on it is never stuck
|
|
272
294
|
const first = new Map(rows.map((x) => [x.p.id, x.p]));
|
|
@@ -285,4 +307,4 @@ function summary(line) {
|
|
|
285
307
|
return { live, placed, percent: live ? Math.round((placed / live) * 1000) / 10 : 0 };
|
|
286
308
|
}
|
|
287
309
|
|
|
288
|
-
module.exports = { place, lineOf, summary, missingOf, limitOf, activityIndex, doubtOf, depsOf, settle, LIMITS, STALE_DAYS };
|
|
310
|
+
module.exports = { place, lineOf, summary, missingOf, byOf, limitOf, activityIndex, doubtOf, depsOf, settle, LIMITS, STALE_DAYS };
|
|
@@ -53,7 +53,7 @@ const VERBS = Object.freeze({
|
|
|
53
53
|
help: 'pmos people list|show|record|settings … — the people you work with in this repository (pmos people help)' }),
|
|
54
54
|
// Not a pm-os-absorb verb (run: null): initiative dry-run-tickets-before-build added it through the same table.
|
|
55
55
|
signoff: Object.freeze({ module: 'signoff-cli.js', run: null, guide: 'cli.md',
|
|
56
|
-
help: 'pmos signoff ask|answer|drop|list … — the
|
|
56
|
+
help: 'pmos signoff ask|answer|drop|evidence|list … — the sign-offs an initiative waits on; a stage\'s sign-offs are Your move rows on Today (pmos signoff help)' }),
|
|
57
57
|
// Not a pm-os-absorb verb (run: null): initiative my-work added it through the same table.
|
|
58
58
|
'my-work': Object.freeze({ module: 'my-work-cli.js', run: null, guide: 'cli.md',
|
|
59
59
|
help: 'pmos my-work list|show|submit … — the Jira tickets and WBS items assigned to you, ranked (pmos my-work help)' }),
|
|
@@ -99,6 +99,7 @@ const MODULES = Object.freeze([
|
|
|
99
99
|
'routes-task-links', // batch 11 item 15: links between tasks, Claude's proposals, the quiet moves (task-links.jsonl; page-press POST)
|
|
100
100
|
'routes-proposals', // batch 12 items 2, 3 and 4: everything Claude proposes on an initiative, under its one ✦ (proposals.jsonl; page-press POST)
|
|
101
101
|
'routes-autonomy', // D106: what agents did by themselves (the Done group, 14 days), its Undo, and the demotions Home says once (autonomy.jsonl)
|
|
102
|
+
'routes-stage-signoffs', // factory-signoffs-reach-you: a stage's sign-offs as Your move rows, ✓ that records one (and moves the stage), Undo, the ✦ suggestion
|
|
102
103
|
'routes-your-move', // workspace grill W3: Your move's overdue outcome verdicts (drafted from Jira) and the first key result with no reading (GET)
|
|
103
104
|
'routes-tracker-sync', // tracker-sync-on-today: the sync with Jira of a product, the PM's ✓ that takes Jira's value, and its Undo (task ledger; page-press POST)
|
|
104
105
|
'routes-standing-rules', // standing-rules-list (A470): the standing rules PMOS keeps, with edit, retire and bring back (memory + standing-rules.jsonl)
|
|
@@ -545,7 +545,7 @@ const wfRowFields = (x) => {
|
|
|
545
545
|
wf: { id: x.wf.id, name: x.wf.name, icon: x.wf.icon, ...(x.own && x.own.pmos ? { setBy: 'pmos', why: x.own.why, from: x.own.from || null } : {}) },
|
|
546
546
|
wfStage: { key: st.key, name: st.name, cat: st.cat, milestone: !!st.milestone, n: st.n, of: st.of },
|
|
547
547
|
wfStages: x.stages.map((s) => ({ key: s.key, name: s.name, cat: s.cat, milestone: !!s.milestone, auto: !!s.auto, when: s.when, status: s.status, reading: s.reading,
|
|
548
|
-
output: s.output, finish: s.finish })), // output and finish: what finishes the stage (the stage card's exit steps on a library workflow)
|
|
548
|
+
output: s.output, finish: s.finish, ...(s.by ? { by: s.by } : {}) })), // output and finish: what finishes the stage (the stage card's exit steps on a library workflow); by: who signs off a line
|
|
549
549
|
ended: x.ended ? { as: x.ended.as, reason: x.ended.reason, note: x.ended.note, at: x.ended.at } : null,
|
|
550
550
|
// batch 20 item 3: where the tasks of an earlier workflow's stages sit now (old key → stage key), and the switch Undo can still put back (7 days)
|
|
551
551
|
wfMap: x.own && x.own.map ? x.own.map : null,
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-stage-signoffs.js — a stage's sign-offs as Today › Your move rows (initiative factory-signoffs-reach-you; lib/stage-signoffs.js).
|
|
3
|
+
*
|
|
4
|
+
* GET /api/stage-signoffs?ws=<id> → { ok, ws, rows: [lib/stage-signoffs.js row], suggest: [suggestion] }
|
|
5
|
+
* POST /api/stage-signoffs/record { ws, ini, id } → { ok, signoff, moved, gate, undo } ✓: the answer, and the stage move when it
|
|
6
|
+
* was the last missing item (one press)
|
|
7
|
+
* POST /api/stage-signoffs/undo { ws, ini, id, from?, to? } → { ok, reopened, movedBack } one Undo for both
|
|
8
|
+
* POST /api/stage-signoffs/suggest { ws, wf, stage, act: 'keep' | 'change' | 'undo', by? } → { ok, line } the ✦ suggestion's answer
|
|
9
|
+
*
|
|
10
|
+
* The rows read the product's kept line (lib/routes-your-move.js lineRowsKept) and never wait for a first read, so the page opens at once. Every
|
|
11
|
+
* POST is a page press (lib/pm-guard.js requirePagePress). Nothing here sends anything: a row with no source drafts its question, and the
|
|
12
|
+
* page puts it in the outbox (POST /api/outbox/draft) only when the PM presses it. */
|
|
13
|
+
const SS = require('./stage-signoffs.js');
|
|
14
|
+
|
|
15
|
+
async function read(req, res, url, ctx, method) {
|
|
16
|
+
if (req.method !== method) { ctx.json(res, { ok: false, error: method + ' only' }, 405); return null; }
|
|
17
|
+
let body = {};
|
|
18
|
+
if (method === 'POST') {
|
|
19
|
+
const got = await ctx.readJson(req);
|
|
20
|
+
if (!got.ok) { ctx.json(res, { ok: false, error: 'invalid JSON body' }, 400); return null; }
|
|
21
|
+
body = got.body || {};
|
|
22
|
+
}
|
|
23
|
+
let w = null;
|
|
24
|
+
try { w = ctx.getWs((method === 'POST' ? body.ws : url.searchParams.get('ws')) || null); } catch { w = null; }
|
|
25
|
+
if (!w || !w.root) { ctx.json(res, { ok: false, error: 'no such workspace' }, 404); return null; }
|
|
26
|
+
if (method === 'POST') {
|
|
27
|
+
const g = require('./pm-guard.js').requirePagePress(req, body);
|
|
28
|
+
if (!g.ok) { ctx.json(res, { ok: false, error: g.error }, g.status); return null; }
|
|
29
|
+
return { w, body, actor: { by: (g.actor && g.actor.by) || 'pm', via: (g.actor && g.actor.via) || 'page' } };
|
|
30
|
+
}
|
|
31
|
+
return { w, body };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// the line row of one initiative: the rows the server already derived; a full read only when they are not ready
|
|
35
|
+
function lineRowOf(root, ini) {
|
|
36
|
+
const L = require('./line.js');
|
|
37
|
+
let r = L.lineOf(root, { only: ini, derive: false });
|
|
38
|
+
if (!r || r.pending) r = L.lineOf(root, { only: ini });
|
|
39
|
+
return r && r.ok ? r.rows[0] || null : null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = {
|
|
43
|
+
prefixes: ['/api/stage-signoffs'],
|
|
44
|
+
handle: async (req, res, url, ctx) => {
|
|
45
|
+
const YM = require('./routes-your-move.js');
|
|
46
|
+
if (url.pathname === '/api/stage-signoffs') {
|
|
47
|
+
const r = await read(req, res, url, ctx, 'GET'); if (!r) return true;
|
|
48
|
+
// the kept line only: a first read of a large product takes a while, so this answers at once and the rows come on a later refresh
|
|
49
|
+
let rows = null;
|
|
50
|
+
try { rows = ctx.signoffLine ? await ctx.signoffLine(r.w) : YM.lineRowsKept(r.w); } catch (e) { ctx.json(res, { ok: false, error: 'the line could not be read: ' + (e && e.message) }, 500); return true; }
|
|
51
|
+
if (!rows) { ctx.json(res, { ok: true, ws: r.w.id, rows: [], suggest: [], reading: true }); return true; }
|
|
52
|
+
const S = SS.rowsOf(r.w.root, rows);
|
|
53
|
+
ctx.json(res, { ok: true, ws: r.w.id, rows: S.rows, suggest: S.suggest });
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
const act = url.pathname.slice('/api/stage-signoffs/'.length);
|
|
57
|
+
if (!['record', 'undo', 'suggest'].includes(act)) return false;
|
|
58
|
+
const r = await read(req, res, url, ctx, 'POST'); if (!r) return true;
|
|
59
|
+
const b = r.body;
|
|
60
|
+
let out;
|
|
61
|
+
if (act === 'record') out = SS.record(r.w.root, { ini: String(b.ini || ''), id: String(b.id || '') }, r.actor, { lineRow: ctx.signoffLineRow || lineRowOf });
|
|
62
|
+
else if (act === 'undo') out = SS.undo(r.w.root, { ini: String(b.ini || ''), id: String(b.id || ''), from: b.from ? String(b.from) : null, to: b.to ? String(b.to) : null }, r.actor);
|
|
63
|
+
else {
|
|
64
|
+
let dir = null; try { dir = require('./jira-tickets.js').stateDirOf(r.w.root); } catch { dir = null; }
|
|
65
|
+
out = SS.answerSuggestion(dir, { wf: b.wf, stage: b.stage, act: b.act, by: b.by }, r.actor);
|
|
66
|
+
}
|
|
67
|
+
if (out && out.ok) YM.forgetLine(r.w.id);
|
|
68
|
+
ctx.json(res, out, out && out.ok ? 200 : 400);
|
|
69
|
+
return true;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
@@ -154,6 +154,15 @@ async function lineRows(w, now = Date.now()) {
|
|
|
154
154
|
LINES.set(w.id, { at: c ? c.at : 0, rows: c ? c.rows : null, p });
|
|
155
155
|
return c && c.rows ? c.rows : p;
|
|
156
156
|
}
|
|
157
|
+
/** A press that moved a stage or recorded a sign-off: the next read of this product's line reads it again (the old rows serve meanwhile). */
|
|
158
|
+
function forgetLine(wsId) { const c = LINES.get(wsId); if (c) c.at = 0; }
|
|
159
|
+
/** The line's rows as kept now, without waiting: a stale or missing answer starts a new read in the background. null while nothing was read yet.
|
|
160
|
+
* For a row that may come a refresh later (Today's sign-offs), so a slow first read never holds a request open. */
|
|
161
|
+
function lineRowsKept(w, now = Date.now()) {
|
|
162
|
+
const c = LINES.get(w.id);
|
|
163
|
+
if (!c || now - c.at >= LINE_MS) lineRows(w, now).catch(() => {});
|
|
164
|
+
return c && c.rows ? c.rows : null;
|
|
165
|
+
}
|
|
157
166
|
/** The initiatives of a product that are in Your move: a question to the PM, or a check due today. */
|
|
158
167
|
function youOf(ctx, w, today) {
|
|
159
168
|
const out = new Set();
|
|
@@ -217,7 +226,7 @@ async function weekWentRoute(req, res, url, ctx) {
|
|
|
217
226
|
const digestParts = (ctx, w, now) => require('./digest-parts.js').partsOf(ctx, w, lineRows, now); // quiet-rows-digest (reads only)
|
|
218
227
|
|
|
219
228
|
module.exports = {
|
|
220
|
-
expire, questions, asksOf, lineRows, digestParts, quietRoute, weekWentRoute,
|
|
229
|
+
expire, questions, asksOf, lineRows, lineRowsKept, forgetLine, digestParts, quietRoute, weekWentRoute,
|
|
221
230
|
prefixes: ['/api/your-move', '/api/line', '/api/digest', '/api/quiet', '/api/week-went'],
|
|
222
231
|
handle: async (req, res, url, ctx) => {
|
|
223
232
|
if (url.pathname === '/api/week-went') return weekWentRoute(req, res, url, ctx);
|