@emiliosp/pi-maestro 0.11.0 → 0.13.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 (74) hide show
  1. package/ADR.md +82 -23
  2. package/CHANGELOG.md +48 -28
  3. package/MISSION.md +2 -4
  4. package/README.md +55 -25
  5. package/TECH_STACK.md +3 -3
  6. package/agents/builder.md +53 -57
  7. package/agents/simplifier.md +79 -61
  8. package/agents/verifier.md +52 -64
  9. package/docs/configuration.md +1 -1
  10. package/docs/glossary.md +43 -40
  11. package/docs/subagent-integration.md +7 -8
  12. package/docs/workflow.md +137 -63
  13. package/extensions/maestro-subagent.ts +1 -0
  14. package/extensions/maestro.ts +60 -30
  15. package/package.json +38 -40
  16. package/src/MaestroPaths.ts +22 -35
  17. package/src/artifacts/builder-handoff/assertBuilderHandoff.ts +6 -15
  18. package/src/artifacts/builder-handoff/schema.ts +3 -6
  19. package/src/artifacts/simplifier-handoff/assertSimplifierHandoff.ts +3 -3
  20. package/src/artifacts/simplifier-handoff/schema.ts +1 -0
  21. package/src/artifacts/verifier-handoff/assertVerifierHandoff.ts +4 -10
  22. package/src/artifacts/verifier-handoff/schema.ts +3 -6
  23. package/src/artifacts/verifier-handoff/writeVerifierHandoff.ts +1 -3
  24. package/src/config/assertConfiguration.ts +3 -6
  25. package/src/config/defaults.ts +1 -5
  26. package/src/config/loadConfiguration.ts +4 -11
  27. package/src/config/schema.ts +1 -2
  28. package/src/ids/createSpecId.ts +1 -2
  29. package/src/ids/isValidSpecId.ts +1 -2
  30. package/src/maestro/checks/assertEnvironment.ts +19 -50
  31. package/src/maestro/instructions/getMaestroInstructions.ts +47 -26
  32. package/src/maestro/session/MaestroSessionState.ts +15 -0
  33. package/src/maestro/status/formatMaestroStatus.ts +4 -13
  34. package/src/maestro/status/refreshMaestroStatus.ts +3 -7
  35. package/src/specs/create.ts +14 -4
  36. package/src/specs/template.ts +10 -14
  37. package/src/tools/child/record-builder-handoff.ts +1 -0
  38. package/src/tools/child/record-simplifier-handoff.ts +4 -4
  39. package/src/tools/child/record-verifier-handoff.ts +2 -3
  40. package/src/tools/child/utils/resolveWorkflowContext.ts +1 -4
  41. package/src/tools/main/create-spec.ts +3 -2
  42. package/src/tools/main/mark-spec-ready.ts +2 -1
  43. package/src/tools/main/resolve-escalations.ts +1 -0
  44. package/src/tools/main/resolve-findings.ts +6 -20
  45. package/src/tools/main/run-builder.ts +37 -57
  46. package/src/tools/main/run-simplifier.ts +10 -20
  47. package/src/tools/main/run-verifier.ts +31 -55
  48. package/src/tools/utils/pi-subagent-delegation.ts +13 -22
  49. package/src/tools/utils/resolveToolRunContext.ts +2 -3
  50. package/src/utils/is-errno-exception.ts +1 -3
  51. package/src/utils/path-exists.ts +1 -0
  52. package/src/utils/path-strictly-within.ts +3 -6
  53. package/src/utils/path-within-or-equal.ts +1 -4
  54. package/src/utils/read-json.ts +1 -4
  55. package/src/utils/write-json.ts +1 -4
  56. package/src/workflow/builder/completeBuilderPass.ts +3 -2
  57. package/src/workflow/builder/prepareBuilderRun.ts +3 -8
  58. package/src/workflow/builder/resolveEscalations.ts +2 -6
  59. package/src/workflow/builder/utils/getWorkflowEventByBuilderHandoff.ts +1 -3
  60. package/src/workflow/simplifier/completeSimplifierPass.ts +2 -3
  61. package/src/workflow/spec/markSpecReady.ts +10 -4
  62. package/src/workflow/state/readWorkflowState.ts +2 -7
  63. package/src/workflow/state/schema.ts +5 -10
  64. package/src/workflow/state/writeWorkflowState.ts +1 -4
  65. package/src/workflow/transitions.ts +3 -11
  66. package/src/workflow/utils/assertSpecAcceptanceCriteria.ts +2 -1
  67. package/src/workflow/utils/getAgentRole.ts +1 -3
  68. package/src/workflow/verifier/completeVerifierPass.ts +1 -0
  69. package/src/workflow/verifier/resolveFindings.ts +9 -29
  70. package/src/workflow/verifier/utils/getWorkflowEventByVerifierHandoff.ts +5 -20
  71. package/templates/design.md +20 -0
  72. package/templates/proposal.md +23 -0
  73. package/templates/spec.md +21 -50
  74. package/ROADMAP.md +0 -319
package/docs/glossary.md CHANGED
@@ -2,52 +2,55 @@
2
2
 
3
3
  ## Terms
4
4
 
