create-pmos 0.671.0 → 0.672.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 +9 -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/state/discoveries.md +1 -1
- package/workspace/changelog.json +8 -2
- package/workspace/guide/agent-capabilities.md +8 -0
- package/workspace/lib/auto-keep.js +8 -0
- package/workspace/lib/autonomy.js +2 -0
- package/workspace/lib/default-decisions.js +199 -0
- package/workspace/lib/proposals.js +4 -0
- package/workspace/lib/question-batch.js +1 -1
- package/workspace/lib/routes-autonomy.js +7 -1
- package/workspace/lib/routes-proposals.js +2 -0
- package/workspace/lib/routes-your-move.js +18 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/test-lists/default-decisions-with-a-deadline.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.672.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-22T05:
|
|
37
|
+
"v": "0.672.0",
|
|
38
|
+
"at": "2026-11-22T05:15:41.155Z",
|
|
39
39
|
"f": 4,
|
|
40
40
|
"prs": [
|
|
41
41
|
{
|
|
@@ -49,6 +49,12 @@
|
|
|
49
49
|
"t": "Plain ✓ actions write directly, with Undo and no agent turn",
|
|
50
50
|
"s": "Plain ✓ actions write directly, with Undo and no agent turn",
|
|
51
51
|
"k": "new"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"n": 1450,
|
|
55
|
+
"t": "Default decisions with a deadline, and the cost of waiting",
|
|
56
|
+
"s": "Default decisions with a deadline, and the cost of waiting",
|
|
57
|
+
"k": "new"
|
|
52
58
|
}
|
|
53
59
|
]
|
|
54
60
|
},
|
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-22T05:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T05:15:37Z"}
|
|
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-22T05:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T05:15:37Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -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-22T05:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T05:15:37Z"}
|
|
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-22T05:
|
|
3
|
+
"v": "0.672.0",
|
|
4
|
+
"at": "2026-11-22T05:15:41.155Z",
|
|
5
5
|
"f": 4,
|
|
6
6
|
"prs": [
|
|
7
7
|
{
|
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
"t": "Plain ✓ actions write directly, with Undo and no agent turn",
|
|
16
16
|
"s": "Plain ✓ actions write directly, with Undo and no agent turn",
|
|
17
17
|
"k": "new"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"n": 1450,
|
|
21
|
+
"t": "Default decisions with a deadline, and the cost of waiting",
|
|
22
|
+
"s": "Default decisions with a deadline, and the cost of waiting",
|
|
23
|
+
"k": "new"
|
|
18
24
|
}
|
|
19
25
|
]
|
|
20
26
|
},
|
|
@@ -53,6 +53,14 @@ A tidy name that uses only the task's own words is not a name change from a sour
|
|
|
53
53
|
|
|
54
54
|
The changes that wait come together in one list of questions a day: one question for each owner and initiative. The owner is the person the plan names on the task, or you. The list is fixed for the day. A change that waits later that day goes on the next day's list. A question for a teammate is a draft. PMOS does not send it. When you keep or drop the change, its question leaves the list.
|
|
55
55
|
|
|
56
|
+
### Defaults when nobody answers
|
|
57
|
+
|
|
58
|
+
Each question on the list says what PMOS does if nobody answers, and by when. For a change that waits for a source, the default is to leave the plan as it is. The deadline is 2 days after the change first joined the list. When the deadline passes and nobody answered, PMOS takes the default and lists it in "PMOS did" with Undo. Undo brings the question back, and PMOS does not take a default on it again.
|
|
59
|
+
|
|
60
|
+
These changes never take a default, because other people see them or they cannot be undone: the state of a Jira ticket, a stage move, a message to a person, a pull request, a merge, a delete, spending money, and the next step for an outcome that did not work. They wait for you. Each question says how many days it has waited and how many tasks stay as they are until someone answers.
|
|
61
|
+
|
|
62
|
+
To stop defaults, set "Defaults when nobody answers" to Ask first in Settings, or turn PMOS's agents off.
|
|
63
|
+
|
|
56
64
|
### Undo
|
|
57
65
|
|
|
58
66
|
Each change an agent applies is listed for 14 days with Undo. Undo puts the record back as it was. If someone changed the record since, Undo keeps that change.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
/* auto-keep.js — the ✦ half of D106 ("Full autonomy now"): after the proposal runs, every open class A or B ✦ proposal of a lead
|
|
3
3
|
* workspace is applied by itself, one batch each, with Undo (lib/routes-proposals.js autoKeep, lib/autonomy.js). A workspace is
|
|
4
4
|
* read again only when its proposals ledger changed. `pmos ai off` and PMOS_AUTONOMY=off stop it (autonomy.killed).
|
|
5
|
+
* DEFAULTS (default-decisions-with-a-deadline): once a local day per lead workspace, the day's question list is read the way Your move
|
|
6
|
+
* reads it (lib/routes-your-move.js questions), which takes the defaults due that day, so a question nobody opened still closes.
|
|
5
7
|
*
|
|
6
8
|
* create({ workspaces, isLead, stateDirFor, proposalCtx, settingsDir, env?, warn? }) → { tick() }
|
|
7
9
|
*/
|
|
@@ -10,6 +12,8 @@ const path = require('path');
|
|
|
10
12
|
|
|
11
13
|
function create({ workspaces, isLead, stateDirFor, proposalCtx, settingsDir, env = process.env, warn = () => {} }) {
|
|
12
14
|
const seen = new Map();
|
|
15
|
+
const daySeen = new Map();
|
|
16
|
+
const localDay = (ms = Date.now()) => { const d = new Date(ms); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
|
|
13
17
|
const mtimeOf = (dir) => { try { return fs.statSync(path.join(dir, 'proposals.jsonl')).mtimeMs; } catch { return null; } };
|
|
14
18
|
function tick() {
|
|
15
19
|
if (require('./autonomy.js').killed({ env, settingsDir: settingsDir() })) return;
|
|
@@ -19,6 +23,10 @@ function create({ workspaces, isLead, stateDirFor, proposalCtx, settingsDir, env
|
|
|
19
23
|
try {
|
|
20
24
|
if (!isLead(w)) continue;
|
|
21
25
|
const dir = stateDirFor(w); if (!dir) continue;
|
|
26
|
+
const day = localDay();
|
|
27
|
+
if (daySeen.get(w.id) !== day) {
|
|
28
|
+
try { require('./routes-your-move.js').questions(proposalCtx(), w, day); daySeen.set(w.id, day); } catch (e) { warn('default decisions tick', e); }
|
|
29
|
+
}
|
|
22
30
|
const mt = mtimeOf(dir);
|
|
23
31
|
if (mt == null || seen.get(w.id) === mt) continue;
|
|
24
32
|
const state = D.fold(D.readLines(D.ledgerFile(D.stateDirOf(w.root) || dir)));
|
|
@@ -98,6 +98,8 @@ const KIND_LIST = Object.freeze([
|
|
|
98
98
|
k('description', 'Descriptions and links', ['propose:description', 'propose:links']),
|
|
99
99
|
k('found', 'What PMOS found elsewhere', ['propose:found', 'propose:scanned', 'propose:improved', 'propose:prototyped']),
|
|
100
100
|
k('grill', 'Fixes from a check', ['propose:grill']),
|
|
101
|
+
// default-decisions-with-a-deadline: the day's questions nobody answered by their deadline (lib/default-decisions.js)
|
|
102
|
+
k('defaults', 'Defaults when nobody answers', ['propose:default']),
|
|
101
103
|
]);
|
|
102
104
|
const KIND_OF_JOB = new Map(KIND_LIST.flatMap((x) => x.jobs.map((j) => [j, x.key])));
|
|
103
105
|
const kindOf = (job) => KIND_OF_JOB.get(String(job || '')) || null;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* default-decisions.js — default decisions with a deadline (initiative default-decisions-with-a-deadline; bet 2 in pmos-ideas/bets.md,
|
|
3
|
+
* proofs A26 + A27). Every question on the day's list (lib/question-batch.js) says what PMOS does if nobody answers, and by when. When the
|
|
4
|
+
* deadline passes with no answer, PMOS takes that default by itself, with Undo. A kind that others see or that cannot be taken back has
|
|
5
|
+
* no default: it waits for the PM, and the list says how long it has waited.
|
|
6
|
+
*
|
|
7
|
+
* DEFAULT_DAYS · JOB · WHY
|
|
8
|
+
* defaultOf(p) PURE → { choice: 'leave', say } | { choice: null, waits } the default of one held change
|
|
9
|
+
* firstDays(dayLines) PURE → Map id → the first day it was on the list (question-days.jsonl lines)
|
|
10
|
+
* defaultedOf(lines) PURE → { taken: Map id → batch, undone: Set id, batches: Map batch → [drop line] } from proposals.jsonl
|
|
11
|
+
* annotate(questions, held, { dayLines, lines, today, extra }) PURE → the questions, each with default | null, waits | null, waiting (days),
|
|
12
|
+
* cost (A27, costOf: what the wait holds up)
|
|
13
|
+
* dueOf(held, { dayLines, lines, today }) PURE → the held changes whose default is due today and was never taken or undone
|
|
14
|
+
* take(dir, held, { dayLines, today, product, pm, now, env, settingsDir }) → { taken: [{ batch, ini, board, ids, title }], why? }
|
|
15
|
+
* undo(dir, batch, { product, actor, now }) → { ok, back } | { ok: false, error }
|
|
16
|
+
*
|
|
17
|
+
* THE DEFAULT. A held change is a plan change PMOS has no source for (lib/source-guard.js), so the safe answer is the one that changes
|
|
18
|
+
* nothing: `leave`, PMOS leaves the plan as it is. Its due day is DEFAULT_DAYS after the day the change first joined the list. Taking it
|
|
19
|
+
* writes one drop line per change in proposals.jsonl, marked `default: true` with the batch (by `pmos:default`, so no job learns from it as
|
|
20
|
+
* from the PM's ✕), and one `applied` line for the job `propose:default` in autonomy.jsonl, so "PMOS did" lists it with Undo. The plan
|
|
21
|
+
* itself is not written; nothing is sent.
|
|
22
|
+
* NEVER A DEFAULT (NEVER below): a Jira ticket's state, a stage move, a message to a person, a pull request, a merge, a delete, spend, and
|
|
23
|
+
* a refuted outcome's next step. They wait for the PM, however long.
|
|
24
|
+
* UNDO. An undo line for the batch (lib/proposals.js fold then reads its drops as never written) brings the question back. An undone id is
|
|
25
|
+
* never defaulted again: it waits for the PM. The Undo is a setback of `propose:default` (two in a row demote it for 7 days).
|
|
26
|
+
* STOPS. `pmos ai off`, PMOS_AUTONOMY=off, a demotion, and the Settings kind "Defaults when nobody answers" set to Ask first
|
|
27
|
+
* (lib/autonomy.js decide). */
|
|
28
|
+
|
|
29
|
+
const DEFAULT_DAYS = 2;
|
|
30
|
+
const JOB = 'propose:default';
|
|
31
|
+
const BY = 'pmos:default';
|
|
32
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
33
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
34
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
35
|
+
const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
36
|
+
const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
|
|
37
|
+
const dn = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? Math.round(Date.UTC(+m[1], +m[2] - 1, +m[3]) / 864e5) : null; };
|
|
38
|
+
const isoOf = (d) => new Date(d * 864e5).toISOString().slice(0, 10);
|
|
39
|
+
const addDays = (day, n) => { const d = dn(day); return d == null ? '' : isoOf(d + n); };
|
|
40
|
+
const md = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] : ''; };
|
|
41
|
+
const WHY = (due) => `No answer by ${md(due)}, so PMOS left the plan as it was.`;
|
|
42
|
+
|
|
43
|
+
/* The kinds that never default, each with the reason the list shows. `test(p)` reads a ✦ proposal (group, type, items) or a Driver
|
|
44
|
+
* proposal (`what`). */
|
|
45
|
+
const NEVER = [
|
|
46
|
+
{ key: 'jira', test: (p) => p.group === 'status' && (p.items || []).some((x) => isObj(x) && x.jira), waits: "It changes a Jira ticket's state, which others see." },
|
|
47
|
+
{ key: 'stage', test: (p) => (p.group === 'found' && p.type === 'stage') || p.what === 'move' || (p.items || []).some((x) => isObj(x) && x.op === 'stage'), waits: 'It moves the stage on a board others read.' },
|
|
48
|
+
{ key: 'message', test: (p) => p.what === 'follow-up' || p.group === 'message' || (isObj(p.data) && (p.data.send === true || p.data.to)), waits: 'It sends a message to a person.' },
|
|
49
|
+
{ key: 'pr', test: (p) => p.group === 'build', waits: 'It opens a pull request.' },
|
|
50
|
+
{ key: 'merge', test: (p) => p.group === 'merge' || (isObj(p.data) && p.data.merge === true), waits: 'It merges into a product repository.' },
|
|
51
|
+
{ key: 'delete', test: (p) => p.group === 'delete' || (isObj(p.data) && p.data.delete === true), waits: 'It deletes something.' },
|
|
52
|
+
{ key: 'spend', test: (p) => p.group === 'spend' || (isObj(p.data) && p.data.spend != null), waits: 'It spends money.' },
|
|
53
|
+
{ key: 'next', test: (p) => p.group === 'outcome' && (p.type === 'refuted' || p.type === 'source'), waits: 'What the work should be next is your call.' },
|
|
54
|
+
// the other asks on the same card (dry-run-tickets-before-build): a ticket's dry-run gap, and an outside sign-off
|
|
55
|
+
{ key: 'ticket', test: (p) => p.group === 'ask' && /^dry:/.test(String(p.id || '')), waits: 'What the ticket should say is your call.' },
|
|
56
|
+
{ key: 'signoff', test: (p) => p.group === 'ask', waits: 'It needs an answer from someone outside the team.' },
|
|
57
|
+
];
|
|
58
|
+
const LEAVE_GROUPS = new Set(['dates', 'status', 'names', 'found', 'links']);
|
|
59
|
+
|
|
60
|
+
/** The default of one held change. PURE. */
|
|
61
|
+
function defaultOf(p) {
|
|
62
|
+
if (!isObj(p)) return { choice: null, waits: 'PMOS cannot read this change.' };
|
|
63
|
+
const never = NEVER.find((n) => { try { return n.test(p); } catch { return false; } });
|
|
64
|
+
if (never) return { choice: null, waits: never.waits, never: never.key };
|
|
65
|
+
if (!LEAVE_GROUPS.has(p.group)) return { choice: null, waits: 'PMOS has no safe default for this kind of change.' };
|
|
66
|
+
return { choice: 'leave', say: 'PMOS leaves the plan as it is' };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** id → the first day it was on the list. PURE. dayLines: the lines of question-days.jsonl, { day, ids }. */
|
|
70
|
+
function firstDays(dayLines) {
|
|
71
|
+
const out = new Map();
|
|
72
|
+
for (const l of dayLines || []) {
|
|
73
|
+
if (!isObj(l) || typeof l.day !== 'string' || !Array.isArray(l.ids)) continue;
|
|
74
|
+
for (const id of l.ids) { const k = String(id); const was = out.get(k); if (!was || l.day < was) out.set(k, l.day); }
|
|
75
|
+
}
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** What PMOS defaulted, from the proposals ledger. PURE. A batch with an undo line is undone: its ids are never defaulted again. */
|
|
80
|
+
function defaultedOf(lines) {
|
|
81
|
+
const undoneB = new Set(), batches = new Map();
|
|
82
|
+
for (const l of lines || []) if (isObj(l) && l.kind === 'undo' && str(l.batch)) undoneB.add(l.batch);
|
|
83
|
+
for (const l of lines || []) {
|
|
84
|
+
if (!isObj(l) || l.kind !== 'drop' || l.default !== true || !str(l.batch)) continue;
|
|
85
|
+
if (!batches.has(l.batch)) batches.set(l.batch, []);
|
|
86
|
+
batches.get(l.batch).push(l);
|
|
87
|
+
}
|
|
88
|
+
const taken = new Map(), undone = new Set();
|
|
89
|
+
for (const [b, ls] of batches) for (const l of ls) { const id = str(l.id); if (!id) continue; if (undoneB.has(b)) undone.add(id); else taken.set(id, b); }
|
|
90
|
+
return { taken, undone, batches, undoneBatches: undoneB };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** One held change's state against the list and the ledger. */
|
|
94
|
+
function stateOf(h, first, D, today) {
|
|
95
|
+
const p = h.prop, id = String(p.id);
|
|
96
|
+
const d = defaultOf(p);
|
|
97
|
+
const since = first.get(id) || '';
|
|
98
|
+
const waiting = since && dn(today) != null ? Math.max(0, dn(today) - dn(since)) : 0;
|
|
99
|
+
if (!d.choice) return { id, d, since, waiting, due: '', open: false };
|
|
100
|
+
if (D.undone.has(id)) return { id, d: { choice: null, waits: 'You undid PMOS\'s default, so it waits for you.' }, since, waiting, due: '', open: false };
|
|
101
|
+
const due = since ? addDays(since, DEFAULT_DAYS) : '';
|
|
102
|
+
return { id, d, since, waiting, due, open: !D.taken.has(id) };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Each question with its default, the reason when it has none, and how long it has waited. PURE. */
|
|
106
|
+
function annotate(questions, held, { dayLines = [], lines = [], today = '', extra = [] } = {}) {
|
|
107
|
+
const first = firstDays(dayLines), D = defaultedOf(lines);
|
|
108
|
+
const byId = new Map((held || []).filter((h) => isObj(h) && isObj(h.prop)).map((h) => [String(h.prop.id), h]));
|
|
109
|
+
// the other asks on the card (dry-run gaps, sign-offs) never default; they still say why they wait and how long they have waited
|
|
110
|
+
for (const x of extra || []) if (isObj(x) && x.id && !byId.has(String(x.id))) byId.set(String(x.id), { ini: x.ini, prop: { id: String(x.id), group: 'ask', items: [] } });
|
|
111
|
+
return (questions || []).map((q) => {
|
|
112
|
+
const st = (q.ids || []).map((id) => byId.get(String(id))).filter(Boolean).map((h) => stateOf(h, first, D, today));
|
|
113
|
+
const yes = st.filter((s) => s.d.choice && s.due), no = st.filter((s) => !s.d.choice);
|
|
114
|
+
const due = yes.map((s) => s.due).sort()[0] || '';
|
|
115
|
+
const part = yes.length && yes.length < st.length ? ` for ${yes.length} of these ${st.length} changes` : '';
|
|
116
|
+
const def = yes.length ? { choice: 'leave', due, n: yes.length, say: `If nobody answers by ${md(due)}, PMOS leaves the plan as it is${part}. You can undo it.` } : null;
|
|
117
|
+
const reasons = [...new Set(no.map((s) => s.d.waits))];
|
|
118
|
+
const waits = no.length ? (reasons.join(' ') + ' So ' + (no.length === st.length ? 'it waits' : plural(no.length, 'change waits', 'changes wait')) + ' for you.') : null;
|
|
119
|
+
const waiting = Math.max(0, ...st.map((s) => s.waiting));
|
|
120
|
+
return { ...q, default: def, waits, waiting, cost: costOf(st.map((s) => byId.get(s.id)), waiting) };
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** A27, the cost of waiting: what the question holds up and for how long. PURE. → { days, tasks, taskDays, say } | null (zero is silence).
|
|
125
|
+
* tasks: the plan's tasks the held changes name; taskDays: tasks × days waited, the slip the plan does not show while nobody answers. */
|
|
126
|
+
function costOf(hs, days) {
|
|
127
|
+
const tasks = new Set();
|
|
128
|
+
for (const h of hs || []) for (const x of (h && h.prop && h.prop.items) || []) if (isObj(x)) tasks.add(String(x.task || x.id || x.title || ''));
|
|
129
|
+
tasks.delete('');
|
|
130
|
+
if (!days) return null;
|
|
131
|
+
const n = tasks.size;
|
|
132
|
+
const say = n ? `Waiting ${plural(days, 'day', 'days')}: ${plural(n, 'task stays', 'tasks stay')} as ${n === 1 ? 'it is' : 'they are'} until someone answers (${plural(n * days, 'task-day', 'task-days')}).`
|
|
133
|
+
: `Waiting ${plural(days, 'day', 'days')}.`;
|
|
134
|
+
return { days, tasks: n, taskDays: n * days, say };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** The held changes whose default is due on `today`, never taken and never undone. PURE. */
|
|
138
|
+
function dueOf(held, { dayLines = [], lines = [], today = '' } = {}) {
|
|
139
|
+
if (!today) return [];
|
|
140
|
+
const first = firstDays(dayLines), D = defaultedOf(lines);
|
|
141
|
+
return (held || []).filter((h) => {
|
|
142
|
+
if (!isObj(h) || !isObj(h.prop) || !h.prop.id || !h.ini) return false;
|
|
143
|
+
const s = stateOf(h, first, D, today);
|
|
144
|
+
return s.open && s.d.choice === 'leave' && s.due && s.due <= today;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Take the defaults due today: one batch per question (owner and initiative). → { taken: [...], why? } */
|
|
149
|
+
function take(dir, held, { dayLines = [], today = '', product = '', pm, now, env = process.env, settingsDir = null } = {}) {
|
|
150
|
+
const out = { taken: [] };
|
|
151
|
+
if (!dir || !today) return out;
|
|
152
|
+
const PR = require('./proposals.js');
|
|
153
|
+
const A = require('./autonomy.js');
|
|
154
|
+
const lines = PR.readLines(PR.ledgerFile(dir));
|
|
155
|
+
const due = dueOf(held, { dayLines, lines, today });
|
|
156
|
+
if (!due.length) return out;
|
|
157
|
+
const dec = A.decide({ stateDir: dir, job: JOB, product, cls: 'B', mode: 'auto', undoable: true, now, env, settingsDir });
|
|
158
|
+
if (!dec.apply) { out.why = dec.why; return out; }
|
|
159
|
+
const first = firstDays(dayLines);
|
|
160
|
+
const groups = require('./question-batch.js').questionsOf(due, { pm });
|
|
161
|
+
const byId = new Map(due.map((h) => [String(h.prop.id), h]));
|
|
162
|
+
for (const q of groups) {
|
|
163
|
+
const batch = PR.newBatch();
|
|
164
|
+
const hs = q.ids.map((id) => byId.get(String(id))).filter(Boolean);
|
|
165
|
+
const dueDay = hs.map((h) => addDays(first.get(String(h.prop.id)), DEFAULT_DAYS)).sort()[0];
|
|
166
|
+
const why = WHY(dueDay);
|
|
167
|
+
for (const h of hs) {
|
|
168
|
+
const p = h.prop;
|
|
169
|
+
const facts = PR.factsOf({ ...p, ini: h.ini });
|
|
170
|
+
PR.append(dir, { by: BY }, { kind: 'drop', ini: h.ini, board: h.board || '', sig: p.sig || PR.sigOf(p), id: String(p.id), group: str(p.group), type: str(p.type),
|
|
171
|
+
...(facts.length ? { facts } : {}), why, default: true, batch });
|
|
172
|
+
}
|
|
173
|
+
const title = `Left the plan as it was on ${one(q.title, 80)}: ${plural(hs.length, 'change', 'changes')} nobody answered by ${md(dueDay)}`;
|
|
174
|
+
A.recordApplied(dir, { job: JOB, product, ref: batch, title, cls: 'B', ini: q.ini, why }, { now, settingsDir });
|
|
175
|
+
out.taken.push({ batch, ini: q.ini, board: q.board, ids: hs.map((h) => String(h.prop.id)), title });
|
|
176
|
+
}
|
|
177
|
+
return out;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Undo one default PMOS took: its question comes back and waits for the PM. */
|
|
181
|
+
function undo(dir, batch, { product = '', actor = { by: 'pm' }, now } = {}) {
|
|
182
|
+
if (!dir || !/^pk-[0-9a-f]{10}$/.test(String(batch || ''))) return { ok: false, error: 'batch is a pk-… id' };
|
|
183
|
+
const PR = require('./proposals.js');
|
|
184
|
+
const D = defaultedOf(PR.readLines(PR.ledgerFile(dir)));
|
|
185
|
+
if (!D.batches.has(batch)) return { ok: false, status: 404, error: 'no default was taken under that id' };
|
|
186
|
+
if (D.undoneBatches.has(batch)) return { ok: false, status: 409, error: 'Nothing to undo' };
|
|
187
|
+
PR.append(dir, actor, { kind: 'undo', batch });
|
|
188
|
+
const r = require('./autonomy.js').recordSetback(dir, { job: JOB, product, ref: batch, kind: 'undo' }, { now });
|
|
189
|
+
return { ok: true, back: true, ...(r.demoted ? { demoted: r.demoted } : {}) };
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Is `batch` a default PMOS took (not a ✓ keep)? */
|
|
193
|
+
function isDefaultBatch(dir, batch) {
|
|
194
|
+
if (!dir) return false;
|
|
195
|
+
const PR = require('./proposals.js');
|
|
196
|
+
return defaultedOf(PR.readLines(PR.ledgerFile(dir))).batches.has(String(batch || ''));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
module.exports = { DEFAULT_DAYS, JOB, BY, WHY, NEVER, defaultOf, firstDays, defaultedOf, annotate, costOf, dueOf, take, undo, isDefaultBatch, addDays };
|
|
@@ -265,8 +265,12 @@ function fold(lines) {
|
|
|
265
265
|
const expired = []; // expire lines, oldest first (History and Your move's "N expired")
|
|
266
266
|
const removes = []; // remove lines, oldest first: a deleted prototype version (removedOf)
|
|
267
267
|
let t = '', epoch = '';
|
|
268
|
+
// default-decisions-with-a-deadline: a drop PMOS took as a default carries its batch; the Undo of that batch reads it as never written
|
|
269
|
+
const undoneB = new Set();
|
|
270
|
+
for (const l of lines || []) if (isObj(l) && l.kind === 'undo' && str(l.batch)) undoneB.add(l.batch);
|
|
268
271
|
for (const l of lines || []) {
|
|
269
272
|
if (!isObj(l) || !KINDS.has(l.kind)) continue;
|
|
273
|
+
if (l.kind === 'drop' && str(l.batch) && undoneB.has(l.batch)) continue;
|
|
270
274
|
if (l.at && String(l.at) > t) t = String(l.at);
|
|
271
275
|
const ini = str(l.ini);
|
|
272
276
|
if (l.kind === 'epoch') { if (!epoch) epoch = str(l.at); }
|
|
@@ -102,4 +102,4 @@ function today(stateDir, held, { day, pm, now, extra = [] } = {}) {
|
|
|
102
102
|
return { day, questions: questionsOf(mine, { pm, extra: mineAsks }), later: list.length - mine.length + asks.length - mineAsks.length };
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
module.exports = { questionsOf, today, ownerOf, partOf, LEDGER };
|
|
105
|
+
module.exports = { questionsOf, today, ownerOf, partOf, readDays, LEDGER };
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* line where the work is.
|
|
12
12
|
* GET /api/autonomy/ahead?ws&ini&title → { ok, ws, ini, outcome: { date, metric, src } | null, jobs: [{ date, name, src }] }
|
|
13
13
|
* the initiative's dated things only the server reads, for the Viewer's Coming up list (lib/coming-up.js; batch 29 item 7)
|
|
14
|
-
* POST /api/autonomy/undo { ws, ref } → { ok, back, demoted? } Undo of one change: a Driver proposal (p-…), a ✦ batch (pk
|
|
14
|
+
* POST /api/autonomy/undo { ws, ref } → { ok, back, demoted? } Undo of one change: a Driver proposal (p-…), a ✦ batch (pk-…, also a default PMOS took
|
|
15
|
+
* on a question nobody answered, lib/default-decisions.js) or a lesson (im-…)
|
|
15
16
|
* POST /api/autonomy/seen { ws, job, product, until } → { ok } Home said the demotion once
|
|
16
17
|
* GET /api/autonomy/kinds → { ok, kinds: [{ kind, label, made, kept, undone, auto, set, way, until }], showUntil }
|
|
17
18
|
* How Claude decides (Settings › Claude, boards AwG and AwG2), over every product's state folders: lib/autonomy.js kindsOf. The PM
|
|
@@ -57,6 +58,11 @@ async function undoRef(ctx, w, ref, g) {
|
|
|
57
58
|
const PR = require('./proposals.js');
|
|
58
59
|
const dir = ctx.stateDirFor ? ctx.stateDirFor(w) : null;
|
|
59
60
|
const line = dir ? PR.readLines(PR.ledgerFile(dir)).find((l) => l.kind === 'keep' && l.batch === ref) : null;
|
|
61
|
+
// a default PMOS took on a question nobody answered (lib/default-decisions.js): its Undo brings the question back
|
|
62
|
+
if (!line && dir && require('./default-decisions.js').isDefaultBatch(dir, ref)) {
|
|
63
|
+
const r = require('./default-decisions.js').undo(dir, ref, { product: w.id, actor: g.actor });
|
|
64
|
+
return r.ok ? { status: 200, body: { ok: true, back: true, ...(r.demoted ? { demoted: r.demoted } : {}) } } : bad(r.status || 409, r.error);
|
|
65
|
+
}
|
|
60
66
|
if (!line) return bad(404, 'no change was applied under that id');
|
|
61
67
|
const RP = require('./routes-proposals.js');
|
|
62
68
|
const RB = require('./routes-boards.js');
|
|
@@ -98,6 +98,8 @@ function keepCore(ctx, p, g, f, ini, want, choices = {}, extra = {}) {
|
|
|
98
98
|
function undoCore(ctx, p, g, id) {
|
|
99
99
|
const dir = dirOf(ctx, p.w), F = PR.read(dir);
|
|
100
100
|
const k = F.kept.find((x) => x.batch === id);
|
|
101
|
+
// a default PMOS took on a question nobody answered (lib/default-decisions.js): no keep line, its drops go back
|
|
102
|
+
if (!k && require('./default-decisions.js').isDefaultBatch(dir, id)) { const r = require('./default-decisions.js').undo(dir, id, { product: p.w.id, actor: g.actor }); return r.ok ? { ok: true, back: 1, kept: 0, demoted: r.demoted || null } : { ok: false, status: r.status || 409, error: r.error }; }
|
|
101
103
|
if (!k || F.undone.has(id)) return { ok: false, status: 409, error: 'Nothing to undo' };
|
|
102
104
|
const f = TLR.frame(ctx, p.w, p.board);
|
|
103
105
|
if (!f) return { ok: false, status: 202, error: 'The board is still being read. Try again in a moment.' };
|
|
@@ -16,7 +16,10 @@
|
|
|
16
16
|
* DONE (C2, board CsD): what an agent kept by itself in the last 14 days, one line per batch with its Undo (lib/done-feed.js).
|
|
17
17
|
* QUESTIONS (act-alone-only-with-a-source): { day, questions: [lib/question-batch.js question], later } — the changes PMOS holds for want
|
|
18
18
|
* of a source, one question per owner and initiative, the PM's first; the list is fixed for the day (one line in question-days.jsonl).
|
|
19
|
-
* On the same card (dry-run-tickets-before-build): the dry-run gaps of drafted tickets and the outside sign-offs with no answer.
|
|
19
|
+
* On the same card (dry-run-tickets-before-build): the dry-run gaps of drafted tickets and the outside sign-offs with no answer.
|
|
20
|
+
* DEFAULTS (default-decisions-with-a-deadline, lib/default-decisions.js): each question carries `default` ({ choice, due, n, say } | null),
|
|
21
|
+
* `waits` (why it has no default | null), `waiting` (days on the list) and `cost` (A27: what the wait holds up | null). The read takes the
|
|
22
|
+
* defaults due today (one batch each, with Undo in "PMOS did"), and `taken` lists them. A dry-run gap or a sign-off never defaults. */
|
|
20
23
|
const YM = require('./your-move.js');
|
|
21
24
|
|
|
22
25
|
const localDay = (ms = Date.now()) => { const d = new Date(ms); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
|
|
@@ -68,13 +71,25 @@ function expire(ctx, w, now = Date.now()) {
|
|
|
68
71
|
|
|
69
72
|
/** The day's question list (act-alone-only-with-a-source): the changes PMOS holds for want of a source, one question per owner and
|
|
70
73
|
* initiative, fixed once a day (lib/question-batch.js). Questions for teammates are drafts: nothing is sent. */
|
|
71
|
-
function questions(ctx, w, today) {
|
|
74
|
+
function questions(ctx, w, today, { take = true } = {}) {
|
|
72
75
|
const dir = ctx.stateDirFor ? ctx.stateDirFor(w) : null;
|
|
76
|
+
const QB = require('./question-batch.js'), DD = require('./default-decisions.js');
|
|
73
77
|
let held = [];
|
|
74
78
|
try { held = require('./routes-proposals.js').heldOf(ctx, w); } catch { held = []; }
|
|
75
79
|
let extra = [];
|
|
76
80
|
try { extra = asksOf(w.root); } catch { extra = []; }
|
|
77
|
-
|
|
81
|
+
let Q = QB.today(dir, held, { day: today, extra });
|
|
82
|
+
if (!dir) return Q;
|
|
83
|
+
// default-decisions-with-a-deadline: a change nobody answered by its due day takes its default (PMOS leaves the plan as it is, with
|
|
84
|
+
// Undo); the question then leaves the list. Every question left says its default or why it waits, and what the wait costs (A27).
|
|
85
|
+
let taken = [];
|
|
86
|
+
if (take) {
|
|
87
|
+
try { taken = DD.take(dir, held, { dayLines: QB.readDays(dir), today, product: w.id, settingsDir: ctx.runtimeDir || null }).taken; } catch { taken = []; }
|
|
88
|
+
if (taken.length) { const gone = new Set(taken.flatMap((t) => t.ids)); held = held.filter((h) => !gone.has(String(h.prop.id))); Q = QB.today(dir, held, { day: today, extra }); }
|
|
89
|
+
}
|
|
90
|
+
const PR = require('./proposals.js');
|
|
91
|
+
const questions2 = DD.annotate(Q.questions, held, { dayLines: QB.readDays(dir), lines: PR.readLines(PR.ledgerFile(dir)), today, extra });
|
|
92
|
+
return { ...Q, questions: questions2, ...(taken.length ? { taken: taken.map((t) => ({ batch: t.batch, ini: t.ini, board: t.board, n: t.ids.length, title: t.title })) } : {}) };
|
|
78
93
|
}
|
|
79
94
|
|
|
80
95
|
/** The other asks on the same card (dry-run-tickets-before-build): each ticket's dry-run gaps nobody answered (lib/ticket-dry-run.js),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.672.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.672.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Default decisions with a deadline (initiative default-decisions-with-a-deadline, done test D1-D11): each question on the day's list says its default and due day, or why it waits and what the wait costs (A27); past the due day PMOS takes the default with Undo; irreversible kinds never default. Pure checks, a temp state folder and one scratch server. No connector, model or network.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"default-decisions.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"default-decisions.test.js": 15
|
|
8
|
+
}
|
|
9
|
+
}
|