@llblab/pi-state-flow 0.9.0 → 0.9.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/AGENTS.md CHANGED
@@ -43,7 +43,7 @@
43
43
  - `/state-flow-stop` must persist only the current session/branch's `config.enabled = false` and necessary runtime provenance, preserving all semantic checkpoints/tails and creating no semantic transition. It must retain a same-physical-session bounded passive context handoff across reload, resume, and tree restoration so disabling semantics never re-exposes pre-stop raw history. Active restart replaces passive mode but uses that bounded boundary for its one migration run; new and forked physical sessions inherit neither projection. It does not rewrite agent-level `autoStart` or change its policy for future new sessions.
44
44
  - Keep the injected runtime protocol compact and normative; put rationale and extended explanation in README rather than the model prompt. Never parse or strip State Flow HTML comments; they are ordinary historical text, while foreign comment handling remains owned by other extensions.
45
45
  - Do not claim strict boundedness for state, the current run trajectory, the turn specification, or the external full trace.
46
- - Remain extension-agnostic in core semantics, storage, and inference: core modules never import, name, special-case, or encode policy for another extension or transport. One optional leaf presentation adapter (`lib/telegram.ts`) may import public `pi-telegram` membranes to mirror status and expose the same start/stop affordances already owned by `state-flow-start` and `state-flow-stop`; it must fail open when the transport is absent or its registry is unready and must never alter core behavior.
46
+ - Remain extension-agnostic in core semantics, storage, and inference: core modules never import, name, special-case, or encode policy for another extension or transport. One optional leaf presentation adapter (`lib/telegram.ts`) may import public `pi-telegram` membranes to mirror the live status on exactly one main-menu section button and expose the same start/stop affordances already owned by `state-flow-start` and `state-flow-stop`; it must fail open when the transport is absent or its registry is unready and must never alter core behavior.
47
47
  - Activate State Flow model tools only while enabled on the selected branch; preserve every unrelated active tool when toggling them. Keep mutation confined to `patch_state` and historical observation read-only.
48
48
  - Keep `.github/workflows/release.yml` as the sole version-tag release owner: it validates immutable tag identity, publishes through npm Trusted Publisher with provenance, verifies the public package, and only then creates the GitHub Release. Keep package, lockfile, tag, and changelog versions aligned; never add a long-lived npm token fallback.
49
49
  - Run `npm run validate` after retained code changes.
package/BACKLOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # BACKLOG
2
2
 
3
- Completed release work belongs in [CHANGELOG.md](CHANGELOG.md). No implementation item remains open for 0.8.0.
3
+ Completed release work belongs in [CHANGELOG.md](CHANGELOG.md). No implementation item remains open for 0.9.0.
4
4
 
5
5
  ## Candidate evolution
6
6
 
@@ -8,6 +8,9 @@ Completed release work belongs in [CHANGELOG.md](CHANGELOG.md). No implementatio
8
8
  - Boundary: project the existing durable global materialization only. No writes, transitions, patches, barriers, session/CWD initialization, or temporal-history changes. Model tools and the full protocol remain opt-in behind explicit start, and the bootstrap adds no second semantic mode.
9
9
  - Open questions: whether deferred Markdown freshness discovery must run ahead of the first inference, token cost of a stable global prefix, behavior under untrusted project contexts, and naming distinct from the existing bootstrap-run concept.
10
10
  - Status: candidate, not scheduled. Do not start without a dedicated release contract.
11
+ - [ ] **Telegram submenu state analyzer:** Extend the State Flow Telegram section with a read-only analyzer view over the same diagnostics `/state-flow-status` already reports (branch mode, temporal head and hot depth, scope keys, retained tails, artifact freshness, publication). The operator deliberately deferred this beyond the 0.9.0 control surface.
12
+ - Boundary: presentation only. Reuse existing status diagnostics; no new semantic mode, and never mutate state from the analyzer view.
13
+ - Status: candidate, not scheduled. Do not start without a dedicated release contract.
11
14
 
12
15
  ## Deferred host integration
13
16
 
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  > Each release keeps at most 8 outcome records of at most 512 characters.
4
4
 
