@haposoft/cafekit 0.16.0-rc.2 → 0.16.0-rc.4

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__/codex-hooks.test.js +794 -21
  2. package/bin/__tests__/codex-native.test.js +228 -7
  3. package/bin/__tests__/develop-contract.test.js +1838 -112
  4. package/bin/__tests__/installer-safety.test.js +82 -29
  5. package/bin/__tests__/opencode-spec-gate.test.js +799 -0
  6. package/bin/__tests__/package-inventory.test.js +841 -10
  7. package/bin/__tests__/specs-v2-execution-closeout.test.js +421 -0
  8. package/bin/__tests__/specs-v2-policy-and-scaffold.test.js +601 -0
  9. package/bin/__tests__/specs-v2-validator-grounder-contract.test.js +952 -0
  10. package/bin/__tests__/test-runtime-dependency-closure.cjs +182 -0
  11. package/bin/__tests__/validator-grounding.test.js +2469 -71
  12. package/bin/lib/managed-writer.js +12 -3
  13. package/bin/phases/codex-runtime.js +17 -1
  14. package/package.json +1 -1
  15. package/src/claude/CLAUDE.md +6 -0
  16. package/src/claude/agents/code-auditor.md +20 -0
  17. package/src/claude/agents/spec-maker.md +153 -202
  18. package/src/claude/hooks/__tests__/completion-authority.test.js +953 -0
  19. package/src/claude/hooks/__tests__/privacy-block.test.js +172 -0
  20. package/src/claude/hooks/__tests__/semantic-review-authority.test.js +257 -0
  21. package/src/claude/hooks/__tests__/spec-gate.test.js +604 -56
  22. package/src/claude/hooks/completion-authority-check.cjs +56 -0
  23. package/src/claude/hooks/completion-authority-state.cjs +527 -0
  24. package/src/claude/hooks/completion-authority.cjs +154 -0
  25. package/src/claude/hooks/docs-sync.cjs +5 -2
  26. package/src/claude/hooks/lib/privacy-command-analysis.cjs +393 -0
  27. package/src/claude/hooks/lib/runtime-path-safety.cjs +119 -0
  28. package/src/claude/hooks/privacy-block.cjs +77 -30
  29. package/src/claude/hooks/semantic-review-authority.cjs +152 -0
  30. package/src/claude/hooks/session.cjs +33 -19
  31. package/src/claude/hooks/spec-gate.cjs +181 -139
  32. package/src/claude/hooks/spec-state.cjs +112 -47
  33. package/src/claude/migration-manifest.json +15 -2
  34. package/src/claude/rules/state-sync.md +52 -21
  35. package/src/claude/rules/workflow.md +17 -9
  36. package/src/claude/scripts/provenance.cjs +315 -0
  37. package/src/claude/scripts/spec-final-state.cjs +244 -0
  38. package/src/claude/scripts/spec-ground.cjs +535 -173
  39. package/src/claude/scripts/spec-readiness.cjs +118 -0
  40. package/src/claude/scripts/spec-receipt.cjs +162 -0
  41. package/src/claude/scripts/spec-resolver.cjs +501 -0
  42. package/src/claude/scripts/spec-scaffold.cjs +1945 -55
  43. package/src/claude/scripts/spec-semantic-model.cjs +396 -0
  44. package/src/claude/scripts/validate-spec-output.cjs +3204 -262
  45. package/src/claude/scripts/workflow-policy.cjs +1888 -203
  46. package/src/claude/settings/settings.json +12 -0
  47. package/src/claude/skills/code-review/SKILL.md +94 -66
  48. package/src/claude/skills/code-review/references/spec-compliance-review.md +10 -2
  49. package/src/claude/skills/code-review/references/verification-gate.md +13 -0
  50. package/src/claude/skills/develop/SKILL.md +138 -283
  51. package/src/claude/skills/develop/references/parallel-waves.md +9 -6
  52. package/src/claude/skills/develop/references/quality-gate.md +123 -148
  53. package/src/claude/skills/develop/references/subagent-patterns.md +42 -37
  54. package/src/claude/skills/specs/SKILL.md +192 -397
  55. package/src/claude/skills/specs/references/ask-user-question-gates.md +27 -18
  56. package/src/claude/skills/specs/references/cross-spec-dependency.md +8 -4
  57. package/src/claude/skills/specs/references/research-strategy.md +4 -1
  58. package/src/claude/skills/specs/references/review.md +200 -260
  59. package/src/claude/skills/specs/references/scope-inquiry.md +18 -5
  60. package/src/claude/skills/specs/rules/design-discovery-full.md +33 -81
  61. package/src/claude/skills/specs/rules/design-discovery-light.md +21 -42
  62. package/src/claude/skills/specs/rules/design-principles.md +136 -180
  63. package/src/claude/skills/specs/rules/design-review.md +42 -97
  64. package/src/claude/skills/specs/rules/ears-format.md +42 -50
  65. package/src/claude/skills/specs/rules/phase-decision-matrix.md +42 -41
  66. package/src/claude/skills/specs/rules/task-scoring-rubric.md +46 -46
  67. package/src/claude/skills/specs/rules/tasks-generation.md +189 -271
  68. package/src/claude/skills/specs/templates/design.md +49 -263
  69. package/src/claude/skills/specs/templates/requirements.md +26 -36
  70. package/src/claude/skills/specs/templates/research.md +9 -98
  71. package/src/claude/skills/specs/templates/spec-state.json +26 -67
  72. package/src/claude/skills/specs/templates/task.md +30 -82
  73. package/src/claude/skills/sync/SKILL.md +45 -15
  74. package/src/claude/skills/sync/references/sync-protocols.md +34 -16
  75. package/src/claude/skills/test/SKILL.md +151 -167
  76. package/src/codex/AGENTS.md +6 -0
  77. package/src/codex/hooks/completion-authority-check.cjs +63 -0
  78. package/src/codex/hooks/completion-authority-state.cjs +527 -0
  79. package/src/codex/hooks/completion-authority.cjs +106 -0
  80. package/src/codex/hooks/lib/hook-context.cjs +58 -4
  81. package/src/codex/hooks/lib/privacy-command-analysis.cjs +3 -0
  82. package/src/codex/hooks/lib/privacy-state.cjs +38 -16
  83. package/src/codex/hooks/lib/runtime-path-safety.cjs +3 -0
  84. package/src/codex/hooks/lib/spec-receipt.cjs +86 -115
  85. package/src/codex/hooks/lib/spec-utils.cjs +104 -27
  86. package/src/codex/hooks/privacy-approval.cjs +1 -1
  87. package/src/codex/hooks/privacy-block.cjs +67 -11
  88. package/src/codex/hooks/semantic-review-authority.cjs +130 -0
  89. package/src/codex/hooks/session.cjs +2 -0
  90. package/src/codex/hooks/spec-gate.cjs +151 -24
  91. package/src/codex/hooks/spec-state.cjs +65 -12
  92. package/src/codex/hooks/state.cjs +2 -0
  93. package/src/codex/hooks.json +16 -1
  94. package/src/codex/rules/state-sync.md +47 -27
  95. package/src/common/AGENTS.md +1 -1
  96. package/src/opencode/AGENTS.md +4 -2
  97. package/src/opencode/plugins/spec-gate.ts +296 -122
  98. package/src/opencode/plugins/spec-state.ts +183 -116
