@dzhechkov/keysarium 1.5.27 → 1.5.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dzhechkov/keysarium",
3
- "version": "1.5.27",
3
+ "version": "1.5.29",
4
4
  "description": "AI Case Research Toolkit for Claude Code — full 7-phase pipeline with feature-adr, dream cycles, background workers, multi-platform support, reward learning, and Cloud.ru AI Factory mapping (--ai-factory flag)",
5
5
  "main": "src/cli.js",
6
6
  "bin": {
@@ -132,7 +132,7 @@ Step | S | M | L | XL | Model | Agentic QE Skill
132
132
  0 Complexity Router | ✓ | ✓ | ✓ | ✓ | haiku | — |
133
133
  1 Requirements | ✓ | ✓ | ✓ | ✓ | sonnet | — |
134
134
  2 Research | - | - | ✓ | ✓ | sonnet | — |
135
- 3 ADR + Shift-Left | - | ✓ | ✓ | ✓ | opus | shift-left-testing |
135
+ 3 ADR + Shift-Left | - | ✓ Nygard/ITD | ✓ MADR+Confirmation | ✓ MADR+Confirmation | opus | shift-left-testing |
136
136
  3.5 QCSD Ideation Swarm | - | ✓ | ✓ | ✓ | sonnet | qcsd-ideation-swarm |
137
137
  4 DDD | - | - | ✓ | ✓ | opus | — |
138
138
  5 Architecture | - | ✓ | ✓ | ✓ | opus | — |
@@ -205,6 +205,8 @@ Execute protocol
205
205
  After Step 8 (or Step 9 for L/XL) completes, verify:
206
206
  - All mandatory artifacts exist per tier
207
207
  - QE checks passed
208
+ - Every generated ADR passes the Step-8 ADR fitness checklist
209
+ - Every ADR Confirmation load-bearing property has a named automated test/fitness check
208
210
  - ADR decisions are traceable to code (L/XL)
209
211
  - QCSD quality risks are mitigated (M+)
210
212
  - Gap detection loop closed with zero remaining gaps
@@ -491,6 +493,12 @@ only the statusline:
491
493
  🎓 Learning: {recalled} patterns recalled for this feature, {stored} new stored this run
492
494
  ```
493
495
 
496
+ **Record the panel at the START of every step, not only at Steps 0/8/9.** The panel shows the last step
497
+ that reported; a pipeline that reports three times per run shows a stale step for most of its life. Emit
498
+ `dz statusline --fa-record --slug <slug> --step "<Step N Name>" --recalled <n> --stored <n>` as the first
499
+ action of each step. The recall/teach counts only change at Steps 0/8/9; the *step label* changes at every
500
+ one of them.
501
+
494
502
  *Honesty note:* the panel is live only insofar as the pipeline records state — it reflects what the
495
503
  pipeline actually did with the loop (recalls that ran, stores that landed), not an aspirational count.
496
504
 
@@ -581,6 +589,7 @@ npx @dzhechkov/skills-feature-adr init --with-learning --knowledge-extractor
581
589
  <promise>[PROMISE_TAG]</promise>
582
590
  Tier: {COMPLEXITY_TIER} | Active Steps: {ACTIVE_STEPS}
583
591
  🎓 Learning: {recalled} patterns recalled for this feature, {stored} new stored this run
592
+ 🚦 Gates: challenge-panel ✓ · claim-check ✓ · discrimination not-run · amendments ✓ · fleet —
584
593
 
585
594
  [2-3 line summary]
586
595
  Artifacts: [list] ✅
@@ -590,3 +599,16 @@ Artifacts: [list] ✅
590
599
  • "[feedback]" — adjust
591
600
  ═══════════════════════════════════════════════════════
592
601
  ```
602
+
603
+ ### The 🚦 Gates line (mandatory, DERIVED — never asserted from memory)
604
+
605
+ Every checkpoint banner carries a `🚦 Gates:` line listing each gate relevant to the run so far. Symbols:
606
+ `✓` ran and passed · `✗` ran and failed · `not-run` pending · `—` N/A for this tier/slice (say why once).
607
+ Each value is **derived from machine-checkable state** — an artifact's existence, a command's JSON verdict, a
608
+ test result — never from what the orchestrator remembers doing. The line does not make a gate run; it makes
609
+ NOT running one loud: a skipped gate shows as `not-run` by construction instead of being silently forgotten
610
+ (cost-of-detection ladder: the banner is the one surface emitted at EVERY step boundary, so strapping the
611
+ checklist to it is the cheapest way to harden orchestrator judgment). Gate sources: challenge-panel → its
612
+ verdict exists; claim-check → its JSON counts (`high-findings` vs `clean`); discrimination → the
613
+ `dz discrimination-check` aggregate; amendments → every `AM-N` row carries its `→ test` and it was checked;
614
+ fleet → the 09 artifact (L/XL only, else `—`).
@@ -57,7 +57,7 @@ Load `references/complexity-matrix.md` for the full matrix. Summary:
57
57
  | 0 Complexity Router | ✓ | ✓ | ✓ | ✓ |
58
58
  | 1 Requirements | ✓ light | ✓ | ✓ | ✓ |
59
59
  | 2 Research | - | - | ✓ | ✓ |
60
- | 3 ADR + Shift-Left | - | ✓ (1 ADR) | ✓ (N ADRs) | ✓ (N ADRs) |
60
+ | 3 ADR + Shift-Left | - | ✓ (1 ADR, Nygard/ITD-light) | ✓ (N ADRs, MADR+Confirmation) | ✓ (N ADRs, MADR+Confirmation) |
61
61
  | 3.5 QCSD Ideation Swarm | - | ✓ | ✓ | ✓ |
62
62
  | 4 DDD | - | - | ✓ | ✓ |
63
63
  | 5 Architecture | - | ✓ light | ✓ | ✓ |
@@ -68,6 +68,13 @@ Load `references/complexity-matrix.md` for the full matrix. Summary:
68
68
 
69
69
  > Steps 3.5 (M+) and 9 (L/XL) are mandatory — skipping them is a BLOCK per the shard Anti-Patterns.
70
70
 
71
+ ADR template weight is part of routing:
72
+ - Summary: S/M -> Nygard/ITD-light; L/XL -> MADR+Confirmation.
73
+ - S: normally skip Step 3; if an ADR is explicitly forced, use Nygard as the lightweight fallback.
74
+ - M: use Nygard/ITD-lightweight ADRs with the invariant core plus drivers, options, rationale, consequences, and Confirmation.
75
+ - L/XL: use full MADR structure with an NHS Wales Confirmation stanza for each significant decision.
76
+ - All generated ADRs must keep the invariant core: Title, Status, Context, Decision, Consequences; one decision per ADR.
77
+
71
78
  ### 5. Calculate Time Budget
72
79
 
73
80
  | Tier | Total Budget | Distribution |
@@ -1,12 +1,13 @@
1
1
  # Step 3: Architecture Decision Records
2
2
 
3
- > Document each significant architectural decision with context, alternatives, and rationale.
3
+ > Document each significant architectural decision with context, rejected options, consequences, and a named verification method before implementation begins.
4
4
 
5
5
  ## When
6
6
 
7
7
  M+ tiers. Depth varies:
8
- - **M:** 1 ADR for the main decision
9
- - **L/XL:** N ADRs for each significant decision
8
+ - **S:** skipped by default; if explicitly forced, use Nygard as the lightweight fallback.
9
+ - **M:** 1 Nygard/ITD-light ADR for the main decision, with the invariant core plus drivers, options, rationale, consequences, and Confirmation.
10
+ - **L/XL:** N MADR+Confirmation ADRs, one per significant decision.
10
11
 
11
12
  Can run **in parallel** with Step 2 (Research) for L/XL tiers.
12
13
 
@@ -36,94 +37,164 @@ Scan requirements for decision points:
36
37
  | Trade-off | "Consistency vs. availability?" |
37
38
 
38
39
  For M-tier: pick the SINGLE most impactful decision.
39
- For L/XL: identify ALL decisions, prioritize by impact.
40
+ For L/XL: identify ALL significant decisions, prioritize by architectural impact, and split them into separate ADRs.
40
41
 
41
- ### 2. Draft ADR per Decision
42
+ Reject explainer-masquerading-as-ADR: a document that describes a space but makes no concrete decision is not an ADR.
42
43
 
43
- Use template from `references/adr-template.md`:
44
+ ### 2. Choose Template Weight
45
+
46
+ All ADRs must emit the invariant core:
47
+ - Title
48
+ - Status
49
+ - Context
50
+ - Decision
51
+ - Consequences
52
+
53
+ Template routing:
54
+ - S forced ADR: Nygard fallback.
55
+ - M: Nygard/ITD-light form with drivers, options, rationale, consequences, and Confirmation.
56
+ - L/XL: MADR structure plus an NHS Wales Confirmation stanza.
57
+
58
+ The chosen template may be short, but it must still satisfy the Step-8 ADR fitness checklist.
59
+
60
+ ### 3. Enforce File Naming
61
+
62
+ Create ADRs in `features/<slug>/03_adr/` as:
63
+
64
+ ```text
65
+ NNN-{decision-slug}.md
66
+ ```
67
+
68
+ Slug rules:
69
+ - lowercase kebab-case
70
+ - present-tense imperative verb phrase
71
+ - no dates
72
+ - no ticket numbers
73
+ - no camelCase, snake_case, or spaces
74
+
75
+ Good examples: `001-choose-event-store.md`, `002-enforce-adr-fitness.md`, `003-format-timestamps.md`.
76
+
77
+ ### 4. Draft ADR per Decision
78
+
79
+ Use `references/adr-template.md`.
80
+
81
+ Minimum structure:
44
82
 
45
83
  ```markdown
46
- # ADR-{NNN}: {Title}
84
+ # ADR-{NNN}: {decision-shaped title}
47
85
 
48
86
  ## Status
49
- Proposed | Accepted | Superseded by ADR-{M}
87
+ proposed - Reversible until {condition}; revisit when {trigger}.
50
88
 
51
89
  ## Context
52
- What is the issue that we're seeing that is motivating this decision?
90
+ {Neutral problem context written before the decision. State forces and constraints without selling the chosen option.}
53
91
 
54
92
  ## Decision Drivers
55
- - {driver 1}
56
- - {driver 2}
93
+ 1. {Driver D1} (weight: high|medium|low)
94
+ 2. {Driver D2} (weight: high|medium|low)
57
95
 
58
96
  ## Considered Options
59
- 1. {Option A} — {1-line summary}
60
- 2. {Option B} — {1-line summary}
61
- 3. {Option C} — {1-line summary}
97
+ ### {Option A}
98
+ Pros:
99
+ - {real strength}
100
+ Cons:
101
+ - {real weakness}
102
+
103
+ ### {Option B}
104
+ Pros:
105
+ - {real strength}
106
+ Cons:
107
+ - {real weakness}
62
108
 
63
109
  ## Decision
64
- We chose **{Option X}** because...
110
+ We will {concrete choice with exact names, versions, formats, paths, commands, APIs, or conventions}.
111
+
112
+ ## Rationale
113
+ - D1: {why the chosen option satisfies the driver}
114
+ - D2: {why rejected options lost despite their strengths}
65
115
 
66
116
  ## Consequences
67
117
  ### Positive
68
- - ...
69
- ### Negative
70
- - ...
71
- ### Risks
72
- - ...
73
- ```
118
+ - {benefit}
74
119
 
75
- ### 3. Evaluate Alternatives
120
+ ### Negative / Accepted Downsides
121
+ - {cost or risk} - Mitigation: {mitigation}
76
122
 
77
- For each ADR, evaluate alternatives using a decision matrix:
123
+ ### Follow-up ADRs
124
+ - {ADR-NNN or "None required now"} - {why}
78
125
 
79
- | Criterion | Weight | Option A | Option B | Option C |
80
- |-----------|--------|----------|----------|----------|
81
- | Simplicity | 3 | ⭐⭐⭐ | ⭐⭐ | ⭐ |
82
- | Performance | 2 | ⭐⭐ | ⭐⭐⭐ | ⭐⭐ |
83
- | Maintainability | 3 | ⭐⭐ | ⭐⭐ | ⭐⭐⭐ |
84
- | Team familiarity | 2 | ⭐⭐⭐ | ⭐ | ⭐⭐ |
126
+ ### After-action Review
127
+ - Owner: {person/team}
128
+ - Schedule: {about one month after acceptance, or a concrete date if known}
85
129
 
86
- If decision involves complex trade-offs, load `problem-solver-enhanced` for TRIZ analysis.
130
+ ## Confirmation
131
+ - Method: {test, review, demo, audit, or fitness function}
132
+ - Monitoring: {ongoing automated check/audit/training}
133
+ - Success metric: {objective pass/fail or numeric metric}
134
+ - Owner: {responsible person/team}
135
+ - Load-bearing property: {the safety property Step 8 must assert has a test}
136
+ - Required automated check: {test file/name, command, or ArchUnit/ArchUnitTS suggestion}
137
+ ```
138
+
139
+ For L/XL ADRs, add a decision matrix or comparison table after Considered Options. Keep per-option pros/cons symmetric.
87
140
 
88
- ### 4. Validate Against Requirements
141
+ ### 5. Validate Against Requirements
89
142
 
90
143
  Each ADR must trace back to specific requirements:
91
144
  - Which FR-{N} does this decision support?
92
- - Does the decision satisfy all relevant NFRs?
93
- - Does the decision respect constraints?
145
+ - Which NFRs does it satisfy?
146
+ - Which constraints does it respect?
147
+ - Which safety property must be tested because the ADR's Confirmation names it?
148
+
149
+ ### 6. Lifecycle Discipline
150
+
151
+ - Status vocabulary is controlled: `proposed`, `accepted`, `rejected`, `deprecated`, `superseded`.
152
+ - Status must include a reversibility or revisit clause.
153
+ - Supersession mints a NEW ADR and sets the old ADR to `superseded by ADR-{NNN}`; do not edit accepted/rejected ADR content in place.
154
+ - If a living-document amendment is unavoidable, add a dated "arrived after the decision" note instead of silently rewriting the original reasoning.
94
155
 
95
156
  ## Anti-Patterns
96
157
 
97
158
  | Anti-Pattern | Detection | Fix |
98
159
  |-------------|-----------|-----|
99
- | Only one alternative | Less than 2 options considered | Require ≥2 alternatives |
160
+ | Explainer masquerading as ADR | Describes a domain but has no concrete Decision | BLOCK; write a decision-shaped ADR |
161
+ | Only one alternative | Less than 2 options considered | Require chosen plus rejected options |
162
+ | Strawman rejected option | Loser has only cons | Add real strengths and fair trade-offs |
100
163
  | No consequences | Missing positive/negative analysis | BLOCK until filled |
101
- | Decision without context | Why is unclear | Add context section |
102
- | Premature optimization | Choosing complex option for hypothetical scale | Prefer simpler option |
164
+ | Benefits-only consequences | No accepted downside | Add negative outcomes and mitigations |
165
+ | Decision without context | Why is unclear | Add neutral Context before Decision |
166
+ | Vague decision | "use a modern database" | Name exact product/version/format/path/API |
167
+ | Placeholder text | Template hints or TODOs remain | Remove or fill before checkpoint |
168
+ | Supersession in-place | Existing ADR rewritten | Mint a new ADR and link it |
103
169
 
104
170
  ## Output
105
171
 
106
172
  Create `features/<slug>/03_adr/` directory with:
107
- - `001-{decision-slug}.md` for each ADR
108
- - Each ADR follows the template
173
+ - `NNN-{decision-slug}.md` for each ADR
174
+ - Each ADR follows the template and satisfies the fitness checklist
109
175
 
110
- Set `{ADR_DECISIONS}` variable with list of decisions.
176
+ Set `{ADR_DECISIONS}` variable with list of decisions and their Confirmation load-bearing properties.
111
177
 
112
178
  ## Checkpoint Format
113
179
 
114
- ```
115
- ═══════════════════════════════════════════════════════
116
- ⏸️ STEP 3/8: ADR Complete
180
+ ```text
181
+ =======================================================
182
+ STEP 3/8: ADR Complete
117
183
  Tier: {COMPLEXITY_TIER}
118
184
 
119
185
  {N} architectural decisions documented:
120
- 1. ADR-001: {title} → chose {option}
121
- 2. ADR-002: {title} → chose {option}
122
-
123
- • "ок" — proceed
124
- • "пересмотри ADR-{N}" — reconsider decision
125
- • "добавь ADR для [topic]" — add new decision
126
- ═══════════════════════════════════════════════════════
186
+ 1. ADR-001: {title} -> chose {option}; Confirmation: {method}, {metric}, owner {owner}
187
+ 2. ADR-002: {title} -> chose {option}; Confirmation: {method}, {metric}, owner {owner}
188
+
189
+ Fitness readiness:
190
+ - Invariant core present: PASS|FAIL
191
+ - Concrete/testable decisions: PASS|FAIL
192
+ - Confirmation properties named for Step 8: PASS|FAIL
193
+
194
+ - "ok" - proceed
195
+ - "revise ADR-{N}" - reconsider decision
196
+ - "add ADR for [topic]" - add new decision
197
+ =======================================================
127
198
  ```
128
199
 
129
200
  ## Shift-Left Validation (after ADR creation)
@@ -136,8 +207,14 @@ After all ADRs are drafted, apply **shift-left-testing** protocol (Level 4: Risk
136
207
 
137
208
  For each ADR decision, run risk analysis:
138
209
 
139
- ```
210
+ ```text
140
211
  ADR-{NNN}: {Title}
212
+ Confirmation:
213
+ Method: {verification method}
214
+ Monitoring: {ongoing monitoring}
215
+ Success metric: {metric}
216
+ Owner: {owner}
217
+ Load-bearing property: {property}
141
218
  Testability Questions:
142
219
  1. What happens when {chosen option} fails under load?
143
220
  2. How do we handle {alternative failure modes}?
@@ -147,6 +224,8 @@ ADR-{NNN}: {Title}
147
224
  Given {precondition from ADR context}
148
225
  When {action that exercises the decision}
149
226
  Then {expected outcome per ADR consequences}
227
+ Required Automated Check:
228
+ {test file/name/command or ArchUnit/ArchUnitTS fitness function}
150
229
  Risk Level: LOW | MEDIUM | HIGH
151
230
  ```
152
231
 
@@ -155,24 +234,35 @@ ADR-{NNN}: {Title}
155
234
  | Check | Threshold |
156
235
  |-------|-----------|
157
236
  | All ADRs have testability questions answered | 100% |
158
- | BDD scenarios generated for non-trivial decisions | ≥1 per ADR |
237
+ | Each ADR has a Confirmation stanza | 100% |
238
+ | Each Confirmation names method, monitoring, success metric, owner | 100% |
239
+ | Each load-bearing property has a proposed automated check | 100% |
240
+ | BDD scenarios generated for non-trivial decisions | >=1 per ADR |
159
241
  | No HIGH risk without mitigation documented | 0 unmitigated |
160
242
 
161
- If any ADR has HIGH risk without mitigation → flag at checkpoint for user decision.
243
+ If any ADR has HIGH risk without mitigation, or a Confirmation property with no proposed automated check, flag at checkpoint for user decision.
162
244
 
163
- ### Integration with Step 3.5
245
+ ### Integration with Step 3.5 and Step 8
164
246
 
165
247
  The shift-left validation output feeds directly into Step 3.5 (QCSD Ideation Swarm):
166
248
  - BDD scenarios become input for the requirements-validator agent
167
249
  - Risk analysis feeds the risk-assessor agent
168
250
  - Testability questions inform the quality-criteria-recommender
169
251
 
252
+ Step 8 must read the Confirmation stanza and assert that the named load-bearing property has a real automated test or fitness function in the shipped code. For architecture dependency/layering/interface rules, suggest ArchUnit or ArchUnitTS.
253
+
170
254
  ## Quality Gates
171
255
 
172
- - [ ] Every ADR has ≥2 alternatives considered
173
- - [ ] Every ADR has consequences (positive + negative)
174
- - [ ] Every ADR traces to requirements
175
- - [ ] Decision matrix used for non-trivial choices
176
- - [ ] No premature optimization detected
177
- - [ ] Shift-left testability check passed for all ADRs
178
- - [ ] BDD scenarios generated for non-trivial ADRs
256
+ - [ ] Every ADR has the invariant core: Title, Status, Context, Decision, Consequences
257
+ - [ ] Every ADR records exactly one decision
258
+ - [ ] Filename slug is kebab-case, imperative, dateless, and ticketless
259
+ - [ ] Status uses controlled vocabulary plus a reversibility clause
260
+ - [ ] Context is neutral and appears before Decision
261
+ - [ ] Decision drivers are ranked or weighted
262
+ - [ ] Considered options include rejected options with symmetric pros/cons
263
+ - [ ] Rationale maps each point to a driver and explains why losers were rejected
264
+ - [ ] Decision is concrete/testable with exact names/versions/formats/paths/APIs
265
+ - [ ] Consequences include positive and negative outcomes/accepted downsides
266
+ - [ ] Consequences link follow-up ADRs and schedule an after-action review
267
+ - [ ] Confirmation names method, monitoring, success metric, owner, load-bearing property, and required automated check
268
+ - [ ] No placeholder text or generation scaffolding remains
@@ -119,7 +119,8 @@ After all agents complete, apply decision logic:
119
119
  | Critical Risks | > 2 | 1-2 | 0 |
120
120
 
121
121
  - **NO-GO**: BLOCK. Requirements/ADR need rework. Return to Step 1 or Step 3.
122
- - **CONDITIONAL**: Proceed with warnings. Pass findings to Steps 6-8 as advisory context.
122
+ - **CONDITIONAL**: Proceed with warnings. Each condition becomes an **amendment row** in a `## Amendments`
123
+ section (see below) — not loose advisory prose.
123
124
  - **GO**: Full confidence. Proceed to Step 6.
124
125
 
125
126
  ### 5. Synthesis Report
@@ -132,6 +133,26 @@ Generate consolidated `03.5_ideation_report.md` with:
132
133
  5. Test ideas (categorized: unit / integration / E2E)
133
134
  6. Conditional agent findings (if any)
134
135
  7. Recommendations prioritized by risk × impact
136
+ 8. `## Amendments` — on a CONDITIONAL verdict, every condition as a fixed-shape row (see below)
137
+
138
+ ### Amendment Confirmation discipline (every amendment is a mini-ADR)
139
+
140
+ Amendments are where the sharpest design corrections land — and, historically, the least-tested part of a
141
+ run: they arrive as prose AFTER the ADR's Confirmation discipline already ran, so a coder can implement one
142
+ with no test proving it works. Therefore every amendment carries a one-line **Confirmation**, in a fixed,
143
+ machine-checkable shape:
144
+
145
+ ```
146
+ AM-N (source): <change>. Confirmation: <property> → test `test_name` (fails if reverted).
147
+ ```
148
+
149
+ - `source` names where it came from (qcsd | challenge-panel | user-steer).
150
+ - The named test must FAIL if the amendment were reverted/broken (non-vacuous — Step 8 verifies via
151
+ `dz discrimination-check`).
152
+ - For a **safeguard** amendment (a warning/guard/fallback): the test must prove the safeguard actually
153
+ **TRIGGERS on a real input** — not merely that its code path exists. A structurally-dead safeguard passes
154
+ an existence test and never fires in production.
155
+ - A cheap lint holds the shape: every `AM-N` line must contain a `→ test ` token naming a test that exists.
135
156
 
136
157
  ## Output
137
158
 
@@ -149,6 +149,11 @@ Create `features/<slug>/06_implementation_plan.md` with:
149
149
  - Parallel groups
150
150
  - Checkpoint schedule
151
151
  - Risk assessment (L/XL)
152
+ - `## Amendments` — every correction folded into this plan (a Step-3.5 CONDITIONAL condition, a
153
+ challenge-panel confirmed finding, a user checkpoint steer) as a fixed-shape row:
154
+ `AM-N (source): <change>. Confirmation: <property> → test `test_name` (fails if reverted).`
155
+ A safeguard amendment's named test must prove it TRIGGERS on a real input, not merely that its code
156
+ path exists. Step 8 verifies every named test exists and is non-vacuous (`dz discrimination-check`).
152
157
 
153
158
  Set `{IMPL_PLAN}` variable.
154
159
 
@@ -169,6 +174,21 @@ Estimated {K} files to create/modify
169
174
  ═══════════════════════════════════════════════════════
170
175
  ```
171
176
 
177
+ ## Challenge panel (adversarial plan-gate — before coding)
178
+
179
+ Before leaving the plan checkpoint for code (especially L/XL), offer the **`challenge-panel`** skill — a
180
+ FRESH adversary (never the plan author) tries to BREAK the plan across the fixed C1-C8 owner questions,
181
+ every P0/P1 is cross-validated, and the verdict is ADVISORY (never an auto-block):
182
+
183
+ ```bash
184
+ dz challenge --plan features/<slug>/06_implementation_plan.md --author <planner-model>
185
+ ```
186
+
187
+ Dispatch the panel on the CROSS-FAMILY model (`--author` prints which): plan by Claude → Codex adversary
188
+ (honest `codex exec`, never a stub); plan by Codex → fresh Claude. Drop any P0/P1 the cross-validator does
189
+ not confirm. A finding the owner accepts can be recorded in `architecture/degradations.md` so C1 stops
190
+ re-flagging it. In the ultracode workflow this врезка runs automatically and returns `challengeVerdict`.
191
+
172
192
  ## Quality Gates
173
193
 
174
194
  - [ ] Every task has clear done criteria
@@ -31,6 +31,24 @@ Before writing any code:
31
31
  - [ ] Identify import patterns and module structure
32
32
  - [ ] Identify error handling patterns
33
33
  - [ ] Identify test patterns
34
+ - [ ] Plan carries `## Amendments`? → implement every AM-N row AND its named Confirmation test (a
35
+ safeguard amendment needs a test proving it FIRES on a real input)
36
+ - [ ] Does the diff add I/O (DB/network/file) to a previously-pure path — especially
37
+ startup/lifespan/health? → name the NEGATIVE resource-down test, or justify N/A
38
+
39
+ ### The I/O-on-pure-path rule (and the fixture-swap smell)
40
+
41
+ If a change introduces I/O into a path that was previously I/O-free — above all a startup, lifespan, or
42
+ health path — the happy-path test is NOT enough. Also write a **negative resource-down test**: a
43
+ broken/unbound resource handle (dead DB, missing table, exhausted pool) → the path degrades per its
44
+ declared contract — **fail-open** for an advisory feature, **explicit fail-fast** for a load-bearing one.
45
+ Without it, an outage of the resource takes down the whole path (including health checks) for the sake of
46
+ an advisory feature — and healthy test fixtures will hide it.
47
+
48
+ **Fixture-swap smell:** if making the new code pass required replacing a "broken" test fixture with a
49
+ healthy one — stop. The old fixture was probably a negative control proving the path was I/O-free. Keep
50
+ BOTH tests: the healthy one (new behavior) and the broken one (degradation contract). Never silently
51
+ delete the case that proved the old property.
34
52
 
35
53
  ### 2. Execute Tasks per Plan
36
54
 
@@ -129,6 +129,59 @@ Choose review mode based on context:
129
129
  - 🟡 **WARNING** — should fix, but not blocking (Ramsay mode: "This is RAW")
130
130
  - 🔵 **SUGGESTION** — nice to have improvement
131
131
 
132
+ ### 3.1 ADR Fitness Checklist Gate (M+)
133
+
134
+ Before final grading, read every generated ADR in `features/<slug>/03_adr/NNN-*.md`.
135
+
136
+ Fail the ADR gate for any miss:
137
+
138
+ | Check | Required Evidence |
139
+ |-------|-------------------|
140
+ | Decision-shaped title | Title names one concrete decision, not a vague topic |
141
+ | One decision per ADR | No bundled independent decisions |
142
+ | Filename discipline | `03_adr/NNN-{decision-slug}.md`; slug is lowercase kebab-case, imperative, dateless, ticketless |
143
+ | Status vocabulary | `proposed`, `accepted`, `rejected`, `deprecated`, or `superseded` |
144
+ | Reversibility clause | Status states when/how to revisit or why it is irreversible |
145
+ | Neutral Context before Decision | Context states problem/forces without advocating the chosen solution |
146
+ | Drivers ranked or weighted | Decision Drivers are explicit and prioritized |
147
+ | Considered Options | Chosen and rejected options are present |
148
+ | Symmetric pros/cons | Each option has real strengths and weaknesses; no strawman loser |
149
+ | Rationale maps to drivers | Every rationale point names the driver it satisfies and why rejected options lost |
150
+ | Concrete/testable Decision | Exact names, versions, formats, paths, commands, APIs, or conventions |
151
+ | Negative consequences | Consequences include accepted downsides/risks, not only benefits |
152
+ | Follow-up discipline | Consequences link follow-up ADRs or state none; after-action review is scheduled |
153
+ | Confirmation stanza | Names verification method, monitoring, success metric, and owner |
154
+ | Confirmation-to-test link | The named load-bearing property has a real automated test/fitness check by file/name |
155
+ | No placeholders | No TODO, template hint text, raw prompt/generation scaffold, or empty tail sections |
156
+
157
+ Reject explainer-masquerading-as-ADR: if the document describes a problem space or technology landscape but has no concrete `Decision`, record a BLOCKER.
158
+
159
+ The Confirmation-to-test link is load-bearing. If absent, grade no better than C and record a blocker gap; for architecture dependency/layering/interface rules, recommend an ArchUnit or ArchUnitTS fitness function.
160
+
161
+ ### 3b. Amendment Gate (P2 — amendments inherit the Confirmation discipline)
162
+
163
+ Read the `## Amendments` sections of `03.5_ideation_report.md` and `06_implementation_plan.md` (skip
164
+ silently if absent). For EVERY `AM-N` row verify:
165
+ 1. the row contains a `→ test ` token naming a real test (the fixed shape);
166
+ 2. the named test **exists** in the suite;
167
+ 3. it is **non-vacuous** — include the amendment test files in the SAME
168
+ `dz discrimination-check --test <f1,f2,...> --base HEAD --json` run as the ADR property test. An
169
+ amendment test that stays green at pre-feature base proves nothing about its amendment;
170
+ 4. a **safeguard** amendment's test proves the safeguard FIRES on a real input (a structurally-dead
171
+ safeguard passes an existence test and never fires in production).
172
+
173
+ A missing, unnamed, or vacuous amendment test is a HIGH gap. This closes the distance between "we caught
174
+ the design flaw" (challenge-panel/QCSD) and "we proved the fix works".
175
+
176
+ ### 3c. I/O-on-pure-path + fixture-swap hunt (P5)
177
+
178
+ In the TEST diff, hunt for replacements of broken/unbound fixtures with healthy ones — the old fixture was
179
+ probably a **negative control** proving a path was I/O-free; each such swap requires a compensating
180
+ negative resource-down test. In the CODE diff, hunt for new I/O (DB/network/file) on previously-pure
181
+ paths — especially startup/lifespan/health: require a negative resource-down test (broken resource → the
182
+ path degrades per its declared contract: fail-open for advisory, explicit fail-fast for load-bearing).
183
+ Missing → HIGH gap.
184
+
132
185
  ### 4. Multi-Agent Review Panel (L/XL)
