@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,300 +1,189 @@
1
- # Task Generation Rules
2
-
3
- ## Core Principles
4
-
5
- ### 0. Conditional generation gates
6
-
7
- This file is loaded only after the persisted lane obligations say that a task
8
- bundle is needed. A bounded Standard scope may finish with its feature receipt
9
- and no `tasks/` or registry.
10
-
11
- Before writing any `tasks/task-R*.md` file:
12
-
13
- 1. Load `phase-decision-matrix.md` only if the task boundaries are unclear.
14
- 2. Load `task-scoring-rubric.md` only if an actual split/merge, dependency, or
15
- evidence-depth decision needs it. Scoring is optional and never selects a
16
- lane or makes tasks mandatory.
17
- 3. Load `../references/ask-user-question-gates.md` only for an unapproved scope
18
- change, unresolved architecture choice, missing evidence, or contradiction.
19
- 4. Use targeted scout, repository files, tests, and current primary docs for
20
- facts before asking the user.
21
-
22
- The task file must explain only decisions that affect execution: scope,
23
- dependencies, ownership, proof, and any intentional split/merge.
24
-
25
- ### 1. Natural Language Descriptions
26
- Focus on capabilities and outcomes, not code structure.
27
-
28
- **Describe**:
29
- - What functionality to achieve
30
- - Business logic and behavior
31
- - Features and capabilities
32
- - Domain language and concepts
33
- - Data relationships and workflows
34
- **Required (Hybrid Human-AI Style)**:
35
- Every sub-task MUST balance Human Intent (for PM review) and Code-Level Details (for AI implementation).
36
- Detail bullets must include:
37
- 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").
38
- 2. **AI Code-Level Details (The "How")**:
39
- - File paths and specific UI components to create/modify.
40
- - Database tables, columns, and Zod/Type schemas (e.g., `Update users.consent_version`).
41
- - API payloads, routes, and JSON contracts.
42
- - Edge cases, error handling, and exact validation thresholds (e.g., `Return 403 if invalid`).
43
-
44
- **Rationale**: Humans review tasks to verify business requirements are met;
45
- coding agents read tasks to write explicit code. If you only write business
46
- jargon, the AI hallucinates. If you only write code names, the human reviewer
47
- cannot verify the business value. You MUST provide both.
48
-
49
- ### 2. Task Integration & Progression
50
-
51
- **Every task must**:
52
- - Build on previous outputs (no orphaned code)
53
- - Connect to the overall system (no hanging features)
54
- - Stay inside the approved `scope_lock` and requirement IDs; do not add unapproved features or silently drop scoped behavior
55
- - Progress incrementally (no big jumps in complexity)
56
- - Validate core functionality early in sequence
57
- - Respect architecture boundaries defined in design.md (Architecture Pattern & Boundary Map)
58
- - Honor interface contracts documented in design.md
59
- - Translate completion criteria into concrete proof (commands, artifacts, routes, manifests, schema objects, UI states)
60
- - Reuse canonical contracts from `design.md` verbatim; never invent alternate auth/provider/deletion policies in task prose
61
- - Use major task summaries sparingly—omit detail bullets if the work is fully captured by child tasks.
62
-
63
- **Add integration proof when the surface needs it**.
64
- - For UI/app/runtime workflows, the last task or a final integration section
65
- names the real entrypoint (`App.tsx`, route, command, worker, extension
66
- manifest, API route, etc.) and verifies every scoped surface is reachable.
67
- - 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.
68
- - Prefer compact, implementation-ready task prose over large boilerplate. The golden shape is: `Context` -> `Steps` -> `Requirements` -> `Related Files` -> `Completion Criteria` -> `Evidence` -> `Risk Assessment`.
69
- - 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.
70
-
71
- ### 3. Flexible Task Sizing
72
-
73
- **Guidelines**:
74
- - **Major tasks**: As many sub-tasks as logically needed (group by cohesion)
75
- - **Sub-tasks**: 1-3 hours each, 3-10 details per sub-task
76
- - Balance between too granular and too broad
77
-
78
- ### 3b. Requirement-to-Task Splitting Heuristics
79
-
80
- Each requirement from `requirements.md` generates **1 or more task files**. Use the following decision logic to determine how many:
81
-
82
- #### When to keep as 1 task file
83
- - Requirement has ≤ 3 acceptance criteria
84
- - All criteria touch the same architectural layer (e.g., all frontend, all backend)
85
- - Total estimated effort ≤ 3 hours
86
-
87
- #### When to split into multiple task files
88
- - Requirement has > 3 acceptance criteria spanning different concerns
89
- - Acceptance criteria touch **multiple architectural layers** (e.g., frontend + backend + database)
90
- - Total estimated effort > 4 hours
91
- - Criteria contain both "happy path" AND "error/edge case" logic that are independently testable
92
-
93
- #### Splitting strategy
94
- When splitting a requirement into multiple tasks:
95
- 1. **Split by architectural layer** — e.g., R1-01 for content script, R1-02 for API endpoint, R1-03 for database schema
96
- 2. **Split by concern** — e.g., R3-01 for consent onboarding UI, R3-02 for consent version re-check logic
97
- 3. **Split by dependency chain** — if acceptance criteria A must finish before B can start, they belong in separate task files with explicit `Dependencies:`
98
- 4. **Never split by arbitrary size** — don't create 3 task files just because "3 feels right"
99
- 5. **Use the Phase Decision Matrix** — only split when the implementation slice has an independent deliverable boundary or proof path.
100
-
101
- #### Cross-cutting requirements
102
- Some requirements (e.g., "language handling", "error handling") naturally touch code in many other requirements' tasks. For these:
103
- - Create 1 primary task file for the core logic (e.g., `task-R6-01-language-detection.md`)
104
- - Add secondary `_Requirements: 6_` references in other tasks' sub-tasks where the cross-cutting concern applies
105
- - Do NOT duplicate the same work across multiple task files
106
-
107
- ### 3c. Maintaining the Big Picture (Preventing Fragmentation)
108
-
109
- 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:
110
-
111
- 1. **Foundation only when real**: Add a foundation task only for a shared
112
- prerequisite that has its own ownership or proof boundary. Do not invent an
113
- R0 task for a small bounded change.
114
- 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`.
115
- 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".
116
- 4. **Final Runtime Integration**: For a feature with a user-facing or
117
- runtime-facing surface, include a final integration task or section only if
118
- the existing task evidence does not already prove the entrypoint. It MUST
119
- fail when outputs are not imported, mounted, registered, or invoked.
120
- 5. **Advisory sequencing**: If the optional rubric was used, apply its
121
- dependency/ownership notes. Never use a score to add ceremony or override
122
- the persisted lane.
123
-
124
- ### 3d. Spike tasks for unresolved uncertainty (ADVISORY)
125
-
126
- When the assessment flags an unproven assumption, a time-boxed spike may be
127
- useful before implementation. A Cynefin `Complex` label alone does not mandate
128
- one, change the lane, or create a registry/DAG.
129
-
130
- **Purpose**: Validate assumptions and reduce uncertainty before committing to full implementation.
131
-
132
- **Naming convention:** `tasks/task-R{N}-00-spike-<slug>.md`
133
- - Use `00` as the sequence number to ensure it runs FIRST within its requirement group.
134
-
135
- **Spike task structure:**
136
- 1. **Objective**: State the specific uncertainty to resolve (e.g., "Validate that Google Meet captions DOM can be reliably scraped across account types")
137
- 2. **Success Criteria**: Define what a successful spike looks like (e.g., "Demonstrate caption text extraction from 3 different Meet account types")
138
- 3. **Time-box**: Maximum 4 hours. If spike exceeds time-box, escalate to user.
139
- 4. **Output**: A brief findings report (can be inline in the task file) and a go/no-go recommendation.
140
- 5. **Dependencies**: The main implementation task for this area MUST depend on the spike task.
141
-
142
- **When NOT to create spike tasks:**
143
- - the assumption is already grounded by targeted evidence or required research;
144
- - the change is clear enough for a direct implementation/proof path;
145
- - the spike would add ceremony without reducing a concrete uncertainty.
146
-
147
- ### 6. Risk Assessment Table (MANDATORY)
148
-
149
- Every task file MUST contain the Risk Assessment table, even if no risks are identified.
150
- - **Rule**: If there are risks, list them with Severity and Mitigation.
151
- - **Rule**: If no risks are found, you MUST still include the table and write `| None identified | — | — |`.
152
- - Never skip the `## Risk Assessment` section.
153
-
154
- ### 4. Requirements Mapping
155
-
156
- **End each task detail section with**:
157
- - `_Requirements: X.X, Y.Y_` listing **only numeric requirement IDs** (comma-separated). Never append descriptive text, parentheses, translations, or free-form labels.
158
- - 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.
159
- - Reference components/interfaces from design.md when helpful (e.g., `_Contracts: AuthService API`)
160
- - 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`.
161
-
162
- ### 5. Code-Only Focus
163
-
164
- **Include ONLY**:
165
- - Coding tasks (implementation)
166
- - Testing tasks (unit, integration, E2E)
167
- - Technical setup tasks (infrastructure, configuration)
168
-
169
- **Exclude**:
170
- - Deployment tasks
171
- - Documentation tasks
172
- - User testing
173
- - Marketing/business activities
174
-
175
- ### Optional Test Coverage Tasks
176
-
177
- - 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.
178
- - Only apply the optional marker when the sub-task directly references acceptance criteria from requirements.md in its detail bullets.
179
- - Never mark implementation work or integration-critical verification as optional—reserve `*` for auxiliary/deferrable test coverage that can be revisited post-MVP.
180
- - Never mark auth, permissions, privacy, data deletion, migration, schema, or contract verification work as optional.
181
-
182
- ### Mandatory Evidence Section
183
-
184
- Every new task file MUST include a `## Evidence` section (`## Evidence` (legacy heading aliases still parse)).
185
-
186
- That section is the task-level test plan and proof checklist. It MUST contain:
187
- 1. **Automated proof** — exact command(s) for typecheck, tests, build, or explicit `N/A`
188
- 2. **Artifact/runtime proof** — exact files, routes, UI surfaces, generated outputs, or persisted state to inspect
189
- 3. **Contract/negative-path proof** — at least one contract-preserving check for unauthorized, invalid, missing-permission, rollback, or failure-path behavior when relevant
190
- 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
191
-
192
- Rules:
193
- - If the task produces a build artifact or generated file, name the exact artifact path to inspect.
194
- - If the task wires entrypoints (popup, content script, route, worker, CLI command), name the exact runtime surface that must exist after implementation.
195
- - 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.
196
- - If verification depends on environment or manual setup, document the blocker explicitly instead of implying success.
197
- - Build success alone is NEVER enough evidence for a completed task.
198
- - For provider-sensitive work, use provider-neutral wording unless the scope lock explicitly names a vendor.
199
- - For delete-data/privacy work, task text MUST match the single deletion/retention policy chosen in `design.md`. Mixed policies are invalid.
200
-
201
- ### Test Type Selection
202
-
203
- 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.
204
-
205
- | Task kind | Required / expected proof |
206
- |---|---|
207
- | Pure logic, data transform, parser, sorting, filtering, validator | Unit test plus negative-path case |
208
- | Stateful UI component or user interaction | Component test or integration test; add runtime UI check if the component must be mounted |
209
- | Cross-module state, API, persistence, provider, or service boundary | Integration test that proves real contract/state handoff |
210
- | User-facing workflow across screens/components | E2E or UI flow verification after the vertical slice exists |
211
- | Layout, theme, responsive, visual style | Runtime/visual viewport checks; screenshot proof when practical |
212
- | Keyboard/focus/form/modal/table interaction | Accessibility check for focus, labels, roles, and keyboard behavior |
213
- | Scaffolding/config/release plumbing | Smoke checks: typecheck/build/test/dev-server or equivalent |
214
- | Bug fix/regression | Regression test reproducing the old failure, then passing |
215
- | Performance/security-sensitive requirement or touched surface | Performance/security check only when specified by requirements, design risk, or changed boundary |
216
-
217
- `hapo:specs` writes the expected proof into each task. `hapo:test` is the sole
218
- execution-proof owner and emits the canonical receipt. `hapo:develop` consumes
219
- that proof at closeout; it does not create a second execution receipt.
220
-
221
- ### Frontend Fidelity Rule (when a visual reference is provided)
222
-
223
- 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:
224
-
225
- 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. `「投稿を削除しました」`).
226
- 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.
227
- 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.
228
-
229
- Reuse vs new component:
230
- - **Reuse** an existing component → reference it by path; it carries the design system's style (no need to restate pixels).
231
- - **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).
232
- - **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.
233
-
234
- > 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.
235
-
236
- ## Task Hierarchy Rules
237
-
238
- ### Maximum 2 Levels
239
- - Prefer one actionable checkbox per real implementation step.
240
- - Use sub-tasks (`1.1`, `1.2`) only when a step has multiple separately verifiable units.
241
- - **No deeper nesting** (no `1.1.1`).
242
- - If a major task would contain only a single actionable item, collapse the structure and promote the sub-task to the major level.
243
- - When a major task exists purely as a container, keep the checkbox description concise and avoid duplicating detailed bullets.
244
-
245
- ### Sequential Numbering
246
- - Major tasks MUST increment: 1, 2, 3, 4, 5...
247
- - Sub-tasks reset per major task: 1.1, 1.2, then 2.1, 2.2...
248
- - Never repeat major task numbers
249
-
250
- ### Parallel Analysis (default)
251
- - Assume parallel analysis is enabled unless explicitly disabled (e.g. `--sequential` flag).
252
- - Identify tasks that can run concurrently when **all** conditions hold:
253
- - No data dependency on other pending tasks
254
- - No shared file or resource contention
255
- - No prerequisite review/approval from another task
256
- - Environment/setup work needed by the task is already satisfied or covered within the task itself
257
- - Validate that identified parallel tasks operate within separate boundaries defined in the Architecture Pattern & Boundary Map.
258
- - Confirm API/event contracts from design.md do not overlap in ways that cause conflicts.
259
- - Append `(P)` immediately after the task number for each parallel-capable task, kept **outside** the checkbox brackets:
260
- - Example: `- [ ] 2.1 (P) Build background worker`
261
- - Apply to both major tasks and sub-tasks when appropriate.
262
- - If sequential mode is requested, omit `(P)` markers entirely.
263
- - Group parallel tasks logically (same parent when possible) and highlight any ordering caveats in detail bullets.
264
- - Do not mark container-only major tasks (no own actionable bullets) with `(P)` — evaluate parallelism at the sub-task level.
265
- - Explicitly call out dependencies that prevent `(P)` even when tasks look similar.
266
-
267
- ### Checkbox Format
268
- ```markdown
269
- - [ ] 1. Major task description
270
- - [ ] 1.1 Sub-task description
271
- - Detail item 1
272
- - Detail item 2
273
- - _Requirements: X.X_
274
-
275
- - [ ] 1.2 Sub-task description
276
- - Detail items...
277
- - _Requirements: Y.Y_
278
-
279
- - [ ] 1.3 Sub-task description
280
- - Detail items...
281
- - _Requirements: Z.Z, W.W_
282
-
283
- - [ ] 2. Next major task (NOT 1 again!)
284
- - [ ] 2.1 Sub-task...
285
- ```
286
-
287
- ## Requirements Coverage
288
-
289
- **Check when a task bundle exists**:
290
- - ALL requirements assigned to the task bundle MUST be covered
291
- - Cross-reference every requirement ID with task mappings
292
- - If gaps found: Return to requirements or design phase
293
- - No requirement should be left without corresponding tasks
294
-
295
- Use the requirement ID style already present in `requirements.md` (`R1`,
296
- `REQ-01`, or `N.M`). The task filename cluster (`task-R1-01-*`) does not have
297
- to mirror every requirement ID exactly, but every requirement represented by
298
- the bundle MUST be listed in at least one task's `## Requirements` section.
299
-
300
- 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.