create-anpunkit 2.0.1 → 2.1.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.
@@ -1,5 +1,5 @@
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 SCAFFOLD -> RED -> TEST REVIEW -> GREEN; 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
 
@@ -29,8 +29,20 @@ 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 replaces the old soft nudge): if this phase
33
+ will run a real/E2E suite, 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 -> real/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 for the GATE.
34
46
 
35
47
  ---
36
48
 
@@ -40,13 +52,21 @@ Dispatch `researcher` in IMPL mode scoped to this phase.
40
52
  Returns terse summary + path. Read the file only if needed.
41
53
  Unknowns block the phase -> re-dispatch narrowed. No guessing.
42
54
 
55
+ DATASOURCE DELTA (hard rule 15): if this phase tests against an external
56
+ datasource, compare what it touches to the confirmed BASELINE in
57
+ docs/research/datasource-<name>.md. If it touches a NEW table/column beyond the
58
+ baseline -> surface my understanding of just that delta as a falsifiable claim;
59
+ WAIT for confirm; append it to datasource-<name>.md. If it touches only confirmed
60
+ data -> proceed with a one-line note, no stop. Real/E2E against an UNCONFIRMED
61
+ datasource is HARD-BLOCKED (mock still runs).
62
+
43
63
  Then classify the phase:
44
64
 
45
65
  `TDD_PHASE` = the phase adds or changes a PUBLIC CALLABLE SURFACE (endpoint,
46
66
  exported function/class, CLI command, message contract) assertable from the
47
67
  acceptance spec. Size is NOT the criterion.
48
68
 
49
- - Clear public surface -> `TDD_PHASE=true` -> run the TDD path (§2 → §3a → §3b).
69
+ - Clear public surface -> `TDD_PHASE=true` -> run the TDD path (§2 → §3a → §3r → §3b).
50
70
  - Pure infra/config/doc, no public surface -> `TDD_PHASE=false` -> run the
51
71
  non-TDD path (§2N → §3N).
52
72
  - AMBIGUOUS -> default `TDD_PHASE=true`, but STATE the classification + the reason
@@ -66,8 +86,10 @@ Returns the stub files + the interface surface.
66
86
  ## 3a. RED
67
87
 
68
88
  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.
89
+ stubs + acceptance, AND emit docs/test-plan-phase-<n>.md (acceptance criteria
90
+ test names, plus a mandatory "NOT covered / assumptions" section). Place
91
+ contract/ENDPOINTS/DATAFLOW-transition tests in `tests/regression/`, phase-local
92
+ tests in `tests/phase-<n>/`. Run the suite.
71
93
 
72
94
  RED GATE = every acceptance test COLLECTS cleanly AND FAILS (assertion /
73
95
  NotImplemented).
@@ -76,14 +98,29 @@ NotImplemented).
76
98
  fix SIGNATURES (not logic); re-run.
77
99
  - UNDERSPEC -> STOP; ask me to sharpen the acceptance spec.
78
100
 
101
+ ## 3r. TEST REVIEW — human gate (hard rule 12)
102
+
103
+ STOP. Surface docs/test-plan-phase-<n>.md to me: what each acceptance criterion
104
+ maps to, and the "NOT covered / assumptions" section. GREEN cannot begin until I
105
+ approve. On rejection, classify with me:
106
+ - MISREAD of an adequate spec -> re-dispatch `test-author` with my feedback as
107
+ added constraint; re-run RED; re-present the test plan.
108
+ - UNDERSPEC (the acceptance spec itself is too vague) -> sharpen the acceptance
109
+ spec in docs/PLAN.md, then re-dispatch `test-author` fresh.
110
+ Loop until I approve. This gate is unskippable on TDD phases.
111
+
79
112
  ## 3b. GREEN
80
113
 
81
114
  Dispatch `implementer` in FILL mode with the phase spec + research + the test
82
115
  file paths (it MAY read the tests — frozen before logic, no overfit — but must
83
116
  NOT edit them). Fill to green. Budget 3, WARN@2, STUCK@3.
84
117
 
