@haposoft/cafekit 0.16.0-rc.3 → 0.16.0-rc.5

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 (98) hide show
  1. package/bin/__tests__/change-firewall.semantic-firewall.test.js +2134 -0
  2. package/bin/__tests__/codex-hooks.test.js +531 -29
  3. package/bin/__tests__/codex-native.test.js +228 -7
  4. package/bin/__tests__/develop-contract.test.js +653 -185
  5. package/bin/__tests__/finalizer-pass-gate.semantic-firewall.test.js +342 -0
  6. package/bin/__tests__/installer-safety.test.js +39 -0
  7. package/bin/__tests__/opencode-spec-gate.test.js +24 -16
  8. package/bin/__tests__/package-inventory.test.js +705 -13
  9. package/bin/__tests__/release-preflight.semantic-firewall.test.js +578 -0
  10. package/bin/__tests__/review-receipt-c2.semantic-firewall.test.js +378 -0
  11. package/bin/__tests__/specs-v2-execution-closeout.test.js +468 -0
  12. package/bin/__tests__/specs-v2-policy-and-scaffold.test.js +665 -0
  13. package/bin/__tests__/specs-v2-validator-grounder-contract.test.js +1132 -0
  14. package/bin/__tests__/test-runtime-dependency-closure.cjs +182 -0
  15. package/bin/__tests__/validator-grounding.test.js +2013 -221
  16. package/bin/lib/managed-writer.js +12 -3
  17. package/bin/phases/codex-runtime.js +17 -1
  18. package/package.json +5 -2
  19. package/src/claude/CLAUDE.md +6 -0
  20. package/src/claude/agents/code-auditor.md +20 -0
  21. package/src/claude/agents/spec-maker.md +143 -99
  22. package/src/claude/hooks/__tests__/completion-authority.test.js +321 -58
  23. package/src/claude/hooks/__tests__/privacy-block.test.js +254 -0
  24. package/src/claude/hooks/__tests__/semantic-review-authority.test.js +257 -0
  25. package/src/claude/hooks/__tests__/spec-gate.test.js +115 -40
  26. package/src/claude/hooks/completion-authority-check.cjs +37 -288
  27. package/src/claude/hooks/completion-authority-state.cjs +10 -8
  28. package/src/claude/hooks/completion-authority.cjs +13 -7
  29. package/src/claude/hooks/docs-sync.cjs +5 -2
  30. package/src/claude/hooks/lib/privacy-command-analysis.cjs +393 -0
  31. package/src/claude/hooks/lib/runtime-path-safety.cjs +119 -0
  32. package/src/claude/hooks/privacy-block.cjs +99 -28
  33. package/src/claude/hooks/semantic-review-authority.cjs +152 -0
  34. package/src/claude/hooks/spec-gate.cjs +47 -117
  35. package/src/claude/hooks/spec-state.cjs +8 -2
  36. package/src/claude/migration-manifest.json +9 -1
  37. package/src/claude/rules/state-sync.md +52 -21
  38. package/src/claude/rules/workflow.md +17 -9
  39. package/src/claude/scripts/change-firewall.cjs +1748 -0
  40. package/src/claude/scripts/spec-authoring-digest.cjs +151 -0
  41. package/src/claude/scripts/spec-authoring-validation.cjs +126 -0
  42. package/src/claude/scripts/spec-final-state.cjs +290 -0
  43. package/src/claude/scripts/spec-ground.cjs +571 -173
  44. package/src/claude/scripts/spec-readiness.cjs +425 -0
  45. package/src/claude/scripts/spec-receipt.cjs +162 -0
  46. package/src/claude/scripts/spec-resolver.cjs +67 -16
  47. package/src/claude/scripts/spec-scaffold.cjs +1594 -139
  48. package/src/claude/scripts/spec-semantic-model.cjs +396 -0
  49. package/src/claude/scripts/validate-spec-output.cjs +3110 -218
  50. package/src/claude/scripts/workflow-policy.cjs +501 -183
  51. package/src/claude/settings/settings.json +4 -0
  52. package/src/claude/skills/code-review/SKILL.md +12 -3
  53. package/src/claude/skills/code-review/references/spec-compliance-review.md +10 -2
  54. package/src/claude/skills/code-review/references/verification-gate.md +13 -0
  55. package/src/claude/skills/develop/SKILL.md +47 -60
  56. package/src/claude/skills/develop/references/parallel-waves.md +9 -6
  57. package/src/claude/skills/develop/references/quality-gate.md +19 -12
  58. package/src/claude/skills/specs/SKILL.md +183 -177
  59. package/src/claude/skills/specs/references/ask-user-question-gates.md +27 -18
  60. package/src/claude/skills/specs/references/cross-spec-dependency.md +8 -4
  61. package/src/claude/skills/specs/references/research-strategy.md +4 -1
  62. package/src/claude/skills/specs/references/review.md +214 -262
  63. package/src/claude/skills/specs/references/scope-inquiry.md +18 -5
  64. package/src/claude/skills/specs/rules/design-discovery-full.md +33 -81
  65. package/src/claude/skills/specs/rules/design-discovery-light.md +21 -42
  66. package/src/claude/skills/specs/rules/design-principles.md +136 -180
  67. package/src/claude/skills/specs/rules/design-review.md +42 -97
  68. package/src/claude/skills/specs/rules/ears-format.md +42 -50
  69. package/src/claude/skills/specs/rules/phase-decision-matrix.md +42 -41
  70. package/src/claude/skills/specs/rules/task-scoring-rubric.md +2 -1
  71. package/src/claude/skills/specs/rules/tasks-generation.md +189 -300
  72. package/src/claude/skills/specs/templates/design.md +49 -263
  73. package/src/claude/skills/specs/templates/requirements.md +26 -36
  74. package/src/claude/skills/specs/templates/research.md +9 -98
  75. package/src/claude/skills/specs/templates/spec-state.json +35 -85
  76. package/src/claude/skills/specs/templates/task.md +30 -102
  77. package/src/claude/skills/sync/SKILL.md +33 -10
  78. package/src/claude/skills/sync/references/sync-protocols.md +31 -13
  79. package/src/claude/skills/test/SKILL.md +17 -7
  80. package/src/codex/AGENTS.md +6 -0
  81. package/src/codex/hooks/completion-authority-check.cjs +43 -240
  82. package/src/codex/hooks/completion-authority-state.cjs +10 -8
  83. package/src/codex/hooks/completion-authority.cjs +13 -7
  84. package/src/codex/hooks/lib/hook-context.cjs +16 -2
  85. package/src/codex/hooks/lib/privacy-command-analysis.cjs +3 -0
  86. package/src/codex/hooks/lib/privacy-state.cjs +61 -38
  87. package/src/codex/hooks/lib/runtime-path-safety.cjs +3 -0
  88. package/src/codex/hooks/lib/spec-receipt.cjs +72 -134
  89. package/src/codex/hooks/lib/spec-utils.cjs +56 -5
  90. package/src/codex/hooks/privacy-approval.cjs +6 -2
  91. package/src/codex/hooks/privacy-block.cjs +94 -15
  92. package/src/codex/hooks/semantic-review-authority.cjs +130 -0
  93. package/src/codex/hooks/spec-gate.cjs +49 -34
  94. package/src/codex/hooks/spec-state.cjs +10 -3
  95. package/src/codex/hooks/state.cjs +2 -0
  96. package/src/codex/hooks.json +6 -1
  97. package/src/codex/rules/state-sync.md +47 -27
  98. package/src/common/AGENTS.md +1 -1