@@ -1,271 +1,189 @@
1
- # Task Generation Rules
2
-
3
- ## Core Principles
4
-
5
- ### 0. Pre-Generation Decision Gates
6
-
7
- Before writing any `tasks/task-R*.md` file:
8
-
9
- 1. Load `phase-decision-matrix.md` and identify implementation slices/task clusters: R0 foundation, risk spikes, vertical slices, layer slices, cross-cutting slices, integration gates, verification gates, and release/packaging slices when in scope.
10
- 2. Load `task-scoring-rubric.md` and score each candidate task. Use the result to choose priority, split/merge, spike needs, dependencies, parallel eligibility, and evidence depth.
11
- 3. Load `../references/ask-user-question-gates.md` if scoring or slicing detects unapproved scope expansion, unresolved architecture tie, missing evidence, contract ambiguity, or final contradiction.
12
- 4. Do not ask about facts that targeted scout, repo files, tests, or official/current docs can answer.
13
-
14
- The raw score table does not need to appear in each task file. The task file must reflect the decisions: why the task exists, what it depends on, why it is split/merged, whether it can be parallel, and what proof is required.
15
-
16
- ### 1. Natural Language Descriptions
17
- Focus on capabilities and outcomes, not code structure.
18
-
19
- **Describe**:
20
- - What functionality to achieve
21
- - Business logic and behavior
22
- - Features and capabilities
23
- - Domain language and concepts
24
- - Data relationships and workflows
25
- **Required (Hybrid Human-AI Style)**:
26
- Every sub-task MUST balance Human Intent (for PM review) and Code-Level Details (for AI implementation).
27
- Detail bullets must include:
28
- 1. **Human Intent (The "Why")**: Briefly explain the business logic, expected UX behavior, or why this code exists (e.g., "Mục đích: Chặn user sử dụng extension nếu chưa đồng ý Privacy").
29
- 2. **AI Code-Level Details (The "How")**:
30
- - File paths and specific UI components to create/modify.
31
- - Database tables, columns, and Zod/Type schemas (e.g., `Update users.consent_version`).
32
- - API payloads, routes, and JSON contracts.
33
- - Edge cases, error handling, and exact validation thresholds (e.g., `Return 403 if invalid`).
34
-
35
- **Rationale**: Humans review tasks to verify business requirements are met; AI Coders (like implementer or ck) read tasks to write explicit code. If you only write business jargon, the AI hallucinates. If you only write code names, the human reviewer cannot verify the business value. You MUST provide both.
36
-
37
- ### 2. Task Integration & Progression
38
-
39
- **Every task must**:
40
- - Build on previous outputs (no orphaned code)
41
- - Connect to the overall system (no hanging features)
42
- - Stay inside the approved `scope_lock` and requirement IDs; do not add unapproved features or silently drop scoped behavior
43
- - Progress incrementally (no big jumps in complexity)
44
- - Validate core functionality early in sequence
45
- - Respect architecture boundaries defined in design.md (Architecture Pattern & Boundary Map)
46
- - Honor interface contracts documented in design.md
47
- - Translate completion criteria into concrete proof (commands, artifacts, routes, manifests, schema objects, UI states)
48
- - Reuse canonical contracts from `design.md` verbatim; never invent alternate auth/provider/deletion policies in task prose
49
- - Use major task summaries sparingly—omit detail bullets if the work is fully captured by child tasks.
50
-
51
- **End with integration tasks** to wire everything together.
52
- - For UI/app/runtime workflows, the final integration task MUST name the real entrypoint (`App.tsx`, route, command, worker, extension manifest, API route, etc.) and verify every user-visible surface from the requirements is reachable from that entrypoint.
53
- - Components, services, routes, commands, workers, providers, and data loaders created by earlier tasks MUST be consumed by a later integration task or explicitly marked as internal support in `design.md`; orphaned deliverables are invalid.
54
- - Prefer compact, implementation-ready task prose over large boilerplate. The golden shape is: `Context` -> `Steps` -> `Requirements` -> `Related Files` -> `Completion Criteria` -> `Evidence` -> `Risk Assessment`.
55
- - A compact task is valid when it names exact files/contracts, maps requirements, and gives executable evidence. Do not expand it into nested filler just to satisfy a template.
56
-
57
- ### 3. Flexible Task Sizing
58
-
59
- **Guidelines**:
60
- - **Major tasks**: As many sub-tasks as logically needed (group by cohesion)
61
- - **Sub-tasks**: 1-3 hours each, 3-10 details per sub-task
62
- - Balance between too granular and too broad
63
-
64
- ### 3b. Requirement-to-Task Splitting Heuristics
65
-
66
- Each requirement from `requirements.md` generates **1 or more task files**. Use the following decision logic to determine how many:
67
-
68
- #### When to keep as 1 task file
69
- - Requirement has ≤ 3 acceptance criteria
70
- - All criteria touch the same architectural layer (e.g., all frontend, all backend)
71
- - Total estimated effort ≤ 3 hours
72
-
73
- #### When to split into multiple task files
74
- - Requirement has > 3 acceptance criteria spanning different concerns
75
- - Acceptance criteria touch **multiple architectural layers** (e.g., frontend + backend + database)
76
- - Total estimated effort > 4 hours
77
- - Criteria contain both "happy path" AND "error/edge case" logic that are independently testable
78
-
79
- #### Splitting strategy
80
- When splitting a requirement into multiple tasks:
81
- 1. **Split by architectural layer** — e.g., R1-01 for content script, R1-02 for API endpoint, R1-03 for database schema
82
- 2. **Split by concern** — e.g., R3-01 for consent onboarding UI, R3-02 for consent version re-check logic
83
- 3. **Split by dependency chain** — if acceptance criteria A must finish before B can start, they belong in separate task files with explicit `Dependencies:`
84
- 4. **Never split by arbitrary size** — don't create 3 task files just because "3 feels right"
85
- 5. **Use the Phase Decision Matrix** — only split when the implementation slice has an independent deliverable boundary or proof path.
86
-
87
- #### Cross-cutting requirements
88
- Some requirements (e.g., "language handling", "error handling") naturally touch code in many other requirements' tasks. For these:
89
- - Create 1 primary task file for the core logic (e.g., `task-R6-01-language-detection.md`)
90
- - Add secondary `_Requirements: 6_` references in other tasks' sub-tasks where the cross-cutting concern applies
91
- - Do NOT duplicate the same work across multiple task files
92
-
93
- ### 3c. Maintaining the Big Picture (Preventing Fragmentation)
94
-
95
- Grouping tasks vertically by requirement carries the risk of "siloed" or fragmented code (e.g., each requirement building its own isolated setup). To ensure the system remains cohesive:
96
-
97
- 1. **Foundation First (The R0 Concept)**: Extract shared infrastructure, core database migrations, authentication wrappers, and base UI layouts into foundational tasks running before feature work. If these aren't explicitly in requirements, classify them as `task-R0-XX-foundation.md` or map them to the most logical architectural requirement. All parallel feature tasks MUST depend on these foundation tasks.
98
- 2. **Shared Interfaces (Horizontal Contracts)**: Sub-tasks that touch shared cross-requirement architecture (like registering a new page in a global `router.ts` or adding a column to a shared table) MUST explicitly reference the shared contract defined in `design.md`.
99
- 3. **Integration Enforcers**: If R1 and R2 interact (e.g., R2 UI displays data fetched by R1 backend), the later task MUST have a sub-task explicitly dedicated to "Wiring/Integrating with [Previous Feature] output".
100
- 4. **Final Runtime Integration**: For any feature that has a user-facing screen, public route, CLI command, background worker, browser extension surface, or API flow, create a final integration task (or a final integration section in the last dependent task) that proves the whole scoped feature works from its runtime entrypoint. This task MUST fail if prior-task outputs exist but are not imported, mounted, registered, or invoked.
101
- 5. **Scored Sequencing**: Use `task-scoring-rubric.md` to schedule high-value/high-dependency tasks early, but only after required foundation/spike work. High file-conflict or high blast-radius tasks must not be marked `(P)` without isolated ownership.
102
-
103
- ### 3d. Spike Tasks for Complex/Uncertain Areas (MANDATORY)
104
-
105
- When the 5-Dimension Complexity Assessment (Step 3) flags a component or requirement as **Risk = Complex** (Cynefin), the task breakdown MUST include a dedicated **spike/prototype task** before the main implementation task for that area.
106
-
107
- **Purpose**: Validate assumptions and reduce uncertainty before committing to full implementation.
108
-
109
- **Naming convention:** `tasks/task-R{N}-00-spike-<slug>.md`
110
- - Use `00` as the sequence number to ensure it runs FIRST within its requirement group.
111
-
112
- **Spike task structure:**
113
- 1. **Objective**: State the specific uncertainty to resolve (e.g., "Validate that Google Meet captions DOM can be reliably scraped across account types")
114
- 2. **Success Criteria**: Define what a successful spike looks like (e.g., "Demonstrate caption text extraction from 3 different Meet account types")
115
- 3. **Time-box**: Maximum 4 hours. If spike exceeds time-box, escalate to user.
116
- 4. **Output**: A brief findings report (can be inline in the task file) and a go/no-go recommendation.
117
- 5. **Dependencies**: The main implementation task for this area MUST depend on the spike task.
118
-
119
- **When NOT to create spike tasks:**
120
- - Risk = Clear or Complicated → skip spike, proceed directly.
121
- - The uncertain area is already covered by research.md with concrete evidence (real API tests, not just documentation links).
122
-
123
- ### 6. Risk Assessment Table (MANDATORY)
124
-
125
- Every task file MUST contain the Risk Assessment table, even if no risks are identified.
126
- - **Rule**: If there are risks, list them with Severity and Mitigation.
127
- - **Rule**: If no risks are found, you MUST still include the table and write `| None identified | — | — |`.
128
- - Never skip the `## Risk Assessment` section.
129
-
130
- ### 4. Requirements Mapping
131
-
132
- **End each task detail section with**:
133
- - `_Requirements: X.X, Y.Y_` listing **only numeric requirement IDs** (comma-separated). Never append descriptive text, parentheses, translations, or free-form labels.
134
- - For cross-cutting requirements, list every relevant requirement ID. All requirements MUST have numeric IDs in requirements.md. If an ID is missing, stop and correct requirements.md before generating tasks.
135
- - Reference components/interfaces from design.md when helpful (e.g., `_Contracts: AuthService API`)
136
- - If a validation interview or red-team finding changes implementation behavior, update the sub-task itself. Do NOT hide the decision only inside `Risk Assessment`.
137
-
138
- ### 5. Code-Only Focus
139
-
140
- **Include ONLY**:
141
- - Coding tasks (implementation)
142
- - Testing tasks (unit, integration, E2E)
143
- - Technical setup tasks (infrastructure, configuration)
144
-
145
- **Exclude**:
146
- - Deployment tasks
147
- - Documentation tasks
148
- - User testing
149
- - Marketing/business activities
150
-
151
- ### Optional Test Coverage Tasks
152
-
153
- - When the design already guarantees functional coverage and rapid MVP delivery is prioritized, mark purely test-oriented follow-up work (e.g., baseline rendering/unit tests) as **optional** using the `- [ ]*` checkbox form.
154
- - Only apply the optional marker when the sub-task directly references acceptance criteria from requirements.md in its detail bullets.
155
- - Never mark implementation work or integration-critical verification as optional—reserve `*` for auxiliary/deferrable test coverage that can be revisited post-MVP.
156
- - Never mark auth, permissions, privacy, data deletion, migration, schema, or contract verification work as optional.
157
-
158
- ### Mandatory Evidence Section
159
-
160
- Every new task file MUST include a `## Evidence` section (`## Evidence` (legacy heading aliases still parse)).
161
-
162
- That section is the task-level test plan and proof checklist. It MUST contain:
163
- 1. **Automated proof** — exact command(s) for typecheck, tests, build, or explicit `N/A`
164
- 2. **Artifact/runtime proof** — exact files, routes, UI surfaces, generated outputs, or persisted state to inspect
165
- 3. **Contract/negative-path proof** — at least one contract-preserving check for unauthorized, invalid, missing-permission, rollback, or failure-path behavior when relevant
166
- 4. **Reachability proof** — when the task creates a runtime-facing artifact, name the upstream entrypoint or caller that reaches it; if reachability is deferred, name the exact later integration task responsible
167
-
168
- Rules:
169
- - If the task produces a build artifact or generated file, name the exact artifact path to inspect.
170
- - If the task wires entrypoints (popup, content script, route, worker, CLI command), name the exact runtime surface that must exist after implementation.
171
- - If the task creates a UI component, service, hook, reducer, route handler, worker, command, or data loader, the evidence MUST prove it is either reachable from the declared runtime surface or intentionally internal support for a named later task.
172
- - If verification depends on environment or manual setup, document the blocker explicitly instead of implying success.
173
- - Build success alone is NEVER enough evidence for a completed task.
174
- - For provider-sensitive work, use provider-neutral wording unless the scope lock explicitly names a vendor.
175
- - For delete-data/privacy work, task text MUST match the single deletion/retention policy chosen in `design.md`. Mixed policies are invalid.
176
-
177
- ### Test Type Selection
178
-
179
- Choose verification by task risk and touched surface. Do not force every task to include every test type, but do not omit the test type that proves the task's actual behavior.
180
-
181
- | Task kind | Required / expected proof |
182
- |---|---|
183
- | Pure logic, data transform, parser, sorting, filtering, validator | Unit test plus negative-path case |
184
- | Stateful UI component or user interaction | Component test or integration test; add runtime UI check if the component must be mounted |
185
- | Cross-module state, API, persistence, provider, or service boundary | Integration test that proves real contract/state handoff |
186
- | User-facing workflow across screens/components | E2E or UI flow verification after the vertical slice exists |
187
- | Layout, theme, responsive, visual style | Runtime/visual viewport checks; screenshot proof when practical |
188
- | Keyboard/focus/form/modal/table interaction | Accessibility check for focus, labels, roles, and keyboard behavior |
189
- | Scaffolding/config/release plumbing | Smoke checks: typecheck/build/test/dev-server or equivalent |
190
- | Bug fix/regression | Regression test reproducing the old failure, then passing |
191
- | Performance/security-sensitive requirement or touched surface | Performance/security check only when specified by requirements, design risk, or changed boundary |
192
-
193
- `hapo:specs` writes the expected proof into each task. `hapo:develop` executes the task-local proof before marking the task done. `hapo:test` runs the broader system pass after implementation or for a requested feature scope.
194
-
195
- ### Frontend Fidelity Rule (when a visual reference is provided)
196
-
197
- If the user/spec provides ANY visual reference for a frontend task — design image, Figma frame, screenshot, mockup, brand palette, design tokens, or a style guide — the task MUST reproduce it faithfully, not approximate it. Concretely, the task file MUST:
198
-
199
- 1. **Extract concrete values into the task** (do NOT paraphrase as "make it look nice"): exact colors (`#DAF1EE`), font family + sizes, spacing/radius/shadow when the reference shows them, and verbatim UI text/labels (especially non-English copy, e.g. `「投稿を削除しました」`).
200
- 2. **State a `MUST: match <reference>` constraint** naming the exact reference (e.g. `image_4.png` / Figma node / `tokens.css`), so fidelity is a requirement, not a suggestion.
201
- 3. **Prove fidelity in Evidence**: a visual/runtime check that compares the rendered UI against the named reference (screenshot diff or side-by-side inspection), plus accessibility/contrast if interactive.
202
-
203
- Reuse vs new component:
204
- - **Reuse** an existing component → reference it by path; it carries the design system's style (no need to restate pixels).
205
- - **New** component (`Create`) WITH a reference → the task MUST cite the concrete tokens/values from the reference (this is the gap that lets new components drift from the design).
206
- - **New** component WITHOUT any reference → derive from a named sibling component or explicitly flag it as an open design question; never invent un-grounded styling silently.
207
-
208
- > Rationale: a spec that says "build the list screen" but omits the provided palette/text/spacing forces the implementer to guess, and the result drifts from what the user actually showed. When a reference exists, "looks roughly similar" is a failure — the task must carry the real values so the build matches the design.
209
-
210
- ## Task Hierarchy Rules
211
-
212
- ### Maximum 2 Levels
213
- - Prefer one actionable checkbox per real implementation step.
214
- - Use sub-tasks (`1.1`, `1.2`) only when a step has multiple separately verifiable units.
215
- - **No deeper nesting** (no `1.1.1`).
216
- - If a major task would contain only a single actionable item, collapse the structure and promote the sub-task to the major level.
217
- - When a major task exists purely as a container, keep the checkbox description concise and avoid duplicating detailed bullets.
218
-
219
- ### Sequential Numbering
220
- - Major tasks MUST increment: 1, 2, 3, 4, 5...
221
- - Sub-tasks reset per major task: 1.1, 1.2, then 2.1, 2.2...
222
- - Never repeat major task numbers
223
-
224
- ### Parallel Analysis (default)
225
- - Assume parallel analysis is enabled unless explicitly disabled (e.g. `--sequential` flag).
226
- - Identify tasks that can run concurrently when **all** conditions hold:
227
- - No data dependency on other pending tasks
228
- - No shared file or resource contention
229
- - No prerequisite review/approval from another task
230
- - Environment/setup work needed by the task is already satisfied or covered within the task itself
231
- - Validate that identified parallel tasks operate within separate boundaries defined in the Architecture Pattern & Boundary Map.
232
- - Confirm API/event contracts from design.md do not overlap in ways that cause conflicts.
233
- - Append `(P)` immediately after the task number for each parallel-capable task, kept **outside** the checkbox brackets:
234
- - Example: `- [ ] 2.1 (P) Build background worker`
235
- - Apply to both major tasks and sub-tasks when appropriate.
236
- - If sequential mode is requested, omit `(P)` markers entirely.
237
- - Group parallel tasks logically (same parent when possible) and highlight any ordering caveats in detail bullets.
238
- - Do not mark container-only major tasks (no own actionable bullets) with `(P)` — evaluate parallelism at the sub-task level.
239
- - Explicitly call out dependencies that prevent `(P)` even when tasks look similar.
240
-
241
- ### Checkbox Format
242
- ```markdown
243
- - [ ] 1. Major task description
244
- - [ ] 1.1 Sub-task description
245
- - Detail item 1
246
- - Detail item 2
247
- - _Requirements: X.X_
248
-
249
- - [ ] 1.2 Sub-task description
250
- - Detail items...
251
- - _Requirements: Y.Y_
252
-
253
- - [ ] 1.3 Sub-task description
254
- - Detail items...
255
- - _Requirements: Z.Z, W.W_
256
-
257
- - [ ] 2. Next major task (NOT 1 again!)
258
- - [ ] 2.1 Sub-task...
259
- ```
260
-
261
- ## Requirements Coverage
262
-
263
- **Mandatory Check**:
264
- - ALL requirements from requirements.md MUST be covered
265
- - Cross-reference every requirement ID with task mappings
266
- - If gaps found: Return to requirements or design phase
267
- - No requirement should be left without corresponding tasks
268
-
269
- Use the requirement ID style already present in `requirements.md` (`R1`, `REQ-01`, or `N.M`). The task filename cluster (`task-R1-01-*`) does not have to mirror every requirement ID exactly, but every requirement MUST be listed in at least one task's `## Requirements` section.
270
-
271
- Document any intentionally deferred requirements with rationale.
1
+ # Task generation rules
2
+
3
+ Load this file only after the task gate passes. Compact durable specs are
4
+ taskless by default, but may have a task bundle and matching registry when a real
5
+ ownership, dependency, durable transition, separate proof, or parallel
6
+ coordination boundary activates the same gate used by Full specs. Full depth
7
+ does not activate the gate by itself.
8
+
9
+ ## Generation gate
10
+
11
+ A task must represent at least one real boundary: distinct ownership, a durable
12
+ dependency, a state transition, separate proof, or parallel coordination. If no
13
+ boundary exists, keep behavior in requirements/design and generate no task.
14
+
15
+ Persist the audited topology only in typed `spec.json.coordination.boundaries`:
16
+
17
+ - `ownership`: disjoint task write sets;
18
+ - `dependency`: producer, consumer, and exact deliverable;
19
+ - `transition`: owner/consumers plus pre/post/failure/recovery semantics;
20
+ - `proof`: subject, verifier, verification ref, and verifier-owned artifact anchor;
21
+ - `parallel`: independent tasks and exact resources.
22
+
23
+ A task bundle requires at least one complete boundary. Legacy trigger fields,
24
+ coordination flags, artifact flags, priority markers, and prose labels are
25
+ read compatibility inputs and forbidden in schema 2.1 authoring. Optional
26
+ phases may group task IDs but must reference a typed owner boundary.
27
+
28
+ Use `phase-decision-matrix.md` only when split/merge boundaries remain unclear.
29
+ Use the scoring rubric only as advisory input; scores, effort estimates, risk
30
+ labels, and requirement count never make a task mandatory.
31
+
32
+ ## Default decomposition
33
+
34
+ Prefer a vertical outcome slice that implements behavior through its real
35
+ runtime entrypoint and proves the result. Split horizontally only when:
36
+
37
+ - one owner must produce a contract, schema, or transition before consumers;
38
+ - file or contract ownership must be disjoint;
39
+ - a proof surface has a different durable owner; or
40
+ - parallel work has no dependency or shared resource contention.
41
+
42
+ Do not create foundation, integration, spike, testing, or release tasks by
43
+ habit. A support output must be consumed by a named later task or identified as
44
+ internal to the same vertical slice.
45
+
46
+ ## Task shape
47
+
48
+ Each task contains exactly the information an implementer needs:
49
+
50
+ 1. **Outcome** — observable behavior delivered by the task.
51
+ 2. **Scope** — exact in/out behavior boundary.
52
+ 3. **Anchors and Ownership** — one six-column ownership projection.
53
+ 4. **Changes** — behavior and code changes, including relevant negative paths.
54
+ 5. **Acceptance** — measurable requirement IDs and task-local outcomes.
55
+ 6. **Dependencies** — projection of typed dependency boundaries or `none`.
56
+ 7. **Verification Plan** — command/inspection, expected result, negative path,
57
+ runtime reachability, exact design `V` ID, and task role when applicable.
58
+
59
+ Do not add estimated effort, empty risk tables, receipt fields, Base/Head,
60
+ verdicts, provenance, agent chains, or generic completion ceremony.
61
+
62
+ `**Status:**` is the canonical files-first lifecycle projection for each task.
63
+ Its value must stay byte-for-byte equivalent in meaning to
64
+ `spec.json.task_registry[path].status`; use the same exact canonical token in
65
+ both places. Allowed values are `pending`, `in_progress`, `blocked`, and `done`.
66
+ Authoring initializes tasks as `pending`. A later lifecycle transition updates
67
+ the task Markdown and registry together. `done` proof remains owned by execution
68
+ closeout; do not add receipts, Evidence sections, Base/Head bindings, verdicts,
69
+ or provenance to the task plan.
70
+
71
+ ## Typed anchors
72
+
73
+ The task's only ownership table is `ID | Type | Target | Role | Access |
74
+ Action`. IDs are unique across the spec. `Access` is `read` or `write`; read
75
+ requires `Action=read`, while write requires `create`, `modify`, or `delete`.
76
+ Targets are exact and grounded, never globs or parent-directory claims. Allowed
77
+ types are `file`, `symbol`, `command`, `route`, `schema`, `contract`, `artifact`,
78
+ and `external`.
79
+
80
+ - Files-first: list exact `file` anchors before anchors contained by those files.
81
+ - Task-owned anchors use `A-R{requirement}-{sequence}-NN`, populated from the
82
+ canonical task ID; their counter is local to that namespace, not globally
83
+ reused as an unnamespaced counter.
84
+ - When the task only consumes a target already anchored by design, reference the
85
+ canonical `A-D-NN` anchor instead of creating another anchor for that target.
86
+ - `Modify`, `Delete`, and `Read` paths must exist when authored; `Create` paths
87
+ need a grounded parent/boundary.
88
+ - A symbol target names or references its containing file.
89
+ - A command target is copied from real project tooling, not invented.
90
+ - A contract anchor references its stable design ID; never copy the contract
91
+ body into the task.
92
+ - Duplicate IDs anywhere in design or tasks block readiness.
93
+
94
+ ## Contracts, ownership, and dependencies
95
+
96
+ Each cross-task contract, invariant, schema transition, or recovery authority
97
+ has exactly one owner task. Every consumer:
98
+
99
+ - references the named contract/invariant ID;
100
+ - depends directly or transitively on the owner; and
101
+ - does not redefine the canonical body.
102
+
103
+ Each `RN.M` has exactly one implementation owner. A proof boundary means its
104
+ subject implements the product criterion and its verifier verifies the referenced
105
+ `V` definition through a separately owned proof criterion/artifact. The verifier
106
+ must not repeat the subject's criterion in `Acceptance`; sharing a proof boundary
107
+ does not create a second implementation owner. Their shared V definition names
108
+ both exact criteria so subject, verifier, and proof boundary resolve to one
109
+ verification contract.
110
+
111
+ Task Markdown and `spec.json.task_registry[path]` must keep both `status` and
112
+ `dependencies` synchronized. Derive task ID from
113
+ `tasks/task-R{N}-{SEQ}-<slug>.md`; use two-digit `SEQ`. Do not create shorthand
114
+ filenames.
115
+
116
+ Parallel eligibility exists only when a typed `parallel` boundary proves exact
117
+ disjoint resources, no dependency path, and no shared transition/proof
118
+ authority. Do not author a parallel-priority marker.
119
+
120
+ ## Changes and acceptance
121
+
122
+ Describe product behavior and the code boundary together. Name exact validation,
123
+ state, route, schema, error, and integration behavior only when relevant. Keep
124
+ all work inside `scope_lock`; an expansion pauses for explicit user approval.
125
+
126
+ Map acceptance to numeric `N.M` IDs from `requirements.md`. Include negative or
127
+ error outcomes where invalid input, missing permission, failure, conflict,
128
+ timeout, retry, rollback, or recovery is relevant. Do not add vague acceptance
129
+ such as “works”, “safe”, or “performant”.
130
+
131
+ ## Verification plan
132
+
133
+ Choose proportional proof for the changed surface:
134
+
135
+ - exact command-shaped invocation or justified `N/A`;
136
+ - expected exit, output, state, artifact, or UI result;
137
+ - contract-preserving negative-path check when relevant; and
138
+ - real entrypoint/caller for runtime-facing work, or the exact dependent task
139
+ that will establish reachability.
140
+
141
+ Declare exactly `Verification ref: Vn` and `Task role: subject` or `Task role:
142
+ verifier`. The V definition lives once in `design.md` using the canonical
143
+ single-line bold-ID syntax. The task references it and does not copy its body.
144
+
145
+ Every executable implementation task must declare concrete test ownership: at
146
+ least one `file` or `artifact` anchor with `write` `create` or `modify` that is
147
+ the focused test, or share proof through a typed `proof` boundary whose
148
+ verifier owns the separate proof artifact. A generic `npm test` string alone
149
+ is not ownership; shared proof without a typed boundary is not ownership.
150
+
151
+ Access/action reachability is deterministic:
152
+
153
+ | Access | Allowed Action | Grounding meaning |
154
+ |---|---|---|
155
+ | `read` | `read` | Exact target already exists and is inspected/consumed. |
156
+ | `write` | `modify` or `delete` | Exact target already exists and is owned by this task. |
157
+ | `write` | `create` | Exact target is absent and its parent/boundary is grounded. |
158
+
159
+ Commands, symbols, contracts, routes, schemas, artifacts, and external targets
160
+ also receive their type-specific grounding check. Grounding is mandatory before
161
+ readiness; the deterministic validator/grounder recompute facts and never create
162
+ an extra receipt or claim semantic judgment.
163
+
164
+ Build success alone is not behavior proof. Static validation may check command
165
+ shape and anchors, but execution owns actual runtime proof.
166
+
167
+ `feature-receipt.md` is created only during execution closeout. Never create or
168
+ reference it as a spec-ready requirement.
169
+
170
+ Every physical task participates in at least one justified typed boundary.
171
+ Ownership and parallel resource maps are keyed exactly by their participants,
172
+ contain non-empty unique exact targets, and equal the task write anchors they
173
+ claim. An ownership boundary is truthful only when at least two physical tasks
174
+ have distinct, non-overlapping exact write anchors. A dependency boundary must match
175
+ the registry DAG and producer-write/consumer-read anchors. Proof, transition,
176
+ and parallel boundaries must satisfy their typed fields; labels never suffice.
177
+
178
+ ## Task graph and phases
179
+
180
+ When a task bundle exists:
181
+
182
+ - cover every scoped acceptance criterion exactly where it is implemented or
183
+ proven;
184
+ - keep owner-before-consumer ordering explicit;
185
+ - rebuild registry inventory from physical task files before readiness; and
186
+ - use optional phases only as compact task-ID groups in `spec.json` for a
187
+ complex Full graph.
188
+
189
+ Never create phase files or repeat task prose in phase metadata.