create-pmos 0.574.0 → 0.576.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 +35 -2
- package/payload/KIT-VERSION +1 -1
- package/payload/okf/core/templates/agent-eval-set-template.md +65 -0
- package/payload/okf/core/templates/index.md +1 -0
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/scripts/agent-eval-set.js +85 -0
- package/payload/scripts/factory-guardrail.js +50 -8
- package/payload/scripts/work-item.js +49 -3
- package/payload/scripts/workflow-state.js +28 -3
- package/payload/state/discoveries.md +1 -1
- package/payload/templates/pmos-guardrail.yml +38 -10
- package/payload/templates/pmos-review-check.yml +59 -0
- package/workspace/briefing-premium-calendar-3-test.js +3 -10
- package/workspace/changelog.json +26 -0
- package/workspace/fixtures/agenda/invites.json +73 -0
- package/workspace/fixtures/builder-bench.json +121 -0
- package/workspace/guide/cli.md +71 -4
- package/workspace/guide/notes.md +1 -1
- package/workspace/guide/settings-and-switches.md +6 -0
- package/workspace/lib/agenda-topics.js +401 -0
- package/workspace/lib/agent-team.js +5 -2
- package/workspace/lib/build-cli.js +119 -7
- package/workspace/lib/build-engine.js +106 -25
- package/workspace/lib/builder-bench.js +267 -0
- package/workspace/lib/engine/agent-eval-set.js +85 -0
- package/workspace/lib/engine/workflow-state.js +28 -3
- package/workspace/lib/factory-checks.js +117 -0
- package/workspace/lib/factory-ci.js +151 -0
- package/workspace/lib/factory-fleet.js +263 -0
- package/workspace/lib/factory-identity.js +182 -0
- package/workspace/lib/factory-lessons.js +183 -0
- package/workspace/lib/factory-needs.js +48 -0
- package/workspace/lib/factory-review.js +241 -0
- package/workspace/lib/factory-rollout.js +56 -10
- package/workspace/lib/factory-traces.js +229 -0
- package/workspace/lib/headless.js +11 -2
- package/workspace/lib/meeting-focus.js +26 -13
- package/workspace/lib/needs-providers.js +1 -0
- package/workspace/lib/pmos-verbs.js +1 -1
- package/workspace/lib/project-onboard.js +1 -1
- package/workspace/lib/proposals.js +3 -1
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-factory-metrics.js +41 -0
- package/workspace/lib/routes-meeting-focus.js +79 -10
- package/workspace/lib/routes-proposals.js +9 -1
- package/workspace/lib/team-cli.js +2 -2
- package/workspace/lib/team-runs.js +13 -3
- package/workspace/lib/vendor/scripts/agent-eval-set.js +85 -0
- package/workspace/lib/vendor/scripts/workflow-state.js +28 -3
- package/workspace/lib/verify-runs.js +62 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/agenda-live.css +44 -0
- package/workspace/public/pm/agenda-live.js +100 -0
- package/workspace/public/pm/cozy-rec-now.js +20 -2
- package/workspace/public/pm/ini-props.js +1 -1
- package/workspace/public/pm/premium-vw-mtg.js +20 -21
- package/workspace/server.js +4 -0
- package/workspace/test-lists/adlc-identity.json +9 -0
- package/workspace/test-lists/build-engine.json +5 -3
- package/workspace/test-lists/builder-bench.json +9 -0
- package/workspace/test-lists/factory-checks.json +9 -0
- package/workspace/test-lists/factory-fleet.json +9 -0
- package/workspace/test-lists/factory-lessons.json +9 -0
- package/workspace/test-lists/factory-real-run.json +9 -0
- package/workspace/test-lists/factory-run-traces.json +9 -0
- package/workspace/test-lists/live-agenda-topics.json +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.576.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,32 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.576.0",
|
|
38
|
+
"at": "2026-11-16T11:57:06.812Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1308,
|
|
43
|
+
"t": "Close the nine ADLC agent-factory gaps",
|
|
44
|
+
"s": "Close the nine ADLC agent-factory gaps",
|
|
45
|
+
"k": "new"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"v": "0.575.0",
|
|
51
|
+
"at": "2026-11-16T11:43:16.900Z",
|
|
52
|
+
"f": 4,
|
|
53
|
+
"prs": [
|
|
54
|
+
{
|
|
55
|
+
"n": 1307,
|
|
56
|
+
"t": "A live meeting's agenda as 3 to 5 topics",
|
|
57
|
+
"s": "A live meeting's agenda as 3 to 5 topics",
|
|
58
|
+
"k": "new"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
36
62
|
{
|
|
37
63
|
"v": "0.574.0",
|
|
38
64
|
"at": "2026-11-16T06:14:05.146Z",
|
|
@@ -278,32 +304,6 @@
|
|
|
278
304
|
"k": "new"
|
|
279
305
|
}
|
|
280
306
|
]
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
"v": "0.556.0",
|
|
284
|
-
"at": "2026-11-11T01:22:29.972Z",
|
|
285
|
-
"f": 4,
|
|
286
|
-
"prs": [
|
|
287
|
-
{
|
|
288
|
-
"n": 1285,
|
|
289
|
-
"t": "Link or remove the 11 OKF files nothing read; move prototype screenshots out of git",
|
|
290
|
-
"s": "Link or remove the 11 OKF files nothing read; move prototype screenshots out of git",
|
|
291
|
-
"k": "x"
|
|
292
|
-
}
|
|
293
|
-
]
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
"v": "0.555.0",
|
|
297
|
-
"at": "2026-11-11T00:11:34.194Z",
|
|
298
|
-
"f": 4,
|
|
299
|
-
"prs": [
|
|
300
|
-
{
|
|
301
|
-
"n": 1284,
|
|
302
|
-
"t": "PMOS writes the first story, says why it acted quietly, and a verifier FAIL or revert sends a job back to asking",
|
|
303
|
-
"s": "PMOS writes the first story, says why it acted quietly, and a verifier FAIL or revert sends a job back to asking",
|
|
304
|
-
"k": "new"
|
|
305
|
-
}
|
|
306
|
-
]
|
|
307
307
|
}
|
|
308
308
|
]
|
|
309
309
|
}
|
package/payload/AGENTS.md
CHANGED
|
@@ -127,9 +127,42 @@ This kit carries the factory: `pmos/scripts/work-item.js` (the one writer of `pm
|
|
|
127
127
|
2. `pmos build propose <item> "<what it does>" --evidence "<the check that passed>"` commits with the repository's own git identity (`pmos git-identity`) and the line `Work-Item: <item>`, marks the item verified, and files "Open a draft pull request" for the PM.
|
|
128
128
|
3. PMOS opens the pull request by itself (D108): the workspace applies the proposal, pushes the one branch and runs `gh pr create --draft`. Undo closes it. With `pmos ai off` it waits for the PM's ✓. The Builder's own run never pushes.
|
|
129
129
|
4. Who merges is the product's own check, `pmos-guardrail` (copy `pmos/templates/pmos-guardrail.yml` to `.github/workflows/`; D108). It runs the default branch's `pmos/scripts/factory-guardrail.js` on the pull request's diff and reads AUTO or HUMAN. On AUTO it turns on GitHub auto-merge with the workflow's own token, so GitHub merges when every required check is green. On HUMAN the PM merges. The triggers that always read HUMAN are listed in that script and in the workspace guide (`pmos build policy <item>` shows the answer).
|
|
130
|
-
5.
|
|
130
|
+
5. Before the merge, PMOS reviews the pull request independently (initiative factory-premerge-reviewer). The cold check (copy `pmos/templates/pmos-review-check.yml` to `.github/workflows/`) reruns the item's declared check on a fresh checkout of the head in CI, with a read-only token and no secret. A separate read-only PMOS run, never the Builder's, reads the diff against the done test and records PASS or FAIL with `pmos build reviewed`. PMOS's own process posts the result as the commit status `pmos-review`. The guardrail reads AUTO only when `pmos-review` is success on the head it diffs; absent, pending or failed reads HUMAN. Two FAILs in a row put the factory back to propose-only for 7 days.
|
|
131
|
+
6. After the merge, `pmos verify-work` marks the item integrated, and the item's flag rolls out 5% → 50% → 100% through the commands in `pmos/factory.json`. A metric over its budget turns the flag off, opens a revert pull request and puts the factory back to propose-only for 7 days.
|
|
132
|
+
7. Order and concurrency. Declare an item with `--depends-on <item,…>` to make it wait: the Builder gets it only after each dependency is integrated. Each dependency must be declared first. Set `"builders": { "max_parallel": N, "per_day": M }` in `pmos/factory.json` to let more Builders work. The default is 1 at a time and 2 a day. A claim past `max_parallel` is refused, and once you set `builders`, a claim past `per_day` too.
|
|
133
|
+
8. The integrator. When a factory pull request changes a file that a merged change also changed, PMOS rebases its branch onto the default branch (`pmos build integrate`; the workspace also does this by itself). PMOS turns the pull request back to a draft and pushes only `pmos/<item>`, with a lease. The checks run again. On a conflict, the item goes back to the Builder once as a fix round. After that, the pull request gets `PMOS-Merge: human` and you resolve it.
|
|
134
|
+
9. **A product that is an AI agent** (an initiative with `agent: true`): the done test is a simulation eval set (`okf/core/templates/agent-eval-set-template.md`), required before the build. Declare the agent's prompt and model-id files and the eval set in `pmos/factory.json` (`"agent": { "files": [...], "eval_set": "..." }`): a pull request that changes one of those files reads HUMAN unless its work item's check names the eval set. Declare the drift numbers in `"agent_metrics"` (each `{ "cmd": ..., "max": ... }` or `{ "cmd": ..., "min": ... }`): they guard every rollout step and a flag at 100% for `agent_watch_days` (default 7), and a breach rolls the flag back like any metric.
|
|
131
135
|
|
|
132
|
-
The
|
|
136
|
+
**The product's checks** (factory-builder-inner-loop). Declare them in `pmos/factory.json` as `"checks": { "test": "npm test", ... }`. `pmos build check <item>` runs exactly these commands in the item's worktree, and `propose` runs them again: a failing check stops the proposal, and the evidence is their exit codes, written by PMOS. When the product's CI fails on the open pull request, PMOS reads it with `gh` in its own process and starts the Builder again on the same branch (`pmos build fix <item>`), at most 2 times and inside the Builder's daily budget. Then the item is `blocked` and waits for the PM on Today.
|
|
137
|
+
|
|
138
|
+
#### The factory's own identity (optional)
|
|
139
|
+
|
|
140
|
+
By default the factory commits with this repository's git identity and opens pull requests with your gh login. To make its work visible as the factory's, and to give it a narrower token than yours, name a factory identity in `pmos/factory.json`:
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{ "identity": { "name": "acme-pmos[bot]", "email": "123456+acme-pmos[bot]@users.noreply.github.com", "token_env": "PMOS_FACTORY_GH_TOKEN" } }
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Then each factory commit has the bot as author and you as `Co-authored-by:`, and PMOS gives gh the token from `PMOS_FACTORY_GH_TOKEN` for its own calls (open, close, revert, hold). The variable name must start with `PMOS_FACTORY_`: PMOS removes every such variable from the environment of its agent runs, so the Builder never holds the token. The push of the branch still uses your git credentials. `pmos build policy <item>` says which identity is in use. To make the token:
|
|
147
|
+
|
|
148
|
+
1. **A GitHub App (preferred).** Create an App owned by your organization. Repository permissions: **Contents: Read and write**, **Pull requests: Read and write**, **Metadata: Read**. Give it no other permission: no Administration, no Workflows, no Secrets. Install it on this repository only. Mint an installation token on your machine and export it as `PMOS_FACTORY_GH_TOKEN`. An installation token expires after one hour, so mint it in the shell that runs the workspace.
|
|
149
|
+
2. **Or a fine-grained personal access token.** Resource owner: the organization. Repository access: this repository only. Permissions: **Contents: Read and write**, **Pull requests: Read and write**. Set an expiry. Export it as `PMOS_FACTORY_GH_TOKEN`.
|
|
150
|
+
3. **Keep branch protection binding.** In the default branch's protection rule (or ruleset), do not add the App or the token's user to the bypass list, and keep "Do not allow bypassing the above settings" on. Limit pushes with the rule to `pmos/*` branches where your plan allows it. The token can open a pull request; only your required checks and the pmos-guardrail check can let it merge.
|
|
151
|
+
4. **Never put the token in a tracked file.** `factory.json` names the variable, not the token. PMOS refuses the whole identity if the file holds a token-like value or a `token`, `secret` or `password` key. If a token reached a commit, rotate it.
|
|
152
|
+
|
|
153
|
+
#### The sandboxed check (optional)
|
|
154
|
+
|
|
155
|
+
When `pmos/factory.json` declares no `checks` map, `pmos build check <item>` runs the item's single check in its worktree: `check.command` in `pmos/factory.json`, else the item's criterion when it is an `assertion`. Set `PMOS_BUILD_SANDBOX=docker` (or `podman`) on the machine and name an image to run it in a container with the worktree mounted and `--network none`:
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
{ "check": { "command": "npm test", "image": "node:20", "install": "npm ci --ignore-scripts" } }
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
The `install` step runs first in the same image with the network, and only when the item's diff changes no dependency manifest, lock file or registry config. Write it so that it runs no package scripts (for example `--ignore-scripts`). With no sandbox, or no image, or no binary, the check runs in the worktree, and only you can run it there: a Builder run is refused, because the worktree mode has this machine's network. `pmos build status` shows which mode the last check ran in.
|
|
162
|
+
|
|
163
|
+
The audit for this path: a Builder run reads private code and untrusted content, so it holds no outward channel. It has no `git push`, no `gh` and no merge, and `pmos build open` refuses a role run. The checks it can run are the PM's commands from `pmos/factory.json` (read from the PM's checkout; the Builder cannot change `pmos/`), and they run with no network namespace (`unshare -rn` on Linux, `sandbox-exec` on macOS) and no token in their environment. Where neither isolation works, the checks do not run. The CI read and the fix-round dispatch run in PMOS's process, never in the Builder's run. With no `checks` map, the single `check.command` runs for a Builder run only in a container with `--network none`. The factory token stays in PMOS's own process and never reaches the Builder's run. A commit that touches `pmos/`, `.github/`, `CLAUDE.md` or `AGENTS.md` is refused. The review run reads untrusted content (the diff) and private code, so it holds no outward channel either: read-only tools and the one verb `pmos build reviewed`, pinned to one item and commit. The pull request's code runs only in the cold-check job in CI, never on the PM's computer. The guardrail workflow holds a write token and reads untrusted content (the diff), so it never runs the pull request's code: `pull_request_target` runs the default branch's workflow and script, and the head is only fetched and diffed. A pull request that changes CI, the guardrail or its own tests reads HUMAN. The compensating gate is the product's own CI and branch protection on the default branch: protect it, and make your CI required, before you use the guardrail.
|
|
164
|
+
|
|
165
|
+
**The Builder benchmark.** `pmos build bench [--model <id>]` runs the Builder on a golden set of 10 small work items in a sandbox copy of a fixture product, one worktree per item, with the same prompt, tools, `claim` and `propose` as a real run. A held-out check that the Builder never sees scores each proposed commit. The command appends one row to `pmos/planning/runs/builder-bench.jsonl` with the model, the harness version (the Builder's prompt, its tool list and the build engine), the pass rate, the cost and the duration. `pmos build bench --report` groups the rows per model and harness version. Like evaluator calibration (D40), a pass rate belongs to one model and one harness: a new model or harness does not inherit the old number. **Run the bench after you change the Builder's model, and after a PMOS update that changes the harness version.** Compare the new row with the last one before you let the factory build again. The bench never pushes and never opens a pull request, and a role run cannot start it.
|
|
133
166
|
|
|
134
167
|
## Escalation (stop and ask the PM)
|
|
135
168
|
|
package/payload/KIT-VERSION
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: Template
|
|
3
|
+
title: Agent Eval Set Template
|
|
4
|
+
description: The done test of a Full SDLC initiative marked agent true — a simulation eval set at planning/done-tests/<id>.md with scenarios (input conversation, expected behaviour, scoring rubric) and one pass threshold. Written before the build.
|
|
5
|
+
tags: [template, done-test, eval-set, agent-product]
|
|
6
|
+
timestamp: 2026-11-16
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Agent Eval Set Template
|
|
10
|
+
|
|
11
|
+
**Situating context:** the ADLC evaluation (initiative `agent-product-lane`) found that a product that is itself an AI agent is judged by simulated conversations, not by a check table. When an initiative says `agent: true`, this file replaces the [done test template](/okf/core/templates/done-test-template.md). The [agent product mode](/okf/products/pmos/references/agent-product-lane.md) explains the rest.
|
|
12
|
+
|
|
13
|
+
## How to use it
|
|
14
|
+
|
|
15
|
+
1. Copy the block below to `planning/done-tests/<id>.md` (`pmos/planning/done-tests/<id>.md` in a product repository).
|
|
16
|
+
2. Set `done_test_path` and `kill:` in the initiative record, and `agent: true`.
|
|
17
|
+
3. Write at least three scenarios. Each scenario has an input conversation, the expected behaviour and a scoring rubric.
|
|
18
|
+
4. Set `pass_threshold`: the share of the total score the agent must reach, above 0 and at most 1.
|
|
19
|
+
5. Commit it before any build commit. Check the shape with `node scripts/agent-eval-set.js <file>`.
|
|
20
|
+
|
|
21
|
+
## The eval set
|
|
22
|
+
|
|
23
|
+
```markdown
|
|
24
|
+
---
|
|
25
|
+
type: Rubric
|
|
26
|
+
title: "Eval set — <title>"
|
|
27
|
+
timestamp: <YYYY-MM-DD>
|
|
28
|
+
initiative: <id>
|
|
29
|
+
pass_threshold: 0.8
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
# Eval set: <id>
|
|
33
|
+
|
|
34
|
+
<One or two sentences: what the agent does and what this set proves.>
|
|
35
|
+
|
|
36
|
+
## Scenario 1: <the happy path>
|
|
37
|
+
|
|
38
|
+
- **Input:**
|
|
39
|
+
> user: <the first message>
|
|
40
|
+
> agent: <what the agent says, when the scenario needs a turn before the one under test>
|
|
41
|
+
> user: <the next message>
|
|
42
|
+
- **Expected:** <the behaviour: what the agent does, says or refuses>
|
|
43
|
+
- **Scoring:** 1 when <fact>; 0.5 when <partial fact>; 0 otherwise.
|
|
44
|
+
|
|
45
|
+
## Scenario 2: <an edge case>
|
|
46
|
+
|
|
47
|
+
- **Input:**
|
|
48
|
+
> user: …
|
|
49
|
+
- **Expected:** …
|
|
50
|
+
- **Scoring:** …
|
|
51
|
+
|
|
52
|
+
## Scenario 3: <a refusal or a hallucination trap>
|
|
53
|
+
|
|
54
|
+
- **Input:**
|
|
55
|
+
> user: …
|
|
56
|
+
- **Expected:** …
|
|
57
|
+
- **Scoring:** …
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Rules
|
|
61
|
+
|
|
62
|
+
- **Grade the behaviour, not the wording** (D14). The scoring rubric names what is true in the reply, not the exact text.
|
|
63
|
+
- **Include one trap.** At least one scenario asks for something the agent must refuse or must not invent.
|
|
64
|
+
- **The work item's check names this file.** A factory pull request that changes the agent's prompts or model ids merges by itself only when its check is this eval set.
|
|
65
|
+
- **Do not change a scenario after the build starts.** If one is wrong, say so in the PR and let the PM decide.
|
|
@@ -16,3 +16,4 @@ OKF reserved file (no frontmatter). Directory listing for progressive disclosure
|
|
|
16
16
|
- [report-weekly-template](report-weekly-template.md) — A regular status report (D68 report lane, light by default): what moved against which KR or domain goal, metrics, blockers, what needs the reader.
|
|
17
17
|
- [experiment-record-template](experiment-record-template.md) — The experiment record (D107) at planning/initiatives/<id>.md: Intent, Done test, kill condition. The batch lead writes one for every batch item before its build.
|
|
18
18
|
- [done-test-template](done-test-template.md) — An experiment's done test (D107) at planning/done-tests/<id>.md: the checks that say the work is done, written before the build.
|
|
19
|
+
- [agent-eval-set-template](agent-eval-set-template.md) — The done test of an initiative marked agent: true (agent-product-lane): a simulation eval set with scenarios (input conversation, expected behaviour, scoring rubric) and a pass threshold.
|
|
@@ -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-16T11:57:03Z"}
|
|
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-16T11:57:03Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* agent-eval-set.js — the simulation eval set of a product that is an AI agent (initiative agent-product-lane, ADLC gap P1).
|
|
4
|
+
*
|
|
5
|
+
* A Full SDLC initiative may say `agent: true`: the product it builds is itself an agent. Its done test is then a simulation eval set,
|
|
6
|
+
* not a check table: scenarios that each give an input conversation, the expected behaviour and a scoring rubric, and one pass threshold.
|
|
7
|
+
* scripts/workflow-state.js requires it before the build. The template is okf/core/templates/agent-eval-set-template.md.
|
|
8
|
+
*
|
|
9
|
+
* isAgent(fm) → bool a record's `agent:` reads true (true, yes)
|
|
10
|
+
* parse(text) → { ok, threshold, scenarios: [{ id, title, input, expected, scoring }], missing: [string] }
|
|
11
|
+
*
|
|
12
|
+
* THE SHAPE (plain markdown, so a person reads it and this file checks it):
|
|
13
|
+
* front matter `pass_threshold: 0.8` a number above 0 and at most 1 (a share of the scenarios' scores)
|
|
14
|
+
* `## Scenario <id>: <title>` at least MIN_SCENARIOS of them
|
|
15
|
+
* under each, three labelled parts: `Input:` (the conversation: at least one `user:` turn), `Expected:`, `Scoring:`
|
|
16
|
+
*
|
|
17
|
+
* Deterministic. No model call, no network, no dependency: it is vendored into the kit with workflow-state.js.
|
|
18
|
+
*
|
|
19
|
+
* CLI: node scripts/agent-eval-set.js <file> [--json] exit 0 when the file is a valid eval set, 1 otherwise.
|
|
20
|
+
*/
|
|
21
|
+
const fs = require('fs');
|
|
22
|
+
|
|
23
|
+
const MIN_SCENARIOS = 3;
|
|
24
|
+
const PARTS = ['input', 'expected', 'scoring'];
|
|
25
|
+
const HEAD = /^##\s+scenario\b\s*([^:]*?)\s*(?::\s*(.*))?$/i;
|
|
26
|
+
const LABEL = /^\s*(?:[-*]\s*)?(?:\*\*|__)?(input|expected|scoring)(?:\s+behaviou?r|\s+rubric|\s+conversation)?\s*(?::\s*(?:\*\*|__)?|(?:\*\*|__)\s*:)\s*(.*)$/i;
|
|
27
|
+
|
|
28
|
+
const truthy = (v) => v === true || /^\s*["']?(true|yes)["']?\s*$/i.test(String(v == null ? '' : v));
|
|
29
|
+
/** The record's `agent:` value reads true. */
|
|
30
|
+
const isAgent = (fm) => !!fm && truthy(fm.agent);
|
|
31
|
+
|
|
32
|
+
function frontmatter(text) {
|
|
33
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(text);
|
|
34
|
+
const out = {};
|
|
35
|
+
if (!m) return { fm: out, body: text };
|
|
36
|
+
for (const l of m[1].split(/\r?\n/)) {
|
|
37
|
+
const kv = /^([A-Za-z_][\w-]*):\s*(.*)$/.exec(l);
|
|
38
|
+
if (kv) out[kv[1]] = kv[2].trim().replace(/^["']|["']$/g, '');
|
|
39
|
+
}
|
|
40
|
+
return { fm: out, body: text.slice(m[0].length) };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Read an eval set. Never throws. */
|
|
44
|
+
function parse(text) {
|
|
45
|
+
const missing = [];
|
|
46
|
+
const { fm, body } = frontmatter(String(text == null ? '' : text));
|
|
47
|
+
const raw = String(fm.pass_threshold == null ? '' : fm.pass_threshold).trim();
|
|
48
|
+
const t = /%$/.test(raw) ? Number(raw.slice(0, -1)) / 100 : Number(raw);
|
|
49
|
+
const threshold = raw !== '' && Number.isFinite(t) && t > 0 && t <= 1 ? t : null;
|
|
50
|
+
if (threshold === null) missing.push(raw ? `pass_threshold "${raw}" is not a number above 0 and at most 1` : 'no pass_threshold in the front matter');
|
|
51
|
+
|
|
52
|
+
const scenarios = [];
|
|
53
|
+
let cur = null, part = null;
|
|
54
|
+
for (const line of body.split(/\r?\n/)) {
|
|
55
|
+
const h = HEAD.exec(line);
|
|
56
|
+
if (h) { cur = { id: h[1] || String(scenarios.length + 1), title: (h[2] || '').trim(), input: '', expected: '', scoring: '' }; scenarios.push(cur); part = null; continue; }
|
|
57
|
+
if (/^#{1,2}\s/.test(line)) { cur = null; part = null; continue; }
|
|
58
|
+
if (!cur) continue;
|
|
59
|
+
const l = LABEL.exec(line);
|
|
60
|
+
if (l) { part = l[1].toLowerCase(); cur[part] = l[2].trim(); continue; }
|
|
61
|
+
if (part) cur[part] = (cur[part] + '\n' + line).trim();
|
|
62
|
+
}
|
|
63
|
+
if (scenarios.length < MIN_SCENARIOS) missing.push(`${scenarios.length} scenario${scenarios.length === 1 ? '' : 's'} (## Scenario …); an eval set needs at least ${MIN_SCENARIOS}`);
|
|
64
|
+
for (const s of scenarios) {
|
|
65
|
+
// a template placeholder (<…>, …, ...) and the turn labels are not content
|
|
66
|
+
const lack = PARTS.filter((p) => !s[p].replace(/<[^>\n]*>|…|\.\.\.|\b(user|agent|assistant)\s*:/gi, '').replace(/[>*_`\s.;:,-]/g, ''));
|
|
67
|
+
if (lack.length) missing.push(`scenario ${s.id} has no ${lack.join(', ')}`);
|
|
68
|
+
else if (!/(^|\n)\s*(?:>\s*)?(?:[-*]\s*)?(?:\*\*)?user(?:\*\*)?\s*:/i.test(s.input)) missing.push(`scenario ${s.id}'s input is not a conversation (no "user:" turn)`);
|
|
69
|
+
}
|
|
70
|
+
return { ok: missing.length === 0, threshold, scenarios, missing };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = { MIN_SCENARIOS, isAgent, parse };
|
|
74
|
+
|
|
75
|
+
if (require.main === module) {
|
|
76
|
+
const f = process.argv[2];
|
|
77
|
+
if (!f) { console.log('usage: node scripts/agent-eval-set.js <file> [--json]'); process.exit(2); }
|
|
78
|
+
let text;
|
|
79
|
+
try { text = fs.readFileSync(f, 'utf8'); } catch { console.log(`agent-eval-set: cannot read ${f}`); process.exit(1); }
|
|
80
|
+
const r = parse(text);
|
|
81
|
+
if (process.argv.includes('--json')) console.log(JSON.stringify(r));
|
|
82
|
+
else console.log(r.ok ? `agent-eval-set: ${f} is a simulation eval set: ${r.scenarios.length} scenarios, pass threshold ${r.threshold}.`
|
|
83
|
+
: `agent-eval-set: ${f} is not a simulation eval set:\n${r.missing.map((m) => '- ' + m).join('\n')}`);
|
|
84
|
+
process.exit(r.ok ? 0 : 1);
|
|
85
|
+
}
|
|
@@ -7,12 +7,16 @@
|
|
|
7
7
|
* (kit/templates/pmos-guardrail.yml, on pull_request_target) runs THE DEFAULT BRANCH'S COPY of this file on the pull request's
|
|
8
8
|
* diff. The pull request's own code never runs, so a pull request cannot rewrite the rule that judges it.
|
|
9
9
|
*
|
|
10
|
-
* classify({ cwd, base, head, branch, body, ledgerText, now }) → { factory, item, verdict: 'auto'|'human'|'none', reasons, files }
|
|
10
|
+
* classify({ cwd, base, head, branch, body, ledgerText, now, review }) → { factory, item, verdict: 'auto'|'human'|'none', reasons, files }
|
|
11
11
|
*
|
|
12
12
|
* `none` not a factory pull request (no branch pmos/<item> and no line `Work-Item: <id>`): PMOS does nothing.
|
|
13
13
|
* `auto` ALL of: the item is verified in the default branch's ledger; every changed file is inside the item's declared scope;
|
|
14
14
|
* the change sits behind the item's flag (its name appears in the added lines) or the item is declared with no
|
|
15
|
-
* user-facing effect;
|
|
15
|
+
* user-facing effect; no trigger below fires; and the independent review passed: the commit status `pmos-review` on the head
|
|
16
|
+
* is `success` (initiative factory-premerge-reviewer). Required CI is GitHub's part: auto-merge waits for every required check.
|
|
17
|
+
* `review` is that status as the workflow read it (success | failure | error | pending | null for absent). The CLI always passes
|
|
18
|
+
* it, so an absent review reads human. A library call that omits it (the local preview, lib/build-engine.js mergePolicy) does not
|
|
19
|
+
* judge the review. The guardrail reads the state only; it never calls a model.
|
|
16
20
|
* `human` any trigger, or any `auto` condition missing. Every reason is named.
|
|
17
21
|
*
|
|
18
22
|
* TRIGGERS (any one → human): migrations or data deletion · auth, permissions, payments, personal data or secrets · CI, gates,
|
|
@@ -21,9 +25,12 @@
|
|
|
21
25
|
* the D11 triggers: the item failed before, a revert on the default branch in the last 14 days, a subsystem untouched 90 days ·
|
|
22
26
|
* the line `PMOS-Merge: human` (PMOS writes it when autonomy is off or the factory is demoted; the PM may add it to stop a merge) ·
|
|
23
27
|
* a pull request from a fork (a branch named pmos/… elsewhere is not PMOS's).
|
|
28
|
+
* agent-product-lane: a changed prompt or model-id file of a product that is an agent (pmos/factory.json agent.files), unless the item's
|
|
29
|
+
* check names the product's simulation eval set (agent.eval_set).
|
|
24
30
|
*
|
|
25
31
|
* CLI (the workflow's one step):
|
|
26
|
-
* node pmos/scripts/factory-guardrail.js --base <ref> --head <ref> [--branch <name>] [--body-file <f>] [--head-repo o/r --base-repo o/r]
|
|
32
|
+
* node pmos/scripts/factory-guardrail.js --base <ref> --head <ref> [--branch <name>] [--body-file <f>] [--head-repo o/r --base-repo o/r]
|
|
33
|
+
* [--review-state <success|failure|error|pending|>] [--json]
|
|
27
34
|
* [--github --pr <number>] in GitHub Actions only: write verdict to GITHUB_OUTPUT and the step summary; on auto run
|
|
28
35
|
* `gh pr ready` and `gh pr merge --auto --squash` with the workflow's own token; on human turn
|
|
29
36
|
* auto-merge off. The agent never runs this: the Builder has no node, gh or push.
|
|
@@ -140,8 +147,26 @@ function staleDirs(cwd, base, files, nowMs) {
|
|
|
140
147
|
const pathsIn = (ref) => String(ref || '').split(/\s+/).map((t) => t.replace(/^['"]|['"]$/g, '').replace(/^\.\//, '')).filter((t) => /[\/]|\.[a-z0-9]+$/i.test(t) && !t.startsWith('-'));
|
|
141
148
|
const inScope = (f, scope) => scope.some((s) => { const p = s.replace(/^\.\//, ''); return p.endsWith('/') ? f.startsWith(p) : f === p || f.startsWith(p + '/'); });
|
|
142
149
|
|
|
150
|
+
/* agent-product-lane (ADLC gap P1): a product that is itself an AI agent declares its prompt and model-id files, and its simulation eval
|
|
151
|
+
* set, in pmos/factory.json: { "agent": { "files": ["src/agent/prompts/", "src/agent/model.json"], "eval_set": "pmos/planning/done-tests/x.md" } }.
|
|
152
|
+
* Read from the BASE, like the ledger, so a pull request cannot change the declaration that judges it. The rule only ever adds a reason. */
|
|
153
|
+
function agentDeclOf(cwd, base, factoryText) {
|
|
154
|
+
let text = factoryText;
|
|
155
|
+
if (text === undefined) {
|
|
156
|
+
const top = git(cwd, ['rev-parse', '--show-toplevel']).out.trim() || cwd;
|
|
157
|
+
const rel = path.relative(top, path.join(__dirname, '..', 'factory.json')).split(path.sep).join('/');
|
|
158
|
+
const r = rel.startsWith('..') ? { ok: false } : git(top, ['show', `${base}:${rel}`]);
|
|
159
|
+
text = r.ok ? r.out : null;
|
|
160
|
+
}
|
|
161
|
+
let a = null;
|
|
162
|
+
try { a = text ? JSON.parse(text).agent : null; } catch { return null; }
|
|
163
|
+
if (!a || typeof a !== 'object') return null;
|
|
164
|
+
const files = (Array.isArray(a.files) ? a.files : []).filter((x) => typeof x === 'string' && x.trim()).map((x) => x.trim().replace(/^\.\//, ''));
|
|
165
|
+
return { files, eval_set: typeof a.eval_set === 'string' ? a.eval_set.trim().replace(/^\.\//, '') : '' };
|
|
166
|
+
}
|
|
167
|
+
|
|
143
168
|
/** The verdict. Pure but for git reads in `cwd`. */
|
|
144
|
-
function classify({ cwd = process.cwd(), base, head, branch = '', body = '', ledgerText, now, headRepo = null, baseRepo = null } = {}) {
|
|
169
|
+
function classify({ cwd = process.cwd(), base, head, branch = '', body = '', ledgerText, factoryText, now, headRepo = null, baseRepo = null, review } = {}) {
|
|
145
170
|
const nowMs = now == null ? Date.now() : (typeof now === 'number' ? now : Date.parse(now));
|
|
146
171
|
const fromBranch = /^(?:refs\/heads\/)?pmos\/(?:revert-)?([a-z0-9][a-z0-9_-]*\.[0-9]+)$/.exec(String(branch || ''));
|
|
147
172
|
const fromBody = /^Work-Item:\s*(\S+)\s*$/m.exec(String(body || ''));
|
|
@@ -205,6 +230,13 @@ function classify({ cwd = process.cwd(), base, head, branch = '', body = '', led
|
|
|
205
230
|
if (it && it.criterion) for (const r of pathsIn(it.criterion.ref)) if (p === r || p.startsWith(r.replace(/\/?$/, '/'))) human('self-test', `${p} is the item's own check (${it.criterion.ref})`);
|
|
206
231
|
}
|
|
207
232
|
|
|
233
|
+
// ---- agent-prompt: the agent product's prompts and model ids are code, and only its simulation eval set judges them
|
|
234
|
+
const ag = agentDeclOf(cwd, base, factoryText);
|
|
235
|
+
const agentHit = ag ? files.find((f) => inScope(f.path, ag.files) || (f.from && inScope(f.from, ag.files))) : null;
|
|
236
|
+
if (agentHit && !(ag.eval_set && it && it.criterion && pathsIn(it.criterion.ref).includes(ag.eval_set))) {
|
|
237
|
+
human('agent-prompt', `${agentHit.path} is a prompt or model id of the product's agent, and ${item || 'this change'}'s check is not the eval set ${ag.eval_set || '(pmos/factory.json declares no agent.eval_set)'}`);
|
|
238
|
+
}
|
|
239
|
+
|
|
208
240
|
// ---- added lines
|
|
209
241
|
const code = all.filter(([p]) => !/\.(md|mdx|txt|rst|adoc)$/i.test(p) && !TEST_FILE.test(p.toLowerCase()) && !TEST_NAME.test(p.toLowerCase()));
|
|
210
242
|
for (const t of ADDED) {
|
|
@@ -224,6 +256,14 @@ function classify({ cwd = process.cwd(), base, head, branch = '', body = '', led
|
|
|
224
256
|
if (rv !== null) human('d11-revert', `a merge was reverted on the default branch ${rv === 0 ? 'today' : rv + ' days ago'} (D11)`);
|
|
225
257
|
for (const s of staleDirs(cwd, base, files, nowMs)) human('d11-stale', `${s.dir} was last changed ${s.days} days ago (D11: a subsystem untouched about 3 months)`);
|
|
226
258
|
|
|
259
|
+
// ---- the independent review of this head (factory-premerge-reviewer). Omitted: a preview, not judged here.
|
|
260
|
+
if (review !== undefined && !isRevert) {
|
|
261
|
+
const st = String(review == null ? '' : review).trim().toLowerCase();
|
|
262
|
+
if (!st) human('no-review', 'the head has no pmos-review check yet: PMOS reviews each factory pull request before it merges by itself');
|
|
263
|
+
else if (st === 'pending') human('review-pending', 'the pmos-review check is still running on this head');
|
|
264
|
+
else if (st !== 'success') human('review-failed', `the pmos-review check is ${one(st, 20)} on this head: the independent review did not pass`);
|
|
265
|
+
}
|
|
266
|
+
|
|
227
267
|
const seen = new Set();
|
|
228
268
|
const uniq = reasons.filter((r) => { const k = r.rule + '|' + r.detail; if (seen.has(k)) return false; seen.add(k); return true; });
|
|
229
269
|
return { factory: true, item, verdict: uniq.length ? 'human' : 'auto', reasons: uniq, files: files.map((f) => f.path) };
|
|
@@ -231,7 +271,7 @@ function classify({ cwd = process.cwd(), base, head, branch = '', body = '', led
|
|
|
231
271
|
|
|
232
272
|
function summaryOf(v) {
|
|
233
273
|
if (v.verdict === 'none') return 'pmos-guardrail: not a factory pull request. Nothing to do.';
|
|
234
|
-
if (v.verdict === 'auto') return `pmos-guardrail: AUTO for ${v.item}. Auto-merge is on: GitHub merges when every required check is green. The change reaches users only through its flag.`;
|
|
274
|
+
if (v.verdict === 'auto') return `pmos-guardrail: AUTO for ${v.item}. The pmos-review check passed. Auto-merge is on: GitHub merges when every required check is green. The change reaches users only through its flag.`;
|
|
235
275
|
return [`pmos-guardrail: HUMAN for ${v.item || 'this revert'}. A person merges this pull request, because:`, ...v.reasons.map((r) => `- ${r.detail}`)].join('\n');
|
|
236
276
|
}
|
|
237
277
|
|
|
@@ -250,11 +290,13 @@ function actOnGitHub(v, { pr, env = process.env } = {}) {
|
|
|
250
290
|
function cliMain(argv, { say = (s) => console.log(s), env = process.env, cwd = process.cwd() } = {}) {
|
|
251
291
|
const opt = (k) => { const i = argv.indexOf(k); return i !== -1 && argv[i + 1] !== undefined && !argv[i + 1].startsWith('--') ? argv[i + 1] : undefined; };
|
|
252
292
|
const base = opt('--base'), head = opt('--head');
|
|
253
|
-
if (!base || !head) { say('usage: node factory-guardrail.js --base <ref> --head <ref> [--branch <name>] [--body-file <f>] [--json] [--github --pr <n>]'); return 2; }
|
|
293
|
+
if (!base || !head) { say('usage: node factory-guardrail.js --base <ref> --head <ref> [--branch <name>] [--body-file <f>] [--review-state <s>] [--json] [--github --pr <n>]'); return 2; }
|
|
254
294
|
let body = '';
|
|
255
295
|
if (opt('--body-file')) { try { body = fs.readFileSync(opt('--body-file'), 'utf8'); } catch { body = 'PMOS-Merge: human'; } }
|
|
256
296
|
let v;
|
|
257
|
-
|
|
297
|
+
// the CLI always judges the review: an absent --review-state (or an empty one) is "no review", never a pass
|
|
298
|
+
const review = opt('--review-state') || null;
|
|
299
|
+
try { v = classify({ cwd, base, head, branch: opt('--branch') || '', body, headRepo: opt('--head-repo') || null, baseRepo: opt('--base-repo') || null, review }); }
|
|
258
300
|
catch (e) { v = { factory: true, item: null, verdict: 'human', reasons: [{ rule: 'unreadable', detail: 'the guardrail failed: ' + one(e.message, 200) }], files: [] }; }
|
|
259
301
|
say(argv.includes('--json') ? JSON.stringify(v) : summaryOf(v));
|
|
260
302
|
if (argv.includes('--github')) {
|
|
@@ -263,5 +305,5 @@ function cliMain(argv, { say = (s) => console.log(s), env = process.env, cwd = p
|
|
|
263
305
|
return 0;
|
|
264
306
|
}
|
|
265
307
|
|
|
266
|
-
module.exports = { classify, summaryOf, actOnGitHub, cliMain, REVERT_DAYS, STALE_DAYS };
|
|
308
|
+
module.exports = { classify, summaryOf, actOnGitHub, cliMain, REVERT_DAYS, STALE_DAYS, MANIFESTS, LOCKS };
|
|
267
309
|
if (require.main === module) process.exitCode = cliMain(process.argv.slice(2));
|
|
@@ -57,6 +57,9 @@ const ITEM_TYPES = Object.freeze([
|
|
|
57
57
|
const BLAST = Object.freeze(['low', 'medium', 'high']);
|
|
58
58
|
const EVENTS = Object.freeze([
|
|
59
59
|
'declared', 'claimed', 'released', 'verified', 'failed', 'integrated', 'shipped', 'withdrawn',
|
|
60
|
+
/* factory-builder-inner-loop: the product's CI stayed red after the Builder's fix rounds, so the item waits for the PM. It needs a
|
|
61
|
+
* `reason`. Not in the chain and not terminal: the PM fixes it, and a later `claimed` or `integrated` moves it on. */
|
|
62
|
+
'blocked',
|
|
60
63
|
]);
|
|
61
64
|
/** How a machine decides the criterion. `none` is legal for ONE type — see requireCriterion. */
|
|
62
65
|
const CHECK_KINDS = Object.freeze(['test', 'assertion', 'rubric_dimension', 'none']);
|
|
@@ -140,6 +143,10 @@ function validateEvent(obj, opts) {
|
|
|
140
143
|
} else if (obj.plan_item !== undefined) {
|
|
141
144
|
errors.push('`plan_item` is written only on `declared` — it is fixed when the item is materialized');
|
|
142
145
|
}
|
|
146
|
+
/* OPTIONAL (initiative factory-fleet-scale): the items this one waits for. The Builder is offered it only once each of them is
|
|
147
|
+
* integrated or shipped (workspace/lib/build-engine.js next). Fixed at `declared`, like plan_item. */
|
|
148
|
+
if (event === 'declared' && obj.depends_on !== undefined) errors.push(...dependsOnErrors(obj.depends_on, itemId));
|
|
149
|
+
else if (obj.depends_on !== undefined) errors.push('`depends_on` is written only on `declared`');
|
|
143
150
|
|
|
144
151
|
// -- required on `claimed` -------------------------------------------------------------------
|
|
145
152
|
if (event === 'claimed') {
|
|
@@ -159,6 +166,11 @@ function validateEvent(obj, opts) {
|
|
|
159
166
|
}
|
|
160
167
|
}
|
|
161
168
|
|
|
169
|
+
// -- required on `blocked`: the PM reads why ------------------------------------------------------
|
|
170
|
+
if (event === 'blocked' && (typeof obj.reason !== 'string' || !obj.reason.trim() || obj.reason.length > 500)) {
|
|
171
|
+
errors.push('`blocked` must carry `reason`, one line of at most 500 characters — the PM reads it on Today');
|
|
172
|
+
}
|
|
173
|
+
|
|
162
174
|
// -- required where a verdict is being asserted ----------------------------------------------
|
|
163
175
|
if (event === 'verified' || event === 'failed' || event === 'shipped') {
|
|
164
176
|
if (obj.evidence === undefined || obj.evidence === null || obj.evidence === '') {
|
|
@@ -169,6 +181,22 @@ function validateEvent(obj, opts) {
|
|
|
169
181
|
return { ok: errors.length === 0, errors };
|
|
170
182
|
}
|
|
171
183
|
|
|
184
|
+
const DEPENDS_MAX = 20;
|
|
185
|
+
/** `depends_on`: a list of other item ids, each once, at most DEPENDS_MAX. */
|
|
186
|
+
function dependsOnErrors(deps, itemId) {
|
|
187
|
+
if (!Array.isArray(deps)) return ['`depends_on` must be a list of item ids'];
|
|
188
|
+
const errs = [];
|
|
189
|
+
if (deps.length > DEPENDS_MAX) errs.push(`\`depends_on\` names ${deps.length} items; at most ${DEPENDS_MAX}`);
|
|
190
|
+
const seen = new Set();
|
|
191
|
+
for (const d of deps) {
|
|
192
|
+
if (typeof d !== 'string' || !ITEM_ID_RE.test(d)) { errs.push(`\`depends_on\` entry ${JSON.stringify(d)} is not an item id (<initiative-id>.<ordinal>)`); continue; }
|
|
193
|
+
if (d === itemId) errs.push(`\`depends_on\` names the item itself ('${d}')`);
|
|
194
|
+
if (seen.has(d)) errs.push(`\`depends_on\` names '${d}' twice`);
|
|
195
|
+
seen.add(d);
|
|
196
|
+
}
|
|
197
|
+
return errs;
|
|
198
|
+
}
|
|
199
|
+
|
|
172
200
|
/**
|
|
173
201
|
* R3 — a slice with no machine-checkable criterion is not a work-item.
|
|
174
202
|
* `check: none` is legal for exactly one type; for the other six it is a validation error, which is
|
|
@@ -453,7 +481,8 @@ function deriveItems(input, opts) {
|
|
|
453
481
|
blast: obj.blast,
|
|
454
482
|
criterion: obj.criterion,
|
|
455
483
|
...(obj.plan_item !== undefined ? { plan_item: obj.plan_item } : {}), // D86 point 1; absent stays absent
|
|
456
|
-
...(obj.guard !== undefined ? { guard: obj.guard } : {}),
|
|
484
|
+
...(obj.guard !== undefined ? { guard: obj.guard } : {}),
|
|
485
|
+
...(obj.depends_on !== undefined ? { depends_on: obj.depends_on.slice() } : {}), // factory-fleet-scale: what it waits for // D108: scope, flag, user_facing, kr — what the merge guardrail reads
|
|
457
486
|
state: 'declared',
|
|
458
487
|
claim: null,
|
|
459
488
|
evidence: null,
|
|
@@ -516,6 +545,7 @@ function deriveItems(input, opts) {
|
|
|
516
545
|
case 'integrated':it.state = 'integrated'; it.claim = null; break;
|
|
517
546
|
case 'shipped': it.state = 'shipped'; it.claim = null; it.evidence = obj.evidence; break;
|
|
518
547
|
case 'withdrawn': it.state = 'withdrawn'; it.claim = null; break;
|
|
548
|
+
case 'blocked': it.state = 'blocked'; it.claim = null; it.reason = obj.reason; break;
|
|
519
549
|
default: it.determinable = false; break;
|
|
520
550
|
}
|
|
521
551
|
}
|
|
@@ -1355,7 +1385,7 @@ module.exports = {
|
|
|
1355
1385
|
ITEM_ID_RE, INITIATIVE_ID_RE, PLAN_ITEM_RE, PERMITTED_BASENAME,
|
|
1356
1386
|
dispatchRefusal, makeRecordOf, makeRankedOf,
|
|
1357
1387
|
ForbiddenWrite, LockUnavailable, LOCK_WAIT_MS, LOCK_STALE_MS, defaultInitiativeExists, makeInitiativeExists, CHECK_OPEN_GAP,
|
|
1358
|
-
validateEvent, criterionErrors, deriveItems, assertWritable, appendEvent, claimRefusal, CLAIM_EVENTS,
|
|
1388
|
+
validateEvent, criterionErrors, dependsOnErrors, DEPENDS_MAX, deriveItems, assertWritable, appendEvent, claimRefusal, CLAIM_EVENTS,
|
|
1359
1389
|
TERMINAL, CHAIN, UNSEEN_NODES, chainFor, chainPos, discardRefusal, readLedgerSafely,
|
|
1360
1390
|
/* Exported so the suite can assert the revocation table is DERIVED — an assertion that retyped
|
|
1361
1391
|
* the pairs would agree with itself and not with the code. */
|
|
@@ -1374,9 +1404,11 @@ module.exports = {
|
|
|
1374
1404
|
*
|
|
1375
1405
|
* node scripts/work-item.js declare <initiative> --type <t> --blast <low|medium|high> --criterion "<text>" \
|
|
1376
1406
|
* --check <test|assertion|rubric_dimension|none> --ref "<suite or file>" [--plan-item <id>] [--agent <who>] [--hours N]
|
|
1407
|
+
* [--depends-on <item,…>] (factory-fleet-scale: the Builder is offered the item only once these are integrated)
|
|
1377
1408
|
* node scripts/work-item.js verify <item> --evidence "<what passed>"
|
|
1378
1409
|
* node scripts/work-item.js claim <item> [--agent <who>] [--hours N] (W7: the kit's Builder claims an item PMOS declared)
|
|
1379
1410
|
* node scripts/work-item.js show [<initiative>] [--json]
|
|
1411
|
+
* node scripts/work-item.js block <item> --reason "<why it waits for the PM>" (the CI-fix loop gave up: workspace/lib/factory-ci.js)
|
|
1380
1412
|
*
|
|
1381
1413
|
* `declare … --no-claim` appends `declared` only, so the item waits for a Builder (`pmos build claim`).
|
|
1382
1414
|
* `declare` appends `declared` and then `claimed` (a lease of --hours, default 72, for --agent, default the session id), and
|
|
@@ -1411,10 +1443,12 @@ function cliMain(argv) {
|
|
|
1411
1443
|
const usage = () => {
|
|
1412
1444
|
console.log('usage: node scripts/work-item.js declare <initiative> --type <t> --blast <b> --criterion "<text>" --check <kind> --ref "<ref>" [--plan-item <id>] [--agent <who>] [--hours N] [--no-claim]');
|
|
1413
1445
|
console.log(' declare claims the item for you; add --no-claim to leave it for the Builder (pmos build next lists only unclaimed items)');
|
|
1446
|
+
console.log(' [--depends-on <item,…>] the items this one waits for; each must be declared already');
|
|
1414
1447
|
console.log(' [--scope <path,…>] [--flag <name> [--metric <name> --budget <max>] | --no-user-facing] [--kr] (D108: what the merge guardrail reads)');
|
|
1415
1448
|
console.log(' node scripts/work-item.js verify <item> --evidence "<what passed>"');
|
|
1416
1449
|
console.log(' node scripts/work-item.js claim <item> [--agent <who>] [--hours N]');
|
|
1417
1450
|
console.log(' node scripts/work-item.js show [<initiative>] [--json]');
|
|
1451
|
+
console.log(' node scripts/work-item.js block <item> --reason "<why it waits for the PM>"');
|
|
1418
1452
|
return 2;
|
|
1419
1453
|
};
|
|
1420
1454
|
const append = (ev) => {
|
|
@@ -1435,8 +1469,12 @@ function cliMain(argv) {
|
|
|
1435
1469
|
const criterion = { text: opt('--criterion') || '', check: opt('--check') || 'test', ref: opt('--ref') || '' };
|
|
1436
1470
|
const guard = guardOf(argv, opt);
|
|
1437
1471
|
if (guard && guard.error) { console.log(`✗ ${guard.error}`); return 2; }
|
|
1472
|
+
// factory-fleet-scale: a dependency must be declared already, so the graph can have no cycle
|
|
1473
|
+
const deps = opt('--depends-on') ? String(opt('--depends-on')).split(',').map((x) => x.trim()).filter(Boolean) : null;
|
|
1474
|
+
const missing = (deps || []).filter((d) => !taken.has(d));
|
|
1475
|
+
if (missing.length) { console.log(`✗ --depends-on names ${missing.join(', ')}, which is not declared. Declare it first.`); return 2; }
|
|
1438
1476
|
const declared = { item_id: id, initiative_id: target, event: 'declared', at, type: opt('--type') || 'feature-slice', blast: opt('--blast') || 'low', criterion,
|
|
1439
|
-
...(opt('--plan-item') ? { plan_item: opt('--plan-item') } : {}), ...(guard ? { guard } : {}) };
|
|
1477
|
+
...(opt('--plan-item') ? { plan_item: opt('--plan-item') } : {}), ...(guard ? { guard } : {}), ...(deps ? { depends_on: deps } : {}) };
|
|
1440
1478
|
if (!append(declared)) return 1;
|
|
1441
1479
|
if (argv.includes('--no-claim')) {
|
|
1442
1480
|
console.log(`✓ ${id} declared → planning/work-items.jsonl (not claimed; a Builder claims it)`);
|
|
@@ -1470,6 +1508,14 @@ function cliMain(argv) {
|
|
|
1470
1508
|
console.log(`✓ ${target} claimed by ${agent} for ${hours} h`);
|
|
1471
1509
|
return 0;
|
|
1472
1510
|
}
|
|
1511
|
+
if (verb === 'block') {
|
|
1512
|
+
const reason = opt('--reason');
|
|
1513
|
+
if (!target || !ITEM_ID_RE.test(target) || !reason) return usage();
|
|
1514
|
+
const ev = { item_id: target, initiative_id: target.slice(0, target.lastIndexOf('.')), event: 'blocked', at: writerNow(), reason: reason.slice(0, 500) };
|
|
1515
|
+
if (!append(ev)) return 1;
|
|
1516
|
+
console.log(`✓ ${target} blocked (${ev.reason})`);
|
|
1517
|
+
return 0;
|
|
1518
|
+
}
|
|
1473
1519
|
if (verb === 'show') {
|
|
1474
1520
|
const { items } = deriveItems(read(), { now: writerNow() });
|
|
1475
1521
|
const shown = items.filter((it) => !target || (target !== '--json' && it.initiative_id === target) || target === '--json');
|