@@ -1,296 +1,82 @@
1
- # Design Document Template
1
+ # Design
2
2
 
3
- ---
4
- **Purpose**: Provide sufficient detail to ensure implementation consistency across different implementers, preventing interpretation drift.
3
+ <!-- Delete every optional section that is not relevant. Compact keeps only the four core sections. -->
5
4
 
6
- **Approach**:
7
- - Include essential sections that directly inform implementation decisions
8
- - Omit optional sections unless critical to preventing implementation errors
9
- - Match detail level to feature complexity
10
- - Use diagrams and tables over lengthy prose
5
+ ## Boundary
11
6
 
12
- **Warning**: Approaching 1000 lines indicates excessive feature complexity that may require design simplification.
13
- ---
7
+ - **Owns:** {{Behavior/state this design owns}}
8
+ - **Reads:** {{Relevant inputs or existing state, or none}}
9
+ - **Writes/exposes:** {{Outputs, state, route, artifact, or none}}
10
+ - **Outside boundary:** {{Explicit non-goal or delegated responsibility}}
14
11
 
15
- > Sections may be reordered (e.g., surfacing Requirements Traceability earlier or moving Data Models nearer Architecture) when it improves clarity. Within each section, keep the flow **Summary → Scope → Decisions → Impacts/Risks** so reviewers can scan consistently.
12
+ ## Typed Anchors
16
13
 
