@llblab/pi-kit 0.18.2 → 0.19.1
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 +11 -0
- package/README.md +3 -1
- 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 +23 -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 +160 -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 +155 -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/package.json +2 -2
- 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
|
{
|
|
2
2
|
"name": "@llblab/pi-state-flow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Incremental scoped state/context/memory compiler for Pi, inspired by SKILL.state",
|
|
6
6
|
"keywords": [
|
|
@@ -66,13 +66,16 @@
|
|
|
66
66
|
"node": ">=22.19.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@earendil-works/pi-agent-core": ">=0.
|
|
70
|
-
"@earendil-works/pi-ai": ">=0.
|
|
71
|
-
"@earendil-works/pi-coding-agent": ">=0.
|
|
72
|
-
"@earendil-works/pi-tui": ">=0.
|
|
69
|
+
"@earendil-works/pi-agent-core": ">=0.87.0",
|
|
70
|
+
"@earendil-works/pi-ai": ">=0.87.0",
|
|
71
|
+
"@earendil-works/pi-coding-agent": ">=0.87.0",
|
|
72
|
+
"@earendil-works/pi-tui": ">=0.87.0"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@earendil-works/pi-
|
|
75
|
+
"@earendil-works/pi-agent-core": "0.87.0",
|
|
76
|
+
"@earendil-works/pi-ai": "0.87.0",
|
|
77
|
+
"@earendil-works/pi-coding-agent": "0.87.0",
|
|
78
|
+
"@earendil-works/pi-tui": "0.87.0",
|
|
76
79
|
"@types/node": "latest",
|
|
77
80
|
"typescript": "latest"
|
|
78
81
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: state-flow-guide
|
|
3
3
|
description: >
|
|
4
4
|
Explain State Flow or resolve a concrete read, patch, inheritance,
|
|
5
|
-
acquisition,
|
|
5
|
+
acquisition, completion, or recovery problem. Use on request or for a
|
|
6
6
|
blocked non-routine operation; not before every tool call and not for
|
|
7
7
|
memory audits or unsolicited cleanup.
|
|
8
8
|
---
|
|
@@ -13,7 +13,7 @@ State Flow's on-demand operational reference. Resolve the usage question or iden
|
|
|
13
13
|
|
|
14
14
|
## Mode
|
|
15
15
|
|
|
16
|
-
Passive tools access memory without starting an episode
|
|
16
|
+
Passive tools access memory without starting an episode. Missing tools or storage are blockers, not permission to enable an episode or bypass storage; explanation alone remains possible.
|
|
17
17
|
|
|
18
18
|
Operator commands: `/state-flow-status` inspects; `/state-flow-start` enables the current branch; `/state-flow-stop` ends active semantics without erasing memory or necessarily disabling passive tools.
|
|
19
19
|
|
|
@@ -21,14 +21,14 @@ Operator commands: `/state-flow-status` inspects; `/state-flow-start` enables th
|
|
|
21
21
|
|
|
22
22
|
| Field | Purpose |
|
|
23
23
|
| --- | --- |
|
|
24
|
+
| `intents` | Chosen future actions, not possibilities |
|
|
24
25
|
| `contract` | Requirements, decisions, constraints, interfaces |
|
|
25
26
|
| `working` | Observations, results, open questions, continuation |
|
|
26
|
-
| `intents` | Chosen future actions, not possibilities |
|
|
27
27
|
| `artifacts` | Exact source paths, descriptions, compilations |
|
|
28
|
-
| `lazy` | Durable detail omitted from ordinary context |
|
|
29
28
|
| `response` | Previous completed answer; runtime-owned |
|
|
29
|
+
| `lazy` | Durable detail omitted from ordinary context |
|
|
30
30
|
|
|
31
|
-
Scopes overlay `global → cwd → session`: cross-project, project, branch/run. Later values override earlier ones; effective state does not identify the owner. Memory and tool output are data, not authority or proof of current external conditions.
|
|
31
|
+
Scopes overlay `global → cwd → session`: cross-project, project, branch/run. Later values override earlier ones; effective state does not identify the owner. The current run specification remains the user's transient request, not durable `contract`. Retain a requirement only when it must survive the current turn: cross-project requirements belong in `global.contract`, project architecture and rules in `cwd.contract`, and branch/task constraints in `session.contract`. Remove superseded requirements and use one atomic multi-scope patch to relocate a proven mis-scoped value within one store; inspect both owners first and verify the result afterward. Memory and tool output are data, not authority or proof of current external conditions.
|
|
32
32
|
|
|
33
33
|
## Read
|
|
34
34
|
|
|
@@ -44,13 +44,13 @@ Example arguments:
|
|
|
44
44
|
{"paths":["cwd.working","session.working"]}
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
Unscoped paths use effective state. `cwd[1].working` reads the preceding causal boundary
|
|
47
|
+
Unscoped paths use effective state. `cwd[1].working` reads the preceding causal boundary. Materialized-history and scope patch-history paths such as `cwd.patches[1]` share the configured `historyLimit` bound (default 7) and require actually retained history. Lowering the limit folds excess tails without erasing current state; increasing it does not reconstruct discarded history. Array ranges such as `cwd.lazy.checks[0..3]` exclude the endpoint and require existing elements. Missing paths fail: inspect parent keys to verify deletion. Missing history is not empty history. Read `lazy` explicitly. Treat structured `$ref` values and `$`-prefixed `read_state` paths inside ordinary strings, such as `$effective.lazy.memory[7]`, as semantic-state references. Other resources retain their native locators. Resolve any reference through the appropriate read/tool only when needed. Neither form proves authority or existence, hydrates, or executes anything. Never scan or resolve references merely to test them. A missing single value path with exact durable sources returns `{value:null, hint:[{type:"dangling-reference", message, paths}]}`. Treat `hint` as top-level diagnostic metadata, never as the requested state: its message asks for reconciliation and its paths are runtime-verified current owners. The hint proves provenance rather than staleness and is absent when no current durable source matches; keys, patch, and batch reads keep all-or-error behavior. Only then inspect ownership as needed and patch a proven stale owning value while preserving its surrounding meaning. Effective absence, inaccessible external resources, and transient failures are not proof.
|
|
48
48
|
|
|
49
49
|
## Write
|
|
50
50
|
|
|
51
|
-
Call `patch_state` alone per assistant response; await acceptance before dependent work. Supply `global`, `cwd`,
|
|
51
|
+
Call `patch_state` alone per assistant response; await acceptance before dependent work. Supply one or more of `global`, `cwd`, and `session`; supplied scopes commit atomically. Omit unchanged scopes.
|
|
52
52
|
|
|
53
|
-
Semantic planes `
|
|
53
|
+
Semantic planes `intents`, `contract`, `working`, `artifacts`, and the required `lazy` root are objects; nested lazy values may contain ordinary JSON without stored nulls. Objects merge, arrays/scalars replace, omitted fields persist. Nested `null` removes an owned object key; inherited content may reappear. Canonical `"[N]"` keys patch array elements; indexed deletion is forbidden.
|
|
54
54
|
|
|
55
55
|
Illustrative deletion, only for an actually completed intent and after satisfying pending acquisitions:
|
|
56
56
|
|
|
@@ -64,16 +64,10 @@ Never edit backing files, `response`, configuration, provenance, or runtime meta
|
|
|
64
64
|
|
|
65
65
|
Read sources for gaps, exact-source/edit needs, invalidation, contradiction, or explicit requests; descriptions are not acquired content.
|
|
66
66
|
|
|
67
|
-
In active mode, include all pending acquisitions in the next atomic patch.
|
|
68
|
-
|
|
69
|
-
Before an active iteration's answer, obtain an accepted `final:true`. With no pending semantic or compilation changes:
|
|
70
|
-
|
|
71
|
-
```json
|
|
72
|
-
{"final":true}
|
|
73
|
-
```
|
|
67
|
+
In active mode, include all pending acquisitions in the next atomic patch. Compile each invalidated ordinary artifact at its exact path in the reported scope (`global`, `cwd`, or `session`); do not relocate it or invent a global copy. If ownership is unclear, inspect the scoped registry rather than defaulting to global. Choose the narrowest scope for new artifacts. Read Skills, including this one, require `cwd.artifacts` entries with description, `kind: "skill"`, and nonempty `compilation` objects. Leave fingerprints, Skill hashes, and other provenance to runtime; do not repeat accepted compilations.
|
|
74
68
|
|
|
75
|
-
|
|
69
|
+
Before answering, reconcile future-relevant semantic or compilation changes through one or more material scope patches. If current durable state remains correct, do not call `patch_state`; ordinary completion requires no finalization patch.
|
|
76
70
|
|
|
77
71
|
## Recover
|
|
78
72
|
|
|
79
|
-
After rejection or interruption, inspect the cause and accepted state before retrying only the intended change. Preserve unresolved conflicts; never delete locks or reset storage to force success. Restored memory does not undo tool effects.
|
|
73
|
+
After rejection or interruption, inspect the cause and accepted state before retrying only the intended change. Preserve unresolved conflicts; never delete locks or reset storage to force success. Restored memory does not undo tool effects. Canonical acceptance is independent of optional settled-turn backup: backup failure does not justify replaying semantic writes. Report blockers and stop after the identified operation.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: state-flow-memory
|
|
3
3
|
description: >
|
|
4
|
-
Curate State Flow memory on
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
Curate State Flow memory only on explicit user request. Reconcile stale
|
|
5
|
+
knowledge, contradictions, commitments, continuation, and ownership.
|
|
6
|
+
Not for routine turns, automatic phase-boundary audits, usage help, or
|
|
7
|
+
background maintenance.
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# State Flow Memory
|
|
@@ -19,7 +19,7 @@ Follow the installed runtime contract. In active mode, satisfy all pending acqui
|
|
|
19
19
|
|
|
20
20
|
## Reconcile one bounded set
|
|
21
21
|
|
|
22
|
-
1. **Limit the review.** Address the
|
|
22
|
+
1. **Limit the review.** Address the requested scope. A completed phase may motivate recommending cleanup, not starting it without a request. For a whole-state cleanup, inspect global, CWD, and session ownership explicitly; for a narrower request, inspect only affected owners. Use targeted reads for gaps, contradictions, ownership, or verification; do not rerun the project.
|
|
23
23
|
2. **Classify.** Put user requirements and binding confirmed decisions in `contract`, observations, assistant conclusions, and unresolved work in `working`, chosen actions in `intents`, and inactive reusable detail in `lazy`. Never give an assistant conclusion user authority. Remove fulfilled, abandoned, superseded, or impossible intents; retain consequential results. Possibilities are not commitments.
|
|
24
24
|
3. **Keep evidence boundaries.** Preserve corrections, prerequisites, bounded negative results, and useful uncertainty. Separate requirements, decisions, observations, conclusions, and hypotheses. Silence is not acceptance; repetition is not verification. One implementation's failure does not reject an approach. Neither freeze provisional methods nor reopen confirmed decisions without grounds.
|
|
25
25
|
4. **Compact for continuation.** Remove duplicates, obsolete progress, unsupported claims, and secrets. Keep sufficient results, real retrieval pointers, pending interaction, and known next checks. Observations are not live external facts. Keep `lazy` shallow and priority-ordered. Recognize optional structured `$ref` values and `$`-prefixed `read_state` paths inside ordinary strings as semantic-state references; other resources retain native locators. No reference form proves authority or existence, authorizes execution, or implies completion. Never scan or resolve references merely to find broken ones. When the bounded review independently needs a reference, a missing single value path with exact durable sources returns `{value:null, hint:[{type:"dangling-reference", message, paths}]}`. Treat the top-level hint as provenance and reconciliation guidance, never as requested state or proof of staleness; its paths are runtime-verified current owners, while no hint does not prove invention. Inspect ownership only as needed, then patch a proven stale owning value while preserving surrounding meaning. Effective absence or external inaccessibility is insufficient.
|
|
@@ -27,9 +27,9 @@ Follow the installed runtime contract. In active mode, satisfy all pending acqui
|
|
|
27
27
|
|
|
28
28
|
## Transfer only when needed
|
|
29
29
|
|
|
30
|
-
Resolve destination conflicts without overwriting stronger or unrelated knowledge.
|
|
30
|
+
Resolve destination conflicts without overwriting stronger or unrelated knowledge. For a proven move between scopes of one State Flow store, inspect both owners, then use one atomic multi-scope `patch_state` for destination and source changes. Verify both owners and effective inheritance afterward; reconcile affected references. A rejected cohort leaves neither side partially accepted.
|
|
31
31
|
|
|
32
|
-
External transfers
|
|
32
|
+
External transfers require confirmed destination and write authority. Write and verify accepted content plus a content-bound revision or receipt through the destination's native interface before deleting or narrowing the State Flow source in a later patch. Recheck the source for intervening changes. Preserve it when acceptance is ambiguous. Never export secrets or broaden sensitive material without authorization.
|
|
33
33
|
|
|
34
34
|
## Apply, verify, stop
|
|
35
35
|
|
|
@@ -37,4 +37,4 @@ A fresh executor must recover constraints, results, open questions, commitments,
|
|
|
37
37
|
|
|
38
38
|
Patch only material changes with `patch_state`, alone per assistant response; await acceptance. Never edit backing files, `response`, configuration, or runtime metadata. Read changed owner paths; inspect parent keys for deletions and effective state for inheritance changes.
|
|
39
39
|
|
|
40
|
-
After rejection or interruption, inspect accepted state before bounded recovery. Report unresolved checks and partial transfers without dumping memory or implying historical erasure.
|
|
40
|
+
After rejection or interruption, inspect accepted state before bounded recovery. Report unresolved checks and partial transfers without dumping memory or implying historical erasure. Before answering, apply only material durable changes; when nothing needs changing, make no `patch_state` call. Stop after this review, including when nothing needs changing.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
- [Architecture](architecture.md): Semantic state, temporal algebra, Pi lifecycle, storage, publication, artifacts, and embedding contracts.
|
|
5
5
|
- [Lazy state](lazy-state.md): Implemented ordinary-JSON lazy planes, an effective-by-default `lazy` read path, pure state/patch snapshots, narrow structural `meta` + `keys`, and recursive indexed array patches.
|
|
6
6
|
- [Filesystem recovery](filesystem-recovery.md): Cohort-wide absence, partial-presence, malformed-evidence, repair-authority, and transaction rules.
|
|
7
|
-
- [Temporal acceptance](temporal-acceptance.md):
|
|
7
|
+
- [Temporal acceptance](temporal-acceptance.md): Required temporal properties and their executable witnesses.
|
|
8
8
|
- [SDK compatibility](compatibility.md): Tested dependency stacks, public lifecycle seams, isolated validation, and host limits.
|
|
9
|
-
- [Physical fork contract](fork-contract.md): Session-stream copying,
|
|
9
|
+
- [Physical fork contract](fork-contract.md): Session-stream copying, live shared memory, child ownership/origin, and tested support boundaries.
|
|
10
10
|
- [Session performance](performance.md): Reproducible native-Pi/stateful workloads, long-session resume measurements, two-process publication probes, and evidence limits.
|
|
@@ -12,13 +12,12 @@ The extension owns durable memory while enabled. Global semantic memory is alway
|
|
|
12
12
|
|
|
13
13
|
- `state`, `json`: semantic shape, validation, recursive overlay and deletion.
|
|
14
14
|
- `temporal`, `history`: causal boundaries, checkpoint/tail folding and hot history.
|
|
15
|
-
- `durable`, `storage`, `git`: exact files, CAS
|
|
15
|
+
- `durable`, `storage`, `git`: exact canonical files, file-cohort CAS, and optional settled-turn backup.
|
|
16
16
|
- `snapshot`, `session`, `runtime`, `recovery`, `episode`: Pi branch/runtime lifecycle, branch traversal, and passive-boundary interpretation.
|
|
17
|
-
- `transition`, `
|
|
18
|
-
- `artifact`, `acquisition`, `
|
|
19
|
-
- `memory`:
|
|
17
|
+
- `transition`, `context`: inference barriers, turn resolution, passive projection, and response reconciliation.
|
|
18
|
+
- `artifact`, `acquisition`, `skills`, `rehydration`: source routing and compilation.
|
|
19
|
+
- `memory`: generic memory-bearing scope diagnostics.
|
|
20
20
|
- `continuation`: native-header discovery, runtime-provenance inspection, deterministic recommendation, and host startup precedence.
|
|
21
|
-
- `publication`: remote policy, durable CAS queue/store, cross-process leases, worker lifecycle, generation fencing, and attempt outcomes.
|
|
22
21
|
- `protocol`, `logging`: model/tool presentation and bounded diagnostic persistence.
|
|
23
22
|
- `status`, `telegram`, `extension`: operator projection, the optional fail-open pi-telegram presentation adapter, and high-level Pi adapter wiring.
|
|
24
23
|
|
|
@@ -28,17 +27,21 @@ Every materialized scope has exactly this shape:
|
|
|
28
27
|
|
|
29
28
|
```json
|
|
30
29
|
{
|
|
31
|
-
"
|
|
30
|
+
"intents": {},
|
|
32
31
|
"contract": {},
|
|
33
32
|
"working": {},
|
|
34
|
-
"
|
|
33
|
+
"artifacts": {},
|
|
34
|
+
"response": "",
|
|
35
|
+
"lazy": {}
|
|
35
36
|
}
|
|
36
37
|
```
|
|
37
38
|
|
|
38
|
-
- `
|
|
39
|
+
- `intents` retains only chosen active commitments.
|
|
39
40
|
- `contract` retains durable requirements, decisions, interfaces and rejected approaches.
|
|
40
41
|
- `working` retains verified current facts, unresolved work and exact continuation.
|
|
42
|
+
- `artifacts` maps exact source paths to compiled routing metadata.
|
|
41
43
|
- `response` is the latest complete user-facing answer for the session scope.
|
|
44
|
+
- `lazy` is a required object root for ordinary JSON detail, omitted from baseline model state and read explicitly.
|
|
42
45
|
|
|
43
46
|
Effective state recursively overlays:
|
|
44
47
|
|
|
@@ -60,11 +63,13 @@ Each scope stores:
|
|
|
60
63
|
checkpoint.json + patches.jsonl
|
|
61
64
|
```
|
|
62
65
|
|
|
63
|
-
The checkpoint is an older anchored materialization. The tail contains at most
|
|
66
|
+
The checkpoint is an older anchored materialization. The tail contains at most the configured `historyLimit` effective patches. On overflow, the oldest tail patch folds into the checkpoint before the new patch is appended.
|
|
67
|
+
|
|
68
|
+
Persisted streams and lineage are validated against the format maximum before applying a newly configured lower limit. Restore/reload/fork accepts only boundaries inside the configured window, then folds excess scope tails during canonical origin acceptance. That representation-only folding preserves selected private state and current shared values/provenance; a fork never rewrites parent-private files. Zero keeps only current checkpoints, and a later increase does not reconstruct discarded records or lineage.
|
|
64
69
|
|
|
65
70
|
`effective[n]`, `global[n]`, `cwd[n]`, and `session[n]` resolve the same nth previous causal boundary. They are not independent per-scope patch counters. The retired top-level `state` segment is rejected; pre-origin history is unavailable rather than empty.
|
|
66
71
|
|
|
67
|
-
A
|
|
72
|
+
A changed accepted response is runtime-owned semantic state and advances history. Ordinary completion requires no `patch_state` call when durable semantic state is already correct.
|
|
68
73
|
|
|
69
74
|
## Pi lifecycle
|
|
70
75
|
|
|
@@ -72,33 +77,39 @@ A final-only `patch_state({"final":true})` call changes only ephemeral terminal
|
|
|
72
77
|
|
|
73
78
|
Tool preflight follows Pi's public `getLeafEntry()` / `getEntry(parentId)` links to the nearest assistant containing the current call ID. It inspects that response's complete tool batch without constructing the whole branch or caching a batch across calls/selections. Foreign custom entries and earlier sibling results remain in the native trace. A missing call ID still searches the selected ancestry and preserves the existing unmatched-call behavior; this is not an unconditional constant-time guarantee. See [measured traversal evidence](performance.md#tool-preflight-parent-traversal).
|
|
74
79
|
|
|
75
|
-
`read_state` reads one cached effective or scoped projection at current index zero or a retained causal index
|
|
80
|
+
`read_state` reads one cached effective or scoped projection at current index zero or a retained causal index through the configured `historyLimit`. It never publishes or advances history.
|
|
76
81
|
|
|
77
|
-
|
|
82
|
+
Before answering, the model uses `patch_state` only when future-relevant durable state must change. An accepted ordinary answer is reconciled directly into runtime-owned `response` at `turn_end`; no terminal eligibility latch, finalization patch, repair inference, or fallback budget exists. If required artifact or Skill compilation prevents reconciliation, State Flow reports the failure without generating another inference. State Flow does not parse `state_flow` or generic HTML comments; historical comments are ordinary text and other extensions retain their own comment handling.
|
|
78
83
|
|
|
79
84
|
## Lifecycle planes
|
|
80
85
|
|
|
81
86
|
```text
|
|
82
|
-
SEMANTIC STATE
|
|
83
|
-
|
|
87
|
+
SEMANTIC STATE intents + contract + working + artifacts + response + lazy
|
|
88
|
+
MUTATION BARRIER patch_state(scope patches) → rematerialized next inference
|
|
84
89
|
CONTEXT PROJECTION active State Flow projection | passive post-stop handoff
|
|
85
90
|
```
|
|
86
91
|
|
|
87
|
-
Stopping State Flow
|
|
92
|
+
Stopping State Flow ends active episode semantics, restores the configured passive tool policy, and switches projection to a frozen effective-state handoff, the active user-run trajectory if interrupted, and post-stop conversation. Paired tool results arriving after Stop remain visible. Foreign context-bearing custom messages survive; a proven active boundary excludes completed earlier ordinary conversation. Direct completion persists no private validation feedback. This projection survives same-physical-session reload, resume, and tree restoration. Active restart uses it for one bootstrap run alongside active runtime context. New and forked physical sessions inherit neither projection. No semantic transition is created.
|
|
88
93
|
|
|
89
|
-
|
|
94
|
+
A proven pre-runtime branch has no accepted runtime to persist: Stop appends State Flow's existing `{disabled:true}` checkpoint in Pi without creating canonical files. Its cached passive view remains readable under the configured policy, but is not runtime authority. Accepted canonical publication, including a later Start or passive patch, ends this pre-runtime condition; failed selected-boundary recovery never qualifies for it.
|
|
90
95
|
|
|
91
|
-
|
|
96
|
+
Lifecycle-only persistence for accepted runtimes reconciles valid live global/CWD drift before publishing the current session's config/runtime pair. Changed shared streams establish a fresh proven origin, not a semantic transition; counters, semantic files, and all provenance files remain unchanged. Cached reads may constrain wider tails left by another writer without rewriting them. Same-session file races and explicitly requested stale provenance writes still fail closed under CAS. The host refreshes its scope cache after adoption: Stop freezes the accepted view, and new-run registered-artifact maintenance runs against that view before inference.
|
|
92
97
|
|
|
93
|
-
|
|
98
|
+
The existing native passive-stop marker stores the stop timestamp and an optional `from` timestamp identifying the active run's first user message. Native user events are observed independently of State Flow enablement, so starting mid-tool and repeated Start/Stop retain the actual first-user timestamp. Native user-run preparation and session-start/tree events reset capture; semantic mode changes do not. No new marker field, stored format or projection-derived lifecycle authority is introduced. Transcript bodies remain in Pi's trace rather than being copied into another state store. A recorded active anchor uses the same conservative selector as active inference: if native compaction removed it, or matching is ambiguous/nonfinite, retain the available native summary and tool trajectory without guessing a post-stop boundary or rereading discarded raw entries. Idle and legacy markers without an active anchor still retain only post-stop conversation plus foreign custom context. The initial system prompt is composed at `before_agent_start`; Stop does not rewrite an already-issued request, while the next provider request receives the current owned protocol section as described below.
|
|
94
99
|
|
|
95
|
-
The
|
|
100
|
+
The current user specification stays at user authority and appears only in synthetic user runtime context. State is fallible assistant-produced data. Active/passive protocol contributes to Pi's native `state_flow` system-prompt section at `before_agent_start`, rather than forcing the entire prompt. Later companion sections and `context_with_system` transformations compose normally; explicit foreign forced prompts retain Pi's documented precedence. Native section diffs remove/reinstate the initial protocol across user requests. At `context_with_system`, the context domain also refreshes only the owned section from current enablement/bootstrap/passive policy, covering Stop/Start inside the same tool loop and accepted-boundary continuations. Unchanged effective protocol reuses the original array without relocating native deltas; a changed mode preserves foreign sections/content/tools and conversation identity/order without mutating native frames or creating missing system authority. Accepted completion removes the specification, not memory availability: a companion's actionable `turn_end` or `agent_before_settle` continuation can request another inference without `before_agent_start`. Every enabled request still gets one current-memory projection, omitting an absent specification and using the captured native anchor when available; no synthetic user run, persisted continuation field or State Flow scheduler is created. Completed trajectories leave model context at user-run boundaries, while Pi's full JSONL trace remains inspectable.
|
|
101
|
+
|
|
102
|
+
After an accepted non-bootstrap run settles with no queued input, State Flow may request native manual compaction under a generation-private marker when public `getContextUsage()` reports at least 24,000 tokens. The settled handler awaits native completion/error callbacks before returning, so Pi can dispatch deferred companion prompts after every observer finishes without racing an in-flight manual compaction. This waits for one existing native operation, without adding a timer, queue or second continuation owner. This token signal provides a modest margin above Pi's default 20,000-token retained suffix; Pi still owns preparation and may benignly decline when custom settings leave no compactable prefix. The extension supplies no model-generated state body: it forwards the existing `runAnchorTimestamp` to the planner, requires one matching native user entry, and keeps the complete accepted run including later steering and tools. A missing, ambiguous, or unanswered anchor produces no request; the planner never falls back to the nearest user message. Compaction details still contain only the retained semantic boundary/step. `buildContextEntries()` then omits the older completed prefix while append-only JSONL/tree history remains intact.
|
|
103
|
+
|
|
104
|
+
Pi 0.87 supports retain-none boundary compactions, but State Flow intentionally does not use them. Completed canonical state omits the exact user prompt, and foreign custom context can legitimately occur inside the latest retained iteration; hiding both would make the projected semantic state a lossy substitute for native context. Unknown or smaller usage, foreign custom metadata or native `custom_message` context in the removed prefix, stale selection, Stop/bootstrap/error/abort, and pending input do not produce this boundary. User manual and native threshold/overflow compaction remain unmodified; unaccepted work stays under Pi's native compaction contract.
|
|
105
|
+
|
|
106
|
+
The Pi adapter passes its raw cached scope overlay to `runtimeContextMessage`, which owns model sanitization of the current state. It does not pre-project that input. `currentRunTrajectory` selects a unique captured user timestamp without requiring specification-text equality: Pi may append image normalization hints after `before_agent_start`. Without a captured timestamp, only a unique exact specification match can select a projected suffix. Missing, nonfinite, or ambiguous selection retains all available context. Projection never assigns `runAnchorTimestamp`; native user events own that lifecycle identity, so a projection fallback cannot become compaction authority. With a selected boundary, one retained-message array preserves foreign custom messages at every position and ordinary messages from the original run, including images, tools and steering, without copying discarded ordinary prefixes. The necessary scan and Pi's earlier native-message clone remain history-dependent. See [context-cost evidence](performance.md#context-projection-and-trajectory-selection).
|
|
96
107
|
|
|
97
108
|
## Storage and identity
|
|
98
109
|
|
|
99
|
-
The default store is `<agentDir>/state-flow
|
|
110
|
+
The default store is `<agentDir>/state-flow`; artifact sources are only exact paths already present in semantic state.
|
|
100
111
|
|
|
101
|
-
|
|
112
|
+
Canonical store layout:
|
|
102
113
|
|
|
103
114
|
```text
|
|
104
115
|
config.json
|
|
@@ -117,47 +128,29 @@ meta.json
|
|
|
117
128
|
|
|
118
129
|
CWD and session keys mirror Pi's native encoding. The Pi UUID remains authoritative; readable directory keys never replace identity validation.
|
|
119
130
|
|
|
120
|
-
Root `config.json` is the read-only operator configuration shared by every session in the repository; it never participates in semantic overlay. `checkpoint.json` is only the canonical materialized semantic state, and each nonblank `patches.jsonl` line is only one semantic patch. Every scope's `meta.json` symmetrically owns checkpoint/tail boundaries and artifact provenance, with CWD ownership added where applicable. Session `config.json` owns behavior; session `runtime.json` asymmetrically owns lineage, counters, session identity,
|
|
121
|
-
|
|
122
|
-
All owned writes use same-directory atomic replacement, regular-file and symlink checks, prepared byte receipts and CAS validation. Unrelated files and detected concurrent bytes are preserved; Git staging follows the acceptance contract below. Rollback restores only bytes still matching the failed publisher's output.
|
|
131
|
+
Root `config.json` is the read-only operator configuration shared by every session in the repository; it never participates in semantic overlay or State Flow-owned staging. Include operator configuration in operator-managed copies/versioning. `checkpoint.json` is only the canonical materialized semantic state, and each nonblank `patches.jsonl` line is only one semantic patch. Every scope's `meta.json` symmetrically owns checkpoint/tail boundaries and artifact provenance, with CWD ownership added where applicable. Session `config.json` owns behavior; session `runtime.json` asymmetrically owns lineage, counters, session identity, and the full specification only while a run is unfinished. Predecessor combined session metadata is unsupported; session `meta.json`, `config.json`, and `runtime.json` must already satisfy their canonical ownership contracts. Metadata writers replace only their owned leaves and preserve JSON-safe unknown siblings. Pi checkpoints retain only a semantic boundary plus lifecycle fields, or a proven ordinary-disabled marker. Revision-pointer checkpoints are unsupported and fail closed without Git restoration.
|
|
123
132
|
|
|
124
|
-
|
|
133
|
+
In-memory patching detaches one basis at its public boundary, then privately path-copies changed object/array containers while sharing untouched nodes only inside that owned draft. Incoming replacement values remain detached; staging no longer makes redundant cohort/per-scope pre-clones. Mutable staged responses and artifact registries stay isolated from accepted scopes, and commit/public temporal reads retain their detachment boundaries. This is not cross-version mutable sharing or a new disk generation format; see [copy-work evidence](performance.md#memory-only-owned-draft-cow).
|
|
125
134
|
|
|
126
|
-
|
|
135
|
+
All owned writes use same-directory atomic replacement, regular-file and symlink checks, prepared byte receipts and CAS validation. Unrelated files and detected concurrent bytes are preserved. Rollback restores only bytes still matching the failed publisher's output.
|
|
127
136
|
|
|
128
|
-
|
|
137
|
+
## Optional Git backup
|
|
129
138
|
|
|
130
|
-
|
|
139
|
+
Canonical files always own semantic persistence, current materialization, and retained hot history. Installing Git beside the store does not change authority or enable cold semantic restoration. Retained-boundary restoration selects private session history from the current canonical lineage while global/CWD scopes remain live; expired boundaries fail closed.
|
|
131
140
|
|
|
132
|
-
|
|
141
|
+
Scope artifact provenance records only current evidence. Restore/fork drops session provenance for paths touched by any retained session patch after the selected boundary, including a change-away-and-back; path existence or equal final values cannot substitute for that causal check. Selected artifact semantics remain intact with unavailable evidence until a stable explicit read and compilation. Untouched paths, provenance-only refreshes of unchanged semantics, and live shared provenance remain usable.
|
|
133
142
|
|
|
134
|
-
|
|
143
|
+
After response reconciliation and Pi's retry/queue processing, `agent_before_settle` may commit the already-accepted State Flow-owned files once. Backup acquires its own Git mutex, briefly takes canonical publication exclusion to inventory the bounded root/CWD/session namespace and capture regular-file bytes, then releases canonical exclusion before every Git command or filter. It never descends into artifact sources, `.git`, or unrelated directory trees. A private temporary worktree/index stages the captured snapshot with Git ignore/filter policy preserved; concurrent writers may advance canonical files without changing that snapshot.
|
|
135
144
|
|
|
136
|
-
|
|
145
|
+
Only exact backed-up owned paths are synchronized in the caller's index, preserving unrelated staged additions, modifications, deletions, index-only content, and worktree edits. HEAD-owned paths remain candidates when their deletion is already staged. Unchanged trees and unowned-only initial backups are skipped; failed index synchronization rolls back only the backup ref, never canonical files. Failure cannot suppress the answer or trigger another inference. Notification-only `agent_settled` does not perform backup writes.
|
|
137
146
|
|
|
138
|
-
|
|
147
|
+
Durable push queues, publication workers, leases, retries, queue filesystem state, and publication-policy metadata have been deleted. Git revision restore, immutable-revision fork APIs, and the legacy semantic Git backend have been removed from `TemporalRuntime`; all initialization, passive loading, model patches, runtime-only persistence, retained-boundary restoration, and retained-boundary forks use canonical files only.
|
|
139
148
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
The persisted `remotePublication` policy is:
|
|
143
|
-
|
|
144
|
-
- `turn-end`: default for new runtimes; local commits are immediate and the newest turn target is queued.
|
|
145
|
-
- `off`: local commits only.
|
|
146
|
-
- `transition`: synchronous compatibility behavior for legacy runtimes.
|
|
147
|
-
|
|
148
|
-
A destination is identified by canonical Git common directory, remote and full ref. Queue files live beneath the Git common directory and are not semantic history.
|
|
149
|
-
|
|
150
|
-
The queue uses exact scalar-string commit targets/confirmations, strict versioned JSON, symlink-safe atomic writes, CAS receipts and exclusive writer locks. Coercible non-string values are rejected at construction, parsing/serialization, coalescing, confirmation, and asynchronous push boundaries, before ancestry or push effects; malformed persisted records remain untouched. A proven descendant may supersede an older target; a journal lineage rewrite retargets the live commit and records the retired target, while changed destinations fail closed.
|
|
151
|
-
|
|
152
|
-
After accepted response reconciliation, an asynchronous non-interactive worker pushes the newest target. Queue failure never rolls back semantic state or regenerates an answer. Failed and interrupted attempts remain retryable across restart. Destination-scoped worker leases use exclusive creation. Dead-owner reclamation rechecks a fully validated regular-file record and PID liveness under the existing queue writer lock; only an `ESRCH` result permits reclamation. A fresh claim may win the removal/creation gap and must survive. Release requires the current process's PID and exact token, without waiting for queue writers. Malformed and symlink records are preserved; an occupied or interrupted writer gate defers reclamation rather than authorizing lock deletion. Confirmation removes only the exact completed target; a newer descendant remains queued.
|
|
153
|
-
|
|
154
|
-
`git.pushGitTarget` owns each asynchronous push with the existing 15,000ms Git command budget, ignored stdin/stdout, bounded diagnostic stderr, and non-interactive credentials. Timeout/cancellation sends `SIGKILL` to its POSIX process group while the owned leader is live; Windows terminates the direct child. The child handle remains referenced, and the promise settles only on process/stdio closure or proven spawn failure. A diagnostic pipe outliving its leader is closed on cancellation/deadline rather than extending the wait indefinitely. Helpers that escape or outlive the process group are not a general process-tree containment guarantee.
|
|
155
|
-
|
|
156
|
-
`extension` owns one abort controller and completion promise per destination worker. `session_shutdown` permanently closes that generation to new launches, cancels its children, and waits at most 2,000ms for the whole cohort. Late results cannot acknowledge/fail the queue or recursively relaunch; only lease cleanup remains allowed. If OS termination is unconfirmed at the wait deadline, emit a warning and keep ownership until actual exit. Filesystem cleanup failures remain fail-closed. A subsequent generation or activation can retry the same durable target once the lease is available. These policies require the owning Pi process and event loop to remain live: abrupt host death, blocked scheduling, and uninterruptible OS I/O are outside the deadline guarantee. Leases identify the Pi worker PID, not an independently supervised child after host death. Synchronous compatibility publication is unchanged.
|
|
149
|
+
Predecessor checkpoint envelopes, combined session metadata, pre-intents checkpoints, `state.json`, hashed layouts, and semantic Pi checkpoints are unsupported and remain untouched.
|
|
157
150
|
|
|
158
151
|
## Artifact routing
|
|
159
152
|
|
|
160
|
-
|
|
153
|
+
State Flow never discovers source directories. Before enabled inference it inspects only exact source paths already registered as artifacts in global, CWD, or session state. Observation uses regular non-symlink file metadata `{size, mtimeNs}` without reading bodies. Proven absence removes the artifact from each owning scope; unavailable, relative, directory, or symlink evidence is non-destructive. Unregistered files are never observed.
|
|
161
154
|
|
|
162
155
|
A model-visible artifact entry requires only a description:
|
|
163
156
|
|
|
@@ -168,48 +161,52 @@ A model-visible artifact entry requires only a description:
|
|
|
168
161
|
}
|
|
169
162
|
```
|
|
170
163
|
|
|
171
|
-
Runtime-owned
|
|
164
|
+
Runtime-owned compilation evidence is retained per scope in `meta.json`; current ordinary artifacts use `sourceFingerprint: {size, mtimeNs}` plus `compilerRevision`, while retained `sourceHash`/`compiledAt` are transitional compatibility evidence. At artifact-entry level, every model scope patch rejects authored `hash`, `compiler`, `compiled_at`, `sourceHash`, `sourceFingerprint`, `compilerRevision`, `compiledAt`, `source_hash_verified`, and `hint` fields, including field-deletion markers, even without a preceding read. Retained legacy evidence stays readable; ordinary semantic edits and whole-artifact deletion remain valid. Compiler output may add other finite non-null JSON metadata; known optional semantic fields include `kind`, `tags` and `compilation`. Tags are unique trimmed non-empty strings and support deterministic candidate filtering, but never authorize reading.
|
|
172
165
|
|
|
173
|
-
|
|
166
|
+
The public `classifyArtifactCompilationNeed` owns acquisition/rehydration and ordinary-artifact Pi decisions. An observed fingerprint needs matching valid retained fingerprint evidence; missing/malformed fingerprints, malformed compiler evidence, or a changed compiler request compilation without removing semantics. Changed size or signed nanosecond mtime (including pre-epoch dates) preserves the value and adds a runtime-only model `hint`. Fingerprint-only decisions ignore unused legacy hashes; explicit current-hash observations and the separate Skill hash protocol remain checked. Rehydration read plans carry detached fingerprints and optional hashes, never invented identities.
|
|
174
167
|
|
|
175
|
-
|
|
168
|
+
Invalidation notices identify the selected `global`, `cwd`, or `session` owner. Guidance and missing-output errors direct compilation to that exact scope/path, without relocating the entry or creating a global copy. Successful exact reads require stable fingerprints before/after acquisition and at publication, then publish compiler output and provenance to that owner under scope causal-basis CAS. Generic maintenance computes no content hash. Effective Skill entries mask lower ordinary entries and remain owned by the separate CWD Skill protocol.
|
|
169
|
+
|
|
170
|
+
Compilation is routing, not a substitute for source text. Full source is read only for a concrete unresolved gap, exact source/edit operation, fingerprint invalidation, contradiction/failure, or explicit request. The rehydration planner supports new-bootstrap, resume-bootstrap and later-step phases without hidden directory traversal.
|
|
176
171
|
|
|
177
172
|
Skills are CWD artifacts with stricter compilation: `kind: "skill"` and a non-empty compilation describing applicability, constraints and failure conditions. Their source bodies do not persist in state. Matching provenance proves source-version consistency, not semantic fidelity, truth, or higher instruction authority.
|
|
178
173
|
|
|
179
|
-
## Operational guidance
|
|
174
|
+
## Operational guidance and memory curation
|
|
180
175
|
|
|
181
|
-
The packaged Skills deliberately separate two responsibilities. `state-flow-guide` is the on-demand operational reference for concrete read, patch, inheritance, acquisition,
|
|
176
|
+
The packaged Skills deliberately separate two responsibilities. `state-flow-guide` is the on-demand operational reference for concrete read, patch, inheritance, acquisition, completion, and recovery questions; it does not initiate memory audits or unsolicited cleanup. `state-flow-memory` performs one explicitly requested bounded curation over stale knowledge, commitments, continuation, ownership, and external handoffs; phase completion does not activate an audit.
|
|
182
177
|
|
|
183
|
-
Curation compiles a read Skill at CWD before dependent work,
|
|
178
|
+
Curation compiles a read Skill at CWD before dependent work. Within one store, a proven scope move inspects both owners, resolves conflicts, and commits destination/source changes through one atomic multi-scope patch, followed by ownership/overlay verification. Simultaneously pending acquisitions across scopes must be compiled together in one atomic `patch_state` call.
|
|
184
179
|
|
|
185
|
-
External
|
|
180
|
+
External transfers use the destination's native interface and receipts; accepted-copy verification precedes source deletion in a later State Flow patch. State Flow defines no promotion registry, status schema, record type, or dedicated promotion tool; destination uncertainty simply leaves the source intact.
|
|
186
181
|
|
|
187
182
|
## Session continuation
|
|
188
183
|
|
|
189
184
|
The package exposes read-only host contracts that:
|
|
190
185
|
|
|
191
186
|
- read only native JSONL headers, never transcript bodies;
|
|
192
|
-
- inspect
|
|
187
|
+
- inspect canonical-file State Flow runtime provenance without mutation;
|
|
193
188
|
- rank exact profile, CWD, Git common-directory, worktree, branch and transport identity;
|
|
194
189
|
- fail closed for stopped, malformed, unavailable or ambiguous candidates;
|
|
195
190
|
- preserve explicit new/resume and native picker precedence;
|
|
196
191
|
- project new-bootstrap, resume-bootstrap and later-step rehydration phases.
|
|
197
192
|
|
|
198
|
-
|
|
193
|
+
Session checkpoint/tail identities must agree with that session's retained runtime lineage before restore/fork accepts a fresh origin. This check permits sparse session changes and inherited pre-origin streams; it does not require a session patch at a shared-only transition. Continuation inspection applies the same session check while validating current global/CWD streams independently. Shared writers do not belong to another session's historical clock. Neither path repairs a contradictory session cohort or manufactures empty session authority.
|
|
194
|
+
|
|
195
|
+
The [tested Pi SDK baseline](compatibility.md) chooses or creates `SessionManager` before package resources and extensions load. Therefore native default auto-resume cannot be installed safely by this extension alone. The remaining host integration requires an upstream pre-session resolver hook or an SDK/launcher that invokes the advisory resolver before constructing the session.
|
|
199
196
|
|
|
200
197
|
## Model tools and embedding
|
|
201
198
|
|
|
202
199
|
### Model tools
|
|
203
200
|
|
|
204
|
-
`patch_state` accepts
|
|
201
|
+
`patch_state` accepts one or more fixed `global`, `cwd`, and `session` semantic patches. Supplied scopes contain object-valued `artifacts`, `contract`, `working`, and `intents`, plus object-valued `lazy` whose nested values are ordinary JSON; omitted fields preserve their values, recursive object merge updates them, arrays/primitives replace, and nested object-key `null` deletes. Materialized null, empty supplied scopes, material no-ops, unknown top-level fields, model-authored `response`, and retired finalization or patch grammars are rejected.
|
|
205
202
|
|
|
206
203
|
```json
|
|
207
|
-
{"session":{"intents":{"next":"Verify the corrected behavior"}}
|
|
204
|
+
{"session":{"intents":{"next":"Verify the corrected behavior"}}}
|
|
208
205
|
```
|
|
209
206
|
|
|
210
207
|
`intents` is the hot plane for active commitments, not requirements, observations, alternatives, or completed plans. Removing an intent does not remove its consequences or any referenced state. Semantic-state references use either the optional structured `{"$ref":"cwd.lazy.plan"}` convention or `$` immediately followed by one valid `read_state` path inside ordinary text, for example `$effective.lazy.memory[7]`. The text prefix distinguishes references from incidental path-like prose and leaves a deterministic seam for possible future parsing. Resource paths, document locators, URIs, Skill identities, and agent identities retain their native syntax. State Flow stores all forms as ordinary JSON and currently does not parse or validate targets. The agent resolves a relevant locator explicitly through `read_state` or the appropriate external tool; presence alone creates no authority, existence proof, dependency, hydration, execution, or completion semantics. Reference repair is reactive: the agent never scans or resolves references merely to test them. Only after one requested value path is missing does the query domain perform one bounded reverse lookup over current model-patchable semantic planes for exact structured `$ref` or `$path` matches. When matches exist, `read_state` returns the explicit diagnostic sentinel `{value:null, hint:[{type:"dangling-reference", message, paths}]}`. `hint` is a top-level sibling rather than state data; its message asks for reconciliation and `paths` contains at most three runtime-verified current owning addresses. The null sentinel is never returned alone for this case. Keys, patch, and multi-path reads keep all-or-error semantics, while no durable match retains the ordinary missing-path error. A match establishes durable semantic provenance, not staleness; no match does not prove invention. The agent may then inspect ownership and patch a proven stale source without discarding surrounding meaning. Effective absence does not establish ownership, and unavailable history, external inaccessibility, or transient read failure does not prove a broken reference.
|
|
211
208
|
|
|
212
|
-
`read_state` accepts one unified path. `effective == effective[0]` is the current effective materialization; `global == global[0]` (and CWD/session equivalents) selects that scope at the same composed causal boundary. `global.patches == global.patches[0]` reads the latest accepted retained global patch, with higher patch indices walking only that scope's retained accepted patches. Indices are bounded
|
|
209
|
+
`read_state` accepts one unified path. `effective == effective[0]` is the current effective materialization; `global == global[0]` (and CWD/session equivalents) selects that scope at the same composed causal boundary. `global.patches == global.patches[0]` reads the latest accepted retained global patch, with higher patch indices walking only that scope's retained accepted patches. Indices are bounded by the configured `historyLimit`; unavailable pre-origin or pre-tail history is an error. Resolver aliases are not literal JSON containers. Reads stay cached and create no Git query, publication, checkpoint append, or semantic step.
|
|
213
210
|
|
|
214
211
|
```json
|
|
215
212
|
{"path":"cwd[1].intents"}
|
|
@@ -221,15 +218,15 @@ Both [tested Pi SDKs](compatibility.md) choose or create `SessionManager` before
|
|
|
221
218
|
|
|
222
219
|
Unscoped semantic paths such as `intents.next` alias the current effective overlay. `value`, `keys`, and `patch` projections plus ordered `paths` batches remain all-or-error.
|
|
223
220
|
|
|
224
|
-
Both tools follow branch enablement and host restrictions. The patch barrier also blocks reader siblings. These tools do not impose project schemas or state-size caps; semantic usefulness, scope choice, and compression remain model responsibilities.
|
|
221
|
+
Both tools follow branch enablement and host restrictions. The patch barrier also blocks reader siblings. These tools do not impose project schemas or state-size caps; semantic usefulness, scope choice, and compression remain model responsibilities. Ordinary handoffs reconcile touched state. Dedicated cleanup and scope review require an explicit user request, including at feature/release/project boundaries. Global retains established cross-project/user/environment knowledge, CWD owns reusable project truth, and session owns branch/run continuation. Intra-store moves use targeted owner reads and one atomic multi-scope patch followed by verification; external moves require verified destination acceptance before source deletion.
|
|
225
222
|
|
|
226
223
|
### Embedding
|
|
227
224
|
|
|
228
|
-
The default extension factory accepts `StateFlowExtensionOptions`: `agentDir` selects the profile
|
|
225
|
+
The default extension factory accepts `StateFlowExtensionOptions`: `agentDir` selects the profile and `repositoryRoot` overrides the configured state store. `onRuntime` receives a cached `read(offset?, scope?)` accessor; omitted scope means effective state. Use it only after runtime initialization/restoration. The pure `readTemporalState(view, offset, scope?)` accessor is exported separately. SDK hosts with an explicit tool allowlist must include both `patch_state` and `read_state` when they want model access.
|
|
229
226
|
|
|
230
|
-
Honor Pi's `session_shutdown` lifecycle before disposing an embedded session. On
|
|
227
|
+
Honor Pi's `session_shutdown` lifecycle before disposing an embedded session. On the [tested Pi SDK baseline](compatibility.md), `AgentSession.reload()` emits and awaits shutdown, but bare `AgentSession.dispose()` only invalidates/disconnects the session. `AgentSessionRuntime` owns native new/resume/fork replacement and its asynchronous `dispose()` delivers quit shutdown; rebind each newly created session's extensions. An SDK host instead disposing a standalone `AgentSession` should first `await session.extensionRunner.emit({ type: "session_shutdown", reason: "quit" })`; ordinary Pi lifecycle owners already deliver the event. Without shutdown, the adapter's queued Start, compaction-stop flags, and optional presentation disposal are not notified.
|
|
231
228
|
|
|
232
|
-
Native replacement teardown and State Flow adoption are separate responsibilities. On a native fork start, the adapter verifies the direct parent header and selected source
|
|
229
|
+
Native replacement teardown and State Flow adoption are separate responsibilities. On a native fork start, the adapter verifies the direct parent header and selected retained source boundary, then copies only the session stream/provenance into a distinct child owner over current live shared scopes. The child has a fresh origin and its own checkpoint, never a UUID alias or historical shared-state rewind. A child-owned native reset marker fences inherited passive Stop projection across reload. Parent-owned checkpoints selected later cannot fall through to an ordinary-disabled marker and reset child storage. See the [fork contract](fork-contract.md) and [operating limits](usage.md#fork-support-and-limits).
|
|
233
230
|
|
|
234
231
|
Agent configuration is read once per extension load; session runtime configuration remains branch-selected. See [configuration](usage.md#configuration) for settings and path precedence. Memory ownership while enabled and global availability are invariants, not configuration switches.
|
|
235
232
|
|
|
@@ -239,6 +236,6 @@ Status is a projection of the selected runtime and semantic view, not a second s
|
|
|
239
236
|
|
|
240
237
|
## Validation boundaries
|
|
241
238
|
|
|
242
|
-
Structural validation proves JSON shape, exact identity, causal lineage,
|
|
239
|
+
Structural validation proves JSON shape, exact identity, causal lineage, compilation evidence, CAS and publication invariants. A valid state, receipt, source hash, or compiler revision cannot prove semantic importance, truth, sufficient compilation, correct scope, useful curation, or historical deletion. Those remain model-judgment concerns evaluated separately from deterministic transport checks.
|
|
243
240
|
|
|
244
241
|
The deterministic continuity and temporal evidence map is in [temporal-acceptance.md](temporal-acceptance.md). Release-scoped open work is in [BACKLOG.md](../BACKLOG.md), and shipped outcomes belong in [CHANGELOG.md](../CHANGELOG.md).
|