@guilhermefsousa/open-spec-kit 0.0.6 → 0.0.7

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": "@guilhermefsousa/open-spec-kit",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "CLI para spec-driven development com suporte a Claude Code e GitHub Copilot",
5
5
  "type": "module",
6
6
  "bin": {
@@ -84,13 +84,16 @@ specs/NNN-nome/
84
84
  links.md ← PRs + link da feature page
85
85
  audit-report.md ← resultado do self-review do /spec
86
86
  conformance-report.json ← validação pós-implementação do /dev
87
+ conformance-history.log ← histórico de validações (append por run)
88
+ openapi.yaml ← stub OpenAPI 3.0 (opcional, se REST endpoints)
87
89
  ```
88
90
 
89
91
  ## Validation checklist
90
92
 
91
93
  - [ ] Brief máx 1 página
92
94
  - [ ] Todo cenário tem Given/When/Then
93
- - [ ] Cenários de falha cobertos
95
+ - [ ] Cenários de falha cobertos (401, 403, input validation 400)
96
+ - [ ] Cenários de NFR cobertos (se PRD tem Requisitos Não-Funcionais)
94
97
  - [ ] Tasks agrupadas por repo (per projects.yml)
95
98
  - [ ] Dependências explícitas
96
99
  - [ ] Cada task = 1 PR
@@ -24,7 +24,8 @@ applyTo: '**/*.md'
24
24
 
25
25
  1. Created: spec directory with brief + scenarios + contracts + tasks
26
26
  2. In progress: tasks are checked off, links.md tracks PRs
27
- 3. Done: all tasks checked, spec directory stays (it IS the history)
27
+ 3. Post-merge sync: if implementation diverged intentionally from spec, /dev updates contracts.md and scenarios.md to match reality (Phase D.1.5)
28
+ 4. Done: all tasks checked, spec directory stays (it IS the history)
28
29
 
29
30
  Specs are NOT archived or moved. The spec directory with checked tasks IS the record.
30
31
 
@@ -39,6 +40,8 @@ Specs are NOT archived or moved. The spec directory with checked tasks IS the re
39
40
  | PR tracking | `specs/<spec>/links.md` |
40
41
  | Spec quality audit | `specs/<spec>/audit-report.md` |
41
42
  | Implementation conformance | `specs/<spec>/conformance-report.json` |
43
+ | Conformance history | `specs/<spec>/conformance-history.log` |
44
+ | OpenAPI stub (optional) | `specs/<spec>/openapi.yaml` |
42
45
  | Architecture overview | `docs/architecture.md` |
43
46
  | Architecture decisions | `docs/decisions/ADR-NNN.md` |
44
47
  | Lessons learned | `docs/lessons/NNN-title.md` |
@@ -6,7 +6,7 @@ applyTo: '**/*.md'
6
6
 
7
7
  # Rule: Artifact Ownership (RACI)
8
8
 
9
- Every artifact in this project has exactly **one Owner** (creates it) and at most **one Updater** (can modify it after creation). Other skills may **Read** or **Validate**, but never **Write**.
9
+ Every artifact in this project has exactly **one Owner** (creates it) and one or more designated **Updaters** (can modify it after creation under specific conditions). Other skills may **Read** or **Validate**, but never **Write**.
10
10
 
11
11
  This rule exists to prevent the "duplicate responsibility" anti-pattern where multiple skills update the same artifact with no clear authority, causing drift and conflicts.
12
12
 
@@ -16,12 +16,8 @@ This rule exists to prevent the "duplicate responsibility" anti-pattern where mu
16
16
  |----------|----------------|---------|---------|------------|
17
17
  | Demandas/ labels | /setup | — | /discovery | — |
18
18
  | Visão do Produto | /setup | — | all | — |
19
- | **Glossário** | /setup | **/discovery** (adds domain terms found in PRD analysis, exit gate), **/dev** (post-merge only — adds terms that emerged during implementation and weren't in the PRD) | /spec | /spec (read-only validate — if terms are missing, stop and ask dev to re-run /discovery) |
20
-
21
- > **Glossário conflict rule**: if /dev (post-merge) needs to update a term that /discovery defined, /dev's update wins — it reflects implemented reality. /dev adds a note: "Atualizado pós-merge: {reason}". If /dev adds a term that already exists with a different definition, update the definition to match implementation.
22
- | DD (Design Document) | /spec (via `design-doc` agent, fallback: MCP direct) | /dev (via `design-doc` agent, fallback: MCP direct) | — | — |
23
-
24
- > **DD update coordination**: /spec updates the DD FIRST (during spec phase), /dev updates AFTER MERGE (during Phase D). If /dev needs to change something /spec wrote, /dev overwrites with implemented reality (code is source of truth post-merge). No locking needed — the sequential workflow prevents simultaneous updates.
19
+ | Glossário | /setup | /discovery (exit gate), /dev (post-merge only) | /spec | /spec (read-only validate) |
20
+ | DD (Design Document) | /spec (via `design-doc` agent) | /dev (post-merge, via `design-doc` agent) | — | — |
25
21
  | Domínio/Regras | /setup | /dev (post-merge only) | /discovery, /spec | — |
26
22
  | Domínio/Fluxos | /setup | /dev (post-merge only) | /discovery | — |
27
23
  | Domínio/Tabelas | /setup | — | /discovery | — |
@@ -31,28 +27,35 @@ This rule exists to prevent the "duplicate responsibility" anti-pattern where mu
31
27
  | Feature labels | each skill at its transition | — | all | — |
32
28
  | Arquivados/ | /setup | — | — | — |
33
29
 
30
+ **Glossário conflict rule**: if /dev (post-merge) needs to update a term that /discovery defined, /dev's update wins — it reflects implemented reality. /dev adds a note: "Atualizado pós-merge: {reason}".
31
+
32
+ **DD update coordination**: /spec updates the DD FIRST (during spec phase), /dev updates AFTER MERGE (during Phase D). If /dev needs to change something /spec wrote, /dev overwrites with implemented reality (code is source of truth post-merge). No locking needed — the sequential workflow prevents simultaneous updates.
33
+
34
34
  ## Local Artifacts
35
35
 
36
36
  | Artifact | Owner (creates) | Updater | Readers | Validators |
37
37
  |----------|----------------|---------|---------|------------|
38
38
  | `projects.yml` | /setup | /spec (adds planned repos), /dev (repo URLs + status) | all | — |
39
- | `docs/architecture.md` | /setup | /discovery (resolves decisions), /dev (adds decisions discovered during implementation — post-merge only) | /spec, /dev | /spec (validates no blockers) |
39
+ | `docs/architecture.md` | /setup | /discovery (resolves decisions), /dev (adds resolved decisions post-merge) | /spec, /dev | /spec (validates no blockers) |
40
40
  | `docs/lessons/` | /dev | /dev | all | — |
41
41
  | `docs/decisions/` | manual / spec-agent | — | all | — |
42
+ | `docs/pending-confluence-updates.md` | any skill (on MCP failure) | any skill (on retry) | all | — |
42
43
  | `specs/NNN/brief.md` | /spec | — | /dev | — |
43
- | `specs/NNN/scenarios.md` | /spec | — | /dev | — |
44
- | `specs/NNN/contracts.md` | /spec | — | /dev | — |
44
+ | `specs/NNN/scenarios.md` | /spec | /dev (post-merge sync D.1.5 only if conformance report shows intentional divergence) | /dev | — |
45
+ | `specs/NNN/contracts.md` | /spec | /dev (post-merge sync D.1.5 only if conformance report shows intentional divergence) | /dev | — |
45
46
  | `specs/NNN/tasks.md` | /spec | — | /dev | — |
46
47
  | `specs/NNN/links.md` | /spec (template) | /dev (MR links) | — | — |
47
48
  | `specs/NNN/audit-report.md` | /spec (self-review) | — | /dev (reads before Phase B, blocks if ❌) | — |
49
+ | `specs/NNN/openapi.yaml` | /spec (optional, if REST endpoints) | /dev (may extend) | — | — |
48
50
  | `specs/NNN/conformance-report.json` | /dev (Phase C.3) | /dev (overwrites per run) | CI Guard | — |
49
51
  | `specs/NNN/conformance-history.log` | /dev (Phase C.3) | /dev (appends per run) | — | — |
52
+ | `CHANGELOG.md` (impl repo) | /dev (Phase D.4.5) | /dev | all | — |
50
53
 
51
- > **Conformance versioning**: `conformance-report.json` is overwritten on each /dev run. To preserve history, /dev appends a summary line to `specs/NNN/conformance-history.log`: `{timestamp} | {result} | {matching}/{total} endpoints | {matching}/{total} fields`
54
+ **Conformance versioning**: `conformance-report.json` is overwritten on each /dev run. To preserve history, /dev appends a summary line to `specs/NNN/conformance-history.log`: `{timestamp} | {result} | {matching}/{total} endpoints | {matching}/{total} fields`
52
55
 
53
56
  ## Key Rules
54
57
 
55
- 1. **One Writer per artifact** — if two skills both write to the same artifact, one of them is wrong. The matrix above is the source of truth.
58
+ 1. **One Owner per artifact** — each artifact has exactly one Owner that creates it. Updaters are explicitly designated in the matrix above with conditions (e.g., "post-merge only"). If a skill writes to an artifact where it is not listed as Owner or Updater, it is wrong.
56
59
 
57
60
  2. **Validate ≠ Update** — /spec validates the Glossário (checks all terms are present) but does NOT add terms. If terms are missing, it stops and asks the dev to re-run /discovery.
58
61
 
@@ -118,7 +121,7 @@ The `docs/architecture.md` "Decisões em Aberto" table uses this schema:
118
121
 
119
122
  Status values: `aberta`, `resolvida — [decisão tomada]`
120
123
 
121
- Only /discovery updates this column (exit gate). /spec validates that no `aberta` decision blocks /dev.
124
+ /discovery updates this column during its exit gate. /dev may also add resolved decisions post-merge (Phase D.4) when new decisions are discovered during implementation. /spec validates that no `aberta` decision blocks /dev.
122
125
 
123
126
  ## links.md PR Table Format
124
127
 
@@ -58,7 +58,7 @@ Read from `projects.yml` → `agents` section:
58
58
 
59
59
  | Role | Config key | If null or missing |
60
60
  |------|-----------|-------------------|
61
- | Security scan | `agents.security` | Skip scan, add note to MR: "Security scan manual necessario" |
61
+ | Security scan | `agents.security` | Skip scan, add note to MR: "Security scan manual necessário" |
62
62
  | Code review | `agents.code_review` | Skip pre-review, notify dev |
63
63
  | Design document | `agents.design_doc` | Update DD directly no Confluence (read → append → update) |
64
64
 
@@ -75,12 +75,12 @@ Read from `projects.yml` → `agents` section:
75
75
  - Dependencies between groups
76
76
  - Parallelizable groups (marked `[P]`)
77
77
  - Execution order
78
- 3. **Check if repos exist** — for each repo referenced in tasks.md:
78
+ 4. **Check if repos exist** — for each repo referenced in tasks.md:
79
79
  - Look up the repo in `projects.yml`
80
80
  - If `status: active` and `url` is filled → repo exists, skip
81
81
  - If `status: planned` and `url` is null → **create the repo** (see Phase A.1 below)
82
82
  - If the repo is NOT declared in projects.yml → stop and ask the dev
83
- 4. Create GitLab/GitHub Issues (1 per task) via API or terminal:
83
+ 5. Create GitLab/GitHub Issues (1 per task) via API or terminal:
84
84
  - Title: `[NNN] task description`
85
85
  - Labels: `spec`, `NNN-feature-name`
86
86
  - Assign to the repo's issue board
@@ -256,6 +256,12 @@ The orchestrator extracts response type field names from contracts.md and asks t
256
256
 
257
257
  This artifact enables CI Guard (see below) and provides audit trail for compliance.
258
258
 
259
+ Also append a summary line to `specs/NNN-name/conformance-history.log` (create if it doesn't exist):
260
+ ```
261
+ {timestamp} | {result} | {matching}/{total} endpoints | {matching}/{total} fields
262
+ ```
263
+ This preserves history across multiple /dev runs.
264
+
259
265
  C.4. **Run extension hooks** (if any)
260
266
 
261
267
  If the spec repo has a `hooks/pre-merge/` directory with executable scripts, run each one in alphabetical order. Each script receives two arguments: `<spec-dir>` and `<repo-dir>`.
@@ -350,10 +356,10 @@ D.3. **Update living docs on Confluence** (via MCP):
350
356
  D.4. **Post-implementation discoveries:**
351
357
 
352
358
  If implementation revealed:
353
- - a) A SURPRISE (unexpected behavior, edge case) → save to `docs/lessons/NNN-title.md` (template below)
359
+ - a) A SURPRISE (unexpected behavior, edge case) → save to `docs/lessons/NNN-title.md` with template below
354
360
  - b) A NEW ARCHITECTURE DECISION (chose a pattern, discovered a constraint) → add to `docs/architecture.md` "Decisões em Aberto" table with Status: `resolvida — [decisão tomada durante implementação de {SIGLA}-NNN]`. This ensures architecture.md reflects decisions made during /dev, not just during /discovery.
355
361
 
356
- If something surprised during implementation → generate `docs/lessons/NNN-title.md` with template:
362
+ Lessons template:
357
363
  ```
358
364
  ## O que aconteceu
359
365
  [description]
@@ -424,6 +430,7 @@ E.3. Validate the API (orchestrator does via curl):
424
430
  - Health check (`GET /health` → 200)
425
431
  - Minimum flow: register → login → 1 authenticated CRUD operation
426
432
  - Verify CORS (front origin must be accepted)
433
+ - If the spec has NFR scenarios (performance targets): run a basic load smoke test against the critical endpoint (e.g., `hey -n 100 -c 10 {url}` or equivalent) and verify the p95 response time meets the target. If load testing tooling is not available, log: "NFR validation manual necessária — tooling de load test não disponível."
427
434
 
428
435
  E.4. Validate the frontend (orchestrator checks):
429
436
  - Build passes (stack agent executes the build)
@@ -571,6 +578,9 @@ BUNDLE_SIZE=$(du -sk "$2/dist/assets/" | cut -f1)
571
578
 
572
579
  ## Validation checklist
573
580
 
581
+ - [ ] Audit-report.md read and evaluated (no ❌ items)
582
+ - [ ] Repos auto-created if `status: planned` (Phase A.1)
583
+ - [ ] Feature label changed to `em-dev` on Confluence
574
584
  - [ ] Correct coding agent selected per stack
575
585
  - [ ] VCS Issues created (1 per task)
576
586
  - [ ] Tests generated before implementation (TDD)
@@ -578,7 +588,7 @@ BUNDLE_SIZE=$(du -sk "$2/dist/assets/" | cut -f1)
578
588
  - [ ] All tests pass
579
589
  - [ ] **Commit GREEN** (`feat(NNN): all tests pass [GREEN]`) done after all tests pass
580
590
  - [ ] Conformance check passed (endpoints + response fields match contracts.md)
581
- - [ ] Conformance report saved (`specs/NNN/conformance-report.json`)
591
+ - [ ] Conformance report saved (`specs/NNN/conformance-report.json`) + history appended to `conformance-history.log`
582
592
  - [ ] Extension hooks passed (if any in `hooks/pre-merge/`)
583
593
  - [ ] Security scan passed
584
594
  - [ ] MR created with spec references
@@ -586,6 +596,9 @@ BUNDLE_SIZE=$(du -sk "$2/dist/assets/" | cut -f1)
586
596
  - [ ] MR rejected loop handled (if applicable — fix, re-test, re-check conformance)
587
597
  - [ ] links.md updated with MR links
588
598
  - [ ] Living docs updated on Confluence (DD, Dominio, Glossario)
599
+ - [ ] Spec synced with implementation if intentional divergences (Phase D.1.5)
600
+ - [ ] Architecture.md updated with new decisions if discovered during implementation (Phase D.4)
601
+ - [ ] CHANGELOG.md updated in main repo (Phase D.4.5)
589
602
  - [ ] Feature label → `done` on Confluence
590
603
  - [ ] Lessons saved if applicable
591
604
  - [ ] GChat notifications sent at each transition
@@ -53,7 +53,7 @@ If NO argument was passed (user ran `/discovery` without a feature name):
53
53
  ```
54
54
  6. **Suggest execution order**: analyze the dependency graph from all features' "Depende de" fields and suggest the order that minimizes blocked time. This is a SUGGESTION — the dev chooses the final order.
55
55
  7. Ask: "Qual feature deseja trabalhar?"
56
- 7. Proceed with the chosen feature.
56
+ 8. Proceed with the chosen feature.
57
57
 
58
58
  If argument WAS passed (e.g., `/discovery TFB-001`):
59
59
  - Locate the corresponding feature page and proceed normally.
@@ -73,7 +73,7 @@ Read these files FIRST:
73
73
  ### 1. Compile all information
74
74
 
75
75
  From Confluence (via MCP), read:
76
- - The feature page in `Features/` (demand extracted by /setup)
76
+ - The feature page in `Features/` (demand extracted by /setup). Read the metadata table — especially the "Seções do PO" field, which tells you exactly which PO document sections are relevant for this feature. Use this to focus your gap analysis.
77
77
  - `Dominio/` — business rules, flows, reference tables, integrations
78
78
  - `Visao do Produto` — product scope and success metrics
79
79
  - Previous Q&A rounds on the feature page (if any)
@@ -186,6 +186,8 @@ Covered / Partial / Missing.
186
186
 
187
187
  **Special rule — PERFORMANCE**: this category can NEVER be marked as "Covered" without at least one question about: data limits (how many records per entity?), response SLA (max acceptable response time per endpoint), or expected throughput (requests/second, concurrent users). If the PO demand does not mention performance, ASK — absence of a performance requirement does not mean "no requirement", it means "undocumented implicit requirement".
188
188
 
189
+ **Special rule — TECHNOLOGY**: this category can NEVER be marked as "Covered" without verifying: (1) all repos in projects.yml have a stack declared, (2) the declared stack supports all feature requirements (WebSocket, background jobs, full-text search, etc.), (3) the auth mechanism is defined. Absence of technology constraints does not mean the stack is fine — it means the constraint is implicit.
190
+
189
191
  For each category marked Partial or Missing, generate a candidate question.
190
192
 
191
193
  **Prioritize:** Impact (High/Medium/Low) x Blocks spec? (Yes/No).
@@ -277,7 +279,7 @@ After documenting technical decisions, **return to step 6** and re-evaluate: if
277
279
 
278
280
  **IF no gaps remain (or all answered):**
279
281
 
280
- Generate the PRD on the feature page in Confluence:
282
+ Generate the PRD on the feature page in Confluence. **IMPORTANT: APPEND the PRD section BELOW the existing metadata table and Escopo section created by /setup — do NOT replace or remove them.**
281
283
 
282
284
  ```
283
285
  ## PRD
@@ -165,7 +165,7 @@ Must contain these sections:
165
165
  - **Premissas**: assumptions stated in the PO docs (copy them, don't summarize)
166
166
  - **Escopo da v1**: what's in
167
167
  - **Fora de escopo**: what's explicitly out
168
- - **Riscos e dependencias criticas**: external systems without defined contracts, teams/knowledge dependencies, technical unknowns. If PO docs mention integration with an external system but no contract or API is defined, register as risk. If PO mentions a technology the team has no experience with, register as risk. If no risks identified, write "Nenhum risco critico identificado nos documentos do PO."
168
+ - **Riscos e dependências críticas**: external systems without defined contracts, teams/knowledge dependencies, technical unknowns. If PO docs mention integration with an external system but no contract or API is defined, register as risk. If PO mentions a technology the team has no experience with, register as risk. If no risks identified, write "Nenhum risco crítico identificado nos documentos do PO."
169
169
  - **Metricas de sucesso**: if the PO defined metrics, use them. If not, write "Metricas de negocio — A CONFIRMAR. Nao definidas pelo PO." Do NOT invent metrics. Do NOT use functional test criteria as metrics.
170
170
  - **Restricoes**: mandatory tech, environment, compliance constraints
171
171
 
@@ -381,7 +381,7 @@ In the local spec repo:
381
381
  | # | Decisao | Impacto | Bloqueia | Status |
382
382
  |---|---------|---------|----------|--------|
383
383
  | 1 | Worker separado ou parte da API? | Alto — define repos e CI | /spec | aberta |
384
- | 2 | Valores do enum de Status | Medio — afeta model e validacao | /dev | aberta |
384
+ | 2 | Valores do enum de Status | Médio — afeta model e validação | /dev | aberta |
385
385
  ```
386
386
 
387
387
  Status values: `aberta`, `resolvida — [decisão tomada]`. The /discovery updates this column when resolving decisions (exit gate).
@@ -410,7 +410,7 @@ Before closing the loop, the agent MUST do a self-review:
410
410
  3. **Fix any gaps found** by updating the pages
411
411
  4. **Report** what was added/fixed in the self-review
412
412
  5. **Feature coverage**: for EACH numbered section or distinct capability in the PO documents, verify it is covered by at least one feature page. If uncovered → create a feature or add the scope to an existing one. Report: "Cobertura de features: {N}/{total} seções do PO cobertas."
413
- 6. **Cross-cutting check**: if PO/architecture docs mention auth keywords (SSO, JWT, roles, LGPD) → verify a feature covers auth implementation. If they mention automation keywords (SLA, automático, scheduled) → verify a feature covers it. If missing → create the dedicated feature.
413
+ 6. **Cross-cutting check**: if PO/architecture docs mention auth keywords (SSO, JWT, OAuth, roles, permissões, autorização, autenticação, LGPD, rate limit) → verify a feature covers auth implementation. If they mention automation keywords (automático, SLA, prazo, timeout, scheduled, job, cron, fechamento automático) → verify a feature covers it. If missing → create the dedicated feature. Use the same trigger keywords from Phase B.
414
414
 
415
415
  ### 6. Close the loop
416
416
 
@@ -487,10 +487,13 @@ The output is considered good when:
487
487
  ### Spec repo updated
488
488
  - [ ] projects.yml filled with all detected repos (status: planned, not commented)
489
489
  - [ ] docs/architecture.md draft with Mermaid diagrams (flowchart, erDiagram) and open decisions table
490
+ - [ ] `docs/lessons/` and `docs/decisions/` directories created
490
491
 
491
492
  ### Quality gates
492
493
  - [ ] Self-review performed (re-read PRD vs. output)
494
+ - [ ] Figma context read and incorporated (if configured)
493
495
  - [ ] No business context was invented
494
496
  - [ ] All ambiguities marked "A CONFIRMAR" with explanation
495
497
  - [ ] Unreadable attachments listed as "NAO PROCESSADO"
496
498
  - [ ] Demand label changed to `processado` (verified)
499
+ - [ ] GChat notification sent (if webhook configured)
@@ -70,7 +70,7 @@ If `projects.yml` has `figma.file_url` and Figma MCP is available:
70
70
  ### 1. Read PRD from Confluence
71
71
 
72
72
  From Confluence (via MCP), read the approved PRD on the feature page.
73
- Extract: requirements, decisions, scope, out of scope, assumptions.
73
+ Extract: requirements, decisions, scope, out of scope, assumptions, and NFRs (if the PRD has a "Requisitos Não-Funcionais" section).
74
74
 
75
75
  ### 2. Identify features in the PRD
76
76
 
@@ -139,6 +139,7 @@ Numbering is sequential: find the highest existing number in `specs/` and increm
139
139
  - Default pagination (no params → uses defaults)
140
140
  - Last page (partial results)
141
141
  - Invalid page values (page ≤ 0, pageSize > max) — expected: 400 or clamped to defaults
142
+ - **NFR scenarios (if PRD has "Requisitos Não-Funcionais")**: for each measurable NFR target (e.g., "GET /bills < 200ms p95"), create at least one CT-NNN-XX scenario with a concrete Given/When/Then. Example: `Given 50 concurrent users, When GET /api/v1/bills with filters, Then p95 response time < 200ms`. If the NFR is not measurable in a test (e.g., "99.9% uptime"), include it in brief.md under "Restrições" instead. Add NFR-related tasks to tasks.md (e.g., "add response time middleware", "configure rate limiting").
142
143
  - **No unresolved markers (MANDATORY)**: specs MUST NOT contain any of these markers anywhere — including inside code blocks and code examples:
143
144
  `MOCKADO`, `TODO`, `A CONFIRMAR`, `TBD`, `FIXME`, `PLACEHOLDER`, `TKTK`
144
145
  If any assumption is not validated, go back to /discovery to resolve it.
@@ -165,9 +166,9 @@ Numbering is sequential: find the highest existing number in `specs/` and increm
165
166
  | UpdatedAt | DateTime | Sim | Data de última atualização |
166
167
  ```
167
168
  5. **Error codes**: every error code specific to this feature, as constants/enum
168
- 5. **Validation rules** (as a top-level `##` section, NOT nested inside a per-stack section): every field validation (required, format, max length, valid values)
169
- 6. **Response examples**: at least one success example and one error example per endpoint, with HTTP status code
170
- 7. **Shared types**: if this feature DEFINES types that other features will reuse (ex: ErrorResponse, PaginatedResponse), mark them in a `## Tipos compartilhados` section. If this feature USES types from another feature, REFERENCE them ("Ver contracts.md da feature NNN") — do NOT copy the full definition. If extending a type, define only the extension.
169
+ 6. **Validation rules** (as a top-level `##` section, NOT nested inside a per-stack section): every field validation (required, format, max length, valid values)
170
+ 7. **Response examples**: at least one success example and one error example per endpoint, with HTTP status code
171
+ 8. **Shared types**: if this feature DEFINES types that other features will reuse (ex: ErrorResponse, PaginatedResponse), mark them in a `## Tipos compartilhados` section. If this feature USES types from another feature, REFERENCE them ("Ver contracts.md da feature NNN") — do NOT copy the full definition. If extending a type, define only the extension.
171
172
 
172
173
  Additional structural rule: **editável entities MUST have both `CriadoEm` and `AtualizadoEm` fields**. If an entity can be modified via PUT/PATCH, it needs `AtualizadoEm` for auditability.
173
174
 
@@ -229,7 +230,7 @@ This is a STUB — /dev may extend it during implementation. Mark as draft: `inf
229
230
 
230
231
  If the feature has no REST endpoints (e.g., worker-only feature), skip this step.
231
232
 
232
-
233
+ ### 4. Self-review and audit
233
234
 
234
235
  Before generating the DD or closing the loop, run ALL checks below. Fix any failures, then generate the audit report.
235
236
 
@@ -242,9 +243,11 @@ Before generating the DD or closing the loop, run ALL checks below. Fix any fail
242
243
  - Response type defined
243
244
  - At least one success example and one error example
244
245
  - Error codes cover all failure scenarios
245
- 4. **Auth consistency**: if feature has authenticated endpoints, confirm a CT for "sem token → 401" exists
246
- 5. **Pagination consistency**: if any endpoint returns lists, confirm pagination scenarios exist
247
- 6. **Cross-feature types**: if contracts.md defines a type that already exists in another feature's contracts.md, replace with a reference
246
+ 4. **Auth consistency**: if feature has authenticated endpoints, confirm CTs exist for: "sem token → 401", "role errado → 403"
247
+ 5. **Input validation**: for each endpoint accepting user input, confirm at least one CT for "input malformado → 400" exists
248
+ 6. **Pagination consistency**: if any endpoint returns lists, confirm pagination scenarios exist
249
+ 7. **Cross-feature types**: if contracts.md defines a type that already exists in another feature's contracts.md, replace with a reference
250
+ 8. **NFR coverage**: if the PRD has a "Requisitos Não-Funcionais" section, confirm each measurable NFR has at least one CT scenario. Non-measurable NFRs should appear in brief.md "Restrições"
248
251
 
249
252
  If ANY check fails, fix the spec files BEFORE proceeding. Report what was fixed.
250
253
 
@@ -258,9 +261,11 @@ If ANY check fails, fix the spec files BEFORE proceeding. Report what was fixed.
258
261
  | 1 | REQ → Scenarios | ✅ 12/12 | All REQs have ≥1 scenario |
259
262
  | 2 | RN → Scenarios | ✅ 8/8 | All RNs have ≥1 scenario |
260
263
  | 3 | Endpoints → Contracts | ✅ 6/6 | All endpoints have request/response/errors |
261
- | 4 | Auth (401 scenario) | ✅ 1/1 | CT-NNN-XX covers |
262
- | 5 | Pagination scenarios | ✅ 2/2 | CT-NNN-XX, CT-NNN-YY |
263
- | 6 | Cross-feature types | ✅ OK | References only, no redefinitions |
264
+ | 4 | Auth (401 + 403 scenarios) | ✅ 2/2 | CT-NNN-XX (401), CT-NNN-YY (403) |
265
+ | 5 | Input validation (400 scenarios) | ✅ 3/3 | One per input endpoint |
266
+ | 6 | Pagination scenarios | ✅ 2/2 | CT-NNN-XX, CT-NNN-YY |
267
+ | 7 | Cross-feature types | ✅ OK | References only, no redefinitions |
268
+ | 8 | NFR coverage | ✅ 2/2 | Each measurable NFR has CT scenario |
264
269
 
265
270
  **Generated**: YYYY-MM-DD
266
271
  **Fixed during review**: (list what was added/corrected, or "none")
@@ -372,8 +377,10 @@ If a Confluence operation fails mid-flow (updating DD, changing labels, reading
372
377
  - [ ] Every scenario has Given/When/Then
373
378
  - [ ] Happy path covered for every endpoint/behavior
374
379
  - [ ] Failure scenarios covered (validation errors, not found, ownership)
375
- - [ ] Auth scenario (401 without token) present if feature has authenticated endpoints
380
+ - [ ] Auth scenarios (401 without token + 403 wrong role) present if feature has authenticated endpoints
381
+ - [ ] Input validation scenarios (malformed input → 400) present for each endpoint accepting user input
376
382
  - [ ] Pagination scenarios present if any endpoint returns paginated lists
383
+ - [ ] NFR scenarios present if PRD has "Requisitos Não-Funcionais" section (each measurable target has a CT)
377
384
  - [ ] Edge cases covered (boundary values, empty results, duplicates)
378
385
 
379
386
  ### Contracts quality
@@ -389,9 +396,17 @@ If a Confluence operation fails mid-flow (updating DD, changing labels, reading
389
396
  - [ ] Each task = 1 PR
390
397
  - [ ] links.md has correct Confluence page link
391
398
 
399
+ ### Artifacts
400
+ - [ ] `audit-report.md` generated with all checks passing
401
+ - [ ] `openapi.yaml` generated (if feature has REST endpoints)
402
+ - [ ] Figma freshness check performed (if configured)
403
+
392
404
  ### Integration
393
405
  - [ ] DD updated on Confluence
406
+ - [ ] Glossary validated on Confluence (all PRD terms present)
407
+ - [ ] All open decisions in architecture.md resolved (no blockers for /dev)
394
408
  - [ ] Feature label updated on Confluence → `em-spec`
409
+ - [ ] All spec files committed and pushed
395
410
  - [ ] GChat notification sent
396
411
  - [ ] Lessons from docs/lessons/ applied
397
412