17
- ## Overview
18
- 2-3 paragraphs max
19
- **Purpose**: This feature delivers [specific value] to [target users].
20
- **Users**: [Target user groups] will utilize this for [specific workflows].
21
- **Impact** (if applicable): Changes the current [system state] by [specific modifications].
14
+ <!-- Files-first. IDs are unique across the whole spec. Design-owned anchors use A-D-NN. Access/Action are machine authority; Role never implies lifecycle. -->
22
15
 
16
+ | ID | Type | Target | Role | Access | Action |
17
+ |---|---|---|---|---|---|
18
+ | A-D-01 | file | `{{path/to/existing-or-planned-file}}` | {{owner / consumer / entrypoint / proof / constraint}} | {{read / write}} | {{read / create / modify / delete}} |
19
+ <!-- For a typed proof boundary, add: | A-D-02 | artifact | `{{path/to/proof-artifact}}` | proof evidence owner | write | create | -->
23
20
 
24
- ### Goals
25
- - Primary objective 1
26
- - Primary objective 2
27
- - Success criteria
21
+ ## Decisions and Invariants
28
22
 
29
- ### Non-Goals
30
- - Explicitly excluded functionality
31
- - Future considerations outside current scope
32
- - Integration points deferred
23
+ <!-- Keep stable D/I/C IDs: every RN.M semantic-review counterexample cites one exact design reference. -->
33
24
 
34
- ## Architecture
25
+ ### D1 — {{Decision name}}
35
26
 
36
- > Reference detailed discovery notes in `research.md` only for background; keep design.md self-contained for reviewers by capturing all decisions and contracts here.
37
- > Capture key decisions in text and let diagrams carry structural detail—avoid repeating the same information in prose.
27
+ - **Decision:** {{Canonical behavior or boundary}}
28
+ - **Rejects ambiguity:** {{Alternative interpretation implementers must not choose}}
29
+ - **Negative path:** {{Failure/error behavior when relevant}}
30
+ - **Anchors:** A-D-01
38
31
 
39
- ### Existing Architecture Analysis (if applicable)
40
- When modifying existing systems:
41
- - Current architecture patterns and constraints
42
- - Existing domain boundaries to be respected
43
- - Integration points that must be maintained
44
- - Technical debt addressed or worked around
32
+ ### I1 — {{Invariant name}}
45
33
 
46
- ### Architecture Pattern & Boundary Map
47
- **RECOMMENDED**: Include Mermaid diagram showing the chosen architecture pattern and system boundaries (required for complex features, optional for simple additions)
34
+ {{Property that must remain true across implementation and verification.}}
48
35
 
49
- **Architecture Integration**:
50
- - Selected pattern: [name and brief rationale]
51
- - Domain/feature boundaries: [how responsibilities are separated to avoid conflicts]
52
- - Existing patterns preserved: [list key patterns]
53
- - New components rationale: [why each is needed]
54
- - Steering compliance: [principles maintained]
36
+ ### Named Contracts (conditional)
55
37
 
56
- ### Technology Stack
38
+ <!-- Define each implementation-significant contract once. Tasks reference IDs and never copy bodies. For any public, replay, or operator API contract, include method, route, auth, required headers, request schema, success response, error semantics, and idempotency/concurrency behavior. -->
57
39
 
58
- | Layer | Choice / Version | Role in Feature | Notes |
59
- |-------|------------------|-----------------|-------|
60
- | Frontend / CLI | | | |
61
- | Backend / Services | | | |
62
- | Data / Storage | | | |
63
- | Messaging / Events | | | |
64
- | Infrastructure / Runtime | | | |
40
+ #### C1 — {{Contract name}}
65
41
 
66
- > Keep rationale concise here and, when more depth is required (trade-offs, benchmarks), add a short summary plus pointer to the Supporting References section and `research.md` for raw investigation notes.
42
+ - **Owner:** {{boundary or future owner task}}
43
+ - **Consumers:** {{boundaries or future consumer tasks}}
44
+ - **Shape/behavior:** {{typed request, response, event, schema, state, or error contract}}
45
+ - **Compatibility:** {{versioning or migration constraint when relevant}}
67
46
 
68
- ## Canonical Contracts & Invariants
47
+ ## Verification Definitions
69
48
 
70
- Capture only the contracts whose inconsistency would break downstream implementation or verification. If the feature touches auth/session, transport/entrypoints, persistence/schema, generated artifacts, or runtime outputs, this section is mandatory.
49
+ <!--
50
+ Canonical parser syntax is one single-line definition per V ID. Keep every
51
+ label on the same line; do not replace this with a table or a V heading.
52
+ -->
71
53
 
