@nklisch/pi-agile-workflow 0.15.3 → 0.16.1

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.
@@ -67,8 +67,8 @@ Pick the **top 3-5** entry points most likely to dominate runtime. Heuristics:
67
67
  on critical user paths, called per-request or per-event, high call count from
68
68
  logs/tests, known historically slow, contain nested loops or I/O.
69
69
 
70
- If confidence is low about which to pick, ask via `structured question tool` (single
71
- multi-select question). Log the picks.
70
+ If confidence is low, apply `principles/SKILL.md` Part III. Candidate selection
71
+ is normally reversible: choose the best-supported paths and log the rationale.
72
72
 
73
73
  **Cap the scan.** Never profile every function in the codebase.
74
74
 
@@ -112,14 +112,13 @@ drafting features. Iterate over the target set:
112
112
 
113
113
  1. Read the feature; skip if not `[perf]`-tagged or not at `stage: drafting`
114
114
  2. Light ground (foundation docs + AGENTS.md / CLAUDE.md + existing benchmarks)
115
- 3. Surface strategic ambiguities specific to perf (e.g., "what target
116
- scenario?", "current vs desired measured throughput?", "target hardware?",
117
- "acceptable memory or layout tradeoff for speed?"). Use structured question tool.
115
+ 3. Use the structured question tool for strategic performance ambiguities such
116
+ as target scenario, success threshold, hardware, or resource trade-offs.
118
117
  4. Capture answers under `## Design decisions` in the feature body
119
118
  5. Do NOT design or advance stage
120
119
  6. Commit per feature: `perf-design --only-questions: <id>`
121
120
 
122
- Requires interactive mode; refuse to run under an active autopilot run or goal.
121
+ Requires interactive mode; refuse under autopilot. Otherwise defer question and advisory policy to `principles/SKILL.md` Parts III–IV.
123
122
 
124
123
  ## The optimization hierarchy
125
124
 
@@ -173,12 +172,12 @@ Read `.work/active/features/<id>.md`. Confirm:
173
172
  - `stage: drafting`
174
173
  - `tags` includes `perf`
175
174
 
176
- The brief should describe the perf problem and target. If it's vague:
177
- - Autopilot mode: profile the hottest identifiable path, set a "2x current"
178
- default target, log under `## Inferred targets` in the body. Halt only if
179
- there's no measurable scenario at all (no entry point matching the brief).
180
- - Otherwise: ask the user for target scenario, current measured performance,
181
- desired performance.
175
+ The brief should describe the performance problem and target. If it is vague,
176
+ apply `principles/SKILL.md` Part III: infer and log reversible benchmark details,
177
+ but use strategic questions in interactive mode when the workload or success
178
+ threshold changes product direction or an external performance contract. Under
179
+ autopilot, choose the best-supported measurable scenario; halt only when no
180
+ scenario matching the brief can be measured.
182
181
 
183
182
  ### Phase 2: Ground yourself
184
183
 
@@ -23,209 +23,32 @@ Each principle has guidance for design time and implementation time.
23
23
 
24
24
  # Part I — Code-Design Principles
25
25
 
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
26
+ These four invariants stay active during design and implementation. Load
27
+ [references/code-design.md](references/code-design.md) when concrete mechanics,
28
+ checklists, or examples are needed.
79
29
 
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
30
+ ## 1. Ports & Adapters
94
31
 
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
32
+ Domain logic stays independent of databases, filesystems, HTTP, time,
33
+ randomness, and other infrastructure. The domain defines the ports it needs;
34
+ adapters implement them, and composition roots wire the two together.
118
35
 