85
- Dispatch `e2e-runner` IF this phase touches the frontend (reads INFRA.md target;
86
- `scripts/e2e-stack.sh up` / Playwright / `down`).
118
+ If FRONTEND_PHASE (from PRE-FLIGHT e): dispatch `e2e-runner` MANDATORY, not
119
+ optional (hard rule 13). It reads INFRA.md target, runs `scripts/e2e-stack.sh up`
120
+ / Playwright / `down`, and captures a screenshot at EACH UI-existence assertion
121
+ regardless of pass/fail to docs/evidence/e2e-phase-<n>/, with a summary in
122
+ docs/research/e2e-<slug>.md. Acceptance spec has no UI-existence criterion ->
123
+ e2e-runner returns UNDERSPEC -> STOP, sharpen the spec.
87
124
 
88
125
  PHASE GATE (rule 5) -> go to §4/§5/§6 (see GATE below).
89
126
 
@@ -101,15 +138,17 @@ includes "deployed URL" before proceeding.
101
138
  ## 3N. TEST (blind)
102
139
 
103
140
  Dispatch `test-author`. It writes MOCK + REAL API suites from the acceptance
104
- spec — never reads the logic. (e2e-runner only if frontend.)
141
+ spec — never reads the logic. (No TEST REVIEW gate on the non-TDD path no
142
+ public surface to mis-test. e2e-runner only if FRONTEND_PHASE.)
105
143
 
106
144
  =====================================================================
107
145
 
108
146
  ## GATE (both paths)
109
147
 
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).
148
+ PHASE GATE = current-phase REAL API suite passes AND (FRONTEND_PHASE) E2E passes
149
+ WITH evidence captured AND the accumulated mock regression corpus stays green AND
150
+ every docs/ENDPOINTS.md entry has a regression test AND every REACHABLE
151
+ docs/DATAFLOW.md transition has a regression test (all checked at CLOSE).
113
152
  - GATE PASS -> go to CLOSE.
114
153
  - GATE BLOCKED (SERVICE UNAVAILABLE, STACK NOT READY, AZURE UNAVAILABLE, FLAKE)
115
154
  -> tell me, wait. Not a code bug. For AZURE UNAVAILABLE: suggest `/infra verify`.
@@ -142,17 +181,28 @@ what to try next. Hand control to me.
142
181
 
143
182
  ## 6. CLOSE
144
183
 
145
- REGRESSION GATE (before closing — Feature 3):
184
+ REGRESSION + COVERAGE GATES (before closing — all FAIL HARD, do not close):
146
185
  - Run `scripts/regression.sh` (mock corpus). A failure BLOCKS close -> route to FIX.
147
186
  - ENDPOINTS COVERAGE: every `docs/ENDPOINTS.md` entry MUST have >=1 test in
148
- `tests/regression/`. Zero coverage -> FAIL HARD; do not close.
187
+ `tests/regression/`. Zero coverage -> FAIL HARD.
188
+ - DATAFLOW COVERAGE (hard rule 14): every `docs/DATAFLOW.md` transition whose
189
+ trigger is REACHABLE in the code shipped so far MUST have >=1 test in
190
+ `tests/regression/`. Zero coverage on a reachable transition -> FAIL HARD.
191
+ Unreachable transitions list as PENDING (not failed). IF IS_FINAL_PHASE: any
192
+ transition still PENDING -> FAIL HARD (everything must be live by the last phase).
193
+ - EVIDENCE (FRONTEND_PHASE only, hard rule 13): docs/evidence/e2e-phase-<n>/ must
194
+ contain at least the per-UI-existence-assertion screenshots. Empty -> FAIL HARD.
149
195
  - IF IS_FINAL_PHASE: additionally run `scripts/regression.sh --real` (full real
150
196
  corpus). A failure blocks close.
151
197
 
152
198
  Mark phase `done` in docs/PLAN.md.
153
199
 
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.
200
+ ARCHITECTURE / DATAFLOW SELF-CHECK:
201
+ - Did this phase add/remove/rename an agent, hook, or command, or change a
202
+ workflow rule? YES -> run `/log-decision`. NO -> state why not.
203
+ - Did this phase add/change an object's STATE LIFECYCLE? YES -> update
204
+ docs/DATAFLOW.md (hard rule 9) in this CLOSE, and confirm new reachable
205
+ transitions are covered. NO -> state why not.
156
206
 
157
207
  IF IS_FINAL_PHASE — FINAL CLOSE sequence:
158
208
 
@@ -175,6 +225,7 @@ IF IS_FINAL_PHASE — FINAL CLOSE sequence:
175
225
 
176
226
  ## Docs
177
227
  - Full endpoint catalogue: docs/ENDPOINTS.md
