flow-workflows 0.95.1 → 0.97.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 (39) hide show
  1. package/adapters/codex/CORE.md +30 -4
  2. package/adapters/codex/skills/flow-bug-fix/SKILL.md +5 -2
  3. package/adapters/codex/skills/flow-bug-validate/SKILL.md +1 -1
  4. package/adapters/codex/skills/flow-feat-build/SKILL.md +9 -2
  5. package/adapters/codex/skills/flow-feat-design/SKILL.md +1 -1
  6. package/adapters/codex/skills/flow-feat-review/SKILL.md +3 -1
  7. package/adapters/codex/skills/flow-feat-validate/SKILL.md +8 -5
  8. package/adapters/codex/skills/flow-work-handoff/SKILL.md +13 -0
  9. package/adapters/codex/skills/flow-work-run/SKILL.md +7 -0
  10. package/adapters/gemini/CORE.md +30 -4
  11. package/adapters/gemini/commands/flow/bug/fix.toml +5 -2
  12. package/adapters/gemini/commands/flow/bug/validate.toml +1 -1
  13. package/adapters/gemini/commands/flow/feat/build.toml +9 -2
  14. package/adapters/gemini/commands/flow/feat/design.toml +1 -1
  15. package/adapters/gemini/commands/flow/feat/review.toml +3 -1
  16. package/adapters/gemini/commands/flow/feat/validate.toml +8 -5
  17. package/adapters/gemini/commands/flow/work/handoff.toml +13 -0
  18. package/adapters/gemini/commands/flow/work/run.toml +7 -0
  19. package/adapters/hermes/CORE.md +30 -4
  20. package/adapters/hermes/skills/flow-bug-fix/SKILL.md +5 -2
  21. package/adapters/hermes/skills/flow-bug-validate/SKILL.md +1 -1
  22. package/adapters/hermes/skills/flow-feat-build/SKILL.md +9 -2
  23. package/adapters/hermes/skills/flow-feat-design/SKILL.md +1 -1
  24. package/adapters/hermes/skills/flow-feat-review/SKILL.md +3 -1
  25. package/adapters/hermes/skills/flow-feat-validate/SKILL.md +8 -5
  26. package/adapters/hermes/skills/flow-work-handoff/SKILL.md +13 -0
  27. package/adapters/hermes/skills/flow-work-run/SKILL.md +7 -0
  28. package/adapters/opencode/CORE.md +30 -4
  29. package/adapters/opencode/commands/flow-bug-fix.md +5 -2
  30. package/adapters/opencode/commands/flow-bug-validate.md +1 -1
  31. package/adapters/opencode/commands/flow-feat-build.md +9 -2
  32. package/adapters/opencode/commands/flow-feat-design.md +1 -1
  33. package/adapters/opencode/commands/flow-feat-review.md +3 -1
  34. package/adapters/opencode/commands/flow-feat-validate.md +8 -5
  35. package/adapters/opencode/commands/flow-work-handoff.md +13 -0
  36. package/adapters/opencode/commands/flow-work-run.md +7 -0
  37. package/package.json +1 -1
  38. package/plugins/flow/.claude-plugin/plugin.json +1 -1
  39. package/plugins/flow/CHANGELOG.md +40 -0
@@ -17,7 +17,7 @@ Every `$flow-*` command assumes these rules. They are stated once, here, so a co
17
17
  carries what is specific to its phase. Read this once per session; a command that says "load
18
18
  `flow-core`" means this file.
19
19
 
20
- **This file belongs to flow `0.95.1`.** Compare it once, at the start of the session, against
20
+ **This file belongs to flow `0.97.0`.** Compare it once, at the start of the session, against
21
21
  `version` in `~/.claude/flow/.claude-plugin/plugin.json`. The two differing means the session
22
22
  is running a **mixture** — the commands from one copy of the plugin, these shared rules from another
23
23
  — which is exactly what happens when a branch or a release candidate is loaded over an installed
@@ -225,7 +225,8 @@ the value someone wrote in the FLOW config, or it is not in effect.
225
225
  each one resolves as §2.1's table says — never approved in silence):
226
226
  1. Any push or MR/PR creation (all of `ship`).
227
227
  2. Creating or switching a branch when the base is ambiguous (not on a clean main, or a possible train/stacked branch).
228
- 3. DB schema changes or migrations.
228
+ 3. DB schema changes or migrations — writing one a schema approved with the study already lists is
229
+ not asked again (below); applying one always is.
229
230
  4. A `review` that surfaced high-severity findings — never chain into `ship` on those.
230
231
  5. The business brief written before touching code (`build`, `fix`).
231
232
 
@@ -262,6 +263,30 @@ studies a ticket there goes on to build it — unless the orchestrator launched
262
263
  (§2.1), which stops at the door to code. With `autonomy.mode: auto`, a `--study` work runs on its
263
264
  own up to the push.
264
265
 
266
+ **A schema approved with the study.** A study that changes the schema says so literally: the
267
+ `## Schema changes` section of the `flow-study` block (`$flow-work-handoff` §5) lists, one line
268
+ each and by name, every table, column, index, constraint and data copy its migrations create,
269
+ alter or drop — from `03-design.md` "Data model", the intended fix of `03-investigation.md` for a
270
+ bug — or says `none`. Approving the study approves that list, and the approval is a file in the
271
+ work folder, `approved-schema.md`: a first line saying where it was approved (`Approved at
272
+ handoff, <date>` · `Approved with the study run, <date>`), then the section verbatim. Two places
273
+ write it and nothing else does — the handoff push answered **Push — schema approved**
274
+ (`$flow-work-handoff` §4), and `$flow-work-run` §2 when the orchestrator approves a study run with
275
+ `why = start`. Then, in every mode:
276
+
277
+ - **Writing** a migration — in `build`, in `fix`, or for a fix a review asks for — whose every
278
+ object created, altered or dropped is on that list is not asked: write it, add
279
+ `{ "key": "study:approved-schema", "default": "<the objects it writes>", "phase": "<phase>" }` to
280
+ `meta.json.defaults_used[]`, and one line under "Decisions made during implementation" naming
281
+ `approved-schema.md`.
282
+ - **Anything the list does not name** — one more column, an index, a drop, a type beyond what its
283
+ line says — is hard gate 3 as always, and the question names what lies beyond the list, so the
284
+ person decides on the difference alone.
285
+ - **Applying** a migration (`validate`) and the pre-deploy SQL (`ship`) are asked as before: the
286
+ study approved what the schema becomes, not when a database changes.
287
+ - A study revision (`$flow-work-run` §2) moves `approved-schema.md` aside with the rest of the
288
+ study; the new summary is approved anew.
289
+
265
290
  ### 2.1 `unattended` — where a person would have been asked
266
291
 
267
292
  No person is there to answer a question in this mode. A question tool — `AskUserQuestion`, OpenCode's `question`,
@@ -373,9 +398,10 @@ person asking for changes, a ticket that already has code — is `$flow-work-run
373
398
  | Business brief before code (`build`, `fix`) | record — the brief is written to the phase artifact, marked `recorded (unattended)`, and travels in the MR/PR body |
374
399
  | The door to code in a study run (`build`, `fix` pre-flight) | done — `done-summary.md`, the study as `$flow-work-handoff` §5 writes it for the ticket, and one `--depends-on` per `meta.json.ticket_deps` entry |
375
400
  | Push and MR/PR creation (`ship`) | `publish` — the run commits on its own branch, writes title and body, and hands them over; the orchestrator pushes and opens the draft |
376
- | Writing a DB schema change, index or migration — in any phase, a review's own fixes included — or applying one (`validate`) | question `migration`, before the first line of it is written or run — except in `respond` and `green`, where it is blocked: a schema change agreed after the MR/PR exists goes back through `build` |
401
+ | Writing a DB schema change, index or migration — in any phase, a review's own fixes included — or applying one (`validate`) | question `migration`, before the first line of it is written or run — except in `respond` and `green`, where it is blocked: a schema change agreed after the MR/PR exists goes back through `build`. Writing one whose every object `approved-schema.md` lists is not asked (§2, a schema approved with the study) |
377
402
  | `review` with blockers or high-severity findings | question `high_findings` |
378
- | `validate` with a red suite or a criterion `unproven` | blocked — the phase does not advance and does not chain. **One exception, and it is measured, never judged**: every failing test also fails, under the same name, on the base (`git merge-base HEAD <git.default_base>`, run in a detached worktree), none of them lives in a file this diff touches, and none is the test that proves an acceptance criterion → record `{"key":"unattended:validate-red-base","default":"<n> red on HEAD and on base <short sha>: <test names>","phase":"validate"}` and advance; `ship` lists those tests under "Not verified — needs a human". Short of all three — a failure the base does not reproduce, a base that cannot be run, a test this diff touched — blocked |
403
+ | `validate` with a criterion `unproven` | blocked — the phase does not advance and does not chain |
404
+ | `validate` with a red suite | **One exception, and it is measured, never judged**: every failing test also fails, under the same name, on the base (`git merge-base HEAD <git.default_base>`, run in a detached worktree), none of them lives in a file this diff touches, and none is the test that proves an acceptance criterion → record `{"key":"unattended:validate-red-base","default":"<n> red on HEAD and on base <short sha>: <test names>","phase":"validate"}` and advance; `ship` lists those tests under "Not verified — needs a human". Short of that, **one repair round per MR/PR**: this MR/PR's plan (`05-implementation.md` / `04-fix.md`) has no `### Red suite at validate (unattended)` heading yet → write it under the plan with one unticked step per failing test (its name and the first line of its failure), each ending *fix the code, or update an assertion whose expected value this MR/PR's design or fix changed — never delete, skip or loosen a test*; record `{"key":"unattended:validate-red-loop","default":"<n> red: <test names>","phase":"validate"}`, leave `phase = build` (`fix`) and chain into `$flow-feat-build` (`$flow-bug-fix`) — whose steps then run through the phases that follow it as always, review and validate included. A review of that round treats a test the round deleted, skipped or loosened as a blocker. The heading already there → it is the same check failing a second time: blocked, naming the tests still red |
379
405
  | A product decision (§7 `decision`) | question `decision` |
380
406
  | Clarifying questions on the ticket (`start`) | question `clarify` — after the branch and the work folder exist, with the questions also written to `01-context.md` |
381
407
  | An unanswered high-severity challenge (`design`, `investigate`) | question `design_challenge` / `investigation_challenge` |
@@ -75,10 +75,12 @@ In `unattended` (flow-core §2.1) nobody is there to answer: write the brief, ma
75
75
  `recorded (unattended)` under its heading, record the site in `meta.json.defaults_used[]`, and fix.
76
76
  The gate's purpose moves to the draft MR/PR, whose body carries the brief for the person who reads it.
77
77
  **A schema change or migration is still a question** (`migration`): before writing the first line
78
- of one → the question stop, end the run. The orchestrator's answer re-enters here
78
+ of one → the question stop, end the run — unless `approved-schema.md` lists every object it
79
+ creates, alters or drops (flow-core §2, a schema approved with the study): then write it, record
80
+ it there, do not stop. The orchestrator's answer re-enters here
79
81
  exactly as `$flow-feat-build §2` says, with `04-fix.md` for `05-implementation.md` and
80
82
  `$flow-bug-validate` as the phase it chains into after a review's *Fix them* (`$flow-bug-review`
81
- for XS, which has no validate).
83
+ for XS, which has no validate), and after a red suite at validate (flow-core §2.1).
82
84
 
83
85
  **The brief travels inside the question** (flow-core §3) — read in the prompt being answered, not by opening `04-fix.md` — and **nothing runs between the brief and the question**: a tool call after it is what lets a terminal fold it away. Options:
84
86
  - **Yes, go ahead** → apply the fix.
@@ -213,6 +215,7 @@ A **product decision** the fix turns out to need is neither of these — not sco
213
215
  - `quality.style_fix`
214
216
  - `quality.static_analysis`
215
217
  - The test that covers the fix: `quality.test_one` (if none exists, `$flow-bug-validate` adds it).
218
+ - The existing tests of the modules or files the fix changed, with `quality.test_one` — the cheap catch before `$flow-bug-validate` runs the full suite. One asserting the behaviour this fix corrects is updated and named in `04-fix.md`; any other failure is a bug in the fix.
216
219
 
217
220
  ## 4.1 Is the investigation still valid?
218
221
 
@@ -97,7 +97,7 @@ this is the same gate as a red test.
97
97
 
98
98
  ## 5. Close
99
99
 
100
- - Red test, regressions, **or the original symptom still reproducible in §2.5** → `phase` stays at `fix`; the user iterates. A red gate stops in every mode (in `unattended`, the run ends `blocked` with the failing test named, flow-core §2.1 — unless every failing test also fails on the base, the one exception that row records; the reproduction test lives in a file this diff touches, so it never qualifies).
100
+ - Red test, regressions, **or the original symptom still reproducible in §2.5** → `phase` stays at `fix`; the user iterates. A red gate stops in every mode except `unattended`, where flow-core §2.1 decides: every failing test also red on the base → its exception advances (the reproduction test lives in a file this diff touches, so it never qualifies); otherwise the one repair round of that row — the failing tests become unticked steps of `04-fix.md`'s plan, `phase = fix`, chain into `$flow-bug-fix`, which chains back here; red a second time → `blocked`, naming the tests still red. The original symptom still reproducible in §2.5 is not a failing test: `blocked`, naming it.
101
101
  - Green → `phase = "validate"`, add to `phases_done`; in the same write record `validated_sha` = `git rev-parse HEAD` — the tree the regression test passed on, which `$flow-bug-ship §0` reads. Suggest `$flow-bug-review`.
102
102
  - **Other bugs detected become `followups[]` entries** (flow-core §7) when they clear its bar — a reproducible symptom with someone who suffers it, not «this looks fragile» — per the output template.
103
103
  - **Stage what the validation taught** (`knowledge.stage` set; silence by default): a mutation that stayed green, a disguise the scenario wore, a fixture that could not produce the case — findings about how this codebase is tested, not about this diff. Same rule and evidence line as the review's Close.
@@ -82,7 +82,9 @@ In `unattended` (flow-core §2.1) nobody is there to answer: write the brief, ma
82
82
  `recorded (unattended)` under its heading, record the site in `meta.json.defaults_used[]`, and build.
83
83
  The gate's purpose moves to the draft MR/PR, whose body carries the brief for the person who reads it.
84
84
  **A schema change or migration is still a question** (`migration`): before writing the first line
85
- of one → the question stop, end the run. The orchestrator's answer re-enters here
85
+ of one → the question stop, end the run — unless `approved-schema.md` lists every object it
86
+ creates, alters or drops (flow-core §2, a schema approved with the study): then write it, record
87
+ it there, do not stop. The orchestrator's answer re-enters here
86
88
  (flow-core §2.1): the brief, the contracts and the plan are already written — keep them — and the
87
89
  MR/PR is the one already `in_progress`, not a new pick. *Write it and continue* → the first unticked
88
90
  step, the migration included · *Change the design first* → `blocked`. A plan step marked approved
@@ -90,7 +92,11 @@ by an answer's `id` (a review wrote it) is that migration already answered **whe
90
92
  `meta.json.defaults_used[]` with gate `migration` and phase `review`**: write it, do not stop. Not
91
93
  there → it is a question like any other.
92
94
  Chained from a review's `high_findings` *Fix them* → the findings are unticked steps at the end of
93
- this MR/PR's plan: build them in order, then chain into `$flow-feat-review`.
95
+ this MR/PR's plan: build them in order, then chain into `$flow-feat-review`. Chained from a red
96
+ suite at validate (flow-core §2.1) → the same, under the plan's `### Red suite at validate
97
+ (unattended)`: one step per failing test, and a test reaches green by fixing the code or by an
98
+ assertion this MR/PR's design changed — never by deleting, skipping or loosening it. Run each
99
+ step's test with `quality.test_one` before ticking it.
94
100
 
95
101
  **The brief travels inside the question** (flow-core §3): the user reads it in the prompt they are answering, never by opening `05-implementation.md`. Write the file, run whatever you need, and *then* open the gate — **nothing runs between the brief and the question**, because a tool call after it is what lets a terminal fold the brief into one collapsed line, and the gate is answered blind. Options:
96
102
  - **Yes, proceed** → start building.
@@ -387,6 +393,7 @@ As larger pieces are completed:
387
393
 
388
394
  - Run `quality.style_fix` from `FLOW.md` to fix style; if empty, auto-discover (Makefile, npm scripts, Gradle, dotnet, Xcode, Flutter…).
389
395
  - Run `quality.static_analysis` from `FLOW.md` when a piece is stable; if empty, auto-discover.
396
+ - **Before closing, the tests this diff can break:** the existing tests of the modules, classes or files the diff changed, with `quality.test_one` (a filter per module or file) — not the full suite, which `$flow-feat-validate` runs. A test asserting the old behaviour that the design changes is updated now, and named under "Decisions made during implementation"; one that fails for any other reason is a bug in this build. Leaving them to validate costs a whole round.
390
397
  - If tests were added, run them individually with `quality.test_one` from `FLOW.md` (substituting `{FILTER}`); if empty, auto-discover. **A filtered run is judged by how many tests it executed, never by its exit code** — most runners exit `0` when the filter matches nothing (`OK, 0 tests`, `No tests ran`, `no tests to run`, `0 passed`). Read the executed count **and** test names: count `0`, or your new tests missing from the names → **the run did not happen**; treat as failure, fix the filter, run again. No count reported → drop the filter and run the whole test file. In "Relevant commands executed", record the count you saw, not just the command — "green" without a number is not evidence.
391
398
 
392
399
  Do not do code review here — that is `$flow-feat-review`.
@@ -228,7 +228,7 @@ Consolidate outputs into `.claude/work/<TICKET>/03-design.md`:
228
228
 
229
229
  ## Data model
230
230
  - New / modified entities: <for each new one, indicate "no equivalent found" or "knowingly duplicated because...">
231
- - Migrations:
231
+ - Migrations: <each table, column, index, constraint and data copy created, altered or dropped, by name — approving the study approves exactly this list (flow-core §2, a schema approved with the study)>
232
232
  - Indexes:
233
233
 
234
234
  ### Access paths
@@ -403,4 +403,6 @@ Write `.claude/work/<TICKET>/06-review.md`. The `Cost:` line of `## Summary` is
403
403
  unticked step under this MR/PR's plan in `05-implementation.md` (`04-fix.md` for a bug), leaves
404
404
  `phase = build` (`fix`), and chains into `$flow-feat-build` (`$flow-bug-fix`), which builds those
405
405
  steps and chains back here — a bug through `$flow-bug-validate` first, as its order has it. A migration one of this round's fixes needs is question `migration`
406
- asked here — after `high_findings`, in its own stop — and answered the same way (flow-core §2.1).
406
+ asked here — after `high_findings`, in its own stop — and answered the same way (flow-core §2.1),
407
+ unless `approved-schema.md` lists every object it writes (flow-core §2): then it is an ordinary
408
+ step, and build writes it without asking.
@@ -228,10 +228,13 @@ Write `.claude/work/<TICKET>/07-validation.md`:
228
228
  - Overwrite `00-summary.md` whole (≤15 lines, flow-core §5).
229
229
  - **Autonomy handoff — this one stops in every mode, `auto` included.** `ship` pushes and opens the MR/PR: a hard gate in every mode, so do **not** chain into it. Stop here and propose `$flow-feat-ship` with a single `AskUserQuestion` (recommended option by default), invoking it only when the user confirms. This is the deliberate end of a run in `auto`.
230
230
  **In `unattended`** (flow-core §2.1): the phase advanced → chain into `$flow-feat-ship`, which
231
- hands the MR/PR to the orchestrator with `publish`. It did not advance
232
- (red suite, a criterion `unproven`) → `blocked`, naming what failed; never chain. A red suite
233
- advances only under the base exception of flow-core §2.1: run the failing tests on the base, and
234
- write each name, its result there and the base sha under "Suite results" in `07-validation.md`.
235
- Calling a failure "pre-existing" without that run is not the exception — it is a red suite.
231
+ hands the MR/PR to the orchestrator with `publish`. A criterion `unproven` → `blocked`, naming
232
+ it; never chain. A red suite advances only under the base exception of flow-core §2.1: run the
233
+ failing tests on the base, and write each name, its result there and the base sha under "Suite
234
+ results" in `07-validation.md`. Calling a failure "pre-existing" without that run is not the
235
+ exception — it is a red suite. Short of it, the red suite gets its one repair round (the same
236
+ row): the failing tests become unticked steps of this MR/PR's plan, `phase = build`, and the run
237
+ chains into `$flow-feat-build`, then review and this phase again. Red a second time → `blocked`,
238
+ naming the tests still red.
236
239
 
237
240
  In `guided`/`auto` this is, together with the brief in `$flow-feat-build §2`, **the only stop of the whole MR/PR** — everything between them ran without a person. It carries the **full stop header** and the body answers, in this order: what is green, what this MR/PR proves and what it does not, and what shipping it takes. Assume the user has read none of the build and review.
@@ -108,6 +108,15 @@ Show the branch, the remote and the file list the build printed — every path,
108
108
  ask with `AskUserQuestion` **in every `autonomy.mode`**: a push leaves the machine (flow-core §2).
109
109
  **Push** · **Cancel**. Nothing between the list and the question (flow-core §3).
110
110
 
111
+ **A study that changes the schema** — its `## Schema changes` section (§5) is not `none` — shows
112
+ that section too, under the file list, and the same question carries the approval: **Push — schema
113
+ approved** · **Push — build asks first** · **Cancel**. Whoever builds it can ask no one about what
114
+ the person here already read. *Push — schema approved* → write `approved-schema.md` in the work
115
+ folder (flow-core §2, a schema approved with the study: `Approved at handoff, <date>`, then the
116
+ section verbatim), run the build block again, check its file list is the one shown plus that file,
117
+ and push that commit. *Push — build asks first* → push as it stands: build will ask `migration`
118
+ before writing the first line of it.
119
+
111
120
  ```bash handoff-push
112
121
  BRANCH='@BRANCH@'; COMMIT='@COMMIT@'
113
122
  case "$COMMIT" in ''|*[!0-9a-f]*) echo "not a commit sha: $COMMIT"; exit 1 ;; esac
@@ -144,6 +153,7 @@ the ticket read it there, never in the work folder; the receiver does not parse
144
153
  ## Acceptance criteria
145
154
  ## Design in brief
146
155
  ## MR/PR plan
156
+ ## Schema changes
147
157
  ## Risks
148
158
  <!-- end flow-study -->
149
159
  ```
@@ -152,6 +162,9 @@ the ticket read it there, never in the work folder; the receiver does not parse
152
162
  entry and its why — `Depends on #253: <why>` — so whoever approves the study sees what it waits
153
163
  for; an unattended study's `done-summary.md` is this block, so it carries them too. The plan
154
164
  lists each MR/PR with what it covers and what it waits on; a bug's plan is its single fix.
165
+ `## Schema changes` lists, one line each and by name, every table, column, index, constraint and
166
+ data copy the study's migrations create, alter or drop (flow-core §2, a schema approved with the
167
+ study), or says `none` — it is what approving the study approves, so nothing there is prose.
155
168
  - **The new body**: the body read above with the block between the two markers replaced — or, with
