@emiliosp/pi-maestro 0.10.1 → 0.11.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/ADR.md +53 -9
- package/CHANGELOG.md +73 -33
- package/MISSION.md +4 -2
- package/README.md +29 -14
- package/ROADMAP.md +114 -85
- package/TECH_STACK.md +12 -11
- package/agents/simplifier.md +214 -0
- package/agents/verifier.md +1 -16
- package/docs/configuration.md +27 -16
- package/docs/glossary.md +41 -36
- package/docs/subagent-integration.md +23 -13
- package/docs/workflow.md +102 -71
- package/extensions/maestro-subagent.ts +3 -1
- package/extensions/maestro.ts +10 -0
- package/package.json +1 -1
- package/src/MaestroPaths.ts +4 -0
- package/src/artifacts/simplifier-handoff/assertSimplifierHandoff.ts +56 -0
- package/src/artifacts/simplifier-handoff/readSimplifierHandoff.ts +29 -0
- package/src/artifacts/simplifier-handoff/schema.ts +26 -0
- package/src/config/assertConfiguration.ts +1 -1
- package/src/config/defaults.ts +7 -0
- package/src/config/loadConfiguration.ts +1 -0
- package/src/config/schema.ts +3 -0
- package/src/maestro/checks/assertEnvironment.ts +7 -3
- package/src/maestro/instructions/getMaestroInstructions.ts +16 -6
- package/src/maestro/status/formatMaestroStatus.ts +3 -0
- package/src/tools/child/record-simplifier-handoff.ts +73 -0
- package/src/tools/main/resolve-findings.ts +1 -1
- package/src/tools/main/run-simplifier.ts +182 -0
- package/src/tools/main/run-verifier.ts +5 -5
- package/src/workflow/roles.ts +2 -1
- package/src/workflow/simplifier/completeSimplifierPass.ts +57 -0
- package/src/workflow/state/schema.ts +4 -0
- package/src/workflow/transitions.ts +9 -1
- package/src/workflow/utils/getAgentRole.ts +5 -1
package/ROADMAP.md
CHANGED
|
@@ -1,66 +1,74 @@
|
|
|
1
1
|
# Roadmap
|
|
2
2
|
|
|
3
|
-
This roadmap records planned outcomes, not permission to implement them. The `owner` selects work and approves its `specification` before implementation starts. Detailed
|
|
3
|
+
This roadmap records planned outcomes, not permission to implement them. The `owner` selects work and approves its `specification` before implementation starts. Detailed
|
|
4
|
+
requirements, technical decisions, and `acceptance criteria` belong in that `specification`.
|
|
4
5
|
|
|
5
|
-
"Now" is the current priority. "Next" follows it.
|
|
6
|
+
"Now" is the current priority. "Next" follows it. "Later" contains uncommitted ideas with no promised order or date.
|
|
6
7
|
|
|
7
8
|
Item identifiers remain stable when priorities change. The `owner` approves changes to priorities and scope.
|
|
8
9
|
|
|
9
10
|
## Overview
|
|
10
11
|
|
|
11
|
-
| ID
|
|
12
|
-
|
|
13
|
-
| R-01 | [Improve status presentation and activation feedback](#r-01-improve-status-presentation-and-activation-feedback)
|
|
14
|
-
| R-02 | [Store escalations and owner decisions in builder handoffs](#r-02-store-escalations-and-owner-decisions-in-builder-handoffs) | Completed
|
|
15
|
-
| R-03 | [Route builder failures through owner escalations](#r-03-route-builder-failures-through-owner-escalations)
|
|
16
|
-
| R-12 | [Format glossary terms consistently](#r-12-format-glossary-terms-consistently)
|
|
17
|
-
| R-14 | [Introduce Maestro at activation](#r-14-introduce-maestro-at-activation)
|
|
18
|
-
| R-15 | [Rename the test support directory](#r-15-rename-the-test-support-directory)
|
|
19
|
-
| R-16 | [Verify code quality against AGENTS.md instructions](#r-16-verify-code-quality-against-agentsmd-instructions)
|
|
20
|
-
| R-06 | [Check subagent extensions at activation](#r-06-check-subagent-extensions-at-activation)
|
|
21
|
-
| R-05 | [Keep acceptance criterion numbering continuous](#r-05-keep-acceptance-criterion-numbering-continuous)
|
|
22
|
-
| R-10 | [Match handoff criteria to the approved spec](#r-10-match-handoff-criteria-to-the-approved-spec)
|
|
23
|
-
| R-17 | [Record escalation resolutions when the spec changes](#r-17-record-escalation-resolutions-when-the-spec-changes)
|
|
24
|
-
| R-20 | [Route finding-driven spec revisions through drafting-spec](#r-20-route-finding-driven-spec-revisions-through-drafting-spec) | Completed
|
|
25
|
-
| R-18 | [Label acceptance criterion coverage](#r-18-label-acceptance-criterion-coverage)
|
|
26
|
-
| R-19 | [Avoid acceptance criteria already covered by tests](#r-19-avoid-acceptance-criteria-already-covered-by-tests)
|
|
27
|
-
| R-04 | [Rename the npm package](#r-04-rename-the-npm-package)
|
|
28
|
-
| R-07 | [Guide initial configuration](#r-07-guide-initial-configuration)
|
|
29
|
-
| R-08 | [Change agent models before a builder run](#r-08-change-agent-models-before-a-builder-run)
|
|
30
|
-
| R-09 | [Define workflow reconciliation](#r-09-define-workflow-reconciliation)
|
|
31
|
-
| R-21 | [Add a simplifier with one clear purpose per agent](#r-21-add-a-simplifier-with-one-clear-purpose-per-agent)
|
|
12
|
+
| ID | Title | Status | Summary |
|
|
13
|
+
|------|------------------------------------------------------------------------------------------------------------------------------|-------------|--------------------------------------------------------------------------------------------------------------------|
|
|
14
|
+
| R-01 | [Improve status presentation and activation feedback](#r-01-improve-status-presentation-and-activation-feedback) | Completed | Show clearer status and configured agent details without adding model context. |
|
|
15
|
+
| R-02 | [Store escalations and owner decisions in builder handoffs](#r-02-store-escalations-and-owner-decisions-in-builder-handoffs) | Completed | Keep `escalation` questions and `owner` answers together in numbered `builder` `handoffs`. |
|
|
16
|
+
| R-03 | [Route builder failures through owner escalations](#r-03-route-builder-failures-through-owner-escalations) | Completed | Route reportable `builder` problems through `owner` `escalations` instead of a terminal failure phase. |
|
|
17
|
+
| R-12 | [Format glossary terms consistently](#r-12-format-glossary-terms-consistently) | Completed | Apply glossary formatting across documentation and record its exclusions. |
|
|
18
|
+
| R-14 | [Introduce Maestro at activation](#r-14-introduce-maestro-at-activation) | Completed | Introduce `Maestro` at activation and load relevant documentation only when needed. |
|
|
19
|
+
| R-15 | [Rename the test support directory](#r-15-rename-the-test-support-directory) | Completed | Rename `test/` to `tests/` and update affected references. |
|
|
20
|
+
| R-16 | [Verify code quality against AGENTS.md instructions](#r-16-verify-code-quality-against-agentsmd-instructions) | Completed | Require the `verifier` to review affected code against applicable `AGENTS.md` code-quality directives. |
|
|
21
|
+
| R-06 | [Check subagent extensions at activation](#r-06-check-subagent-extensions-at-activation) | Completed | Require a successful parent `pi-subagents` availability reply before activation. |
|
|
22
|
+
| R-05 | [Keep acceptance criterion numbering continuous](#r-05-keep-acceptance-criterion-numbering-continuous) | Completed | Reject gaps in `acceptance criterion` numbering before approving a `spec`. |
|
|
23
|
+
| R-10 | [Match handoff criteria to the approved spec](#r-10-match-handoff-criteria-to-the-approved-spec) | Completed | Require every approved `spec` criterion ID in each submitted `builder` and `verifier` `handoff`. |
|
|
24
|
+
| R-17 | [Record escalation resolutions when the spec changes](#r-17-record-escalation-resolutions-when-the-spec-changes) | Completed | Save all current `escalation` answers before changing phase, including when the `spec` requires revision. |
|
|
25
|
+
| R-20 | [Route finding-driven spec revisions through drafting-spec](#r-20-route-finding-driven-spec-revisions-through-drafting-spec) | Completed | Record `finding` decisions before `spec` revision and require renewed `GREEN FLAG` before another `builder` `run`. |
|
|
26
|
+
| R-18 | [Label acceptance criterion coverage](#r-18-label-acceptance-criterion-coverage) | Completed | Label each `acceptance criterion` as success, failure, or unchanged behavior. |
|
|
27
|
+
| R-19 | [Avoid acceptance criteria already covered by tests](#r-19-avoid-acceptance-criteria-already-covered-by-tests) | Completed | Omit `acceptance criteria` whose exact scenarios already have test coverage. |
|
|
28
|
+
| R-04 | [Rename the npm package](#r-04-rename-the-npm-package) | Later | Rename `@emiliosp/pi-maestro` to `pi-maestro-sdd` with compatibility decisions defined in the `spec`. |
|
|
29
|
+
| R-07 | [Guide initial configuration](#r-07-guide-initial-configuration) | Later | Help the `owner` create valid `Maestro` configuration through an interview. |
|
|
30
|
+
| R-08 | [Change agent models before a builder run](#r-08-change-agent-models-before-a-builder-run) | Later | Let the `owner` change `builder` and `verifier` models before subsequent `runs`. |
|
|
31
|
+
| R-09 | [Define workflow reconciliation](#r-09-define-workflow-reconciliation) | Later | Define how `Maestro` can reconcile saved `artifacts` and workflow state. |
|
|
32
|
+
| R-21 | [Add a simplifier with one clear purpose per agent](#r-21-add-a-simplifier-with-one-clear-purpose-per-agent) | Implemented | Run the `simplifier` after accepted verification, with a Git-only file scope and separate report. |
|
|
32
33
|
|
|
33
34
|
## Completed
|
|
34
35
|
|
|
35
36
|
### R-01: Improve status presentation and activation feedback
|
|
36
37
|
|
|
37
|
-
The status bar uses phase icons, theme colors, and shortened `spec` IDs. Successful activation shows the configured `builder` and `verifier` settings without adding the
|
|
38
|
+
The status bar uses phase icons, theme colors, and shortened `spec` IDs. Successful activation shows the configured `builder` and `verifier` settings without adding the
|
|
39
|
+
notice to session history or model context. All 12 `acceptance criteria` passed with no `verifier` `findings`. The saved workflow reached `candidate-ready`.
|
|
38
40
|
|
|
39
41
|
#### Evidence
|
|
40
42
|
|
|
41
|
-
[Specification](.specs/20261007-170438-update-maestro-status-bar-with-agent-models-theme-colors-and-phase-icons/spec.md), [verifier report](.specs/20261007-170438-update-maestro-status-bar-with-agent-models-theme-colors-and-phase-icons/handoffs/verifier/V1.json),
|
|
43
|
+
[Specification](.specs/20261007-170438-update-maestro-status-bar-with-agent-models-theme-colors-and-phase-icons/spec.md), [verifier report](.specs/20261007-170438-update-maestro-status-bar-with-agent-models-theme-colors-and-phase-icons/handoffs/verifier/V1.json),
|
|
44
|
+
and [merged PR #26](https://github.com/emilioSp/pi-maestro/pull/26).
|
|
42
45
|
|
|
43
46
|
### R-02: Store escalations and owner decisions in builder handoffs
|
|
44
47
|
|
|
45
|
-
Numbered `builder` `handoffs` contain multiple `escalation` questions and their `owner` resolutions. The `owner` resolves all current questions in one batch. Earlier
|
|
48
|
+
Numbered `builder` `handoffs` contain multiple `escalation` questions and their `owner` resolutions. The `owner` resolves all current questions in one batch. Earlier
|
|
49
|
+
`handoffs` remain available as history. All 10 `acceptance criteria` passed with no `verifier` `findings`. The saved workflow reached `candidate-ready`.
|
|
46
50
|
|
|
47
51
|
#### Evidence
|
|
48
52
|
|
|
49
|
-
[Specification](.specs/20261008-132344-store-escalations-in-builder-handoffs/spec.md), [verifier report](.specs/20261008-132344-store-escalations-in-builder-handoffs/handoffs/verifier/V1.json),
|
|
53
|
+
[Specification](.specs/20261008-132344-store-escalations-in-builder-handoffs/spec.md), [verifier report](.specs/20261008-132344-store-escalations-in-builder-handoffs/handoffs/verifier/V1.json),
|
|
54
|
+
and [merged PR #27](https://github.com/emilioSp/pi-maestro/pull/27).
|
|
50
55
|
|
|
51
56
|
### R-03: Route builder failures through owner escalations
|
|
52
57
|
|
|
53
|
-
Released in `0.9.0`. The `builder` reports only `done` or `escalation`. Reportable technical problems use the existing `owner` `escalation` process. Individual `probe`
|
|
58
|
+
Released in `0.9.0`. The `builder` reports only `done` or `escalation`. Reportable technical problems use the existing `owner` `escalation` process. Individual `probe`
|
|
59
|
+
results retain `failed`. Execution errors and missing or invalid saved results still stop the workflow without automatic recovery.
|
|
54
60
|
|
|
55
61
|
All 8 `acceptance criteria` passed with no `verifier` `findings`. The saved workflow reached `candidate-ready`.
|
|
56
62
|
|
|
57
63
|
#### Evidence
|
|
58
64
|
|
|
59
|
-
[Specification](.specs/20261013-101454-route-builder-failures-through-owner-escalations/spec.md), [verifier report](.specs/20261013-101454-route-builder-failures-through-owner-escalations/handoffs/verifier/V1.json),
|
|
65
|
+
[Specification](.specs/20261013-101454-route-builder-failures-through-owner-escalations/spec.md), [verifier report](.specs/20261013-101454-route-builder-failures-through-owner-escalations/handoffs/verifier/V1.json),
|
|
66
|
+
and [merged PR #32](https://github.com/emilioSp/pi-maestro/pull/32).
|
|
60
67
|
|
|
61
68
|
### R-12: Format glossary terms consistently
|
|
62
69
|
|
|
63
|
-
Applied glossary formatting across the documentation and recorded its exclusions in `AGENTS.md` and the documentation audit skill. The approved change document uses the
|
|
70
|
+
Applied glossary formatting across the documentation and recorded its exclusions in `AGENTS.md` and the documentation audit skill. The approved change document uses the
|
|
71
|
+
term `spec`. The `owner` confirmed completion.
|
|
64
72
|
|
|
65
73
|
#### Evidence
|
|
66
74
|
|
|
@@ -68,19 +76,23 @@ Applied glossary formatting across the documentation and recorded its exclusions
|
|
|
68
76
|
|
|
69
77
|
### R-14: Introduce Maestro at activation
|
|
70
78
|
|
|
71
|
-
Implemented in `0.9.1`. Successful activation introduces `Maestro` and invites the `owner` to ask how it works. The UI-only notice retains the configured agent details
|
|
79
|
+
Implemented in `0.9.1`. Successful activation introduces `Maestro` and invites the `owner` to ask how it works. The UI-only notice retains the configured agent details
|
|
80
|
+
and does not add session history or start a model request.
|
|
72
81
|
|
|
73
|
-
Active instructions identify absolute paths to the installed README and documentation directory. `Maestro` reads relevant documentation on demand without automatically
|
|
82
|
+
Active instructions identify absolute paths to the installed README and documentation directory. `Maestro` reads relevant documentation on demand without automatically
|
|
83
|
+
loading its contents.
|
|
74
84
|
|
|
75
85
|
All 6 `acceptance criteria` passed with no `verifier` `findings`. The saved workflow reached `candidate-ready`.
|
|
76
86
|
|
|
77
87
|
#### Evidence
|
|
78
88
|
|
|
79
|
-
[Specification](.specs/20261013-171954-introduce-maestro-at-activation/spec.md), [verifier report](.specs/20261013-171954-introduce-maestro-at-activation/handoffs/verifier/V1.json),
|
|
89
|
+
[Specification](.specs/20261013-171954-introduce-maestro-at-activation/spec.md), [verifier report](.specs/20261013-171954-introduce-maestro-at-activation/handoffs/verifier/V1.json),
|
|
90
|
+
and [merged PR #33](https://github.com/emilioSp/pi-maestro/pull/33).
|
|
80
91
|
|
|
81
92
|
### R-15: Rename the test support directory
|
|
82
93
|
|
|
83
|
-
Renamed `test/` to `tests/` at the owner's request. Updated imports, fixture paths, lint configuration, and project instructions. This follows the global instruction to
|
|
94
|
+
Renamed `test/` to `tests/` at the owner's request. Updated imports, fixture paths, lint configuration, and project instructions. This follows the global instruction to
|
|
95
|
+
keep fixtures under `tests/fixtures`. Source tests remain next to their source files. Historical `handoffs` retain their recorded paths.
|
|
84
96
|
|
|
85
97
|
#### Evidence
|
|
86
98
|
|
|
@@ -88,51 +100,65 @@ Renamed `test/` to `tests/` at the owner's request. Updated imports, fixture pat
|
|
|
88
100
|
|
|
89
101
|
### R-16: Verify code quality against AGENTS.md instructions
|
|
90
102
|
|
|
91
|
-
Implemented in `0.9.2`. `Verifier` guidance now requires code-quality review only for code affected by the approved change when applicable `AGENTS.md` directives exist.
|
|
103
|
+
Implemented in `0.9.2`. `Verifier` guidance now requires code-quality review only for code affected by the approved change when applicable `AGENTS.md` directives exist.
|
|
104
|
+
All existing duties remain unchanged, including independent verification of every `acceptance criterion`.
|
|
92
105
|
|
|
93
|
-
Instruction-violation `findings` identify the instruction file, quote the rule, and explain the violating code through existing evidence fields. Missing files or
|
|
106
|
+
Instruction-violation `findings` identify the instruction file, quote the rule, and explain the violating code through existing evidence fields. Missing files or
|
|
107
|
+
code-quality directives cause only the added review to be skipped. Personal style preferences are not requirements.
|
|
94
108
|
|
|
95
|
-
All 5 `acceptance criteria` passed through independent inspection of the written guidance, with no `verifier` `findings`. No additional model trials were performed. The
|
|
109
|
+
All 5 `acceptance criteria` passed through independent inspection of the written guidance, with no `verifier` `findings`. No additional model trials were performed. The
|
|
110
|
+
saved workflow reached `candidate-ready`.
|
|
96
111
|
|
|
97
112
|
#### Evidence
|
|
98
113
|
|
|
99
|
-
[Specification](.specs/20261013-185941-verify-code-quality-against-agents-md-instructions/spec.md), [verifier report](.specs/20261013-185941-verify-code-quality-against-agents-md-instructions/handoffs/verifier/V1.json),
|
|
114
|
+
[Specification](.specs/20261013-185941-verify-code-quality-against-agents-md-instructions/spec.md), [verifier report](.specs/20261013-185941-verify-code-quality-against-agents-md-instructions/handoffs/verifier/V1.json),
|
|
115
|
+
and [merged PR #34](https://github.com/emilioSp/pi-maestro/pull/34).
|
|
100
116
|
|
|
101
117
|
### R-06: Check subagent extensions at activation
|
|
102
118
|
|
|
103
|
-
Implemented in `0.9.3`. Activation requires a matching successful version 1 `ping` reply from the parent `pi-subagents` extension within 2000 ms. A failed or invalid
|
|
119
|
+
Implemented in `0.9.3`. Activation requires a matching successful version 1 `ping` reply from the parent `pi-subagents` extension within 2000 ms. A failed or invalid
|
|
120
|
+
reply, emission error, or timeout prevents activation and reports the installation requirement. The check starts no agent and makes no model request. It confirms parent
|
|
121
|
+
extension availability, not child execution readiness.
|
|
104
122
|
|
|
105
123
|
All 7 `acceptance criteria` passed using controlled replies and code inspection, with no `verifier` `findings`. The saved workflow reached `candidate-ready`.
|
|
106
124
|
|
|
107
|
-
A later integration test requested by the `owner` directly checks the environment check's failed-reply error. This test addition is outside the completed independent
|
|
125
|
+
A later integration test requested by the `owner` directly checks the environment check's failed-reply error. This test addition is outside the completed independent
|
|
126
|
+
verification.
|
|
108
127
|
|
|
109
128
|
#### Evidence
|
|
110
129
|
|
|
111
|
-
[Specification](.specs/20261013-194407-check-pi-subagents-availability-with-ping-at-activation/spec.md), [verifier report](.specs/20261013-194407-check-pi-subagents-availability-with-ping-at-activation/handoffs/verifier/V1.json),
|
|
130
|
+
[Specification](.specs/20261013-194407-check-pi-subagents-availability-with-ping-at-activation/spec.md), [verifier report](.specs/20261013-194407-check-pi-subagents-availability-with-ping-at-activation/handoffs/verifier/V1.json),
|
|
131
|
+
and [merged PR #35](https://github.com/emilioSp/pi-maestro/pull/35).
|
|
112
132
|
|
|
113
133
|
### R-05: Keep acceptance criterion numbering continuous
|
|
114
134
|
|
|
115
|
-
Implemented in `0.9.4`. `Spec` approval rejects numbered `acceptance criterion` headings that do not start at `AC1` and continue without gaps. Rejection leaves saved
|
|
135
|
+
Implemented in `0.9.4`. `Spec` approval rejects numbered `acceptance criterion` headings that do not start at `AC1` and continue without gaps. Rejection leaves saved
|
|
136
|
+
files unchanged.
|
|
116
137
|
|
|
117
|
-
`Maestro` corrects numbering and affected references without changing criterion order or requirements, then retries with the existing `GREEN FLAG`. No additional `owner`
|
|
138
|
+
`Maestro` corrects numbering and affected references without changing criterion order or requirements, then retries with the existing `GREEN FLAG`. No additional `owner`
|
|
139
|
+
approval is required.
|
|
118
140
|
|
|
119
141
|
All 3 `acceptance criteria` passed with no `verifier` `findings`. The saved workflow reached `candidate-ready`.
|
|
120
142
|
|
|
121
143
|
#### Evidence
|
|
122
144
|
|
|
123
|
-
[Specification](.specs/20261013-202811-check-acceptance-criterion-numbering-before-builder-execution/spec.md), [verifier report](.specs/20261013-202811-check-acceptance-criterion-numbering-before-builder-execution/handoffs/verifier/V1.json),
|
|
145
|
+
[Specification](.specs/20261013-202811-check-acceptance-criterion-numbering-before-builder-execution/spec.md), [verifier report](.specs/20261013-202811-check-acceptance-criterion-numbering-before-builder-execution/handoffs/verifier/V1.json),
|
|
146
|
+
and [merged PR #36](https://github.com/emilioSp/pi-maestro/pull/36).
|
|
124
147
|
|
|
125
148
|
### R-10: Match handoff criteria to the approved spec
|
|
126
149
|
|
|
127
|
-
Implemented in `0.9.5` with the narrower scope approved by the `owner`. Both `handoff` submissions require every `acceptance criterion` ID from the approved `spec` before
|
|
150
|
+
Implemented in `0.9.5` with the narrower scope approved by the `owner`. Both `handoff` submissions require every `acceptance criterion` ID from the approved `spec` before
|
|
151
|
+
saving a report or changing phase. Extra report IDs remain allowed. Existing report validation is unchanged, and no new check rejects duplicate `spec` IDs.
|
|
128
152
|
|
|
129
153
|
Both `acceptance criteria` passed independent verification with no `findings`. The saved workflow reached `candidate-ready`.
|
|
130
154
|
|
|
131
|
-
Later changes requested by the `owner` extracted the shared check and replaced repeated integration scenarios with unit tests. One missing-ID integration test remains per
|
|
155
|
+
Later changes requested by the `owner` extracted the shared check and replaced repeated integration scenarios with unit tests. One missing-ID integration test remains per
|
|
156
|
+
role. These changes are outside the completed independent verification. The final `npm run check` passed all 227 tests and coverage thresholds.
|
|
132
157
|
|
|
133
158
|
#### Evidence
|
|
134
159
|
|
|
135
|
-
[Specification](.specs/20261013-211629-match-handoff-criteria-to-the-approved-spec/spec.md), [verifier report](.specs/20261013-211629-match-handoff-criteria-to-the-approved-spec/handoffs/verifier/V1.json),
|
|
160
|
+
[Specification](.specs/20261013-211629-match-handoff-criteria-to-the-approved-spec/spec.md), [verifier report](.specs/20261013-211629-match-handoff-criteria-to-the-approved-spec/handoffs/verifier/V1.json),
|
|
161
|
+
and [merged PR #37](https://github.com/emilioSp/pi-maestro/pull/37).
|
|
136
162
|
|
|
137
163
|
### R-17: Record escalation resolutions when the spec changes
|
|
138
164
|
|
|
@@ -145,11 +171,11 @@ Each `resolution` records the owner's chosen solution and reason. A decision req
|
|
|
145
171
|
|
|
146
172
|
`Maestro` records the complete decision batch through `maestro_resolve_escalations` before changing phase.
|
|
147
173
|
|
|
148
|
-
| Decision
|
|
149
|
-
|
|
150
|
-
| No `spec` change
|
|
151
|
-
| `Spec` change required
|
|
152
|
-
| Revised `spec` receives renewed `GREEN FLAG` | `drafting-spec` → `ready-for-builder` through separate `maestro_mark_spec_ready` approval.
|
|
174
|
+
| Decision | Next phase and action |
|
|
175
|
+
|----------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|
|
|
176
|
+
| No `spec` change | `escalation-decisions` → `ready-for-builder`. The `builder` continues under the approved `spec`, without renewed approval. |
|
|
177
|
+
| `Spec` change required | `escalation-decisions` → `drafting-spec`. The `owner` and `Maestro` revise and review the same `spec`. |
|
|
178
|
+
| Revised `spec` receives renewed `GREEN FLAG` | `drafting-spec` → `ready-for-builder` through separate `maestro_mark_spec_ready` approval. |
|
|
153
179
|
|
|
154
180
|
Direct `spec` approval from `escalation-decisions` is rejected. Recording answers does not move to `ready-for-verifier`; that phase requires a completed `builder` `pass`.
|
|
155
181
|
|
|
@@ -171,22 +197,25 @@ Implemented the approved revision route. `Maestro` records every current `findin
|
|
|
171
197
|
The `owner` reviews the same revised `spec` and gives renewed `GREEN FLAG` before separate approval and another `builder` `run`.
|
|
172
198
|
Revision takes priority in mixed batches. Direct approval from `finding-decisions` is rejected.
|
|
173
199
|
|
|
174
|
-
Later event naming cleanup identifies `builder` and `owner` actions explicitly. Both revision routes use `OWNER_REQUEST_SPEC_REVISION` without changing the phase flow.
|
|
200
|
+
Later event naming cleanup identifies `builder` and `owner` actions explicitly. Both revision routes use `OWNER_REQUEST_SPEC_REVISION` without changing the phase flow.
|
|
201
|
+
Batch resolution uses `RESOLVE_ESCALATIONS`, and the status label refers to `escalations` in the plural. The saved decision phases are named `escalation-decisions` and
|
|
202
|
+
`finding-decisions`.
|
|
175
203
|
|
|
176
204
|
#### Evidence
|
|
177
205
|
|
|
178
|
-
[Specification](.specs/20261015-154812-route-finding-driven-spec-revisions-through-drafting-spec/spec.md)
|
|
206
|
+
[Specification](.specs/20261015-154812-route-finding-driven-spec-revisions-through-drafting-spec/spec.md)
|
|
207
|
+
and [resolution integration tests](src/tools/main/resolve-findings.integration.test.ts).
|
|
179
208
|
|
|
180
209
|
### R-18: Label acceptance criterion coverage
|
|
181
210
|
|
|
182
211
|
Implemented with R-19 as one task, as selected by the `owner`.
|
|
183
212
|
The `spec` template and `Maestro` guidance require one `Coverage` label per `acceptance criterion`:
|
|
184
213
|
|
|
185
|
-
| Label
|
|
186
|
-
|
|
187
|
-
| `success`
|
|
188
|
-
| `failure`
|
|
189
|
-
| `unchanged` | The change preserves existing behavior.
|
|
214
|
+
| Label | Purpose |
|
|
215
|
+
|-------------|----------------------------------------------|
|
|
216
|
+
| `success` | A valid action produces the required result. |
|
|
217
|
+
| `failure` | An invalid action is correctly rejected. |
|
|
218
|
+
| `unchanged` | The change preserves existing behavior. |
|
|
190
219
|
|
|
191
220
|
Use `unchanged` when the criterion explicitly checks behavior that the change must preserve.
|
|
192
221
|
Labels describe scenarios, not test outcomes. A `failure` scenario passes when the invalid action is correctly rejected.
|
|
@@ -199,7 +228,8 @@ The final `npm run check` passed all 238 tests and coverage thresholds. No model
|
|
|
199
228
|
|
|
200
229
|
#### Evidence
|
|
201
230
|
|
|
202
|
-
[Spec template](templates/spec.md), [Maestro guidance](src/maestro/instructions/getMaestroInstructions.ts), [creation integration test](src/specs/create.integration.test.ts),
|
|
231
|
+
[Spec template](templates/spec.md), [Maestro guidance](src/maestro/instructions/getMaestroInstructions.ts), [creation integration test](src/specs/create.integration.test.ts),
|
|
232
|
+
and [workflow documentation](docs/workflow.md#acceptance-criteria).
|
|
203
233
|
|
|
204
234
|
### R-19: Avoid acceptance criteria already covered by tests
|
|
205
235
|
|
|
@@ -215,21 +245,42 @@ Verification consisted of inspecting the written guidance and running `npm run c
|
|
|
215
245
|
|
|
216
246
|
#### Evidence
|
|
217
247
|
|
|
218
|
-
[Maestro guidance](src/maestro/instructions/getMaestroInstructions.ts), [spec template](templates/spec.md),
|
|
248
|
+
[Maestro guidance](src/maestro/instructions/getMaestroInstructions.ts), [spec template](templates/spec.md),
|
|
249
|
+
and [workflow documentation](docs/workflow.md#acceptance-criteria).
|
|
219
250
|
|
|
220
251
|
## Now
|
|
221
252
|
|
|
253
|
+
### R-21: Add a simplifier with one clear purpose per agent
|
|
254
|
+
|
|
255
|
+
Implemented under the [specification](.specs/20261016-090319-add-a-dedicated-simplifier-after-verification/spec.md). Independent review is pending.
|
|
256
|
+
The `builder` implements the approved `spec`. The `verifier` checks its `acceptance criteria`. The `simplifier` refactors accepted code for clarity.
|
|
257
|
+
The extra code-quality review introduced in R-16 is removed from the verifier's instructions.
|
|
258
|
+
|
|
259
|
+
Successful verification and rejection of all current `findings` save `simplifier-running`.
|
|
260
|
+
`Maestro` calls `maestro_run_simplifier` without another approval or verification cycle.
|
|
261
|
+
Only that tool checks Git readiness. If Git is unavailable, it warns and saves `candidate-ready` without delegation or a `simplifier` `handoff`.
|
|
262
|
+
|
|
263
|
+
The `simplifier` selects all uncommitted code changes, including pre-existing staged, unstaged, and untracked files.
|
|
264
|
+
It preserves observable behavior and the accepted check baseline. Rejected `findings` remain rejected, not passed.
|
|
265
|
+
Required caller updates can include initially unchanged files. Unrelated refactoring, index changes, and automatic commits are excluded.
|
|
266
|
+
|
|
267
|
+
A completed `pass` saves the fixed, unnumbered `handoffs/simplifier/S.json`, then saves `candidate-ready`.
|
|
268
|
+
The report contains refactored files, a summary, and notes. No refactoring is required when selected code is already clear.
|
|
269
|
+
Maestro's final summary separates this report from independent `verifier` evidence.
|
|
270
|
+
|
|
222
271
|
## Next
|
|
223
272
|
|
|
224
273
|
## Later
|
|
225
274
|
|
|
226
|
-
These items need scope review before `specification` approval. Existing behavior must be checked before adding new code. Dependencies between these items are not yet
|
|
275
|
+
These items need scope review before `specification` approval. Existing behavior must be checked before adding new code. Dependencies between these items are not yet
|
|
276
|
+
agreed.
|
|
227
277
|
|
|
228
278
|
### R-04: Rename the npm package
|
|
229
279
|
|
|
230
280
|
#### Objective
|
|
231
281
|
|
|
232
|
-
Rename `@emiliosp/pi-maestro` to `pi-maestro-sdd`. The `owner` installs the package under the new name. This item changes the package identity, not the development
|
|
282
|
+
Rename `@emiliosp/pi-maestro` to `pi-maestro-sdd`. The `owner` installs the package under the new name. This item changes the package identity, not the development
|
|
283
|
+
workflow.
|
|
233
284
|
|
|
234
285
|
Compatibility with installations under the old name must be decided in the `specification`. No `specification` is approved yet.
|
|
235
286
|
|
|
@@ -266,25 +317,3 @@ Explore how `Maestro` can reconcile saved `artifacts` and workflow state. The re
|
|
|
266
317
|
#### Completed when
|
|
267
318
|
|
|
268
319
|
Not yet defined. The `owner` must define the intended outcome, recovery boundaries, and completion condition before this item can move forward.
|
|
269
|
-
|
|
270
|
-
### R-21: Add a simplifier with one clear purpose per agent
|
|
271
|
-
|
|
272
|
-
#### Objective
|
|
273
|
-
|
|
274
|
-
Each agent has exactly one purpose. The `builder` implements the approved `spec`. The `verifier` independently checks its `acceptance criteria`. The simplifier refactors verified code.
|
|
275
|
-
|
|
276
|
-
Add the simplifier after the `verifier`. It receives code built by the `builder` only after verification confirms that all checks defined in the `acceptance criteria` pass.
|
|
277
|
-
|
|
278
|
-
The simplifier reduces complexity while preserving exact behavior. The goal is code that is easier to read, understand, modify, and debug, not fewer lines.
|
|
279
|
-
Every simplification must pass this test: "Would a new team member understand this faster than the original?"
|
|
280
|
-
|
|
281
|
-
#### Scope boundaries
|
|
282
|
-
|
|
283
|
-
Remove the "Review code quality" section from `agents/verifier.md`. This replaces the additional review introduced in R-16, not independent verification of `acceptance criteria`.
|
|
284
|
-
|
|
285
|
-
The simplifier's detailed instructions will be defined during `spec` preparation. This roadmap item does not define them.
|
|
286
|
-
|
|
287
|
-
#### Completed when
|
|
288
|
-
|
|
289
|
-
The workflow includes the simplifier after successful verification. Agent instructions keep implementation, verification, and simplification as separate responsibilities.
|
|
290
|
-
The simplifier preserves exact behavior and follows the instructions agreed in the approved `spec`.
|
package/TECH_STACK.md
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# Tech stack
|
|
2
2
|
|
|
3
|
-
`Maestro` is a source-only TypeScript package that uses ECMAScript modules (ESM). Pi loads the TypeScript source directly. The package has no build step or compiled
|
|
3
|
+
`Maestro` is a source-only TypeScript package that uses ECMAScript modules (ESM). Pi loads the TypeScript source directly. The package has no build step or compiled
|
|
4
|
+
`dist/` directory.
|
|
4
5
|
|
|
5
|
-
| Technology
|
|
6
|
-
|
|
7
|
-
| TypeScript
|
|
8
|
-
| Node.js
|
|
9
|
-
| Pi
|
|
10
|
-
| `pi-subagents`
|
|
11
|
-
| TypeBox
|
|
12
|
-
| Vitest with coverage
|
|
13
|
-
| Biome
|
|
14
|
-
| Oxlint with `oxlint-anti-slop` | Additional lint and anti-slop checks.
|
|
6
|
+
| Technology | Use |
|
|
7
|
+
|--------------------------------|---------------------------------------------------------------------------------------------------|
|
|
8
|
+
| TypeScript | Application code and static type checks with `tsc --noEmit`. |
|
|
9
|
+
| Node.js | Runtime. |
|
|
10
|
+
| Pi | Extension host, agent APIs, and terminal interface. |
|
|
11
|
+
| `pi-subagents` | `Builder`, `verifier`, and `simplifier` execution and activity tracking. |
|
|
12
|
+
| TypeBox | Schemas and runtime validation for configuration, workflow state, tool inputs, and agent reports. |
|
|
13
|
+
| Vitest with coverage | Unit tests, integration tests, and code coverage. |
|
|
14
|
+
| Biome | Formatting and lint checks. |
|
|
15
|
+
| Oxlint with `oxlint-anti-slop` | Additional lint and anti-slop checks. |
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: simplifier
|
|
3
|
+
package: maestro
|
|
4
|
+
description: Refactors accepted Maestro code for clarity without changing behavior.
|
|
5
|
+
systemPromptMode: replace
|
|
6
|
+
inheritProjectContext: true
|
|
7
|
+
inheritGlobalContext: true
|
|
8
|
+
inheritSkills: true
|
|
9
|
+
subagentOnlyExtensions: ../extensions/maestro-subagent.ts
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Simplifier
|
|
13
|
+
|
|
14
|
+
Refactor accepted code for clarity. Work only in the canonical project directory supplied by Maestro.
|
|
15
|
+
Communicate with Maestro, never directly with the owner. Do not delegate, approve work, implement new behavior, or raise findings or escalations.
|
|
16
|
+
|
|
17
|
+
## Read the accepted contract
|
|
18
|
+
|
|
19
|
+
1. Use the exact project directory and `specId` supplied by Maestro. Use `specDirectory` from `.pi/maestro.json`, or `.specs` when unset.
|
|
20
|
+
2. Read `<specDirectory>/<specId>/spec.md`, relevant prototypes, `workflow.json`, and applicable `AGENTS.md` files.
|
|
21
|
+
3. Read relevant builder and verifier handoffs and embedded owner decisions. The highest numeric B or V sequence is active; earlier numbered handoffs are context, not active instructions.
|
|
22
|
+
4. Confirm that the saved workflow identifies this spec and is in `simplifier-running`. If inputs or phase do not match, report the mismatch to Maestro and stop. Do not repair protocol state.
|
|
23
|
+
|
|
24
|
+
You start with a fresh context. The accepted behavior includes existing failures explicitly accepted through rejected verifier findings. For example, if V1/F1 reports an existing failing translation check and the owner rejects it as "Outside approved scope", that failure can remain. Do not fix F1, change its test to pass, or introduce another check failure. Rejected findings do not become passed verification.
|
|
25
|
+
Preserve the accepted baseline and introduce no new check failures. Do not repair rejected findings or modify existing tests to make checks pass.
|
|
26
|
+
Do not edit the frozen spec, prototypes, workflow state, or earlier handoffs through any tool. Record your result only through `maestro_record_simplifier_handoff`.
|
|
27
|
+
|
|
28
|
+
## Discover the file scope
|
|
29
|
+
|
|
30
|
+
Use `git status --porcelain=v1 -z --untracked-files=all -- .` to discover all current uncommitted code changes within the project directory, including pre-existing staged, unstaged, and untracked files. Paths are repository-relative: convert them to project-relative paths if the project directory is a repository subdirectory. Parse the NUL-separated output safely, including paths with spaces and both paths in rename or copy records. Read the selected files' diffs and current contents. Deleted files offer no live code to refactor.
|
|
31
|
+
Committed changes alone do not select files. There is no starting commit, builder file list, or non-Git fallback.
|
|
32
|
+
Required caller updates may include initially unchanged code files. Exclude unrelated refactoring.
|
|
33
|
+
Do not reset pre-existing changes or modify the Git index or history. Do not create commits or checkpoints.
|
|
34
|
+
If the selected code is already clear or no code files are selected, no refactoring is required.
|
|
35
|
+
|
|
36
|
+
## Checks and result
|
|
37
|
+
|
|
38
|
+
Inspect repository scripts before running checks. Follow applicable project conventions and required commands. Compare check results with the accepted baseline, not an invented all-green baseline. Undo your own simplifications if they introduce failures or make code harder to understand or review. Preserve all pre-existing content and changes.
|
|
39
|
+
Remove temporary files and restore only temporary verification changes before recording the result. Keep successful refactoring.
|
|
40
|
+
Call `maestro_record_simplifier_handoff` exactly once with `specId`, `refactoredFiles`, `summary`, and `notes`.
|
|
41
|
+
List only files actually refactored by this agent, including required caller updates. Use project-relative paths within the project root. Reviewed files left unchanged are not refactored files. An empty array is valid.
|
|
42
|
+
The tool supplies version `1.0.0`, saves the fixed unnumbered `handoffs/simplifier/S.json`, then applies `SIMPLIFIER_DONE` to save `candidate-ready`. Do not add acceptance results, findings, escalations, status, or sequence numbers.
|
|
43
|
+
After success, return the saved summary and artifact path to Maestro and stop. Do not run another verifier pass.
|
|
44
|
+
If execution, checks, or cleanup prevent safe completion, report the exact problem to Maestro and stop without manufacturing a successful result. An explicitly accepted existing failure alone does not prevent completion.
|
|
45
|
+
If submission fails, inspect the error, workflow, and artifacts. Correct a validation rejection only when nothing was written. If an artifact or phase was partially written, report it and stop without retrying, deleting the artifact, or changing protocol files.
|
|
46
|
+
|
|
47
|
+
## Overview
|
|
48
|
+
|
|
49
|
+
Simplify code by reducing complexity while preserving exact behavior. The goal is not fewer lines — it's code that is easier to read, understand, modify, and debug. Every simplification must pass a simple test: "Would a new team member understand this faster than the original?"
|
|
50
|
+
|
|
51
|
+
## The Five Principles
|
|
52
|
+
|
|
53
|
+
### 1. Preserve Behavior Exactly
|
|
54
|
+
|
|
55
|
+
Don't change what the code does — only how it expresses it. All inputs, outputs, side effects, error behavior, and edge cases must remain identical. If you're not sure a simplification preserves behavior, don't make it.
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
ASK BEFORE EVERY CHANGE:
|
|
59
|
+
→ Does this produce the same output for every input?
|
|
60
|
+
→ Does this maintain the same error behavior?
|
|
61
|
+
→ Does this preserve the same side effects and ordering?
|
|
62
|
+
→ Do checks preserve the accepted baseline without test modification or new failures?
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 2. Follow Project Conventions
|
|
66
|
+
|
|
67
|
+
Simplification means making code more consistent with the codebase, not imposing external preferences. Before simplifying:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
1. Read AGENTS.md / project conventions
|
|
71
|
+
2. Study how neighboring code handles similar patterns
|
|
72
|
+
3. Match the project's style for:
|
|
73
|
+
- Import ordering and module system
|
|
74
|
+
- Function declaration style
|
|
75
|
+
- Naming conventions
|
|
76
|
+
- Error handling patterns
|
|
77
|
+
- Type annotation depth
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Simplification that breaks project consistency is not simplification — it's churn.
|
|
81
|
+
|
|
82
|
+
### 3. Prefer Clarity Over Cleverness
|
|
83
|
+
|
|
84
|
+
Explicit code is better than compact code when the compact version requires a mental pause to parse.
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
// UNCLEAR: Dense ternary chain
|
|
88
|
+
const label = isNew ? 'New' : isUpdated ? 'Updated' : isArchived ? 'Archived' : 'Active';
|
|
89
|
+
|
|
90
|
+
// CLEAR: Readable mapping
|
|
91
|
+
function getStatusLabel(item: Item): string {
|
|
92
|
+
if (item.isNew) return 'New';
|
|
93
|
+
if (item.isUpdated) return 'Updated';
|
|
94
|
+
if (item.isArchived) return 'Archived';
|
|
95
|
+
return 'Active';
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
// UNCLEAR: Chained reduces with inline logic
|
|
101
|
+
const result = items.reduce((acc, item) => ({
|
|
102
|
+
...acc,
|
|
103
|
+
[item.id]: { ...acc[item.id], count: (acc[item.id]?.count ?? 0) + 1 }
|
|
104
|
+
}), {});
|
|
105
|
+
|
|
106
|
+
// CLEAR: Named intermediate step
|
|
107
|
+
const countById = new Map<string, number>();
|
|
108
|
+
for (const item of items) {
|
|
109
|
+
countById.set(item.id, (countById.get(item.id) ?? 0) + 1);
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
This object-to-Map example is one internal refactoring, not permission to change observable behavior. Update affected internal callers in the same refactoring: replace `result.a.count` with `result.get("a")` (using the Map as `result`). Keep observable inputs, outputs, side effects, ordering, errors, and edge cases identical. Do not use this change if the object itself is an observable output that must remain unchanged.
|
|
114
|
+
|
|
115
|
+
### 4. Maintain Balance
|
|
116
|
+
|
|
117
|
+
Simplification has a failure mode: over-simplification. Watch for these traps:
|
|
118
|
+
|
|
119
|
+
- **Inlining too aggressively** — removing a helper that gave a concept a name makes the call site harder to read
|
|
120
|
+
- **Combining unrelated logic** — two simple functions merged into one complex function is not simpler
|
|
121
|
+
- **Removing "unnecessary" abstraction** — some abstractions exist for extensibility or testability, not complexity
|
|
122
|
+
- **Optimizing for line count** — fewer lines is not the goal; easier comprehension is
|
|
123
|
+
|
|
124
|
+
### 5. Scope to What Changed
|
|
125
|
+
|
|
126
|
+
Default to simplifying recently modified code. Avoid drive-by refactors of unrelated code unless explicitly asked to broaden scope. Unscoped simplification creates noise in diffs and risks unintended regressions.
|
|
127
|
+
|
|
128
|
+
## The Simplification Process
|
|
129
|
+
|
|
130
|
+
### Step 1: Understand Before Touching (Chesterton's Fence)
|
|
131
|
+
|
|
132
|
+
Before changing or removing anything, understand why it exists. This is Chesterton's Fence: if you see a fence across a road and don't understand why it's there, don't tear it down. First understand the reason, then decide if the reason still applies.
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
BEFORE SIMPLIFYING, ANSWER:
|
|
136
|
+
- What is this code's responsibility?
|
|
137
|
+
- What calls it? What does it call?
|
|
138
|
+
- What are the edge cases and error paths?
|
|
139
|
+
- Are there tests that define the expected behavior?
|
|
140
|
+
- Why might it have been written this way? (Performance? Platform constraint? Historical reason?)
|
|
141
|
+
- Check history in project constitution and changelog: what was the original context for this code?
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
If you can't answer these, you're not ready to simplify. Read more context first.
|
|
145
|
+
|
|
146
|
+
### Step 2: Identify Simplification Opportunities
|
|
147
|
+
|
|
148
|
+
Scan for these patterns — each one is a concrete signal, not a vague smell:
|
|
149
|
+
|
|
150
|
+
**Structural complexity:**
|
|
151
|
+
|
|
152
|
+
| Pattern | Signal | Simplification |
|
|
153
|
+
|---------|--------|----------------|
|
|
154
|
+
| Deep nesting (3+ levels) | Hard to follow control flow | Extract conditions into guard clauses or helper functions |
|
|
155
|
+
| Long functions (50+ lines) | Multiple responsibilities | Split into focused functions with descriptive names |
|
|
156
|
+
| Nested ternaries | Requires mental stack to parse | Replace with if/else chains, switch, or lookup objects |
|
|
157
|
+
| Boolean parameter flags | `doThing(true, false, true)` | Replace with options objects or separate functions |
|
|
158
|
+
| Repeated conditionals | Same `if` check in multiple places | Extract to a well-named predicate function |
|
|
159
|
+
|
|
160
|
+
**Naming and readability:**
|
|
161
|
+
|
|
162
|
+
| Pattern | Signal | Simplification |
|
|
163
|
+
|---------|--------|----------------|
|
|
164
|
+
| Generic names | `data`, `result`, `temp`, `val`, `item` | Rename to describe the content: `userProfile`, `validationErrors` |
|
|
165
|
+
| Abbreviated names | `usr`, `cfg`, `btn`, `evt` | Use full words unless the abbreviation is universal (`id`, `url`, `api`) |
|
|
166
|
+
| Misleading names | Function named `get` that also mutates state | Rename to reflect actual behavior |
|
|
167
|
+
| Comments explaining "what" | `// increment counter` above `count++` | Delete the comment — the code is clear enough |
|
|
168
|
+
| Comments explaining "why" | `// Retry because the API is flaky under load` | Keep these — they carry intent the code can't express |
|
|
169
|
+
|
|
170
|
+
**Redundancy:**
|
|
171
|
+
|
|
172
|
+
| Pattern | Signal | Simplification |
|
|
173
|
+
|---------|--------|----------------|
|
|
174
|
+
| Duplicated logic | Same 5+ lines in multiple places | Extract to a shared function |
|
|
175
|
+
| Dead code | Unreachable branches, unused variables, commented-out blocks | Remove (after confirming it's truly dead) |
|
|
176
|
+
| Unnecessary abstractions | Wrapper that adds no value | Inline the wrapper, call the underlying function directly |
|
|
177
|
+
| Over-engineered patterns | Factory-for-a-factory, strategy-with-one-strategy | Replace with the simple direct approach |
|
|
178
|
+
| Redundant type assertions | Casting to a type that's already inferred | Remove the assertion |
|
|
179
|
+
|
|
180
|
+
### Step 3: Verify the Result
|
|
181
|
+
|
|
182
|
+
After all simplifications, step back and evaluate the whole:
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
COMPARE BEFORE AND AFTER:
|
|
186
|
+
- Is the simplified version genuinely easier to understand?
|
|
187
|
+
- Did you introduce any new patterns inconsistent with the codebase?
|
|
188
|
+
- Is the diff clean and reviewable?
|
|
189
|
+
- Would a teammate approve this change?
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
If the "simplified" version is harder to understand or review, revert. Not every simplification attempt succeeds.
|
|
193
|
+
|
|
194
|
+
## Common Rationalizations
|
|
195
|
+
|
|
196
|
+
| Rationalization | Reality |
|
|
197
|
+
|---|---|
|
|
198
|
+
| "It's working, no need to touch it" | Working code that's hard to read will be hard to fix when it breaks. Simplifying now saves time on every future change. |
|
|
199
|
+
| "Fewer lines is always simpler" | A 1-line nested ternary is not simpler than a 5-line if/else. Simplicity is about comprehension speed, not line count. |
|
|
200
|
+
| "I'll just quickly simplify this unrelated code too" | Unscoped simplification creates noisy diffs and risks regressions in code you didn't intend to change. Stay focused. |
|
|
201
|
+
| "The types make it self-documenting" | Types document structure, not intent. A well-named function explains *why* better than a type signature explains *what*. |
|
|
202
|
+
| "This abstraction might be useful later" | Don't preserve speculative abstractions. If it's not used now, it's complexity without value. Remove it and re-add when needed. |
|
|
203
|
+
| "The original author must have had a reason" | Maybe. Check git blame — apply Chesterton's Fence. But accumulated complexity often has no reason; it's just the residue of iteration under pressure. |
|
|
204
|
+
| "I'll refactor while adding this feature" | Separate refactoring from feature work. Mixed changes are harder to review, revert, and understand in history. |
|
|
205
|
+
|
|
206
|
+
## Red Flags
|
|
207
|
+
|
|
208
|
+
- Simplification that requires modifying tests to pass (you likely changed behavior)
|
|
209
|
+
- "Simplified" code that is longer and harder to follow than the original
|
|
210
|
+
- Renaming things to match your preferences rather than project conventions and AGENTS.md
|
|
211
|
+
- Removing error handling because "it makes the code cleaner"
|
|
212
|
+
- Simplifying code you don't fully understand
|
|
213
|
+
- Batching many simplifications into one large, hard-to-review commit
|
|
214
|
+
- Refactoring code outside the scope of the current task without being asked
|