72
- | Contract Area | Canonical Decision | Applies To | Must Stay Consistent In |
73
- |---------------|--------------------|------------|-------------------------|
74
- | Auth / session | | | |
75
- | Transport / entrypoints | | | |
76
- | Data / persistence | | | |
77
- | Deletion / retention policy | | | |
78
- | Generated artifacts / runtime outputs | | | |
54
+ - **V1**: Criteria R{{SUBJECT_REQ}}.{{X}}; Owner A-D-01; Decision refs D1, I1, C1; Method command `{{exact command}}`; Expected {{concrete observable result}}; Negative/failure {{concrete rejected or recovery case}}; Reachability/grounding entrypoint `{{exact/repository/entrypoint}}` via A-D-01.
79
55
 
80
- > Task files must reuse the same contract wording. If the feature touches delete-data or privacy retention, explicitly decide whether re-registration is blocked and how that lock works without keeping raw PII. If implementation later needs a different contract, update this section first before generating or editing tasks.
56
+ <!-- Only for a typed proof boundary, insert after Owner: Proof criteria Rn.m; Proof owner <distinct owner>; Evidence anchor <proof-owned anchor>; -->
81
57
 
82
- ### Machine-checkable contracts (optional, recommended for cross-layer work)
58
+ <!-- Full-only conditional sections follow. Keep only those relevant to this feature. -->
83
59
 
84
- When a data shape must stay identical across layers (e.g. a response consumed by both a backend task and a frontend task), define it as a **named contract block** so the validator can detect drift. Mark it with an HTML comment `<!-- contract:NAME -->` on its own line, immediately followed by a fenced code block holding the shape. For example, a contract named `OrderResponse` would be an HTML marker line followed by a json fenced block containing `{ "orderId": "string", "total": "number" }`.
60
+ ## Flow (Full, conditional)
85
61
 
86
- Any task that produces or consumes this shape adds a `Contracts: OrderResponse` line in its body and **copies the same fenced block verbatim**. `validate-spec-output.cjs` then fails the spec if a task's copy diverges from this canonical definition, or references a contract name not defined here. This is opt-in: specs without `<!-- contract:* -->` markers are unaffected.
62
+ {{Only multi-step, branching, asynchronous, or cross-boundary flow decisions.}}
87
63
 
88
- ## System Flows
64
+ ## Data and Consistency (Full, conditional)
89
65
 
90
- Provide only the diagrams needed to explain non-trivial flows. Use pure Mermaid syntax. Common patterns:
91
- - Sequence (multi-party interactions)
92
- - Process / state (branching logic or lifecycle)
93
- - Data / event flow (pipelines, async messaging)
66
+ {{Ownership, schema, constraints, concurrency, lifecycle, or idempotency. For any retention/lifecycle policy, state clock anchor, clock source, timezone/precision, cutoff comparator/inclusivity, enforcement boundary, and a wrong-clock/boundary counterexample.}}
94
67
 
95
- Skip this section entirely for simple CRUD changes.
96
- > Describe flow-level decisions (e.g., gating conditions, retries) briefly after the diagram instead of restating each step.
68
+ ## Errors and Recovery (Full, conditional)
97
69
 
98
- ## Requirements Traceability
70
+ {{Trigger, error contract, retry/rollback/reconciliation, and terminal state.}}
99
71
 
100
- Use this section for complex or compliance-sensitive features where requirements span multiple domains. Straightforward 1:1 mappings can rely on the Components summary table.
72
+ ## Security and Privacy (Full, conditional)
101
73
 
102
- Map each requirement ID (e.g., `2.1`) to the design elements that realize it.
74
+ {{Trust boundary, authorization, sensitive data, deletion, and retention decisions.}}
103
75
 
104
- | Requirement | Summary | Components | Interfaces | Flows |
105
- |-------------|---------|------------|------------|-------|
106
- | 1.1 | | | | |
107
- | 1.2 | | | | |
76
+ ## Migration and Compatibility (Full, conditional)
108
77
 
109
- > Omit this section only when a single component satisfies a single requirement without cross-cutting concerns.
78
+ {{Ordering, compatibility window, rollback trigger, and migration proof.}}
110
79
 
111
- ## Components and Interfaces
80
+ ## Unresolved Questions
112
81
 
