create-anpunkit 2.0.3 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/bin/cli.js +3 -2
  2. package/package.json +1 -1
  3. package/template/.claude/agents/e2e-runner.md +44 -13
  4. package/template/.claude/agents/implementer.md +13 -7
  5. package/template/.claude/agents/infra-provisioner.md +33 -2
  6. package/template/.claude/agents/planner.md +79 -6
  7. package/template/.claude/agents/researcher.md +19 -8
  8. package/template/.claude/agents/spec-author.md +118 -0
  9. package/template/.claude/agents/test-author.md +76 -43
  10. package/template/.claude/anpunkit-manifest.json +47 -27
  11. package/template/.claude/commands/infra.md +28 -3
  12. package/template/.claude/commands/overview.md +84 -24
  13. package/template/.claude/commands/phase.md +139 -40
  14. package/template/.claude/commands/replan.md +23 -9
  15. package/template/.cursor/commands/infra.md +26 -1
  16. package/template/.cursor/commands/overview.md +83 -23
  17. package/template/.cursor/commands/phase.md +138 -39
  18. package/template/.cursor/commands/replan.md +22 -8
  19. package/template/.gitattributes +1 -0
  20. package/template/AGENTS.md +215 -36
  21. package/template/CLAUDE.md +1 -0
  22. package/template/README.md +59 -23
  23. package/template/anpunkit.png +0 -0
  24. package/template/commands.src/infra.md +28 -3
  25. package/template/commands.src/overview.md +84 -24
  26. package/template/commands.src/phase.md +139 -40
  27. package/template/commands.src/replan.md +23 -9
  28. package/template/docs/DESIGN_LOG.md +192 -1
  29. package/template/index.html +339 -0
  30. package/template/scripts/spec-conformance.sh +93 -0
  31. package/template/scripts/spec-staleness.sh +115 -0
  32. package/template/setup.sh +110 -47
  33. package/template/tests/helpers/spec-assert.py +162 -0
  34. package/template/tests/helpers/spec-assert.ts +158 -0
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: Bootstrap a new project. Runs design-research, double grill, and planning. Run once per project.
2
+ description: Bootstrap a new project. Runs design-research, research review, double grill (incl. data/state flow), datasource-understanding baseline, and planning. Run once per project.
3
3
  ---
4
4
 
5
5
  Caveman ULTRA mode.
@@ -18,7 +18,9 @@ Goal: stand up a fresh project workspace with a well-grounded plan.
18
18
  1. Run the `grill-me` skill to interrogate me. Goal: understand initial scope.
19
19
  Cover: project purpose, success criteria, external services, Azure services
20
20
  needed (type + sizing), region, deployment target (Azure or local for E2E),
21
- known constraints, unknowns.
21
+ known constraints, unknowns. ALSO establish:
22
+ - **has_frontend**: is there a browser-facing UI? If yes, what is the frontend
23
+ root path (e.g. `src/web/`, `app/`)? This drives the mandatory-E2E path match.
22
24
  Do not stop early. Do not write OVERVIEW.md yet.
23
25
 
24
26
  Store the round-1 answers as working context — do NOT write OVERVIEW.md yet.
@@ -33,74 +35,132 @@ Store the round-1 answers as working context — do NOT write OVERVIEW.md yet.
33
35
  Quotas, rate limits, known gaps?
34
36
  - Azure services: any sizing or SKU constraints relevant to the use case?
35
37
  - Auth patterns: any MSAL/Entra constraints for this scenario?
38
+ - Each external DATASOURCE: its DATA UNDERSTANDING (see step 4).
36
39
  - Any other architectural assumption in the round-1 answers worth verifying.
37
40
 
38
41
  3. Dispatch `researcher` in DESIGN mode with the DESIGN TOPICS list.
