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

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 (87) 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 +382 -0
  4. package/bin/__tests__/codex-native.test.js +579 -80
  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 +494 -26
  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 +82 -155
  26. package/src/claude/gitignore +1 -1
  27. package/src/claude/hooks/__tests__/spec-gate.test.js +238 -0
  28. package/src/claude/hooks/__tests__/state.test.js +249 -3
  29. package/src/claude/hooks/lib/context.cjs +1 -1
  30. package/src/claude/hooks/lib/detect.cjs +1 -1
  31. package/src/claude/hooks/spec-gate.cjs +44 -9
  32. package/src/claude/hooks/spec-state.cjs +51 -13
  33. package/src/claude/hooks/task-scaffold-guard.cjs +1 -1
  34. package/src/claude/migration-manifest.json +17 -3
  35. package/src/claude/rules/manage-docs.md +43 -24
  36. package/src/claude/rules/state-sync.md +57 -62
  37. package/src/claude/rules/workflow.md +30 -13
  38. package/src/claude/scripts/change-firewall.cjs +2 -2
  39. package/src/claude/scripts/generate-skill-catalog.cjs +0 -1
  40. package/src/claude/scripts/spec-receipt.cjs +196 -1
  41. package/src/claude/scripts/spec-resolver.cjs +428 -0
  42. package/src/claude/skills/develop/SKILL.md +89 -125
  43. package/src/claude/skills/develop/references/parallel-waves.md +75 -162
  44. package/src/claude/skills/develop/references/quality-gate.md +61 -121
  45. package/src/claude/skills/develop/references/subagent-patterns.md +31 -38
  46. package/src/claude/skills/question/SKILL.md +1 -1
  47. package/src/claude/skills/specs/SKILL.md +152 -204
  48. package/src/claude/skills/specs/references/review.md +124 -243
  49. package/src/claude/skills/specs/references/templates.md +202 -0
  50. package/src/claude/skills/sync/SKILL.md +66 -90
  51. package/src/claude/skills/sync/references/sync-protocols.md +62 -83
  52. package/src/codex/AGENTS.md +20 -7
  53. package/src/codex/hooks/lib/spec-receipt.cjs +18 -0
  54. package/src/codex/hooks/lib/spec-utils.cjs +25 -0
  55. package/src/codex/hooks/spec-gate.cjs +46 -16
  56. package/src/codex/hooks/spec-state.cjs +54 -16
  57. package/src/codex/rules/state-sync.md +57 -61
  58. package/src/common/AGENTS.md +8 -1
  59. package/bin/__tests__/opencode-spec-gate.test.js +0 -799
  60. package/bin/lib/opencode-install.js +0 -899
  61. package/bin/phases/opencode-runtime.js +0 -38
  62. package/src/claude/skills/specs/references/archive-workflow.md +0 -74
  63. package/src/claude/skills/specs/references/ask-user-question-gates.md +0 -70
  64. package/src/claude/skills/specs/references/codebase-analysis.md +0 -102
  65. package/src/claude/skills/specs/references/cross-spec-dependency.md +0 -76
  66. package/src/claude/skills/specs/references/research-strategy.md +0 -107
  67. package/src/claude/skills/specs/references/scope-inquiry.md +0 -107
  68. package/src/claude/skills/specs/references/translation-mirror.md +0 -83
  69. package/src/claude/skills/specs/rules/design-discovery-full.md +0 -45
  70. package/src/claude/skills/specs/rules/design-discovery-light.md +0 -28
  71. package/src/claude/skills/specs/rules/design-principles.md +0 -138
  72. package/src/claude/skills/specs/rules/design-review.md +0 -55
  73. package/src/claude/skills/specs/rules/ears-format.md +0 -42
  74. package/src/claude/skills/specs/rules/phase-decision-matrix.md +0 -56
  75. package/src/claude/skills/specs/rules/task-scoring-rubric.md +0 -52
  76. package/src/claude/skills/specs/rules/tasks-generation.md +0 -189
  77. package/src/opencode/AGENTS.md +0 -41
  78. package/src/opencode/plugins/docs-sync.ts +0 -175
  79. package/src/opencode/plugins/inspect-block.ts +0 -164
  80. package/src/opencode/plugins/privacy-block.ts +0 -182
  81. package/src/opencode/plugins/rules.ts +0 -155
  82. package/src/opencode/plugins/session.ts +0 -179
  83. package/src/opencode/plugins/spec-gate.ts +0 -457
  84. package/src/opencode/plugins/spec-state.ts +0 -311
  85. package/src/opencode/plugins/state.ts +0 -253
  86. package/src/opencode/plugins/task-scaffold-guard.ts +0 -161
  87. package/src/opencode/plugins/usage.ts +0 -178
