pi-dev-flow 0.53.0 → 0.53.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 +13 -0
- package/docs/concurrency.md +11 -0
- package/docs/gates.md +1 -1
- package/extensions/dev-flow.ts +45 -3
- package/package.json +1 -1
- package/src/core.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.53.2] - 2026-10-22
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **A claim now dies with its session, not with the process.** Dev-flow's session state is module-level, and pi runs many sessions inside one long-lived Node process (pi-web's agent lives in the server) — so bindings and the compaction flag outlived the session that wrote them, and claim liveness asked only `pidAlive(claim.pid)`, a pid that never goes away in a shared host. The result was a lock nobody could see the owner of: one pi-web session starts a feature, that session ends, and every later session in the repo is refused the auto-bind and told the feature `is claimed by another live session` — forever, because the claim's pid is the server itself. `session_shutdown` now releases the dead session's binding, its compaction flag and every claim it held; a restored session (reload, resume, fork) reclaims what its own branch history says it holds, and a foreign live claim still wins, because restoring is not a takeover.
|
|
12
|
+
- **Claim keys say what kind of identity they are.** A key was either pi's session id or, when the host hands out none, the working directory — indistinguishable in `claim.json`, which made a shared-directory collision read exactly like a session that had gone missing. Keys are now `sid:<session id>` and `cwd:<directory>`, and `flow status` prints the session's own key (saying plainly when it is the directory one, because then every pi session in that directory shares a single dev-flow binding and must pass `flow use <slug>`). One migration seam, expected and harmless: a claim written by an older build carries the old bare key, so the first rival session after this upgrade needs one explicit `flow use` — the same path a takeover already takes.
|
|
13
|
+
|
|
14
|
+
## [0.53.1] - 2026-10-22
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **`flow check` no longer runs tier-1 checks for a `--docs` flow.** Every other gate already exempted docs flows — `pendingChecks`, verify and the release gate all skip the check requirement there, and verify says `docs mode: project commands skipped` — but `flow check` ran the project's commands anyway. In a fresh checkout that has never built anything, a CHANGELOG-only change therefore came back `health: FAIL` (`/bin/sh: kill: No such process` from a probe aimed at a binary that does not exist), which reads exactly like a broken deploy. It now answers in verify's words: `docs mode: project commands skipped`, and says plainly that CI on the tag and the artifact proof are what still stand behind the release. Nothing about the docs contract changed — this removed a command surface that contradicted it.
|
|
19
|
+
|
|
7
20
|
## [0.53.0] - 2026-10-22
|
|
8
21
|
|
|
9
22
|
### Fixed
|
package/docs/concurrency.md
CHANGED
|
@@ -13,6 +13,17 @@ passing another session's slug to `flow approve`/`verify`/`finish` is refused un
|
|
|
13
13
|
or two sessions quietly overwrite one state file. `flow use <slug>` switches, and ambiguous sessions must
|
|
14
14
|
bind or pass explicit slugs. With nothing unfinished and no binding, the session must start a
|
|
15
15
|
flow — work does not happen outside the flow.
|
|
16
|
+
|
|
17
|
+
**A claim dies with its session, not with its process.** Hosts like pi-web run many sessions inside
|
|
18
|
+
one long-lived Node process, so the pid on a claim says nothing about whether its holder still
|
|
19
|
+
exists — `session_shutdown` releases the dead session's binding and every claim it held, and a
|
|
20
|
+
restored session (reload, resume, fork) reclaims what its own branch history says it holds. A claim
|
|
21
|
+
key names the identity it came from: `sid:<session id>` when pi provides one, `cwd:<directory>`
|
|
22
|
+
when the host hands out none — and in that second case every session in that directory shares one
|
|
23
|
+
binding, so `flow status` prints the key and says so instead of leaving a shared binding to be
|
|
24
|
+
guessed from a path. Dev-flow keeps no per-process session state beyond that keyed map, released on
|
|
25
|
+
shutdown; the one other process-wide cache (`compile()` in `src/core.ts`) holds flag-less regexes,
|
|
26
|
+
which carry no mutable state to leak between sessions.
|
|
16
27
|
Enforcement is by attribution: a write inside worktree X is judged
|
|
17
28
|
by X's own feature stage no matter which session touches it; main-checkout code stays closed
|
|
18
29
|
while your bound feature is in `plan`/`implement` and while any feature is unbound-and-ambiguous.
|
package/docs/gates.md
CHANGED
|
@@ -13,7 +13,7 @@ so it needs no `--confirmed`.
|
|
|
13
13
|
| `use <slug>` | — (binds this session to a feature) | slug unfinished |
|
|
14
14
|
| `approve [--yolo]` | plan → implement (creates worktree + branch) | `plan/*.md` exists; if `--ui`, rendered mockup screenshots (per `mockupGlobs`, default `*.png`) exist under `plan/` — headless chromium renders embedded in plan.md; **one question** — or `--confirmed` after you answered in chat; **yolo** (your chat answer at **any** checkpoint question) → run that gate with `--yolo --confirmed` (`approve`/`verify`/`release`/`finish`): that question is answered and every later one (Verified?/Release?/Finish?) is pre-confirmed — the agent then runs the remaining gates back to back, honoring guidance attached to the yolo word (e.g. "yolo, create a patch version release") — checks and guardrails stay fully enforced. `commands.setup` runs in the worktree and is retried until it succeeds once (a worktree left behind by a failed setup is set up on the next `approve`, never silently reused); a `--docs` feature runs no project command at all and says `setup skipped (docs mode)` |
|
|
15
15
|
| `test` | records a check | — (runs the `test` command/check, records pass/fail) |
|
|
16
|
-
| `check` | records all tier-1 checks | — (runs every `flow-check`/test/health from project.md `## implement`) |
|
|
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
18
|
| `verify [--yolo]` | implement → pre-release | 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 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`), 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; 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 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 |
|
package/extensions/dev-flow.ts
CHANGED
|
@@ -188,9 +188,17 @@ function atomicWrite(file: string, text: string): void {
|
|
|
188
188
|
renameSync(tmp, file);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
/** Session bindings: one flow per pi session; persisted per session branch via appendEntry.
|
|
191
|
+
/** Session bindings: one flow per pi session; persisted per session branch via appendEntry.
|
|
192
|
+
* Module-level means shared by every session in the process — pi runs many sessions inside one Node
|
|
193
|
+
* process (pi-web's agent lives in the server) — so every key here is a session identity and every
|
|
194
|
+
* entry is released when that session ends (see releaseSession). */
|
|
192
195
|
const bindings = new Map<string, string | null>();
|
|
193
|
-
|
|
196
|
+
// Two identities are possible: pi's session id, or — when the host hands out none — the working
|
|
197
|
+
// directory. Both are prefixed, because a claim written under the directory identity is not a session:
|
|
198
|
+
// two pi sessions sharing one directory share that key, and `cwd:` in a claim file says so out loud
|
|
199
|
+
// instead of reading like a session that went missing.
|
|
200
|
+
const sessionKey = (ctx: { cwd: string; sessionManager?: { getSessionId(): string } }): string =>
|
|
201
|
+
ctx.sessionManager?.getSessionId() ? `sid:${ctx.sessionManager.getSessionId()}` : `cwd:${ctx.cwd}`;
|
|
194
202
|
/** Sessions with a dev-flow-initiated compaction in flight (prevents stacked compactions). */
|
|
195
203
|
const compacting = new Set<string>();
|
|
196
204
|
|
|
@@ -247,6 +255,20 @@ function readClaim(root: string, slug: string): SessionClaim | null {
|
|
|
247
255
|
const writeClaim = (root: string, slug: string, key: string) =>
|
|
248
256
|
atomicWrite(claimFile(root, slug), `${JSON.stringify({ key, pid: process.pid, at: now() })}\n`);
|
|
249
257
|
|
|
258
|
+
/** Let go of everything one session held. In a shared-process host the pid on a claim is the server's and
|
|
259
|
+
* never dies, so a claim left behind by a finished session keeps refusing every later session with
|
|
260
|
+
* "claimed by another live session" — the lock has to end with the session that wrote it. Idempotent:
|
|
261
|
+
* shutdown, reload and process exit can converge on this path. */
|
|
262
|
+
function releaseSession(root: string, key: string): void {
|
|
263
|
+
bindings.delete(key);
|
|
264
|
+
compacting.delete(key);
|
|
265
|
+
if (!existsSync(dfDir(root))) return;
|
|
266
|
+
for (const d of readdirSync(dfDir(root), { withFileTypes: true })) {
|
|
267
|
+
if (!d.isDirectory()) continue;
|
|
268
|
+
if (readClaim(root, d.name)?.key === key) rmSync(claimFile(root, d.name), { force: true });
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
250
272
|
/** The auto-bind this session was denied by another live session's claim — lets the unbound-context message name the feature. */
|
|
251
273
|
function claimBlocker(root: string, key: string): { state: FlowState; claim: SessionClaim } | null {
|
|
252
274
|
const un = unfinishedStates(root);
|
|
@@ -639,6 +661,9 @@ ${mdDigest(draftRefresh)}`))
|
|
|
639
661
|
];
|
|
640
662
|
});
|
|
641
663
|
if (warn.length) lines.push(...warn);
|
|
664
|
+
// which identity this session's state is keyed by: a claim fight is undiagnosable when the key
|
|
665
|
+
// could be a session id or a shared directory and the output does not say which
|
|
666
|
+
lines.push(`session: ${sess.key}${sess.key.startsWith("cwd:") ? " — no session id from pi, so every pi session in this directory shares one dev-flow binding (pass flow use <slug> in each)" : ""}`);
|
|
642
667
|
const refl = readReflections(root);
|
|
643
668
|
if (refl.length) lines.push(`↻ ${refl.length} reflection(s) open — run flow doctor (it reviews and routes them)`);
|
|
644
669
|
lines.push(...rmapLine);
|
|
@@ -861,6 +886,12 @@ ${mdDigest(draftRefresh)}`))
|
|
|
861
886
|
case "check": {
|
|
862
887
|
const { state, err } = needState(root, sess, slugArg);
|
|
863
888
|
if (err) return err;
|
|
889
|
+
// a docs flow runs no project command anywhere else — pendingChecks, verifyGate and releaseGate all skip
|
|
890
|
+
// it — so running tier-1 here only produced a FAIL that read like a broken deploy in a checkout that
|
|
891
|
+
// never built the binary (#96)
|
|
892
|
+
// shortcut: --docs is the operator's word, nothing checks the changeset is docs-only, so a mislabelled
|
|
893
|
+
// flow now gets no test run at all; the mechanical fix is a diff-scope guard at verify if it ever bites
|
|
894
|
+
if (state!.docs) return { text: "docs mode: project commands skipped — a docs flow runs no tier-1 checks (CI on the tag and the artifact proof still do)" };
|
|
864
895
|
if (!cfg.checkList.length) return { text: 'no tier-1 checks configured — add ```flow blocks / flow-check blocks to ## implement in project.md', isError: true };
|
|
865
896
|
const ran = await runChecks(root, state!, cfg, cfg.checkList);
|
|
866
897
|
return { text: `tier-1 checks:\n${ran.lines.join("\n")}`, isError: ran.failed };
|
|
@@ -1310,7 +1341,12 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
1310
1341
|
const ce = e as unknown as { type: string; customType?: string; data?: { slug?: string | null } };
|
|
1311
1342
|
if (ce.type === "custom" && ce.customType === "dev-flow-bind") slug = ce.data?.slug ?? null;
|
|
1312
1343
|
}
|
|
1313
|
-
|
|
1344
|
+
const key = sessionKey(ctx);
|
|
1345
|
+
bindings.set(key, slug);
|
|
1346
|
+
// A reload ends the old session, which released its claim; the restored one must reclaim what its own
|
|
1347
|
+
// branch says it holds, or the repo answers "claimed by another live session" to the session that
|
|
1348
|
+
// holds it. A foreign live claim wins — restoring is not a takeover.
|
|
1349
|
+
if (slug && readState(ctx.cwd, slug) && !claimBlocks(readClaim(ctx.cwd, slug), key)) writeClaim(ctx.cwd, slug, key);
|
|
1314
1350
|
};
|
|
1315
1351
|
|
|
1316
1352
|
pi.registerCommand("flow", {
|
|
@@ -1349,6 +1385,12 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
1349
1385
|
refreshStatus(ctx);
|
|
1350
1386
|
});
|
|
1351
1387
|
pi.on("session_tree", async (_event, ctx) => rebuildSession(ctx));
|
|
1388
|
+
// The session, not the process, owns the binding and the claim: pi-web keeps serving other sessions
|
|
1389
|
+
// after one ends, and a stale claim there is a permanent lock (its pid is the server's, always alive).
|
|
1390
|
+
pi.on("session_shutdown", async (_event, ctx) => {
|
|
1391
|
+
if (!existsSync(dfDir(ctx.cwd))) return;
|
|
1392
|
+
releaseSession(ctx.cwd, sessionKey(ctx));
|
|
1393
|
+
});
|
|
1352
1394
|
pi.on("turn_end", async (_event, ctx) => {
|
|
1353
1395
|
refreshStatus(ctx);
|
|
1354
1396
|
// pi checks its compaction threshold between every turn; our safe points must be as frequent.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-dev-flow",
|
|
3
|
-
"version": "0.53.
|
|
3
|
+
"version": "0.53.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": [
|
package/src/core.ts
CHANGED
|
@@ -894,6 +894,9 @@ const READ_ONLY_GIT = new Set(["log", "show", "diff", "status", "blame", "cat-fi
|
|
|
894
894
|
const GIT_INVOKED = /(^|[\s/;|&(])git\s+(\S+)/;
|
|
895
895
|
|
|
896
896
|
// project.md is re-parsed on every tool call; compiled rules are cached by source.
|
|
897
|
+
// Process-global on purpose, and safe only because compile() builds flag-less regexes: no /g and no /y
|
|
898
|
+
// means no lastIndex, so a shared RegExp carries nothing mutable between sessions. Add a stateful flag
|
|
899
|
+
// here and this cache becomes cross-session state — the one thing this package must never keep.
|
|
897
900
|
const regexCache = new Map<string, RegExp | null>();
|
|
898
901
|
function compile(source: string): RegExp | null {
|
|
899
902
|
if (!regexCache.has(source)) {
|