@haposoft/cafekit 0.16.0-rc.2 → 0.16.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/__tests__/codex-hooks.test.js +794 -21
- package/bin/__tests__/codex-native.test.js +228 -7
- package/bin/__tests__/develop-contract.test.js +1838 -112
- package/bin/__tests__/installer-safety.test.js +82 -29
- package/bin/__tests__/opencode-spec-gate.test.js +799 -0
- package/bin/__tests__/package-inventory.test.js +841 -10
- package/bin/__tests__/specs-v2-execution-closeout.test.js +421 -0
- package/bin/__tests__/specs-v2-policy-and-scaffold.test.js +601 -0
- package/bin/__tests__/specs-v2-validator-grounder-contract.test.js +952 -0
- package/bin/__tests__/test-runtime-dependency-closure.cjs +182 -0
- package/bin/__tests__/validator-grounding.test.js +2469 -71
- package/bin/lib/managed-writer.js +12 -3
- package/bin/phases/codex-runtime.js +17 -1
- package/package.json +1 -1
- package/src/claude/CLAUDE.md +6 -0
- package/src/claude/agents/code-auditor.md +20 -0
- package/src/claude/agents/spec-maker.md +153 -202
- package/src/claude/hooks/__tests__/completion-authority.test.js +953 -0
- package/src/claude/hooks/__tests__/privacy-block.test.js +172 -0
- package/src/claude/hooks/__tests__/semantic-review-authority.test.js +257 -0
- package/src/claude/hooks/__tests__/spec-gate.test.js +604 -56
- package/src/claude/hooks/completion-authority-check.cjs +56 -0
- package/src/claude/hooks/completion-authority-state.cjs +527 -0
- package/src/claude/hooks/completion-authority.cjs +154 -0
- package/src/claude/hooks/docs-sync.cjs +5 -2
- package/src/claude/hooks/lib/privacy-command-analysis.cjs +393 -0
- package/src/claude/hooks/lib/runtime-path-safety.cjs +119 -0
- package/src/claude/hooks/privacy-block.cjs +77 -30
- package/src/claude/hooks/semantic-review-authority.cjs +152 -0
- package/src/claude/hooks/session.cjs +33 -19
- package/src/claude/hooks/spec-gate.cjs +181 -139
- package/src/claude/hooks/spec-state.cjs +112 -47
- package/src/claude/migration-manifest.json +15 -2
- package/src/claude/rules/state-sync.md +52 -21
- package/src/claude/rules/workflow.md +17 -9
- package/src/claude/scripts/provenance.cjs +315 -0
- package/src/claude/scripts/spec-final-state.cjs +244 -0
- package/src/claude/scripts/spec-ground.cjs +535 -173
- package/src/claude/scripts/spec-readiness.cjs +118 -0
- package/src/claude/scripts/spec-receipt.cjs +162 -0
- package/src/claude/scripts/spec-resolver.cjs +501 -0
- package/src/claude/scripts/spec-scaffold.cjs +1945 -55
- package/src/claude/scripts/spec-semantic-model.cjs +396 -0
- package/src/claude/scripts/validate-spec-output.cjs +3204 -262
- package/src/claude/scripts/workflow-policy.cjs +1888 -203
- package/src/claude/settings/settings.json +12 -0
- package/src/claude/skills/code-review/SKILL.md +94 -66
- package/src/claude/skills/code-review/references/spec-compliance-review.md +10 -2
- package/src/claude/skills/code-review/references/verification-gate.md +13 -0
- package/src/claude/skills/develop/SKILL.md +138 -283
- package/src/claude/skills/develop/references/parallel-waves.md +9 -6
- package/src/claude/skills/develop/references/quality-gate.md +123 -148
- package/src/claude/skills/develop/references/subagent-patterns.md +42 -37
- package/src/claude/skills/specs/SKILL.md +192 -397
- package/src/claude/skills/specs/references/ask-user-question-gates.md +27 -18
- package/src/claude/skills/specs/references/cross-spec-dependency.md +8 -4
- package/src/claude/skills/specs/references/research-strategy.md +4 -1
- package/src/claude/skills/specs/references/review.md +200 -260
- package/src/claude/skills/specs/references/scope-inquiry.md +18 -5
- package/src/claude/skills/specs/rules/design-discovery-full.md +33 -81
- package/src/claude/skills/specs/rules/design-discovery-light.md +21 -42
- package/src/claude/skills/specs/rules/design-principles.md +136 -180
- package/src/claude/skills/specs/rules/design-review.md +42 -97
- package/src/claude/skills/specs/rules/ears-format.md +42 -50
- package/src/claude/skills/specs/rules/phase-decision-matrix.md +42 -41
- package/src/claude/skills/specs/rules/task-scoring-rubric.md +46 -46
- package/src/claude/skills/specs/rules/tasks-generation.md +189 -271
- package/src/claude/skills/specs/templates/design.md +49 -263
- package/src/claude/skills/specs/templates/requirements.md +26 -36
- package/src/claude/skills/specs/templates/research.md +9 -98
- package/src/claude/skills/specs/templates/spec-state.json +26 -67
- package/src/claude/skills/specs/templates/task.md +30 -82
- package/src/claude/skills/sync/SKILL.md +45 -15
- package/src/claude/skills/sync/references/sync-protocols.md +34 -16
- package/src/claude/skills/test/SKILL.md +151 -167
- package/src/codex/AGENTS.md +6 -0
- package/src/codex/hooks/completion-authority-check.cjs +63 -0
- package/src/codex/hooks/completion-authority-state.cjs +527 -0
- package/src/codex/hooks/completion-authority.cjs +106 -0
- package/src/codex/hooks/lib/hook-context.cjs +58 -4
- package/src/codex/hooks/lib/privacy-command-analysis.cjs +3 -0
- package/src/codex/hooks/lib/privacy-state.cjs +38 -16
- package/src/codex/hooks/lib/runtime-path-safety.cjs +3 -0
- package/src/codex/hooks/lib/spec-receipt.cjs +86 -115
- package/src/codex/hooks/lib/spec-utils.cjs +104 -27
- package/src/codex/hooks/privacy-approval.cjs +1 -1
- package/src/codex/hooks/privacy-block.cjs +67 -11
- package/src/codex/hooks/semantic-review-authority.cjs +130 -0
- package/src/codex/hooks/session.cjs +2 -0
- package/src/codex/hooks/spec-gate.cjs +151 -24
- package/src/codex/hooks/spec-state.cjs +65 -12
- package/src/codex/hooks/state.cjs +2 -0
- package/src/codex/hooks.json +16 -1
- package/src/codex/rules/state-sync.md +47 -27
- package/src/common/AGENTS.md +1 -1
- package/src/opencode/AGENTS.md +4 -2
- package/src/opencode/plugins/spec-gate.ts +296 -122
- package/src/opencode/plugins/spec-state.ts +183 -116
|
@@ -1,427 +1,222 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: hapo:specs
|
|
3
|
-
description: "
|
|
3
|
+
description: "Author the smallest durable, grounded specification that removes product decisions from implementation."
|
|
4
4
|
user-invocable: true
|
|
5
|
-
when_to_use: "
|
|
5
|
+
when_to_use: "Use when a change needs durable requirements or design before implementation."
|
|
6
6
|
category: utilities
|
|
7
7
|
keywords: [specs, requirements, design, tasks]
|
|
8
8
|
argument-hint: "[<feature-description>] [--auto] | --status | --validate <feature> | --archive"
|
|
9
9
|
metadata:
|
|
10
10
|
author: haposoft
|
|
11
|
-
version: "2.
|
|
11
|
+
version: "2.1.0"
|
|
12
12
|
---
|
|
13
|
-
# Specs
|
|
13
|
+
# Specs — semantic kernel v2.1
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
## Canonical authoring contract
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- **YAGNI** — Don't add functionality until it's actually needed
|
|
27
|
-
- **KISS** — Prefer simple solutions over complex ones
|
|
28
|
-
- **DRY** — Don't repeat existing code/logic
|
|
29
|
-
- **Be honest, direct, to the point, concise.**
|
|
30
|
-
|
|
31
|
-
### Phase Separation Rules
|
|
32
|
-
- Each phase (Init → Requirements → Design → Tasks) must complete before the next begins
|
|
33
|
-
- No skipping — don't write design without requirements
|
|
34
|
-
- Exception: simple tasks may merge requirements + design into one step
|
|
35
|
-
- A `/hapo:specs <feature-description>` run defaults to **Interactive State Discovery**: it asks the Creation Mode (Auto / Stop after Design / Step by step) before running. `--auto` runs the full pipeline end-to-end without asking. Either way, phases never skip — each completes before the next begins, and Init is never a stop point.
|
|
36
|
-
|
|
37
|
-
### Scope Rules
|
|
38
|
-
- Respect `scope_lock` absolutely once user has confirmed
|
|
39
|
-
- Never silently expand or shrink scope
|
|
40
|
-
- If scope change needed → ask user, record reason in `spec.json`
|
|
41
|
-
|
|
42
|
-
### State & Integrity Rules
|
|
43
|
-
- Canonical active status: `in_progress` (legacy `in-progress` may be READ only; never emit it).
|
|
44
|
-
- `current_phase` must track the active phase (`init` … `review`).
|
|
45
|
-
- Deterministic validator enforces the structural rules — see Step 8.5.
|
|
46
|
-
- `ready_for_implementation` is a hard gate — never set it before the finalization audit passes.
|
|
47
|
-
- Non-trivial specs MUST have an evidence trail in `research.md` before finalizing requirements/design/tasks.
|
|
48
|
-
|
|
49
|
-
### Language & Canonical Rules
|
|
50
|
-
- **English is the canonical language for every spec artifact** — write them in English regardless of the session's response language.
|
|
51
|
-
- Non-English `language` setting MAY add a **reference-only translation mirror** under `i18n/<lang>/`. See `references/translation-mirror.md`.
|
|
52
|
-
|
|
53
|
-
### Output Criteria
|
|
54
|
-
- Never implement code — only create spec documents
|
|
55
|
-
- Return file paths and a brief summary
|
|
56
|
-
- Spec files must be self-contained; insert code samples when needed to clarify flow
|
|
57
|
-
- Comply with `./docs/development-rules.md` if it exists
|
|
58
|
-
|
|
59
|
-
### Hard Output Contract
|
|
60
|
-
For a normal `/hapo:specs <feature-description>` run, the persistent spec artifacts MUST use this shape:
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
specs/<feature>/
|
|
64
|
-
├── spec.json
|
|
65
|
-
├── requirements.md
|
|
66
|
-
├── research.md
|
|
67
|
-
├── design.md
|
|
68
|
-
├── tasks/
|
|
69
|
-
│ ├── task-R0-01-<slug>.md
|
|
70
|
-
│ ├── task-R1-01-<slug>.md
|
|
71
|
-
│ └── ...
|
|
72
|
-
└── reports/
|
|
73
|
-
└── <optional-review-or-research-report>.md
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Forbidden generated artifacts:
|
|
77
|
-
- Do NOT create `specs/<feature>/init.json`.
|
|
78
|
-
- Do NOT create `specs/<feature>/spec-state.json`.
|
|
79
|
-
- Do NOT create `specs/<feature>/hydration.md`.
|
|
80
|
-
- Do NOT create shorthand task files such as `tasks/task-R0-1.md`, `tasks/task-R1-1.md`, or `tasks/R0-1-<slug>.md`.
|
|
81
|
-
- The template file name is never the output file name. `templates/spec-state.json` is only the schema source for generated `spec.json`.
|
|
82
|
-
- Before marking a spec ready, run the deterministic validator:
|
|
83
|
-
- `node .claude/scripts/validate-spec-output.cjs specs/<feature>`
|
|
84
|
-
- Any validator failure blocks `ready_for_implementation = true`.
|
|
85
|
-
- Deterministic validator enforces the structural rules — see Step 8.5.
|
|
86
|
-
|
|
87
|
-
### Writing Style
|
|
88
|
-
- Concise, prefer bullet lists; no fluff
|
|
89
|
-
- Unresolved questions → list at the end of each document
|
|
90
|
-
|
|
91
|
-
## Lane selection before spec gate
|
|
92
|
-
|
|
93
|
-
Classify task risk at the runtime boundary before starting spec state or approval flow. Use the executable policy, not keyword count or prose alone:
|
|
17
|
+
`spec.json` is machine semantic authority. `requirements.md`, `design.md`,
|
|
18
|
+
conditional `research.md`, and conditional task Markdown are human projections.
|
|
19
|
+
Host state records authority/integrity only; it never supplies product semantics.
|
|
20
|
+
Markdown edits that affect semantics must be synchronized back into `spec.json`
|
|
21
|
+
and pass the same round-trip validation before readiness.
|
|
22
|
+
Promote `semantic_model`, semantic review, and readiness together only through
|
|
23
|
+
the explicit installed machine semantic-sync step, `spec-readiness.cjs`. Authors
|
|
24
|
+
and reviewers never directly write or promote those authority fields; any later
|
|
25
|
+
semantic Markdown edit invalidates the bound round-trip result.
|
|
94
26
|
|
|
95
27
|
```bash
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
- **Direct** — clear, isolated, reversible, low-risk work. May skip spec files, registry/state, and subagents. Still run targeted verification, diff self-check, and evidence proportional to blast radius. No spec/state/registry ceremony required.
|
|
102
|
-
- **Standard** — default lane. Create one bounded spec artifact (`requirements.md` + `design.md` in the current layout), keep one canonical receipt, and run exactly one combined `code-auditor` review at feature ship point (not per-task).
|
|
103
|
-
- **Critical** — destructive/irreversible, auth/payment/privacy/data, schema/migration, public contract, cross-runtime coupling, outcome-changing ambiguity, or difficult rollback. Require strict spec/state/evidence; delegation is risk-driven (inspector/test-runner/code-auditor enabled only when risk lens requires), not a fixed four-agent chain.
|
|
104
|
-
|
|
105
|
-
Explicit `override` is allowed in either direction but is enforced at the runtime boundary. A model-supplied lane or downgrade must not bypass risk signals. Downgrading from Critical requires explicit user-originated authorization (`userAuthorized:true` or `origin:user`) and must surface the trade-off (reduced review/evidence coverage). Agent validation or --auto never fabricates `user_approved`; `generated`, `agent_validated`, and `user_approved` are independent booleans per `schema_version: "2.0"`.
|
|
106
|
-
|
|
107
|
-
## Default Behavior
|
|
108
|
-
|
|
109
|
-
> **This section is the entry/dispatch layer ONLY.** It decides *which part of the pipeline to run and where to stop*. It does NOT change any pipeline step, the validator, templates, or rules.
|
|
110
|
-
|
|
111
|
-
`hapo:specs` exposes exactly **four flags**: `--auto`, `--validate`, `--status`, `--archive`. Everything else is resolved by **Interactive State Discovery**. Bare `status` / `archive` / `resume` are silent back-compat aliases.
|
|
112
|
-
|
|
113
|
-
### Dispatch order
|
|
114
|
-
|
|
115
|
-
1. `--status` (or bare `status`) → run the status report (see **Subcommands**), then stop.
|
|
116
|
-
2. `--validate <feature>` → jump to **Step 8** (the `--validate` rules below are unchanged).
|
|
117
|
-
3. `--archive` (or bare `archive`) → run the archive workflow, then stop.
|
|
118
|
-
4. `--auto` → **non-interactive run**. If the argument matches an unfinished spec → resume it from `current_phase` and finish to Tasks. Otherwise create new and run the full pipeline (Step 1→10) end-to-end. Either way: auto-approve and skip the Creation Mode question; if a new description is missing, ask only for it; the hard safety gates still apply.
|
|
119
|
-
5. Otherwise (`/hapo:specs` or `/hapo:specs "<description>"`) → **Interactive State Discovery**.
|
|
120
|
-
|
|
121
|
-
### Interactive State Discovery (no-flag path)
|
|
122
|
-
|
|
123
|
-
1. **Detect state** — unfinished specs (`in_progress` / not ready) + git-branch match → `Continue <A> · Continue <B> · Create new`; else create-new.
|
|
124
|
-
2. **Create-new** — ask description if missing. Too short → 1-2 questions. Unclear architecture/acceptance/scope/multi-approach → `/hapo:brainstorm`. Simple → "spec may not be needed?". Complex → deep research + 3 scope Qs. Non-trivial → Step 5 Evidence Gate.
|
|
125
|
-
3. **Creation Mode Gate** — see below. Non-English → also offer **Translation Mirror**.
|
|
126
|
-
4. **Continue** unfinished → resume from `current_phase` with remaining stop points.
|
|
127
|
-
5. **Run** chosen scope; early stop → Step 9b; sync per `state-sync.md`.
|
|
128
|
-
|
|
129
|
-
### Creation Mode Gate
|
|
130
|
-
|
|
131
|
-
Shown once on the no-flag create path. Selects the **stop point only**. Approval schema is versioned (`schema_version: "2.0"`): each phase has `generated`, `agent_validated`, `user_approved` as independent booleans. `ready` requires all three true. Legacy `approved` field is rejected — `--auto` or agent validation never fabricates `user_approved`.
|
|
132
|
-
|
|
133
|
-
| Option | Runs | Stops after | Approvals (v2) |
|
|
134
|
-
|---|---|---|---|
|
|
135
|
-
| **Auto (→ Tasks)** | Step 1→10 end-to-end | full (ready gate) | each phase `generated=true` + `agent_validated=true`; `user_approved` stays false until explicit user approval (`--auto` does NOT auto-set `user_approved`). Ready requires `generated && agent_validated && user_approved`. |
|
|
136
|
-
| **Stop after Design** | Step 1→6 | `design` (before Step 7) | requirements + design `generated=true` + `agent_validated=true`; `user_approved=true` only after explicit user approval; later phases ungenerated; `ready_for_implementation=false` |
|
|
137
|
-
| **Step by step** | one phase at a time | after each phase | per phase `generated=true`, `agent_validated` per agent check, `user_approved=false` until user explicitly approves |
|
|
138
|
-
|
|
139
|
-
`--auto` = Auto without the gate. Early stops leave `ready_for_implementation=false` and emit Step 9b. Resume via `/hapo:specs` Interactive State Discovery. If legacy `approved` field is present, fail closed with migration guidance: replace `approved` with `agent_validated` + `user_approved` per `spec-state.json` template.
|
|
140
|
-
|
|
141
|
-
### Translation Mirror (optional reference copy)
|
|
142
|
-
|
|
143
|
-
Load `references/translation-mirror.md`. Canonical = English. Non-English interactive run may set `spec.json.translation` and regenerate `i18n/<code>/` after Steps 5–7 writes. `--auto` create skips the prompt unless already enabled. Mirror is reference-only (never validated / never SoT / ignored by develop).
|
|
144
|
-
|
|
145
|
-
### When called WITH `--validate` argument
|
|
146
|
-
|
|
147
|
-
System IMMEDIATELY jumps to **Step 8: Validation Review**.
|
|
148
|
-
The system MUST NOT execute Steps 1-7. Instead, load `references/review.md` and follow it **step-by-step**.
|
|
149
|
-
|
|
150
|
-
#### `--validate` Guardrails (NON-NEGOTIABLE)
|
|
151
|
-
|
|
152
|
-
1. **Red Team cannot be skipped by the system.** If auto-decision says "Red Team + Validate", you MUST run Red Team. A previous `code-auditor` review does NOT count — code-auditor reviews source code, NOT specifications. Only the USER can downgrade to "Validate only" by explicitly saying so.
|
|
153
|
-
2. **MUST use the 4 Personas** defined in `review.md` Part A Step 3 (Security Adversary, Failure Mode Analyst, Assumption Destroyer, Scope & Complexity Critic). Generic observations without persona attribution are REJECTED.
|
|
154
|
-
3. **MUST use the Finding Format** defined in `review.md` Part A (Severity, Location, Flaw, Failure scenario, Evidence, Suggested fix, Disposition, Rationale). Shortened or custom formats are REJECTED.
|
|
155
|
-
4. **MUST create `reports/red-team-report.md`** when Red Team runs (review.md Part A Step 8).
|
|
156
|
-
5. **MUST NOT create implementation code files** (`.ts`, `.js`, `.py`, etc.). The validate workflow produces ONLY markdown spec documents and reports. If a fix requires a new shared module, describe it in the relevant task file instead of creating the actual code file.
|
|
157
|
-
6. **MUST NOT over-engineer fixes.** Apply YAGNI — if user says "configure later", add an abstraction note to the task, do NOT generate 4 concrete provider implementations.
|
|
158
|
-
7. **MUST follow auto-decision table exactly.** Count task files + scan for keywords → pick mode. No self-justification to override the table result.
|
|
159
|
-
8. **MUST run deterministic validator.** Before reporting validation PASS, run `node .claude/scripts/validate-spec-output.cjs specs/<feature>`. If it exits non-zero, validation is FAIL/BLOCKED, `ready_for_implementation` remains `false`, and output MUST NOT suggest `/hapo:develop`.
|
|
160
|
-
|
|
161
|
-
## Workflow Diagram
|
|
162
|
-
|
|
163
|
-
```mermaid
|
|
164
|
-
flowchart TD
|
|
165
|
-
A["Call /hapo:specs"] --> B{Flag?}
|
|
166
|
-
B -->|"--status"| ST["Status report → stop"]
|
|
167
|
-
B -->|"--archive"| AR["Archive workflow → stop"]
|
|
168
|
-
B -->|"--validate"| W
|
|
169
|
-
B -->|"--auto"| D["Step 1: Analyze description"]
|
|
170
|
-
B -->|none| DISC["Interactive State Discovery"]
|
|
171
|
-
DISC --> DISC1{Unfinished spec?}
|
|
172
|
-
DISC1 -->|Continue| RES["Read current_phase → resume remaining phases"]
|
|
173
|
-
DISC1 -->|New| D
|
|
174
|
-
RES --> CM
|
|
175
|
-
D --> DB{"Needs pre-spec brainstorm?"}
|
|
176
|
-
DB -->|Yes| DB2["Stop: run /hapo:brainstorm with same idea"]
|
|
177
|
-
DB -->|No| E{Clear enough?}
|
|
178
|
-
E -->|No| F["Ask user 1-2 clarifying questions"]
|
|
179
|
-
F --> D
|
|
180
|
-
E -->|Yes| G["Step 2: Scan specs/ for related specs"]
|
|
181
|
-
G --> H["Step 3: 5-Dimension Assessment"]
|
|
182
|
-
H --> H1{Risk level?}
|
|
183
|
-
H1 -->|Chaotic| HX["Exit → redirect to hapo:hotfix"]
|
|
184
|
-
H1 -->|Complex| H2["Include spike/prototype tasks"]
|
|
185
|
-
H1 -->|Clear/Complicated| H3{Need scope inquiry?}
|
|
186
|
-
H2 --> H3
|
|
187
|
-
H3 -->|Yes| J["Present 5D summary → user picks Expand/Hold/Reduce"]
|
|
188
|
-
H3 -->|No| K["Keep default scope"]
|
|
189
|
-
J --> L["Step 4: Init — create specs/<feature>/"]
|
|
190
|
-
K --> L
|
|
191
|
-
L --> M["Step 5A: Evidence Gate — scout + research"]
|
|
192
|
-
M --> N{Evidence sufficient?}
|
|
193
|
-
N -->|No| O["Ask user / run targeted scout / external research"]
|
|
194
|
-
O --> M
|
|
195
|
-
N -->|Yes| P["Step 5B: Requirements — write EARS"]
|
|
196
|
-
P --> Q["Step 6: Design — pick discovery mode"]
|
|
197
|
-
Q --> R["Write design.md"]
|
|
198
|
-
R --> CM{"Creation Mode?"}
|
|
199
|
-
CM -->|"Stop after Design"| STOP["Paused at design → emit Paused Block"]
|
|
200
|
-
CM -->|"Auto / Step by step"| S["Step 7: Tasks — split into individual files"]
|
|
201
|
-
S --> T["Create tasks/task-R*.md + task_registry"]
|
|
202
|
-
T --> V{Review?}
|
|
203
|
-
V -->|Yes| W["Run review — auto-pick red team or validation"]
|
|
204
|
-
V -->|No| X["Update spec.json → DONE"]
|
|
205
|
-
W --> X
|
|
206
|
-
X --> Y["MANDATORY: Output Context Reminder + next command"]
|
|
28
|
+
# Claude Code
|
|
29
|
+
node .claude/scripts/spec-readiness.cjs specs/<feature> --review-result <review.json>
|
|
30
|
+
# Codex
|
|
31
|
+
node .codex/scripts/spec-readiness.cjs specs/<feature> --review-result <review.json>
|
|
207
32
|
```
|
|
208
33
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
### Step 1: Analyze Description
|
|
214
|
-
- Load `references/ask-user-question-gates.md` before asking; do not ask what repo evidence or current docs can answer.
|
|
215
|
-
- Route to `hapo:brainstorm` before creating files when acceptance criteria are not concrete, scope is unknown, 2-3 viable architectures lack a winner, the feature spans 3+ subsystems, or the user wants to explore/compare/debate.
|
|
216
|
-
- **Multimodal & Document Auto-Ingestion (MANDATORY):** media → `hapo:ai-multimodal`; `.pdf` → `hapo:pdf`; `.docx` → `hapo:docx`; `.pptx` → `hapo:pptx`; `.xlsx`/`.csv` → `hapo:xlsx`. Append findings as the enriched description.
|
|
217
|
-
- Description < 20 words or lacks concrete nouns → 1-2 clarifying questions. Too simple → warn a spec may not be needed.
|
|
218
|
-
|
|
219
|
-
### Step 2: Cross-Spec Dependency Scan
|
|
220
|
-
Load: `references/cross-spec-dependency.md` — scan incomplete specs; compare overlapping files/deps; update `spec.json` bidirectionally if related.
|
|
221
|
-
|
|
222
|
-
### Step 3: Complexity Assessment & Scope Inquiry
|
|
223
|
-
Load: `references/scope-inquiry.md` (+ `references/ask-user-question-gates.md` for scope/evidence/contract/architecture decisions).
|
|
224
|
-
- 5 dimensions: Semantic Intent, Implementation Hypothesis, Gap Sizing, Risk/Cynefin, Blast Radius
|
|
225
|
-
- **Chaotic** → `hapo:hotfix`; **Complex** → spike/prototype tasks; **Critical Path** → rollback + test coverage
|
|
226
|
-
- Smell: >8 files / >2 new classes / >12 tasks → challenge; **>15 tasks → sibling specs**
|
|
227
|
-
- User: Expand / Hold / Reduce. Skip if trivial (< 20 words, 1 file, "just do it")
|
|
228
|
-
|
|
229
|
-
#### Execution Tier (auto-scale — after 5-Dimension assessment) — legacy metadata
|
|
230
|
-
Record in `spec.json.design_context.execution_tier` for backward compatibility. Tier is metadata only; **lane controls ceremony and delegation** (Direct/Standard/Critical). Light/Standard/Deep mappings are preserved for compatibility but lane policy is authoritative.
|
|
231
|
-
|
|
232
|
-
| Tier (legacy) | Trigger | Research | Discovery | Red-Team | Always runs |
|
|
233
|
-
|---|---|---|---|---|---|
|
|
234
|
-
| **Light** | Clear + Isolated + ≤2 tasks | skip (rationale) | minimal | Validate-only | scope_lock, EARS, **Layer 1+2** |
|
|
235
|
-
| **Standard** | default / 3-4 tasks | targeted | light | per Step 8 | all of the above |
|
|
236
|
-
| **Deep** | Complex/Critical / security-migration / 5+ tasks | full | full | Red-Team → Validate | all of the above |
|
|
237
|
-
|
|
238
|
-
Grounding + validator + scope_lock never skip. Auth/payment/migration/schema/privacy force Deep (legacy) and Critical (lane). Tier remains backward-compatible execution metadata; lane controls ceremony and delegation.
|
|
239
|
-
|
|
240
|
-
### Step 4: Init
|
|
241
|
-
- Check duplicate slugs; create `specs/<feature-name>/`
|
|
242
|
-
- Create `spec.json` from `templates/spec-state.json` (output name MUST be `spec.json`, never the template filename)
|
|
243
|
-
- Create empty `requirements.md` from `templates/requirements-init.md`
|
|
244
|
-
- Init `scope_lock`: `source`, `in_scope`, `out_of_scope`, `expansion_policy: requires-user-approval`
|
|
245
|
-
- Step 4 only initializes; Creation Mode / `--auto` decides how far — Init is never a stop point.
|
|
246
|
-
|
|
247
|
-
### Step 5: Evidence Gate, Requirements & Research
|
|
248
|
-
- Stop if init incomplete or requirements exist (unless regenerate). Respect `scope_lock`.
|
|
249
|
-
- Load `references/research-strategy.md` + `references/codebase-analysis.md`
|
|
250
|
-
- **Scout mandatory** when changing existing behavior, touching API/CLI/export/schema/auth/config/hook/runtime contracts, lacking paths, invalidating tests, resuming old specs, or crossing package boundaries.
|
|
251
|
-
- **External research mandatory** for third-party APIs/libs/policies/AI/security/auth/payment/privacy/standards, or "best/optimal/latest/recommended".
|
|
252
|
-
- **Skip only** for trivial one-file/docs/isolated new files or user-provided report — record rationale in `research.md`.
|
|
253
|
-
- Scout is targeted (not full-repo). External prefers official/primary sources with links + date.
|
|
254
|
-
- Write `research.md` first with Evidence Summary: scout result, external or skip rationale, selected decision, rejected alternatives, gaps, task/test implications.
|
|
255
|
-
- Unresolved architecture / acceptance / multi-approach → `/hapo:brainstorm`, don't force a spec.
|
|
256
|
-
- EARS requirements (`rules/ears-format.md`) with literal IDs `R{N}.{M}` (not bare `1. 2. 3.`) so Layer 1 sub-criterion coverage works via `_Requirements: 1.1_`.
|
|
257
|
-
- Feasibility vs `research.md`; unique numeric IDs; quality = Singular, Unambiguous, Testable + NFRs. Template `templates/research.md`. Update phase + timestamps.
|
|
258
|
-
|
|
259
|
-
### Step 6: Design
|
|
260
|
-
- Stop if requirements incomplete. Discovery: `minimal` / `light` (default) / `full`.
|
|
261
|
-
- Load `rules/design-principles.md`, `rules/phase-decision-matrix.md` (implementation slices, clusters, foundation, spike needs, integration/verification gates), `references/ask-user-question-gates.md` when needed, and `rules/design-discovery-[mode].md`.
|
|
262
|
-
- Record research findings; write `design.md` from `templates/design.md`. Decisions MUST trace to `research.md` evidence.
|
|
263
|
-
- Diagrams only for multi-step/cross-boundary flows. Auth/session/transport/persistence/artifact/runtime work MUST fill `Canonical Contracts & Invariants`; tasks inherit verbatim.
|
|
264
|
-
- Any spec whose tasks span both backend and frontend surfaces MUST declare shared data shapes as named contract blocks. Declare each as `<!-- contract:NAME -->` followed by a fenced block — per `templates/design.md`. Tasks that produce/consume it add `Contracts: NAME` and copy the block verbatim; the validator then hard-fails on cross-layer drift.
|
|
265
|
-
- Update phase, timestamps, discovery mode.
|
|
266
|
-
|
|
267
|
-
### Step 7: Task Breakdown
|
|
268
|
-
- Stop if `requirements.md` or `design.md` missing. Respect `scope_lock`.
|
|
269
|
-
- Load `rules/tasks-generation.md`, `rules/phase-decision-matrix.md` (implementation slice/task cluster, not `phase-XX.md`), `rules/task-scoring-rubric.md` (priority, split/merge, spike needs, deps, parallel, evidence depth), and `references/ask-user-question-gates.md` if scoring expands scope.
|
|
270
|
-
- **Scaffold is mandatory — raw `Write` to a task file is blocked.** PreToolUse `task-scaffold-guard.cjs` rejects `Write` to `specs/<feature>/tasks/task-*.md`. Path: scaffold → Edit:
|
|
271
|
-
`node .claude/scripts/spec-scaffold.cjs <feature> --tasks "R0-01-slug,R1-01-slug,..." --tasks-only`
|
|
272
|
-
Creates stubs from `templates/task.md`, merges `task_files` + `task_registry` (no overwrite of filled tasks). **Edit-fill** all `{{...}}` (`Edit`/`MultiEdit` ok; `Write` not). Fails open if scaffold missing; disable via `"spec": { "scaffold_guard": false }`.
|
|
273
|
-
- Leave NO `{{...}}` unfilled. Related Files/tests inherit scout paths — Layer 2 grounds them at Step 8.5; phantom paths hard-fail.
|
|
274
|
-
- Each task MUST include `Completion Criteria` and `## Evidence` (legacy heading aliases still parse). Choose proof type by surface (unit / component / E2E / visual / a11y / smoke / regression / perf-security when required).
|
|
275
|
-
- Preserve `scope_lock`; deferrals = named later tasks. UI/runtime specs need a final reachability task naming a real entrypoint.
|
|
276
|
-
- Register each task: `id`, `title`, `status` (`pending`), `dependencies` (relative paths), `blocker`, `started_at`, `completed_at`, `last_updated_at`.
|
|
277
|
-
|
|
278
|
-
#### Requirement-Covered Task Grouping (MANDATORY)
|
|
279
|
-
**Naming:** `tasks/task-R{N}-{SEQ}-<slug>.md` — R0 foundation, R1+ feature; SEQ two-digit; kebab slug.
|
|
280
|
-
Example: `task-R0-01-database-schema-foundation.md`, `task-R1-01-captions-observer.md`.
|
|
281
|
-
|
|
282
|
-
Split by dependency chain (schema → service → API → UI → integration). Tasks may cover multiple IDs; IDs may span tasks. Not all under R0. Every requirement ID must appear in some task's `## Requirements`. Blast-radius breakages → explicit fix tasks. Cross-req deps via `Dependencies:`.
|
|
283
|
-
|
|
284
|
-
#### Task File Quality Requirements (MANDATORY)
|
|
285
|
-
Self-contained and implementation-ready. Structure: **Context**, **Constraints**, **Steps**, **Requirements**, **Related Files**, **Completion Criteria**, **Evidence**, **Risk Assessment**.
|
|
286
|
-
|
|
287
|
-
**Template fidelity is mandatory:** preserve the task template headings exactly. Do NOT rename `## Context` to `## Objective`, do NOT replace `## Completion Criteria` with prose, do NOT remove `## Related Files`, `## Constraints`, or `## Risk Assessment`, and do NOT collapse `## Evidence` into generic QA scenarios. Compact wording is fine; missing sections are invalid.
|
|
288
|
-
|
|
289
|
-
Parallel: append `(P)` when no data/file/approval deps. **FORBIDDEN:** vague checkboxes without exact files/requirements/evidence.
|
|
290
|
-
|
|
291
|
-
#### Definition of a Complete Task (DoCT) — the quality bar
|
|
292
|
-
|
|
293
|
-
| DoCT element | Enforced by |
|
|
294
|
-
|---|---|
|
|
295
|
-
| **Related Files** name exact real paths (Create/Modify/Delete) | Layer 2 grounding (`spec-ground.cjs`) — phantom path fails |
|
|
296
|
-
| **Contract** (API/DB/event shape) stated concretely | Layer 1 contract-drift check (`<!-- contract:NAME -->`) |
|
|
297
|
-
| **Acceptance** measurable (no "fast/nice/safe" without a threshold) | EARS rule + reviewer judgment |
|
|
298
|
-
| **Evidence** uses commands that exist in the project (`package.json`) | Author + grounding spirit; never invent test commands |
|
|
299
|
-
| **Reachability** names a real entrypoint/caller | `Runtime reachability verification` (Layer 1 presence) + judgment |
|
|
300
|
-
| **Requirements mapping** present (`_Requirements: x.y_`) | Layer 1 coverage check |
|
|
301
|
-
| **FE fidelity** — if a visual reference is provided, task carries concrete values + `match <reference>` constraint | `tasks-generation.md` Frontend Fidelity Rule + reviewer/visual check |
|
|
302
|
-
|
|
303
|
-
Unfilled `{{...}}` fails DoCT. Layer 1+2 are the floor; reviewer judgment covers the rest.
|
|
304
|
-
|
|
305
|
-
### Step 8: Validation Review (Optional)
|
|
306
|
-
Load: `references/review.md` + `rules/design-review.md` + `references/ask-user-question-gates.md` before applying findings that change scope/contracts/tasks.
|
|
307
|
-
- Auto-depth: **< 3 tasks, no security** → Validate only; **≥ 5 OR security/migration** → Red Team then Validate; user request → respect
|
|
308
|
-
- `validation_recommended = true` for auth/session/privacy/deletion/migration/schema/AI-provider/extension-permissions or 5+ tasks
|
|
309
|
-
- Red Team always before Validate when both run. MUST NOT skip Red Team for code-auditor reviews. MUST NOT create implementation files.
|
|
310
|
-
- `validation.status = "completed"` only after findings propagated into requirements/design/tasks/spec.json.
|
|
311
|
-
- **Deterministic Gate (2 layers):** `validate-spec-output.cjs` + `spec-ground.cjs` after fixes. Either script failing overrides any LLM checklist result and blocks `ready_for_implementation = true`.
|
|
312
|
-
|
|
313
|
-
### Step 8.5: Finalization Audit (MANDATORY)
|
|
314
|
-
- Rebuild `task_files` + `task_registry` from real `tasks/` (sorted; preserve status when path matches).
|
|
315
|
-
- **Layer 1 — Structural:** `node .claude/scripts/validate-spec-output.cjs specs/<feature>` — non-zero = block.
|
|
316
|
-
- **Layer 2 — Grounding (MANDATORY):** `node .claude/scripts/spec-ground.cjs specs/<feature> [--root <work-context>]` — non-zero = block. Verifies every Modify/Delete/Read Related Files path exists or is Created earlier. Layer 1 pass + Layer 2 fail = NOT ready.
|
|
317
|
-
|
|
318
|
-
**Validator-enforced (do not re-check by hand — a clean exit clears all of these):** task_files/task_registry synced to disk; task naming `tasks/task-R{N}-{SEQ}-<slug>.md`; no forbidden artifacts; research.md Evidence Summary present; every requirement **and sub-criterion** covered by a task; each task keeps the full template (Context, Constraints, Steps, Related Files, Completion Criteria, Evidence, Risk Assessment) plus Runtime reachability; numeric requirement IDs only; validation_recommended vs validation.status; timestamps not reused from init; ready_for_implementation blocked while any error exists.
|
|
319
|
-
|
|
320
|
-
**Grounding-enforced:** every Modify/Delete/Read Related Files path exists or is Created earlier. Phantom paths hard-fail.
|
|
321
|
-
|
|
322
|
-
**Judgment-only audit:**
|
|
323
|
-
- FAIL: multi-output UI/runtime spec without final integration/reachability task.
|
|
324
|
-
- FAIL: accepted review decisions not reflected in Context/Steps/Requirements/Completion Criteria/Evidence/contracts.
|
|
325
|
-
- FAIL: stale Claude/Haiku strings outside `research.md` after provider switch.
|
|
326
|
-
- FAIL: privacy/delete-data without one canonical policy (hard-delete, or hash-based re-reg lock + retention) reused verbatim by tasks.
|
|
327
|
-
- FAIL: `validation.status=completed` without synced `validation_done`/`review_done`/`updated_at`/report metadata.
|
|
328
|
-
- `validation_recommended` without completed validation (or recorded risk acceptance) → keep `ready_for_implementation=false`.
|
|
329
|
-
- `translation.enabled` → re-sync `i18n/<code>/` after final write (mirror never blocks ready).
|
|
330
|
-
- Only after audit passes: `progress.tasks = "done"` and `ready_for_implementation = true`.
|
|
331
|
-
|
|
332
|
-
### Step 9: Completion — Context Reminder (MANDATORY)
|
|
333
|
-
Output a short summary, then this block EXACTLY (no awkward translations — keep professional):
|
|
334
|
-
|
|
335
|
-
**Command integrity:** The implementation handoff command is always `/hapo:develop <feature>`. Never suggest `/work`, `/code`, or any non-CafeKit alias as the next step for this workflow.
|
|
34
|
+
`review.json` has exactly `reviewed_criteria` and `counterexamples`. The command
|
|
35
|
+
projects current Markdown, validates structure, grounding, round-trip, and
|
|
36
|
+
Strict authority, then writes atomically; failure preserves exact original bytes.
|
|
336
37
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
📌 Next step — run:
|
|
340
|
-
/hapo:develop <feature>
|
|
341
|
-
|
|
342
|
-
💡 Tip: Run /clear or start a new chat session before implementing to reduce planning context carryover.
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
### Step 9b: Paused Block (early stop)
|
|
346
|
-
|
|
347
|
-
Early stop (**Stop after Design** / **Step by step**): no completion block, no validator. Print:
|
|
348
|
-
|
|
349
|
-
```
|
|
350
|
-
⏸ Spec paused at <phase>: specs/<feature>/
|
|
351
|
-
📌 Continue — run /hapo:specs and choose "Continue <feature>"
|
|
352
|
-
(or /hapo:specs <feature> --auto to finish straight to Tasks)
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
`ready_for_implementation` stays `false`. Next `/hapo:specs` re-detects via Interactive State Discovery.
|
|
356
|
-
|
|
357
|
-
## Active Spec State
|
|
38
|
+
Persist `planning_depth`, `assurance_level`, `classified_minimum`, normalized
|
|
39
|
+
`risks`, and contract `version`. Planning and assurance are independent:
|
|
358
40
|
|
|
359
|
-
|
|
|
360
|
-
|---|---|
|
|
361
|
-
| `in_progress` or branch match | Continue vs Create new |
|
|
362
|
-
| Nothing found | Create new → Creation Mode Gate |
|
|
363
|
-
| `init` / `requirements` / `design` done | write requirements / design / break into tasks |
|
|
364
|
-
| tasks done, validation incomplete | `/hapo:specs --validate <feature>` |
|
|
365
|
-
| ready_for_implementation = true | `/hapo:develop <feature>` |
|
|
366
|
-
| `blocked` | warn which spec blocks |
|
|
367
|
-
|
|
368
|
-
`spec.json` is the single source of truth — sync phase on each transition.
|
|
369
|
-
|
|
370
|
-
### spec.json Update Rules (MANDATORY)
|
|
371
|
-
|
|
372
|
-
| Field | Rule |
|
|
373
|
-
|---|---|
|
|
374
|
-
| `schema_version` | Must be `"2.0"`; approvals use `generated` + `agent_validated` + `user_approved` per phase. Legacy `approved` field is rejected — fail closed with migration guidance. |
|
|
375
|
-
| Status | `in_progress` / `blocked` / `done` / `archived` only (never emit `in-progress`) |
|
|
376
|
-
| Timestamps | Each `timestamps.*_done` = actual ISO 8601 time at that phase; never reuse init |
|
|
377
|
-
| Approvals (Auto / full pipeline) | `generated=true` + `agent_validated=true`; `user_approved` stays false until explicit user approval (`--auto` never fabricates `user_approved`). Ready requires all three true per phase. |
|
|
378
|
-
| Approvals (Stop after Design) | phases that ran: `generated=true` + `agent_validated=true`; `user_approved=true` only after explicit user approval; later phases ungenerated; `ready_for_implementation=false` |
|
|
379
|
-
| Approvals (Step by step) | `generated=true`, `agent_validated` per agent check, `user_approved=false` until user explicitly approves |
|
|
380
|
-
| `task_files` / `task_registry` | Exact match to disk after Step 7; registry keys = relative paths with full registry fields |
|
|
381
|
-
| `validation_recommended` | `true` for auth/privacy/delete/migration/schema/extension/provider or 5+ tasks |
|
|
382
|
-
| `translation` | optional mirror metadata; never affects ready gate |
|
|
383
|
-
| `ready_for_implementation` | `true` only when requirements+design+tasks each have `generated && agent_validated && user_approved`, `progress.tasks=done`, inventories match disk, and validation completed when recommended |
|
|
384
|
-
|
|
385
|
-
If any approval (`generated`, `agent_validated`, or `user_approved`) is `false`, keep `ready_for_implementation = false`. Specs with 5+ tasks stay not-ready until `--validate` writes `validation.status = "completed"`. Legacy `approved` fails closed — do not infer `user_approved` from `generated` or `agent_validated`.
|
|
386
|
-
|
|
387
|
-
## Subcommands
|
|
388
|
-
|
|
389
|
-
| Command | Purpose | Reference |
|
|
41
|
+
| Axis | Values | Decides |
|
|
390
42
|
|---|---|---|
|
|
391
|
-
|
|
|
392
|
-
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
43
|
+
| `planning_depth` | `None`, `Compact`, `Full` | Durable artifact/detail topology. |
|
|
44
|
+
| `assurance_level` | `Routine`, `Elevated`, `Strict` | Review and verification depth. |
|
|
45
|
+
|
|
46
|
+
`Direct`, `Standard`, and `Critical` are derived compatibility views. Risk may
|
|
47
|
+
raise assurance without creating artifacts; decomposition may raise planning
|
|
48
|
+
depth without inventing risk. Reclassify before persistence. A persisted
|
|
49
|
+
same-feature baseline is monotonic and never contaminates another feature.
|
|
50
|
+
|
|
51
|
+
Any non-empty normalized risk raises the automatic assurance floor from Routine
|
|
52
|
+
to Elevated. Strict is opt-in: select it only when the user or project policy
|
|
53
|
+
explicitly requires independent audit, or after the user confirms a concrete,
|
|
54
|
+
scope-specific audit need. A keyword, risk severity, Full depth, or model
|
|
55
|
+
preference never selects Strict by itself.
|
|
56
|
+
|
|
57
|
+
Canonical lifecycle is exactly `in_progress`, `paused`, `blocked`, `done`.
|
|
58
|
+
Legacy aliases are read compatibility only. `ready_for_implementation` means
|
|
59
|
+
technical authoring readiness; it is not lifecycle completion, implementation
|
|
60
|
+
permission, execution proof, or closeout. `done` belongs to final-state
|
|
61
|
+
authority after execution closeout.
|
|
62
|
+
|
|
63
|
+
## Artifact router
|
|
64
|
+
|
|
65
|
+
Decide this table before loading discovery rules or creating files:
|
|
66
|
+
|
|
67
|
+
| Depth | Durable core | Research route | Task route | Design expansion |
|
|
68
|
+
|---|---|---|---|---|
|
|
69
|
+
| `None` | none | absent | absent | none |
|
|
70
|
+
| `Compact` | `spec.json`, `requirements.md`, `design.md` | only on a research trigger | only on a typed topology trigger | bounded core sections |
|
|
71
|
+
| `Full` | `spec.json`, `requirements.md`, `design.md` | only on a research trigger | only on a typed topology trigger | only sections activated by scoped behavior |
|
|
72
|
+
|
|
73
|
+
Research triggers are: unresolved material uncertainty that can change
|
|
74
|
+
requirements/design; an external-current fact that must be grounded; or an
|
|
75
|
+
explicit user request. Otherwise `authoring.research=absent`, omit the pointer,
|
|
76
|
+
and create no file or placeholder. Repository scouting may inform requirements
|
|
77
|
+
or design without producing `research.md`.
|
|
78
|
+
|
|
79
|
+
Task triggers are typed ownership, dependency, transition, proof, or parallel
|
|
80
|
+
boundaries that require separate execution packets. Requirement count, size,
|
|
81
|
+
planning depth, assurance level, risk label, architectural layers, and habit do
|
|
82
|
+
not trigger tasks. `coordination.boundaries` is machine authority.
|
|
83
|
+
|
|
84
|
+
Full selects potential detail, never automatic discovery ceremony. It does not
|
|
85
|
+
automatically search the web, invoke a researcher, dump discovery results, create
|
|
86
|
+
research, create tasks, or retain unused template sections.
|
|
87
|
+
|
|
88
|
+
## Artifact profiles
|
|
89
|
+
|
|
90
|
+
- `None`: create no spec directory, registry, research, task, phase, report, or
|
|
91
|
+
receipt artifact.
|
|
92
|
+
- `Compact` and `Full`: create the routed core and only optional artifacts whose
|
|
93
|
+
trigger is present.
|
|
94
|
+
- Research, task, and phase metadata must disappear when their trigger is absent.
|
|
95
|
+
- `feature-receipt.md` and task execution receipts belong to execution closeout,
|
|
96
|
+
not authoring or readiness.
|
|
97
|
+
|
|
98
|
+
Forbidden authoring artifacts include `init.json`, `spec-state.json`,
|
|
99
|
+
`hydration.md`, `phase-*.md`, and shorthand task filenames.
|
|
100
|
+
|
|
101
|
+
## Route
|
|
102
|
+
|
|
103
|
+
1. Resolve the request and active feature; ambiguity fails closed.
|
|
104
|
+
Ambiguous active candidates fail closed: multiple active specs require an
|
|
105
|
+
explicit target. Do not rely on first-directory selection or guess from the
|
|
106
|
+
first active directory.
|
|
107
|
+
2. Classify both axes and run the artifact router before loading discovery.
|
|
108
|
+
3. Establish `scope_lock` with source, in/out scope, and
|
|
109
|
+
`expansion_policy=requires-user-approval`.
|
|
110
|
+
4. Author requirements, then design, then conditional research/tasks as their
|
|
111
|
+
actual dependency requires; do not create empty artifacts to reserve them.
|
|
112
|
+
5. Review the final graph, synchronize machine and Markdown projections, then
|
|
113
|
+
run deterministic gates.
|
|
114
|
+
6. Pause for unresolved product/scope decisions instead of inventing semantics.
|
|
115
|
+
|
|
116
|
+
Investigate a `repository_fact` and record grounding. Choose the simplest
|
|
117
|
+
`reversible_assumption` and record its bounded reversal boundary. Ask the user
|
|
118
|
+
for a `user_owned` product, scope, security, data, or irreversible decision.
|
|
119
|
+
Persist only actual items in optional `spec.json.decisions`; omit it when none
|
|
120
|
+
exist. Unresolved `user_owned` entries block readiness.
|
|
121
|
+
|
|
122
|
+
Supported flags are `--auto`, `--validate`, `--status`, and `--archive`; bare
|
|
123
|
+
`status`, `archive`, and `resume` are compatibility aliases.
|
|
124
|
+
|
|
125
|
+
## Requirements
|
|
126
|
+
|
|
127
|
+
Load `rules/ears-format.md` and `templates/requirements.md`.
|
|
128
|
+
|
|
129
|
+
- Use `Requirement N` and literal `RN.M`; task mappings use numeric `N.M`.
|
|
130
|
+
- State scoped outcomes and non-goals before detailed criteria.
|
|
131
|
+
- Every behavior has measurable acceptance and relevant negative/error cases.
|
|
132
|
+
- Add only feature-specific measurable non-functional constraints.
|
|
133
|
+
- User story, rationale, and scenarios are conditional, not ceremony.
|
|
134
|
+
|
|
135
|
+
## Design and discovery
|
|
136
|
+
|
|
137
|
+
Load `rules/design-principles.md` plus the routed light/full discovery rule.
|
|
138
|
+
Load research guidance only when the artifact router selected research.
|
|
139
|
+
|
|
140
|
+
- Compact keeps boundary, six-column typed anchors, decisions/invariants, and
|
|
141
|
+
verification. Full adds only triggered contract/flow/data/error/security/
|
|
142
|
+
migration sections.
|
|
143
|
+
- Define each implementation-significant contract once and reference its stable
|
|
144
|
+
`D`/`I`/`C` ID.
|
|
145
|
+
- For retention/lifecycle and API contracts, follow `rules/design-principles.md` (clock anchor/source/timezone/precision/comparator/inclusivity/boundary + wrong-clock/boundary counterexample; method/route/auth/headers/schema/response/error/idempotency).
|
|
146
|
+
- Keep exactly one parser-visible `## Verification Definitions` section. Each
|
|
147
|
+
single-line V definition starts with `Criteria ...; Owner ...;` and traces
|
|
148
|
+
exact decision refs, method,
|
|
149
|
+
expected result, negative/failure case, and reachability/grounding.
|
|
150
|
+
- Add `Proof criteria ...; Proof owner ...; Evidence anchor ...;` only for a
|
|
151
|
+
typed proof boundary; ordinary verification stays in the owner boundary.
|
|
152
|
+
- Delete unused optional sections. Ground repository facts to exact anchors;
|
|
153
|
+
ground external-current decisions to primary sources.
|
|
154
|
+
|
|
155
|
+
## Tasks and lightweight phases
|
|
156
|
+
|
|
157
|
+
Load `rules/tasks-generation.md` and `templates/task.md` only when at least one
|
|
158
|
+
typed topology trigger exists. Size, risk labels, and tradition alone do not
|
|
159
|
+
create tasks. Keep `Direct`/`Compact` light: do not coerce a task when no typed
|
|
160
|
+
boundary exists, and never invent a task to justify structure.
|
|
398
161
|
|
|
399
|
-
|
|
400
|
-
|
|
162
|
+
Each task has exactly seven H2 sections: Outcome, Scope, Anchors and Ownership, Changes, Acceptance, Dependencies, and Verification Plan. The only ownership table is `ID | Type | Target | Role | Access | Action`. Planned verification is not execution evidence. Every executable task must own a concrete test file/artifact anchor (write create/modify) or share proof via a typed proof boundary; bare npm test is not ownership.
|
|
163
|
+
|
|
164
|
+
Typed `coordination.boundaries` entries (`ownership`, `dependency`,
|
|
165
|
+
`transition`, `proof`, `parallel`) are the sole topology authority. Legacy
|
|
166
|
+
priority markers, trigger fields, related-file lists, and prose labels are inert
|
|
167
|
+
read compatibility, never canonical authoring.
|
|
168
|
+
|
|
169
|
+
Each `RN.M` has exactly one implementation owner. A proof subject implements
|
|
170
|
+
its criterion; its verifier owns a separate proof criterion/artifact, references
|
|
171
|
+
the same V definition, and never duplicates the subject acceptance claim.
|
|
172
|
+
|
|
173
|
+
Phases are optional task-ID groups only for a complex Full task graph. They do
|
|
174
|
+
not create files, repeat prose, or replace typed edges.
|
|
175
|
+
|
|
176
|
+
## Review and readiness
|
|
401
177
|
|
|
402
|
-
|
|
403
|
-
|
|
178
|
+
Load `references/review.md`. Review the whole graph and inventory every blocker; presentation may be concise, but finding count is never capped. Each `RN.M` receives a concrete counterexample mapped to real `D`/`I`/`C` and `V` refs. For any retention/lifecycle rule, include a counterexample where the wrong clock (for example creation time instead of terminal/state-transition) would violate the policy.
|
|
179
|
+
|
|
180
|
+
Routine and Elevated have no reviewer ceremony. Strict requires an independent, allowlisted reviewer capability observed by the host hook. The author cannot self-attest Strict. If that host event is unavailable, pause once with the exact capability blocker; do not retry reviewer loops, self-attest, downgrade, or simulate the event. This is an honest-agent guardrail, not host-attested evidence or a security boundary. Two-review target is advisory: after two failed semantic rounds, pause for unresolved product/security/architecture uncertainty or repeated non-convergence; one bounded mechanical correction without weakening gates is allowed; budgets never override correctness.
|
|
404
181
|
|
|
405
|
-
|
|
406
|
-
-
|
|
182
|
+
For Strict, the reviewer binds its host-observed event to the read-only candidate
|
|
183
|
+
digest from `node .claude/scripts/validate-spec-output.cjs specs/<feature> --semantic-digest` (Claude Code) or `node .codex/scripts/validate-spec-output.cjs specs/<feature> --semantic-digest` (Codex);
|
|
184
|
+
finalization then verifies that current observation.
|
|
407
185
|
|
|
408
|
-
|
|
409
|
-
- Document rationale; extensible without over-engineering (function > class when enough)
|
|
186
|
+
Run final-byte validation and grounding for every durable spec:
|
|
410
187
|
|
|
411
|
-
|
|
412
|
-
|
|
188
|
+
```bash
|
|
189
|
+
# Claude Code
|
|
190
|
+
node .claude/scripts/validate-spec-output.cjs specs/<feature>
|
|
191
|
+
# Codex
|
|
192
|
+
node .codex/scripts/validate-spec-output.cjs specs/<feature>
|
|
193
|
+
```
|
|
413
194
|
|
|
414
|
-
|
|
195
|
+
Exit 0 proves only implemented structural/grounding checks. It does not prove
|
|
196
|
+
semantic quality, product correctness, execution PASS, or closeout.
|
|
415
197
|
|
|
416
|
-
|
|
198
|
+
The installed atomic finalizer may set `ready_for_implementation = true`
|
|
199
|
+
only after routed artifacts match policy, all projections round-trip, the full
|
|
200
|
+
blocker inventory is resolved, every required authoring state is `validated`,
|
|
201
|
+
semantic review coverage is exact, and every deterministic gate passes. The
|
|
202
|
+
author must not write this authority conclusion directly. This flag is technical
|
|
203
|
+
artifact readiness only.
|
|
204
|
+
Specs never invokes or auto-chains into Develop; only a fresh explicit user
|
|
205
|
+
invocation of Develop starts implementation. Specs-only never creates or
|
|
206
|
+
updates docs; record doc impact as a brief recommendation and leave creation or
|
|
207
|
+
update to the docs workflow. Never fabricate execution proof. On failure, keep lifecycle state unfinished and report the exact blocker.
|
|
417
208
|
|
|
418
|
-
|
|
419
|
-
❌ Simple bugfixes, < 1 hour changes, emergency hotfixes
|
|
209
|
+
## Platform acceptance and handoff
|
|
420
210
|
|
|
421
|
-
|
|
211
|
+
Semantic acceptance covers Claude Code and Codex. Validate both installed
|
|
212
|
+
instruction projections and use native vocabulary for each runtime.
|
|
422
213
|
|
|
423
|
-
|
|
214
|
+
After readiness, report the optional handoff without invoking it:
|
|
424
215
|
|
|
425
|
-
|
|
216
|
+
- Claude Code: `/hapo:develop <feature>`
|
|
217
|
+
- Codex: `$hapo-develop <feature>`
|
|
426
218
|
|
|
427
|
-
|
|
219
|
+
For an early stop, keep readiness false and explain how to resume. `--auto` may
|
|
220
|
+
set technical readiness after every gate passes, but must stop in Specs. Never
|
|
221
|
+
claim proof, authority, approval, readiness, or closeout from placeholders,
|
|
222
|
+
self-authored receipts, chat state, or stale validation.
|