@haposoft/cafekit 0.16.0-rc.6 → 0.16.0-rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +21 -58
  2. package/bin/__tests__/change-firewall.semantic-firewall.test.js +4 -5
  3. package/bin/__tests__/codex-hooks.test.js +137 -0
  4. package/bin/__tests__/codex-native.test.js +130 -74
  5. package/bin/__tests__/develop-contract.test.js +155 -76
  6. package/bin/__tests__/installer-safety.test.js +19 -154
  7. package/bin/__tests__/package-inventory.test.js +10 -20
  8. package/bin/__tests__/release-preflight.semantic-firewall.test.js +2 -2
  9. package/bin/__tests__/validator-grounding.test.js +11 -11
  10. package/bin/install.js +2 -7
  11. package/bin/lib/context.js +0 -45
  12. package/bin/lib/copy-utils.js +1 -1
  13. package/bin/lib/i18n.js +0 -3
  14. package/bin/lib/manifest.js +1 -1
  15. package/bin/phases/claude-runtime.js +1 -3
  16. package/bin/phases/codex-runtime.js +4 -2
  17. package/bin/phases/copy-payload.js +3 -15
  18. package/bin/phases/post-install.js +5 -17
  19. package/bin/phases/root-config.js +2 -3
  20. package/bin/phases/select-platform.js +2 -5
  21. package/bin/phases/summary.js +0 -1
  22. package/package.json +2 -5
  23. package/src/claude/CLAUDE.md +19 -6
  24. package/src/claude/agents/project-manager.md +41 -9
  25. package/src/claude/agents/spec-maker.md +76 -155
  26. package/src/claude/gitignore +1 -1
  27. package/src/claude/hooks/__tests__/spec-gate.test.js +162 -0
  28. package/src/claude/hooks/lib/context.cjs +1 -1
  29. package/src/claude/hooks/lib/detect.cjs +1 -1
  30. package/src/claude/hooks/spec-gate.cjs +44 -9
  31. package/src/claude/hooks/spec-state.cjs +22 -11
  32. package/src/claude/hooks/task-scaffold-guard.cjs +1 -1
  33. package/src/claude/migration-manifest.json +17 -3
  34. package/src/claude/rules/manage-docs.md +43 -24
  35. package/src/claude/rules/state-sync.md +57 -62
  36. package/src/claude/rules/workflow.md +30 -13
  37. package/src/claude/scripts/change-firewall.cjs +2 -2
  38. package/src/claude/scripts/generate-skill-catalog.cjs +0 -1
  39. package/src/claude/scripts/spec-receipt.cjs +141 -1
  40. package/src/claude/scripts/spec-resolver.cjs +288 -0
  41. package/src/claude/skills/develop/SKILL.md +89 -125
  42. package/src/claude/skills/develop/references/parallel-waves.md +75 -162
  43. package/src/claude/skills/develop/references/quality-gate.md +61 -121
  44. package/src/claude/skills/develop/references/subagent-patterns.md +31 -38
  45. package/src/claude/skills/question/SKILL.md +1 -1
  46. package/src/claude/skills/specs/SKILL.md +142 -204
  47. package/src/claude/skills/specs/references/review.md +109 -243
  48. package/src/claude/skills/specs/references/templates.md +173 -0
  49. package/src/claude/skills/sync/SKILL.md +66 -90
  50. package/src/claude/skills/sync/references/sync-protocols.md +62 -83
  51. package/src/codex/AGENTS.md +20 -7
  52. package/src/codex/hooks/lib/spec-receipt.cjs +18 -0
  53. package/src/codex/hooks/lib/spec-utils.cjs +25 -0
  54. package/src/codex/hooks/spec-gate.cjs +46 -16
  55. package/src/codex/hooks/spec-state.cjs +22 -12
  56. package/src/codex/rules/state-sync.md +57 -61
  57. package/src/common/AGENTS.md +8 -1
  58. package/bin/__tests__/opencode-spec-gate.test.js +0 -799
  59. package/bin/lib/opencode-install.js +0 -899
  60. package/bin/phases/opencode-runtime.js +0 -38
  61. package/src/claude/skills/specs/references/archive-workflow.md +0 -74
  62. package/src/claude/skills/specs/references/ask-user-question-gates.md +0 -70
  63. package/src/claude/skills/specs/references/codebase-analysis.md +0 -102
  64. package/src/claude/skills/specs/references/cross-spec-dependency.md +0 -76
  65. package/src/claude/skills/specs/references/research-strategy.md +0 -107
  66. package/src/claude/skills/specs/references/scope-inquiry.md +0 -107
  67. package/src/claude/skills/specs/references/translation-mirror.md +0 -83
  68. package/src/claude/skills/specs/rules/design-discovery-full.md +0 -45
  69. package/src/claude/skills/specs/rules/design-discovery-light.md +0 -28
  70. package/src/claude/skills/specs/rules/design-principles.md +0 -138
  71. package/src/claude/skills/specs/rules/design-review.md +0 -55
  72. package/src/claude/skills/specs/rules/ears-format.md +0 -42
  73. package/src/claude/skills/specs/rules/phase-decision-matrix.md +0 -56
  74. package/src/claude/skills/specs/rules/task-scoring-rubric.md +0 -52
  75. package/src/claude/skills/specs/rules/tasks-generation.md +0 -189
  76. package/src/opencode/AGENTS.md +0 -41
  77. package/src/opencode/plugins/docs-sync.ts +0 -175
  78. package/src/opencode/plugins/inspect-block.ts +0 -164
  79. package/src/opencode/plugins/privacy-block.ts +0 -182
  80. package/src/opencode/plugins/rules.ts +0 -155
  81. package/src/opencode/plugins/session.ts +0 -179
  82. package/src/opencode/plugins/spec-gate.ts +0 -457
  83. package/src/opencode/plugins/spec-state.ts +0 -311
  84. package/src/opencode/plugins/state.ts +0 -253
  85. package/src/opencode/plugins/task-scaffold-guard.ts +0 -161
  86. package/src/opencode/plugins/usage.ts +0 -178
