@llblab/pi-kit 0.27.1 → 0.27.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/BACKLOG.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # Backlog
2
2
 
3
- The 0.27.1 composition is recorded in [CHANGELOG.md](./CHANGELOG.md). Package pins, resource order and bundled runtime ownership remain authoritative in `package.json`.
3
+ The 0.27.2 composition is recorded in [CHANGELOG.md](./CHANGELOG.md). Package pins, resource order and bundled runtime ownership remain authoritative in `package.json`.
4
4
 
5
5
  ## Carried checks
6
6
 
7
+ - **Installed 0.27.2 cascade receipt smoke (operator-owned):** After separately authorized installation/reload, close an intent owning a nested lazy key in disposable State Flow storage and confirm the receipt lists its owner path under `cascaded`, without the body. Packed validation does not certify installed clients.
8
+
7
9
  - **Installed 0.27.1 Fast status smoke (operator-owned):** After separately authorized installation/reload, check Telegram menu Fast on/off and model switching for Codex and Claude Opus; unsupported Claude families must not show Fast. Use disposable settings and mocked quota where possible; do not mutate live stores or reconnect Telegram without separate authorization.
8
10
 
9
11
  - **Installed 0.27.0 smoke (operator-owned):** After separately authorized installation/reload, check the exact released kit's terminal controls and optional Telegram rendering with disposable State Flow storage. Packed SDK validation does not certify the operator's running clients. Do not reconnect Telegram, change Pi settings or use live memory/usage/Recipe stores as fixtures without separate authorization.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to `@llblab/pi-kit` are documented here.
4
4
 
5
+ ## 0.27.2: State Flow Cascade Receipts
6
+
7
+ - `Cascade Receipts`: Advances the exact State Flow pin to published `0.25.1`. Accepted receipts now list every intent-cascaded owner path, including nested lazy keys, without exposing bodies or eliding the list as predictable. The lifecycle-state ceiling also counts const-bound operation slots and lifetimes. Other pins, resources, load order and storage semantics are unchanged.
8
+
5
9
  ## 0.27.1: Telegram Fast Status
6
10
 
7
11
  - `Telegram Fast Status`: Advances Codex Usage to `0.12.1` and Claude Usage to `0.2.1`. Their Telegram rows now show the active model's Fast preference alongside quota, or alone when quota is unavailable, and reread it at menu render time. Claude retains Opus-only eligibility. Other pins, resource order and quota coordination are unchanged.