156
169
  no markers yet, the block appended after a blank line. Then, for each `meta.json.ticket_deps`
157
170
  entry (`$flow-feat-design` §5.1) whose line is not already a line of that body — same text,
@@ -107,6 +107,13 @@ record `{ "key": "unattended:base-caught-up", "default": "<old short sha> → <n
107
107
  ancestor → it holds commits a previous run made: leave it as it is — bringing the base into work in
108
108
  progress is the orchestrator's (flow-core §2.1).
109
109
 
110
+ **On `start`, an approved study run approves its schema** — only while no build or fix has begun,
111
+ `done-summary.md` exists (the summary a person approved) and `approved-schema.md` does not. Its
112
+ `## Schema changes` section names something → write `approved-schema.md` (flow-core §2, a schema
113
+ approved with the study: `Approved with the study run, <date>`, then the section verbatim) and
114
+ record `{ "key": "unattended:schema-approved", "default": "<n> object(s)", "phase": "run" }`. The
115
+ section says `none`, or is missing → nothing is written, and build asks as it always did.
116
+
110
117
  **A person's changes to a study, on `study`** (flow-core §2.1: they rewind it). The work's branch
111
118
  first, as above. `<work>/study-revision.md` holds the reply, as the row above wrote it. Each step
112
119
  can be run again: a run that dies part-way is finished by the next relaunch, whatever it serves.
@@ -16,7 +16,7 @@ Every `/flow:*` command assumes these rules. They are stated once, here, so a co
16
16
  carries what is specific to its phase. Read this once per session; a command that says "load
17
17
  `flow-core`" means this file.
18
18
 
19
- **This file belongs to flow `0.95.1`.** Compare it once, at the start of the session, against
19
+ **This file belongs to flow `0.97.0`.** Compare it once, at the start of the session, against
20
20
  `version` in `~/.claude/flow/.claude-plugin/plugin.json`. The two differing means the session
21
21
  is running a **mixture** — the commands from one copy of the plugin, these shared rules from another
22
22
  — which is exactly what happens when a branch or a release candidate is loaded over an installed
@@ -224,7 +224,8 @@ the value someone wrote in the FLOW config, or it is not in effect.
224
224
  each one resolves as §2.1's table says — never approved in silence):
225
225
  1. Any push or MR/PR creation (all of `ship`).
226
226
  2. Creating or switching a branch when the base is ambiguous (not on a clean main, or a possible train/stacked branch).
227
- 3. DB schema changes or migrations.
227
+ 3. DB schema changes or migrations — writing one a schema approved with the study already lists is
228
+ not asked again (below); applying one always is.
228
229
  4. A `review` that surfaced high-severity findings — never chain into `ship` on those.
229
230
  5. The business brief written before touching code (`build`, `fix`).
230
231
 
@@ -261,6 +262,30 @@ studies a ticket there goes on to build it — unless the orchestrator launched
261
262
  (§2.1), which stops at the door to code. With `autonomy.mode: auto`, a `--study` work runs on its
262
263
  own up to the push.
263
264
 
265
+ **A schema approved with the study.** A study that changes the schema says so literally: the
266
+ `## Schema changes` section of the `flow-study` block (`/flow:work:handoff` §5) lists, one line
267
+ each and by name, every table, column, index, constraint and data copy its migrations create,
268
+ alter or drop — from `03-design.md` "Data model", the intended fix of `03-investigation.md` for a
269
+ bug — or says `none`. Approving the study approves that list, and the approval is a file in the
270
+ work folder, `approved-schema.md`: a first line saying where it was approved (`Approved at
271
+ handoff, <date>` · `Approved with the study run, <date>`), then the section verbatim. Two places
272
+ write it and nothing else does — the handoff push answered **Push — schema approved**
273
+ (`/flow:work:handoff` §4), and `/flow:work:run` §2 when the orchestrator approves a study run with
274
+ `why = start`. Then, in every mode:
275
+
276
+ - **Writing** a migration — in `build`, in `fix`, or for a fix a review asks for — whose every
277
+ object created, altered or dropped is on that list is not asked: write it, add
278
+ `{ "key": "study:approved-schema", "default": "<the objects it writes>", "phase": "<phase>" }` to
279
+ `meta.json.defaults_used[]`, and one line under "Decisions made during implementation" naming
280
+ `approved-schema.md`.
281
+ - **Anything the list does not name** — one more column, an index, a drop, a type beyond what its
282
+ line says — is hard gate 3 as always, and the question names what lies beyond the list, so the
283
+ person decides on the difference alone.
284
+ - **Applying** a migration (`validate`) and the pre-deploy SQL (`ship`) are asked as before: the
285
+ study approved what the schema becomes, not when a database changes.
286
+ - A study revision (`/flow:work:run` §2) moves `approved-schema.md` aside with the rest of the
287
+ study; the new summary is approved anew.
288
+
264
289
  ### 2.1 `unattended` — where a person would have been asked
265
290
 
266
291
  No person is there to answer a question in this mode. A question tool — `AskUserQuestion`, OpenCode's `question`,
@@ -372,9 +397,10 @@ person asking for changes, a ticket that already has code — is `/flow:work:run
372
397
  | Business brief before code (`build`, `fix`) | record — the brief is written to the phase artifact, marked `recorded (unattended)`, and travels in the MR/PR body |
373
398
  | The door to code in a study run (`build`, `fix` pre-flight) | done — `done-summary.md`, the study as `/flow:work:handoff` §5 writes it for the ticket, and one `--depends-on` per `meta.json.ticket_deps` entry |
374
399
  | Push and MR/PR creation (`ship`) | `publish` — the run commits on its own branch, writes title and body, and hands them over; the orchestrator pushes and opens the draft |
375
- | Writing a DB schema change, index or migration — in any phase, a review's own fixes included — or applying one (`validate`) | question `migration`, before the first line of it is written or run — except in `respond` and `green`, where it is blocked: a schema change agreed after the MR/PR exists goes back through `build` |
400
+ | Writing a DB schema change, index or migration — in any phase, a review's own fixes included — or applying one (`validate`) | question `migration`, before the first line of it is written or run — except in `respond` and `green`, where it is blocked: a schema change agreed after the MR/PR exists goes back through `build`. Writing one whose every object `approved-schema.md` lists is not asked (§2, a schema approved with the study) |
376
401
  | `review` with blockers or high-severity findings | question `high_findings` |
377
- | `validate` with a red suite or a criterion `unproven` | blocked — the phase does not advance and does not chain. **One exception, and it is measured, never judged**: every failing test also fails, under the same name, on the base (`git merge-base HEAD <git.default_base>`, run in a detached worktree), none of them lives in a file this diff touches, and none is the test that proves an acceptance criterion → record `{"key":"unattended:validate-red-base","default":"<n> red on HEAD and on base <short sha>: <test names>","phase":"validate"}` and advance; `ship` lists those tests under "Not verified — needs a human". Short of all three — a failure the base does not reproduce, a base that cannot be run, a test this diff touched — blocked |
402
+ | `validate` with a criterion `unproven` | blocked — the phase does not advance and does not chain |
403
+ | `validate` with a red suite | **One exception, and it is measured, never judged**: every failing test also fails, under the same name, on the base (`git merge-base HEAD <git.default_base>`, run in a detached worktree), none of them lives in a file this diff touches, and none is the test that proves an acceptance criterion → record `{"key":"unattended:validate-red-base","default":"<n> red on HEAD and on base <short sha>: <test names>","phase":"validate"}` and advance; `ship` lists those tests under "Not verified — needs a human". Short of that, **one repair round per MR/PR**: this MR/PR's plan (`05-implementation.md` / `04-fix.md`) has no `### Red suite at validate (unattended)` heading yet → write it under the plan with one unticked step per failing test (its name and the first line of its failure), each ending *fix the code, or update an assertion whose expected value this MR/PR's design or fix changed — never delete, skip or loosen a test*; record `{"key":"unattended:validate-red-loop","default":"<n> red: <test names>","phase":"validate"}`, leave `phase = build` (`fix`) and chain into `/flow:feat:build` (`/flow:bug:fix`) — whose steps then run through the phases that follow it as always, review and validate included. A review of that round treats a test the round deleted, skipped or loosened as a blocker. The heading already there → it is the same check failing a second time: blocked, naming the tests still red |
378
404
  | A product decision (§7 `decision`) | question `decision` |
379
405
  | Clarifying questions on the ticket (`start`) | question `clarify` — after the branch and the work folder exist, with the questions also written to `01-context.md` |
380
406
  | An unanswered high-severity challenge (`design`, `investigate`) | question `design_challenge` / `investigation_challenge` |
@@ -71,10 +71,12 @@ In `unattended` (flow-core §2.1) nobody is there to answer: write the brief, ma
71
71
  `recorded (unattended)` under its heading, record the site in `meta.json.defaults_used[]`, and fix.
72
72
  The gate's purpose moves to the draft MR/PR, whose body carries the brief for the person who reads it.
73
73
  **A schema change or migration is still a question** (`migration`): before writing the first line
74
- of one → the question stop, end the run. The orchestrator's answer re-enters here
74
+ of one → the question stop, end the run — unless `approved-schema.md` lists every object it
75
+ creates, alters or drops (flow-core §2, a schema approved with the study): then write it, record
76
+ it there, do not stop. The orchestrator's answer re-enters here
75
77
  exactly as `/flow:feat:build §2` says, with `04-fix.md` for `05-implementation.md` and
76
78
  `/flow:bug:validate` as the phase it chains into after a review's *Fix them* (`/flow:bug:review`
77
- for XS, which has no validate).
79
+ for XS, which has no validate), and after a red suite at validate (flow-core §2.1).
78
80
 
79
81
  **The brief travels inside the question** (flow-core §3) — read in the prompt being answered, not by opening `04-fix.md` — and **nothing runs between the brief and the question**: a tool call after it is what lets a terminal fold it away. Options:
80
82
  - **Yes, go ahead** → apply the fix.
@@ -209,6 +211,7 @@ A **product decision** the fix turns out to need is neither of these — not sco
209
211
  - `quality.style_fix`
210
212
  - `quality.static_analysis`
211
213
  - The test that covers the fix: `quality.test_one` (if none exists, `/flow:bug:validate` adds it).
214
+ - The existing tests of the modules or files the fix changed, with `quality.test_one` — the cheap catch before `/flow:bug:validate` runs the full suite. One asserting the behaviour this fix corrects is updated and named in `04-fix.md`; any other failure is a bug in the fix.
212
215
 
213
216
  ## 4.1 Is the investigation still valid?
214
217
 
@@ -93,7 +93,7 @@ this is the same gate as a red test.
93
93
 
94
94
  ## 5. Close
95
95
 
96
- - Red test, regressions, **or the original symptom still reproducible in §2.5** → `phase` stays at `fix`; the user iterates. A red gate stops in every mode (in `unattended`, the run ends `blocked` with the failing test named, flow-core §2.1 — unless every failing test also fails on the base, the one exception that row records; the reproduction test lives in a file this diff touches, so it never qualifies).
96
+ - Red test, regressions, **or the original symptom still reproducible in §2.5** → `phase` stays at `fix`; the user iterates. A red gate stops in every mode except `unattended`, where flow-core §2.1 decides: every failing test also red on the base → its exception advances (the reproduction test lives in a file this diff touches, so it never qualifies); otherwise the one repair round of that row — the failing tests become unticked steps of `04-fix.md`'s plan, `phase = fix`, chain into `/flow:bug:fix`, which chains back here; red a second time → `blocked`, naming the tests still red. The original symptom still reproducible in §2.5 is not a failing test: `blocked`, naming it.
97
97
  - Green → `phase = "validate"`, add to `phases_done`; in the same write record `validated_sha` = `git rev-parse HEAD` — the tree the regression test passed on, which `/flow:bug:ship §0` reads. Suggest `/flow:bug:review`.