113
- Provide a quick reference before diving into per-component details.
114
-
115
- - Summaries can be a table or compact list. Example table:
116
- | Component | Domain/Layer | Intent | Req Coverage | Key Dependencies (P0/P1) | Contracts |
117
- |-----------|--------------|--------|--------------|--------------------------|-----------|
118
- | ExampleComponent | UI | Displays XYZ | 1, 2 | GameProvider (P0), MapPanel (P1) | Service, State |
119
- - Only components introducing new boundaries (e.g., logic hooks, external integrations, persistence) require full detail blocks. Simple presentation components can rely on the summary row plus a short Implementation Note.
120
-
121
- Group detailed blocks by domain or architectural layer. For each detailed component, list requirement IDs as `2.1, 2.3` (omit “Requirement”). When multiple UI components share the same contract, reference a base interface/props definition instead of duplicating code blocks.
122
-
123
- ### [Domain / Layer]
124
-
125
- #### [Component Name]
126
-
127
- | Field | Detail |
128
- |-------|--------|
129
- | Intent | 1-line description of the responsibility |
130
- | Requirements | 2.1, 2.3 |
131
- | Owner / Reviewers | (optional) |
132
-
133
- **Responsibilities & Constraints**
134
- - Primary responsibility
135
- - Domain boundary and transaction scope
136
- - Data ownership / invariants
137
-
138
- **Dependencies**
139
- - Inbound: Component/service name — purpose (Criticality)
140
- - Outbound: Component/service name — purpose (Criticality)
141
- - External: Service/library — purpose (Criticality)
142
-
143
- Summarize external dependency findings here; deeper investigation (API signatures, rate limits, migration notes) lives in `research.md`.
144
-
145
- **Contracts**: Service [ ] / API [ ] / Event [ ] / Batch [ ] / State [ ] ← check only the ones that apply.
146
-
147
- ##### Service Interface
148
- ```typescript
149
- interface [ComponentName]Service {
150
- methodName(input: InputType): Result<OutputType, ErrorType>;
151
- }
152
- ```
153
- - Preconditions:
154
- - Postconditions:
155
- - Invariants:
156
-
157
- ##### API Contract
158
- | Method | Endpoint | Request | Response | Errors |
159
- |--------|----------|---------|----------|--------|
160
- | POST | /api/resource | CreateRequest | Resource | 400, 409, 500 |
161
-
162
- ##### Event Contract
163
- - Published events:
164
- - Subscribed events:
165
- - Ordering / delivery guarantees:
166
-
167
- ##### Batch / Job Contract
168
- - Trigger:
169
- - Input / validation:
170
- - Output / destination:
171
- - Idempotency & recovery:
172
-
173
- ##### State Management
174
- - State model:
175
- - Persistence & consistency:
176
- - Concurrency strategy:
177
-
178
- **Implementation Notes**
179
- - Integration:
180
- - Validation:
181
- - Risks:
182
-
183
- ## Data Models
184
-
185
- Focus on the portions of the data landscape that change with this feature.
186
-
187
- ### Domain Model
188
- - Aggregates and transactional boundaries
189
- - Entities, value objects, domain events
190
- - Business rules & invariants
191
- - Optional Mermaid diagram for complex relationships
192
-
193
- ### Logical Data Model
194
-
195
- **Structure Definition**:
196
- - Entity relationships and cardinality
197
- - Attributes and their types
198
- - Natural keys and identifiers
199
- - Referential integrity rules
200
-
201
- **Consistency & Integrity**:
202
- - Transaction boundaries
203
- - Cascading rules
204
- - Temporal aspects (versioning, audit)
205
-
206
- ### Physical Data Model
207
- **When to include**: When implementation requires specific storage design decisions
208
-
209
- **For Relational Databases**:
210
- - Table definitions with data types
211
- - Primary/foreign keys and constraints
212
- - Indexes and performance optimizations
213
- - Partitioning strategy for scale
214
-
215
- **For Document Stores**:
216
- - Collection structures
217
- - Embedding vs referencing decisions
218
- - Sharding key design
219
- - Index definitions
220
-
221
- **For Event Stores**:
222
- - Event schema definitions
223
- - Stream aggregation strategies
224
- - Snapshot policies
225
- - Projection definitions
226
-
227
- **For Key-Value/Wide-Column Stores**:
228
- - Key design patterns
229
- - Column families or value structures
230
- - TTL and compaction strategies
231
-
232
- ### Data Contracts & Integration
233
-
234
- **API Data Transfer**
235
- - Request/response schemas
236
- - Validation rules
237
- - Serialization format (JSON, Protobuf, etc.)
238
-
239
- **Event Schemas**
240
- - Published event structures
241
- - Schema versioning strategy
242
- - Backward/forward compatibility rules
243
-
244
- **Cross-Service Data Management**
245
- - Distributed transaction patterns (Saga, 2PC)
246
- - Data synchronization strategies
247
- - Eventual consistency handling
248
-
249
- Skip subsections that are not relevant to this feature.
250
-
251
- ## Error Handling
252
-
253
- ### Error Strategy
254
- Concrete error handling patterns and recovery mechanisms for each error type.
255
-
256
- ### Error Categories and Responses
257
- **User Errors** (4xx): Invalid input → field-level validation; Unauthorized → auth guidance; Not found → navigation help
258
- **System Errors** (5xx): Infrastructure failures → graceful degradation; Timeouts → circuit breakers; Exhaustion → rate limiting
259
- **Business Logic Errors** (422): Rule violations → condition explanations; State conflicts → transition guidance
260
-
261
- **Process Flow Visualization** (when complex business logic exists):
262
- Include Mermaid flowchart only for complex error scenarios with business workflows.
263
-
264
- ### Monitoring
265
- Error tracking, logging, and health monitoring implementation.
266
-
267
- ## Testing Strategy
268
-
269
- ### Default sections (adapt names/sections to fit the domain)
270
- - Unit Tests: 3–5 items from core functions/modules (e.g., auth methods, subscription logic)
271
- - Integration Tests: 3–5 cross-component flows (e.g., webhook handling, notifications)
272
- - E2E/UI Tests (if applicable): 3–5 critical user paths (e.g., forms, dashboards)
273
- - Performance/Load (if applicable): 3–4 items (e.g., concurrency, high-volume ops)
274
-
275
- ## Conditional Sections (Include when relevant)
276
-
277
- ### Security Considerations
278
- _**REQUIRED** when features handle user data, authentication, PII, external integrations, or permissions. Omit only for purely internal UI changes._
279
- - Threat modeling, security controls, compliance requirements
280
- - Authentication and authorization patterns
281
- - Data protection and privacy considerations
282
-
283
- ### Performance & Scalability
284
- _Use this section when performance targets, high load, or scaling concerns exist. Record only feature-specific targets or trade-offs and rely on steering documents for general practices._
285
- - Target metrics and measurement strategies
286
- - Scaling approaches (horizontal/vertical)
287
- - Caching strategies and optimization techniques
288
-
289
- ### Migration Strategy
290
- Include a Mermaid flowchart showing migration phases when schema/data movement is required.
291
- - Phase breakdown, rollback triggers, validation checkpoints
292
-
293
- ## Supporting References (Optional)
294
- - Create this section only when keeping the information in the main body would hurt readability (e.g., very long TypeScript definitions, vendor option matrices, exhaustive schema tables). Keep decision-making context in the main sections so the design stays self-contained.
295
- - Link to the supporting references from the main text instead of inlining large snippets.
296
- - Background research notes and comparisons continue to live in `research.md`, but their conclusions must be summarized in the main design.
82
+ - None.
@@ -1,52 +1,42 @@
1
- # Requirements Document
1
+ # Requirements
2
2
 