5
+ ## 0.9.2: Single Telegram surface
6
+
7
+ - `Interop`: State Flow now appears on Telegram exactly once. The inline main-menu section button before Settings carries the live status (`🌀 State Flow: #N`, `⚫️ State Flow` while off) and opens the existing start/stop submenu; the duplicated Status-screen row is removed, so the same value no longer renders in two places. Fail-open registration and shutdown disposal are unchanged.
8
+
9
+ ## 0.9.1: Status text mirrors the terminal line
10
+
11
+ - `Interop`: The `pi-telegram` surfaces now copy the compact terminal status instead of decorating it. The Status screen shows the terminal value itself (`State Flow: #N`) and hides entirely while State Flow is off; the main-menu button shows `🌀 State Flow: #N` or a plain `⚫️ State Flow` without on/off, starting, bootstrap, or separator text.
12
+ - `Testing`: The shared test harness removes its temporary fixture repositories at process exit; runaway fixtures previously exhausted the `/tmp` inode table and made later runs fail with ENOSPC.
13
+
5
14
  ## 0.9.0: Telegram status surface
6
15
 
7
16
  - `Interop`: Added an optional fail-open `pi-telegram` presentation adapter. With the transport installed, the status screen shows `State Flow: on · step #N` while enabled, and the inline main menu places a `🌀 State Flow: #N` or `⚫️ State Flow: off` section button directly before Settings.
package/README.md CHANGED
@@ -66,7 +66,7 @@ Stopping changes the current session/branch configuration, preserves semantic ch
66
66
 
67
67
  The compact status is an accent `state-flow` and dim `#<step>`. Detailed status distinguishes runtime config/meta from semantic materialization, reports scope keys, the selected temporal head and runtime revision, available hot offsets, per-scope retained patch tails, artifact counts, stale Markdown reasons, and pending publication. Retained tails may include inherited pre-origin records, so their counts are not active history depth. It labels global/CWD/session/effective state without dumping source bodies. Failed inspection means unavailable evidence, never a falsely clean count.
68
68
 
69
- When the optional `pi-telegram` extension is installed, State Flow mirrors the same identity there: the Status screen shows `State Flow: on · step #N` while enabled, and the inline main menu places a `🌀 State Flow: #N` or `⚫️ State Flow: off` section button directly before Settings. The button opens a compact control submenu for the current session branch: `Start` or `Stop`, `Refresh`, and `Cancel start` while a start deferred behind an active run is pending. Starting while a run is active waits for that run to settle; stopping applies immediately. Registration fails open when the transport is absent, retries when the section registry becomes ready, and disposes on session shutdown; the `/state-flow-*` commands remain the authority and nothing changes for hosts without `pi-telegram`.
69
+ When the optional `pi-telegram` extension is installed, State Flow appears exactly once in Telegram: the inline main menu places a `🌀 State Flow: #N` or `⚫️ State Flow` section button directly before Settings, and that button's label carries the live status. The button opens a compact control submenu for the current session branch: `Start` or `Stop`, `Refresh`, and `Cancel start` while a start deferred behind an active run is pending. Starting while a run is active waits for that run to settle; stopping applies immediately. Registration fails open when the transport is absent, retries when the section registry becomes ready, and disposes on session shutdown; the `/state-flow-*` commands remain the authority and nothing changes for hosts without `pi-telegram`.
70
70
 
71
71
  ## State, scope, and time
72
72
 
@@ -199,7 +199,7 @@ Unknown keys fail loading. State Flow memory ownership and global availability a
199
199
 
200
200
  `/state-flow-status` reports branch mode, runtime revision, temporal head/history depth, scope keys, patch tails, artifact freshness, memory-bearing scopes, external-promotion summaries, remote policy/queue state, and pending publication. Unavailable materialization is reported as unavailable, never fabricated as empty. Artifact source bodies are not read for status.
201
201
 
202
- With `pi-telegram` installed, the optional `telegram` adapter mirrors the same identity in Telegram: the Status screen row shows `State Flow: on · step #N` while enabled, and the main-menu section button before Settings opens the branch start/stop submenu. Registration is fail-open and retried on session start, disposal happens on session shutdown, the adapter reads the same snapshot as the compact terminal status, and its start/stop actions call the same functions as the commands.
202
+ With `pi-telegram` installed, the optional `telegram` adapter mirrors the same identity in Telegram: the main-menu section button before Settings carries the live `🌀 State Flow: #N` or `⚫️ State Flow` label and opens the branch start/stop submenu. Registration is fail-open and retried on session start, disposal happens on session shutdown, the adapter reads the same snapshot as the compact terminal status, and its start/stop actions call the same functions as the commands.
203
203
 