98
98
  - **Other bugs detected become `followups[]` entries** (flow-core §7) when they clear its bar — a reproducible symptom with someone who suffers it, not «this looks fragile» — per the output template.
99
99
  - **Stage what the validation taught** (`knowledge.stage` set; silence by default): a mutation that stayed green, a disguise the scenario wore, a fixture that could not produce the case — findings about how this codebase is tested, not about this diff. Same rule and evidence line as the review's Close.
@@ -78,7 +78,9 @@ In `unattended` (flow-core §2.1) nobody is there to answer: write the brief, ma
78
78
  `recorded (unattended)` under its heading, record the site in `meta.json.defaults_used[]`, and build.
79
79
  The gate's purpose moves to the draft MR/PR, whose body carries the brief for the person who reads it.
80
80
  **A schema change or migration is still a question** (`migration`): before writing the first line
81
- of one → the question stop, end the run. The orchestrator's answer re-enters here
81
+ of one → the question stop, end the run — unless `approved-schema.md` lists every object it
82
+ creates, alters or drops (flow-core §2, a schema approved with the study): then write it, record
83
+ it there, do not stop. The orchestrator's answer re-enters here
82
84
  (flow-core §2.1): the brief, the contracts and the plan are already written — keep them — and the
83
85
  MR/PR is the one already `in_progress`, not a new pick. *Write it and continue* → the first unticked
84
86
  step, the migration included · *Change the design first* → `blocked`. A plan step marked approved
@@ -86,7 +88,11 @@ by an answer's `id` (a review wrote it) is that migration already answered **whe
86
88
  `meta.json.defaults_used[]` with gate `migration` and phase `review`**: write it, do not stop. Not
87
89
  there → it is a question like any other.
88
90
  Chained from a review's `high_findings` *Fix them* → the findings are unticked steps at the end of
89
- this MR/PR's plan: build them in order, then chain into `/flow:feat:review`.
91
+ this MR/PR's plan: build them in order, then chain into `/flow:feat:review`. Chained from a red
92
+ suite at validate (flow-core §2.1) → the same, under the plan's `### Red suite at validate
93
+ (unattended)`: one step per failing test, and a test reaches green by fixing the code or by an
94
+ assertion this MR/PR's design changed — never by deleting, skipping or loosening it. Run each
95
+ step's test with `quality.test_one` before ticking it.
90
96
 
91
97
  **The brief travels inside the question** (flow-core §3): the user reads it in the prompt they are answering, never by opening `05-implementation.md`. Write the file, run whatever you need, and *then* open the gate — **nothing runs between the brief and the question**, because a tool call after it is what lets a terminal fold the brief into one collapsed line, and the gate is answered blind. Options:
92
98
  - **Yes, proceed** → start building.
@@ -383,6 +389,7 @@ As larger pieces are completed:
383
389
 
384
390
  - Run `quality.style_fix` from `FLOW.md` to fix style; if empty, auto-discover (Makefile, npm scripts, Gradle, dotnet, Xcode, Flutter…).
385
391
  - Run `quality.static_analysis` from `FLOW.md` when a piece is stable; if empty, auto-discover.
392
+ - **Before closing, the tests this diff can break:** the existing tests of the modules, classes or files the diff changed, with `quality.test_one` (a filter per module or file) — not the full suite, which `/flow:feat:validate` runs. A test asserting the old behaviour that the design changes is updated now, and named under "Decisions made during implementation"; one that fails for any other reason is a bug in this build. Leaving them to validate costs a whole round.
386
393
  - If tests were added, run them individually with `quality.test_one` from `FLOW.md` (substituting `{FILTER}`); if empty, auto-discover. **A filtered run is judged by how many tests it executed, never by its exit code** — most runners exit `0` when the filter matches nothing (`OK, 0 tests`, `No tests ran`, `no tests to run`, `0 passed`). Read the executed count **and** test names: count `0`, or your new tests missing from the names → **the run did not happen**; treat as failure, fix the filter, run again. No count reported → drop the filter and run the whole test file. In "Relevant commands executed", record the count you saw, not just the command — "green" without a number is not evidence.
387
394
 
388
395
  Do not do code review here — that is `/flow:feat:review`.
@@ -224,7 +224,7 @@ Consolidate outputs into `.claude/work/<TICKET>/03-design.md`:
224
224
 
225
225
  ## Data model
226
226
  - New / modified entities: <for each new one, indicate "no equivalent found" or "knowingly duplicated because...">
227
- - Migrations:
227
+ - Migrations: <each table, column, index, constraint and data copy created, altered or dropped, by name — approving the study approves exactly this list (flow-core §2, a schema approved with the study)>
228
228
  - Indexes:
229
229
 
230
230
  ### Access paths
@@ -399,5 +399,7 @@ Write `.claude/work/<TICKET>/06-review.md`. The `Cost:` line of `## Summary` is
399
399
  unticked step under this MR/PR's plan in `05-implementation.md` (`04-fix.md` for a bug), leaves
400
400
  `phase = build` (`fix`), and chains into `/flow:feat:build` (`/flow:bug:fix`), which builds those
401
401
  steps and chains back here — a bug through `/flow:bug:validate` first, as its order has it. A migration one of this round's fixes needs is question `migration`
402
- asked here — after `high_findings`, in its own stop — and answered the same way (flow-core §2.1).
402
+ asked here — after `high_findings`, in its own stop — and answered the same way (flow-core §2.1),
403
+ unless `approved-schema.md` lists every object it writes (flow-core §2): then it is an ordinary
404
+ step, and build writes it without asking.
403
405
  """
@@ -224,11 +224,14 @@ Write `.claude/work/<TICKET>/07-validation.md`:
224
224
  - Overwrite `00-summary.md` whole (≤15 lines, flow-core §5).
225
225
  - **Autonomy handoff — this one stops in every mode, `auto` included.** `ship` pushes and opens the MR/PR: a hard gate in every mode, so do **not** chain into it. Stop here and propose `/flow:feat:ship` with a single `AskUserQuestion` (recommended option by default), invoking it only when the user confirms. This is the deliberate end of a run in `auto`.
226
226
  **In `unattended`** (flow-core §2.1): the phase advanced → chain into `/flow:feat:ship`, which
227
- hands the MR/PR to the orchestrator with `publish`. It did not advance
228
- (red suite, a criterion `unproven`) → `blocked`, naming what failed; never chain. A red suite
229
- advances only under the base exception of flow-core §2.1: run the failing tests on the base, and
230
- write each name, its result there and the base sha under "Suite results" in `07-validation.md`.
231
- Calling a failure "pre-existing" without that run is not the exception — it is a red suite.
227
+ hands the MR/PR to the orchestrator with `publish`. A criterion `unproven` → `blocked`, naming
228
+ it; never chain. A red suite advances only under the base exception of flow-core §2.1: run the
229
+ failing tests on the base, and write each name, its result there and the base sha under "Suite
230
+ results" in `07-validation.md`. Calling a failure "pre-existing" without that run is not the
231
+ exception — it is a red suite. Short of it, the red suite gets its one repair round (the same
232
+ row): the failing tests become unticked steps of this MR/PR's plan, `phase = build`, and the run
233
+ chains into `/flow:feat:build`, then review and this phase again. Red a second time → `blocked`,
234
+ naming the tests still red.
232
235
 
233
236
  In `guided`/`auto` this is, together with the brief in `/flow:feat:build §2`, **the only stop of the whole MR/PR** — everything between them ran without a person. It carries the **full stop header** and the body answers, in this order: what is green, what this MR/PR proves and what it does not, and what shipping it takes. Assume the user has read none of the build and review.
234
237
  """
@@ -104,6 +104,15 @@ Show the branch, the remote and the file list the build printed — every path,
104
104
  ask with `AskUserQuestion` **in every `autonomy.mode`**: a push leaves the machine (flow-core §2).
105
105
  **Push** · **Cancel**. Nothing between the list and the question (flow-core §3).
106
106
 
107
+ **A study that changes the schema** — its `## Schema changes` section (§5) is not `none` — shows
108
+ that section too, under the file list, and the same question carries the approval: **Push — schema
109
+ approved** · **Push — build asks first** · **Cancel**. Whoever builds it can ask no one about what
110
+ the person here already read. *Push — schema approved* → write `approved-schema.md` in the work
111
+ folder (flow-core §2, a schema approved with the study: `Approved at handoff, <date>`, then the
112
+ section verbatim), run the build block again, check its file list is the one shown plus that file,
113
+ and push that commit. *Push — build asks first* → push as it stands: build will ask `migration`
114
+ before writing the first line of it.
115
+
107
116
  ```bash handoff-push
108
117
  BRANCH='@BRANCH@'; COMMIT='@COMMIT@'
109
118
  case "$COMMIT" in ''|*[!0-9a-f]*) echo "not a commit sha: $COMMIT"; exit 1 ;; esac
@@ -140,6 +149,7 @@ the ticket read it there, never in the work folder; the receiver does not parse
140
149
  ## Acceptance criteria
141
150
  ## Design in brief
142
151
  ## MR/PR plan
152
+ ## Schema changes
143
153
  ## Risks
144
154
  <!-- end flow-study -->
145
155
  ```
@@ -148,6 +158,9 @@ the ticket read it there, never in the work folder; the receiver does not parse
148
158
  entry and its why — `Depends on #253: <why>` — so whoever approves the study sees what it waits
149
159
  for; an unattended study's `done-summary.md` is this block, so it carries them too. The plan
150
160
  lists each MR/PR with what it covers and what it waits on; a bug's plan is its single fix.
161
+ `## Schema changes` lists, one line each and by name, every table, column, index, constraint and
162
+ data copy the study's migrations create, alter or drop (flow-core §2, a schema approved with the
163
+ study), or says `none` — it is what approving the study approves, so nothing there is prose.
151
164
  - **The new body**: the body read above with the block between the two markers replaced — or, with
152
165
  no markers yet, the block appended after a blank line. Then, for each `meta.json.ticket_deps`
153
166
  entry (`/flow:feat:design` §5.1) whose line is not already a line of that body — same text,
@@ -103,6 +103,13 @@ record `{ "key": "unattended:base-caught-up", "default": "<old short sha> → <n
103
103
  ancestor → it holds commits a previous run made: leave it as it is — bringing the base into work in
104
104
  progress is the orchestrator's (flow-core §2.1).
105
105
 
106
+ **On `start`, an approved study run approves its schema** — only while no build or fix has begun,
107
+ `done-summary.md` exists (the summary a person approved) and `approved-schema.md` does not. Its
108
+ `## Schema changes` section names something → write `approved-schema.md` (flow-core §2, a schema
109
+ approved with the study: `Approved with the study run, <date>`, then the section verbatim) and
110
+ record `{ "key": "unattended:schema-approved", "default": "<n> object(s)", "phase": "run" }`. The
111
+ section says `none`, or is missing → nothing is written, and build asks as it always did.
112
+
106
113
  **A person's changes to a study, on `study`** (flow-core §2.1: they rewind it). The work's branch
107
114
  first, as above. `<work>/study-revision.md` holds the reply, as the row above wrote it. Each step
108
115
  can be run again: a run that dies part-way is finished by the next relaunch, whatever it serves.
@@ -17,7 +17,7 @@ Every `/flow-*` command assumes these rules. They are stated once, here, so a co
17
17
  carries what is specific to its phase. Read this once per session; a command that says "load
18
18
  `flow-core`" means this file.
19
19
 