133
186
 
134
187
  For L/XL features, spawn 3 parallel review agents using brutal-honesty modes:
@@ -150,6 +203,7 @@ After review findings are compiled, run a gap check:
150
203
  ITERATION {N}:
151
204
  1. Check: Every FR-{N} from requirements → has passing test or verification
152
205
  2. Check: Every ADR decision → reflected in code
206
+ 2a. Check: Every ADR Confirmation load-bearing property → has a named automated test/fitness check
153
207
  3. Check: Every critical risk from QCSD → has mitigation in code
154
208
  4. Check: Every 🔴 BLOCKER → has fix plan
155
209
 
@@ -199,6 +253,11 @@ Compile all findings into a structured report:
199
253
  ## Review Findings
200
254
  {list of findings with severity}
201
255
 
256
+ ## ADR Fitness Checklist
257
+ | ADR | Fitness | Confirmation Test Evidence | Gaps |
258
+ |-----|---------|----------------------------|------|
259
+ | ADR-001 | PASS/FAIL | {test file/name or missing} | {none or blocker} |
260
+
202
261
  ## Acceptance Criteria
203
262
  {FR-N status table}
204
263
 
@@ -1,102 +1,158 @@
1
1
  # ADR Template
2
2
 
3
- Use this template for every Architecture Decision Record.
3
+ Use this template for every Architecture Decision Record generated by feature-adr.
4
+
5
+ Template weight:
6
+ - S forced ADR: Nygard fallback.
7
+ - M: Nygard/ITD-light with drivers, options, rationale, consequences, and Confirmation.
8
+ - L/XL: MADR structure plus NHS Wales Confirmation.
9
+
10
+ Every ADR must keep the invariant core: Title, Status, Context, Decision, Consequences. Record exactly one decision per ADR.
4
11
 
