@nklisch/pi-agile-workflow 0.15.3 → 0.16.3

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 (41) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +8 -0
  4. package/docs/ARCHITECTURE.md +117 -65
  5. package/docs/PRINCIPLES.md +84 -18
  6. package/docs/SPEC.md +70 -2
  7. package/docs/VISION.md +33 -12
  8. package/hooks/scripts/prompt-context.py +7 -1
  9. package/hooks/scripts/test_prompt_context.py +16 -0
  10. package/package.json +1 -1
  11. package/scripts/tests/convert-content-integrity.test.sh +4 -4
  12. package/scripts/tests/convert-review-weight.test.sh +61 -0
  13. package/scripts/work-view.sh +1 -1
  14. package/skills/autopilot/SKILL.md +138 -91
  15. package/skills/convert/SKILL.md +55 -11
  16. package/skills/epic-design/SKILL.md +37 -70
  17. package/skills/feature-design/SKILL.md +52 -68
  18. package/skills/fix/SKILL.md +52 -34
  19. package/skills/gate-cruft/SKILL.md +69 -24
  20. package/skills/gate-docs/SKILL.md +12 -5
  21. package/skills/gate-patterns/SKILL.md +7 -3
  22. package/skills/gate-refactor/SKILL.md +18 -6
  23. package/skills/gate-security/SKILL.md +16 -7
  24. package/skills/gate-tests/SKILL.md +86 -71
  25. package/skills/implement/SKILL.md +79 -58
  26. package/skills/implement-orchestrator/SKILL.md +274 -587
  27. package/skills/perf-design/SKILL.md +11 -12
  28. package/skills/principles/SKILL.md +175 -379
  29. package/skills/principles/references/advisory-review.md +76 -0
  30. package/skills/principles/references/code-design.md +164 -0
  31. package/skills/principles/references/models.md +42 -63
  32. package/skills/prose-author/SKILL.md +9 -4
  33. package/skills/refactor-design/SKILL.md +26 -17
  34. package/skills/review/SKILL.md +169 -64
  35. package/skills/review/references/substrate-side-effects.md +17 -10
  36. package/skills/scope/SKILL.md +20 -7
  37. package/work-view/crates/cli/.work-view-version +1 -1
  38. package/work-view/dist/aarch64-apple-darwin/work-view +0 -0
  39. package/work-view/dist/aarch64-unknown-linux-musl/work-view +0 -0
  40. package/work-view/dist/x86_64-apple-darwin/work-view +0 -0
  41. package/work-view/dist/x86_64-unknown-linux-musl/work-view +0 -0
@@ -1,8 +1,9 @@
1
1
  ---
2
2
  name: principles
3
3
  description: >
4
- agile-workflow principles — code-design (Ports & Adapters, Single Source of Truth, Generated
5
- Contracts, Fail Fast) and substrate-execution (Item-IS-the-Work, Rolling-Foundation, Late-Binding).
4
+ agile-workflow principles — code-design (clear boundaries, proportional rigor, code economy,
5
+ useful tests, and continuous simplification) and substrate-execution (Item-IS-the-Work,
6
+ Rolling-Foundation, Late-Binding).
6
7
  Auto-loads when designing modules, defining interfaces, writing or implementing code, scoping work
7
8
  in the substrate, advancing stages, scoping releases, or any time the agile-workflow
8
9
  design/implement/review skills are active.
@@ -23,209 +24,56 @@ Each principle has guidance for design time and implementation time.
23
24
 
24
25
  # Part I — Code-Design Principles
25
26
 
