create-pmos 0.538.0 → 0.539.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.
Files changed (36) hide show
  1. package/package.json +14 -26
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/changelog.json +13 -0
  7. package/workspace/guide/agent-capabilities.md +7 -5
  8. package/workspace/guide/agents-act.md +68 -0
  9. package/workspace/guide/index.md +2 -1
  10. package/workspace/guide/initiative-driver.md +16 -7
  11. package/workspace/lib/agent-inbox.js +2 -2
  12. package/workspace/lib/ai-guard.js +16 -6
  13. package/workspace/lib/auto-keep.js +33 -0
  14. package/workspace/lib/autonomy-cli.js +53 -0
  15. package/workspace/lib/autonomy.js +234 -0
  16. package/workspace/lib/bg-queue.js +2 -1
  17. package/workspace/lib/driver-cli.js +26 -10
  18. package/workspace/lib/driver-decide.js +76 -8
  19. package/workspace/lib/driver.js +15 -4
  20. package/workspace/lib/goal-loop.js +221 -0
  21. package/workspace/lib/job-graph.js +3 -0
  22. package/workspace/lib/loop-cli.js +84 -0
  23. package/workspace/lib/pm-lines-needs.js +3 -0
  24. package/workspace/lib/pmos-verbs.js +6 -1
  25. package/workspace/lib/route-modules.js +1 -0
  26. package/workspace/lib/routes-autonomy.js +95 -0
  27. package/workspace/lib/routes-proposals.js +101 -46
  28. package/workspace/lib/stage-tools.js +11 -1
  29. package/workspace/lib/today.js +2 -8
  30. package/workspace/package-lock.json +2 -2
  31. package/workspace/package.json +1 -1
  32. package/workspace/public/pm/home-around.js +2 -2
  33. package/workspace/replaced-tests.json +17 -0
  34. package/workspace/server.js +26 -14
  35. package/workspace/test-lists/full-autonomy.json +11 -0
  36. package/workspace/test-run.js +3 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.538.0",
3
+ "version": "0.539.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": {
@@ -32,6 +32,19 @@
32
32
  "audit"
33
33
  ],
34
34
  "pmosChanges": [
35
+ {
36
+ "v": "0.539.0",
37
+ "at": "2026-11-08T04:03:50.219Z",
38
+ "f": 4,
39
+ "prs": [
40
+ {
41
+ "n": 1261,
42
+ "t": "Full autonomy now (D106): class A/B changes apply by themselves with Undo",
43
+ "s": "Full autonomy now: class A/B changes apply by themselves with Undo",
44
+ "k": "new"
45
+ }
46
+ ]
47
+ },
35
48
  {
36
49
  "v": "0.538.0",
37
50
  "at": "2026-11-08T03:45:27.128Z",
@@ -434,31 +447,6 @@
434
447
  "k": "new"
435
448
  }
436
449
  ]
437
- },
438
- {
439
- "v": "0.519.0",
440
- "at": "2026-11-04T01:26:27.710Z",
441
- "f": 4,
442
- "prs": [
443
- {
444
- "n": 1213,
445
- "t": "Every undated initiative is a Timeline row with No dates",
446
- "s": "Every undated initiative is a Timeline row with No dates",
447
- "k": "fix"
448
- },
449
- {
450
- "n": 1214,
451
- "t": "Chat prompt suggestions run on claude -p by default, and never fail silently",
452
- "s": "Chat prompt suggestions run on claude -p by default, and never fail silently",
453
- "k": "fix"
454
- },
455
- {
456
- "n": 1215,
457
- "t": "Background runs read long connector results; guide fills the wide Viewer",
458
- "s": "Background runs read long connector results; guide fills the wide Viewer",
459
- "k": "fix"
460
- }
461
- ]
462
450
  }
463
451
  ]
464
452
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@be5f6fe3
1
+ kernel-source: pmos@2f79897c
2
2
  assembled: 2026-11-08
3
3
  mode: vendor
