pi-dev-flow 0.96.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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.97.0] - 2026-11-23
8
+
9
+ **A standard flow asks two questions, Approve? and Verified?, and runs the rest to done. Release? answers itself over docs and test commits and a stale build. Finish files the closing reflection's own fold/drop recommendations and does release-stage items as work. Dev port? is asked only while another flow's deploy is under review.**
10
+
11
+ ### Changed
12
+ - **A standard flow asks two questions: Approve? and Verified?** The rest runs to done unless something new comes up. Measured over ~50 real flows, the operator also answered Release? most of the time, "fold as suggested" at nearly every fold/drop list, and Finish? in chat.
13
+ - **Verified? is the release word.** Release? (`ask = on-change`) now also answers itself when the only commits after Verified? are docs (`docs/`, README, CHANGELOG) or tests, and the release output names those commits. `yolo = until-release` now holds back only a standing yolo, not a Verified? the operator gave themselves. A session running an older dev-flow build is a note on the release output instead of a question. Release? is still asked for a code change after Verified?, a major bump the playbook made, and `ask = always`.
14
+ - **Finish files the closing reflection's own fold/drop recommendations** instead of asking. A fold records a note, or counts a recurrence on the row it duplicates. A drop records nothing. The output lists each one with how to undo it. A plugin finding outside the dev-flow repo is named for the operator to file upstream, never filed by the gate. `finish = always` asks fold/drop as before.
15
+ - **Release-stage checklist items are work, not a question.** The first `flow finish` stops once to list them, to be done from the main checkout. The next `flow finish` closes out, and Finish? then answers itself.
16
+ - **Dev port? is asked only while another flow's deploy is under review and running alongside is not possible.** A holder that isn't waiting on its Verified? is replaced with a note, as one past Verified? already was. A holder under review gets a second instance next to it on the next free port when `parallelDev = yes` and the measured RAM and disk fit.
17
+ - **Skill rules:** a bare "continue", "proceed", "ok" or "yes" at a pending checkpoint is its answer. Never ask before `flow start`. Never pre-ask Release? or Finish?: run the gate, which asks only when something is open.
18
+
7
19
  ## [0.96.1] - 2026-11-23
8
20
 
9
21
  **A fold flow (started with `--reflections`) always merges unreleased with no release call, and finishes without the closing reflection.**
@@ -35,9 +35,11 @@ while your feature is at plan or implement.
35
35
  A dev deploy is machine state, not branch state, so `flow verify` keeps a small registry in
36
36
  `.dev-flow/dev-ports.json` (port → slug, commit, time). `flow status` shows it.
37
37
 
38
- If the flow holding your port is already past its **Verified?** (at pre-release or release, and not
39
- re-asking it), nobody is reviewing that deploy, so verify replaces it and says so. If the holder is
40
- still being reviewed or still in implement, verify doesn't deploy. Instead it asks
38
+ If the flow holding your port isn't waiting on its **Verified?** (it's past it, still in implement,
39
+ or gone), nobody is reviewing that deploy, so verify replaces it and says so; the holder's own
40
+ verify redeploys before it asks you. If the holder is under review and the playbook says
41
+ `parallelDev = yes`, verify runs alongside on the next free port by itself, as long as a second
42
+ instance fits the measured RAM and disk. Otherwise verify doesn't deploy. Instead it asks
41
43
  **Dev port?**, showing who holds the port and how much RAM and disk are free, and offers:
42
44
 
43
45
  - **run alongside** on the next free port (`--port=<n>`). This needs `parallelDev` not set to `no`,
package/docs/gates.md CHANGED
@@ -90,9 +90,10 @@ Run without `--confirmed`, it deploys for your review:
90
90
 
91
91
  1. Fetches, and rebases the branch if main moved ahead. Conflicts or uncommitted tracked edits
92
92
  refuse, and the branch is left untouched.
93
- 2. Checks the dev port. If another flow that is past its Verified? holds it, verify takes it over
94
- and says so. If one still under review holds it, it asks **Dev port?**: run alongside on
95
- another port, replace that deploy, or wait. See [concurrency](concurrency.md).
93
+ 2. Checks the dev port. If the flow holding it isn't waiting on its Verified?, nobody is reviewing
94
+ that deploy, so verify takes it over and says so. If it is under review, verify runs alongside on
95
+ the next free port when `parallelDev = yes` and a second instance fits; otherwise it asks
96
+ **Dev port?**: replace that deploy, or wait. See [concurrency](concurrency.md).
96
97
  3. Runs the checks (re-running any that are stale or missing), the build, the `dev` deploy, and then
97
98
  the health probe against what it just deployed.
98
99
  4. Asks **Verified?**
@@ -146,17 +147,21 @@ Proves the branch is ready to ship:
146
147
  - **No re-verify is waiting.** When `flow verify` at pre-release asked Verified? again, the answer
147
148
  has to be recorded (`flow verify --confirmed`) before the release ships under it.
148
149
 
149
- **Release? often answers itself** (`ask = on-change`, the default). That happens when your call is
150
- on record and only release prep (bump, changelog) changed since Verified?. A `--confirmed` given before the gate asked doesn't count where a question carries news you haven't
150
+ **Release? usually answers itself** (`ask = on-change`, the default): your Verified? is the release
151
+ word. That happens when your call is on record and only release prep (bump, changelog), docs
152
+ (`docs/`, README, CHANGELOG) or tests changed since Verified?; the output names any docs/test commit
153
+ that rode under it. A `--confirmed` given before the gate asked doesn't count where a question carries news you haven't
151
154
  seen (commits after Verified? on a yolo flow, or a stale build): the gate asks first. A yolo held back
152
155
  only by `yolo = until-release` is asked like any flow, so your chat answer stands on the first call.
153
156
 
154
157
  It still asks when:
155
- - code changed after Verified?;
156
- - the session runs an old build (proceeding is allowed, and it says what you'd miss);
157
- - the playbook sets `yolo = until-release`;
158
+ - code changed after Verified? (a CI fix, a late review fix: news you haven't seen);
159
+ - a standing yolo reaches it and the playbook sets `yolo = until-release` (a Verified? you gave yourself is not held back);
158
160
  - it's a major bump the playbook made rather than you.
159
161
 
162
+ A session running an older dev-flow build than the install is a note on the release output, not a
163
+ question: it names both builds and what didn't run, and `/reload` picks up the newer one.
164
+
160
165
  Set `ask = always` in `## release` to be asked every time.
161
166
 
162
167
  Escape hatches, used only on your word: `--no-fold-check` skips the line-level changelog check, and
@@ -220,7 +225,10 @@ call it.
220
225
  items, it stops and lists them.
221
226
  2. Runs the after-merge checks (`flow-check` blocks under `## release`) from the main checkout. A red
222
227
  one stops finish and removes nothing.
223
- 3. Runs the **closing reflection** (see [reflections](reflections.md)) and waits for your fold/drop.
228
+ 3. Runs the **closing reflection** (see [reflections](reflections.md)) and files the reviewer's own
229
+ fold/drop recommendations: a fold becomes a note (or a recurrence on the note it duplicates), a
230
+ drop records nothing. The output lists each with how to undo it. dev-flow feedback for upstream is
231
+ named for you, never filed by the gate. `finish = always` asks fold/drop as before.
224
232
  4. Cleans up, on `--confirmed` or when Finish? answers itself: removes the worktree, the branch and `.dev-flow/<slug>/`. It deletes
225
233
  the remote branch only once it's proven merged. If local main is just behind origin, it
226
234
  fast-forwards it.
@@ -232,10 +240,11 @@ Playbook commits from `flow init --track` are only noted: they reach origin thro
232
240
  never a direct push. Under `merge = merge`, commits missing from main are a policy violation that
233
241
  yolo can't answer.
234
242
 
235
- **Finish? answers itself on a clean flow** (`finish = on-change`, the default): the release is
236
- recorded, the flow had no friction so no reflection ran, no `## release` checklist item is open, and
237
- no forge release was skipped. It still asks when any of those is open, and always with
238
- `finish = always` in `## release`.
243
+ **Finish? answers itself** (`finish = on-change`, the default) once the release is recorded, the
244
+ closing reflection was skipped or filed, and no forge release was skipped. `## release` checklist
245
+ items are work, not a question: the first `finish` stops once and lists them (run from the main
246
+ checkout), and the next `finish` closes out. It still asks when a forge release was skipped or the
247
+ reflection's report didn't parse, and always with `finish = always` in `## release`.
239
248
 
240
249
  To drop an unreleased feature, use `flow abort` instead.
241
250
 
@@ -269,7 +278,6 @@ Answering **yolo** at any checkpoint runs that gate with `--yolo --confirmed`. T
269
278
  question and pre-confirms the rest, so the agent runs the remaining gates back to back, following
270
279
  any wishes you added ("yolo, patch bump"). Every check and guard still applies. Yolo never answers:
271
280
  - the re-verify at pre-release;
272
- - Release? when code changed after Verified?, when the playbook sets `yolo = until-release`, or
273
- when the session runs an older build than the install;
281
+ - Release? when code changed after Verified?, or when the playbook sets `yolo = until-release`;
274
282
  - a `merge = merge` policy violation at finish;
275
283
  - skipping the closing reflection.
@@ -43,8 +43,12 @@ transcript and every worker's. It checks the findings against the open notes and
43
43
  issues, then gives you a numbered list. Each finding is marked docs, code or plugin, with a
44
44
  suggestion to **fold** (keep) or **drop** it.
45
45
 
46
- You answer per item, for example `fold 1,3 drop 2`. Folding records a note, or files the issue for a
47
- plugin finding. Dropping records nothing.
46
+ Finish files the reviewer's own recommendation for each finding, without asking: a fold records a
47
+ note (or counts a recurrence on the note it duplicates), a drop records nothing. The output lists
48
+ each one with how to undo it (`flow reflect done <id> "dropped"`, or `flow reflect --playbook|--code
49
+ "<note>"` to keep a drop). A plugin finding outside the dev-flow repo is an upstream issue, which is
50
+ public, so it's named for you to file and never filed by the gate. Set `finish = always` in
51
+ `## release` to answer fold/drop yourself, for example `fold 1,3 drop 2`.
48
52
 
49
53
  The review is skipped when the flow ran into no friction: no guard block, no gate refusing for a
50
54
  process reason (wrong stage, a missing plan, a proof that doesn't hold), no gate refusing twice in a
@@ -281,7 +281,7 @@ export default function devFlow(pi: ExtensionAPI) {
281
281
  /** Driver sessions with a worker running right now — one worker per session at a time. */
282
282
  const runningWorkers = new Set<string>();
283
283
 
284
- type WorkerResult = { content: { type: "text"; text: string }[]; details: { op: WorkerOp; outcome: string; verdict: string | null; commits: number; findings?: number; recorded?: boolean } | undefined; isError?: boolean };
284
+ type WorkerResult = { content: { type: "text"; text: string }[]; details: { op: WorkerOp; outcome: string; verdict: string | null; commits: number; findings?: number; recorded?: boolean; report?: ReturnType<typeof parseReflectReport> | null } | undefined; isError?: boolean };
285
285
 
286
286
  /** One fresh-session worker run for a bound flow — the body of flow_stage, shared with flow finish,
287
287
  * which runs the closing reflection itself before it removes anything (the worker reads the session
@@ -513,7 +513,7 @@ export default function devFlow(pi: ExtensionAPI) {
513
513
  if (nudges.tidy) parts.push(`${nudges.tidy} — offer it after the fold/drop answer.`);
514
514
  if (newCommits.trim() || dirty !== statusBefore) parts.push("note: the reflect worker changed the tree — inspect the change; it was told to write nothing");
515
515
  parts.push(`transcript: ${transcript || "(unknown)"}`);
516
- return { content: [{ type: "text", text: parts.join("\n\n") }], details: { op: wop, outcome, verdict: null, commits: 0, findings: reflected?.findings.length ?? 0, recorded: report.found } };
516
+ return { content: [{ type: "text", text: parts.join("\n\n") }], details: { op: wop, outcome, verdict: null, commits: 0, findings: reflected?.findings.length ?? 0, recorded: report.found, report: rows ? reflected : null } };
517
517
  }
518
518
  parts.push(
519
519
  report.found ? `REPORT:\n${report.body.slice(0, 6000)}` : modelError ? deadModelNote : `no REPORT — last words:\n${report.body}`,
@@ -544,7 +544,7 @@ export default function devFlow(pi: ExtensionAPI) {
544
544
  const finishReflectHook = (id: string, ctx: ExtensionContext, root: string, signal?: AbortSignal, onUpdate?: (u: { content: { type: "text"; text: string }[]; details: unknown }) => void): FlowHooks => ({
545
545
  reflect: async (st, note) => {
546
546
  const r = await runStageWorker({ id, wop: "reflect", st, root, key: sessionKey(ctx), note, label: "finish reflection", signal, onUpdate, ctx });
547
- return { text: r.content.map((c) => c.text).join("\n"), recorded: !!r.details?.recorded, findings: r.details?.findings ?? 0, failed: !!r.isError };
547
+ return { text: r.content.map((c) => c.text).join("\n"), recorded: !!r.details?.recorded, findings: r.details?.findings ?? 0, failed: !!r.isError, report: r.details?.report ?? undefined };
548
548
  },
549
549
  });
550
550
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev-flow",
3
- "version": "0.96.1",
3
+ "version": "0.97.0",
4
4
  "description": "Enforced feature workflow for Pi: plan → implement → pre-release → release, gated checkpoints, self-improvement reflections, one git worktree per feature, changelog + publish as part of the release",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -19,10 +19,10 @@ criteria hold. Call it with an args array — `["start", "dark-mode"]`,
19
19
  - **The flow tool is the only invocation.** There is no `flow` shell command —
20
20
  never bash, `npx` or a path.
21
21
  - **You run the gates; the operator says words.** Never ask the operator to
22
- type a `flow` or `/flow` command. A checkpoint is one word asked in plain
22
+ type a `flow` or `/flow` command. A checkpoint is one word asked in
23
23
  chat — **Approve? / Verified? / Release? / Finish?** — mentioning that
24
- *yolo* is an answer, then stop. Their word (or a clear equivalent) in chat →
25
- run that gate with `--confirmed`. A structured question tool is not chat;
24
+ *yolo* is an answer, then stop. Their word (or an equivalent, even "ok") in chat →
25
+ run that gate with `--confirmed`; never re-ask. A structured question tool is not chat;
26
26
  never infer the answer — the flow tool refuses a `--confirmed` with no
27
27
  operator message since the gate asked. A gate returning `NEEDS-OPERATOR <Question?>` means:
28
28
  ask exactly that, in chat. `/flow` is the operator's own override; mention it
@@ -14,29 +14,35 @@ unbinds the session — so anything that needs them runs first.
14
14
  reviews this session's transcript and every worker transcript, dedupes
15
15
  against `.dev-flow/reflections.md` and upstream issues, and returns
16
16
  numbered findings, each **docs** / **code** / **plugin** with a **fold**
17
- or **drop** recommendation. Finish then stops.
17
+ or **drop** recommendation. Finish files those recommendations itself
18
+ (a fold is a note or a recurrence on the row it duplicates; a drop
19
+ records nothing) and goes on — no fold/drop question. Relay the list it
20
+ prints, with its undo line. A plugin finding outside the dev-flow repo
21
+ is listed for the operator to file upstream on their word — never file
22
+ it yourself.
18
23
  - A flow with **no friction** (no guard block, no process refusal, no gate
19
24
  stuck twice in a row, no `--note`) skips the worker, unless the playbook
20
25
  says `reflect = always`. A red test or build is not friction.
21
26
  - Worker failed or died → the gate says so and nothing is removed: re-run, or review inline (bare `flow
22
27
  reflect` prints the protocol). Only the operator's explicit word skips
23
28
  it: `flow finish --no-reflect --confirmed` — yolo never does.
24
- 2. **Findings → ask fold or drop** per item — one plain line each — with
25
- your recommendation (`fold
26
- 1,3 drop 2` is a fine answer), and stop. That answer **is** Finish?.
27
- 3. **Apply it**: fold docs → `flow reflect --playbook "<note>"`; fold code →
28
- `flow reflect --code "<note>"`; fold plugin → `flow reflect --plugin
29
- "<note>"` prints the upstream recipe — search first, then `gh issue create`
30
- and report the URL. Plugin findings never go into `reflections.md`. Open
31
- items the reviewer found fixed → propose checking them off.
32
- 4. **`flow finish --confirmed`** without asking again. Nothing found → ask
33
- **Finish?** first.
34
- - **A clean flow needs no question**: no friction, no open release-stage
35
- item, nothing skipped → the first `flow finish` closes the feature and
36
- says Finish? answered itself (`finish = always` in the playbook asks
37
- every time). Report it; do not ask afterwards.
29
+ - `finish = always` in the playbook, or a report whose rows did not parse →
30
+ the gate asks **Fold or drop?** / **Finish?** as before: ask it, apply the
31
+ answer (`flow reflect --playbook|--code "<note>"`, `--same r<id>`,
32
+ `--plugin` prints the upstream recipe), then `flow finish --confirmed`.
33
+ 2. **Release-stage checklist items** (`- [ ]` under `## release`) are work:
34
+ the first `flow finish` stops once (`release-stage work —`, not a
35
+ question) and lists them. Do each from the main checkout, then run `flow
36
+ finish` again — no question to ask; report what each showed.
38
37
  - A red after-merge check (`flow-check` under `## release`, run from the
39
38
  main checkout) stops finish with its output: fix, re-run.
39
+ 3. **Never ask Finish? before calling the gate.** Run `flow finish` as soon
40
+ as the release is recorded; it answers Finish? itself when nothing is left
41
+ open, and returns `NEEDS-OPERATOR Finish?` only when something is (a
42
+ skipped forge release, `finish = always`). Report it; do not ask
43
+ afterwards.
44
+ 4. Open items the reviewer found fixed are listed as proposals — check them
45
+ off only on the operator's word (`flow reflect done r<id> "<where>"`).
40
46
  5. Offer the printed suggestions (`⚑ fix the open reflections now?`, `↻ N
41
47
  closed reflection(s)`) in one line each; never start a fix flow without
42
48
  the operator's word.
@@ -52,21 +52,22 @@ and settle the scheme with the operator; never invent one.
52
52
  6. **Run `flow release` before asking anything.** Never ask Release? in
53
53
  chat ahead of the call: the gate did not see that question, and when it
54
54
  needs the word it asks again, so the operator answers twice. By default (`ask = on-change`) it answers
55
- Release? itself when the release call is on record and only the prep
56
- landed since Verified? — say in a few lines what the PR delivers (the
55
+ Release? itself when the release call is on record and only the prep,
56
+ docs or tests landed since Verified? — the operator's Verified? is the
57
+ release word. Say in a few lines what the PR delivers (the
57
58
  changelog entry usually is that) and the version, and carry on with the
58
59
  release stage.
59
60
  7. **It returned `NEEDS-OPERATOR Release?`** (it says why: code after
60
- Verified?, no call on record, a stale build, `yolo = until-release`, a
61
- major bump, or the playbook's `ask = always`) → **ask Release? and
61
+ Verified?, no call on record, a standing yolo under `yolo =
62
+ until-release`, a major bump, or the playbook's `ask = always`) → **ask Release? and
62
63
  stop**, with the same summary and the version. Report opening:
63
64
  **🔍 pre-release · `<slug>`** (the gate's stage line; the version field
64
65
  reads `pending` until decided — never invent a bump or a no-version
65
66
  decision). Answer → `flow release --confirmed`.
66
67
  - Standing yolo → run `flow release` bare, without asking. It still returns
67
- `NEEDS-OPERATOR Release?` when commits landed after Verified?, the
68
- playbook says `yolo = until-release`, or the session build is stale —
69
- then ask. A `--confirmed` passed before the gate asked is not an answer
68
+ `NEEDS-OPERATOR Release?` when commits landed after Verified? or the
69
+ playbook says `yolo = until-release` — then ask. A stale session build is
70
+ a note in the output, never a question. A `--confirmed` passed before the gate asked is not an answer
70
71
  there: the gate asks first. Never carry the standing yolo onto the call
71
72
  as `--yolo`: the operator's answer is `flow release --confirmed`.
72
73
  - Operator ships **without a version** → `flow release --no-version
@@ -57,5 +57,5 @@ git (merge, tag, push on the default branch) is allowed only in this stage.
57
57
  - `release.artifact` set and CI publishes from the tag: the record step waits
58
58
  for that CI (up to 15 min) — no hand-run `gh run watch`.
59
59
  - After-merge work: `flow-check` blocks under `## release` are run by
60
- `flow finish` from the main checkout; `- [ ]` items there close with the
61
- Finish? answer.
60
+ `flow finish` from the main checkout; `- [ ]` items there are work — the
61
+ first `flow finish` stops once to list them, the next one closes out.
@@ -35,6 +35,8 @@ knobs · merge-policy state.
35
35
  adds the mockup gate, so don't ask. Turning it **off** is the operator's:
36
36
  `flow start <slug> --no-ui --confirmed` at plan, after they say so, and
37
37
  aborting a ui feature at plan asks the same.
38
+ - **Never ask before `flow start`**: starting only creates the plan stage;
39
+ the operator's first word is Approve?.
38
40
  - **A mode is a proposal, not a grant**: pass `--patch` or `--docs` on the
39
41
  start call when the work fits (no `--confirmed`, no question). The
40
42
  operator grants it with their **Approve?** answer — say the mode and why
package/src/core.ts CHANGED
@@ -71,6 +71,7 @@ export interface FlowState {
71
71
  reflectedAt?: string; // a reflect worker reported for this flow — finish runs one first while this is unset (only --no-reflect --confirmed skips it)
72
72
  devPort?: number; // the port the operator chose for this flow's dev deploy when the default was held by another flow — finish stops it (devDown)
73
73
  friction?: number; // process refusals, a gate refusing twice in a row, guard blocks and post-Verified? code changes this feature hit (isFriction; a red check alone is not one) — finish skips the closing reflection at 0 (playbook reflect = on-friction)
74
+ reflectApplied?: boolean; // finish filed the closing reflection's own fold/drop recommendations (no question) — like reflectQuiet, nothing is left open for Finish?
74
75
  reflectQuiet?: boolean; // finish skipped the closing reflection because the flow had no friction — with nothing else open, Finish? answers itself (release.finish = on-change)
75
76
  reviewDeploy?: { wt: string; slot: string; at: string }; // the tree (checkFingerprint) and dev slot `flow verify` deployed for the operator's review — a --confirmed over the same tree does not build and deploy it a second time
76
77
  review?: FlowReview; // the review step ran (worker or inline) or the operator skipped it — flow verify (before Verified?) and flow release refuse without one (gh#233)
@@ -758,6 +759,13 @@ export function prepFiles(cfg: Config): Set<string> {
758
759
  return new Set([cfg.versioning.file, cfg.release.changelog, cfg.versioning.file === "package.json" ? "package-lock.json" : ""].filter(Boolean) as string[]);
759
760
  }
760
761
 
762
+ /** A path that ships no behaviour an operator's look at the running app could have judged: docs and tests. A
763
+ * commit touching only these after Verified? rides under that word (named in the release output) instead of
764
+ * asking Release? again. Markdown outside docs/ is not here: a skill or prompt file is product in some repos. */
765
+ export function nonBehaviourPath(f: string): boolean {
766
+ return /^docs\//.test(f) || /^(README|CONTRIBUTING|CHANGELOG)(\.[a-z]+)?$/i.test(f) || /(^|\/)(test|tests|__tests__|spec)\//.test(f) || /\.(test|spec)\.[a-z0-9]+$/i.test(f);
767
+ }
768
+
761
769
  /** True when every changed path is a release-prep file (and something changed): the bump and the changelog
762
770
  * entry land after the checks by design, and re-running the whole suite over them proves nothing new. */
763
771
  export function prepOnlyChange(cfg: Config, changed: string[]): boolean {
@@ -2694,7 +2702,7 @@ function stageHint(state: FlowState, cfg: Config): string {
2694
2702
  return `${review}fix must/should${state.docs ? "" : " (a fix that changes behaviour: flow verify redeploys and re-asks Verified? over it)"}, update docs${prep ? `, ${prep}` : ""}; show the PR summary, version and changelog, then run flow release${gateAsks}`;
2695
2703
  }
2696
2704
  case "release":
2697
- if (state.approvals.release) return `release recorded — commit and push any release chores in the main checkout (DEV_FLOW_ALLOW_MAIN=1 for the pre-commit hook), then flow finish (closing reflection first; its fold/drop answer is Finish?)`;
2705
+ if (state.approvals.release) return `release recorded — commit and push any release chores in the main checkout (DEV_FLOW_ALLOW_MAIN=1 for the pre-commit hook), then run flow finish right away — do not ask Finish? first: it runs the closing reflection, files its suggestions and closes out, and asks only when something is left open`;
2698
2706
  if (state.publish) return `flow release publishes (push, PR, CI wait, merge${state.noVersion ? "" : ", tag"}) and records the release — re-run it after a "publish stopped" or "publish waiting" result; then flow finish`;
2699
2707
  return `publish: push the branch, open the PR, merge once CI is green (gh pr checks <n> --watch)${mergeHintFor(cfg)}${state.noVersion ? " — unversioned: no bump, no tag" : ", push the annotated tag"}; then flow finish records the release and closes out`;
2700
2708
  }
@@ -131,8 +131,10 @@ export async function devSlotCheck(o: GateCtx, state: FlowState): Promise<RunRes
131
131
  // the holder's review is over — it is past Verified? (pre-release or release) and not re-asking it, or it is
132
132
  // gone: nobody is looking at that deploy, so taking the port asks nobody (lettuce rail-avatar-size-28 asked
133
133
  // replace-or-wait over a flow that had already merged)
134
- if (!other || ((other.stage === "pre-release" || other.stage === "release") && other.pendingAsk !== "Verified?"))
135
- return { note: `dev: replaced ${slot.slug}'s deploy on ${portLabel(port)} — ${other ? `it is at ${other.stage}, past its Verified?` : "that flow is gone"}, so nobody was reviewing it` };
134
+ // The same holds for a holder that is not waiting on its Verified?: only that question puts a person in front
135
+ // of the deploy — the holder's own verify redeploys before it asks again.
136
+ if (!other || other.pendingAsk !== "Verified?")
137
+ return { note: `dev: replaced ${slot.slug}'s deploy on ${portLabel(port)} — ${other ? `it is at ${other.stage}, not waiting on its Verified?` : "that flow is gone"}, so nobody was reviewing it` };
136
138
  const taken = new Set(Object.keys(reg).map(Number).filter(Number.isFinite));
137
139
  const nextPort = port !== undefined ? await nextFreePort(port, taken) : null;
138
140
  const mem = memAvailable();
@@ -142,6 +144,12 @@ export async function devSlotCheck(o: GateCtx, state: FlowState): Promise<RunRes
142
144
  `RAM available ${mem !== null ? formatSize(mem) : "unknown"}${cfg.instanceMem !== undefined ? ` (one instance needs ${formatSize(cfg.instanceMem)})` : ""}`,
143
145
  `disk free ${disk !== null ? formatSize(disk) : "unknown"}${cfg.instanceDisk !== undefined ? ` (one instance needs ${formatSize(cfg.instanceDisk)})` : ""}`,
144
146
  ].join(", ");
147
+ // under review, and a second instance is known to fit: run alongside — nothing of the other flow is touched
148
+ if (side.ok && cfg.parallelDev === true && nextPort !== null) {
149
+ state.devPort = nextPort;
150
+ writeState(root, state);
151
+ return { note: `dev: ${portLabel(port)} is serving ${slot.slug} under review — deployed alongside on port ${nextPort} (parallelDev = yes)` };
152
+ }
145
153
  const caveat = side.ok
146
154
  ? cfg.parallelDev === undefined
147
155
  ? " The playbook does not say whether two instances can share this machine (parallelDev = yes|no) — tell the operator that when you ask."
@@ -1,7 +1,7 @@
1
1
  /** dev-flow runtime — The gate runner and the gates that do not ship anything. Moved out of extensions/dev-flow.ts as is (exports added). */
2
2
  import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3
3
  import path from "node:path";
4
- import { foldCallError, skipsChecks, approveGate, versionArg, playbookVersionChoice, releaseCallQuestion, describeVersionChoice, applicableItems, appendRoadmapItem, checklistHash, claimBlocks, doneItemCount, detectForge, gateHelpJson, healthProbe, parseMergeStyle, investigationBrief, pluginVersion, reflectProtocol, reflectUnfiledCount, reflectionNudges, reflectionRoutes, listFiles, needsOperator, newState, nextHint, openChecklistItems, releaseGate, roadmapDone, roadmapDrop, roadmapOpenCount, roadmapOpenRows, roadmapBriefFor, roadmapPick, roadmapTidy, statusJson, subst, sq, featureTmpDir, foreignWorktreeLinks, validSlug, verifyGate, STAGE_EMOJI, type ReflectTarget, type Config, type FlowState, parseRowIds, DF_GITIGNORE } from "../core.ts";
4
+ import { type ReflectFinding, type ReflectOpenCheck, foldCallError, skipsChecks, approveGate, versionArg, playbookVersionChoice, releaseCallQuestion, describeVersionChoice, applicableItems, appendRoadmapItem, checklistHash, claimBlocks, doneItemCount, detectForge, gateHelpJson, healthProbe, parseMergeStyle, investigationBrief, pluginVersion, reflectProtocol, reflectUnfiledCount, reflectionNudges, reflectionRoutes, listFiles, needsOperator, newState, nextHint, openChecklistItems, releaseGate, roadmapDone, roadmapDrop, roadmapOpenCount, roadmapOpenRows, roadmapBriefFor, roadmapPick, roadmapTidy, statusJson, subst, sq, featureTmpDir, foreignWorktreeLinks, validSlug, verifyGate, STAGE_EMOJI, type ReflectTarget, type Config, type FlowState, parseRowIds, DF_GITIGNORE } from "../core.ts";
5
5
  import { applyAnswers, buildDraft, doctorFindings, ghostFeatureDirs, ghostInfo, lineDiff, loadProject, mdDigest, parseAnswers, parseProjectMd } from "../projectmd.ts";
6
6
  import { linkedTag } from "../fold.ts";
7
7
  import { detectProject } from "../detect.ts";
@@ -14,7 +14,7 @@ import { gateFinish, gateRelease, gateReleaseDone, gateVerify } from "./ship.ts"
14
14
 
15
15
  /** What a gate may need from the extension closure: finish runs the closing reflection worker itself. */
16
16
  export interface FlowHooks {
17
- reflect?: (state: FlowState, note: string) => Promise<{ text: string; recorded: boolean; findings: number; failed: boolean }>;
17
+ reflect?: (state: FlowState, note: string) => Promise<{ text: string; recorded: boolean; findings: number; failed: boolean; report?: { findings: ReflectFinding[]; open: ReflectOpenCheck[] } }>;
18
18
  }
19
19
 
20
20
  /** Write `.dev-flow/.gitignore` when it is missing; true when it did. Best effort — never fails a gate. */
@@ -79,8 +79,9 @@ export function grantRecord(args: readonly string[], key: string, users: number
79
79
 
80
80
  /** A refusal that is the work failing, not the process: a red test, a broken build, a deploy that did not come up. */
81
81
  const WORK_FAILURE = /check run at the gate failed|\bbuild FAILED\b|dev deploy FAILED|probe FAILED|served-build check FAILED|after-merge check "[^"]*" failed|has not passed|publish stopped — PR #\d+ checks failed/;
82
- /** The release gate still waiting on CI: re-running it is the instruction, never a sign the agent is stuck. */
83
- const WAITING = /(?:^|\n)publish waiting —/;
82
+ /** The release gate still waiting on CI, or finish handing over the release-stage items: re-running it is the
83
+ * instruction, never a sign the agent is stuck. */
84
+ const WAITING = /(?:^|\n)(?:publish waiting|release-stage work) —/;
84
85
  /** `flow check|test|health` reporting a red run — the answer those tools exist to give. A refusal from them that
85
86
  * is not a run (nothing configured, no feature bound) stays friction. */
86
87
  const RED_RUN = /^(?:tier-1 checks:|test: FAIL|health: FAIL)/;
@@ -1,7 +1,7 @@
1
1
  /** dev-flow runtime — Reflections and the upstream issue fold. Moved out of extensions/dev-flow.ts as is (exports added). */
2
2
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import path from "node:path";
4
- import { ensureReflectIds as ensureReflectIdsFor, appendReflection, doneItemCount, githubSlug, pluginVersion, guessReflectSections, reflectItems, reflectMove, reflectDone, reflectRow, reflectLegacyPluginCount, reflectionNudges, pluginIssueRecipe, reflectionLine, reflectionsTidy, openChecklistItems, parseRowIds, reflectSame, reflectReopen, closedRowsBySection, archiveAppend, archiveTake, reflectFixPlan, rowId, type ReflectTarget, type ReflectItem, type ReflectSection, type FlowState } from "../core.ts";
4
+ import { ensureReflectIds as ensureReflectIdsFor, appendReflection, doneItemCount, githubSlug, pluginVersion, guessReflectSections, reflectItems, reflectMove, reflectDone, reflectRow, reflectLegacyPluginCount, reflectionNudges, pluginIssueRecipe, reflectionLine, reflectionsTidy, openChecklistItems, parseRowIds, reflectSame, reflectReopen, closedRowsBySection, archiveAppend, archiveTake, reflectFixPlan, rowId, shortFindingNote, type ReflectFinding, type ReflectOpenCheck, type ReflectTarget, type ReflectItem, type ReflectSection, type FlowState } from "../core.ts";
5
5
  import { dedupeReflections, linkedTag, parseGhIssues, similarNote, type FoldResult, type GhIssue } from "../fold.ts";
6
6
  import { dfDir, now, originUrl, readState, writeState, readReflectArchive, readReflections, readReflectionsText, reflectArchiveFile, sh } from "./base.ts";
7
7
  import { type RunResult, type Session } from "./checks.ts";
@@ -107,6 +107,54 @@ export function reflectDeferNote(root: string, sess: Session, args: string[]): R
107
107
  return { text: `reflect: r${id} deferred by ${sess.slug} — it stays open (${why}); finish closes the rest of the linked rows as fixed` };
108
108
  }
109
109
 
110
+ /** finish's closing reflection, settled without a question: the reviewer's own fold/drop recommendation is
111
+ * applied — a fold is recorded (a recurrence on the row its dup names), a drop records nothing — and the lines
112
+ * say what happened and how to undo it. A plugin fold outside the dev-flow repo is an upstream issue, which is
113
+ * public: it is named for the operator, never filed from here. */
114
+ export async function applyReflectFindings(root: string, sess: Session, report: { findings: ReflectFinding[]; open: ReflectOpenCheck[] }): Promise<string[]> {
115
+ const self = isSelfRepo(root);
116
+ const out: string[] = [];
117
+ const upstream: string[] = [];
118
+ for (const f of report.findings) {
119
+ const short = shortFindingNote(f.note);
120
+ if (f.rec === "drop") {
121
+ out.push(` ${f.n}. dropped: ${short}`);
122
+ continue;
123
+ }
124
+ const dupRow = /^r(\d+)$/i.exec(f.dup.trim());
125
+ if (dupRow) {
126
+ const same = reflectSameNote(root, sess, [`r${dupRow[1]}`, f.evidence]);
127
+ if (!same.isError) {
128
+ out.push(` ${f.n}. folded as a recurrence of r${dupRow[1]}: ${short}`);
129
+ continue;
130
+ }
131
+ }
132
+ if (/^gh#\d+$/i.test(f.dup.trim())) {
133
+ out.push(` ${f.n}. already filed as ${f.dup.trim()}: ${short}`);
134
+ continue;
135
+ }
136
+ if (f.kind === "plugin" && !self) {
137
+ upstream.push(` ${f.n}. ${short}`);
138
+ continue;
139
+ }
140
+ const r = await reflectNote(root, sess, [f.note], f.kind === "docs" ? "playbook" : "code", f.evidence);
141
+ const id = /reflected as (r\d+)/.exec(r.text)?.[1] ?? /as (r\d+)/.exec(r.text)?.[1];
142
+ out.push(` ${f.n}. folded${id ? ` as ${id}` : ""} (${f.kind === "docs" ? "playbook" : "code"}): ${short}`);
143
+ }
144
+ for (const o of report.open) {
145
+ if (o.status === "recurred") {
146
+ const same = reflectSameNote(root, sess, [`r${o.n}`, o.reason]);
147
+ if (!same.isError) out.push(` r${o.n} seen again: ${shortFindingNote(o.reason)}`);
148
+ } else if (o.status === "fixed") out.push(` r${o.n} looks fixed${o.reason ? ` (${shortFindingNote(o.reason)})` : ""} — close it on the operator's word: flow reflect done r${o.n} "<where>"`);
149
+ }
150
+ if (!out.length && !upstream.length) return ["closing reflection: nothing new to fold."];
151
+ return [
152
+ `closing reflection — the reviewer's recommendations were applied (no question; to undo a fold: flow reflect done <id> "dropped"; to keep a drop: flow reflect --playbook|--code "<note>"):`,
153
+ ...out,
154
+ ...(upstream.length ? [" dev-flow feedback to file upstream on the operator's word (flow reflect --plugin \"<note>\" prints the recipe):", ...upstream] : []),
155
+ ];
156
+ }
157
+
110
158
  /** Close the rows a flow was linked to and did not defer — finish's half of the link. Returns the ids closed. */
111
159
  export function closeLinkedReflections(root: string, state: FlowState, prNote: string): number[] {
112
160
  const linked = (state.reflections ?? []).filter((r) => !r.deferred);
@@ -1,13 +1,13 @@
1
1
  /** dev-flow runtime — The gates that ship: verify, release, release-done, finish. Moved out of extensions/dev-flow.ts as is (exports added). */
2
2
  import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3
3
  import path from "node:path";
4
- import { foldCallError, skipsChecks, applicableItems, changelogVersionsBetween, normalizeReleaseBody, pendingEntryLines, pickReleaseNotes, checklistHash, checklistPending, cmpVersions, freshenChecks, healthProbe, mergeShapeProof, preReleaseGate, reflectionNudges, conflictMarkerLines, isReleaseOnly, looksLikeShellError, needsOperator, newestTaggedVersion, nextHint, releaseGate, parseVersion, roadmapDoneForSlug, sq, tagNotesCommand, verifyGate, versionTagGate, servedBuildMatches, prepFiles, versionArg, playbookVersionChoice, describeVersionChoice, majorBump, releaseCallQuestion, releaseCallProof, cmpRelease, versionCore, resolvedDevEnv, reviewOwed, localDefaultAhead, failTail, operatorDirt } from "../core.ts";
4
+ import { foldCallError, nonBehaviourPath, skipsChecks, applicableItems, changelogVersionsBetween, normalizeReleaseBody, pendingEntryLines, pickReleaseNotes, checklistHash, checklistPending, cmpVersions, freshenChecks, healthProbe, mergeShapeProof, preReleaseGate, reflectionNudges, conflictMarkerLines, isReleaseOnly, looksLikeShellError, needsOperator, newestTaggedVersion, nextHint, releaseGate, parseVersion, roadmapDoneForSlug, sq, tagNotesCommand, verifyGate, versionTagGate, servedBuildMatches, prepFiles, versionArg, playbookVersionChoice, describeVersionChoice, majorBump, releaseCallQuestion, releaseCallProof, cmpRelease, versionCore, resolvedDevEnv, reviewOwed, localDefaultAhead, failTail, operatorDirt } from "../core.ts";
5
5
  import type { Config, FlowState } from "../core.ts";
6
6
  import { AGENT_MARK } from "../present.ts";
7
7
  import { manifestAt, recordReleaseCall, refreshDocsCode, buildSkew, copyWarning, currentBranch, featDir, flagValue, forgeMergeStyle, forgeOf, gateCwd, mergeBase, needState, now, originUrl, readReflectionsText, readRoadmap, readState, releaseTags, roadmapFile, sh, tail, worktreeAbs, writeState } from "./base.ts";
8
8
  import { type RunResult, ago, releaseDevSlot, keepThroughPrep, branchState, catchUp, describeBranchState, devEnv, devPortOf, devSlotCheck, healthRerunsAfterDeploy, pendingChecks, probeHealth, readDevPorts, runChecks, slotKey, triedNote, unreleasedOnMain, worktreeFingerprint, writeDevPorts } from "./checks.ts";
9
9
  import { type GateCtx, markPendingAsk } from "./gates.ts";
10
- import { closeLinkedReflections } from "./reflect.ts";
10
+ import { applyReflectFindings, closeLinkedReflections } from "./reflect.ts";
11
11
  import { gatePublishes, prBodyOwed, publishRelease } from "./publish.ts";
12
12
 
13
13
  /** The release call, asked with Verified? only for a flow approved before Approve? carried it — null when the
@@ -374,22 +374,17 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
374
374
  // truly behind, not merely different: a session whose loaded build is NEWER than the checkout's manifest
375
375
  // has every proof the checkout would run, and asking about it would be noise.
376
376
  const stale = !!behind && !!selfBuild.version && cmpVersions(behind, selfBuild.version) < 0;
377
- let staleAsk = "";
378
377
  let staleNote = "";
379
378
  if (stale) {
380
379
  const clPath = path.join(selfBuild.dir, "CHANGELOG.md");
381
380
  const missing = existsSync(clPath) && selfBuild.version ? changelogVersionsBetween(readFileSync(clPath, "utf8"), behind, selfBuild.version) : [];
382
- staleAsk =
383
- ` This session runs dev-flow ${behind}, ${selfBuild.label} ships ${selfBuild.version ?? "?"} — gate proofs shipped between the two will NOT run. ` +
384
- (missing.length
385
- ? `Shipped since ${behind}: ${missing.slice(0, 8).join(", ")}${missing.length > 8 ? ` …(${missing.length} total)` : ""} — see ${clPath}. `
386
- : `What shipped between them is not readable from the checkout's CHANGELOG.md — read it before deciding. `) +
387
- `Update (/reload, then re-run flow release on the current build) or proceed with the old release?`;
388
- staleNote = `released under dev-flow ${behind} (${selfBuild.label} ${selfBuild.version ?? "?"}) — the operator was asked update-or-proceed and chose to proceed; proofs newer than ${behind} did not run`;
381
+ // advisory, never a question: the operator chose the build when they loaded the session, and /reload is theirs
382
+ staleNote = `released under dev-flow ${behind} (${selfBuild.label} ships ${selfBuild.version ?? "?"}) — proofs newer than ${behind} did not run${missing.length ? ` (shipped since: ${missing.slice(0, 8).join(", ")}${missing.length > 8 ? ` …(${missing.length} total)` : ""})` : ""}; /reload picks up the newer build for the next flow`;
389
383
  }
390
384
  // #162: Verified? was answered over one tree; commits after it ship under that word unless someone says
391
385
  // so. A warning, never a refusal — doc-only moves after verify are normal; the operator decides.
392
386
  let postVerify = "";
387
+ let quietAfterVerify = "";
393
388
  let unverifiedChange = false;
394
389
  if (state!.verifiedHead) {
395
390
  // gh#180: upstream work merged in after the verdict was approved on its own branch — only the branch's
@@ -410,7 +405,10 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
410
405
  const prepSet = prepFiles(cfg);
411
406
  const isPrep = (c: { files: string[] }) => (!!cfg.versioning.file && c.files.includes(cfg.versioning.file)) || (c.files.length > 0 && c.files.every((f) => prepSet.has(f)));
412
407
  const prep = commits.filter(isPrep);
413
- const changed = commits.filter((c) => !isPrep(c));
408
+ // docs and tests ship no behaviour the operator's look could have caught: they ride under the verdict, named
409
+ const quiet = commits.filter((c) => !isPrep(c) && c.files.length > 0 && c.files.every(nonBehaviourPath));
410
+ const changed = commits.filter((c) => !isPrep(c) && !quiet.includes(c));
411
+ if (quiet.length) quietAfterVerify = `${quiet.length} docs/test-only commit(s) after Verified? (${quiet.map((c) => c.line.split(" ")[0]).join(", ")}) ride under it`;
414
412
  // changed code shipping under an earlier word is friction the closing reflection should look at
415
413
  unverifiedChange = changed.length > 0;
416
414
  if (changed.length)
@@ -430,9 +428,7 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
430
428
  ? "the playbook sets yolo = until-release: a yolo given earlier never answers Release? — ask it"
431
429
  : postVerify
432
430
  ? "a yolo given earlier does not cover commits that landed after Verified? — ask Release? with them named"
433
- : stale
434
- ? "a yolo given earlier does not choose to release under an older dev-flow build — ask Release? with the update-or-proceed question"
435
- : "";
431
+ : "";
436
432
  // gh#206: a yolo held back only by the playbook's until-release knob carries nothing new for the operator
437
433
  // to weigh — it just means "Release? is asked like on any flow". Their chat answer (a plain --confirmed)
438
434
  // stands on the first call, as it does on a flow without yolo; asking first made them repeat a word already
@@ -444,8 +440,8 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
444
440
  // this session after that point lets the flag stand, and only a true replay is asked first.
445
441
  const vm = state!.verifiedAtMessage;
446
442
  const spokeSinceVerify = !!vm && vm.key === sess.key && typeof sess.operatorMessages === "number" && sess.operatorMessages > vm.users;
447
- const untilReleaseOnly = cfg.release.yolo === "until-release" && !postVerify && !stale;
448
- const mustAskFirst = (!!holdWhy && !(untilReleaseOnly && (!flag("yolo") || spokeSinceVerify))) || stale;
443
+ const untilReleaseOnly = cfg.release.yolo === "until-release" && !postVerify;
444
+ const mustAskFirst = !!holdWhy && !(untilReleaseOnly && (!flag("yolo") || spokeSinceVerify));
449
445
  const confirmed = flag("confirmed") && !(mustAskFirst && !ui.hasUI && state!.pendingAsk !== "Release?");
450
446
  const yoloHeld = confirmed ? "" : holdWhy;
451
447
  // gh#198: release.ask = on-change — Release? answers itself when it would only re-confirm Verified?: the call
@@ -461,23 +457,19 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
461
457
  ? `the release call changes (${state!.versionChoice ?? "none"} → ${relArg.choice}) — changing it is the operator's word`
462
458
  : postVerify
463
459
  ? "commits beyond release prep landed after Verified?"
464
- : stale
465
- ? "the session build is behind the checkout"
466
- : cfg.release.yolo === "until-release"
467
- ? "the playbook sets yolo = until-release"
468
- : choice === "next" && newest && manifestVer && majorBump(newest, manifestVer)
460
+ : choice === "next" && newest && manifestVer && majorBump(newest, manifestVer)
469
461
  ? `${newest} → ${manifestVer} is a major bump — the playbook's versioned call does not choose that`
470
462
  : "";
471
463
  const auto = onChange && !askWhy;
472
- let audit = confirmed ? " (confirmed by operator instruction)" : auto ? ` (auto-answered: release.ask = on-change — ${describeVersionChoice(choice ?? "next", state!.versionFrom)} is the call on record, and only release prep landed since Verified?)` : state!.yolo ? " (yolo: pre-confirmed)" : "";
464
+ let audit = confirmed ? " (confirmed by operator instruction)" : auto ? ` (auto-answered: release.ask = on-change — ${describeVersionChoice(choice ?? "next", state!.versionFrom)} is the call on record, and only release prep${quietAfterVerify ? ", docs or tests" : ""} landed since Verified?)` : state!.yolo ? " (yolo: pre-confirmed)" : "";
473
465
  const askPending = !auto && !confirmed && (!state!.yolo || !!yoloHeld);
474
466
  if (askPending) {
475
467
  markPendingAsk(root, state!, "Release?");
476
468
  if (!ui.hasUI) {
477
469
  const callAsk = cfg.versioning.file && !choice ? " — also ask the release call: a patch, minor or major release, or merge unreleased (no bump, no tag)?" : "";
478
- return { text: needsOperator(`ready to publish${yoloHeld ? ` (${yoloHeld})` : ""}${askWhy ? ` (asked: ${askWhy})` : ""}${stale ? ` — also: ${staleAsk}` : ""}${postVerify ? ` — ${postVerify}` : ""}${callAsk}`, "Release?", `re-run with --confirmed once the operator answered 'Release?' in chat${stale ? " (and the stale-build question)" : ""}${callAsk ? " (add --version=patch|minor|major or --no-version for their release call)" : ""}`), isError: true };
470
+ return { text: needsOperator(`ready to publish${yoloHeld ? ` (${yoloHeld})` : ""}${askWhy ? ` (asked: ${askWhy})` : ""}${postVerify ? ` — ${postVerify}` : ""}${callAsk}`, "Release?", `re-run with --confirmed once the operator answered 'Release?' in chat${callAsk ? " (add --version=patch|minor|major or --no-version for their release call)" : ""}`), isError: true };
479
471
  }
480
- const ok = await ui.confirm("Enter release", `Release ${state!.slug}${manifestVer ? ` v${manifestVer}` : ""}${noVersion ? " (unversioned — merge + changelog entry only: no bump, no tag for this flow)" : ""}? Publishing starts: PR, merge${noVersion ? "" : ", tag"} — release-done afterwards needs no further answer.${staleAsk ? `\n\n${staleAsk}` : ""}${postVerify ? `\n\n${postVerify}` : ""}${yoloHeld ? `\n\n(${yoloHeld})` : ""}`);
472
+ const ok = await ui.confirm("Enter release", `Release ${state!.slug}${manifestVer ? ` v${manifestVer}` : ""}${noVersion ? " (unversioned — merge + changelog entry only: no bump, no tag for this flow)" : ""}? Publishing starts: PR, merge${noVersion ? "" : ", tag"} — release-done afterwards needs no further answer.${staleNote ? `\n\n${staleNote}` : ""}${postVerify ? `\n\n${postVerify}` : ""}${yoloHeld ? `\n\n(${yoloHeld})` : ""}`);
481
473
  if (!ok) {
482
474
  delete state!.pendingAsk;
483
475
  writeState(root, state!);
@@ -511,7 +503,7 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
511
503
  if (selfPublish) state!.publish = {};
512
504
  else delete state!.publish;
513
505
  writeState(root, state!);
514
- const approved = `release approved${audit}${state!.noVersion ? " — unversioned: no bump or tag; your changelog entry rides under Unreleased until the next versioned release folds it" : ""} — entering release stage.${manifestVer ? ` Version ${manifestVer}.` : ""}${checksNote}${foldNote}${staleNote ? ` ${staleNote}.` : ""}${postVerify ? ` Warning: ${postVerify}.` : ""}\n${describeBranchState(branchProof, cfg.defaultBranch)}`;
506
+ const approved = `release approved${audit}${state!.noVersion ? " — unversioned: no bump or tag; your changelog entry rides under Unreleased until the next versioned release folds it" : ""} — entering release stage.${manifestVer ? ` Version ${manifestVer}.` : ""}${checksNote}${foldNote}${staleNote ? ` ${staleNote}.` : ""}${postVerify ? ` Warning: ${postVerify}.` : ""}${quietAfterVerify ? ` ${quietAfterVerify}.` : ""}\n${describeBranchState(branchProof, cfg.defaultBranch)}`;
515
507
  if (selfPublish) return publishAndRecord(o, state!, approved);
516
508
  return { text: `${approved}\n${AGENT_MARK}next: ${nextHint(state!, cfg)}` };
517
509
  }
@@ -717,7 +709,7 @@ export async function gateReleaseDone(o: GateCtx): Promise<RunResult> {
717
709
  const tailNote = [
718
710
  // a session that shipped from behind: the code it runs is not the code the checkout just released
719
711
  state!.staleBuild
720
- ? `stale build acknowledged at release gate: this session ran dev-flow ${state!.staleBuild} — proofs newer than it did not run.`
712
+ ? `stale build noted at the release gate: this session ran dev-flow ${state!.staleBuild} — proofs newer than it did not run.`
721
713
  : skew.behind
722
714
  // #117: the pair (session vs what the disk ships) makes the warning actionable where it prints;
723
715
  // a second registered copy is what made the skew confusing on the report — name it too
@@ -745,15 +737,6 @@ export async function gateFinish(o: GateCtx): Promise<RunResult> {
745
737
  // gh#205: release-stage items (a post-merge build, a deploy check from the default branch) are work done after
746
738
  // the merge. A separate release-done names them while the worktree still stands; folded into finish, one
747
739
  // call recorded the release and removed everything, so an unversioned flow never saw them. Stop once here.
748
- const cur = readState(o.root, state.slug) ?? state;
749
- if (checklistPending(o.cfg, cur, "release")) {
750
- markPendingAsk(o.root, cur, "Finish?");
751
- const items = applicableItems(o.cfg, cur, "release").map((i) => `"${i.text}"`).join(" | ");
752
- return {
753
- text: `${recorded}\n\n${needsOperator(`release recorded — nothing was removed yet: the release-stage checklist (## release in .dev-flow/project.md) is still open: ${items}`, "Finish?", `do each release-stage item now (they run after the merge, from ${o.cfg.defaultBranch} — not the worktree), tell the operator what each showed, then ask Finish? and run flow finish --confirmed when they answer`)}`,
754
- isError: true,
755
- };
756
- }
757
740
  const fin = await gateFinishCore(o);
758
741
  return { ...fin, text: `${recorded}\n\n${fin.text}` };
759
742
  }
@@ -853,6 +836,17 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
853
836
  // yolo works uniformly at every gate: at Finish? nothing later remains to pre-confirm, the flag just answers this one
854
837
  const yoloWord = takeYoloWord(state!);
855
838
  if (yoloWord) return { text: yoloWord, isError: true };
839
+ // gh#205: release-stage items are work done after the merge, from the main checkout — stop once so it is done
840
+ // while the worktree still stands. It is work, not a question: the next finish goes on (finish = always asks).
841
+ const relItems = applicableItems(cfg, state!, "release");
842
+ if (checklistPending(cfg, state!, "release") && cfg.release.finish !== "always") {
843
+ state!.confirmations = { ...state!.confirmations, release: { hash: checklistHash(relItems), at: now() } };
844
+ writeState(root, state!);
845
+ return {
846
+ text: `release-stage work — the release is recorded and nothing was removed yet: the release-stage checklist (## release in .dev-flow/project.md) is work to do now, from ${cfg.defaultBranch} (the main checkout, not the worktree): ${relItems.map((i) => `"${i.text}"`).join(" | ")}\n${AGENT_MARK}next: do each item, then run flow finish again — no question to ask; say in your report what each showed`,
847
+ isError: true,
848
+ };
849
+ }
856
850
  // The closing reflection runs here, before anything is removed: the worker reads this session's
857
851
  // transcripts and .dev-flow/<slug>/tmp, and finish is about to drop that folder and the binding — a
858
852
  // reflection asked for after finish has nothing bound to run against. Only the operator's explicit
@@ -872,6 +866,7 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
872
866
  writeState(root, state!);
873
867
  }
874
868
  const quietNote = quiet && fold ? " closing reflection skipped: a fold flow (it fixes reflections, it does not review for new ones)." : quiet ? " closing reflection skipped: no refusals, guard blocks or unverified changes this flow (playbook reflect = always runs it anyway)." : "";
869
+ let appliedLines: string[] = [];
875
870
  if (!state!.reflectedAt && !skipReflect) {
876
871
  const skipHint = "or — only on the operator's explicit word — flow finish --no-reflect --confirmed";
877
872
  if (!o.hooks.reflect) return { text: `finish: no reflection recorded for ${state!.slug} and no reflect worker available here — run flow_stage(op: "reflect") first, ${skipHint}`, isError: true };
@@ -887,12 +882,20 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
887
882
  const cur = readState(root, state!.slug) ?? state!; // the worker stamped reflectedAt on disk
888
883
  if (!r.recorded)
889
884
  return { text: `finish: the closing reflection did not report — nothing was removed.\n\n${r.text}\n\nNext: re-run flow finish to retry, or review inline (bare flow reflect prints the protocol) and then flow_stage(op: "reflect"), ${skipHint}.`, isError: true };
890
- if (!r.findings) {
885
+ // the reviewer's own fold/drop recommendation is applied, and reported with how to undo it: the operator
886
+ // answered "fold as suggested" to nearly every list. finish = always, or rows that did not parse, still ask.
887
+ if (r.report && cfg.release.finish !== "always") {
888
+ appliedLines = await applyReflectFindings(root, sess, r.report);
889
+ Object.assign(state!, readState(root, state!.slug) ?? cur);
890
+ state!.reflectApplied = true;
891
+ writeState(root, state!);
892
+ } else if (!r.findings) {
891
893
  markPendingAsk(root, cur, "Finish?");
892
894
  return { text: needsOperator(`the closing reflection found nothing new to fold — nothing was removed yet; on your word the worktree, branch and .dev-flow/${state!.slug}/ go.\n\n${r.text}`, "Finish?", "ask the operator Finish? and run flow finish --confirmed when they answer"), isError: true };
895
+ } else {
896
+ markPendingAsk(root, cur, "Fold or drop?");
897
+ return { text: needsOperator(`the closing reflection has findings — nothing was removed yet; your fold/drop answer also finishes the feature.\n\n${r.text}`, "Fold or drop?", `the fold/drop answer is the Finish? answer: apply it, then run flow finish --confirmed without asking again — the worktree, branch and .dev-flow/${state!.slug}/ go on that run`), isError: true };
893
898
  }
894
- markPendingAsk(root, cur, "Fold or drop?");
895
- return { text: needsOperator(`the closing reflection has findings — nothing was removed yet; your fold/drop answer also finishes the feature.\n\n${r.text}`, "Fold or drop?", `the fold/drop answer is the Finish? answer: apply it, then run flow finish --confirmed without asking again — the worktree, branch and .dev-flow/${state!.slug}/ go on that run`), isError: true };
896
899
  }
897
900
  const reflectSkipNote = skipReflect && !state!.reflectedAt ? ` Reflection skipped on the operator's word — nothing re-checked this session or the open reflections.` : "";
898
901
  // Finish? answers itself on a clean flow (release.finish = on-change, the default): the release is recorded,
@@ -900,7 +903,7 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
900
903
  // the question had no decision left in it. Anything open (a reflection that ran, release-stage items, a
901
904
  // forge release that failed, a skipped reflection) still asks.
902
905
  const openReleaseItems = checklistPending(cfg, state!, "release");
903
- const autoFinish = cfg.release.finish !== "always" && !flag("confirmed") && !state!.yolo && !!state!.reflectQuiet && !openReleaseItems && !forgeSkipNote && !skipReflect;
906
+ const autoFinish = cfg.release.finish !== "always" && !flag("confirmed") && !state!.yolo && (!!state!.reflectQuiet || !!state!.reflectApplied) && !openReleaseItems && !forgeSkipNote && !skipReflect;
904
907
  const autoNote = autoFinish ? " Finish? answered itself (finish = on-change): the release is recorded, nothing was skipped and nothing is open." : "";
905
908
  const askPending = !flag("confirmed") && !state!.yolo && !autoFinish;
906
909
  if (askPending) {
@@ -965,5 +968,5 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
965
968
  // finish is the moment between flows: name the fix / tidy suggestion when a rule fires, nothing otherwise
966
969
  const nudge = reflectionNudges(readReflectionsText(root), now().slice(0, 10), { between: true });
967
970
  const nudgeNote = [nudge.fix, nudge.tidy].filter(Boolean).map((n) => ` ${n} — offer it to the operator.`).join("");
968
- return { text: `feature ${state!.slug} done — ${closeNote}${remoteNote}; .dev-flow/${state!.slug}/ removed.${devDownNote}${roadmapNote}${reflNote}${forgeSkipNote}${reflectSkipNote}${quietNote}${releaseChecksNote}${autoNote}${syncNote}${nudgeNote} Re-read flow status before reporting open flows — a sibling feature may have finished while this session ran.` };
971
+ return { text: `feature ${state!.slug} done — ${closeNote}${remoteNote}; .dev-flow/${state!.slug}/ removed.${devDownNote}${roadmapNote}${reflNote}${forgeSkipNote}${reflectSkipNote}${quietNote}${releaseChecksNote}${autoNote}${syncNote}${nudgeNote}${appliedLines.length ? `\n${appliedLines.join("\n")}\n` : ""} Re-read flow status before reporting open flows — a sibling feature may have finished while this session ran.` };
969
972
  }