228
+ - Object/state flow: docs/DATAFLOW.md
178
229
  - Infrastructure: docs/INFRA.md
179
230
  - Project history: docs/HISTORY.md
180
231
  ```
@@ -194,6 +245,7 @@ After each step, update docs/STATE.md:
194
245
 
195
246
  phase: <n> (in progress)
196
247
  tdd: <true|false>
248
+ frontend_phase: <true|false>
197
249
  completed: <steps done so far>
198
250
  next: <exact next step>
199
251
  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.
@@ -31,6 +31,31 @@ Action: $ARGUMENTS (default: "provision" if INFRA.md missing, "verify" if presen
31
31
  4. On "make changes": dispatch UPDATE with feedback. Loop to step 2.
32
32
 
33
33
  5. On APPLIED: tell me INFRA.md ✓, .env.test ✓, and any manual steps remaining.
34
+ Then run AUTH PROOF (below) before declaring Phase 0 complete.
35
+
36
+ ---
37
+
38
+ ## AUTH PROOF (one-time, hard rule 16)
39
+
40
+ Runs after a successful PROVISION (and on demand via `/infra auth-proof`). Proves
41
+ every credential the project's real tests will use is reusable WITHOUT interaction.
42
+ "Reusable" is defined falsifiably: obtainable headlessly TWICE IN A ROW.
43
+
44
+ 1. Enumerate the credentials in scope: the Entra/MSAL app login, plus every
45
+ external datasource credential referenced in docs/DATAFLOW.md (external rows)
46
+ and docs/ENDPOINTS.md (auth column) — Azure SQL, Tableau, etc.
47
+
48
+ 2. Dispatch `infra-provisioner` to run, for EACH credential, a headless obtain
49
+ twice in a row: first call primes (token fetch / connect), second call must
50
+ succeed from cache/refresh with ZERO prompts. The Microsoft login UI is never
51
+ driven (ROPC + dedicated MFA-excluded test account; hard rule 8).
52
+
53
+ 3. Result:
54
+ - All credentials pass twice headlessly -> write `AUTH PROOF: PASS <timestamp>`
55
+ to docs/INFRA.md with the per-credential list. Phase 0 may complete.
56
+ - Any credential prompts or fails the second obtain -> NOT reusable. Write
57
+ `AUTH PROOF: FAIL` + which credential, STOP, tell me what to fix. Phase 0 is
58
+ not complete until the proof passes.
34
59
 
35
60
  ---
36
61
 
@@ -38,7 +63,7 @@ Action: $ARGUMENTS (default: "provision" if INFRA.md missing, "verify" if presen
38
63
 
39
64
  1. Check INFRA.md exists. If missing: tell me to run `/infra provision` first.
40
65
  2. Dispatch `infra-provisioner` VERIFY mode.
41
- 3. Return drift report.
66
+ 3. Return drift report. If the AUTH PROOF marker is missing or stale, re-run AUTH PROOF.
42
67
 
43
68
  ---
44
69
 
@@ -14,7 +14,9 @@ Goal: stand up a fresh project workspace with a well-grounded plan.
14
14
  1. Run the `grill-me` skill to interrogate me. Goal: understand initial scope.
15
15
  Cover: project purpose, success criteria, external services, Azure services
16
16
  needed (type + sizing), region, deployment target (Azure or local for E2E),
17
- known constraints, unknowns.
17
+ known constraints, unknowns. ALSO establish:
18
+ - **has_frontend**: is there a browser-facing UI? If yes, what is the frontend
19
+ root path (e.g. `src/web/`, `app/`)? This drives the mandatory-E2E path match.
18
20
  Do not stop early. Do not write OVERVIEW.md yet.
19
21
 
20
22
  Store the round-1 answers as working context — do NOT write OVERVIEW.md yet.
@@ -29,74 +31,115 @@ Store the round-1 answers as working context — do NOT write OVERVIEW.md yet.
29
31
  Quotas, rate limits, known gaps?
30
32
  - Azure services: any sizing or SKU constraints relevant to the use case?
31
33
  - Auth patterns: any MSAL/Entra constraints for this scenario?
34
+ - Each external DATASOURCE: its DATA UNDERSTANDING (see step 4).
32
35
  - Any other architectural assumption in the round-1 answers worth verifying.
33
36
 
34
37
  3. Dispatch `researcher` in DESIGN mode with the DESIGN TOPICS list.
35
- It returns a terse summary + file paths. Read the design-<slug>.md files
36
- only if needed.
38
+ It returns a terse summary + file paths. For every external datasource it
39
+ drafts a DATA UNDERSTANDING to `docs/research/datasource-<name>.md`:
40
+ grain (one row = what?), the fields likely under test with their meaning and
41
+ real-world nullability/range, a sample-fixture shape, and the assumption that
42
+ if wrong makes a test meaningless. Read the design-<slug>.md files only if needed.
43
+
44
+ ---
45
+
46
+ ### RESEARCH REVIEW (v2.1 — read-and-confirm, not a grill)
47
+
48
+ 4. Surface the design-research findings to me DIRECTLY, phrased as FALSIFIABLE
49
+ CLAIMS about my systems — not a passive findings dump. For example:
50
+ "I understand your Tableau extract refreshes nightly and the API is read-only;
51
+ the `orders` grain is one row per line-item; `status` is never null in practice."
52
+ For each external datasource, present its drafted DATA UNDERSTANDING for me to
53
+ confirm or correct. Then:
54
+ - Minor corrections -> fold forward as seed context for round-2 grill.
55
+ - A MATERIAL error (wrong service tier, wrong data model, wrong grain) ->
56
+ re-dispatch `researcher` with the correction, then re-present. Do not carry
57
+ a known-wrong research file into grill or OVERVIEW.md.
58
+ A confirmed datasource understanding is recorded as the BASELINE in its
59
+ `datasource-<name>.md`. (Per-phase delta-confirms happen later in `/phase`.)
37
60
 
38
61
  ---
39
62
 
40
63
  ### Round 2 — Research-informed re-grill
41
64
 
42
- 4. Run `grill-me` again — a second focused pass. Seed it with:
65
+ 5. Run `grill-me` again — a second focused pass. Seed it with:
43
66
  - The round-1 answers (already established — do not re-ask these)
44
67
  - The design-research key findings and new questions raised
68
+ - The RESEARCH REVIEW corrections
45
69
 
46
- The re-grill asks whatever it needs to build complete understanding. It is
47
- not limited to "gaps from research" research context makes new questions
48
- relevant even if it found no blockers. Do not re-ask what round 1 already
49
- established clearly.
70
+ This pass MUST explicitly cover DATA STRUCTURE and DATAFLOW, especially the
71
+ STATE FLOW of each key object: what are the core entities, what states does
72
+ each move through, what transition triggers each change, who writes it, and
73
+ does any state map to an external system. The re-grill asks whatever else it
74
+ needs for complete understanding. Do not re-ask what round 1 established.
50
75
 
51
76
  ---
52
77
 
53
- ### Write OVERVIEW.md
78
+ ### Write OVERVIEW.md + DATAFLOW.md
54
79
 
55
- 5. Write docs/OVERVIEW.md from the COMBINED output of round-1 + design-research
56
- + round-2. Include:
80
+ 6. Write docs/OVERVIEW.md from the COMBINED output of round-1 + design-research
81
+ + research review + round-2. Include:
57
82
  - Project purpose and success criteria
58
83
  - Scope and constraints (informed by research findings)
59
84
  - External services with confirmed capabilities/limits
60
85
  - "Azure services" section: every service with expected SKU
61
86
  - Deployment target (azure-deployed or local-docker for E2E)
87
+ - `has_frontend: true|false` and, if true, the frontend root path
62
88
  - Known risks / open questions (if any remain)
63
89
 
64
90
  OVERVIEW.md is written HERE — after the re-grill, not before.
65
91
 
92
+ 7. Write docs/DATAFLOW.md — a state-transition table per key object, driven by the
93
+ round-2 data/state-flow grill. The data-side analogue of ENDPOINTS.md. Columns:
94
+ ```
95
+ # Dataflow — <project name>
96
+ > Maintained from /overview; updated each phase that changes an object lifecycle.
97
+ > Each transition row is one testable unit (drives the CLOSE coverage gate).
98
+
99
+ | object | states | transition (from→to) | trigger | who writes | external system |
100
+ |--------|--------|----------------------|---------|------------|-----------------|
101
+ | Order | draft,submitted,fulfilled | draft→submitted | POST /orders/submit | order-svc | — |
102
+ ```
103
+ Any row whose `external system` is populated ties to a `datasource-<name>.md`.
104
+
66
105
  ---
67
106
 
68
107
  ### Plan
69
108
 
70
- 6. Hand OVERVIEW.md + design-research findings to the `planner` subagent.
71
- PLAN.md MUST:
109
+ 8. Hand OVERVIEW.md + DATAFLOW.md + design-research findings to the `planner`
110
+ subagent. PLAN.md MUST:
72
111
  - Start with Phase 0 (infra setup) as the first entry (always).
73
112
  - End with a final code phase that contains the deploy task block.
113
+ - For any phase whose `changes` touch the frontend root: include ≥1
114
+ UI-existence acceptance criterion naming the specific user-visible
115
+ interactive element the phase introduces (not "page renders 200").
116
+ - Map each phase to the DATAFLOW transitions it is expected to make reachable.
74
117
 
75
- 7. Create docs/STATE.md:
118
+ 9. Create docs/STATE.md:
76
119
  ```