20
- **This file belongs to flow `0.95.1`.** Compare it once, at the start of the session, against
20
+ **This file belongs to flow `0.97.0`.** Compare it once, at the start of the session, against
21
21
  `version` in `~/.claude/flow/.claude-plugin/plugin.json`. The two differing means the session
22
22
  is running a **mixture** — the commands from one copy of the plugin, these shared rules from another
23
23
  — which is exactly what happens when a branch or a release candidate is loaded over an installed
@@ -225,7 +225,8 @@ the value someone wrote in the FLOW config, or it is not in effect.
225
225
  each one resolves as §2.1's table says — never approved in silence):
226
226
  1. Any push or MR/PR creation (all of `ship`).
227
227
  2. Creating or switching a branch when the base is ambiguous (not on a clean main, or a possible train/stacked branch).
228
- 3. DB schema changes or migrations.
228
+ 3. DB schema changes or migrations — writing one a schema approved with the study already lists is
229
+ not asked again (below); applying one always is.
229
230
  4. A `review` that surfaced high-severity findings — never chain into `ship` on those.
230
231
  5. The business brief written before touching code (`build`, `fix`).
231
232
 
@@ -262,6 +263,30 @@ studies a ticket there goes on to build it — unless the orchestrator launched
262
263
  (§2.1), which stops at the door to code. With `autonomy.mode: auto`, a `--study` work runs on its
263
264
  own up to the push.
264
265
 
266
+ **A schema approved with the study.** A study that changes the schema says so literally: the
267
+ `## Schema changes` section of the `flow-study` block (`/flow-work-handoff` §5) lists, one line
268
+ each and by name, every table, column, index, constraint and data copy its migrations create,
269
+ alter or drop — from `03-design.md` "Data model", the intended fix of `03-investigation.md` for a
270
+ bug — or says `none`. Approving the study approves that list, and the approval is a file in the
271
+ work folder, `approved-schema.md`: a first line saying where it was approved (`Approved at
272
+ handoff, <date>` · `Approved with the study run, <date>`), then the section verbatim. Two places
273
+ write it and nothing else does — the handoff push answered **Push — schema approved**
274
+ (`/flow-work-handoff` §4), and `/flow-work-run` §2 when the orchestrator approves a study run with
275
+ `why = start`. Then, in every mode:
276
+
277
+ - **Writing** a migration — in `build`, in `fix`, or for a fix a review asks for — whose every
278
+ object created, altered or dropped is on that list is not asked: write it, add
279
+ `{ "key": "study:approved-schema", "default": "<the objects it writes>", "phase": "<phase>" }` to
280
+ `meta.json.defaults_used[]`, and one line under "Decisions made during implementation" naming
281
+ `approved-schema.md`.
282
+ - **Anything the list does not name** — one more column, an index, a drop, a type beyond what its
283
+ line says — is hard gate 3 as always, and the question names what lies beyond the list, so the
284
+ person decides on the difference alone.
285
+ - **Applying** a migration (`validate`) and the pre-deploy SQL (`ship`) are asked as before: the
286
+ study approved what the schema becomes, not when a database changes.
287
+ - A study revision (`/flow-work-run` §2) moves `approved-schema.md` aside with the rest of the
288
+ study; the new summary is approved anew.
289
+
265
290
  ### 2.1 `unattended` — where a person would have been asked
266
291
 
267
292
  No person is there to answer a question in this mode. A question tool — `AskUserQuestion`, OpenCode's `question`,
@@ -373,9 +398,10 @@ person asking for changes, a ticket that already has code — is `/flow-work-run
373
398
  | Business brief before code (`build`, `fix`) | record — the brief is written to the phase artifact, marked `recorded (unattended)`, and travels in the MR/PR body |
374
399
  | The door to code in a study run (`build`, `fix` pre-flight) | done — `done-summary.md`, the study as `/flow-work-handoff` §5 writes it for the ticket, and one `--depends-on` per `meta.json.ticket_deps` entry |
375
400
  | Push and MR/PR creation (`ship`) | `publish` — the run commits on its own branch, writes title and body, and hands them over; the orchestrator pushes and opens the draft |
376
- | Writing a DB schema change, index or migration — in any phase, a review's own fixes included — or applying one (`validate`) | question `migration`, before the first line of it is written or run — except in `respond` and `green`, where it is blocked: a schema change agreed after the MR/PR exists goes back through `build` |
401
+ | Writing a DB schema change, index or migration — in any phase, a review's own fixes included — or applying one (`validate`) | question `migration`, before the first line of it is written or run — except in `respond` and `green`, where it is blocked: a schema change agreed after the MR/PR exists goes back through `build`. Writing one whose every object `approved-schema.md` lists is not asked (§2, a schema approved with the study) |
377
402
  | `review` with blockers or high-severity findings | question `high_findings` |
378
- | `validate` with a red suite or a criterion `unproven` | blocked — the phase does not advance and does not chain. **One exception, and it is measured, never judged**: every failing test also fails, under the same name, on the base (`git merge-base HEAD <git.default_base>`, run in a detached worktree), none of them lives in a file this diff touches, and none is the test that proves an acceptance criterion → record `{"key":"unattended:validate-red-base","default":"<n> red on HEAD and on base <short sha>: <test names>","phase":"validate"}` and advance; `ship` lists those tests under "Not verified — needs a human". Short of all three — a failure the base does not reproduce, a base that cannot be run, a test this diff touched — blocked |
403
+ | `validate` with a criterion `unproven` | blocked — the phase does not advance and does not chain |
404
+ | `validate` with a red suite | **One exception, and it is measured, never judged**: every failing test also fails, under the same name, on the base (`git merge-base HEAD <git.default_base>`, run in a detached worktree), none of them lives in a file this diff touches, and none is the test that proves an acceptance criterion → record `{"key":"unattended:validate-red-base","default":"<n> red on HEAD and on base <short sha>: <test names>","phase":"validate"}` and advance; `ship` lists those tests under "Not verified — needs a human". Short of that, **one repair round per MR/PR**: this MR/PR's plan (`05-implementation.md` / `04-fix.md`) has no `### Red suite at validate (unattended)` heading yet → write it under the plan with one unticked step per failing test (its name and the first line of its failure), each ending *fix the code, or update an assertion whose expected value this MR/PR's design or fix changed — never delete, skip or loosen a test*; record `{"key":"unattended:validate-red-loop","default":"<n> red: <test names>","phase":"validate"}`, leave `phase = build` (`fix`) and chain into `/flow-feat-build` (`/flow-bug-fix`) — whose steps then run through the phases that follow it as always, review and validate included. A review of that round treats a test the round deleted, skipped or loosened as a blocker. The heading already there → it is the same check failing a second time: blocked, naming the tests still red |
379
405
  | A product decision (§7 `decision`) | question `decision` |
380
406
  | Clarifying questions on the ticket (`start`) | question `clarify` — after the branch and the work folder exist, with the questions also written to `01-context.md` |
381
407
  | An unanswered high-severity challenge (`design`, `investigate`) | question `design_challenge` / `investigation_challenge` |
@@ -75,10 +75,12 @@ In `unattended` (flow-core §2.1) nobody is there to answer: write the brief, ma
75
75
  `recorded (unattended)` under its heading, record the site in `meta.json.defaults_used[]`, and fix.
76
76
  The gate's purpose moves to the draft MR/PR, whose body carries the brief for the person who reads it.
77
77
  **A schema change or migration is still a question** (`migration`): before writing the first line
78
- of one → the question stop, end the run. The orchestrator's answer re-enters here
78
+ of one → the question stop, end the run — unless `approved-schema.md` lists every object it
79
+ creates, alters or drops (flow-core §2, a schema approved with the study): then write it, record
80
+ it there, do not stop. The orchestrator's answer re-enters here
79
81
  exactly as `/flow-feat-build §2` says, with `04-fix.md` for `05-implementation.md` and
80
82
  `/flow-bug-validate` as the phase it chains into after a review's *Fix them* (`/flow-bug-review`
81
- for XS, which has no validate).
83
+ for XS, which has no validate), and after a red suite at validate (flow-core §2.1).
82
84
 
83
85
  **The brief travels inside the question** (flow-core §3) — read in the prompt being answered, not by opening `04-fix.md` — and **nothing runs between the brief and the question**: a tool call after it is what lets a terminal fold it away. Options:
84
86
  - **Yes, go ahead** → apply the fix.
@@ -213,6 +215,7 @@ A **product decision** the fix turns out to need is neither of these — not sco
213
215
  - `quality.style_fix`
214
216
  - `quality.static_analysis`
215
217
  - The test that covers the fix: `quality.test_one` (if none exists, `/flow-bug-validate` adds it).
218
+ - The existing tests of the modules or files the fix changed, with `quality.test_one` — the cheap catch before `/flow-bug-validate` runs the full suite. One asserting the behaviour this fix corrects is updated and named in `04-fix.md`; any other failure is a bug in the fix.
216
219
 
217
220
  ## 4.1 Is the investigation still valid?
218
221
 
@@ -97,7 +97,7 @@ this is the same gate as a red test.
97
97
 
98
98
  ## 5. Close
99
99
 
100
- - Red test, regressions, **or the original symptom still reproducible in §2.5** → `phase` stays at `fix`; the user iterates. A red gate stops in every mode (in `unattended`, the run ends `blocked` with the failing test named, flow-core §2.1 — unless every failing test also fails on the base, the one exception that row records; the reproduction test lives in a file this diff touches, so it never qualifies).
100
+ - Red test, regressions, **or the original symptom still reproducible in §2.5** → `phase` stays at `fix`; the user iterates. A red gate stops in every mode except `unattended`, where flow-core §2.1 decides: every failing test also red on the base → its exception advances (the reproduction test lives in a file this diff touches, so it never qualifies); otherwise the one repair round of that row — the failing tests become unticked steps of `04-fix.md`'s plan, `phase = fix`, chain into `/flow-bug-fix`, which chains back here; red a second time → `blocked`, naming the tests still red. The original symptom still reproducible in §2.5 is not a failing test: `blocked`, naming it.
101
101
  - Green → `phase = "validate"`, add to `phases_done`; in the same write record `validated_sha` = `git rev-parse HEAD` — the tree the regression test passed on, which `/flow-bug-ship §0` reads. Suggest `/flow-bug-review`.
102
102
  - **Other bugs detected become `followups[]` entries** (flow-core §7) when they clear its bar — a reproducible symptom with someone who suffers it, not «this looks fragile» — per the output template.
103
103
  - **Stage what the validation taught** (`knowledge.stage` set; silence by default): a mutation that stayed green, a disguise the scenario wore, a fixture that could not produce the case — findings about how this codebase is tested, not about this diff. Same rule and evidence line as the review's Close.
@@ -82,7 +82,9 @@ In `unattended` (flow-core §2.1) nobody is there to answer: write the brief, ma
82
82
  `recorded (unattended)` under its heading, record the site in `meta.json.defaults_used[]`, and build.
83
83
  The gate's purpose moves to the draft MR/PR, whose body carries the brief for the person who reads it.
84
84
  **A schema change or migration is still a question** (`migration`): before writing the first line
85
- of one → the question stop, end the run. The orchestrator's answer re-enters here
85
+ of one → the question stop, end the run — unless `approved-schema.md` lists every object it
86
+ creates, alters or drops (flow-core §2, a schema approved with the study): then write it, record
87
+ it there, do not stop. The orchestrator's answer re-enters here
86
88
  (flow-core §2.1): the brief, the contracts and the plan are already written — keep them — and the
87
89
  MR/PR is the one already `in_progress`, not a new pick. *Write it and continue* → the first unticked
88
90
  step, the migration included · *Change the design first* → `blocked`. A plan step marked approved