5
12
  ---
6
13
 
7
14
  ```markdown
8
- # ADR-{NNN}: {Short Title of Decision}
15
+ # ADR-{NNN}: {Decision-shaped title}
9
16
 
10
17
  ## Status
11
18
 
12
- {Proposed | Accepted | Deprecated | Superseded by ADR-{M}}
19
+ proposed - Reversible until {condition}; revisit when {trigger}.
13
20
 
14
- ## Date
15
-
16
- {YYYY-MM-DD}
21
+ Allowed status values: `proposed`, `accepted`, `rejected`, `deprecated`, `superseded`.
17
22
 
18
23
  ## Context
19
24
 
20
- {What is the issue that we're seeing that is motivating this decision or change?
21
- Describe the forces at play — technical, business, political, social.
22
- Describe the problem space, not the solution.}
25
+ {Neutral problem statement written before the decision. Describe the forces, constraints, requirements, team context, and trade-offs without advocating the chosen option.}
23
26
 
24
27
  ## Decision Drivers
25
28
 
26
- - {driver 1: e.g., "Team has no experience with technology X"}
27
- - {driver 2: e.g., "Feature requires sub-100ms latency"}
28
- - {driver 3: e.g., "Must integrate with existing auth system"}
29
+ 1. {Driver D1} (weight: high|medium|low; traces to FR/NFR/constraint)
30
+ 2. {Driver D2} (weight: high|medium|low; traces to FR/NFR/constraint)
31
+ 3. {Driver D3} (weight: high|medium|low; traces to FR/NFR/constraint)
29
32
 
30
33
  ## Considered Options
31
34
 
32
- ### Option 1: {Name}
35
+ ### {Option A}
36
+
37
+ {Short description.}
33
38
 
34
- {1-2 paragraph description of this option}
39
+ Pros:
40
+ - {Real strength}
41
+ - {Real strength}
35
42
 
36
- - ✅ {Pro 1}
37
- - ✅ {Pro 2}
38
- - ❌ {Con 1}
39
- - ❌ {Con 2}
43
+ Cons:
44
+ - {Real weakness}
45
+ - {Real weakness}
40
46
 
41
- ### Option 2: {Name}
47
+ ### {Option B}
42
48
 
43
- {1-2 paragraph description}
49
+ {Short description.}
44
50
 
45
- - ✅ {Pro 1}
46
- - ❌ {Con 1}
51
+ Pros:
52
+ - {Real strength}
53
+ - {Real strength}
47
54
 
48
- ### Option 3: {Name} (optional)
55
+ Cons:
56
+ - {Real weakness}
57
+ - {Real weakness}
49
58
 
50
- {1-2 paragraph description}
59
+ ### {Option C, optional}
51
60
 
52
- - ✅ {Pro 1}
53
- - ❌ {Con 1}
61
+ {Short description.}
62
+
63
+ Pros:
64
+ - {Real strength}
65
+
66
+ Cons:
67
+ - {Real weakness}
54
68
 
55
69
  ## Decision Matrix
56
70
 
57
- | Criterion | Weight | Option 1 | Option 2 | Option 3 |
58
- |-----------|--------|----------|----------|----------|
59
- | {Criterion 1} | {1-5} | {1-5} | {1-5} | {1-5} |
60
- | {Criterion 2} | {1-5} | {1-5} | {1-5} | {1-5} |
61
- | {Criterion 3} | {1-5} | {1-5} | {1-5} | {1-5} |
62
- | **Weighted Total** | | **{sum}** | **{sum}** | **{sum}** |
71
+ Use for non-trivial M decisions and all L/XL decisions.
72
+
73
+ | Driver | Weight | Option A | Option B | Option C |
74
+ |--------|--------|----------|----------|----------|
75
+ | D1 | high | {score/rationale} | {score/rationale} | {score/rationale} |
76
+ | D2 | medium | {score/rationale} | {score/rationale} | {score/rationale} |
77
+ | D3 | low | {score/rationale} | {score/rationale} | {score/rationale} |
63
78
 
64
79
  ## Decision
65
80
 
66
- We chose **{Option N}** because {1-2 sentence rationale linking back to decision drivers}.
81
+ We will {concrete, testable choice with exact names, versions, formats, paths, commands, APIs, or conventions}.
82
+
83
+ ## Rationale
84
+
85
+ - D1: {Why the chosen option best satisfies this driver.}
86
+ - D2: {Why the chosen option best satisfies this driver.}
87
+ - Rejected {Option B}: {Why it lost despite its real strengths.}
67
88
 
68
89
  ## Consequences
69
90
 
70
91
  ### Positive
71
- - {Positive consequence 1}
72
- - {Positive consequence 2}
92
+ - {Positive consequence}
93
+ - {Positive consequence}
73
94
 
74
- ### Negative
75
- - {Negative consequence 1 — with mitigation strategy}
95
+ ### Negative / Accepted Downsides
96
+ - {Negative consequence or accepted downside} - Mitigation: {mitigation}
97
+ - {Risk with likelihood/impact if relevant} - Mitigation: {mitigation}
76
98
 
77
- ### Risks
78
- - {Risk 1} — Mitigation: {how to mitigate}
79
- - {Risk 2} — Mitigation: {how to mitigate}
99
+ ### Follow-up ADRs
100
+ - {ADR-NNN: title, or "None required now"} - {why}
80
101
 
81
- ## Links
102
+ ### After-action Review
103
+ - Owner: {person/team}
104
+ - Schedule: {about one month after acceptance, or a concrete date if known}
105
+ - Review question: Did the expected benefits and accepted downsides match reality?
82
106
 
83
- - Requirement: FR-{N}
84
- - Related: ADR-{M} (if any)
85
- ```
107
+ ## Confirmation
86
108
 