119
- ### At implementation time
36
+ ## 2. Single Source of Truth
120
37
 
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
- ```
149
-
150
- ---
38
+ Growing variant sets have one authoritative typed registry. Types, validation,
39
+ routing, and display derive from it rather than re-enumerating the variants.
151
40
 
152
41
  ## 3. Generated Contracts
153
42
 
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.
43
+ Boundary types derive from the schema, router, database model, or a generation
44
+ step. Consumers import or infer that contract instead of maintaining hand-written
45
+ copies.
155
46
 
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
163
-
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
168
-
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
173
-
174
- ### At implementation time
175
-
176
- Do not hand-write types that are derivable from a schema, router, or database definition. Import or generate them.
177
-
178
- **Good:**
179
- ```typescript
180
- import type { AppRouter } from '../../server/router'
181
- // type-safe from the source
182
-
183
- const { data } = useQuery<InferSelectModel<typeof users>>( ... )
184
- ```
185
-
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
- ```
195
-
196
- If a generated type needs extending, use `type MyType = GeneratedType & { extra: string }` — extend the source of truth, don't replace it.
47
+ ## 4. Fail Fast
197
48
 
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
- ```
49
+ Validate unknown input at system boundaries and assert internal preconditions at
50
+ function entry. Reject invalid state early with specific errors instead of
51
+ letting it fail deep in the call chain.
229
52
 
230
53
  ---
231
54
 
@@ -420,43 +243,37 @@ auditable later.
420
243
 
421
244
  ---
422
245
 
423
- # Part III — Caller Awareness
246
+ # Part III — Caller Awareness and Question Policy
247
+
248
+ **The normal rule is consequence-based, not mode-based.** Resolve routine,
249
+ reversible decisions with judgment and record the rationale in the item body.
250
+ Use the structured question tool only when the answer sets product direction,
251
+ materially changes user-facing behavior or an external contract, or commits the
252
+ project to an expensive choice that is difficult to reverse. Existing `## Design decisions` and foundation
253
+ docs are inputs; do not re-ask what they already settle.
424
254
 
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.
255
+ Interactive mode permits those strategic questions. An active autopilot driver
256
+ never asks them: use available evidence and choose the least irreversible sound
257
+ option, logging the decision. Ordinary ambiguity must not halt the queue.
429
258
 
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.
259
+ Autopilot mode is binary and detectable. It is on when this skill was delegated
260
+ by an explicit autopilot invocation, an active autopilot harness goal, or a
261
+ prompt clearly continuing/draining that scope. An autopilot caller note is the
262
+ strongest signal. If no active driver exists, the invocation is interactive.
435
263
 
436
264
  ## What does NOT count as autopilot
437
265
 
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.
266
+ - **General harness "auto mode"** a reminder to work autonomously changes
267
+ conversational posture, but does not create an autopilot queue goal.
268
+ - **An earlier "just decide" instruction** — it applies to that decision, not a
269
+ later explicit skill invocation.
270
+ - **A completed, blocked, or interrupted autopilot run** later direct skill
271
+ invocations are interactive again.
272
+
273
+ A direct `/agile-workflow:feature-design <id>` (or other design, implement, or
274
+ review skill) is interactive unless its prompt clearly belongs to an active
275
+ autopilot driver. The disambiguation test is: *"Can I point to the active
276
+ autopilot goal or caller note driving this invocation?"*
460
277
 
461
278
  ## What still warrants a hard halt (autopilot or not)
462
279
 
@@ -465,171 +282,96 @@ interactive.
465
282
  - `depends_on` cycle detected when writing items
466
283
  - Genuinely contradictory state the skill cannot recover from
467
284
 
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.
285
+ Everything else resolves through evidence and judgment under autopilot. Prefer
286
+ the simpler, more reversible option and log why.
471
287
 
472
288
  ## Worked examples (autopilot mode)
473
289
 
474
290
  | Situation | Judgment-mode action |
475
291
  |---|---|
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 |
292
+ | Two architectural options both look valid | Pick the one with fewer moving parts; log the rationale. |
293
+ | Brief is vague, several plausible interpretations | Pick the one most consistent with foundation docs; log under `## Design decisions`. |
294
+ | Multiple candidate items at a stage and no id was passed | Pick most recent by `updated:`; the next iteration picks the next. |
295
+ | Wrong-tag invocation routed to you by mistake | Log a misroute note; return without advancing. |
296
+ | Empty diff during review after trying ranges | Advance to `done` with a "No diff found" note. |
297
+ | Item at unexpected stage | Choose the recoverable transition and log it. |
482
298
 