@@ -90,7 +92,11 @@ by an answer's `id` (a review wrote it) is that migration already answered **whe
90
92
  `meta.json.defaults_used[]` with gate `migration` and phase `review`**: write it, do not stop. Not
91
93
  there → it is a question like any other.
92
94
  Chained from a review's `high_findings` *Fix them* → the findings are unticked steps at the end of
93
- this MR/PR's plan: build them in order, then chain into `/flow-feat-review`.
95
+ this MR/PR's plan: build them in order, then chain into `/flow-feat-review`. Chained from a red
96
+ suite at validate (flow-core §2.1) → the same, under the plan's `### Red suite at validate
97
+ (unattended)`: one step per failing test, and a test reaches green by fixing the code or by an
98
+ assertion this MR/PR's design changed — never by deleting, skipping or loosening it. Run each
99
+ step's test with `quality.test_one` before ticking it.
94
100
 
95
101
  **The brief travels inside the question** (flow-core §3): the user reads it in the prompt they are answering, never by opening `05-implementation.md`. Write the file, run whatever you need, and *then* open the gate — **nothing runs between the brief and the question**, because a tool call after it is what lets a terminal fold the brief into one collapsed line, and the gate is answered blind. Options:
96
102
  - **Yes, proceed** → start building.
@@ -387,6 +393,7 @@ As larger pieces are completed:
387
393
 
388
394
  - Run `quality.style_fix` from `FLOW.md` to fix style; if empty, auto-discover (Makefile, npm scripts, Gradle, dotnet, Xcode, Flutter…).
389
395
  - Run `quality.static_analysis` from `FLOW.md` when a piece is stable; if empty, auto-discover.
396
+ - **Before closing, the tests this diff can break:** the existing tests of the modules, classes or files the diff changed, with `quality.test_one` (a filter per module or file) — not the full suite, which `/flow-feat-validate` runs. A test asserting the old behaviour that the design changes is updated now, and named under "Decisions made during implementation"; one that fails for any other reason is a bug in this build. Leaving them to validate costs a whole round.
390
397
  - If tests were added, run them individually with `quality.test_one` from `FLOW.md` (substituting `{FILTER}`); if empty, auto-discover. **A filtered run is judged by how many tests it executed, never by its exit code** — most runners exit `0` when the filter matches nothing (`OK, 0 tests`, `No tests ran`, `no tests to run`, `0 passed`). Read the executed count **and** test names: count `0`, or your new tests missing from the names → **the run did not happen**; treat as failure, fix the filter, run again. No count reported → drop the filter and run the whole test file. In "Relevant commands executed", record the count you saw, not just the command — "green" without a number is not evidence.
391
398
 
392
399
  Do not do code review here — that is `/flow-feat-review`.
@@ -228,7 +228,7 @@ Consolidate outputs into `.claude/work/<TICKET>/03-design.md`:
228
228
 
229
229
  ## Data model
230
230
  - New / modified entities: <for each new one, indicate "no equivalent found" or "knowingly duplicated because...">
231
- - Migrations:
231
+ - Migrations: <each table, column, index, constraint and data copy created, altered or dropped, by name — approving the study approves exactly this list (flow-core §2, a schema approved with the study)>
232
232
  - Indexes:
233
233
 
234
234
  ### Access paths
@@ -403,4 +403,6 @@ Write `.claude/work/<TICKET>/06-review.md`. The `Cost:` line of `## Summary` is
403
403
  unticked step under this MR/PR's plan in `05-implementation.md` (`04-fix.md` for a bug), leaves
404
404
  `phase = build` (`fix`), and chains into `/flow-feat-build` (`/flow-bug-fix`), which builds those
405
405
  steps and chains back here — a bug through `/flow-bug-validate` first, as its order has it. A migration one of this round's fixes needs is question `migration`
406
- asked here — after `high_findings`, in its own stop — and answered the same way (flow-core §2.1).
406
+ asked here — after `high_findings`, in its own stop — and answered the same way (flow-core §2.1),
407
+ unless `approved-schema.md` lists every object it writes (flow-core §2): then it is an ordinary
408
+ step, and build writes it without asking.
@@ -228,10 +228,13 @@ Write `.claude/work/<TICKET>/07-validation.md`:
228
228
  - Overwrite `00-summary.md` whole (≤15 lines, flow-core §5).
229
229
  - **Autonomy handoff — this one stops in every mode, `auto` included.** `ship` pushes and opens the MR/PR: a hard gate in every mode, so do **not** chain into it. Stop here and propose `/flow-feat-ship` with a single `AskUserQuestion` (recommended option by default), invoking it only when the user confirms. This is the deliberate end of a run in `auto`.
230
230
  **In `unattended`** (flow-core §2.1): the phase advanced → chain into `/flow-feat-ship`, which
231
- hands the MR/PR to the orchestrator with `publish`. It did not advance
232
- (red suite, a criterion `unproven`) → `blocked`, naming what failed; never chain. A red suite
233
- advances only under the base exception of flow-core §2.1: run the failing tests on the base, and
234
- write each name, its result there and the base sha under "Suite results" in `07-validation.md`.
235
- Calling a failure "pre-existing" without that run is not the exception — it is a red suite.
231
+ hands the MR/PR to the orchestrator with `publish`. A criterion `unproven` → `blocked`, naming
232
+ it; never chain. A red suite advances only under the base exception of flow-core §2.1: run the
233
+ failing tests on the base, and write each name, its result there and the base sha under "Suite
234
+ results" in `07-validation.md`. Calling a failure "pre-existing" without that run is not the
235
+ exception — it is a red suite. Short of it, the red suite gets its one repair round (the same
236
+ row): the failing tests become unticked steps of this MR/PR's plan, `phase = build`, and the run
237
+ chains into `/flow-feat-build`, then review and this phase again. Red a second time → `blocked`,
238
+ naming the tests still red.
236
239
 
237
240
  In `guided`/`auto` this is, together with the brief in `/flow-feat-build §2`, **the only stop of the whole MR/PR** — everything between them ran without a person. It carries the **full stop header** and the body answers, in this order: what is green, what this MR/PR proves and what it does not, and what shipping it takes. Assume the user has read none of the build and review.
@@ -108,6 +108,15 @@ Show the branch, the remote and the file list the build printed — every path,
108
108
  ask with `AskUserQuestion` **in every `autonomy.mode`**: a push leaves the machine (flow-core §2).
109
109
  **Push** · **Cancel**. Nothing between the list and the question (flow-core §3).
110
110
 
111
+ **A study that changes the schema** — its `## Schema changes` section (§5) is not `none` — shows
112
+ that section too, under the file list, and the same question carries the approval: **Push — schema
113
+ approved** · **Push — build asks first** · **Cancel**. Whoever builds it can ask no one about what
114
+ the person here already read. *Push — schema approved* → write `approved-schema.md` in the work
115
+ folder (flow-core §2, a schema approved with the study: `Approved at handoff, <date>`, then the
116
+ section verbatim), run the build block again, check its file list is the one shown plus that file,
117
+ and push that commit. *Push — build asks first* → push as it stands: build will ask `migration`
118
+ before writing the first line of it.
119
+
111
120
  ```bash handoff-push
112
121
  BRANCH='@BRANCH@'; COMMIT='@COMMIT@'
113
122
  case "$COMMIT" in ''|*[!0-9a-f]*) echo "not a commit sha: $COMMIT"; exit 1 ;; esac
@@ -144,6 +153,7 @@ the ticket read it there, never in the work folder; the receiver does not parse
144
153
  ## Acceptance criteria
145
154
  ## Design in brief
146
155
  ## MR/PR plan
156
+ ## Schema changes
147
157
  ## Risks
148
158
  <!-- end flow-study -->
149
159
  ```
@@ -152,6 +162,9 @@ the ticket read it there, never in the work folder; the receiver does not parse
152
162
  entry and its why — `Depends on #253: <why>` — so whoever approves the study sees what it waits
153
163
  for; an unattended study's `done-summary.md` is this block, so it carries them too. The plan
154
164
  lists each MR/PR with what it covers and what it waits on; a bug's plan is its single fix.
165
+ `## Schema changes` lists, one line each and by name, every table, column, index, constraint and
166
+ data copy the study's migrations create, alter or drop (flow-core §2, a schema approved with the
167
+ study), or says `none` — it is what approving the study approves, so nothing there is prose.
155
168
  - **The new body**: the body read above with the block between the two markers replaced — or, with
156
169
  no markers yet, the block appended after a blank line. Then, for each `meta.json.ticket_deps`
157
170
  entry (`/flow-feat-design` §5.1) whose line is not already a line of that body — same text,
@@ -107,6 +107,13 @@ record `{ "key": "unattended:base-caught-up", "default": "<old short sha> → <n
107
107
  ancestor → it holds commits a previous run made: leave it as it is — bringing the base into work in
108
108
  progress is the orchestrator's (flow-core §2.1).
109
109
 
110
+ **On `start`, an approved study run approves its schema** — only while no build or fix has begun,
111
+ `done-summary.md` exists (the summary a person approved) and `approved-schema.md` does not. Its
112
+ `## Schema changes` section names something → write `approved-schema.md` (flow-core §2, a schema
113
+ approved with the study: `Approved with the study run, <date>`, then the section verbatim) and
114
+ record `{ "key": "unattended:schema-approved", "default": "<n> object(s)", "phase": "run" }`. The
115
+ section says `none`, or is missing → nothing is written, and build asks as it always did.
116
+
110
117
  **A person's changes to a study, on `study`** (flow-core §2.1: they rewind it). The work's branch
111
118
  first, as above. `<work>/study-revision.md` holds the reply, as the row above wrote it. Each step
112
119
  can be run again: a run that dies part-way is finished by the next relaunch, whatever it serves.
@@ -16,7 +16,7 @@ Every `/flow-*` command assumes these rules. They are stated once, here, so a co
16
16
  carries what is specific to its phase. Read this once per session; a command that says "load
17
17
  `flow-core`" means this file.
18
18
 
19
- **This file belongs to flow `0.95.1`.** Compare it once, at the start of the session, against
19
+ **This file belongs to flow `0.97.0`.** Compare it once, at the start of the session, against
20
20
  `version` in `~/.claude/flow/.claude-plugin/plugin.json`. The two differing means the session
21
21
  is running a **mixture** — the commands from one copy of the plugin, these shared rules from another
22
22
  — which is exactly what happens when a branch or a release candidate is loaded over an installed
@@ -224,7 +224,8 @@ the value someone wrote in the FLOW config, or it is not in effect.
224
224
  each one resolves as §2.1's table says — never approved in silence):
225
225
  1. Any push or MR/PR creation (all of `ship`).
226
226
  2. Creating or switching a branch when the base is ambiguous (not on a clean main, or a possible train/stacked branch).
227
- 3. DB schema changes or migrations.
227
+ 3. DB schema changes or migrations — writing one a schema approved with the study already lists is
228
+ not asked again (below); applying one always is.
228
229
  4. A `review` that surfaced high-severity findings — never chain into `ship` on those.
229
230
  5. The business brief written before touching code (`build`, `fix`).
230
231
 
@@ -261,6 +262,30 @@ studies a ticket there goes on to build it — unless the orchestrator launched
261
262
  (§2.1), which stops at the door to code. With `autonomy.mode: auto`, a `--study` work runs on its
262
263
  own up to the push.
263
264
 