3
- ## Introduction
4
- {{INTRODUCTION}}
3
+ ## Outcomes
5
4
 
6
- ## Requirements
5
+ - {{Observable product or system outcome}}
7
6
 
8
- ### Requirement 1: {{REQUIREMENT_AREA_1}}
9
- <!-- Requirement headings MUST include a leading numeric ID only (for example: "Requirement 1: ...", "1. Overview", "2 Feature: ..."). Alphabetic IDs like "Requirement A" are not allowed. -->
10
- <!-- Acceptance criteria use EXPLICIT literal IDs `R{N}.{M}` (R1.1, R1.2, ...), NOT a bare numbered list. This lets the validator verify per-criterion coverage (each R1.1 must be mapped by a task `_Requirements: 1.1_`). Do not switch to a bare `1. 2. 3.` list — that silently disables sub-criterion coverage. -->
11
- **Objective:** As a {{ROLE}}, I want {{CAPABILITY}}, so that {{BENEFIT}}
7
+ ## Scope
12
8
 
13
- #### Acceptance Criteria
14
- - **R1.1** When [event], the [system] shall [response/action]
15
- - **R1.2** If [trigger], then the [system] shall [response/action]
16
- - **R1.3** While [precondition], the [system] shall [response/action]
17
- - **R1.4** Where [feature is included], the [system] shall [response/action]
18
- - **R1.5** The [system] shall [response/action]
9
+ ### In scope
19
10
 
