@llblab/pi-kit 0.26.0 → 0.27.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/BACKLOG.md +2 -2
- package/CHANGELOG.md +5 -0
- package/README.md +4 -4
- package/node_modules/@llblab/pi-state-flow/AGENTS.md +1 -1
- package/node_modules/@llblab/pi-state-flow/BACKLOG.md +12 -5
- package/node_modules/@llblab/pi-state-flow/CHANGELOG.md +9 -0
- package/node_modules/@llblab/pi-state-flow/README.md +116 -34
- package/node_modules/@llblab/pi-state-flow/dist/lib/acquisition.d.ts +24 -1
- package/node_modules/@llblab/pi-state-flow/dist/lib/acquisition.js +80 -1
- package/node_modules/@llblab/pi-state-flow/dist/lib/compaction.d.ts +17 -0
- package/node_modules/@llblab/pi-state-flow/dist/lib/compaction.js +40 -0
- package/node_modules/@llblab/pi-state-flow/dist/lib/extension.js +149 -298
- package/node_modules/@llblab/pi-state-flow/dist/lib/git.d.ts +29 -0
- package/node_modules/@llblab/pi-state-flow/dist/lib/git.js +58 -0
- package/node_modules/@llblab/pi-state-flow/dist/lib/operation.d.ts +37 -0
- package/node_modules/@llblab/pi-state-flow/dist/lib/operation.js +59 -0
- package/node_modules/@llblab/pi-state-flow/dist/lib/ownership.d.ts +31 -0
- package/node_modules/@llblab/pi-state-flow/dist/lib/ownership.js +117 -0
- package/node_modules/@llblab/pi-state-flow/dist/lib/protocol.js +7 -7
- package/node_modules/@llblab/pi-state-flow/dist/lib/query.js +1 -1
- package/node_modules/@llblab/pi-state-flow/dist/lib/status.d.ts +2 -0
- package/node_modules/@llblab/pi-state-flow/dist/lib/status.js +28 -0
- package/node_modules/@llblab/pi-state-flow/dist/lib/transition.js +6 -1
- package/node_modules/@llblab/pi-state-flow/dist/package.json +1 -1
- package/node_modules/@llblab/pi-state-flow/dist/skills/state-flow-guide/SKILL.md +14 -6
- package/node_modules/@llblab/pi-state-flow/dist/skills/state-flow-memory/SKILL.md +2 -2
- package/node_modules/@llblab/pi-state-flow/docs/README.md +19 -9
- package/node_modules/@llblab/pi-state-flow/docs/agent-contract-relocation.md +4 -4
- package/node_modules/@llblab/pi-state-flow/docs/architecture.md +644 -91
- package/node_modules/@llblab/pi-state-flow/docs/compatibility.md +116 -37
- package/node_modules/@llblab/pi-state-flow/docs/filesystem-recovery.md +118 -21
- package/node_modules/@llblab/pi-state-flow/docs/fork-contract.md +68 -8
- package/node_modules/@llblab/pi-state-flow/docs/lazy-state.md +88 -14
- package/node_modules/@llblab/pi-state-flow/docs/performance.md +83 -66
- package/node_modules/@llblab/pi-state-flow/docs/temporal-acceptance.md +391 -62
- package/node_modules/@llblab/pi-state-flow/docs/usage.md +317 -62
- package/node_modules/@llblab/pi-state-flow/lib/acquisition.ts +85 -1
- package/node_modules/@llblab/pi-state-flow/lib/compaction.ts +47 -0
- package/node_modules/@llblab/pi-state-flow/lib/extension.ts +161 -295
- package/node_modules/@llblab/pi-state-flow/lib/git.ts +63 -0
- package/node_modules/@llblab/pi-state-flow/lib/operation.ts +75 -0
- package/node_modules/@llblab/pi-state-flow/lib/ownership.ts +120 -0
- package/node_modules/@llblab/pi-state-flow/lib/protocol.ts +7 -8
- package/node_modules/@llblab/pi-state-flow/lib/query.ts +1 -1
- package/node_modules/@llblab/pi-state-flow/lib/runtime.ts +1 -1
- package/node_modules/@llblab/pi-state-flow/lib/snapshot.ts +1 -2
- package/node_modules/@llblab/pi-state-flow/lib/status.ts +29 -0
- package/node_modules/@llblab/pi-state-flow/lib/transition.ts +5 -1
- package/node_modules/@llblab/pi-state-flow/package.json +1 -1
- package/node_modules/@llblab/pi-state-flow/skills/state-flow-guide/SKILL.md +14 -6
- package/node_modules/@llblab/pi-state-flow/skills/state-flow-memory/SKILL.md +2 -2
- package/node_modules/@llblab/pi-telegram/BACKLOG.md +1 -0
- package/node_modules/@llblab/pi-telegram/CHANGELOG.md +10 -0
- package/node_modules/@llblab/pi-telegram/README.md +1 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/bindings.d.ts +4 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/bindings.js +16 -12
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.d.ts +1 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.js +7 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/commands.d.ts +12 -3
- package/node_modules/@llblab/pi-telegram/dist/lib/commands.js +137 -83
- package/node_modules/@llblab/pi-telegram/dist/lib/extension.js +26 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/lifecycle.d.ts +57 -2
- package/node_modules/@llblab/pi-telegram/dist/lib/lifecycle.js +109 -4
- package/node_modules/@llblab/pi-telegram/dist/lib/model.js +2 -4
- package/node_modules/@llblab/pi-telegram/dist/lib/status.d.ts +3 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/status.js +31 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/sync.js +4 -4
- package/node_modules/@llblab/pi-telegram/dist/lib/threads.d.ts +1 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/threads.js +17 -4
- package/node_modules/@llblab/pi-telegram/dist/lib/workspace-retirement.d.ts +2 -2
- package/node_modules/@llblab/pi-telegram/dist/lib/workspace-retirement.js +48 -12
- package/node_modules/@llblab/pi-telegram/dist/package.json +1 -1
- package/node_modules/@llblab/pi-telegram/docs/architecture.md +6 -5
- package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +2 -0
- package/node_modules/@llblab/pi-telegram/docs/public-api.md +2 -2
- package/node_modules/@llblab/pi-telegram/docs/ui-style.md +4 -0
- package/node_modules/@llblab/pi-telegram/lib/bindings.ts +17 -10
- package/node_modules/@llblab/pi-telegram/lib/bus-follower.ts +8 -2
- package/node_modules/@llblab/pi-telegram/lib/commands.ts +135 -97
- package/node_modules/@llblab/pi-telegram/lib/extension.ts +25 -0
- package/node_modules/@llblab/pi-telegram/lib/lifecycle.ts +140 -4
- package/node_modules/@llblab/pi-telegram/lib/model.ts +2 -4
- package/node_modules/@llblab/pi-telegram/lib/status.ts +30 -1
- package/node_modules/@llblab/pi-telegram/lib/sync.ts +4 -4
- package/node_modules/@llblab/pi-telegram/lib/threads.ts +21 -3
- package/node_modules/@llblab/pi-telegram/lib/workspace-retirement.ts +46 -13
- package/node_modules/@llblab/pi-telegram/package.json +1 -1
- package/package.json +3 -3
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
## Supported Pi stack
|
|
4
4
|
|
|
5
|
-
State Flow requires matching `pi-coding-agent`, `pi-agent-core`, `pi-ai
|
|
5
|
+
State Flow requires matching `pi-coding-agent`, `pi-agent-core`, `pi-ai` and `pi-tui` packages at `>=1.0.0`. Keep all four on the same release line. The open-ended peer range permits newer SDK releases; it does not certify them.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**Verified environment:** Linux/x64, Node 26.8.1, Git 2.55.0 and matching Pi SDK 1.0.0 packages.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- Repository validation covers tests, typecheck, build, compiled imports and package dry-run. Results apply to the exact source and dependency identities validated.
|
|
10
|
+
- The release workflow uses Node 24; its result is a separate verification gate.
|
|
11
|
+
- Tests use isolated stores and scripted providers through the real Pi SDK. They do not certify installed Telegram/TUI reachability, live provider behavior, other operating systems, mixed SDK versions or untested newer SDK releases.
|
|
12
|
+
|
|
13
|
+
Detailed behavioral witnesses live in [temporal acceptance](temporal-acceptance.md); benchmark methodology and source-bound results live in [performance](performance.md).
|
|
10
14
|
|
|
11
15
|
## Public host seams
|
|
12
16
|
|
|
@@ -24,79 +28,149 @@ An embedding must deliver the native lifecycle, not merely construct or dispose
|
|
|
24
28
|
|
|
25
29
|
## Context, tools and provider input
|
|
26
30
|
|
|
27
|
-
State Flow contributes
|
|
31
|
+
**System prompt.** State Flow contributes protocol through `systemPromptOptions.sections.state_flow` and refreshes only that section at `context_with_system`.
|
|
32
|
+
|
|
33
|
+
- Companion sections, native system deltas, tool declarations and non-system message identities remain intact.
|
|
34
|
+
- An explicit foreign forced prompt retains Pi's precedence.
|
|
35
|
+
- Mode changes update the next provider request without requiring another `before_agent_start`.
|
|
36
|
+
|
|
37
|
+
**Conversation and recovery:**
|
|
28
38
|
|
|
29
|
-
Native context edits, omitted messages and replaced tool results reach the provider through Pi's canonical context. Raw native trace remains inspectable.
|
|
39
|
+
- Native context edits, omitted messages and replaced tool results reach the provider through Pi's canonical context. Raw native trace remains inspectable.
|
|
40
|
+
- Branch selection applies branch-relative edits without rewriting separately owned memory.
|
|
41
|
+
- Retry, length and overflow recovery omit failed attempts from subsequent provider input, without accepting them as State Flow responses or advancing semantic history.
|
|
42
|
+
- Edited-context usage accounting must not trigger phantom compaction.
|
|
30
43
|
|
|
31
|
-
Image resizing, encoding and provider limits remain SDK-owned. Tests exercise prompt images, built-in reads and generic tool results across model-specific resize profiles while preserving historical payloads. State Flow supplies no image pipeline or provider-limit enforcement.
|
|
44
|
+
**Images and provider limits.** Image resizing, encoding and provider limits remain SDK-owned. Tests exercise prompt images, built-in reads and generic tool results across model-specific resize profiles while preserving historical payloads. State Flow supplies no image pipeline or provider-limit enforcement. Its tests do not independently certify provider strict schemas, cache behavior, diagnostics or other SDK capabilities.
|
|
32
45
|
|
|
33
|
-
Active boundary continuation receives accepted memory even
|
|
46
|
+
**Continuation.** Active boundary continuation receives accepted memory even without a new `before_agent_start`. A completed specification is not resurrected, and State Flow does not own the host's continuation scheduler.
|
|
34
47
|
|
|
35
48
|
## Pre-inference cancellation
|
|
36
49
|
|
|
37
|
-
On the tested SDK, `before_agent_start` precedes the low-level agent's `prompt`; `ExtensionContext.signal` is undefined there.
|
|
50
|
+
On the tested SDK, `before_agent_start` precedes the low-level agent's `prompt`; `ExtensionContext.signal` is undefined there.
|
|
38
51
|
|
|
39
|
-
|
|
52
|
+
1. State Flow captures the specification at that hook without canonical publication.
|
|
53
|
+
2. The active `context` hook supplies the operation signal and awaits preparation/maintenance before provider inference.
|
|
54
|
+
3. If preparation fails, State Flow calls public `ctx.abort()`. Pi catches context-hook errors and may otherwise continue inference, so a thrown error alone is not a fence.
|
|
40
55
|
|
|
41
|
-
|
|
56
|
+
Native tests prove no provider call before coherent acceptance, cancellation while an independent writer remains held, rollback without draft installation and preservation of uncompiled native input.
|
|
57
|
+
|
|
58
|
+
**Signals are not universal.** Idle commands and session events can lack them. Do not infer native Abort cancellation from an extension-owned shutdown signal or generalize active-run tests to idle waits.
|
|
42
59
|
|
|
43
60
|
## Mode configuration compatibility
|
|
44
61
|
|
|
45
|
-
|
|
62
|
+
**Preferred representation:**
|
|
63
|
+
|
|
64
|
+
- Global `config.json` accepts `mode: "active" | "passive" | "off"`. It defaults to Off when no mode policy is configured and supplies only the initial policy for new sessions.
|
|
65
|
+
- Session `config.json` uses the same key for the concrete retained choice. Commands and Telegram never edit the global default.
|
|
66
|
+
- Before semantic initialization, an inactive choice is retained in a native `{mode}` checkpoint instead.
|
|
46
67
|
|
|
47
|
-
|
|
68
|
+
**Other readable representations.** Decoding is read-only; ordinary writers emit only mode, with no eager migration or semantic normalization.
|
|
48
69
|
|
|
49
|
-
|
|
70
|
+
- Without explicit global mode, absence of all flag-based mode settings means Off.
|
|
71
|
+
- `autoStart: true` means Active. With any flag-based mode setting present, `passiveBootstrap: false` together with `passiveTools: false` means Off; otherwise the fallback is Passive.
|
|
72
|
+
- Explicit global mode overrides valid flags; invalid values still fail validation.
|
|
73
|
+
- Session `enabled:true` means Active, and `enabled:false` means non-active.
|
|
74
|
+
- Native inactive checkpoints without an explicit mode use the configured inactive fallback, never an Active default.
|
|
75
|
+
- Session config and native checkpoints reject mixed `mode`/`enabled` representations, even when apparently consistent, rather than choosing between two stored policies.
|
|
76
|
+
|
|
77
|
+
To use Passive, select it in the current session or set global `mode: "passive"` for new sessions.
|
|
78
|
+
|
|
79
|
+
**SDK and Telegram controls.** The extension SDK accepts an optional `mode` default override. Both Telegram port variants use `snapshot.mode` plus `select(mode)`. A stale callback keyboard may refresh the view without selecting a mode. Synchronous enum-based ports are supported; Start/Stop port signatures are not.
|
|
50
80
|
|
|
51
81
|
## Mode selection and memory restoration
|
|
52
82
|
|
|
53
|
-
Start
|
|
83
|
+
**Start:**
|
|
84
|
+
|
|
85
|
+
- Activates current same-session authority under awaited exclusion.
|
|
86
|
+
- Rechecks physical identity and initialization permission after waiting, accepts once, then installs policy, memory and checkpoint.
|
|
87
|
+
- Does not claim to restore an expired historical boundary.
|
|
88
|
+
- Native tests prove current shared plus local-private memory at the next provider, and actual Abort withdrawal for in-run Start with an operation signal.
|
|
89
|
+
|
|
90
|
+
**Passive:**
|
|
91
|
+
|
|
92
|
+
- Selects local tools/context policy before waiting for persistence.
|
|
93
|
+
- For accepted memory, publishes lifecycle metadata without rewriting semantic/provenance files. Pending inactive choices share one acceptance of the latest mode.
|
|
94
|
+
- Keeps independently owned retained restoration, Active-default initialization and fork copying; the latest inactive policy is applied at acceptance.
|
|
95
|
+
- Read-only recovery preserves an intervening Passive choice and its write fence.
|
|
96
|
+
- Selection, shutdown and accepted Start cancel obsolete Stop persistence; rejected Start does not.
|
|
97
|
+
- Genuine persistence failure retains readable memory and native context while fencing writes until accepted Start.
|
|
54
98
|
|
|
55
|
-
|
|
99
|
+
**Off:**
|
|
56
100
|
|
|
57
|
-
|
|
101
|
+
- Selects local tools/context policy immediately and injects no State Flow context, including a frozen handoff.
|
|
102
|
+
- Cancels owned restoration/fork and persistence waits, clears semantic caches and records native policy only, without canonical publication.
|
|
103
|
+
- Keeps the deferred boundary/source bookkeeping for later explicit Passive/Active acquisition.
|
|
58
104
|
|
|
59
|
-
|
|
105
|
+
Modes select workflow policy, not whether canonical memory exists. Cancelling a Start waiter does not cancel independently owned restoration. Selection changes, shutdown and an available native operation signal can revoke obsolete restoration; failure after acceptance cannot undo memory.
|
|
60
106
|
|
|
61
|
-
|
|
107
|
+
**Native restoration evidence.** Startup and tree handlers await restoration. Tests cover held-store tree/fork selection, exact private state over live shared streams, unchanged parent-private files, cold reopening, failed-Stop recovery and next-provider input without later-branch private values.
|
|
108
|
+
|
|
109
|
+
A public SDK host can observe the child factory result before awaiting extension binding and send Stop or Stop→Start through the child's public `prompt` method while copying waits. This proves that embedding route, not that the installed CLI or Telegram exposes the child before runtime replacement finishes.
|
|
110
|
+
|
|
111
|
+
**Read-only recovery** validates current private memory without initializing absent storage or granting patch/lifecycle publication authority. Invalid or expired historical evidence never authorizes newer, empty or unrelated private memory as fallback.
|
|
62
112
|
|
|
63
113
|
## Settlement cancellation
|
|
64
114
|
|
|
65
|
-
|
|
115
|
+
Native `AgentSession.abort()` can withdraw a settlement lock wait only when the host supplies a suitable operation signal. An extension-owned cancellation lifetime is not a substitute for that signal.
|
|
116
|
+
|
|
117
|
+
**Optional Git backup** remains at `agent_before_settle`:
|
|
66
118
|
|
|
67
|
-
|
|
119
|
+
- It waits for exclusion only when the host supplies a suitable signal. Otherwise contention produces an explicit diagnostic-only deferral to a later eligible turn.
|
|
120
|
+
- Malformed or interrupted ownership remains a failure, not permission to steal a lock.
|
|
121
|
+
- Git commands run outside canonical exclusion. Shutdown drains owned attempts and pending pushes.
|
|
122
|
+
- Backup failure neither rolls back memory, suppresses an answer nor requests repair inference.
|
|
68
123
|
|
|
69
124
|
This optional-backup policy does not apply to required semantic publication or restoration. The persistence model is [optimistic canonical storage](filesystem-recovery.md#power-loss-durability), not power-loss-safe acknowledgement or crash-atomic multi-file publication. No journal, replacement Abort handler or background publication worker supplies a stronger guarantee.
|
|
70
125
|
|
|
71
|
-
State Flow-owned compaction
|
|
126
|
+
**State Flow-owned compaction:**
|
|
127
|
+
|
|
128
|
+
- Requires known sufficient context usage and a proven retained run anchor.
|
|
129
|
+
- Preserves the complete accepted run, skips protected foreign context and never requests retain-none shortening.
|
|
130
|
+
- Leaves native manual/threshold/overflow compaction to Pi.
|
|
131
|
+
- Awaits native compaction completion or refusal in the settled handler, so deferred companion prompts do not race it.
|
|
132
|
+
- Skips compaction when usage is unknown or insufficient; a benign refusal permits a later attempt.
|
|
72
133
|
|
|
73
134
|
## Telegram adapter
|
|
74
135
|
|
|
75
|
-
The optional adapter presents one Off | Passive | Active row and uses the same mode-selection and inspection owners as native commands.
|
|
136
|
+
The optional adapter presents one Off | Passive | Active row and uses the same mode-selection and inspection owners as native commands.
|
|
137
|
+
|
|
138
|
+
- Inspection returns coherent state plus matching revisions, without publication.
|
|
139
|
+
- Controls and inspections acknowledge callbacks before waiting, suppress revoked results and escape late failures in the current menu.
|
|
140
|
+
- Synchronous mode-selection ports are supported.
|
|
141
|
+
- A first Passive selection may install a read-only shared cache without invalidating its own success receipt. Later controls, branch changes and cancellation still revoke obsolete presentation.
|
|
76
142
|
|
|
77
|
-
Adapter tests establish
|
|
143
|
+
Adapter tests establish these contracts with isolated transport fixtures; they are not a live Telegram smoke test. Missing or unready transport remains fail-open and cannot change core memory behavior.
|
|
78
144
|
|
|
79
145
|
## State Flow library API compatibility
|
|
80
146
|
|
|
81
147
|
The package root exports `TemporalRuntime`. The Pi registration shim is a separate default-only entrypoint, not the named library API.
|
|
82
148
|
|
|
83
|
-
|
|
149
|
+
**Awaited runtime operations:**
|
|
84
150
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
| Retained restoration | `withRestoreTransaction` | Exact retained private boundary beside current shared streams |
|
|
93
|
-
| Child creation | `withForkTransaction` | Exact parent authority and an unoccupied independent child |
|
|
151
|
+
- **Shared inspection — `refreshShared`:** read-only; no initialization or revision advance.
|
|
152
|
+
- **Current private recovery — `refreshCurrentMemory`:** read-only; no publication authority.
|
|
153
|
+
- **Authored semantic patch — `withPatchTransaction`:** current shared basis and selected private authority; one atomic acceptance.
|
|
154
|
+
- **Accepted-runtime lifecycle — `withLifecycleTransaction`:** config/runtime only; cannot initialize or repair semantic storage.
|
|
155
|
+
- **Current-head activation — `withStartTransaction`:** origin creation defaults off and requires explicit authorization.
|
|
156
|
+
- **Retained restoration — `withRestoreTransaction`:** exact retained private boundary beside current shared streams.
|
|
157
|
+
- **Child creation — `withForkTransaction`:** exact parent authority and an unoccupied independent child.
|
|
94
158
|
|
|
95
|
-
Await completion before consuming results. Transaction callbacks
|
|
159
|
+
Await completion before consuming results. Transaction callbacks:
|
|
96
160
|
|
|
97
|
-
|
|
161
|
+
1. Recheck caller selection/policy after waiting.
|
|
162
|
+
2. Stage and publish synchronously, using their publication capability once within its lifetime.
|
|
163
|
+
3. Install host state only after acceptance.
|
|
98
164
|
|
|
99
|
-
|
|
165
|
+
Keep inference, source acquisition and Git outside canonical exclusion. Raw precomputed replay retains its selected-basis guards.
|
|
166
|
+
|
|
167
|
+
Continuation inspection/candidate building and Git backup also return Promises. Await them rather than treating a Promise as a boolean or accessing a result before completion. Continuation inspection is advisory: it cannot initialize, restore or select a session on the host's behalf.
|
|
168
|
+
|
|
169
|
+
**Synchronous runtime methods:** `loadPassive`, `prepareBoundaryRestore`, `restoreBoundary`, `acceptRestoredOrigin`, `prepareBoundaryFork` and `initialize`.
|
|
170
|
+
|
|
171
|
+
- They are supported for library consumers and local tests/benchmarks; production lifecycle wiring uses the awaited APIs.
|
|
172
|
+
- They are not signature-compatible substitutes and do not acquire the awaited APIs' cancellation behavior.
|
|
173
|
+
- Their presence is not permission to bypass ownership, retained-history or raw-replay checks.
|
|
100
174
|
|
|
101
175
|
## Validation procedure
|
|
102
176
|
|
|
@@ -109,4 +183,9 @@ Validate another SDK line in an isolated copy so the installed extension, sessio
|
|
|
109
183
|
5. Inspect the compiled public API through `dist/index.js` and the Pi default registration through `dist/pi-state-flow/index.js`.
|
|
110
184
|
6. Compare generated `dist` and packaged Skills with source, and verify package inventory after final documentation edits.
|
|
111
185
|
|
|
112
|
-
|
|
186
|
+
**Evidence limits:**
|
|
187
|
+
|
|
188
|
+
- Focused tests do not replace the full integration suite.
|
|
189
|
+
- Tree-bound evidence can be reused only when its relevant inputs are unchanged.
|
|
190
|
+
- Ref-, environment- and external-publication-sensitive checks require their own verification.
|
|
191
|
+
- A successful tag push is not release completion: verify the owning workflow, published GitHub Release and exact npm package identity.
|
|
@@ -2,32 +2,125 @@
|
|
|
2
2
|
|
|
3
3
|
State Flow classifies absence separately from partial or malformed evidence. Recovery may derive bytes only from an authoritative surviving cohort or from a semantic default that the owner explicitly permits. It never invents history, ownership, provenance, or external success.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
## Resource rules
|
|
6
|
+
|
|
7
|
+
### Global `checkpoint.json` + `patches.jsonl`
|
|
8
|
+
|
|
9
|
+
- **Authority:** State Flow; authoritative shared semantics.
|
|
10
|
+
- **Wholly absent:** Authored patches use current empty reality; stale precomputed replay refuses it.
|
|
11
|
+
- **Partial or malformed:** Either half missing, malformed replay, or invalid envelope fails closed.
|
|
12
|
+
- **Allowed repair and writes:** Normal CAS publication may materialize the complete empty pair.
|
|
13
|
+
|
|
14
|
+
### CWD `checkpoint.json` + `patches.jsonl`
|
|
15
|
+
|
|
16
|
+
- **Authority:** State Flow; authoritative shared semantics with CWD identity.
|
|
17
|
+
- **Wholly absent:** Same as global; selected values are not resurrected.
|
|
18
|
+
- **Partial or malformed:** Same as global; owner mismatch also fails closed.
|
|
19
|
+
- **Allowed repair and writes:** Normal CAS publication may materialize the complete empty pair.
|
|
20
|
+
|
|
21
|
+
### Session `checkpoint.json` + `patches.jsonl`
|
|
22
|
+
|
|
23
|
+
- **Authority:** State Flow; authoritative private semantics.
|
|
24
|
+
- **Wholly absent:** Fresh lifecycle origin may initialize; an existing selected session requires exact retained authority.
|
|
25
|
+
- **Partial or malformed:** Partial or malformed pair fails closed.
|
|
26
|
+
- **Allowed repair and writes:** Fresh initialization or exact retained-boundary recovery only.
|
|
27
|
+
|
|
28
|
+
### Global/CWD `meta.json`
|
|
29
|
+
|
|
30
|
+
- **Authority:** State Flow; temporal boundaries, CWD identity, and artifact provenance.
|
|
31
|
+
- **Wholly absent:** Missing metadata removes temporal authority and fails closed; only an omitted `artifacts` leaf degrades provenance to `{}`.
|
|
32
|
+
- **Partial or malformed:** Malformed metadata or semantic/boundary mismatch fails closed.
|
|
33
|
+
- **Allowed repair and writes:** Normal CAS publication from a complete proven cohort.
|
|
34
|
+
|
|
35
|
+
### Session `meta.json`
|
|
36
|
+
|
|
37
|
+
- **Authority:** State Flow; session temporal boundaries and artifact provenance.
|
|
38
|
+
- **Wholly absent:** Fresh origin may initialize; selected sessions recover only from exact scope authority.
|
|
39
|
+
- **Partial or malformed:** Partial, malformed, or contradictory boundary evidence fails closed.
|
|
40
|
+
- **Allowed repair and writes:** Canonical scope publication from the selected temporal state.
|
|
41
|
+
|
|
42
|
+
### Session `config.json` + `runtime.json`
|
|
43
|
+
|
|
44
|
+
- **Authority:** State Flow; behavior plus authoritative runtime identity, lineage, and counters.
|
|
45
|
+
- **Wholly absent:** Fresh origin may initialize; selected sessions recover only from exact authority.
|
|
46
|
+
- **Partial or malformed:** Partial, malformed, contradictory identity or lineage fails closed.
|
|
47
|
+
- **Allowed repair and writes:** Canonical runtime publication from proven lifecycle/selected state; combined session metadata is unsupported.
|
|
48
|
+
|
|
49
|
+
### Unsupported checkpoint envelopes, `state.json`, hashed layouts, or semantic Pi checkpoints
|
|
50
|
+
|
|
51
|
+
- **Authority:** No current authority.
|
|
52
|
+
- **Wholly absent:** Ignored.
|
|
53
|
+
- **Partial or malformed:** Presence never becomes recovery or conversion input.
|
|
54
|
+
- **Allowed repair and writes:** Preserve bytes; operator-managed removal or external conversion only.
|
|
55
|
+
|
|
56
|
+
### Retained Pi boundary
|
|
57
|
+
|
|
58
|
+
- **Authority:** State Flow/Pi entry; current canonical lineage.
|
|
59
|
+
- **Wholly absent:** Expired or missing boundary is unavailable.
|
|
60
|
+
- **Partial or malformed:** Identity, lifecycle, or lineage contradiction fails closed.
|
|
61
|
+
- **Allowed repair and writes:** Select exact retained private history over live shared scopes; never consult Git.
|
|
62
|
+
|
|
63
|
+
### Canonical writer lock
|
|
64
|
+
|
|
65
|
+
- **Authority:** State Flow; file-cohort mutual exclusion.
|
|
66
|
+
- **Wholly absent:** Unlocked.
|
|
67
|
+
- **Partial or malformed:** Present lock excludes cooperating publishers, including interrupted owners.
|
|
68
|
+
- **Allowed repair and writes:** Current owner releases; no opportunistic deletion.
|
|
69
|
+
|
|
70
|
+
### Repository-root `config.json`
|
|
71
|
+
|
|
72
|
+
- **Authority:** Operator; optional read-only global configuration.
|
|
73
|
+
- **Wholly absent:** Built-in defaults.
|
|
74
|
+
- **Partial or malformed:** Present unreadable/malformed/unknown settings fail extension configuration.
|
|
75
|
+
- **Allowed repair and writes:** State Flow never creates, rewrites, or stages operator edits; include it in operator-managed copies/versioning.
|
|
76
|
+
|
|
77
|
+
### Registered artifact source path
|
|
78
|
+
|
|
79
|
+
- **Authority:** External source owner.
|
|
80
|
+
- **Wholly absent:** Exact proven absence permits owning-scope artifact/provenance removal.
|
|
81
|
+
- **Partial or malformed:** Relative, symlink, directory, malformed, or unreadable paths disable maintenance locally.
|
|
82
|
+
- **Allowed repair and writes:** Never create; semantic removal only for exact proven absence.
|
|
83
|
+
|
|
84
|
+
### Skill and external artifact sources
|
|
85
|
+
|
|
86
|
+
- **Authority:** External package/user owner.
|
|
87
|
+
- **Wholly absent:** Freshness unavailable unless ownership proves removal semantics.
|
|
88
|
+
- **Partial or malformed:** Unsafe/non-regular/unreadable sources disable acquisition locally.
|
|
89
|
+
- **Allowed repair and writes:** Never create or fabricate source/provenance.
|
|
90
|
+
|
|
91
|
+
### Pi State Flow entries
|
|
92
|
+
|
|
93
|
+
- **Authority:** Pi session log / State Flow entry owner.
|
|
94
|
+
- **Wholly absent:** Missing required selected boundary blocks that restore.
|
|
95
|
+
- **Partial or malformed:** Malformed or contradictory owner/version/boundary fails the dependent restore.
|
|
96
|
+
- **Allowed repair and writes:** Append through Pi entry APIs only; never replace failed selection with passive state.
|
|
97
|
+
|
|
98
|
+
### Optional diagnostic log
|
|
99
|
+
|
|
100
|
+
- **Authority:** State Flow logger; outside the canonical repository.
|
|
101
|
+
- **Wholly absent:** No diagnostic evidence.
|
|
102
|
+
- **Partial or malformed:** I/O failure warns once without changing accepted state.
|
|
103
|
+
- **Allowed repair and writes:** Append local JSONL only when opted in; never use it as semantic recovery authority.
|
|
21
104
|
|
|
22
105
|
## Power-loss durability
|
|
23
106
|
|
|
24
|
-
**
|
|
107
|
+
**Persistence is optimistic, not power-loss safe.** `lib/durable.ts` writes same-directory temporary files with `writeFileSync`, then replaces owned paths one at a time with `renameSync`.
|
|
25
108
|
|
|
26
|
-
|
|
109
|
+
- There is no file/directory `fsync` barrier. A successful call or subsequent readback proves filesystem-visible bytes, not persistence beyond volatile OS/device caches.
|
|
110
|
+
- Guarded rollback handles caught errors while the process is alive. It cannot run after abrupt termination, and several individually atomic replacements are not one crash-atomic cohort.
|
|
111
|
+
- A crash may leave mixed old/new files or unavailable evidence. Rollback, cancellation and process-kill tests do not establish power-loss survival.
|
|
27
112
|
|
|
28
|
-
|
|
113
|
+
**Accepted risk.** Loss of recent work after abrupt power loss is an accepted risk. There is no power-loss-safe acknowledgement or at-most-one-patch loss bound: an interrupted multi-file publication can leave incomplete evidence and require operator recovery.
|
|
29
114
|
|
|
30
|
-
|
|
115
|
+
- Do not add a patch journal, temporary recovery store, flush protocol or storage-format redesign for this scenario without a separate design decision.
|
|
116
|
+
- Same-directory temporary replacement files are an implementation detail, not a separate patch store.
|
|
117
|
+
- Stronger durability would require persistence barriers and a coherent recovery protocol; it is outside the current contract.
|
|
118
|
+
|
|
119
|
+
**Concurrency guarantees still apply.** Ordinary concurrent publication preserves unrelated current Global/CWD fields, orders overlapping writes by acceptance and protects private Session authority.
|
|
120
|
+
|
|
121
|
+
- Use one short asynchronously awaited capture/stage/publication exclusion plus CAS. Inference, source acquisition and Git stay outside it.
|
|
122
|
+
- Optimism does not authorize replacing a stale whole state, accepting a partial cohort, fabricating empty memory, ignoring a reported write failure or stealing an unavailable lock.
|
|
123
|
+
- Optional Git backup and remote synchronization may defer to a later eligible settled turn. Neither every intermediate commit nor immediate remote replication is required.
|
|
31
124
|
|
|
32
125
|
## Transaction rule
|
|
33
126
|
|
|
@@ -40,4 +133,8 @@ Every semantic repair follows the ordinary transaction path:
|
|
|
40
133
|
5. Recheck CAS and ownership.
|
|
41
134
|
6. Publish with per-file atomic replacement, conflict-preserving rollback, and then install the accepted runtime state; this is not kernel-atomic multi-file CAS.
|
|
42
135
|
|
|
43
|
-
A wholly absent shared scope is current empty reality
|
|
136
|
+
**A wholly absent shared scope is current empty reality**, not permission to restore cached cold values or leftover compilation evidence.
|
|
137
|
+
|
|
138
|
+
- Authored `patch_state` operations select this basis under the awaited store lock and publish only after complete validation. A rejected first patch never leaves separately published empty initialization.
|
|
139
|
+
- Raw precomputed replay targeting a disappeared selected basis still fails closed.
|
|
140
|
+
- Discarded history is unavailable and is never reconstructed or promoted back into current shared memory.
|
|
@@ -21,26 +21,86 @@ The child receives:
|
|
|
21
21
|
- current live global/CWD values and provenance without rewinding them;
|
|
22
22
|
- selected `mode` and bootstrap lifecycle state, with step reset to zero and no inherited unfinished specification or validation diagnostic.
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
**What stays unchanged:**
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
- The parent's private files and native trace remain unchanged. Later child session writes cannot modify the parent's private layer.
|
|
27
|
+
- Applying a smaller configured `historyLimit` may fold excess shared tails during child acceptance under file-cohort CAS, without changing current shared materialization or provenance. Without retention reduction, the shared files remain unchanged too.
|
|
28
|
+
- Forking semantic memory does not clone or roll back project files or tool effects.
|
|
29
|
+
|
|
30
|
+
**Artifact evidence is current-only, not a historical registry.**
|
|
31
|
+
|
|
32
|
+
- Any retained parent session patch touching an artifact after the selected boundary makes its current provenance unproven for that selection, even if a later patch restores an equal value.
|
|
33
|
+
- The child keeps the selected artifact semantics but omits that provenance until explicit reacquisition and compilation.
|
|
34
|
+
- Untouched artifact paths retain their evidence, including provenance-only refreshes of unchanged semantics; shared provenance remains live.
|
|
27
35
|
|
|
28
36
|
## Lifecycle and failure
|
|
29
37
|
|
|
30
|
-
`TemporalRuntime.withForkTransaction(source, checkpoint, action, signal?)
|
|
38
|
+
**Copying and acceptance.** `TemporalRuntime.withForkTransaction(source, checkpoint, action, signal?)`:
|
|
39
|
+
|
|
40
|
+
1. Pins source identity/boundary before waiting.
|
|
41
|
+
2. Selects exact parent authority plus an unoccupied child under one awaited exclusion.
|
|
42
|
+
3. Lets the caller recheck native selection/policy and publish its child lifecycle synchronously, once.
|
|
43
|
+
4. Revalidates parent evidence before publication and protects the child cohort with CAS. Only accepted memory installs.
|
|
44
|
+
|
|
45
|
+
Cancellation or rejection cannot initialize an empty child. Failure after acceptance cannot roll it back or authorize another parent copy. Existing child storage, an identity mismatch, missing parent files, malformed storage, a concurrency conflict or an expired boundary fails closed.
|
|
46
|
+
|
|
47
|
+
**Forking while Off:**
|
|
31
48
|
|
|
32
|
-
|
|
49
|
+
- Parent-header acquisition and canonical copying are deferred. Only a child-owned pending-fork marker is appended to the native trace; it carries no semantic authority.
|
|
50
|
+
- The marker survives cold extension reload and permits later explicit Passive/Active acquisition of the still-selected exact parent boundary, subject to the same identity, retention and occupied-child checks.
|
|
51
|
+
- Accepted initialization resets the marker.
|
|
52
|
+
- Parent expiry while Off is diagnosed only on explicit acquisition, never silently replaced with newer parent memory.
|
|
33
53
|
|
|
34
54
|
Memory-enabled native fork adoption and Start's exact-source retry use this transaction inside the extension's owned restoration lifetime; the synchronous `prepareBoundaryFork()` adapter remains supported for library consumers. Both paths publish the fresh child origin before any runtime-only lifecycle write. Native evidence holds a publisher across fork adoption; it does not certify idle native Abort.
|
|
35
55
|
|
|
36
|
-
|
|
56
|
+
**Retry and cancellation:**
|
|
57
|
+
|
|
58
|
+
- A failed or expired selection never substitutes the parent's current/newer private state and never falls through to an older disabled marker.
|
|
59
|
+
- In the same live extension instance, explicit Start may retry the unaccepted fork after missing identity or storage evidence is corrected.
|
|
60
|
+
- Passive selection retains an in-flight fork or its activation-owned retry and applies Passive inside that existing acceptance.
|
|
61
|
+
- Off aborts the owned copy/retry before acceptance and records child-owned native Off/pending-fork policy without publishing memory. A later explicit Passive/Active request reacquires the exact source.
|
|
62
|
+
- Cancelling the Start waiter does not cancel that independently owned copy.
|
|
63
|
+
- Off, selection, shutdown, native Abort, invalid source evidence and expired history can prevent acceptance.
|
|
64
|
+
|
|
65
|
+
**After acceptance:**
|
|
66
|
+
|
|
67
|
+
- Passive exposes both tools for child memory without active episode behavior; Off exposes neither.
|
|
68
|
+
- Ordinary memory-enabled cold reopening loads that child-owned state; Off defers loading it.
|
|
69
|
+
- Explicit Start can activate validated current child-owned memory even after selecting an inherited parent checkpoint. This neither restores parent history nor copies newer parent data.
|
|
70
|
+
- Child-owned checkpoints use ordinary retained-boundary reload/resume without rereading the parent header.
|
|
71
|
+
|
|
72
|
+
**Before the first child-owned checkpoint:** cold recovery requires the explicit Off-deferred pending marker. Missing child files alone never authorize a parent recopy.
|
|
37
73
|
|
|
38
|
-
|
|
74
|
+
**Mode and projection:**
|
|
75
|
+
|
|
76
|
+
- A child-owned passive-projection reset prevents copied parent Stop markers from resurfacing after child reload.
|
|
77
|
+
- Inactive sources retain their selected mode, including a same-owner native failed-Stop policy that could not reach canonical config.
|
|
78
|
+
- A child inherits neither its parent's write fence nor its passive projection. Source history must still be provable, and copying must pass CAS; ordinary activation policy is not overridden.
|
|
79
|
+
- Nested forks require each direct parent boundary to remain retained. Ancestry is not recursively reconstructed.
|
|
39
80
|
|
|
40
81
|
## Support boundary
|
|
41
82
|
|
|
42
|
-
Supported copying requires a persisted regular parent session file, matching header UUID/CWD, current canonical scope/runtime files, and an available retained boundary. Arbitrary session search, UUID aliases, cross-CWD imports, in-memory-only parent locators,
|
|
83
|
+
Supported copying requires a persisted regular parent session file, matching header UUID/CWD, current canonical scope/runtime files, and an available retained boundary. Arbitrary session search, UUID aliases, cross-CWD imports, in-memory-only parent locators, conversion of unsupported storage formats, unlimited history, and Git recovery are unsupported.
|
|
43
84
|
|
|
44
85
|
## Evidence
|
|
45
86
|
|
|
46
|
-
Native integration tests cover retained private selection versus newer parent/shared state, fresh child origin, independent child mutation, child reload/resume, disabled sources, Stop projection fencing, malformed parent identity/CWD, retry
|
|
87
|
+
**Native integration tests** cover retained private selection versus newer parent/shared state, fresh child origin, independent child mutation, child reload/resume, disabled sources, Stop projection fencing, malformed parent identity/CWD, retry and expired-boundary refusal.
|
|
88
|
+
|
|
89
|
+
**Runtime tests** cover single-use preparation, canonical child publication, live shared ownership, artifact provenance, occupied child storage and retention reduction/increase without parent-private mutation or reconstructed history.
|
|
90
|
+
|
|
91
|
+
**Awaited runtime witnesses** also:
|
|
92
|
+
|
|
93
|
+
- hold an independent partial writer for over two seconds and cancel waiting copies;
|
|
94
|
+
- mutate admitted locators and expire source history during waiting;
|
|
95
|
+
- race parent/child bytes and serialize competing child acceptances;
|
|
96
|
+
- reject every occupied child file;
|
|
97
|
+
- roll back injected publication failure and retain accepted memory after checkpoint failure;
|
|
98
|
+
- preserve shared unknown metadata and unrelated provenance.
|
|
99
|
+
|
|
100
|
+
**Continuation tests** cover header-only reading and refusal of non-regular or symlinked locators.
|
|
101
|
+
|
|
102
|
+
**The extension mode matrix** holds storage across native fork selection or Start-owned fork retry. Stop returns with passive policy while the copy remains pending; release permits selected memory to be accepted with disabled policy. Passive patching and subsequent cold header/trace reopening through `SessionManager.open` retain independent child memory. Expired parent history still refuses without canonical writes or replacement checkpoints. These are isolated extension fixtures.
|
|
103
|
+
|
|
104
|
+
**A separate native SDK fixture** observes the child through the public session factory before awaiting extension binding. It sends Stop and optionally Start through the child's public `prompt` method while fork copying waits, then checks the requested mode, independent private state and next-provider patch after release. No private SDK hook or direct State Flow handler invocation is used.
|
|
105
|
+
|
|
106
|
+
These tests prove a supported embedding route, not installed Telegram/TUI reachability before the child replaces the current runtime session.
|