39
- It returns a terse summary + file paths. Read the design-<slug>.md files
40
- only if needed.
42
+ It returns a terse summary + file paths. For every external datasource it
43
+ drafts a DATA UNDERSTANDING to `docs/research/datasource-<name>.md`:
44
+ grain (one row = what?), the fields likely under test with their meaning and
45
+ real-world nullability/range, a sample-fixture shape, and the assumption that
46
+ if wrong makes a test meaningless. Read the design-<slug>.md files only if needed.
47
+
48
+ ---
49
+
50
+ ### RESEARCH REVIEW (v2.1 — read-and-confirm, not a grill)
51
+
52
+ 4. Surface the design-research findings to me DIRECTLY, phrased as FALSIFIABLE
53
+ CLAIMS about my systems — not a passive findings dump. For example:
54
+ "I understand your Tableau extract refreshes nightly and the API is read-only;
55
+ the `orders` grain is one row per line-item; `status` is never null in practice."
56
+ For each external datasource, present its drafted DATA UNDERSTANDING for me to
57
+ confirm or correct. Then:
58
+ - Minor corrections -> fold forward as seed context for round-2 grill.
59
+ - A MATERIAL error (wrong service tier, wrong data model, wrong grain) ->
60
+ re-dispatch `researcher` with the correction, then re-present. Do not carry
61
+ a known-wrong research file into grill or OVERVIEW.md.
62
+ A confirmed datasource understanding is recorded as the BASELINE in its
63
+ `datasource-<name>.md`. (Per-phase delta-confirms happen later in `/phase`.)
41
64
 
42
65
  ---
43
66
 
44
67
  ### Round 2 — Research-informed re-grill
45
68
 
46
- 4. Run `grill-me` again — a second focused pass. Seed it with:
69
+ 5. Run `grill-me` again — a second focused pass. Seed it with:
47
70
  - The round-1 answers (already established — do not re-ask these)
48
71
  - The design-research key findings and new questions raised
72
+ - The RESEARCH REVIEW corrections
49
73
 
50
- The re-grill asks whatever it needs to build complete understanding. It is
51
- not limited to "gaps from research" research context makes new questions
52
- relevant even if it found no blockers. Do not re-ask what round 1 already
53
- established clearly.
74
+ This pass MUST explicitly cover DATA STRUCTURE and DATAFLOW, especially the
75
+ STATE FLOW of each key object: what are the core entities, what states does
76
+ each move through, what transition triggers each change, who writes it, and
77
+ does any state map to an external system. The re-grill asks whatever else it
78
+ needs for complete understanding. Do not re-ask what round 1 established.
54
79
 
55
80
  ---
56
81
 
57
- ### Write OVERVIEW.md
82
+ ### Write OVERVIEW.md + DATAFLOW.md
58
83
 
59
- 5. Write docs/OVERVIEW.md from the COMBINED output of round-1 + design-research
60
- + round-2. Include:
84
+ 6. Write docs/OVERVIEW.md from the COMBINED output of round-1 + design-research
85
+ + research review + round-2. Include:
61
86
  - Project purpose and success criteria
62
87
  - Scope and constraints (informed by research findings)
63
88
  - External services with confirmed capabilities/limits
64
89
  - "Azure services" section: every service with expected SKU
65
90
  - Deployment target (azure-deployed or local-docker for E2E)
91
+ - `has_frontend: true|false` and, if true, the frontend root path
66
92
  - Known risks / open questions (if any remain)
67
93
 
68
94
  OVERVIEW.md is written HERE — after the re-grill, not before.
69
95
 
96
+ 7. Write docs/DATAFLOW.md — a state-transition table per key object, driven by the
97
+ round-2 data/state-flow grill. The data-side analogue of ENDPOINTS.md. Columns:
98
+ ```
99
+ # Dataflow — <project name>
100
+ > Maintained from /overview; updated each phase that changes an object lifecycle.
101
+ > Each transition row is one testable unit (drives the CLOSE coverage gate).
102
+
103
+ | object | states | transition (from→to) | trigger | who writes | external system |
104
+ |--------|--------|----------------------|---------|------------|-----------------|
105
+ | Order | draft,submitted,fulfilled | draft→submitted | POST /orders/submit | order-svc | — |
106
+ ```
107
+ Any row whose `external system` is populated ties to a `datasource-<name>.md`.
108
+
70
109
  ---
71
110
 
72
111
  ### Plan
73
112
 
74
- 6. Hand OVERVIEW.md + design-research findings to the `planner` subagent.
75
- PLAN.md MUST:
113
+ 8. Hand OVERVIEW.md + DATAFLOW.md + design-research findings to the `planner`
114
+ subagent. PLAN.md MUST:
76
115
  - Start with Phase 0 (infra setup) as the first entry (always).
77
116
  - End with a final code phase that contains the deploy task block.