265
+ **A schema approved with the study.** A study that changes the schema says so literally: the
266
+ `## Schema changes` section of the `flow-study` block (`/flow-work-handoff` §5) lists, one line
267
+ each and by name, every table, column, index, constraint and data copy its migrations create,
268
+ alter or drop — from `03-design.md` "Data model", the intended fix of `03-investigation.md` for a
269
+ bug — or says `none`. Approving the study approves that list, and the approval is a file in the
270
+ work folder, `approved-schema.md`: a first line saying where it was approved (`Approved at
271
+ handoff, <date>` · `Approved with the study run, <date>`), then the section verbatim. Two places
272
+ write it and nothing else does — the handoff push answered **Push — schema approved**
273
+ (`/flow-work-handoff` §4), and `/flow-work-run` §2 when the orchestrator approves a study run with
274
+ `why = start`. Then, in every mode:
275
+
276
+ - **Writing** a migration — in `build`, in `fix`, or for a fix a review asks for — whose every
277
+ object created, altered or dropped is on that list is not asked: write it, add
278
+ `{ "key": "study:approved-schema", "default": "<the objects it writes>", "phase": "<phase>" }` to
279
+ `meta.json.defaults_used[]`, and one line under "Decisions made during implementation" naming
280
+ `approved-schema.md`.
281
+ - **Anything the list does not name** — one more column, an index, a drop, a type beyond what its
282
+ line says — is hard gate 3 as always, and the question names what lies beyond the list, so the
283
+ person decides on the difference alone.
284
+ - **Applying** a migration (`validate`) and the pre-deploy SQL (`ship`) are asked as before: the
285
+ study approved what the schema becomes, not when a database changes.
286
+ - A study revision (`/flow-work-run` §2) moves `approved-schema.md` aside with the rest of the
287
+ study; the new summary is approved anew.
288
+
264
289
  ### 2.1 `unattended` — where a person would have been asked
265
290
 
266
291
  No person is there to answer a question in this mode. A question tool — `AskUserQuestion`, OpenCode's `question`,
@@ -372,9 +397,10 @@ person asking for changes, a ticket that already has code — is `/flow-work-run
372
397
  | Business brief before code (`build`, `fix`) | record — the brief is written to the phase artifact, marked `recorded (unattended)`, and travels in the MR/PR body |
373
398
  | The door to code in a study run (`build`, `fix` pre-flight) | done — `done-summary.md`, the study as `/flow-work-handoff` §5 writes it for the ticket, and one `--depends-on` per `meta.json.ticket_deps` entry |
374
399
  | Push and MR/PR creation (`ship`) | `publish` — the run commits on its own branch, writes title and body, and hands them over; the orchestrator pushes and opens the draft |
375
- | Writing a DB schema change, index or migration — in any phase, a review's own fixes included — or applying one (`validate`) | question `migration`, before the first line of it is written or run — except in `respond` and `green`, where it is blocked: a schema change agreed after the MR/PR exists goes back through `build` |
400
+ | Writing a DB schema change, index or migration — in any phase, a review's own fixes included — or applying one (`validate`) | question `migration`, before the first line of it is written or run — except in `respond` and `green`, where it is blocked: a schema change agreed after the MR/PR exists goes back through `build`. Writing one whose every object `approved-schema.md` lists is not asked (§2, a schema approved with the study) |
376
401
  | `review` with blockers or high-severity findings | question `high_findings` |
377
- | `validate` with a red suite or a criterion `unproven` | blocked — the phase does not advance and does not chain. **One exception, and it is measured, never judged**: every failing test also fails, under the same name, on the base (`git merge-base HEAD <git.default_base>`, run in a detached worktree), none of them lives in a file this diff touches, and none is the test that proves an acceptance criterion → record `{"key":"unattended:validate-red-base","default":"<n> red on HEAD and on base <short sha>: <test names>","phase":"validate"}` and advance; `ship` lists those tests under "Not verified — needs a human". Short of all three — a failure the base does not reproduce, a base that cannot be run, a test this diff touched — blocked |
402
+ | `validate` with a criterion `unproven` | blocked — the phase does not advance and does not chain |
403
+ | `validate` with a red suite | **One exception, and it is measured, never judged**: every failing test also fails, under the same name, on the base (`git merge-base HEAD <git.default_base>`, run in a detached worktree), none of them lives in a file this diff touches, and none is the test that proves an acceptance criterion → record `{"key":"unattended:validate-red-base","default":"<n> red on HEAD and on base <short sha>: <test names>","phase":"validate"}` and advance; `ship` lists those tests under "Not verified — needs a human". Short of that, **one repair round per MR/PR**: this MR/PR's plan (`05-implementation.md` / `04-fix.md`) has no `### Red suite at validate (unattended)` heading yet → write it under the plan with one unticked step per failing test (its name and the first line of its failure), each ending *fix the code, or update an assertion whose expected value this MR/PR's design or fix changed — never delete, skip or loosen a test*; record `{"key":"unattended:validate-red-loop","default":"<n> red: <test names>","phase":"validate"}`, leave `phase = build` (`fix`) and chain into `/flow-feat-build` (`/flow-bug-fix`) — whose steps then run through the phases that follow it as always, review and validate included. A review of that round treats a test the round deleted, skipped or loosened as a blocker. The heading already there → it is the same check failing a second time: blocked, naming the tests still red |
378
404
  | A product decision (§7 `decision`) | question `decision` |
379
405
  | Clarifying questions on the ticket (`start`) | question `clarify` — after the branch and the work folder exist, with the questions also written to `01-context.md` |
380
406
  | An unanswered high-severity challenge (`design`, `investigate`) | question `design_challenge` / `investigation_challenge` |
@@ -73,10 +73,12 @@ In `unattended` (flow-core §2.1) nobody is there to answer: write the brief, ma
73
73
  `recorded (unattended)` under its heading, record the site in `meta.json.defaults_used[]`, and fix.
74
74
  The gate's purpose moves to the draft MR/PR, whose body carries the brief for the person who reads it.
75
75
  **A schema change or migration is still a question** (`migration`): before writing the first line
76
- of one → the question stop, end the run. The orchestrator's answer re-enters here
76
+ of one → the question stop, end the run — unless `approved-schema.md` lists every object it
77
+ creates, alters or drops (flow-core §2, a schema approved with the study): then write it, record
78
+ it there, do not stop. The orchestrator's answer re-enters here
77
79
  exactly as `/flow-feat-build §2` says, with `04-fix.md` for `05-implementation.md` and
78
80
  `/flow-bug-validate` as the phase it chains into after a review's *Fix them* (`/flow-bug-review`
79
- for XS, which has no validate).
81
+ for XS, which has no validate), and after a red suite at validate (flow-core §2.1).
80
82
 
81
83
  **The brief travels inside the question** (flow-core §3) — read in the prompt being answered, not by opening `04-fix.md` — and **nothing runs between the brief and the question**: a tool call after it is what lets a terminal fold it away. Options:
82
84
  - **Yes, go ahead** → apply the fix.
@@ -211,6 +213,7 @@ A **product decision** the fix turns out to need is neither of these — not sco
211
213
  - `quality.style_fix`
212
214
  - `quality.static_analysis`
213
215
  - The test that covers the fix: `quality.test_one` (if none exists, `/flow-bug-validate` adds it).
216
+ - The existing tests of the modules or files the fix changed, with `quality.test_one` — the cheap catch before `/flow-bug-validate` runs the full suite. One asserting the behaviour this fix corrects is updated and named in `04-fix.md`; any other failure is a bug in the fix.
214
217
 
215
218
  ## 4.1 Is the investigation still valid?
216
219
 
@@ -95,7 +95,7 @@ this is the same gate as a red test.
95
95
 
96
96
  ## 5. Close
97
97
 
98
- - Red test, regressions, **or the original symptom still reproducible in §2.5** → `phase` stays at `fix`; the user iterates. A red gate stops in every mode (in `unattended`, the run ends `blocked` with the failing test named, flow-core §2.1 — unless every failing test also fails on the base, the one exception that row records; the reproduction test lives in a file this diff touches, so it never qualifies).
98
+ - Red test, regressions, **or the original symptom still reproducible in §2.5** → `phase` stays at `fix`; the user iterates. A red gate stops in every mode except `unattended`, where flow-core §2.1 decides: every failing test also red on the base → its exception advances (the reproduction test lives in a file this diff touches, so it never qualifies); otherwise the one repair round of that row — the failing tests become unticked steps of `04-fix.md`'s plan, `phase = fix`, chain into `/flow-bug-fix`, which chains back here; red a second time → `blocked`, naming the tests still red. The original symptom still reproducible in §2.5 is not a failing test: `blocked`, naming it.
99
99
  - Green → `phase = "validate"`, add to `phases_done`; in the same write record `validated_sha` = `git rev-parse HEAD` — the tree the regression test passed on, which `/flow-bug-ship §0` reads. Suggest `/flow-bug-review`.
100
100
  - **Other bugs detected become `followups[]` entries** (flow-core §7) when they clear its bar — a reproducible symptom with someone who suffers it, not «this looks fragile» — per the output template.
101
101
  - **Stage what the validation taught** (`knowledge.stage` set; silence by default): a mutation that stayed green, a disguise the scenario wore, a fixture that could not produce the case — findings about how this codebase is tested, not about this diff. Same rule and evidence line as the review's Close.
@@ -80,7 +80,9 @@ In `unattended` (flow-core §2.1) nobody is there to answer: write the brief, ma
80
80
  `recorded (unattended)` under its heading, record the site in `meta.json.defaults_used[]`, and build.
81
81
  The gate's purpose moves to the draft MR/PR, whose body carries the brief for the person who reads it.
82
82
  **A schema change or migration is still a question** (`migration`): before writing the first line
83
- of one → the question stop, end the run. The orchestrator's answer re-enters here
83
+ of one → the question stop, end the run — unless `approved-schema.md` lists every object it
84
+ creates, alters or drops (flow-core §2, a schema approved with the study): then write it, record
85
+ it there, do not stop. The orchestrator's answer re-enters here
84
86
  (flow-core §2.1): the brief, the contracts and the plan are already written — keep them — and the
85
87
  MR/PR is the one already `in_progress`, not a new pick. *Write it and continue* → the first unticked
86
88
  step, the migration included · *Change the design first* → `blocked`. A plan step marked approved
@@ -88,7 +90,11 @@ by an answer's `id` (a review wrote it) is that migration already answered **whe
88
90
  `meta.json.defaults_used[]` with gate `migration` and phase `review`**: write it, do not stop. Not
89
91
  there → it is a question like any other.
90
92
  Chained from a review's `high_findings` *Fix them* → the findings are unticked steps at the end of
