@llblab/pi-state-flow 0.17.1 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +81 -69
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
> Each release keeps at most 8 outcome records of at most 512 characters.
|
|
4
4
|
|
|
5
|
+
## 0.17.2: incremental memory model documentation
|
|
6
|
+
|
|
7
|
+
- `README`: Explains the combination of durable state between user runs and native working context within each run. Clarifies global/CWD/session composition into effective memory, configurable historical access and optional Git backups, with a simpler flow diagram and a compact semantic-plane reference. Runtime behavior is unchanged.
|
|
8
|
+
|
|
5
9
|
## 0.17.1: precise patch diagnostics and clearer onboarding
|
|
6
10
|
|
|
7
11
|
- `Patch diagnostics`: Unknown scope-patch keys are reported by their exact JSON-quoted name, with permitted fields listed in intent-first order: intents, contract, working, artifacts, lazy. Accepted patch structure and runtime-owned response protection are unchanged. Thanks to @Jipok for the feedback in #5.
|
package/README.md
CHANGED
|
@@ -4,135 +4,147 @@
|
|
|
4
4
|
|
|
5
5
|
**Incremental scoped context/memory compiler for Pi.**
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
State Flow maintains explicit state across requests and sessions. The agent incrementally compiles requirements, decisions, findings and source knowledge into durable memory rather than carrying every completed exchange into the next request.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Drawing on the explicit-state approach of [SKILL.state](https://arxiv.org/html/2608.26263v2), State Flow combines durable state with Pi's native conversation context. In this hybrid, **state carries continuity between user runs; Pi's native context carries the working trajectory within a run.** The conversation is not reset after each model response or tool call. Pi retains ownership of execution, session navigation and the full inspectable trace.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## How it works
|
|
12
|
+
|
|
13
|
+
A user run starts with effective memory and a new request. The agent works through Pi's ordinary inference/tool loop, updates memory when useful information changes, and returns an ordinary answer. The next run receives the accepted state and compact recent transitions instead of the completed ordinary conversation history.
|
|
12
14
|
|
|
13
15
|
```text
|
|
14
|
-
Current state +
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
Current state + Request
|
|
17
|
+
↓
|
|
18
|
+
Pi's native tool loop
|
|
19
|
+
↓
|
|
20
|
+
Patched state + Answer
|
|
21
|
+
↓
|
|
22
|
+
Updated state
|
|
21
23
|
```
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
|
|
25
|
+
Within a run, the available request, intermediate responses, tool results and steering remain in context. A state patch updates memory without discarding that working trajectory. Persistent context-bearing messages from other extensions are preserved as well.
|
|
26
|
+
|
|
27
|
+
This reduces reliance on repeated model-generated summaries of an accumulating transcript. Retaining the current trajectory also allows prompt-cache reuse while the relevant prefix remains unchanged. Avoiding summary calls and repeated prompt processing can improve responsiveness; the result depends on the model, provider, workload and frequency of state changes, not a fixed latency guarantee.
|
|
28
|
+
|
|
29
|
+
Native compaction remains available for long runs. State Flow may also request a completed-history boundary without another model summary, retaining the complete latest accepted run. Neither mechanism deletes Pi's append-only session trace. See [lifecycle behavior](docs/usage.md#session-behavior) and [performance evidence](docs/performance.md).
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
## Installation and activation
|
|
29
32
|
|
|
30
|
-
|
|
33
|
+
Requires **Pi 0.87.0+** and **Node.js 22.19.0+**. See [SDK compatibility](docs/compatibility.md) for tested stacks and verification limits.
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
From NPM:
|
|
33
36
|
|
|
34
37
|
```bash
|
|
35
38
|
pi install npm:@llblab/pi-state-flow
|
|
36
39
|
```
|
|
37
40
|
|
|
38
|
-
|
|
41
|
+
From Git:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pi install git:github.com/llblab/pi-state-flow
|
|
45
|
+
```
|
|
39
46
|
|
|
40
|
-
|
|
47
|
+
Enable active State Flow on the current branch:
|
|
41
48
|
|
|
42
49
|
```text
|
|
43
50
|
/state-flow-start
|
|
44
51
|
```
|
|
45
52
|
|
|
46
|
-
|
|
53
|
+
Starting in an existing conversation retains its context for one complete bootstrap run so the agent can compile what matters.
|
|
47
54
|
|
|
48
|
-
- `/state-flow-start
|
|
49
|
-
- `/state-flow-status
|
|
50
|
-
- `/state-flow-stop
|
|
55
|
+
- `/state-flow-start`: Enable active state updates and memory-based context projection.
|
|
56
|
+
- `/state-flow-status`: Inspect effective state, retained history and known recovery issues without scanning sources or changing state.
|
|
57
|
+
- `/state-flow-stop`: End active episode semantics without deleting memory; an interrupted run retains its frozen handoff and available trajectory.
|
|
51
58
|
|
|
52
|
-
|
|
59
|
+
Active mode is **opt-in**. Passive memory projection and the memory tools are enabled by default: existing state can be read or explicitly patched without an active episode or State Flow compaction. Stop returns to the configured passive behavior. `autoStart` can enable active mode for genuinely new sessions; resumed branches restore their own enablement. See [configuration](docs/usage.md#configuration).
|
|
53
60
|
|
|
54
|
-
##
|
|
61
|
+
## State model
|
|
55
62
|
|
|
56
|
-
|
|
63
|
+
### Scopes and effective memory
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
- **`contract`** — Durable requirements, decisions, constraints and interface commitments.
|
|
60
|
-
- **`working`** — Current observations, verified results, uncertainties and next checks.
|
|
61
|
-
- **`artifacts`** — Descriptions and compiled knowledge keyed by exact source path. Refreshes belong to the source's registered scope; Skills belong to CWD.
|
|
62
|
-
- **`response`** — The latest complete answer, captured by the runtime rather than authored in a model patch.
|
|
63
|
-
- **`lazy`** — Supporting memory available through explicit reads, with its body omitted from ordinary baseline projection.
|
|
65
|
+
Memory has three ownership scopes:
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
- `global`: Knowledge and preferences shared across projects.
|
|
68
|
+
- `cwd`: Knowledge shared by sessions in the same working directory.
|
|
69
|
+
- `session`: State belonging to the current session and its selected branch.
|
|
66
70
|
|
|
67
|
-
|
|
68
|
-
- **CWD:** Reusable knowledge for this project.
|
|
69
|
-
- **Session:** This branch's commitments and continuation.
|
|
71
|
+
They compose recursively in **global → CWD → session** order. More-specific values override lower-scope values, while object fields merge. Removing a local value can reveal an inherited value again.
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
The agent receives the **effective view** of this composition, not three unrelated memory dumps. It can read that view or inspect an individual scope when ownership matters. `effective` is a computed view, not a fourth storage scope. Scope precedence does not elevate memory into system-level instructions.
|
|
72
74
|
|
|
73
|
-
###
|
|
75
|
+
### Semantic planes
|
|
74
76
|
|
|
75
|
-
|
|
77
|
+
Every scope uses the same shape:
|
|
78
|
+
|
|
79
|
+
- `intents`: Active commitments to future action.
|
|
80
|
+
- `contract`: Requirements, decisions, constraints and interface commitments.
|
|
81
|
+
- `working`: Observations, results, uncertainties and current continuation.
|
|
82
|
+
- `artifacts`: Source-addressed descriptions and compiled knowledge.
|
|
83
|
+
- `response`: The latest complete answer, captured by the runtime.
|
|
84
|
+
- `lazy`: Supporting memory available through explicit reads, with its body omitted from baseline model context.
|
|
85
|
+
|
|
86
|
+
These planes organize ordinary JSON rather than imposing a project-specific schema. The model updates the semantic planes except `response`, which is runtime-owned. Memory remains fallible: storing an observation does not make it current or correct.
|
|
87
|
+
|
|
88
|
+
## Incremental updates and history
|
|
89
|
+
|
|
90
|
+
`patch_state` updates one or more named scopes atomically. Unmentioned values remain unchanged; object patches merge recursively, and `null` deletes an object key rather than becoming stored data.
|
|
76
91
|
|
|
77
92
|
```json
|
|
78
93
|
{
|
|
94
|
+
"cwd": {
|
|
95
|
+
"contract": { "verification": { "command": "npm test" } }
|
|
96
|
+
},
|
|
79
97
|
"session": {
|
|
80
|
-
"intents": {
|
|
81
|
-
|
|
82
|
-
},
|
|
83
|
-
"contract": { "runtime": "Node.js >=22.19.0" },
|
|
84
|
-
"working": { "build": "Not checked yet" }
|
|
98
|
+
"intents": { "verify": { "action": "Run the checks before publishing" } },
|
|
99
|
+
"working": { "checks": "Pending" }
|
|
85
100
|
}
|
|
86
101
|
}
|
|
87
102
|
```
|
|
88
103
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
During an active episode, a material patch is an inference barrier: sibling tool calls are blocked, and the next inference receives the accepted memory. Ordinary answers need no bookkeeping patch; `response` is runtime-owned.
|
|
104
|
+
During an active episode, a material patch is an inference barrier: sibling tool calls are blocked, and the next inference sees the accepted effective state. Ordinary completion needs no finalization patch or additional State Flow reasoning loop.
|
|
92
105
|
|
|
93
|
-
`read_state`
|
|
106
|
+
`read_state` provides targeted current and historical access:
|
|
94
107
|
|
|
95
108
|
```json
|
|
96
|
-
{ "
|
|
109
|
+
{ "paths": ["effective.contract", "cwd.working", "session.intents"] }
|
|
97
110
|
```
|
|
98
111
|
|
|
99
|
-
|
|
112
|
+
- `working`: Current effective working memory; unscoped paths are effective aliases.
|
|
113
|
+
- `effective[1].working`: Working memory at the preceding accepted transition boundary, when retained.
|
|
114
|
+
- `cwd.patches[0]`: The latest retained CWD semantic patch.
|
|
115
|
+
- `effective.lazy.memory[0..3]`: A bounded slice of a stored collection.
|
|
100
116
|
|
|
101
|
-
|
|
117
|
+
Historical materializations and scope patch histories use the configurable **`historyLimit`**, from **0 to 100**, with a default of **7**. Materialized offsets refer to accepted semantic transitions, not user messages or an independent counter for each scope. Requested history must still exist in the active lineage; increasing the limit cannot recreate discarded history. Older patches fold into the checkpoint without removing current values.
|
|
102
118
|
|
|
103
|
-
|
|
119
|
+
Array ranges, structural `keys` reads and path-intersected `patch` projections support progressive access without loading whole memory collections. See [progressive memory](docs/lazy-state.md) and [tool contracts](docs/architecture.md#model-tools).
|
|
104
120
|
|
|
105
|
-
|
|
121
|
+
## Persistence, backups and continuity
|
|
106
122
|
|
|
107
|
-
|
|
123
|
+
The default store is `~/.pi/agent/state-flow/`, independent of registered source files. Canonical `checkpoint.json`, `patches.jsonl` and `meta.json` files hold each scope's state, retained changes and metadata; session configuration and runtime identity are stored separately.
|
|
108
124
|
|
|
109
|
-
**
|
|
125
|
+
**Git backups are optional.** When the store is a configured Git repository, accepted active turns may create versioned backups of State Flow-owned files. Backup needs a Git commit identity; accepting and persisting state does not. A backup failure produces a warning without rejecting or rolling back accepted memory. Git history can be inspected separately, but it is not the authority for `read_state` or automatic restoration of expired semantic boundaries.
|
|
110
126
|
|
|
111
|
-
|
|
127
|
+
Resume and tree navigation restore the selected retained session boundary over current shared global/CWD memory. A new session gets its own session layer. Supported native forks copy selected session state into a new owner without changing the parent's private data. Expired, incomplete or contradictory boundaries fail closed rather than silently substituting newer state. See [fork support](docs/usage.md#fork-support-and-limits) and [storage recovery](docs/usage.md#storage-and-recovery).
|
|
112
128
|
|
|
113
|
-
|
|
129
|
+
Version 0.17 accepts only the current canonical storage contract and has no in-place predecessor converter. Preserve existing data and check the [format boundary](docs/usage.md#moving-a-store-and-the-017-format-boundary) before changing versions or moving a store.
|
|
114
130
|
|
|
115
|
-
|
|
116
|
-
- **`state-flow-memory`** — Bounded curation when explicitly requested. Ask: **“Review and clean State Flow state.”**
|
|
131
|
+
## Operational boundaries
|
|
117
132
|
|
|
118
|
-
|
|
133
|
+
State Flow adds memory, not another agent controller. It does not introduce background reasoning, a scheduler, automatic reference hydration or rollback of external tool effects. State and the current trajectory are not size-capped; performance depends on how much useful information the agent retains.
|
|
119
134
|
|
|
120
|
-
|
|
135
|
+
The packaged `state-flow-guide` Skill covers concrete operations and recovery. `state-flow-memory` supports explicitly requested curation, for example: **“Review and clean State Flow state”** Normal handoffs reconcile touched memory; dedicated cleanup is not an automatic audit after each task.
|
|
121
136
|
|
|
122
|
-
|
|
123
|
-
- **Not live workspace truth.** Revalidate consequential observations before acting. Restored memory does not undo external tool effects.
|
|
124
|
-
- **Not a token or latency guarantee.** State and the active trajectory are not size-capped; benefits depend on workload and curation. [Performance evidence](docs/performance.md) separates measured copying work from end-to-end cost.
|
|
125
|
-
- **Not a transcript replacement.** Pi retains its full inspectable trace. Use ordinary Pi context when the model needs every historical exchange verbatim.
|
|
126
|
-
- **Not secret storage.** Memory, diagnostic logs and backups may contain sensitive content. Deletion from current state does not erase older histories or remote copies. Use a dedicated store and review what you retain.
|
|
137
|
+
Treat state, diagnostic logs and backups as private data. Revalidate consequential observations before acting, and verify a transfer's destination before deleting its source. Removing a value from current state does not erase older histories or remote copies.
|
|
127
138
|
|
|
128
139
|
## Documentation and development
|
|
129
140
|
|
|
130
|
-
- [Usage and recovery](docs/usage.md) — Configuration, lifecycle, diagnostics and
|
|
131
|
-
- [Architecture](docs/architecture.md) — Semantic model, temporal boundaries, artifacts and
|
|
141
|
+
- [Usage and recovery](docs/usage.md) — Configuration, lifecycle, diagnostics and storage operations.
|
|
142
|
+
- [Architecture](docs/architecture.md) — Semantic model, temporal boundaries, artifacts and integration contracts.
|
|
132
143
|
- [SDK compatibility](docs/compatibility.md) — Tested stacks and verification limits.
|
|
144
|
+
- [Performance](docs/performance.md) — Measurements, workload definitions and limits.
|
|
133
145
|
- [Acceptance map](docs/temporal-acceptance.md) — Properties tied to concrete tests.
|
|
134
146
|
- [Documentation index](docs/README.md) — All maintained guides.
|
|
135
147
|
|
|
136
|
-
For development, run `npm install` and `npm run validate`.
|
|
148
|
+
For development, run `npm install` and `npm run validate`. `npm run benchmark` is opt-in and separate from the normal suite; see `benchmarks/README.md` in a source checkout.
|
|
137
149
|
|
|
138
150
|
Project context: [AGENTS.md](AGENTS.md), [BACKLOG.md](BACKLOG.md), [CHANGELOG.md](CHANGELOG.md).
|
package/dist/package.json
CHANGED