78
-
79
- 7. Create docs/STATE.md:
117
+ - For any phase whose `changes` touch the frontend root: include ≥1
118
+ UI-existence acceptance criterion naming the specific user-visible
119
+ interactive element the phase introduces (not "page renders 200").
120
+ - Map each phase to the DATAFLOW transitions it is expected to make reachable.
121
+
122
+ The planner ALSO writes the up-front SKELETON spec files (v2.2, §5.44/§5.51):
123
+ one `docs/spec-phase-<n>.md` per public-surface phase (skip Phase 0 + pure
124
+ infra/config/doc phases), enumerating the case NAMES — happy path, each named
125
+ edge, each named failure + error code — for every `dataflow:` transition and
126
+ every `acceptance` criterion, with `TBD` values. The generated header transcludes
127
+ that phase's `acceptance:` line + in-scope `DATAFLOW.md` transition rows verbatim.
128
+
129
+ 8b. STAMP each skeleton's staleness hash: for every `docs/spec-phase-<n>.md` the
130
+ planner wrote, run `bash scripts/spec-staleness.sh stamp <n>`. This embeds the
131
+ hash of the transcluded acceptance line + transition rows so phase-time
132
+ `/phase` can detect upstream drift. (Values are filled per phase by `spec-author`.)
133
+
134
+ 9. Create docs/STATE.md:
80
135
  ```
81
136
 
82
137
  # STATE
83
138
 
84
139
  phase: 0 (pending)
85
- completed: project bootstrapped — design research done, double grill done
140
+ completed: project bootstrapped — design research, research review, double grill (incl. data/state flow) done
86
141
  next: run /infra to provision Azure infrastructure
87
142
  blocker: none
88
143
 
89
144
  ```
90
- 8. Create docs/ISSUES.md with header `# Issues` and `## Archived` section.
145
+ 10. Create docs/ISSUES.md with header `# Issues` and `## Archived` section.
91
146
 
92
- 9. Create empty docs/HISTORY.md.
147
+ 11. Create empty docs/HISTORY.md.
93
148
 
94
- 10. Create docs/INFRA.md from the template (populated by /infra).
149
+ 12. Create docs/INFRA.md from the template (populated by /infra).
95
150
 
96
- 11. Create docs/ENDPOINTS.md:
151
+ 13. Create docs/ENDPOINTS.md:
97
152
  ```
98
153
  # Endpoints — <project name>
99
154
  > Maintained by implementer. Updated each phase.
100
155
  > Base URL: (populated after deployment phase)
101
156
  ```
102
157
 
103
- Then stop and show me PLAN.md for approval before any phase starts.
158
+ Then stop and show me PLAN.md + DATAFLOW.md for approval before any phase starts.
159
+ EXTEND the approval surface (v2.2, §5.51 — one confirmation, no new gate): for each
160
+ public-surface phase, list the transition/acceptance ids it covers and the enumerated
161
+ case NAMES (no values). I confirm the case-name set is COMPLETE here — these names
162
+ are the up-front behavioral contract; values get filled + reviewed per phase at
163
+ `/phase` SPEC REVIEW.
104
164
 
105
- Remind me: "Run `/infra` next to provision the Azure environment (Phase 0)
106
- before starting Phase 1."
165
+ Remind me: "Run `/infra` next to provision the Azure environment (Phase 0) and
166
+ run the one-time AUTH PROOF before starting Phase 1."
@@ -1,10 +1,10 @@
1
1
  ---
2
- description: Run one phase end-to-end. TDD phases run SCAFFOLD -> RED -> GREEN; non-TDD phases run IMPLEMENT -> TEST. Both with the debug circuit breaker and the regression guard at CLOSE.
2
+ description: Run one phase end-to-end. TDD phases run SPEC fill -> SPEC REVIEW -> SCAFFOLD -> RED -> conformance -> GREEN -> boundary/E2E; non-TDD phases run IMPLEMENT -> TEST. Both with the debug circuit breaker and the regression + dataflow + evidence guards at CLOSE.
3
3
  argument-hint: [phase number]
4
4
  ---
5
5
 
6
6
  Caveman ULTRA mode. You are the ORCHESTRATOR. Route work to subagents —
7
- you do NOT implement or debug yourself.
7
+ you do NOT implement, fill specs, or debug yourself.
8
8
 
9
9
  Note: subagents cannot talk to the user. Only YOU can.
10
10
 
@@ -29,8 +29,21 @@ b. PHASE STATE CHECK: Read docs/STATE.md and docs/PLAN.md.
29
29
  c. FINAL PHASE CHECK: Read docs/PLAN.md. Is this the last phase (no further
30
30
  pending phases after this one)? Record this as IS_FINAL_PHASE=true/false.
31
31
 