20
- ### Requirement 2: {{REQUIREMENT_AREA_2}}
21
- **Objective:** As a {{ROLE}}, I want {{CAPABILITY}}, so that {{BENEFIT}}
11
+ - {{Approved behavior or boundary}}
22
12
 
23
- #### Acceptance Criteria
24
- - **R2.1** When [event], the [system] shall [response/action]
25
- - **R2.2** When [event] and [condition], the [system] shall [response/action]
13
+ ### Non-goals
26
14
 
27
- <!-- Additional requirements follow the same pattern, with literal R{N}.{M} IDs -->
15
+ - {{Explicit exclusion that prevents scope inference}}
28
16
 
29
- ## Non-Functional Requirements
17
+ ## Requirements
30
18
 
31
- <!-- Continue the SAME numeric sequence as functional requirements. Do NOT switch to labels like NFR-1, SEC-1, PERF-1. -->
19
+ ### Requirement 1: {{Outcome area}}
32
20
 
33
- ### Requirement {{NEXT_REQ_NUMBER}}: Performance & Scalability
34
- **Objective:** As a system owner, I want predictable performance characteristics, so that the feature remains usable under expected load.
21
+ <!-- Keep Objective/User Story only when role and benefit remove ambiguity. -->
22
+ {{Optional: **Objective:** As a <role>, I want <capability>, so that <benefit>.}}
35
23
 
36
24
  #### Acceptance Criteria
37
- - **R{{NEXT_REQ_NUMBER}}.1** The [system] shall [measurable performance metric, e.g. "respond within 500ms"]
38
- - **R{{NEXT_REQ_NUMBER}}.2** The [system] shall [measurable scale metric, e.g. "support 100 concurrent users"]
39
25
 
40
- ### Requirement {{NEXT_REQ_NUMBER_PLUS_ONE}}: Security & Privacy
41
- **Objective:** As a security/compliance stakeholder, I want the feature to protect sensitive data and enforce access boundaries, so that the system is safe to ship.
26
+ - **R1.1** When {{event}}, the {{system}} shall {{measurable subject response}}.
42
27
 
43
- #### Acceptance Criteria
44
- - **R{{NEXT_REQ_NUMBER_PLUS_ONE}}.1** The [system] shall [measurable security behavior, e.g. "encrypt data at rest using AES-256"]
45
- - **R{{NEXT_REQ_NUMBER_PLUS_ONE}}.2** If [unauthorized or invalid condition], the [system] shall [deny or recover with explicit behavior]
28
+ <!-- Add a separate proof criterion only when a typed proof boundary exists. -->
46
29
 
47
- ### Requirement {{NEXT_REQ_NUMBER_PLUS_TWO}}: Reliability & Availability
48
- **Objective:** As an operator, I want predictable failure handling, so that incidents remain diagnosable and recoverable.
30
+ <!-- Add state, optional-feature, or ubiquitous EARS criteria only when relevant. -->
31
+ <!-- Add a concrete example only when values, order, boundaries, or transformation could be interpreted differently. -->
49
32
 
50
- #### Acceptance Criteria
51
- - **R{{NEXT_REQ_NUMBER_PLUS_TWO}}.1** If [failure condition], the [system] shall [recovery behavior]
52
- - **R{{NEXT_REQ_NUMBER_PLUS_TWO}}.2** The [system] shall [durability / retry / fallback expectation]
33
+ #### Examples (conditional)
34
+
35
+ - {{Input/state}} → {{expected output/state}}
36
+
37
+ <!-- Repeat Requirement N with literal RN.M acceptance IDs. -->
38
+ <!-- Add feature-specific NFRs in the same numeric sequence only when measurable and relevant. -->
39
+
40
+ ## Unresolved Questions
41
+
42
+ - None.
@@ -1,108 +1,19 @@
1
- # Research & Design Decisions
1
+ # Research: {{FEATURE_NAME}}
2
2
 
3
- ---
4
- **Purpose**: Capture discovery findings, architectural investigations, and rationale that inform the technical design.
3
+ Research exists only because this uncertainty can change requirements or design. Record evidence and a decision; do not use this file as a generic discovery log.
5
4
 
6
- **Usage**:
7
- - Log research activities and outcomes during the discovery phase.
8
- - Document design decision trade-offs that are too detailed for `design.md`.
9
- - Provide references and evidence for future audits or reuse.
10
- ---
5
+ ## Uncertainty
11
6
 
