pirl-framework-cli 0.0.0-stage → 1.0.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 (92) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/LICENSE +21 -0
  3. package/README.md +265 -2
  4. package/bundled-framework/files/.agents/evals/layer_record.py +438 -0
  5. package/bundled-framework/files/.agents/evals/tests/test_layer_record.py +264 -0
  6. package/bundled-framework/files/.agents/evals/tests/test_skills.py +210 -0
  7. package/bundled-framework/files/.agents/evals/tests/test_validate_layer_artifact.py +214 -0
  8. package/bundled-framework/files/.agents/evals/validate_layer_artifact.py +415 -0
  9. package/bundled-framework/files/.agents/instructions/implement.instructions.md +343 -0
  10. package/bundled-framework/files/.agents/instructions/layered-task-execution.instructions.md +370 -0
  11. package/bundled-framework/files/.agents/instructions/layout-verification.instructions.md +107 -0
  12. package/bundled-framework/files/.agents/instructions/plan.instructions.md +292 -0
  13. package/bundled-framework/files/.agents/instructions/review.instructions.md +236 -0
  14. package/bundled-framework/files/.agents/instructions/self-evaluation.instructions.md +146 -0
  15. package/bundled-framework/files/.agents/instructions/standalone-and-maintenance.instructions.md +230 -0
  16. package/bundled-framework/files/.agents/roles/backend-developer.role.md +45 -0
  17. package/bundled-framework/files/.agents/roles/business-analyst.role.md +55 -0
  18. package/bundled-framework/files/.agents/roles/code-analyst.role.md +63 -0
  19. package/bundled-framework/files/.agents/roles/code-reviewer.role.md +46 -0
  20. package/bundled-framework/files/.agents/roles/frontend-developer.role.md +51 -0
  21. package/bundled-framework/files/.agents/roles/process-auditor.role.md +62 -0
  22. package/bundled-framework/files/.agents/roles/solution-architect.role.md +53 -0
  23. package/bundled-framework/files/.agents/roles/technical-writer.role.md +68 -0
  24. package/bundled-framework/files/.agents/roles/ux-designer.role.md +46 -0
  25. package/bundled-framework/files/.skills/pirl-implement/SKILL.md +115 -0
  26. package/bundled-framework/files/.skills/pirl-implement/assets/implementation-record-template.md +22 -0
  27. package/bundled-framework/files/.skills/pirl-implement/references/implementation-record-format.md +41 -0
  28. package/bundled-framework/files/.skills/pirl-implement/scripts/add_implementation_record.py +58 -0
  29. package/bundled-framework/files/.skills/pirl-implement/scripts/new_layout_run.py +51 -0
  30. package/bundled-framework/files/.skills/pirl-plan/SKILL.md +100 -0
  31. package/bundled-framework/files/.skills/pirl-plan/assets/plan-template.md +48 -0
  32. package/bundled-framework/files/.skills/pirl-plan/references/plan-format.md +65 -0
  33. package/bundled-framework/files/.skills/pirl-plan/scripts/new_plan.py +93 -0
  34. package/bundled-framework/files/.skills/pirl-review/SKILL.md +106 -0
  35. package/bundled-framework/files/.skills/pirl-review/assets/review-template.md +92 -0
  36. package/bundled-framework/files/.skills/pirl-review/references/review-format.md +70 -0
  37. package/bundled-framework/files/.skills/pirl-review/scripts/new_review.py +83 -0
  38. package/bundled-framework/files/AGENTS.md +303 -0
  39. package/bundled-framework/files/CONTEXT.md +187 -0
  40. package/bundled-framework/files/LICENSE +21 -0
  41. package/bundled-framework/files/README.md +170 -0
  42. package/bundled-framework/files/gitignore.pirl-bundled +12 -0
  43. package/bundled-framework/manifest.json +45 -0
  44. package/dist/bin/main.js +128 -0
  45. package/dist/bin/pirl.js +6 -0
  46. package/dist/commands/dispatch.js +57 -0
  47. package/dist/commands/registry.js +39 -0
  48. package/dist/core/clipboard.js +70 -0
  49. package/dist/core/config.js +73 -0
  50. package/dist/core/exec.js +32 -0
  51. package/dist/core/paths.js +34 -0
  52. package/dist/core/targetRepo.js +22 -0
  53. package/dist/doctor/doctor.js +95 -0
  54. package/dist/engine/agentMerge.js +71 -0
  55. package/dist/engine/agents.js +67 -0
  56. package/dist/engine/attachments.js +251 -0
  57. package/dist/engine/claudeQuota.js +62 -0
  58. package/dist/engine/claudeRunner.js +118 -0
  59. package/dist/engine/claudeStream.js +205 -0
  60. package/dist/engine/hubData.js +176 -0
  61. package/dist/engine/permissions.js +67 -0
  62. package/dist/engine/pricing.js +24 -0
  63. package/dist/engine/protocol.js +98 -0
  64. package/dist/engine/run.js +527 -0
  65. package/dist/engine/runStore.js +67 -0
  66. package/dist/engine/types.js +3 -0
  67. package/dist/hub/framework.js +13 -0
  68. package/dist/hub/hub.js +125 -0
  69. package/dist/hub/services.js +38 -0
  70. package/dist/hub/update.js +261 -0
  71. package/dist/providers/claude.js +62 -0
  72. package/dist/providers/index.js +17 -0
  73. package/dist/providers/types.js +1 -0
  74. package/dist/ui/App.js +849 -0
  75. package/dist/ui/browse.js +144 -0
  76. package/dist/ui/components/Header.js +54 -0
  77. package/dist/ui/components/Input.js +76 -0
  78. package/dist/ui/components/Lines.js +50 -0
  79. package/dist/ui/components/Panels.js +73 -0
  80. package/dist/ui/content.js +225 -0
  81. package/dist/ui/frameworkConsole.js +541 -0
  82. package/dist/ui/inputEditor.js +86 -0
  83. package/dist/ui/layout.js +36 -0
  84. package/dist/ui/lines.js +15 -0
  85. package/dist/ui/listOverlay.js +97 -0
  86. package/dist/ui/runView.js +305 -0
  87. package/dist/ui/session.js +1 -0
  88. package/dist/ui/terminalInput.js +45 -0
  89. package/dist/ui/text.js +58 -0
  90. package/dist/ui/theme.js +139 -0
  91. package/dist/ui/ticker.js +48 -0
  92. package/package.json +67 -4