32
- d. AUTH NUDGE: if INFRA.md exists and auth marker absent, remind me to run
33
- `scripts/auth-setup.sh`. Not a gate just a reminder.
32
+ d. AUTH LIVENESS GATE (hard rule 16): if this phase will run a boundary/E2E suite,
33
+ confirm every credential it needs is live NOW.
34
+ - If INFRA.md has no `AUTH PROOF: PASS` marker -> STOP: "Auth never proven
35
+ reusable. Run `/infra` first."
36
+ - Run `scripts/auth-setup.sh --check` (Entra token obtainable + not expired)
37
+ and, for each external system this phase touches (docs/DATAFLOW.md external
38
+ rows + docs/ENDPOINTS.md auth column), confirm its credential is obtainable
39
+ headlessly. Any failure -> boundary/E2E is BLOCKED; tell me what to run; the
40
+ MOCK suite may still proceed.
41
+
42
+ e. FRONTEND TRIGGER (hard rule 13): read docs/OVERVIEW.md `has_frontend` + the
43
+ frontend root. Set FRONTEND_PHASE=true iff `has_frontend: true` AND this
44
+ phase's `changes` (docs/PLAN.md) include any path under the frontend root.
45
+ This is a PATH MATCH, not a judgment call. Record FRONTEND_PHASE — it gates the
46
+ `ui` boundary run + evidence at CLOSE.
34
47
 
35
48
  ---
36
49
 
@@ -40,52 +53,120 @@ Dispatch `researcher` in IMPL mode scoped to this phase.
40
53
  Returns terse summary + path. Read the file only if needed.
41
54
  Unknowns block the phase -> re-dispatch narrowed. No guessing.
42
55
 
56
+ DATASOURCE DELTA (hard rule 15): if this phase tests against an external
57
+ datasource, compare what it touches to the confirmed BASELINE in
58
+ docs/research/datasource-<name>.md. If it touches a NEW table/column beyond the
59
+ baseline -> surface my understanding of just that delta as a falsifiable claim;
60
+ WAIT for confirm; append it to datasource-<name>.md. If it touches only confirmed
61
+ data -> proceed with a one-line note, no stop. Boundary/E2E against an UNCONFIRMED
62
+ datasource is HARD-BLOCKED (mock still runs). The confirmed baseline is what
63
+ `spec-author` grounds fixtures in.
64
+
43
65
  Then classify the phase:
44
66
 
45
67
  `TDD_PHASE` = the phase adds or changes a PUBLIC CALLABLE SURFACE (endpoint,
46
68
  exported function/class, CLI command, message contract) assertable from the
47
69
  acceptance spec. Size is NOT the criterion.
48
70
 
49
- - Clear public surface -> `TDD_PHASE=true` -> run the TDD path (§2 → §3a → §3b).
71
+ - Clear public surface -> `TDD_PHASE=true` -> run the TDD path (§2 → §3 → §4 → §5 → §6 → §7).
50
72
  - Pure infra/config/doc, no public surface -> `TDD_PHASE=false` -> run the
51
73
  non-TDD path (§2N → §3N).
52
74
  - AMBIGUOUS -> default `TDD_PHASE=true`, but STATE the classification + the reason
53
- to me, so I can override to non-TDD BEFORE SCAFFOLD fires. (Hard rule 11: never
54
- downgrade a TDD phase just to dodge the RED gate.)
75
+ to me, so I can override to non-TDD BEFORE SPEC fill fires. (Hard rule 11: never
76
+ downgrade a TDD phase just to dodge the gates.)
55
77
 
56
78
  =====================================================================
57
79
  ## TDD PATH (TDD_PHASE=true)
58
80
  =====================================================================
59
81
 