26
- ## 1. Ports & Adapters
27
-
28
- Core domain logic must not depend on infrastructure. Infrastructure depends on the domain.
29
-
30
- **Ports** are interfaces defined in the domain layer that describe what the domain needs (a database, a file store, an HTTP client, a clock). **Adapters** are infrastructure implementations of those interfaces.
31
-
32
- ### At design time
33
-
34
- - Identify every external dependency the feature touches (DB, filesystem, HTTP, queues, time, randomness)
35
- - Define an interface (port) for each one in the domain layer
36
- - Infrastructure modules implement those interfaces
37
- - The domain function signature takes the port as a parameter or receives it via dependency injection — it never imports the adapter directly
38
-
39
- **Example structure:**
40
- ```
41
- src/
42
- domain/
43
- user.ts # core logic — imports only domain types and ports
44
- ports.ts # UserRepository interface, EmailSender interface
45
- infrastructure/
46
- db/user-repo.ts # implements UserRepository using Drizzle
47
- email/smtp.ts # implements EmailSender using nodemailer
48
- app/
49
- wire.ts # assembles: new UserService(new DbUserRepo(), new SmtpEmailSender())
50
- ```
51
-
52
- **Design checklist:**
53
- - [ ] Every external dependency has an interface in the domain layer
54
- - [ ] No `import { db }` or `import { fs }` in domain modules
55
- - [ ] Infrastructure modules are only referenced in composition roots (wire-up / entry points)
56
-
57
- ### At implementation time
58
-
59
- When implementing domain logic, enforce the boundary: domain code receives infrastructure as a typed parameter, never imports it directly.
60
-
61
- **Good:**
62
- ```typescript
63
- // domain/user-service.ts
64
- export function createUser(repo: UserRepository, email: string): Promise<User> {
65
- return repo.insert({ email })
66
- }
67
-
68
- // app/wire.ts (entry point)
69
- import { createUser } from '../domain/user-service'
70
- import { DrizzleUserRepo } from '../infrastructure/db/user-repo'
71
- const repo = new DrizzleUserRepo(db)
72
- app.post('/users', (c) => createUser(repo, c.req.body.email))
73
- ```
74
-
75
- **Bad:**
76
- ```typescript
77
- // domain/user-service.ts
78
- import { db } from '../infrastructure/db' // NEVER — domain imports infra
79
-
80
- export function createUser(email: string) {
81
- return db.insert(users).values({ email })
82
- }
83
- ```
84
-
85
- If you find yourself needing to import infrastructure into domain, that's the signal to add a port interface instead.
86
-
87
- ---
88
-
89
- ## 2. Single Source of Truth (Data-Driven Extensibility)
90
-
91
- When a concept can have multiple variants that may grow over time (roles, statuses, event types, providers, feature flags), define that set of variants **once** as a data structure. All logic — types, validation, routing, display — derives from that single definition.
92
-
93
- ### At design time
27
+ These principles stay active during design and implementation. Load
28
+ [references/code-design.md](references/code-design.md) when concrete mechanics,
29
+ checklists, or examples are needed.
94
30
 
95
- - Identify enumerations that classes of things fall into
96
- - Design a central registry: a typed constant, a config map, or a schema object
97
- - Derive all downstream types and logic from that registry rather than re-enumerating variants in each consumer
98
-
99
- **Example structure:**
100
- ```typescript
101
- // Defined once
102
- const ROLES = ['admin', 'editor', 'viewer'] as const
103
- type Role = typeof ROLES[number]
104
-
105
- // Or richer: a config map where behavior flows from data
106
- const ROLE_CONFIG = {
107
- admin: { level: 2, label: 'Admin' },
108
- editor: { level: 1, label: 'Editor' },
109
- viewer: { level: 0, label: 'Viewer' },
110
- } satisfies Record<string, RoleConfig>
111
- type Role = keyof typeof ROLE_CONFIG
112
- ```
113
-
114
- **Design checklist:**
115
- - [ ] Extensible sets of variants are defined as a single authoritative constant/schema
116
- - [ ] Downstream types are derived from the registry (not duplicated)
117
- - [ ] Adding a new variant requires changing only the registry definition
31
+ ## 1. Ports & Adapters
118
32
 
119
- ### At implementation time
33
+ Domain logic stays independent of databases, filesystems, HTTP, time,
34
+ randomness, and other infrastructure. The domain defines the ports it needs;
35
+ adapters implement them, and composition roots wire the two together.
120
36
 
121
- Implement extensible variant sets as a single typed constant. Derive all downstream behavior from it — do not re-enumerate variants in switch statements, conditionals, or validation schemas.
122
-
123
- **Good:**
124
- ```typescript
125
- const ROLE_CONFIG = {
126
- admin: { level: 2, canDelete: true },
127
- editor: { level: 1, canDelete: false },
128
- viewer: { level: 0, canDelete: false },
129
- } as const satisfies Record<string, RoleConfig>
130
-
131
- type Role = keyof typeof ROLE_CONFIG
132
- const ROLES = Object.keys(ROLE_CONFIG) as Role[]
133
- const RoleSchema = z.enum(ROLES as [Role, ...Role[]])
134
-
135
- // Adding 'owner' role = one change, in one place
136
- ```
137
-
138
- **Bad:**
139
- ```typescript
140
- type Role = 'admin' | 'editor' | 'viewer' // defined here
141
- const roles = ['admin', 'editor', 'viewer'] // re-enumerated here
142
- const RoleSchema = z.enum(['admin', 'editor', 'viewer']) // again here
143
- switch (role) {
144
- case 'admin': ... // and again here
145
- case 'editor': ...
146
- case 'viewer': ...
147
- }
148
- ```
37
+ ## 2. Single Source of Truth
149
38
 