87
- ---
109
+ - Method: {How the decision is verified: automated test, fitness function, review, demo, audit}
110
+ - Monitoring: {How compliance is monitored over time}
111
+ - Success metric: {Objective pass/fail or numeric metric}
112
+ - Owner: {responsible person/team}
113
+ - Load-bearing property: {The safety property Step 8 must assert has a test}
114
+ - Required automated check: {test file/name, command, or ArchUnit/ArchUnitTS suggestion}
88
115
 
89
- ## ADR Numbering
116
+ ## Links
90
117
 
91
- - Start from 001 for each feature
92
- - Use kebab-case slugs: `001-choose-database-engine.md`
93
- - Keep sequential within a feature, no gaps
118
+ - Requirement: FR-{N} / NFR-{N}
119
+ - Related ADRs: {ADR links, typed if relevant: Refines, Supersedes, Superseded by, Follow-up}
120
+ - Evidence: {research, code path, benchmark, external source}
121
+ ```
94
122
 
95
- ## ADR Quality Checklist
123
+ ---
96
124
 
97
- - [ ] At least 2 options considered
98
- - [ ] Every option has both pros and cons
99
- - [ ] Decision matrix used for non-trivial decisions
100
- - [ ] Consequences include both positive AND negative
101
- - [ ] Risks have mitigation strategies
102
- - [ ] Links to requirements present
125
+ ## ADR Numbering and Slugs
126
+
127
+ - Start from 001 for each feature.
128
+ - Keep numbers sequential within a feature, no gaps.
129
+ - Use `NNN-{decision-slug}.md`.
130
+ - The slug must be lowercase kebab-case, present-tense imperative, dateless, and ticketless.
131
+ - Good: `001-choose-database-engine.md`, `002-enforce-adr-fitness.md`, `003-format-timestamps.md`.
132
+ - Bad: `001-database.md`, `001-ADR-1234-database.md`, `001-2026-07-08-database.md`.
133
+
134
+ ## ADR Fitness Checklist
135
+
136
+ - [ ] Title is decision-shaped and records one decision only
137
+ - [ ] Status is one of `proposed`, `accepted`, `rejected`, `deprecated`, `superseded`
138
+ - [ ] Status includes a reversibility or revisit clause
139
+ - [ ] Context is neutral and appears before Decision
140
+ - [ ] Decision drivers are ranked/weighted
141
+ - [ ] Considered options include chosen and rejected options
142
+ - [ ] Every option has symmetric pros and cons
143
+ - [ ] Rationale maps each point to a stated driver
144
+ - [ ] Rationale explains why rejected options lost
145
+ - [ ] Decision is concrete/testable with exact names, versions, formats, paths, commands, APIs, or conventions
146
+ - [ ] Consequences include positive and negative outcomes/accepted downsides
147
+ - [ ] Consequences link follow-up ADRs or explicitly say none
148
+ - [ ] Consequences schedule an after-action review
149
+ - [ ] Confirmation names verification method, monitoring, success metric, and owner
150
+ - [ ] Confirmation names the load-bearing property and required automated check
151
+ - [ ] No placeholder text, raw prompt text, or template hints remain
152
+ - [ ] The document is not an explainer masquerading as an ADR
153
+
154
+ ## Lifecycle
155
+
156
+ - Supersession mints a new ADR and links it; do not edit accepted/rejected ADR content in place.
157
+ - If an amendment is unavoidable, add a dated note that the information arrived after the decision.
158
+ - Rejected ADRs must record why the option was rejected to avoid re-litigating it.
@@ -64,6 +64,8 @@
64
64
 
65
65
  ## Step Activation by Tier
66
66
 
67
+ ADR template weight: S/M -> Nygard/ITD-light; L/XL -> MADR+Confirmation.
68
+
67
69
  ### Tier S (Score 6-8)
68
70
 
69
71
  ```