@@ -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-08T03:45:24Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-08T04:03:46Z"}
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-08T03:45:24Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-08T04:03:46Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-11-08T03:45:24Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-08T04:03:46Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,17 @@
1
1
  [
2
+ {
3
+ "v": "0.539.0",
4
+ "at": "2026-11-08T04:03:50.219Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1261,
9
+ "t": "Full autonomy now (D106): class A/B changes apply by themselves with Undo",
10
+ "s": "Full autonomy now: class A/B changes apply by themselves with Undo",
11
+ "k": "new"
12
+ }
13
+ ]
14
+ },
2
15
  {
3
16
  "v": "0.538.0",
4
17
  "at": "2026-11-08T03:45:27.128Z",
@@ -7,14 +7,15 @@ timestamp: 2026-11-08
7
7
 
8
8
  # What Claude does behind the scenes
9
9
 
10
- Claude works in the background while the workspace runs. It reads your records and the tools you connected, it drafts, and it checks. It does not decide for you. A result waits for your ✓, most often under the blue ✦ of an initiative or as one ✦ in Home's chat. A background job never sends, posts, pushes or merges anything.
10
+ Claude works in the background while the workspace runs. It reads your records and the tools you connected, it drafts, and it checks. Since D106 (Full autonomy now), a change that is reversible is applied at once, with Undo for 14 days. A change that other people see, or that cannot be undone, waits for your ✓. A background job never sends, posts, pushes or merges anything. See [Agents act by themselves](agents-act.md).
11
11
 
12
12
  This page lists every job, so you know what runs and why. Each row links to the page with the full detail.
13
13
 
14
14
  ## The rules every job follows
15
15
 
16
- - **Propose-only.** A background job files proposals. Nothing lands on an initiative, a task or a metric until you press ✓. ✕ drops a proposal, and Undo brings back what was there.
17
- - **Every claim has a source.** An AI job files through one shared guard. The guard checks that each quote is really at the file and line it cites. A claim with no source that checks out is dropped. A proposal with a key that would write, apply, send or run a command is dropped.
16
+ - **Three classes of change (D106).** Class A is upkeep with one right answer: tidy names, dates moved by evidence, a note. Class B is a reversible judgment: a problem statement, an outcome, a description, a task, a grill fix, what was found elsewhere. Class A and class B changes are applied at once and listed with Undo for 14 days. Class C is a change that other people see or that cannot be undone: a message to a person, a Jira move, a stage move, a merge into a product repository, a delete or spend. Class C waits for your ✓. A change with no Undo also waits.
17
+ - **Undo teaches it.** Each Undo is a correction. Two Undos in a row, or one revert, puts that job back to propose for 7 days. So does an Undo rate above 30% in a week. Home says so once.
18
+ - **Every claim has a source.** An AI job files through one shared guard. The guard checks that each quote is really at the file and line it cites. A claim with no source that checks out is dropped. A proposal with a key that would write, apply, send or run a command is dropped. The one exception is a class A or B proposal, which can carry `data.apply`: the change it makes, with Undo.
18
19
  - **Few at a time.** A run shows at most 3 proposals. In a quiet week it shows nothing.
19
20
  - **Tested first.** A new version of a job shows nothing until its replay passes: its own known cases, and the guard's own cases (a made-up quote, a missing source, a path outside the repository, a write key). Each of those must be dropped.
20
21
  - **Your login, your connections.** A job runs as a background Claude session with your own login, model, profile and connectors. The workspace holds no password or token. `PMOS_HEADLESS=off` sends every job back to a terminal pane.
@@ -30,6 +31,7 @@ This page lists every job, so you know what runs and why. Each row links to the
30
31
 
31
32
  | Job | When it runs | What it reads | Where you see it | How to stop it |
32
33
  |---|---|---|---|---|
34
+ | [Goal loops](agents-act.md) | A goal you set with `pmos loop start`: one round each minute the queue allows, until the goal is done, its budget is spent, or it needs you for a named reason. | The goal, its done criteria, and what the last round found | `pmos loop status` | `pmos loop stop <id>`. `pmos ai off goal-loops` |
33
35
  | [Initiative Driver](initiative-driver.md) | An initiative is created, moved or sent back. The unblock sweep runs every 30 minutes in working hours. At most 3 runs at once. | The initiative record, its tasks and its Jira tickets | The Agent strip of the initiative, and Needs you | Board settings › Agent: Off. `PMOS_DRIVER=off` |
34
36
  | [Found elsewhere](claude-proposes.md) | You add an initiative | Drive, Docs, Sheets, Slides, Jira, the calendar, meeting notes, Gmail, Slack and Confluence | The initiative's ✦ | `PMOS_PROPOSE=off` |
35
37
  | [New dates, done and tidy names](claude-proposes.md) | Each morning, and when a date passes | The tasks of the initiative, and the evidence that work happened | The initiative's ✦ | `PMOS_PROPOSE=off` |
@@ -64,7 +66,7 @@ Sync by itself is on by default. `PMOS_AUTO_SYNC=0` stops the sync, the repair a
64
66
 
65
67
  ## What a background job never does
66
68
 
67
- - It sends, posts, replies, pushes and merges nothing. A message to a person is a draft that you send. A Jira change is a drafted comment in your outbox.
69
+ - It sends, posts, replies, pushes and merges nothing. A message to a person is a draft that you send. A Jira change is a drafted comment in your outbox. These are class C: they always wait for you.
68
70
  - It does not create an initiative. The Horizon scan proposes one, and you approve it.
69
71
  - It does not record a verdict on an outcome. The verdict is always yours.
70
72
 
@@ -76,7 +78,7 @@ When you ask an agent session to do a piece of work, it can finish it, including
76
78
  - `pmos ai log [<job>]`: the last audit lines. Each dropped proposal shows why.
77
79
  - `pmos ai off [<job>]` and `pmos ai on [<job>]`: turn every AI job, or one job, off or on. `PMOS_AI=off` in the environment wins over the setting.
78
80
 
79
- The AI jobs are `past-repeat`, `decision-memory`, `outcomes`, `descriptions`, `drift`, `rehearse`, `next-prompt`, `sharpen-prompt` and `idle-lab`. The switch also covers each job in the queue by its queue name: `schedules`, `proactive`, `prepare`, `day`, `refresh`, `reports`, `driver`, `finder`, `coredocs`, `milestones`, `propose`, `grill`, `metric-drafts`, `impact`, `metric-reads`, `forecast`, `report-design`, `report-structure`, `team`, `scan` and `idle-lab`. `pmos ai off` with no job stops all of them. Git sync uses no model, so the switch does not stop it. A background run cannot change the switch.
81
+ The AI jobs are `past-repeat`, `decision-memory`, `outcomes`, `descriptions`, `drift`, `rehearse`, `next-prompt`, `sharpen-prompt` and `idle-lab`. The switch also covers each job in the queue by its queue name: `schedules`, `proactive`, `prepare`, `day`, `refresh`, `reports`, `driver`, `goal-loops`, `finder`, `coredocs`, `milestones`, `propose`, `grill`, `metric-drafts`, `impact`, `metric-reads`, `forecast`, `report-design`, `report-structure`, `team`, `scan` and `idle-lab`. `pmos ai off` with no job stops all of them. Git sync uses no model, so the switch does not stop it. A background run cannot change the switch.
80
82
 
81
83
  ## The team of role agents
82
84
 
@@ -0,0 +1,68 @@
1
+ ---
2
+ type: Guide
3
+ title: "Agents act by themselves"
4
+ description: "D106, Full autonomy now: the three classes of change, what agents apply at once with Undo, what waits for you, how a job goes back to propose, the stop switches, long-running goals, and the pmos autonomy and pmos loop commands."
5
+ timestamp: 2026-11-08
6
+ ---
7
+
8
+ # Agents act by themselves
9
+
10
+ PMOS agents finish work without waiting for you. A change that can be undone is applied at once and listed with Undo. A change that other people see, or that cannot be undone, waits for you. This is decision D106 (Full autonomy now, 2026-11-08).
11
+
12
+ ## The three classes
13
+
14
+ | Class | What it is | Examples | What happens |
15
+ |---|---|---|---|
16
+ | A | Upkeep with one right answer | A tidy task name, a date moved by evidence, a note | Applied at once. Undo for 14 days. |
17
+ | B | A judgment that can be undone | A problem statement, evidence, an expected outcome, a description, a task, a grill fix, what was found elsewhere | Applied at once. Undo for 14 days. |
18
+ | C | Seen by others, or cannot be undone | A message to a person, a Jira move, a stage move, a merge into a product repository, a delete, spend | Waits for your ✓. |
19
+
20
+ A change with no Undo waits too, whatever its class. A "maybe" or a possible duplicate that Claude found elsewhere waits, because it is a question for you.
21
+
22
+ ## Undo
23
+
24
+ Each change an agent applies is listed for 14 days with Undo. Undo puts the record back as it was. If someone changed the record since, Undo keeps that change.
25
+
26
+ - `pmos autonomy status` lists what agents applied in the last 14 days, each with its id.
27
+ - `pmos driver undo <proposal>` undoes a change of the Initiative Driver.
28
+ - A ✦ change is undone on its initiative's ✦, as before.
29
+
30
+ Each Undo counts as a correction, so the north star (human corrections per agent run) still sees it.
31
+
32
+ ## A job goes back to propose
33
+
34
+ Undo is also the safety net. A job goes back to propose for 7 days on one product when:
35
+
36
+ - its last two changes were both undone, or
37
+ - one of its changes was reverted, or
38
+ - in the last 7 days it applied 4 or more changes and more than 30% of them were undone.
39
+
40
+ When the verifier is running, a change it fails counts like an Undo. Home says once that a job went back to propose. The job applies by itself again after the 7 days. `pmos autonomy restore <job>` ends it early.
41
+
42
+ ## Stop it
43
+
44
+ - `pmos ai off` stops every agent job, and every change that would apply by itself. `pmos ai on` starts them again.
45
+ - `PMOS_AUTONOMY=off` in the environment stops only what applies by itself. Proposals still come.
46
+ - `pmos driver mode approve` makes every Driver proposal wait for you again.
47
+ - The spending limit in Settings › Claude's checks holds.
48
+
49
+ ## Long-running goals
50
+
51
+ Set a goal once, and agents work on it round after round until it is done.
52
+
53
+ - `pmos loop start --goal "<one sentence>" --done "<criterion>"` starts a goal. Give one `--done` for each criterion that must be true, each one checkable. Add `--forbid "<action>"` for each thing it must never do. The budget is 20 rounds and 24 hours by default; `--rounds N` and `--hours H` change it.
54
+ - Each round is one background run: it plans the next step, does it, checks it against the criteria, and records a checkpoint. The next round starts when the queue allows.
55
+ - `pmos loop checkpoint <id> --note "<what and how checked>" --met "<criterion>"` is what a round runs last. You do not need to run it.
56
+ - The loop ends when every criterion is met, or when its rounds or hours are used. If the computer restarts, the loop goes on from its last checkpoint.
57
+ - A loop stops for you only with a named reason: it needs a class C act, it needs a sign-in or secret only you have, it cannot cut the goal into steps, its check failed with no retries left, its work conflicts with other work, an outcome check it depends on is overdue, or three rounds met nothing new.
58
+ - `pmos loop status` shows every goal, its state, its rounds and what is met.
59
+ - `pmos loop resume <id> --note "<your answer>"` answers a loop that waits for you.
60
+ - `pmos loop stop <id>` stops a goal.
61
+
62
+ A loop never sends a message, moves a Jira ticket, merges into a product repository, deletes or spends. It files those as proposals and goes on with the rest.
63
+
64
+ ## What did not change
65
+
66
+ - Class C still waits for you (D65 point h: the factory proposes and never merges into a product repository).
67
+ - No request header is logged (D08).
68
+ - Every line an agent writes names the agent (D98).
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  type: Guide
3
3
  title: "Guide: start here"
4
- timestamp: 2026-11-04
4
+ timestamp: 2026-11-08
5
5
  ---
6
6
 
7
7
  # Guide: start here
@@ -39,6 +39,7 @@ PMOS has three places: **Home**, **Board** and **Intelligence**. The round menu
39
39
  ### Get started
40
40
 
41
41
  - [What Claude does behind the scenes](agent-capabilities.md): every job Claude runs by itself, when it runs, what it reads, where you see it, how to stop it, and what it fixes by itself.
42
+ - [Agents act by themselves](agents-act.md): the three classes of change, what is applied at once with Undo, what waits for you, how a job goes back to propose, long-running goals, and `pmos autonomy` and `pmos loop`.
42
43
  - [First run](welcome.md): test your Claude login, describe the project, choose its folder, search your tools read-only, and set up PMOS from Home.
43
44
  - [Features appear when their moment comes](moments.md): why a new PMOS starts quiet, what opens the Board, Intelligence and reports, the one ✦ a day, and the dot on the menu.
44
45
  - [Layout](layout.md): the three places, the menu button, the Viewer and its trail, docking panels, the keys, and the phone.
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  type: Guide
3
3
  title: "The Initiative Driver: drafts the agent files for you"
4
- description: "What the Initiative Driver does when an initiative is created or moved, what stops it, how it files proposals you keep, send back or drop, the board modes, and the pmos driver commands."
5
- timestamp: 2026-10-15
4
+ description: "What the Initiative Driver does when an initiative is created or moved, what stops it, what it applies by itself with Undo, the proposals you keep, send back or drop, the board modes, and the pmos driver commands."
5
+ timestamp: 2026-11-08
6
6
  ---
7
7
 
8
8
  # The Initiative Driver: drafts the agent files for you
9
9
 
10
- The Initiative Driver is a short background agent run for one initiative or one Work task. It reads the record, decides the next useful step, files the result as a **proposal**, and ends. It never decides for you. You keep a proposal, send it back with a note, or drop it.
10
+ The Initiative Driver is a short background agent run for one initiative or one Work task. It reads the record, decides the next useful step, files the result as a **proposal**, and ends. In Auto mode, the default since D106, a class A or B proposal is applied at once, with Undo for 14 days. A class C proposal waits for you: you keep it, send it back with a note, or drop it. See [Agents act by themselves](agents-act.md).
11
11
 
12
12
  ## When a run starts
13
13
 
@@ -56,7 +56,7 @@ In Discover, the agent writes the problem statement, the evidence, the opportuni
56
56
  - **Keep, Send back and Drop on a row.** A kept row stays in the strip, marked "Kept by you", until you leave the page. Send back asks for a one-line note. A kept stage move changes the stage on the page at once. These three acts cannot be undone: each adds one line to the ledger.
57
57
  - **One line in Work.** A Work task with an open proposal shows one line under its title, for example "Agent drafted a follow-up to Dana. Nothing is sent." Press Review to read the draft. Keep copies the text so you can send it yourself, and records your decision. If the browser does not allow copying, the text is selected and you press Ctrl+C. A suggested next step shows Keep and Drop in the line. Shadow and Off show no line.
58
58
  - **Needs you.** In Briefing, the agent has two kinds of row: "Agent has 3 drafts on ..." and "... is waiting on you". Press a row to open the initiative. A long title wraps inside the card.
59
- - **The Agent setting.** Open the board, press Board settings, and find Agent. Choose Off, Shadow or Approve. The setting is saved when you press it.
59
+ - **The Agent setting.** Open the board, press Board settings, and find Agent. Choose Off, Shadow, Approve or Auto. The setting is saved when you press it.
60
60
 
61
61
  ## Keep, send back, drop
62
62
 
@@ -68,21 +68,30 @@ Open proposals appear in Needs you as one row for each initiative or task: "Agen
68
68
 
69
69
  An agent session can keep, send back, drop, pause or change the mode too, with no typed confirmation (D98). Each line names the agent, so you see who decided.
70
70
 
71
+ ## What Auto applies, and Undo
72
+
73
+ In Auto mode the Driver applies these kinds at once, through the same Keep, as the agent: a note (class A), and a problem statement, evidence, sizing, an assumption, stakeholders, an overlap and a Work next step (class B). Each one is listed with Undo for 14 days. These kinds always wait for you: a stage move and a follow-up (class C), and a core document, because issuing it has no Undo yet.
74
+
75
+ - **Undo** puts the record back as it was, unless someone changed it since: then it keeps that change. Undo counts as a correction.
76
+ - Two Undos in a row for one kind on one product put that kind back to propose for 7 days. So does an Undo rate above 30% in a week. `pmos autonomy status` shows it.
77
+
71
78
  ## Board modes
72
79
 
73
- - **Approve** is the default. The agent runs and drafts, and Needs you shows the rows.
80
+ - **Auto** is the default (D106). Class A and B proposals are applied with Undo. Class C proposals wait, and Needs you shows their rows.
81
+ - **Approve.** Every proposal waits for you, and Needs you shows the rows.
74
82
  - **Shadow.** The agent runs and drafts, and raises no Needs you rows.
75
83
  - **Off.** No run starts.
76
84
 
77
85
  ## The commands
78
86
 
79
- The agent uses `pmos driver propose` to file a proposal and `pmos driver status` to read what exists. The other commands are yours, at an interactive terminal:
87
+ The agent uses `pmos driver propose` to file a proposal and `pmos driver status` to read what exists. In Auto mode, `pmos driver propose` says whether it applied the proposal or left it for you, and why. The other commands are yours, at an interactive terminal:
80
88
 
81
89
  - `pmos driver keep <proposal>` asks you to type the proposal id. A kept move is pressed on the page.
82
90
  - `pmos driver return <proposal> --note "<what to change>"` sends it back.
83
91
  - `pmos driver drop <proposal>` drops it.
92
+ - `pmos driver undo <proposal>` undoes a kept proposal, within 14 days.
84
93
  - `pmos driver pause <initiative|work> <id>` and `pmos driver resume <initiative|work> <id>` stop and restart the runs for one target.
85
- - `pmos driver mode <off|shadow|approve> [--board <id>]` sets the board mode. Without `--board` it sets every board.
94
+ - `pmos driver mode <off|shadow|approve|auto> [--board <id>]` sets the board mode. Without `--board` it sets every board.
86
95
 
87
96
  When the agent files a proposal, it can also state what it knows, so that the Briefing can rank the row: `--confidence 0..1` (how sure it is), `--recommended "<what it suggests you do>"`, `--reversible true|false` (whether you can undo the move) and `--effort S|M|L` (about 2 minutes, about 15 minutes, an hour or more). Each one is optional. The Briefing shows a missing one as "Not known yet" and does not guess it. The agent states a fact only when it knows it.
88
97
 
@@ -107,7 +107,7 @@ function build({ proposals = [], goals = [], work = [], seen = { all: 0, ids: ne
107
107
  return { count: items.length, newCount: fresh.length, items: fresh.slice(0, MAX_NEW), more: Math.max(0, fresh.length - MAX_NEW), bundles, oldest: ages.length ? Math.min(...ages) : null, seenAt: seen.all || null };
108
108
  }
109
109
 
110
- /** The open proposals of each included product whose board is in Approve mode: the set GET /api/driver/open gives the Agent proposals dialog. A ledger that cannot be read gives none. */
110
+ /** The open proposals of each included product whose board is in Approve or Auto mode (D106: in Auto only class C and demoted jobs stay open): the set GET /api/driver/open gives the Agent proposals dialog. A ledger that cannot be read gives none. */
111
111
  function readProposals(available) {
112
112
  const D = require('./driver.js'), DN = require('./driver-needs.js');
113
113
  const out = [];
@@ -120,7 +120,7 @@ function readProposals(available) {
120
120
  let titles = new Map(); try { titles = DN.titlesOf({ root: a.root }); } catch { /* the ids stand in */ }
121
121
  for (const p of D.openProposals(state)) {
122
122
  if (!p.target || (p.target.ws && p.target.ws !== a.ws)) continue;
123
- if (D.modeOf(state, p.target.kind === 'work' ? 'work' : null) !== 'approve') continue;
123
+ if (!['approve', 'auto'].includes(D.modeOf(state, p.target.kind === 'work' ? 'work' : null))) continue; // D106: in auto what is still open waits for the PM
124
124
  out.push({ p, ws: a.ws, product: a.name, targetTitle: titles.get(p.target.kind + ':' + p.target.id) || '' });
125
125
  }
126
126
  } catch { /* this product gives no items */ }
@@ -7,13 +7,16 @@
7
7
  *
8
8
  * THE PROPOSAL (the only thing a job may file):
9
9
  * { id, title, say, confidence: 'high'|'medium'|'low'|'none',
10
- * claims: [{ text, sources: [{ label, ref, quote }] }], data? }
10
+ * claims: [{ text, sources: [{ label, ref, quote }] }], data?, cls?: 'A'|'B'|'C' }
11
+ * cls (D106): A reversible upkeep, B reversible judgment, C seen by others or not reversible. Absent is C.
11
12
  * ref is `path:line` relative to the repository root, or `state:<file>:line` for a ledger in the job's state folder. Other refs
12
13
  * (`jira:KEY`, a URL) are kept as context but are unverified. confidence 'none' is "no record": claims may be empty, and that is a
13
14
  * valid, complete answer.
14
15
  *
15
16
  * THE RULES (check):
16
- * propose-only a key named write, apply, ops, patch, send, command or exec anywhere in the proposal rejects it
17
+ * propose-only a key named write, apply, ops, patch, send, command or exec anywhere in the proposal rejects it, with ONE exception
18
+ * (D106): a class A or B proposal may carry `data.apply`, the change the job applies by itself with Undo. A class C
19
+ * proposal (or one with no class) with any write key is still dropped, and so is a write key anywhere but data.apply
17
20
  * every claim at least 1 verified source: the quote (12+ characters) is found within ±2 lines of ref, case and spacing ignored
18
21
  * honest 'high' needs 2 or more distinct verified refs; 'none' must have no claims
19
22
  * bounded at most `max` proposals per run (default 3); the rest are dropped, in the order given
@@ -46,6 +49,7 @@ const QUOTE_MIN = 12;
46
49
  const NEAR = 2;
47
50
  const CONF = ['high', 'medium', 'low', 'none'];
48
51
  const WRITE_KEYS = new Set(['write', 'apply', 'ops', 'patch', 'send', 'command', 'exec']);
52
+ const CLASSES = ['A', 'B', 'C'];
49
53
  const JOB_ID = /^[a-z][a-z0-9-]{1,40}$/;
50
54
  const ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,119}$/;
51
55
 
@@ -129,8 +133,13 @@ function writeKey(v, depth = 0) {
129
133
  function check(p, { root, stateDir, cache = new Map() } = {}) {
130
134
  const errors = [];
131
135
  if (!p || typeof p !== 'object' || Array.isArray(p)) return { ok: false, p: null, errors: ['a proposal must be an object'] };
132
- const wk = writeKey(p);
133
- if (wk) errors.push(`propose-only: the key "${wk}" names a write`);
136
+ const cls = p.cls == null ? 'C' : String(p.cls);
137
+ if (!CLASSES.includes(cls)) errors.push('cls is A, B or C');
138
+ // D106: only a class A or B proposal may carry data.apply; nothing inside data.apply may name a send, a command or an exec
139
+ const applyOk = (cls === 'A' || cls === 'B') && p.data && typeof p.data === 'object' && !Array.isArray(p.data) && p.data.apply && typeof p.data.apply === 'object';
140
+ const scan = applyOk ? { ...p, data: Object.fromEntries(Object.entries(p.data).filter(([k]) => k !== 'apply')) } : p;
141
+ const wk = writeKey(scan) || (applyOk ? ['send', 'command', 'exec'].find((k) => JSON.stringify(p.data.apply).includes(`"${k}"`)) : null);
142
+ if (wk) errors.push(`propose-only: the key "${wk}" names a write${cls === 'C' ? ' (class C stays propose-only)' : ''}`);
134
143
  const id = String(p.id || '').trim();
135
144
  if (!ID.test(id)) errors.push('id is missing or has characters other than letters, digits and . _ : -');
136
145
  const title = one(p.title, 200), say = one(p.say, 1200);
@@ -168,7 +177,7 @@ function check(p, { root, stateDir, cache = new Map() } = {}) {
168
177
  if (confidence === 'high' && verifiedRefs.size < 2) errors.push('confidence high needs 2 or more distinct verified sources');
169
178
  const data = p.data && typeof p.data === 'object' && !Array.isArray(p.data) ? p.data : undefined;
170
179
  if (errors.length) return { ok: false, p: null, errors };
171
- return { ok: true, p: { id, title, say, confidence, claims, ...(data ? { data } : {}) }, errors: [] };
180
+ return { ok: true, p: { id, title, say, confidence, claims, ...(data ? { data } : {}), ...(p.cls != null ? { cls } : {}) }, errors: [] };
172
181
  }
173
182
 
174
183
  /* ── audit ───────────────────────────────────────────────────────────────────────────────── */
@@ -232,7 +241,8 @@ function negatives(p) {
232
241
  { const q = clone(); first(q).quote = 'this sentence was never written anywhere in the sources ' + Date.now(); out.push({ name: 'a fabricated quote is dropped', p: q }); }
233
242
  { const q = clone(); q.claims[0].sources = []; out.push({ name: 'a claim with no source is dropped', p: q }); }
234
243
  { const q = clone(); first(q).ref = '../../etc/passwd:1'; out.push({ name: 'a ref outside the repository is dropped', p: q }); }
235
- { const q = clone(); q.data = { ...(q.data || {}), apply: { op: 'set' } }; out.push({ name: 'a write key is dropped', p: q }); }
244
+ { const q = clone(); q.cls = 'C'; q.data = { ...(q.data || {}), apply: { op: 'set' } }; out.push({ name: 'a class C proposal with a write key is dropped', p: q }); }
245
+ { const q = clone(); q.cls = 'B'; q.send = { to: 'someone' }; out.push({ name: 'a write key outside data.apply is dropped, whatever the class', p: q }); }
236
246
  return out;
237
247
  }
238
248
 
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+ /* auto-keep.js — the ✦ half of D106 ("Full autonomy now"): after the proposal runs, every open class A or B ✦ proposal of a lead
3
+ * workspace is applied by itself, one batch each, with Undo (lib/routes-proposals.js autoKeep, lib/autonomy.js). A workspace is
4
+ * read again only when its proposals ledger changed. `pmos ai off` and PMOS_AUTONOMY=off stop it (autonomy.killed).
5
+ *
6
+ * create({ workspaces, isLead, stateDirFor, proposalCtx, settingsDir, env?, warn? }) → { tick() }
7
+ */
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+
11
+ function create({ workspaces, isLead, stateDirFor, proposalCtx, settingsDir, env = process.env, warn = () => {} }) {
12
+ const seen = new Map();
13
+ const mtimeOf = (dir) => { try { return fs.statSync(path.join(dir, 'proposals.jsonl')).mtimeMs; } catch { return null; } };
14
+ function tick() {
15
+ if (require('./autonomy.js').killed({ env, settingsDir: settingsDir() })) return;
16
+ const D = require('./driver.js');
17
+ const RP = require('./routes-proposals.js');
18
+ for (const w of workspaces()) {
19
+ try {
20
+ if (!isLead(w)) continue;
21
+ const dir = stateDirFor(w); if (!dir) continue;
22
+ const mt = mtimeOf(dir);
23
+ if (mt == null || seen.get(w.id) === mt) continue;
24
+ const state = D.fold(D.readLines(D.ledgerFile(D.stateDirOf(w.root) || dir)));
25
+ RP.autoKeep(proposalCtx(), w, { modeOf: (board) => D.modeOf(state, board) });
26
+ seen.set(w.id, mtimeOf(dir));
27
+ } catch (e) { warn('auto keep tick', e); }
28
+ }
29
+ }
30
+ return { tick };
31
+ }
32
+
33
+ module.exports = { create };
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+ /* autonomy-cli.js — `pmos autonomy`: what agents do by themselves (D106, lib/autonomy.js).
3
+ *
4
+ * pmos autonomy status [--json] [--root <dir>] the changes applied by agents in the last 14 days, and the jobs back to propose
5
+ * pmos autonomy restore <job> [--product <ws>] end a job's demotion early (PM or agent, D98)
6
+ *
7
+ * Undo a change on its page, or with `pmos driver undo <proposal>` for a Driver change. Exit codes: 0 done, 1 refused, 2 usage. */
8
+ const path = require('path');
9
+ const { execFileSync } = require('child_process');
10
+ const A = require('./autonomy.js');
11
+ const D = require('./driver.js');
12
+ const actorLib = require('./actor.js');
13
+
14
+ const COMMANDS = { autonomy: ['status', 'restore'] };
15
+ const USAGE = [
16
+ 'usage: pmos autonomy status|restore — what agents do by themselves (class A and B, with Undo)',
17
+ ' pmos autonomy status [--json] the changes agents applied in the last 14 days, and the jobs back to propose',
18
+ ' pmos autonomy restore <job> [--product <ws>] end a job\'s demotion early',
19
+ 'Class C (a message to a person, a Jira move others see, a merge into a product repository, a delete, spend) always waits for you.',
20
+ ];
21
+ const flag = (args, k) => { const i = args.indexOf('--' + k); return i >= 0 ? (args[i + 1] === undefined || args[i + 1].startsWith('--') ? true : args[i + 1]) : undefined; };
22
+ function repoRoot(cwd) { try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; } catch { return cwd; } }
23
+
24
+ function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), env = process.env, isTTY, now } = {}) {
25
+ const args = argv[0] === 'autonomy' ? argv.slice(1) : argv.slice();
26
+ const verb = args[0];
27
+ if (!verb || ['help', '--help', '-h'].includes(verb)) { for (const l of USAGE) say(l); return verb ? 0 : 1; }
28
+ if (!COMMANDS.autonomy.includes(verb)) { say(`unknown autonomy command "${verb}" — one of ${COMMANDS.autonomy.join(', ')}`); return 2; }
29
+ const root = typeof flag(args, 'root') === 'string' ? path.resolve(cwd, flag(args, 'root')) : repoRoot(cwd);
30
+ const dir = D.stateDirOf(root);
31
+ if (!dir) { say('✗ this repository has no PMOS state folder (pmos/state, state or .pmos)'); return 1; }
32
+ if (verb === 'status') {
33
+ const done = A.done(dir, { now }), notices = A.notices(dir, { now });
34
+ const killed = A.killed({ env, settingsDir: require('./state-root.js').defaultRoot({ env }) });
35
+ if (flag(args, 'json')) { say(JSON.stringify({ ok: true, on: !killed, why: killed, done, demoted: notices })); return 0; }
36
+ say(killed ? `Agents act by themselves: off (${killed})` : 'Agents act by themselves: on (class A and B, with Undo for 14 days)');
37
+ for (const n of notices) say(` back to propose until ${n.until.slice(0, 10)}: ${n.job} — ${n.why}`);
38
+ if (!done.length) say(' nothing applied by an agent in the last 14 days');
39
+ for (const a of done) say(` ${a.at.slice(0, 16).replace('T', ' ')} · ${a.job} · class ${a.cls || '?'} · ${a.ref} — ${a.title}`);
40
+ return 0;
41
+ }
42
+ const job = args[1] && !args[1].startsWith('--') ? args[1] : null;
43
+ if (!job) { say('usage: pmos autonomy restore <job> [--product <ws>]'); return 2; }
44
+ const a = actorLib.fromCli({ isTTY: isTTY === undefined ? !!(process.stdin.isTTY && process.stdout.isTTY) : isTTY, env });
45
+ if (!actorLib.isPm(a) && !actorLib.isAgent(a)) { say('✗ only the PM or an agent session can restore a job'); return 1; }
46
+ const p = flag(args, 'product');
47
+ const r = A.restore(dir, { job, product: typeof p === 'string' ? p : null }, a, { now });
48
+ if (!r.ok) { say('✗ ' + r.error); return 1; }
49
+ say(`✓ ${job} applies by itself again`);
50
+ return 0;
51
+ }
52
+
53
+ module.exports = { run, COMMANDS, USAGE };