@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.
Files changed (88) hide show
  1. package/BACKLOG.md +2 -2
  2. package/CHANGELOG.md +5 -0
  3. package/README.md +4 -4
  4. package/node_modules/@llblab/pi-state-flow/AGENTS.md +1 -1
  5. package/node_modules/@llblab/pi-state-flow/BACKLOG.md +12 -5
  6. package/node_modules/@llblab/pi-state-flow/CHANGELOG.md +9 -0
  7. package/node_modules/@llblab/pi-state-flow/README.md +116 -34
  8. package/node_modules/@llblab/pi-state-flow/dist/lib/acquisition.d.ts +24 -1
  9. package/node_modules/@llblab/pi-state-flow/dist/lib/acquisition.js +80 -1
  10. package/node_modules/@llblab/pi-state-flow/dist/lib/compaction.d.ts +17 -0
  11. package/node_modules/@llblab/pi-state-flow/dist/lib/compaction.js +40 -0
  12. package/node_modules/@llblab/pi-state-flow/dist/lib/extension.js +149 -298
  13. package/node_modules/@llblab/pi-state-flow/dist/lib/git.d.ts +29 -0
  14. package/node_modules/@llblab/pi-state-flow/dist/lib/git.js +58 -0
  15. package/node_modules/@llblab/pi-state-flow/dist/lib/operation.d.ts +37 -0
  16. package/node_modules/@llblab/pi-state-flow/dist/lib/operation.js +59 -0
  17. package/node_modules/@llblab/pi-state-flow/dist/lib/ownership.d.ts +31 -0
  18. package/node_modules/@llblab/pi-state-flow/dist/lib/ownership.js +117 -0
  19. package/node_modules/@llblab/pi-state-flow/dist/lib/protocol.js +7 -7
  20. package/node_modules/@llblab/pi-state-flow/dist/lib/query.js +1 -1
  21. package/node_modules/@llblab/pi-state-flow/dist/lib/status.d.ts +2 -0
  22. package/node_modules/@llblab/pi-state-flow/dist/lib/status.js +28 -0
  23. package/node_modules/@llblab/pi-state-flow/dist/lib/transition.js +6 -1
  24. package/node_modules/@llblab/pi-state-flow/dist/package.json +1 -1
  25. package/node_modules/@llblab/pi-state-flow/dist/skills/state-flow-guide/SKILL.md +14 -6
  26. package/node_modules/@llblab/pi-state-flow/dist/skills/state-flow-memory/SKILL.md +2 -2
  27. package/node_modules/@llblab/pi-state-flow/docs/README.md +19 -9
  28. package/node_modules/@llblab/pi-state-flow/docs/agent-contract-relocation.md +4 -4
  29. package/node_modules/@llblab/pi-state-flow/docs/architecture.md +644 -91
  30. package/node_modules/@llblab/pi-state-flow/docs/compatibility.md +116 -37
  31. package/node_modules/@llblab/pi-state-flow/docs/filesystem-recovery.md +118 -21
  32. package/node_modules/@llblab/pi-state-flow/docs/fork-contract.md +68 -8
  33. package/node_modules/@llblab/pi-state-flow/docs/lazy-state.md +88 -14
  34. package/node_modules/@llblab/pi-state-flow/docs/performance.md +83 -66
  35. package/node_modules/@llblab/pi-state-flow/docs/temporal-acceptance.md +391 -62
  36. package/node_modules/@llblab/pi-state-flow/docs/usage.md +317 -62
  37. package/node_modules/@llblab/pi-state-flow/lib/acquisition.ts +85 -1
  38. package/node_modules/@llblab/pi-state-flow/lib/compaction.ts +47 -0
  39. package/node_modules/@llblab/pi-state-flow/lib/extension.ts +161 -295
  40. package/node_modules/@llblab/pi-state-flow/lib/git.ts +63 -0
  41. package/node_modules/@llblab/pi-state-flow/lib/operation.ts +75 -0
  42. package/node_modules/@llblab/pi-state-flow/lib/ownership.ts +120 -0
  43. package/node_modules/@llblab/pi-state-flow/lib/protocol.ts +7 -8
  44. package/node_modules/@llblab/pi-state-flow/lib/query.ts +1 -1
  45. package/node_modules/@llblab/pi-state-flow/lib/runtime.ts +1 -1
  46. package/node_modules/@llblab/pi-state-flow/lib/snapshot.ts +1 -2
  47. package/node_modules/@llblab/pi-state-flow/lib/status.ts +29 -0
  48. package/node_modules/@llblab/pi-state-flow/lib/transition.ts +5 -1
  49. package/node_modules/@llblab/pi-state-flow/package.json +1 -1
  50. package/node_modules/@llblab/pi-state-flow/skills/state-flow-guide/SKILL.md +14 -6
  51. package/node_modules/@llblab/pi-state-flow/skills/state-flow-memory/SKILL.md +2 -2
  52. package/node_modules/@llblab/pi-telegram/BACKLOG.md +1 -0
  53. package/node_modules/@llblab/pi-telegram/CHANGELOG.md +10 -0
  54. package/node_modules/@llblab/pi-telegram/README.md +1 -1
  55. package/node_modules/@llblab/pi-telegram/dist/lib/bindings.d.ts +4 -1
  56. package/node_modules/@llblab/pi-telegram/dist/lib/bindings.js +16 -12
  57. package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.d.ts +1 -1
  58. package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.js +7 -1
  59. package/node_modules/@llblab/pi-telegram/dist/lib/commands.d.ts +12 -3
  60. package/node_modules/@llblab/pi-telegram/dist/lib/commands.js +137 -83
  61. package/node_modules/@llblab/pi-telegram/dist/lib/extension.js +26 -0
  62. package/node_modules/@llblab/pi-telegram/dist/lib/lifecycle.d.ts +57 -2
  63. package/node_modules/@llblab/pi-telegram/dist/lib/lifecycle.js +109 -4
  64. package/node_modules/@llblab/pi-telegram/dist/lib/model.js +2 -4
  65. package/node_modules/@llblab/pi-telegram/dist/lib/status.d.ts +3 -1
  66. package/node_modules/@llblab/pi-telegram/dist/lib/status.js +31 -1
  67. package/node_modules/@llblab/pi-telegram/dist/lib/sync.js +4 -4
  68. package/node_modules/@llblab/pi-telegram/dist/lib/threads.d.ts +1 -0
  69. package/node_modules/@llblab/pi-telegram/dist/lib/threads.js +17 -4
  70. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-retirement.d.ts +2 -2
  71. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-retirement.js +48 -12
  72. package/node_modules/@llblab/pi-telegram/dist/package.json +1 -1
  73. package/node_modules/@llblab/pi-telegram/docs/architecture.md +6 -5
  74. package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +2 -0
  75. package/node_modules/@llblab/pi-telegram/docs/public-api.md +2 -2
  76. package/node_modules/@llblab/pi-telegram/docs/ui-style.md +4 -0
  77. package/node_modules/@llblab/pi-telegram/lib/bindings.ts +17 -10
  78. package/node_modules/@llblab/pi-telegram/lib/bus-follower.ts +8 -2
  79. package/node_modules/@llblab/pi-telegram/lib/commands.ts +135 -97
  80. package/node_modules/@llblab/pi-telegram/lib/extension.ts +25 -0
  81. package/node_modules/@llblab/pi-telegram/lib/lifecycle.ts +140 -4
  82. package/node_modules/@llblab/pi-telegram/lib/model.ts +2 -4
  83. package/node_modules/@llblab/pi-telegram/lib/status.ts +30 -1
  84. package/node_modules/@llblab/pi-telegram/lib/sync.ts +4 -4
  85. package/node_modules/@llblab/pi-telegram/lib/threads.ts +21 -3
  86. package/node_modules/@llblab/pi-telegram/lib/workspace-retirement.ts +46 -13
  87. package/node_modules/@llblab/pi-telegram/package.json +1 -1
  88. 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`, 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.
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
- The repository-local verified stack is Linux/x64, Node 26.8.1, Git 2.55.0 and matching Pi SDK 1.0.0 packages. Earlier source-bound measurements on Pi 0.87.0 remain historical evidence, not 1.0.0 performance results. Repository validation covers tests, typecheck, build, compiled imports and package dry-run; successful results are bound to the validated source and dependency identities. The release workflow uses Node 24; its result is a separate verification gate.
7
+ **Verified environment:** Linux/x64, Node 26.8.1, Git 2.55.0 and matching Pi SDK 1.0.0 packages.
8
8
 
9
- 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. Detailed behavioral witnesses live in [temporal acceptance](temporal-acceptance.md); benchmark methodology and source-bound results live in [performance](performance.md).
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 its protocol through `systemPromptOptions.sections.state_flow` and refreshes only that section at `context_with_system`. Companion sections, native system deltas, tool declarations and non-system message identities remain intact; an explicit foreign forced prompt retains Pi's precedence. Mode changes update the next provider request without requiring another `before_agent_start`.
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. Branch selection applies branch-relative edits without rewriting separately owned memory. Retry, length and overflow recovery omit failed attempts from subsequent provider input without accepting them as State Flow responses or advancing semantic history. Edited-context usage accounting must not trigger phantom compaction.
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. Provider strict schemas, cache behavior, diagnostics and other SDK capabilities are not independently certified by State Flow's tests.
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 when no new `before_agent_start` occurs. A completed specification is not resurrected. State Flow does not become the owner of the host's continuation scheduler.
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. State Flow captures the specification at that hook without canonical publication. The active `context` hook supplies the operation signal and awaits preparation/maintenance before provider inference.
50
+ On the tested SDK, `before_agent_start` precedes the low-level agent's `prompt`; `ExtensionContext.signal` is undefined there.
38
51
 
39
- Pi catches context-hook errors and may otherwise continue inference. State Flow therefore calls public `ctx.abort()` on preparation failure rather than relying on a thrown error as a fence. 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.
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
- Operation 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.
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
- Global `config.json` accepts `mode: "active" | "passive" | "off"`, defaulting to Off when no mode policy is configured, solely as the initial policy for new sessions. Session `config.json` uses the same key for the concrete retained choice; commands and Telegram never edit the global default. Before semantic initialization, an inactive choice is retained in a native `{mode}` checkpoint instead.
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
- Legacy decoding is read-only. Without explicit global mode, the absence of all legacy mode flags means Off; `autoStart: true` means Active, while any present legacy mode flag retains its former mapping: `passiveBootstrap: false` together with `passiveTools: false` means Off, and otherwise the fallback is Passive. An operator who previously relied on an absent configuration for implicit Passive must now select Passive in that session or set global `mode: "passive"` for new sessions. Explicit global mode overrides valid legacy flags; invalid values still fail validation. Session `enabled:true` remains Active, and `enabled:false` is non-active. Native legacy inactive checkpoints use the configured inactive fallback, never an Active default. Session config and native checkpoints reject mixed `mode`/`enabled` representations, even when apparently consistent, rather than choosing between two stored policies. Ordinary writers emit only mode; no eager migration or semantic normalization runs.
68
+ **Other readable representations.** Decoding is read-only; ordinary writers emit only mode, with no eager migration or semantic normalization.
48
69
 
49
- The extension SDK uses an optional `mode` default override, and both Telegram port variants use `snapshot.mode` plus `select(mode)`. Old callback keyboards may refresh the view without selecting a mode. Synchronous enum-based ports remain supported; this does not promise the removed Start/Stop port signatures.
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 activates current same-session authority under awaited exclusion. It rechecks physical identity and initialization permission after waiting, accepts once, then installs policy, memory and checkpoint. Explicit Start does not claim to restore an expired historical boundary. 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.
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
- Passive/Off selects local tools/context policy before waiting for persistence; Off injects no State Flow context, including a frozen handoff. For accepted memory it publishes lifecycle metadata without rewriting semantic/provenance files. Pending inactive choices share one acceptance of the latest mode. Selection, shutdown and accepted Start cancel obsolete Stop work; rejected Start does not. Genuine persistence failure retains readable memory and native context while fencing writes until accepted Start.
99
+ **Off:**
56
100
 
57
- Mode choices select workflow policy, not whether canonical memory exists. Passive/Off never cancels retained restoration, Active-default initialization or fork copying: the latest inactive policy is applied at acceptance. Read-only recovery likewise preserves an intervening mode choice and its write fence. Cancelling a Start waiter does not cancel independently owned restoration. Selection changes, shutdown and an available native operation signal can revoke obsolete restoration; post-acceptance ancillary failure cannot undo memory.
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
- Native 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. 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.
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
- 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.
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
- On Pi SDK 0.87.0, the agent clears its active run before `agent_before_settle`, so that event has no operation signal. Native `AgentSession.abort()` cannot withdraw an extension's lock wait at this boundary.
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
- Optional Git backup remains at `agent_before_settle`. 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. Malformed/interrupted ownership remains a failure, not permission to steal a lock. Git commands run outside canonical exclusion. Shutdown drains owned attempts and pending pushes. Backup failure does not roll back memory, suppress an answer or request repair inference.
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 requires known sufficient context usage and a proven retained run anchor. It preserves the complete accepted run, skips protected foreign context and never requests retain-none shortening. Native manual/threshold/overflow compaction remains Pi-owned. The settled handler awaits native compaction completion or refusal so deferred companion prompts do not race it. Unknown or insufficient usage skips compaction; a benign refusal permits a later attempt.
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. Inspection returns coherent state plus matching revisions without publication. Controls and inspections acknowledge callbacks before waiting, suppress revoked results and escape late failures in the current menu. Synchronous mode-selection ports remain supported. 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.
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 those 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.
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
- Use these awaited runtime operations:
149
+ **Awaited runtime operations:**
84
150
 
85
- | Operation | API | Authority boundary |
86
- | --- | --- | --- |
87
- | Shared inspection | `refreshShared` | Read-only; no initialization or revision advance |
88
- | Current private recovery | `refreshCurrentMemory` | Read-only; no publication authority |
89
- | Authored semantic patch | `withPatchTransaction` | Current shared basis and selected private authority; one atomic acceptance |
90
- | Accepted-runtime lifecycle | `withLifecycleTransaction` | Config/runtime only; cannot initialize or repair semantic storage |
91
- | Current-head activation | `withStartTransaction` | Origin creation defaults off and requires explicit authorization |
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 stage and publish synchronously, recheck caller selection/policy after waiting and use their publication capability once within its lifetime. Install host state only after acceptance. Keep inference, source acquisition and Git outside canonical exclusion. Raw precomputed replay retains its selected-basis guards.
159
+ Await completion before consuming results. Transaction callbacks:
96
160
 
97
- Continuation inspection/candidate building and Git backup also return Promises. Callers must 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.
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
- The supported synchronous runtime methods are `loadPassive`, `prepareBoundaryRestore`, `restoreBoundary`, `acceptRestoredOrigin`, `prepareBoundaryFork` and `initialize`. They remain available to library consumers and local tests/benchmarks, but production lifecycle wiring uses the awaited APIs. They are not signature-compatible substitutes and do not acquire the awaited APIs' cancellation behavior. Their presence is not permission to bypass ownership, retained-history or raw-replay checks.
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
- Focused tests do not replace the full integration suite. Tree-bound evidence can be reused only when its relevant inputs are unchanged. Ref-, environment- and external-publication-sensitive checks require their own verification. A successful tag push is not release completion: verify the owning workflow, published GitHub Release and exact npm package identity.
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
- | Resource or cohort | Owner / authority | Total absence | Partial or malformed presence | Allowed repair and writes |
6
- | --- | --- | --- | --- | --- |
7
- | Global `checkpoint.json` + `patches.jsonl` | State Flow; authoritative shared semantics | Authored patches use current empty reality; stale precomputed replay refuses it | Either half missing, malformed replay, or invalid envelope fails closed | Normal CAS publication may materialize the complete empty pair |
8
- | CWD `checkpoint.json` + `patches.jsonl` | State Flow; authoritative shared semantics with CWD identity | Same as global; selected values are not resurrected | Same as global; owner mismatch also fails closed | Normal CAS publication may materialize the complete empty pair |
9
- | Session `checkpoint.json` + `patches.jsonl` | State Flow; authoritative private semantics | Fresh lifecycle origin may initialize; an existing selected session requires exact retained authority | Partial or malformed pair fails closed | Fresh initialization or exact retained-boundary recovery only |
10
- | Global/CWD `meta.json` | State Flow; temporal boundaries, CWD identity, and artifact provenance | Missing metadata removes temporal authority and fails closed; only an omitted `artifacts` leaf degrades provenance to `{}` | Malformed metadata or semantic/boundary mismatch fails closed | Normal CAS publication from a complete proven cohort |
11
- | Session `meta.json` | State Flow; session temporal boundaries and artifact provenance | Fresh origin may initialize; selected sessions recover only from exact scope authority | Partial, malformed, or contradictory boundary evidence fails closed | Canonical scope publication from the selected temporal state |
12
- | Session `config.json` + `runtime.json` | State Flow; behavior plus authoritative runtime identity, lineage, and counters | Fresh origin may initialize; selected sessions recover only from exact authority | Partial, malformed, contradictory identity or lineage fails closed | Canonical runtime publication from proven lifecycle/selected state; combined predecessor metadata is unsupported |
13
- | Unsupported predecessor envelopes, `state.json`, hashed layouts, or semantic Pi checkpoints | No current authority | Ignored | Presence never becomes recovery or conversion input | Preserve bytes; operator-managed removal or external conversion only |
14
- | Retained Pi boundary | State Flow/Pi entry; current canonical lineage | Expired or missing boundary is unavailable | Identity, lifecycle, or lineage contradiction fails closed | Select exact retained private history over live shared scopes; never consult Git |
15
- | Canonical writer lock | State Flow; file-cohort mutual exclusion | Unlocked | Present lock excludes cooperating publishers, including interrupted owners | Current owner releases; no opportunistic deletion |
16
- | Repository-root `config.json` | Operator; optional read-only global configuration | Built-in defaults | Present unreadable/malformed/unknown settings fail extension configuration | State Flow never creates, rewrites, or stages operator edits; include it in operator-managed copies/versioning |
17
- | Registered artifact source path | External source owner | Exact proven absence permits owning-scope artifact/provenance removal | Relative, symlink, directory, malformed, or unreadable paths disable maintenance locally | Never create; semantic removal only for exact proven absence |
18
- | Skill and external artifact sources | External package/user owner | Freshness unavailable unless ownership proves removal semantics | Unsafe/non-regular/unreadable sources disable acquisition locally | Never create or fabricate source/provenance |
19
- | Pi State Flow entries | Pi session log / State Flow entry owner | Missing required selected boundary blocks that restore | Malformed or contradictory owner/version/boundary fails the dependent restore | Append through Pi entry APIs only; never replace failed selection with passive state |
20
- | Optional diagnostic log | State Flow logger; outside the canonical repository | No diagnostic evidence | I/O failure warns once without changing accepted state | Append local JSONL only when opted in; never use it as semantic recovery authority |
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
- **Current limitation:** `lib/durable.ts` writes same-directory temporary files with `writeFileSync`, then replaces owned paths one at a time with `renameSync`. There is no file/directory `fsync` barrier. A successful call or subsequent readback proves filesystem-visible bytes, not persistence beyond volatile OS/device caches. 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. A crash may leave mixed old/new files or unavailable evidence. Existing rollback and cancellation tests do not establish power-loss survival.
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
- **Selected contract (operator decision, 2026-09-24):** optimistic ordinary-operation persistence is sufficient for this release. Loss of recent work after abrupt power loss is an accepted risk, not a requirement for a new recovery mechanism. Power-loss-safe acknowledgement is removed from the release gates; do not add a patch journal, temporary recovery store, flush protocol or storage-format redesign for that scenario. Existing same-directory temporary replacement files remain an implementation detail, not a new patch store. No at-most-one-patch loss bound is promised: an interrupted multi-file publication can leave incomplete evidence and require operator recovery.
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
- Ordinary concurrent publication still preserves unrelated current Global/CWD fields, orders overlapping writes by acceptance and protects private Session authority. Use one short asynchronously awaited capture/stage/publication exclusion plus CAS; inference, source acquisition and Git stay outside it. 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. Optional Git backup and remote synchronization may defer to a later eligible settled turn; neither every intermediate commit nor immediate remote replication is required.
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
- **Native Pi comparison:** inspection of Pi SDK 0.87.0 `dist/core/session-manager.js` shows `_persist()` appending JSONL with `appendFileSync` and initially writing entries with `writeFileSync`; `_rewriteFile()` writes through an opened file descriptor and closes it. These paths specify no `fsync`, `fdatasync` or `flush: true` barrier. Its `flushed` flag tracks whether the initial in-memory entries were written, not stable-media acknowledgement. This is source evidence for that SDK line, not a power-failure experiment or a guarantee about other versions/filesystems. Stronger durability is technically possible with persistence barriers and a coherent recovery protocol, but is deliberately outside this release scope. Process-kill tests alone would not prove volatile-cache survival.
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, not permission to restore cached cold values or leftover compilation evidence. 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. Raw precomputed replay targeting a disappeared selected basis still fails closed. Discarded history is unavailable and is never reconstructed or promoted back into current shared memory.
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
- The parent's private files and native trace remain unchanged. Later child session writes cannot modify the parent's private layer. 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. Forking semantic memory does not clone or roll back project files or tool effects.
24
+ **What stays unchanged:**
25
25
 
26
- Artifact provenance is current-only, not a historical registry. 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. The child keeps the selected artifact semantics but omits that provenance until explicit reacquisition and compilation. Untouched artifact paths retain their evidence, including provenance-only refreshes of unchanged semantics; shared provenance remains live.
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?)` pins source identity/boundary before waiting and selects exact parent authority plus an unoccupied child under one awaited exclusion. The caller rechecks native selection/policy and publishes its child lifecycle synchronously once. Parent evidence is revalidated before publication, the child cohort is CAS-protected, and only accepted memory installs. Cancellation or rejection cannot initialize an empty child; post-acceptance failure cannot roll it back or authorize another parent copy. Existing child storage, identity mismatch, missing parent files, malformed storage, concurrency conflict, or an expired boundary fails closed.
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
- An Off native fork defers parent-header acquisition and canonical copying. Only a child-owned pending-fork marker is appended to the native trace; it carries no semantic authority. 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. Accepted initialization resets the marker. Parent expiry while Off is diagnosed only on explicit acquisition, never silently replaced with newer parent memory.
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
- A failed or expired selection never substitutes the parent's current/newer private state and never falls through to an older disabled marker. In the same live extension instance, explicit Start may retry the unaccepted fork after missing identity or storage evidence is corrected. Passive selection retains an in-flight fork or its activation-owned retry and applies Passive inside that existing acceptance. Off instead 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. Cancelling the Start waiter does not cancel that independently owned copy. After acceptance, Passive exposes both tools for child memory without active episode behavior, while Off exposes neither; ordinary memory-enabled cold reopening loads that child-owned state, while Off defers loading it. Off, selection, shutdown, native Abort, invalid source evidence and expired history still can prevent acceptance. Cold recovery before the first child-owned checkpoint remains unsupported without the explicit Off-deferred pending marker; missing child files alone never authorize a parent recopy. Once child storage has been accepted, explicit Start can activate its validated current child-owned memory even after selecting an inherited parent checkpoint; this neither restores parent history nor copies newer parent data. Child-owned checkpoints subsequently use ordinary retained-boundary reload/resume without rereading the parent header.
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
- A child-owned passive-projection reset prevents copied parent Stop markers from resurfacing after child reload. Inactive sources retain their selected mode, including a same-owner native failed-Stop policy that could not reach canonical config. A child inherits neither that 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. Nested forks require each direct parent boundary to remain retained; ancestry is not recursively reconstructed.
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, predecessor conversion, unlimited history, and Git recovery are unsupported.
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, and expired-boundary refusal. 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. Awaited runtime witnesses additionally hold an independent partial writer for over two seconds, cancel waiting copies, mutate admitted locators, expire source history during waiting, race parent/child bytes, serialize competing child acceptances, reject every occupied child file, roll back injected publication failure and retain accepted memory after checkpoint failure. Shared unknown metadata and unrelated provenance remain intact. Continuation tests cover header-only reading and refusal of non-regular or symlinked locators. 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. A separate native SDK fixture observes the child through the public session factory before awaiting extension binding, sends Stop and optionally Start through the child's public `prompt` method while fork copying waits, and 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. This proves a supported embedding route, not installed Telegram/TUI reachability before the child replaces the current runtime session.
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.