483
- ## How to phrase decision points
299
+ ## Explicit alignment mode
484
300
 
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.
301
+ `--only-questions` is unchanged: it is an explicit, interactive-only alignment
302
+ pass that captures answers under `## Design decisions`, does not design, and
303
+ does not advance stage. Refuse it when autopilot is the active driver. Inside
304
+ that mode, surface the target's meaningful strategic ambiguities even when a
305
+ normal design pass would resolve a reversible point autonomously.
490
306
 
491
307
  ## Skills this applies to
492
308
 
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.
309
+ This policy governs `feature-design`, `epic-design`, `refactor-design`,
310
+ `perf-design`, `implement`, `implement-orchestrator`, and `review`, plus the
311
+ cross-plugin research orchestrator when routed from autopilot. Interactive-only
312
+ skills may remain workshop-oriented, but should still avoid questions whose
313
+ answers are routine and reversible.
502
314
 
503
315
  ---
504
316
 
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.
317
+ # Part IV — Risk-Driven Advisory Review
318
+
319
+ Advisory review is selected by risk in both direct and autopilot design modes;
320
+ it is not a stage transition and is never triggered merely because autopilot is
321
+ active. Small, low-risk work skips it. Uncertain or risky work gains independent
322
+ scrutiny, while deep or complex work may use multiple model classes. Load
323
+ [references/advisory-review.md](references/advisory-review.md) for scope defaults,
324
+ two-phase mechanics, and the item-body record format. Model classes, host-peer
325
+ pairing, and concrete mechanism flags remain in
326
+ [references/models.md](references/models.md).
327
+
328
+ ## `review_weight`
329
+
330
+ `review_weight` is the canonical caller/project control consumed by review and
331
+ autopilot. Allowed values are `none | light | standard | thorough | maximum`;
332
+ the default is `standard`. It expresses the intended breadth and depth of
333
+ **independent** review, while the agent derives the exact topology from artifact
334
+ risk, item tier, scope, and available model classes:
335
+
336
+ - `none` explicitly opt out of independent review. Implementation
337
+ verification and acceptance evidence remain mandatory.
338
+ - `light` minimize ceremony while preserving focused scrutiny where risk
339
+ clearly warrants it.
340
+ - `standard` — balanced, risk-driven independent review.
341
+ - `thorough` increase fresh-context breadth and depth for meaningful risk.
342
+ - `maximum` permit multi-model, multi-pass complementary-then-adversarial
343
+ review for features and epics, with stories escalating dynamically by risk.
344
+
345
+ The levels are intent and ceilings, not fixed reviewer or pass counts. Explicit
346
+ caller and project policy takes precedence; record the effective weight and any
347
+ degradation. Configuration schema and foundation-doc wiring are follow-up work
348
+ for their owning stories.
349
+
350
+ ## Load-bearing invariants
351
+
352
+ - **Different-class labeling:** call a pass cross-model only when the reviewer is
353
+ known to be a different model class from the host. Otherwise label it
354
+ fresh-context. Different-class review is valuable for independent blind spots,
355
+ not greater authority.
356
+ - **Fresh-context semantics:** when independent review is warranted and a
357
+ different class is unavailable, use the strongest suitable fresh-context
358
+ reviewer available. Do not present inline self-review as independent.
359
+ - **Two-phase order:** completeness / complementary / advisory comes before
360
+ adversarial attack. Never reverse the order or skip directly to attack.
361
+ - **Non-blocking design:** unavailable or failed design-time advisory review does
362
+ not block direct or autopilot design. Continue with judgment and record the
363
+ reason. A slow top-tier reviewer is not a failure until its appropriately
364
+ sized timeout or mechanism reports failure.
365
+ - **Strict completion:** final autopilot completion must clear a successful
366
+ review path and resolve or file accepted findings. At weights `light` through
367
+ `maximum`, that path must use a supported fresh-context reviewer; if it fails,
368
+ the run is blocked rather than complete. At explicit weight `none`, documented
369
+ implementation verification and acceptance evidence satisfy the path without
370
+ independent review.
371
+
372
+ User instructions and project-level review/egress rules override defaults. Do
373
+ not invoke an external peer mechanism when policy prohibits it. `--only-questions`
374
+ is user alignment and therefore skips advisory review.
633
375
 
634
376
  ---
635
377