@cleocode/core 2026.4.4 → 2026.4.6

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 (145) hide show
  1. package/dist/discovery.d.ts +69 -0
  2. package/dist/discovery.d.ts.map +1 -0
  3. package/dist/index.d.ts +3 -2
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1643 -2349
  6. package/dist/index.js.map +4 -4
  7. package/dist/init.d.ts +51 -0
  8. package/dist/init.d.ts.map +1 -1
  9. package/dist/internal.d.ts +9 -1
  10. package/dist/internal.d.ts.map +1 -1
  11. package/dist/lifecycle/default-chain.d.ts +8 -2
  12. package/dist/lifecycle/default-chain.d.ts.map +1 -1
  13. package/dist/lifecycle/index.d.ts +1 -0
  14. package/dist/lifecycle/index.d.ts.map +1 -1
  15. package/dist/lifecycle/stage-guidance.d.ts +140 -0
  16. package/dist/lifecycle/stage-guidance.d.ts.map +1 -0
  17. package/dist/orchestration/protocol-validators.d.ts +122 -3
  18. package/dist/orchestration/protocol-validators.d.ts.map +1 -1
  19. package/dist/paths.d.ts +91 -0
  20. package/dist/paths.d.ts.map +1 -1
  21. package/dist/scaffold.d.ts +31 -1
  22. package/dist/scaffold.d.ts.map +1 -1
  23. package/dist/skills/dispatch.d.ts +1 -1
  24. package/dist/skills/skill-paths.d.ts +9 -6
  25. package/dist/skills/skill-paths.d.ts.map +1 -1
  26. package/dist/validation/protocols/_shared.d.ts +40 -0
  27. package/dist/validation/protocols/_shared.d.ts.map +1 -0
  28. package/dist/validation/protocols/architecture-decision.d.ts +23 -0
  29. package/dist/validation/protocols/architecture-decision.d.ts.map +1 -0
  30. package/dist/validation/protocols/artifact-publish.d.ts +22 -0
  31. package/dist/validation/protocols/artifact-publish.d.ts.map +1 -0
  32. package/dist/validation/protocols/consensus.d.ts +11 -17
  33. package/dist/validation/protocols/consensus.d.ts.map +1 -1
  34. package/dist/validation/protocols/contribution.d.ts +12 -17
  35. package/dist/validation/protocols/contribution.d.ts.map +1 -1
  36. package/dist/validation/protocols/decomposition.d.ts +18 -21
  37. package/dist/validation/protocols/decomposition.d.ts.map +1 -1
  38. package/dist/validation/protocols/implementation.d.ts +9 -17
  39. package/dist/validation/protocols/implementation.d.ts.map +1 -1
  40. package/dist/validation/protocols/provenance.d.ts +23 -0
  41. package/dist/validation/protocols/provenance.d.ts.map +1 -0
  42. package/dist/validation/protocols/release.d.ts +25 -0
  43. package/dist/validation/protocols/release.d.ts.map +1 -0
  44. package/dist/validation/protocols/research.d.ts +9 -17
  45. package/dist/validation/protocols/research.d.ts.map +1 -1
  46. package/dist/validation/protocols/specification.d.ts +7 -17
  47. package/dist/validation/protocols/specification.d.ts.map +1 -1
  48. package/dist/validation/protocols/testing.d.ts +22 -0
  49. package/dist/validation/protocols/testing.d.ts.map +1 -0
  50. package/dist/validation/protocols/validation.d.ts +22 -0
  51. package/dist/validation/protocols/validation.d.ts.map +1 -0
  52. package/package.json +7 -7
  53. package/src/__tests__/injection-mvi-tiers.test.js +54 -90
  54. package/src/__tests__/injection-mvi-tiers.test.js.map +1 -1
  55. package/src/discovery.ts +235 -0
  56. package/src/hooks/handlers/__tests__/hook-automation-e2e.test.js +3 -1
  57. package/src/hooks/handlers/__tests__/hook-automation-e2e.test.js.map +1 -1
  58. package/src/index.ts +16 -0
  59. package/src/init.ts +196 -0
  60. package/src/internal.ts +31 -1
  61. package/src/lifecycle/default-chain.ts +11 -2
  62. package/src/lifecycle/index.ts +10 -0
  63. package/src/lifecycle/stage-guidance.ts +282 -0
  64. package/src/metrics/__tests__/provider-detection.test.js +19 -7
  65. package/src/metrics/__tests__/provider-detection.test.js.map +1 -1
  66. package/src/metrics/__tests__/provider-detection.test.ts +19 -7
  67. package/src/orchestration/__tests__/protocol-validators.test.js +228 -8
  68. package/src/orchestration/__tests__/protocol-validators.test.js.map +1 -1
  69. package/src/orchestration/__tests__/protocol-validators.test.ts +259 -7
  70. package/src/orchestration/protocol-validators.ts +419 -4
  71. package/src/paths.ts +110 -0
  72. package/src/scaffold.ts +240 -4
  73. package/src/skills/dispatch.ts +6 -6
  74. package/src/skills/skill-paths.ts +27 -23
  75. package/src/validation/protocols/_shared.ts +88 -0
  76. package/src/validation/protocols/architecture-decision.ts +52 -0
  77. package/src/validation/protocols/artifact-publish.ts +49 -0
  78. package/src/validation/protocols/consensus.ts +44 -74
  79. package/src/validation/protocols/contribution.ts +28 -65
  80. package/src/validation/protocols/decomposition.ts +37 -64
  81. package/src/validation/protocols/implementation.ts +25 -65
  82. package/src/validation/protocols/protocols-markdown/architecture-decision.md +303 -0
  83. package/src/validation/protocols/protocols-markdown/artifact-publish.md +600 -0
  84. package/src/validation/protocols/protocols-markdown/consensus.md +322 -0
  85. package/src/validation/protocols/protocols-markdown/contribution.md +388 -0
  86. package/src/validation/protocols/protocols-markdown/decomposition.md +421 -0
  87. package/src/validation/protocols/protocols-markdown/implementation.md +357 -0
  88. package/src/validation/protocols/protocols-markdown/provenance.md +613 -0
  89. package/src/validation/protocols/protocols-markdown/release.md +783 -0
  90. package/src/validation/protocols/protocols-markdown/research.md +261 -0
  91. package/src/validation/protocols/protocols-markdown/specification.md +300 -0
  92. package/src/validation/protocols/protocols-markdown/testing.md +287 -0
  93. package/src/validation/protocols/protocols-markdown/validation.md +242 -0
  94. package/src/validation/protocols/provenance.ts +50 -0
  95. package/src/validation/protocols/release.ts +44 -0
  96. package/src/validation/protocols/research.ts +25 -87
  97. package/src/validation/protocols/specification.ts +27 -89
  98. package/src/validation/protocols/testing.ts +46 -0
  99. package/src/validation/protocols/validation.ts +46 -0
  100. package/dist/validation/protocols/release-protocol.d.ts +0 -27
  101. package/dist/validation/protocols/release-protocol.d.ts.map +0 -1
  102. package/dist/validation/protocols/testing-protocol.d.ts +0 -27
  103. package/dist/validation/protocols/testing-protocol.d.ts.map +0 -1
  104. package/dist/validation/protocols/validation-protocol.d.ts +0 -27
  105. package/dist/validation/protocols/validation-protocol.d.ts.map +0 -1
  106. package/schemas/agent-configs.schema.json +0 -120
  107. package/schemas/agent-registry.schema.json +0 -132
  108. package/schemas/archive.schema.json +0 -450
  109. package/schemas/brain-decision.schema.json +0 -69
  110. package/schemas/brain-learning.schema.json +0 -57
  111. package/schemas/brain-pattern.schema.json +0 -72
  112. package/schemas/critical-path.schema.json +0 -246
  113. package/schemas/deps-cache.schema.json +0 -97
  114. package/schemas/doctor-output.schema.json +0 -283
  115. package/schemas/error.schema.json +0 -161
  116. package/schemas/global-config.schema.json +0 -219
  117. package/schemas/grade.schema.json +0 -49
  118. package/schemas/log.schema.json +0 -250
  119. package/schemas/metrics.schema.json +0 -328
  120. package/schemas/migrations.schema.json +0 -150
  121. package/schemas/nexus-registry.schema.json +0 -90
  122. package/schemas/operation-constitution.schema.json +0 -438
  123. package/schemas/output.schema.json +0 -164
  124. package/schemas/projects-registry.schema.json +0 -107
  125. package/schemas/protocol-frontmatter.schema.json +0 -72
  126. package/schemas/rcasd-consensus-report.schema.json +0 -10
  127. package/schemas/rcasd-evidence.schema.json +0 -42
  128. package/schemas/rcasd-gate-result.schema.json +0 -46
  129. package/schemas/rcasd-hitl-resolution.schema.json +0 -10
  130. package/schemas/rcasd-index.schema.json +0 -10
  131. package/schemas/rcasd-manifest.schema.json +0 -10
  132. package/schemas/rcasd-research-output.schema.json +0 -10
  133. package/schemas/rcasd-spec-frontmatter.schema.json +0 -10
  134. package/schemas/rcasd-stage-transition.schema.json +0 -38
  135. package/schemas/releases.schema.json +0 -267
  136. package/schemas/skills-manifest.schema.json +0 -91
  137. package/schemas/spec-index.schema.json +0 -196
  138. package/schemas/system-flow-atlas.schema.json +0 -125
  139. package/src/conduit/__tests__/dual-api-e2e.test.d.ts.map +0 -1
  140. package/src/conduit/__tests__/dual-api-e2e.test.js +0 -178
  141. package/src/conduit/__tests__/dual-api-e2e.test.js.map +0 -1
  142. package/src/conduit/__tests__/dual-api-e2e.test.ts +0 -212
  143. package/src/validation/protocols/release-protocol.ts +0 -80
  144. package/src/validation/protocols/testing-protocol.ts +0 -93
  145. package/src/validation/protocols/validation-protocol.ts +0 -93