5
- | Term | Meaning |
6
- |-------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
7
- | `Owner` | The person who approves the `spec`, decides questions and `findings`, and performs the final review. |
8
- | `Maestro` | The coordinator that prepares the `spec`, runs the agents, and records `owner` decisions. |
9
- | `Builder` | The agent that implements the approved `spec` and runs its `probes`. |
10
- | `Verifier` | The independent agent that checks the implementation and reports technical issues. |
11
- | `Simplifier` | The agent that refactors accepted code for clarity without changing behavior or introducing check failures. |
12
- | `Spec` | A `specification` that describes one change, its scope, and its `acceptance criteria`. The approved `spec` defines the required behavior. It is saved as `spec.md`. |
13
- | `Acceptance criterion` (`AC`) | One required, observable result defined in the `spec`. |
14
- | `Probe` | A scenario used to test an `acceptance criterion`. Reports record the actual command or procedure and its outcome. |
15
- | `Expected result` | The observable result that a `probe` must produce. |
16
- | `Artifact` | A saved workflow file, such as a `spec`, or a `handoff` between agents. |
17
- | `Handoff` | A saved agent report. `Builder` and `verifier` reports include `probe` outcomes. A `simplifier` report includes refactored files, a summary, and notes. |
18
- | `Observability` | The owner's ability to inspect workflow progress and reported results. |
19
- | `Run` or `pass` | One agent execution with a fresh conversation. |
20
- | `Candidate` | The project files created by agents after a workflow `run` |
21
- | `Finding` | A technical issue that the `verifier` records for an `owner` decision. |
22
- | `Escalation` | An implementation question or reportable technical problem that the `builder` records in its `handoff` for an `owner` decision. |
23
- | `GREEN FLAG` | The owner's explicit reply that approves the current `spec` and starts the `builder`. |
24
- | `fix-code` | An `owner` decision that requests code fixes without changing the approved `spec`. |
25
- | `revise-spec` | An `owner` decision that records a reason and agreed requirement change, then returns to `drafting-spec` for revision and renewed approval. |
26
- | `reject` | An `owner` decision that declines a `finding` and records a reason. It does not mean that verification passed. |
27
- | `candidate-ready` | The completed workflow phase. Final review remains with the `owner`. |
5
+ | Term | Meaning |
6
+ | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7
+ | `Owner` | The person who approves the `spec`, decides questions and `findings`, and performs the final review. |
8
+ | `Maestro` | The coordinator that prepares the `spec`, runs the agents, and records `owner` decisions. |
9
+ | `Builder` | The agent that implements the approved `spec` and runs its `probes`. |
10
+ | `Verifier` | The independent agent that checks the implementation and reports technical issues. |
11
+ | `Simplifier` | The agent that refactors accepted code for clarity without changing behavior or introducing check failures. |
12
+ | `Spec` | A `specification` for one change: `proposal.md` for motivation and scope, `spec.md` for behavior and `acceptance criteria`, and optional `design.md` for technical decisions. The present documents are approved and frozen together. |
13
+ | `Acceptance criterion` (`AC`) | One required, observable result defined in the `spec`. |
14
+ | `Probe` | A scenario used to test an `acceptance criterion`. Reports record the actual command or procedure and its outcome. |
15
+ | `Expected result` | The observable result that a `probe` must produce. |
16
+ | `Artifact` | A saved workflow file, such as a `spec`, or a `handoff` between agents. |
17
+ | `Handoff` | A saved agent report. `Builder` and `verifier` reports include `probe` outcomes. A `simplifier` report includes refactored files, a summary, and notes. |
18
+ | `Observability` | The owner's ability to inspect workflow progress and reported results. |
19
+ | `Run` or `pass` | One agent execution with a fresh conversation. |
20
+ | `Candidate` | The project files created by agents after a workflow `run` |
21
+ | `Finding` | A technical issue that the `verifier` records for an `owner` decision. |
22
+ | `Escalation` | An implementation question or reportable technical problem that the `builder` records in its `handoff` for an `owner` decision. |
23
+ | `GREEN FLAG` | The owner's explicit reply that approves the current `spec` and starts the `builder`. |
24
+ | `fix-code` | An `owner` decision that requests code fixes without changing the approved `spec`. |
25
+ | `revise-spec` | An `owner` decision that records a reason and agreed requirement change, then returns to `drafting-spec` for revision and renewed approval. |
26
+ | `reject` | An `owner` decision that declines a `finding` and records a reason. It does not mean that verification passed. |
27
+ | `candidate-ready` | The completed workflow phase. Final review remains with the `owner`. |
28
28
 
29
29
  ## Identifiers and file names
30
30
 
31
31
  An ID is an identifier that names one record. These labels refer to records within one `spec`, not across all workflows.
32
32
 