@@ -73,6 +75,7 @@ Skipped: 2, 3, 4, 5
73
75
 
74
76
  **Step adaptations:**
75
77
  - Step 1: 3-5 bullet requirements, no formal document
78
+ - Step 3: skipped by default; if explicitly forced, use Nygard as the lightweight fallback
76
79
  - Step 6: Inline in conversation, no separate file
77
80
  - Step 8: Smoke tests only — does it compile? Do existing tests pass?
78
81
 
@@ -84,7 +87,7 @@ Skipped: 2, 4, 9
84
87
  ```
85
88
 
86
89
  **Step adaptations:**
87
- - Step 3: Single ADR for the main architectural decision
90
+ - Step 3: Single Nygard/ITD-light ADR for the main architectural decision; keep the invariant core plus drivers, options, rationale, consequences, and Confirmation
88
91
  - Step 3.5: QCSD ideation swarm — 3 core agents + GO/CONDITIONAL/NO-GO verdict (mandatory for M+ — skipping is a BLOCK)
89
92
  - Step 5: Component diagram only, no full C4
90
93
 
@@ -97,7 +100,7 @@ Parallel groups: (2,3) and (4,5); Step 3.5 runs after Step 3, Step 9 after Step
97
100
 
98
101
  **Step adaptations:**
99
102
  - Step 2: Research analogues in codebase and external patterns
100
- - Step 3: Multiple ADRs for each significant decision
103
+ - Step 3: Multiple MADR+Confirmation ADRs for each significant decision
101
104
  - Step 3.5: QCSD ideation swarm — 3-9 parallel agents + GO/CONDITIONAL/NO-GO verdict (mandatory for M+ — skipping is a BLOCK)
102
105
  - Step 4: Bounded contexts + ubiquitous language
103
106
  - Step 5: Full C4 (Context + Container + Component)
@@ -113,6 +116,7 @@ Parallel groups: (2,3), (4,5 — after 3.5), (7 per module)
113
116
 
114
117
  **Step adaptations:**
115
118
  - All steps at full depth
119
+ - Step 3: Full MADR+Confirmation ADRs; one decision per ADR with typed follow-up links
116
120
  - Step 3.5: QCSD ideation swarm — 3-9 parallel agents + GO/CONDITIONAL/NO-GO verdict (mandatory for M+ — skipping is a BLOCK)
117
121
  - Step 7: Multiple parallel agents, one per module/domain
118
122
  - Step 8: Full QE — unit + integration + e2e + performance + security review