77
120
 
78
121
  # STATE
79
122
 
80
123
  phase: 0 (pending)
81
- completed: project bootstrapped — design research done, double grill done
124
+ completed: project bootstrapped — design research, research review, double grill (incl. data/state flow) done
82
125
  next: run /infra to provision Azure infrastructure
83
126
  blocker: none
84
127
 
85
128
  ```
86
- 8. Create docs/ISSUES.md with header `# Issues` and `## Archived` section.
129
+ 10. Create docs/ISSUES.md with header `# Issues` and `## Archived` section.
87
130
 
88
- 9. Create empty docs/HISTORY.md.
131
+ 11. Create empty docs/HISTORY.md.
89
132
 
90
- 10. Create docs/INFRA.md from the template (populated by /infra).
133
+ 12. Create docs/INFRA.md from the template (populated by /infra).
91
134
 
92
- 11. Create docs/ENDPOINTS.md:
135
+ 13. Create docs/ENDPOINTS.md:
93
136
  ```
94
137
  # Endpoints — <project name>
95
138
  > Maintained by implementer. Updated each phase.
96
139
  > Base URL: (populated after deployment phase)
97
140
  ```
98
141
 
99
- Then stop and show me PLAN.md for approval before any phase starts.
142
+ Then stop and show me PLAN.md + DATAFLOW.md for approval before any phase starts.
100
143
 