60
- ## 2. SCAFFOLD
82
+ ## 2. SPEC FILL + STALENESS
83
+
84
+ a. SKELETON CHECK: confirm docs/spec-phase-<n>.md exists (planner generated it at
85
+ /overview). If MISSING (planner classified it non-TDD, or it's a new phase from
86
+ /replan): generate the skeleton NOW from this phase's PLAN.md `acceptance` +
87
+ `dataflow:` transitions in the planner skeleton format (generated header + named
88
+ `TBD` rows), then `bash scripts/spec-staleness.sh stamp <n>` to stamp its hash.
89
+
90
+ b. Dispatch `spec-author`. It fills each case row with a real input payload
91
+ (`fixtures/<case-id>-input.json`), concrete expected output
92
+ (`fixtures/<case-id>-expected.json`), matcher tokens for volatile fields,
93
+ `error-code` for failures, and `selector/assert/value` `ui` descriptors —
94
+ grounded in the RESEARCH findings + the confirmed datasource baseline.
95
+
96
+ c. CASE-SET-DIVERGENCE (hard re-entry, hard rule 12 / §5.52): if `spec-author`
97
+ returns `CASE-SET-DIVERGENCE` (a required case can't be filled from real facts,
98
+ or research revealed an unlisted/contradicted case) -> STOP. Surface the finding.
99
+ I amend the up-front case-name contract in the skeleton; you re-stamp
100
+ (`bash scripts/spec-staleness.sh stamp <n>`); then re-dispatch `spec-author` to
101
+ re-fill from scratch. AI never amends the case-name set — I own the contract.
102
+
103
+ d. STALENESS (hard rule 17): run `bash scripts/spec-staleness.sh <n>`. Nonzero
104
+ (upstream PLAN acceptance line / DATAFLOW rows drifted since the skeleton was
105
+ stamped, e.g. via /replan) -> regenerate the skeleton header from current
106
+ PLAN/DATAFLOW, re-stamp, re-dispatch `spec-author`. Do NOT hand-edit the hash.
107
+
108
+ ## 3. SPEC REVIEW — human gate (hard rule 12)
109
+
110
+ STOP. Surface the FILLED cases to me as FALSIFIABLE CLAIMS in plain language, e.g.:
111
+ - "POST /orders/submit with an empty line-item list → 422 EMPTY_ORDER."
112
+ - "Successful submit of a 3-line order → 201; order.id is a UUID; order.status is
113
+ 'submitted'."
114
+ Re-run `bash scripts/spec-staleness.sh <n>` at entry (nonzero -> back to §2d).
115
+ SCAFFOLD cannot begin until I confirm. Classify any rejection WITH me (§5.50):
116
+ - WRONG EXPECTED -> fix the case row + `fixtures/<case-id>-expected.json`; no
117
+ re-research. (You may patch the fixture directly per my correction.)
118
+ - WRONG INPUT SHAPE -> re-dispatch `spec-author` with the correction.
119
+ - NEW CASE or CONTRADICTED CASE -> hard re-entry (§2c): I amend the skeleton, you
120
+ re-stamp, re-confirm the amended case(s) + any case sharing their `covers` id
121
+ (the staleness hash certifies the unchanged remainder — not re-read), re-fill.
122
+ Loop until I approve. Unskippable on TDD phases.
123
+
124
+ ## 4. SCAFFOLD
61
125
 
62
126
  Dispatch `implementer` in SCAFFOLD mode: interface stubs only (signatures +
63
- types; bodies raise NotImplementedError / return 501); NO logic, NO tests.
64
- Returns the stub files + the interface surface.
127
+ types; bodies raise NotImplementedError / return 501); NO logic, NO tests, NO
128
+ edits to the spec or fixtures. Returns the stub files + the interface surface.
129
+
130
+ ## 5. RED
65
131
 
66
- ## 3a. RED
132
+ Dispatch `test-author` to EMIT the boundary harness from the locked spec `data`
133
+ rows: one deep-equality assertion per case against `fixtures/<case-id>-expected.json`
134
+ via the kit comparator `tests/helpers/spec-assert.*`, each citing its case with a
135
+ `# spec: <case-id>` comment. It does NOT author assertions — it generates them from
136
+ the spec. Place contract/ENDPOINTS/transition tests in `tests/regression/`,
137
+ phase-local in `tests/phase-<n>/`.
67
138
 
68
- Dispatch `test-author` to write the REAL API suite (+ mock) BLIND against the
69
- stubs + acceptance. Place contract/ENDPOINTS tests in `tests/regression/`,
70
- phase-local tests in `tests/phase-<n>/`. Run the suite.
139
+ If FRONTEND_PHASE (and the phase has `ui` cases): also dispatch `e2e-runner` to EMIT
140
+ Playwright assertions from each `ui` case's `fixtures/<case-id>-ui.json` descriptor,
141
+ each citing `// spec: <case-id>`. Run the suites.
71
142
 
72
- RED GATE = every acceptance test COLLECTS cleanly AND FAILS (assertion /
73
- NotImplemented).
74
- - Any test PASSES on stubs -> STOP (spec trivial or test wrong); show me.
143
+ RED GATE = every case test COLLECTS cleanly AND FAILS (assertion / NotImplemented).
144
+ - Any test PASSES on stubs -> STOP (spec trivial or emitter wrong); show me.
75
145
  - Collection / import / syntax error -> stub mismatch; re-dispatch SCAFFOLD to