150
- ---
39
+ Growing variant sets have one authoritative typed registry. Types, validation,
40
+ routing, and display derive from it rather than re-enumerating the variants.
151
41
 
152
42
  ## 3. Generated Contracts
153
43
 
154
- When designing a boundary between two systems (client/server, package/consumer, service/service), prefer generating the contract from the source of truth rather than hand-authoring both sides.
155
-
156
- ### At design time
157
-
158
- **Common approaches by boundary type:**
159
- - **HTTP API → client**: OpenAPI schema → generated client types (openapi-typescript, orval)
160
- - **tRPC router → client**: router type is the contract, shared directly
161
- - **Database schema → app types**: Drizzle/Prisma inferred types, not hand-written interfaces
162
- - **GraphQL schema → types**: codegen from SDL
44
+ Boundary types derive from the schema, router, database model, or a generation
45
+ step. Consumers import or infer that contract instead of maintaining hand-written
46
+ copies.
163
47
 
164
- - Identify every cross-boundary interface in the feature
165
- - For each one, choose a single source of truth (schema file, router definition, DB schema)
166
- - Design the generation step into the build pipeline — not a manual step
167
- - Consumers import generated types, not hand-written duplicates
48
+ ## 4. Fail Fast—Where It Matters
168
49
 
169
- **Design checklist:**
170
- - [ ] Every client-facing contract has a designated source of truth
171
- - [ ] A generation step is identified (codegen tool, shared type import, inferred type)
172
- - [ ] No hand-written types that mirror types defined elsewhere
50
+ Validate untrusted input and required external contracts at system boundaries.
51
+ Add internal checks only when the project's actual risks justify them. Do not
52
+ manufacture exhaustive invariants, edge handling, determinism, or defensive
53
+ layers that the product's scope and consequences do not need.
173
54
 
174
- ### At implementation time
55
+ ## 5. Code Economy
175
56
 
176
- Do not hand-write types that are derivable from a schema, router, or database definition. Import or generate them.
57
+ Short, direct code is a virtue when it stays clear. Prefer fewer concepts,
58
+ layers, branches, options, and lines over speculative generality. Match rigor to
59
+ the project's context rather than engineering every codebase as critical
60
+ infrastructure.
177
61
 
178
- **Good:**
179
- ```typescript
180
- import type { AppRouter } from '../../server/router'
181
- // type-safe from the source
62
+ ## 6. Tests Earn Their Keep
182
63
 
183
- const { data } = useQuery<InferSelectModel<typeof users>>( ... )
184
- ```
64
+ Test stable interfaces, important behavior, and regressions learned from real
65
+ bugs. Unit-test genuinely complex units, not every wrapper, branch, or line.
66
+ Tests are maintained code: remove duplicate, tautological, implementation-bound,
67
+ or otherwise low-value tests when their upkeep exceeds the confidence they add.
185
68
 
186
- **Bad:**
187
- ```typescript
188
- // Hand-written duplicate of what Drizzle already knows
189
- interface User {
190
- id: number
191
- email: string
192
- createdAt: Date
193
- }
194
- ```
69
+ ## 7. Leave It Simpler
195
70
 
196
- If a generated type needs extending, use `type MyType = GeneratedType & { extra: string }` — extend the source of truth, don't replace it.
197
-
198
- ---
199
-
200
- ## 4. Fail Fast (implementation only)
201
-
202
- Catch bad data at the door, not three calls deep where the stack trace is useless. Validate inputs at the entry point of every function or system boundary.
203
-
204
- - At system boundaries (HTTP handlers, CLI args, external API responses, config files): parse with Zod or equivalent before any logic runs
205
- - At internal function boundaries: assert preconditions at the top of the function — guard clauses, not nested ifs
206
- - Prefer `throw`/`return early` over propagating bad state deep into call chains
207
- - Errors should be loud and specific at the point of violation — "expected positive number, got -3" beats a cryptic null reference five layers down
208
-
209
- **Good:**
210
- ```typescript
211
- function processOrder(input: unknown) {
212
- const order = OrderSchema.parse(input) // throws immediately if invalid
213
- return computeTotal(order)
214
- }
215
-
216
- function applyDiscount(order: Order, pct: number) {
217
- if (pct < 0 || pct > 1) throw new Error(`Invalid discount: ${pct}`)
218
- // ... rest of logic
219
- }
220
- ```
221
-
222
- **Bad:**
223
- ```typescript
224
- function processOrder(input: any) {
225
- // passes raw input through, blows up 5 calls deep
226
- return computeTotal(input)
227
- }
228
- ```
71
+ Exploration, design, and implementation include an elimination pass. In the
72
+ area being touched, look for code, tests, checks, abstractions, compatibility
73
+ paths, and complexity that the feature can make unnecessary. Fold safe,
74
+ cohesive cleanup into the work or create explicit cleanup/refactor stories;
75
+ park broader opportunities. Question whole systems when warranted, but ask the
76
+ user before removing behavior, guarantees, validation, compatibility, or safety.
229
77
 