101
- Remind me: "Run `/infra` next to provision the Azure environment (Phase 0)
102
- before starting Phase 1."
144
+ Remind me: "Run `/infra` next to provision the Azure environment (Phase 0) and
145
+ run the one-time AUTH PROOF before starting Phase 1."
@@ -24,8 +24,20 @@ b. PHASE STATE CHECK: Read docs/STATE.md and docs/PLAN.md.
24
24
  c. FINAL PHASE CHECK: Read docs/PLAN.md. Is this the last phase (no further
25
25
  pending phases after this one)? Record this as IS_FINAL_PHASE=true/false.
26
26
 
27
- d. AUTH NUDGE: if INFRA.md exists and auth marker absent, remind me to run
28
- `scripts/auth-setup.sh`. Not a gate just a reminder.
27
+ d. AUTH LIVENESS GATE (hard rule 16 replaces the old soft nudge): if this phase
28
+ will run a real/E2E suite, confirm every credential it needs is live NOW.
29
+ - If INFRA.md has no `AUTH PROOF: PASS` marker -> STOP: "Auth never proven
30
+ reusable. Run `/infra` first."
31
+ - Run `scripts/auth-setup.sh --check` (Entra token obtainable + not expired)
32
+ and, for each external system this phase touches (docs/DATAFLOW.md external
33
+ rows + docs/ENDPOINTS.md auth column), confirm its credential is obtainable
34
+ headlessly. Any failure -> real/E2E is BLOCKED; tell me what to run; the
35
+ MOCK suite may still proceed.
36
+
37
+ e. FRONTEND TRIGGER (hard rule 13): read docs/OVERVIEW.md `has_frontend` + the
38
+ frontend root. Set FRONTEND_PHASE=true iff `has_frontend: true` AND this
39
+ phase's `changes` (docs/PLAN.md) include any path under the frontend root.
40
+ This is a PATH MATCH, not a judgment call. Record FRONTEND_PHASE for the GATE.
29
41
 
30
42
  ---
31
43
 
@@ -35,13 +47,21 @@ Dispatch `researcher` in IMPL mode scoped to this phase.
35
47
  Returns terse summary + path. Read the file only if needed.