204
204
  Opt-in `logging` appends local JSONL diagnostics for rejected `patch_state` calls and preserved drafts plus fallback turns while turn resolution is pending. A rejected call retains its exact attempted arguments, the precise error, and, when available, tool identity, call id, resolution attempt, and terminal-eligibility state; accepted patches are never logged. Records preserve useful exact text blocks and reduce other blocks to structural identity without duplicating reasoning. They are never semantic state, scope `meta.json`, Pi checkpoints, or repository input. Write failure changes no resolution, enablement, or accepted state and reports at most one bounded local warning.
205
205
 
package/index.ts CHANGED
@@ -189,7 +189,6 @@ export {
189
189
  buildStateFlowSectionView,
190
190
  createStateFlowTelegramAdapter,
191
191
  formatStateFlowSectionLabel,
192
- formatStateFlowStatusLine,
193
192
  loadStateFlowTelegramModules,
194
193
  STATE_FLOW_TELEGRAM_ID,
195
194
  type StateFlowTelegramAdapter,
@@ -202,8 +201,6 @@ export {
202
201
  type StateFlowTelegramSectionContext,
203
202
  type StateFlowTelegramSectionModule,
204
203
  type StateFlowTelegramSnapshot,
205
- type StateFlowTelegramStatusLine,
206
- type StateFlowTelegramStatusModule,
207
204
  type StateFlowTelegramView
208
205
  } from "./lib/telegram.ts";
209
206
  export { advanceTemporalState, readTemporalState, type TemporalState } from "./lib/temporal.ts";
package/lib/telegram.ts CHANGED
@@ -1,13 +1,9 @@
1
- // Domain: optional pi-telegram presentation adapter for State Flow status and branch controls.
1
+ // Domain: optional pi-telegram presentation adapter for the State Flow main-menu section.
2
2
  //
3
3
  // This is a leaf adapter. Core semantics, storage, and inference never depend on it; when
4
4
  // pi-telegram is absent or its registry is not ready, registration fails open and retries.
5
5
 
6
6
  export const STATE_FLOW_TELEGRAM_ID = "@llblab/pi-state-flow";
7
- const STATUS_IMPORT_SPECIFIERS = [
8
- "@llblab/pi-telegram/status",
9
- new URL("../../pi-telegram/api/status.ts", import.meta.url).href,
10
- ];
11
7
  const SECTIONS_IMPORT_SPECIFIERS = [
12
8
  "@llblab/pi-telegram/sections",
13
9
  new URL("../../pi-telegram/api/sections.ts", import.meta.url).href,
@@ -20,11 +16,6 @@ export interface StateFlowTelegramSnapshot {
20
16
  startPending: boolean;
21
17
  }
22
18
 
23
- export interface StateFlowTelegramStatusLine {
24
- label: string;
25
- value: string;
26
- }
27
-
28
19
  export interface StateFlowTelegramButton {
29
20
  text: string;
30
21
  callback_data: string;
@@ -47,13 +38,6 @@ export interface StateFlowTelegramCallbackContext extends StateFlowTelegramSecti
47
38
  payload: string;
48
39
  }
49
40
 
50
- export interface StateFlowTelegramStatusModule {
51
- registerTelegramStatusLineProvider(
52
- provider: (ctx: { activeModel?: unknown }) => StateFlowTelegramStatusLine | undefined,
53
- options: { id: string },
54
- ): () => void;
55
- }
56
-
57
41
  export interface StateFlowTelegramSectionModule {
58
42
  registerTelegramSection(section: {
59
43
  id: string;
@@ -65,7 +49,6 @@ export interface StateFlowTelegramSectionModule {
65
49
  }
66
50
 
67
51
  export interface StateFlowTelegramModules {
68
- status?: StateFlowTelegramStatusModule;
69
52
  sections?: StateFlowTelegramSectionModule;
70
53
  }
71
54
 
@@ -90,16 +73,9 @@ export interface StateFlowTelegramAdapter {
90
73
  dispose(): void;
91
74
  }
92
75
 
93
- /** The Status screen mirrors the terminal status identity: hidden while State Flow is off. */
94
- export function formatStateFlowStatusLine(snapshot: StateFlowTelegramSnapshot): StateFlowTelegramStatusLine | undefined {
95
- if (!snapshot.enabled) return snapshot.startPending ? { label: "State Flow", value: "starting…" } : undefined;
96
- return { label: "State Flow", value: snapshot.bootstrap ? "bootstrap" : `on · step #${snapshot.step}` };
97
- }
98
-
99
- /** Main-menu section label doubles as the live status text. */
76
+ /** Main-menu section label doubles as the live status value; the disabled row carries no status text. */
100
77
  export function formatStateFlowSectionLabel(snapshot: StateFlowTelegramSnapshot): string {
101
- if (!snapshot.enabled) return snapshot.startPending ? "🌀 State Flow: starting…" : "⚫️ State Flow: off";
102
- return snapshot.bootstrap ? "🌀 State Flow: bootstrap" : `🌀 State Flow: #${snapshot.step}`;
78
+ return snapshot.enabled ? `🌀 State Flow: #${snapshot.step}` : "⚫️ State Flow";
103
79
  }
104
80
 
105
81
  export function buildStateFlowSectionView(
@@ -177,17 +153,12 @@ async function importTelegramModule<TModule>(
177
153
 
178
154
  /** Default loader; injectable so tests and embedded hosts can control transport presence. */
179
155
  export async function loadStateFlowTelegramModules(): Promise<StateFlowTelegramModules> {
180
- const status = await importTelegramModule<StateFlowTelegramStatusModule>(
181
- STATUS_IMPORT_SPECIFIERS,
182
- (module): module is StateFlowTelegramStatusModule =>
183
- typeof (module as StateFlowTelegramStatusModule | undefined)?.registerTelegramStatusLineProvider === "function",
184
- );
185
156
  const sections = await importTelegramModule<StateFlowTelegramSectionModule>(
186
157
  SECTIONS_IMPORT_SPECIFIERS,
187
158
  (module): module is StateFlowTelegramSectionModule =>
188
159
  typeof (module as StateFlowTelegramSectionModule | undefined)?.registerTelegramSection === "function",
189
160
  );
190
- return { ...(status === undefined ? {} : { status }), ...(sections === undefined ? {} : { sections }) };
161
+ return { ...(sections === undefined ? {} : { sections }) };
191
162
  }
192
163
 
193
164
  export function createStateFlowTelegramAdapter(options: {
@@ -196,7 +167,6 @@ export function createStateFlowTelegramAdapter(options: {
196
167
  }): StateFlowTelegramAdapter {
197
168
  const load = options.load ?? loadStateFlowTelegramModules;
198
169
  let generation = 0;
199
- let statusRegistered = false;
200
170
  let sectionRegistered = false;
201
171
  let registration: Promise<boolean> | undefined;
202
172
  const disposers: Array<() => void> = [];
@@ -211,22 +181,6 @@ export function createStateFlowTelegramAdapter(options: {
211
181
  }
212
182
  // A shutdown during loading must not leave a registration behind.
213
183
  if (epoch !== generation) return false;
214
- if (!statusRegistered && modules.status) {
215
- try {
216
- const dispose = modules.status.registerTelegramStatusLineProvider(
217
- () => formatStateFlowStatusLine(options.port.snapshot()),
218
- { id: STATE_FLOW_TELEGRAM_ID },
219
- );
220
- if (epoch === generation) {
221
- disposers.push(dispose);
222
- statusRegistered = true;
223
- } else {
224
- dispose();
225
- }
226
- } catch {
227
- // Registry not initialized yet; the next ensure retries.
228
- }
229
- }
230
184
  if (!sectionRegistered && modules.sections) {
231
185
  try {
232
186
  const dispose = modules.sections.registerTelegramSection(buildStateFlowTelegramSection(options.port));
@@ -240,12 +194,12 @@ export function createStateFlowTelegramAdapter(options: {
240
194
  // Registry not initialized yet; the next ensure retries.
241
195
  }
242
196
  }
243
- return statusRegistered || sectionRegistered;
197
+ return sectionRegistered;
244
198
  };
245
199
 
246
200
  return {
247
201
  async ensure(): Promise<boolean> {
248
- if (statusRegistered && sectionRegistered) return true;
202
+ if (sectionRegistered) return true;
249
203
  registration ??= register().finally(() => {
250
204
  registration = undefined;
251
205
  });
@@ -260,7 +214,6 @@ export function createStateFlowTelegramAdapter(options: {
260
214
  // Disposal is best-effort; pi-telegram owns its registry lifetime.
261
215
  }
262
216
  }
263
- statusRegistered = false;
264
217
  sectionRegistered = false;
265
218
  },
266
219
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llblab/pi-state-flow",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "private": false,
5
5
  "description": "Incremental scoped state/context compiler for Pi, inspired by SKILL.state",
6
6
  "keywords": [