@caupulican/pi-adaptative 0.96.4 → 0.96.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +8 -0
  3. package/dist/config.d.ts +2 -0
  4. package/dist/config.d.ts.map +1 -1
  5. package/dist/config.js +3 -1
  6. package/dist/config.js.map +1 -1
  7. package/dist/core/agent-session-contracts.d.ts +1 -1
  8. package/dist/core/agent-session-contracts.d.ts.map +1 -1
  9. package/dist/core/agent-session-contracts.js.map +1 -1
  10. package/dist/core/agent-session.d.ts +2 -0
  11. package/dist/core/agent-session.d.ts.map +1 -1
  12. package/dist/core/agent-session.js +29 -14
  13. package/dist/core/agent-session.js.map +1 -1
  14. package/dist/core/goals/goal-lifecycle.d.ts.map +1 -1
  15. package/dist/core/goals/goal-lifecycle.js +5 -1
  16. package/dist/core/goals/goal-lifecycle.js.map +1 -1
  17. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  18. package/dist/core/goals/goal-session-controller.js +3 -1
  19. package/dist/core/goals/goal-session-controller.js.map +1 -1
  20. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  21. package/dist/core/goals/goal-tool-core.js +32 -7
  22. package/dist/core/goals/goal-tool-core.js.map +1 -1
  23. package/dist/core/learning/durable-learning-state.d.ts +76 -0
  24. package/dist/core/learning/durable-learning-state.d.ts.map +1 -0
  25. package/dist/core/learning/durable-learning-state.js +493 -0
  26. package/dist/core/learning/durable-learning-state.js.map +1 -0
  27. package/dist/core/reflection-controller.d.ts +37 -7
  28. package/dist/core/reflection-controller.d.ts.map +1 -1
  29. package/dist/core/reflection-controller.js +278 -49
  30. package/dist/core/reflection-controller.js.map +1 -1
  31. package/dist/core/settings-manager.js.map +1 -1
  32. package/dist/core/tools/goal.d.ts.map +1 -1
  33. package/dist/core/tools/goal.js +6 -3
  34. package/dist/core/tools/goal.js.map +1 -1
  35. package/dist/modes/interactive/components/settings-selector.js +1 -1
  36. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  37. package/docs/durable-learning-state-design.md +217 -0
  38. package/docs/settings.md +5 -3
  39. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  40. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  41. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  42. package/examples/extensions/sandbox/package-lock.json +2 -2
  43. package/examples/extensions/sandbox/package.json +1 -1
  44. package/examples/extensions/with-deps/package-lock.json +2 -2
  45. package/examples/extensions/with-deps/package.json +1 -1
  46. package/npm-shrinkwrap.json +12 -12
  47. package/package.json +4 -4