12
- ## Summary
13
- - **Feature**: `<feature-name>`
14
- - **Discovery Scope**: New Feature / Extension / Simple Addition / Complex Integration
15
- - **Key Findings**:
16
- - Finding 1
17
- - Finding 2
18
- - Finding 3
7
+ - {{UNCERTAINTY}}
19
8
 
20
9
  ## Evidence Summary
21
- This section is mandatory for non-trivial specs. It must be written before finalizing requirements, design, or tasks.
22
10
 
23
- - **Codebase Scout**: Required / Skipped
24
- - Result or skip rationale:
25
- - Relevant files/modules:
26
- - Existing patterns/contracts:
27
- - Tests or checks affected:
28
- - **External / Current Research**: Required / Skipped
29
- - Result or skip rationale:
30
- - Primary sources:
31
- - Current constraints or best practices:
32
- - **Selected Decision**:
33
- - Decision:
34
- - Why it fits the current codebase:
35
- - Why it fits current external constraints:
36
- - **Rejected Alternatives**:
37
- - Alternative 1 — rejection reason
38
- - Alternative 2 — rejection reason
39
- - **Remaining Gaps / Questions**:
40
- - Gap 1
41
- - Gap 2
42
- - **Downstream Task & Test Implications**:
43
- - Task implication:
44
- - Test/verification implication:
11
+ <!-- Cite concrete repository evidence or current primary sources that resolve the uncertainty. -->
45
12
 
46
- ## Codebase Scout
47
- Capture only useful repo evidence, not raw file dumps.
13
+ ## Decision
48
14
 
49
- | Area | Finding | Evidence / Path | Implication |
50
- |------|---------|-----------------|-------------|
51
- | Project surface | | | |
52
- | Relevant files/modules | | | |
53
- | Existing patterns | | | |
54
- | Contracts | | | |
55
- | Tests and verification | | | |
56
- | Blast radius | | | |
57
- | Staleness / conflicts | | | |
15
+ <!-- State the selected decision and how the evidence supports it. -->
58
16
 
59
- ## External / Current Research
60
- Use official docs, standards, package repos, release notes, or maintained upstream references first.
17
+ ## Remaining Gaps
61
18
 
62
- | Question | Source | Finding | Decision Impact |
63
- |----------|--------|---------|-----------------|
64
- | | | | |
65
-
66
- ## Research Log
67
- Document notable investigation steps and their outcomes. Group entries by topic for readability.
68
-
69
- ### [Topic or Question]
70
- - **Context**: What triggered this investigation?
71
- - **Sources Consulted**: Links, documentation, API references, benchmarks
72
- - **Findings**: Concise bullet points summarizing the insights
73
- - **Implications**: How this affects architecture, contracts, or implementation
74
-
75
- _Repeat the subsection for each major topic._
76
-
77
- ## Architecture Pattern Evaluation
78
- List candidate patterns or approaches that were considered. Use the table format where helpful.
79
-
80
- | Option | Description | Strengths | Risks / Limitations | Notes |
81
- |--------|-------------|-----------|---------------------|-------|
82
- | Hexagonal | Ports & adapters abstraction around core domain | Clear boundaries, testable core | Requires adapter layer build-out | Aligns with existing steering principle X |
83
-
84
- ## Design Decisions
85
- Record major decisions that influence `design.md`. Focus on choices with significant trade-offs.
86
-
87
- ### Decision: `<Title>`
88
- - **Context**: Problem or requirement driving the decision
89
- - **Alternatives Considered**:
90
- 1. Option A — short description
91
- 2. Option B — short description
92
- - **Selected Approach**: What was chosen and how it works
93
- - **Rationale**: Why this approach fits the current project context
94
- - **Status**: [Proposed / Accepted / Superseded]
95
- - **Trade-offs**: Benefits vs. compromises
96
- - **Follow-up**: Items to verify during implementation or testing
97
-
98
- _Repeat the subsection for each decision._
99
-
100
- ## Risks & Mitigations
101
- - Risk 1 — Proposed mitigation
102
- - Risk 2 — Proposed mitigation
103
- - Risk 3 — Proposed mitigation
104
-
105
- ## References
106
- Provide canonical links and citations (official docs, standards, ADRs, internal guidelines).
107
- - [Title](https://example.com) — brief note on relevance
108
- - ...
19
+ <!-- List only unresolved gaps that still affect scope/design, or state `None` with evidence. -->