sinapse-ai 1.15.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/.claude/hooks/doc-first-gate.cjs +156 -0
  2. package/.claude/hooks/enforce-story-gate.cjs +6 -2
  3. package/.claude/rules/hook-governance.md +1 -0
  4. package/.sinapse-ai/constitution.md +1 -1
  5. package/.sinapse-ai/core/atlas/atlas-data.js +278 -0
  6. package/.sinapse-ai/core/atlas/flows-pt.js +253 -0
  7. package/.sinapse-ai/core/atlas/flows.js +266 -0
  8. package/.sinapse-ai/core/atlas/index.js +62 -0
  9. package/.sinapse-ai/core/atlas/render-html.js +216 -0
  10. package/.sinapse-ai/core/atlas/render-markdown.js +313 -0
  11. package/.sinapse-ai/core/atlas/render-research-card.js +164 -0
  12. package/.sinapse-ai/core/orchestration/build-command.js +136 -0
  13. package/.sinapse-ai/core/orchestration/doc-first-resolver.js +322 -0
  14. package/.sinapse-ai/core/orchestration/route-command.js +97 -0
  15. package/.sinapse-ai/data/entity-registry.yaml +113 -16
  16. package/.sinapse-ai/development/agents/snps-orqx.md +9 -0
  17. package/.sinapse-ai/development/tasks/create-doc.md +1 -1
  18. package/.sinapse-ai/development/tasks/create-next-story.md +2 -3
  19. package/.sinapse-ai/development/tasks/spec-analyze.md +460 -0
  20. package/.sinapse-ai/development/tasks/spec-clarify.md +374 -0
  21. package/.sinapse-ai/development/tasks/spec-gather-requirements.md +11 -0
  22. package/.sinapse-ai/development/templates/approval-table.md +106 -0
  23. package/.sinapse-ai/development/workflows/spec-pipeline.yaml +122 -7
  24. package/.sinapse-ai/install-manifest.yaml +70 -18
  25. package/.sinapse-ai/product/templates/prd-tmpl.yaml +6 -2
  26. package/.sinapse-ai/product/templates/spec-tmpl.md +18 -0
  27. package/AGENTS.md +1 -1
  28. package/CHANGELOG.md +18 -3
  29. package/bin/sinapse.js +121 -0
  30. package/docs/framework/atlas/OPERATING-ATLAS.md +537 -0
  31. package/docs/framework/atlas/README.md +34 -0
  32. package/docs/framework/atlas/atlas-data.json +2810 -0
  33. package/docs/framework/atlas/atlas.html +392 -0
  34. package/package.json +1 -1
  35. package/packages/installer/src/wizard/ide-config-generator.js +6 -0
  36. package/scripts/install-chrome-brain.sh +2 -2
  37. package/scripts/validate-no-personal-leaks.js +24 -9
  38. package/squads/squad-copy/knowledge-base/consequence-headline-patterns.md +2 -2
  39. package/docs/guides/hooks-two-layers.md +0 -66