230
78
  ---
231
79
 
@@ -237,7 +85,7 @@ dispatch. The agent applies these whenever operating on `.work/` or `docs/`,
237
85
  and whenever choosing discovery or implementation dispatch during substrate
238
86
  work.
239
87
 
240
- ## 5. Item-IS-the-Work
88
+ ## 8. Item-IS-the-Work
241
89
 
242
90
  The unit of work is its file. The brief, the design, the implementation notes, and the review findings all accumulate in the item's body as stages advance. Reading the file IS reading the state of the work.
243
91
 
@@ -277,7 +125,7 @@ The unit of work is its file. The brief, the design, the implementation notes, a
277
125
 
278
126
  ---
279
127
 
280
- ## 6. Rolling-Foundation
128
+ ## 9. Rolling-Foundation
281
129
 
282
130
  Foundation docs (`docs/VISION.md`, `docs/SPEC.md`, `docs/ARCHITECTURE.md`, and any others) describe the project's vision (future-looking) and current intent — what is true now, OR what will be true once in-flight design lands. They roll forward in place as either evolves. No legacy comments. Git carries history; the doc carries truth.
283
131
 
@@ -329,7 +177,7 @@ The discipline is identical in both styles: replace stale assertions in place, n
329
177
 
330
178
  ---
331
179
 
332
- ## 7. Late-Binding
180
+ ## 10. Late-Binding
333
181
 
334
182
  Items advance stages when work actually completes. Releases bind items only when the user cuts a version. Foundation docs are not pre-decided into a phase plan. Work happens, then commitments crystallize — not the other way around.
335
183
 
@@ -369,7 +217,7 @@ Items advance stages when work actually completes. Releases bind items only when
369
217
 
370
218
  ---
371
219
 
372
- ## 8. Agent Dispatch Economy
220
+ ## 11. Agent Dispatch Economy
373
221
 
374
222
  Sub-agents are for breadth, isolation, independent judgment, or parallel
375
223
  implementation with clear write ownership. They are not a replacement for
@@ -420,43 +268,37 @@ auditable later.
420
268
 
421
269
  ---
422
270
 
423
- # Part III — Caller Awareness
271
+ # Part III — Caller Awareness and Question Policy
424
272
 
425
- **The rule:** If an active agile-workflow autopilot run or harness goal is
426
- driving this skill, no structured question tool and no halts on ordinary ambiguity.
427
- Resolve with judgment and log the rationale in the item body. Otherwise,
428
- asking the user is fine and often helpful.
273
+ **The normal rule is consequence-based, not mode-based.** Resolve routine,
274
+ reversible decisions with judgment and record the rationale in the item body.
275
+ Use the structured question tool only when the answer sets product direction,
276
+ materially changes user-facing behavior or an external contract, or commits the
277
+ project to an expensive choice that is difficult to reverse. Existing `## Design decisions` and foundation
278
+ docs are inputs; do not re-ask what they already settle.
429
279
 
430
- This is binary and detectable. Autopilot mode is on when the current skill was
431
- delegated by an explicit autopilot invocation, an active autopilot harness goal,
432
- or a prompt that clearly says it is continuing/draining an autopilot scope.
433
- Autopilot includes a caller note when delegating work; treat that note as the
434
- strongest signal. If no active autopilot driver exists, you are interactive.
280
+ Interactive mode permits those strategic questions. An active autopilot driver
281
+ never asks them: use available evidence and choose the least irreversible sound
282
+ option, logging the decision. Ordinary ambiguity must not halt the queue.
283
+
284
+ Autopilot mode is binary and detectable. It is on when this skill was delegated
285
+ by an explicit autopilot invocation, an active autopilot harness goal, or a
286
+ prompt clearly continuing/draining that scope. An autopilot caller note is the
287
+ strongest signal. If no active driver exists, the invocation is interactive.
435
288
 
436
289
  ## What does NOT count as autopilot
437
290
 