76
146
  fix SIGNATURES (not logic); re-run.
77
- - UNDERSPEC -> STOP; ask me to sharpen the acceptance spec.
78
147
 
79
- ## 3b. GREEN
148
+ ## 6. CONFORMANCE GATE (hard rule 18) — replaces the v2.1 human TEST REVIEW
149
+
150
+ Run `bash scripts/spec-conformance.sh <n>`. It loud-fails (and BLOCKS GREEN) if:
151
+ - any `TBD` marker remains in docs/spec-phase-<n>.md or a referenced fixture, OR
152
+ - any case-id in the spec table has no boundary test citing it (`# spec: <case-id>`).
153
+ Nonzero -> fix the gap (re-dispatch `spec-author` for a stray TBD, or `test-author`/
154
+ `e2e-runner` for a missing citation) and re-run. GREEN cannot start until it passes.
155
+
156
+ ## 7. GREEN + BOUNDARY/E2E
80
157
 
81
- Dispatch `implementer` in FILL mode with the phase spec + research + the test
82
- file paths (it MAY read the tests — frozen before logic, no overfit — but must
83
- NOT edit them). Fill to green. Budget 3, WARN@2, STUCK@3.
158
+ Dispatch `implementer` in FILL mode with the FILLED docs/spec-phase-<n>.md + its
159
+ fixtures + research + the generated test file paths (it MAY read the tests — frozen
160
+ before logic, no overfit but must NOT edit tests, spec, or fixtures). Fill to
161
+ green against the spec. Budget 3, WARN@2, STUCK@3.
84
162
 
85
- Dispatch `e2e-runner` IF this phase touches the frontend (reads INFRA.md target;
86
- `scripts/e2e-stack.sh up` / Playwright / `down`).
163
+ Run the BOUNDARY suite (real HTTP/CLI/message; `TEST_MODE=real`). If FRONTEND_PHASE,
164
+ `e2e-runner` runs its emitted `ui` specs — MANDATORY (hard rule 13) — reads INFRA.md
165
+ target, runs `scripts/e2e-stack.sh up` / Playwright / `down`, and captures a
166
+ screenshot at EACH UI-existence assertion regardless of pass/fail to
167
+ docs/evidence/e2e-phase-<n>/, with a summary in docs/research/e2e-<slug>.md.
87
168
 
88
- PHASE GATE (rule 5) -> go to §456 (see GATE below).
169
+ PHASE GATE (rule 5) -> go to §8910 (see GATE below).
89
170
 
90
171
  =====================================================================
91
172
  ## NON-TDD PATH (TDD_PHASE=false)
@@ -100,16 +181,19 @@ includes "deployed URL" before proceeding.
100
181
 
101
182
  ## 3N. TEST (blind)
102
183
 
103
- Dispatch `test-author`. It writes MOCK + REAL API suites from the acceptance
104
- spec — never reads the logic. (e2e-runner only if frontend.)
184
+ Dispatch `test-author`. It writes MOCK + boundary suites from the acceptance
185
+ spec — never reads the logic. (No spec file, SPEC REVIEW, or conformance gate on
186
+ the non-TDD path — no public surface to contract. e2e-runner only if FRONTEND_PHASE.)
105
187
 
106
188
  =====================================================================
107
189
 
108
190
  ## GATE (both paths)
109
191
 
110
- PHASE GATE = current-phase REAL API suite passes AND (if frontend) E2E passes AND
111
- the accumulated mock regression corpus stays green AND every docs/ENDPOINTS.md
112
- entry has a regression test (checked at CLOSE).
192
+ PHASE GATE = current-phase BOUNDARY suite passes AND (FRONTEND_PHASE) the `ui`
193
+ boundary passes WITH evidence captured AND the accumulated mock regression corpus
194
+ stays green AND every docs/ENDPOINTS.md entry has a regression test AND (TDD)
195
+ `spec-conformance.sh` passed AND every REACHABLE docs/DATAFLOW.md transition has a
196
+ filled case in the phase spec (all checked at CLOSE).
113
197
  - GATE PASS -> go to CLOSE.
114
198
  - GATE BLOCKED (SERVICE UNAVAILABLE, STACK NOT READY, AZURE UNAVAILABLE, FLAKE)