@@ -0,0 +1,292 @@
1
+ ---
2
+ name: "Plan Layer Instructions"
3
+ description: "Create a short Plan in English, settle the business logic, assign implementation roles and verification roles that verify by reasoning."
4
+ applyTo: ".agents/instructions/plan.instructions.md"
5
+ metadata:
6
+ id: ".agents/instructions/plan"
7
+ kind: "instruction"
8
+ version: "2.0.3"
9
+ status: "active"
10
+ ---
11
+
12
+ # Plan Layer Instructions
13
+
14
+ Apply the Plan process only when the request and the [router](layered-task-execution.instructions.md)
15
+ have selected this layer. Reading or updating a Plan/report file does not
16
+ activate another layer. The run is carried out through the
17
+ [`pirl-plan` skill](../../.skills/pirl-plan/SKILL.md), which owns the run procedure, the
18
+ Plan file format and the helper script; this contract owns the decisions and
19
+ the exit conditions.
20
+
21
+ A Plan settles the work to do, how to do it, the implementation roles, the
22
+ verification roles and the logic that must hold. Write it in English; keep
23
+ IDs, data keys, symbols, commands and paths verbatim when referencing them. The
24
+ output is short, but the implementers must not have to re-decide product
25
+ behavior themselves.
26
+
27
+ ## AI Agent roles at the Plan layer
28
+
29
+ The role catalog lives in the [standalone and maintenance instructions](standalone-and-maintenance.instructions.md#role-catalog) and the
30
+ assignment principles in the [router](layered-task-execution.instructions.md#assignment-principles);
31
+ each role's expertise lives in the role file linked in the table.
32
+ Plan picks the smallest team with enough expertise for the request using the
33
+ "Select when" column and records it in `planning_roles`. When the user names
34
+ roles, keep exactly that list. Do not add roles just to complete the process.
35
+
36
+ | Role | Select when | Responsibility at Plan | Input | Done when |
37
+ | --- | --- | --- | --- | --- |
38
+ | [`business-analyst`](../roles/business-analyst.role.md) | The request has business behavior to settle | Settle REQs, business logic and QGs; find missing product decisions | Request, existing decisions, specifications | Each REQ has a source and an outcome; a source is recorded as the user's decision only for what is in the user's words or in the verbatim text of the choices and choice descriptions the user saw when choosing; what is inferred from the source or the repository's conventions, what interprets or extends a choice, and what the agent chose itself in work the user explicitly delegated to the agent are all recorded as decided by the agent, with their basis; product choices that change the result and that nobody has decided have been asked or marked unsettled; each QG states its required logic; the basis is read from sources by the role, which runs or builds measuring tools only when the user asks for a root-cause investigation ([Investigating and settling decisions](#investigating-and-settling-decisions)) |
39
+ | [`code-analyst`](../roles/code-analyst.role.md) | The request touches the target repository's source or documentation | Read callers/consumers, configuration and constraints; identify change points and affected documentation | Source of the target repository | The change scope and allowed paths are grounded in the source; for changes that spread to other elements or consumers (inherited properties, creating a containing block or stacking context, default configuration), the element carrying the change and the list of affected ones are stated; the basis is read from sources by the role, which runs or builds measuring tools only when the user asks for a root-cause investigation ([Investigating and settling decisions](#investigating-and-settling-decisions)) |
40
+ | [`solution-architect`](../roles/solution-architect.role.md) | API/data/permission contracts change, or the package has several tasks | Settle contracts, ownership, permission model, boundaries and dependencies between tasks | Source, shared contracts | Each task has its own acceptance outcome; real dependencies are recorded; for each value, symbol or file that a task adds, changes or removes, every passage of a file shared between tasks (including context documentation) that mentions it is in that same task's REQs, `Allowed paths` and QGs, so the file stays right after each task completes; the basis is read from sources by the role, which runs or builds measuring tools only when the user asks for a root-cause investigation ([Investigating and settling decisions](#investigating-and-settling-decisions)) |
41
+ | [`ux-designer`](../roles/ux-designer.role.md) | The request touches what the user sees | Settle screens, display states, interaction flows, UI strings per language and viewports; write UI QGs as state and layout logic | Request, existing UI, the repository's context documentation | Every display state created or changed has a QG; the basis is read from sources by the role, which runs or builds measuring tools only when the user asks for a root-cause investigation ([Investigating and settling decisions](#investigating-and-settling-decisions)) |
42
+ | [`process-auditor`](../roles/process-auditor.role.md) | Every Plan run; not recorded in `planning_roles` | Self-evaluate the Plan run per the [router](layered-task-execution.instructions.md#self-evaluation-and-improvement) | Plan, sources used, each role's decisions | Record written; improvements applied or summarized for the user |
43
+
44
+ The Plan coordinator merges the roles' conclusions, settles disagreements by
45
+ sources (not by voting), writes the Plan and self-reviews it. Each role returns
46
+ expert decisions with the sources that change the approach. Each Plan file
47
+ records how the planning roles were performed on the `Planning` line of the
48
+ `Participating roles` section: a separate agent, or the coordinator
49
+ self-performing with the reason delegation was not possible, per role when they
50
+ differ. When self-performed, do not claim an independent challenge happened.
51
+
52
+ ## Investigating and settling decisions
53
+
54
+ - Read the request and the existing decisions; identify the target repository
55
+ per [AGENTS.md](../../AGENTS.md#target-repository) and the part to
56
+ change from the source.
57
+ - Read the related callers/consumers, constraints and configuration before
58
+ claiming a mechanism is missing; do not infer the whole system from one file
59
+ or from an unverified review. Planning roles investigate by reading the
60
+ source, documentation, git history and existing records; they do not build
61
+ mock pages or measuring tools and do not run the application or a browser.
62
+ A quantity that reading does not yield is computed from the source with its
63
+ formula, or recorded as not yet measured. Only when the user asks for a
64
+ root-cause investigation may the responsible role reproduce the defect per the
65
+ [router](layered-task-execution.instructions.md#verification-by-reasoning);
66
+ the Plan records the distinguished cause and does not turn the reproduction
67
+ result into a QG.
68
+ - Settle the difference between the current state and the target outcome. Ask
69
+ when a product choice that changes the result is missing; resolve details
70
+ yourself from the source and the repository's conventions. If only one branch
71
+ is blocked, complete the independent part of the Plan and mark the limit clearly.
72
+
73
+ ## Splitting tasks for separate implementation and acceptance
74
+
75
+ - Prefer each Plan file to be one piece of work with its own outcome and
76
+ independently verifiable QGs. Draw boundaries by behavior/contracts that can
77
+ be completed, not by file count, technical layer or a goal of splitting as
78
+ small as possible. Shipping in the same release is no reason to merge all
79
+ work into one task.
80
+ - For each task, consider the state made of only the original source, the
81
+ outputs of completed prerequisite tasks and the task's own changes: every QG
82
+ must be provable by reasoning on the source of that state. A QG must not need
83
+ code, configuration, fixes or evidence that are assigned only to a later task
84
+ or a task planned to run in parallel. Do not create a task that, once
85
+ implemented, still has to wait for a later task before Review can PASS.
86
+ - Reduce dependencies with settled contracts and a clear change scope. For
87
+ APIs, schemas or shared files, state which part already exists, which part
88
+ needs implementing and which task owns each change. For documents that
89
+ several tasks edit, assign by change, not by section, column or topic: for
90
+ each value, symbol or file that a task adds, changes or removes, search by
91
+ token name, value and file name for every passage that mentions it, including
92
+ exhaustive listings (component lists, directory trees), then assign that
93
+ passage to that same task. When two tasks change the same value, each task
94
+ updates that passage for its own change. A contract on paper does not replace
95
+ the implementation needed to conclude a QG; two tasks editing the same
96
+ symbol/decision cannot be treated as independent just because of
97
+ `depends_on: []`.
98
+ - When there is a real dependency, record `depends_on` and the concrete output
99
+ to receive in `How to do it`. The prerequisite task must meet its own QGs
100
+ before the dependent task starts the part that needs that output. If the QGs
101
+ cannot be closed separately, change the boundary, make the shared part a
102
+ prerequisite task with a verifiable outcome, or merge exactly the parts that
103
+ cannot be separated. Do not hide a dependency with mocks, deleted
104
+ declarations, weakened QGs or abstractions created only to split tasks.
105
+ - Assign each acceptance condition to the task that owns that outcome.
106
+ End-to-end criteria, or removing an old mechanism, that only hold once several
107
+ parts are combined belong to an integration task that depends on those parts;
108
+ do not restate such criteria as PASS conditions of a prerequisite task. Keep
109
+ all package-wide requirements, and do not push a task's core behavior into
110
+ the integration so that the task can PASS. Reasoning on a local contract does
111
+ not prove the real execution path or data invariants; QGs of that kind must
112
+ name the write/read points to trace.
113
+ - `depends_on` points to tasks in the same package, never to itself, and never
114
+ forms a cycle. Re-read all QGs to find implicit dependencies: T02 needing T01
115
+ while T01's QG needs T02 is still a cycle even when the `depends_on` list is
116
+ valid. Fix the assignment/QGs before handoff; do not leave Implement/Review
117
+ to repeatedly edit code to work around a task-splitting mistake.
118
+
119
+ ## Scope of work: source code, documentation and functional tests
120
+
121
+ Per the [router](layered-task-execution.instructions.md#verification-by-reasoning),
122
+ a task covers implementing product source code (with accompanying documentation
123
+ in the target repository), creating/updating the target repository's context
124
+ documentation ([AGENTS.md](../../AGENTS.md#target-repository)), and functional
125
+ tests under the [FUT rule](layered-task-execution.instructions.md#functional-tests-fut-rule)
126
+ when a REQ/specification needs them.
127
+
128
+ - Never create a task, a `How to do it` step, a REQ, a QG, a `Done when` or
129
+ `Allowed paths` for building, running the application/database/browser for
130
+ acceptance, measuring performance, new harnesses or verification scripts,
131
+ deploying or releasing. [Layout verification with mocks](implement.instructions.md#layout-verification-with-mocks)
132
+ is something Implement does on its own when the diff changes the UI: the
133
+ Plan creates no task, step or QG for it, including a numbered step assigning
134
+ the implementation role to capture layout. UI QGs are still written as
135
+ layout/state logic. What needs to be captured or measured beyond that
136
+ section (viewports the user asked for, thresholds computable from the source,
137
+ computed properties to record) goes in the logic of the UI QGs and in the
138
+ implementation role's `Done when`; how to build the state without the diff
139
+ belongs to that section.
140
+ - When a task has tests, state the REQ/behavior under test, the affected
141
+ functionality with its grounds (call path, contract or shared data that is
142
+ changed), the test files allowed to be edited and exactly which tests run.
143
+ Do not assign tests for unrelated functionality, do not assign running the
144
+ whole suite, and do not invent test viewpoints beyond the specification.
145
+ - Specification goals that belong to the user's stage (performance thresholds,
146
+ device testing, running the whole system, release) do not become work in the
147
+ package; write one line in `What to do` saying they belong to the user's
148
+ build/test/release stage.
149
+ - QGs do not use test/build/run results as a baseline. Do not write QGs like
150
+ "test X is green", "the full test suite is green", "`npm run build` passes",
151
+ "seen in the browser…", "evidence on the real database" or a measurement.
152
+ Write the source logic that must hold: situation → where it is handled →
153
+ outcome/state and failure branches, enough for the verification role to
154
+ trace through the source and conclude. For example, replace "the sign-up test
155
+ is green" with "a valid code creates a `PENDING` account; a wrong code returns
156
+ `400` and writes no data".
157
+
158
+ ## Separating implementation roles from verification roles
159
+
160
+ - `implementation_roles` produce the task's output. `verification_roles` do not
161
+ edit the output; after the implementation roles finish, they conclude each
162
+ QG by reasoning per the
163
+ [Implement contract](implement.instructions.md#verifying-quality-gates-by-reasoning).
164
+ Each task has at least one role of each kind, and the two lists do not
165
+ overlap: a role does not verify what it implemented itself.
166
+ - Pick implementation roles from the
167
+ [Implement](implement.instructions.md#ai-agent-roles-at-the-implement-layer)
168
+ catalog by the kind of work: `backend-developer` for all non-UI code (API,
169
+ domain, data, jobs, CLI, scripts, tools), `frontend-developer` for the UI,
170
+ `technical-writer` for documentation-only tasks. When a task has both sides,
171
+ record the real dependency order, for example `backend-developer` before
172
+ `frontend-developer` uses the new API.
173
+ - Pick verification roles by the question the QG must answer, not by a fixed
174
+ pairing with the implementation role:
175
+ - `code-reviewer` challenges the diff: bugs, regressions, permissions and
176
+ security, data/state inconsistency, guards/validators/error handling that
177
+ report false success, contract violations; the default for every code change.
178
+ - `code-analyst` traces the flow from the entrypoint to the final state
179
+ through every caller/consumer and builds scenario tables for QGs with many
180
+ branches, states or orderings; suited to contract changes, many
181
+ integration points, or documentation that must match the source.
182
+ - `ux-designer` checks layout screenshots against UI QGs; pick it when the
183
+ task has UI QGs.
184
+
185
+ Examples: fixing one bug → `code-reviewer`; changing an API with its docs →
186
+ `code-reviewer` for permissions/regressions and `code-analyst` for consumers
187
+ and docs; adding a screen → `code-reviewer` and `ux-designer`. Combine
188
+ several roles only when each answers its own question; each QG has exactly
189
+ one verification role accountable for its conclusion.
190
+ - Verification is not running scripts, creating tests or running commands. Do
191
+ not assign verification roles to build, write/run tests, run the application
192
+ or write tools; tests belong to the implementation roles. A verification
193
+ role's `Done when` is a `PASS|FAIL|BLOCKED` conclusion for each assigned QG,
194
+ with the path traced, counterexamples and sources, plus a check of the tests
195
+ in the diff against FUT when the task has tests.
196
+
197
+ ## Content must be sufficient to execute
198
+
199
+ - Each REQ has a source and a concrete outcome; a QG says when something is
200
+ allowed/refused, the state to preserve and the related failure branches. Only
201
+ include risks with a mechanism within the request's scope; do not add
202
+ platforms, coverage or operations that were not assigned.
203
+ - `Allowed paths` include known documents that describe the behavior about to
204
+ change (an earlier task's contract, indexes, status tables, API/error/
205
+ configuration/permission catalogs): search by route name, error code,
206
+ collection, configuration, token, file name or phrases like "until task N",
207
+ then name them.
208
+ Anything missed is still swept by Implement under its contract; the Plan does
209
+ not need to list every place.
210
+ - Processing steps state the change point, the chosen direction, the order that
211
+ is really needed and the outcome. Settle decisions that affect APIs/data/
212
+ ownership; leave equivalent implementation details for Implement to choose.
213
+ Do not hide a missing decision inside the word "integrate".
214
+ - Pick `implementation_roles` and responsibilities by the work, not by the
215
+ number of layers or directories; pick `verification_roles` per the section
216
+ above. Do not make several roles accountable for the same decision without a
217
+ merging owner.
218
+ - Re-read using one main scenario and one scenario that could refute the
219
+ approach. The right criterion is behavior the source must guarantee, provable
220
+ by reasoning on the source; a test/build/validator PASS does not replace that
221
+ logic. When the task is content, the criterion is that the instructions lead
222
+ to the right decision, not that a tool accepts the text.
223
+
224
+ ## Plan file format
225
+
226
+ Each task is one Plan file. The [`pirl-plan` skill](../../.skills/pirl-plan/SKILL.md)
227
+ owns its format: the [template](../../.skills/pirl-plan/assets/plan-template.md)
228
+ with the four sections `What to do`, `How to do it`, `Participating roles` and
229
+ `Required quality gates`, and the [format reference](../../.skills/pirl-plan/references/plan-format.md)
230
+ with the frontmatter fields, file naming and output location. This contract
231
+ owns what those sections must settle.
232
+
233
+ ## Self-review before handoff
234
+
235
+ 1. Check each role's contribution against the request, the source, the approach
236
+ and the QGs. If the Plan is wrong or lacks a mandatory decision, fix the
237
+ content before declaring it ready. For a multi-task package, check separate
238
+ acceptability per the task-splitting section above and confirm every
239
+ package-wide requirement still has an owning task. Confirm each task
240
+ separates implementation roles from verification roles that fit the QGs'
241
+ questions, that no task, step or QG belongs to the user's build/test/release
242
+ stage, that there is no separate QG for capturing layout, and that the test
243
+ part (if any) is limited to FUT. Before declaring the Plan ready, re-read it
244
+ with the following five checks and fix the Plan if anything is wrong:
245
+ - Every claim about the current state (sections, tables, files, behavior,
246
+ languages that exist) has been opened and confirmed at exactly each
247
+ location or language the Plan names; what does not exist yet is recorded in
248
+ the REQ as new.
249
+ - Every table of values or derived numbers with a measurable constraint
250
+ (contrast, luminance, size, limits) has been recalculated value by value
251
+ against each constraint; on a conflict, fix the table or the constraint
252
+ instead of handing over both.
253
+ - A REQ that changes a composite element (label, icon, border, background)
254
+ states which parts are kept, removed or added.
255
+ - FUT commands name only test files that exist, or test files whose name a
256
+ REQ settles for the task to create; when the Plan leaves Implement to choose
257
+ between editing or replacing a unit (for example replacing a hook), refer to
258
+ the test file by that unit ("the test file of the replacement hook")
259
+ instead of naming a file that may no longer exist. `Allowed paths` include
260
+ the shared test setup or configuration files the change needs (for example
261
+ a fake of a browser API the test environment lacks).
262
+ - No step of `How to do it` assigns the implementation role to capture
263
+ layout, measure or run the application, not even a short step like
264
+ "capture layout per the layout verification instructions": the extra viewports, states and properties
265
+ to capture go in the UI QGs and in the implementation role's `Done when`.
266
+ The UI verification role's step only says it runs after the implementation
267
+ role captures.
268
+ 2. Run the Plan validator (command in the
269
+ [`pirl-plan` skill's procedure](../../.skills/pirl-plan/SKILL.md#procedure)) and fix
270
+ structural errors before handoff. The validator only checks the handoff
271
+ input (schema, required fields, roles, dependencies, time zone); it does not
272
+ grade content. The reviewer still has to prove the Plan is right.
273
+ 3. `process-auditor` self-evaluates the Plan run, applies improvements and
274
+ writes the record per the [router](layered-task-execution.instructions.md#self-evaluation-and-improvement).
275
+ Defects of the Plan itself are fixed in the Plan before handoff; instruction
276
+ defects do not turn into new product requirements.
277
+
278
+ ## Saving and handoff
279
+
280
+ - After the final review and self-evaluation, the coordinator and every role
281
+ complete the [temporary-resource cleanup](layered-task-execution.instructions.md#cleaning-up-temporary-resources-before-handoff)
282
+ and check again before declaring the Plan ready. A blocked draft must still
283
+ clean up what is no longer needed; do not hand Plan clutter to Implement.
284
+ - Save each task file where the user says, or by default under the Hub root,
285
+ per the [Plan file format](../../.skills/pirl-plan/references/plan-format.md).
286
+ Do not overwrite history.
287
+ - State clearly whether the Plan has all decisions or still has unsettled
288
+ parts, its path and the self-improvement result per the router's reporting
289
+ section. Do not call a draft with insufficient input ready for Implement.
290
+ - Do not edit product source at Plan. Finish and hand off the specific files
291
+ to the corresponding Implement instruction; do not start the next task on
292
+ your own.
@@ -0,0 +1,236 @@
1
+ ---
2
+ name: "Review Layer Instructions"
3
+ description: "Check the Plan's quality gates by reasoning on the source, without relying on builds/tests, and report Business and Evaluations (assessment of the Implement roles, causes of their issues and improvements applied)."
4
+ applyTo: ".agents/instructions/review.instructions.md"
5
+ metadata:
6
+ id: ".agents/instructions/review"
7
+ kind: "instruction"
8
+ version: "2.0.4"
9
+ status: "active"
10
+ ---
11
+
12
+ # Review Layer Instructions
13
+
14
+ Apply the Review process only when the request and the [router](layered-task-execution.instructions.md)
15
+ have selected this layer. Reading or updating a Plan/report file does not
16
+ activate another layer.
17
+
18
+ This contract owns the decisions and the exit conditions of a Review against a
19
+ Plan; the run is carried out through the
20
+ [`pirl-review` skill](../../.skills/pirl-review/SKILL.md), which owns the run procedure,
21
+ the report template, its presentation rules, its location and the helper
22
+ script. Review must distinguish a wrong product, insufficient evidence and
23
+ instructions that led an agent to a wrong decision.
24
+ Use exactly the two sections `Business` and `Evaluations`; keep IDs, symbols,
25
+ role names and paths verbatim, and explain in plain English.
26
+
27
+ ## AI Agent roles at the Review layer
28
+
29
+ The role catalog lives in the [standalone and maintenance instructions](standalone-and-maintenance.instructions.md#role-catalog) and the
30
+ assignment principles in the [router](layered-task-execution.instructions.md#assignment-principles);
31
+ each role's expertise lives in the role file linked in the table.
32
+ Review picks `review_roles` from the table below using the "Select when"
33
+ column, in the table's order: the first four roles are the default, and
34
+ `ux-designer` is added when the diff changes the UI. Each role applies its own
35
+ expertise to specific QGs/boundaries; do not force every role to find a defect.
36
+
37
+ | Role | Select when | Responsibility at Review | Done when |
38
+ | --- | --- | --- | --- |
39
+ | [`code-analyst`](../roles/code-analyst.role.md) | Default | Trace the entrypoint, callers, writers/readers and configuration to the final state of each QG | QG conclusions with the path traced and sources |
40
+ | [`code-reviewer`](../roles/code-reviewer.role.md) | Default | Challenge the diff: bugs, regressions, permissions and security, inconsistency, guards/error handling, tests that violate FUT | Each suspicion is proven as a FIND or refuted with sources |
41
+ | [`business-analyst`](../roles/business-analyst.role.md) | Default | Check the REQs and the QGs' `Required logic` against the source's behavior; block self-invented criteria | Each QG has `PASS\|FAIL\|BLOCKED` true to its REQ |
42
+ | [`solution-architect`](../roles/solution-architect.role.md) | Default | Consider whether contracts, ownership, task boundaries and dependencies are broken | Names the affected QGs or confirms there is no impact |
43
+ | [`ux-designer`](../roles/ux-designer.role.md) | The diff changes the UI | Read Implement's `layout_verification` and screenshots and check them against the UI QGs | Each UI QG has a conclusion with the screenshots and source checked |
44
+ | [`process-auditor`](../roles/process-auditor.role.md) | Every Review round; not recorded in `review_roles` | Re-evaluate the Implement roles (Evaluations section) and self-evaluate the Review run per the [router](layered-task-execution.instructions.md#self-evaluation-and-improvement) | Evaluations cover the Implement team; record written; improvements applied or summarized for the user |
45
+
46
+ - Settle disagreements by the source and merge suspicions with the same cause;
47
+ do not vote. Delegate each role in `review_roles` per the
48
+ [assignment principles](layered-task-execution.instructions.md#assignment-principles). The report records
49
+ how each role was performed (a separate agent, or self-performed with the
50
+ reason) and the actual level of independence when a role has read the run's
51
+ drafts or conclusions or has consulted a reviewer outside the role team.
52
+ - For each Implement record, assign one evaluation owner and cross-check when
53
+ there is a suspicion.
54
+
55
+ ## Inputs and permissions
56
+
57
+ - Read exactly the `pirl-plan/v1` Plan, the Implementation Record, the
58
+ source/diff of the assigned run and any earlier report for the same task.
59
+ Identify the snapshot before concluding and read it per the
60
+ [Shared snapshots and older records section](layered-task-execution.instructions.md#shared-snapshots-and-older-records)
61
+ of the router.
62
+ - Conclude each QG on the final source; when several tasks share a snapshot,
63
+ record the shared snapshot in `implementation_target`. A mismatch with an
64
+ earlier task's QG that belongs to a later task, in the order rebuilt per the
65
+ router, is not a FAIL of the earlier task and is not counted against the
66
+ earlier task's Implement roles; if it lies outside the later task's REQs, it
67
+ is a FIND of the later task. An unowned change is not a FIND of any task: if
68
+ it breaks a QG of the task under review, record that QG `BLOCKED` with an
69
+ `escalate` BLOCK because there is no owner to assign a `repair` to; otherwise
70
+ state it in `implementation_target` and `Next`.
71
+ - A Plan with `Confirmed change` annotations is the current Plan: conclude the
72
+ QGs against it, after finding the trace of each annotation per the
73
+ [Implement rule](implement.instructions.md#changes-to-the-plan-confirmed-by-the-user):
74
+ the `plan_amendments` field of the Implementation Record, or the record of the
75
+ Plan run for the same task whose `record_id` the annotation states. An
76
+ annotation without any trace, or whose trace does not state the user's
77
+ confirmation of that change, is not a baseline: conclude the QGs against the
78
+ value before the change and record an `escalate` BLOCK for the user to confirm.
79
+ - Product source, tests, config, the Plan and the Implementation Record are
80
+ read-only inputs. Review writes this run's report; framework files are edited
81
+ only by `process-auditor` per the [router](layered-task-execution.instructions.md#self-evaluation-and-improvement).
82
+ Do not edit the product, the Plan or the Implementation Record.
83
+
84
+ ## Business: prove or refute each suspicion
85
+
86
+ 1. Take the QGs and `Required logic` verbatim from the Plan. The REQs and the
87
+ user's decisions explain the criteria; rubrics, reviewer preferences and
88
+ instruction defects do not create new product criteria.
89
+ Check against the [Plan's task boundaries](plan.instructions.md#splitting-tasks-for-separate-implementation-and-acceptance):
90
+ do not use another task's integration criteria as a PASS condition of the
91
+ task under review. If a QG itself needs work assigned to a later/parallel
92
+ task, record that QG `BLOCKED` and create an `escalate` BLOCK back to Plan to
93
+ fix the assignment/QG; do not assign `repair`/`retry` to the same task just
94
+ to wait for that work. Do not drop the QG or record PASS yourself; still
95
+ evaluate independent implementation defects that have enough evidence.
96
+ 2. Trace the entrypoint, callers, guards, writers/readers, configuration and
97
+ failure branches that can occur. Confirm the trigger is within the usage
98
+ contract. An internal function that does not validate data does not prove
99
+ the whole system lacks validation.
100
+ 3. For a suspicion, connect trigger → mechanism → consequence → violated QG.
101
+ Actively look for refuting sources, including deliberate invariants.
102
+ Severity must rest on impact and on whether the failure path is reachable;
103
+ a name, a regex or a code fragment is not enough to prove a deadlock, data
104
+ loss or a Critical defect.
105
+ 4. Conclude QGs by reasoning on the source per the
106
+ [router](layered-task-execution.instructions.md#verification-by-reasoning):
107
+ Review does not build, does not create/run tests, scripts, mocks or the
108
+ application, and does not use test/build results, including results written
109
+ in the Implementation Record, as a baseline or PASS/FAIL evidence. When the
110
+ diff changes the UI, read the `layout_verification` and screenshots that
111
+ Implement captured per
112
+ [layout verification with mocks](layout-verification.instructions.md)
113
+ as a source for UI QGs, without capturing again. A green test does not prove
114
+ the business logic is right, and a red test does not prove the product is
115
+ wrong. A counterexample is an input and call path traceable on the source,
116
+ valid only if it can occur within the QG's scope.
117
+ 5. Keep only well-grounded conclusions:
118
+ - `FIND`: a real bug that violates a QG, with trigger, source, cause and impact.
119
+ - `RISK`: a grounded risk mechanism while the QG still holds; record the
120
+ limit, owner and revisit condition. A risk does not require a fix or
121
+ block a business PASS.
122
+ - `BLOCK`: missing sources, conditions or decisions needed to conclude a
123
+ QG; state the missing evidence, who provides it and the action to continue.
124
+ A refuted suspicion is removed from the findings, not relabeled as a risk to
125
+ keep it. Missing tests, not having built/run, or red/green test results are
126
+ not by themselves a FIND, RISK or BLOCK; do not ask for more tests, builds or
127
+ releases. Conversely, tests in the diff that violate the
128
+ [FUT rule](layered-task-execution.instructions.md#functional-tests-fut-rule)
129
+ (not traceable to a REQ/specification, outside the functionality under
130
+ development and the affected functionality, redundant duplicates, assertions
131
+ contrary to the specification or that block a correct result) are a
132
+ `repair` FIND; its QG field records `FUT` with the related REQ. A diff that
133
+ changes the UI while the Implementation Record lacks `layout_verification`,
134
+ or screenshots showing a layout that violates a QG, is also a `repair` FIND
135
+ for the implementation role that owns the UI.
136
+ 6. Give instructions by the mechanism to fix, file/symbol, order and the
137
+ outcome to preserve; instructions cover editing source, documentation or
138
+ tests under FUT; do not assign builds or running tests outside FUT.
139
+ A FIND within the Plan's scope uses `repair`; if it changes settled
140
+ behavior, paths or decisions, use `replan`. While any `replan` remains,
141
+ leave `repair_roles` empty and hand off to Plan. If the fix stays within
142
+ scope, the repair team is exactly the implementation roles accountable for
143
+ `repair` FINDs and `retry` BLOCKs, in handoff order.
144
+ RISKs are deferred: `Instructions` and `Revisit when` name the task and layer
145
+ that will handle them or the work the user needs to assign; while there is no
146
+ owning task, do not write "a later run" or "the next edit of <file>", and
147
+ instructions for another task to handle name that task. `escalate` BLOCKs
148
+ move to another owner. Assign `retry` only when there is a new
149
+ action/condition; do not open another round for the same blocker.
150
+ 7. Record QG `PASS|FAIL|BLOCKED`. Business is `FAIL` when a QG has failed or
151
+ there is a `FUT` FIND; if nothing failed but mandatory grounds are missing,
152
+ it is `BLOCKED`; otherwise `PASS`. Risks and instruction defects alone do not
153
+ reverse this conclusion.
154
+
155
+ ## Evaluations: assessing Implement roles
156
+
157
+ This section answers: did each role of the reviewed Implement run do its
158
+ assigned part correctly, and if not, what was the root cause and where was the
159
+ framework improved. The Review's `process-auditor` carries out this section
160
+ together with the Review run's self-evaluation, per the
161
+ [router](layered-task-execution.instructions.md#self-evaluation-and-improvement).
162
+ Review also knows the FINDs that the Implement run missed, so this evaluation
163
+ has more evidence than Implement's own self-evaluation.
164
+
165
+ 1. Find the record of the reviewed Implement run with
166
+ `python -B .agents/evals/layer_record.py query --layer implement --plan-set <plan-set> --task <task-id>`.
167
+ In the result, pick the latest record whose `roles` list contains the
168
+ Implement roles to evaluate and write it into the Review record's `evaluates`.
169
+ A record that only applies improvements or corrections (`supersedes` set,
170
+ `roles` containing only `coordinator`) is not the evaluated record; mention it
171
+ in the EVAL's Evidence field. A correction record that carries all the roles
172
+ is itself the evaluated record.
173
+ 2. Create one EVAL for each role in `effective_implementation_roles`, then each
174
+ verification role of the Plan, in the Implementation Record's order. Evaluate
175
+ against the work, information and instructions actually assigned; do not
176
+ fail the whole team over one bug. A verification role is evaluated on its QG
177
+ conclusions: whether its reasoning stands against the source, whether it
178
+ missed FINDs that Review found, whether it relied on run results instead of
179
+ reasoning.
180
+ 3. Each issue of an Implement role is classified by cause and improved per the
181
+ [self-evaluation instructions](self-evaluation.instructions.md#issues-and-causes),
182
+ recorded in the Review record with `record` set to the record in
183
+ `evaluates`; the issue is attributed to the task and run that produced it per
184
+ the [Shared snapshots and older records section](layered-task-execution.instructions.md#shared-snapshots-and-older-records)
185
+ of the router. The EVAL records the cause, the `issue_key` and where it was
186
+ fixed, or that it is pending the user.
187
+ 4. Do not invent issues. Role or instruction issues do not lower the Business
188
+ verdict and do not block handing off a delivery that already qualifies; if
189
+ the report itself is wrong, fix the report before settling it.
190
+
191
+ ## Report and rounds
192
+
193
+ Each Review round writes one `pirl-review/v1` report, built from the `review`
194
+ skill's [template](../../.skills/pirl-review/assets/review-template.md) and saved
195
+ where the user says, or by default under the Hub root, per the
196
+ [report format](../../.skills/pirl-review/references/review-format.md). The first
197
+ round has `prior_review: null`; later rounds reference the report immediately
198
+ before.
199
+ A request for additional phases or evidence for the same implementation run
200
+ belongs to the current Review round: update that report and keep
201
+ `review_round` and `prior_review`. Do not increment the round just because of
202
+ a message, the time of verification or an extra investigation scope. Open a new
203
+ round when assigned to review the next implementation/repair run or when the
204
+ user explicitly asks for an independent round. When editing a settled report,
205
+ record the reason for the edit in the report and leave the other rounds intact.
206
+
207
+ ## Finishing and next permissions
208
+
209
+ Run the report validator (command in the
210
+ [`pirl-review` skill's procedure](../../.skills/pirl-review/SKILL.md#procedure)) and fix
211
+ structural errors before the final response.
212
+
213
+ The coordinator and every Review role carry out the
214
+ [temporary-resource cleanup](layered-task-execution.instructions.md#cleaning-up-temporary-resources-before-handoff)
215
+ after the final verification, self-evaluation and record writing, then check
216
+ again before the final response. The rule applies even when Business is FAIL or
217
+ the Review is blocked; do not claim completion just because the report and
218
+ validator pass.
219
+
220
+ `verdict` equals `business_verdict`. `status: completed` means the evaluation
221
+ is complete: Business has a well-grounded conclusion, Evaluations cover the
222
+ Implement team, the Review record is written, and temporary resources have been
223
+ cleaned up and checked again under the shared contract.
224
+ A Business FAIL can still be a completed Review. Missing input needed for the
225
+ evaluation uses `status: blocked`.
226
+
227
+ If the Implementation Record or the implementation run's input is missing,
228
+ keep a two-part draft with exactly the missing input. A draft that does not
229
+ meet the contract cannot be used as a source for assigning product repairs.
230
+ Complete it directly on the draft when the input arrives; do not open a round
231
+ just to fill in missing information.
232
+
233
+ Report the Business result, the level of evaluation completion, the
234
+ self-improvement result per the router's reporting section and links to the
235
+ report/Plan. Finish at handoff; do not implement the product, pick the next
236
+ task or open a new Review round on your own.