pi-dev-flow 0.70.0 → 0.72.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 +14 -0
- package/docs/gates.md +2 -2
- package/docs/guardrails.md +2 -2
- package/docs/stage-agent.md +52 -15
- package/extensions/dev-flow.ts +275 -59
- package/package.json +1 -1
- package/skills/dev-flow/SKILL.md +2 -0
- package/skills/dev-flow/references/implement.md +21 -16
- package/src/core.ts +264 -10
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.72.0] - 2026-11-03
|
|
8
|
+
|
|
9
|
+
- **The implement stage must be worked, not just driven.** A session could always judge its own implement work too small to delegate and author it inline — `flow verify` proved the tree, never who wrote it. Now a normal feature's verify refuses unless every commit the branch holds falls inside a `flow_stage` worker's recorded run window: each finished worker appends its window to a dev-flow-owned `stage-sessions/delegations.log` (a session cannot sign its own proof — the ledger is refused to edit/write tools and counted as state tampering in bash), and an after-the-fact amend or rebase surfaces as an uncovered sha no write guard could ever see. While a normal feature is at implement, its own worktree is closed to its driver's edit/write tools and open to the worker that was sent to do it; the injected implement hint, the playbook and the skill no longer offer the inline escape. `--docs` and `--patch` — the operator-granted inline modes — are exempt, and there is no flag or yolo path around the rule. Heads-up for flows already at implement when you upgrade: their existing commits precede any ledger, so their next `flow verify` refuses — delegate a worker that finishes (or redoes) the work.
|
|
10
|
+
- **A session inside a feature worktree is judged by the main checkout's flow truth.** Workers run with cwd = the worktree, whose own tracked `.dev-flow/` holds only `project.md` — so the guard found zero features and every worker since worktrees existed heard `no active flow` when it reached for the edit tool: real workers authored everything through bash, the one surface the guard never policed. A linked worktree now resolves to its main checkout for feature, binding and state reads, and the write guard's worker half fires for the first time. A plain human session opened inside a worktree reads as a driver there — deliberate: worker-ness is a registration, not a location.
|
|
11
|
+
|
|
12
|
+
## [0.71.0] - 2026-11-02
|
|
13
|
+
|
|
14
|
+
- **A running worker finally wears its `⏳` name.** pi fires `session_start` only for sessions a host binds, never for the SDK-built worker, so the live name dev-flow hung on that event never landed: every worker since 0.68 ran as whatever an auto-namer made of its brief (`you-are-a-dev`), and only the final `✓`/`✗` rename showed. The name is now written onto the session before its first prompt.
|
|
15
|
+
- **Workers get their brief, not the driver's context.** A worker loads the operator's extensions, dev-flow included (its guards must hold there too), and dev-flow injected into it what it injects into an unbound driver: about 5k characters of playbook core, "pre-plan first… `flow start`", and a false "main checkout is on feat/…, not main — surface this to the operator" (it read the worktree as the checkout). dev-flow now registers each worker it spawns and stays silent in it. Separately, a human session opened in a linked worktree is no longer told the main checkout is on the wrong branch.
|
|
16
|
+
- **Verify rounds are numbered** like runs: `✓ 🔍 #3 · PASS · <label>`, so a feature that takes six rounds reads as a sequence.
|
|
17
|
+
- **The family view reads headers, not history.** Finding a session's workers used to parse every transcript in the driver's bucket (~15 ms per MB; the dev-flow checkout's bucket was 55 MB, so ~0.8 s for every idle status and settled card, growing with every worker). It now reads the first line of each transcript and only the workers in full.
|
|
18
|
+
- **A recycled pid no longer holds a dead session's claim.** A claim now records its process's start identity (`/proc/<pid>/stat` starttime); a live pid with a different start is somebody else's process and the claim is void. Refusals name the claim's age (`pid 854, claim 3 days old`), and atomic writes use a per-process temp name.
|
|
19
|
+
- **`flow doctor` names worker buckets nothing will show again.** Workers from before 0.70 sit in a session bucket per worktree, invisible from the checkout's folder scope and left behind by `flow finish`; the doctor lists those whose feature is finished or whose worktree is gone, with the `rm -r` that removes them. It never removes them.
|
|
20
|
+
|
|
7
21
|
## [0.70.0] - 2026-10-31
|
|
8
22
|
|
|
9
23
|
- **A flow's workers are one family in the picker.** Every `flow_stage` worker is now stamped as a child of the session that delegated it: its header carries `parentSession` → the driver's session file, and its transcript lands in the driver's own session bucket. `pi --resume` therefore nests the whole family under the driver in its default **Current Folder** scope, Threaded sort, with no scope switch — and because the worker's name carries its outcome (`✓ 🔍 · PASS · stamp attack`, `✗ 🔨 #3 · hard-cut`), the tree reads without opening a single row. One layout boundary: with a configured session directory that is not the checkout's default, the folder scope filters by each session's own cwd, so workers — whose cwd is the worktree — sit one Tab away under **All**, still threaded.
|
package/docs/gates.md
CHANGED
|
@@ -15,13 +15,13 @@ so it needs no `--confirmed`.
|
|
|
15
15
|
| `test` | records a check | — (runs the `test` command/check, records pass/fail) |
|
|
16
16
|
| `check` | records all tier-1 checks | — (runs every `flow-check`/test/health from project.md `## implement`); a `--docs` feature runs none of them and says `docs mode: project commands skipped` — a docs flow builds nothing, so a fresh checkout must not read as a failed deploy (#96) |
|
|
17
17
|
| `health` | records a check | — (runs `seedData` + the health command, retrying up to `healthWait` seconds; app must be up locally with real data) |
|
|
18
|
-
| `verify [--yolo]` | implement → pre-release | a **verify-worker PASS over the current tree** first (`flow_stage { op: "verify" }`; the stamp belongs to the tree it read — any edit drops it like a tier-1 record and a fresh worker is owed; a docs flow is exempt), then all tier-1 checks green — a check with no passing record is **run by the gate itself** (`checks ran at the gate (test)`) rather than refused and pointed at `flow check`, since entering the stage or editing the worktree is what cleared it — and so is a record whose worktree fingerprint differs from the tree now (`stale record(s) rerun after a worktree change: …`): a change made through bash fires no edit-tool hook, the fingerprint is what notices the tree moved — and a failure there prints the run output, **the feature branch holds at least one commit** (verify refuses a branch with nothing committed — the checks describe the working tree, so an uncommitted state has never been recorded — and prints `commits: N ahead of <default>, M uncommitted path(s)` with what it ran; uncommitted paths are reported, never gated), build (if configured) green, `dev` deploy (if configured) runs first so you can review the running app **and the health probe (if configured) re-runs against what it just deployed, retrying every 2s up to `healthWait` seconds** (a failing probe refuses the gate and reports how many attempts it took: the `flow check` PASS predates the deploy, and a service that needs seconds after its container starts is not a broken deploy; with no probe the output says `health: none configured`); with **no `dev` command but a `health` probe configured the gate live-re-probes the app before asking** (`health: live re-probe PASS` — a killed server refuses with `live probe FAILED`, because process death dirties no worktree fingerprint and a green record alone cannot prove liveness: start the app and rerun), tier-2 checklist (ui-only items excluded for non-UI features) confirmed as a set; a `--docs` feature runs none of it (`docs mode: project commands skipped`) and only asks you; **one question** — or `--confirmed`; `--yolo --confirmed` = you answered 'yolo' at Verified? — answers it and pre-confirms the rest |
|
|
18
|
+
| `verify [--yolo]` | implement → pre-release | a **verify-worker PASS over the current tree** first (`flow_stage { op: "verify" }`; the stamp belongs to the tree it read — any edit drops it like a tier-1 record and a fresh worker is owed; a docs flow is exempt), **evidence that worker sessions did the implement work** (`.dev-flow/<slug>/stage-sessions/delegations.log` holds each finished `flow_stage` run's commit window, and is dev-flow-owned — a session may read it but never write it (the write guard and the bash tamper patterns both refuse it), so the session under test cannot sign its own proof; the gate refuses when no implement-stage window carried a commit — the refusal prints the `flow_stage { stage: "implement" }` call to run — and refuses by count when commits on the branch fall outside every window, naming the fix: delegate a fixer that redoes them, or reset them; a `--docs` or `--patch` flow is exempt, nothing measured, and a git answer that cannot be had is never proof of a violation, while a gate that holds prints `delegation proven: N worker commit(s) in M window(s)`; judged only here, so the driver's own pre-release commits — changelog, bump — stay legal), then all tier-1 checks green — a check with no passing record is **run by the gate itself** (`checks ran at the gate (test)`) rather than refused and pointed at `flow check`, since entering the stage or editing the worktree is what cleared it — and so is a record whose worktree fingerprint differs from the tree now (`stale record(s) rerun after a worktree change: …`): a change made through bash fires no edit-tool hook, the fingerprint is what notices the tree moved — and a failure there prints the run output, **the feature branch holds at least one commit** (verify refuses a branch with nothing committed — the checks describe the working tree, so an uncommitted state has never been recorded — and prints `commits: N ahead of <default>, M uncommitted path(s)` with what it ran; uncommitted paths are reported, never gated), build (if configured) green, `dev` deploy (if configured) runs first so you can review the running app **and the health probe (if configured) re-runs against what it just deployed, retrying every 2s up to `healthWait` seconds** (a failing probe refuses the gate and reports how many attempts it took: the `flow check` PASS predates the deploy, and a service that needs seconds after its container starts is not a broken deploy; with no probe the output says `health: none configured`); with **no `dev` command but a `health` probe configured the gate live-re-probes the app before asking** (`health: live re-probe PASS` — a killed server refuses with `live probe FAILED`, because process death dirties no worktree fingerprint and a green record alone cannot prove liveness: start the app and rerun), tier-2 checklist (ui-only items excluded for non-UI features) confirmed as a set; a `--docs` feature runs none of it (`docs mode: project commands skipped`) and only asks you; **one question** — or `--confirmed`; `--yolo --confirmed` = you answered 'yolo' at Verified? — answers it and pre-confirms the rest |
|
|
19
19
|
| `release [--yolo|--no-version|--no-fold-check]` | pre-release → release | checks re-greened after the prep edits; **the worktree holds no uncommitted paths** (gh#131: a merge ships the branch, not the working tree — an uncommitted fix at this gate is a fix that never ships; the refusal lists the paths, and the approved line prints `commits: N ahead of <default>, M uncommitted path(s)` like verify's); with `versioning.file`: the manifest version parses and is **not tagged yet** (the bump must be ahead of the last release); with `release.changelog` the gate **proves the entry mechanically** (#97): a **heading names the version** (prose that mentions it, or a `1.2.0-beta` section when releasing `1.2.0`, is not an entry), **this branch touched the file** (an inherited changelog is not release prep), **every entry that was pending before the release survives inside the new section** — compared on normalized lines, so re-indenting a fold is free while rewording or deleting one is refused by naming the line — and **nothing is left under `Unreleased`**. The proofs guard the **baseline's** pending lines — they do not freeze the wording of the entry this flow writes, so a branch that landed as several iteration commits is free to state its result as one entry (see the changelog-writer rule in the pre-release reference). The pending baseline is the newest tag's changelog (what actually shipped), else the branch's merge base; when neither resolves, the two git-dependent proofs are skipped **with a printed advisory** rather than refusing a legal release for a topology reason, and the content proofs (the heading, its body) always run; tier-2 `## pre-release` checklist confirmed; the manifest version it validates is **stamped as the release's version of record** (`release-done` publishes that, whatever the checkouts say later); **one question** (Release?) — or `--confirmed`; `--no-version` (your call at Release?) ships this flow as **merge + changelog** — the bump/tag requirements and the tag checks at `release-done` are skipped for it, but the branch must still add its **own line under `Unreleased`** (editing an older section releases nothing) and it rides there until the next versioned release folds it (default: versioned); `--no-fold-check` is the operator-granted escape from the line-level fold proofs — one flow, stamped in the gate output, the heading and touched proofs stay; **stale session build** (loaded build behind the checkout): the gate prints both builds, lists what shipped between them (those proofs will not run this release) and folds *update (/reload, then re-run) or proceed with the old release?* into the Release? question — the operator's word, recorded in the release output, **never a block**: publishing under an older gate is a legitimate choice (hotfix, offline reload) |
|
|
20
20
|
| `release-done` | records the release (the stage stays `release`) | **no question — the Release? answer covered the publication**; verify approval; the version published is the one `release` **stamped** from the manifest it validated (a main checkout still behind cannot republish the previous version), and it must not be older than the newest matching tag **on origin** (tag lists come from `git ls-remote`, so an unfetched clone does not decide what exists; when an origin exists but cannot be asked (offline, no ssh agent) **both release gates refuse** rather than answering with local tags); with `versioning.file`: that tag exists, is reachable from the default branch **and is on origin** (a local-only tag is not a release); with `release.artifact`: the published-artifact check runs (`{version}`/`{tag}` placeholders — the line it prints names the version it verified; skip once with `--no-artifact-check`, operator-instructed only) · creates the forge release from the tag, its body **the `release.changelog` entry for that version** — the changelog is the source of truth, and the tag's annotation stands in only when the changelog has no entry for the version, else nothing (and it says why — a body that is really a shell error is dropped, never shipped) — `gh` for GitHub, `glab` for GitLab) and then **proves the release exists**: it asks the forge (`gh release view <tag>` / `glab release view <tag>`) and refuses when nothing is there, because #51, #60 and #63 were three ways of ending `release recorded as complete` with nothing published — and when the changelog was the body it **reads the stored body back** and refuses a mismatch, so the release page and the changelog cannot drift (#97; normalized before comparing, skipped with a printed note on another forge). Skipping is deliberate and loud — `--no-release-create`, `release.releases = false` or `forge = self` each print that no forge release was created, and the view check is skipped for them; **with a `merge` policy** it also proves the merge that shipped matches it — branch ancestry plus what the forge says (`gh pr view` / `glab api`), so a squash under `merge = merge` (or a merge commit under `merge = squash`) refuses the release record, while a shape it cannot see prints an advisory instead (#97's split: an invisible topology never blocks a legal release); when the release went out on a stale build the operator acknowledged at the release gate, it prints that acknowledgement in place of the after-the-fact version-skew warning, and that warning prints the session vs disk version pair plus the duplicate-copy note when a second copy is registered (#117) |
|
|
21
21
|
| `finish [--yolo] [slug]` | release → done (removes worktree + branch, deletes `.dev-flow/<slug>/`, and deletes `origin/<branch>` **only** when its merged state is verified — ancestor of the default branch or a merged PR/MR via `gh`/`glab`; unverifiable branches stay with a note) | a release is recorded (`release-done` ran), the main checkout is clean **and** pushed to `origin/<default>`, and the worktree has no uncommitted changes (the refusal lists the paths, not just the count — gh#131); when the clean checkout trails `origin/<default>` the gate **fast-forwards local main** as it closes out (never a merge — anything that cannot fast-forward prints the operator's exact `git pull --ff-only` command); **one question** (Finish? — mentions unmerged-looking commits with the playbook's `merge` policy in mind, and warns when the forge release create failed at `release-done` and no retry succeeded) — or `--confirmed`; under `merge = merge`, commits that never reached the default branch are a **policy violation**: `yolo` does not answer it, only your explicit answer does; to abandon an unreleased feature use `abort` |
|
|
22
22
|
| `reflect ["<note>"|list|tidy|move <n> --plugin|--playbook]` | — | `reflect "<note>"` queues a suggestion in `reflections.md` (never gates; gate flags such as `--confirmed` are ignored, they never become part of the note). `--playbook` / `--plugin` files it in that section — the agent knows what its own note is about, so the wording guess is the fallback, and the echoed line prints the reason it landed where it did (`"gate" names dev-flow itself`, `playbook or project wording`, `nothing plugin-shaped in the note …`); a note is filed under **one** section, never both. `reflect list` numbers the open items with their section; `reflect move <n> --plugin|--playbook` re-files one of them. `reflect tidy` drops the closed (`- [x]`) items — the preamble and open items stay verbatim and a `## section` heading left empty goes with its items; every surface that queues or reviews reflections (`reflect "<note>"`, bare `reflect`, `doctor`) nudges with the closed count when the checked-off pile grows. Bare `reflect` prints the full **session-reflection protocol** for the agent (from the `/flow reflect` bar it additionally wakes the model, so the protocol executes immediately): review the whole session log, re-check every open item against the current playbook and **newer dev-flow versions** (`npm view pi-dev-flow version` vs the running version — dev-flow ships from npm; recommend `pi install npm:pi-dev-flow` + `/reload`, the operator performs updates), dedupe new findings against the open ones, then report playbook vs plugin items to the operator and ask whether to fix now — plugin items: search upstream issues first (`gh issue list --repo <upstream> --state all --search …`; an author-addressed match is reported back, no match → `gh issue create` with a detailed description and a suggested fix), playbook items: `flow doctor` routes each to the docs flow that implements it |
|
|
23
23
|
| `roadmap [add "<feature>" \| pick <n> <slug> \| done <n> \| tidy]` | — | manages `.dev-flow/roadmap.md`, the gitignored backlog of future features (`- [ ]` checklist): bare prints the numbered open items, `add` appends one, `pick <n> <slug>` stamps open item n with `(slug)` so `flow start <slug>` can take it — **`finish` checks the stamped item off when that feature ships**; `done <n>` checks off by hand (items shipped outside a flow), `tidy` drops the checked lines. Never gates; the open count is surfaced in `status` and session context |
|
|
24
|
-
| `doctor ["<issue note>"]` | — | read-only findings: playbook drift, dead commands/scripts, untracked playbook, ghost feature dirs, orphan worktrees/branches — the state of an **aborted** feature is never a finding (its worktree cleanup is by design — gh#138) — **plus a review of every open reflection, each routed to the flow that should fix it** (playbook item → docs flow; plugin item → upstream issue, or a patch/normal flow inside the dev-flow repo) — every item is labelled from the `## section` it is filed under (the file is the record, so the table cannot disagree with it) and items sitting outside both sections are named rather than silently bucketed. It writes nothing and asks nothing, safe for agents and CI at any stage; the agent investigates, you confirm, the routed flow implements. `doctor "<note>"` prints an investigation brief and a fix route for a fresh observation, including the section it would be filed under and why |
|
|
24
|
+
| `doctor ["<issue note>"]` | — | read-only findings: playbook drift, dead commands/scripts, untracked playbook, ghost feature dirs, orphan worktrees/branches, pi session buckets left by stage workers under finished or removed worktrees (named with their `rm -r`, never removed) — the state of an **aborted** feature is never a finding (its worktree cleanup is by design — gh#138) — **plus a review of every open reflection, each routed to the flow that should fix it** (playbook item → docs flow; plugin item → upstream issue, or a patch/normal flow inside the dev-flow repo) — every item is labelled from the `## section` it is filed under (the file is the record, so the table cannot disagree with it) and items sitting outside both sections are named rather than silently bucketed. It writes nothing and asks nothing, safe for agents and CI at any stage; the agent investigates, you confirm, the routed flow implements. `doctor "<note>"` prints an investigation brief and a fix route for a fresh observation, including the section it would be filed under and why |
|
|
25
25
|
| `status [slug]` / `abort [slug]` | — | — |
|
|
26
26
|
| `help` (`--help`, `-h`) | — | — (prints the gate help — answerable in any repo, at any stage, with no `.dev-flow/`) |
|
|
27
27
|
| `version [--check-upstream]` | — | — (prints dev-flow's **own** version and the directory it was loaded from — which copy this session runs, this checkout vs an installed `pi-dev-flow`; when the checkout has moved past the build this session loaded it says so and names both, because the gates execute the loaded code — `/reload` to run the newer one; `--check-upstream` adds the published npm version; answerable in any repo, at any stage, with no `.dev-flow/`) |
|
package/docs/guardrails.md
CHANGED
|
@@ -6,9 +6,9 @@ While a feature is active, the extension intercepts every tool call:
|
|
|
6
6
|
|
|
7
7
|
- **Nothing on main, ever** (until release): `git commit` on the default branch is blocked at every stage except `release` — where release chores commit in the main checkout (prefixed `DEV_FLOW_ALLOW_MAIN=1` for the hook) — and except one chore that needs no flow: a commit whose **only** change in the checkout is `.dev-flow/project.md`, because tracking the operator's playbook is setup, not feature work (any other dirty path closes that lane). pushes are judged by the ref they write — only pushing *to* the default branch (or a bare push while on it) requires stage `release`, so tag pushes and feature-branch pushes pass from any stage; `git merge` onto the default branch also requires stage `release`. Plus the standalone pre-commit hook for commits made outside Pi.
|
|
8
8
|
- **No code before an approved plan**: at stage `plan`, edits are confined to `.dev-flow/<slug>/` — the session's **own** feature directory, so one session cannot write another feature's plan and have its gate rubber-stamp what it never wrote.
|
|
9
|
-
- **Work stays in the worktree**: at stages `implement` and `pre-release`, edits are confined to that feature's worktree — judged per-path by the owning feature, so one session can never write into another session's worktree or into the main checkout. A throwaway **outside** the checkout is not feature work and stays free at every stage (the OS temp dir, e.g. a one-off rewrite script): both sides are realpath'd, so a symlink out of the temp dir is still judged as the repo path it writes, and a repository that merely lives under the temp dir (a test repo) keeps the stage rules.
|
|
9
|
+
- **Work stays in the worktree**: at stages `implement` and `pre-release`, edits are confined to that feature's worktree — judged per-path by the owning feature, so one session can never write into another session's worktree or into the main checkout. A throwaway **outside** the checkout is not feature work and stays free at every stage (the OS temp dir, e.g. a one-off rewrite script): both sides are realpath'd, so a symlink out of the temp dir is still judged as the repo path it writes, and a repository that merely lives under the temp dir (a test repo) keeps the stage rules. **At implement the driver drives**: for a normal feature the driving session's own edit/write tools are refused inside its own worktree — the `flow_stage` worker it sent (workers are registered when spawned) is the session allowed to author there, and `flow verify` proves the branch's commits fall inside a worker's recorded run window (`stage-sessions/delegations.log`); `--docs` and `--patch` flows stay inline because the operator granted those modes, and bash is left alone — running commands is driving, not authoring. Being a worker is a **registration**, not a location: a human session opened **inside** the worktree is not a registered worker, so it reads as a driver and its edit tools are refused at implement too — deliberate: at this stage the work goes out through `flow_stage` whoever is holding the editor, and the stages that stay the driver's own (pre-release prep, a `--docs`/`--patch` flow) open the same pen. Attribution reads the **main checkout's** `.dev-flow/` even when the session's cwd is the worktree: a linked worktree carries only the tracked playbook copy, so judging from the worktree's own copy saw no features and every guard answered "no active flow".
|
|
10
10
|
- **Flow by default**: in a repo with `.dev-flow/`, an unbound session cannot touch source files at all — every request goes through `flow start`/`flow use`; there is no bypass. `flow start` refuses when the main checkout isn't on the default branch, worktrees are always created from the default branch, and the agent cannot check feature branches out in the main checkout.
|
|
11
|
-
- **Gates can't be skipped**: flow state is untouchable by the agent (edit tool and bash) — writing `state.json` or `
|
|
11
|
+
- **Gates can't be skipped**: flow state is untouchable by the agent (edit tool and bash) — writing `state.json`, `claim.json` or the **delegation ledger** (`stage-sessions/delegations.log` — the file `flow verify` trusts about *who* worked the stage, so it is dev-flow-owned like the other two: the write guard refuses it to a session and the bash tamper patterns refuse a write, move or delete of it, while reading it and `git add`-ing it stay legal; the only writer is a finished `flow_stage` worker run, appending in-process where that code already computes the worker's commits — the session the gate constrains cannot sign its own proof), moving any of them away, or deleting a feature directory or the whole `.dev-flow/` folder all block, at a relative **or an absolute** path (an absolute path names the same folder); the `project.md` playbook is operator-owned — the main-checkout copy is blocked for the agent outright, and only a **docs or patch flow's** worktree copy may be edited (normal features route playbook changes to their own flow); every sanctioned playbook overwrite keeps the previous file as `project.md.bak`; every recorded check carries a fingerprint of the worktree it ran against (paths, uncommitted diff, HEAD) — an edit-tool change clears the records at once, and any other write (`sed -i`, a formatter, codegen through bash) is caught at the gate itself, which reruns what went stale and says so; edit/write paths are judged by realpath, so a symlink out of the worktree cannot launder a confined write.
|
|
12
12
|
- **Your project's own rules**: every `deny`/`confirm`/`protect`/`forbid` rule from the `flow-guard` block in project.md `## global` runs on every bash command and every edit/write path — in every stage and binding, ahead of dev-flow's own verdicts. A block always carries the reason you wrote.
|
|
13
13
|
- **The rules reach the agent, they are not left in a file it may never read**: pi advertises a skill and loads it only if the model chooses to, so the ground rules of the dev-flow skill are injected into every session once (and again after a compaction that summarized them away), and each stage's turn names the one playbook file that stage needs. The guards enforce the same discipline either way — this is what makes the agent follow it without being stuck.
|
|
14
14
|
- **A forced push asks the operator**: `git push` carrying `--force`, `--force-with-lease…` or `-f` is confirmed before it runs — a rewritten branch is history CI and other sessions already have. The one spelling that answers for it is the prefix the refusal prints (`DEV_FLOW_ALLOW_REWRITE=1 git push -f …`), the same "the operator said so" contract as `DEV_FLOW_ALLOW_MAIN`. Local history rewrites (`git filter-branch --force`) are not pushes and stay free, so a project never needs a blunt flag-only deny of its own.
|
package/docs/stage-agent.md
CHANGED
|
@@ -4,8 +4,8 @@ A big `implement` costs more context than the rest of the flow will ever need:
|
|
|
4
4
|
the driving session carries those hundred tool calls into every later gate and
|
|
5
5
|
checkpoint. `flow_stage` runs that work in a fresh, disposable session
|
|
6
6
|
instead, and hands back one bounded report. The conversation that talks to you
|
|
7
|
-
stays lean — which is why
|
|
8
|
-
|
|
7
|
+
stays lean — which is why implement work is **delegated**, not inlined, and why
|
|
8
|
+
`flow verify` proves it from the ledger below (see `references/implement.md`). Three ops share one mechanism: `run` (a stage's work), `verify` (an
|
|
9
9
|
independent, check-only reviewer of the implement work) and `reflect` (an
|
|
10
10
|
independent review of the whole finished flow at release). Only the brief, the
|
|
11
11
|
toolset, the budget default and the closing contract differ — the safety story
|
|
@@ -13,6 +13,24 @@ is identical, and a second mechanism would drift.
|
|
|
13
13
|
|
|
14
14
|
## What delegates, what does not
|
|
15
15
|
|
|
16
|
+
**The ledger proves who worked.** Every finished `run` worker appends its stage and its commit
|
|
17
|
+
range to `.dev-flow/<slug>/stage-sessions/delegations.log` — one line, `[<iso>] run (<stage>):
|
|
18
|
+
<start>..<end> <n> commit(s)` — written by the same completion code that renames the worker with
|
|
19
|
+
its commit count. The file is dev-flow-owned — the write guard refuses it to a session, the bash tamper patterns refuse a write, move or delete of it, and only a worker run's completion appends it, in-process — precisely so the session whose work it proves cannot sign its own proof. `flow verify` reads it fresh and refuses when it shows no implement-stage
|
|
20
|
+
delivery, or when a commit on the branch falls outside every implement window (the refusal counts
|
|
21
|
+
the strays and names the fix: delegate a fixer that redoes them, or reset them). A range, not a
|
|
22
|
+
count, is what makes it hold: an amend or a rebase after the fact moves the sha out of every window
|
|
23
|
+
the ledger recorded, which no write guard could see. `--docs` and `--patch` flows are exempt —
|
|
24
|
+
nothing to delegate in a docs pass or a one-file chore — and a git question that cannot be answered
|
|
25
|
+
is never proof of a violation. Coverage is judged only at verify: the driver's own commits after it
|
|
26
|
+
(changelog, bump) are pre-release work and belong to the session by design. The write guard is the
|
|
27
|
+
early nudge of the same rule — a driver's edit inside its own worktree at implement is refused, a
|
|
28
|
+
registered worker session's is not — while bash stays unguarded: running commands is driving, and
|
|
29
|
+
the ledger's commit ranges are what carry the proof. A worktree session is judged by the **main
|
|
30
|
+
checkout's** `.dev-flow/`, which is where the state actually lives: a linked worktree carries only the
|
|
31
|
+
tracked playbook copy, so reading the worktree's own copy found no features and every guard answered
|
|
32
|
+
"no active flow" — including for the worker it had to attribute.
|
|
33
|
+
|
|
16
34
|
`flow_stage(stage: "implement" | "pre-release", note)` runs the **work** of
|
|
17
35
|
the stage you are in; `flow_stage(op: "verify")` (legal only while the flow is
|
|
18
36
|
at implement) and `flow_stage(op: "reflect")` (at release, after
|
|
@@ -64,6 +82,13 @@ binding of its own:
|
|
|
64
82
|
reaching around them is a hardening decision, not a control this feature
|
|
65
83
|
claims.
|
|
66
84
|
|
|
85
|
+
The worker loads your extensions like any session, dev-flow included — that is
|
|
86
|
+
how the guards above hold inside it. What it does **not** get is the driver's
|
|
87
|
+
context: dev-flow registers each worker it spawns and injects neither the
|
|
88
|
+
playbook core nor the unbound-session posture into it (that text told a worker
|
|
89
|
+
to pre-plan and `flow start`, and read its worktree as a main checkout on the
|
|
90
|
+
wrong branch). The brief is the worker's whole instruction.
|
|
91
|
+
|
|
67
92
|
## The handoff
|
|
68
93
|
|
|
69
94
|
The worker receives a brief assembled by the tool. A `run` worker gets the
|
|
@@ -108,16 +133,20 @@ Around it, three mirrors:
|
|
|
108
133
|
either layout. On a host with no file-backed session the stamp
|
|
109
134
|
is skipped and the worker keeps pi's default location, unlinked. Named by role
|
|
110
135
|
glyph, ordinal and purpose — `⏳ 🔨 #2 · wire ops` while it runs, renamed
|
|
111
|
-
at the end with its outcome: `✓ 🔨 #2 · 3 commits · wire ops`, a verify `✓ 🔍 ·
|
|
112
|
-
PASS · stamp attack
|
|
113
|
-
|
|
114
|
-
|
|
136
|
+
at the end with its outcome: `✓ 🔨 #2 · 3 commits · wire ops`, a verify `✓ 🔍 #3 ·
|
|
137
|
+
PASS · stamp attack` (verify rounds are numbered like runs, so a feature that took
|
|
138
|
+
six rounds reads as a sequence), a cut-off worker `✗ 🔨 #3 · hard-cut`; the verdict
|
|
139
|
+
never depends on opening the row (a `label` on the call supplies the purpose; with
|
|
140
|
+
none, the ordinal still separates the rows). The live name is written onto the
|
|
141
|
+
session before its first prompt — pi fires `session_start` only for sessions a host
|
|
142
|
+
binds, never for an SDK-built worker, so a name hung on that event never landed and
|
|
143
|
+
an auto-namer was left to title the row from the brief. It appears in the `/resume`
|
|
115
144
|
picker, and its
|
|
116
145
|
transcript grows live on disk, readable at any moment — whether a viewer
|
|
117
146
|
tails a session still running is the viewer's choice, the card above is what
|
|
118
147
|
the flow promises. Every finished worker appends its transcript path to
|
|
119
148
|
`.dev-flow/<slug>/stage-sessions/transcripts.log` — the durable index the
|
|
120
|
-
reflect worker reads;
|
|
149
|
+
reflect worker reads, next to `delegations.log` — the delegation ledger the verify gate reads;
|
|
121
150
|
- the driving session's **footer** beats `⏳ 🔨 implement · <label> · <slug>
|
|
122
151
|
mm:ss · <tool>` while a worker runs (cleared when it ends);
|
|
123
152
|
- every line appends to `.dev-flow/<slug>/stage-live.log` — tail-able, and
|
|
@@ -137,7 +166,7 @@ session has never spawned one:
|
|
|
137
166
|
|
|
138
167
|
```
|
|
139
168
|
workers this session spawned:
|
|
140
|
-
✓ 🔍 · PASS · stamp attack · 7 msgs · 2026-10-30 12:04 · ~/.pi/agent/sessions/…/w2.jsonl
|
|
169
|
+
✓ 🔍 #2 · PASS · stamp attack · 7 msgs · 2026-10-30 12:04 · ~/.pi/agent/sessions/…/w2.jsonl
|
|
141
170
|
✗ 🔨 #1 · hard-cut · 31 msgs · 2026-10-30 11:02 · ~/.pi/agent/sessions/…/w1.jsonl
|
|
142
171
|
```
|
|
143
172
|
|
|
@@ -145,9 +174,11 @@ It is read back from pi's session listing, not from a dev-flow index, so renames
|
|
|
145
174
|
deletions and workers an earlier session already delegated all read correctly for
|
|
146
175
|
free. A host that gives dev-flow no session file to be a parent of falls back to
|
|
147
176
|
the lines the flow's own `transcripts.log` already holds — coarser (no message
|
|
148
|
-
count, no rename), still the same answer.
|
|
149
|
-
|
|
150
|
-
|
|
177
|
+
count, no rename), still the same answer. A family read opens only the first line
|
|
178
|
+
of each transcript in the bucket to find the workers whose header names this
|
|
179
|
+
session, and reads only those in full — its cost follows the family, not the
|
|
180
|
+
bucket's history. The polled live view still re-reads at most once every two
|
|
181
|
+
seconds, while the settled card and an idle status always read fresh.
|
|
151
182
|
|
|
152
183
|
Lifecycle is also on the bus: `dev-flow:worker-started` / `-completed` /
|
|
153
184
|
`-failed` events (slug, op, elapsed, usage) let other extensions react without
|
|
@@ -178,13 +209,19 @@ knowing: a worker's header `cwd` is still the worktree, so after `flow finish`
|
|
|
178
209
|
removes that worktree the row points at a directory that is gone (browsing and
|
|
179
210
|
`pi export` still work — resuming it would not); and the bucket is shared with the
|
|
180
211
|
driver's own history, so worker transcripts are only ever deleted by path, never
|
|
181
|
-
by clearing a folder.
|
|
212
|
+
by clearing a folder. Workers from before 0.70 sit in a bucket of their own per
|
|
213
|
+
worktree, which no folder scope opened from the checkout shows; `flow doctor` names
|
|
214
|
+
those buckets once their feature is finished or its worktree is gone, with the
|
|
215
|
+
`rm -r` that removes them — it never removes them itself. Snapshots and the
|
|
216
|
+
`transcripts.log` index live under
|
|
182
217
|
`.dev-flow/<slug>/stage-sessions/` (gitignored, like all flow-owned state).
|
|
183
218
|
|
|
184
219
|
## Deliberate limits (v2)
|
|
185
220
|
|
|
186
221
|
Same model for worker and driver (a per-stage model/tool policy is a playbook
|
|
187
|
-
conversation for later);
|
|
188
|
-
fresh each cycle
|
|
189
|
-
|
|
222
|
+
conversation for later); the verify worker's fixing is delegated too — the
|
|
223
|
+
checker is fresh each cycle and so is the fixer, because at implement the guard
|
|
224
|
+
refuses the driver's own pen in its own worktree (the driver decides *what* the
|
|
225
|
+
fix is and sends the note; a `run` worker writes it, then a fresh verify worker
|
|
226
|
+
re-reads the tree); the worker cannot ask you anything — if it needed to, the note
|
|
190
227
|
was too thin.
|