438
- Judgment-mode is triggered only by an active autopilot driver. In particular:
439
-
440
- - **General harness "auto mode"** — a reminder to work without unnecessary
441
- clarification does **not** suppress `structured question tool` inside these skills.
442
- It shapes default conversational tone; it does not mean an autopilot queue
443
- goal is active.
444
- - **A user saying "just decide" earlier in the conversation** — that applies
445
- to whatever was being discussed at the time, not to a later explicit skill
446
- invocation.
447
- - **A previous autopilot run that has already ended** autopilot mode lasts
448
- only while autopilot itself is the active driver of the queue. Once the goal
449
- completes, blocks, or is interrupted, subsequent direct skill invocations are
450
- interactive again.
451
-
452
- When a user types `/agile-workflow:feature-design <id>` (or any other
453
- design/implement/review skill) directly, they want a collaborator at the
454
- checkpoints. Use `structured question tool` unless the direct prompt also makes clear it
455
- is part of an active autopilot goal.
456
-
457
- The disambiguation test: *"Is an active autopilot queue goal currently driving
458
- this skill?"* If you cannot point to that active driver or caller note, you are
459
- interactive.
291
+ - **General harness "auto mode"** a reminder to work autonomously changes
292
+ conversational posture, but does not create an autopilot queue goal.
293
+ - **An earlier "just decide" instruction** — it applies to that decision, not a
294
+ later explicit skill invocation.
295
+ - **A completed, blocked, or interrupted autopilot run** later direct skill
296
+ invocations are interactive again.
297
+
298
+ A direct `/agile-workflow:feature-design <id>` (or other design, implement, or
299
+ review skill) is interactive unless its prompt clearly belongs to an active
300
+ autopilot driver. The disambiguation test is: *"Can I point to the active
301
+ autopilot goal or caller note driving this invocation?"*
460
302
 
461
303
  ## What still warrants a hard halt (autopilot or not)
462
304
 
@@ -465,171 +307,120 @@ interactive.
465
307
  - `depends_on` cycle detected when writing items
466
308
  - Genuinely contradictory state the skill cannot recover from
467
309
 
468
- Everything else should resolve via judgment under autopilot. When in doubt,
469
- prefer the simpler option and log the rationale in the item body so the user
470
- can review later.
310
+ Everything else resolves through evidence and judgment under autopilot. Prefer
311
+ the simpler, more reversible option and log why.
471
312
 
472
313
  ## Worked examples (autopilot mode)
473
314
 
474
315
  | Situation | Judgment-mode action |
475
316
  |---|---|
476
- | Two architectural options both look valid | Pick the one with fewer moving parts; log "Chose X over Y because: simpler surface" |
477
- | Brief is vague, several plausible interpretations | Pick the one most consistent with foundation docs; log under `## Design decisions` |
478
- | Multiple candidate items at a stage and no id was passed | Pick most recent by `updated:`; the next iteration picks the next |
479
- | Wrong-tag invocation routed to you by mistake | Log a misroute note in the body; return without advancing |
480
- | Empty diff during review after trying ranges | Advance to `done` with a "No diff found" note; don't block the queue |
481
- | Item at unexpected stage | Use judgment about what transition makes sense; log it |
317
+ | Two architectural options both look valid | Pick the one with fewer moving parts; log the rationale. |
318
+ | Brief is vague, several plausible interpretations | Pick the one most consistent with foundation docs; log under `## Design decisions`. |
319
+ | Multiple candidate items at a stage and no id was passed | Pick most recent by `updated:`; the next iteration picks the next. |
320
+ | Wrong-tag invocation routed to you by mistake | Log a misroute note; return without advancing. |
321
+ | Empty diff during review after trying ranges | Advance to `done` with a "No diff found" note. |
322
+ | Item at unexpected stage | Choose the recoverable transition and log it. |
482
323
 
483
- ## How to phrase decision points
324
+ ## Explicit alignment mode
484
325
 
485
- > If an active autopilot run or goal is driving this skill, <judgment-mode
486
- > behavior>. Otherwise, ask the user via structured question tool.
487
-
488
- Not "halt and tell the user." The first form supports both modes; the second
489
- silently kills autopilot.
326
+ `--only-questions` is unchanged: it is an explicit, interactive-only alignment
327
+ pass that captures answers under `## Design decisions`, does not design, and
328
+ does not advance stage. Refuse it when autopilot is the active driver. Inside
329
+ that mode, surface the target's meaningful strategic ambiguities even when a
330
+ normal design pass would resolve a reversible point autonomously.
490
331
 
491
332
  ## Skills this applies to
492
333
 
