@haposoft/cafekit 0.8.6 → 0.8.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.
- package/bin/install.js +8 -1
- package/package.json +1 -1
- package/src/claude/agents/code-auditor.md +8 -0
- package/src/claude/agents/inspector.md +24 -1
- package/src/claude/agents/spec-maker.md +22 -2
- package/src/claude/agents/test-runner.md +14 -3
- package/src/claude/archive-command/spec-init.md +2 -2
- package/src/claude/skills/develop/SKILL.md +39 -8
- package/src/claude/skills/develop/references/quality-gate.md +40 -38
- package/src/claude/skills/specs/SKILL.md +32 -2
- package/src/claude/skills/specs/references/review.md +1 -1
- package/src/claude/skills/specs/rules/tasks-generation.md +6 -0
- package/src/claude/skills/specs/templates/task.md +5 -0
- package/src/claude/skills/sync/references/sync-protocols.md +1 -1
- package/src/claude/skills/test/SKILL.md +23 -1
- /package/src/claude/skills/specs/templates/{init.json → spec-state.json} +0 -0
package/bin/install.js
CHANGED
|
@@ -424,8 +424,15 @@ function copyPlatformFiles(platformKey, results, options = {}) {
|
|
|
424
424
|
|
|
425
425
|
// Keep templates in sync for claude command runtime copies under .claude/skills/specs
|
|
426
426
|
if (platformKey === 'claude') {
|
|
427
|
+
const legacyInitTemplate = path.join(platform.skillsDir, 'specs', 'templates', 'init.json');
|
|
428
|
+
if (fs.existsSync(legacyInitTemplate)) {
|
|
429
|
+
fs.rmSync(legacyInitTemplate, { force: true });
|
|
430
|
+
console.log(` ↻ Removed legacy template: ${legacyInitTemplate}`);
|
|
431
|
+
results.updated++;
|
|
432
|
+
}
|
|
433
|
+
|
|
427
434
|
const specTemplates = [
|
|
428
|
-
'
|
|
435
|
+
'spec-state.json',
|
|
429
436
|
'requirements-init.md',
|
|
430
437
|
'requirements.md',
|
|
431
438
|
'design.md',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haposoft/cafekit",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.8",
|
|
4
4
|
"description": "Claude Code-first spec-driven workflow for AI coding assistants. Bundles CafeKit hapo: skills, runtime hooks, agents, and installer scaffolding.",
|
|
5
5
|
"author": "Haposoft <nghialt@haposoft.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,6 +16,8 @@ You DO NOT fix code. You only READ, SCORE, and REPORT.
|
|
|
16
16
|
## Pre-Review: Task / Spec Compliance (MANDATORY)
|
|
17
17
|
|
|
18
18
|
If the prompt includes task file paths, requirement IDs, completion criteria, or design contracts, you MUST read them before reviewing code.
|
|
19
|
+
If the prompt says `SPEC COMPLIANCE REVIEW ONLY`, do not perform a general quality review yet. First prove the implementation matches the active task, `scope_lock`, requirements, design contracts, and scout-discovered runtime entrypoints.
|
|
20
|
+
Do NOT trust implementer reports. Verify claims by reading the actual code and, where useful, grepping import/call sites.
|
|
19
21
|
|
|
20
22
|
Extract and verify:
|
|
21
23
|
1. Declared deliverables (files, routes, entrypoints, UI surfaces, schemas, migrations)
|
|
@@ -24,8 +26,10 @@ Extract and verify:
|
|
|
24
26
|
4. Task Test Plan & Verification Evidence expectations (or legacy Verification & Evidence)
|
|
25
27
|
5. Canonical Contracts & Invariants from the design
|
|
26
28
|
6. Named technologies and runtime choices that the task/spec explicitly requires
|
|
29
|
+
7. Runtime entrypoints/callers and reachability obligations from task evidence or the task-aware scout report
|
|
27
30
|
|
|
28
31
|
Any missing declared deliverable, placeholder-only wiring, or contract drift is a **Critical** issue even if tests/build pass.
|
|
32
|
+
Any scoped behavior omitted, unapproved behavior added, orphaned component/service/route/command/worker/provider/reducer, unmounted UI, unregistered route, uncalled loader/service, or unreachable runtime surface is a **Critical** issue even if tests/build pass.
|
|
29
33
|
If the task/spec explicitly names Better Auth, Hono, Next.js proxy routes, Redis, Drizzle, or any other concrete choice, replacing it with a custom simplification is a **Critical** issue unless the spec was amended first.
|
|
30
34
|
|
|
31
35
|
## Pre-Review: Blast Radius Check (MANDATORY)
|
|
@@ -61,6 +65,8 @@ Before reading any specific logic, you MUST run a Dependency Scope Check (Blast
|
|
|
61
65
|
- Hunt serious logic bugs (crashes, data loss, infinite loops).
|
|
62
66
|
- Hunt severe architecture violations (circular imports, cross-layer coupling).
|
|
63
67
|
- Hunt missing required artifacts/runtime entrypoints and spec contract mismatches.
|
|
68
|
+
- Hunt reachability failures: created exports with no importers, UI not mounted, route not registered, service/data loader never called, provider never wrapping consumers, reducer/action disconnected from runtime state, CLI/worker/manifest not wired.
|
|
69
|
+
- Hunt scope drift: accepted requirement omitted or out-of-scope behavior added without spec amendment.
|
|
64
70
|
- Hunt overscope edits: later-task deliverables, unjustified file additions, or edits outside the active task packet.
|
|
65
71
|
- Hunt named-contract substitutions: custom placeholders or in-memory stand-ins where the spec required a concrete framework/service.
|
|
66
72
|
- Hunt fake cross-service proof: flows that claim web ↔ api ↔ worker ↔ extension integration while using isolated local state on each side.
|
|
@@ -131,6 +137,8 @@ When called from `hapo:develop` Step 4 (Quality Gate Auto-Fix):
|
|
|
131
137
|
|
|
132
138
|
**Automatic Criticals:**
|
|
133
139
|
- Missing required entrypoint/artifact/runtime output named in the task/spec
|
|
140
|
+
- Runtime-facing artifact exists only as orphaned or unreachable code: component/export unused, UI unmounted, route unregistered, service/loader uncalled, provider not mounted, reducer/action disconnected, command/worker/manifest not wired
|
|
141
|
+
- Missing scoped acceptance criteria or behavior outside `scope_lock` without a spec amendment
|
|
134
142
|
- Placeholder scaffolding marked as complete when the task demanded real wiring
|
|
135
143
|
- Auth/session/transport/persistence behavior that contradicts the design contracts
|
|
136
144
|
- Silent replacement of a named framework/auth/provider/transport/datastore with a custom simplification
|
|
@@ -8,7 +8,7 @@ model: haiku
|
|
|
8
8
|
# Inspect — Codebase Scout
|
|
9
9
|
|
|
10
10
|
You hold two primary roles depending on when you are called:
|
|
11
|
-
1. **Architecture Scout (Pre-coding):** Quickly map out directory trees
|
|
11
|
+
1. **Task-Aware Architecture Scout (Pre-coding):** Quickly map out directory trees, runtime entrypoints, integration points, and exact files relevant to the active task.
|
|
12
12
|
2. **Edge Case Scout (Code Review phase):** Quickly grep and scan the codebase to find where modified functions/components are imported elsewhere. You hunt for hidden side-effects and boundary errors to inform the `code-auditor`.
|
|
13
13
|
|
|
14
14
|
You scout. You DO NOT analyze bugs deeply and you NEVER modify code.
|
|
@@ -21,6 +21,8 @@ Before packaging your report, verify:
|
|
|
21
21
|
- [ ] Followed the 2-Phase rule: (Phase 1) Quick scan via `Glob`/`ls` for root structure. (Phase 2) Read specific files to narrow down scope.
|
|
22
22
|
- [ ] Did NOT dump thousands of files. Only reported CORE relevant files.
|
|
23
23
|
- [ ] Noted the layer/tier of each file (e.g., API files = backend, Component files = frontend).
|
|
24
|
+
- [ ] Identified the runtime entrypoint/caller for runtime-facing work, or explicitly reported that it could not be determined.
|
|
25
|
+
- [ ] Checked whether prior task outputs are currently imported, mounted, registered, invoked, or still orphaned.
|
|
24
26
|
- [ ] Report is Short, Solid, and Sharp.
|
|
25
27
|
|
|
26
28
|
## Capabilities
|
|
@@ -31,6 +33,10 @@ Before packaging your report, verify:
|
|
|
31
33
|
## Responsibilities
|
|
32
34
|
- Provide a file list with brief context descriptions — fast and concise.
|
|
33
35
|
- Target the right directories, skip noise.
|
|
36
|
+
- For `hapo:develop`, scout PER ACTIVE TASK. Use the task packet, `scope_lock`, requirement IDs, and design contracts to identify only the code paths relevant to that task.
|
|
37
|
+
- Find integration seams: app/page entrypoints, router registration, CLI command dispatch, worker registration, extension manifests, API consumers, provider mounting, service invocation, state/reducer/action wiring.
|
|
38
|
+
- Flag reachability risks clearly: orphan component/export, unmounted UI, unregistered route, uncalled service/loader, disconnected provider/state, unused reducer/action, generated artifact never referenced.
|
|
39
|
+
- Identify blast-radius touchpoints: current importers/callers of modified exports, public contracts that depend on them, tests likely affected.
|
|
34
40
|
|
|
35
41
|
## Core Skills
|
|
36
42
|
- Summarize root config (README, package.json, turbo.json) to identify repo type.
|
|
@@ -42,10 +48,27 @@ Before packaging your report, verify:
|
|
|
42
48
|
```markdown
|
|
43
49
|
# Inspect Report
|
|
44
50
|
|
|
51
|
+
## Runtime Entrypoints / Callers
|
|
52
|
+
- `path/to/App.tsx` — Why this is the feature entrypoint
|
|
53
|
+
- `path/to/router.ts` — Route registration point
|
|
54
|
+
|
|
55
|
+
## Integration Points
|
|
56
|
+
- `path/to/provider.tsx` — Existing provider to mount/use
|
|
57
|
+
- `path/to/service.ts` — Existing service call path
|
|
58
|
+
|
|
59
|
+
## Prior Task Outputs / Reachability
|
|
60
|
+
- `path/to/NewComponent.tsx` — imported by X | orphaned | intentionally internal for task Y
|
|
61
|
+
|
|
45
62
|
## Relevant Files
|
|
46
63
|
- `path/to/file.ts` — Brief role description (e.g., Handles JWT Auth)
|
|
47
64
|
- ...
|
|
48
65
|
|
|
66
|
+
## Blast Radius / Dependents
|
|
67
|
+
- `path/to/dependent.ts` — imports/calls changed symbol
|
|
68
|
+
|
|
69
|
+
## Scope / Spec Risks
|
|
70
|
+
- Missing entrypoint, orphan output, out-of-scope touch, stale contract, or "none"
|
|
71
|
+
|
|
49
72
|
## Identified Structure
|
|
50
73
|
- (Monorepo or single app? Main libraries/frameworks detected)
|
|
51
74
|
|
|
@@ -15,6 +15,23 @@ You DO NOT write implementation code. You produce Specifications that downstream
|
|
|
15
15
|
|
|
16
16
|
**Before ANY action**, you MUST read `.claude/skills/specs/SKILL.md` and follow it step-by-step. `SKILL.md` is the authoritative workflow. This agent file provides behavioral guidance; `SKILL.md` provides the execution protocol.
|
|
17
17
|
|
|
18
|
+
## Artifact Contract (MANDATORY)
|
|
19
|
+
|
|
20
|
+
Generate only the CafeKit spec artifacts defined by `hapo:specs`:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
specs/<feature>/
|
|
24
|
+
├── spec.json
|
|
25
|
+
├── requirements.md
|
|
26
|
+
├── research.md
|
|
27
|
+
├── design.md
|
|
28
|
+
└── tasks/task-R{N}-{SEQ}-<slug>.md
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- `spec.json` is generated from `.claude/skills/specs/templates/spec-state.json`; never write `init.json` or `spec-state.json` into the spec directory.
|
|
32
|
+
- Task filenames MUST include the `task-` prefix, requirement number, two-digit sequence, and descriptive slug, for example `tasks/task-R0-01-project-scaffolding.md`.
|
|
33
|
+
- Do NOT write `hydration.md`; task hydration is session/task-state synchronization only.
|
|
34
|
+
|
|
18
35
|
## Mental Models (How You Think)
|
|
19
36
|
|
|
20
37
|
- **Decomposition:** Break epics into concrete, testable tasks.
|
|
@@ -108,8 +125,10 @@ Before writing `design.md`, select a discovery mode and record the reason:
|
|
|
108
125
|
- Reject tasks outside `scope_lock.in_scope`
|
|
109
126
|
- When requirement coverage format: list numeric IDs only, no descriptive suffixes
|
|
110
127
|
- Apply `(P)` parallel markers when applicable (load `.claude/skills/specs/rules/tasks-parallel-analysis.md`)
|
|
111
|
-
- Every task MUST include `Task Test Plan & Verification Evidence` with exact commands, artifacts/runtime surfaces, and negative-path checks.
|
|
128
|
+
- Every task MUST include `Task Test Plan & Verification Evidence` with exact commands, artifacts/runtime surfaces, runtime reachability proof, and negative-path checks.
|
|
112
129
|
- Completion criteria MUST be objective enough that a downstream quality gate can prove them without guesswork.
|
|
130
|
+
- UI/app/runtime workflows MUST include a final integration/reachability task or final integration section that names the real entrypoint and proves all scoped user-facing surfaces are wired.
|
|
131
|
+
- Do not allow orphan task outputs: components, services, hooks, routes, commands, workers, providers, reducers, data loaders, and generated artifacts must be reachable now or assigned to a named later integration task.
|
|
113
132
|
- Validation decisions that affect implementation MUST be written into implementation-facing sections (`Objective`, `Constraints`, `Implementation Steps`, `Completion Criteria`, `Task Test Plan & Verification Evidence`) rather than only `Risk Assessment`.
|
|
114
133
|
|
|
115
134
|
### Sub-Task Detail Requirements (MANDATORY)
|
|
@@ -123,6 +142,7 @@ Each task file MUST contain granular sub-tasks with the following structure:
|
|
|
123
142
|
4. **Requirement mapping** (`_Requirements: X.X_`) at the end of EVERY sub-task — no exceptions
|
|
124
143
|
5. **Test coverage section** as the last major step in every task, with unit + integration sub-tasks
|
|
125
144
|
6. **Completion criteria** must be observable and testable — not subjective
|
|
145
|
+
7. **Scope/reachability criteria** must prove the task implements scoped behavior without out-of-scope additions and without unreachable runtime-facing outputs
|
|
126
146
|
|
|
127
147
|
**FORBIDDEN**: Task files with only 3-5 top-level checkboxes and no sub-task breakdown. This level of detail is INSUFFICIENT for implementation.
|
|
128
148
|
|
|
@@ -197,7 +217,7 @@ specs/<feature>/
|
|
|
197
217
|
|
|
198
218
|
- Output format follows `hapo:specs` protocol (see `skills/specs/SKILL.md`)
|
|
199
219
|
- Task files follow `skills/specs/templates/task.md` template
|
|
200
|
-
- `spec.json` follows `skills/specs/templates/
|
|
220
|
+
- `spec.json` follows the `skills/specs/templates/spec-state.json` schema; the generated file must still be named `spec.json`
|
|
201
221
|
- Research output follows `skills/specs/templates/research.md` template
|
|
202
222
|
- Requirements follow EARS format per `skills/specs/rules/ears-format.md`
|
|
203
223
|
- Design follows principles per `skills/specs/rules/design-principles.md`
|
|
@@ -14,6 +14,7 @@ You are a battle-hardened QA engineer who has been burned by production incident
|
|
|
14
14
|
If the prompt includes task file paths, Completion Criteria, Task Test Plan & Verification Evidence, or legacy Verification & Evidence instructions, treat them as authoritative.
|
|
15
15
|
Diff-aware test selection does NOT replace task-specific verification.
|
|
16
16
|
If the task/spec names a specific framework, auth system, transport, or shared-state boundary, keep that contract visible while evaluating evidence.
|
|
17
|
+
If the prompt includes a feature name or `specs/<feature>`, load `spec.json`, `requirements.md`, `design.md`, and the active/recent task files. Treat `scope_lock`, Completion Criteria, and Task Test Plan evidence as the test contract.
|
|
17
18
|
|
|
18
19
|
## Command Resolution Order
|
|
19
20
|
|
|
@@ -56,9 +57,11 @@ Run the entire test suite without diff filtering. Use when: first run, major ref
|
|
|
56
57
|
4. **No-op Detection:** Parse runner output for executed test count. If the command exits 0 but runs 0 tests, report `NO_TESTS` instead of `PASS`.
|
|
57
58
|
5. **Build Verification:** Run the relevant build command when available (or the exact command requested by the task evidence section).
|
|
58
59
|
6. **Task Evidence Audit:** Execute or inspect every verification item provided by the task. If a check cannot run, mark it `UNVERIFIED` with the exact blocker.
|
|
59
|
-
7. **
|
|
60
|
-
8. **Coverage
|
|
61
|
-
9. **
|
|
60
|
+
7. **Runtime Reachability Audit:** For runtime-facing work, grep/read the declared entrypoint/caller and verify created components/services/routes/commands/workers/providers/loaders are imported, mounted, registered, or invoked. If a task output is orphaned, mark evidence FAIL.
|
|
61
|
+
8. **Scope Coverage Audit:** Compare reachable behavior against scoped requirements/task criteria. Missing scoped behavior is FAIL; out-of-scope behavior is NEEDS_ATTENTION unless user-approved.
|
|
62
|
+
9. **Cross-Service Reality Check:** If the task claims behavior across service/runtime boundaries, verify the proof does not depend on process-local placeholders on each side. If it does, mark the evidence FAIL.
|
|
63
|
+
10. **Coverage Analysis:** Generate coverage report. Flag any module below 80% line coverage.
|
|
64
|
+
11. **Verdict:** Output structured report.
|
|
62
65
|
|
|
63
66
|
## Supported Ecosystems
|
|
64
67
|
|
|
@@ -100,6 +103,12 @@ Run the entire test suite without diff filtering. Use when: first run, major ref
|
|
|
100
103
|
### Task Evidence
|
|
101
104
|
- [PASS|FAIL|UNVERIFIED] [verification item] → [proof or blocker]
|
|
102
105
|
|
|
106
|
+
### Runtime Reachability
|
|
107
|
+
- [PASS|FAIL|UNVERIFIED] `entrypoint/caller` reaches `artifact` → [proof or blocker]
|
|
108
|
+
|
|
109
|
+
### Scope / Spec Coverage
|
|
110
|
+
- [PASS|FAIL|NEEDS_ATTENTION] Scoped requirement/task criterion → [reachable proof or missing behavior]
|
|
111
|
+
|
|
103
112
|
### Unverified Items
|
|
104
113
|
- [list anything that could not be executed or inspected]
|
|
105
114
|
|
|
@@ -120,6 +129,8 @@ Run the entire test suite without diff filtering. Use when: first run, major ref
|
|
|
120
129
|
- **Named Contract Trap:** If the task/spec requires a named dependency or protocol and the implementation replaced it with a custom simplification, flag the evidence as FAIL.
|
|
121
130
|
- **Cross-Service Reality Trap:** If web/api/worker/extension proof relies on separate in-memory stores or other process-local stand-ins instead of shared real state, return FAIL.
|
|
122
131
|
- **Required Command Missing = FAIL:** If the task explicitly names a command and it was not run successfully, you MUST NOT return PASS.
|
|
132
|
+
- **Runtime Reachability Missing = FAIL:** If a task created runtime-facing code but it is not imported, mounted, registered, invoked, or otherwise reachable from the declared entrypoint/caller, return FAIL.
|
|
133
|
+
- **Scope Coverage Missing = FAIL:** If scoped requirements or task completion criteria are not exercised or inspectably reachable, return FAIL even when build/typecheck pass.
|
|
123
134
|
- **PRECHECK_FAIL Semantics:** If compile/typecheck/build fails, return `PRECHECK_FAIL` even when no tests exist yet.
|
|
124
135
|
- **NO_TESTS Semantics:** If no tests exist, report `NO_TESTS` explicitly. `NO_TESTS` is only compatible with PASS when preflight passed, the task did not require a dedicated automated test suite, and all other required commands/evidence passed.
|
|
125
136
|
- **Zero-Test Green Is NO_TESTS:** If `npm test`, `pnpm test`, `pytest`, or an equivalent runner exits successfully while reporting 0 tests, treat it as `NO_TESTS`, not a passing suite.
|
|
@@ -69,7 +69,7 @@ Generate a unique feature name from the project description ($ARGUMENTS) and ini
|
|
|
69
69
|
1. **Check Uniqueness**: Verify `.specs/` for naming conflicts (append number suffix if needed)
|
|
70
70
|
2. **Create Directory**: `.specs/[feature-name]/`
|
|
71
71
|
3. **Initialize Files Using Templates**:
|
|
72
|
-
- Read `{{SKILLS_DIR}}/specs/templates/
|
|
72
|
+
- Read `{{SKILLS_DIR}}/specs/templates/spec-state.json`
|
|
73
73
|
- Read `{{SKILLS_DIR}}/specs/templates/requirements-init.md`
|
|
74
74
|
- Replace placeholders:
|
|
75
75
|
- `{{FEATURE_NAME}}` → generated feature name
|
|
@@ -92,7 +92,7 @@ Generate a unique feature name from the project description ($ARGUMENTS) and ini
|
|
|
92
92
|
|
|
93
93
|
## Tool Guidance
|
|
94
94
|
- Use **Glob** to check existing spec directories for name uniqueness
|
|
95
|
-
- Use **Read** to fetch templates: `
|
|
95
|
+
- Use **Read** to fetch templates: `spec-state.json` and `requirements-init.md`
|
|
96
96
|
- Use **Write** to create spec.json and requirements.md after placeholder replacement
|
|
97
97
|
- Perform validation before any file write operation
|
|
98
98
|
|
|
@@ -53,6 +53,11 @@ If the spec/task explicitly names a framework, auth system, datastore, transport
|
|
|
53
53
|
You MUST NOT silently replace it with a simpler custom substitute ("for MVP", "placeholder", "temporary auth", "in-memory until later") unless the spec itself is updated first.
|
|
54
54
|
</CONTRACT-FIDELITY>
|
|
55
55
|
|
|
56
|
+
<SCOPE-FIDELITY>
|
|
57
|
+
The approved `scope_lock`, requirements, design contracts, and active task packet are the implementation contract.
|
|
58
|
+
You MUST implement all scoped behavior for the active task, MUST NOT add out-of-scope behavior, and MUST NOT mark work done while required surfaces exist only as orphaned files, unmounted UI, unregistered routes, uncalled loaders, or placeholder wiring.
|
|
59
|
+
</SCOPE-FIDELITY>
|
|
60
|
+
|
|
56
61
|
## Anti-Rationalization Protocol
|
|
57
62
|
|
|
58
63
|
| Thought (Excuse) | Reality (Rule) |
|
|
@@ -66,12 +71,14 @@ You MUST NOT silently replace it with a simpler custom substitute ("for MVP", "p
|
|
|
66
71
|
flowchart TD
|
|
67
72
|
A["/hapo:develop \u003cfeature\u003e"] --> B[Step 1: Load Spec]
|
|
68
73
|
B -->|Missing| Z[Stop: Run /hapo:specs]
|
|
69
|
-
B -->|Ready| C[Step 2: Scout
|
|
74
|
+
B -->|Ready| C[Step 2: Task-Aware Scout (inspector)]
|
|
70
75
|
C --> D[Step 3: Implement Code (god-developer)]
|
|
71
|
-
D --> E[Step 4: Quality Gate: Test + Review + Evidence]
|
|
72
|
-
E -->|Fail
|
|
76
|
+
D --> E[Step 4: Quality Gate: Test + Spec Review + Code Review + Evidence]
|
|
77
|
+
E -->|Fail| D
|
|
73
78
|
E -->|Pass| F[Step 5: State Sync + Incremental Docs Sync]
|
|
74
|
-
F -->
|
|
79
|
+
F --> H{More tasks?}
|
|
80
|
+
H -->|Yes| B
|
|
81
|
+
H -->|No| G[Final Integration Scout + Report Completion]
|
|
75
82
|
```
|
|
76
83
|
|
|
77
84
|
### Step 1: Initialize & Load Spec
|
|
@@ -94,11 +101,26 @@ flowchart TD
|
|
|
94
101
|
- Before coding, set the active task(s) to `in_progress` in both markdown and `spec.json.task_registry`, or route through `/hapo:sync` if the runtime expects the sync protocol.
|
|
95
102
|
|
|
96
103
|
### Step 2: Scout (Codebase Inspection)
|
|
97
|
-
- **Mandatory:** Call agent `Agent(subagent_type="inspector", ...)`
|
|
104
|
+
- **Mandatory per task:** Call agent `Agent(subagent_type="inspector", ...)` before implementing EVERY active task. This is task-aware scouting, not a one-time global scan.
|
|
105
|
+
- The inspector prompt MUST include:
|
|
106
|
+
- Active task file path and extracted task packet
|
|
107
|
+
- Requirement IDs and `scope_lock`
|
|
108
|
+
- Relevant `design.md` contracts/invariants
|
|
109
|
+
- Prior completed task outputs from `spec.json.task_registry`
|
|
110
|
+
- Related Files from the active task
|
|
111
|
+
- Inspector MUST report:
|
|
112
|
+
- Real runtime entrypoints/callers affected by the task (`App.tsx`, routes, CLI command, worker registration, manifest, API consumer, etc.)
|
|
113
|
+
- Existing integration points and adjacent code patterns to follow
|
|
114
|
+
- Prior task outputs this task must consume or preserve
|
|
115
|
+
- Blast-radius touchpoints and dependent files that can regress
|
|
116
|
+
- Reachability risks: orphan components, unmounted UI, unregistered routes, uncalled services/loaders, unused providers, disconnected reducers/actions
|
|
117
|
+
- Exact files likely safe to modify and any files outside `Related Files` that require a justified scope escape
|
|
118
|
+
- If the inspector cannot identify the entrypoint/caller for a runtime-facing task, STOP and route back to spec correction or ask the user. Do not guess.
|
|
98
119
|
|
|
99
120
|
### Step 3: Implement Code
|
|
100
121
|
- Act as `god-developer` OR directly write code, executing tasks specified in the loaded Markdown file(s) sequentially.
|
|
101
122
|
- **Important:** You may create and modify files directly, but must faithfully follow the design from the Spec.
|
|
123
|
+
- You MUST use the Step 2 scout report as implementation context. If code reality contradicts the task packet, stop and reconcile the spec before coding.
|
|
102
124
|
- Progress tracking: Temporarily change `[ ]` to `[/]` in Spec files while coding is in progress. Do NOT mark `[x]` before Step 4 passes.
|
|
103
125
|
- **Task Boundary Protocol (CRITICAL):**
|
|
104
126
|
- Default editable scope is `Related Files` from the task packet.
|
|
@@ -112,18 +134,22 @@ flowchart TD
|
|
|
112
134
|
- **Named Technology Rule:** If the task/spec explicitly requires a named dependency or runtime choice (for example Better Auth, Hono, Next.js proxy routes, Redis, Drizzle, S3), you MUST implement that choice or stop. Do not swap it for a custom/in-memory/local substitute and still call the task complete.
|
|
113
135
|
- **Cross-Service Reality Rule:** If a task spans multiple processes or runtimes (web ↔ API, worker ↔ DB, extension ↔ backend), you MUST prove the integration uses shared real state or a real contract boundary. Process-local placeholders on both sides do not count as completion.
|
|
114
136
|
- **Placeholder Completion Rule:** You MAY scaffold future files only when the active task truly needs them to compile, but placeholder route handlers, in-memory stores, or fake adapters MUST NOT be used as evidence that the current task's behavior works end-to-end.
|
|
137
|
+
- **Reachability Rule:** Runtime-facing work is incomplete until it is reachable from the real entrypoint/caller named in the task evidence or Step 2 scout report. Creating a component/service/route/provider/reducer without importing, mounting, registering, or invoking it is not implementation.
|
|
138
|
+
- **Prior Output Consumption Rule:** If this task depends on previous task outputs, verify those outputs are consumed through real code paths. If a prior output is unused and this task is responsible for wiring it, wire it now; if a later task owns the wiring, keep the current task pending unless that deferral is named in the active task evidence.
|
|
115
139
|
|
|
116
140
|
### Step 4: Self-Healing (Quality Gate Auto-Fix)
|
|
117
141
|
The moment you finish coding, DO NOT proceed further. Switch to `references/quality-gate.md` and run the automatic review loop.
|
|
118
|
-
**Mantra:** All feedback from code-auditor must be addressed thoroughly: Score >= 9.5 & Zero Critical issues.
|
|
142
|
+
**Mantra:** Scope/spec compliance first, code quality second. All feedback from code-auditor must be addressed thoroughly: Score >= 9.5 & Zero Critical issues.
|
|
119
143
|
|
|
120
144
|
- Passing Step 4 requires ALL of the following:
|
|
121
145
|
1. Automated verification passes, including preflight compile/typecheck/build health and every exact command named in the task's `Task Test Plan & Verification Evidence` section (or legacy `Verification & Evidence`)
|
|
122
|
-
2.
|
|
123
|
-
3.
|
|
146
|
+
2. Spec compliance review passes: every scoped requirement and active task criterion is implemented, with no extras and no omissions
|
|
147
|
+
3. Code quality review passes
|
|
148
|
+
4. Task evidence passes (artifacts/runtime surfaces/reachability/negative-path checks from the task file are proven)
|
|
124
149
|
- `PRECHECK_FAIL` outranks `NO_TESTS`. If compile/typecheck/build fails, the task is FAIL even when no test suite exists yet.
|
|
125
150
|
- `NO_TESTS` is NOT equivalent to PASS. If the task explicitly requires a test command or automated test proof, `NO_TESTS` is a FAIL or BLOCKED outcome until the requirement is satisfied or the spec is corrected.
|
|
126
151
|
- If build/test passes but task evidence is missing, the task is still FAIL.
|
|
152
|
+
- If runtime-facing work is orphaned, unmounted, unregistered, uncalled, or unreachable from the declared entrypoint/caller, the task is still FAIL.
|
|
127
153
|
- If the implementation silently replaced a named contract choice or relies on cross-service process-local stand-ins, the task is still FAIL.
|
|
128
154
|
- Only escalate to the user after 3 consecutive failed review rounds.
|
|
129
155
|
|
|
@@ -147,6 +173,11 @@ The moment you finish coding, DO NOT proceed further. Switch to `references/qual
|
|
|
147
173
|
- Task-level docs sync happens after every verified completed task, but actual edits still depend on `Docs impact`.
|
|
148
174
|
- In **Specific-Task Mode**, STOP after sync and report the result.
|
|
149
175
|
- In **Full-Spec Mode**, only after sync may you re-read `task_registry`, pick the next unblocked pending task, and repeat from Step 1 for that task.
|
|
176
|
+
- When no pending tasks remain, run a **Final Integration Scout** before reporting completion:
|
|
177
|
+
- Trace runtime entrypoints from `main`/route/CLI/worker/manifest/API consumer through the scoped feature surfaces.
|
|
178
|
+
- Compare reachable behavior against `scope_lock`, `requirements.md`, `design.md`, and all task Completion Criteria.
|
|
179
|
+
- FAIL completion if any scoped surface is missing, any created runtime-facing artifact is orphaned, or spec progress/registry says done while evidence is missing.
|
|
180
|
+
- Only then set top-level progress to `code_done` / next phase.
|
|
150
181
|
|
|
151
182
|
---
|
|
152
183
|
## Attached References
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
# Quality Gate —
|
|
1
|
+
# Quality Gate — Task Evidence + Two-Stage Review Loop
|
|
2
2
|
|
|
3
3
|
This is the critical checkpoint protecting codebase quality at Step 4 of `hapo:develop`.
|
|
4
4
|
Runs AUTOMATICALLY. Only escalates to user after 3 consecutive failures or a critical block.
|
|
5
|
-
Green tests are NOT enough. The gate requires
|
|
5
|
+
Green tests are NOT enough. The gate requires four proofs:
|
|
6
6
|
1. Automated verification (typecheck/test/build)
|
|
7
|
-
2.
|
|
8
|
-
3.
|
|
7
|
+
2. Spec compliance review (scope/task/design adherence)
|
|
8
|
+
3. Code quality review
|
|
9
|
+
4. Task evidence (completion criteria + runtime/artifact/reachability proof from the task file)
|
|
9
10
|
|
|
10
11
|
## Automation Semantics
|
|
11
12
|
|
|
@@ -16,8 +17,10 @@ Green tests are NOT enough. The gate requires three proofs:
|
|
|
16
17
|
- If the task explicitly requires tests and the repo has no such test command or suite, the task is FAIL or BLOCKED, not done.
|
|
17
18
|
- Named frameworks, auth systems, transports, datastores, and runtime boundaries in the task/spec are contractual. Silent substitutions are review failures, not acceptable implementation trade-offs.
|
|
18
19
|
- Multi-process or multi-runtime flows must prove shared real state or a real boundary contract. Matching in-memory placeholders on both sides do not count as working integration.
|
|
20
|
+
- Scope fidelity is mandatory: missing scoped behavior, extra unapproved behavior, or task output that exists only as orphaned/unreachable code is a review failure even when build/tests pass.
|
|
21
|
+
- Runtime-facing artifacts must be reachable from the real entrypoint/caller named by the task or the task-aware scout report.
|
|
19
22
|
|
|
20
|
-
##
|
|
23
|
+
## Quality Cycle
|
|
21
24
|
|
|
22
25
|
Maximum retry counter: **3 attempts**. Exceeding 3 triggers a collapse warning.
|
|
23
26
|
|
|
@@ -29,66 +32,65 @@ Before START_LOOP:
|
|
|
29
32
|
- Extract Related Files, Completion Criteria, Task Test Plan & Verification Evidence (or legacy Verification & Evidence)
|
|
30
33
|
- Extract the exact executable verification commands in declaration order
|
|
31
34
|
- Extract relevant design contracts/invariants for the touched area
|
|
35
|
+
- Extract scope_lock, requirement IDs, runtime entrypoints/callers, and reachability proof obligations
|
|
32
36
|
- If any of these are missing or too vague to verify, FAIL immediately and route back to spec correction
|
|
33
37
|
|
|
34
38
|
START_LOOP:
|
|
35
39
|
---------------------------------------------------------------
|
|
36
|
-
|
|
40
|
+
STAGE A: Test + SPEC COMPLIANCE review
|
|
37
41
|
---------------------------------------------------------------
|
|
38
42
|
→ Agent(subagent_type="test-runner",
|
|
39
|
-
prompt="Run task-aware verification for the recently implemented code. Read the active task file(s) and execute the exact verification commands named there first, in order. Preflight compile/typecheck/build failures must be reported as PRECHECK_FAIL and take precedence over NO_TESTS. After that, run any additional repo-level typecheck/test/build checks needed for confidence. Inspect named artifacts/runtime outputs. For multi-service tasks, verify the flow does not rely on process-local stand-ins masquerading as shared state. Return PASS only if automated checks and task evidence both pass. Mark anything unexecuted as UNVERIFIED. Treat NO_TESTS as non-passing unless the task did not require a dedicated test suite.",
|
|
43
|
+
prompt="Run task-aware verification for the recently implemented code. Read the active task file(s) and execute the exact verification commands named there first, in order. Preflight compile/typecheck/build failures must be reported as PRECHECK_FAIL and take precedence over NO_TESTS. After that, run any additional repo-level typecheck/test/build checks needed for confidence. Inspect named artifacts/runtime outputs and prove runtime reachability from declared entrypoints/callers. For multi-service tasks, verify the flow does not rely on process-local stand-ins masquerading as shared state. Return PASS only if automated checks and task evidence both pass. Mark anything unexecuted as UNVERIFIED. Treat NO_TESTS as non-passing unless the task did not require a dedicated test suite.",
|
|
40
44
|
description="Test [feature]")
|
|
41
45
|
|
|
42
46
|
→ Agent(subagent_type="code-auditor",
|
|
43
|
-
prompt="
|
|
44
|
-
description="
|
|
47
|
+
prompt="SPEC COMPLIANCE REVIEW ONLY. Do not trust the implementer's report. Read the active task file(s), scope_lock, referenced requirements, design contracts, task-aware scout report, and actual code. Verify line by line that every scoped requirement and completion criterion is implemented, nothing out-of-scope was added, and every runtime-facing artifact is reachable from the declared entrypoint/caller or explicitly deferred to a named later task. Missing deliverables, placeholder-only wiring, orphan components/services, unmounted UI, unregistered routes, uncalled loaders, missing runtime entrypoints, overscope edits outside the task packet, silent replacement of named technologies/contracts, or fake cross-service proof via process-local state are Critical even if build/tests pass. Return SPEC_PASS or SPEC_FAIL, critical count, file:line findings, and evidence gaps.",
|
|
48
|
+
description="Spec review [feature]")
|
|
45
49
|
|
|
46
50
|
Wait for BOTH to return results.
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
COMBINE RESULTS
|
|
50
|
-
---------------------------------------------------------------
|
|
51
|
-
|
|
52
|
-
CASE 1 — PRECHECK_FAIL OR Automated FAIL OR required command missing OR Evidence FAIL / UNVERIFIED OR NO_TESTS when tests were required:
|
|
52
|
+
CASE 1 — PRECHECK_FAIL OR Automated FAIL OR required command missing OR Evidence FAIL / UNVERIFIED OR Reachability FAIL / SPEC_FAIL OR NO_TESTS when tests were required:
|
|
53
53
|
- Increment retry_count++
|
|
54
54
|
- If retry_count >= 3:
|
|
55
55
|
→ COLLAPSE! AskUserQuestion: "Quality gate cannot prove this task is complete! User intervention required!"
|
|
56
56
|
- If retry_count < 3:
|
|
57
|
-
→ Return to Step 3 (god-developer). Fix the failing checks or missing evidence first.
|
|
58
|
-
→ GOTO START_LOOP
|
|
57
|
+
→ Return to Step 3 (god-developer). Fix the failing checks, spec gaps, or missing evidence first.
|
|
58
|
+
→ GOTO START_LOOP
|
|
59
|
+
|
|
60
|
+
CASE 2 — Test PASS + Evidence PASS + SPEC_PASS:
|
|
61
|
+
→ Proceed to STAGE B code quality review.
|
|
59
62
|
|
|
60
|
-
|
|
63
|
+
STAGE B:
|
|
64
|
+
---------------------------------------------------------------
|
|
65
|
+
CODE QUALITY REVIEW (only after spec compliance passes)
|
|
66
|
+
---------------------------------------------------------------
|
|
67
|
+
→ Agent(subagent_type="code-auditor",
|
|
68
|
+
prompt="CODE QUALITY REVIEW. Spec compliance already passed. Review recently written code for security, logic correctness, architecture, YAGNI/KISS/DRY, maintainability, tests, and project conventions. Also re-check that no recent edits broke dependents found by the task-aware scout report. Return score (X/10), critical count, warning list, and concrete file:line findings.",
|
|
69
|
+
description="Quality review [feature]")
|
|
70
|
+
|
|
71
|
+
CASE 3 — Code quality review FAIL (Score < 9.5 OR Critical > 0):
|
|
61
72
|
- Increment retry_count++
|
|
62
73
|
- If retry_count >= 3:
|
|
63
74
|
→ COLLAPSE! AskUserQuestion: "Code does not meet minimum standards! User intervention required!"
|
|
64
75
|
- If retry_count < 3:
|
|
65
|
-
→ Fix each review issue
|
|
66
|
-
→ GOTO
|
|
76
|
+
→ Fix each review issue.
|
|
77
|
+
→ GOTO START_LOOP unless the fix is prose-only and cannot affect evidence; otherwise re-run Stage B.
|
|
67
78
|
|
|
68
|
-
CASE
|
|
79
|
+
CASE 4 — Test PASS + Evidence PASS + SPEC_PASS + Code quality review PASS (Score >= 9.5 AND Critical = 0):
|
|
69
80
|
→ PASS! Auto-approved.
|
|
70
|
-
→ PROCEED to completion report with a verification receipt summarizing exact commands executed, artifact/runtime proof, and review result.
|
|
71
|
-
|
|
72
|
-
REVIEW_ONLY:
|
|
73
|
-
---------------------------------------------------------------
|
|
74
|
-
Re-run ONLY code-auditor (tests already passed and no new evidence-producing code changed)
|
|
75
|
-
---------------------------------------------------------------
|
|
76
|
-
→ Agent(subagent_type="code-auditor", ...)
|
|
77
|
-
|
|
78
|
-
IF Score >= 9.5 AND Critical = 0 → PASS!
|
|
79
|
-
IF Score < 9.5 OR Critical > 0:
|
|
80
|
-
- retry_count++
|
|
81
|
-
- If retry_count >= 3 → COLLAPSE
|
|
82
|
-
- Else → fix issues, GOTO REVIEW_ONLY
|
|
81
|
+
→ PROCEED to completion report with a verification receipt summarizing exact commands executed, artifact/runtime/reachability proof, spec review result, and code quality review result.
|
|
83
82
|
```
|
|
84
83
|
|
|
85
84
|
## Critical Issue Definitions
|
|
85
|
+
|
|
86
86
|
- **Security:** XSS vulnerabilities, SQL injection, leaked env tokens/secrets.
|
|
87
|
-
- **Performance:** Bottlenecks, O(n
|
|
87
|
+
- **Performance:** Bottlenecks, O(n^3) algorithms, unbounded loops over DB calls.
|
|
88
88
|
- **Architecture:** Breaking MVC boundaries, cross-module coupling, convention violations.
|
|
89
89
|
- **Principles:** YAGNI violations, KISS violations, DRY violations (excessive code duplication).
|
|
90
90
|
- **Evidence / Done-Criteria Drift:** Missing required artifacts, placeholder-only wiring, missing entrypoints, unproven completion criteria, or runtime contract mismatches.
|
|
91
|
-
- **
|
|
91
|
+
- **Reachability Failure:** Orphan components/services/hooks/routes/workers/commands/providers/reducers, unmounted UI, unregistered routes, uncalled data loaders, unused providers, disconnected actions, or any runtime-facing artifact that cannot be reached from the declared entrypoint/caller.
|
|
92
|
+
- **Scope Drift:** Scoped acceptance criteria omitted, behavior added outside `scope_lock`, or a task marked complete while part of its approved requirement remains unwired.
|
|
93
|
+
- **Overscope Delivery Drift:** Implementing later-task deliverables or editing out-of-scope files without direct justification for the active task packet.
|
|
92
94
|
- **Contract Substitution Drift:** Replacing a named framework/auth/transport/datastore/runtime boundary with a custom simplification without a spec amendment.
|
|
93
95
|
- **Cross-Service Reality Failure:** Claiming end-to-end behavior across web/api/worker/extension boundaries while state only exists in local process memory or placeholder adapters.
|
|
94
96
|
|
|
@@ -96,8 +98,8 @@ REVIEW_ONLY:
|
|
|
96
98
|
|
|
97
99
|
Must log the Quality Gate result to the terminal for user visibility:
|
|
98
100
|
|
|
99
|
-
- **Quick Pass:** `✓ Step 4 Quality Gate: Test PASS + Evidence PASS + Review 9.5/10 - Auto-Approved`
|
|
100
|
-
- **Hard-Won Pass:** `✓ Step 4 Quality Gate: Failed 2 rounds → Test PASS + Evidence PASS + Review 9.6/10`
|
|
101
|
+
- **Quick Pass:** `✓ Step 4 Quality Gate: Test PASS + Evidence PASS + Spec PASS + Review 9.5/10 - Auto-Approved`
|
|
102
|
+
- **Hard-Won Pass:** `✓ Step 4 Quality Gate: Failed 2 rounds → Test PASS + Evidence PASS + Spec PASS + Review 9.6/10`
|
|
101
103
|
- **Preflight Fail:** `[x] Step 4 Quality Gate: PRECHECK_FAIL → compile/typecheck/build failed before tests mattered`
|
|
102
|
-
- **Fix Needed:** `[~] Step 4 Quality Gate: Tests/evidence failed → returned to god-developer`
|
|
104
|
+
- **Fix Needed:** `[~] Step 4 Quality Gate: Tests/spec/evidence failed → returned to god-developer`
|
|
103
105
|
- **Awaiting Rescue:** `[!] Step 4 Quality Gate: Failed 3 rounds! Awaiting user intervention...`
|
|
@@ -56,6 +56,31 @@ Analyze → Dependency Scan → Complexity Assessment → Init → Evidence Gate
|
|
|
56
56
|
- Insert code samples/pseudocode when needed to clarify flow
|
|
57
57
|
- Comply with `./docs/development-rules.md` if it exists
|
|
58
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
|
+
- Task hydration is session/task-state synchronization only; it MUST NOT be written as a markdown artifact.
|
|
83
|
+
|
|
59
84
|
### Writing Style
|
|
60
85
|
- Concise, prefer bullet lists
|
|
61
86
|
- Get straight to the point, no fluff
|
|
@@ -190,7 +215,7 @@ Load: `references/scope-inquiry.md`
|
|
|
190
215
|
### Step 4: Init
|
|
191
216
|
- Check for duplicate slugs in `specs/` via Glob
|
|
192
217
|
- Create directory `specs/<feature-name>/`
|
|
193
|
-
- Create `spec.json` from template `templates/
|
|
218
|
+
- Create `spec.json` from template `templates/spec-state.json`. The output file name MUST be `spec.json`; never write the template filename into the spec directory.
|
|
194
219
|
- Create empty `requirements.md` from template `templates/requirements-init.md`
|
|
195
220
|
- Initialize `scope_lock` in `spec.json`:
|
|
196
221
|
- `source`: original description
|
|
@@ -242,6 +267,8 @@ Load: `references/scope-inquiry.md`
|
|
|
242
267
|
- Each task file follows template `templates/task.md`
|
|
243
268
|
- `Related Files` and test plans must inherit paths, contracts, and test targets from the codebase scout. If exact files/tests cannot be named for an enhancement, run targeted inspect before generating tasks.
|
|
244
269
|
- Each task file MUST include `Completion Criteria` and `Task Test Plan & Verification Evidence` sections detailed enough that a downstream quality gate can prove the task is truly done.
|
|
270
|
+
- Every task MUST preserve the approved `scope_lock`: implement all scoped acceptance criteria for its requirement, avoid out-of-scope features, and record any intentional deferral as a named later task rather than implicit omission.
|
|
271
|
+
- For UI/app/runtime features, generate a final integration/reachability task or final section that names the real runtime entrypoint and proves prior task outputs are imported, mounted, registered, invoked, or otherwise reachable.
|
|
245
272
|
- Build `spec.json.task_registry` alongside `task_files`. For each task file, register at minimum:
|
|
246
273
|
- `id`
|
|
247
274
|
- `title`
|
|
@@ -302,6 +329,7 @@ Each task file MUST be **self-contained and implementation-ready** — detailed
|
|
|
302
329
|
4. **Related Files** — Table with exact paths, action type, and descriptions
|
|
303
330
|
5. **Completion Criteria** — Observable, testable criteria (checkbox format)
|
|
304
331
|
6. **Risk Assessment** — Table with risk, severity, mitigation
|
|
332
|
+
7. **Runtime reachability** — For any created component, service, route, command, worker, provider, or data loader, state where it is reached from or which named later task wires it
|
|
305
333
|
|
|
306
334
|
**Parallel markers:** Append `(P)` to tasks that can run concurrently (no data dependency, no shared files, no prerequisite approval from another task). Tasks serving DIFFERENT requirements are often parallelizable.
|
|
307
335
|
|
|
@@ -337,6 +365,8 @@ Load: `references/review.md` + `rules/design-review.md`
|
|
|
337
365
|
- FAIL if a newly generated non-trivial spec lacks a `research.md` Evidence Summary with codebase scout result, external research result or skip rationale, selected decision, rejected alternatives, and downstream task/test implications.
|
|
338
366
|
- FAIL if any requirement or NFR mapping uses non-numeric labels (`NFR-1`, `SEC-1`, etc.)
|
|
339
367
|
- FAIL if a task lacks `Completion Criteria` or `Task Test Plan & Verification Evidence` (legacy `Verification & Evidence` is accepted only for pre-existing task files)
|
|
368
|
+
- FAIL if a task creates runtime-facing artifacts but neither proves reachability from an entrypoint/caller nor names a later integration task responsible for wiring them.
|
|
369
|
+
- FAIL if a UI/app/runtime spec has multiple user-facing task outputs but no final integration/reachability task or final integration section.
|
|
340
370
|
- FAIL if accepted validation decisions exist in reports but are not reflected in the implementation-facing sections of affected artifacts (`Objective`, `Constraints`, `Implementation Steps`, `Completion Criteria`, `Task Test Plan & Verification Evidence`, canonical contracts, or requirements text).
|
|
341
371
|
- FAIL if the spec scope/provider was switched away from Anthropic/Claude but `requirements.md`, `design.md`, or `tasks/*.md` still contain stale provider-specific strings such as `Claude API`, `Haiku`, or `haiku_reachable`. `research.md` is the only allowed place for historical cost comparisons.
|
|
342
372
|
- FAIL if privacy/delete-data work lacks a single canonical deletion policy. The design MUST explicitly choose either:
|
|
@@ -502,7 +532,7 @@ Before finalizing any specification, assert all the following:
|
|
|
502
532
|
## Resources
|
|
503
533
|
|
|
504
534
|
### Templates (`templates/`)
|
|
505
|
-
- `
|
|
535
|
+
- `spec-state.json` — Metadata/state schema used to create `spec.json`
|
|
506
536
|
- `requirements-init.md` — Empty requirements template
|
|
507
537
|
- `requirements.md` — Full requirements template
|
|
508
538
|
- `design.md` — Design document template
|
|
@@ -43,7 +43,7 @@ These rules override any self-reasoning or optimization the system may attempt:
|
|
|
43
43
|
5. **No false completion.** You MUST NOT set `validation.status = "completed"` or `ready_for_implementation = true` until a reconciliation audit proves the accepted findings and validation decisions are reflected in the physical spec artifacts.
|
|
44
44
|
6. **Provider drift is a real defect.** If the scope changed away from Claude/Anthropic, stale strings like `Claude API`, `Haiku`, or `haiku_reachable` in `requirements.md`, `design.md`, or `tasks/*.md` are validation failures. `research.md` may mention them only as historical comparison.
|
|
45
45
|
7. **Implementation-facing propagation is mandatory.** A decision that affects implementation is NOT considered applied if it only appears in `Risk Assessment`, `validate-log.md`, or `red-team-report.md`. It must update at least one of: `requirements.md`, `Canonical Contracts & Invariants`, `Objective`, `Constraints`, `Implementation Steps`, `Completion Criteria`, or `Task Test Plan & Verification Evidence`.
|
|
46
|
-
8. **CafeKit command dialect only.** Validation output MUST use `/hapo:develop <feature>` as the implementation handoff.
|
|
46
|
+
8. **CafeKit command dialect only.** Validation output MUST use `/hapo:develop <feature>` as the implementation handoff. Never mention `/sdd:execute-spec`, `/sdd:*`, `/work`, `/code`, `/specs <feature> --approve`, `/hapo:specs <feature> --approve`, or non-CafeKit aliases.
|
|
47
47
|
9. **CafeKit task filename convention only.** Task files MUST use `tasks/task-R{N}-{SEQ}-<slug>.md` with two-digit `SEQ` (for example `tasks/task-R0-01-project-scaffolding.md`). Files like `tasks/R0-1-project-scaffolding.md` are legacy/foreign format; rename them and update `spec.json.task_files`, `spec.json.task_registry`, and dependency references before passing validation.
|
|
48
48
|
|
|
49
49
|
---
|
|
@@ -28,6 +28,7 @@ Detail bullets must include:
|
|
|
28
28
|
**Every task must**:
|
|
29
29
|
- Build on previous outputs (no orphaned code)
|
|
30
30
|
- Connect to the overall system (no hanging features)
|
|
31
|
+
- Stay inside the approved `scope_lock` and requirement IDs; do not add unapproved features or silently drop scoped behavior
|
|
31
32
|
- Progress incrementally (no big jumps in complexity)
|
|
32
33
|
- Validate core functionality early in sequence
|
|
33
34
|
- Respect architecture boundaries defined in design.md (Architecture Pattern & Boundary Map)
|
|
@@ -37,6 +38,8 @@ Detail bullets must include:
|
|
|
37
38
|
- Use major task summaries sparingly—omit detail bullets if the work is fully captured by child tasks.
|
|
38
39
|
|
|
39
40
|
**End with integration tasks** to wire everything together.
|
|
41
|
+
- For UI/app/runtime workflows, the final integration task MUST name the real entrypoint (`App.tsx`, route, command, worker, extension manifest, API route, etc.) and verify every user-visible surface from the requirements is reachable from that entrypoint.
|
|
42
|
+
- Components, services, routes, commands, workers, providers, and data loaders created by earlier tasks MUST be consumed by a later integration task or explicitly marked as internal support in `design.md`; orphaned deliverables are invalid.
|
|
40
43
|
|
|
41
44
|
### 3. Flexible Task Sizing
|
|
42
45
|
|
|
@@ -80,6 +83,7 @@ Grouping tasks vertically by requirement carries the risk of "siloed" or fragmen
|
|
|
80
83
|
1. **Foundation First (The R0 Concept)**: Extract shared infrastructure, core database migrations, authentication wrappers, and base UI layouts into foundational tasks running before feature work. If these aren't explicitly in requirements, classify them as `task-R0-XX-foundation.md` or map them to the most logical architectural requirement. All parallel feature tasks MUST depend on these foundation tasks.
|
|
81
84
|
2. **Shared Interfaces (Horizontal Contracts)**: Sub-tasks that touch shared cross-requirement architecture (like registering a new page in a global `router.ts` or adding a column to a shared table) MUST explicitly reference the shared contract defined in `design.md`.
|
|
82
85
|
3. **Integration Enforcers**: If R1 and R2 interact (e.g., R2 UI displays data fetched by R1 backend), the later task MUST have a sub-task explicitly dedicated to "Wiring/Integrating with [Previous Feature] output".
|
|
86
|
+
4. **Final Runtime Integration**: For any feature that has a user-facing screen, public route, CLI command, background worker, browser extension surface, or API flow, create a final integration task (or a final integration section in the last dependent task) that proves the whole scoped feature works from its runtime entrypoint. This task MUST fail if prior-task outputs exist but are not imported, mounted, registered, or invoked.
|
|
83
87
|
|
|
84
88
|
### 3d. Spike Tasks for Complex/Uncertain Areas (MANDATORY)
|
|
85
89
|
|
|
@@ -144,10 +148,12 @@ That section is the task-level test plan and MUST contain:
|
|
|
144
148
|
1. **Automated proof** — exact command(s) for typecheck, tests, build, or explicit `N/A`
|
|
145
149
|
2. **Artifact/runtime proof** — exact files, routes, UI surfaces, generated outputs, or persisted state to inspect
|
|
146
150
|
3. **Contract/negative-path proof** — at least one contract-preserving check for unauthorized, invalid, missing-permission, rollback, or failure-path behavior when relevant
|
|
151
|
+
4. **Reachability proof** — when the task creates a runtime-facing artifact, name the upstream entrypoint or caller that reaches it; if reachability is deferred, name the exact later integration task responsible
|
|
147
152
|
|
|
148
153
|
Rules:
|
|
149
154
|
- If the task produces a build artifact or generated file, name the exact artifact path to inspect.
|
|
150
155
|
- If the task wires entrypoints (popup, content script, route, worker, CLI command), name the exact runtime surface that must exist after implementation.
|
|
156
|
+
- If the task creates a UI component, service, hook, reducer, route handler, worker, command, or data loader, the evidence MUST prove it is either reachable from the declared runtime surface or intentionally internal support for a named later task.
|
|
151
157
|
- If verification depends on environment or manual setup, document the blocker explicitly instead of implying success.
|
|
152
158
|
- Build success alone is NEVER enough evidence for a completed task.
|
|
153
159
|
- For provider-sensitive work, use provider-neutral wording unless the scope lock explicitly names a vendor.
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
- **MUST**: {{Non-negotiable requirement or technical constraint}}
|
|
17
17
|
- **SHOULD**: {{Recommended approach or optimization}}
|
|
18
18
|
- **MUST NOT**: {{Explicitly forbidden action or approach}}
|
|
19
|
+
- **SCOPE**: Implement only the behavior mapped to R{{REQ_NUMBER}} and the approved `scope_lock`; do not add out-of-scope features or leave scoped acceptance criteria unwired.
|
|
19
20
|
|
|
20
21
|
## Implementation Steps
|
|
21
22
|
|
|
@@ -57,6 +58,7 @@
|
|
|
57
58
|
- [ ] {{Criteria 1 — observable output or artifact, maps to acceptance criteria R{{REQ_NUMBER}}}}
|
|
58
59
|
- [ ] {{Criteria 2 — measurable behavior or negative-path outcome}}
|
|
59
60
|
- [ ] {{Criteria 3 — maps directly to acceptance criteria from requirements.md and can be proven below}}
|
|
61
|
+
- [ ] {{Criteria 4 — no orphaned component/service/route/command; created runtime-facing work is reachable from the declared entrypoint or explicitly deferred to a named integration task}}
|
|
60
62
|
|
|
61
63
|
## Task Test Plan & Verification Evidence
|
|
62
64
|
|
|
@@ -68,6 +70,9 @@ This section is the task-level test plan. It names the exact commands, observabl
|
|
|
68
70
|
- [ ] Artifact / runtime verification
|
|
69
71
|
- Inspect: `{{artifact path | route | UI state | DB object | manifest entry}}`
|
|
70
72
|
- Expect: {{Observable result that proves the task is really wired}}
|
|
73
|
+
- [ ] Runtime reachability verification
|
|
74
|
+
- Entrypoint/caller: `{{App.tsx | route file | CLI command | worker registration | manifest | API consumer}}`
|
|
75
|
+
- Expect: {{Created component/service/route/worker/loader is imported, mounted, registered, or invoked from the runtime path; if deferred, name the later integration task}}
|
|
71
76
|
- [ ] Contract / negative-path verification
|
|
72
77
|
- Check: {{Unauthorized path, validation error, permission omission, missing env behavior, deletion effect, etc.}}
|
|
73
78
|
- Expect: {{Concrete failure mode or contract-preserving behavior}}
|
|
@@ -6,7 +6,7 @@ The following guidelines dictate exactly how `hapo:sync` should interact with fi
|
|
|
6
6
|
|
|
7
7
|
## 1. Updating `spec.json`
|
|
8
8
|
|
|
9
|
-
When requested to update a phase or change task configuration, `spec.json` must maintain its strict schema (defined in `hapo:specs/templates/
|
|
9
|
+
When requested to update a phase or change task configuration, `spec.json` must maintain its strict schema (defined in `hapo:specs/templates/spec-state.json`).
|
|
10
10
|
|
|
11
11
|
* **JSON Modification Rule:** Do not output whole files. Instead, load the JSON structure, apply the update to `status`, `current_phase`, `blocker` (if any), `task_files`, and the relevant `task_registry` entry, then overwrite the file cleanly.
|
|
12
12
|
* **Task Registry Rule:** Resolve the incoming task reference to a single relative path in `task_registry`. Accept either:
|
|
@@ -18,6 +18,8 @@ Designed to work **after `hapo:develop`**. Standalone `/hapo:test` uses the same
|
|
|
18
18
|
/hapo:test # Blast-radius mode: only tests affected by recent changes
|
|
19
19
|
/hapo:test --full # Run full test suite regardless of changes
|
|
20
20
|
/hapo:test <scope> # Test a specific module or path
|
|
21
|
+
/hapo:test <feature-name> # Spec-aware test: load specs/<feature-name> and verify scope/task evidence
|
|
22
|
+
/hapo:test specs/<feature> # Spec-aware test by spec directory
|
|
21
23
|
/hapo:test --ui <url> # UI verification via chrome-devtools (public pages)
|
|
22
24
|
/hapo:test --ui-auth <url> # UI verification with auth injection (protected pages)
|
|
23
25
|
/hapo:test --ui-flow <url> # UI testing with User Journey (form fill/submit simulation)
|
|
@@ -31,6 +33,13 @@ If a test command exits 0 but runs 0 tests, report NO_TESTS — this is a green
|
|
|
31
33
|
If tests fail, list every failure explicitly — do not summarize failures away.
|
|
32
34
|
</HARD-GATE>
|
|
33
35
|
|
|
36
|
+
<SCOPE-GATE>
|
|
37
|
+
When a feature name or `specs/<feature>` path is supplied, testing is spec-aware.
|
|
38
|
+
Load `spec.json`, `requirements.md`, `design.md`, active/recent task files, and Task Test Plan evidence.
|
|
39
|
+
The verdict MUST compare executed/reachable behavior against `scope_lock`, requirements, design contracts, task Completion Criteria, and runtime reachability obligations.
|
|
40
|
+
Build/typecheck success without scoped runtime proof is not PASS.
|
|
41
|
+
</SCOPE-GATE>
|
|
42
|
+
|
|
34
43
|
## 4-Phase Execution
|
|
35
44
|
|
|
36
45
|
```mermaid
|
|
@@ -61,6 +70,12 @@ Auto-detect the test runner from project files:
|
|
|
61
70
|
Unless `--full` is specified: apply **Blast Radius scoping** to run only tests
|
|
62
71
|
affected by recent file changes. See `references/execution-strategy.md` Phase A.
|
|
63
72
|
|
|
73
|
+
If the argument resolves to `specs/<feature>` or a feature directory under `specs/`, enter **Spec-Aware Mode**:
|
|
74
|
+
- Load `spec.json`, `requirements.md`, `design.md`, and task files referenced by `task_registry`
|
|
75
|
+
- Identify tasks marked `done`, `in_progress`, or recently changed
|
|
76
|
+
- Extract exact commands, runtime/artifact proof, runtime reachability proof, and negative-path checks
|
|
77
|
+
- Scope test selection by affected task files, but do not skip any mandatory task evidence
|
|
78
|
+
|
|
64
79
|
### Phase 2 — Execute
|
|
65
80
|
|
|
66
81
|
**Code testing (default):**
|
|
@@ -68,6 +83,7 @@ affected by recent file changes. See `references/execution-strategy.md` Phase A.
|
|
|
68
83
|
2. Execute test command with coverage flags
|
|
69
84
|
3. Collect test counts, coverage percentages, and fail stack traces
|
|
70
85
|
4. Treat 0 executed tests as `NO_TESTS`, even if the command exits 0
|
|
86
|
+
5. In Spec-Aware Mode, inspect runtime reachability from declared entrypoints/callers and fail if scoped surfaces are missing or orphaned
|
|
71
87
|
|
|
72
88
|
**UI verification (`--ui` / `--ui-auth` / `--ui-flow`):**
|
|
73
89
|
Execute multi-page discovery, then spawn **Parallel UI Subagents** (test-runner instances) to handle Smoke, Core-Vitals, Accessibility, SEO, Security, and User Flows simultaneously.
|
|
@@ -76,7 +92,7 @@ See `references/execution-strategy.md` Phase C for full phase breakdown.
|
|
|
76
92
|
Delegate execution to `test-runner` agent:
|
|
77
93
|
```
|
|
78
94
|
Agent(subagent_type="test-runner",
|
|
79
|
-
prompt="Run tests. Scope: [blast-radius|full|ui]. Target: [path|url]. Return structured verdict.",
|
|
95
|
+
prompt="Run tests. Scope: [blast-radius|full|ui|spec-aware]. Target: [path|url|feature]. Load specs when target is a feature. Return structured verdict with scope/spec coverage and runtime reachability.",
|
|
80
96
|
description="Test [feature]")
|
|
81
97
|
```
|
|
82
98
|
|
|
@@ -111,6 +127,12 @@ Return a **structured verdict** (required format — not free-form prose):
|
|
|
111
127
|
- Accessibility issues: N found | none
|
|
112
128
|
- Screenshots: [paths]
|
|
113
129
|
|
|
130
|
+
### Scope / Spec Coverage (if feature scope)
|
|
131
|
+
- Requirements covered: N/N
|
|
132
|
+
- Task evidence checks: PASS | FAIL | UNVERIFIED
|
|
133
|
+
- Runtime reachability: PASS | FAIL | UNVERIFIED
|
|
134
|
+
- Out-of-scope behavior detected: none | [list]
|
|
135
|
+
|
|
114
136
|
### Test Regression Check
|
|
115
137
|
- **Comparison:** Compare current test count and assertion depth against previous runs.
|
|
116
138
|
- **Result:** OK | REGRESSION (tests deleted/weakened)
|
|
File without changes
|