create-pmos 0.654.0 → 0.655.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 +14 -14
- 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 +13 -0
- package/workspace/guide/agent-capabilities.md +2 -2
- package/workspace/guide/cli.md +1 -0
- package/workspace/guide/settings-and-switches.md +1 -1
- package/workspace/lib/ai-guard.js +9 -7
- package/workspace/lib/autonomy.js +2 -2
- package/workspace/lib/headless.js +1 -1
- package/workspace/lib/job-graph.js +3 -1
- package/workspace/lib/outcome-judge.js +162 -0
- package/workspace/lib/outcome-props.js +115 -11
- package/workspace/lib/outcomes.js +33 -8
- package/workspace/lib/proposal-runs.js +12 -6
- package/workspace/lib/proposals.js +15 -1
- package/workspace/lib/propose-cli.js +36 -1
- package/workspace/lib/routes-proposals.js +30 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/run-tests.js +26 -1
- package/workspace/server.js +3 -0
- package/workspace/skills/initiative-propose.skill +8 -2
- package/workspace/test-lists/outcome-checks-run-themselves.json +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.655.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -33,6 +33,19 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.655.0",
|
|
38
|
+
"at": "2026-11-22T02:03:29.259Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1439,
|
|
43
|
+
"t": "Outcome checks that run themselves",
|
|
44
|
+
"s": "Outcome checks that run themselves",
|
|
45
|
+
"k": "new"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
36
49
|
{
|
|
37
50
|
"v": "0.654.0",
|
|
38
51
|
"at": "2026-11-22T01:23:23.116Z",
|
|
@@ -303,19 +316,6 @@
|
|
|
303
316
|
"k": "fix"
|
|
304
317
|
}
|
|
305
318
|
]
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
"v": "0.629.0",
|
|
309
|
-
"at": "2026-11-19T07:37:18.343Z",
|
|
310
|
-
"f": 4,
|
|
311
|
-
"prs": [
|
|
312
|
-
{
|
|
313
|
-
"n": 1410,
|
|
314
|
-
"t": "Jira read goes where the tickets are, and the sprint read no longer sticks on an old sprint",
|
|
315
|
-
"s": "Jira read goes where the tickets are, and the sprint read no longer sticks on an old sprint",
|
|
316
|
-
"k": "fix"
|
|
317
|
-
}
|
|
318
|
-
]
|
|
319
319
|
}
|
|
320
320
|
]
|
|
321
321
|
}
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T02:03:26Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T02:03:26Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T02:03:26Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.655.0",
|
|
4
|
+
"at": "2026-11-22T02:03:29.259Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1439,
|
|
9
|
+
"t": "Outcome checks that run themselves",
|
|
10
|
+
"s": "Outcome checks that run themselves",
|
|
11
|
+
"k": "new"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
2
15
|
{
|
|
3
16
|
"v": "0.654.0",
|
|
4
17
|
"at": "2026-11-22T01:23:23.116Z",
|
|
@@ -97,7 +97,7 @@ A loop never sends a message, moves a Jira ticket, merges into a product reposit
|
|
|
97
97
|
| [Grill](claude-proposes.md) | Before an initiative leaves a stage, when a forecast turns at risk, when scope or dates move a lot, and once a month on running work with late work. Also when you write "grill this" in the initiative's chat. | The initiative, your stored research, your meeting notes and the decisions that stand | "PMOS grilled it" under the initiative's ✦ | Settings › PMOS › Checks: Off. `PMOS_GRILL=off` |
|
|
98
98
|
| [You decided this before](claude-proposes.md) | You add an initiative that repeats an earlier decision | `DECISIONS.md`, the decision records, the PM journal, `planning/out-of-scope/` and the initiative records | The initiative's ✦ | `pmos ai off past-repeat` |
|
|
99
99
|
| [Initiative descriptions](claude-proposes.md) | Once a day. At most 3 drafts a day for each product. | The PRD's first Problem or Why paragraph, or the record's own first paragraph | "Description" under the initiative's ✦ | `pmos ai off descriptions`. `PMOS_DESCRIPTIONS=off` |
|
|
100
|
-
| [Expected outcomes](claude-proposes.md) | Once a day. At most 3 drafts a day for each product. | The PRD's success criteria, or the anchored key result | "Expected outcome" under the initiative's ✦.
|
|
100
|
+
| [Expected outcomes](claude-proposes.md) | Once a day. At most 3 drafts a day for each product. When a check date passes: the verdict, from the goal's reading or one short run. | The PRD's success criteria, or the anchored key result. For a verdict: the goal's reading, or the lines the run cites | "Expected outcome" under the initiative's ✦. A verdict is recorded with Undo. Your move when PMOS cannot tell. | `pmos ai off outcomes`. `PMOS_OUTCOMES=off` |
|
|
101
101
|
| [Metric drafts](claude-proposes.md) | A product with no North Star, the first 14 days of a quarter, a program with no goal, and an initiative that gets a PRD | The last 8 weeks of real readings | The page of that product, program or initiative | `PMOS_METRIC_DRAFT=off` |
|
|
102
102
|
| [Horizon scan](intelligence-okr-goals.md) | Daily by default, at most once a day, the first time you step away after 09:00. Scan now: at most 3 a day. | The public web for your kept watch list, and your repository | Report documents and proposals you approve | Cadence: Off. `PMOS_SCAN=off` |
|
|
103
103
|
| Live round | When you press ✓ on its ✦ ask, or run `pmos lab round`. Three runs at once. No time limit: you see its progress and can stop it. | The initiative's name, the product's Intent and the PMOS design system; a feedback round also reads the last version. | "PMOS prototyped it" or "PMOS improved it" under the initiative's ✦, each version as soon as it renders. | ✕ on its ✦ ask; Undo after ✓ |
|
|
@@ -131,7 +131,7 @@ Sync by itself is on by default. `PMOS_AUTO_SYNC=0` stops the sync, the repair a
|
|
|
131
131
|
|
|
132
132
|
- It sends, posts, replies, pushes and merges nothing. A message to a person is a draft that you send. A Jira change is a drafted comment in your outbox. These are class C: they always wait for you.
|
|
133
133
|
- It does not create an initiative. The Horizon scan proposes one, and you approve it.
|
|
134
|
-
- It
|
|
134
|
+
- It records a verdict on an outcome only from evidence it cites: the goal's own reading, or the lines a short outcome run read. Each verdict is listed with Undo. When it cannot tell, it records nothing and Your move asks you. A goal it fails to read twice the same way becomes one question for you, not a silent failure.
|
|
135
135
|
|
|
136
136
|
When you ask an agent session to do a piece of work, it can finish it, including acts that were yours alone. Each line it writes names the agent, so you see who did it. See **PM-only acts**.
|
|
137
137
|
|
package/workspace/guide/cli.md
CHANGED
|
@@ -160,6 +160,7 @@ PMOS's background run files proposals with these commands. The server pins the i
|
|
|
160
160
|
- `pmos propose date --json <file|->`: new dates for late or at-risk tasks, with the reason.
|
|
161
161
|
- `pmos propose done --json <file|->`: a task that looks done, with the evidence.
|
|
162
162
|
- `pmos propose name --json <file|->`: tidy names.
|
|
163
|
+
- `pmos propose verdict --json <file|->`: whether an initiative's expected outcome worked, once its check date has passed, with cited evidence. Only the outcome check run can file it. `cant-tell` files nothing, and the check stays with you.
|
|
163
164
|
- `pmos propose status`: what is open, kept and dropped.
|
|
164
165
|
- `pmos propose loose <link|merge|finish|start> --json <file|->`: the clean-up of the work that is not in an initiative. Only the clean-up run can file these, and that run files nothing else. `pmos propose loose status` shows what is open and kept.
|
|
165
166
|
|
|
@@ -283,7 +283,7 @@ PMOS sets these in the environment of a terminal session or a background run. Do
|
|
|
283
283
|
| `PMOS_CHECK` | Set to `1` inside each product check that `pmos build check` and `pmos build propose` run in a work item's worktree, with no network. A check can read it. | none | — |
|
|
284
284
|
| `PMOS_TEAM_FILE`, `PMOS_TEAM_ROOT`, `PMOS_TEAM_WS`, `PMOS_TEAM_ROLE`, `PMOS_TEAM_RUN`, `PMOS_TEAM_INI`, `PMOS_TEAM_MODE` | Set inside a role agent's run: its ledger, product folder, workspace, role, run, initiative, and whether it proposes or applies (`auto`). | none | — |
|
|
285
285
|
| `PMOS_GRILL_FILE`, `PMOS_GRILL_LOG`, `PMOS_GRILL_ROOT`, `PMOS_GRILL_BOARD`, `PMOS_GRILL_INI`, `PMOS_GRILL_RUN`, `PMOS_GRILL_BUDGET`, `PMOS_GRILL_WS` | Pin a grill run to its ledger, log, repository, board, initiative, run id and budget. No command reads `PMOS_GRILL_WS`. | none | — |
|
|
286
|
-
| `PMOS_PROPOSE_FILE`, `PMOS_PROPOSE_BOARD`, `PMOS_PROPOSE_INI`, `PMOS_PROPOSE_RUN`, `PMOS_PROPOSE_WS` | Pin a proposal run to its ledger, board, initiative and run id. No command reads `PMOS_PROPOSE_WS`. | none | — |
|
|
286
|
+
| `PMOS_PROPOSE_FILE`, `PMOS_PROPOSE_BOARD`, `PMOS_PROPOSE_INI`, `PMOS_PROPOSE_RUN`, `PMOS_PROPOSE_WS`, `PMOS_PROPOSE_ROOT` | Pin a proposal run to its ledger, board, initiative and run id. `PMOS_PROPOSE_ROOT` is the repository an outcome run's verdict citations are checked in. No command reads `PMOS_PROPOSE_WS`. | none | — |
|
|
287
287
|
| `PMOS_METRIC_DRAFT_FILE`, `PMOS_METRIC_DRAFT_SCOPE`, `PMOS_METRIC_DRAFT_ID`, `PMOS_METRIC_DRAFT_RUN`, `PMOS_METRIC_DRAFT_WS` | Pin a metric draft run to its ledger, scope, id and run id. No command reads `PMOS_METRIC_DRAFT_WS`. | none | — |
|
|
288
288
|
| `PMOS_METRIC_READ_FILE`, `PMOS_METRIC_READ_RECORDS`, `PMOS_METRIC_READ_DRAFTS`, `PMOS_METRIC_READ_WS`, `PMOS_METRIC_READ_RUN`, `PMOS_METRIC_READ_RIDS`, `PMOS_METRIC_READ_TEST` | Pin a goal reading run to its ledger, records, drafts, workspace, run id, goals and test mode. | none | — |
|
|
289
289
|
| `PMOS_IMPACT_FILE`, `PMOS_IMPACT_RUN` | Pin an impact run to its ledger and run id. | none | — |
|
|
@@ -33,9 +33,11 @@
|
|
|
33
33
|
*
|
|
34
34
|
* off(job, { env, settingsDir }) → null | reason
|
|
35
35
|
* check(p, { root, stateDir }) → { ok, p, errors }
|
|
36
|
-
* replay(job, version, cases, { root, stateDir }) → Promise<{ ok, failed: [{ name, why }] }>
|
|
36
|
+
* replay(job, version, cases, { root, stateDir, refDir? }) → Promise<{ ok, failed: [{ name, why }] }>
|
|
37
|
+
* refDir: the folder `state:` refs resolve in, when it is not stateDir (a product's own state folder, while the audit and the replay
|
|
38
|
+
* record stay in the per-user runtime folder: lib/outcome-props.js)
|
|
37
39
|
* ready(stateDir, job, version) → bool
|
|
38
|
-
* file({ job, version, run, root, stateDir, settingsDir?, env?, max? }, proposals, deliver) → Promise<{ filed, dropped, held?, off? }>
|
|
40
|
+
* file({ job, version, run, root, stateDir, refDir?, settingsDir?, env?, max? }, proposals, deliver) → Promise<{ filed, dropped, held?, off? }>
|
|
39
41
|
* audit(stateDir, line) · readAudit(stateDir, { job?, limit? }) → [line] · status({ stateDir, settingsDir, env }) → summary
|
|
40
42
|
* setOff(settingsDir, job | null, off) → { ok } | { ok: false, error }
|
|
41
43
|
*/
|
|
@@ -258,7 +260,7 @@ function expectFails(name, expect, got) {
|
|
|
258
260
|
}
|
|
259
261
|
|
|
260
262
|
/** Run a job's replay cases plus the guard's negatives; record the result for (job, version). */
|
|
261
|
-
async function replay(job, version, cases, { root, stateDir, max = MAX } = {}) {
|
|
263
|
+
async function replay(job, version, cases, { root, stateDir, refDir = null, max = MAX } = {}) {
|
|
262
264
|
const failed = [];
|
|
263
265
|
let seed = null;
|
|
264
266
|
if (!JOB_ID.test(String(job || ''))) return { ok: false, failed: [{ name: 'job', why: 'the job id is not valid' }] };
|
|
@@ -267,13 +269,13 @@ async function replay(job, version, cases, { root, stateDir, max = MAX } = {}) {
|
|
|
267
269
|
const name = one(c && c.name, 120) || '(unnamed)';
|
|
268
270
|
let list;
|
|
269
271
|
try { list = await c.run(); } catch (e) { failed.push({ name, why: 'the case threw: ' + one(e && e.message, 200) }); continue; }
|
|
270
|
-
const got = sift(list, { root, stateDir, max });
|
|
272
|
+
const got = sift(list, { root, stateDir: refDir || stateDir, max });
|
|
271
273
|
const why = expectFails(name, c.expect, got);
|
|
272
274
|
if (why) failed.push({ name, why });
|
|
273
275
|
if (!seed) seed = got.filed.find((p) => p.claims.length) || null;
|
|
274
276
|
}
|
|
275
277
|
if (seed) for (const n of negatives(seed)) {
|
|
276
|
-
const got = sift([n.p], { root, stateDir, max });
|
|
278
|
+
const got = sift([n.p], { root, stateDir: refDir || stateDir, max });
|
|
277
279
|
if (got.filed.length) failed.push({ name: n.name, why: 'the guard filed it' });
|
|
278
280
|
} else if (!failed.length) failed.push({ name: '(negatives)', why: 'no case filed a cited proposal, so the guard could not test its own drops; add a case that files one' });
|
|
279
281
|
const ok = !failed.length;
|
|
@@ -289,7 +291,7 @@ async function replay(job, version, cases, { root, stateDir, max = MAX } = {}) {
|
|
|
289
291
|
/* ── the door ────────────────────────────────────────────────────────────────────────────── */
|
|
290
292
|
|
|
291
293
|
async function file(o, proposals, deliver) {
|
|
292
|
-
const { job, version, run = null, root, stateDir, settingsDir = stateDir, env = process.env, max = MAX } = o || {};
|
|
294
|
+
const { job, version, run = null, root, stateDir, refDir = null, settingsDir = stateDir, env = process.env, max = MAX } = o || {};
|
|
293
295
|
const base = { job, version: String(version), ...(run ? { run } : {}) };
|
|
294
296
|
if (!JOB_ID.test(String(job || ''))) return { filed: [], dropped: [], error: 'the job id is not valid' };
|
|
295
297
|
const why = off(job, { env, settingsDir });
|
|
@@ -299,7 +301,7 @@ async function file(o, proposals, deliver) {
|
|
|
299
301
|
audit(stateDir, { ...base, event: 'held', n: list.length, why: 'no passing replay for this version' });
|
|
300
302
|
return { filed: [], dropped: [], held: true };
|
|
301
303
|
}
|
|
302
|
-
const got = sift(list, { root, stateDir, max });
|
|
304
|
+
const got = sift(list, { root, stateDir: refDir || stateDir, max });
|
|
303
305
|
for (const d of got.dropped) audit(stateDir, { ...base, event: 'dropped', id: d.id, why: one(d.why, 400) });
|
|
304
306
|
if (!got.filed.length) { audit(stateDir, { ...base, event: 'end', filed: 0, dropped: got.dropped.length }); return { filed: [], dropped: got.dropped }; }
|
|
305
307
|
try { await deliver(got.filed); } catch (e) {
|
|
@@ -91,7 +91,7 @@ const KIND_LIST = Object.freeze([
|
|
|
91
91
|
k('notes', 'Notes on where work stands', ['driver:note']),
|
|
92
92
|
k('problem', 'Problem statements and evidence', ['driver:problem', 'driver:evidence', 'driver:sizing', 'driver:assumption', 'driver:stakeholders', 'driver:overlap']),
|
|
93
93
|
k('experiment', 'The experiment and its next step', ['driver:artefact', 'driver:doc', 'driver:next-step']),
|
|
94
|
-
k('outcome', 'Expected outcomes and
|
|
94
|
+
k('outcome', 'Expected outcomes, check dates and whether they worked', ['propose:outcome']),
|
|
95
95
|
k('names', 'Task names', ['propose:names']),
|
|
96
96
|
k('dates', 'Dates moved by evidence', ['propose:dates']),
|
|
97
97
|
k('status', 'Closing tasks Jira marked Done', ['propose:status']),
|
|
@@ -119,7 +119,7 @@ function classOfProposal(p) {
|
|
|
119
119
|
if (!isObj(p)) return 'C';
|
|
120
120
|
const c = PROPOSAL_CLASS[p.group] || 'C';
|
|
121
121
|
if (p.group === 'status' && (p.items || []).some((x) => x && x.jira)) return 'C';
|
|
122
|
-
if (p.group === 'outcome' && p.type === 'refuted') return 'C';
|
|
122
|
+
if (p.group === 'outcome' && (p.type === 'refuted' || p.type === 'source')) return 'C'; // a next step, or the one ask for a source PMOS cannot read
|
|
123
123
|
// D108 as amended 2026-11-16 (Wawan: "Open them automatically"): the factory's pull request opens by itself, from the server (never the
|
|
124
124
|
// Builder's run), and Undo closes it. The guardrail and CI decide merge or review. `pmos ai off` or a demotion returns it to the ✓.
|
|
125
125
|
// a live round's prototype (lib/live-round.js, data.live) is the PM's to keep: PMOS never keeps one by itself (2026-11-18: a test round it
|
|
@@ -679,7 +679,7 @@ const RUN_ENV = Object.freeze(['PMOS_SCAN_FILE', 'PMOS_SCAN_ORIGIN', 'PMOS_SCAN_
|
|
|
679
679
|
'PMOS_CORE_DOC_SCOPE', 'PMOS_CORE_DOC_KEY', 'PMOS_CORE_DOC_KEYS',
|
|
680
680
|
'PMOS_METRIC_DRAFT_FILE', 'PMOS_METRIC_DRAFT_WS', 'PMOS_METRIC_DRAFT_SCOPE', 'PMOS_METRIC_DRAFT_ID', 'PMOS_METRIC_DRAFT_RUN',
|
|
681
681
|
'PMOS_METRIC_READ_FILE', 'PMOS_METRIC_READ_RECORDS', 'PMOS_METRIC_READ_DRAFTS', 'PMOS_METRIC_READ_WS', 'PMOS_METRIC_READ_RUN', 'PMOS_METRIC_READ_RIDS', 'PMOS_METRIC_READ_TEST',
|
|
682
|
-
'PMOS_PROPOSE_FILE', 'PMOS_PROPOSE_WS', 'PMOS_PROPOSE_BOARD', 'PMOS_PROPOSE_INI', 'PMOS_PROPOSE_RUN',
|
|
682
|
+
'PMOS_PROPOSE_FILE', 'PMOS_PROPOSE_WS', 'PMOS_PROPOSE_BOARD', 'PMOS_PROPOSE_INI', 'PMOS_PROPOSE_RUN', 'PMOS_PROPOSE_ROOT',
|
|
683
683
|
'PMOS_GRILL_FILE', 'PMOS_GRILL_LOG', 'PMOS_GRILL_WS', 'PMOS_GRILL_BOARD', 'PMOS_GRILL_INI', 'PMOS_GRILL_RUN', 'PMOS_GRILL_BUDGET',
|
|
684
684
|
'PMOS_IMPACT_FILE', 'PMOS_IMPACT_RUN', 'PMOS_VERIFY_RUN', 'PMOS_REVIEW_RUN', 'PMOS_IMPROVE_RUN', 'PMOS_IMPROVE_WS', 'PMOS_IMPROVE_AREA', 'PMOS_IMPROVE_STATE', 'PMOS_IMPROVE_ROOT', 'PMOS_CHECK_REF', 'PMOS_CHECK_DIR', 'PMOS_MS_REVIEW_FILE', 'PMOS_MS_REVIEW_RUN', 'PMOS_MS_REVIEW_PROGRAM',
|
|
685
685
|
'PMOS_TEAM_FILE', 'PMOS_TEAM_ROOT', 'PMOS_TEAM_WS', 'PMOS_TEAM_ROLE', 'PMOS_TEAM_RUN', 'PMOS_TEAM_INI', 'PMOS_TEAM_MODE',
|
|
@@ -67,6 +67,8 @@ const LEDGERS = Object.freeze({
|
|
|
67
67
|
r('lib/routes-forecast.js', null, 'the forecast on the Board and Intelligence')] },
|
|
68
68
|
'<state>/scan.jsonl': { concept: 'horizon-scan', owner: 'lib/scan.js', readers: [
|
|
69
69
|
r('lib/routes-scan.js', null, 'the Horizon scan results')] },
|
|
70
|
+
'<state>/outcome-runs.jsonl': { concept: 'outcome-runs', owner: 'lib/outcome-props.js', readers: [
|
|
71
|
+
r('lib/outcome-props.js', 'runsOf', 'one outcome run per initiative and check date')] },
|
|
70
72
|
'<state>/drift.jsonl': { concept: 'drift', owner: 'lib/drift.js', readers: [
|
|
71
73
|
r('lib/routes-drift.js', null, "What you might have missed, in Home's chat")] },
|
|
72
74
|
'<runtime>/idle-lab.jsonl': { concept: 'idle-lab', owner: 'lib/idle-lab.js', readers: [
|
|
@@ -164,7 +166,7 @@ const JOBS = Object.freeze([
|
|
|
164
166
|
q('meeting-prewarm', 'lib/live-round-meeting.js', ['<runtime>/idle-lab/meeting-prewarm.jsonl'], [props, 'calendar', '<runtime>/meeting-material.jsonl'], 'round 1 itself is filed by lib/live-round.js (W1)'),
|
|
165
167
|
ai('past-repeat', 'lib/past-repeat.js', [props], ['repo:DECISIONS.md']),
|
|
166
168
|
ai('decision-memory', 'lib/decision-memory.js', [props], ['repo:DECISIONS.md']),
|
|
167
|
-
ai('outcomes', 'lib/outcome-props.js', [props], ['initiative records']),
|
|
169
|
+
ai('outcomes', 'lib/outcome-props.js', [props, '<state>/outcome-runs.jsonl'], ['initiative records', 'repo:planning/runs/outcome_checks.jsonl', '<state>/metric-reads.jsonl']),
|
|
168
170
|
ai('descriptions', 'lib/description-props.js', [props], ['initiative records']),
|
|
169
171
|
ai('drift', 'lib/drift-runs.js', ['<state>/drift.jsonl'], ['<state>/boards.jsonl']),
|
|
170
172
|
ai('rehearse', 'lib/rehearse-guard.js', [], ['task links']),
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* outcome-judge.js — PMOS checks an outcome by itself when its check date passes (initiative outcome-checks-run-themselves; bet 1 of the
|
|
3
|
+
* factory line, proof A3). Pure apart from reading the product's own ledgers; no model, no clock of its own (`today` comes in).
|
|
4
|
+
*
|
|
5
|
+
* judge({ root, it, src, recordsDir, stateDir, today }) → one of
|
|
6
|
+
* { kind: 'verdict', disposition: validated | refuted, evidence, reading, rec, claims } the anchor goal's own reading decides it
|
|
7
|
+
* { kind: 'cant', rid, goal, why, repeats, claims } PMOS could not read that goal; repeats = the identical failures in a row
|
|
8
|
+
* { kind: 'none', why } nothing here decides it: a short run reads the records (lib/proposal-runs.js `outcome`)
|
|
9
|
+
* drafts(S, { src, recordsDir, stateDir, refDir, only }) → [{ judged, draft }] the ai-guard drafts (lib/ai-guard.js) of the due outcomes
|
|
10
|
+
* verdict class B: recorded by itself with Undo (lib/routes-proposals.js applyOne → lib/outcomes.js recordCheck)
|
|
11
|
+
* source class C: ONE ask to the PM, filed at the second identical "can't read" of the goal the outcome rests on
|
|
12
|
+
* barOf(text) → { lt, inclusive, v, pct } | null the number and direction an expected outcome names ("at least 70%", "≤ 2 hours")
|
|
13
|
+
* ASK_AFTER identical failures before the one ask (2)
|
|
14
|
+
*
|
|
15
|
+
* WHAT DECIDES (nothing else does; a reading never says more than it read):
|
|
16
|
+
* 1. The initiative's anchor (parent_kr) resolves to a goal record (lib/goal-source.js resolve) with a reading taken no earlier than the check
|
|
17
|
+
* date less the goal's own staleness window (lib/goal-status.js staleDays), and no later than today.
|
|
18
|
+
* 2. The expected outcome names a number with a direction: the reading meets it → validated, misses it → refuted.
|
|
19
|
+
* It names none: the goal's own target. Reached → validated. Not reached → no verdict (the initiative may move only part of it).
|
|
20
|
+
* A limit goal (Stay within) is never judged from its target here: the run reads it.
|
|
21
|
+
* 3. No fresh reading, and the goal's reads failed since its last good one → `cant`, with the failures cited.
|
|
22
|
+
* Every verdict cites the reading's own line in kr-metrics.jsonl and the record's outcome_metric line. With no citable line there is no verdict.
|
|
23
|
+
*/
|
|
24
|
+
const fs = require('fs');
|
|
25
|
+
const path = require('path');
|
|
26
|
+
const O = require('./outcomes.js');
|
|
27
|
+
|
|
28
|
+
const ASK_AFTER = 2;
|
|
29
|
+
const DAY = 864e5;
|
|
30
|
+
const fin = (v) => typeof v === 'number' && Number.isFinite(v);
|
|
31
|
+
const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length <= n ? t : t.slice(0, n - 1).replace(/[,;:\s]+$/, '') + '…'; };
|
|
32
|
+
const rel = (root, f) => path.relative(root, f).split(path.sep).join('/');
|
|
33
|
+
const inside = (base, f) => { const b = path.resolve(base), a = path.resolve(f); return a === b || a.startsWith(b + path.sep); };
|
|
34
|
+
const dayMs = (d) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(d || '')); return m ? Date.UTC(+m[1], +m[2] - 1, +m[3]) : null; };
|
|
35
|
+
const addDays = (d, n) => new Date(dayMs(d) + n * DAY).toISOString().slice(0, 10);
|
|
36
|
+
const linesOf = (f) => { try { return fs.readFileSync(f, 'utf8').split('\n'); } catch { return null; } };
|
|
37
|
+
const parse = (s) => { try { const o = JSON.parse(s); return o && typeof o === 'object' ? o : null; } catch { return null; } };
|
|
38
|
+
const fmt = (v, unit) => { const r = Math.abs(v) >= 100 ? Math.round(v) : Math.round(v * 100) / 100, s = Math.abs(r) >= 1000 ? r.toLocaleString('en-US') : String(r), u = String(unit || '').trim(); return u ? (/^[A-Za-z]/.test(u) ? s + ' ' + u : s + u) : s; };
|
|
39
|
+
const norm = (s) => String(s || '').toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim();
|
|
40
|
+
|
|
41
|
+
/* ── the number an expected outcome names ─────────────────────────────────────────────────────────────────── */
|
|
42
|
+
|
|
43
|
+
const N = '(\\d{1,3}(?:,\\d{3})+|\\d+(?:\\.\\d+)?)\\s*(%)?';
|
|
44
|
+
const LT_U = new RegExp('(≤|<=|<|fewer than|less than|lower than|below|under|at most|no more than|drops? (?:to|below)|falls? (?:to|below))\\s*' + N, 'i');
|
|
45
|
+
const GT_U = new RegExp('(≥|>=|>|more than|greater than|higher than|above|over|at least|exceeds?|rises? (?:to|above))\\s*' + N, 'i');
|
|
46
|
+
const INCL = /at most|no more than|at least|≤|≥|<=|>=/i;
|
|
47
|
+
/** The number and direction an expected outcome names. → { lt, inclusive, v, pct } | null (no number with a direction: the goal's target decides) */
|
|
48
|
+
function barOf(text) {
|
|
49
|
+
const t = String(text || '');
|
|
50
|
+
const lt = LT_U.exec(t), gt = GT_U.exec(t);
|
|
51
|
+
const m = lt && gt ? (lt.index <= gt.index ? lt : gt) : lt || gt;
|
|
52
|
+
if (!m) return null;
|
|
53
|
+
return { lt: m === lt, inclusive: INCL.test(m[1]), v: Number(m[2].replace(/,/g, '')), pct: !!m[3] };
|
|
54
|
+
}
|
|
55
|
+
const meets = (bar, v) => (bar.lt ? (bar.inclusive ? v <= bar.v : v < bar.v) : (bar.inclusive ? v >= bar.v : v > bar.v));
|
|
56
|
+
|
|
57
|
+
/* ── where each fact sits (path:line and its text, for the citation guard) ───────────────────────────────── */
|
|
58
|
+
|
|
59
|
+
/** A cited source for line n of file f: repository-relative when it is inside the repository, else `state:` relative to refDir. → source | null */
|
|
60
|
+
function srcOf(root, refDir, f, n, text, label) {
|
|
61
|
+
const quote = clip(String(text || '').trim(), 400);
|
|
62
|
+
if (inside(root, f)) return { label, ref: rel(root, f) + ':' + n, quote };
|
|
63
|
+
if (refDir && inside(refDir, f)) return { label, ref: 'state:' + rel(refDir, f) + ':' + n, quote };
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
/** The newest line of kr-metrics.jsonl that holds this reading. → { n, text } | null */
|
|
67
|
+
function readingLine(file, rid, reading) {
|
|
68
|
+
const L = linesOf(file); if (!L) return null;
|
|
69
|
+
for (let i = L.length - 1; i >= 0; i--) {
|
|
70
|
+
const e = parse(L[i]);
|
|
71
|
+
if (e && e.kind === 'reading' && e.rid === rid && e.fields && e.fields.at === reading.at && e.fields.value === reading.value) return { n: i + 1, text: L[i] };
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
/** The goal's failed reads since its last good one, oldest first, from metric-reads.jsonl (a test read never counts). → [{ n, text, why }] */
|
|
76
|
+
function cantsOf(file, rid) {
|
|
77
|
+
const L = linesOf(file); if (!L) return [];
|
|
78
|
+
let out = [];
|
|
79
|
+
L.forEach((raw, i) => {
|
|
80
|
+
const e = parse(raw); if (!e || e.rid !== rid || e.test) return;
|
|
81
|
+
if (e.kind === 'read') out = [];
|
|
82
|
+
else if (e.kind === 'cant') out.push({ n: i + 1, text: raw, why: String(e.why || '').trim() });
|
|
83
|
+
});
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* ── the judgement ───────────────────────────────────────────────────────────────────────────────────────── */
|
|
88
|
+
|
|
89
|
+
function judge({ root, it, src, recordsDir, stateDir, refDir = stateDir, today }) {
|
|
90
|
+
root = path.resolve(root);
|
|
91
|
+
if (!it || !it.horizon) return { kind: 'none', why: 'It has no check date.' };
|
|
92
|
+
const GS = require('./goal-source.js'), ST = require('./goal-status.js');
|
|
93
|
+
const rec = it.anchor ? GS.resolve(src, it.anchor) : null;
|
|
94
|
+
if (!rec) return { kind: 'none', why: it.anchor ? `Its anchor ${it.anchor} has no goal that PMOS reads.` : 'It has no anchor goal.' };
|
|
95
|
+
const goal = clip(rec.title || rec.metric || rec.rid, 80);
|
|
96
|
+
const from = addDays(it.horizon, -ST.staleDays(rec));
|
|
97
|
+
const fresh = (Array.isArray(rec.readings) ? rec.readings : []).filter((x) => x && fin(x.value) && String(x.at || '') >= from && String(x.at || '').slice(0, 10) <= today);
|
|
98
|
+
const metricSrc = it.fm && it.fm.outcome_metric ? srcOf(root, refDir, path.join(root, it.record), it.fm.outcome_metric.n, it.fm.outcome_metric.text, 'Expected outcome') : null;
|
|
99
|
+
|
|
100
|
+
if (!fresh.length) {
|
|
101
|
+
const cants = stateDir ? cantsOf(path.join(stateDir, 'metric-reads.jsonl'), rec.rid) : [];
|
|
102
|
+
if (!cants.length) return { kind: 'none', why: `"${goal}" has no reading since ${from}.` };
|
|
103
|
+
const last = cants[cants.length - 1];
|
|
104
|
+
let repeats = 0;
|
|
105
|
+
for (let i = cants.length - 1; i >= 0 && norm(cants[i].why) === norm(last.why); i--) repeats++;
|
|
106
|
+
const file = path.join(stateDir, 'metric-reads.jsonl');
|
|
107
|
+
const sources = cants.slice(-repeats).slice(-3).map((c) => srcOf(root, refDir, file, c.n, c.text, 'PMOS could not read it')).filter(Boolean);
|
|
108
|
+
return { kind: 'cant', rid: rec.rid, goal, why: last.why || 'no reason given', repeats, claims: sources.length ? [{ text: `PMOS could not read "${goal}" ${repeats} time${repeats === 1 ? '' : 's'} in a row: ${clip(last.why, 160)}`, sources }] : [] };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const reading = fresh[fresh.length - 1], v = reading.value;
|
|
112
|
+
const bar = barOf(it.metric);
|
|
113
|
+
let disposition = null, said = '';
|
|
114
|
+
if (bar) {
|
|
115
|
+
disposition = meets(bar, v) ? 'validated' : 'refuted';
|
|
116
|
+
said = `${disposition === 'validated' ? 'meets' : 'misses'} the ${bar.lt ? (bar.inclusive ? 'at most' : 'below') : (bar.inclusive ? 'at least' : 'above')} ${fmt(bar.v, bar.pct ? '%' : '')} it expected`;
|
|
117
|
+
} else if (!ST.isLimit(rec) && fin(Number(rec.target)) && fin(Number(rec.baseline)) && Number(rec.target) !== Number(rec.baseline)) {
|
|
118
|
+
const target = Number(rec.target), up = target > Number(rec.baseline);
|
|
119
|
+
if (up ? v >= target : v <= target) { disposition = 'validated'; said = `reached its target of ${fmt(target, rec.unit)}`; }
|
|
120
|
+
else return { kind: 'none', why: `"${goal}" reads ${fmt(v, rec.unit)}, short of its target of ${fmt(target, rec.unit)}, and the expected outcome names no number of its own.` };
|
|
121
|
+
} else return { kind: 'none', why: 'The expected outcome names no number, and the goal has no target PMOS can compare with.' };
|
|
122
|
+
|
|
123
|
+
const file = path.join(recordsDir || GS.recordsDirOf(root), 'kr-metrics.jsonl');
|
|
124
|
+
const line = readingLine(file, rec.rid, reading);
|
|
125
|
+
const rsrc = line ? srcOf(root, refDir, file, line.n, line.text, 'The goal\'s reading') : null;
|
|
126
|
+
if (!rsrc) return { kind: 'none', why: 'The reading could not be cited by its line.' };
|
|
127
|
+
const evidence = clip(`"${goal}" read ${fmt(v, rec.unit)} on ${String(reading.at).slice(0, 10)}${reading.source ? ' (' + reading.source + ')' : ''}, which ${said}. Source: ${rsrc.ref}`, 600);
|
|
128
|
+
const claims = [{ text: `"${goal}" read ${fmt(v, rec.unit)} on ${String(reading.at).slice(0, 10)}`, sources: [rsrc] }];
|
|
129
|
+
if (metricSrc) claims.push({ text: `It expected: ${clip(it.metric, 160)}`, sources: [metricSrc] });
|
|
130
|
+
return { kind: 'verdict', disposition, evidence, reading, rec, claims };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const WORDS = Object.freeze({ validated: 'It worked', refuted: 'It did not work' });
|
|
134
|
+
|
|
135
|
+
/** The drafts of the due outcomes of one scan (lib/outcomes.js scan). → [{ judged, it, draft | null }] (draft null: nothing to file now) */
|
|
136
|
+
function drafts(S, { src, recordsDir, stateDir, refDir = stateDir, only = null } = {}) {
|
|
137
|
+
const out = [];
|
|
138
|
+
for (const it of S.due) {
|
|
139
|
+
if (only && it.id !== only) continue;
|
|
140
|
+
const j = judge({ root: S.root, it, src, recordsDir, stateDir, refDir, today: S.today });
|
|
141
|
+
let draft = null;
|
|
142
|
+
if (j.kind === 'verdict') {
|
|
143
|
+
draft = {
|
|
144
|
+
id: `outcome-verdict:${it.id}:${it.horizon}`, cls: 'B', confidence: 'medium', claims: j.claims,
|
|
145
|
+
title: `${WORDS[j.disposition]}: ${clip(it.title, 80)}`,
|
|
146
|
+
say: `Its check date was ${O.short(it.horizon)}. ${j.evidence.replace(/ Source: .*$/, '')} PMOS recorded "${j.disposition === 'validated' ? 'worked' : 'didn\'t work'}". Undo takes it back.`,
|
|
147
|
+
data: { kind: 'verdict', initiative: it.id, disposition: j.disposition, evidence: j.evidence, horizon: it.horizon },
|
|
148
|
+
};
|
|
149
|
+
} else if (j.kind === 'cant' && j.repeats >= ASK_AFTER && j.claims.length) {
|
|
150
|
+
draft = {
|
|
151
|
+
id: `outcome-source:${it.id}:${j.rid}`, cls: 'C', confidence: 'medium', claims: j.claims,
|
|
152
|
+
title: `PMOS can't read "${clip(j.goal, 60)}"`,
|
|
153
|
+
say: `PMOS tried to read "${j.goal}" ${j.repeats} times and could not: ${clip(j.why, 200)}. Until it can, the outcome of ${clip(it.title, 80)} can't be checked. Connect the source, or pick another number to steer by. ✓ adds this as a task for you.`,
|
|
154
|
+
data: { kind: 'source', initiative: it.id, rid: j.rid, goal: j.goal, why: clip(j.why, 300), repeats: j.repeats, horizon: it.horizon },
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
out.push({ judged: j, it, draft });
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
module.exports = { judge, drafts, barOf, ASK_AFTER, WORDS };
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* No model and no session: the drafts are the PRD's and the KR's own words, each claim cited with path:line and that line's text.
|
|
12
12
|
*
|
|
13
13
|
* THE DOOR. Every draft goes through lib/ai-guard.js file(): the kill switch (PMOS_AI, PMOS_AI_OUTCOMES, Settings), the citation check and the
|
|
14
|
-
* audit. Its replay gate is per product (version `outcomes-
|
|
14
|
+
* audit. Its replay gate is per product (version `outcomes-2:<ws>`): before a product's first filing the server replays the drafts on that
|
|
15
15
|
* product's real records, with the guard's planted fabrications, and files nothing until that passed. The audit and the replay record live in
|
|
16
16
|
* the per-user runtime folder, never in the repository.
|
|
17
17
|
*
|
|
@@ -23,10 +23,18 @@
|
|
|
23
23
|
* that says it did not work, files PMOS's next step under the ✦ (lib/outcomes.js refutedDrafts): stop it when the evidence meets the
|
|
24
24
|
* kill condition, a new experiment after a second refuted check, else one more round. Class C (lib/autonomy.js): only the PM's ✓ does it.
|
|
25
25
|
*
|
|
26
|
+
* A DUE CHECK (initiative outcome-checks-run-themselves, bet 1 of the factory line). Every tick in the hours the PM allows, PMOS judges each
|
|
27
|
+
* outcome whose check date passed (duePass, lib/outcome-judge.js): the anchor goal's own reading files a verdict ✦ (class B: recorded by
|
|
28
|
+
* itself with Undo); a goal PMOS failed to read twice the same way files ONE ask (class C); else one short run per initiative and check date
|
|
29
|
+
* reads the records (deps.startRun, <state>/outcome-runs.jsonl). What none of these can tell stays due, and Your move asks the PM once.
|
|
30
|
+
*
|
|
26
31
|
* deps: { workspaces() → [w], isLead(w), stateDirFor(w), boardOf(w, id) → board id | null, runtime() → the per-user state folder, open(now),
|
|
27
|
-
* env, every (ms, its own timer), mayRun(), warn(what, err)
|
|
32
|
+
* env, every (ms, its own timer), mayRun(), warn(what, err),
|
|
33
|
+
* recordsDir(w)? → the goal records folder, startRun(w, { ini, board, it, why, now })? → { ok, run } | { ok: false, held?, error } }
|
|
28
34
|
*/
|
|
29
35
|
const crypto = require('crypto');
|
|
36
|
+
const fs = require('fs');
|
|
37
|
+
const path = require('path');
|
|
30
38
|
const O = require('./outcomes.js');
|
|
31
39
|
const PR = require('./proposals.js');
|
|
32
40
|
|
|
@@ -36,12 +44,21 @@ const off = (env) => flagOff((env || process.env).PMOS_OUTCOMES);
|
|
|
36
44
|
const localDay = (ms) => { const d = new Date(ms); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
|
|
37
45
|
const guardLib = () => { try { return require('./ai-guard.js'); } catch { return null; } };
|
|
38
46
|
const versionOf = (w) => O.VERSION + ':' + w.id;
|
|
39
|
-
const typeOf = (d) => (d.data.kind === 'undated' ? 'date' : d.data.kind === 'refuted' ? 'refuted' : 'new');
|
|
47
|
+
const typeOf = (d) => (d.data.kind === 'undated' ? 'date' : d.data.kind === 'refuted' ? 'refuted' : d.data.kind === 'verdict' ? 'verdict' : d.data.kind === 'source' ? 'source' : 'new');
|
|
48
|
+
const J = require('./outcome-judge.js');
|
|
49
|
+
const RUNS = 'outcome-runs.jsonl'; // <state>/outcome-runs.jsonl: one line per outcome run started { ini, horizon, run, at }
|
|
50
|
+
const RUNS_PER_PASS = 1; // a backlog of due checks starts one run per pass (the machine runs at most 2 at once)
|
|
40
51
|
|
|
41
52
|
/** The proposals line a draft becomes. */
|
|
42
53
|
function lineOf(d, board, run) {
|
|
43
54
|
const type = typeOf(d), ini = d.data.initiative;
|
|
44
55
|
const sources = d.claims.flatMap((c) => c.sources).map((s) => ({ label: s.label, ref: s.ref }));
|
|
56
|
+
if (type === 'verdict' || type === 'source') {
|
|
57
|
+
// PMOS's own verdict (class B, with Undo) or the one ask for a goal it cannot read (class C): one per initiative and check date / goal
|
|
58
|
+
const items = type === 'verdict' ? [{ id: 'verdict', title: J.WORDS[d.data.disposition] || 'Checked' }] : [{ id: 'source', title: 'Connect the source, or pick another number' }];
|
|
59
|
+
const c = PR.clean('outcome', type, { title: d.title, why: d.say, sources, items, data: d.data });
|
|
60
|
+
return c.error ? null : { kind: 'propose', ini, board, run, id: PR.idOf(ini, 'outcome', type, type === 'verdict' ? d.data.horizon : d.data.rid), ...c.prop };
|
|
61
|
+
}
|
|
45
62
|
if (type === 'refuted') {
|
|
46
63
|
// one per check: a later refuted check files again (its key is the check's own line)
|
|
47
64
|
const c = PR.clean('outcome', 'refuted', { title: d.title, why: d.say, sources, items: [{ id: 'next', title: O.NEXT_WORDS[d.data.next], ...(d.data.horizon ? { due: d.data.horizon } : {}) }], data: d.data });
|
|
@@ -73,7 +90,7 @@ function create(deps) {
|
|
|
73
90
|
// a record that has its outcome now: its open draft goes (zero is silence)
|
|
74
91
|
const has = new Map(S.subjects.map((it) => [it.id, it]));
|
|
75
92
|
for (const p of F.props.values()) {
|
|
76
|
-
if (p.group !== 'outcome' || p.type === 'refuted' || kept.has(p.id)) continue; //
|
|
93
|
+
if (p.group !== 'outcome' || p.type === 'refuted' || p.type === 'verdict' || p.type === 'source' || kept.has(p.id)) continue; // refutedPass and duePass keep theirs
|
|
77
94
|
const it = has.get(p.ini), sig = PR.sigOf(p);
|
|
78
95
|
if (F.drops.has(sig)) continue;
|
|
79
96
|
if (!it || (it.metric && (p.type === 'new' || it.horizon))) PR.append(dir, { by: 'pmos:outcomes' }, { kind: 'drop', ini: p.ini, sig });
|
|
@@ -92,11 +109,11 @@ function create(deps) {
|
|
|
92
109
|
const AG = guardLib(); if (!AG) return { ws: w.id, filed: 0, why: 'the shared guard is not installed' };
|
|
93
110
|
const version = versionOf(w), run = 'oc' + now.toString(36) + crypto.randomBytes(3).toString('hex');
|
|
94
111
|
if (!AG.off(O.JOB, { env: deps.env || process.env, settingsDir: rt }) && !AG.ready(rt, O.JOB, version)) {
|
|
95
|
-
const rep = await AG.replay(O.JOB, version, cases(S, fresh.map((x) => x.d)), { root: w.root, stateDir: rt, max: PER_DAY });
|
|
112
|
+
const rep = await AG.replay(O.JOB, version, cases(S, fresh.map((x) => x.d)), { root: w.root, stateDir: rt, refDir: dir, max: PER_DAY });
|
|
96
113
|
if (!rep.ok) { warn('outcomes replay ' + w.id, new Error(rep.failed.map((f) => f.name + ': ' + f.why).join('; '))); return { ws: w.id, filed: 0, replay: rep }; }
|
|
97
114
|
}
|
|
98
115
|
const byId = new Map(fresh.map((x) => [x.d.id, x]));
|
|
99
|
-
const r = await AG.file({ job: O.JOB, version, run, root: w.root, stateDir: rt, settingsDir: rt, env: deps.env || process.env, max: PER_DAY }, fresh.map((x) => x.d),
|
|
116
|
+
const r = await AG.file({ job: O.JOB, version, run, root: w.root, stateDir: rt, refDir: dir, settingsDir: rt, env: deps.env || process.env, max: PER_DAY }, fresh.map((x) => x.d),
|
|
100
117
|
async (acc) => { for (const p of acc) { const x = byId.get(p.id); const l = x && lineOf(x.d, x.board, run); if (l) PR.append(dir, { by: 'agent:outcomes' }, l); } });
|
|
101
118
|
return { ws: w.id, filed: (r.filed || []).length, held: !!r.held, off: r.off || null };
|
|
102
119
|
}
|
|
@@ -125,15 +142,78 @@ function create(deps) {
|
|
|
125
142
|
const AG = guardLib(); if (!AG) return { ws: w.id, filed: 0, why: 'the shared guard is not installed' };
|
|
126
143
|
const rt = deps.runtime && deps.runtime(), version = versionOf(w), run = 'or' + now.toString(36) + crypto.randomBytes(3).toString('hex');
|
|
127
144
|
if (!AG.off(O.JOB, { env: deps.env || process.env, settingsDir: rt }) && !AG.ready(rt, O.JOB, version)) {
|
|
128
|
-
const rep = await AG.replay(O.JOB, version, cases(S, fresh.map((x) => x.d)), { root: w.root, stateDir: rt, max: PER_DAY });
|
|
145
|
+
const rep = await AG.replay(O.JOB, version, cases(S, fresh.map((x) => x.d)), { root: w.root, stateDir: rt, refDir: dir, max: PER_DAY });
|
|
129
146
|
if (!rep.ok) { warn('outcomes replay ' + w.id, new Error(rep.failed.map((f) => f.name + ': ' + f.why).join('; '))); return { ws: w.id, filed: 0, replay: rep }; }
|
|
130
147
|
}
|
|
131
148
|
const byId = new Map(fresh.map((x) => [x.d.id, x]));
|
|
132
|
-
const r = await AG.file({ job: O.JOB, version, run, root: w.root, stateDir: rt, settingsDir: rt, env: deps.env || process.env, max: PER_DAY }, fresh.map((x) => x.d),
|
|
149
|
+
const r = await AG.file({ job: O.JOB, version, run, root: w.root, stateDir: rt, refDir: dir, settingsDir: rt, env: deps.env || process.env, max: PER_DAY }, fresh.map((x) => x.d),
|
|
133
150
|
async (acc) => { for (const p of acc) { const x = byId.get(p.id); const l = x && lineOf(x.d, x.board, run); if (l) PR.append(dir, { by: 'agent:outcomes' }, l); } });
|
|
134
151
|
return { ws: w.id, filed: (r.filed || []).length, held: !!r.held, off: r.off || null };
|
|
135
152
|
}
|
|
136
153
|
|
|
154
|
+
/** The due checks (initiative outcome-checks-run-themselves): PMOS judges each one by itself (lib/outcome-judge.js). A goal's own reading
|
|
155
|
+
* that decides it files a verdict ✦ (class B: lib/auto-keep.js records it with Undo); a goal PMOS failed to read twice the same way files
|
|
156
|
+
* ONE ask; anything else starts one short outcome run per initiative and check date (deps.startRun → lib/proposal-runs.js why `outcome`).
|
|
157
|
+
* When neither decides, nothing more is filed: the check stays due and Your move asks the PM (lib/your-move.js verdictsOf). */
|
|
158
|
+
async function duePass(w, { now = Date.now() } = {}) {
|
|
159
|
+
const dir = deps.stateDirFor(w); if (!dir) return { ws: w.id, filed: 0, runs: 0 };
|
|
160
|
+
const S = O.scan(w.root, { today: localDay(now) });
|
|
161
|
+
const F = PR.read(dir), kept = PR.keptIds(F);
|
|
162
|
+
const dueBy = new Map(S.due.map((it) => [it.id, it]));
|
|
163
|
+
// a verdict or ask whose check is no longer due on its date (the PM answered it, or moved the date) goes: zero is silence
|
|
164
|
+
for (const p of F.props.values()) {
|
|
165
|
+
if (p.group !== 'outcome' || (p.type !== 'verdict' && p.type !== 'source') || kept.has(p.id) || F.drops.has(PR.sigOf(p))) continue;
|
|
166
|
+
const it = dueBy.get(p.ini);
|
|
167
|
+
if (!it || (p.data && p.data.horizon && p.data.horizon !== it.horizon)) PR.append(dir, { by: 'pmos:outcomes' }, { kind: 'drop', ini: p.ini, sig: PR.sigOf(p) });
|
|
168
|
+
}
|
|
169
|
+
if (!S.due.length) return { ws: w.id, filed: 0, runs: 0 };
|
|
170
|
+
const AG = guardLib(); if (!AG) return { ws: w.id, filed: 0, runs: 0, why: 'the shared guard is not installed' };
|
|
171
|
+
const rt = deps.runtime && deps.runtime();
|
|
172
|
+
const aiOff = AG.off(O.JOB, { env: deps.env || process.env, settingsDir: rt });
|
|
173
|
+
if (aiOff || off(deps.env)) return { ws: w.id, filed: 0, runs: 0, off: aiOff || 'PMOS_OUTCOMES is off' }; // the switch stops the verdicts and the runs
|
|
174
|
+
const GS = require('./goal-source.js');
|
|
175
|
+
let recordsDir = null; try { recordsDir = (deps.recordsDir && deps.recordsDir(w)) || GS.recordsDirOf(w.root); } catch { recordsDir = GS.recordsDirOf(w.root); }
|
|
176
|
+
let src = null; try { src = GS.source({ root: w.root, recordsDir }); } catch { src = null; }
|
|
177
|
+
const fresh = [], toRun = [];
|
|
178
|
+
const verdictFiled = (ini, horizon) => F.props.has(PR.idOf(ini, 'outcome', 'verdict', horizon));
|
|
179
|
+
for (const x of J.drafts(S, { src, recordsDir, stateDir: dir, refDir: dir })) {
|
|
180
|
+
const board = deps.boardOf(w, x.it.id); if (!board) continue;
|
|
181
|
+
if (x.draft) {
|
|
182
|
+
const l = lineOf(x.draft, board, '');
|
|
183
|
+
if (l && !F.props.has(l.id)) fresh.push({ d: x.draft, board }); // filed once: kept, dropped, undone or waiting, never again
|
|
184
|
+
}
|
|
185
|
+
if (x.judged.kind !== 'verdict' && !verdictFiled(x.it.id, x.it.horizon)) toRun.push({ it: x.it, board, why: x.judged.why });
|
|
186
|
+
}
|
|
187
|
+
let filed = 0, held = false;
|
|
188
|
+
if (fresh.length) {
|
|
189
|
+
const version = versionOf(w), run = 'ov' + now.toString(36) + crypto.randomBytes(3).toString('hex');
|
|
190
|
+
if (!AG.ready(rt, O.JOB, version)) {
|
|
191
|
+
const rep = await AG.replay(O.JOB, version, cases(S, fresh.map((x) => x.d)), { root: w.root, stateDir: rt, refDir: dir, max: PER_DAY });
|
|
192
|
+
if (!rep.ok) { warn('outcomes replay ' + w.id, new Error(rep.failed.map((f) => f.name + ': ' + f.why).join('; '))); return { ws: w.id, filed: 0, runs: 0, replay: rep }; }
|
|
193
|
+
}
|
|
194
|
+
const byId = new Map(fresh.map((x) => [x.d.id, x]));
|
|
195
|
+
const r = await AG.file({ job: O.JOB, version, run, root: w.root, stateDir: rt, refDir: dir, settingsDir: rt, env: deps.env || process.env, max: PER_DAY }, fresh.map((x) => x.d),
|
|
196
|
+
async (acc) => { for (const p of acc) { const x = byId.get(p.id); const l = x && lineOf(x.d, x.board, run); if (l) PR.append(dir, { by: 'agent:outcomes' }, l); } });
|
|
197
|
+
filed = (r.filed || []).length; held = !!r.held;
|
|
198
|
+
if (r.off) return { ws: w.id, filed, runs: 0, off: r.off }; // the AI switch is off: no run either
|
|
199
|
+
}
|
|
200
|
+
let runs = 0;
|
|
201
|
+
if (deps.startRun && toRun.length) {
|
|
202
|
+
const started = runsOf(dir);
|
|
203
|
+
for (const x of toRun) {
|
|
204
|
+
if (runs >= RUNS_PER_PASS) break;
|
|
205
|
+
const key = x.it.id + '|' + x.it.horizon;
|
|
206
|
+
if (started.has(key)) continue; // one run per initiative and check date: what it could not tell, the PM is asked
|
|
207
|
+
let r = null;
|
|
208
|
+
try { r = deps.startRun(w, { ini: x.it.id, board: x.board, it: x.it, why: x.why, now }); } catch (e) { warn('outcome run ' + w.id, e); r = null; }
|
|
209
|
+
if (!r || !r.ok) { if (r && r.held) break; continue; }
|
|
210
|
+
try { fs.mkdirSync(dir, { recursive: true }); fs.appendFileSync(path.join(dir, RUNS), JSON.stringify({ ini: x.it.id, horizon: x.it.horizon, run: r.run || null, at: new Date(now).toISOString() }) + '\n'); } catch (e) { warn('outcome runs ledger', e); }
|
|
211
|
+
runs++;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return { ws: w.id, filed, held, runs };
|
|
215
|
+
}
|
|
216
|
+
|
|
137
217
|
async function tick({ now = Date.now() } = {}) {
|
|
138
218
|
if (off(deps.env) || busy) return { off: off(deps.env), running: busy };
|
|
139
219
|
busy = true;
|
|
@@ -144,8 +224,24 @@ function create(deps) {
|
|
|
144
224
|
try { refuted.push(await refutedPass(w, { now })); } catch (e) { warn('outcomes refuted ' + w.id, e); }
|
|
145
225
|
}
|
|
146
226
|
} finally { busy = false; }
|
|
227
|
+
const due = await dueTick({ now });
|
|
147
228
|
const r = await dailyTick({ now });
|
|
148
|
-
return { ...r, refuted };
|
|
229
|
+
return { ...r, refuted, due };
|
|
230
|
+
}
|
|
231
|
+
/** Every tick in the hours the PM allows (deps.open): the due checks of each product (duePass). */
|
|
232
|
+
async function dueTick({ now = Date.now() } = {}) {
|
|
233
|
+
let open = true;
|
|
234
|
+
try { open = deps.open ? !!deps.open(now) : true; } catch { open = true; }
|
|
235
|
+
if (!open || busy) return [];
|
|
236
|
+
busy = true;
|
|
237
|
+
const out = [];
|
|
238
|
+
try {
|
|
239
|
+
for (const w of deps.workspaces()) {
|
|
240
|
+
try { if (deps.isLead && !deps.isLead(w)) continue; } catch { continue; }
|
|
241
|
+
try { out.push(await duePass(w, { now })); } catch (e) { warn('outcomes due ' + w.id, e); }
|
|
242
|
+
}
|
|
243
|
+
} finally { busy = false; }
|
|
244
|
+
return out;
|
|
149
245
|
}
|
|
150
246
|
async function dailyTick({ now = Date.now() } = {}) {
|
|
151
247
|
let open = true;
|
|
@@ -168,7 +264,15 @@ function create(deps) {
|
|
|
168
264
|
const t = setInterval(() => { try { if (deps.mayRun && !deps.mayRun()) return; } catch { /* no lock: run */ } tick({}).catch((e) => warn('outcomes tick', e)); }, deps.every);
|
|
169
265
|
if (t.unref) t.unref();
|
|
170
266
|
}
|
|
171
|
-
return { tick, runProduct, refutedPass };
|
|
267
|
+
return { tick, runProduct, refutedPass, duePass };
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** The outcome runs started, as `ini|horizon` keys (<state>/outcome-runs.jsonl). */
|
|
271
|
+
function runsOf(dir) {
|
|
272
|
+
const out = new Set();
|
|
273
|
+
let text = ''; try { text = fs.readFileSync(path.join(dir, RUNS), 'utf8'); } catch { return out; }
|
|
274
|
+
for (const l of text.split('\n')) { try { const o = JSON.parse(l); if (o && o.ini && o.horizon) out.add(o.ini + '|' + o.horizon); } catch { /* torn */ } }
|
|
275
|
+
return out;
|
|
172
276
|
}
|
|
173
277
|
|
|
174
278
|
/** The refuted outcomes whose ✦ next step still waits for the PM (launch simulation W6): every current refuted verdict, less the ones whose
|
|
@@ -191,4 +295,4 @@ function waiting(root, stateDir, { today } = {}) {
|
|
|
191
295
|
return out;
|
|
192
296
|
}
|
|
193
297
|
|
|
194
|
-
module.exports = { create, cases, lineOf, off, waiting, PER_DAY };
|
|
298
|
+
module.exports = { create, cases, lineOf, off, waiting, runsOf, PER_DAY, RUNS };
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
const fs = require('fs');
|
|
27
27
|
const path = require('path');
|
|
28
28
|
|
|
29
|
-
const VERSION = 'outcomes-
|
|
29
|
+
const VERSION = 'outcomes-2'; // 2: PMOS's own verdicts and the one ask for an unreadable source (outcome-checks-run-themselves)
|
|
30
30
|
const JOB = 'outcomes';
|
|
31
31
|
const DAY = 86400000;
|
|
32
32
|
const DAYS_AFTER = 30;
|
|
@@ -80,6 +80,14 @@ function ledger(root, L, name) {
|
|
|
80
80
|
|
|
81
81
|
/** The record's check date moved past the one a check answered: the check line's own horizon (written since launch simulation W2), else its
|
|
82
82
|
* date. Then the outcome is open again. */
|
|
83
|
+
/** The outcome checks that stand: a line `{ initiative_id, undo: <at> }` (the PM's Undo of a verdict PMOS recorded by itself, undoCheck) takes the
|
|
84
|
+
* check with that `at` back, and is no check itself. → [row], ledger order */
|
|
85
|
+
function liveChecks(rows) {
|
|
86
|
+
const gone = new Set();
|
|
87
|
+
for (const r of rows || []) if (r && r.initiative_id && typeof r.undo === 'string' && r.undo) gone.add(r.initiative_id + '|' + r.undo);
|
|
88
|
+
return (rows || []).filter((r) => r && !r.undo && !(r.initiative_id && r.at && gone.has(r.initiative_id + '|' + r.at)));
|
|
89
|
+
}
|
|
90
|
+
|
|
83
91
|
const reopened = (it, row) => !!(it.horizon && it.horizon > String(row.horizon || row.date || String(row.at || '').slice(0, 10)));
|
|
84
92
|
|
|
85
93
|
const STOPPED = new Set(['paused', 'cancelled', 'canceled', 'stopped', 'dropped', 'archived', 'killed']);
|
|
@@ -104,7 +112,7 @@ function scan(root, { today = todayOf() } = {}) {
|
|
|
104
112
|
let deleted = new Set();
|
|
105
113
|
try { const D = require('./ini-deleted.js'); if (typeof D.idsOf === 'function') deleted = new Set(D.idsOf(root)); } catch { /* none */ }
|
|
106
114
|
const disposedBy = new Map();
|
|
107
|
-
for (const c of ledger(root, L, 'outcome_checks.jsonl')) if (c && c.initiative_id && DISPOSITIONS.includes(c.disposition)) disposedBy.set(String(c.initiative_id), c);
|
|
115
|
+
for (const c of liveChecks(ledger(root, L, 'outcome_checks.jsonl'))) if (c && c.initiative_id && DISPOSITIONS.includes(c.disposition)) disposedBy.set(String(c.initiative_id), c);
|
|
108
116
|
|
|
109
117
|
const subjects = [], missing = [], undated = [], due = [], pending = [], disposed = [];
|
|
110
118
|
let shippedWithout = 0;
|
|
@@ -375,9 +383,10 @@ function anyRefuted(root) {
|
|
|
375
383
|
/** Every outcome check of the repository with its path:line, oldest first. → [{ row, ref, quote, file, n }] */
|
|
376
384
|
function checkLines(root, L) {
|
|
377
385
|
const files = [...new Set([path.join(L.runsDir, 'outcome_checks.jsonl'), path.join(root, 'pmos', 'state', 'outcome_checks.jsonl'), path.join(root, 'planning', 'runs', 'outcome_checks.jsonl')])];
|
|
378
|
-
const out = [];
|
|
379
|
-
for (const f of files) (linesOf(f) || []).forEach((l, i) => { let o = null; try { o = JSON.parse(l); } catch { return; } if (o && o.initiative_id && DISPOSITIONS.includes(o.disposition)) out.push({ row: o, file: f, n: i + 1, ref: rel(root, f) + ':' + (i + 1), quote: cut(l) }); });
|
|
380
|
-
|
|
386
|
+
const out = [], rows = [];
|
|
387
|
+
for (const f of files) (linesOf(f) || []).forEach((l, i) => { let o = null; try { o = JSON.parse(l); } catch { return; } if (o && o.initiative_id) rows.push(o); if (o && o.initiative_id && DISPOSITIONS.includes(o.disposition)) out.push({ row: o, file: f, n: i + 1, ref: rel(root, f) + ':' + (i + 1), quote: cut(l) }); });
|
|
388
|
+
const live = new Set(liveChecks(rows));
|
|
389
|
+
return out.filter((c) => live.has(c.row)).sort((a, b) => String(a.row.at || a.row.date || '').localeCompare(String(b.row.at || b.row.date || '')));
|
|
381
390
|
}
|
|
382
391
|
|
|
383
392
|
/** The verdict that stands on each initiative: its newest outcome check. A refuted one is CURRENT until the PM chose what next: a check date
|
|
@@ -462,7 +471,7 @@ function setLife(root, id, state, reason, actor) {
|
|
|
462
471
|
/* ── the outcome ledger: the one writer behind `pmos outcomes record` ───────────────────────────────────────── */
|
|
463
472
|
|
|
464
473
|
/** Append the PM's verdict. Evidence is required for all three (an `inconclusive` with no reason is the cheapest lie). */
|
|
465
|
-
function recordCheck(root, { initiative, disposition, evidence, by, via }, { now = Date.now() } = {}) {
|
|
474
|
+
function recordCheck(root, { initiative, disposition, evidence, by, via, sources }, { now = Date.now() } = {}) {
|
|
466
475
|
root = path.resolve(root);
|
|
467
476
|
if (typeof initiative !== 'string' || !ID_RE.test(initiative)) return { ok: false, error: 'name the initiative by its id' };
|
|
468
477
|
if (!DISPOSITIONS.includes(disposition)) return { ok: false, error: `the verdict is one of ${DISPOSITIONS.join(', ')}` };
|
|
@@ -479,11 +488,27 @@ function recordCheck(root, { initiative, disposition, evidence, by, via }, { now
|
|
|
479
488
|
fs.mkdirSync(dir, { recursive: true });
|
|
480
489
|
const st = (() => { try { return fs.lstatSync(file); } catch { return null; } })();
|
|
481
490
|
if (st && !st.isFile()) return { ok: false, error: 'the outcome ledger is not a plain file — nothing was saved' };
|
|
482
|
-
const
|
|
491
|
+
const src = (Array.isArray(sources) ? sources : []).filter((x) => x && typeof x.ref === 'string' && x.ref).slice(0, 6).map((x) => ({ label: clip(x.label || x.ref, 80), ref: clip(x.ref, 200) }));
|
|
492
|
+
const line = { initiative_id: initiative, disposition, evidence: ev, date: todayOf(now), ...(it.horizon ? { horizon: it.horizon } : {}), ...(src.length ? { sources: src } : {}), at: new Date(now).toISOString(), by: by || 'agent:unknown', via: via || 'cli' };
|
|
483
493
|
fs.appendFileSync(file, JSON.stringify(line) + '\n');
|
|
484
494
|
return { ok: true, file: rel(root, file), line };
|
|
485
495
|
} catch (e) { return { ok: false, error: 'the outcome ledger could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
|
|
486
496
|
}
|
|
487
497
|
|
|
488
|
-
|
|
498
|
+
/** Take back one check PMOS recorded by itself (the Undo of its ✦, lib/routes-proposals.js): an `undo` line naming the check's `at`. The check
|
|
499
|
+
* is never rewritten; liveChecks leaves it out, so the outcome is due again. → { ok, file } | { ok: false, error } */
|
|
500
|
+
function undoCheck(root, { initiative, at, by, via }, { now = Date.now() } = {}) {
|
|
501
|
+
root = path.resolve(root);
|
|
502
|
+
if (typeof initiative !== 'string' || !ID_RE.test(initiative)) return { ok: false, error: 'name the initiative by its id' };
|
|
503
|
+
if (typeof at !== 'string' || !at) return { ok: false, error: 'name the check by its time (at)' };
|
|
504
|
+
const L = layoutOf(root), file = path.join(L.runsDir, 'outcome_checks.jsonl');
|
|
505
|
+
try {
|
|
506
|
+
const st = (() => { try { return fs.lstatSync(file); } catch { return null; } })();
|
|
507
|
+
if (!st || !st.isFile()) return { ok: false, error: 'the outcome ledger is not there — nothing to undo' };
|
|
508
|
+
fs.appendFileSync(file, JSON.stringify({ initiative_id: initiative, undo: at, at: new Date(now).toISOString(), by: by || 'pm', via: via || 'ui' }) + '\n');
|
|
509
|
+
return { ok: true, file: rel(root, file) };
|
|
510
|
+
} catch (e) { return { ok: false, error: 'the outcome ledger could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
module.exports = { VERSION, undoCheck, liveChecks, JOB, DAYS_AFTER, DEFAULT_DAYS, DISPOSITIONS, scan, drafts, prdMetric, anchorMetric, horizonFor, recordCheck, todayOf, short, frontOf,
|
|
489
514
|
experimentField, krMismatch, killMet, anyRefuted, verdictsOf, rowOutcomes, outcomeOfRow, refutedDrafts, setLife, NEXT_WORDS };
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
* populate an initiative was just added (devPiRules 1): with no extra press, Claude looks for it in every connected source (the name, the
|
|
10
10
|
* Why, the material and the people in it) and files what it finds as Found elsewhere. The New initiative panel's Create starts it
|
|
11
11
|
* at once (POST /api/proposals/look); the tick starts it for every other way an initiative is made (a `created` placement line).
|
|
12
|
+
* outcome an outcome's check date passed and its goal's own reading did not decide it (lib/outcome-props.js duePass, once per initiative
|
|
13
|
+
* and check date): PMOS reads the initiative's records and files whether it worked with `pmos propose verdict`, each claim cited
|
|
14
|
+
* path:line with its quote, or nothing when it cannot tell (then Your move asks the PM). The verdict is class B: recorded with Undo.
|
|
12
15
|
* check each morning inside the day-check window, once a day per initiative that has a late or at-risk task (devTpRules 1): Claude finds
|
|
13
16
|
* WHY each one slipped (the stored reads, the calendar, meeting notes, chat, Jira status) and files its dates, "looks done" and
|
|
14
17
|
* tidy names. A date that passes shows at once without a run: lib/proposals.js datesOf proposes from the tasks themselves, with
|
|
@@ -16,7 +19,7 @@
|
|
|
16
19
|
*
|
|
17
20
|
* WHAT THE RUN MAY DO (lib/headless.js kind `propose`): read and search the repository, read through the PM's own connectors where the PM's
|
|
18
21
|
* Claude Code settings allow it, and file with `pmos propose`, pinned by the server to this initiative and run (PMOS_PROPOSE_FILE, _WS,
|
|
19
|
-
* _BOARD, _INI, _RUN). It writes no task, no document and no stage: only the PM's ✓ does. Nothing is sent.
|
|
22
|
+
* _BOARD, _INI, _RUN; _ROOT is the repository its verdict's citations are checked in). It writes no task, no document and no stage: only the PM's ✓ does. Nothing is sent.
|
|
20
23
|
*
|
|
21
24
|
* At most 2 runs at once for the machine; one per initiative. A run that ends writes the `end` line; ■ Stop ends it at once.
|
|
22
25
|
*
|
|
@@ -42,6 +45,7 @@ const localDay = (ms) => { const d = new Date(ms); return d.getFullYear() + '-'
|
|
|
42
45
|
const WHY = {
|
|
43
46
|
populate: 'The PM just added this initiative. It most likely already lives elsewhere: find it in every connected source and file what you find (Found elsewhere).',
|
|
44
47
|
check: 'The morning check: some tasks are late or at risk. Find why each one slipped and file new dates, "looks done" and tidy names.',
|
|
48
|
+
outcome: 'Its outcome check date has passed and its goal\'s own reading did not decide it. Read its records and file whether it worked (`pmos propose verdict`), or file nothing when you cannot tell.',
|
|
45
49
|
};
|
|
46
50
|
|
|
47
51
|
function promptOf(skill, o) {
|
|
@@ -49,7 +53,9 @@ function promptOf(skill, o) {
|
|
|
49
53
|
return `${skill}\n\nThis run:\n- Run: ${o.run}\n- Why it runs: ${WHY[o.why] || WHY.check} (${o.why})\n- Today: ${o.today}\n`
|
|
50
54
|
+ `- Initiative: ${o.ini} · ${one(o.title, 140)}${o.intent ? '\n- Its Why: ' + one(o.intent, 600) : ''}\n- Its stage now: ${o.stage || 'the first stage'}\n`
|
|
51
55
|
+ `- Its workflow's stages, in order:\n${list((o.stages || []).map((s) => s.key + ' · ' + s.name), 'not known')}\n`
|
|
52
|
-
+ (o.why === 'check' ? `- Its late and at-risk tasks:\n${list(o.tasks, 'none')}\n`
|
|
56
|
+
+ (o.why === 'check' ? `- Its late and at-risk tasks:\n${list(o.tasks, 'none')}\n`
|
|
57
|
+
: o.why === 'outcome' && o.outcome ? `- Its expected outcome: ${one(o.outcome.metric, 400)}\n- Its check date: ${o.outcome.horizon}\n- Its anchor: ${one(o.outcome.anchor, 120) || 'none'}\n- Its record: ${one(o.outcome.record, 200)}\n- Why the goal's reading did not decide it: ${one(o.outcome.why, 300)}\n`
|
|
58
|
+
: `- The material the PM gave and the people named are in its record and its first questions (\`pmos initiative export ${o.ini}\`).\n`)
|
|
53
59
|
+ `- Dropped by the PM (do not file these again unless the evidence is new):\n${list(o.dropped, 'none')}\n`
|
|
54
60
|
+ (o.lessons && o.lessons.length ? `- What the PM said about your earlier proposals here, newest first (learn from it: file what they would keep):\n${list(o.lessons, 'none')}\n` : '')
|
|
55
61
|
+ '\nFile with `pmos propose` only (the server pins this initiative and run). Report each source as you read it with `pmos propose look`. Send nothing.';
|
|
@@ -94,7 +100,7 @@ function create(deps) {
|
|
|
94
100
|
}
|
|
95
101
|
|
|
96
102
|
/** Start one run now. → { ok, run } | { ok: false, error } */
|
|
97
|
-
function start({ ws, board, ini, why = 'populate', press = true, now = Date.now() } = {}) {
|
|
103
|
+
function start({ ws, board, ini, why = 'populate', press = true, now = Date.now(), outcome = null } = {}) {
|
|
98
104
|
if (off(deps.env) || (deps.headlessOff && deps.headlessOff())) return { ok: false, error: 'PMOS\'s background runs are off (PMOS_PROPOSE or PMOS_HEADLESS)' };
|
|
99
105
|
const w = (deps.workspaces() || []).find((x) => x.id === ws);
|
|
100
106
|
if (!w) return { ok: false, error: 'no such workspace' };
|
|
@@ -111,13 +117,13 @@ function create(deps) {
|
|
|
111
117
|
const lessons = PR.lessonsOf(lines, { ini, match: (p) => ['found', 'dates', 'status', 'names'].includes(p.group), n: 3, wide: true });
|
|
112
118
|
let tasks = [];
|
|
113
119
|
if (why === 'check') { try { const c = (deps.checks(w, localDay(now)) || []).find((x) => x.ini === ini); tasks = c ? c.tasks : []; } catch { tasks = []; } }
|
|
114
|
-
const prompt = promptOf(skill, { run, why, ini, title: row.title || ini, intent: row.intent || '', stage: row.stage || '', stages: row.stages || [], today: localDay(now), tasks, dropped, lessons });
|
|
120
|
+
const prompt = promptOf(skill, { run, why, ini, title: row.title || ini, intent: row.intent || '', stage: row.stage || '', stages: row.stages || [], today: localDay(now), tasks, dropped, lessons, outcome });
|
|
115
121
|
const go = press && deps.spawnNow ? deps.spawnNow : deps.spawn;
|
|
116
122
|
active.set(run, { ws, ini, dir, session: null, why });
|
|
117
123
|
let session = null;
|
|
118
124
|
try {
|
|
119
|
-
session = go({ name: (why === 'check' ? 'Task check · ' : 'Looking for · ') + one(row.title || ini, 60), ws, origin: `propose:${ws}:${ini}:${run}`, initialInput: prompt + '\r', initiative: ini,
|
|
120
|
-
env: { PMOS_PROPOSE_FILE: PR.ledgerFile(dir), PMOS_PROPOSE_WS: ws, PMOS_PROPOSE_BOARD: board || '', PMOS_PROPOSE_INI: ini, PMOS_PROPOSE_RUN: run }, onDone: (r) => ended(run, r) });
|
|
125
|
+
session = go({ name: (why === 'check' ? 'Task check · ' : why === 'outcome' ? 'Outcome check · ' : 'Looking for · ') + one(row.title || ini, 60), ws, origin: `propose:${ws}:${ini}:${run}`, initialInput: prompt + '\r', initiative: ini,
|
|
126
|
+
env: { PMOS_PROPOSE_FILE: PR.ledgerFile(dir), PMOS_PROPOSE_WS: ws, PMOS_PROPOSE_BOARD: board || '', PMOS_PROPOSE_INI: ini, PMOS_PROPOSE_RUN: run, PMOS_PROPOSE_ROOT: w.root }, onDone: (r) => ended(run, r) });
|
|
121
127
|
} catch (e) { warn('proposal run', e); }
|
|
122
128
|
if (session && session.held) { active.delete(run); return { ok: false, held: true, error: 'PMOS is busy with other runs; it looks again in a minute' }; }
|
|
123
129
|
// the look line lands before the run's first `pmos propose look` (the run starts reading after this returns)
|
|
@@ -86,7 +86,7 @@ const KINDS = new Set(['epoch', 'look', 'src', 'end', 'propose', 'drop', 'keep',
|
|
|
86
86
|
const EXPIRE_DAYS = 14;
|
|
87
87
|
const EXPIRE_WHY = 'No answer in 14 days, so I left it as it was.';
|
|
88
88
|
const GROUPS = ['found', 'dates', 'status', 'names', 'outcome', 'description', 'build'];
|
|
89
|
-
const TYPES = { found: ['stage', 'docs', 'tasks', 'link', 'maybe', 'unplaced'], dates: ['stage', 'task'], status: ['done'], names: ['tidy'], outcome: ['new', 'date', 'refuted'], description: ['new', 'enrich'], build: ['pr'] };
|
|
89
|
+
const TYPES = { found: ['stage', 'docs', 'tasks', 'link', 'maybe', 'unplaced'], dates: ['stage', 'task'], status: ['done'], names: ['tidy'], outcome: ['new', 'date', 'refuted', 'verdict', 'source'], description: ['new', 'enrich'], build: ['pr'] };
|
|
90
90
|
const SOURCES = ['drive', 'docs', 'sheets', 'slides', 'jira', 'calendar', 'notes', 'mail', 'slack', 'confluence', 'chat', 'repo'];
|
|
91
91
|
const SOURCE_NAMES = { drive: 'Drive and Slides', docs: 'Docs', sheets: 'Sheets', slides: 'Slides', jira: 'Jira', calendar: 'Calendar and meeting notes', notes: 'Meeting notes',
|
|
92
92
|
mail: 'Gmail', slack: 'Slack', confluence: 'Confluence', chat: 'Chat', repo: 'This repository' };
|
|
@@ -186,6 +186,20 @@ function clean(group, type, input) {
|
|
|
186
186
|
if (d.next === 'iterate' && !DAY_RE.test(str(d.horizon))) return { error: 'data.horizon is the new check date, YYYY-MM-DD' };
|
|
187
187
|
Object.assign(data, { next: d.next, check: str(d.check), ref: one(d.ref, 200), evidence: one(d.evidence, 300), metric: one(d.metric, 300), anchor: one(d.anchor, 120), title: one(d.title, LIM.title),
|
|
188
188
|
lane: one(d.lane, 40), work: one(d.work, 20), killMet: d.killMet === true ? true : d.killMet === false ? false : null, ...(d.next === 'iterate' ? { horizon: str(d.horizon) } : {}) });
|
|
189
|
+
} else if (group === 'outcome' && type === 'verdict') {
|
|
190
|
+
// PMOS's own verdict on a due outcome (initiative outcome-checks-run-themselves; lib/outcome-judge.js, or the outcome run's `pmos propose
|
|
191
|
+
// verdict`). Class B: applied by itself with Undo, it records the check in outcome_checks.jsonl (lib/outcomes.js recordCheck)
|
|
192
|
+
const d = isObj(input.data) ? input.data : {};
|
|
193
|
+
if (!['validated', 'refuted'].includes(d.disposition)) return { error: 'data.disposition is validated or refuted (when PMOS cannot tell, it files nothing: the PM is asked)' };
|
|
194
|
+
const evidence = one(d.evidence, 600);
|
|
195
|
+
if (evidence.length < 12) return { error: 'data.evidence says what shows it, at least 12 characters' };
|
|
196
|
+
if (!DAY_RE.test(str(d.horizon))) return { error: 'data.horizon is the check date it answers, YYYY-MM-DD' };
|
|
197
|
+
Object.assign(data, { disposition: d.disposition, evidence, horizon: str(d.horizon) });
|
|
198
|
+
} else if (group === 'outcome' && type === 'source') {
|
|
199
|
+
// the one ask for a goal PMOS cannot read (lib/outcome-judge.js): class C, ✓ adds a task for the PM
|
|
200
|
+
const d = isObj(input.data) ? input.data : {};
|
|
201
|
+
if (!str(d.rid)) return { error: 'data.rid names the goal record PMOS cannot read' };
|
|
202
|
+
Object.assign(data, { rid: one(d.rid, 80), goal: one(d.goal, 120), why: one(d.why, 300), repeats: Number.isInteger(d.repeats) ? d.repeats : 0, ...(DAY_RE.test(str(d.horizon)) ? { horizon: str(d.horizon) } : {}) });
|
|
189
203
|
} else if (group === 'outcome') {
|
|
190
204
|
const d = isObj(input.data) ? input.data : {};
|
|
191
205
|
const metric = one(d.metric, 300), horizon = str(d.horizon);
|
|
@@ -19,7 +19,7 @@ const fs = require('fs');
|
|
|
19
19
|
const PR = require('./proposals.js');
|
|
20
20
|
const LP = require('./loose-proposals.js');
|
|
21
21
|
|
|
22
|
-
const COMMANDS = { propose: ['look', 'found', 'date', 'done', 'name', 'status', 'loose'] };
|
|
22
|
+
const COMMANDS = { propose: ['look', 'found', 'date', 'done', 'name', 'verdict', 'status', 'loose'] };
|
|
23
23
|
const USAGE = [
|
|
24
24
|
'usage: pmos propose look|found|date|done|name|status — what PMOS proposes on an initiative, under its ✦',
|
|
25
25
|
' pmos propose look <source> --reading | --found <n> --what "<5 documents>" | --none',
|
|
@@ -34,6 +34,9 @@ const USAGE = [
|
|
|
34
34
|
' pmos propose done --json <file|-> { "why", "sources", "items": [{ "task" }] }',
|
|
35
35
|
' pmos propose name --json <file|-> { "why", "sources", "items": [{ "task", "to", "notes"? }] } verb first, sentence case, about 7 words,',
|
|
36
36
|
' the WBS number kept, no "+" and no brackets; the cut detail goes in notes',
|
|
37
|
+
' pmos propose verdict --json <file|-> only in an outcome run: { "disposition": "worked" | "didnt-work" | "cant-tell", "evidence": "<one line>",',
|
|
38
|
+
' "claims": [{ "text", "sources": [{ "label", "ref": "<path:line>", "quote": "<the text on that line>" }] }] } each quote is checked',
|
|
39
|
+
' against its line; a claim that does not match is refused. cant-tell files nothing: the PM is asked.',
|
|
37
40
|
' pmos propose status',
|
|
38
41
|
' pmos propose loose link --json - { "initiative", "title", "why", "items": [{ "row" }] } rows that belong to one open initiative',
|
|
39
42
|
' pmos propose loose merge --json - { "into": "w:<item>", "why", "items": [{ "row": "c:<chat>" }] } a chat that doubles the PM\'s own item',
|
|
@@ -82,6 +85,37 @@ function readJson(src, stdin) {
|
|
|
82
85
|
}
|
|
83
86
|
const flag = (args, k) => { const i = args.indexOf('--' + k); return i >= 0 ? (args[i + 1] === undefined || args[i + 1].startsWith('--') ? true : args[i + 1]) : undefined; };
|
|
84
87
|
|
|
88
|
+
/** `pmos propose verdict`: the outcome run's verdict on a due check (initiative outcome-checks-run-themselves). Every claim's quote must be
|
|
89
|
+
* on its path:line in the repository (lib/ai-guard.js check) or nothing is filed. It files the class B verdict ✦; the server records it
|
|
90
|
+
* with Undo (lib/routes-proposals.js applyOne). "cant-tell" files nothing: the check stays due and Your move asks the PM. */
|
|
91
|
+
const VERDICT = { worked: 'validated', 'didnt-work': 'refuted', validated: 'validated', refuted: 'refuted' };
|
|
92
|
+
function verdict(args, { say, stdin, env, file, runId, ini, board, F, line }) {
|
|
93
|
+
const root = env.PMOS_PROPOSE_ROOT;
|
|
94
|
+
if (!root) { say('✗ pmos propose verdict is for PMOS\'s outcome run (the server pins PMOS_PROPOSE_ROOT)'); return 1; }
|
|
95
|
+
const jsonAt = args.indexOf('--json'), src = jsonAt >= 0 ? args[jsonAt + 1] : null;
|
|
96
|
+
if (!src) { say('usage: pmos propose verdict --json <file|->'); return 2; }
|
|
97
|
+
const r = readJson(src, stdin); if (r.error) { say('✗ ' + r.error); return 1; }
|
|
98
|
+
const b = r.body && typeof r.body === 'object' && !Array.isArray(r.body) ? r.body : {};
|
|
99
|
+
if (b.disposition === 'cant-tell' || b.disposition === 'inconclusive') { say('filed nothing: the check stays due and Your move asks the PM'); return 0; }
|
|
100
|
+
const disposition = VERDICT[b.disposition];
|
|
101
|
+
if (!disposition) { say('✗ refused: disposition is worked, didnt-work or cant-tell'); return 1; }
|
|
102
|
+
const O = require('./outcomes.js'), AG = require('./ai-guard.js'), J = require('./outcome-judge.js');
|
|
103
|
+
const it = O.scan(root).due.find((x) => x.id === ini);
|
|
104
|
+
if (!it) { say(`✗ refused: ${ini} has no outcome check due now`); return 1; }
|
|
105
|
+
const evidence = String(b.evidence || '').replace(/\s+/g, ' ').trim();
|
|
106
|
+
const c0 = AG.check({ id: 'outcome-verdict:' + ini, title: J.WORDS[disposition], say: evidence || '-', confidence: 'medium', cls: 'B', claims: b.claims }, { root, stateDir: require('path').dirname(file) });
|
|
107
|
+
if (!c0.ok) { say('✗ refused: ' + c0.errors.join('; ')); return 1; }
|
|
108
|
+
const sources = c0.p.claims.flatMap((c) => c.sources).filter((x) => x.verified).map((x) => ({ label: x.label, ref: x.ref }));
|
|
109
|
+
const why = `Its check date was ${O.short(it.horizon)}. ${evidence.replace(/[.\s]+$/, '')}. PMOS recorded "${disposition === 'validated' ? 'worked' : 'didn\'t work'}". Undo takes it back.`;
|
|
110
|
+
const c = PR.clean('outcome', 'verdict', { title: `${J.WORDS[disposition]}: ${it.title}`.slice(0, 120), why, sources, items: [{ id: 'verdict', title: J.WORDS[disposition] }], data: { disposition, evidence, horizon: it.horizon } });
|
|
111
|
+
if (c.error) { say('✗ refused: ' + c.error); return 1; }
|
|
112
|
+
const id = PR.idOf(ini, 'outcome', 'verdict', it.horizon);
|
|
113
|
+
if (F.props.has(id)) { say(`already ${id}: a verdict for this check date was filed before`); return 0; }
|
|
114
|
+
line({ kind: 'propose', ini, board, run: runId, id, ...c.prop });
|
|
115
|
+
say(`filed ${id} · outcome/verdict · ${disposition}`);
|
|
116
|
+
return 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
85
119
|
async function run(argv, { say = (s) => console.log(s), env = process.env, stdin } = {}) {
|
|
86
120
|
const args = argv[0] === 'propose' ? argv.slice(1) : argv.slice();
|
|
87
121
|
const verb = args[0];
|
|
@@ -114,6 +148,7 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, stdin
|
|
|
114
148
|
}
|
|
115
149
|
const L = F.looks.get(ini);
|
|
116
150
|
if (L && L.run === runId && L.stopped) { say('✗ the PM pressed Stop: file nothing more'); return 1; }
|
|
151
|
+
if (verb === 'verdict') return verdict(args, { say, stdin, env, file, runId, ini, board, F, line });
|
|
117
152
|
const type = verb === 'found' ? args[1] : verb === 'date' ? 'stage' : verb === 'done' ? 'done' : 'tidy';
|
|
118
153
|
const jsonAt = args.indexOf('--json'), src = jsonAt >= 0 ? args[jsonAt + 1] : null;
|
|
119
154
|
if (!src) { say(`usage: pmos propose ${verb}${verb === 'found' ? ' <type>' : ''} --json <file|->`); return 2; }
|
|
@@ -81,6 +81,8 @@ function keepCore(ctx, p, g, f, ini, want, choices = {}, extra = {}) {
|
|
|
81
81
|
const w = applyOne(ctx, p, g, f, ini, x, choices, outbox);
|
|
82
82
|
if (x.group === 'build' && !w.length) { failed.push({ id: x.id, why: x.failed || 'not opened' }); continue; } // stays open, says why
|
|
83
83
|
if (x.group === 'live' && !w.length) { failed.push({ id: x.id, why: x.failed || 'the round did not start' }); continue; } // stays open, says why
|
|
84
|
+
// a verdict on an outcome that is no longer due on its date: nothing is recorded and the ✦ goes (the PM answered it another way)
|
|
85
|
+
if (x.group === 'outcome' && x.type === 'verdict' && !w.length) { failed.push({ id: x.id, why: x.failed || 'not recorded' }); if (x.sig || x.why) PR.append(dir, { by: 'pmos:outcomes' }, { kind: 'drop', ini, sig: PR.sigOf(x), id: x.id, group: 'outcome', type: 'verdict' }); continue; }
|
|
84
86
|
if ((x.group === 'prototyped' || x.group === 'improved') && !w.length && x.failed) { failed.push({ id: x.id, why: x.failed }); continue; } // a round still being made stays open
|
|
85
87
|
wrote.push(...w);
|
|
86
88
|
if (x.group === 'dates' && x.plan && w.some((y) => y.op === 'dates')) plans++;
|
|
@@ -122,6 +124,14 @@ function undoCore(ctx, p, g, id) {
|
|
|
122
124
|
else if (w.op === 'created') { r = RB.writeAs(ctx, '/api/boards/ini-delete', { ws: p.w.id, board: p.board.id, id: w.id }, g); }
|
|
123
125
|
else if (w.op === 'round') { const LR = require('./live-round.js'); LR.cancel(w.round); if (w.proposal) LR.dropCard(dir, w.proposal); back++; continue; } // a live round: its runs stop and its card goes
|
|
124
126
|
else if (w.op === 'pr') { const r2 = require('./build-engine.js').close(p.w.root, w.item, { url: w.url }); if (r2.ok) back++; else kept++; continue; } // D108: Undo closes the pull request (the branch stays)
|
|
127
|
+
else if (w.op === 'verdict') {
|
|
128
|
+
// the PM's Undo of a verdict PMOS recorded by itself: the check is taken back (the outcome is due again, and Your move asks the PM),
|
|
129
|
+
// and the ✦ is dropped so PMOS does not record the same verdict again
|
|
130
|
+
const r2 = require('./outcomes.js').undoCheck(p.w.root, { initiative: k.ini, at: w.at, by: (g.actor && g.actor.by) || 'pm', via: 'ui' });
|
|
131
|
+
if (r2.ok) back++; else kept++;
|
|
132
|
+
for (const pid of k.ids) { const pp = F.props.get(pid); if (pp && pp.group === 'outcome' && pp.type === 'verdict') PR.append(dir, { by: 'pmos:outcomes' }, { kind: 'drop', ini: k.ini, sig: PR.sigOf(pp), id: pid, group: 'outcome', type: 'verdict' }); }
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
125
135
|
else if (w.op === 'outcome') { const r2 = require('./initiative-writer.js').restoreOutcome(p.w.root, k.ini, w.from || {}, w.to || {}, { actor: g.actor }); if (r2.ok && !r2.kept) back++; else kept++; continue; } // a record edited since keeps its edit
|
|
126
136
|
if (r && r.body && r.body.ok) back++; else kept++;
|
|
127
137
|
}
|
|
@@ -162,6 +172,7 @@ function autoKeep(ctx, w, { modeOf = () => 'auto', now } = {}) {
|
|
|
162
172
|
if (!d.apply) { out.held++; continue; }
|
|
163
173
|
try {
|
|
164
174
|
const r = keepCore(ctx, p, g, f, ini, [x], {}, { auto: true, group: x.group });
|
|
175
|
+
if (!r.keptIds.length) { out.held++; continue; } // nothing landed (a verdict no longer due, a pull request not opened): nothing to list
|
|
165
176
|
A.recordApplied(dir, { job: `propose:${x.group}`, product: w.id, ref: r.batch, title: x.title || x.why || x.group, cls, ini, why: x.title && x.why && x.why !== x.title ? x.why : '' }, { now, settingsDir: ctx.runtimeDir || null });
|
|
166
177
|
out.applied.push({ ini, batch: r.batch, group: x.group, title: x.title || x.why || '' });
|
|
167
178
|
} catch { out.held++; }
|
|
@@ -266,6 +277,24 @@ function applyOne(ctx, p, g, f, ini, x, choices, outbox) {
|
|
|
266
277
|
const next = String((x.data && x.data.next) || x.title || 'Change the factory harness').slice(0, 200);
|
|
267
278
|
const r = RB.taskAdd(ctx, { ws: p.w.id, board: p.board.id, initiative: ini, title: next, notes: [x.why, source ? 'From ' + source : ''].filter(Boolean).join('\n').slice(0, 1900) }, g);
|
|
268
279
|
if (W.ok(r)) add({ op: 'add', task: r.body.item && (r.body.item.uid || r.body.item.id), title: next, to: { start: '', due: '' } });
|
|
280
|
+
} else if (x.group === 'outcome' && x.type === 'verdict') {
|
|
281
|
+
// PMOS's own verdict on a due outcome (initiative outcome-checks-run-themselves). Class B: recorded at once with Undo. It records only
|
|
282
|
+
// while the check is still due on the date it answers: a verdict the PM gave another way, or a check date moved since, writes nothing.
|
|
283
|
+
const O = require('./outcomes.js'), d = x.data || {};
|
|
284
|
+
const S = O.scan(p.w.root);
|
|
285
|
+
const it = S.due.find((y) => y.id === ini);
|
|
286
|
+
if (!it || it.horizon !== d.horizon) x.failed = 'This outcome is not due on that date any more.';
|
|
287
|
+
else {
|
|
288
|
+
const by = g.actor && g.actor.by && g.actor.by !== 'agent:auto' ? g.actor.by : 'agent:outcomes';
|
|
289
|
+
const r = O.recordCheck(p.w.root, { initiative: ini, disposition: d.disposition, evidence: d.evidence, by, via: 'pmos', sources: x.sources || [] });
|
|
290
|
+
if (r.ok) add({ op: 'verdict', at: r.line.at, disposition: d.disposition, horizon: d.horizon });
|
|
291
|
+
else x.failed = r.error;
|
|
292
|
+
}
|
|
293
|
+
} else if (x.group === 'outcome' && x.type === 'source') {
|
|
294
|
+
// the one ask for a goal PMOS cannot read (lib/outcome-judge.js). Class C: only the PM's ✓ reaches here. It adds a task for the PM.
|
|
295
|
+
const d = x.data || {}, title = `Connect the source of "${String(d.goal || 'the goal').slice(0, 80)}", or pick another number`.slice(0, 200);
|
|
296
|
+
const r = RB.taskAdd(ctx, { ws: p.w.id, board: p.board.id, initiative: ini, title, notes: [x.why, source ? 'From ' + source : ''].filter(Boolean).join('\n').slice(0, 1900) }, g);
|
|
297
|
+
if (W.ok(r)) add({ op: 'add', task: r.body.item && (r.body.item.uid || r.body.item.id), title, to: { start: '', due: '' } });
|
|
269
298
|
} else if (x.group === 'outcome' && x.type === 'refuted') {
|
|
270
299
|
// a refuted outcome's next step (launch simulation W2; lib/outcomes.js refutedDrafts). Class C: only the PM's ✓ reaches here.
|
|
271
300
|
// kill the experiment is cancelled with the check as its reason (the D70 lifecycle line the Board's ⋯ Cancel writes)
|
|
@@ -390,6 +419,7 @@ function saidOf(wrote, plans, left) {
|
|
|
390
419
|
if (n('created')) bits.push((bits.length ? 'started ' : 'Started ') + 'the next experiment');
|
|
391
420
|
if (wrote.some((w) => w.op === 'life' && w.to === 'cancelled')) bits.push((bits.length ? 'stopped ' : 'Stopped ') + 'this one');
|
|
392
421
|
if (n('outcome')) bits.push((bits.length ? 'set ' : 'Set ') + 'the outcome and its check date');
|
|
422
|
+
if (n('verdict')) bits.push((bits.length ? 'recorded ' : 'Recorded ') + 'whether it worked');
|
|
393
423
|
// a live round (lib/live-round.js): each version shows on its card as soon as it renders
|
|
394
424
|
const rd = wrote.find((w) => w.op === 'round');
|
|
395
425
|
if (rd) bits.push((bits.length ? 'started ' : 'Started ') + ((rd.keys || []).length > 1 ? (rd.keys || []).join(', ').replace(/, ([^,]*)$/, ' and $1') + ': each shows as soon as it renders' : 'the new round: it shows as soon as it renders'));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.655.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.655.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
package/workspace/run-tests.js
CHANGED
|
@@ -694,6 +694,11 @@ function traceChanges(changes, ctx) {
|
|
|
694
694
|
for (const s of list) if (s === 'headless.test.js' || nk.some((x) => (get(s) || '').includes(x))) picked.add(s);
|
|
695
695
|
continue;
|
|
696
696
|
}
|
|
697
|
+
const rk = f === 'lib/headless.js' ? runEnvOnly(sget(f), lines) : null;
|
|
698
|
+
if (rk) { // a pin added to RUN_ENV: only the runs whose spec sets one of those variables are touched, so the suites that name them
|
|
699
|
+
for (const s of list) if (s === 'headless.test.js' || rk.some((x) => (get(s) || '').includes(x))) picked.add(s);
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
697
702
|
let why = null;
|
|
698
703
|
const before = picked.size;
|
|
699
704
|
if (get(f) == null) { // removed: only the names in the suites can say who used it
|
|
@@ -747,6 +752,26 @@ function newKindOnly(src, lines) {
|
|
|
747
752
|
return [...[...consts.values()].flat(), ...kinds].map((x) => `'${x}`);
|
|
748
753
|
}
|
|
749
754
|
|
|
755
|
+
/* lib/headless.js RUN_ENV lists the variables a background run's spawn spec may set. A change whose every line sits inside that list and
|
|
756
|
+
* holds only quoted PMOS_ names changes what one kind of run is pinned with, not how any run is spawned: it reaches the suites that name
|
|
757
|
+
* one of the names on those lines. Returns those names, or null when any changed line is something else. `src` is without comments. */
|
|
758
|
+
function runEnvOnly(src, lines) {
|
|
759
|
+
if (src == null || !Array.isArray(lines) || !lines.length) return null;
|
|
760
|
+
const C = src.split('\n');
|
|
761
|
+
const start = C.findIndex((l) => /^const RUN_ENV = Object\.freeze\(\[/.test(l.trim()));
|
|
762
|
+
if (start < 0) return null;
|
|
763
|
+
let end = start; while (end < C.length && !/\]\);\s*$/.test(C[end])) end++;
|
|
764
|
+
const names = new Set();
|
|
765
|
+
for (const n of lines) {
|
|
766
|
+
const l = (C[n - 1] || '').trim();
|
|
767
|
+
if (!l) continue;
|
|
768
|
+
if (n - 1 <= start || n - 1 > end) return null;
|
|
769
|
+
if (!/^('PMOS_[A-Z0-9_]+',?\s*)+(\]\);)?$/.test(l)) return null;
|
|
770
|
+
for (const m of l.matchAll(/'(PMOS_[A-Z0-9_]+)'/g)) names.add(m[1]);
|
|
771
|
+
}
|
|
772
|
+
return names.size ? [...names] : null;
|
|
773
|
+
}
|
|
774
|
+
|
|
750
775
|
/* The suites in `list` that the diff against `ref` can reach, by traceChanges() above. Returns { files, suites, why }. */
|
|
751
776
|
function changedSuites(list, ref, { exact = false } = {}) {
|
|
752
777
|
const git = (...a) => {
|
|
@@ -968,4 +993,4 @@ async function main() {
|
|
|
968
993
|
}
|
|
969
994
|
|
|
970
995
|
if (require.main === module) main().catch((e) => { console.error(e); process.exitCode = 1; });
|
|
971
|
-
else module.exports = { traceChanges, diffLines, strip, changedDeps, WIDE };
|
|
996
|
+
else module.exports = { traceChanges, runEnvOnly, diffLines, strip, changedDeps, WIDE };
|
package/workspace/server.js
CHANGED
|
@@ -3222,6 +3222,9 @@ const outcomeProps = require('./lib/outcome-props.js').create({
|
|
|
3222
3222
|
boardOf: (w, id) => require('./lib/routes-boards.js').boardIndex(proposalCtx(), w).of(id),
|
|
3223
3223
|
runtime: () => STATE,
|
|
3224
3224
|
open: (now) => !proactiveLib.inQuietHours(now, proSettings().quiet),
|
|
3225
|
+
// outcome-checks-run-themselves: a due check no reading decides gets one short run that reads the initiative's records (lib/proposal-runs.js)
|
|
3226
|
+
startRun: (w, o) => proposalRuns.start({ ws: w.id, board: o.board, ini: o.ini, why: 'outcome', press: false, now: o.now,
|
|
3227
|
+
outcome: { metric: o.it.metric, horizon: o.it.horizon, anchor: o.it.anchor, record: o.it.record, why: o.why } }),
|
|
3225
3228
|
env: process.env,
|
|
3226
3229
|
every: TICK_MS,
|
|
3227
3230
|
mayRun: () => { try { return scheduleOwner.mayRun(); } catch { return true; } },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: initiative-propose
|
|
3
3
|
label: "Claude proposes, per initiative"
|
|
4
|
-
description: "One short background run for one initiative. When the initiative was just added, it looks for it in every connected source and files what it finds: the stage the work is really in, its documents and its tasks with their dates. Each morning it finds why late tasks slipped and files new dates, done and tidy names. Everything waits under the initiative's ✦ for the PM's ✓. It writes no task, document or stage and sends nothing."
|
|
4
|
+
description: "One short background run for one initiative. When the initiative was just added, it looks for it in every connected source and files what it finds: the stage the work is really in, its documents and its tasks with their dates. Each morning it finds why late tasks slipped and files new dates, done and tidy names. When an outcome check date passes and no reading decides it, it reads the records and files whether it worked. Everything waits under the initiative's ✦ for the PM's ✓. It writes no task, document or stage and sends nothing."
|
|
5
5
|
run: agent
|
|
6
6
|
agent: claude
|
|
7
7
|
output:
|
|
@@ -10,7 +10,7 @@ output:
|
|
|
10
10
|
- Not read
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
/initiative-propose: for ONE initiative, find what the evidence says and file it with `pmos propose`, then stop. The lines after this procedure name the initiative, why this run runs (populate or
|
|
13
|
+
/initiative-propose: for ONE initiative, find what the evidence says and file it with `pmos propose`, then stop. The lines after this procedure name the initiative, why this run runs (populate, check or outcome), today, its stages and what the PM dropped.
|
|
14
14
|
|
|
15
15
|
Rules that always hold:
|
|
16
16
|
1. THE ONLY WRITE is `pmos propose`. You have no Write and no Edit tool. Do not add a task, move a stage or write a document: the PM's ✓ on the page does that. Do not commit and do not push.
|
|
@@ -39,6 +39,12 @@ Procedure when the run is `check` (the morning check: tasks are late or at risk)
|
|
|
39
39
|
3. When the evidence says the work happened (an email was sent, a ticket closed), file `pmos propose done --json -` with `{ "why", "sources", "items": [{ "task" }] }`.
|
|
40
40
|
4. For names that do not keep the standard, file one `pmos propose name --json -`: `{ "why": "Verb first, short, the WBS number kept. Detail moves to the task's notes.", "sources": [{ "label": "The tasks" }], "items": [{ "task", "to", "notes" }] }`. The standard: the WBS number kept if the PM uses one, verb first, sentence case, at most about 7 words, no "+" and no brackets. Put the detail you cut in `notes`. Propose a new task's name once.
|
|
41
41
|
|
|
42
|
+
Procedure when the run is `outcome` (the check date of its expected outcome has passed, and its goal's own reading did not decide it):
|
|
43
|
+
1. Read the lines below: the expected outcome, the check date, the anchor, the record and why the reading did not decide it. Read the record, its PRD and done test if it names them, and the product's own ledgers and files the outcome is about (for example a ledger that should keep filling, a bench that should have run, a feedback ledger with or without a repeat complaint). Read the stored reads first (`pmos source show <source>`).
|
|
44
|
+
2. Decide only from what you read: `worked` when the evidence shows the expected outcome happened, `didnt-work` when it shows it did not. "Nobody complained" is not evidence it worked. When you cannot tell, file `{ "disposition": "cant-tell" }`: the PM is asked, and that is the right answer.
|
|
45
|
+
3. File once with `pmos propose verdict --json -`: `{ "disposition": "worked" | "didnt-work" | "cant-tell", "evidence": "<one line: what you found, with the number>", "claims": [{ "text": "<one fact>", "sources": [{ "label": "<what it is>", "ref": "<path:line, from the repository root>", "quote": "<the text on that line, at least 12 characters>" }] }] }`. Each quote is checked against its line; a claim that does not match is refused, and so is the verdict.
|
|
46
|
+
4. Do not record the check yourself: the server records your verdict with Undo.
|
|
47
|
+
|
|
42
48
|
Output contract: produce EXACTLY these sections in your final message:
|
|
43
49
|
- Filed (the proposal ids and their kinds, or "nothing new")
|
|
44
50
|
- Not found (what you looked for and did not find)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Outcome checks that run themselves (initiative outcome-checks-run-themselves, done test C1-C12): PMOS judges a due outcome from the goal's own reading, asks once for a source it cannot read twice, and starts one short run per check date for the rest; the verdict's ✓ and Undo on a scratch server. No connector, model or network.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"outcome-judge.test.js",
|
|
5
|
+
"outcome-check-runs.test.js"
|
|
6
|
+
],
|
|
7
|
+
"seconds": {
|
|
8
|
+
"outcome-judge.test.js": 4,
|
|
9
|
+
"outcome-check-runs.test.js": 12
|
|
10
|
+
}
|
|
11
|
+
}
|