create-pmos 0.570.0 → 0.572.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +27 -27
- package/payload/AGENTS.md +4 -3
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/scripts/factory-guardrail.js +267 -0
- package/payload/scripts/gate-initiative.sh +12 -2
- package/payload/scripts/work-item.js +25 -1
- package/payload/scripts/workflow-state.js +60 -5
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/payload/templates/pmos-guardrail.yml +61 -0
- package/workspace/changelog.json +26 -0
- package/workspace/guide/cli.md +39 -4
- package/workspace/guide/initiatives-and-next-steps.md +1 -1
- package/workspace/lib/autonomy.js +3 -1
- package/workspace/lib/build-cli.js +33 -6
- package/workspace/lib/build-engine.js +89 -19
- package/workspace/lib/engine/workflow-state.js +60 -5
- package/workspace/lib/factory-rollout.js +190 -0
- package/workspace/lib/pmos-verbs.js +1 -1
- package/workspace/lib/routes-proposals.js +1 -1
- package/workspace/lib/team-cli.js +1 -1
- package/workspace/lib/vendor/scripts/workflow-state.js +60 -5
- package/workspace/lib/verify-runs.js +17 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/ini-props.js +1 -1
- package/workspace/test-lists/build-engine.json +5 -3
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# PMOS factory guardrail (D108). Copy to .github/workflows/pmos-guardrail.yml in the product repository, then make
|
|
2
|
+
# "pmos-guardrail / classify" a required check on the default branch, together with your own CI.
|
|
3
|
+
#
|
|
4
|
+
# What it does: for a pull request the PMOS factory opened (branch pmos/<item>), it reads AUTO or HUMAN from the default
|
|
5
|
+
# branch's copy of pmos/scripts/factory-guardrail.js. On AUTO it marks the pull request ready and turns on GitHub auto-merge
|
|
6
|
+
# with this workflow's own token: GitHub then merges only when every required check is green. On HUMAN it turns auto-merge
|
|
7
|
+
# off and names every reason in the run summary; a person merges. Any other pull request: nothing. To stop one merge, add the
|
|
8
|
+
# line "PMOS-Merge: human" to the pull request's description: the edit runs this check again and turns auto-merge off.
|
|
9
|
+
#
|
|
10
|
+
# Why pull_request_target: it runs THIS workflow and THE DEFAULT BRANCH'S guardrail, never the pull request's code. The head
|
|
11
|
+
# is fetched and diffed only. Do not add a step that runs, installs or builds anything from the head in this workflow.
|
|
12
|
+
#
|
|
13
|
+
# Before it can merge anything:
|
|
14
|
+
# - Settings > General > "Allow auto-merge" is on.
|
|
15
|
+
# - Branch protection (or a ruleset) on the default branch requires your CI checks. Without required checks GitHub could
|
|
16
|
+
# merge before CI runs, so leave this workflow out until they exist.
|
|
17
|
+
# - A merge made with this token does not start other workflows on the default branch (GitHub's rule). If your release
|
|
18
|
+
# runs on push to the default branch, start it from a pull_request "closed" event or give this job a GitHub App token.
|
|
19
|
+
name: pmos-guardrail
|
|
20
|
+
on:
|
|
21
|
+
pull_request_target:
|
|
22
|
+
types: [opened, synchronize, reopened, ready_for_review, edited]
|
|
23
|
+
|
|
24
|
+
permissions:
|
|
25
|
+
contents: write
|
|
26
|
+
pull-requests: write
|
|
27
|
+
|
|
28
|
+
concurrency:
|
|
29
|
+
group: pmos-guardrail-${{ github.event.pull_request.number }}
|
|
30
|
+
cancel-in-progress: true
|
|
31
|
+
|
|
32
|
+
jobs:
|
|
33
|
+
classify:
|
|
34
|
+
name: classify
|
|
35
|
+
if: startsWith(github.event.pull_request.head.ref, 'pmos/')
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/checkout@v4
|
|
39
|
+
with:
|
|
40
|
+
ref: ${{ github.event.pull_request.base.sha }}
|
|
41
|
+
fetch-depth: 0
|
|
42
|
+
persist-credentials: false
|
|
43
|
+
- name: Fetch the pull request's head (diffed, never run)
|
|
44
|
+
env:
|
|
45
|
+
PR: ${{ github.event.pull_request.number }}
|
|
46
|
+
run: git fetch --no-tags origin "+refs/pull/${PR}/head:refs/remotes/pmos-pr/head"
|
|
47
|
+
- name: Guardrail
|
|
48
|
+
env:
|
|
49
|
+
GH_TOKEN: ${{ github.token }}
|
|
50
|
+
GH_REPO: ${{ github.repository }}
|
|
51
|
+
PR: ${{ github.event.pull_request.number }}
|
|
52
|
+
HEAD_REF: ${{ github.event.pull_request.head.ref }}
|
|
53
|
+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
|
54
|
+
PR_BODY: ${{ github.event.pull_request.body }}
|
|
55
|
+
HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
|
|
56
|
+
BASE_REPO: ${{ github.repository }}
|
|
57
|
+
run: |
|
|
58
|
+
printf '%s' "$PR_BODY" > "$RUNNER_TEMP/pmos-pr-body.txt"
|
|
59
|
+
node pmos/scripts/factory-guardrail.js --base "$BASE_SHA" --head refs/remotes/pmos-pr/head \
|
|
60
|
+
--branch "$HEAD_REF" --body-file "$RUNNER_TEMP/pmos-pr-body.txt" --head-repo "$HEAD_REPO" --base-repo "$BASE_REPO" \
|
|
61
|
+
--github --pr "$PR"
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.572.0",
|
|
4
|
+
"at": "2026-11-16T04:39:30.480Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1305,
|
|
9
|
+
"t": "A Project's dated tasks with a ◇ milestone are its dated plan",
|
|
10
|
+
"s": "A Project's dated tasks with a ◇ milestone are its dated plan",
|
|
11
|
+
"k": "new"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"v": "0.571.0",
|
|
17
|
+
"at": "2026-11-16T04:26:43.356Z",
|
|
18
|
+
"f": 4,
|
|
19
|
+
"prs": [
|
|
20
|
+
{
|
|
21
|
+
"n": 1303,
|
|
22
|
+
"t": "The factory merges behind a guardrail, and rolls out behind a flag",
|
|
23
|
+
"s": "The factory merges behind a guardrail, and rolls out behind a flag",
|
|
24
|
+
"k": "new"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
2
28
|
{
|
|
3
29
|
"v": "0.570.0",
|
|
4
30
|
"at": "2026-11-15T17:32:20.370Z",
|
package/workspace/guide/cli.md
CHANGED
|
@@ -447,20 +447,55 @@ The Builder does these steps:
|
|
|
447
447
|
2. `pmos build claim <item>` claims one item. PMOS makes the branch `pmos/<item>` from the default branch, in a worktree outside your folder. Your own checkout does not change.
|
|
448
448
|
3. The Builder changes files in that worktree only, and runs the item's check.
|
|
449
449
|
4. `pmos build propose <item> "<what it does>" --evidence "<the check that passed>"` commits the change with the line `Work-Item: <item>`, marks the item verified, and puts "Open a draft pull request" under the initiative's ✦. Nothing is pushed yet.
|
|
450
|
-
5.
|
|
451
|
-
6.
|
|
450
|
+
5. PMOS opens the pull request by itself: it pushes only `pmos/<item>` and opens a draft pull request with `gh`. The push comes from PMOS, never from the Builder's run. Undo on the ✦ closes the pull request. When agents are off (`pmos ai off`), or the factory is back to propose-only after a revert, the proposal waits for your ✓. You can also run `pmos build open <item>` yourself.
|
|
451
|
+
6. The product's `pmos-guardrail` check decides who merges (see below). Then `pmos verify-work` marks the item integrated.
|
|
452
452
|
|
|
453
453
|
`pmos build status` lists every work item, its branch and whether its worktree is on this computer.
|
|
454
454
|
|
|
455
|
+
#### Who merges: the guardrail
|
|
456
|
+
|
|
457
|
+
PMOS never merges and the Builder holds no merge right (D108). The product repository's own check decides. Copy `pmos/templates/pmos-guardrail.yml` to `.github/workflows/`, turn on "Allow auto-merge" in the repository settings, and make your CI checks required on the default branch.
|
|
458
|
+
|
|
459
|
+
For each pull request on a `pmos/` branch, the check runs the default branch's copy of `pmos/scripts/factory-guardrail.js`. It reads the pull request's changes and never runs its code. The answer is one of these:
|
|
460
|
+
|
|
461
|
+
- **AUTO.** The item is verified in the default branch's records, every changed file is inside the item's declared scope, the change reads its flag (or the item has no user-facing effect), and no trigger fires. The check marks the pull request ready and turns on auto-merge. GitHub merges when every required check is green.
|
|
462
|
+
- **HUMAN.** The check names every reason and turns auto-merge off. You merge.
|
|
463
|
+
|
|
464
|
+
These triggers always make the answer HUMAN: migrations or data deletion; auth, permissions, payments, personal data or secrets; CI, gates, the guardrail or PMOS records; a new dependency; a public API or contract; anything sent outward; a new agent path; a changed existing test, test configuration or the item's own check; an item that failed before; a revert on the default branch in the last 14 days; a folder untouched for 90 days. When agents are switched off (`pmos ai off`) or the factory is back to propose-only after a revert, PMOS writes `PMOS-Merge: human` in the pull request, and the check reads HUMAN. To stop one merge yourself, add that line to the pull request's description. A pull request from a fork always reads HUMAN.
|
|
465
|
+
|
|
466
|
+
`pmos build policy <item>` shows the answer on this computer before the check runs.
|
|
467
|
+
|
|
468
|
+
A work item says what the guardrail reads when it is declared: `node pmos/scripts/work-item.js declare <initiative> … --scope src/login/ --flag otp_login --metric login_errors --budget 0.02`. Use `--no-user-facing` instead of a flag for a change users cannot see, and `--kr` for an item that moves a key result.
|
|
469
|
+
|
|
470
|
+
#### The flag rollout
|
|
471
|
+
|
|
472
|
+
After the merge, PMOS moves the item's flag to 5%, then 50%, then 100%. Each step holds for an hour (`hold_minutes`) and moves only while the item's metric stays inside its budget. A key-result item stops before 100% and waits for you. When the metric goes over its budget, PMOS turns the flag off, opens a revert pull request for you to merge, and puts the factory back to propose-only for 7 days.
|
|
473
|
+
|
|
474
|
+
PMOS uses your flag service through the commands in `pmos/factory.json`:
|
|
475
|
+
|
|
476
|
+
```json
|
|
477
|
+
{ "flags": { "set": "my-flags set {flag} {percent}" },
|
|
478
|
+
"metrics": { "login_errors": "node ops/login-error-rate.js" },
|
|
479
|
+
"hold_minutes": 60 }
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
`{flag}` and `{percent}` are filled in. Each metric command prints one number. With no `factory.json`, or no metric for the item, PMOS says so and moves nothing: the change merged with its flag off, and you turn it on.
|
|
483
|
+
|
|
484
|
+
- `pmos build rollout` shows where every flag stands.
|
|
485
|
+
- `pmos build rollout <item> [--to <percent>]` moves one flag yourself.
|
|
486
|
+
- `pmos build rollback <item>` turns the flag off and stops its rollout.
|
|
487
|
+
|
|
488
|
+
`pmos ai off` stops the rollout too.
|
|
489
|
+
|
|
455
490
|
The command refuses these cases:
|
|
456
491
|
|
|
457
492
|
- The repository has no git identity of its own. Set it once with `pmos git-identity set`. PMOS never guesses who commits.
|
|
458
493
|
- The change touches a PMOS record, CI or the agent rules: `pmos/`, `.github/`, `planning/initiatives/`, `CLAUDE.md`, `AGENTS.md`.
|
|
459
494
|
- `propose` without `--evidence`. The check comes before the pull request.
|
|
460
|
-
- `open` inside a role run.
|
|
495
|
+
- `open` inside a role run. PMOS or you open the pull request, never the Builder's run.
|
|
461
496
|
- `open` without `gh`. The branch is pushed, and the command tells you to open the pull request on your Git host.
|
|
462
497
|
|
|
463
|
-
PMOS never pushes to the default branch and merges
|
|
498
|
+
PMOS never pushes to the default branch and never merges. Every command takes `--json` and `--root <dir>`.
|
|
464
499
|
|
|
465
500
|
### pmos jira
|
|
466
501
|
|
|
@@ -135,7 +135,7 @@ The writer makes the record in `planning/initiatives/<id>.md` with its type, tit
|
|
|
135
135
|
**New initiative** asks for one kind of work. PMOS works out the rest from it.
|
|
136
136
|
|
|
137
137
|
- **Product.** Product management. You decide what to build and whether it worked. Engineers build it, and PMOS writes the specs.
|
|
138
|
-
- **Full SDLC.** From idea to shipped. Where a factory runs in the repository, PMOS also builds it, as pull requests
|
|
138
|
+
- **Full SDLC.** From idea to shipped. Where a factory runs in the repository, PMOS also builds it, as pull requests. The product's guardrail check merges the safe ones and leaves the rest for you. Elsewhere PMOS writes the done test and the pull request plan, and the team's agents build it. A factory runs where the repository has `planning/work-items.jsonl` and `scripts/verify-work.js`. A repository made with `create-pmos` has no factory yet.
|
|
139
139
|
- **Project.** Project management. Others do the work. PMOS chases, syncs the dates and reports.
|
|
140
140
|
|
|
141
141
|
PMOS picks a kind from the name as you type, and a blue line says so. Tap another kind to change it. After you tap a kind, PMOS does not change it. When the name gives no hint, the kind is Product.
|
|
@@ -120,7 +120,9 @@ function classOfProposal(p) {
|
|
|
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
122
|
if (p.group === 'outcome' && p.type === 'refuted') return 'C';
|
|
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
|
+
// 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
|
+
if (p.group === 'build') return 'B'; // stopping or replacing an experiment is the PM's call (launch simulation W2)
|
|
124
126
|
// a maybe, or a duplicate already in another initiative (type link, or an item with `other`), is a question for the PM, not a change
|
|
125
127
|
// found type stage moves the initiative's stage: a stage move is C (as the Driver's `move`)
|
|
126
128
|
if (p.group === 'found' && (p.type === 'stage' || p.type === 'maybe' || p.type === 'link' || (p.items || []).some((x) => x && x.other))) return 'C';
|
|
@@ -8,26 +8,33 @@
|
|
|
8
8
|
* commit, mark verified, and file "Open a draft pull request" under the ✦
|
|
9
9
|
* pmos build open <item> [--json] the PM only: push the branch and open the DRAFT pull request
|
|
10
10
|
* pmos build status [--json] every work item, its branch and whether its worktree is here
|
|
11
|
+
* pmos build policy <item> [--json] what the merge guardrail reads for it now: auto or human, and why (D108)
|
|
12
|
+
* pmos build rollout [<item> [--to <percent>]] [--json] no item: where every flag stands; an item: the PM's own next step
|
|
13
|
+
* pmos build rollback <item> [--json] undo a rollout: the item's flag to 0
|
|
11
14
|
* common: [--root <dir>]
|
|
12
15
|
*
|
|
13
|
-
* `open` is what the
|
|
14
|
-
*
|
|
16
|
+
* `open` is what the ✦ runs by itself (class B since D108 as amended 2026-11-16; Undo closes the pull request), or the ✓ when agents
|
|
17
|
+
* are off. A role run (PMOS_TEAM_RUN set) cannot run it: the push comes from PMOS, never from the Builder's own run. Nothing here merges: the product's pmos-guardrail check turns on auto-merge for a pull request it
|
|
18
|
+
* reads AUTO (D108; lib/build-engine.js mergePolicy previews it). The flag rollout runs by itself (lib/factory-rollout.js).
|
|
15
19
|
* Exit codes: 0 done, 1 refused, 2 usage.
|
|
16
20
|
*/
|
|
17
21
|
const path = require('path');
|
|
18
22
|
const { execFileSync } = require('child_process');
|
|
19
23
|
const BE = require('./build-engine.js');
|
|
20
24
|
|
|
21
|
-
const COMMANDS = { build: ['next', 'claim', 'propose', 'open', 'status'] };
|
|
25
|
+
const COMMANDS = { build: ['next', 'claim', 'propose', 'open', 'status', 'policy', 'rollout', 'rollback'] };
|
|
22
26
|
const USAGE = [
|
|
23
|
-
'usage: pmos build next|claim|propose|open|status — the Builder: PMOS builds a declared work item as a
|
|
27
|
+
'usage: pmos build next|claim|propose|open|status|policy|rollout|rollback — the Builder: PMOS builds a declared work item as a pull request',
|
|
24
28
|
' pmos build next [<initiative>] the declared work items no Builder has taken',
|
|
25
29
|
' pmos build claim <item> claim one; PMOS makes the branch pmos/<item> in a worktree outside this folder',
|
|
26
30
|
' pmos build propose <item> "<what it does>" --evidence "<the check that passed>"',
|
|
27
31
|
' commit it and file "Open a draft pull request" under the initiative\'s ✦',
|
|
28
32
|
' pmos build open <item> you only (the ✓ runs it): push pmos/<item> and open the draft pull request',
|
|
29
33
|
' pmos build status every work item and its branch',
|
|
30
|
-
'
|
|
34
|
+
' pmos build policy <item> auto or human: whether its pull request merges by itself, and why',
|
|
35
|
+
' pmos build rollout [<item> [--to <percent>]] where every flag stands; with an item, take its flag to the next step',
|
|
36
|
+
' pmos build rollback <item> turn the item\'s flag off and stop its rollout',
|
|
37
|
+
'every command: [--json] [--root <dir>]. PMOS never merges: the product\'s pmos-guardrail check turns on auto-merge, or you merge.',
|
|
31
38
|
];
|
|
32
39
|
|
|
33
40
|
function parse(argv) {
|
|
@@ -67,8 +74,28 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
|
|
|
67
74
|
for (const x of list) say(verb === 'next' ? `${x.item_id} ${x.type || ''} ${(x.criterion && x.criterion.text) || ''}` : `${x.item} ${x.state} ${x.branch}${x.here ? ' (worktree here)' : ''}`);
|
|
68
75
|
return 0;
|
|
69
76
|
}
|
|
77
|
+
if (verb === 'rollout' && !pos[0]) {
|
|
78
|
+
const list = require('./factory-rollout.js').statusOf(root);
|
|
79
|
+
if (json) return ok({ flags: list });
|
|
80
|
+
if (!list.length) { say('No flag is rolling out.'); return 0; }
|
|
81
|
+
for (const x of list) say(`${x.item} ${x.flag} ${x.percent}% ${x.step} ${x.why || ''}`);
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
70
84
|
const item = pos[0];
|
|
71
85
|
if (!item) return fail(`usage: pmos build ${verb} <item>`, 2);
|
|
86
|
+
if (verb === 'policy') {
|
|
87
|
+
const it = BE.itemsOf(root).find((x) => x.item_id === item);
|
|
88
|
+
if (!it) return fail(`${item} is not a work item here`);
|
|
89
|
+
const p = BE.mergePolicy(root, it, { env });
|
|
90
|
+
return ok({ item, ...p }, `${p.verdict === 'auto' ? 'AUTO' : 'HUMAN'} ${item}: ${p.why}`);
|
|
91
|
+
}
|
|
92
|
+
if (verb === 'rollout' || verb === 'rollback') {
|
|
93
|
+
if (env.PMOS_TEAM_RUN) return fail('a role run cannot move a flag. The rollout runs by itself, and the PM moves it by hand');
|
|
94
|
+
const FR = require('./factory-rollout.js');
|
|
95
|
+
const r = verb === 'rollout' ? FR.rollout(root, item, { to: flags.to !== undefined && flags.to !== '' ? Number(flags.to) : null, env }) : FR.rollback(root, item, { env });
|
|
96
|
+
if (!r.ok) return fail(r.error);
|
|
97
|
+
return ok(r, `✓ ${r.flag} is at ${r.percent}%${verb === 'rollback' ? '. Its rollout stops until you run pmos build rollout ' + item : ''}`);
|
|
98
|
+
}
|
|
72
99
|
if (verb === 'claim') {
|
|
73
100
|
const agent = env.PMOS_TEAM_RUN ? `pmos:builder:${env.PMOS_TEAM_RUN}` : 'pmos:builder';
|
|
74
101
|
const r = BE.claim(root, item, { agent });
|
|
@@ -80,7 +107,7 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
|
|
|
80
107
|
if (!summary) return fail(`usage: pmos build propose ${item} "<what it does>" --evidence "<the check that passed>"`, 2);
|
|
81
108
|
const r = BE.propose(root, item, { summary, evidence: flags.evidence || '', run: env.PMOS_TEAM_RUN || null });
|
|
82
109
|
if (!r.ok) return fail(r.error);
|
|
83
|
-
return ok(r, `✓ committed ${r.commit.slice(0, 8)} (${r.files.length} ${r.files.length === 1 ? 'file' : 'files'}) and filed "Open a draft pull request" under the ✦.
|
|
110
|
+
return ok(r, `✓ committed ${r.commit.slice(0, 8)} (${r.files.length} ${r.files.length === 1 ? 'file' : 'files'}) and filed "Open a draft pull request" under the ✦. PMOS opens it by itself (with Undo); when agents are off it waits for the PM's ✓. Nothing is pushed by this run.`);
|
|
84
111
|
}
|
|
85
112
|
if (verb === 'open') {
|
|
86
113
|
const r = BE.open(root, item, { env });
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* next(root, ini?) → [item] declared and not claimed: what a Builder may take
|
|
8
8
|
* claim(root, item, { agent }) → { ok, branch, worktree, base } | { ok: false, error }
|
|
9
9
|
* propose(root, item, { summary, evidence, run? }) → { ok, commit, files, proposal } | { ok: false, error }
|
|
10
|
-
* open(root, item, { env,
|
|
10
|
+
* open(root, item, { env, title, revert }) → { ok, pushed, url, policy } | { ok: false, pushed, error }
|
|
11
|
+
* revert(root, item, { env, why }) → { ok, branch, url } | { ok: false, error } the rollout's revert pull request (lib/factory-rollout.js)
|
|
11
12
|
* status(root) → [{ item, state, branch, worktree, here }]
|
|
12
|
-
* mergePolicy(item,
|
|
13
|
+
* mergePolicy(root, item, { env }) → { merge, verdict, why, reasons, mark } when a PR merges with no person (see MERGE POLICY)
|
|
13
14
|
* FORBIDDEN · forbiddenIn(files) · worktreeOf(root, item) · branchOf(item) · defaultBranch(root)
|
|
14
15
|
*
|
|
15
16
|
* THE STEPS, in order. Each one is a separate verb, so each refusal is its own and a test can reach it:
|
|
@@ -22,17 +23,21 @@
|
|
|
22
23
|
* (FORBIDDEN: the kit's pmos/ folder, .github/, the agent rules; D65: the factory may never write one). Then it commits
|
|
23
24
|
* with the line `Work-Item: <id>`, appends `verified` with the evidence, and FILES a class C ✦ proposal "Open a draft
|
|
24
25
|
* pull request". It pushes nothing.
|
|
25
|
-
* 3. open
|
|
26
|
+
* 3. open never the Builder's run (refused when PMOS_TEAM_RUN is set). D108 as amended 2026-11-16: the proposal is class B, so the
|
|
27
|
+
* server's ✦ applies it by itself (routes-proposals autoKeep) and Undo closes the pull request; with `pmos ai off` or a
|
|
28
|
+
* demoted factory it waits for the PM's ✓. The PM can still run `pmos build open`.
|
|
26
29
|
* It pushes the ONE branch by an explicit refspec (refs/heads/pmos/<item>, never forced) and refuses a branch that is not
|
|
27
30
|
* pmos/… or that names the default branch. Then `gh pr create --draft`. With no gh it says so and claims no PR.
|
|
28
31
|
*
|
|
29
32
|
* THE TRIFECTA, structurally (kit/AGENTS.md): a Builder run reads private code and untrusted content, so it holds no outward channel:
|
|
30
|
-
* no git push, no gh, no network tool, and open() refuses it. The one outward step
|
|
33
|
+
* no git push, no gh, no network tool, and open() refuses it. The one outward step runs in PMOS's own process (the ✦, class B since D108), never in the Builder's run.
|
|
31
34
|
*
|
|
32
|
-
* MERGE POLICY (
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
35
|
+
* MERGE POLICY (D108). Nothing here merges, and the Builder never holds a merge right. The product repository's own workflow
|
|
36
|
+
* `pmos-guardrail` (kit/templates/pmos-guardrail.yml) runs the default branch's scripts/factory-guardrail.js on each factory pull
|
|
37
|
+
* request and, on `auto`, turns on GitHub auto-merge with the workflow's token: GitHub merges when every required check is green.
|
|
38
|
+
* mergePolicy() runs the SAME classifier here, as a preview for the PM and the ✦, and adds what only this machine knows: autonomy off
|
|
39
|
+
* (`pmos ai off`, PMOS_AUTONOMY=off) or the factory demoted after a revert (D106 (5), job ai:factory). Then `mark` is true and open()
|
|
40
|
+
* writes `PMOS-Merge: human` into the pull request body, which the guardrail reads as human.
|
|
36
41
|
*/
|
|
37
42
|
const fs = require('fs');
|
|
38
43
|
const os = require('os');
|
|
@@ -41,10 +46,32 @@ const crypto = require('crypto');
|
|
|
41
46
|
const cp = require('child_process');
|
|
42
47
|
const WK = require('./work-kind.js');
|
|
43
48
|
|
|
44
|
-
const POLICY = '
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
const POLICY = 'guardrail';
|
|
50
|
+
const FACTORY_JOB = 'ai:factory';
|
|
51
|
+
/** The merge seam (D108). → { merge, verdict: 'auto'|'human', why, reasons: [{ rule, detail }], mark } */
|
|
52
|
+
function mergePolicy(root, it, { env = process.env } = {}) {
|
|
53
|
+
const human = (why, reasons = [], mark = false) => ({ merge: false, verdict: 'human', why, reasons, mark });
|
|
54
|
+
const A = require('./autonomy.js');
|
|
55
|
+
const k = A.killed({ env });
|
|
56
|
+
if (k) return human(`A person merges this pull request: ${k}.`, [{ rule: 'autonomy-off', detail: k }], true);
|
|
57
|
+
if (typeof root !== 'string' || !it || !it.item_id) return human('A person merges this pull request.');
|
|
58
|
+
const top = topOf(root) || root;
|
|
59
|
+
try {
|
|
60
|
+
const sd = require('./driver.js').stateDirOf(top, { create: false });
|
|
61
|
+
const dm = sd ? A.demotedNow(A.fold(A.read(sd)), FACTORY_JOB, null) : null;
|
|
62
|
+
if (dm) return human(`A person merges this pull request: the factory is back to propose-only until ${String(dm.until).slice(0, 10)} (${dm.why}).`, [{ rule: 'demoted', detail: dm.why }], true);
|
|
63
|
+
} catch { /* no autonomy ledger: nothing demoted */ }
|
|
64
|
+
const dir = WK.factoryDir(root);
|
|
65
|
+
const gpath = dir && path.join(dir, 'scripts', 'factory-guardrail.js');
|
|
66
|
+
if (!gpath || !fs.existsSync(gpath)) return human('A person merges this pull request: this repository\'s PMOS kit has no merge guardrail yet. Update PMOS to get it.');
|
|
67
|
+
const d = defaultBranch(root);
|
|
68
|
+
if (!d) return human('A person merges this pull request: there is no default branch to compare with.');
|
|
69
|
+
let v;
|
|
70
|
+
try { v = require(gpath).classify({ cwd: top, base: d.ref, head: 'refs/heads/' + branchOf(it.item_id), branch: branchOf(it.item_id) }); }
|
|
71
|
+
catch (e) { return human(`A person merges this pull request: the guardrail failed here (${one(e.message, 160)}).`); }
|
|
72
|
+
if (v.verdict === 'auto') return { merge: true, verdict: 'auto', reasons: [], mark: false,
|
|
73
|
+
why: 'The guardrail reads AUTO: once every required check is green, the product\'s pmos-guardrail check turns on auto-merge. The change reaches users only through its flag.' };
|
|
74
|
+
return human(`A person merges this pull request (the guardrail reads HUMAN): ${v.reasons.map((r) => r.detail).join('; ')}.`, v.reasons);
|
|
48
75
|
}
|
|
49
76
|
|
|
50
77
|
/* What a factory commit may not touch (D65: the factory never writes a control-graph record). Lower case; a folder ends in "/".
|
|
@@ -164,13 +191,13 @@ function hasGh(env) {
|
|
|
164
191
|
}
|
|
165
192
|
|
|
166
193
|
/** The outward step. Only the PM: the ✓ or the PM's own command. */
|
|
167
|
-
function open(root, item, { env = process.env, title = '' } = {}) {
|
|
194
|
+
function open(root, item, { env = process.env, title = '', revert = null } = {}) {
|
|
168
195
|
if (env.PMOS_TEAM_RUN) return { ok: false, pushed: false, error: 'a role run cannot open a pull request. It waits for the PM\'s ✓ under the ✦' };
|
|
169
196
|
const it = itemOf(root, item);
|
|
170
197
|
if (!it) return { ok: false, pushed: false, error: `${item} is not a work item here` };
|
|
171
|
-
if (it.state !== 'verified') return { ok: false, pushed: false, error: `${item} is ${it.state}; only a verified item gets a pull request` };
|
|
198
|
+
if (!revert && it.state !== 'verified') return { ok: false, pushed: false, error: `${item} is ${it.state}; only a verified item gets a pull request` };
|
|
172
199
|
const d = defaultBranch(root);
|
|
173
|
-
const branch = branchOf(item);
|
|
200
|
+
const branch = revert ? revertBranchOf(item) : branchOf(item);
|
|
174
201
|
if (!d) return { ok: false, pushed: false, error: 'this repository has no default branch' };
|
|
175
202
|
if (!branch.startsWith('pmos/') || branch === d.name || branch.replace(/^refs\/heads\//, '') === d.name) return { ok: false, pushed: false, error: `PMOS never pushes to ${d.name}` };
|
|
176
203
|
if (!git(root, ['rev-parse', '--verify', '--quiet', 'refs/heads/' + branch]).ok) return { ok: false, pushed: false, error: `there is no branch ${branch}` };
|
|
@@ -178,20 +205,63 @@ function open(root, item, { env = process.env, title = '' } = {}) {
|
|
|
178
205
|
const login = require('./git-identity.js').pushLogin(top);
|
|
179
206
|
const p = git(top, ['push', 'origin', `refs/heads/${branch}:refs/heads/${branch}`]);
|
|
180
207
|
if (!p.ok) return { ok: false, pushed: false, error: `the push of ${branch} failed: ${one(p.err, 300)}` };
|
|
181
|
-
const policy = mergePolicy(it, {});
|
|
208
|
+
const policy = revert ? { merge: false, verdict: 'human', why: 'A person merges this revert. Its flag is already off.', reasons: [], mark: true } : mergePolicy(root, it, { env });
|
|
182
209
|
let ghEnv = { ...env };
|
|
183
210
|
if (login) { const t = cp.spawnSync('gh', ['auth', 'token', '--user', login], { encoding: 'utf8', env }); if (t.status === 0 && String(t.stdout).trim()) ghEnv = { ...ghEnv, GH_TOKEN: String(t.stdout).trim() }; }
|
|
184
211
|
if (!hasGh(ghEnv)) return { ok: false, pushed: true, policy, error: `${branch} is pushed, but gh is not installed here, so no pull request was opened. Open a draft pull request from ${branch} into ${d.name} on your Git host` };
|
|
185
212
|
const it2 = itemOf(root, item);
|
|
186
|
-
const body =
|
|
187
|
-
|
|
213
|
+
const body = (revert
|
|
214
|
+
? [`PMOS reverts work item ${item}: ${revert.why}.`, '', policy.why, '', 'PMOS-Merge: human', `Work-Item: ${item}`]
|
|
215
|
+
: [`PMOS built work item ${item}.`, '', it2 && it2.evidence ? `Check that passed: ${it2.evidence}` : '', '', policy.why, '', ...(policy.mark ? ['PMOS-Merge: human'] : []), `Work-Item: ${item}`])
|
|
216
|
+
.filter((x, i, a) => x || a[i - 1]).join('\n');
|
|
217
|
+
const r = cp.spawnSync('gh', ['pr', 'create', ...(revert ? [] : ['--draft']), '--base', d.name, '--head', branch, '--title', one(title || (revert ? `Revert ${item}` : `PMOS: ${item}`), 120), '--body', body], { cwd: top, encoding: 'utf8', env: ghEnv });
|
|
188
218
|
if (r.error || r.status !== 0) return { ok: false, pushed: true, policy, error: `${branch} is pushed, but gh could not open the pull request: ${one(r.stderr || (r.error && r.error.message), 300)}` };
|
|
189
219
|
const url = (String(r.stdout).match(/https?:\/\/\S+/) || [''])[0];
|
|
190
220
|
return { ok: true, pushed: true, url, branch, base: d.name, policy };
|
|
191
221
|
}
|
|
192
222
|
|
|
223
|
+
const revertBranchOf = (item) => 'pmos/revert-' + item;
|
|
224
|
+
|
|
225
|
+
/** The rollout's breach (lib/factory-rollout.js): revert the merged change on pmos/revert-<item> and open a pull request through open().
|
|
226
|
+
* It reads the default branch as this checkout last fetched it (the PM's sync fetches); it fetches nothing itself. */
|
|
227
|
+
function revert(root, item, { env = process.env, why = 'its guard metric left its budget' } = {}) {
|
|
228
|
+
if (env.PMOS_TEAM_RUN) return { ok: false, error: 'a role run cannot revert' };
|
|
229
|
+
const it = itemOf(root, item);
|
|
230
|
+
if (!it) return { ok: false, error: `${item} is not a work item here` };
|
|
231
|
+
const d = defaultBranch(root);
|
|
232
|
+
if (!d) return { ok: false, error: 'this repository has no default branch' };
|
|
233
|
+
const top = topOf(root) || root;
|
|
234
|
+
const hit = git(top, ['log', '--format=%H %P', '-E', `--grep=^Work-Item: ${item.replace(/\./g, '\\.')}$`, d.ref]).out.split('\n').filter(Boolean);
|
|
235
|
+
if (!hit.length) return { ok: false, error: `no commit on ${d.name} carries Work-Item: ${item}` };
|
|
236
|
+
// the newest commit naming the item: a merge commit reverts against its first parent; a squash merge is one commit
|
|
237
|
+
const [sha, ...parents] = hit[0].split(' ');
|
|
238
|
+
const id = require('./git-identity.js').localIdentity(top);
|
|
239
|
+
if (!id.name || !id.email) return { ok: false, error: 'this repository has no git identity of its own, and PMOS never guesses who commits' };
|
|
240
|
+
const branch = revertBranchOf(item), wt = worktreeOf(root, 'revert-' + item);
|
|
241
|
+
if (fs.existsSync(wt)) return { ok: false, error: `${wt} already exists` };
|
|
242
|
+
fs.mkdirSync(path.dirname(wt), { recursive: true });
|
|
243
|
+
const w = git(top, ['worktree', 'add', '-b', branch, wt, d.ref]);
|
|
244
|
+
if (!w.ok) return { ok: false, error: `the revert worktree could not be made: ${one(w.err, 300)}` };
|
|
245
|
+
const r = git(wt, ['-c', `user.name=${id.name}`, '-c', `user.email=${id.email}`, 'revert', '--no-edit', ...(parents.length > 1 ? ['-m', '1'] : []), sha]);
|
|
246
|
+
if (!r.ok) return { ok: false, error: `git could not revert ${sha.slice(0, 8)}: ${one(r.err, 300)}` };
|
|
247
|
+
const o = open(root, item, { env, revert: { why } });
|
|
248
|
+
return o.ok ? { ok: true, branch, url: o.url } : { ok: false, branch, error: o.error };
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Undo of an opened pull request (D108): close it with gh, comment why, leave the branch. → { ok } | { ok: false, error } */
|
|
252
|
+
function close(root, item, { url = '', env = process.env } = {}) {
|
|
253
|
+
if (env.PMOS_TEAM_RUN) return { ok: false, error: 'a role run cannot close a pull request' };
|
|
254
|
+
const target = /^https?:\/\/\S+$/.test(String(url || '')) ? url : branchOf(item);
|
|
255
|
+
const top = topOf(root) || root;
|
|
256
|
+
const login = require('./git-identity.js').pushLogin(top);
|
|
257
|
+
let ghEnv = { ...env };
|
|
258
|
+
if (login) { const t = cp.spawnSync('gh', ['auth', 'token', '--user', login], { encoding: 'utf8', env }); if (t.status === 0 && String(t.stdout).trim()) ghEnv = { ...ghEnv, GH_TOKEN: String(t.stdout).trim() }; }
|
|
259
|
+
const r = cp.spawnSync('gh', ['pr', 'close', target, '--comment', 'Closed by Undo in PMOS.'], { cwd: top, encoding: 'utf8', env: ghEnv });
|
|
260
|
+
return r.error || r.status !== 0 ? { ok: false, error: one(r.stderr || (r.error && r.error.message) || 'gh could not close it', 300) } : { ok: true };
|
|
261
|
+
}
|
|
262
|
+
|
|
193
263
|
function status(root) {
|
|
194
264
|
return itemsOf(root).map((x) => { const wt = worktreeOf(root, x.item_id); return { item: x.item_id, state: x.state, branch: branchOf(x.item_id), worktree: wt, here: fs.existsSync(wt) }; });
|
|
195
265
|
}
|
|
196
266
|
|
|
197
|
-
module.exports = { POLICY, FORBIDDEN, mergePolicy, forbiddenIn, branchOf, worktreeOf, defaultBranch, itemsOf, next, claim, propose, open, status };
|
|
267
|
+
module.exports = { POLICY, FACTORY_JOB, FORBIDDEN, mergePolicy, forbiddenIn, branchOf, revertBranchOf, worktreeOf, defaultBranch, itemsOf, next, claim, propose, open, revert, close, status };
|
|
@@ -231,6 +231,48 @@ function layout(root) {
|
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
// ── A Project's dated plan in the task store (launch simulation W6 follow-up) ─────────────────────
|
|
235
|
+
// `pmos task add/link/set --milestone` writes a Project's plan as task lines in <runsDir>/initiative-tasks.jsonl (lib/task-store.js; lines
|
|
236
|
+
// not yet moved there still sit in boards.jsonl). Dated tasks with at least one dated ◇ milestone ARE the dated plan, so plan_path is not
|
|
237
|
+
// needed: the gate (kit/scripts/gate-initiative.sh, through --task-plan) and both ladders read them here. The fold is the task part of
|
|
238
|
+
// scripts/boards.js fold: the first task line makes the task, task-update moves or re-dates it, task-remove and task-restore take it out and
|
|
239
|
+
// back, and the last task-milestone line wins. → { ok, dated, milestones, file, evidence }
|
|
240
|
+
const DAY_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
241
|
+
function taskPlanOf(root, id) {
|
|
242
|
+
const L = layout(root);
|
|
243
|
+
const files = ['boards.jsonl', 'initiative-tasks.jsonl'].map((f) => path.join(L.runsDir, f));
|
|
244
|
+
const tasks = new Map(); const removed = new Map(); const milestones = new Map();
|
|
245
|
+
for (const file of files) {
|
|
246
|
+
let text = '';
|
|
247
|
+
try { text = fs.readFileSync(file, 'utf8'); } catch { continue; }
|
|
248
|
+
for (const raw of text.split('\n')) {
|
|
249
|
+
const t = raw.trim();
|
|
250
|
+
if (!t || t[0] !== '{' || !t.includes('"task')) continue;
|
|
251
|
+
let e; try { e = JSON.parse(t); } catch { continue; }
|
|
252
|
+
if (!e || typeof e.task !== 'string' || !e.task) continue;
|
|
253
|
+
if (e.kind === 'task' && typeof e.initiative === 'string' && !tasks.has(e.task) && !removed.has(e.task)) {
|
|
254
|
+
tasks.set(e.task, { initiative: e.initiative, due: typeof e.due === 'string' ? e.due : '' });
|
|
255
|
+
} else if (e.kind === 'task-update' && tasks.has(e.task)) {
|
|
256
|
+
const x = tasks.get(e.task);
|
|
257
|
+
if (typeof e.initiative === 'string' && e.initiative) x.initiative = e.initiative;
|
|
258
|
+
if (typeof e.due === 'string') x.due = e.due;
|
|
259
|
+
} else if (e.kind === 'task-milestone' && typeof e.milestone === 'boolean') milestones.set(e.task, e.milestone);
|
|
260
|
+
else if (e.kind === 'task-remove' && tasks.has(e.task)) { removed.set(e.task, tasks.get(e.task)); tasks.delete(e.task); }
|
|
261
|
+
else if (e.kind === 'task-restore' && removed.has(e.task) && !tasks.has(e.task)) { tasks.set(e.task, removed.get(e.task)); removed.delete(e.task); }
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
let dated = 0; let ms = 0;
|
|
265
|
+
for (const [tid, x] of tasks) {
|
|
266
|
+
if (x.initiative !== id || !DAY_RE.test(x.due)) continue;
|
|
267
|
+
dated++;
|
|
268
|
+
if (milestones.get(tid) === true) ms++;
|
|
269
|
+
}
|
|
270
|
+
const file = path.relative(root, path.join(L.runsDir, 'initiative-tasks.jsonl')).split(path.sep).join('/');
|
|
271
|
+
const ok = ms > 0;
|
|
272
|
+
const evidence = `${dated} dated task${dated === 1 ? '' : 's'}, ${ms} dated milestone${ms === 1 ? '' : 's'} in ${file}`;
|
|
273
|
+
return { ok, dated, milestones: ms, file, evidence };
|
|
274
|
+
}
|
|
275
|
+
|
|
234
276
|
// ── Git ────────────────────────────────────────────────────────────────────────────────────────
|
|
235
277
|
function git(root, args) {
|
|
236
278
|
try {
|
|
@@ -973,9 +1015,12 @@ function computeWorkflowDerived(id, opts) {
|
|
|
973
1015
|
`write the done test (okf/core/templates/done-test-template.md), set done_test_path and kill: in ${recRel}`, { blocking: true, rule: 'R2' }));
|
|
974
1016
|
} else if (!doneTest && workKind === 'project' && (planPath || !prd)) {
|
|
975
1017
|
const planIdx = planPath ? firstAppearance(root, range, planPath) : null;
|
|
976
|
-
|
|
1018
|
+
const taskPlan = planPath ? null : taskPlanOf(root, id);
|
|
1019
|
+
if (taskPlan && taskPlan.ok) {
|
|
1020
|
+
steps.push(step('spec', 'spec', 'done', `dated plan in the task store: ${taskPlan.evidence}`));
|
|
1021
|
+
} else if (!planPath) {
|
|
977
1022
|
steps.push(step('spec', 'spec', 'blocked', 'Project needs a dated plan before Execute — never a PRD',
|
|
978
|
-
`write the plan (milestones with dates and owners, go-live matching the KR date) and set plan_path in ${recRel}, or a done test`, { blocking: true, rule: 'R2' }));
|
|
1023
|
+
`write the plan (milestones with dates and owners, go-live matching the KR date) and set plan_path in ${recRel}, or add dated tasks with a ◇ milestone (pmos task add --due … / pmos task set --milestone), or a done test`, { blocking: true, rule: 'R2' }));
|
|
979
1024
|
} else if (planIdx === null) {
|
|
980
1025
|
steps.push(step('spec', 'spec', 'blocked', `plan_path '${planPath}' does not exist in the repo`,
|
|
981
1026
|
'create the plan the record points at, or correct plan_path', { blocking: true, rule: 'R2' }));
|
|
@@ -1605,14 +1650,16 @@ function pmLadder({ id, fm, lane, effLane, knownLane, legacy, steps, root, L, re
|
|
|
1605
1650
|
const workKind = (() => { const k = String(fm.kind || '').trim().replace(/^["']|["']$/g, ''); return k === 'sdlc' || k === 'project' ? k : 'product'; })();
|
|
1606
1651
|
const planPath = String(fm.plan_path || '').trim();
|
|
1607
1652
|
const kindSpec = !doneTest && !exists(briefPath) && !foundBrief && (workKind === 'sdlc' || (workKind === 'project'));
|
|
1653
|
+
const tasksPlan = kindSpec && workKind === 'project' && !planPath ? taskPlanOf(root, id) : null;
|
|
1608
1654
|
if (doneTest && dtPresent && killCond) steps.push(step('brief', def.brief_label, 'done', `done test ${doneTest} + kill condition (D107)`));
|
|
1609
1655
|
else if (kindSpec && workKind === 'sdlc') steps.push(step('brief', 'done test', legacy ? 'pending' : 'blocked',
|
|
1610
1656
|
'Full SDLC needs a done test and a kill condition before the first pull request — never a brief or a PRD',
|
|
1611
1657
|
`write the done test, set done_test_path and kill: in ${recRel} (pmos artefacts set experiment:${id} done-test check --text "…" writes both)`, { blocking: !legacy, rule: 'R2' }));
|
|
1612
1658
|
else if (kindSpec && exists(planPath)) steps.push(step('brief', 'dated plan', 'done', `plan ${planPath} present`));
|
|
1659
|
+
else if (kindSpec && !planPath && tasksPlan && tasksPlan.ok) steps.push(step('brief', 'dated plan', 'done', `dated plan in the task store: ${tasksPlan.evidence}`));
|
|
1613
1660
|
else if (kindSpec) steps.push(step('brief', 'dated plan', legacy ? 'pending' : 'blocked',
|
|
1614
1661
|
planPath ? `plan_path '${planPath}' does not exist in the repo` : 'Project needs a dated plan before Execute — never a brief or a PRD',
|
|
1615
|
-
planPath ? 'create the plan the record points at, or correct plan_path' : `write the plan (milestones with dates and owners, go-live matching the KR date) and set plan_path in ${recRel}, or a done test`,
|
|
1662
|
+
planPath ? 'create the plan the record points at, or correct plan_path' : `write the plan (milestones with dates and owners, go-live matching the KR date) and set plan_path in ${recRel}, or add dated tasks with a ◇ milestone (pmos task add --due … / pmos task set --milestone), or a done test`,
|
|
1616
1663
|
{ blocking: !legacy, rule: 'R2' }));
|
|
1617
1664
|
else if (doneTest && dtPresent) steps.push(step('brief', def.brief_label, 'blocked', 'no kill condition — an experiment states what would stop it (D107)',
|
|
1618
1665
|
`write kill: "<the result that would make us stop>" in ${recRel}`, { blocking: !legacy, rule: 'R2' }));
|
|
@@ -1896,7 +1943,7 @@ function listInitiatives(root) {
|
|
|
1896
1943
|
// ── CLI ────────────────────────────────────────────────────────────────────────────────────────
|
|
1897
1944
|
function main(argv) {
|
|
1898
1945
|
const args = argv.slice(2);
|
|
1899
|
-
let root = process.cwd(); let json = false; let gate = false; let all = false; let lanes = false;
|
|
1946
|
+
let root = process.cwd(); let json = false; let gate = false; let all = false; let lanes = false; let taskPlan = null;
|
|
1900
1947
|
const rest = [];
|
|
1901
1948
|
for (let i = 0; i < args.length; i++) {
|
|
1902
1949
|
const a = args[i];
|
|
@@ -1905,6 +1952,7 @@ function main(argv) {
|
|
|
1905
1952
|
if (a === '--gate') { gate = true; continue; }
|
|
1906
1953
|
if (a === '--all') { all = true; continue; }
|
|
1907
1954
|
if (a === '--lanes') { lanes = true; continue; }
|
|
1955
|
+
if (a === '--task-plan') { taskPlan = args[++i] || ''; continue; }
|
|
1908
1956
|
if (a === '--open') { continue; } // the board is in-flight-only by default now
|
|
1909
1957
|
if (a === '--help' || a === '-h') {
|
|
1910
1958
|
process.stdout.write([
|
|
@@ -1914,12 +1962,19 @@ function main(argv) {
|
|
|
1914
1962
|
' --gate <id> CI mode — exit 1 on a blocking order violation, with the next action',
|
|
1915
1963
|
' --all the board without the 12-row cap',
|
|
1916
1964
|
' --lanes every lane this repository offers: when to use it, input, output, done',
|
|
1965
|
+
' --task-plan <id> exit 0 when the task store holds a Project\'s dated plan (dated tasks with a ◇ milestone)',
|
|
1917
1966
|
' --json machine-readable (what an agent reads at session start)', '',
|
|
1918
1967
|
].join('\n') + '\n');
|
|
1919
1968
|
return 0;
|
|
1920
1969
|
}
|
|
1921
1970
|
rest.push(a);
|
|
1922
1971
|
}
|
|
1972
|
+
if (taskPlan !== null) {
|
|
1973
|
+
if (!/^[a-z0-9][a-z0-9._-]*$/.test(taskPlan)) { process.stdout.write('--task-plan needs an initiative id\n'); return 2; }
|
|
1974
|
+
const tp = taskPlanOf(root, taskPlan);
|
|
1975
|
+
process.stdout.write(json ? JSON.stringify(tp) + '\n' : tp.evidence + '\n');
|
|
1976
|
+
return tp.ok ? 0 : 1;
|
|
1977
|
+
}
|
|
1923
1978
|
if (lanes) {
|
|
1924
1979
|
const info = lanesFor(root);
|
|
1925
1980
|
if (json) { process.stdout.write(JSON.stringify(info, null, 2) + '\n'); return 0; }
|
|
@@ -1987,7 +2042,7 @@ function main(argv) {
|
|
|
1987
2042
|
}
|
|
1988
2043
|
|
|
1989
2044
|
module.exports = {
|
|
1990
|
-
computeWorkflow, declaredLane: laneDefs.declaredLane, readLifecycle, STOPPED_STATES, renderLadder, renderBoard, listInitiatives, layout, inFlight, BOARD_CAP,
|
|
2045
|
+
computeWorkflow, taskPlanOf, declaredLane: laneDefs.declaredLane, readLifecycle, STOPPED_STATES, renderLadder, renderBoard, listInitiatives, layout, inFlight, BOARD_CAP,
|
|
1991
2046
|
parseLeadingFrontmatter, specimenRoute, surfaceRoute, priorsCitation, isBuildPath, commitRange,
|
|
1992
2047
|
// the board's trunk range, exported so the suite can assert the split: the same record is legacy
|
|
1993
2048
|
// under BOTH ranges, and `in this change` is false under the trunk one.
|