36
48
  Unknowns block the phase -> re-dispatch narrowed. No guessing.
37
49
 
50
+ DATASOURCE DELTA (hard rule 15): if this phase tests against an external
51
+ datasource, compare what it touches to the confirmed BASELINE in
52
+ docs/research/datasource-<name>.md. If it touches a NEW table/column beyond the
53
+ baseline -> surface my understanding of just that delta as a falsifiable claim;
54
+ WAIT for confirm; append it to datasource-<name>.md. If it touches only confirmed
55
+ data -> proceed with a one-line note, no stop. Real/E2E against an UNCONFIRMED
56
+ datasource is HARD-BLOCKED (mock still runs).
57
+
38
58
  Then classify the phase:
39
59
 
40
60
  `TDD_PHASE` = the phase adds or changes a PUBLIC CALLABLE SURFACE (endpoint,
41
61
  exported function/class, CLI command, message contract) assertable from the
42
62
  acceptance spec. Size is NOT the criterion.
43
63
 
44
- - Clear public surface -> `TDD_PHASE=true` -> run the TDD path (§2 → §3a → §3b).
64
+ - Clear public surface -> `TDD_PHASE=true` -> run the TDD path (§2 → §3a → §3r → §3b).
45
65
  - Pure infra/config/doc, no public surface -> `TDD_PHASE=false` -> run the
46
66
  non-TDD path (§2N → §3N).
47
67
  - AMBIGUOUS -> default `TDD_PHASE=true`, but STATE the classification + the reason
@@ -61,8 +81,10 @@ Returns the stub files + the interface surface.
61
81
  ## 3a. RED
62
82
 
63
83
  Dispatch `test-author` to write the REAL API suite (+ mock) BLIND against the
64
- stubs + acceptance. Place contract/ENDPOINTS tests in `tests/regression/`,
65
- phase-local tests in `tests/phase-<n>/`. Run the suite.
84
+ stubs + acceptance, AND emit docs/test-plan-phase-<n>.md (acceptance criteria
85
+ test names, plus a mandatory "NOT covered / assumptions" section). Place
86
+ contract/ENDPOINTS/DATAFLOW-transition tests in `tests/regression/`, phase-local
87
+ tests in `tests/phase-<n>/`. Run the suite.
66
88
 
67
89
  RED GATE = every acceptance test COLLECTS cleanly AND FAILS (assertion /
68
90
  NotImplemented).
@@ -71,14 +93,29 @@ NotImplemented).
71
93
  fix SIGNATURES (not logic); re-run.
72
94
  - UNDERSPEC -> STOP; ask me to sharpen the acceptance spec.
73
95
 
96
+ ## 3r. TEST REVIEW — human gate (hard rule 12)
97
+
98
+ STOP. Surface docs/test-plan-phase-<n>.md to me: what each acceptance criterion
99
+ maps to, and the "NOT covered / assumptions" section. GREEN cannot begin until I
100
+ approve. On rejection, classify with me:
101
+ - MISREAD of an adequate spec -> re-dispatch `test-author` with my feedback as
102
+ added constraint; re-run RED; re-present the test plan.
103
+ - UNDERSPEC (the acceptance spec itself is too vague) -> sharpen the acceptance
104
+ spec in docs/PLAN.md, then re-dispatch `test-author` fresh.
105
+ Loop until I approve. This gate is unskippable on TDD phases.
106
+
74
107
  ## 3b. GREEN
75
108
 
76
109
  Dispatch `implementer` in FILL mode with the phase spec + research + the test
77
110
  file paths (it MAY read the tests — frozen before logic, no overfit — but must
78
111
  NOT edit them). Fill to green. Budget 3, WARN@2, STUCK@3.
79
112
 
80
- Dispatch `e2e-runner` IF this phase touches the frontend (reads INFRA.md target;
81
- `scripts/e2e-stack.sh up` / Playwright / `down`).
113
+ If FRONTEND_PHASE (from PRE-FLIGHT e): dispatch `e2e-runner` MANDATORY, not
114
+ optional (hard rule 13). It reads INFRA.md target, runs `scripts/e2e-stack.sh up`
115
+ / Playwright / `down`, and captures a screenshot at EACH UI-existence assertion
116
+ regardless of pass/fail to docs/evidence/e2e-phase-<n>/, with a summary in
117
+ docs/research/e2e-<slug>.md. Acceptance spec has no UI-existence criterion ->
118
+ e2e-runner returns UNDERSPEC -> STOP, sharpen the spec.
82
119
 