@@ -1,243 +1,109 @@
1
- # Whole-spec semantic review v2.1
2
-
3
- ## Purpose
4
-
5
- Review the spec as one consistency graph. A structural validator exit 0 proves
6
- only implemented structural checks; it does not prove semantic completeness,
7
- grounding, product correctness, negative paths, or executable behavior.
8
-
9
- ## Resolve and inventory
10
-
11
- 1. Resolve the exact spec path; ambiguous active specs fail closed.
12
- 2. Read final physical `spec.json`, `requirements.md`, `design.md`, optional
13
- `research.md`, every task, and the machine-recorded semantic-review state.
14
- 3. Confirm the physical artifact set matches `planning_depth` and its justified
15
- optional gates:
16
- - `None`: no durable spec;
17
- - `Compact`: three-file core plus an optional task bundle/registry only when
18
- ownership, dependency, durable transition, separate proof, or parallel
19
- coordination activates the task gate;
20
- - `Full`: the same three-file core plus only justified optional research,
21
- task, or complex-task-graph phase metadata. Full depth
22
- alone does not justify any optional artifact.
23
- 4. Reject `feature-receipt.md` in spec authoring. It belongs to execution
24
- closeout only.
25
-
26
- ## Consistency graph
27
-
28
- Build and inspect these edges:
29
-
30
- ```text
31
- scope_lock
32
- -> outcomes/non-goals
33
- -> RN.M acceptance
34
- -> design boundary + typed anchors
35
- -> named contracts/invariants
36
- -> conditional task owners/consumers
37
- -> verification + negative paths
38
- -> technical readiness
39
- ```
40
-
41
- Check both directions:
42
-
43
- - every scoped outcome reaches measurable acceptance and proof;
44
- - every design decision traces to scope or acceptance;
45
- - every anchor has an ID unique across the whole spec, allowed type, exact
46
- target, and role;
47
- - design anchors use `A-D-NN`; task-owned anchors use the canonical task-scoped
48
- `A-R{requirement}-{sequence}-NN` namespace;
49
- - file anchors come first and symbols identify their containing files;
50
- - a task that only consumes a design target references its canonical `A-D-NN`
51
- anchor instead of redefining the same target under a task-local ID;
52
- - every named contract/invariant has one canonical definition;
53
- - tasks reference contract IDs without copying bodies;
54
- - every cross-task contract/transition has exactly one owner before consumers;
55
- - every `RN.M` has exactly one implementation owner; a proof verifier owns a
56
- separate proof criterion/artifact and does not repeat the subject's Acceptance;
57
- - every dependency is real and Markdown agrees with `task_registry`;
58
- - every task has one canonical `**Status:**` header using `pending`,
59
- `in_progress`, `blocked`, or `done`, and its exact status token matches
60
- `spec.json.task_registry[path].status`;
61
- - every task has exactly seven H2 sections and one
62
- `ID | Type | Target | Role | Access | Action` table;
63
- - typed `coordination.boundaries` own topology; legacy trigger fields, priority
64
- markers, related-file lists, and prose own nothing;
65
- - every executable implementation task owns a concrete test file or artifact
66
- anchor or shares proof through a typed `proof` boundary; a bare `npm test`
67
- string without such an anchor is not ownership;
68
- - specs-only never creates or updates docs and never fabricates execution
69
- proof; doc impact is a brief recommendation at most;
70
- - no task, phase, research note, or review finding expands `scope_lock`;
71
- - optional phases exist only as compact `spec.json` groups for a complex Full
72
- task graph and never repeat prose.
73
- - exactly one `## Verification Definitions` section uses parser-visible lines
74
- `- **Vn**: Criteria RN.M; Owner ...; [Proof criteria ...; Proof owner ...;
75
- Evidence anchor ...;] Decision refs D/I/C; Method ...; Expected ...;
76
- Negative/failure ...; Reachability/grounding ...`; the proof extension is
77
- conditional on a typed proof boundary; tables and V headings are not canonical.
78
-
79
- ## Counterexample review
80
-
81
- For every `RN.M`, try at least one concrete counterexample that could
82
- make two competent implementers choose different behavior. Use relevant lenses:
83
-
84
- - missing/invalid input or permission;
85
- - dependency unavailable, timeout, partial success, retry, or duplicate event;
86
- - conflicting state, ordering, concurrency, restart, rollback, or migration;
87
- - boundary bypass, data disclosure, retention, or authorization confusion;
88
- - wrong clock anchor/source/timezone/precision or cutoff comparator/inclusivity or enforcement boundary for a retention/lifecycle rule (for example creation time or UTC vs local or `>` vs `>=` mismatch) that would retain or delete the wrong records;
89
- - partial public, replay, or operator API contract (missing method, route, auth, headers, request or response schema, error semantics, or idempotency and concurrency behavior);
90
- - orphaned route/component/worker/artifact with no runtime reachability;
91
- - task consumer beginning before its contract/schema/transition owner;
92
- - verification command passing while the user-visible behavior is wrong;
93
- - an executable task with only a generic test command and no owned test file or typed proof verifier.
94
-
95
- A counterexample passes only when requirements or design already choose the
96
- behavior and the verification plan can distinguish the correct result. Do not
97
- invent a product decision during review; unresolved choices require a user
98
- decision. Two-review target is advisory: after two failed semantic rounds, pause for unresolved product/security/architecture uncertainty or repeated non-convergence; one clearly bounded mechanical correction without weakening gates is allowed; budgets never override correctness. Specs-only never creates or updates docs and never fabricates execution proof; record doc impact as a brief recommendation only.
99
-
100
- ## Assurance depth
101
-
102
- | Level | Required semantic review |
103
- |---|---|
104
- | Routine | Same-session graph check and relevant counterexamples; no reviewer ceremony. |
105
- | Elevated | Same-session targeted adversarial review; no reviewer ceremony. |
106
- | Strict | Full red-team plus a host-hook-observed event from an allowlisted reviewer capability. |
107
-
108
- Risk presence sets the automatic minimum to Elevated. Strict is opt-in only
109
- for an explicit user/project independent-audit requirement or a user-confirmed,
110
- scope-specific audit decision. Never select it from a keyword, severity label,
111
- Full depth, or reviewer availability. If the required host event is unavailable,
112
- pause once and report the capability blocker; do not retry loops or downgrade.
113
-
114
- Strict red-team lenses are Security Adversary, Failure Mode Analyst, Assumption
115
- Destroyer, and Scope & Complexity Critic. Findings without a concrete physical
116
- location and counterexample are rejected as unsupported.
117
-
118
- ## Finding format
119
-
120
- ```markdown
121
- ## Finding N: <title>
122
- - **Severity:** Critical | High | Medium
123
- - **Location:** <file:line or exact section/anchor/requirement ID>
124
- - **Broken edge:** <source -> target in the consistency graph>
125
- - **Flaw:** <specific contradiction or omission>
126
- - **Counterexample:** <concrete input/state/event and incorrect possible result>
127
- - **Evidence:** <short quote or missing required mapping>
128
- - **Suggested fix:** <smallest semantic correction>
129
- - **Disposition:** Accept | Reject
130
- - **Rationale:** <why>
131
- ```
132
-
133
- Apply accepted findings to requirements, design, task acceptance/changes, named
134
- contracts/invariants, dependencies, or verification. A report-only fix is not a
135
- fix. Scope or product decisions require explicit user approval before editing.
136
-
137
- ## Deterministic and grounding gates
138
-
139
- Finalize requirements, design, optional research, task files, and canonical
140
- `spec.json` topology first. Every required authoring stage (`requirements`,
141
- `design`, and, when present, `research`/`tasks`) must already read `validated`
142
- via a fresh run of `spec-authoring-validation.cjs` — the sole atomic writer of
143
- that transition and its C16 `AuthoringValidationReceipt` — before the digest
144
- below is computed; a `validated` reading with no matching fresh receipt digest
145
- is treated as `draft` everywhere it is read. Compute the candidate digest
146
- read-only, then provide a review JSON object with exactly `verdict`,
147
- `findings`, `unresolved_decisions`, `graph_coverage`, `reviewed_criteria`,
148
- `counterexamples`, and `reviewer_evidence` — the frozen C2 fields the reviewer
149
- itself supplies. `lifecycle_disposition` and `repair_round` are never authored
150
- in this JSON: the finalizer derives both (repair_round is the C13 `attempt_index`
151
- for the current review_epoch; lifecycle_disposition is CONTINUE unless a
152
- non-PASS at the epoch's third attempt forces BLOCKED) and appends the completed
153
- receipt to the durable, append-only `semantic_review_history` lineage. The
154
- author must not fabricate or directly write authority state.
155
-
156
- The digest projects task registry semantics as `id`, `dependencies`, and optional
157
- `artifacts`. Execution-only status, blocker, timestamps, Markdown `Status`, and
158
- checkbox checked state do not stale review; requirement, design, research, task
159
- prose, dependency, artifact, or coordination changes do.
160
-
161
- ```bash
162
- # Claude Code
163
- node .claude/scripts/validate-spec-output.cjs specs/<feature> --semantic-digest
164
- # Codex (installed projection — verify, not raw .claude path)
165
- node .codex/scripts/validate-spec-output.cjs specs/<feature> --semantic-digest
166
- ```
167
-
168
- The machine-recorded state binds the returned digest, exact reviewed `RN.M`
169
- criteria, and one concrete counterexample per criterion. Each counterexample uses exactly `criterion`,
170
- `case_kind`, `scenario`, `expected`, `decision_refs`, and `verification_ref`.
171
- Decision refs resolve to real `D`/`I`/`C` definitions; the `V` definition traces
172
- both the criterion and decisions. This state binds what was reviewed; it never
173
- substitutes for semantic judgment or resolves ambiguity.
174
-
175
- Routine and Elevated have no reviewer ceremony. Strict requires a real event
176
- observed by the installed host hook from an allowlisted reviewer capability.
177
- The hook derives reviewer identity/capability and binds the digest; authoring
178
- prose cannot self-declare it.
179
- The final reviewer message contains
180
- exactly one line:
181
-
182
- ```text
183
- CAFEKIT_SEMANTIC_REVIEW_ATTESTATION {"feature_name":"<feature>","spec_file":"specs/<feature>/spec.json","semantic_digest":"sha256:<digest>","verdict":"PASS"}
184
- ```
185
-
186
- The `SubagentStop` hook recomputes the digest and stores a MAC-protected record
187
- outside the project, bound to canonical project/spec/feature identity. Codex
188
- must use its event-capable thread-spawn path for this Strict gate. Its legacy
189
- internal multi-agent path does not expose the child completion message through
190
- a supported hook event, so it stays not-ready; never derive authority from a
191
- parent summary or a spawn-only `PostToolUse` event.
192
- Do not add reviewer identity or independence claims to `semantic_review`.
193
- This is a host-hook-observed honest-agent guardrail. It is not host-attested
194
- evidence and not a security boundary against another process running as the
195
- same OS account.
196
-
197
- After the Strict observation (or immediately for Routine/Elevated), invoke the
198
- only supported atomic promotion path:
199
-
200
- ```bash
201
- # Claude Code
202
- node .claude/scripts/spec-readiness.cjs specs/<feature> --review-result <review.json>
203
- # Codex (installed projection — verify, not raw .claude path)
204
- node .codex/scripts/spec-readiness.cjs specs/<feature> --review-result <review.json>
205
- ```
206
-
207
- Run normal validation only after the installed finalizer records that state:
208
-
209
- ```bash
210
- # Claude Code
211
- node .claude/scripts/validate-spec-output.cjs specs/<feature>
212
- # Codex (installed projection)
213
- node .codex/scripts/validate-spec-output.cjs specs/<feature>
214
- ```
215
-
216
- Run the runtime-provided grounding command for every durable spec. It
217
- deterministically recomputes factual anchor/path/symbol/command reachability and
218
- creates no additional receipt. Record command, exit code, and failing categories.
219
- Non-zero blocks readiness. Exit 0 does not override a broken consistency edge or
220
- counterexample; semantic review remains mandatory at the selected assurance level.
221
-
222
- ## Final reconciliation
223
-
224
- Before readiness:
225
-
226
- 1. Re-read all physical artifacts after fixes.
227
- 2. Confirm accepted findings changed implementation-facing content.
228
- 3. Confirm requirements, globally unique anchor IDs, canonical design-anchor
229
- references, contracts, owners/consumers, dependencies, negative paths, and
230
- verification form a closed graph.
231
- 4. Confirm `feature-receipt.md`, phase files, copied contract bodies, legacy
232
- topology markers, and unused template sections are absent.
233
- 5. Write coherent final timestamps/status and rerun deterministic gates;
234
- readiness means technical artifact readiness, not permission to implement.
235
-
236
- If any check fails, report `FAIL` or `BLOCKED`, preserve unfinished lifecycle
237
- state, and do not suggest implementation handoff.
238
-
239
- ## Platform acceptance
240
-
241
- Acceptance covers Claude Code and Codex artifacts only. Verify the semantic
242
- rules/templates installed for both runtimes remain equivalent. Do not add a
243
- third runtime to this acceptance scope.
1
+ # Plan review — evidence, adversarial lenses, and C2
2
+
3
+ Review exists to find costly errors before code. It is not a prose-quality
4
+ score. Every accepted finding must be reproducible from current repository
5
+ evidence.
6
+
7
+ ## B1 — evidence rule
8
+
9
+ - Cite at least one real `path:line` for every repository claim. A finding
10
+ without a citation is excluded rather than debated.
11
+ - Run the search or read command; a plausible-looking citation is not proof.
12
+ - When a plan changes a symbol, interface, route, config key, or file contract,
13
+ count and list its callers, tests, exports, help text, and generated copies.
14
+ - Replace "update all callers" with the observed count and names. Above ten,
15
+ list the first ten plus the total.
16
+ - Label an unresolved external or runtime claim `[UNVERIFIED]` and name the
17
+ command, document, or environment that would settle it.
18
+
19
+ ## Reviewer roles
20
+
21
+ | Role | Question | Required evidence |
22
+ |---|---|---|
23
+ | Fact Checker | Do named paths, symbols, commands, and keys exist? | search/read output with `path:line` |
24
+ | Flow Tracer | Does the claimed call order and error path exist? | entrypoint-to-effect trace, including early returns |
25
+ | Scope Auditor | Is new state scoped to the right lifetime and owner? | constructors, writers, cleanup, and existing equivalents |
26
+ | Contract Verifier | Are all consumers and compatibility surfaces covered? | caller/test/export/config/help inventory |
27
+
28
+ Scale the review to the number of independent work groups:
29
+
30
+ | Groups | Reviewers | Roles | Claim budget |
31
+ |---|---:|---|---:|
32
+ | 1-2 | 2 | Fact Checker plus the highest-risk role | about 5 per group |
33
+ | 3-5 | 3 | Fact Checker, Contract Verifier, one risk role | about 10 per group |
34
+ | 6+ | 4 | all roles | at least 15 total |
35
+
36
+ The table is a sizing guide, not permission to skip a material boundary.
37
+
38
+ ## B2 — fresh-context red team
39
+
40
+ Use reviewers that did not author the plan and give each one a distinct lens:
41
+
42
+ - **Security adversary:** authorization bypass, injection, secret exposure,
43
+ unsafe path and trust-boundary transitions.
44
+ - **Failure-mode analyst:** race, partial write, crash recovery, retry,
45
+ cancellation, and stale state.
46
+ - **Assumption destroyer:** implicit dependencies, unavailable services,
47
+ untested error paths, and claims that something "should" work.
48
+ - **Scope and complexity critic:** premature abstraction, duplicated state,
49
+ optional work, and tasks too large for one owner.
50
+
51
+ Prompt them to break the plan. For every finding require: severity, exact plan
52
+ location, concrete counterexample, repository evidence, and the smallest repair.
53
+ Ignore style-only feedback.
54
+
55
+ ## Four red-team lenses
56
+
57
+ Apply these to the relevant boundary:
58
+
59
+ 1. **Input and identity:** empty, duplicate, malformed, adversarial, stale, and
60
+ cross-tenant inputs.
61
+ 2. **State transition:** retry, partial completion, reordering, concurrency,
62
+ rollback, and recovery.
63
+ 3. **Integration:** callers, exports, registration, transport, persistence,
64
+ packaging, and runtime reachability.
65
+ 4. **Proof:** negative path, exact command, nonzero exit, zero-test result,
66
+ missing artifact, stale provenance, and environment limitation.
67
+
68
+ Each finding must describe an observable failure, not a preference.
69
+
70
+ ## Aggregate before C2
71
+
72
+ Normalize duplicate findings by root cause. Preserve the strongest evidence and
73
+ smallest counterexample. Sort Critical, High, then Medium. Cap the presented
74
+ list at 15; a larger useful set means the plan should be split.
75
+
76
+ Present C2 as a table:
77
+
78
+ | ID | Severity | Plan location | Failure scenario | Evidence | Proposed repair | Decision |
79
+ |---|---|---|---|---|---|---|
80
+
81
+ The user chooses accept, reject, or revise. Do not apply findings before that
82
+ decision. Record the result in the plan review log.
83
+
84
+ ## B3 — consistency sweep
85
+
86
+ After any accepted finding or user edit:
87
+
88
+ 1. Reread every file in `specs/<feature>/`.
89
+ 2. List deltas: renamed terms, changed decisions, removed assumptions, task
90
+ order, ownership, dependencies, acceptance IDs, and commands.
91
+ 3. Search every delta and its old spelling across the whole feature packet.
92
+ 4. Reconcile the plan table, task details, examples, acceptance mapping, and
93
+ verification commands.
94
+ 5. Record: `files reread / deltas / stale references fixed / conflicts left`.
95
+
96
+ Any unresolved contradiction keeps the plan unready.
97
+
98
+ ## B4 — stop condition
99
+
100
+ - Allow at most two review-and-repair rounds before implementation.
101
+ - Round three requires runtime evidence: an executed test, command output, or
102
+ observed host behavior. More paper argument is not a new finding.
103
+ - A repair round should not grow the plan unless evidence proves missing scope.
104
+ - Two add-only rounds trigger a split, deferral, or return to C1.
105
+ - Stop early when remaining findings are duplicates, preferences, or already
106
+ covered by one acceptance criterion and one verification command.
107
+
108
+ Review saturation means new reviewers no longer find a distinct material
109
+ failure with new evidence. It does not mean the plan is guaranteed correct.
@@ -0,0 +1,173 @@
1
+ # Process-first plan, task, and receipt templates
2
+
3
+ Use these as compact starting points. Remove unused examples and placeholders
4
+ before C2. The primary layout is always flat:
5
+
6
+ ```text
7
+ specs/<feature>/
8
+ ├── plan.md
9
+ ├── task-01-<slug>.md
10
+ └── task-NN-<slug>.md
11
+ ```
12
+
13
+ ## `plan.md` template
14
+
15
+ Keep the plan short enough to scan as one index, normally under 100 lines.
16
+
17
+ ```markdown
18
+ # <Feature name>
19
+
20
+ ## Scope decision (C1 — YYYY-MM-DD)
21
+ - Existing: <reusable code with path:line>
22
+ - Minimum change: <required behavior>
23
+ - Expansion signals: <none or evidence>
24
+ - User decision: EXPAND | KEEP | CUT — <reason>
25
+
26
+ ## Out of scope
27
+ - <deliberate exclusion>
28
+
29
+ ## Acceptance criteria
30
+ | ID | EARS criterion | Proof |
31
+ |---|---|---|
32
+ | AC-01 | When <trigger>, the system shall <response>. | `<command>` |
33
+
34
+ ## Tasks
35
+ | # | Task | Criteria | Primary ownership | Dependencies | Status |
36
+ |---|---|---|---|---|---|
37
+ | 01 | <one outcome> | AC-01 | `src/example.ts` | - | pending |
38
+
39
+ ## Review log
40
+ - Round 1: <findings accepted/rejected/revised>; sweep <result>.
41
+ ```
42
+
43
+ Each acceptance ID must map to at least one task and one proof. A task with no
44
+ criterion is scope drift; a criterion with no task or proof is not executable.
45
+
46
+ ## `task-NN-*.md` template
47
+
48
+ Keep one exact `Status:` field. The task file is one owner's packet.
49
+
50
+ ````markdown
51
+ # Task NN — <one observable outcome>
52
+
53
+ Status: pending
54
+
55
+ ## Outcome
56
+ <What becomes true when this task succeeds.>
57
+
58
+ ## Scope
59
+ - In: <exact behavior>
60
+ - Out: <nearby behavior deliberately excluded>
61
+
62
+ ## Ownership
63
+ - Modify: `src/a.ts`
64
+ - Create: `test/a.test.ts`
65
+ - Read: `src/caller.ts`
66
+
67
+ ## Acceptance
68
+ - AC-01: <task-local measurable condition>
69
+
70
+ ## Dependencies
71
+ - <task number or `none`>
72
+
73
+ ## Verification Plan
74
+ - Command: `<exact runnable command>`
75
+ - Expected: <observable success, including nonzero/negative behavior if relevant>
76
+ - Reachability: <entrypoint or consumer>
77
+ - Artifacts: <path and digest requirement, or none>
78
+
79
+ ## Receipt
80
+ <!-- Fill only after execution; see canonical form below. -->
81
+ ````
82
+
83
+ ## Canonical inline Receipt
84
+
85
+ The completed task keeps this section at the end of the same file. Derive Base
86
+ and Head from the current runtime; do not invent or reuse them.
87
+
88
+ ````markdown
89
+ ## Receipt
90
+
91
+ Verification: PASS
92
+ Command: pnpm test -- --filter example
93
+ Exit: 0
94
+ Base: <runtime-derived base commit>
95
+ Head: <runtime-derived tree digest or commit>
96
+ ```text
97
+ $ pnpm test -- --filter example
98
+ PASS example.test.ts
99
+ Tests: 3 passed, 3 total
100
+ ```
101
+ ````
102
+
103
+ The receipt is invalid when it has a placeholder, missing output fence, zero
104
+ executed tests where tests are required, a failure marker, nonzero exit, stale
105
+ Base/Head, or a bare PASS claim without the command output.
106
+
107
+ ## EARS sentence patterns
108
+
109
+ Use the narrowest pattern that describes observable behavior:
110
+
111
+ 1. **Ubiquitous:** `The <system> shall <response>.`
112
+ 2. **Event-driven:** `When <trigger>, the <system> shall <response>.`
113
+ 3. **State-driven:** `While <state>, the <system> shall <response>.`
114
+ 4. **Unwanted behavior:** `If <fault>, the <system> shall <response>.`
115
+ 5. **Optional feature:** `Where <feature is enabled>, the <system> shall <response>.`
116
+
117
+ Avoid implementation detail unless it is a user-approved contract. Replace
118
+ "fast", "robust", and "works" with a measurable threshold or observation.
119
+
120
+ ## Example Mapping rule
121
+
122
+ When the expected outcome is uncertain, write a question and take it to C1 or
123
+ C2; do not guess. When a rule is ambiguous, add two or three examples:
124
+
125
+ ```text
126
+ Rule: A done task has fresh executable proof.
127
+ Example: command exits 0 and reports 3 tests passed -> done may be proposed.
128
+ Example: command exits 0 but reports 0 tests -> remains unfinished.
129
+ Example: output is copied from an earlier session -> remains unfinished.
130
+ Question: which environment owns the authoritative integration run?
131
+ ```
132
+
133
+ Keep examples only until they clarify a rule or acceptance criterion.
134
+
135
+ ## Twelve edge-case dimensions
136
+
137
+ For each material boundary, select relevant dimensions rather than filling a
138
+ ceremonial matrix:
139
+
140
+ | Dimension | Probe |
141
+ |---|---|
142
+ | Input shape | empty, malformed, duplicate, maximum size |
143
+ | Identity | missing, wrong actor, cross-scope, replay |
144
+ | State | initial, partial, terminal, stale |
145
+ | Order | early, late, repeated, out of order |
146
+ | Concurrency | double writer, race, cancellation |
147
+ | Dependency | missing, blocked, version drift |
148
+ | Failure | timeout, exception, nonzero exit |
149
+ | Recovery | retry, resume, rollback, cleanup |
150
+ | Persistence | partial write, corruption, migration |
151
+ | Integration | caller, registration, packaging, reachability |
152
+ | Security/privacy | injection, traversal, secret exposure |
153
+ | Observability/proof | logs, artifact, negative path, provenance |
154
+
155
+ Turn a discovered risk into an EARS criterion, a task acceptance item, or a
156
+ verification probe. Do not duplicate it across all three.
157
+
158
+ ## Quality and saturation checks
159
+
160
+ Before C2 confirm:
161
+
162
+ - every repository fact has current evidence or `[UNVERIFIED]`;
163
+ - every acceptance criterion maps to task and proof;
164
+ - task ownership does not overlap within a proposed parallel wave;
165
+ - dependencies are acyclic and refer to real task numbers;
166
+ - commands are runnable from the named work context;
167
+ - negative, recovery, and reachability probes exist where risk requires them;
168
+ - examples settle ambiguous rules rather than adding prose;
169
+ - the latest consistency sweep reports zero unresolved contradictions.
170
+
171
+ Stop expanding when a fresh reviewer finds no new material failure with new
172
+ evidence, the 12 dimensions yield no uncovered relevant boundary, and every
173
+ accepted C2 finding is represented exactly once.