@@ -0,0 +1,217 @@
1
+ # Version-aware durable learning design
2
+
3
+ **Status:** Implemented and verified on 2026-08-23. The implementation tribunal reached unanimous core consensus, focused and repository-wide gates pass, and release verification remains pending.
4
+
5
+ This document defines one root-owned path for automatic durable learning and release-aware memory review. It complements [`memory-subsystem-design.md`](memory-subsystem-design.md), [`self-adaptation.md`](self-adaptation.md), and [`task-steps.md`](task-steps.md); it does not duplicate their general subsystem descriptions.
6
+
7
+ ## Scope
8
+
9
+ Covered in depth: same-turn reflection ownership, durable knowledge routing, runtime-version state, lifecycle, bounded persistence, concurrency, failure behavior, migration, and acceptance tests.
10
+
11
+ Structurally referenced only: OKF file syntax, individual memory providers, pipeline implementation, and release automation. Those remain owned by their existing documents and source modules.
12
+
13
+ ## Confirmed implemented behavior
14
+
15
+ - External root prompts call `ReflectionController.queueExternalRootTurnCue()` before provider planning (`src/core/agent-session.ts`).
16
+ - `ReflectionController` keeps at most one active cue on the current session branch, merges trigger classes, injects it only into provider context, and records accepted-plan delivery separately from terminal review (`src/core/reflection-controller.ts`).
17
+ - Automatic reflection is disabled for child sessions, disposed sessions, or resolved settings/environment kill switches (`ReflectionController.isAutomaticReflectionEnabled`).
18
+ - Completed-turn analysis uses bounded, secret-redacted user and assistant semantics plus tool names/counts; raw non-memory tool results are excluded (`src/core/learning/reflection-turn-analysis.ts`).
19
+ - Signal analysis recognizes corrections, explicit durable instructions, durable completed work, and configured complexity (`analyzeReflectionTurn`).
20
+ - `AgentSession` computes final root/child/worker role before constructing reflection. Child and worker sessions receive no `DurableLearningState` owner and therefore create no state-file footprint.
21
+ - `VERSION` and `VERSION_SOURCE_AVAILABLE` come from installed package metadata (`src/config.ts`). Missing metadata keeps ordinary reflection active but suppresses version claims.
22
+ - `DurableLearningState` persists bounded runtime/policy transition control state through `stateFile`, `withFileLockSync`, and `writeFileAtomicSync`; it has no semantic-memory writer dependency (`src/core/learning/durable-learning-state.ts`).
23
+ - The root memory tool remains the only semantic mutation route and directs structured project decisions, architecture, rules, findings, and references to OKF; child sessions receive no memory tool (`src/core/memory/providers/file-store.ts`).
24
+
25
+ ## Core invariant
26
+
27
+ Exactly one root provider turn owns semantic learning decisions.
28
+
29
+ 1. The current root model receives one provider-only reflection cue in the same turn.
30
+ 2. That model confronts existing durable knowledge before writing.
31
+ 3. Existing memory and skill tools remain the only semantic mutation path and retain their confidence, evidence, contradiction, rollback, and approval gates.
32
+ 4. No child session, worker, background learner, isolated provider request, or concurrent unclaimed root turn may own or complete the reflection.
33
+ 5. Runtime-version reconciliation stores only bounded control state. It never mechanically rewrites semantic memory, and `reviewed` can be committed only by compare-and-swap from the exact claimed cue-bearing successful root run.
34
+
35
+ ## Canonical knowledge routing
36
+
37
+ A durable fact has one semantic owner:
38
+
39
+ - `USER.md`: collaborator preferences and stable working relationship facts.
40
+ - `MEMORY.md`: compact, frequently needed cross-session facts.
41
+ - OKF: canonical project decisions, architecture, rules, findings, references, implementation knowledge, and evidence.
42
+ - Skills: repeatable procedures whose value is operational specialization rather than a static fact.
43
+ - ICM task/pipeline context: workflow stage, progression, active artifacts, and references to OKF records. It must not copy an OKF fact into an independent second truth.
44
+
45
+ Verified stage findings may be promoted into OKF through the existing memory gate. ICM then references the resulting OKF record. Supersession updates the canonical record and leaves workflow history as history.
46
+
47
+ The provider cue and root memory-tool guidance enforce this routing together. A semantic fact must be written to exactly one durable target. Goal, task-step, and pipeline payloads may contain execution status, acceptance evidence, artifact paths, and OKF references, but not an independently maintained copy of canonical project semantics. Runtime reconciliation has no API for editing memory, OKF, skills, tasks, goals, or pipelines.
48
+
49
+ ## Runtime learning state
50
+
51
+ `src/core/learning/durable-learning-state.ts` is the sole control-state owner. `DURABLE_LEARNING_MEMORY_POLICY_VERSION` is an explicit source string independent from JSON `schemaVersion`; file compatibility and semantic-policy review remain separate invariants.
52
+
53
+ ```ts
54
+ interface DurableLearningStateFileV1 {
55
+ schemaVersion: 1;
56
+ revision: number;
57
+ observedRuntimeVersion: string;
58
+ observedMemoryPolicyVersion: string;
59
+ current: PendingDurableLearningTransition | null;
60
+ history: ResolvedDurableLearningTransition[];
61
+ }
62
+
63
+ interface PendingDurableLearningTransition {
64
+ transitionId: string;
65
+ reason:
66
+ | "first-observation"
67
+ | "runtime-change"
68
+ | "memory-policy-change"
69
+ | "runtime-and-policy-change"
70
+ | "recovered-corrupt-state";
71
+ previousRuntimeVersion: string | null;
72
+ runtimeVersion: string;
73
+ previousMemoryPolicyVersion: string | null;
74
+ memoryPolicyVersion: string;
75
+ createdAt: string;
76
+ updatedAt: string;
77
+ claim: {
78
+ claimId: string;
79
+ ownerId: string; // random per root ReflectionController; never a real session ID
80
+ acquiredAt: string;
81
+ expiresAt: string;
82
+ } | null;
83
+ }
84
+ ```
85
+
86
+ Exactly one `current` slot is the pending-transition truth. `history` contains only resolved `reviewed` or `superseded` records. A runtime or policy change resolves an older current transition as superseded before installing one new current transition. Completion identity includes transition ID, claim ID, owner ID, runtime version, and memory-policy version. `ownerId`, `claimId`, and `transitionId` use `randomUUID()` or an injected equivalent.
87
+
88
+ ### Bounds and validation
89
+
90
+ - Keep at most 32 newest resolved history records plus the single current transition.
91
+ - Accept version strings matching the bounded implementation alphabet (`A-Z`, `a-z`, `0-9`, `.`, `_`, `+`, `-`) with length 1-128; accept canonical ISO timestamps up to 64 characters and UUID-v4-format IDs.
92
+ - Reject files larger than 64 KiB before JSON materialization. Default claim TTL is 90 minutes. Exact same-owner reconciliation or provider-loop continuation renews only the live matching token and never rotates identity. Retry also renews the same token. Superseded, released, expired-and-taken-over, or otherwise mismatched tokens cannot renew or complete.
93
+ - Store only bounded transition control fields. Never store transcript text, memory contents, credentials, tool results, provider output, real session IDs, task payloads, or OKF contents.
94
+ - Schema v1 is closed at every object level. Unknown v1 keys, unknown schema versions, and oversized state enter unsupported read-only mode and preserve exact bytes.
95
+
96
+ ### Location, role, and atomicity
97
+
98
+ `DurableLearningState.forAgentDir()` uses `stateFile(agentDir, "durable-learning-state.json")`, `withFileLockSync`, and `writeFileAtomicSync(..., { mode: 0o600 })`.
99
+
100
+ Every reconcile, renewal, release, or completion performs lock-serialized load/validate/mutate/save. `revision` increases only when control state persists a change; read-only and rejected operations leave it unchanged.
101
+
102
+ `AgentSession` computes final child/worker role before constructing reflection or state. Child and worker sessions receive no durable-learning state owner and perform no state read, directory creation, lock acquisition, or write. Root runtime is the only activation owner.
103
+
104
+ ## Reconciliation lifecycle
105
+
106
+ ### Session construction
107
+
108
+ After computing final root-versus-child role, `AgentSession` constructs one root-only state owner from the agent state directory. Construction performs no I/O. `ReflectionController` owns one random non-session owner ID and receives installed `VERSION`, `VERSION_SOURCE_AVAILABLE`, and current `DURABLE_LEARNING_MEMORY_POLICY_VERSION` through dependencies at reconciliation time. Missing package metadata is therefore distinguishable from a real `"0.0.0"` release; missing identity emits one bounded warning and never claims a semantic review.
109
+
110
+ ### Before an external root provider request
111
+
112
+ Only a prompt with no `internalContextType` may reconcile. It must pass the same authoritative eligibility predicate used by current-session reflection: resolved `enabled`, resolved `reflectionReview`, `PI_NATIVE_REFLECTION !== "0"`, `PI_AUTO_LEARN_CHILD !== "1"`, root role, and non-disposed session. An ineligible request performs no read, lock, or state write. If eligibility is revoked during an active review, only lease cleanup may write; observation and completion remain forbidden.
113
+
114
+ For an eligible external root prompt, one state-owner `reconcileClaimAndAttach(ownerId, attachCue)` transaction holds the state-file lock through both claim reconciliation and the synchronous durable cue-state append:
115
+
116
+ 1. Missing state creates one pending `first-observation` transition and records the current observed runtime and policy. This first supporting release therefore audits an existing installation once.
117
+ 2. A changed runtime or memory policy marks the older pending transition `superseded`, clears its embedded claim, updates observed values, and appends one pending transition. Exact string equality detects upgrade, downgrade, and reinstall; semver ordering is unnecessary.
118
+ 3. Matching observed values create no transition and no revision change. An existing pending transition remains eligible.
119
+ 4. The schema has exactly one current-transition slot and at most one embedded claim. A pending transition with no live claim receives a fresh cryptographically random claim ID. Exact same-owner renewal only extends that claim's expiry and returns the identical transition ID, claim ID, owner ID, runtime, and policy; renewal never rotates a token. Expiry takeover atomically revokes the predecessor claim before creating a new claim ID. A live different-owner claim returns `busy`; that root receives the ordinary reflection cue without version metadata.
120
+ 5. The current claim is exposed to `attachCue` as an opaque compare-and-swap token containing transition ID, claim ID, owner ID, target runtime, and target policy. It is persisted in bounded session cue state but claim and owner IDs never enter provider text.
121
+
122
+ Claim attachment and cue coalescing are one state-owner operation: no claim token escapes for later attachment. While the state-file lock remains held, the synchronous callback attaches `root-turn` plus `version-change`, hidden token, and bounded metadata to the single cue. It returns `attached` when it created or amended the cue, `coalesced` when that cue already durably carries the identical token, `replaced-stale` when the one current claim proves a different hidden token non-current, `disabled` when reflection became ineligible, or `failed` on persistence. `attached`, exact-token `coalesced`, and `replaced-stale` retain the current claim; a boolean no-op is never interpreted as failure. A different token can only name a superseded transition, an exactly released claim, or an expired claim atomically revoked before takeover: same-owner renewal preserves the exact claim ID, one current transition prevents a second live same-owner claim, and the held lock prevents interleaving between proof and cue append. The stale token is retired in the same cue-state revision that attaches the current token. `disabled`, `failed`, or a thrown append releases only the exact current claim before unlocking; a crash after claim persistence but before cue append is recovered only by lease expiry. Adding `version-change` requires extending `CurrentTurnReflectionTrigger`, `CURRENT_TURN_REFLECTION_TRIGGERS`, the provider-hidden cue-state token, and the cue-state parser. Deterministic completed-turn analysis must never infer `version-change` from transcript text.
123
+
124
+ ### Provider cue contract
125
+
126
+ For every root turn, one logical cue asks the current model to classify:
127
+
128
+ - explicit durable intent;
129
+ - corrections and standing preferences;
130
+ - repeated patterns or behavior supported by accumulated evidence;
131
+ - reusable procedures that belong in skills;
132
+ - verified project knowledge that belongs in OKF;
133
+ - version-sensitive knowledge when a claimed transition is pending.
134
+
135
+ It routes stable collaborator preferences to USER, compact hot facts to MEMORY, canonical project semantics and evidence to OKF, repeatable procedures to skills, and workflow status plus OKF references to goals/tasks/pipelines. It forbids an independently maintained semantic copy in ICM.
136
+
137
+ For a claimed transition, provider-visible metadata contains current runtime version, prior runtime version when known, policy versions, and reason, but no control token. `first-observation` is explicitly an audit-only reason: it does not imply that existing memory is stale. Every transition cue says that version movement alone is not semantic evidence; source-backed revalidation and existing memory/skill approval gates remain mandatory.
138
+
139
+ The same cue ID is transiently injected into every provider request in that cue's one logical request loop: the first attempt, tool-loop continuations, and routed retries only. Injection stops on that loop's terminal success, terminal failure, or abort; a later unrelated external prompt must reconcile and claim independently and must never inherit the prior run token. No extra provider request is created. The first accepted request-plan commit marks durable cue state `consumed` and records the exact active-run review token; later injections inside the same loop are idempotent continuations of that one logical cue. `consumed` means delivered, not reviewed.
140
+
141
+ ### Successful completion
142
+
143
+ The sole completion hook is the existing non-retry `agent_end` path in `AgentSession._handleAgentEvent`. It may call compare-and-swap completion only when all conditions hold:
144
+
145
+ 1. the run has the exact token recorded by accepted-plan commit;
146
+ 2. reflection remains eligible and the session is root and non-disposed;
147
+ 3. `_willRetryAfterAgentEnd(event)` is false;
148
+ 4. the final assistant message has `stopReason === "stop"`, no `errorMessage`, and non-empty assistant text;
149
+ 5. under the file lock, the matching transition is still pending and its transition ID, claim ID, owner ID, runtime, and policy all match.
150
+
151
+ Error, abort, length/runaway stop, empty assistant, disposal, provider-plan rejection, stale token, failed request, or failed write cannot mark reviewed. A retry requeues the same logical cue through one revision-bumping cue-state transaction and extends the exact existing claim expiry without changing any token field, so the successful retry is still cue-bearing; ordinary branch-navigation cache invalidation therefore applies. A terminal failure releases the exact claim while leaving the transition pending for a later enabled external root turn. Process death is recovered by claim expiry.
152
+
153
+ `reviewed` means the current root model completed the required comparison. It does not claim that semantic memory changed; a valid evidence-based review may make no write. Completion, release, and stale-token handling are idempotent. Exactly one current-transition slot, one embedded claim, non-rotating same-owner renewal, locked claim-and-attach, and exact completion compare-and-swap prevent two live tokens from existing for one transition. Competing root sessions can preview ordinary cues, but only the claimed cue can complete the transition; first valid compare-and-swap wins.
154
+
155
+ ### Disabled learning
156
+
157
+ Resolved settings and environment kill switches are authoritative for reconciliation, cue delivery, and completion. Disabling mid-turn permits only exact-claim cleanup and leaves the semantic transition pending. Re-enabling later allows a new eligible external root turn to claim it.
158
+
159
+ ## Failure and compatibility behavior
160
+
161
+ - Missing state: initialize one pending first review on the next eligible external root request.
162
+ - Malformed closed-schema v1 state within the size bound: recover to one bounded pending state with reason `recovered-corrupt-state`, emit a bounded warning without raw file content, and never touch semantic memory.
163
+ - Unknown newer schema, unknown v1 keys, or oversize file: enter unsupported read-only mode, preserve bytes exactly, emit at most one bounded warning per session, keep ordinary turns usable, suppress version metadata, and block review completion until compatible code or explicit repair exists.
164
+ - Missing package-version metadata: record no claim or semantic review; emit one bounded warning and keep ordinary reflection usable.
165
+ - Atomic or lock failure: report a bounded warning, treat the operation as unsuccessful, and leave the prior file authoritative.
166
+ - Concurrent root sessions: one current-transition slot, lock serialization held through cue attachment, non-rotating same-owner renewal, atomic expiry takeover/supersession, and exact-token compare-and-swap prevent lost transitions, duplicate ownership, and false completion.
167
+ - Existing sessions and state files require no eager migration. The first compatible eligible request performs lazy, idempotent reconciliation.
168
+
169
+ ## Required tests
170
+
171
+ ### State unit tests
172
+
173
+ - Missing file creates one bounded pending first-observation transition; cue text treats it as audit-only and no reconciliation API can write semantic memory.
174
+ - Same runtime and policy reconcile twice without a second transition or observation revision increase.
175
+ - Runtime upgrade, downgrade, and policy-only change supersede the older pending transition and create the correct new identity.
176
+ - Repeated reconciliation coalesces one pending transition without unbounded growth; history retains only the newest 32 records.
177
+ - Claim acquisition, exact same-owner renewal that preserves every token field, live different-owner rejection, expiry takeover with predecessor revocation, release, and crash-recovery paths are deterministic under an injected clock; no path creates a second live claim and takeover prevents the old owner from renewing or completing.
178
+ - Successful exact-token completion marks exactly one transition reviewed; duplicate completion is a no-op.
179
+ - Stale transition, claim, runtime, policy, or older-session completion cannot close a newer pending transition.
180
+ - Corrupt supported v1 state recovers without touching memory files; warning text contains no raw state.
181
+ - Unknown newer schema, unknown v1 keys, and oversize files preserve exact bytes and create no lock/write footprint.
182
+ - Invalid version strings, timestamps, IDs, counts, outcomes, claims, and unsafe revisions fail closed.
183
+ - In-process child and worker construction/access leave zero filesystem footprint.
184
+ - Two real OS-thread roots cannot both own one live claim, lose a transition, or falsely complete after supersession.
185
+ - Atomic write and lock fault injection leaves prior bytes authoritative.
186
+
187
+ ### Reflection integration tests
188
+
189
+ - Root turn receives one logical cue with the full durable-learning taxonomy and exact canonical routing.
190
+ - One locked claim-and-attach operation atomically attaches one recognized `version-change` trigger plus provider-hidden exact token and bounded provider metadata without control IDs; same-owner renewal preserves the token and returns `coalesced`, while expiry takeover, exact release, or transition supersession revokes the predecessor before one `replaced-stale` cue revision.
191
+ - The same cue ID appears on the first request, tool-loop continuations, and routed retries of one logical request loop, while provider-request count remains unchanged; terminal completion clears the run token and a later unrelated external prompt cannot reuse it.
192
+ - First accepted plan commit means consumed/delivered only; preview, discarded plan, stale plan, and commit do not mark reviewed.
193
+ - Strict terminal success marks review only on matching non-retry `agent_end`; a direct spy on the completion boundary proves that no `markReviewed`/completion call occurs unless every listed success condition is true. Error, abort, length, runaway stop, empty text, disposal, failover/retry, handled extension error, and `errorMessage` retain pending state.
194
+ - Retry requeues the claimed cue; a later success without that cue cannot complete it.
195
+ - Internal-context, child, and worker turns receive no version cue and perform no state I/O.
196
+ - Each resolved setting/environment kill switch suppresses reconcile, claim, cue, and completion; mid-turn disable only releases the claim.
197
+ - Fallback runtime identity and unsupported schema warn once, preserve ordinary root reflection, and never complete version review.
198
+ - Existing trigger coalescing, exact-token idempotent coalescing, stale-token replacement after release/expiry/supersession, live different-owner rejection before cue attachment, branch navigation, stale-plan rejection, cue-state backward parsing, transcript non-persistence, and no-extra-provider-request behavior remain intact.
199
+
200
+ ### Canonical-truth negative tests
201
+
202
+ - Runtime reconciliation has no semantic-writer dependency and never edits `MEMORY.md`, `USER.md`, OKF records, skill files, goal/task state, or pipeline artifacts.
203
+ - Cue text routes project semantics to OKF and ICM workflow context to OKF references, never an independent duplicated fact.
204
+ - First-observation, runtime movement, and policy movement alone never authorize a semantic write.
205
+ - No transcript, raw tool result, real session ID, provider content, or secret-shaped input appears in runtime state, durable cue state, warnings, or provider-visible metadata.
206
+
207
+ ## Release acceptance
208
+
209
+ The implementation is releasable only when:
210
+
211
+ 1. Grok, Ox Alpha, Claude, and Agy explicitly accept the core invariant after adversarial review.
212
+ 2. Material dissent is either implemented or rejected with source-backed evidence and reviewer re-review.
213
+ 3. Focused state/reflection tests, package tests, type checks, repository checks, and build all pass.
214
+ 4. Documentation and changelog describe the state file, kill switches, canonical routing, compatibility, and recovery.
215
+ 5. Final commit is pushed through the authorized flow.
216
+ 6. Canonical release automation publishes the next patch version.
217
+ 7. Exact-head CI, tag, registry artifact, and installed runtime behavior are verified.
package/docs/settings.md CHANGED
@@ -272,7 +272,7 @@ Environment kill switches override their diagnostic layers: `PI_TOOL_REPAIR_DISA
272
272
 
273
273
  ### Auto Learn Advanced
274
274
 
275
- Native reflection belongs only to the main/orchestrator session. Eligible turns append a durable cue to the orchestrator's next ordinary current-session provider turn; reflection never starts a separate/background model request. Workers cannot run reflection or mutate durable memory; they return evidence to the parent, which decides what should be retained. A fresh main session uses this audited learning policy:
275
+ Native reflection belongs only to the main/orchestrator session. Each eligible external root turn carries one provider-only cue in that same current-session request; completed-turn evidence coalesces into the next eligible cue. Reflection never starts a separate/background model request. Workers cannot run reflection or mutate durable memory; they return evidence to the parent, which decides what should be retained. A fresh main session uses this audited learning policy:
276
276
 
277
277
  | Setting | Type | Default | Description |
278
278
  |---------|------|---------|-------------|
@@ -288,7 +288,7 @@ Safe `memory_add`, `okf_add`, and `okf_organize` writes can therefore land auton
288
288
 
289
289
  | Setting | Type | Default | Description |
290
290
  |---------|------|---------|-------------|
291
- | `autoLearn.enabled` | boolean | `true` in every autonomy mode | Enable root-session current-turn reflection. Disabling it immediately dismisses any pending cue and removes the standing reflection contract; re-enabling does not resurrect dismissed evidence. Automatic reflection never schedules a separate or background model request. |
291
+ | `autoLearn.enabled` | boolean | `true` in every autonomy mode | Enable root-session current-turn reflection. Disabling it immediately dismisses the session cue and releases any exact version claim. Re-enabling lets the next external root turn reconcile a still-pending version transition, but does not resurrect ordinary dismissed cue evidence. Automatic reflection never schedules a separate or background model request. |
292
292
  | `autoLearn.model` | string | `modelRouter.learningModel`, otherwise `"active"` | Legacy/direct override for the background learner; `"active"` uses the current session model, otherwise use a `pi --model` pattern |
293
293
  | `autoLearn.longSessionMessages` | number | `32` | Readiness threshold after this many message entries in the active branch for an eligible learner run |
294
294
  | `autoLearn.longSessionContextPercent` | number | `70` | Readiness threshold when current context usage reaches this percent |
@@ -296,10 +296,12 @@ Safe `memory_add`, `okf_add`, and `okf_organize` writes can therefore land auton
296
296
  | `autoLearn.leaseMinutes` | number | `90` | Shared-state lease duration for a running background learner |
297
297
  | `autoLearn.maxConcurrentLearners` | number | `1` | Maximum running Auto Learn background learners per session tenant |
298
298
  | `autoLearn.applyHighConfidence` | boolean | `false` | Allow the learner to apply high-confidence memory candidates; broader write authority is controlled by `autonomy.mode` |
299
- | `autoLearn.reflectionReview` | boolean | `true` | When enabled, allow root-only automatic reflection cues after eligible corrective or complex turns; the cue is consumed by the next ordinary current-session turn |
299
+ | `autoLearn.reflectionReview` | boolean | `true` | Allow root-only provider cues on eligible external turns. Corrective, durable, complex, and version-transition evidence coalesces into the one current cue; accepted delivery is distinct from strict terminal review completion. |
300
300
  | `autoLearn.reflectionMinToolCalls` | number | `12` | Queue a root-session reflection cue after this many tool calls in one completed turn |
301
301
  | `autoLearn.reflectionCooldownMinutes` | number | `1440` | Per-session-tenant cooldown between automatic root-session reflection cues; corrective and complex-task signals can bypass it |
302
302
 
303
+ Eligible root sessions also reconcile `~/.pi/agent/state/durable-learning-state.json`, which records only bounded runtime/memory-policy transition control state. First observation and version changes are audit cues, not semantic-write authority. Child and worker sessions receive no state owner; unsupported or oversized state remains byte-preserved and read-only. Canonical project truth routes to OKF, while ICM/workflow context keeps status plus OKF references instead of a duplicate fact copy.
304
+
303
305
  Use `/settings` → **Model Router** for the preferred place to choose the learner/skill-creator model. Automatic reflection uses the orchestrator's current session turn rather than a separate or background model request. Use `/settings` → **Auto Learn Advanced** for readiness/cooldown/concurrency overrides and the legacy direct `autoLearn.model` override. Use `/autonomy status` for the compact preset dashboard, `/auto-learn status` to inspect readiness and running leases, or `/auto-learn run` to explicitly start one bounded background learner immediately. Workers never receive reflection or durable-memory mutation authority; they return evidence to the root orchestrator.
304
306
 
305
307
  When enabled, Auto Learn keeps a small shared state file for visibility/cooldowns, but prompt/log/session artifacts are isolated under per-session-tenant directories so one session's learner does not consume another session's concurrency budget. Learners must confront available user/project memory first, using existing rules, preferences, corrections, and project facts to decide whether each candidate is useful, unique versus merge/upgrade-worthy, and agent-improving. Candidate validation is chunked/vectorized instead of one memory query per candidate. Successful Auto Learn workers purge their internal prompt/log/session artifacts after exit; the 7-day retention pruner is a fallback for unfinished or failed artifacts, and active leases are skipped so running learners are not raced. Provider/user history pruning is delegated to the continuous-learning tool after it records a learning outcome: only files older than 7 days whose current fingerprint still matches a successfully extracted index entry are deleted, and active/current sessions are protected.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider",
3
- "version": "0.96.4",
3
+ "version": "0.96.5",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-custom-provider",
9
- "version": "0.96.4",
9
+ "version": "0.96.5",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.52.0"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-anthropic",
3
3
  "private": true,
4
- "version": "0.96.4",
4
+ "version": "0.96.5",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-gitlab-duo",
3
3
  "private": true,
4
- "version": "0.96.4",
4
+ "version": "0.96.5",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
- "version": "0.96.4",
3
+ "version": "0.96.5",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-sandbox",
9
- "version": "0.96.4",
9
+ "version": "0.96.5",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sandbox-runtime": "^0.0.26"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
3
  "private": true,
4
- "version": "0.96.4",
4
+ "version": "0.96.5",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
- "version": "0.96.4",
3
+ "version": "0.96.5",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-with-deps",
9
- "version": "0.96.4",
9
+ "version": "0.96.5",
10
10
  "dependencies": {
11
11
  "ms": "^2.1.3"
12
12
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
3
  "private": true,
4
- "version": "0.96.4",
4
+ "version": "0.96.5",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@caupulican/pi-adaptative",
3
- "version": "0.96.4",
3
+ "version": "0.96.5",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@caupulican/pi-adaptative",
9
- "version": "0.96.4",
9
+ "version": "0.96.5",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@caupulican/pi-agent-core": "^0.96.4",
13
- "@caupulican/pi-ai": "^0.96.4",
14
- "@caupulican/pi-tui": "^0.96.4",
12
+ "@caupulican/pi-agent-core": "^0.96.5",
13
+ "@caupulican/pi-ai": "^0.96.5",
14
+ "@caupulican/pi-tui": "^0.96.5",
15
15
  "@silvia-odwyer/photon-node": "0.3.4",
16
16
  "chalk": "5.6.2",
17
17
  "cross-spawn": "7.0.6",
@@ -506,11 +506,11 @@
506
506
  }
507
507
  },
508
508
  "node_modules/@caupulican/pi-agent-core": {
509
- "version": "0.96.4",
510
- "resolved": "https://registry.npmjs.org/@caupulican/pi-agent-core/-/pi-agent-core-0.96.4.tgz",
509
+ "version": "0.96.5",
510
+ "resolved": "https://registry.npmjs.org/@caupulican/pi-agent-core/-/pi-agent-core-0.96.5.tgz",
511
511
  "license": "MIT",
512
512
  "dependencies": {
513
- "@caupulican/pi-ai": "^0.96.4",
513
+ "@caupulican/pi-ai": "^0.96.5",
514
514
  "ignore": "7.0.5",
515
515
  "typebox": "1.1.38",
516
516
  "yaml": "2.9.0"
@@ -520,8 +520,8 @@
520
520
  }
521
521
  },
522
522
  "node_modules/@caupulican/pi-ai": {
523
- "version": "0.96.4",
524
- "resolved": "https://registry.npmjs.org/@caupulican/pi-ai/-/pi-ai-0.96.4.tgz",
523
+ "version": "0.96.5",
524
+ "resolved": "https://registry.npmjs.org/@caupulican/pi-ai/-/pi-ai-0.96.5.tgz",
525
525
  "license": "MIT",
526
526
  "dependencies": {
527
527
  "@anthropic-ai/sdk": "0.117.1",
@@ -546,8 +546,8 @@
546
546
  }
547
547
  },
548
548
  "node_modules/@caupulican/pi-tui": {
549
- "version": "0.96.4",
550
- "resolved": "https://registry.npmjs.org/@caupulican/pi-tui/-/pi-tui-0.96.4.tgz",
549
+ "version": "0.96.5",
550
+ "resolved": "https://registry.npmjs.org/@caupulican/pi-tui/-/pi-tui-0.96.5.tgz",
551
551
  "license": "MIT",
552
552
  "dependencies": {
553
553
  "get-east-asian-width": "1.6.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caupulican/pi-adaptative",
3
- "version": "0.96.4",
3
+ "version": "0.96.5",
4
4
  "description": "Adaptive fork of Pi coding agent for self-evolving agent harness experiments",
5
5
  "type": "module",
6
6
  "piConfig": {
@@ -89,9 +89,9 @@
89
89
  "postinstall": "node scripts/postinstall-python-runtime.mjs"
90
90
  },
91
91
  "dependencies": {
92
- "@caupulican/pi-agent-core": "^0.96.4",
93
- "@caupulican/pi-ai": "^0.96.4",
94
- "@caupulican/pi-tui": "^0.96.4",
92
+ "@caupulican/pi-agent-core": "^0.96.5",
93
+ "@caupulican/pi-ai": "^0.96.5",
94
+ "@caupulican/pi-tui": "^0.96.5",
95
95
  "@silvia-odwyer/photon-node": "0.3.4",
96
96
  "chalk": "5.6.2",
97
97
  "cross-spawn": "7.0.6",