@llblab/pi-kit 0.18.1 → 0.19.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/CHANGELOG.md +12 -0
- package/README.md +4 -2
- package/node_modules/@llblab/pi-state-flow/AGENTS.md +35 -37
- package/node_modules/@llblab/pi-state-flow/BACKLOG.md +5 -3
- package/node_modules/@llblab/pi-state-flow/CHANGELOG.md +19 -1
- package/node_modules/@llblab/pi-state-flow/README.md +102 -48
- package/node_modules/@llblab/pi-state-flow/dist/index.d.ts +6 -9
- package/node_modules/@llblab/pi-state-flow/dist/index.js +6 -9
- package/node_modules/@llblab/pi-state-flow/dist/lib/acquisition.d.ts +2 -2
- package/node_modules/@llblab/pi-state-flow/dist/lib/acquisition.js +21 -8
- package/node_modules/@llblab/pi-state-flow/dist/lib/artifact.d.ts +40 -24
- package/node_modules/@llblab/pi-state-flow/dist/lib/artifact.js +93 -63
- package/node_modules/@llblab/pi-state-flow/dist/lib/compaction.d.ts +4 -3
- package/node_modules/@llblab/pi-state-flow/dist/lib/compaction.js +9 -9
- package/node_modules/@llblab/pi-state-flow/dist/lib/config.d.ts +1 -1
- package/node_modules/@llblab/pi-state-flow/dist/lib/config.js +6 -5
- package/node_modules/@llblab/pi-state-flow/dist/lib/context.d.ts +8 -7
- package/node_modules/@llblab/pi-state-flow/dist/lib/context.js +56 -58
- package/node_modules/@llblab/pi-state-flow/dist/lib/continuation.js +12 -24
- package/node_modules/@llblab/pi-state-flow/dist/lib/durable.d.ts +7 -18
- package/node_modules/@llblab/pi-state-flow/dist/lib/durable.js +47 -78
- package/node_modules/@llblab/pi-state-flow/dist/lib/extension.d.ts +4 -6
- package/node_modules/@llblab/pi-state-flow/dist/lib/extension.js +241 -437
- package/node_modules/@llblab/pi-state-flow/dist/lib/git.d.ts +2 -72
- package/node_modules/@llblab/pi-state-flow/dist/lib/git.js +120 -499
- package/node_modules/@llblab/pi-state-flow/dist/lib/history.d.ts +2 -1
- package/node_modules/@llblab/pi-state-flow/dist/lib/history.js +4 -3
- package/node_modules/@llblab/pi-state-flow/dist/lib/json.d.ts +3 -0
- package/node_modules/@llblab/pi-state-flow/dist/lib/json.js +43 -22
- package/node_modules/@llblab/pi-state-flow/dist/lib/logging.d.ts +1 -5
- package/node_modules/@llblab/pi-state-flow/dist/lib/logging.js +0 -2
- package/node_modules/@llblab/pi-state-flow/dist/lib/memory.d.ts +1 -14
- package/node_modules/@llblab/pi-state-flow/dist/lib/memory.js +5 -37
- package/node_modules/@llblab/pi-state-flow/dist/lib/protocol.d.ts +1 -2
- package/node_modules/@llblab/pi-state-flow/dist/lib/protocol.js +13 -32
- package/node_modules/@llblab/pi-state-flow/dist/lib/query.d.ts +6 -6
- package/node_modules/@llblab/pi-state-flow/dist/lib/query.js +25 -21
- package/node_modules/@llblab/pi-state-flow/dist/lib/recovery.d.ts +3 -3
- package/node_modules/@llblab/pi-state-flow/dist/lib/recovery.js +15 -12
- package/node_modules/@llblab/pi-state-flow/dist/lib/rehydration.d.ts +2 -4
- package/node_modules/@llblab/pi-state-flow/dist/lib/rehydration.js +5 -1
- package/node_modules/@llblab/pi-state-flow/dist/lib/runtime.d.ts +26 -88
- package/node_modules/@llblab/pi-state-flow/dist/lib/runtime.js +159 -255
- package/node_modules/@llblab/pi-state-flow/dist/lib/skills.d.ts +0 -3
- package/node_modules/@llblab/pi-state-flow/dist/lib/skills.js +1 -47
- package/node_modules/@llblab/pi-state-flow/dist/lib/snapshot.d.ts +16 -33
- package/node_modules/@llblab/pi-state-flow/dist/lib/snapshot.js +48 -137
- package/node_modules/@llblab/pi-state-flow/dist/lib/state.d.ts +16 -11
- package/node_modules/@llblab/pi-state-flow/dist/lib/state.js +13 -14
- package/node_modules/@llblab/pi-state-flow/dist/lib/status.d.ts +1 -9
- package/node_modules/@llblab/pi-state-flow/dist/lib/status.js +15 -43
- package/node_modules/@llblab/pi-state-flow/dist/lib/storage.d.ts +5 -9
- package/node_modules/@llblab/pi-state-flow/dist/lib/storage.js +13 -45
- package/node_modules/@llblab/pi-state-flow/dist/lib/telegram.js +1 -1
- package/node_modules/@llblab/pi-state-flow/dist/lib/temporal.d.ts +15 -7
- package/node_modules/@llblab/pi-state-flow/dist/lib/temporal.js +104 -24
- package/node_modules/@llblab/pi-state-flow/dist/lib/transition.d.ts +0 -2
- package/node_modules/@llblab/pi-state-flow/dist/lib/transition.js +11 -14
- package/node_modules/@llblab/pi-state-flow/dist/package.json +9 -6
- package/node_modules/@llblab/pi-state-flow/dist/skills/state-flow-guide/SKILL.md +11 -17
- package/node_modules/@llblab/pi-state-flow/dist/skills/state-flow-memory/SKILL.md +8 -8
- package/node_modules/@llblab/pi-state-flow/docs/README.md +2 -2
- package/node_modules/@llblab/pi-state-flow/docs/architecture.md +64 -67
- package/node_modules/@llblab/pi-state-flow/docs/compatibility.md +24 -6
- package/node_modules/@llblab/pi-state-flow/docs/filesystem-recovery.md +12 -15
- package/node_modules/@llblab/pi-state-flow/docs/fork-contract.md +22 -27
- package/node_modules/@llblab/pi-state-flow/docs/lazy-state.md +25 -41
- package/node_modules/@llblab/pi-state-flow/docs/performance.md +38 -421
- package/node_modules/@llblab/pi-state-flow/docs/temporal-acceptance.md +33 -46
- package/node_modules/@llblab/pi-state-flow/docs/usage.md +37 -61
- package/node_modules/@llblab/pi-state-flow/index.ts +7 -71
- package/node_modules/@llblab/pi-state-flow/lib/acquisition.ts +26 -11
- package/node_modules/@llblab/pi-state-flow/lib/artifact.ts +116 -88
- package/node_modules/@llblab/pi-state-flow/lib/compaction.ts +12 -10
- package/node_modules/@llblab/pi-state-flow/lib/config.ts +6 -6
- package/node_modules/@llblab/pi-state-flow/lib/context.ts +52 -59
- package/node_modules/@llblab/pi-state-flow/lib/continuation.ts +11 -20
- package/node_modules/@llblab/pi-state-flow/lib/durable.ts +44 -86
- package/node_modules/@llblab/pi-state-flow/lib/extension.ts +237 -460
- package/node_modules/@llblab/pi-state-flow/lib/git.ts +110 -552
- package/node_modules/@llblab/pi-state-flow/lib/history.ts +4 -3
- package/node_modules/@llblab/pi-state-flow/lib/json.ts +39 -23
- package/node_modules/@llblab/pi-state-flow/lib/logging.ts +1 -7
- package/node_modules/@llblab/pi-state-flow/lib/memory.ts +5 -44
- package/node_modules/@llblab/pi-state-flow/lib/protocol.ts +14 -25
- package/node_modules/@llblab/pi-state-flow/lib/query.ts +26 -22
- package/node_modules/@llblab/pi-state-flow/lib/recovery.ts +17 -11
- package/node_modules/@llblab/pi-state-flow/lib/rehydration.ts +7 -5
- package/node_modules/@llblab/pi-state-flow/lib/runtime.ts +154 -254
- package/node_modules/@llblab/pi-state-flow/lib/skills.ts +1 -49
- package/node_modules/@llblab/pi-state-flow/lib/snapshot.ts +58 -142
- package/node_modules/@llblab/pi-state-flow/lib/state.ts +27 -19
- package/node_modules/@llblab/pi-state-flow/lib/status.ts +16 -54
- package/node_modules/@llblab/pi-state-flow/lib/storage.ts +12 -40
- package/node_modules/@llblab/pi-state-flow/lib/telegram.ts +1 -1
- package/node_modules/@llblab/pi-state-flow/lib/temporal.ts +104 -22
- package/node_modules/@llblab/pi-state-flow/lib/transition.ts +16 -26
- package/node_modules/@llblab/pi-state-flow/package.json +9 -6
- package/node_modules/@llblab/pi-state-flow/skills/state-flow-guide/SKILL.md +11 -17
- package/node_modules/@llblab/pi-state-flow/skills/state-flow-memory/SKILL.md +8 -8
- package/node_modules/@llblab/pi-telegram/CHANGELOG.md +7 -0
- package/node_modules/@llblab/pi-telegram/README.md +1 -2
- package/node_modules/@llblab/pi-telegram/dist/lib/bindings.d.ts +1 -3
- package/node_modules/@llblab/pi-telegram/dist/lib/bindings.js +1 -6
- package/node_modules/@llblab/pi-telegram/dist/lib/commands.d.ts +1 -4
- package/node_modules/@llblab/pi-telegram/dist/lib/commands.js +13 -33
- package/node_modules/@llblab/pi-telegram/dist/lib/extension.js +1 -4
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-queue.d.ts +1 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-queue.js +72 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/queue.d.ts +7 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/queue.js +27 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/replies.d.ts +3 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/replies.js +17 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/sync.js +8 -1
- package/node_modules/@llblab/pi-telegram/dist/package.json +1 -1
- package/node_modules/@llblab/pi-telegram/docs/architecture.md +2 -0
- package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +1 -1
- package/node_modules/@llblab/pi-telegram/docs/public-api.md +1 -1
- package/node_modules/@llblab/pi-telegram/lib/bindings.ts +0 -10
- package/node_modules/@llblab/pi-telegram/lib/commands.ts +18 -41
- package/node_modules/@llblab/pi-telegram/lib/extension.ts +1 -8
- package/node_modules/@llblab/pi-telegram/lib/menu-queue.ts +126 -1
- package/node_modules/@llblab/pi-telegram/lib/queue.ts +46 -0
- package/node_modules/@llblab/pi-telegram/lib/replies.ts +19 -0
- package/node_modules/@llblab/pi-telegram/lib/sync.ts +8 -1
- package/node_modules/@llblab/pi-telegram/package.json +1 -1
- package/package.json +3 -3
- package/node_modules/@llblab/pi-state-flow/dist/lib/discovery.d.ts +0 -21
- package/node_modules/@llblab/pi-state-flow/dist/lib/discovery.js +0 -125
- package/node_modules/@llblab/pi-state-flow/dist/lib/maintenance.d.ts +0 -36
- package/node_modules/@llblab/pi-state-flow/dist/lib/maintenance.js +0 -98
- package/node_modules/@llblab/pi-state-flow/dist/lib/migration.d.ts +0 -13
- package/node_modules/@llblab/pi-state-flow/dist/lib/migration.js +0 -167
- package/node_modules/@llblab/pi-state-flow/dist/lib/publication.d.ts +0 -86
- package/node_modules/@llblab/pi-state-flow/dist/lib/publication.js +0 -437
- package/node_modules/@llblab/pi-state-flow/lib/discovery.ts +0 -133
- package/node_modules/@llblab/pi-state-flow/lib/maintenance.ts +0 -147
- package/node_modules/@llblab/pi-state-flow/lib/migration.ts +0 -171
- package/node_modules/@llblab/pi-state-flow/lib/publication.ts +0 -458
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Temporal acceptance
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This is a maintained property-to-test map for the current canonical-file contract, not a second backlog or a substitute for running tests. Paths and quoted test names refer to a source checkout; tests are not shipped in the npm runtime package.
|
|
4
4
|
|
|
5
5
|
## Required properties and witnesses
|
|
6
6
|
|
|
@@ -8,62 +8,49 @@ The numbering below follows the twenty required tests in the temporal design cor
|
|
|
8
8
|
2. **One patch:** `tests/temporal.test.ts` — “one patch shifts current to history and reads return detached materializations” checks new current state and the preceding checkpoint state.
|
|
9
9
|
3. **Seven patches:** `tests/temporal.test.ts` — “seven patches and repeated eighth-patch folding preserve every hot state exactly” compares every effective/scoped offset with retained snapshots at seven transitions.
|
|
10
10
|
4. **Eighth-patch folding:** The same test explicitly checks checkpoint advancement through T1, its absorbed value, and the retained T2–T8 tail, alongside every hot offset.
|
|
11
|
-
5. **Repeated folding:** The same test repeats through forty transitions
|
|
11
|
+
5. **Repeated folding:** The same test repeats through forty transitions; `tests/storage.test.ts` exercises the persisted canonical representation.
|
|
12
12
|
6. **Sparse scopes share one target:** `tests/temporal.test.ts` — “sparse scope patches use effective boundaries, not each scope's mutation count” reproduces the T181–T184 example.
|
|
13
|
-
7. **CWD indexing is not local-patch indexing:** That sparse test explicitly asserts both CWD offsets 1 and 2 equal C′. `tests/extension.test.ts` — “read_state lazily projects all hot
|
|
13
|
+
7. **CWD indexing is not local-patch indexing:** That sparse test explicitly asserts both CWD offsets 1 and 2 equal C′. `tests/extension.test.ts` — “read_state lazily projects all hot historical paths and scopes without publication or Git calls” checks all 32 offset/scope combinations.
|
|
14
14
|
8. **Shared multi-scope identity:** `tests/transition.test.ts` — “publishes one exact multi-scope replay cohort without explanatory windows or current-state DTOs” verifies one identity across changed scope records and exact replay.
|
|
15
15
|
9. **Unchanged scopes stay stable:** The sparse temporal example checks global state at a boundary where only CWD/session change; “true no-ops do not enter history while response-only changes do” also checks that an unchanged session receives no new patch.
|
|
16
16
|
10. **Historical deletion overlay:** `tests/temporal.test.ts` — “mixed sparse changes and deletion overlays match an independent snapshot oracle through compaction” explicitly checks session → CWD → global fallback and retained historical values.
|
|
17
17
|
11. **Barrier shifts current to offset 1:** `tests/integration.test.ts` — “real Pi patch_state barriers rematerialize every scope before the next inference” observes the predecessor immediately after a barrier.
|
|
18
|
-
12. **Next inference sees new current state:** The same real-Pi test inspects actual model-input projections after session, CWD, and global barriers. “real Pi reads prior scoped state lazily after a barrier and rejects offset eight without a transition” adds model-tool access to the predecessor.
|
|
18
|
+
12. **Next inference sees new current state:** The same real-Pi test inspects actual model-input projections after session, CWD, and global barriers. “real Pi reads prior scoped state lazily after a barrier and rejects path offset eight without a transition” adds model-tool access to the predecessor.
|
|
19
19
|
13. **No automatic old full-state duplication:** `tests/context.test.ts` — “projects only the latest seven compact accepted transitions” rejects full-state records in transition context. The real-Pi barrier test requires exactly one current runtime projection per inference. Explicitly requested history remains ordinary tool-result trajectory, not eager snapshot injection.
|
|
20
|
-
14. **Accepted response changes are transitions:** `tests/extension.test.ts` — “
|
|
21
|
-
15. **
|
|
22
|
-
16. **
|
|
23
|
-
17. **
|
|
24
|
-
18. **Tree/resume select the correct lineage:** `tests/integration.test.ts` — “real Pi preserves branch-local state through compaction
|
|
25
|
-
19. **Stop changes config, not semantic history:** `tests/
|
|
26
|
-
20. **Lossless current-state migration:** `tests/migration.test.ts` — “migration anchors exact current materializations and never replays explanatory journals”; `tests/git.test.ts` — “migrates all three current snapshots in one isolated commit without losing semantic or cold history”; runtime tests cover revision-linked migration with malformed explanatory history.
|
|
20
|
+
14. **Accepted response changes are transitions:** `tests/extension.test.ts` — “accepts only canonical materially changing atomic scope patches” verifies that an ordinary accepted answer becomes runtime-owned `response` without a finalization patch or fallback inference.
|
|
21
|
+
15. **No-op mutation signals are rejected:** The same extension test rejects empty and obsolete finalization-shaped calls, while a changed accepted response remains a runtime-owned transition.
|
|
22
|
+
16. **Configured hot-history bounds:** `tests/temporal.test.ts` verifies hot-range and unavailable pre-origin boundaries; the real-Pi history-reader test rejects offset eight at the default limit seven without a transition. `tests/config.test.ts` exercises materialized and scope patch-history paths at limits 0, 1, 7, and 12, including single-path/one-item batch reads above seven and distinct configured versus actually retained boundaries.
|
|
23
|
+
17. **Selected history fails closed:** `tests/recovery.test.ts` proves every failure resolving a selected retained boundary refuses without falling through to older boundaries or disabled markers. `tests/extension.test.ts` covers all passive bootstrap/tool combinations; the native “real Pi expired selection cannot reset private state through passive Start, Stop, patch, or reload” witness preserves exact canonical bytes and Pi checkpoints while allowing shared reads. Fork identity/CWD repair witnesses retry the original source with passive access both enabled and disabled.
|
|
24
|
+
18. **Tree/resume select the correct lineage:** `tests/integration.test.ts` — “real Pi preserves branch-local state through compaction and rejects an expired sibling after fresh-origin navigation” and “real Pi old tree branch stop and resume preserve selected semantics without rewinding shared files”.
|
|
25
|
+
19. **Stop changes config, not semantic history:** `tests/runtime.test.ts` lifecycle-only witnesses use a separate process to advance global/CWD semantics or provenance, including wider foreign retention, then prove exact semantic/sidecar preservation, unchanged steps, idempotent Stop, and same-session/stale-evidence refusal. Native Stop/new-request witnesses verify the accepted shared view reaches handoff/inference without a lifecycle semantic write, while a shared write racing after inference still fails closed. Mid-tool Stop tests preserve ordinary/bootstrap trajectories through tree, reload, resume, and restart. The native “real Pi retains a native split-turn continuation through late tools” Stop/no-Stop controls actually remove the original user with native threshold compaction, then require summary, paired reads and foreign context in model input. The Stop case also checks frozen semantics/step, unchanged trace prefix, tree/reload/cold resume/bootstrap restart, no resurrection of discarded input, and persistent foreign context after the next active run. Pure passive-selector tests cover missing, colliding and nonfinite recorded active anchors without changing idle/legacy cutoffs. `tests/storage.test.ts` fences lifecycle-only writes to config/runtime files; `tests/extension.test.ts` covers idle/legacy cutoffs and new/fork boundaries.
|
|
27
26
|
|
|
28
27
|
## Additional preservation boundaries
|
|
29
28
|
|
|
30
|
-
- `tests/
|
|
31
|
-
- `tests/
|
|
32
|
-
- `tests/
|
|
33
|
-
- `tests/git.test.ts`
|
|
34
|
-
- `tests/integration.test.ts` native new/resume/fork
|
|
35
|
-
- `tests/recovery.test.ts` and `tests/runtime.test.ts` distinguish
|
|
36
|
-
- `tests/git.test.ts` — “large Git-backed checkpoint, tail and runtime blobs survive cold reads and later publication” checks UTF-8 documents beyond Node's default subprocess-output budget, selected cold semantics, runtime-only Stop and unchanged live files/branch during inspection. The native “real Pi retains large state and accepted answers across reload, resume and a large specification” witness preserves the exact session/leaf/revision and earlier response boundaries, then accepts a new run with large runtime metadata.
|
|
37
|
-
- `tests/git.test.ts` tree-catalog witnesses cover one exact tree query per selected revision/cohort, per-path blob reuse, literal metacharacter/tab/newline paths and inherited literal-path settings, unused malformed fallback isolation, incomplete/ambiguous catalog rejection, and fresh mode validation after HEAD advances. Existing symlink, omitted-stream, cold-history, migration, prepared-output and CAS regressions remain required; batching cannot replace file validation with working-tree equality.
|
|
38
|
-
- `tests/publication.test.ts` — “queue commit boundaries reject non-string values without coercion or side effects” covers constructor, parser/serializer, store, coalescing, confirmation, and worker input. Malformed files remain byte-identical, ancestry/push callbacks stay unused, and exact scalar strings still round-trip. `tests/git.test.ts` rejects coercible asynchronous push targets before creating a child.
|
|
29
|
+
- `tests/continuation.test.ts` independently advances global/CWD at limits 0/7, then proves read-only eligibility agrees with actual restore and preserves the session layer, including shared-only transitions. `tests/temporal.test.ts` covers sparse/inherited session lineage, conflicting checkpoint/tail identities and parents, future patches, and immutable inputs. The runtime restore/fork contradiction witnesses preserve source/target files rather than accepting a new origin over mixed session files. The native “real Pi refuses contradictory session files without passive substitution and retries the repaired selection” witness retains shared access, fences session access/Start/Stop, preserves the selected checkpoint, and succeeds after exact-source repair. These are synthetic integrity tests, not evidence of spontaneous cross-session leakage.
|
|
30
|
+
- `tests/extension.test.ts` distinguishes pre-runtime Stop from accepted-runtime Stop across passive configurations: global-only and shared storage remain unchanged, repeated Stop/reload retain the disabled marker, and subsequent Start/passive patch establishes a retained session boundary. Malformed/incomplete scope files remain unavailable; Stop does not repair CWD-only storage, while explicit Start may initialize its wholly absent global scope. The native “real Pi Stop preserves a global-only passive branch through reload, patch, and Start” witness checks the same lifecycle without Git. `tests/invariants.test.ts` rejects the retired Skill converter in both package and domain exports; existing Skill/transition witnesses preserve real source hashing, hashing failure, and retired-field rejection.
|
|
31
|
+
- `tests/durable.test.ts` and `tests/storage.test.ts` cover canonical-format rejection, owned regular files, raw-byte rollback, prepared-output receipts, stale/omitted-scope CAS, literal paths, malformed cohorts, and shared-writer exclusion.
|
|
32
|
+
- `tests/git.test.ts` proves settled backup preserves unrelated staged/index-only/worktree data, already-staged owned deletions, Git ignore/filter policy, literal paths, and opaque bytes. Controlled Git pauses before/after snapshot capture allow an independent canonical writer to advance and create a new scope; the commit must match exactly one captured cohort, never mixed live bytes. Every observed Git command runs outside the backup's canonical lock. Namespace/type witnesses exclude unrelated traversal and refuse non-regular sources. No-op/unowned-only initial backups skip; Git/index failures preserve canonical acceptance and caller data. `tests/episode.test.ts` proves one diagnostic-only attempt at `agent_before_settle`, without answer changes or an automatic retry.
|
|
33
|
+
- `tests/integration.test.ts` native new/resume/fork witnesses preserve canonical files and retained boundaries. Fork witnesses cover selected private state over current shared layers, fresh child ownership, reload/resume, disabled-source fencing, identity/CWD refusal, retry, and expired-boundary refusal. `tests/runtime.test.ts` restore/fork provenance witnesses preserve current-head, untouched-path, and shared evidence while discarding evidence for later-changed private artifacts, including change-away-and-back. The test-only provenance reader is checked against nonempty canonical `meta.json` evidence in every scope before and after reload; native restore/fork tests verify missing-evidence invalidation, explicit recompilation, parent preservation, and provenance across reload.
|
|
34
|
+
- `tests/recovery.test.ts` and `tests/runtime.test.ts` distinguish malformed checkpoints from expired retained boundaries, prevent fallthrough or newer-state substitution, and require detached single-use restoration followed by canonical origin acceptance.
|
|
39
35
|
- `tests/extension.test.ts` — “tool preflight walks only the selected native suffix for matching calls, without rebuilding a branch” uses real in-memory `SessionManager` trees with zero/two hundred prior request-answer pairs, intervening custom/results, and a later unselected assistant reusing a call ID. It requires exact parent visits, no full-branch construction, preserved sibling/duplicate-patch rejection and unchanged complete native entries. The native sibling-tool witness in `tests/integration.test.ts` separately observes all three start/end events and requires zero branch reads during preflight/execution while accepting the correct state/answer.
|
|
40
|
-
- `tests/context.test.ts` — “enabled context projects the complete overlay once in ordinary and bootstrap runs” counts one full-overlay clone at 8 KiB and 1 MiB while preserving selected/cached state, native entries, input messages and artifact semantics. “current run trajectory allocates no arrays of discarded ordinary history” observes source-derived arrays after zero/two hundred historical request-answer pairs while preserving foreign context, current tools, steering, reference identity and order. Anchor tests
|
|
41
|
-
- `tests/compaction.test.ts` owns State Flow's completed-run compaction policy:
|
|
36
|
+
- `tests/context.test.ts` — “enabled context projects the complete overlay once in ordinary and bootstrap runs” counts one full-overlay clone at 8 KiB and 1 MiB while preserving selected/cached state, native entries, input messages and artifact semantics. “current run trajectory allocates no arrays of discarded ordinary history” observes source-derived arrays after zero/two hundred historical request-answer pairs while preserving foreign context, current tools, steering, reference identity and order. Anchor tests prefer captured identity over normalized text, retain images/tools/steering, and preserve available context on missing/nonfinite/colliding identities or ambiguous specification matches; unique text fallback remains projection-only. The native barrier witness separately counts one marked full-overlay clone per post-barrier `emitContext()` invocation; it still requires each next inference to see all accepted scope changes.
|
|
37
|
+
- `tests/compaction.test.ts` owns State Flow's completed-run compaction policy: captured run-anchor retention across steering/tools, missing/ambiguous/unfinished-anchor refusal, large-history eligibility, generation-owned invocation, foreign `custom`/`custom_message` prefix refusal, queued-work exclusion, stale selection, benign preparation refusal and shutdown fencing. Its harness emits native user `message_end` and checks that repeated projection plus steering cannot promote missing, ambiguous or unobserved anchors into compaction authority. The native “real Pi compaction retains the original run through steering, tool results, and foreign context” cases actually compact plaintext and SDK-normalized image requests with two steering messages, a successful read/patch, and persisted custom context; image/read-result evidence reaches later model calls, exact message ids survive reload, the trace prefix stays byte-identical, and no model summary is requested. The short “real Pi retains a normalized image and read evidence through steering without compaction” controls check State Flow enabled/disabled parity before any compaction. Existing native witnesses cover ordinary compaction/cold resume and leave threshold compaction after partial tool work native.
|
|
38
|
+
- `tests/integration.test.ts` — “real Pi boundary continuation keeps accepted State Flow memory” exercises actual companion `turn_end` and `agent_before_settle` draft entries and continuation. Each next provider input has exactly one current-memory projection before/after a continued patch, the accepted response and current tool declarations. There is only one `before_agent_start`, no restored specification in runtime checkpoints or model projection, exactly one requested continuation and correct final response/step. The pure “projects accepted memory without resurrecting a completed specification for boundary continuation” witness preserves source state, omits lazy bodies, and keeps available context when both specification and native capture are absent.
|
|
39
|
+
- `tests/integration.test.ts` — “real Pi context edits remain canonical through tools, tree selection and reload” proves native user-content replacement, assistant/custom-message omission and live tool-result replacement reach provider input without resurrecting raw history. Selecting an unedited branch restores its native view without overwriting accepted semantic files; selecting the edited branch and reloading preserves its edits and independent memory. Raw JSONL stays append-only.
|
|
40
|
+
- `tests/integration.test.ts` — “real Pi structured prompt composes with context hooks” covers active, passive, disabled and explicit foreign-force modes. Conversation hooks exclude systems; full-system hooks receive them; companion before-run and per-request sections plus actual tool declarations survive. User specifications remain outside system authority. Stop/Start on subsequent user requests removes/reinstates the owned section once.
|
|
41
|
+
- `tests/integration.test.ts` — “real Pi preserves native run identity across mode toggles” covers initially enabled, mid-tool Start and repeated Start/Stop with passive bootstrap on/off. Actual provider inputs retain original user/read evidence but not the preceding disabled request; persisted Stop markers name the observed native user, and fixture reload preserves trajectory, frozen state and raw trace prefix. `tests/compaction.test.ts` — “native session boundaries invalidate observed run capture without projection reacquisition” pairs session-start/tree resets with an admitted unchanged-run control. No new stored field or guessed anchor is used.
|
|
42
|
+
- `tests/integration.test.ts` — “real Pi refreshes protocol within the same run” covers mid-read Stop, passive Stop, mid-read Start and accepted-boundary Stop/continuation. The next provider request has current protocol/tools, foreign context and tool evidence, no elevated specification and only one user-run preparation; response reconciliation follows the actual mode and earlier native system frames remain intact. `tests/context.test.ts` — “refreshes only owned system protocol without mutating native frames” covers old/replaced/deleted sections, foreign content/tools, conversation identity/order, frozen inputs, absent-frame non-synthesis and unchanged-delta no-ops.
|
|
43
|
+
- `tests/integration.test.ts` — “real Pi recovery omits failed attempts without accepting them” checks retry/length/overflow through actual SDK dispatch: durable omission edits, raw trace preservation, unchanged accepted response/step until successful recovery, native split-turn summaries and fixture reload. “real Pi edited-context accounting discards stale provider usage” checks reduced native usage after replacement and one subsequent inference without phantom compaction.
|
|
44
|
+
- `tests/integration.test.ts` — “real Pi settled dispatch preserves deferred companion work” covers low pressure, real owned compaction and explicit compaction refusal. The native completion/error callback finishes before settled dispatch returns; all companion observers precede exactly one deferred request, which sees accepted memory and reconciles the expected response/step. The admitted case verifies an actual State Flow-owned compaction rather than relying only on a token estimate.
|
|
45
|
+
- `tests/integration.test.ts` — “real Pi applies image profiles only to newly admitted images” compares actual PNG payload dimensions for wide/tall prompt images, built-in image reads and generic tool-result images under two native model profiles. Switching to smaller bounds preserves prior user/read/tool payload bytes through later provider inputs and reload, with disabled/enabled controls and detached caller images. The settled-dispatch witness also inspects actual system prompt and tool declarations after owned compaction, not just scripted execution.
|
|
46
|
+
- `tests/json.test.ts` and `tests/transition.test.ts` characterize detached public results and rejected mutable drafts, prototype-named merge isolation, signed zero and single-copy cold-data boundaries. Existing artifact replacement, failed publication, replay/fork and late-response tests remain applicable. The owned-draft COW differential/copy-work evidence in [performance](performance.md#memory-only-owned-draft-cow) is semantic/alias evidence, not a persistence-format or end-to-end speed claim.
|
|
42
47
|
- `tests/context.test.ts` and `tests/extension.test.ts` prohibit process queries during ordinary context/history reads. `tests/transition.test.ts` rejects stale staging even when semantic values coincide across different causal boundaries.
|
|
43
48
|
- `tests/status.test.ts` distinguishes selected temporal history depth from retained per-scope tails and unavailable materialization from an empty state.
|
|
44
|
-
- `tests/artifact.test.ts` and
|
|
45
|
-
- `tests/
|
|
46
|
-
- `tests/
|
|
47
|
-
-
|
|
48
|
-
- `tests/config.test.ts` covers optional agent configuration, path precedence/expansion, invalid input, load-time caching and read-only behavior. Session tests and native Pi distinguish configured new-session auto-start from branch-local resume/tree/stop. `tests/extension.test.ts` proves
|
|
49
|
-
|
|
50
|
-
## Fatal writer interruption
|
|
51
|
-
|
|
52
|
-
`tests/runtime.test.ts` — “fatal publisher interruption preserves selected history and fails closed” uses `tests/runtime-worker.ts` for four same/different-CWD × before/after-ref cases. A separate process first accepts a global/CWD/session cohort while session A retains an older seven-transition selection, then pauses its next real publication around `git update-ref`:
|
|
53
|
-
|
|
54
|
-
| Boundary | HEAD at termination | Caller-visible index |
|
|
55
|
-
| --- | --- | --- |
|
|
56
|
-
| Before ref CAS | Previous accepted peer commit; the attempted commit object already exists | Exact pre-attempt bytes |
|
|
57
|
-
| After successful ref CAS | New, unacknowledged peer commit | Still the pre-attempt bytes; synchronization was not reached |
|
|
58
|
-
|
|
59
|
-
The parent sends `SIGKILL` only to its owned, paused process group and requires actual closure with that signal and a gone PID. Both cases retain the publication locks; attempted writes and prepared/fresh restore installation fail closed without installing a partial runtime. Exact earlier commits, all 32 selected hot/cold projections, another session's private files, interrupted owned bytes/modes, unrelated worktree bytes and caller index survive. The attempted commit contains the complete non-ignored worktree delta and all three new scope values, but the interrupted call never returns success. Tests perform no lock clearing, automatic repair, ref reset or store checkout.
|
|
60
|
-
|
|
61
|
-
The pause is synchronous after previous Git subprocesses have exited. This is process-death evidence at those Git boundaries, not in-flight Git-child containment, file-only crash recovery, power-loss/fsync durability, native Pi trace interruption or Windows signal behavior; these four POSIX tests are skipped on Windows. Ordinary inference abort remains the [same-session preservation behavior](usage.md#session-behavior), not this fatal-publication scenario.
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
node --experimental-strip-types --test \
|
|
65
|
-
--test-name-pattern='fatal publisher interruption' tests/runtime.test.ts
|
|
66
|
-
```
|
|
49
|
+
- `tests/artifact.test.ts` and extension/native integration witnesses prove exact registered-path inspection, `size + mtimeNs` evidence, non-destructive unavailable/symlink handling, owning-scope removal, runtime-only changed-source hints, and stable-read acceptance without directory discovery. The native newly-adopted-artifact witness proves run preparation refreshes live shared state before proven-missing maintenance and the first inference. Artifact/acquisition/rehydration tests and “real Pi ordinary artifact invalidations share the public fingerprint classifier” cover equal/changed/missing/malformed fingerprints, pre-epoch timestamps, compiler invalidation, detached read plans, legacy hash handling, and effective Skill masking while preserving Skill hashing.
|
|
50
|
+
- `tests/protocol.test.ts` checks runtime/Skill guidance names the reported artifact owner. Transition and native three-scope compilation witnesses reject wrong-scope output with an exact owning-scope target, preserve canonical bytes on failure, and accept stable recompilation without unrelated-scope writes; native reload retains the accepted provenance.
|
|
51
|
+
- `tests/transition.test.ts` rejects authored provenance fields and field deletions in every scope through both staging entrypoints, without requiring a preceding read; legacy semantic edits and whole-artifact deletion remain valid. The native “real Pi rejects no-read provenance forgery atomically and accepts a corrected model patch” witness proves whole-cohort rejection and recovery, while existing artifact/Skill tests preserve runtime-owned compilation evidence and legacy decoding.
|
|
52
|
+
- `tests/storage.test.ts` covers exact file-cohort references, file CAS/rollback, and shared writer exclusion. `tests/runtime.test.ts` and native Pi lifecycle tests cover retained-boundary restart, immediate barriers, finalized response, config-only stop, and unavailable-reference provenance. Canonical files supply current state and bounded hot history; arbitrary cold revision recovery is unsupported.
|
|
53
|
+
- `tests/runtime.test.ts` and native integration cover retained-boundary restoration and fork after lowering `historyLimit` to 0/1: current shared values/provenance and selected private state survive folding, parent-private fork files remain unchanged, out-of-window selections fail closed, and later increases do not reconstruct discarded history. `tests/config.test.ts` covers optional agent configuration, path precedence/expansion, invalid input, load-time caching and read-only behavior. Session tests and native Pi distinguish configured new-session auto-start from branch-local resume/tree/stop. `tests/extension.test.ts` proves registered artifacts are reconciled only at enabled inference boundaries. The global default is manual; CWD materialization alone no longer grants automatic activation.
|
|
67
54
|
|
|
68
55
|
## Validation and limits
|
|
69
56
|
|
|
@@ -71,4 +58,4 @@ Run `npm run validate` in the source checkout; the [SDK compatibility matrix](co
|
|
|
71
58
|
|
|
72
59
|
Benchmark contracts in `tests/benchmark.test.ts` and `tests/benchmark-session.test.ts` separately verify source-drift rejection, oversized terminal-report delivery with correct failure status, optional phase resources, immutable prefix counters, release after measurement failure, and isolated post-resume probes. Probes check selected model projection and exact delivery of the current native read content; workers that mutate baseline JSONL or repository files after reporting success are rejected. Native-read witnesses distinguish full UTF-8, byte-truncated and line-truncated output, retain source-versus-notice byte counts and release observers after success/failure. A rewritten model-facing read that becomes a faux assistant error must fail the native terminal check, not be counted as a successful run. These correctness tests impose no wall-time performance threshold. The [performance guide](performance.md) owns measurements and their limits.
|
|
73
60
|
|
|
74
|
-
Real-Pi tests use the actual Pi SDK and native tool loop with a deterministic faux model and temporary Git repositories. They do not prove that an unconstrained model always follows the memory protocol, nor do they
|
|
61
|
+
Real-Pi tests use the actual Pi SDK and native tool loop with a deterministic faux model and temporary Git repositories. They do not prove that an unconstrained model always follows the memory protocol, nor do they inspect/repair production stores or publish the real repository. Complete native trace remains available; normal model projection retains only the required active context. Cooperative locking and conflict preservation are not kernel-atomic multi-file transactions against nonparticipating writers. Test counts do not establish exhaustive equivalence with every removed predecessor assertion.
|
|
@@ -8,19 +8,20 @@ For the concept and installation, start with the [README](../README.md). This gu
|
|
|
8
8
|
|
|
9
9
|
- **New session:** Passive durable memory is available by default without starting an episode. `autoStart` promotes genuinely new sessions into active State Flow; an active new session has its own empty session layer and inherits global/CWD state, never another session's private continuation.
|
|
10
10
|
- **Resume:** Restores the selected session's stored enablement, state, and lineage. Agent-level `autoStart` does not override a resumed branch.
|
|
11
|
-
- **Tree navigation:** Restores the selected
|
|
11
|
+
- **Tree navigation:** Restores the selected retained private boundary over live shared scopes without checking out or resetting the shared store.
|
|
12
12
|
- **Abort inference:** Stops generation while already accepted patches remain durable for continued work and corrected direction in the same session. It does not roll back memory or require immediate remote replication.
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
13
|
+
- **Native boundary continuation:** A companion may continue through Pi's `turn_end` or `agent_before_settle` boundary without a new user prompt. State Flow keeps projecting current memory and accepted response across those requests and subsequent patches; it does not restore the completed specification or request another turn itself.
|
|
14
|
+
- **Stop:** Ends active episode semantics and returns to the configured passive bootstrap/tool combination. For a proven pre-runtime branch, it records only the existing disabled checkpoint in Pi, without creating canonical files or publishing the passive view; later Start or passive patch remains available. For an accepted runtime, it adopts unrelated shared-state changes without semantic/provenance writes or step changes, while same-session conflicts still fail closed. Its frozen handoff uses the accepted view. It does not change passive or automatic-start policy.
|
|
15
|
+
- **Continue after Stop:** The same physical session retains a frozen state handoff, any interrupted current request and tool trajectory (including late results), and post-stop conversation. A proven active boundary excludes completed earlier conversation; when native split-turn compaction removed the original request anchor, Stop instead preserves the available summary and tools without reconstructing discarded raw input. Other extensions' custom context survives. Idle Stop still retains only later conversation plus foreign custom context. Reload/resume/tree preserve this projection; new/forked physical sessions do not inherit it. Mid-tool Start and repeated Start/Stop retain the first user event already observed while disabled, so subsequent Stop does not mistake that busy run for idle. Active restart uses the retained projection for one bootstrap run.
|
|
16
|
+
- **Completed-history compaction:** After an accepted run settles without queued input, State Flow asks Pi for a native compaction boundary only when public context usage reaches 24,000 tokens. No extra model summary is requested; Pi keeps the complete latest run—from its original request through steering, tools, foreign context and final answer—in active history and retains the complete append-only JSONL/tree. State Flow uses the native first-user anchor, independent of image-normalization hints or later steering; images and earlier tool results remain available to the model. Uncertain projection retains available context without changing that anchor. A missing or ambiguous native anchor skips compaction instead of choosing the last steering message. On resume, native `buildContextEntries()` and TUI rendering omit the older completed prefix. Unknown or smaller usage skips the request, and custom Pi retention settings may still decline it benignly. Foreign custom context in the removed prefix, bootstrap/abort/error, Stop and pending input prevent State Flow-owned shortening; ordinary manual/threshold/overflow compaction remains native and may preserve unfinished work not yet patched into memory.
|
|
16
17
|
|
|
17
18
|
State Flow does not undo tool effects. After interruption or returning to an older branch, check the relevant workspace or external system before repeating consequential operations. Restored memory is not restored reality.
|
|
18
19
|
|
|
19
20
|
### Fork support and limits
|
|
20
21
|
|
|
21
|
-
Native fork replacement copies the source session checkpoint, retained patch tail and matching provenance into the new session's own storage. Global/CWD
|
|
22
|
+
Native fork replacement copies the source session checkpoint, retained patch tail and matching provenance into the new session's own storage. Global/CWD values and provenance stay current; applying a smaller `historyLimit` may fold shared tails under CAS. An earlier fork selection copies that point's private state, not the parent's later private work. Parent-private data/history remain intact; selected enablement is retained, so a stopped source does not become enabled automatically.
|
|
22
23
|
|
|
23
|
-
The child starts at step zero and a new temporal origin. Its copied tail
|
|
24
|
+
The child starts at step zero and a new temporal origin. Its copied tail obeys the configured retention limit, but pre-origin records are not additional aligned causal boundaries addressable through `effective[n]` or scoped paths. The child's own transitions build its hot window; owned checkpoints support normal reload/resume. Parent Stop projection is not inherited, including after child reload.
|
|
24
25
|
|
|
25
26
|
Initial copying requires a native fork start event, a regular canonical direct-parent session file, matching CWD/identity, a readable temporal source and an unused child namespace. Missing/unsafe evidence or CAS conflicts leave the copy unavailable rather than importing unrelated or newer private state. Explicit Start can retry an unaccepted copy in the same loaded fork after the cause is corrected.
|
|
26
27
|
|
|
@@ -37,25 +38,25 @@ Optional global `config.json` at the root of the State Flow repository, normally
|
|
|
37
38
|
"passiveTools": true,
|
|
38
39
|
"logging": false,
|
|
39
40
|
"showSuccessfulPatches": true,
|
|
40
|
-
"
|
|
41
|
+
"historyLimit": 7
|
|
41
42
|
}
|
|
42
43
|
```
|
|
43
44
|
|
|
44
45
|
The canonical store is `state-flow/` beneath the agent directory. Keeping configuration inside that repository removes the separate agent-level `state-flow.json`; SDK embeddings may still provide an explicit repository override.
|
|
45
46
|
- `autoStart`: Defaults to `false`. When `true`, genuinely new sessions use the same initialization as explicit Start, including fresh CWDs.
|
|
46
|
-
- `passiveBootstrap`: Defaults to `true`. Projects existing effective durable memory into ordinary model context without creating scopes,
|
|
47
|
-
- `passiveTools`: Defaults to `true`. Exposes `read_state` and `patch_state` outside active episodes. Reads remain side-effect free; the first explicit patch may initialize
|
|
48
|
-
- `logging`: Defaults to `false`. When enabled, records rejected patches and
|
|
49
|
-
- `showSuccessfulPatches`: Defaults to `true`. In interactive Pi, successful `patch_state` rows show only the applied pretty-printed JSON arguments, with blank lines between adjacent memory sections; set it to `false` to keep only the compact summary. Rejected calls still use ordinary error rendering
|
|
50
|
-
- `
|
|
47
|
+
- `passiveBootstrap`: Defaults to `true`. Projects existing effective durable memory into ordinary model context without creating scopes, publishing, or starting an episode.
|
|
48
|
+
- `passiveTools`: Defaults to `true`. Exposes `read_state` and `patch_state` outside active episodes. Reads remain side-effect free; the first explicit patch may initialize absent canonical storage but never converts predecessor formats or enables an episode or State Flow compaction.
|
|
49
|
+
- `logging`: Defaults to `false`. When enabled, records rejected patches and accepted-answer reconciliation failures locally at `tmp/state-flow/logs.jsonl` beneath the agent directory.
|
|
50
|
+
- `showSuccessfulPatches`: Defaults to `true`. In interactive Pi, successful `patch_state` rows show only the applied pretty-printed JSON arguments, with blank lines between adjacent memory sections; set it to `false` to keep only the compact summary. Rejected calls still use ordinary error rendering; State Flow adds no private validation turn.
|
|
51
|
+
- `historyLimit`: Defaults to `7` and accepts integers from `0` through `100`. It bounds materialized-history and scope patch-history offsets. Lowering it on reload/restore/fork folds excess tails forward without losing current state; selected boundaries outside the new window are unavailable. Zero retains only current checkpoints. Raising the limit affects only future retention and cannot reconstruct discarded history.
|
|
51
52
|
|
|
52
53
|
Settings are read once at extension load. After editing, use `/reload` or restart Pi. A missing file uses defaults without creating a configuration file; malformed JSON, unknown keys, or invalid values fail loading rather than silently selecting another store.
|
|
53
54
|
|
|
54
|
-
`PI_CODING_AGENT_DIR` changes both the default State Flow repository and its global configuration location.
|
|
55
|
+
`PI_CODING_AGENT_DIR` changes both the default State Flow repository and its global configuration location. State Flow has no source-directory or Knowledge-root configuration. SDK repository overrides are documented under [embedding](architecture.md#embedding); an overridden repository owns its own root `config.json`.
|
|
55
56
|
|
|
56
57
|
### Diagnostic logging and privacy
|
|
57
58
|
|
|
58
|
-
Rejected-call records may contain exact attempted arguments and useful draft text, plus the error
|
|
59
|
+
Rejected-call records may contain exact attempted arguments and useful draft text, plus the error category and tool/call identity. Successful patches are not logged; reasoning bodies are excluded. Logs are not semantic state, scope metadata, Pi checkpoints, or publication input. If the log path overlaps a custom state repository, capture fails closed instead of committing it. A logging failure changes no accepted state and produces at most one local warning.
|
|
59
60
|
|
|
60
61
|
Logs remain local unless you move them; rotation/deletion is operator-owned. Treat them and state files as private. Removing a secret from current state does not erase older offsets, Git history, native sessions, or remote copies.
|
|
61
62
|
|
|
@@ -63,85 +64,60 @@ Logs remain local unless you move them; rotation/deletion is operator-owned. Tre
|
|
|
63
64
|
|
|
64
65
|
`/state-flow-status` separates runtime configuration/metadata from semantic state. It reports:
|
|
65
66
|
|
|
66
|
-
- Selected CWD/session keys, step, temporal head,
|
|
67
|
+
- Selected CWD/session keys, step, temporal head, recovery failures, and available hot history.
|
|
67
68
|
- Per-scope retained patch tails and artifact counts, plus one JSON representation of effective global → CWD → session memory. Individual scope JSON is available through `read_state`, not duplicated in status.
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
- Memory-bearing scopes and external-promotion records, including invalid or incompletely evidenced acceptance.
|
|
69
|
+
- Already-known runtime hints or pending artifact invalidations; status does not discover or validate sources.
|
|
70
|
+
- Memory-bearing scopes. Promotion-shaped values receive no special interpretation.
|
|
71
71
|
|
|
72
|
-
Tail counts are not history depth: inherited records may predate the active origin. Failed inspection reports unavailable evidence, not invented empty state
|
|
72
|
+
Tail counts are not history depth: inherited records may predate the active origin. Failed inspection reports unavailable evidence, not invented empty state. Status is observational: it does not read source files, calculate fingerprints, create invalidations, or mutate semantic state.
|
|
73
73
|
|
|
74
|
-
The terminal indicator is `state-flow #N`. When `pi-telegram` is available, one main-menu section carries the live State Flow status and opens Start/Stop controls. Start requested during a run waits for settlement; Stop currently applies immediately. The adapter is optional and the Pi commands remain available without it.
|
|
74
|
+
The terminal indicator is `state-flow #N`. When `pi-telegram` is available, one main-menu section carries the live State Flow status and opens Start/Stop controls. Start requested during a run waits for settlement; Stop currently applies immediately. The adapter is optional and the Pi commands remain available without it. Open implementation work is tracked in [BACKLOG.md](../BACKLOG.md).
|
|
75
75
|
|
|
76
76
|
## Storage and recovery
|
|
77
77
|
|
|
78
|
-
Use a dedicated directory. State storage and
|
|
78
|
+
Use a dedicated directory. State storage and registered artifact sources have separate responsibilities:
|
|
79
79
|
|
|
80
80
|
```text
|
|
81
81
|
<agentDir>/state-flow/ global config, accepted state, and runtime metadata
|
|
82
|
-
<
|
|
82
|
+
<any exact registered path> optional external source owned outside State Flow
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
Each scope materializes an anchored semantic-only `checkpoint.json` plus semantic-only lines in `patches.jsonl`. Scope `meta.json` holds temporal boundaries, CWD ownership where applicable, and runtime-owned artifact evidence. The session additionally uses `config.json` for behavior and `runtime.json` for branch/run recovery metadata; a full prompt is retained there only while its run is unfinished. CWD/session directories mirror Pi's native naming while validating canonical identities separately. See the [storage contract](architecture.md#storage-and-identity) for the exact layout.
|
|
86
86
|
|
|
87
87
|
### Missing, partial, and malformed storage
|
|
88
88
|
|
|
89
|
-
A checkpoint and tail are one semantic pair. If both live files for an untouched global or CWD scope disappear, State Flow treats that complete absence as current empty shared reality during the next accepted publication. It creates a fresh canonical pair through
|
|
89
|
+
A checkpoint and tail are one semantic pair. If both live files for an untouched global or CWD scope disappear, State Flow treats that complete absence as current empty shared reality during the next accepted publication. It creates a fresh canonical pair through normal file-cohort exclusion and CAS; no cold Git value is resurrected. A patch targeting the disappeared scope is rejected once as stale so a later inference can work from the actual empty basis.
|
|
90
90
|
|
|
91
|
-
Exactly one surviving pair member is corruption and fails closed. Present malformed JSON, incomplete predecessor envelopes, semantic/metadata boundary mismatches, identity contradictions, and partial session runtime evidence also remain fail-closed and are not replaced. A
|
|
91
|
+
Exactly one surviving pair member is corruption and fails closed. Present malformed JSON, incomplete predecessor envelopes, semantic/metadata boundary mismatches, identity contradictions, and partial session runtime evidence also remain fail-closed and are not replaced. A missing or expired private retained boundary is unavailable; State Flow does not substitute Git history or newer private files.
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
After a selected-boundary failure, configured passive access may still expose current global/CWD memory, but it never grants access to the unavailable session layer or permission to publish an empty replacement. Session reads, every `patch_state`, and Stop refuse without changing canonical files or appending substitute checkpoints. Status retains the restoration error even when shared reads work. Start retries the original selection; repair its missing or invalid evidence, select a still-retained boundary, or use a genuinely new Pi session instead of forcing a reset.
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
Missing artifact provenance inside an otherwise complete scope `meta.json` means compilation evidence is unavailable while semantic state remains usable; removing the whole metadata file also removes temporal authority and fails closed. An unavailable registered source path does not prove that durable artifact routing was deleted, and external files are never created. State Flow has no durable push queue or publication-worker lease. See the complete [filesystem recovery contract](filesystem-recovery.md).
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
### Canonical files and optional Git backup
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
Canonical scope/runtime files own current materialization and retained hot history regardless of Git availability. Pi checkpoints identify a retained semantic boundary, not a Git commit or arbitrary historical snapshot. Restart and branch restoration fail closed when the selected boundary has expired rather than substituting newer files as the selected past.
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
After an accepted turn has reconciled its response, Pi 0.87's final actionable `agent_before_settle` boundary may create one best-effort backup commit when Git is available. Backup failure is diagnostic-only. Git availability never changes semantic authority, step, or retained lineage.
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
### Moving a store and the 0.17 format boundary
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
An SDK `repositoryRoot` override or a different `PI_CODING_AGENT_DIR` selects a location; it does not relocate existing state or retained history. Copy the complete canonical store while all writers are quiescent, or use a genuinely new Pi session for an independent store. Copying only current checkpoints without their tails and metadata cannot preserve retained boundaries.
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
git -C ~/.pi/agent/state-flow status --short
|
|
109
|
-
git -C ~/.pi/agent/state-flow log --oneline -10
|
|
110
|
-
git -C ~/.pi/agent/state-flow show <selected-revision>:checkpoint.json
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
Use the revision reported for the selected Pi branch. Shared live files may belong to a newer branch, so `HEAD` is not automatically that branch's memory.
|
|
114
|
-
|
|
115
|
-
### Without Git
|
|
116
|
-
|
|
117
|
-
Only an absent Git executable selects file-only mode; Git corruption, permission errors, and command failures remain errors. Files retain current materialization and its proven hot history. Their `file:<hash>` checkpoint reference identifies one exact current cohort, not an arbitrary historical snapshot.
|
|
118
|
-
|
|
119
|
-
Restart can restore that reference while its complete cohort remains available. An older branch or a crash between file publication and Pi checkpoint append can leave a reference unavailable even though newer files exist. State Flow must not pass those newer files off as the selected past. Preserve the store and diagnose the reference rather than resetting it.
|
|
120
|
-
|
|
121
|
-
If Git becomes available later, explicit Start can adopt the proven current file cohort. It preserves state, step, and hot lineage; Git cold history begins at adoption rather than inventing earlier commits.
|
|
122
|
-
|
|
123
|
-
### Moving or migrating a store
|
|
124
|
-
|
|
125
|
-
Changing `directory` selects a location; it does not relocate existing state or history. Git-backed Pi checkpoints require their original commit objects. Copying only current checkpoint/tail files cannot preserve old branch recovery. Keep the original store intact until an explicit history-preserving relocation is complete, or use a genuinely new Pi session for an independent store.
|
|
126
|
-
|
|
127
|
-
The only supported in-store migration converts complete predecessor checkpoint/tail envelopes into semantic-only files plus temporal `meta.json`. `state.json`, pre-0.4 hashed layouts, and semantic Pi checkpoint envelopes are unsupported and fail closed; manually renaming files is not a valid conversion.
|
|
128
|
-
|
|
129
|
-
Pre-0.4 hashed-path layouts remain readable at their historical revisions and can be adopted into native paths at current HEAD. A missing revision or failed restoration is not permission to import another session or reset existing files.
|
|
107
|
+
State Flow 0.17 accepts only its canonical checkpoint/tail, temporal metadata, and separate session config/runtime contract. Predecessor checkpoint envelopes, combined session metadata, pre-intents checkpoints, `state.json`, hashed layouts, and semantic Pi checkpoint envelopes fail as unsupported without rewriting existing bytes. State Flow does not provide an in-place converter; external conversion or a fresh store is operator-owned.
|
|
130
108
|
|
|
131
109
|
### Conflicts and interrupted publication
|
|
132
110
|
|
|
133
|
-
Cooperating writers use
|
|
134
|
-
|
|
135
|
-
Fatal process termination during local Git publication can leave attempted worktree files, a private index and publication locks. HEAD may or may not have advanced; a new commit need not have returned success or reached a Pi checkpoint. The [fatal-writer witnesses](temporal-acceptance.md#fatal-writer-interruption) preserve earlier accepted revisions and read-only inspection while new writes and live restore installation remain blocked. A dead PID alone does not establish which effects completed or whether Git children stopped. Before any repair, quiesce all store writers and preserve the complete store, Git/index data and selected Pi references; reconcile the exact interrupted attempt before clearing ownership. No automatic crash repair or power-loss durability is promised.
|
|
111
|
+
Cooperating canonical writers use file-cohort exclusion, exact prepared bytes, and compare-and-swap checks. These are not kernel-atomic multi-file transactions against nonparticipating writers. A busy writer lock fails before writes and is not silently stolen; reconcile the active or interrupted owner before retrying. Do not delete locks or state directories merely because an operation is slow.
|
|
136
112
|
|
|
137
|
-
|
|
113
|
+
Fatal process termination can leave an incomplete canonical file cohort. Before repair, quiesce all store writers and preserve the complete store plus selected Pi retained-boundary references. Reconcile exact files against the last complete checkpoint/tail/metadata cohort; no automatic crash repair or power-loss durability is promised. Git backup has no semantic recovery authority.
|
|
138
114
|
|
|
139
|
-
An untouched shared scope may be adopted from newer proven live state at a fresh origin. A patch that actually changes an advanced shared scope fails with a named conflict instead of silently overwriting it. Rollback restores only bytes still matching that publisher's output and preserves detected external changes. See [performance evidence](performance.md) for measured contention and the [acceptance map](temporal-acceptance.md) for the tested boundaries; the [backlog](../BACKLOG.md) owns
|
|
115
|
+
An untouched shared scope may be adopted from newer proven live state at a fresh origin. A patch that actually changes an advanced shared scope fails with a named conflict instead of silently overwriting it. Rollback restores only bytes still matching that publisher's output and preserves detected external changes. See [performance evidence](performance.md) for measured contention and the [acceptance map](temporal-acceptance.md) for the tested boundaries; the [backlog](../BACKLOG.md) owns open implementation work.
|
|
140
116
|
|
|
141
117
|
## Memory and source acquisition
|
|
142
118
|
|
|
143
119
|
The agent should use sufficient materialized knowledge before rereading files. Read for a concrete gap, exact-source/edit operation, evidenced invalidation, contradiction/failure, explicit request, or bounded maintenance—not simply because a new session began.
|
|
144
120
|
|
|
145
|
-
|
|
121
|
+
Artifact maintenance inspects only exact paths already registered in global, CWD, or session state, using `size + mtimeNs` without directory traversal or generic content hashing. Proven-missing paths are pruned from their exact owning scopes; unavailable, relative, directory, and symlink paths are preserved. Changed sources keep their artifact value and receive a runtime-only model `hint` until a stable read and same-path compilation updates hidden provenance. Skill reads retain their separate CWD compilation protocol. Model patches cannot author or delete runtime provenance or hints.
|
|
146
122
|
|
|
147
|
-
The packaged `state-flow-guide` Skill answers concrete operational questions about reads, patches, inheritance, acquisition,
|
|
123
|
+
The packaged `state-flow-guide` Skill answers concrete operational questions about reads, patches, inheritance, acquisition, completion, and recovery without initiating cleanup. The separate `state-flow-memory` Skill handles explicitly requested bounded curation and externally verified transfers. Feature/release/project boundaries may motivate recommending cleanup, not starting an audit. Ordinary handoffs reconcile touched state; neither Skill is a background maintenance loop. External transfers use the destination's native receipt and preserve the source whenever acceptance is uncertain. Artifact/compiler details and model-tool contracts belong in the [architecture](architecture.md#artifact-routing).
|
|
@@ -8,7 +8,7 @@ export {
|
|
|
8
8
|
type SuccessfulArtifactRead
|
|
9
9
|
} from "./lib/acquisition.ts";
|
|
10
10
|
export {
|
|
11
|
-
|
|
11
|
+
classifyArtifactCompilationNeed,
|
|
12
12
|
compileArtifact,
|
|
13
13
|
hashArtifactSource,
|
|
14
14
|
isArtifactHash,
|
|
@@ -16,7 +16,6 @@ export {
|
|
|
16
16
|
isArtifactRegistry,
|
|
17
17
|
ORDINARY_ARTIFACT_COMPILER,
|
|
18
18
|
parseArtifactProvenanceRegistry,
|
|
19
|
-
planArtifactInvalidation,
|
|
20
19
|
projectArtifactForModel,
|
|
21
20
|
projectArtifactsForModel,
|
|
22
21
|
pruneArtifactProvenance,
|
|
@@ -28,10 +27,8 @@ export {
|
|
|
28
27
|
validateArtifactRegistry,
|
|
29
28
|
type ArtifactCompilationUpdate,
|
|
30
29
|
type ArtifactCompilerOutput,
|
|
31
|
-
type
|
|
30
|
+
type ArtifactCompilationNeed,
|
|
32
31
|
type ArtifactInvalidationNotice,
|
|
33
|
-
type ArtifactInvalidationOptions,
|
|
34
|
-
type ArtifactInvalidationPlan,
|
|
35
32
|
type ArtifactInvalidationReason,
|
|
36
33
|
type ArtifactInvalidationRequest,
|
|
37
34
|
type ArtifactMetadata,
|
|
@@ -60,13 +57,6 @@ export {
|
|
|
60
57
|
type ContinuationTransport,
|
|
61
58
|
type NativeSessionHeader
|
|
62
59
|
} from "./lib/continuation.ts";
|
|
63
|
-
export {
|
|
64
|
-
discoverGlobalMarkdownSources,
|
|
65
|
-
getKnowledgeRoot,
|
|
66
|
-
GlobalMarkdownDiscovery,
|
|
67
|
-
type ArtifactSourceCandidate,
|
|
68
|
-
type GlobalMarkdownDiscoveryResult
|
|
69
|
-
} from "./lib/discovery.ts";
|
|
70
60
|
export {
|
|
71
61
|
captureTemporalFileBases,
|
|
72
62
|
cwdScopeKey,
|
|
@@ -80,21 +70,13 @@ export {
|
|
|
80
70
|
sessionStorageKey, temporalScopePaths,
|
|
81
71
|
temporalStateFileUpdates, type ScopeStreamSources, type TemporalScopePaths
|
|
82
72
|
} from "./lib/durable.ts";
|
|
83
|
-
export { default,
|
|
84
|
-
export {
|
|
85
|
-
captureTemporalGitBase,
|
|
86
|
-
isGitCommitAncestor,
|
|
87
|
-
loadTemporalRevision,
|
|
88
|
-
migrateLegacyStorageToGit,
|
|
89
|
-
publishTemporalStateToGit,
|
|
90
|
-
pushGitCommit,
|
|
91
|
-
resolveGitPushDestination, type GitPushResult, type TemporalGitBase,
|
|
92
|
-
type TemporalRevisionLoad
|
|
93
|
-
} from "./lib/git.ts";
|
|
73
|
+
export { default, PATCH_STATE_TOOL_NAME, READ_STATE_TOOL_NAME, type StateFlowExtensionOptions } from "./lib/extension.ts";
|
|
74
|
+
export { backupCurrentStateFlowFiles } from "./lib/git.ts";
|
|
94
75
|
export {
|
|
95
76
|
createAcceptedTransition,
|
|
77
|
+
DEFAULT_HISTORY_LIMIT,
|
|
78
|
+
MAX_HISTORY_LIMIT,
|
|
96
79
|
projectRecentTransitionsWithLimit,
|
|
97
|
-
RECENT_TRANSITION_LIMIT,
|
|
98
80
|
validateRecentTransition, type AcceptedTransition, type RecentScopePatch,
|
|
99
81
|
type RecentTransition,
|
|
100
82
|
type RecentTransitionWindow
|
|
@@ -109,52 +91,7 @@ export {
|
|
|
109
91
|
type StateFlowDiagnosticCategory,
|
|
110
92
|
type StateFlowDiagnosticRecord
|
|
111
93
|
} from "./lib/logging.ts";
|
|
112
|
-
export {
|
|
113
|
-
DEFAULT_ARTIFACT_MAINTENANCE_MAX_READS,
|
|
114
|
-
DEFAULT_ARTIFACT_MAINTENANCE_MAX_SOURCE_BYTES,
|
|
115
|
-
DEFAULT_ARTIFACT_MAINTENANCE_MINIMUM_AGE_MS,
|
|
116
|
-
planArtifactMaintenance,
|
|
117
|
-
type ArtifactMaintenanceOptions,
|
|
118
|
-
type ArtifactMaintenancePlan,
|
|
119
|
-
type ArtifactMaintenanceRequest
|
|
120
|
-
} from "./lib/maintenance.ts";
|
|
121
|
-
export {
|
|
122
|
-
inspectMemoryPromotions, MEMORY_PROMOTION_STATUSES, MEMORY_PROMOTIONS_KEY, retainedMemoryScopes,
|
|
123
|
-
type MemoryPromotionDiagnostic,
|
|
124
|
-
type MemoryPromotionStatus
|
|
125
|
-
} from "./lib/memory.ts";
|
|
126
|
-
export {
|
|
127
|
-
acquirePublicationWorkerLease,
|
|
128
|
-
beginPublicationAttempt,
|
|
129
|
-
coalescePublicationTarget,
|
|
130
|
-
confirmPublicationTarget,
|
|
131
|
-
createPublicationQueue,
|
|
132
|
-
failPublicationAttempt,
|
|
133
|
-
loadPublicationQueue,
|
|
134
|
-
parsePublicationQueue,
|
|
135
|
-
parseRemotePublicationPolicyDocument,
|
|
136
|
-
publicationQueuePath,
|
|
137
|
-
recoverPublicationQueue,
|
|
138
|
-
remotePublicationDestinationKey,
|
|
139
|
-
removePublicationQueue,
|
|
140
|
-
resolveRemotePublicationPolicy,
|
|
141
|
-
runPublicationWorker,
|
|
142
|
-
savePublicationQueue,
|
|
143
|
-
serializePublicationQueue,
|
|
144
|
-
serializeRemotePublicationPolicyDocument,
|
|
145
|
-
validatePublicationQueue,
|
|
146
|
-
type CommitAncestor,
|
|
147
|
-
type PublicationPush,
|
|
148
|
-
type PublicationQueueReceipt,
|
|
149
|
-
type PublicationQueueState,
|
|
150
|
-
type PublicationQueueStatus,
|
|
151
|
-
type PublicationWorkerLease,
|
|
152
|
-
type PublicationWorkerResult,
|
|
153
|
-
type RemotePublicationDestination,
|
|
154
|
-
type RemotePublicationMode,
|
|
155
|
-
type RemotePublicationPolicy,
|
|
156
|
-
type RemotePublicationPolicyDocument
|
|
157
|
-
} from "./lib/publication.ts";
|
|
94
|
+
export { retainedMemoryScopes } from "./lib/memory.ts";
|
|
158
95
|
export {
|
|
159
96
|
planKnowledgeRehydration,
|
|
160
97
|
type RehydrationOptions,
|
|
@@ -167,7 +104,6 @@ export { TemporalRuntime } from "./lib/runtime.ts";
|
|
|
167
104
|
export {
|
|
168
105
|
hasCompiledSkillArtifact,
|
|
169
106
|
hashSkillSource,
|
|
170
|
-
migrateLegacySkillCompilations,
|
|
171
107
|
SKILL_ARTIFACT_COMPILER,
|
|
172
108
|
type SuccessfulSkillRead
|
|
173
109
|
} from "./lib/skills.ts";
|