115
199
  -> tell me, wait. Not a code bug. For AZURE UNAVAILABLE: suggest `/infra verify`.
@@ -117,17 +201,17 @@ entry has a regression test (checked at CLOSE).
117
201
 
118
202
  ---
119
203
 
120
- ## 4. FIX
204
+ ## 8. FIX
121
205
 
122
206
  Dispatch `debugger` (isolated context) on the specific failure.
123
- - FIXED -> re-run TEST (and the regression corpus).
207
+ - FIXED -> re-run the boundary suite (and the regression corpus).
124
208
  - SERVICE UNAVAILABLE -> tell me, wait. Suggest `/infra verify` if Azure.
125
209
  - WARN (2 attempts failed) -> relay immediately, then let debugger finish attempt 3.
126
210
  - STUCK -> go to ESCALATE.
127
211
 
128
212
  ---
129
213
 
130
- ## 5. ESCALATE — circuit breaker. Mode B.
214
+ ## 9. ESCALATE — circuit breaker. Mode B.
131
215
 
132
216
  FIRST STUCK: STOP. Present to me: the problem, 3 failed hypotheses, the
133
217
  debugger's recommendation, the debug file path. Ask what to do. Wait. Options:
@@ -140,19 +224,32 @@ what to try next. Hand control to me.
140
224
 
141
225
  ---
142
226
 
143
- ## 6. CLOSE
227
+ ## 10. CLOSE
144
228
 
145
- REGRESSION GATE (before closing — Feature 3):
146
- - Run `scripts/regression.sh` (mock corpus). A failure BLOCKS close -> route to FIX.
229
+ REGRESSION + COVERAGE GATES (before closing — all FAIL HARD, do not close):
230
+ - Run `bash scripts/regression.sh` (mock corpus). A failure BLOCKS close -> route to FIX.
147
231
  - ENDPOINTS COVERAGE: every `docs/ENDPOINTS.md` entry MUST have >=1 test in