@@ -1,243 +1,124 @@
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
+ - Any privacy/security claim names the exact identifier surface at risk, such as an env var, header, path, token class, or field name; generic “sensitive data” is insufficient.
19
+
20
+ ## Reviewer roles
21
+
22
+ | Role | Question | Required evidence |
23
+ |---|---|---|
24
+ | Fact Checker | Do named paths, symbols, commands, and keys exist? | search/read output with `path:line` |
25
+ | Flow Tracer | Does the claimed call order and error path exist? | entrypoint-to-effect trace, including early returns |
26
+ | Scope Auditor | Is new state scoped to the right lifetime and owner? | constructors, writers, cleanup, and existing equivalents |
27
+ | Contract Verifier | Are all consumers and compatibility surfaces covered? | caller/test/export/config/help inventory |
28
+
29
+ Scale the review to the number of independent work groups:
30
+
31
+ | Groups | Reviewers | Roles | Claim budget |
32
+ |---|---:|---|---:|
33
+ | 1-2 | 2 | Fact Checker plus the highest-risk role | about 5 per group |
34
+ | 3-5 | 3 | Fact Checker, Contract Verifier, one risk role | about 10 per group |
35
+ | 6+ | 4 | all roles | at least 15 total |
36
+
37
+ The table is a sizing guide, not permission to skip a material boundary.
38
+
39
+ ## B2 — fresh-context red team
40
+
41
+ Use reviewers that did not author the plan and give each one a distinct lens:
42
+
43
+ - **Security adversary:** authorization bypass, injection, secret exposure,
44
+ unsafe path and trust-boundary transitions.
45
+ - **Failure-mode analyst:** race, partial write, crash recovery, retry,
46
+ cancellation, and stale state.
47
+ - **Assumption destroyer:** implicit dependencies, unavailable services,
48
+ untested error paths, and claims that something "should" work.
49
+ - **Scope and complexity critic:** premature abstraction, duplicated state,
50
+ optional work, and tasks too large for one owner.
51
+
52
+ Prompt them to break the plan. For every finding require: severity, exact plan
53
+ location, concrete counterexample, repository evidence, and the smallest repair.
54
+ Ignore style-only feedback.
55
+ Run mutation or destructive negative controls only on disposable copies below a verified temporary root, never tracked worktree or canonical source bytes.
56
+
57
+ ## Four red-team lenses
58
+
59
+ Apply these to the relevant boundary:
60
+
61
+ 1. **Input and identity:** empty, duplicate, malformed, adversarial, stale, and
62
+ cross-tenant inputs.
63
+ 2. **State transition:** retry, partial completion, reordering, concurrency,
64
+ rollback, and recovery.
65
+ 3. **Integration:** callers, exports, registration, transport, persistence,
66
+ packaging, and runtime reachability.
67
+ 4. **Proof:** negative path, exact command, nonzero exit, zero-test result,
68
+ missing artifact, stale provenance, and environment limitation.
69
+
70
+ Each finding must describe an observable failure, not a preference.
71
+
72
+ ## Aggregate before C2
73
+
74
+ Normalize duplicate findings by root cause. Preserve the strongest evidence and
75
+ smallest counterexample. Sort Critical, High, then Medium. Cap the presented
76
+ list at 15; a larger useful set means the plan should be split.
77
+
78
+ Present C2 as a table:
79
+
80
+ | ID | Severity | Plan location | Failure scenario | Evidence | Proposed repair | Decision |
81
+ |---|---|---|---|---|---|---|
82
+
83
+ The user chooses accept, reject, or revise. Do not apply findings before that
84
+ decision. Record the result in the plan review log.
85
+
86
+ ## Accepted-repair closure
87
+
88
+ After applying an accepted C2 finding, a fresh-context closure pass records and
89
+ freshly replays its original counterexample after the repair under this exact review-log header:
90
+
91
+ | ID | Decision | Original counterexample | Repaired at | Proved at | Replay | Closure |
92
+ |---|---|---|---|---|---|---|
93
+
94
+ `Repaired at` cites the repair edit; `Proved at` must cite distinct evidence from the fresh replay, never the repair-edit citation.
95
+ An accepted finding transitions `accepted → repaired → PASS|FAIL|UNKNOWN`.
96
+ Only `PASS` closes it; `FAIL` remains open for the remaining paper-review round; `UNKNOWN` blocks implementation handoff.
97
+ A repair that adds user semantics or scope returns to C1.
98
+
99
+ ## B3 — consistency sweep
100
+
101
+ After any accepted finding or user edit:
102
+
103
+ 1. Reread every file in `specs/<feature>/`.
104
+ 2. List deltas: renamed terms, changed decisions, removed assumptions, task
105
+ order, ownership, dependencies, acceptance IDs, and commands.
106
+ 3. Search every delta and its old spelling across the whole feature packet.
107
+ 4. Reconcile the plan table, task details, examples, acceptance mapping, and
108
+ verification commands.
109
+ 5. Record: `files reread / deltas / stale references fixed / conflicts left`.
110
+
111
+ Any unresolved contradiction keeps the plan unready.
112
+
113
+ ## B4 — stop condition
114
+
115
+ - Allow at most two review-and-repair rounds before implementation.
116
+ - Round three requires runtime evidence: an executed test, command output, or
117
+ observed host behavior. More paper argument is not a new finding.
118
+ - A repair round should not grow the plan unless evidence proves missing scope.
119
+ - Two add-only rounds trigger a split, deferral, or return to C1.
120
+ - Stop early when remaining findings are duplicates, preferences, or already
121
+ covered by one acceptance criterion and one verification command.
122
+
123
+ Review saturation means new reviewers no longer find a distinct material
124
+ failure with new evidence. It does not mean the plan is guaranteed correct.
@@ -0,0 +1,202 @@
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
+ Specs-Contract: process-first-ready-v1
20
+
21
+ ## Scope decision (C1 — YYYY-MM-DD)
22
+ - Existing: <reusable code with path:line>
23
+ - Minimum change: <required behavior>
24
+ - Expansion signals: <none or evidence>
25
+ - User decision: EXPAND | KEEP | CUT — <reason>
26
+
27
+ ## Out of scope
28
+ - <deliberate exclusion>
29
+
30
+ ## Acceptance criteria
31
+ | ID | EARS criterion | Proof |
32
+ |---|---|---|
33
+ | AC-01 | When <trigger>, the system shall <response>. | `<command>` |
34
+
35
+ ## Tasks
36
+ | # | Task | Criteria | Primary ownership | Dependencies | Status |
37
+ |---|---|---|---|---|---|
38
+ | 01 | <one outcome> | AC-01 | `src/example.ts` | - | blocked |
39
+
40
+ ## Review log
41
+ - Round 1: <findings accepted/rejected/revised>; sweep <result>.
42
+ ```
43
+
44
+ Each acceptance ID must map to at least one task and one proof. A task with no
45
+ criterion is scope drift; a criterion with no task or proof is not executable.
46
+
47
+ ## `task-NN-*.md` template
48
+
49
+ Keep one exact `Status:` field. The task file is one owner's packet.
50
+
51
+ ````markdown
52
+ # Task NN — <one observable outcome>
53
+
54
+ Status: blocked
55
+
56
+ ## Outcome
57
+ <What becomes true when this task succeeds.>
58
+
59
+ ## Scope
60
+ - In: <exact behavior>
61
+ - Out: <nearby behavior deliberately excluded>
62
+
63
+ ## Ownership
64
+ - Modify: `src/a.ts`
65
+ - Create: `test/a.test.ts`
66
+ - Read: `src/caller.ts`
67
+
68
+ ## Acceptance
69
+ - AC-01: <task-local measurable condition>
70
+
71
+ ## Dependencies
72
+ - <exact `task-NN-*.md` basename or `none`; one bullet per dependency>
73
+
74
+ ## Verification Plan
75
+ - Command: `<exact runnable command>`
76
+ - Named probe: <existing concrete probe/test/hook ID; never only a suite label>
77
+ - Reachability: <real entrypoint/caller at each `source`/`installed`/`live` level; `UNKNOWN` if unexecuted>
78
+ - Oracle: <externally observable success or failure>
79
+ - Counterexample: <material alternative behavior that must make this proof fail>
80
+ - Artifacts: <required artifact path plus digest algorithm/comparison rule, or explicitly ephemeral with cleanup rule>
81
+
82
+ ## Receipt
83
+ <!-- Fill only after execution; see canonical form below. -->
84
+ ````
85
+
86
+ Trace `Command → Named probe → Reachability → Oracle`. Aggregate suites
87
+ name the owning concrete probe. Proof at `source`/`installed`/`live` stays
88
+ separate; one level never promotes another. Run mutation or destructive
89
+ negative controls only on disposable copies under a verified temporary root,
90
+ never tracked worktree or canonical source bytes.
91
+
92
+ ## Status matrix
93
+
94
+ | Status condition | Persisted state |
95
+ |---|---|
96
+ | C1/C2 decision open | `blocked` |
97
+ | accepted finding open or `UNKNOWN` | `blocked` |
98
+ | every non-dependency blocker closed | `pending` |
99
+ | named task dependency not done | keep `pending`; queue gates it |
100
+ Use only direct-child task basenames or `none` under `## Dependencies`; keep `## Receipt` empty until execution produces canonical proof.
101
+
102
+ ## Canonical inline Receipt
103
+
104
+ The completed task keeps this section at the end of the same file. Derive Base
105
+ and Head from the current runtime; do not invent or reuse them.
106
+
107
+ ````markdown
108
+ ## Receipt
109
+
110
+ Verification: PASS
111
+ Command: pnpm test -- --filter example
112
+ Exit: 0
113
+ Base: <runtime-derived base commit>
114
+ Head: <runtime-derived tree digest or commit>
115
+ ```text
116
+ $ pnpm test -- --filter example
117
+ PASS example.test.ts
118
+ Tests: 3 passed, 3 total
119
+ ```
120
+ ````
121
+
122
+ The receipt is invalid when it has a placeholder, missing output fence, zero
123
+ executed tests where tests are required, a failure marker, nonzero exit, stale
124
+ Base/Head, or a bare PASS claim without the command output.
125
+
126
+ ## EARS sentence patterns
127
+
128
+ Use the narrowest pattern that describes observable behavior:
129
+
130
+ 1. **Ubiquitous:** `The <system> shall <response>.`
131
+ 2. **Event-driven:** `When <trigger>, the <system> shall <response>.`
132
+ 3. **State-driven:** `While <state>, the <system> shall <response>.`
133
+ 4. **Unwanted behavior:** `If <fault>, the <system> shall <response>.`
134
+ 5. **Optional feature:** `Where <feature is enabled>, the <system> shall <response>.`
135
+
136
+ Avoid implementation detail unless it is a user-approved contract. Replace
137
+ "fast", "robust", and "works" with a measurable threshold or observation.
138
+
139
+ ## Example Mapping rule
140
+
141
+ When the expected outcome is uncertain, write a question and take it to C1 or
142
+ C2; do not guess. When a rule is ambiguous, add two or three examples:
143
+
144
+ ```text
145
+ Rule: A done task has fresh executable proof.
146
+ Example: command exits 0 and reports 3 tests passed -> done may be proposed.
147
+ Example: command exits 0 but reports 0 tests -> remains unfinished.
148
+ Example: output is copied from an earlier session -> remains unfinished.
149
+ Question: which environment owns the authoritative integration run?
150
+ ```
151
+
152
+ Keep examples only until they clarify a rule or acceptance criterion.
153
+
154
+ ## No-invention and conditional boundary contracts
155
+
156
+ Before implementation handoff, apply the **no-invention gate**: if two implementations conform to the packet text yet can produce different externally observable output, state, error, security, or compatibility behavior, surface the missing choice as an explicit C1 or C2 question and block handoff.
157
+
158
+ A boundary is material when the task creates, changes, or depends on it and a different choice changes an external observation, security, durable data, compatibility, or proof reachability. Require only the matching material row; omit nonmaterial categories.
159
+ For every required row, name each listed choice exactly; labels such as “JSON”, “local path”, “locked”, or “timestamped” alone remain unresolved.
160
+
161
+ | Boundary | Required contract when material |
162
+ |---|---|
163
+ | API/CLI | entrypoint/route or command grammar; identity/auth; input/default/normalization; success output; error/status/exit; duplicate/retry/idempotency; compatibility |
164
+ | Schema | version; exact keys/nesting/types; required/optional; enum/format/bounds/cardinality; unknown-field behavior; compatibility/migration |
165
+ | State/concurrency | initial/terminal states; event + guard + effect + next + error; ordering; duplicate/retry; writer/lock acquire/contention/release; rollback/recovery |
166
+ | Filesystem/security | authoritative root; trusted/untrusted segment grammar; lexical + canonical containment and symlink policy; flags/mode; temp/rename/fsync; lock/stale reclaim; crash cleanup |
167
+ | Time/retention | clock source; unit/precision/timezone; endpoints and inclusion/comparator; anomaly behavior; expiry/purge/recovery |
168
+ | Integration/proof | caller; export/registration; packaging/config; native path/consumer; proof level (`source`/`installed`/`live`); observable failure oracle |
169
+
170
+ ## Twelve edge-case dimensions
171
+
172
+ For each material boundary, select relevant dimensions rather than filling a
173
+ ceremonial matrix:
174
+
175
+ - Input shape, identity, state, order: malformed/duplicate/bounds, wrong actor,
176
+ partial/stale state, replay/reordering.
177
+ - Concurrency, dependency, failure, recovery: races/cancellation, version drift,
178
+ timeout/nonzero exit, retry/rollback/cleanup.
179
+ - Persistence, integration, security/privacy, observability/proof: partial
180
+ writes, registration/reachability, traversal/secrets, artifacts/provenance.
181
+
182
+ `Crash` means abrupt unhandled termination before the claimed catch point; a catchable failure returns/raises an error or exits nonzero. Never use them interchangeably.
183
+
184
+ Turn a discovered risk into an EARS criterion, a task acceptance item, or a
185
+ verification probe. Do not duplicate it across all three.
186
+
187
+ ## Quality and saturation checks
188
+
189
+ Before C2 confirm:
190
+
191
+ - every repository fact has current evidence or `[UNVERIFIED]`;
192
+ - every acceptance criterion maps to task and proof;
193
+ - task ownership does not overlap within a proposed parallel wave;
194
+ - dependencies are acyclic and refer to real task numbers;
195
+ - commands are runnable from the named work context;
196
+ - negative, recovery, and reachability probes exist where risk requires them;
197
+ - examples settle ambiguous rules rather than adding prose;
198
+ - the latest consistency sweep reports zero unresolved contradictions.
199
+
200
+ Stop expanding when a fresh reviewer finds no new material failure with new
201
+ evidence, the 12 dimensions yield no uncovered relevant boundary, and every
202
+ accepted C2 finding is represented exactly once.