@@ -0,0 +1,460 @@
1
+ # Spec Pipeline: Analyze Cross-Consistency
2
+
3
+ > **Phase:** 7 - Analyze (final, READ-ONLY)
4
+ > **Owner Agent:** @quality-gate
5
+ > **Pipeline:** spec-pipeline
6
+
7
+ ---
8
+
9
+ ## Purpose
10
+
11
+ Provar, antes de gastar geração de código, que cada requisito virou task e que nada contradiz a
12
+ constituição do projeto. Roda DEPOIS de `plan` (fase final do pipeline) e ANTES do handoff para
13
+ implementação. É um gate **READ-ONLY**: não modifica nenhum arquivo — apenas lê spec ↔ plan ↔ tasks
14
+ ↔ constitution, roda 6 passes de detecção e emite uma matriz requisito→task com lacunas e
15
+ inconsistências classificadas por severidade. Qualquer conflito constitucional é automaticamente
16
+ CRITICAL e bloqueia a implementação.
17
+
18
+ ---
19
+
20
+ ## autoClaude
21
+
22
+ ```yaml
23
+ autoClaude:
24
+ version: '3.0'
25
+ pipelinePhase: spec-analyze
26
+
27
+ elicit: false
28
+ deterministic: true # Same artifacts = same findings
29
+ composable: true
30
+
31
+ readOnly: true # Contract: never mutate any file
32
+ selfCritique:
33
+ required: false
34
+
35
+ inputs:
36
+ - name: storyId
37
+ type: string
38
+ required: true
39
+
40
+ - name: spec
41
+ type: file
42
+ path: docs/stories/{storyId}/spec/spec.md
43
+ required: true
44
+
45
+ - name: plan
46
+ type: file
47
+ path: docs/stories/{storyId}/spec/plan.json
48
+ required: true
49
+
50
+ - name: tasks
51
+ type: file
52
+ path: docs/stories/{storyId}/spec/tasks.md
53
+ required: false
54
+
55
+ - name: constitution
56
+ type: file
57
+ path: .sinapse-ai/constitution.md
58
+ required: true
59
+
60
+ outputs:
61
+ - name: analyze-report.json
62
+ type: file
63
+ path: docs/stories/{storyId}/spec/analyze-report.json
64
+ schema: analyze-report-schema
65
+
66
+ verification:
67
+ type: gate
68
+ blocking: true
69
+ verdict_field: gate
70
+
71
+ contextRequirements:
72
+ projectContext: true
73
+ filesContext: true
74
+ implementationPlan: true
75
+ spec: true
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Read-Only Contract
81
+
82
+ ```yaml
83
+ read_only_contract:
84
+ rule: 'This task MUST NOT modify any file. Findings become recommendations, never auto-fixes.'
85
+ rationale: 'An audit that edits the artifacts it audits cannot be trusted.'
86
+ violations:
87
+ - Editing spec.md / plan.json / tasks.md / constitution.md
88
+ - Applying "auto-fixes" to resolve findings
89
+ when_change_needed: 'Recommend the change; adjustment is done by the owner agent in a later pass.'
90
+ ```
91
+
92
+ ---
93
+
94
+ ## Detection Passes (6)
95
+
96
+ Cruze 4 artefatos: `spec.md` (FR-###, SC-###, user stories, edge cases) ↔ `plan.json`
97
+ (arquitetura, data model, fases) ↔ `tasks.md` (IDs, fases, marcador `[P]`, file paths) ↔
98
+ `constitution.md` (princípios MUST/SHOULD).
99
+
100
+ ```yaml
101
+ passes:
102
+ - id: pass-1
103
+ name: 'Duplication'
104
+ detects: 'Near-duplicate requirements; the same behavior specified twice'
105
+ default_severity: MEDIUM
106
+
107
+ - id: pass-2
108
+ name: 'Ambiguity'
109
+ detects: 'Vague adjectives (fast/scalable/secure) without a metric; TODO/??? placeholders; open [NEEDS CLARIFICATION] markers'
110
+ default_severity: HIGH
111
+
112
+ - id: pass-3
113
+ name: 'Underspecification'
114
+ detects: 'Requirement with no object/outcome; task referencing an undefined file/path'
115
+ default_severity: HIGH
116
+
117
+ - id: pass-4
118
+ name: 'Constitution Alignment'
119
+ detects: 'Conflict with a MUST principle; a mandatory constitution section absent'
120
+ default_severity: CRITICAL # Always
121
+
122
+ - id: pass-5
123
+ name: 'Coverage Gaps'
124
+ detects: 'Requirement (FR-*) with zero tasks; task with no mapped requirement; Success Criterion (SC-*) with no task'
125
+ default_severity: HIGH
126
+
127
+ - id: pass-6
128
+ name: 'Inconsistency'
129
+ detects: 'Terminology drift; entity in plan absent from spec; contradictory task ordering'
130
+ default_severity: MEDIUM
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Severity Rules
136
+
137
+ ```yaml
138
+ severity:
139
+ levels: [CRITICAL, HIGH, MEDIUM, LOW]
140
+
141
+ rules:
142
+ - 'Constitution conflict (pass-4) is ALWAYS CRITICAL — never downgraded, reinterpreted, or silently ignored.'
143
+ - 'Coverage gap on a P0/P1 requirement -> escalate to CRITICAL.'
144
+ - 'Ambiguity / Underspecification default HIGH; cosmetic-only -> LOW.'
145
+ - 'Duplication / Inconsistency default MEDIUM.'
146
+
147
+ max_findings: 50
148
+ ```
149
+
150
+ ---
151
+
152
+ ## Output: Findings Table + Metrics
153
+
154
+ A saída humana é uma tabela de findings seguida do Coverage Summary. O artefato persistido é
155
+ `analyze-report.json` (schema abaixo).
156
+
157
+ ```markdown
158
+ ## Analyze Report — {storyId}
159
+
160
+ | ID | Category | Severity | Location | Summary | Recommendation |
161
+ | --- | -------- | -------- | -------- | ------- | -------------- |
162
+ | A-1 | Constitution Alignment | CRITICAL | spec.md#3.1 ↔ constitution.md#Art-IV | Spec invents an unsourced feature | Remove or trace to FR-*/research; do not dilute Art. IV |
163
+ | A-2 | Coverage Gaps | HIGH | FR-3 ↔ tasks.md | FR-3 has zero tasks | Add a task covering FR-3 |
164
+
165
+ ### Coverage Summary
166
+
167
+ - Total Requirements: {n}
168
+ - Total Tasks: {n}
169
+ - Coverage: {covered}/{total} ({pct}%)
170
+ - Ambiguity findings: {n}
171
+ - Duplication findings: {n}
172
+ - CRITICAL count: {n}
173
+ ```
174
+
175
+ ---
176
+
177
+ ## Gate
178
+
179
+ ```yaml
180
+ gate:
181
+ order: 'Run AFTER plan, as the final phase, BEFORE handoff to implementation'
182
+ blocking: true
183
+
184
+ verdict:
185
+ PASS:
186
+ condition: 'No CRITICAL findings'
187
+ next_action: 'Proceed to implementation (@developer *develop)'
188
+ BLOCKED:
189
+ condition: 'One or more CRITICAL findings (includes ANY constitution conflict)'
190
+ next_action: |
191
+ Resolve CRITICAL findings before /implement by ADJUSTING spec / plan / tasks.
192
+ A constitution conflict MUST NOT be diluted, reinterpreted, or silently ignored.
193
+ escalate_to: '@architect'
194
+ ```
195
+
196
+ ---
197
+
198
+ ## Execution Flow
199
+
200
+ ### Step 1: Load Artifacts (read-only)
201
+
202
+ ```yaml
203
+ load:
204
+ action: gather_all_artifacts
205
+ files:
206
+ - spec.md (required)
207
+ - plan.json (required)
208
+ - tasks.md (optional)
209
+ - constitution.md (required)
210
+ guard: 'Open read-only. No write handles.'
211
+ ```
212
+
213
+ ### Step 2: Build Requirement→Task Matrix
214
+
215
+ ```yaml
216
+ build_matrix:
217
+ action: map_requirements_to_tasks
218
+ process: |
219
+ 1. Extract FR-*, NFR-*, SC-* from spec.md
220
+ 2. Extract task IDs + their referenced requirement from tasks.md
221
+ 3. Build a bidirectional map (requirement <-> tasks)
222
+ ```
223
+
224
+ ### Step 3: Run 6 Detection Passes
225
+
226
+ ```yaml
227
+ run_passes:
228
+ for_each: pass in [Duplication, Ambiguity, Underspecification, Constitution Alignment, Coverage Gaps, Inconsistency]
229
+ process: |
230
+ 1. Execute detection over the relevant artifact pair(s)
231
+ 2. Record each finding (location, summary)
232
+ 3. Assign severity (constitution conflict ALWAYS CRITICAL)
233
+ 4. Cap total findings at 50
234
+ ```
235
+
236
+ ### Step 4: Compute Metrics
237
+
238
+ ```yaml
239
+ metrics:
240
+ action: compute_coverage
241
+ fields:
242
+ - totalRequirements
243
+ - totalTasks
244
+ - coveragePct
245
+ - ambiguityCount
246
+ - duplicationCount
247
+ - criticalCount
248
+ ```
249
+
250
+ ### Step 5: Emit Report + Verdict
251
+
252
+ ```yaml
253
+ emit:
254
+ action: write_analyze_report
255
+ outputs:
256
+ - findings table (markdown, to user)
257
+ - analyze-report.json (persisted artifact)
258
+ verdict: 'BLOCKED if criticalCount > 0, else PASS'
259
+ ```
260
+
261
+ ---
262
+
263
+ ## Output Schema
264
+
265
+ ```json
266
+ {
267
+ "$schema": "http://json-schema.org/draft-07/schema#",
268
+ "type": "object",
269
+ "required": ["storyId", "analyzedAt", "gate", "findings", "metrics"],
270
+ "properties": {
271
+ "storyId": { "type": "string" },
272
+ "analyzedAt": { "type": "string", "format": "date-time" },
273
+ "analyzedBy": { "type": "string", "default": "@quality-gate" },
274
+ "readOnly": { "type": "boolean", "const": true },
275
+ "gate": { "enum": ["PASS", "BLOCKED"] },
276
+ "gateReason": { "type": "string" },
277
+ "findings": {
278
+ "type": "array",
279
+ "maxItems": 50,
280
+ "items": {
281
+ "type": "object",
282
+ "required": ["id", "category", "severity", "location", "summary", "recommendation"],
283
+ "properties": {
284
+ "id": { "type": "string", "pattern": "^A-\\d+$" },
285
+ "category": {
286
+ "enum": [
287
+ "Duplication",
288
+ "Ambiguity",
289
+ "Underspecification",
290
+ "Constitution Alignment",
291
+ "Coverage Gaps",
292
+ "Inconsistency"
293
+ ]
294
+ },
295
+ "severity": { "enum": ["CRITICAL", "HIGH", "MEDIUM", "LOW"] },
296
+ "location": { "type": "string" },
297
+ "summary": { "type": "string" },
298
+ "recommendation": { "type": "string" }
299
+ }
300
+ }
301
+ },
302
+ "metrics": {
303
+ "type": "object",
304
+ "required": ["totalRequirements", "totalTasks", "coveragePct", "criticalCount"],
305
+ "properties": {
306
+ "totalRequirements": { "type": "integer", "minimum": 0 },
307
+ "totalTasks": { "type": "integer", "minimum": 0 },
308
+ "coveragePct": { "type": "number", "minimum": 0, "maximum": 100 },
309
+ "ambiguityCount": { "type": "integer", "minimum": 0 },
310
+ "duplicationCount": { "type": "integer", "minimum": 0 },
311
+ "criticalCount": { "type": "integer", "minimum": 0 }
312
+ }
313
+ }
314
+ }
315
+ }
316
+ ```
317
+
318
+ ---
319
+
320
+ ## Integration
321
+
322
+ ### Command Integration (@quality-gate)
323
+
324
+ ```yaml
325
+ command:
326
+ name: '*analyze-spec'
327
+ syntax: '*analyze-spec {story-id}'
328
+ agent: qa
329
+
330
+ examples:
331
+ - '*analyze-spec STORY-42'
332
+ ```
333
+
334
+ ### Pipeline Integration
335
+
336
+ ```yaml
337
+ pipeline:
338
+ phase: analyze
339
+ previous_phase: plan
340
+ next_phase: none # Final phase - hands off to implementation (SDC)
341
+
342
+ requires:
343
+ - spec.md
344
+ - plan.json
345
+ - constitution.md
346
+
347
+ optional:
348
+ - tasks.md
349
+
350
+ gate: true # Blocking gate
351
+ readOnly: true
352
+
353
+ on_verdict:
354
+ PASS:
355
+ action: handoff_to_implementation
356
+ BLOCKED:
357
+ action: halt
358
+ escalate_to: '@architect'
359
+ ```
360
+
361
+ ---
362
+
363
+ ## Error Handling
364
+
365
+ ```yaml
366
+ errors:
367
+ - id: missing-spec
368
+ condition: 'spec.md not found'
369
+ action: 'Halt - cannot analyze without a spec'
370
+ blocking: true
371
+
372
+ - id: missing-plan
373
+ condition: 'plan.json not found'
374
+ action: 'Halt - analyze runs after plan'
375
+ blocking: true
376
+
377
+ - id: missing-tasks
378
+ condition: 'tasks.md not found'
379
+ action: 'Run with reduced coverage analysis; flag tasks coverage as UNKNOWN'
380
+ blocking: false
381
+
382
+ - id: missing-constitution
383
+ condition: 'constitution.md not found'
384
+ action: 'Halt - constitution alignment pass cannot run'
385
+ blocking: true
386
+ ```
387
+
388
+ ---
389
+
390
+ ## Examples
391
+
392
+ ### Example: BLOCKED on constitution conflict + coverage gap
393
+
394
+ **Input:** spec.md adds a feature with no FR source; FR-3 has no task.
395
+
396
+ **Output:**
397
+
398
+ ```json
399
+ {
400
+ "storyId": "STORY-42",
401
+ "analyzedBy": "@quality-gate",
402
+ "readOnly": true,
403
+ "gate": "BLOCKED",
404
+ "gateReason": "1 CRITICAL (constitution conflict) + 1 HIGH (coverage gap)",
405
+ "findings": [
406
+ {
407
+ "id": "A-1",
408
+ "category": "Constitution Alignment",
409
+ "severity": "CRITICAL",
410
+ "location": "spec.md#3.1 ↔ constitution.md#Article-IV",
411
+ "summary": "Spec includes a feature with no FR/research source (No Invention)",
412
+ "recommendation": "Remove the feature or trace it to a requirement; do not dilute Article IV"
413
+ },
414
+ {
415
+ "id": "A-2",
416
+ "category": "Coverage Gaps",
417
+ "severity": "HIGH",
418
+ "location": "FR-3 ↔ tasks.md",
419
+ "summary": "FR-3 has zero tasks",
420
+ "recommendation": "Add at least one task covering FR-3"
421
+ }
422
+ ],
423
+ "metrics": {
424
+ "totalRequirements": 5,
425
+ "totalTasks": 7,
426
+ "coveragePct": 80,
427
+ "ambiguityCount": 0,
428
+ "duplicationCount": 0,
429
+ "criticalCount": 1
430
+ }
431
+ }
432
+ ```
433
+
434
+ ---
435
+
436
+ ## Metadata
437
+
438
+ ```yaml
439
+ metadata:
440
+ story: '3.7'
441
+ epic: 'Epic 3 - Spec Pipeline'
442
+ created: '2026-06-24'
443
+ author: '@quality-gate (Litmus)'
444
+ version: '1.0.0'
445
+ source: 'GitHub Spec Kit — templates/commands/analyze.md'
446
+ tags:
447
+ - spec-pipeline
448
+ - analyze
449
+ - consistency
450
+ - constitution
451
+ - read-only
452
+ - quality-gate
453
+ ```
454
+
455
+ ## Handoff
456
+ next_agent: @developer
457
+ next_command: *develop {story-id}
458
+ condition: Analyze gate is PASS (no CRITICAL findings)
459
+ alternatives:
460
+ - agent: @architect, command: *analyze-impact, condition: Analyze gate is BLOCKED (CRITICAL findings open)