@@ -0,0 +1,303 @@
1
+ ---
2
+ id: ADR
3
+ title: Architecture Decision Record Protocol
4
+ version: 1.0.0
5
+ status: active
6
+ type: conditional
7
+ audience: [llm-agent, orchestrator]
8
+ tags: [adr, architecture, decisions]
9
+ skillRef: ct-adr-recorder
10
+ lastUpdated: 2026-04-07
11
+ enforcement: advisory
12
+ ---
13
+
14
+ # Architecture Decision Record (ADR) Protocol
15
+
16
+ **Provenance**: @task T4798 (ADR-006 Implementation)
17
+ **Version**: 1.1.0
18
+ **Type**: Conditional Protocol
19
+ **Stage**: RCADSD - A (ADR)
20
+ **Max Active**: 3 protocols (including base)
21
+
22
+ ---
23
+
24
+ ## Trigger Conditions
25
+
26
+ This protocol activates when the task involves:
27
+
28
+ | Trigger | Keywords | Context |
29
+ |---------|----------|---------|
30
+ | Decision Recording | "decision", "adr", "architecture decision" | Formalizing a consensus verdict |
31
+ | Stage Transition | "after consensus", "begin adr" | Pipeline progression from consensus |
32
+ | Formalization | "lock in decision", "formalize choice", "decide" | Approving a consensus outcome |
33
+ | Architectural Shift | "pivot", "new architecture", "supersede" | Modifying technical direction |
34
+ | Record Creation | "create adr", "write adr", "record decision" | Explicit decision documentation |
35
+
36
+ **Explicit Override**: `--protocol adr` flag on task creation.
37
+
38
+ ---
39
+
40
+ ## Requirements (RFC 2119)
41
+
42
+ ### MUST
43
+
44
+ | Requirement | Description |
45
+ |-------------|-------------|
46
+ | ADR-001 | MUST be generated from an accepted Consensus report verdict. |
47
+ | ADR-002 | MUST include a `consensus_manifest_id` linking to its originating consensus. |
48
+ | ADR-003 | MUST require explicit HITL (Human-in-the-Loop) approval to transition from `proposed` to `accepted`. |
49
+ | ADR-004 | MUST include Context, Options Evaluated, Decision, Rationale, and Consequences sections. |
50
+ | ADR-005 | MUST trigger downstream invalidation: if superseded, all downstream Specifications, Decompositions, and Implementations MUST be flagged for review. |
51
+ | ADR-006 | MUST be stored in the canonical `decisions` SQLite table via Drizzle ORM. |
52
+ | ADR-007 | MUST set `agent_type: "decision"` in manifest entry. |
53
+ | ADR-008 | MUST block the Specification stage until the ADR status is `accepted`. |
54
+
55
+ ### SHOULD
56
+
57
+ | Requirement | Description |
58
+ |-------------|-------------|
59
+ | ADR-010 | SHOULD document the exact data structures or schema changes required by the decision. |
60
+ | ADR-011 | SHOULD explicitly list which existing ADRs (if any) are superseded, with rationale. |
61
+ | ADR-012 | SHOULD flag known technical debt introduced by the decision. |
62
+ | ADR-013 | SHOULD document rejected alternatives with rationale for rejection. |
63
+
64
+ ### MAY
65
+
66
+ | Requirement | Description |
67
+ |-------------|-------------|
68
+ | ADR-020 | MAY include diagrams (Mermaid) illustrating the architectural shift. |
69
+ | ADR-021 | MAY link to external prior art or research documents. |
70
+ | ADR-022 | MAY reference related ADRs that are not superseded but are contextually relevant. |
71
+
72
+ ---
73
+
74
+ ## Output Format
75
+
76
+ ### Decision Status Lifecycle
77
+
78
+ ```
79
+ proposed -> accepted -> superseded
80
+ \-> deprecated
81
+ ```
82
+
83
+ | Status | Definition | Transition From | Requires |
84
+ |--------|------------|-----------------|----------|
85
+ | `proposed` | Drafted pending HITL review | (initial) | Consensus report link |
86
+ | `accepted` | Approved via HITL review | `proposed` | Human approval |
87
+ | `superseded` | Replaced by a newer decision | `accepted` | New ADR ID |
88
+ | `deprecated` | No longer applicable, not replaced | `accepted` | Deprecation reason |
89
+
90
+ ### Frontmatter (Markdown Representation)
91
+
92
+ While the canonical record lives in SQLite, the markdown artifact MUST contain this frontmatter:
93
+
94
+ ```yaml
95
+ ---
96
+ id: ADR-XXX
97
+ title: "{Decision Title}"
98
+ status: proposed | accepted | superseded | deprecated
99
+ date: YYYY-MM-DD
100
+ consensus_manifest_id: {Manifest ID of the consensus verdict}
101
+ supersedes: [ADR-YYY]
102
+ superseded_by: [ADR-ZZZ]
103
+ ---
104
+ ```
105
+
106
+ ### Document Structure
107
+
108
+ ```markdown
109
+ # ADR-XXX: {Decision Title}
110
+
111
+ ## 1. Context and Problem Statement
112
+ {What is the issue that is motivating this decision or change?}
113
+
114
+ ## 2. Options Evaluated
115
+ {Derived from the Research and Consensus stages. List the options that were considered.}
116
+ * Option 1: {Description}
117
+ * Option 2: {Description}
118
+
119
+ ## 3. Decision
120
+ {The exact, unambiguous technical decision.}
121
+
122
+ ## 4. Rationale
123
+ {Why was this option chosen? Reference the consensus debate.}
124
+
125
+ ## 5. Consequences
126
+ ### Positive
127
+ * {Benefit}
128
+ ### Negative
129
+ * {Trade-off}
130
+
131
+ ## 6. Downstream Impact (Traceability)
132
+ {List the systems, specs, or decomposition epics that must be updated because of this decision.}
133
+ ```
134
+
135
+ ### File Output
136
+
137
+ ```markdown
138
+ # ADR-XXX: {Decision Title}
139
+
140
+ **Task**: T####
141
+ **Epic**: T####
142
+ **Date**: YYYY-MM-DD
143
+ **Status**: complete|partial|blocked
144
+ **Agent Type**: decision
145
+
146
+ ---
147
+
148
+ ## Summary
149
+
150
+ {2-3 sentence summary of the decision and its rationale}
151
+
152
+ ## Decision
153
+
154
+ {The exact technical decision made}
155
+
156
+ ## Key Consequences
157
+
158
+ | Impact | Description |
159
+ |--------|-------------|
160
+ | Positive | {Benefit 1} |
161
+ | Positive | {Benefit 2} |
162
+ | Negative | {Trade-off 1} |
163
+
164
+ ## Supersession Chain
165
+
166
+ | ADR | Relationship | Status |
167
+ |-----|-------------|--------|
168
+ | ADR-YYY | Supersedes | superseded |
169
+ | ADR-ZZZ | Superseded by | (none yet) |
170
+ ```
171
+
172
+ ### Manifest Entry
173
+
174
+ @skills/_shared/manifest-operations.md
175
+
176
+ Use `cleo research add` to create the manifest entry:
177
+
178
+ ```bash
179
+ cleo research add \
180
+ --title "ADR: Decision Title" \
181
+ --file "YYYY-MM-DD_adr-topic.md" \
182
+ --topics "adr,decision,architecture" \
183
+ --findings "Decision accepted,Option B selected,Supersedes ADR-YYY" \
184
+ --status complete \
185
+ --task T#### \
186
+ --epic T#### \
187
+ --actionable \
188
+ --agent-type decision
189
+ ```
190
+
191
+ ---
192
+
193
+ ## Integration Points
194
+
195
+ ### Base Protocol
196
+
197
+ - Inherits task lifecycle (start, execute, complete)
198
+ - Inherits manifest append requirement
199
+ - Inherits error handling patterns
200
+
201
+ ### Protocol Interactions
202
+
203
+ | Combined With | Behavior |
204
+ |---------------|----------|
205
+ | research | Research provides evidence cited in the ADR context |
206
+ | consensus | Consensus produces the verdict that the ADR captures |
207
+ | specification | ADR acceptance gates the specification stage |
208
+ | decomposition | ADR governs which specification the decomposition implements |
209
+
210
+ ### Pipeline Integration (RCADSD-ICR)
211
+
212
+ #### The HITL Gate
213
+
214
+ 1. Agent drafts the ADR based on consensus verdict.
215
+ 2. Status is set to `proposed`.
216
+ 3. Pipeline pauses (`HANDOFF_REQUIRED` - exit code 65).
217
+ 4. Human reviews the proposed ADR.
218
+ 5. If approved, status transitions to `accepted`.
219
+ 6. Only an `accepted` ADR unlocks the **Specification** stage.
220
+
221
+ #### Stage Sequencing
222
+
223
+ ```
224
+ Consensus (completed)
225
+ |
226
+ v
227
+ ADR (proposed -> HITL -> accepted)
228
+ |
229
+ v
230
+ Specification (unblocked)
231
+ ```
232
+
233
+ ### HITL Escalation
234
+
235
+ | Condition | Action |
236
+ |-----------|--------|
237
+ | ADR drafted as `proposed` | Present to human for review and acceptance |
238
+ | Contested consensus verdict (no clear winner) | Flag in ADR context, request human tiebreak |
239
+ | Supersession of accepted ADR | Alert human: downstream artifacts need review |
240
+ | ADR contradicts existing accepted ADR | Require explicit supersession or rejection |
241
+
242
+ ### Downstream Invalidation (Cascade)
243
+
244
+ If an `accepted` ADR is later marked as `superseded`:
245
+ 1. The pipeline MUST identify all linked Specifications (via SQLite `decision_evidence` relations).
246
+ 2. The pipeline MUST flag the linked Epic's Decomposition as `needs-review`.
247
+ 3. Any active `implementation` or `contribution` stages relying on the superseded ADR MUST be suspended until the Specification and Decomposition stages have been reconciled with the new ADR.
248
+
249
+ ---
250
+
251
+ ## Example
252
+
253
+ **Task**: Record architecture decision for canonical SQLite storage
254
+
255
+ **Flow**:
256
+ 1. Research (T4790) investigated storage strategies: JSON, JSONL, SQLite, hybrid
257
+ 2. Consensus (T4797) reached: PROVEN verdict for SQLite-only with 90% confidence
258
+ 3. ADR (T4798) captures the decision as ADR-006
259
+ 4. HITL reviews and accepts ADR-006
260
+ 5. Specification (T4776) formalizes the schema and migration requirements
261
+
262
+ **Manifest Entry Command**:
263
+ ```bash
264
+ cleo research add \
265
+ --title "ADR: Canonical SQLite Storage Architecture" \
266
+ --file "2026-02-21_adr-006-sqlite-storage.md" \
267
+ --topics "adr,architecture,sqlite,storage" \
268
+ --findings "SQLite canonical for all operational data,JSON reserved for config only,Supersedes ADR-001 and ADR-002" \
269
+ --status complete \
270
+ --task T4798 \
271
+ --epic T4772 \
272
+ --actionable \
273
+ --needs-followup T4776 \
274
+ --agent-type decision
275
+ ```
276
+
277
+ ---
278
+
279
+ ## Exit Codes
280
+
281
+ | Code | Name | When |
282
+ |------|------|------|
283
+ | 65 | `HANDOFF_REQUIRED` | ADR drafted as `proposed`, awaiting HITL acceptance |
284
+ | 84 | `PROVENANCE_REQUIRED` | Attempted to create an ADR without a linked Consensus report |
285
+ | 18 | `CASCADE_FAILED` | Downstream work blocked because the governing ADR was superseded |
286
+
287
+ ---
288
+
289
+ ## Anti-Patterns
290
+
291
+ | Pattern | Why Avoid |
292
+ |---------|-----------|
293
+ | Creating ADR without consensus | Decisions lack evidence foundation (violates ADR-001) |
294
+ | Auto-accepting without HITL review | Bypasses human oversight gate (violates ADR-003) |
295
+ | Omitting downstream impact section | Future implementers unaware of cascade effects |
296
+ | Superseding without updating specs | Creates orphaned specifications referencing outdated decisions |
297
+ | Using ADR to define implementation requirements | That is the Specification's role; ADR captures the decision, not the how |
298
+ | Storing ADR only as markdown without SQLite record | Loses relational queries, lifecycle tracking, and evidence chain (violates ADR-006) |
299
+ | Skipping rejected alternatives | Loses institutional knowledge of why other options were ruled out |
300
+
301
+ ---
302
+
303
+ *Protocol Version 1.1.0 - Architecture Decision Record Protocol*