148
- `tests/regression/`. Zero coverage -> FAIL HARD; do not close.
149
- - IF IS_FINAL_PHASE: additionally run `scripts/regression.sh --real` (full real
232
+ `tests/regression/`. Zero coverage -> FAIL HARD.
233
+ - DATAFLOW COVERAGE (hard rule 14, re-seamed v2.2): every `docs/DATAFLOW.md`
234
+ transition whose trigger is REACHABLE in the code shipped so far MUST have >=1
235
+ FILLED CASE in docs/spec-phase-<n>.md. Zero coverage on a reachable transition ->
236
+ FAIL HARD. Unreachable transitions list as PENDING (not failed). IF
237
+ IS_FINAL_PHASE: any transition still PENDING -> FAIL HARD. (The case→test half is
238
+ already enforced by `spec-conformance.sh` at §6 — every case-id is cited by a
239
+ boundary test, which by placement lands in tests/regression/.)
240
+ - EVIDENCE (FRONTEND_PHASE only, hard rule 13): docs/evidence/e2e-phase-<n>/ must
241
+ contain at least the per-UI-existence-assertion screenshots. Empty -> FAIL HARD.
242
+ - IF IS_FINAL_PHASE: additionally run `bash scripts/regression.sh --real` (full real
150
243
  corpus). A failure blocks close.
151
244
 
152
245
  Mark phase `done` in docs/PLAN.md.
153
246
 
154
- ARCHITECTURE SELF-CHECK: did this phase add/remove/rename an agent, hook, or
155
- command, or change a workflow rule? YES -> run `/log-decision`. NO -> state why not.
247
+ ARCHITECTURE / DATAFLOW SELF-CHECK:
248
+ - Did this phase add/remove/rename an agent, hook, or command, or change a
249
+ workflow rule? YES -> run `/log-decision`. NO -> state why not.
250
+ - Did this phase add/change an object's STATE LIFECYCLE? YES -> update
251
+ docs/DATAFLOW.md (hard rule 9) in this CLOSE, and confirm new reachable
252
+ transitions are covered by a filled case. NO -> state why not.
156
253
 
157
254
  IF IS_FINAL_PHASE — FINAL CLOSE sequence:
158
255
 
@@ -175,6 +272,7 @@ IF IS_FINAL_PHASE — FINAL CLOSE sequence:
175
272
 
176
273
  ## Docs
177
274
  - Full endpoint catalogue: docs/ENDPOINTS.md
275
+ - Object/state flow: docs/DATAFLOW.md
178
276
  - Infrastructure: docs/INFRA.md
179
277
  - Project history: docs/HISTORY.md
180
278
  ```
@@ -194,6 +292,7 @@ After each step, update docs/STATE.md:
194
292
 
195
293
  phase: <n> (in progress)
196
294
  tdd: <true|false>
295
+ frontend_phase: <true|false>
197
296
  completed: <steps done so far>
198
297
  next: <exact next step>
199
298
  blocker: <none or open issue>
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: Revise docs/PLAN.md when it no longer matches reality — add, cut, split, merge, or reorder phases.
2
+ description: Revise docs/PLAN.md when it no longer matches reality — add, cut, split, merge, or reorder phases. Keeps the deploy-last, ENDPOINTS, and DATAFLOW invariants intact.
3
3
  argument-hint: [what changed about the plan]
4
4
  ---
5
5
 
@@ -25,10 +25,13 @@ Use when PLAN.md no longer matches reality. Change: $ARGUMENTS
25
25
  - A new external service is mentioned (Stripe, Twilio, a new Azure service, etc.)
26
26
  - The change involves architecture (a new integration pattern, auth change, etc.)
27
27
  - A service tier or quota change is implied
28
+ - A new external DATASOURCE or a change to an object's STATE LIFECYCLE
28
29
 
29
30
  If ANY of these signals are present: dispatch `researcher` in DESIGN mode
30
- with the specific new service/pattern as the DESIGN TOPICS list. Show me the
31
- key findings before proceeding to step 3.
31
+ with the specific new service/pattern as the DESIGN TOPICS list. For a new
32
+ datasource, it drafts a DATA UNDERSTANDING; surface it to me as a falsifiable
33
+ claim and confirm (baseline) before proceeding. Show me the key findings
34
+ before step 3.
32
35
 
33
36
  If none: proceed directly to step 3 (impl-research may still be dispatched
34
37
  in step 3 for non-trivial changes per the original logic).
@@ -37,11 +40,13 @@ Use when PLAN.md no longer matches reality. Change: $ARGUMENTS
37
40
  was not needed, dispatch `researcher` in IMPL mode to ground the re-plan
38
41
  in facts.
39
42
 
40
- 4. RE-PLAN. Dispatch `planner` with the change + current PLAN.md. It must:
43
+ 4. RE-PLAN. Dispatch `planner` with the change + current PLAN.md + DATAFLOW.md.
44
+ It must:
41
45
  - Keep done phases untouched.
42
46
  - Insert / cut / split / merge / reorder only PENDING phases.
43
47
  - Place new phases in correct DEPENDENCY order.
44
48
  - Keep every phase a vertical slice with its own acceptance spec.
49
+ - Preserve the UI-existence criterion on any frontend-touching phase.
45
50
  - Ensure the LAST pending phase still contains the deploy task block.
46
51
  - Renumber pending phases if needed; update STATE.md `phase:` pointer.
47
52
 
@@ -54,11 +59,20 @@ Use when PLAN.md no longer matches reality. Change: $ARGUMENTS
54
59
  reconciled corpus still passes against live services. A failure -> surface it
55
60
  and stop before approval.
56
61
 
57
- 6. SHOW ME the revised phase list + the regression-corpus changes, and STOP for
58
- approval.
62
+ 6. RECONCILE DATAFLOW.md (v2.1). If the re-plan adds, cuts, or re-scopes objects
63
+ or transitions, update docs/DATAFLOW.md in step:
64
+ - A CUT/removed object or transition -> remove its row(s) and retire the
65
+ matching regression test(s).
66
+ - A new object/transition -> add the row(s); mark them PENDING until the phase
67
+ that makes them reachable runs. The deploy-last / "no PENDING at final phase"
68
+ invariant (hard rule 14) still holds.
69
+ - A reorder must not strand a transition as permanently unreachable.
59
70
 
60
- 7. ARCHITECTURE SELF-CHECK: re-planning is not normally a kit-architecture
71
+ 7. SHOW ME the revised phase list + the regression-corpus changes + the
72
+ DATAFLOW.md changes, and STOP for approval.
73
+
74
+ 8. ARCHITECTURE SELF-CHECK: re-planning is not normally a kit-architecture
61
75
  change. Only run /log-decision if the workflow itself changed (rare).
62
76
 
63
- Report what changed: phases added / cut / split / reordered, and regression
64
- tests retired / consolidated.
77
+ Report what changed: phases added / cut / split / reordered, regression tests
78
+ retired / consolidated, and DATAFLOW rows added / removed.