91
- this MR/PR's plan: build them in order, then chain into `/flow-feat-review`.
93
+ this MR/PR's plan: build them in order, then chain into `/flow-feat-review`. Chained from a red
94
+ suite at validate (flow-core §2.1) → the same, under the plan's `### Red suite at validate
95
+ (unattended)`: one step per failing test, and a test reaches green by fixing the code or by an
96
+ assertion this MR/PR's design changed — never by deleting, skipping or loosening it. Run each
97
+ step's test with `quality.test_one` before ticking it.
92
98
 
93
99
  **The brief travels inside the question** (flow-core §3): the user reads it in the prompt they are answering, never by opening `05-implementation.md`. Write the file, run whatever you need, and *then* open the gate — **nothing runs between the brief and the question**, because a tool call after it is what lets a terminal fold the brief into one collapsed line, and the gate is answered blind. Options:
94
100
  - **Yes, proceed** → start building.
@@ -385,6 +391,7 @@ As larger pieces are completed:
385
391
 
386
392
  - Run `quality.style_fix` from `FLOW.md` to fix style; if empty, auto-discover (Makefile, npm scripts, Gradle, dotnet, Xcode, Flutter…).
387
393
  - Run `quality.static_analysis` from `FLOW.md` when a piece is stable; if empty, auto-discover.
394
+ - **Before closing, the tests this diff can break:** the existing tests of the modules, classes or files the diff changed, with `quality.test_one` (a filter per module or file) — not the full suite, which `/flow-feat-validate` runs. A test asserting the old behaviour that the design changes is updated now, and named under "Decisions made during implementation"; one that fails for any other reason is a bug in this build. Leaving them to validate costs a whole round.
388
395
  - If tests were added, run them individually with `quality.test_one` from `FLOW.md` (substituting `{FILTER}`); if empty, auto-discover. **A filtered run is judged by how many tests it executed, never by its exit code** — most runners exit `0` when the filter matches nothing (`OK, 0 tests`, `No tests ran`, `no tests to run`, `0 passed`). Read the executed count **and** test names: count `0`, or your new tests missing from the names → **the run did not happen**; treat as failure, fix the filter, run again. No count reported → drop the filter and run the whole test file. In "Relevant commands executed", record the count you saw, not just the command — "green" without a number is not evidence.
389
396
 
390
397
  Do not do code review here — that is `/flow-feat-review`.
@@ -226,7 +226,7 @@ Consolidate outputs into `.claude/work/<TICKET>/03-design.md`:
226
226
 
227
227
  ## Data model
228
228
  - New / modified entities: <for each new one, indicate "no equivalent found" or "knowingly duplicated because...">
229
- - Migrations:
229
+ - Migrations: <each table, column, index, constraint and data copy created, altered or dropped, by name — approving the study approves exactly this list (flow-core §2, a schema approved with the study)>
230
230
  - Indexes:
231
231
 
232
232
  ### Access paths
@@ -401,4 +401,6 @@ Write `.claude/work/<TICKET>/06-review.md`. The `Cost:` line of `## Summary` is
401
401
  unticked step under this MR/PR's plan in `05-implementation.md` (`04-fix.md` for a bug), leaves
402
402
  `phase = build` (`fix`), and chains into `/flow-feat-build` (`/flow-bug-fix`), which builds those
403
403
  steps and chains back here — a bug through `/flow-bug-validate` first, as its order has it. A migration one of this round's fixes needs is question `migration`
404
- asked here — after `high_findings`, in its own stop — and answered the same way (flow-core §2.1).
404
+ asked here — after `high_findings`, in its own stop — and answered the same way (flow-core §2.1),
405
+ unless `approved-schema.md` lists every object it writes (flow-core §2): then it is an ordinary
406
+ step, and build writes it without asking.
@@ -226,10 +226,13 @@ Write `.claude/work/<TICKET>/07-validation.md`:
226
226
  - Overwrite `00-summary.md` whole (≤15 lines, flow-core §5).
227
227
  - **Autonomy handoff — this one stops in every mode, `auto` included.** `ship` pushes and opens the MR/PR: a hard gate in every mode, so do **not** chain into it. Stop here and propose `/flow-feat-ship` with a single `AskUserQuestion` (recommended option by default), invoking it only when the user confirms. This is the deliberate end of a run in `auto`.
228
228
  **In `unattended`** (flow-core §2.1): the phase advanced → chain into `/flow-feat-ship`, which
229
- hands the MR/PR to the orchestrator with `publish`. It did not advance
230
- (red suite, a criterion `unproven`) → `blocked`, naming what failed; never chain. A red suite
231
- advances only under the base exception of flow-core §2.1: run the failing tests on the base, and
232
- write each name, its result there and the base sha under "Suite results" in `07-validation.md`.
233
- Calling a failure "pre-existing" without that run is not the exception — it is a red suite.
229
+ hands the MR/PR to the orchestrator with `publish`. A criterion `unproven` → `blocked`, naming
230
+ it; never chain. A red suite advances only under the base exception of flow-core §2.1: run the
231
+ failing tests on the base, and write each name, its result there and the base sha under "Suite
232
+ results" in `07-validation.md`. Calling a failure "pre-existing" without that run is not the
233
+ exception — it is a red suite. Short of it, the red suite gets its one repair round (the same
234
+ row): the failing tests become unticked steps of this MR/PR's plan, `phase = build`, and the run
235
+ chains into `/flow-feat-build`, then review and this phase again. Red a second time → `blocked`,
236
+ naming the tests still red.
234
237
 
235
238
  In `guided`/`auto` this is, together with the brief in `/flow-feat-build §2`, **the only stop of the whole MR/PR** — everything between them ran without a person. It carries the **full stop header** and the body answers, in this order: what is green, what this MR/PR proves and what it does not, and what shipping it takes. Assume the user has read none of the build and review.
@@ -106,6 +106,15 @@ Show the branch, the remote and the file list the build printed — every path,
106
106
  ask with `AskUserQuestion` **in every `autonomy.mode`**: a push leaves the machine (flow-core §2).
107
107
  **Push** · **Cancel**. Nothing between the list and the question (flow-core §3).
108
108
 
109
+ **A study that changes the schema** — its `## Schema changes` section (§5) is not `none` — shows
110
+ that section too, under the file list, and the same question carries the approval: **Push — schema
111
+ approved** · **Push — build asks first** · **Cancel**. Whoever builds it can ask no one about what
112
+ the person here already read. *Push — schema approved* → write `approved-schema.md` in the work
113
+ folder (flow-core §2, a schema approved with the study: `Approved at handoff, <date>`, then the
114
+ section verbatim), run the build block again, check its file list is the one shown plus that file,
115
+ and push that commit. *Push — build asks first* → push as it stands: build will ask `migration`
116
+ before writing the first line of it.
117
+
109
118
  ```bash handoff-push
110
119
  BRANCH='@BRANCH@'; COMMIT='@COMMIT@'
111
120
  case "$COMMIT" in ''|*[!0-9a-f]*) echo "not a commit sha: $COMMIT"; exit 1 ;; esac
@@ -142,6 +151,7 @@ the ticket read it there, never in the work folder; the receiver does not parse
142
151
  ## Acceptance criteria
143
152
  ## Design in brief
144
153
  ## MR/PR plan
154
+ ## Schema changes
145
155
  ## Risks
146
156
  <!-- end flow-study -->
147
157
  ```
@@ -150,6 +160,9 @@ the ticket read it there, never in the work folder; the receiver does not parse
150
160
  entry and its why — `Depends on #253: <why>` — so whoever approves the study sees what it waits
151
161
  for; an unattended study's `done-summary.md` is this block, so it carries them too. The plan
152
162
  lists each MR/PR with what it covers and what it waits on; a bug's plan is its single fix.
163
+ `## Schema changes` lists, one line each and by name, every table, column, index, constraint and
164
+ data copy the study's migrations create, alter or drop (flow-core §2, a schema approved with the
165
+ study), or says `none` — it is what approving the study approves, so nothing there is prose.
153
166
  - **The new body**: the body read above with the block between the two markers replaced — or, with
154
167
  no markers yet, the block appended after a blank line. Then, for each `meta.json.ticket_deps`
155
168
  entry (`/flow-feat-design` §5.1) whose line is not already a line of that body — same text,
@@ -105,6 +105,13 @@ record `{ "key": "unattended:base-caught-up", "default": "<old short sha> → <n
105
105
  ancestor → it holds commits a previous run made: leave it as it is — bringing the base into work in
106
106
  progress is the orchestrator's (flow-core §2.1).
107
107
 
108
+ **On `start`, an approved study run approves its schema** — only while no build or fix has begun,
109
+ `done-summary.md` exists (the summary a person approved) and `approved-schema.md` does not. Its
110
+ `## Schema changes` section names something → write `approved-schema.md` (flow-core §2, a schema
111
+ approved with the study: `Approved with the study run, <date>`, then the section verbatim) and
112
+ record `{ "key": "unattended:schema-approved", "default": "<n> object(s)", "phase": "run" }`. The
113
+ section says `none`, or is missing → nothing is written, and build asks as it always did.
114
+
108
115
  **A person's changes to a study, on `study`** (flow-core §2.1: they rewind it). The work's branch
109
116
  first, as above. `<work>/study-revision.md` holds the reply, as the row above wrote it. Each step
110
117
  can be run again: a run that dies part-way is finished by the next relaunch, whatever it serves.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flow-workflows",
3
- "version": "0.95.1",
3
+ "version": "0.97.0",
4
4
  "description": "Guided feat/bug workflows (start→ship), post-deploy monitoring and multi-agent code review, stack-agnostic. Each repo uses a shared FLOW.md plus optional harness overlay.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -3,7 +3,7 @@
3
3
  "name": "flow",
4
4
  "displayName": "Flow — guided dev workflows",
5
5
  "description": "Guided feat/bug workflows (start→ship), post-deploy monitoring and multi-agent code review, stack-agnostic. Each repo uses a shared FLOW.md plus optional harness overlay.",
6
- "version": "0.95.1",
6
+ "version": "0.97.0",
7
7
  "author": {
8
8
  "name": "Alberto Vioque",
9
9
  "email": "mashware@gmail.com"
@@ -5,6 +5,46 @@ plugin and is what `/flow:news` reads to show you what changed since your previo
5
5
 
6
6
  The canonical, richest notes live in the [GitHub Releases](https://github.com/mashware/flow-workflows/releases).
7
7
 
8
+ ## v0.97.0 — An unattended run fixes a red suite once before it blocks · 2026-10-20
9
+
10
+ **In short**
11
+ - **A red suite at validate gets one repair round.** In an unattended run, each failing test
12
+ becomes a step of the MR/PR's plan and the run goes back to build — or fix, for a bug — then
13
+ through review and validate again, as a review's *Fix them* already did.
14
+ - **Only one.** Red a second time, the run blocks and names the tests still red.
15
+ - **Green is never bought.** A test reaches green by fixing the code, or by updating an assertion
16
+ this MR/PR's own design changed. A test deleted, skipped or loosened in that round is a review
17
+ blocker.
18
+ - **The base exception comes first.** Failures the base also has still advance, as before.
19
+ - **Build and fix now run the existing tests of what they changed** before closing. A test still
20
+ asserting the old format turns red there, not a whole round later in validate.
21
+
22
+ An unattended run stopped with 2,683 tests green and 11 red, all of them work the agent could do:
23
+ an invalid name that answered 500, tests asserting the previous format, incomplete fixtures. The
24
+ validate row blocked on any red suite, while the same table blocked only on "a red suite it cannot
25
+ fix". Build ran only the tests it wrote, so fallout in other test files surfaced only at validate.
26
+ An unproven acceptance criterion still blocks. Closes #208.
27
+
28
+ ## v0.96.0 — A schema approved with the study is not asked again at build · 2026-10-20
29
+
30
+ **In short**
31
+ - **A study that changes the schema now lists it, object by object.** The study summary — the one
32
+ a handoff writes to the ticket and a study run sends to the orchestrator — gains
33
+ `## Schema changes`: every table, column, index, constraint and data copy, by name, or `none`.
34
+ - **Approving the study approves that list.** The handoff push question offers **Push — schema
35
+ approved**; a study run approved with `why = start` takes its list from the summary. Either way
36
+ the approval is written to `approved-schema.md` in the work folder.
37
+ - **Build no longer asks for a migration that is on the list.** It writes it and records it. One
38
+ more column, an index or a drop the list does not name is still the `migration` question, which
39
+ now names only what lies beyond the list.
40
+ - **Applying a migration and the pre-deploy SQL are still asked.** The study approved what the
41
+ schema becomes, not when a database changes.
42
+
43
+ An unattended build stopped before writing a migration the study had already designed in full and
44
+ a person had already approved, and the question repeated that design almost word for word. Nothing
45
+ recorded the approval in a form build could check. A study revision moves the approval aside with
46
+ the rest of the study, so a changed study is approved again. Closes #206.
47
+
8
48
  ## v0.95.1 — An unattended run waits for its tests instead of sleeping a guess · 2026-10-15
9
49
 
10
50
  **In short**