33
- | Label | Meaning | Location or scope |
34
- |--------------|-------------------------------------------------------------------|---------------------------------------------------------------------------------|
35
- | `<spec-id>` | The identifier shared by the `spec` and its workflow `artifacts`. | The directory name under `<project-root>/.specs/` by default. |
36
- | `B1`, `B2` | `Builder` `handoff` 1, `builder` `handoff` 2. | `handoffs/builder/B1.json`, `handoffs/builder/B2.json`. |
37
- | `V1`, `V2` | `Verifier` `handoff` 1, `verifier` `handoff` 2. | `handoffs/verifier/V1.json`, `handoffs/verifier/V2.json`. |
38
- | `S.json` | The fixed, unnumbered `simplifier` `handoff`. | `handoffs/simplifier/S.json`. |
39
- | `E1`, `E2` | `Escalation` 1, `escalation` 2 within one `builder` report. | Entries in that report's `escalations` list. |
40
- | `F1`, `F2` | `Finding` 1, `finding` 2 within one `verifier` report. | Entries in that report's `findings` list. |
41
- | `AC1`, `AC2` | `Acceptance criterion` 1, `acceptance criterion` 2. | Criteria in `spec.md` and the matching `acceptanceCriteria` entries in reports. |
42
- | `B1/E1` | `Escalation` 1 in `builder` `handoff` 1. | The question with `id: "E1"` inside `handoffs/builder/B1.json`. |
43
- | `V1/F2` | `Finding` 2 in `verifier` `handoff` 1. | The `finding` with `id: "F2"` inside `handoffs/verifier/V1.json`. |
33
+ | Label | Meaning | Location or scope |
34
+ | -------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------- |
35
+ | `<spec-id>` | The identifier shared by the `spec` and its workflow `artifacts`. | The directory name under `<project-root>/.specs/` by default. |
36
+ | `B1`, `B2` | `Builder` `handoff` 1, `builder` `handoff` 2. | `handoffs/builder/B1.json`, `handoffs/builder/B2.json`. |
37
+ | `V1`, `V2` | `Verifier` `handoff` 1, `verifier` `handoff` 2. | `handoffs/verifier/V1.json`, `handoffs/verifier/V2.json`. |
38
+ | `S.json` | The fixed, unnumbered `simplifier` `handoff`. | `handoffs/simplifier/S.json`. |
39
+ | `E1`, `E2` | `Escalation` 1, `escalation` 2 within one `builder` report. | Entries in that report's `escalations` list. |
40
+ | `F1`, `F2` | `Finding` 1, `finding` 2 within one `verifier` report. | Entries in that report's `findings` list. |
41
+ | `REQ1`, `REQ2` | Requirement 1, requirement 2. | Requirements in `spec.md`, each with a `Verified by` field. |
42
+ | `AC1`, `AC2` | `Acceptance criterion` 1, `acceptance criterion` 2. | Criteria in `spec.md` and the matching `acceptanceCriteria` entries in reports. |
43
+ | `B1/E1` | `Escalation` 1 in `builder` `handoff` 1. | The question with `id: "E1"` inside `handoffs/builder/B1.json`. |
44
+ | `V1/F2` | `Finding` 2 in `verifier` `handoff` 1. | The `finding` with `id: "F2"` inside `handoffs/verifier/V1.json`. |
44
45
 