83
120
  PHASE GATE (rule 5) -> go to §4/§5/§6 (see GATE below).
84
121
 
@@ -96,15 +133,17 @@ includes "deployed URL" before proceeding.
96
133
  ## 3N. TEST (blind)
97
134
 
98
135
  Dispatch `test-author`. It writes MOCK + REAL API suites from the acceptance
99
- spec — never reads the logic. (e2e-runner only if frontend.)
136
+ spec — never reads the logic. (No TEST REVIEW gate on the non-TDD path no
137
+ public surface to mis-test. e2e-runner only if FRONTEND_PHASE.)
100
138
 
101
139
  =====================================================================
102
140
 
103
141
  ## GATE (both paths)
104
142
 
105
- PHASE GATE = current-phase REAL API suite passes AND (if frontend) E2E passes AND
106
- the accumulated mock regression corpus stays green AND every docs/ENDPOINTS.md
107
- entry has a regression test (checked at CLOSE).
143
+ PHASE GATE = current-phase REAL API suite passes AND (FRONTEND_PHASE) E2E passes
144
+ WITH evidence captured AND the accumulated mock regression corpus stays green AND
145
+ every docs/ENDPOINTS.md entry has a regression test AND every REACHABLE
146
+ docs/DATAFLOW.md transition has a regression test (all checked at CLOSE).
108
147
  - GATE PASS -> go to CLOSE.
109
148
  - GATE BLOCKED (SERVICE UNAVAILABLE, STACK NOT READY, AZURE UNAVAILABLE, FLAKE)
110
149
  -> tell me, wait. Not a code bug. For AZURE UNAVAILABLE: suggest `/infra verify`.
@@ -137,17 +176,28 @@ what to try next. Hand control to me.
137
176
 
138
177
  ## 6. CLOSE
139
178
 
140
- REGRESSION GATE (before closing — Feature 3):
179
+ REGRESSION + COVERAGE GATES (before closing — all FAIL HARD, do not close):
141
180
  - Run `scripts/regression.sh` (mock corpus). A failure BLOCKS close -> route to FIX.
142
181
  - ENDPOINTS COVERAGE: every `docs/ENDPOINTS.md` entry MUST have >=1 test in
143
- `tests/regression/`. Zero coverage -> FAIL HARD; do not close.
182
+ `tests/regression/`. Zero coverage -> FAIL HARD.
183
+ - DATAFLOW COVERAGE (hard rule 14): every `docs/DATAFLOW.md` transition whose
184
+ trigger is REACHABLE in the code shipped so far MUST have >=1 test in
185
+ `tests/regression/`. Zero coverage on a reachable transition -> FAIL HARD.
186
+ Unreachable transitions list as PENDING (not failed). IF IS_FINAL_PHASE: any
187
+ transition still PENDING -> FAIL HARD (everything must be live by the last phase).
188
+ - EVIDENCE (FRONTEND_PHASE only, hard rule 13): docs/evidence/e2e-phase-<n>/ must
189
+ contain at least the per-UI-existence-assertion screenshots. Empty -> FAIL HARD.
144
190
  - IF IS_FINAL_PHASE: additionally run `scripts/regression.sh --real` (full real
145
191
  corpus). A failure blocks close.
146
192
 
147
193
  Mark phase `done` in docs/PLAN.md.
148
194
 
149
- ARCHITECTURE SELF-CHECK: did this phase add/remove/rename an agent, hook, or
150
- command, or change a workflow rule? YES -> run `/log-decision`. NO -> state why not.
195
+ ARCHITECTURE / DATAFLOW SELF-CHECK:
196
+ - Did this phase add/remove/rename an agent, hook, or command, or change a
197
+ workflow rule? YES -> run `/log-decision`. NO -> state why not.
198
+ - Did this phase add/change an object's STATE LIFECYCLE? YES -> update
199
+ docs/DATAFLOW.md (hard rule 9) in this CLOSE, and confirm new reachable
200
+ transitions are covered. NO -> state why not.
151
201
 
152
202
  IF IS_FINAL_PHASE — FINAL CLOSE sequence:
153
203
 
@@ -170,6 +220,7 @@ IF IS_FINAL_PHASE — FINAL CLOSE sequence:
170
220
 