package/README.md CHANGED
@@ -17,7 +17,7 @@ Package links lead to the owning repositories for usage, documentation, issues,
17
17
  | [`@llblab/pi-clean-room`](https://github.com/llblab/pi-clean-room) | `0.3.0` | Isolated nested Pi TUI with named npm extensions and compatible model selection |
18
18
  | [`@llblab/pi-codex-usage`](https://github.com/llblab/pi-codex-usage) | `0.12.1` | Shared Codex quota/Business credit status and persistent priority Fast toggle, mirrored in Telegram |
19
19
  | [`@llblab/pi-grow-loop`](https://github.com/llblab/pi-grow-loop) | `0.9.0` | Visible continuation scheduling and bounded worker Skills through compiled, manifest-owned resources |
20
- | [`@llblab/pi-state-flow`](https://github.com/llblab/pi-state-flow) | `0.25.0` | Scoped context/memory compiler with intent-owned self-cleaning memory, memory-inert Off and ownership status |
20
+ | [`@llblab/pi-state-flow`](https://github.com/llblab/pi-state-flow) | `0.25.1` | Scoped context/memory compiler with intent-owned self-cleaning memory, memory-inert Off and ownership status |
21
21
  | [`@llblab/pi-telegram`](https://github.com/llblab/pi-telegram) | `0.51.6` | Telegram companion with connection resume, Workspace slot recovery, follower Threads, filterable Skills, files, voice, and controls |
22
22
  | [`@llblab/skills`](https://github.com/llblab/skills) | `1.15.0` | Portable workflows for engineering, review, design, context maintenance, and other focused tasks |
23
23
 
@@ -25,7 +25,7 @@ Versions are exact by design. An upstream release does not change an installed k
25
25
 
26
26
  ## Install
27
27
 
28
- Requires **Pi 1.0.0+** and **Node.js 22.19.0+**. State Flow requires its canonical checkpoint/tail storage format and does not convert unsupported stores in place. Preserve existing stores and consult the [owning package's storage guidance](https://github.com/llblab/pi-state-flow/blob/v0.25.0/docs/usage.md#moving-a-store-and-supported-formats) before changing installations.
28
+ Requires **Pi 1.0.0+** and **Node.js 22.19.0+**. State Flow requires its canonical checkpoint/tail storage format and does not convert unsupported stores in place. Preserve existing stores and consult the [owning package's storage guidance](https://github.com/llblab/pi-state-flow/blob/v0.25.1/docs/usage.md#moving-a-store-and-supported-formats) before changing installations.
29
29
 
30
30
  From npm:
31
31
 
@@ -45,7 +45,7 @@ Prefer the kit instead of separately loading the same packages. If you already u
45
45
 
46
46
  ## Development
47
47
 
48
- The `0.27.1` composition includes published Codex Usage `0.12.1` and Claude Usage `0.2.1` with Telegram Fast status, alongside State Flow `0.25.0`, Telegram `0.51.6` and the Pi 1.0 cohort. The packed bundle loads all seven extensions on Pi 1.0.0 with no credentials or external requests. This does not certify installed-client rendering; carried checks remain in [Backlog](./BACKLOG.md).
48
+ The `0.27.2` composition includes published State Flow `0.25.1` with complete cascade receipts, Codex Usage `0.12.1` and Claude Usage `0.2.1` with Telegram Fast status, alongside Telegram `0.51.6` and the Pi 1.0 cohort. The packed bundle loads all seven extensions on Pi 1.0.0 with no credentials or external requests. This does not certify installed-client rendering; carried checks remain in [Backlog](./BACKLOG.md).
49
49
 
50
50
  ```bash
51
51
  npm install
@@ -1,28 +1,24 @@
1
1
  # Backlog
2
2
 
3
- The **0.25.0: Intent-Owned Memory** scope is implemented and locally validated; outcomes are recorded in [CHANGELOG.md](CHANGELOG.md), with package, lockfile and changelog aligned at 0.25.0. This backlog keeps publication, installed-client evidence and later decisions open. Current contracts live in [architecture](docs/architecture.md), [usage](docs/usage.md) and [intent ownership](docs/lazy-state.md#intent-ownership).
3
+ The **0.25.1: Cascade Receipts** scope is implemented; outcomes belong in [CHANGELOG.md](CHANGELOG.md). This backlog retains release and installed-client gates and deferred decisions. Cascade semantics, canonical storage, stored patch records and lifecycle behaviour remain unchanged.
4
+
5
+ ## Out of scope
6
+
7
+ - Changing what a cascade deletes, including writes into an owned target made by the closing patch. That stays deleted by design and already appears in the receipt.
8
+ - Nested `lazy_navigation`, warnings, validation or rejection of any kind.
9
+ - Any reduction of lifecycle state; the tagged-union question stays deferred.
4
10
 
5
11
  ## Carried gates
6
12
 
7
- - **0.25.0 publication (approval-gated):** Commit the prepared tree and push the exact `v0.25.0` tag; then verify the tag's successful release workflow, published GitHub Release and matching npm package before reporting release completion.
8
- - **Installed 0.25.0 smoke (operator-owned):** After separately authorized installation/reload, use a disposable store. In `session` and in `cwd`: open an intent with owned `working` and `lazy` entries plus one textual mention, close it, and confirm the owned entries are gone, the mentioned one remains, the receipt lists the deletions and `/state-flow-status` shares update. Then supersede an intent in one patch and confirm its targets survive.
9
- - **Installed 0.22.0 smoke (operator-owned):** Perform the carried check if it is not yet recorded, only against the exact released 0.22.0 installation; a reload of a later candidate cannot certify the old release. After an operator-authorized reload, confirm:
10
- - terminal autocomplete exposes Active/Passive/Off and status;
11
- - Telegram shows the single `off | passive | active` row plus the four inspection buttons;
12
- - current-session mode agrees across tools, context and status, and survives reload.
13
- Do not edit real global defaults or unrelated sessions.
14
- - **Installed 0.23.0 smoke (operator-owned):** After separately authorized installation/reload, confirm an unconfigured *new* session is Off without semantic writes, retained choices and explicit global modes survive, and Telegram shows one `Off | Passive | Active` radio row with the selected 🟡/🟣/🟢 marker and ⚫️ inactive markers, followed by four direct scope inspections. Isolate test storage; do not use the live store as a fixture. SDK tests alone do not certify installed-client rendering.
15
- - **Installed 0.24.0 smoke (approval/operator-owned):** Local lifecycle, cancellation, background-work and callback/inspection acceptance is complete; real-client behavior remains separate evidence. After separately authorized installation/reload of the exact 0.24.0 release, use a disposable store to check Off attachment and pending-work cancellation, no late memory warnings, current read-only inspections without private placeholders, preserved deferred Passive/Active/fork acquisition, and unchanged terminal/Telegram mode controls. Do not use the live store, treat its reload as evidence for older published releases, or change unrelated operator sessions.
16
-
17
- ## Deferred beyond 0.25.0 (decision inputs, not commitments)
18
-
19
- - **Convention uptake:** After some real use, read the `/state-flow-status` ownership shares; if most `working`/`lazy` entries stay unowned, revisit the protocol wording, not the mechanism.
20
- - **Behavioural evaluation:** Live-model comparison of Active against native compaction on one long cyclic task. Needs a policy decision first; current benchmarks are synthetic and make no model calls.
21
- - **Lifecycle real-use measurement (gated):** The operator install runs with `logging: true` and has no recorded `publication-conflict`, `finalization` or `barrier-block` entries; cooperating-writer waits, Stop fences and fork/restore contention are not instrumented. Removing any awaited layer for rarity first needs a decision to add opt-in counters.
22
- - **Lifecycle state as one tagged union:** The 0.25.0 lifecycle review left 17 closure bindings in `lib/extension.ts`, each a justified selection, run or host fact. Remaining candidates: the seven branch-selection facts (`snapshot`, `runtime`, `branchStartsWithoutRuntime`, `selectedHistoryExpired`, `modePersistenceError`, `forkInitialization`, `deferredBranch`) as one Off-deferred/attached union, and `passiveContinuation`/`bootstrapContinuation` as one continuation slot once their exclusivity is proven. Decide only with a behavioural reason; no further mechanical moves are pending.
23
- - **Skill compilation fidelity:** Hashes detect source change, not a lossy first compilation. Measure before adding anything.
24
- - **Compaction threshold:** `STATE_FLOW_COMPACTION_MIN_CONTEXT_TOKENS = 24_000` is documented as a margin above Pi's default 20,000-token retained suffix. Make it configurable only if a real workload or non-default Pi retention settings demonstrate a mismatch.
13
+ - **Installed 0.25.1 smoke (operator-owned).** Disposable store: close an intent that owns a nested lazy key and confirm the receipt lists it under `cascaded`. May be combined with the open 0.25.0 smoke.
14
+ - **Installed 0.22.0, 0.23.0, 0.24.0 and 0.25.0 smokes** remain open as recorded.
15
+
16
+ ## Deferred (decision inputs, not commitments)
17
+
18
+ - **Closing-patch losses.** In real sessions, look for closing patches that write into a target the same patch cascades. If frequent, revisit the closing sentence in the protocol, not the mechanism.
19
+ - Convention uptake, behavioural evaluation, lifecycle real-use measurement, lifecycle tagged union, Skill compilation fidelity and compaction threshold carry over unchanged from the 0.25.0 backlog.
25
20
 
26
21
  ## Release boundary
27
22
 
28
- Release publication is owned by `.github/workflows/release.yml`. Align package, lockfile, tag and changelog at the release version, rebuild `dist/` from final sources, run `npm run validate` and the context validator after context edits, and verify the exact tag's successful workflow, published GitHub Release and matching npm package before reporting release completion. Installed-instance reload remains a separate operator action.
23
+ - **Publication (approval-gated).** After explicit authorization, commit the prepared 0.25.1 package, lockfile, changelog and rebuilt `dist/`, tag the exact commit `v0.25.1`, and push. Verify the exact-tag release workflow, non-draft GitHub Release and matching npm version/commit before closing this gate. Local readiness requires `npm run validate` and the context validator; it does not certify installed clients.
24
+ - **Installation/reload (operator-owned).** Requires separate authorization and disposable storage. Grow Loop preparation does not cross publication or live-client gates.
@@ -2,9 +2,14 @@
2
2
 
3
3
  > Each release keeps at most 8 outcome records of at most 512 characters.
4
4
 
5
+ ## 0.25.1: Cascade Receipts
6
+
7
+ - `Composition ceiling`: One invariant now counts mutable closure bindings plus `OwnedOperationSlot` and `RenewableLifetime` instances in `lib/extension.ts`, including const-bound holders, against the current total of 24 (17 + 5 + 2). Existing named owner assertions remain. Mutation checks reject an added binding, operation slot or lifetime; lifecycle source and behavior are unchanged.
8
+ - `Cascade receipts`: `state_updates.cascaded` lists every owner-scoped target removed by intent deletion, including nested lazy keys invisible to effective updates and top-level navigation. Paths only, never bodies; deterministic across scopes and never elided as predictable. Staging passes its existing cascade to the context projection without recomputing ownership or changing stored records. Native Active/Passive tests verify each scope, and the always-injected protocol did not grow.
9
+
5
10
  ## 0.25.0: Intent-Owned Memory
6
11
 
7
- - `Intent-owned memory`: Deleting an intent key now deletes the same-scope `working`/`lazy` object keys its structured `{"$ref"}` values own, after authored operations in the same atomic cohort and revision, unless a remaining intent of that scope references the target, an ancestor or a descendant. Other targets and textual `$path` mentions are skipped silently; nothing is rejected, warned about or archived. Records store the cascade as explicit deletions and receipts report it.
12
+ - `Intent-owned memory`: Deleting an intent deletes same-scope `working`/`lazy` keys its structured `{"$ref"}` values own, after authored operations in one atomic cohort/revision, unless a surviving intent references the target, an ancestor or descendant. Other targets and textual `$path` mentions are skipped silently; no rejection, warning or archive. Records store explicit deletions; receipts report effective changes and top-level lazy navigation, but omit nested lazy targets (fixed in 0.25.1).
8
13
  - `Work from intents`: Protocol, `patch_state` description, both Skills, README and docs present `intents` as the queue of chosen actions and `working` as their temporary context. Structured refs inside intents own; textual `$path` mentions only use. Before closing an intent, save survivors to unowned paths, with abandonment reasons in `contract`. Unowned entries stay legal. The always-injected protocol did not grow; duplicated read-path and barrier wording now lives only in the tool definitions.
9
14
  - `Ownership status`: `/state-flow-status` adds a per-scope `Scope memory:` block with UTF-8 sizes of present planes and the share of top-level `working`/`lazy` entries owned by an open intent. Operator-only; no notices, thresholds or model-facing effects.
10
15
  - `Composition root step one`: Completed-history compaction request state moves into `StateFlowCompactionRequests` and settled-turn backup/push state into `SettledTurnBackup`, cutting `lib/extension.ts` mutable closure bindings from 34 to 26 and adding an invariant ceiling. No behaviour change.
@@ -3,8 +3,9 @@ import { type ArtifactInvalidationNotice, type ArtifactModelHints } from "./arti
3
3
  import type { RecentTransitionWindow } from "./history.ts";
4
4
  import { type JsonValue } from "./json.ts";
5
5
  import type { Snapshot } from "./snapshot.ts";
6
+ import { type OwnedPath } from "./ownership.ts";
6
7
  import type { RehydrationPhase } from "./rehydration.ts";
7
- import { type AtomicScopePatches, type SemanticState } from "./state.ts";
8
+ import { type AtomicScopePatches, type SemanticState, type StateScope } from "./state.ts";
8
9
  /** Refresh only our section; Pi owns system frames, tools and forced-prompt precedence. */
9
10
  export declare function projectSystemProtocol(messages: AgentMessage[], protocol: string | undefined): AgentMessage[];
10
11
  type LazyValueKind = "array" | "boolean" | "null" | "number" | "object" | "string";
@@ -48,7 +49,7 @@ export declare class ContextProjection {
48
49
  private notices;
49
50
  reset(): void;
50
51
  /** Called only after successful publication and ancillary acceptance, immediately before returning the native result. */
51
- acceptPatch(before: SemanticState, after: SemanticState, patches: AtomicScopePatches, hints: ArtifactModelHints): {
52
+ acceptPatch(before: SemanticState, after: SemanticState, patches: AtomicScopePatches, hints: ArtifactModelHints, cascades?: Partial<Record<StateScope, readonly OwnedPath[]>>): {
52
53
  effective: ModelStateUpdate[];
53
54
  lazy_navigation?: {
54
55
  available: boolean;
@@ -56,6 +57,7 @@ export declare class ContextProjection {
56
57
  keys?: Record<string, LazyValueKind>;
57
58
  } | undefined;
58
59
  projection: `${string}-${string}-${string}-${string}-${string}`;
60
+ cascaded?: string[] | undefined;
59
61
  } | undefined;
60
62
  project(messages: AgentMessage[], current: ContextView, makeHead: () => AgentMessage, initial?: ContextView): AgentMessage[];
61
63
  }
@@ -1,6 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { projectArtifactForModel } from "./artifact.js";
3
3
  import { applyPatch, isObject, presentationJson, sameJson } from "./json.js";
4
+ import { formatOwnedPath } from "./ownership.js";
4
5
  import { projectSemanticPatch, projectStateForModel } from "./state.js";
5
6
  /** Refresh only our section; Pi owns system frames, tools and forced-prompt precedence. */
6
7
  export function projectSystemProtocol(messages, protocol) {
@@ -144,7 +145,7 @@ export class ContextProjection {
144
145
  this.notices = [];
145
146
  }
146
147
  /** Called only after successful publication and ancillary acceptance, immediately before returning the native result. */
147
- acceptPatch(before, after, patches, hints) {
148
+ acceptPatch(before, after, patches, hints, cascades = {}) {
148
149
  const state = projectStateForModel(after, hints);
149
150
  const navigation = lazyNavigationHint(after);
150
151
  const beforeNavigation = this.view?.lazy_navigation ?? lazyNavigationHint(before);
@@ -252,7 +253,11 @@ export class ContextProjection {
252
253
  }
253
254
  if (this.view)
254
255
  this.view = { ...this.view, state, lazy_navigation: navigation };
255
- return updates.effective.length || updates.lazy_navigation ? { projection: this.identity, ...updates } : undefined;
256
+ // Owner paths remain informative even when effective state/navigation is masked
257
+ // or the model could predict every direct write. Never expose target values.
258
+ const cascaded = ["global", "cwd", "session"].flatMap((scope) => (cascades[scope] ?? []).map((path) => formatOwnedPath(scope, path)));
259
+ return updates.effective.length || updates.lazy_navigation || cascaded.length
260
+ ? { projection: this.identity, ...updates, ...(cascaded.length ? { cascaded } : {}) } : undefined;
256
261
  }
257
262
  project(messages, current, makeHead, initial) {
258
263
  const identities = messages.map((message) => JSON.stringify([message.role, message.timestamp,
@@ -801,7 +801,7 @@ export default function stateFlowExtension(pi, options = {}) {
801
801
  }
802
802
  clearAcceptedAcquisitions(new Set(acquiredArtifacts.map(({ path }) => path)));
803
803
  updateUi(ctx);
804
- const updates = contextProjection.acceptPatch(previousEffective, effectiveState, patches, acquisition.hints);
804
+ const updates = contextProjection.acceptPatch(previousEffective, effectiveState, patches, acquisition.hints, stage.cascades);
805
805
  const acknowledgement = changed
806
806
  ? `\nState materialized atomically at ${scopes.join("+")} scope${scopes.length === 1 ? "" : "s"}.`
807
807
  : "\nState already current.";
@@ -1,6 +1,6 @@
1
1
  import type { AgentMessage } from "@earendil-works/pi-agent-core";
2
2
  export type { StateDocument } from "./state.ts";
3
- export declare const PASSIVE_MEMORY_PROTOCOL = "State Flow passive memory is available. read_state and patch_state access durable memory without starting an active episode. Passive turns never trigger State Flow continuation or compaction. Missing paths/hints do not require history search. Choose targeted historical reads when useful to the task; no separate user permission is needed. Past values are evidence, not current state; never automatically restore deleted memory. Head state/recent transitions are frozen at projection start. Only state_updates matching the head's State Flow projection ID apply; older IDs are history. When present, patch_state results/context-update notices carry state_updates: effective entries replace values at key/index-segment path arrays (deleted:true means absent); direct writes need no echo; shared drift remains visible. Latest entries win over earlier state at those paths; lazy bodies remain omitted. Notices replace invalidations/rehydration, including []/null.";
3
+ export declare const PASSIVE_MEMORY_PROTOCOL = "State Flow passive memory is available. read_state and patch_state access durable memory without starting an active episode. Passive turns never trigger State Flow continuation or compaction. Missing paths/hints do not require history search. Choose targeted historical reads when useful to the task; no separate user permission is needed. Past values are evidence, not current state; never automatically restore deleted memory. Head state/recent transitions are frozen at projection start. Only state_updates matching the head's State Flow projection ID apply; other IDs are history. Results/context notices carry state_updates: effective entries replace values at key/index-segment path arrays (deleted:true means absent); cascaded lists owner paths an intent deletion removed. Direct writes may elide; shared drift stays visible. Latest entries win over earlier state; lazy bodies stay omitted. Notices replace invalidations/rehydration, including []/null.";
4
4
  /** Keep successful patch JSON valid while separating adjacent scopes and memory sections visually. */
5
5
  export declare function formatPatchStateArguments(args: unknown): string;
6
6
  /** Flatten causes before transport; native tool results need not retain Error.cause or AggregateError.errors. */
@@ -1,5 +1,5 @@
1
1
  const TASK_DRIVEN_HISTORY = "Missing paths/hints do not require history search. Choose targeted historical reads when useful to the task; no separate user permission is needed. Past values are evidence, not current state; never automatically restore deleted memory.";
2
- const PATCH_RESULT_PROTOCOL = "Head state/recent transitions are frozen at projection start. Only state_updates matching the head's State Flow projection ID apply; older IDs are history. When present, patch_state results/context-update notices carry state_updates: effective entries replace values at key/index-segment path arrays (deleted:true means absent); direct writes need no echo; shared drift remains visible. Latest entries win over earlier state at those paths; lazy bodies remain omitted. Notices replace invalidations/rehydration, including []/null.";
2
+ const PATCH_RESULT_PROTOCOL = "Head state/recent transitions are frozen at projection start. Only state_updates matching the head's State Flow projection ID apply; other IDs are history. Results/context notices carry state_updates: effective entries replace values at key/index-segment path arrays (deleted:true means absent); cascaded lists owner paths an intent deletion removed. Direct writes may elide; shared drift stays visible. Latest entries win over earlier state; lazy bodies stay omitted. Notices replace invalidations/rehydration, including []/null.";
3
3
  export const PASSIVE_MEMORY_PROTOCOL = `State Flow passive memory is available. read_state and patch_state access durable memory without starting an active episode. Passive turns never trigger State Flow continuation or compaction. ${TASK_DRIVEN_HISTORY} ${PATCH_RESULT_PROTOCOL}`;
4
4
  const PATCH_DISPLAY_SECTION_KEYS = new Set(["global", "cwd", "session", "intents", "contract", "working", "artifacts", "response", "lazy"]);
5
5
  /** Keep successful patch JSON valid while separating adjacent scopes and memory sections visually. */
@@ -1,11 +1,14 @@
1
1
  import { type ArtifactProvenance } from "./artifact.ts";
2
2
  import type { SuccessfulArtifactRead } from "./acquisition.ts";
3
3
  import { type AcceptedTransition } from "./history.ts";
4
+ import { type OwnedPath } from "./ownership.ts";
4
5
  import { type SuccessfulSkillRead } from "./skills.ts";
5
6
  import type { Snapshot } from "./snapshot.ts";
6
7
  import type { AtomicScopePatches, ScopedSemanticStates, StateScope, TerminalTransition } from "./state.ts";
7
8
  export interface StagedScopedTransition {
8
9
  nextStates: ScopedSemanticStates;
10
+ /** Scope-local targets removed by the staged intent cascade, not replay input. */
11
+ cascades: Record<StateScope, OwnedPath[]>;
9
12
  stateHashes: Record<StateScope, string>;
10
13
  /** Fresh runtime-owned provenance for artifacts compiled in this transition. */
11
14
  provenanceUpdates: Record<StateScope, Record<string, ArtifactProvenance>>;
@@ -136,12 +136,13 @@ function stageScopedSemanticTransition(currentStates, transition, successfulSkil
136
136
  validateSkillCompilerTargets(patches, skillReads);
137
137
  const nextStates = { ...currentStates };
138
138
  const provenanceUpdates = { global: {}, cwd: {}, session: {} };
139
+ const cascades = { global: [], cwd: [], session: [] };
139
140
  for (const scope of SCOPES) {
140
141
  const authored = patches.get(scope) ?? {};
141
142
  const patch = { ...authored, ...(scope === "session" && acceptedResponse !== undefined ? { response: acceptedResponse } : {}) };
142
143
  let materialized = applyPatch({ ...emptyState(), ...currentStates[scope] }, patch);
143
144
  // Authored operations first, then the same-scope intent ownership cascade.
144
- const cascade = computeIntentCascade(scope, currentStates[scope], materialized);
145
+ const cascade = cascades[scope] = computeIntentCascade(scope, currentStates[scope], materialized);
145
146
  if (cascade.length > 0)
146
147
  materialized = applyPatch(materialized, cascadeDeletionPatch(cascade));
147
148
  compileReadArtifacts(materialized, { artifacts: authored.artifacts ?? {} }, artifactReads.filter((read) => (read.scope ?? "global") === scope), provenanceUpdates[scope]);
@@ -157,6 +158,7 @@ function stageScopedSemanticTransition(currentStates, transition, successfulSkil
157
158
  }
158
159
  return {
159
160
  nextStates,
161
+ cascades,
160
162
  provenanceUpdates,
161
163
  stateHashes: {
162
164
  global: hashJson(currentStates.global),
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llblab/pi-state-flow",
3
- "version": "0.25.0",
3
+ "version": "0.25.1",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "description": "Incremental scoped state/context/memory compiler for Pi, inspired by SKILL.state",
@@ -32,7 +32,7 @@ Scopes overlay `global → cwd → session`: cross-project, project, branch/run.
32
32
 
33
33
  ## Read
34
34
 
35
- Reuse sufficient visible state. The memory head and its recent transitions are frozen at projection start. Apply later `state_updates` only when their `projection` matches the head's `State Flow projection:` ID; older native results remain historical. Effective update paths are key/index arrays whose values replace that path, while `deleted: true` means absence. Current notices can replace invalidation lists or rehydration phase, including clearing them with `[]` or `null`; lazy bodies still require explicit reads.
35
+ Reuse sufficient visible state. The memory head and its recent transitions are frozen at projection start. Apply later `state_updates` only when their `projection` matches the head's `State Flow projection:` ID; older native results remain historical. Effective update paths are key/index arrays whose values replace that path, while `deleted: true` means absence. The optional `cascaded` array lists owner-scoped paths removed by intent deletion, including nested lazy keys; it contains no values, is never elided, and does not mean the effective path is absent if a broader-scope value remains. Current notices can replace invalidation lists or rehydration phase, including clearing them with `[]` or `null`; lazy bodies still require explicit reads.
36
36
 
37
37
  `read_state` accepts `path` or `paths`, never both. Multi-path reads succeed or fail together. Projections: `value` (default), `keys` (structure), `patch` (intersecting change at the selected boundary).
38
38
 
@@ -122,7 +122,7 @@ checkpoint.json + patches.jsonl
122
122
 
123
123
  ### `state_updates` receipts
124
124
 
125
- A successful native tool result includes a `state_updates` block, separate from the compact acknowledgement used by interactive rendering. The context domain owns this projection, not storage or the lifecycle composition root.
125
+ A successful native tool result may include a `state_updates` block, separate from the compact acknowledgement used by interactive rendering. The context domain owns this projection, not storage or the lifecycle composition root.
126
126
 
127
127
  **Shape.** `effective` entries contain a `path` array of exact object keys/array indices, plus either a replacing `value` or `deleted: true`.
128
128
 
@@ -131,9 +131,10 @@ A successful native tool result includes a `state_updates` block, separate from
131
131
  - Indexed-array patch selectors become numeric update paths only against a communicated in-bounds array basis. Object keys with the same spelling are literal.
132
132
  - Artifact cards use the normal metadata filter, and touched cards replace their whole projected entry.
133
133
  - Lazy bodies never enter this block; a changed bounded `lazy_navigation` may accompany it.
134
- - Unrelated unchanged branches are omitted. A result with nothing left to reconcile has only the acknowledgement.
134
+ - An optional `cascaded` array lists owner-scoped paths removed by intent deletion, including nested lazy targets that do not change the top-level navigation. It contains paths only, never values, and is absent when no target cascaded.
135
+ - Unrelated unchanged branches are omitted. A result with nothing left to reconcile and no cascade has only the acknowledgement.
135
136
 
136
- **What is always included.** Entries conservatively cover changed scope fallbacks, masked or overlapping multi-scope touches, and projected changes since the last communicated view, including shared refreshes before or during the transaction.
137
+ **What is always included.** Entries conservatively cover changed scope fallbacks, masked or overlapping multi-scope touches, and projected changes since the last communicated view, including shared refreshes before or during the transaction. `cascaded` lists every target computed during accepted staging, in deterministic per-scope order across Global, CWD and Session. It is never elided as predictable: a receipt with only `cascaded` and an empty `effective` array still reaches the model. The owner path does not imply effective absence; `effective` entries still describe any revealed fallback.
137
138
 
138
139
  **What may be omitted as predictable:**
139
140
 
@@ -134,9 +134,11 @@ Intents can own the memory they create:
134
134
  - missing targets;
135
135
  - keys outside the `read_state` key grammar `[A-Za-z_$][A-Za-z0-9_$-]*`, for example keys with spaces, dots or non-Latin letters.
136
136
 
137
+ **Receipt.** `state_updates.cascaded` lists all owner-scoped targets removed by intent deletion, for example `["session.lazy.plans.x", "session.working.draft"]`. Paths only, never lazy bodies or deleted values. The list is deterministic (Global, CWD, Session, then each scope's cascade order), absent when no target cascaded, and never omitted as a predictable write. Nested lazy deletions are reported even when the top-level `lazy_navigation` catalog is unchanged.
138
+
137
139
  **Edge cases:**
138
140
 
139
- - Deletion is scope-local, so an effective read may afterwards show a same-path value inherited from a broader scope. The receipt then reports that value rather than `deleted: true`.
141
+ - Deletion is scope-local, so an effective read may afterwards show a same-path value inherited from a broader scope. The receipt's `effective` entry then reports that value rather than `deleted: true`; `cascaded` still identifies the deleted owner path.
140
142
  - Concurrent shared writers keep last-accepted-wins behaviour: a later write into an intent another session already deleted simply recreates a partial intent.
141
143
 
142
144
  **History and limits.** The accepted patch record stores cascaded keys as explicit deletions, so replay never re-derives them, and nothing is archived beyond ordinary retained history. Ownership adds no validation, unresolved-reference warning, cross-scope cascade, age-based cleanup, size budget, growth notice, archive of deleted entries or automatic hydration.
@@ -4,6 +4,7 @@ import { projectArtifactForModel, type ArtifactInvalidationNotice, type Artifact
4
4
  import type { RecentTransitionWindow } from "./history.ts";
5
5
  import { applyPatch, isObject, presentationJson, sameJson, type JsonObject, type JsonValue } from "./json.ts";
6
6
  import type { Snapshot } from "./snapshot.ts";
7
+ import { formatOwnedPath, type OwnedPath } from "./ownership.ts";
7
8
  import type { RehydrationPhase } from "./rehydration.ts";
8
9
  import { projectSemanticPatch, projectStateForModel, type AtomicScopePatches, type SemanticState, type StateScope } from "./state.ts";
9
10
 
@@ -138,7 +139,8 @@ export class ContextProjection {
138
139
  }
139
140
 
140
141
  /** Called only after successful publication and ancillary acceptance, immediately before returning the native result. */
141
- acceptPatch(before: SemanticState, after: SemanticState, patches: AtomicScopePatches, hints: ArtifactModelHints) {
142
+ acceptPatch(before: SemanticState, after: SemanticState, patches: AtomicScopePatches, hints: ArtifactModelHints,
143
+ cascades: Partial<Record<StateScope, readonly OwnedPath[]>> = {}) {
142
144
  const state = projectStateForModel(after, hints);
143
145
  const navigation = lazyNavigationHint(after);
144
146
  const beforeNavigation = this.view?.lazy_navigation ?? lazyNavigationHint(before);
@@ -228,7 +230,12 @@ export class ContextProjection {
228
230
  if (predictable && seen.size > 0 && sameJson(Object.fromEntries(expected), navigation.keys)) delete updates.lazy_navigation;
229
231
  }
230
232
  if (this.view) this.view = { ...this.view, state, lazy_navigation: navigation };
231
- return updates.effective.length || updates.lazy_navigation ? { projection: this.identity, ...updates } : undefined;
233
+ // Owner paths remain informative even when effective state/navigation is masked
234
+ // or the model could predict every direct write. Never expose target values.
235
+ const cascaded = (["global", "cwd", "session"] as const).flatMap((scope) =>
236
+ (cascades[scope] ?? []).map((path) => formatOwnedPath(scope, path)));
237
+ return updates.effective.length || updates.lazy_navigation || cascaded.length
238
+ ? { projection: this.identity, ...updates, ...(cascaded.length ? { cascaded } : {}) } : undefined;
232
239
  }
233
240
 
234
241
  project(messages: AgentMessage[], current: ContextView, makeHead: () => AgentMessage, initial?: ContextView): AgentMessage[] {
@@ -807,7 +807,7 @@ export default function stateFlowExtension(pi: ExtensionAPI, options: StateFlowE
807
807
  }
808
808
  clearAcceptedAcquisitions(new Set(acquiredArtifacts.map(({ path }) => path)));
809
809
  updateUi(ctx);
810
- const updates = contextProjection.acceptPatch(previousEffective, effectiveState, patches, acquisition.hints);
810
+ const updates = contextProjection.acceptPatch(previousEffective, effectiveState, patches, acquisition.hints, stage.cascades);
811
811
  const acknowledgement = changed
812
812
  ? `\nState materialized atomically at ${scopes.join("+")} scope${scopes.length === 1 ? "" : "s"}.`
813
813
  : "\nState already current.";
@@ -4,7 +4,7 @@ export type { StateDocument } from "./state.ts";
4
4
 
5
5
  const TASK_DRIVEN_HISTORY = "Missing paths/hints do not require history search. Choose targeted historical reads when useful to the task; no separate user permission is needed. Past values are evidence, not current state; never automatically restore deleted memory.";
6
6
 
7
- const PATCH_RESULT_PROTOCOL = "Head state/recent transitions are frozen at projection start. Only state_updates matching the head's State Flow projection ID apply; older IDs are history. When present, patch_state results/context-update notices carry state_updates: effective entries replace values at key/index-segment path arrays (deleted:true means absent); direct writes need no echo; shared drift remains visible. Latest entries win over earlier state at those paths; lazy bodies remain omitted. Notices replace invalidations/rehydration, including []/null.";
7
+ const PATCH_RESULT_PROTOCOL = "Head state/recent transitions are frozen at projection start. Only state_updates matching the head's State Flow projection ID apply; other IDs are history. Results/context notices carry state_updates: effective entries replace values at key/index-segment path arrays (deleted:true means absent); cascaded lists owner paths an intent deletion removed. Direct writes may elide; shared drift stays visible. Latest entries win over earlier state; lazy bodies stay omitted. Notices replace invalidations/rehydration, including []/null.";
8
8
 
9
9
  export const PASSIVE_MEMORY_PROTOCOL = `State Flow passive memory is available. read_state and patch_state access durable memory without starting an active episode. Passive turns never trigger State Flow continuation or compaction. ${TASK_DRIVEN_HISTORY} ${PATCH_RESULT_PROTOCOL}`;
10
10
 
@@ -10,7 +10,7 @@ import {
10
10
  import type { SuccessfulArtifactRead } from "./acquisition.ts";
11
11
  import { createAcceptedTransition, type AcceptedTransition } from "./history.ts";
12
12
  import { applyPatch, containsNull, hashJson, isObject, validatePatch, type JsonObject } from "./json.ts";
13
- import { cascadeDeletionPatch, computeIntentCascade } from "./ownership.ts";
13
+ import { cascadeDeletionPatch, computeIntentCascade, type OwnedPath } from "./ownership.ts";
14
14
  import { hasCompiledSkillArtifact, SKILL_ARTIFACT_COMPILER, type SuccessfulSkillRead } from "./skills.ts";
15
15
  import type { Snapshot } from "./snapshot.ts";
16
16
  import { emptyState } from "./state.ts";
@@ -29,6 +29,8 @@ import type {
29
29
 
30
30
  export interface StagedScopedTransition {
31
31
  nextStates: ScopedSemanticStates;
32
+ /** Scope-local targets removed by the staged intent cascade, not replay input. */
33
+ cascades: Record<StateScope, OwnedPath[]>;
32
34
  stateHashes: Record<StateScope, string>;
33
35
  /** Fresh runtime-owned provenance for artifacts compiled in this transition. */
34
36
  provenanceUpdates: Record<StateScope, Record<string, ArtifactProvenance>>;
@@ -186,12 +188,13 @@ function stageScopedSemanticTransition(
186
188
  validateSkillCompilerTargets(patches, skillReads);
187
189
  const nextStates = { ...currentStates };
188
190
  const provenanceUpdates: Record<StateScope, Record<string, ArtifactProvenance>> = { global: {}, cwd: {}, session: {} };
191
+ const cascades: Record<StateScope, OwnedPath[]> = { global: [], cwd: [], session: [] };
189
192
  for (const scope of SCOPES) {
190
193
  const authored = patches.get(scope) ?? {};
191
194
  const patch = { ...authored, ...(scope === "session" && acceptedResponse !== undefined ? { response: acceptedResponse } : {}) };
192
195
  let materialized = applyPatch({ ...emptyState(), ...currentStates[scope] }, patch) as StateDocument;
193
196
  // Authored operations first, then the same-scope intent ownership cascade.
194
- const cascade = computeIntentCascade(scope, currentStates[scope], materialized);
197
+ const cascade = cascades[scope] = computeIntentCascade(scope, currentStates[scope], materialized);
195
198
  if (cascade.length > 0) materialized = applyPatch(materialized, cascadeDeletionPatch(cascade)) as StateDocument;
196
199
  compileReadArtifacts(
197
200
  materialized,
@@ -210,6 +213,7 @@ function stageScopedSemanticTransition(
210
213
  }
211
214
  return {
212
215
  nextStates,
216
+ cascades,
213
217
  provenanceUpdates,
214
218
  stateHashes: {
215
219
  global: hashJson(currentStates.global),
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llblab/pi-state-flow",
3
- "version": "0.25.0",
3
+ "version": "0.25.1",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "description": "Incremental scoped state/context/memory compiler for Pi, inspired by SKILL.state",
@@ -32,7 +32,7 @@ Scopes overlay `global → cwd → session`: cross-project, project, branch/run.
32
32
 
33
33
  ## Read
34
34
 
35
- Reuse sufficient visible state. The memory head and its recent transitions are frozen at projection start. Apply later `state_updates` only when their `projection` matches the head's `State Flow projection:` ID; older native results remain historical. Effective update paths are key/index arrays whose values replace that path, while `deleted: true` means absence. Current notices can replace invalidation lists or rehydration phase, including clearing them with `[]` or `null`; lazy bodies still require explicit reads.
35
+ Reuse sufficient visible state. The memory head and its recent transitions are frozen at projection start. Apply later `state_updates` only when their `projection` matches the head's `State Flow projection:` ID; older native results remain historical. Effective update paths are key/index arrays whose values replace that path, while `deleted: true` means absence. The optional `cascaded` array lists owner-scoped paths removed by intent deletion, including nested lazy keys; it contains no values, is never elided, and does not mean the effective path is absent if a broader-scope value remains. Current notices can replace invalidation lists or rehydration phase, including clearing them with `[]` or `null`; lazy bodies still require explicit reads.
36
36
 
37
37
  `read_state` accepts `path` or `paths`, never both. Multi-path reads succeed or fail together. Projections: `value` (default), `keys` (structure), `patch` (intersecting change at the selected boundary).
38
38
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llblab/pi-kit",
3
- "version": "0.27.1",
3
+ "version": "0.27.2",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -46,7 +46,7 @@
46
46
  "@llblab/pi-clean-room": "0.3.0",
47
47
  "@llblab/pi-codex-usage": "0.12.1",
48
48
  "@llblab/pi-grow-loop": "0.9.0",
49
- "@llblab/pi-state-flow": "0.25.0",
49
+ "@llblab/pi-state-flow": "0.25.1",
50
50
  "@llblab/pi-telegram": "0.51.6",
51
51
  "@llblab/skills": "1.15.0"
52
52
  },