493
- Autopilot delegates to: `feature-design`, `epic-design`, `refactor-design`,
494
- `perf-design`, `implement`, `implement-orchestrator`, `review` plus, for
495
- `[research]`-tagged items, the cross-plugin
496
- `agentic-research:research-orchestrator` (inert without that plugin; the item
497
- then routes as a plain feature). Every one of those needs caller-aware
498
- decision points.
499
-
500
- User-invocable-only skills (`convert`, `epicize`, `ideate`, `bold-refactor`,
501
- `release-deploy`) can stay interactive-first — autopilot doesn't call them.
334
+ This policy governs `feature-design`, `epic-design`, `refactor-design`,
335
+ `perf-design`, `implement`, `implement-orchestrator`, and `review`, plus the
336
+ cross-plugin research orchestrator when routed from autopilot. Interactive-only
337
+ skills may remain workshop-oriented, but should still avoid questions whose
338
+ answers are routine and reversible.
502
339
 
503
340
  ---
504
341
 
505
- # Part IV — Cross-Model Advisory Review
506
-
507
- Cross-model review is an advisory signal, not a stage transition. The policy
508
- below is written in **role and capability** terms so it holds as model
509
- generations change. For the concrete model-to-capability mapping, the
510
- host→peer pairing table, and the exact `peeragent` flags, load
511
- [references/models.md](references/models.md) that is the single source of
512
- truth for which models fill each role.
513
-
514
- Cross-model review is used only when a **different model class** is available
515
- through an installed peer mechanism such as `peeragent:peer` /
516
- `peeragent:peer-review`, or through a host sub-agent spawn where the caller can
517
- select a different model/provider for the reviewer. The value of a peer is
518
- **independent blind spots**, not a more authoritative answer, so the reviewer
519
- must be a different class than the host before you label the pass cross-model. If
520
- `peeragent` would use the same model class, do not use `peer` or `peer-review`;
521
- instead spawn a **fresh generic sub-agent at the strongest appropriate model
522
- available to the host**, prompted with the reviewer posture from
523
- [references/subagents.md](references/subagents.md) — never review inline in the
524
- host's own context, which is anchored on the work it just produced. Label the
525
- pass cross-model only when the caller intentionally selected a different model
526
- class for that subagent; if the spawned reviewer's model class is uncertain,
527
- label it fresh-context, not cross-model.
528
-
529
- Explicit user instructions and project-level `AGENTS.md` / `CLAUDE.md` review
530
- rules override this policy. If they require review, follow them. If they opt out
531
- or restrict external model egress, do not invoke peeragent.
532
-
533
- Latency expectation: a top-tier reasoning peer (Opus-class, xhigh Codex/GLM,
534
- or equivalent) commonly takes 10 to 30 minutes for large reviews and may be
535
- quiet for most of it. A long quiet period or lack of intermediate output is
536
- normal. Do not treat "it has not returned in a few minutes" as a hang, and do
537
- not fall back, mark the peer attempt failed, or block the run unless the process
538
- exits with an error, reports failure, or exceeds a timeout sized for top-tier
539
- review work.
540
-
541
- Default judgment (by scope see [references/models.md](references/models.md)
542
- for the model classes that fill each role):
543
-
544
- - Small, low-risk work: skip cross-model review.
545
- - Small/medium work with real uncertainty: optionally use one focused `peer`
546
- pass.
547
- - Large, risky, or architectural design points under autopilot: use one focused
548
- `peer` pass when no prior `--only-questions` / `## Design decisions`
549
- alignment exists.
550
- - **Deep or complex work** (architectural design, large/risky features or
551
- epics, the final autopilot completion review, whole-repo scans): **if two
552
- different model classes are available, use both**, paired across the two
553
- review phases below. Two distinct training lineages catch more than one, and
554
- their disagreements are themselves signal.
555
- - Reviewing a completed **feature or epic** at `stage: review` (the `review`
556
- skill's deep lane): run the lens review in a fresh context a different-class
557
- `peer-review` when reachable; otherwise a generic sub-agent prompted with the
558
- reviewer posture from [references/subagents.md](references/subagents.md),
559
- cross-model only when the host can spawn it with a different model class;
560
- otherwise the strongest same-harness fresh-context reviewer available.
561
- **Stories skip this** entirely; they fast-advance on `implement`'s
562
- verification.
563
- - End of an autopilot run, after the scoped queue appears drained and before
564
- reporting `complete`: run a final `peer-review` loop when a different model
565
- class is available; otherwise use the freshest reviewer role available,
566
- labeling it cross-model only if spawned with a different model class. Fix or
567
- file accepted findings before completion.
568
- - Completed substantial artifacts, or explicit user requests for review: use
569
- `peer-review` only when the full iterative loop is appropriate.
570
-
571
- Designs and reviews are both evaluated in a fixed **two-phase order**
572
- (full mechanics in [references/models.md](references/models.md) §6):
573
-
574
- 1. **Phase 1 Completeness / Complementary / Advisory.** Augmentation, not
575
- judgment. Ask a different-class peer what is missing, what alternatives
576
- strengthen it, and what questions/risks should be weighed. The loop shape
577
- depends on the artifact: **designs (open)** get a **single pass** before
578
- decisions lock; **reviews (complete artifact)** get a **multi-step
579
- convergence loop to nits** — the ideal is the full `peer-review` loop
580
- (≥3 passes, stop on nits, cap ~5) when `peer-review` is available.
581
- 2. **Phase 2 Adversarial.** Attack posture. Ask a **different** peer
582
- (ideally a different class than Phase 1, per the 2-class rule) what is
583
- broken, contradictory, built on a false assumption, or will fail in
584
- operation. For reviews this is the same convergence loop in the attack
585
- posture; for designs it is a focused adversarial pass. Verify concrete
586
- claims before accepting.
587
-
588
- Never reverse the phases and never skip Phase 1 to jump straight to attack. For
589
- autopilot-driven design work, the default peer ask is **augmentation before
590
- decisions are locked**, not validation after the host has already decided.
591
-
592
- Design-time advisory peer failures are non-blocking under autopilot. If the
593
- peer wrapper is missing, the executable cannot be resolved, the invocation
594
- fails, or the call would use the same model class, continue with host judgment
595
- and log the reason briefly. A top-tier reasoning peer still running after only
596
- a few minutes is not a failure. Do not halt the queue for an advisory review
597
- failure.
598
-
599
- The final autopilot completion review is stricter: it must succeed through a
600
- different-model `peer-review` loop, a generic sub-agent prompted as a
601
- fresh-context reviewer (cross-model when the caller selects a different model
602
- class, otherwise same-harness), or another supported fresh-context fallback
603
- before the run reports `complete`. For deep/complex scope that means clearing
604
- through at least one cross-class pass per phase in §6 where two classes are
605
- available; if the selected final-review path fails, the run is blocked on final
606
- review rather than complete.
607
-
608
- When invoked, summarize the result in the item body without dumping transcripts:
609
-
610
- ```markdown
611
- ## Other agent review
612
- - Invoked because: <large/risky/deep-complex/autopilot/no prior alignment>
613
- - Scope: <single peer | two-class — list classes>
614
- - Reviewer (Phase 1 — advisory/completeness): <class, if known>
615
- - Gaps / missing requirements / alternatives considered:
616
- - <summary>
617
- - Reviewer (Phase 2 — adversarial): <class, if known; different from Phase 1>
618
- - Broken assumptions / failure modes / rejected points:
619
- - <summary>
620
- - Accepted:
621
- - <decision or adjustment> (phase N)
622
- - Rejected:
623
- - <point> — <reason> (phase N)
624
- ```
625
-
626
- If only one peer class was available (or only one phase was warranted by scope),
627
- fill only the phase that ran and note the other was skipped and why.
628
-
629
- Limit autopilot to one advisory pass per item per design stage. Do not run a
630
- multi-pass `peer-review` loop inside routine autopilot design unless the user or
631
- project instructions explicitly require it. The final completion review at the
632
- end of autopilot is separate from these design-time advisory passes.
342
+ # Part IV — Risk-Driven Advisory Review
343
+
344
+ Advisory review is selected by risk in both direct and autopilot design modes;
345
+ it is not a stage transition and is never triggered merely because autopilot is
346
+ active. Small, low-risk work skips it. Uncertain or risky work gains independent
347
+ scrutiny, while deep or complex work may use multiple model classes. Load
348
+ [references/advisory-review.md](references/advisory-review.md) for scope defaults,
349
+ two-phase mechanics, and the item-body record format. Model classes, host-peer
350
+ pairing, and concrete mechanism flags remain in
351
+ [references/models.md](references/models.md).
352
+
353
+ ## `review_weight`
354
+
355
+ `review_weight` is the canonical caller/project control consumed by review and
356
+ autopilot. Allowed values are `none | light | standard | thorough | maximum`;
357
+ the default is `standard`. It expresses the intended breadth and depth of
358
+ **independent** review, while the agent derives the exact topology from artifact
359
+ risk, item tier, scope, and available model classes:
360
+
361
+ - `none` explicitly opt out of independent review. Implementation
362
+ verification and acceptance evidence remain mandatory.
363
+ - `light` minimize ceremony while preserving focused scrutiny where risk
364
+ clearly warrants it.
365
+ - `standard` — balanced, risk-driven independent review.
366
+ - `thorough` increase fresh-context breadth and depth for meaningful risk.
367
+ - `maximum` permit multi-model, multi-pass complementary-then-adversarial
368
+ review for features and epics, with stories escalating dynamically by risk.
369
+
370
+ The levels are intent and ceilings, not fixed reviewer or pass counts. Explicit
371
+ caller and project policy takes precedence; record the effective weight and any
372
+ degradation. Configuration schema and foundation-doc wiring are follow-up work
373
+ for their owning stories.
374
+
375
+ ## Load-bearing invariants
376
+
377
+ - **Different-class labeling:** call a pass cross-model only when the reviewer is
378
+ known to be a different model class from the host. Otherwise label it
379
+ fresh-context. Different-class review is valuable for independent blind spots,
380
+ not greater authority.
381
+ - **Fresh-context semantics:** when independent review is warranted and a
382
+ different class is unavailable, use the strongest suitable fresh-context
383
+ reviewer available. Do not present inline self-review as independent.
384
+ - **Two-phase order:** completeness / complementary / advisory comes before
385
+ adversarial attack. Never reverse the order or skip directly to attack.
386
+ - **Non-blocking design:** unavailable or failed design-time advisory review does
387
+ not block direct or autopilot design. Continue with judgment and record the
388
+ reason. A slow top-tier reviewer is not a failure until its appropriately
389
+ sized timeout or mechanism reports failure.
390
+ - **Strict completion:** final autopilot completion must clear a successful
391
+ review path and adjudicate every proposed finding. At weights `light` through
392
+ `maximum`, that path must use a supported fresh-context reviewer; if it fails,
393
+ the run is blocked rather than complete. At explicit weight `none`, documented
394
+ implementation verification and acceptance evidence satisfy the path without
395
+ independent review.
396
+
397
+ ## Recipient-owned finding disposition
398
+
399
+ Reviewer output is evidence, not authority. The receiving agent orchestrating the
400
+ run independently verifies each claim and assigns its disposition against the
401
+ repository's actual context: acceptance criteria, supported users and deployment
402
+ shape, likelihood, blast radius, recoverability, existing safeguards, and the
403
+ cost of delaying the current work. A reviewer's `blocker` label never binds the
404
+ receiver by itself, and disagreement is resolved by evidence rather than
405
+ seniority or model strength.
406
+
407
+ A finding blocks the current cycle only when the receiver judges it a credible,
408
+ material risk to required correctness, security, data integrity, public
409
+ contracts, acceptance criteria, release safety, or trustworthy verification.
410
+ Fix those findings now or keep an active item that prevents completion. Park a
411
+ valid concern below that bar in the unbound backlog with its risk rationale and
412
+ continue; leave nits in review notes, and reject unsupported findings with a
413
+ brief reason. Rarity alone does not make a case irrelevant, but a corner case's
414
+ likelihood and consequence must justify its delivery cost. Repetition across
415
+ review passes does not elevate severity by itself.
416
+
417
+ A successful review path therefore means independent scrutiny ran when required
418
+ and the receiving agent adjudicated the results. It does not mean every reviewer
419
+ suggestion was implemented or promoted into the active queue.
420
+
421
+ User instructions and project-level review/egress rules override defaults. Do
422
+ not invoke an external peer mechanism when policy prohibits it. `--only-questions`
423
+ is user alignment and therefore skips advisory review.
633
424
 
634
425
  ---
635
426
 
@@ -656,12 +447,17 @@ family (`gate-cruft`, `gate-security`, `gate-tests`, `gate-docs`,
656
447
 
657
448
  | Arg | Behavior |
658
449
  |---|---|
659
- | no arg / `--all` | Sweep the relevant scope (whole codebase, or release bundle for gates) |
450
+ | no arg / `--all` | Sweep the relevant scope; release-bound items are a gate's focus, not a hard scan boundary |
660
451
  | `<path>` | Scope to that subtree |
661
452
  | `<NL scope>` | Interpret free text against the codebase; log the interpretation |
662
453
  | `<feature-id>` (where applicable) | Per-feature design mode (refactor-design, perf-design) |
663
454
 
664
455
  These skills *emit substrate items as findings* rather than gating pass/fail.
456
+ For release gates, follow relevant evidence into adjacent dependencies, shared
457
+ infrastructure, or system-wide mechanisms. Bind findings to the release only
458
+ when they are caused by, exposed by, or materially relevant to it; route merely
459
+ ambient discoveries to unbound backlog proposals so a gate does not silently
460
+ expand release scope.
665
461
 
666
462
  ## Per-item design verbs
667
463