pi-dev-flow 0.93.0 → 0.94.2

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,32 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.94.2] - 2026-11-19
8
+
9
+ **Publishes 0.94.1's fix: you're asked Release? once. 0.94.1 never reached npm because a flaky test failed its publish run.**
10
+
11
+ ### Fixed
12
+ - **A malformed session pid always reads as dead.** `pidAlive("123")` was meant to treat a malformed pid as dead, but `process.kill` turned it into pid 123. On a machine where a process with that pid existed, the claim read as alive, and that failed the 0.94.1 publish run. `pidAlive` now treats anything but a positive integer as dead without checking for the process.
13
+
14
+ ## [0.94.1] - 2026-11-19
15
+
16
+ **You're asked Release? once: the gate asks it, never the agent ahead of the call, and your answer after Verified? stands even when the agent carries a yolo onto it.**
17
+
18
+ ### Fixed
19
+ - **You're asked Release? once (gh#254, gh#253).** The pre-release hint told the agent to ask Release? in chat and then run `flow release`. The gate never saw that question, so when it needed your word (`yolo = until-release`, commits after Verified?, a stale build) it asked again, and you answered twice. A PR-body refusal could also land after your answer. The hint now says to run `flow release` first and ask only when it returns `NEEDS-OPERATOR Release?`. Under `yolo = until-release` the injected yolo note no longer claims Release? is pre-confirmed, and says to run `flow release` without `--yolo`. When the agent still adds `--yolo` to your answer, the gate accepts it if you've sent a message since Verified?. A yolo replayed with nothing said since is still asked first (gh#219).
20
+
21
+ ## [0.94.0] - 2026-11-19
22
+
23
+ **The review runs before Verified?, so you're asked Verified? once; an unanswered re-verify holds the release; your Release? word stands on the first call under `yolo = until-release`; and `flow roadmap done` closes the items you named.**
24
+
25
+ ### Changed
26
+ - **The review runs before Verified?, so you're asked Verified? once (gh#248).** The review step ran after your Verified?, so every finding changed the tree you had already approved and the agent asked again. One flow asked three times. The review now runs in implement once `flow check` is green, and the first `flow verify` refuses until one is on record (a review worker records itself; an inline one is recorded with `flow review done "<verdict>"`). Your one look covers the tree that ships. A flow already at pre-release without a review still owes it at release.
27
+
28
+ ### Fixed
29
+ - **An unanswered re-verify holds the release (gh#249).** When `flow verify` at pre-release asked Verified? again, nothing recorded that it was waiting. The agent took your "verified", went straight to release prep and shipped without recording it, so the release went out under the older word with only a warning. `flow release` now refuses until the answer is recorded with `flow verify --confirmed`.
30
+ - **Your Release? word stands on the first call under `yolo = until-release` (gh#206).** On a yolo flow the knob made the gate ask Release? itself first, so an answer you had already given in chat was refused twice and you had to repeat it. A plain `--confirmed` now stands like on any flow. A replayed `--yolo --confirmed` (gh#219) and a release with commits after Verified? or a stale build are still asked first.
31
+ - **`flow roadmap done` closes the items you named (gh#245).** The list was numbered over open items only, so closing item 6 renumbered the rest: for "close 6 and 7", a second `done 7` hit the item that used to be 8. Numbers are now row numbers: a done item keeps its row, so the other numbers stay where the list printed them. `done 6,7` closes several in one call, and one bad number closes none. `drop` takes a batch too, and `drop` and `tidy` say the numbers changed.
32
+
7
33
  ## [0.93.0] - 2026-11-18
8
34
 
9
35
  **`flow release` needs a review on record and opens the PR with the body your template asks for; checks stay passed across a commit of the same tree; feature worktrees take only their own feature's work; and `flow finish` names what is really wrong.**
package/docs/gates.md CHANGED
@@ -88,6 +88,7 @@ Run without `--confirmed`, it deploys for your review:
88
88
  4. Asks **Verified?**
89
89
 
90
90
  It refuses if:
91
+ - no review is on record (see below);
91
92
  - the branch has no commits (except a release-only flow on a versioned project with unreleased
92
93
  commits on main);
93
94
  - a check, the build or the post-deploy health probe fails;
@@ -102,8 +103,17 @@ With `--confirmed`, it never rewrites history. If main moved since the review de
102
103
  your review, it only checks that the app still answers. If the tree changed, or the app stopped
103
104
  answering, it deploys again.
104
105
 
105
- **At pre-release, `verify` is the re-verify:** after review fixes, it re-runs the build, deploy and
106
- probes on the current tree and asks Verified? again. A standing yolo never answers this.
106
+ **The review comes before Verified?** The playbook's review step (`release.review`, `/flow-review`
107
+ by default) runs in implement, once `flow check` is green, and the first `flow verify` refuses until
108
+ it is on record: a `flow_stage` review worker records itself, and an inline review is recorded with
109
+ `flow review done "<verdict>"`. Run after Verified?, every review finding changed the tree you had
110
+ already approved and you were asked again. Reviewed first, your one look covers the tree that ships.
111
+ Docs flows and release-only cuts owe none, `review = ""` under `## release` turns it off, and
112
+ skipping it is your call (`flow review --skip`, asked as **Skip review?**).
113
+
114
+ **At pre-release, `verify` is the re-verify:** after a late fix, it re-runs the build, deploy and
115
+ probes on the current tree and asks Verified? again. A standing yolo never answers this, and
116
+ `flow release` refuses until the answer is recorded with `flow verify --confirmed`.
107
117
 
108
118
  ## release: Release?
109
119
 
@@ -122,15 +132,16 @@ Proves the branch is ready to ship:
122
132
  before a commit holding only release prep (version file, changelog) stay green without a re-run;
123
133
  set `recheck = always` in `## release` to re-run them anyway. `release.preflight` passes if set.
124
134
  - There are no leftover conflict markers (`<<<<<<<`) and no uncommitted files in the worktree.
125
- - **A review is on record.** The playbook's review step (`release.review`, `/flow-review` by
126
- default) has to have run: a `flow_stage` review worker records itself, and an inline review is
127
- recorded with `flow review done "<verdict>"`. The verdict stays advisory; only that a review ran
128
- is checked. Shipping without one is your call (`flow review --skip`, asked as **Skip review?**).
129
- Docs flows and release-only cuts owe none, and `review = ""` under `## release` turns it off.
135
+ - **A review is on record.** It normally ran before Verified? (see [verify](#verify-verified)); a
136
+ flow that reached pre-release without one owes it here. The verdict stays advisory; only that a
137
+ review ran is checked.
138
+ - **No re-verify is waiting.** When `flow verify` at pre-release asked Verified? again, the answer
139
+ has to be recorded (`flow verify --confirmed`) before the release ships under it.
130
140
 
131
141
  **Release? often answers itself** (`ask = on-change`, the default). That happens when your call is
132
- on record and only release prep (bump, changelog) changed since Verified?. A `--confirmed` given before the gate asked doesn't count where a question must be put (a held yolo,
133
- or a stale build): the gate asks first.
142
+ 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
143
+ seen (commits after Verified? on a yolo flow, or a stale build): the gate asks first. A yolo held back
144
+ only by `yolo = until-release` is asked like any flow, so your chat answer stands on the first call.
134
145
 
135
146
  It still asks when:
136
147
  - code changed after Verified?;
@@ -213,7 +224,7 @@ To drop an unreleased feature, use `flow abort` instead.
213
224
  ## reflect, roadmap, doctor
214
225
 
215
226
  - `flow reflect …` manages the notes queue. See [reflections](reflections.md).
216
- - `flow roadmap [add "<feature>" [--slug=] [--brief=] | pick <n> <slug> | done <n> | drop <n> | tidy]`
227
+ - `flow roadmap [add "<feature>" [--slug=] [--brief=] | pick <n> <slug> | done <n>[,<n>…] | drop <n>[,<n>…] | tidy]` — `<n>` is the row number the list prints; `done` leaves the others in place, `drop` and `tidy` renumber
217
228
  manages `.dev-flow/roadmap.md`. `pick` stamps an item for `flow start <slug>`, and `finish` checks
218
229
  it off when the feature ships.
219
230
  - `flow doctor ["<note>"]` is a read-only health report: playbook drift, dead commands, ghost
package/docs/playbook.md CHANGED
@@ -178,7 +178,7 @@ These go under `## pre-release` or `## release`. Either section works.
178
178
  | `recheck` | `prep-skip` | `prep-skip`: checks stay green across a commit that holds only the version bump and changelog. `always`: re-run them. |
179
179
  | `yolo` | `all` | `until-release`: a yolo given earlier never answers Release?. The gate asks, and only your answer to that question releases. |
180
180
  | `reflect` | `on-friction` | `always`: run the closing reflection on every finish |
181
- | `review` | `/flow-review` | the review step at pre-release. `flow release` requires one on record (see [gates](gates.md#release-release)); set it empty to turn that off. |
181
+ | `review` | `/flow-review` | the review step, run in implement before Verified?. `flow verify` requires one on record (see [gates](gates.md#verify-verified)), and so does `flow release`; set it empty to turn that off. |
182
182
  | `preflight` | — | runs in the worktree at `flow release` before anything ships, for example `docker build .` |
183
183
  | `artifact` | — | proves the release was published, for example `npm view <pkg>@{version} version` |
184
184
  | `releases` | `true` | `false` skips creating a forge release |
@@ -120,6 +120,7 @@ export default function devFlow(pi: ExtensionAPI) {
120
120
  return {
121
121
  key,
122
122
  slug: bindings.get(key) ?? null,
123
+ operatorMessages: operatorMessageCount((() => { try { return ctx.sessionManager?.getBranch(); } catch { return null; } })()),
123
124
  bind: (slug) => {
124
125
  const prev = bindings.get(key);
125
126
  bindings.set(key, slug);
@@ -526,7 +527,7 @@ export default function devFlow(pi: ExtensionAPI) {
526
527
  name: "flow_stage",
527
528
  label: "Stage worker",
528
529
  description:
529
- 'Optional: hand a slice of work to a fresh pi session so this conversation stays lean. op "implement" (stage implement) — the worker edits and commits a slice on the feature branch; op "review" (implement or pre-release) — a fresh read-only reviewer that returns findings and a PASS/FAIL verdict (the verdict is advisory; that a review ran is recorded — flow release requires a review on record); op "reflect" (any stage; flow finish runs it itself before cleanup) — a fresh read-only reviewer of this session\'s transcript and every worker transcript that returns classified reflection findings (docs / code / plugin) with a fold-or-drop recommendation each, for the operator to decide. The plan path, branch, commits so far and the project checks are added to the brief automatically — `note` is just the slice: what to do, operator answers and decisions the worker cannot see. The worker holds no flow tool; gates and checkpoints stay with you. Delegate an implement slice when it is in the plan, provable by flow check, needs no operator input mid-slice and is big enough (≈4+ files or heavy reading) to crowd this context; small work, small fixes, mid-debug work, operator-judged work and final integration stay inline (criteria: references/implement.md). In pi-web the worker appears in the session\'s Agents menu as a subagent (running while it works, then its final status); the opened transcript holds its report.',
530
+ 'Optional: hand a slice of work to a fresh pi session so this conversation stays lean. op "implement" (stage implement) — the worker edits and commits a slice on the feature branch; op "review" (implement or pre-release) — a fresh read-only reviewer that returns findings and a PASS/FAIL verdict (the verdict is advisory; that a review ran is recorded — run it in implement once flow check is green: flow verify requires a review on record before it asks Verified?); op "reflect" (any stage; flow finish runs it itself before cleanup) — a fresh read-only reviewer of this session\'s transcript and every worker transcript that returns classified reflection findings (docs / code / plugin) with a fold-or-drop recommendation each, for the operator to decide. The plan path, branch, commits so far and the project checks are added to the brief automatically — `note` is just the slice: what to do, operator answers and decisions the worker cannot see. The worker holds no flow tool; gates and checkpoints stay with you. Delegate an implement slice when it is in the plan, provable by flow check, needs no operator input mid-slice and is big enough (≈4+ files or heavy reading) to crowd this context; small work, small fixes, mid-debug work, operator-judged work and final integration stay inline (criteria: references/implement.md). In pi-web the worker appears in the session\'s Agents menu as a subagent (running while it works, then its final status); the opened transcript holds its report.',
530
531
  promptSnippet: 'flow_stage(op: "implement"|"review"|"reflect", note, label?) — optional fresh-session worker for a big implement slice, an independent review, or a reflection (flow finish runs the closing one itself); gates stay with you; in pi-web workers show up as subagents in the Agents menu',
531
532
  parameters: Type.Object({
532
533
  op: Type.String({ description: '"implement" (a worker edits + commits a slice), "review" (read-only reviewer, findings + verdict) or "reflect" (read-only reviewer of the session transcripts, reflection findings + fold/drop recommendations)' }),
@@ -907,7 +908,11 @@ export default function devFlow(pi: ExtensionAPI) {
907
908
  return { message: { customType: "dev-flow-context", display: false, content: `${core}${sameAsLast(key, content, `[dev-flow] no flow bound — unchanged since the last [dev-flow] note (playbook map is ${path.join(SKILL_DIR, "SKILL.md")}).`)}` } };
908
909
  }
909
910
  const guidance: string[] = [];
910
- if (state.yolo) guidance.push("YOLO mode: the operator pre-confirmed every gate question from here on (Verified?/Release?/Finish?) — run the remaining gates (verify → release → finish) back to back without stopping to ask; guidance the operator attached to the yolo word (e.g. patch bump, no tag) is a binding directive for the chain; checks and guardrails stay fully enforced.");
911
+ // gh#254: under yolo = until-release the standing word does not answer Release? — saying it did sent the agent
912
+ // to carry it onto the call as --yolo --confirmed, which the gate reads as a replay and asks again
913
+ if (state.yolo && cfg.release.yolo === "until-release")
914
+ guidance.push("YOLO mode (until-release): the operator pre-confirmed Verified? and Finish? — run verify and finish without stopping to ask; Release? is NOT pre-confirmed (the playbook sets yolo = until-release). Run flow release bare — never with --yolo — and when it returns NEEDS-OPERATOR Release?, ask Release? in chat, stop, and on their answer re-run flow release --confirmed (plus --version=… / --no-version if they named the call). Guidance the operator attached to the yolo word (e.g. patch bump, no tag) is a binding directive for the chain; checks and guardrails stay fully enforced.");
915
+ else if (state.yolo) guidance.push("YOLO mode: the operator pre-confirmed every gate question from here on (Verified?/Release?/Finish?) — run the remaining gates (verify → release → finish) back to back without stopping to ask; guidance the operator attached to the yolo word (e.g. patch bump, no tag) is a binding directive for the chain; checks and guardrails stay fully enforced.");
911
916
  // The one playbook file this stage needs, named outright: the model reads it instead of
912
917
  // guessing what a stage asks of it, and it pays for itself the first time a gate is refused.
913
918
  const ref = stageReference(state.stage);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev-flow",
3
- "version": "0.93.0",
3
+ "version": "0.94.2",
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": [
@@ -71,8 +71,8 @@ The stage injection names the file to read now; this is the map.
71
71
  | --- | --- |
72
72
  | `references/start.md` | `flow init`, starting a feature, modes (`--patch`, `--docs`, `--ui`), merge policy |
73
73
  | `references/plan.md` | plan — research, clarify, plan file, mockups, Approve? |
74
- | `references/implement.md` | implement — worktree, commits, checks, workers, Verified? |
75
- | `references/pre-release.md` | pre-release — review, docs, changelog + bump, Release? |
74
+ | `references/implement.md` | implement — worktree, commits, checks, workers, review, Verified? |
75
+ | `references/pre-release.md` | pre-release — docs, changelog + bump, Release? |
76
76
  | `references/release.md` | release — PR, CI, merge, tag; hands over to finish |
77
77
  | `references/finish.md` | finish — closing reflection, fold/drop, cleanup |
78
78
  | `references/reflect.md` | reflections and the roadmap backlog |
@@ -22,6 +22,14 @@ note). Other sessions' worktrees are theirs.
22
22
  5. UI feature → a real browser visual pass, not just a typecheck.
23
23
  6. Walk the **tier-2 checklist** (`- [ ]` items) with the operator honestly —
24
24
  it cannot be scripted.
25
+ 7. **Review before Verified?**: once `flow check` is green, run the playbook's
26
+ review step (`/flow-review`, or `flow_stage` op `"review"` for a fresh
27
+ reviewer); fix every **Must fix** and **Should fix**, `flow check` again,
28
+ then record it: `flow review done "<verdict in a line>"` (a worker records
29
+ itself). `flow verify` refuses until a review is on record, so the
30
+ operator's Verified? covers the reviewed tree and review fixes never re-ask
31
+ it. Run the review once; skipping it is the operator's word
32
+ (`flow review --skip`, asked as **Skip review?**).
25
33
 
26
34
  ### Verified? — two calls
27
35
 
@@ -51,7 +59,8 @@ note). Other sessions' worktrees are theirs.
51
59
  deploy again when the tree is the one it deployed for review — it only
52
60
  probes that the app still answers. If the
53
61
  default branch moved since the review deploy it refuses: run `flow verify`
54
- again first. Fixes → iterate and re-verify; that loop is free.
62
+ again first. Fixes → iterate and re-verify; that loop is free (a fix that
63
+ changes behaviour needs no new review unless it is large).
55
64
 
56
65
  Verify lands the feature in **pre-release**. A `--docs` feature runs no
57
66
  project command and asks only the question.
@@ -9,15 +9,14 @@ release gate hands over.
9
9
  tags are `versioning.pattern` rendered from it. No `versioning.file` → stop
10
10
  and settle the scheme with the operator; never invent one.
11
11
 
12
- 1. **Review**: `/flow-review` the change; fix every **Must fix** and **Should
13
- fix**; `flow check` again if code changed. Then record it:
14
- `flow review done "<verdict in a line>"` (a `flow_stage` review worker records
15
- itself). `flow release` refuses until a review is on record; shipping without
16
- one is the operator's word (`flow review --skip`, asked as **Skip review?**).
12
+ 1. **Review**: it ran in implement, before Verified? — don't run it again.
13
+ A flow that reached pre-release without one (started on an older dev-flow)
14
+ runs it now: `/flow-review`, fix, `flow check`, `flow review done
15
+ "<verdict>"`; `flow release` refuses until a review is on record.
17
16
  - A fix that changes behaviour → `flow verify` again: it redeploys, then
18
17
  ask **Verified?** over the fixed build and run `flow verify --confirmed`
19
18
  on the answer (stays in pre-release; a standing yolo does not answer it).
20
- Otherwise `flow release` warns that the fix shipped after Verified?.
19
+ `flow release` refuses while that re-verify is unanswered.
21
20
  2. **Docs**: update them to match the change.
22
21
  3. **Changelog + bump** — manifest, changelog heading and tag must agree;
23
22
  commit the prep on the feature branch. The release call recorded with
@@ -44,7 +43,9 @@ and settle the scheme with the operator; never invent one.
44
43
  refuses without it.
45
44
  5. No `flow check` is owed after the prep commit: the gate keeps green checks across a commit that
46
45
  holds only the bump and changelog, and runs any stale check itself.
47
- 6. **Run `flow release`.** By default (`ask = on-change`) it answers
46
+ 6. **Run `flow release` before asking anything.** Never ask Release? in
47
+ chat ahead of the call: the gate did not see that question, and when it
48
+ needs the word it asks again, so the operator answers twice. By default (`ask = on-change`) it answers
48
49
  Release? itself when the release call is on record and only the prep
49
50
  landed since Verified? — say in a few lines what the PR delivers (the
50
51
  changelog entry usually is that) and the version, and carry on with the
@@ -60,7 +61,8 @@ and settle the scheme with the operator; never invent one.
60
61
  `NEEDS-OPERATOR Release?` when commits landed after Verified?, the
61
62
  playbook says `yolo = until-release`, or the session build is stale —
62
63
  then ask. A `--confirmed` passed before the gate asked is not an answer
63
- there: the gate asks first.
64
+ there: the gate asks first. Never carry the standing yolo onto the call
65
+ as `--yolo`: the operator's answer is `flow release --confirmed`.
64
66
  - Operator ships **without a version** → `flow release --no-version
65
67
  --confirmed`: no bump or tag, but the branch must add its line under
66
68
  `Unreleased`. A changed call is `--version=<v>` / `--no-version` with
@@ -54,6 +54,8 @@ never gating.
54
54
  --slug=<slug> --brief=<notes>` — `flow start <slug>` later seeds the plan
55
55
  from the brief. A hand-made `.dev-flow/<slug>/plan/` is a ghost; `flow start
56
56
  <slug> --confirmed` adopts it.
57
- - Shipped outside a flow: `flow roadmap done <n>`; `flow roadmap tidy` drops
58
- checked lines. Not wanted any more (never built): `flow roadmap drop <n>` —
59
- `done` would claim it shipped.
57
+ - Shipped outside a flow: `flow roadmap done <n>` (several: `done 6,7` in one
58
+ call); `flow roadmap tidy` drops checked lines. Not wanted any more (never
59
+ built): `flow roadmap drop <n>` — `done` would claim it shipped.
60
+ - `<n>` is the row number `flow roadmap` prints: `done` leaves every other
61
+ number in place; `drop` and `tidy` renumber, so list again after them.
@@ -4,7 +4,7 @@ description: >
4
4
  Read-only senior-engineer review of a change before it ships: correct, safe,
5
5
  holds under load, tested, fast, lean — judged also against the flow's plan.
6
6
  Report only, changes no code. Use for "review this", "code review", "is this
7
- ready to ship?", and as the dev-flow pre-release review step. Default target:
7
+ ready to ship?", and as the dev-flow review step (implement, before Verified?). Default target:
8
8
  the bound flow's branch diff against the default branch.
9
9
  argument-hint: "[ref | base..head | file...]"
10
10
  ---
package/src/core.ts CHANGED
@@ -53,20 +53,25 @@ export interface FlowState {
53
53
  forgeReleaseSkipped?: string; // a gh/glab release create that failed: release-done says so, finish names it so the missing forge release cannot slip past (#63)
54
54
  staleBuild?: string; // release ran under an older dev-flow than the checkout by operator choice ("<loaded> (checkout <disk>)"); release-done repeats the acknowledgement
55
55
  pendingAsk?: string; // the checkpoint word a gate asked for and has not been given ("Approve?", "Verified?", …) — presentation only (💬 in the footer), it never gates
56
+ /** when flow verify at pre-release asked Verified? over review fixes; cleared by the answer — flow release refuses while it is set */
57
+ reverifyAsked?: string;
56
58
  releaseOnly?: boolean; // verify found nothing on the branch but unreleased work on main: this flow only cuts the version (#161)
57
59
  versionChoice?: string; // the operator's release call, recorded with Verified? (gh#198): patch | minor | major (counted from the newest tag at release, so a parallel flow taking the number moves it), an exact version, "next" (playbook version = versioned: any bump past the last tag) or "unreleased"
58
60
  versionFrom?: string; // the manifest version when the call was recorded — what a patch/minor/major call was counted from at Verified?
61
+ /** the session and its operator-message count when Verified? moved this flow to pre-release (gh#254): under
62
+ * yolo = until-release, a message after it is the operator's own Release? word, not a replayed plan-stage yolo */
63
+ verifiedAtMessage?: { key: string; users: number };
59
64
  verifiedHead?: string; // HEAD the operator's Verified? was given over — release names commits after it, so the word is not recorded as the verdict for a tree nobody looked at (#162)
60
65
  reflectedAt?: string; // a reflect worker reported for this flow — finish runs one first while this is unset (only --no-reflect --confirmed skips it)
61
66
  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)
62
67
  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)
63
68
  reflectQuiet?: boolean; // finish skipped the closing reflection because the flow had no friction — with nothing else open, Finish? answers itself (release.finish = on-change)
64
69
  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
65
- review?: FlowReview; // the pre-release review step ran (worker or inline) or the operator skipped it — flow release refuses without one (gh#233)
70
+ 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)
66
71
  aborted?: string; // flow abort on a feature whose worktree exists: the state is a deliberate abandoned-feature record (gh#138) — the doctor's git-consistency sweep must never flag its hand-removed worktree as drift
67
72
  }
68
73
 
69
- /** A recorded pre-release review: `worker` (a flow_stage review worker reported), `inline` (the agent ran the
74
+ /** A recorded review (run in implement, before Verified?): `worker` (a flow_stage review worker reported), `inline` (the agent ran the
70
75
  * playbook's review step and recorded it with `flow review done`), or `skipped` (the operator's word). */
71
76
  export interface FlowReview {
72
77
  by: "worker" | "inline" | "skipped";
@@ -1756,6 +1761,8 @@ export interface SessionClaim {
1756
1761
 
1757
1762
  /** Whether a process is running (kill 0 only probes existence; EPERM means it exists, foreign-owned). */
1758
1763
  export function pidAlive(pid: number): boolean {
1764
+ // a corrupt value is dead, never probed: process.kill coerces "123" to pid 123, which may be a live process
1765
+ if (!Number.isInteger(pid) || pid <= 0) return false;
1759
1766
  try {
1760
1767
  process.kill(pid, 0);
1761
1768
  return true;
@@ -2251,45 +2258,57 @@ export function roadmapBriefFor(text: string, slug: string): { item: string; bri
2251
2258
  /** Number of open roadmap items. */
2252
2259
  export const roadmapOpenCount = (text: string) => openChecklistItems(text).length;
2253
2260
 
2254
- /** Stamp the nth open item (1-based, open items only) with `(slug)` — the pick→finish handshake.
2255
- * Returns null when n is out of range. Re-picking the same slug is a no-op stamp. */
2256
- export function roadmapPick(text: string, n: number, slug: string): string | null {
2257
- let seen = 0;
2261
+ /** gh#245: roadmap numbers are row numbers over every item, open and done, the way reflections number
2262
+ * theirs (gh#197). Numbered over open items only, `done 6` shifted the old 7 into 6, so "close 6 and 7"
2263
+ * closed one item twice over and the wrong one went with it. A done item keeps its row, so closing one
2264
+ * leaves every other number where `list` printed it; drop and tidy remove rows and renumber. */
2265
+ const isRoadmapRow = (l: string) => isOpenItem(l) || isDoneItem(l);
2266
+
2267
+ /** The open items with their row numbers — what `flow roadmap` lists and pick/done/drop take. */
2268
+ export function roadmapOpenRows(text: string): { row: number; item: string }[] {
2269
+ let row = 0;
2270
+ const out: { row: number; item: string }[] = [];
2271
+ for (const l of text.split("\n")) {
2272
+ if (!isRoadmapRow(l)) continue;
2273
+ row++;
2274
+ if (isOpenItem(l)) out.push({ row, item: l.trim().slice(6) });
2275
+ }
2276
+ return out;
2277
+ }
2278
+
2279
+ /** Rewrite the open item at row n (rows count open and done items, 1-based); null when row n is no open item. */
2280
+ function editOpenRow(text: string, n: number, edit: (line: string) => string): string | null {
2281
+ let row = 0;
2258
2282
  let hit = false;
2259
2283
  const out = text.split("\n").map((l) => {
2260
- if (!isOpenItem(l)) return l;
2261
- ++seen;
2262
- if (seen !== n) return l;
2284
+ if (!isRoadmapRow(l) || ++row !== n || !isOpenItem(l)) return l;
2263
2285
  hit = true;
2264
- return l.trim().includes(`(${slug})`) ? l.trim() : `${l.trim()} (${slug})`;
2286
+ return edit(l);
2265
2287
  });
2266
2288
  return hit ? out.join("\n") : null;
2267
2289
  }
2268
2290
 
2269
- /** Check the nth open item (1-based, open items only) with a done stamp. Returns null when n is out of range. */
2291
+ /** Stamp the open item at row n with `(slug)` — the pick→finish handshake. Null when row n is no open item.
2292
+ * Re-picking the same slug is a no-op stamp. */
2293
+ export function roadmapPick(text: string, n: number, slug: string): string | null {
2294
+ return editOpenRow(text, n, (l) => (l.trim().includes(`(${slug})`) ? l.trim() : `${l.trim()} (${slug})`));
2295
+ }
2296
+
2297
+ /** Check the open item at row n with a done stamp. Null when row n is no open item. */
2270
2298
  export function roadmapDone(text: string, n: number, stamp: string): string | null {
2271
- let seen = 0;
2272
- let hit = false;
2273
- const out = text.split("\n").map((l) => {
2274
- if (!isOpenItem(l)) return l;
2275
- ++seen;
2276
- if (seen !== n) return l;
2277
- hit = true;
2278
- return stampItem(l, stamp);
2279
- });
2280
- return hit ? out.join("\n") : null;
2299
+ return editOpenRow(text, n, (l) => stampItem(l, stamp));
2281
2300
  }
2282
2301
 
2283
- /** Remove the nth open item (1-based, open items only) and its brief — an idea the operator no longer
2284
- * wants, which `done` would record as shipped. Returns null when n is out of range. */
2302
+ /** Remove the open item at row n and its brief — an idea the operator no longer wants, which `done` would
2303
+ * record as shipped. Null when row n is no open item. */
2285
2304
  export function roadmapDrop(text: string, n: number): { text: string; item: string } | null {
2286
- let seen = 0;
2305
+ let row = 0;
2287
2306
  let item: string | null = null;
2288
2307
  let dropping = false;
2289
2308
  const out = text.split("\n").filter((l) => {
2290
2309
  if (isBriefLine(l)) return !dropping;
2291
2310
  dropping = false;
2292
- if (!isOpenItem(l) || ++seen !== n) return true;
2311
+ if (!isRoadmapRow(l) || ++row !== n || !isOpenItem(l)) return true;
2293
2312
  item = l.trim().slice(6);
2294
2313
  dropping = true;
2295
2314
  return false;
@@ -2387,7 +2406,9 @@ export function nextHint(state: FlowState, cfg: Config): string {
2387
2406
  const open = openItemsNote(cfg, state, "implement");
2388
2407
  return `edit in ${state.worktree} (docs mode: no project commands)${open ? `, go through the checklist with the operator (${open})` : ""}, ask Verified?, then flow verify --confirmed`;
2389
2408
  }
2390
- return `build and test in ${state.worktree}, commit as you go, flow check; then flow verify (deploys for review), look yourself, keep the app running, ask Verified? and run flow verify --confirmed on the answer`;
2409
+ // the review comes before Verified? (flow verify refuses until it is on record), so the operator's one look covers the reviewed tree
2410
+ const rv = reviewOwed(state, cfg) ? `; then the review — ${cfg.release.review}, fix what it finds and record it (flow review done "<verdict>"; a flow_stage review worker records itself)` : "";
2411
+ return `build and test in ${state.worktree}, commit as you go, flow check${rv}; then flow verify (deploys for review), look yourself, keep the app running, ask Verified? and run flow verify --confirmed on the answer`;
2391
2412
  case "pre-release": {
2392
2413
  // gh#198: the release call made with Verified? decides which prep this is
2393
2414
  const vc = state.versionChoice;
@@ -2395,12 +2416,15 @@ export function nextHint(state: FlowState, cfg: Config): string {
2395
2416
  const rv = reviewOwed(state, cfg) ? `${cfg.release.review} (then record it: flow review done "<verdict>")` : cfg.release.review && state.review ? "review on record" : "";
2396
2417
  const review = rv ? `${rv}, ` : "";
2397
2418
  const auto = cfg.release.ask !== "always" ? " (release.ask = on-change: it asks Release? only when something beyond the prep changed)" : "";
2419
+ // gh#254: the gate is the one that asks Release? — asked in chat first, the gate never saw the question and
2420
+ // put it again (a yolo or until-release hold), so the operator answered twice
2421
+ const gateAsks = `${auto} — the gate asks Release? when it needs the operator's word (NEEDS-OPERATOR Release?): ask it then, never before the call`;
2398
2422
  if (vc === "unreleased")
2399
- return `${review}fix must/should${state.docs ? "" : " (a fix that changes behaviour: flow verify redeploys and re-asks Verified? over it)"}, update docs${cfg.release.changelog && !state.docs ? `, add this flow's line under Unreleased in ${cfg.release.changelog} (the call is merge unreleased: no bump)` : ""}; show the PR summary, then run flow release${auto || " and ask Release?"}`;
2423
+ return `${review}fix must/should${state.docs ? "" : " (a fix that changes behaviour: flow verify redeploys and re-asks Verified? over it)"}, update docs${cfg.release.changelog && !state.docs ? `, add this flow's line under Unreleased in ${cfg.release.changelog} (the call is merge unreleased: no bump)` : ""}; show the PR summary, then run flow release${gateAsks}`;
2400
2424
  const prep = [cfg.release.changelog ? `prepare ${cfg.release.changelog} (fold Unreleased lines verbatim)` : "", cfg.versioning.file ? `bump version in ${cfg.versioning.file}${isBumpKind(vc) ? ` to ${bumpVersion(state.versionFrom, vc) ?? `the next ${vc}`} (a ${vc} release, the operator's call — the gate counts it from the newest tag, so a flow that released first moves the number)` : vc && vc !== "next" ? ` to ${vc} (the operator's call)` : ""}` : ""].filter(Boolean).join(" and ");
2401
- if (vc && prep) return `${review}fix must/should${state.docs ? "" : " (a fix that changes behaviour: flow verify redeploys and re-asks Verified? over it)"}, update docs, ${prep}; show the PR summary, version and changelog, then run flow release${auto || " and ask Release?"}`;
2402
- if (state.docs && prep) return `${review}fix must/should; a docs flow usually ships unversioned — ask the operator (flow release --no-version on their word); versioned instead: ${prep}; then ask Release? and run flow release`;
2403
- 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, ask Release? and run flow release`;
2425
+ if (vc && prep) return `${review}fix must/should${state.docs ? "" : " (a fix that changes behaviour: flow verify redeploys and re-asks Verified? over it)"}, update docs, ${prep}; show the PR summary, version and changelog, then run flow release${gateAsks}`;
2426
+ if (state.docs && prep) return `${review}fix must/should; a docs flow usually ships unversioned — ask the operator (flow release --no-version on their word); versioned instead: ${prep}; then run flow release${gateAsks}`;
2427
+ 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}`;
2404
2428
  }
2405
2429
  case "release":
2406
2430
  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?)`;
@@ -236,7 +236,7 @@ export async function releaseTags(root: string): Promise<string[] | null> {
236
236
  }
237
237
 
238
238
  export const GATE_HELP =
239
- "help [--json] | init [--force|--draft|--write <text>|--write-file <path>|--answers key=value…|--answers-file <path>] [--confirmed] [--track] | reflect [<note>|list|tidy|move <n> --playbook|--code|done <n>[,<n>…] [<what>]] | roadmap [add <text> [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]|pick <n> <slug>|done <n>|drop <n>|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui|--patch|--docs] [--no-ui --confirmed] [--force] [--merge=squash|merge|rebase|any] [--check-upstream] | use <slug> | test | check | health | review [done <verdict>|--skip] | approve [--yolo] | verify [--yolo] [--port=<n>|--replace] [--version=<v>|--no-version] | release [--yolo|--version=<v>|--no-version|--no-fold-check|--no-marker-check] | finish [--yolo] [--no-reflect] [--note=<text>] [--no-artifact-check|--no-release-create] [slug] | abort [slug] [--purge] | version [--check-upstream] — state gates take [slug] and --confirmed (the operator already answered in chat); without it the agent's call returns NEEDS-OPERATOR with the question to ask in chat (it never opens a dialog), and the /flow slash command asks in a dialog — verify without --confirmed rebases a branch that is behind the default branch and deploys for review; --port=<n> / --replace answer its Dev port? question when another flow holds the stack — --ui on start is the agent's call whenever screens change (it only adds the mockup gate); --patch/--docs are proposed at start and granted by the Approve? answer; --no-ui (clearing ui on a plan-stage feature) and --merge=<style> are operator-granted (--confirmed); start refuses until the playbook has a merge policy and writes the answer into project.md — --yolo (with --confirmed) answers that checkpoint and pre-confirms every later one; checks and guardrails stay — verify --confirmed carries the operator's release call: --version=<v> (ship that version) or --no-version (merge unreleased), asked with Verified?; release takes the same flags when the call changed — on GitHub release then publishes itself (push, PR, CI wait, merge in the playbook style, annotated tag) and records the release; a 'publish stopped' or 'publish waiting' result is resumed by re-running flow release; publish = manual in the playbook (or another forge) leaves those steps to the agent, and finish records the release (--no-artifact-check / --no-release-create skip a proof on the operator's word) — release --no-version ships merge + changelog only (no bump, tag or forge release); --no-fold-check skips the changelog fold line proofs on the operator's word; --no-marker-check lets a branch add conflict-marker-shaped lines on purpose — finish runs the closing reflection worker first (before removing anything) and stops for the operator's fold/drop; the re-run with --confirmed cleans up; --no-reflect --confirmed skips it on the operator's explicit word (yolo never does), --note= hands the worker the operator's friction notes — release names a session running an older dev-flow build than the disk ships and asks update (/reload) or proceed — recorded, never a block — reflect <note> queues a project suggestion in reflections.md (--playbook = docs-flow fix, --code = patch-flow fix); --plugin never writes — dev-flow feedback goes upstream and it prints the GitHub issue recipe; bare reflect prints the session-reflection protocol (bound: run flow_stage op reflect); list numbers open items, move <n> re-files one, done <n> checks a fixed one off, tidy drops closed ones — roadmap manages .dev-flow/roadmap.md: pick <n> <slug> (or add --slug=) stamps an item for flow start, which seeds the new plan from its brief; finish checks it off; drop <n> removes an item nobody wants any more (done would record it as shipped) — a new feature asked for mid-flow is parked there, never as a hand-made .dev-flow/<slug>/; start <slug> --confirmed adopts such a ghost dir — review records the pre-release review flow release requires: done <verdict> after the playbook's review step ran inline (a flow_stage review worker records itself); --skip (--confirmed, the operator's Skip review? answer) ships without one; bare review shows what is on record — doctor reviews structure, git consistency and open reflections (never writes); doctor <note> prints an investigation brief — abort unbinds and keeps the worktree; abort --purge (--confirmed, the operator's Purge? answer) removes the worktree, branch and feature folder of a dropped feature, never anything on origin — version prints the build the disk ships and any other dev-flow copies in this process (--check-upstream asks the registry)";
239
+ "help [--json] | init [--force|--draft|--write <text>|--write-file <path>|--answers key=value…|--answers-file <path>] [--confirmed] [--track] | reflect [<note>|list|tidy|move <n> --playbook|--code|done <n>[,<n>…] [<what>]] | roadmap [add <text> [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]|pick <n> <slug>|done <n>[,<n>…]|drop <n>[,<n>…]|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui|--patch|--docs] [--no-ui --confirmed] [--force] [--merge=squash|merge|rebase|any] [--check-upstream] | use <slug> | test | check | health | review [done <verdict>|--skip] | approve [--yolo] | verify [--yolo] [--port=<n>|--replace] [--version=<v>|--no-version] | release [--yolo|--version=<v>|--no-version|--no-fold-check|--no-marker-check] | finish [--yolo] [--no-reflect] [--note=<text>] [--no-artifact-check|--no-release-create] [slug] | abort [slug] [--purge] | version [--check-upstream] — state gates take [slug] and --confirmed (the operator already answered in chat); without it the agent's call returns NEEDS-OPERATOR with the question to ask in chat (it never opens a dialog), and the /flow slash command asks in a dialog — verify without --confirmed rebases a branch that is behind the default branch and deploys for review; --port=<n> / --replace answer its Dev port? question when another flow holds the stack — --ui on start is the agent's call whenever screens change (it only adds the mockup gate); --patch/--docs are proposed at start and granted by the Approve? answer; --no-ui (clearing ui on a plan-stage feature) and --merge=<style> are operator-granted (--confirmed); start refuses until the playbook has a merge policy and writes the answer into project.md — --yolo (with --confirmed) answers that checkpoint and pre-confirms every later one; checks and guardrails stay — verify --confirmed carries the operator's release call: --version=<v> (ship that version) or --no-version (merge unreleased), asked with Verified?; release takes the same flags when the call changed — on GitHub release then publishes itself (push, PR, CI wait, merge in the playbook style, annotated tag) and records the release; a 'publish stopped' or 'publish waiting' result is resumed by re-running flow release; publish = manual in the playbook (or another forge) leaves those steps to the agent, and finish records the release (--no-artifact-check / --no-release-create skip a proof on the operator's word) — release --no-version ships merge + changelog only (no bump, tag or forge release); --no-fold-check skips the changelog fold line proofs on the operator's word; --no-marker-check lets a branch add conflict-marker-shaped lines on purpose — finish runs the closing reflection worker first (before removing anything) and stops for the operator's fold/drop; the re-run with --confirmed cleans up; --no-reflect --confirmed skips it on the operator's explicit word (yolo never does), --note= hands the worker the operator's friction notes — release names a session running an older dev-flow build than the disk ships and asks update (/reload) or proceed — recorded, never a block — reflect <note> queues a project suggestion in reflections.md (--playbook = docs-flow fix, --code = patch-flow fix); --plugin never writes — dev-flow feedback goes upstream and it prints the GitHub issue recipe; bare reflect prints the session-reflection protocol (bound: run flow_stage op reflect); list numbers open items, move <n> re-files one, done <n> checks a fixed one off, tidy drops closed ones — roadmap manages .dev-flow/roadmap.md: pick <n> <slug> (or add --slug=) stamps an item for flow start, which seeds the new plan from its brief; finish checks it off; drop <n> removes an item nobody wants any more (done would record it as shipped); <n> is the row number list prints — done leaves the others in place, drop and tidy renumber — a new feature asked for mid-flow is parked there, never as a hand-made .dev-flow/<slug>/; start <slug> --confirmed adopts such a ghost dir — review records the review flow verify requires before it asks Verified? (and flow release before it ships): done <verdict> after the playbook's review step ran inline (a flow_stage review worker records itself); --skip (--confirmed, the operator's Skip review? answer) ships without one; bare review shows what is on record — doctor reviews structure, git consistency and open reflections (never writes); doctor <note> prints an investigation brief — abort unbinds and keeps the worktree; abort --purge (--confirmed, the operator's Purge? answer) removes the worktree, branch and feature folder of a dropped feature, never anything on origin — version prints the build the disk ships and any other dev-flow copies in this process (--check-upstream asks the registry)";
240
240
  export const featDir = (root: string, slug: string) => path.join(dfDir(root), slug);
241
241
  export const stateFile = (root: string, slug: string) => path.join(featDir(root, slug), "state.json");
242
242
  export const claimFile = (root: string, slug: string) => path.join(featDir(root, slug), "claim.json");
@@ -471,4 +471,7 @@ export interface Session {
471
471
  bind: (slug: string | null) => void;
472
472
  /** Name the pi session after a slug (one session = one feature: the picker shows the feature). */
473
473
  rename: (slug: string) => void;
474
+ /** Operator messages in this session's branch so far, or null/undefined when it cannot be read — a gate
475
+ * compares it with the count it recorded earlier to know whether the operator spoke since (gh#254). */
476
+ operatorMessages?: number | null;
474
477
  }
@@ -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 { approveGate, applicableItems, appendRoadmapItem, checklistHash, claimBlocks, doneItemCount, detectForge, gateHelpJson, healthProbe, parseMergeStyle, investigationBrief, pluginVersion, reflectProtocol, reflectUnfiledCount, reflectionNudges, reflectionRoutes, listFiles, needsOperator, newState, nextHint, openChecklistItems, releaseGate, roadmapDone, roadmapDrop, roadmapOpenCount, roadmapBriefFor, roadmapPick, roadmapTidy, statusJson, subst, sq, featureTmpDir, foreignWorktreeLinks, validSlug, verifyGate, STAGE_EMOJI, type ReflectTarget, type Config, type FlowState } from "../core.ts";
4
+ import { approveGate, 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 } 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";
@@ -558,12 +558,20 @@ export async function gateRoadmap(o: GateCtx): Promise<RunResult> {
558
558
  const open = roadmapOpenCount(text);
559
559
  const done = doneItemCount(text);
560
560
  const save = (next: string) => writeFileSync(roadmapFile(root), next); // .dev-flow/ existence is runFlow's precondition
561
+ // gh#245: numbers are row numbers (open and done items) — a done keeps every other number where list printed it
562
+ const rows = roadmapOpenRows(text);
563
+ const openRows = new Set(rows.map((r) => r.row));
561
564
  const idx = Number(args[0]);
562
- const validIdx = Number.isInteger(idx) && idx >= 1 && idx <= open;
565
+ const validIdx = Number.isInteger(idx) && openRows.has(idx);
566
+ const rowRange = rows.length ? `an open row (${rows.map((r) => r.row).join(", ")})` : "an open item (none open)";
567
+ // done/drop take a batch (`done 6,7` or `done 6 7`), resolved against the list as it stands before any edit
568
+ const batch = [...new Set(args.flatMap((a) => a.split(",")).map((a) => a.trim()).filter(Boolean))];
569
+ const batchNums = batch.map(Number);
570
+ const badBatch = batch.filter((_, i) => !Number.isInteger(batchNums[i]) || !openRows.has(batchNums[i]));
563
571
  switch (verb) {
564
572
  case "list": {
565
573
  if (!open) return { text: done ? `roadmap: nothing open (${done} done — flow roadmap tidy drops them)` : "roadmap: empty — flow roadmap add \"<future feature>\"" };
566
- return { text: [`roadmap — ${open} open (${done} done):`, ...openChecklistItems(text).map((l, i) => ` ${i + 1}. ${l.slice(6)}`)].join("\n") };
574
+ return { text: [`roadmap — ${open} open (${done} done; numbers are row numbers: done leaves the others as they are, drop and tidy renumber):`, ...rows.map((r) => ` ${r.row}. ${r.item}`)].join("\n") };
567
575
  }
568
576
  case "add": {
569
577
  if (!args.length) return { text: 'usage: flow roadmap add "<future feature>" [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]', isError: true };
@@ -580,33 +588,44 @@ export async function gateRoadmap(o: GateCtx): Promise<RunResult> {
580
588
  }
581
589
  case "pick": {
582
590
  const slug = args[1] ?? "";
583
- if (!validIdx) return { text: `pick: open item 1–${open} required — flow roadmap lists them`, isError: true };
591
+ if (!validIdx) return { text: `pick: ${rowRange} required — flow roadmap lists them`, isError: true };
584
592
  if (!slug || !validSlug(slug)) return { text: `usage: flow roadmap pick <n> <slug> — the slug flow start will use (lowercase, dashes)`, isError: true };
585
593
  save(roadmapPick(text, idx, slug)!);
586
594
  return { text: `roadmap: item ${idx} picked for ${slug} — now: flow start ${slug} (flow finish checks the item off when it ships)` };
587
595
  }
588
596
  case "done": {
589
- if (!validIdx) return { text: `done: open item 1–${open} required — flow roadmap lists them`, isError: true };
597
+ if (!batch.length || badBatch.length) return { text: `done: ${badBatch.length ? `${badBatch.join(", ")} ${badBatch.length > 1 ? "are" : "is"} not ` : ""}${rowRange}${badBatch.length ? "" : " required"} — nothing was changed; flow roadmap lists them`, isError: true };
590
598
  // stamped with date + bound slug, so history says what shipped it
591
- save(roadmapDone(text, idx, [new Date().toISOString().slice(0, 10), sess.slug].filter(Boolean).join(" "))!);
592
- return { text: `roadmap: item ${idx} marked done (${open - 1} open)` };
599
+ const stamp = [new Date().toISOString().slice(0, 10), sess.slug].filter(Boolean).join(" ");
600
+ let next = text;
601
+ for (const n of batchNums) next = roadmapDone(next, n, stamp)!; // rows stay put under done
602
+ save(next);
603
+ const names = batchNums.map((n) => `${n}. ${rows.find((r) => r.row === n)!.item}`);
604
+ return { text: `roadmap: ${batchNums.length > 1 ? `${batchNums.length} items` : `item ${batchNums[0]}`} marked done (${open - batchNums.length} open) — ${names.join(" | ")}` };
593
605
  }
594
606
  case "drop":
595
607
  case "remove":
596
608
  case "delete": {
597
609
  // not shipped, not wanted: gone from the backlog, so the done list never claims it was built
598
- if (!validIdx) return { text: `drop: open item 1–${open} required — flow roadmap lists them`, isError: true };
599
- const r = roadmapDrop(text, idx)!;
600
- save(r.text);
601
- return { text: `roadmap: item ${idx} dropped — "${r.item}" (${open - 1} open)` };
610
+ if (!batch.length || badBatch.length) return { text: `drop: ${badBatch.length ? `${badBatch.join(", ")} ${badBatch.length > 1 ? "are" : "is"} not ` : ""}${rowRange}${badBatch.length ? "" : " required"} — nothing was changed; flow roadmap lists them`, isError: true };
611
+ let next = text;
612
+ const gone: string[] = [];
613
+ // highest row first: removing a row shifts only the rows below it
614
+ for (const n of [...batchNums].sort((a, b) => b - a)) {
615
+ const r = roadmapDrop(next, n)!;
616
+ next = r.text;
617
+ gone.unshift(`"${r.item}"`);
618
+ }
619
+ save(next);
620
+ return { text: `roadmap: ${gone.length > 1 ? `${gone.length} items` : `item ${batchNums[0]}`} dropped — ${gone.join(", ")} (${open - gone.length} open); the row numbers below changed — run flow roadmap before the next pick, done or drop` };
602
621
  }
603
622
  case "tidy": {
604
623
  if (!done) return { text: `roadmap: nothing to tidy (${open} open, 0 done)` };
605
624
  save(roadmapTidy(text));
606
- return { text: `roadmap: dropped ${done} done item(s) — ${open} open` };
625
+ return { text: `roadmap: dropped ${done} done item(s) — ${open} open; the row numbers changed — run flow roadmap before the next pick, done or drop` };
607
626
  }
608
627
  default:
609
- return { text: "usage: flow roadmap [list|add <text> [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]|pick <n> <slug>|done <n>|drop <n>|tidy]", isError: true };
628
+ return { text: "usage: flow roadmap [list|add <text> [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]|pick <n> <slug>|done <n>[,<n>…]|drop <n>[,<n>…]|tidy] — <n> is the row number flow roadmap prints", isError: true };
610
629
  }
611
630
  }
612
631
 
@@ -710,7 +729,7 @@ export async function gateHealth(o: GateCtx): Promise<RunResult> {
710
729
  return { text: `health: ${res.ok ? "PASS" : "FAIL"} (${probe}${triedNote(res.attempts)})\n${tail(res.out)}` };
711
730
  }
712
731
 
713
- /** gh#233: records the pre-release review flow release requires. `done "<verdict>"` — the agent ran the playbook's
732
+ /** gh#233: records the review flow verify (before Verified?) and flow release require. `done "<verdict>"` — the agent ran the playbook's
714
733
  * review step inline; `--skip` — the operator's word to ship without one (asked first: Skip review?). A
715
734
  * flow_stage review worker records itself. Bare: what is on record. Bound flow only — `done`'s verdict is free text. */
716
735
  export async function gateReview(o: GateCtx): Promise<RunResult> {
@@ -722,7 +741,7 @@ export async function gateReview(o: GateCtx): Promise<RunResult> {
722
741
  const onRecord = st.review
723
742
  ? `review on record: ${st.review.by === "skipped" ? "skipped on the operator's word" : `${st.review.by}${st.review.head ? ` over ${st.review.head.slice(0, 7)}` : ""}${st.review.verdict ? ` — ${st.review.verdict}` : ""}`} (${ago(st.review.at)})`
724
743
  : "no review on record";
725
- if (!words.length && !flag("skip")) return { text: `${onRecord}${cfg.release.review ? ` — flow release requires one (${cfg.release.review})` : " — the playbook sets no review step"}` };
744
+ if (!words.length && !flag("skip")) return { text: `${onRecord}${cfg.release.review ? ` — flow verify requires one before Verified? (${cfg.release.review})` : " — the playbook sets no review step"}` };
726
745
  if (st.stage !== "implement" && st.stage !== "pre-release") return { text: `review is recorded at implement or pre-release — ${st.slug} is at ${st.stage}`, isError: true };
727
746
  const head = st.worktree ? (await sh("git rev-parse HEAD", gateCwd(root, st))).out.trim() : "";
728
747
  if (flag("skip")) {
@@ -48,6 +48,14 @@ export async function gateVerify(o: GateCtx): Promise<RunResult> {
48
48
  // tier-1 gate first (tier-2 confirmation is recorded by this very command, so it is excluded here)
49
49
  const preGate = verifyGate({ ...state!, confirmations: { ...state!.confirmations, implement: { hash: checklistHash(items), at: now() } } }, cfg, branch);
50
50
  if (preGate.length) return { text: `verify gate FAILED:\n- ${preGate.join("\n- ")}\n${branchLine}`, isError: true };
51
+ // The review runs before the operator is asked Verified?, not after it: reviewed in pre-release, every
52
+ // finding the review turned up changed the tree the operator had already said yes to, and Verified? was
53
+ // asked again — three times in one flow. Reviewed first, the operator's one look covers the tree that ships.
54
+ // A re-verify at pre-release and a release-only cut (nothing on the branch to read) owe none here.
55
+ if (state!.stage === "implement" && !isReleaseOnly(cfg, branch)) {
56
+ const owed = reviewOwed(state!, cfg);
57
+ if (owed) return { text: `verify gate FAILED:\n- the review comes before Verified?, so the operator's word covers the reviewed tree and review fixes never re-ask it — ${owed}\n${branchLine}`, isError: true };
58
+ }
51
59
  // a stack another flow is reviewing or releasing on is not this gate's to take — ask before deploying
52
60
  const slotted = cfg.commands.dev && !state!.docs ? await devSlotCheck(o, state!) : { note: "" };
53
61
  if ("text" in slotted) return slotted;
@@ -151,6 +159,10 @@ export async function gateVerify(o: GateCtx): Promise<RunResult> {
151
159
  const fpDeployed = state!.docs ? null : await worktreeFingerprint(gateCwd(root, state!));
152
160
  if (fpDeployed) state!.reviewDeploy = { wt: fpDeployed, slot: slotKey(devPortOf(state!, cfg)), at: now() };
153
161
  else delete state!.reviewDeploy;
162
+ // a re-verify the gate asked for holds the release until it is answered: the operator's "verified" in chat
163
+ // reached the agent once, which went on to release prep and never recorded it, and the release shipped
164
+ // under the older word with a warning nobody acted on
165
+ if (reverify) state!.reverifyAsked = now();
154
166
  markPendingAsk(root, state!, "Verified?"); // pending however it is asked — a chat question or a dialog
155
167
  // the agent's call never opens a dialog (#181): this is the review deploy — the app is up for the
156
168
  // operator, and the answer comes back in chat as flow verify --confirmed
@@ -164,6 +176,7 @@ export async function gateVerify(o: GateCtx): Promise<RunResult> {
164
176
  const ok = await ui.confirm("Operator verification", `Verified? All checks green${cfg.commands.dev && !state!.docs ? `; dev deploy is up for review (${cfg.commands.dev})` : ""} \u2014 does it work?`);
165
177
  if (!ok) {
166
178
  delete state!.pendingAsk;
179
+ delete state!.reverifyAsked;
167
180
  writeState(root, state!);
168
181
  return { text: `verification declined — stay in ${reverify ? "pre-release" : "implement"} and fix what failed` };
169
182
  }
@@ -194,7 +207,11 @@ export async function gateVerify(o: GateCtx): Promise<RunResult> {
194
207
  const choiceNote = choice ? `\nrelease call: ${describeVersionChoice(choice, state!.versionFrom)}` : "";
195
208
  const before = state!.stage;
196
209
  state!.stage = "pre-release";
210
+ // gh#254: what the operator says after this point is said over a tree they verified — the release gate reads it
211
+ if (typeof sess.operatorMessages === "number") state!.verifiedAtMessage = { key: sess.key, users: sess.operatorMessages };
212
+ else delete state!.verifiedAtMessage;
197
213
  delete state!.pendingAsk;
214
+ delete state!.reverifyAsked;
198
215
  writeState(root, state!);
199
216
  if (before === "pre-release")
200
217
  return { text: `re-verified${audit} over ${state!.verifiedHead?.slice(0, 7) ?? "the current tree"} — the Verified? word now covers the review fixes; still in pre-release.${choiceNote}\n${ran}\n${AGENT_MARK}next: ${nextHint(state!, cfg)}` };
@@ -245,6 +262,9 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
245
262
  const n = dirtyWt.out.split("\n").filter((l) => l.trim()).length;
246
263
  return { text: `release gate FAILED:\n- ${n} uncommitted path(s) in ${state!.worktree} — a merge ships the branch, not your working tree: commit or discard them, then re-run\n${tail(dirtyWt.out)}`, isError: true };
247
264
  }
265
+ // a re-verify flow verify asked for and nobody recorded: the release would ship under the older Verified?
266
+ if (state!.reverifyAsked)
267
+ return { text: `release gate FAILED:\n- flow verify asked the operator Verified? over the review fixes (${ago(state!.reverifyAsked)}) and no answer is recorded — once they answer in chat, run flow verify --confirmed (an unchanged tree is not deployed again); if they said no, fix it and run flow verify again`, isError: true };
248
268
  // gh#233: the review step ran (or the operator waived it) before anything slow or anything ships
249
269
  const noReview = reviewOwed(state!, cfg);
250
270
  if (noReview) return { text: `release gate FAILED:\n- ${noReview}`, isError: true };
@@ -423,7 +443,19 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
423
443
  : stale
424
444
  ? "a yolo given earlier does not choose to release under an older dev-flow build — ask Release? with the update-or-proceed question"
425
445
  : "";
426
- const mustAskFirst = !!holdWhy || stale;
446
+ // gh#206: a yolo held back only by the playbook's until-release knob carries nothing new for the operator
447
+ // to weigh — it just means "Release? is asked like on any flow". Their chat answer (a plain --confirmed)
448
+ // stands on the first call, as it does on a flow without yolo; asking first made them repeat a word already
449
+ // given. gh#219's shape — `--yolo --confirmed` replayed from the plan-stage word — still gets the question.
450
+ // Commits after Verified? and a stale build carry news, so those holds always ask first.
451
+ // gh#254: the agent carried the standing yolo onto the call as `--yolo --confirmed` after the operator had
452
+ // answered Release? in chat, and the replay guard threw the fresh answer out with the replayed flag. A replay
453
+ // has no operator message behind it since Verified? moved the flow here; an answer does — so a message in
454
+ // this session after that point lets the flag stand, and only a true replay is asked first.
455
+ const vm = state!.verifiedAtMessage;
456
+ const spokeSinceVerify = !!vm && vm.key === sess.key && typeof sess.operatorMessages === "number" && sess.operatorMessages > vm.users;
457
+ const untilReleaseOnly = cfg.release.yolo === "until-release" && !postVerify && !stale;
458
+ const mustAskFirst = (!!holdWhy && !(untilReleaseOnly && (!flag("yolo") || spokeSinceVerify))) || stale;
427
459
  const confirmed = flag("confirmed") && !(mustAskFirst && !ui.hasUI && state!.pendingAsk !== "Release?");
428
460
  const yoloHeld = confirmed ? "" : holdWhy;
429
461
  // gh#198: release.ask = on-change — Release? answers itself when it would only re-confirm Verified?: the call