45
46
  All paths in this table are relative to the `spec` directory unless stated otherwise. The [configuration](configuration.md#path-rules) can change the directory that
46
47
  contains `specs`.
47
48
 
48
- The `AC` prefix is the template's naming convention. Criterion IDs must be unique within the `spec`. Reports use the exact IDs from the `spec`.
49
+ Requirement IDs use the `REQ` prefix. They are unique within the `spec` and remain stable during revisions. Each requirement links to its verification through
50
+ `Verified by`. See [Requirement coverage](workflow.md#requirement-coverage).
49
51
 
50
- `Builder` and `verifier` numbers count saved `handoffs` in separate sequences.
52
+ The `AC` prefix is the template's naming convention. Criterion IDs must be unique within the `spec`. Reports use the exact IDs from the `spec`, including standalone
53
+ regression criteria without a requirement association. `Builder` and `verifier` numbers count saved `handoffs` in separate sequences.
51
54
 
52
55
  ## Escalation references
53
56
 
@@ -55,8 +58,8 @@ Read `B1/E1` as "escalation 1 in builder report 1". `B1` selects `handoffs/build
55
58
 
56
59
  `Escalation` numbers restart at `E1` in each `builder` report. `B1/E1` and `B2/E1` identify different questions, even if they concern the same topic.
57
60
 
58
- The `owner` discusses every current question with `Maestro`. `Maestro` records all answers and reasons together in that same `builder` report.
59
- See [Escalations](workflow.md#escalations) for the available choices and their effects.
61
+ The `owner` discusses every current question with `Maestro`. `Maestro` records all answers and reasons together in that same `builder` report. See
62
+ [Escalations](workflow.md#escalations) for the available choices and their effects.
60
63
 
61
64
  ## Finding references
62
65
 
@@ -66,8 +69,8 @@ Read `V1/F2` as "finding 2 in verifier report 1". `V1` selects `handoffs/verifie
66
69
 
67
70
  For example, a `finding` about a saved title can appear in a `Maestro` message like this:
68
71
 
69
- > Verifier report 1, finding 2 (`V1/F2`): the title returns to "Draft" after saving "Ready" and reopening the item.
70
- > Acceptance criterion 1 (`AC1`) requires the saved title to remain "Ready".
72
+ > Verifier report 1, finding 2 (`V1/F2`): the title returns to "Draft" after saving "Ready" and reopening the item. Acceptance criterion 1 (`AC1`) requires the saved
73
+ > title to remain "Ready".
71
74
 
72
75
  In this example, the finding's `acceptanceCriterion: "AC1"` connects the issue to criterion `AC1` in `spec.md`.
73
76
 
@@ -8,7 +8,7 @@ stays in the main `Maestro` conversation.
8
8
  The package supplies all three roles and the tools that save their results:
9
9
 
10
10
  | Role | Agent name | Definition |
11
- |--------------|----------------------|---------------------------------------------------|
11
+ | ------------ | -------------------- | ------------------------------------------------- |
12
12
  | `Builder` | `maestro.builder` | [`agents/builder.md`](../agents/builder.md) |
13
13
  | `Verifier` | `maestro.verifier` | [`agents/verifier.md`](../agents/verifier.md) |
14
14
  | `Simplifier` | `maestro.simplifier` | [`agents/simplifier.md`](../agents/simplifier.md) |
@@ -16,8 +16,8 @@ The package supplies all three roles and the tools that save their results:
16
16
  Each `run` starts with a fresh conversation, not the main session's conversation history. All three agents inherit project instructions, the owner's global `AGENTS.md`,
17
17
  and available skills. The global file normally lives at `~/.pi/agent/AGENTS.md`.
18
18
 
19
- `Maestro` supplies the `spec` ID, project directory, model, thinking level, and timeout. The agents read the approved `spec` and saved `artifacts` to understand the work.
20
- Earlier `artifacts` provide context, not proof.
19
+ `Maestro` supplies the `spec` ID, project directory, model, thinking level, and timeout. The agents read all approved documents (`proposal.md`, `spec.md`, and `design.md`
20
+ when present) and saved `artifacts` to understand the work. Earlier `artifacts` provide context, not proof.
21
21
 
22
22
  The `owner` does not call agent tools directly. `Maestro` starts the `builder` after `GREEN FLAG` approval. The `verifier` starts after successful `builder` completion,
23
23
  and the `simplifier` follows successful `verifier` completion.
@@ -36,9 +36,8 @@ If a `run` fails or returns without a valid saved result, `Maestro` reports the
36
36
 
37
37
  ## External configuration
38
38
 
39
- The `pi-subagents` extension must be installed and enabled in Pi. `Builder`, `verifier`, and `simplifier` model choices, thinking levels, and timeouts come
40
- from [Maestro configuration](configuration.md). Other `pi-subagents` configuration remains the owner's responsibility.
39
+ The `pi-subagents` extension must be installed and enabled in Pi. `Builder`, `verifier`, and `simplifier` model choices, thinking levels, and timeouts come from
40
+ [Maestro configuration](configuration.md). Other `pi-subagents` configuration remains the owner's responsibility.
41
41
 
42
- Only `maestro_run_simplifier` checks Git readiness, with `git rev-parse --is-inside-work-tree`.
43
- If readiness cannot be confirmed, it warns and completes without delegation.
44
- The `simplifier` uses Git to select all uncommitted code changes. `Maestro` does not change the Git index or create commits or checkpoints.
42
+ Only `maestro_run_simplifier` checks Git readiness, with `git rev-parse --is-inside-work-tree`. If readiness cannot be confirmed, it warns and completes without
43
+ delegation. The `simplifier` uses Git to select all uncommitted code changes. `Maestro` does not change the Git index or create commits or checkpoints.
package/docs/workflow.md CHANGED
@@ -2,19 +2,20 @@
2
2
 
3
3
  `Maestro` manages one spec-driven workflow in the current Pi session. The `owner` works directly with `Maestro`.
4
4
 
5
- The approved `spec.md` defines behavior, scope, constraints, technical decisions, and `acceptance criteria` for the change.
5
+ The approved `spec` is one document set: `proposal.md` explains motivation and scope, `spec.md` defines behavior and `acceptance criteria`, and optional `design.md`
6
+ records significant technical decisions. The set forms one contract for the change.
6
7
 
7
- An `acceptance criterion` contains a coverage label, a `probe`, an `expected result`, and an example. A `probe` is a scenario used to test behavior.
8
+ An `acceptance criterion` contains a `probe`, an `expected result`, and an example. A `probe` is a scenario used to test behavior.
8
9
 
9
10
  A `handoff` is a saved agent report. `Builder` and `verifier` reports contain `probe` outcomes. The simplifier's report records refactored files, a summary, and notes.
10
11
 
11
- A `builder` `handoff` can contain `escalations`, which are questions that need `owner` decisions.
12
- A `verifier` `handoff` can contain `findings`, which are technical issues.
12
+ A `builder` `handoff` can contain `escalations`, which are questions that need `owner` decisions. A `verifier` `handoff` can contain `findings`, which are technical
13
+ issues.
13
14
 
14
15
  ## Roles
15
16
 
16
17
  | Role | Responsibility |
17
- |--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
18
+ | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
18
19
  | `Owner` | Decides requirements, scope, technical decisions, `spec` approval, `escalation` answers, and `finding` decisions. Performs the final review. |
19
20
  | `Maestro` | Prepares the `spec` with the `owner`, records workflow progress, runs agents, presents issues, and saves `owner` decisions. |
20
21
  | `Builder` | Implements the approved `spec` and runs every `probe`. Reports completion or an `escalation`, including technical problems that prevent completion. |
@@ -31,11 +32,9 @@ Maestro's Pi status shows the current phase.
31
32
 
32
33
  `pi-subagents` FleetView and `/subagents-fleet` show live agent activity and transcripts.
33
34
 
34
- Saved `handoffs` provide a structured account of each reported `run`.
35
- The `builder` reports its outcome, `probe` results, notes, and any `escalation` questions.
36
- The `verifier` reports its independent checks, results, and `findings`.
37
- The `simplifier` reports its refactoring separately.
38
- Recorded `owner` decisions explain how questions and issues were resolved. Earlier numbered reports remain available for inspection.
35
+ Saved `handoffs` provide a structured account of each reported `run`. The `builder` reports its outcome, `probe` results, notes, and any `escalation` questions. The
36
+ `verifier` reports its independent checks, results, and `findings`. The `simplifier` reports its refactoring separately. Recorded `owner` decisions explain how questions
37
+ and issues were resolved. Earlier numbered reports remain available for inspection.
39
38
 
40
39
  For example, the `owner` can read `B1.json` to see what the `builder` reports implementing and which `probes` it ran. `V1.json` shows what the `verifier` reports checking
41
40
  independently and which issues it found.
@@ -52,7 +51,7 @@ flowchart TD
52
51
  buildOutcome{Builder outcome}
53
52
  verify[Verifier checks live project files]
54
53
  findings{Findings?}
55
- simplify[Simplifier refactors accepted code or skips if Git is unavailable]
54
+ simplify[Simplifier refactors accepted code]
56
55
  candidate[Candidate ready]
57
56
  summary[Maestro summarizes results]
58
57
  review[Owner performs the final review]
@@ -86,7 +85,7 @@ alone does not establish a completed action.
86
85
  The default path is `.specs/<spec-id>/workflow.json`. The `spec` directory is [configurable](configuration.md).
87
86
 
88
87
  | Phase | Meaning |
89
- |------------------------|--------------------------------------------------------------------------------------------------------------------------------|
88
+ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
90
89
  | `drafting-spec` | The `owner` and `Maestro` prepare the initial `spec` or revise it after recorded `escalation` answers or `finding` decisions. |
91
90
  | `ready-for-builder` | The approved `spec` or recorded `owner` decisions permit a `builder` `run`. |
92
91
  | `builder-running` | A `builder` `run` is active. |
@@ -97,48 +96,124 @@ The default path is `.specs/<spec-id>/workflow.json`. The `spec` directory is [c
97
96
  | `simplifier-running` | Verification succeeded or the `owner` rejected all current `findings`. The `simplifier` can run or skip if Git is unavailable. |
98
97
  | `candidate-ready` | Simplification completed. The workflow is complete. |
99
98
 
99
+ ## Specification documents
100
+
101
+ Each new `spec` uses these documents in the same directory:
102
+
103
+ | Document | Content | Presence |
104
+ | ------------- | ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
105
+ | `proposal.md` | Problem, goal, scope, and exclusions. | Always created. |
106
+ | `spec.md` | Required behavior, constraints, deltas, and `acceptance criteria` next to their requirements. | Always created. |
107
+ | `design.md` | Approved technical decisions, brief reasons, relevant contracts, risks, and prototype references. | Only when significant technical decisions need to be recorded. |
108
+
100
109
  ## Spec approval
101
110
 
102
111
  For the initial `spec`:
103
112
 
104
- 1. `Maestro` creates `spec.md` and `workflow.json` in `drafting-spec` and prepares the `spec` with the `owner`.
105
- 2. The `owner` reviews the requirements, scope, technical decisions, and `acceptance criteria`.
106
- 3. `Maestro` asks the `owner` to inspect the current `spec.md` and reply `GREEN FLAG` to approve it and start the `builder`.
113
+ 1. `Maestro` creates `proposal.md`, `spec.md`, and `workflow.json` in `drafting-spec`, then prepares the documents with the `owner`. It adds `design.md` only when needed.
114
+ 2. The `owner` reviews the complete document set: motivation, scope, requirements, `acceptance criteria`, and any approved technical decisions.
115
+ 3. `Maestro` asks the `owner` to inspect `proposal.md`, `spec.md`, and `design.md` when present and reply `GREEN FLAG` once to approve the entire set and start the
116
+ `builder`.
107
117
  4. After that reply, `Maestro` saves `ready-for-builder` and starts the `builder` in the foreground.
108
118
 
109
- Approval freezes the `spec`. The `spec` and its visual prototypes remain unchanged during `builder`, `verifier`, and `simplifier` execution.
110
- See [Spec revision](#spec-revision) for permitted revisions.
119
+ Approval freezes all present `spec` documents and visual prototypes together. None may change during `builder`, `verifier`, or `simplifier` execution. See
120
+ [Spec revision](#spec-revision) for permitted revisions.
121
+
122
+ ## Requirement deltas
123
+
124
+ Each requirement has exactly one `Delta` field. It describes the impact of the requirement against the current system's behavior.
125
+
126
+ | Value | Meaning |
127
+ | ---------- | ------------------------------------------------------------------------- |
128
+ | `added` | Introduces behavior or a constraint that did not exist before the change. |
129
+ | `modified` | Changes existing behavior or a constraint. |
130
+ | `removed` | Removes behavior that must no longer be available. |
131
+
132
+ The `spec` describes only requirements added, modified, or removed by the change. Existing behavior must continue working unless explicitly changed or removed. Unchanged
133
+ behavior is implicit, not an inventory of requirements to repeat in every `spec`.
134
+
135
+ For `modified` or `removed` requirements, a short `Before` description is included only when it helps explain the change. For example,
136
+ `Before: Tokens expire 30 minutes after issuance.`
137
+
138
+ ## Requirement coverage
139
+
140
+ Each requirement has its own section and a unique, stable ID, such as `REQ1`. Its `Verified by` field links to the `acceptance criteria` or existing tests that verify it.
141
+ The mapping appears only under the requirement, not again inside each `acceptance criterion`. Requirements use `### REQ<number>:` headings; their criteria immediately
142
+ follow as `#### AC<number>:` subsections. Each requirement-associated AC is defined once under its primary requirement; other requirements can link to it. AC numbering is
143
+ continuous across the whole document, including standalone regression criteria, not restarted for each requirement or section.
144
+
145
+ For example, a change that introduces persistent item titles can describe its requirement and linked `acceptance criterion` in `spec.md` as follows:
146
+
147
+ ```markdown
148
+ ### REQ1: Persist saved titles
149
+
150
+ Delta: added
151
+
152
+ Saving and reopening an item must preserve its title.
153
+
154
+ Verified by: [AC1](#ac1-saved-title-is-persisted)
155
+
156
+ #### AC1: Saved title is persisted
157
+
158
+ 1. Probe: Save a change to an item's title, then reopen the item.
159
+ 2. Expected result: The saved title is still present.
160
+ 3. Example: Change the title from "Draft" to "Ready", save, and reopen the item. The title is "Ready".
161
+ ```
162
+
163
+ A requirement can link to several `acceptance criteria`, and one criterion can verify several requirements (1:N). When an existing test covers the exact starting
164
+ conditions, action, and `expected result`, `Verified by` links to the test file relative to `spec.md` and includes the exact scenario name. No duplicate criterion is
165
+ needed. A requirement can reference both criteria and existing tests.
166
+
167
+ Before approval, `Maestro` follows the links and checks that their combined scenarios verify the whole requirement. Missing, partial, or uncertain coverage must be
168
+ resolved with an appropriate criterion or a confirmed existing test. References are updated when criterion headings or test locations change, including during `spec`
169
+ revisions.
111
170
 
112
171
  ## Acceptance criteria
113
172
 
114
- Each `acceptance criterion` has a unique ID and describes one observable result.
173
+ Each `acceptance criterion` has a unique ID and describes one observable result. A criterion can verify a changed requirement or check a relevant regression in existing
174
+ behavior without an associated requirement.
175
+
176
+ Standalone regression criteria belong in an optional `## Regression checks` section, with `### AC<number>:` headings. They do not need a `REQ` heading, `Delta`, or an
177
+ artificial requirement association. Only regressions relevant to the change belong here; unchanged requirements are not listed. The section is omitted when unnecessary.
178
+
179
+ For example, if saving item descriptions already works, adding title persistence may warrant this regression check without a new requirement for descriptions:
180
+
181
+ ```markdown
182
+ ## Regression checks
183
+
184
+ ### AC2: Existing descriptions remain saved
185
+
186
+ 1. Probe: Change and save the title of an item with a saved description, then reopen it.
187
+ 2. Expected result: The description is unchanged.
188
+ 3. Example: An item's saved description is "Buy milk". Change its title from "Draft" to "Shopping", save, and reopen it. Its description is still "Buy milk".
189
+ ```
115
190
 
116
- Each criterion contains these parts:
191
+ Both nested and standalone criteria share one continuous AC sequence and are checked by the `builder` and `verifier`. Standalone criteria have the same fields as
192
+ requirement-associated criteria:
117
193
 
118
- | Part | Content |
119
- |-------------------|-------------------------------------------------------------------------------------|
120
- | Coverage | One label that states the scenario's purpose: `success`, `failure`, or `unchanged`. |
121
- | `Probe` | Starting conditions and the action or observation that checks the behavior. |
122
- | `Expected result` | The measurable result the `probe` observes. |
123
- | Example | Concrete starting conditions, an input or action, and the exact `expected result`. |
194
+ | Part | Content |
195
+ | ----------------- | ---------------------------------------------------------------------------------- |
196
+ | `Probe` | Starting conditions and the action or observation that checks the behavior. |
197
+ | `Expected result` | The measurable result the `probe` observes. |
198
+ | Example | Concrete starting conditions, an input or action, and the exact `expected result`. |
124
199
 
125
200
  ## Escalations
126
201
 
127
- An `escalation` returns an implementation decision or a technical problem to the `owner`.
128
- For instance a technical failure, an undefined behavior, a conflict with the `spec`, or a possible scope change.
202
+ An `escalation` returns an implementation decision or a technical problem to the `owner`. For instance a technical failure, an undefined behavior, a conflict with the
203
+ `spec`, or a possible scope change.
129
204
 
130
205
  The `builder` saves all questions from one `pass` in the `escalations` list of its numbered `handoff`. `Maestro` identifies each question with both report and
131
206
  `escalation` IDs, such as `B1/E1`. See [Escalation references](glossary.md#escalation-references) for their scope.
132
207
 
133
208
  `Maestro` presents each question, evidence, options, consequences, and next steps. The workflow pauses in `escalation-decisions` while the `owner` decides how to proceed.
134
209
 
135
- The `owner` gives `Maestro` an answer and reason for every current question, whether or not the `spec` must change.
136
- The `owner` can select a listed option or give a different decision.
210
+ The `owner` gives `Maestro` an answer and reason for every current question, whether or not the `spec` must change. The `owner` can select a listed option or give a
211
+ different decision.
137
212
 
138
213
  `Maestro` saves all answers in the current `builder` `handoff` before the workflow continues.
139
214
 
140
215
  | `Owner` choice | Result |
141
- |-------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
216
+ | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
142
217
  | Keep the current `spec` | `Maestro` starts another `builder` `run` without renewed approval. |
143
218
  | Change the `spec` | The `owner` and `Maestro` revise the same `spec`. The `owner` reviews it and replies `GREEN FLAG` before another `builder` `run`. |
144
219
 
@@ -149,36 +224,34 @@ The `owner` can select a listed option or give a different decision.
149
224
  Every current `finding` requires an `owner` decision, regardless of severity. `Maestro` explains the issue, evidence, practical effect, and available choices.
150
225
 
151
226
  `Maestro` identifies each `finding` with its report and `finding` IDs. For example, `V1/F2` means `finding` 2 in `verifier` report `V1.json`. The `finding` is an entry in
152
- that file's `findings` list, not a separate `F2.json` file. `Finding` numbers restart at `F1` in each `verifier` report.
153
- See [Finding references](glossary.md#finding-references) for a worked example.
227
+ that file's `findings` list, not a separate `F2.json` file. `Finding` numbers restart at `F1` in each `verifier` report. See
228
+ [Finding references](glossary.md#finding-references) for a worked example.
154
229
 
155
230
  `Maestro` records `owner` decisions in the same `verifier` report, e.g. decisions about `V1/F2` update `V1.json`, not a new `V2.json`. A new `verifier` result creates the
156
231
  next report (`V2.json`).
157
232
 
158
233
  | Decision | Result |
159
- |---------------|----------------------------------------------------------------------------------------------------------------|
234
+ | ------------- | -------------------------------------------------------------------------------------------------------------- |
160
235
  | `reject` | Records the owner's reason. If every `finding` is rejected, the workflow reaches `simplifier-running`. |
161
236
  | `fix-code` | Keeps the current `spec` and returns to `ready-for-builder` for code fixes when no decision requires revision. |
162
237
  | `revise-spec` | Records the owner's reason and agreed requirement change, then returns to `drafting-spec`. |
163
238
 
164
- `Maestro` saves every current decision together before the phase changes.
165
- If any `finding` requires revision, revision takes priority over code fixes and rejections. See [Spec revision](#spec-revision).
239
+ `Maestro` saves every current decision together before the phase changes. If any `finding` requires revision, revision takes priority over code fixes and rejections. See
240
+ [Spec revision](#spec-revision).
166
241
 
167
- Without revision, any `fix-code` decision requires another `builder` `run`, including when other `findings` are rejected.
168
- After the `builder` completes the fixes, the `verifier` checks the work again.
242
+ Without revision, any `fix-code` decision requires another `builder` `run`, including when other `findings` are rejected. After the `builder` completes the fixes, the
243
+ `verifier` checks the work again.
169
244
 
170
245
  ## Spec revision
171
246
 
172
- For either `escalation` answers or `finding` decisions, `Maestro` records the complete batch before the workflow returns to `drafting-spec`.
173
- This decision does not approve the `spec` or start an agent.
174
- The `owner` and `Maestro` then revise the same `spec` together in `drafting-spec`.
247
+ For either `escalation` answers or `finding` decisions, `Maestro` records the complete batch before the workflow returns to `drafting-spec`. This decision does not
248
+ approve the `spec` or start an agent. The `owner` and `Maestro` then revise the same `spec` together in `drafting-spec`.
175
249
 
176
- The `owner` reviews the changes and replies `GREEN FLAG` again.
177
- `Maestro` records that renewed approval separately, moves to `ready-for-builder`, and starts another `builder` `run`.
178
- Approval is permitted only in `drafting-spec`, not directly from either decision phase.
250
+ The `owner` reviews the complete revised set of `proposal.md`, `spec.md`, and `design.md` when present and replies `GREEN FLAG` once again. `Maestro` records that renewed
251
+ approval separately, moves to `ready-for-builder`, and starts another `builder` `run`. Approval is permitted only in `drafting-spec`, not directly from either decision
252
+ phase.
179
253
 
180
- The revised `spec` controls subsequent work.
181
- Earlier `escalations`, `findings`, and their decisions remain historical context.
254
+ The revised `spec` controls subsequent work. Earlier `escalations`, `findings`, and their decisions remain historical context.
182
255
 
183
256
  ## Verification boundary
184
257
 
@@ -189,25 +262,24 @@ Cleanup relies on the `verifier`. If cleanup cannot finish safely, the `verifier
189
262
 
190
263
  ## Simplification
191
264
 
192
- After a successful verification, Maestro starts the `simplifier`.
193
- The `simplifier` runs only if Git is available, if not, a warning is displayed: `Simplifier skipped: Git repository unavailable.`
265
+ After a successful verification, Maestro starts the `simplifier`. The `simplifier` runs only if Git is available, if not, a warning is displayed:
266
+ `Simplifier skipped: Git repository unavailable.`
194
267
 
195
268
  The `simplifier` starts from all staged, unstaged, and untracked code changes, including pre-existing changes. It preserves observable behavior and introduces no new
196
- check failures.
197
- If no code needs refactoring, the `simplifier` does not make any change.
269
+ check failures. If no code needs refactoring, the `simplifier` does not make any change.
198
270
 
199
271
  ## Workflow completion
200
272
 
201
- The workflow ends at `candidate-ready`.
202
- `Maestro` summarizes the changes, verification results, rejected `findings` and reasons, relevant `builder` notes from the saved `artifacts`, and simplifier's summary and
203
- notes
273
+ The workflow ends at `candidate-ready`. `Maestro` summarizes the changes, verification results, rejected `findings` and reasons, relevant `builder` notes from the saved
274
+ `artifacts`, and simplifier's summary and notes.
204
275
 
205
- The `owner` performs the final review and controls any later Git use, pull request, or merge. Changes after completion are outside the completed verification.
276
+ `Maestro` stays active while delivering this final summary, then automatically turns off after successful delivery. The `owner` performs the final review and controls any
277
+ later Git use, pull request, or merge. Changes after completion are outside the completed verification.
206
278
 
207
279
  ## Stored artifacts
208
280
 
209
- An `artifact` is a saved workflow file. `Maestro` creates the `spec` directory with `spec.md`, `workflow.json`, and an empty `prototypes/` directory. `Builder`,
210
- `verifier`, and `simplifier` `handoff` directories appear when those results are saved.
281
+ An `artifact` is a saved workflow file. `Maestro` creates the `spec` directory with `proposal.md`, `spec.md`, `workflow.json`, and an empty `prototypes/` directory.
282
+ `design.md` is created during drafting only when needed. `Builder`, `verifier`, and `simplifier` `handoff` directories appear when those results are saved.
211
283
 
212
284
  The agents submit results through `Maestro` tools instead of writing the reports directly. A successful submission saves the result and updates the phase in
213
285
  `workflow.json` before the agent returns.
@@ -220,7 +292,7 @@ outcome, including `escalation`, creates the next `B` report. Revising the same
220
292
  For example, a repair cycle with successful `builder` results produces these files:
221
293
 
222
294
  | Step | Action | Report saved or updated |
223
- |------|-------------------------------------------------------------------------|---------------------------------------------------------------------------------|
295
+ | ---- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
224
296
  | 1 | The `builder` completes the implementation. | Creates `handoffs/builder/B1.json`. |
225
297
  | 2 | The `verifier` checks it and reports `findings`. | Creates `handoffs/verifier/V1.json`. |
226
298
  | 3 | The `owner` decides every `finding` and requests a code fix. | Updates decisions in the existing `V1.json`. |
@@ -230,8 +302,8 @@ For example, a repair cycle with successful `builder` results produces these fil
230
302
 
231
303
  If the first `builder` `run` escalates, it creates `B1.json` with its questions. `Owner` answers update `B1.json`. The next saved `builder` result creates `B2.json`.
232
304
 
233
- A `builder` report has `status: done` or `status: escalation`. A `done` report requires every recorded `probe` to pass and an empty `escalations` list.
234
- An `escalation` retains actual `probe` results: `passed`, `failed`, or `not-run`.
305
+ A `builder` report has `status: done` or `status: escalation`. A `done` report requires every recorded `probe` to pass and an empty `escalations` list. An `escalation`
306
+ retains actual `probe` results: `passed`, `failed`, or `not-run`.
235
307
 
236
308
  Execution errors or missing or invalid saved results stop the workflow. See [Limitations](#limitations).
237
309
 
@@ -239,7 +311,9 @@ The default layout after multiple `runs` is:
239
311
 
240
312
  ```text
241
313
  .specs/<spec-id>/
314
+ ├── proposal.md
242
315
  ├── spec.md
316
+ ├── design.md # only when needed
243
317
  ├── workflow.json
244
318
  ├── handoffs/
245
319
  │ ├── builder/
@@ -260,17 +334,17 @@ available as context, not as proof for the current `run`. `Owner` decisions upda
260
334
 
261
335
  ### No small models
262
336
 
263
- The `owner` must not use small models with a `low` thinking level for this workflow. These combinations cannot reliably follow the workflow rules.
264
- One example is `gpt-luna-6` with `thinking: "low"`.
337
+ The `owner` must not use small models with a `low` thinking level for this workflow. These combinations cannot reliably follow the workflow rules. One example is
338
+ `gpt-luna-6` with `thinking: "low"`.
265
339
 
266
340
  Moreover, the workflow works well with a defined harness: tests, lint for code rules, anti-slop checks for unwanted patterns, and `AGENTS.md`. `Maestro` does not supply
267
341
  these project-specific checks.
268
342
 
269
343
  ### No automatic rollback
270
344
 
271
- Launch errors, delegation failures, timeouts, interruptions, cancellations, and missing or invalid `handoffs` stop the workflow without a recovery transition.
272
- If a `run` saves no completed transition, its saved running phase remains unchanged. Partial protocol writes require manual `owner` follow-up.
273
- `Maestro` provides no automatic rollback, repair, or recovery for these errors. The files that remain are available for `owner` inspection.
345
+ Launch errors, delegation failures, timeouts, interruptions, cancellations, and missing or invalid `handoffs` stop the workflow without a recovery transition. If a `run`
346
+ saves no completed transition, its saved running phase remains unchanged. Partial protocol writes require manual `owner` follow-up. `Maestro` provides no automatic
347
+ rollback, repair, or recovery for these errors. The files that remain are available for `owner` inspection.
274
348
 
275
349
  ### No reconciliation
276
350
 
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
7
+
7
8
  import { registerRecordBuilderHandoffTool } from '#tools/child/record-builder-handoff.ts';
8
9
  import { registerRecordSimplifierHandoffTool } from '#tools/child/record-simplifier-handoff.ts';
9
10
  import { registerRecordVerifierHandoffTool } from '#tools/child/record-verifier-handoff.ts';