171
221
  ## Docs
172
222
  - Full endpoint catalogue: docs/ENDPOINTS.md
223
+ - Object/state flow: docs/DATAFLOW.md
173
224
  - Infrastructure: docs/INFRA.md
174
225
  - Project history: docs/HISTORY.md
175
226
  ```
@@ -189,6 +240,7 @@ After each step, update docs/STATE.md:
189
240
 
190
241
  phase: <n> (in progress)
191
242
  tdd: <true|false>
243
+ frontend_phase: <true|false>
192
244
  completed: <steps done so far>
193
245
  next: <exact next step>
194
246
  blocker: <none or open issue>
@@ -20,10 +20,13 @@ Use when PLAN.md no longer matches reality. Change: $ARGUMENTS
20
20
  - A new external service is mentioned (Stripe, Twilio, a new Azure service, etc.)
21
21
  - The change involves architecture (a new integration pattern, auth change, etc.)
22
22
  - A service tier or quota change is implied
23
+ - A new external DATASOURCE or a change to an object's STATE LIFECYCLE
23
24
 
24
25
  If ANY of these signals are present: dispatch `researcher` in DESIGN mode
25
- with the specific new service/pattern as the DESIGN TOPICS list. Show me the
26
- key findings before proceeding to step 3.
26
+ with the specific new service/pattern as the DESIGN TOPICS list. For a new
27
+ datasource, it drafts a DATA UNDERSTANDING; surface it to me as a falsifiable
28
+ claim and confirm (baseline) before proceeding. Show me the key findings
29
+ before step 3.
27
30
 
28
31
  If none: proceed directly to step 3 (impl-research may still be dispatched
29
32
  in step 3 for non-trivial changes per the original logic).
@@ -32,11 +35,13 @@ Use when PLAN.md no longer matches reality. Change: $ARGUMENTS
32
35
  was not needed, dispatch `researcher` in IMPL mode to ground the re-plan
33
36
  in facts.
34
37
 
35
- 4. RE-PLAN. Dispatch `planner` with the change + current PLAN.md. It must:
38
+ 4. RE-PLAN. Dispatch `planner` with the change + current PLAN.md + DATAFLOW.md.
39
+ It must:
36
40
  - Keep done phases untouched.
37
41
  - Insert / cut / split / merge / reorder only PENDING phases.
38
42
  - Place new phases in correct DEPENDENCY order.
39
43
  - Keep every phase a vertical slice with its own acceptance spec.
44
+ - Preserve the UI-existence criterion on any frontend-touching phase.
40
45
  - Ensure the LAST pending phase still contains the deploy task block.
41
46
  - Renumber pending phases if needed; update STATE.md `phase:` pointer.
42
47
 
@@ -49,11 +54,20 @@ Use when PLAN.md no longer matches reality. Change: $ARGUMENTS
49
54
  reconciled corpus still passes against live services. A failure -> surface it
50
55
  and stop before approval.
51
56
 
52
- 6. SHOW ME the revised phase list + the regression-corpus changes, and STOP for
53
- approval.
57
+ 6. RECONCILE DATAFLOW.md (v2.1). If the re-plan adds, cuts, or re-scopes objects
58
+ or transitions, update docs/DATAFLOW.md in step:
59
+ - A CUT/removed object or transition -> remove its row(s) and retire the
60
+ matching regression test(s).
61
+ - A new object/transition -> add the row(s); mark them PENDING until the phase
62
+ that makes them reachable runs. The deploy-last / "no PENDING at final phase"
63
+ invariant (hard rule 14) still holds.
64
+ - A reorder must not strand a transition as permanently unreachable.
54
65
 
55
- 7. ARCHITECTURE SELF-CHECK: re-planning is not normally a kit-architecture
66
+ 7. SHOW ME the revised phase list + the regression-corpus changes + the
67
+ DATAFLOW.md changes, and STOP for approval.
68
+
69
+ 8. ARCHITECTURE SELF-CHECK: re-planning is not normally a kit-architecture
56
70
  change. Only run /log-decision if the workflow itself changed (rare).
57
71
 
58
- Report what changed: phases added / cut / split / reordered, and regression
59
- tests retired / consolidated.
72
+ Report what changed: phases added / cut / split / reordered, regression tests
73
+ retired / consolidated, and DATAFLOW rows added / removed.