@animalabs/context-manager 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/dist/src/adaptive/chunker.d.ts +70 -0
  2. package/dist/src/adaptive/chunker.d.ts.map +1 -0
  3. package/dist/src/adaptive/chunker.js +233 -0
  4. package/dist/src/adaptive/chunker.js.map +1 -0
  5. package/dist/src/adaptive/folding-strategy.d.ts +118 -0
  6. package/dist/src/adaptive/folding-strategy.d.ts.map +1 -0
  7. package/dist/src/adaptive/folding-strategy.js +12 -0
  8. package/dist/src/adaptive/folding-strategy.js.map +1 -0
  9. package/dist/src/adaptive/index.d.ts +17 -0
  10. package/dist/src/adaptive/index.d.ts.map +1 -0
  11. package/dist/src/adaptive/index.js +23 -0
  12. package/dist/src/adaptive/index.js.map +1 -0
  13. package/dist/src/adaptive/picker.d.ts +103 -0
  14. package/dist/src/adaptive/picker.d.ts.map +1 -0
  15. package/dist/src/adaptive/picker.js +357 -0
  16. package/dist/src/adaptive/picker.js.map +1 -0
  17. package/dist/src/adaptive/render.d.ts +39 -0
  18. package/dist/src/adaptive/render.d.ts.map +1 -0
  19. package/dist/src/adaptive/render.js +104 -0
  20. package/dist/src/adaptive/render.js.map +1 -0
  21. package/dist/src/adaptive/strategies/flat-profile.d.ts +19 -0
  22. package/dist/src/adaptive/strategies/flat-profile.d.ts.map +1 -0
  23. package/dist/src/adaptive/strategies/flat-profile.js +86 -0
  24. package/dist/src/adaptive/strategies/flat-profile.js.map +1 -0
  25. package/dist/src/adaptive/strategies/oldest-first.d.ts +19 -0
  26. package/dist/src/adaptive/strategies/oldest-first.d.ts.map +1 -0
  27. package/dist/src/adaptive/strategies/oldest-first.js +39 -0
  28. package/dist/src/adaptive/strategies/oldest-first.js.map +1 -0
  29. package/dist/src/context-manager.d.ts +74 -2
  30. package/dist/src/context-manager.d.ts.map +1 -1
  31. package/dist/src/context-manager.js +150 -10
  32. package/dist/src/context-manager.js.map +1 -1
  33. package/dist/src/index.d.ts +1 -1
  34. package/dist/src/index.d.ts.map +1 -1
  35. package/dist/src/index.js.map +1 -1
  36. package/dist/src/message-store.d.ts +36 -1
  37. package/dist/src/message-store.d.ts.map +1 -1
  38. package/dist/src/message-store.js +134 -8
  39. package/dist/src/message-store.js.map +1 -1
  40. package/dist/src/strategies/autobiographical.d.ts +422 -5
  41. package/dist/src/strategies/autobiographical.d.ts.map +1 -1
  42. package/dist/src/strategies/autobiographical.js +2248 -98
  43. package/dist/src/strategies/autobiographical.js.map +1 -1
  44. package/dist/src/strategies/index.d.ts +1 -1
  45. package/dist/src/strategies/index.d.ts.map +1 -1
  46. package/dist/src/strategies/index.js.map +1 -1
  47. package/dist/src/types/index.d.ts +2 -2
  48. package/dist/src/types/index.d.ts.map +1 -1
  49. package/dist/src/types/index.js +1 -1
  50. package/dist/src/types/index.js.map +1 -1
  51. package/dist/src/types/message.d.ts +38 -0
  52. package/dist/src/types/message.d.ts.map +1 -1
  53. package/dist/src/types/strategy.d.ts +302 -10
  54. package/dist/src/types/strategy.d.ts.map +1 -1
  55. package/dist/src/types/strategy.js +28 -0
  56. package/dist/src/types/strategy.js.map +1 -1
  57. package/dist/test/adaptive/branching.test.d.ts +20 -0
  58. package/dist/test/adaptive/branching.test.d.ts.map +1 -0
  59. package/dist/test/adaptive/branching.test.js +176 -0
  60. package/dist/test/adaptive/branching.test.js.map +1 -0
  61. package/dist/test/adaptive/chunker.test.d.ts +2 -0
  62. package/dist/test/adaptive/chunker.test.d.ts.map +1 -0
  63. package/dist/test/adaptive/chunker.test.js +120 -0
  64. package/dist/test/adaptive/chunker.test.js.map +1 -0
  65. package/dist/test/adaptive/deep-levels.test.d.ts +10 -0
  66. package/dist/test/adaptive/deep-levels.test.d.ts.map +1 -0
  67. package/dist/test/adaptive/deep-levels.test.js +167 -0
  68. package/dist/test/adaptive/deep-levels.test.js.map +1 -0
  69. package/dist/test/adaptive/doc-plus-chat.test.d.ts +10 -0
  70. package/dist/test/adaptive/doc-plus-chat.test.d.ts.map +1 -0
  71. package/dist/test/adaptive/doc-plus-chat.test.js +194 -0
  72. package/dist/test/adaptive/doc-plus-chat.test.js.map +1 -0
  73. package/dist/test/adaptive/hard-fail.test.d.ts +9 -0
  74. package/dist/test/adaptive/hard-fail.test.d.ts.map +1 -0
  75. package/dist/test/adaptive/hard-fail.test.js +154 -0
  76. package/dist/test/adaptive/hard-fail.test.js.map +1 -0
  77. package/dist/test/adaptive/harness.d.ts +109 -0
  78. package/dist/test/adaptive/harness.d.ts.map +1 -0
  79. package/dist/test/adaptive/harness.js +263 -0
  80. package/dist/test/adaptive/harness.js.map +1 -0
  81. package/dist/test/adaptive/ingestion.test.d.ts +13 -0
  82. package/dist/test/adaptive/ingestion.test.d.ts.map +1 -0
  83. package/dist/test/adaptive/ingestion.test.js +306 -0
  84. package/dist/test/adaptive/ingestion.test.js.map +1 -0
  85. package/dist/test/adaptive/integration.test.d.ts +12 -0
  86. package/dist/test/adaptive/integration.test.d.ts.map +1 -0
  87. package/dist/test/adaptive/integration.test.js +247 -0
  88. package/dist/test/adaptive/integration.test.js.map +1 -0
  89. package/dist/test/adaptive/long-chronicle.test.d.ts +13 -0
  90. package/dist/test/adaptive/long-chronicle.test.d.ts.map +1 -0
  91. package/dist/test/adaptive/long-chronicle.test.js +186 -0
  92. package/dist/test/adaptive/long-chronicle.test.js.map +1 -0
  93. package/dist/test/adaptive/persistence.test.d.ts +11 -0
  94. package/dist/test/adaptive/persistence.test.d.ts.map +1 -0
  95. package/dist/test/adaptive/persistence.test.js +200 -0
  96. package/dist/test/adaptive/persistence.test.js.map +1 -0
  97. package/dist/test/adaptive/picker.test.d.ts +2 -0
  98. package/dist/test/adaptive/picker.test.d.ts.map +1 -0
  99. package/dist/test/adaptive/picker.test.js +333 -0
  100. package/dist/test/adaptive/picker.test.js.map +1 -0
  101. package/dist/test/adaptive/render.test.d.ts +2 -0
  102. package/dist/test/adaptive/render.test.d.ts.map +1 -0
  103. package/dist/test/adaptive/render.test.js +109 -0
  104. package/dist/test/adaptive/render.test.js.map +1 -0
  105. package/dist/test/adaptive/shard-immutability.test.d.ts +14 -0
  106. package/dist/test/adaptive/shard-immutability.test.d.ts.map +1 -0
  107. package/dist/test/adaptive/shard-immutability.test.js +184 -0
  108. package/dist/test/adaptive/shard-immutability.test.js.map +1 -0
  109. package/dist/test/adaptive/strategy-integration.test.d.ts +9 -0
  110. package/dist/test/adaptive/strategy-integration.test.d.ts.map +1 -0
  111. package/dist/test/adaptive/strategy-integration.test.js +293 -0
  112. package/dist/test/adaptive/strategy-integration.test.js.map +1 -0
  113. package/dist/test/message-store-sequence.test.d.ts +25 -0
  114. package/dist/test/message-store-sequence.test.d.ts.map +1 -0
  115. package/dist/test/message-store-sequence.test.js +157 -0
  116. package/dist/test/message-store-sequence.test.js.map +1 -0
  117. package/dist/test/non-blocking-compile.test.d.ts +22 -0
  118. package/dist/test/non-blocking-compile.test.d.ts.map +1 -0
  119. package/dist/test/non-blocking-compile.test.js +114 -0
  120. package/dist/test/non-blocking-compile.test.js.map +1 -0
  121. package/dist/test/pins.test.d.ts +10 -0
  122. package/dist/test/pins.test.d.ts.map +1 -0
  123. package/dist/test/pins.test.js +164 -0
  124. package/dist/test/pins.test.js.map +1 -0
  125. package/dist/test/recall-positioning.test.d.ts +16 -0
  126. package/dist/test/recall-positioning.test.d.ts.map +1 -0
  127. package/dist/test/recall-positioning.test.js +181 -0
  128. package/dist/test/recall-positioning.test.js.map +1 -0
  129. package/dist/test/search.test.d.ts +10 -0
  130. package/dist/test/search.test.d.ts.map +1 -0
  131. package/dist/test/search.test.js +141 -0
  132. package/dist/test/search.test.js.map +1 -0
  133. package/dist/test/speculation-cap.test.d.ts +17 -0
  134. package/dist/test/speculation-cap.test.d.ts.map +1 -0
  135. package/dist/test/speculation-cap.test.js +157 -0
  136. package/dist/test/speculation-cap.test.js.map +1 -0
  137. package/dist/test/strategy-persistence.test.d.ts +15 -0
  138. package/dist/test/strategy-persistence.test.d.ts.map +1 -0
  139. package/dist/test/strategy-persistence.test.js +244 -0
  140. package/dist/test/strategy-persistence.test.js.map +1 -0
  141. package/dist/test/tool-pruning.test.d.ts +10 -0
  142. package/dist/test/tool-pruning.test.d.ts.map +1 -0
  143. package/dist/test/tool-pruning.test.js +140 -0
  144. package/dist/test/tool-pruning.test.js.map +1 -0
  145. package/dist/tsconfig.tsbuildinfo +1 -1
  146. package/package.json +1 -1
  147. package/src/adaptive/chunker.ts +323 -0
  148. package/src/adaptive/folding-strategy.ts +129 -0
  149. package/src/adaptive/index.ts +51 -0
  150. package/src/adaptive/picker.ts +442 -0
  151. package/src/adaptive/render.ts +115 -0
  152. package/src/adaptive/strategies/flat-profile.ts +96 -0
  153. package/src/adaptive/strategies/oldest-first.ts +48 -0
  154. package/src/context-manager.ts +174 -10
  155. package/src/index.ts +1 -1
  156. package/src/message-store.ts +147 -8
  157. package/src/strategies/autobiographical.ts +2468 -166
  158. package/src/strategies/index.ts +1 -1
  159. package/src/types/index.ts +14 -1
  160. package/src/types/message.ts +43 -0
  161. package/src/types/strategy.ts +332 -10
@@ -1,6 +1,11 @@
1
+ import type { JsStore } from '@animalabs/chronicle';
1
2
  import type { ContentBlock } from '@animalabs/membrane';
2
3
  import { NativeFormatter } from '@animalabs/membrane';
3
- import type { ResettableStrategy, StrategyContext, ReadinessState, MessageStoreView, ContextLogView, TokenBudget, ContextEntry, StoredMessage, AutobiographicalConfig, SummaryLevel, SummaryEntry } from '../types/index.js';
4
+ import type { ResettableStrategy, StrategyContext, ReadinessState, MessageStoreView, ContextLogView, TokenBudget, ContextEntry, StoredMessage, AutobiographicalConfig, SummaryLevel, SummaryEntry, ProtectedRange, SearchQuery, SearchResult } from '../types/index.js';
5
+ import { Picker } from '../adaptive/picker.js';
6
+ import type { FoldOp } from '../adaptive/folding-strategy.js';
7
+ import type { MessageId } from '../types/message.js';
8
+ import type { IngressChunkResult } from '../types/strategy.js';
4
9
  /**
5
10
  * Chunk of messages to be compressed.
6
11
  */
@@ -26,6 +31,30 @@ export interface Chunk {
26
31
  /** Phase type tag (set by KnowledgeStrategy for semantic chunking) */
27
32
  phaseType?: string;
28
33
  }
34
+ /**
35
+ * Point-in-time snapshot of compression progress, returned from
36
+ * `AutobiographicalStrategy.getProgressSnapshot()`. External observers
37
+ * (warmup scripts, dashboards) use this to track convergence without
38
+ * reaching into the strategy's protected fields.
39
+ */
40
+ export interface AutobiographicalProgressSnapshot {
41
+ /** All chunks the strategy is tracking, compressed or not. */
42
+ totalChunks: number;
43
+ /** Chunks that already have an L1 summary. */
44
+ chunksCompressed: number;
45
+ /** Chunks queued for L1 compression. */
46
+ l1QueueLength: number;
47
+ /** Pending L1→L2 and L2→L3 merges. */
48
+ mergeQueueLength: number;
49
+ /** Stored summary counts per level (1 = raw L1, 2 = L1→L2 merge, 3 = L2→L3 merge). */
50
+ summaryCounts: {
51
+ l1: number;
52
+ l2: number;
53
+ l3: number;
54
+ };
55
+ /** True if a compression or merge LLM call is currently in flight. */
56
+ pending: boolean;
57
+ }
29
58
  /**
30
59
  * Autobiographical chunking strategy.
31
60
  * Compresses old conversation chunks into summaries in the model's own words.
@@ -54,11 +83,231 @@ export declare class AutobiographicalStrategy implements ResettableStrategy {
54
83
  protected headWindowStartId: string | null;
55
84
  /** Cached result of getHeadWindowStartIndex to avoid repeated linear scans. */
56
85
  private _cachedHeadStartIndex;
86
+ /** Chronicle store for persistent state. Set in `initialize()`. */
87
+ protected store: JsStore | null;
88
+ /** Namespace for state-id scoping. Set in `initialize()`. */
89
+ protected ns: string;
90
+ protected get summariesStateId(): string;
91
+ protected get counterStateId(): string;
92
+ protected get mergeQueueStateId(): string;
93
+ protected get pinsStateId(): string;
94
+ protected get resolutionsStateId(): string;
95
+ protected get locksStateId(): string;
96
+ /** Protected ranges (pins + documents). Loaded from chronicle in initialize. */
97
+ protected pins: ProtectedRange[];
98
+ /** Monotonically increasing counter for pin ids. Persisted as part of the pins snapshot. */
99
+ protected pinIdCounter: number;
100
+ /**
101
+ * Per-message resolution state for the adaptive-resolution picker.
102
+ * - Key: MessageId
103
+ * - Value: currentResolution (0 = render raw, k>0 = render L_k recall)
104
+ *
105
+ * Maintained only when `config.adaptiveResolution` is true. Loaded from
106
+ * the chronicle on `initialize()` and persisted via the resolutions state
107
+ * slot so resolutions survive process restart and follow branches.
108
+ */
109
+ protected resolutions: Map<MessageId, number>;
110
+ /**
111
+ * Per-message lock state for the adaptive-resolution picker. Set via the
112
+ * programmatic `lockChunk(id)` API on the strategy. Locked messages are
113
+ * skipped by the picker. Persisted via the locks state slot.
114
+ */
115
+ protected locked: Set<MessageId>;
116
+ /** Lazy picker instance, built from config.foldingStrategy. */
117
+ private _adaptivePicker;
57
118
  constructor(config?: Partial<AutobiographicalConfig>);
119
+ /**
120
+ * Lock a message so the adaptive picker won't change its resolution.
121
+ * No-op when adaptiveResolution is false. Set-only programmatic API per
122
+ * the design (no agent-facing tool in V1). Persisted to chronicle.
123
+ */
124
+ lockChunk(id: MessageId): void;
125
+ /**
126
+ * Unlock a message so the adaptive picker may again change its resolution.
127
+ * No-op when adaptiveResolution is false. Persisted to chronicle.
128
+ */
129
+ unlockChunk(id: MessageId): void;
130
+ /**
131
+ * Ingestion-time chunking hook.
132
+ *
133
+ * Active only when `config.adaptiveResolution` is true. Inspects the
134
+ * incoming message's text content; if its approximate token count
135
+ * exceeds the chunker's threshold, splits it into shards with a stable
136
+ * shared `bodyGroupId`. The framework then stores each shard as its own
137
+ * StoredMessage, and the render path concatenates them back into one
138
+ * API message at compile time (preserving KV cache structure).
139
+ *
140
+ * Multi-block content: text blocks are concatenated for chunking, then
141
+ * the resulting shards are emitted as text blocks. Non-text blocks
142
+ * (images, tool results) are passed through unchanged on the first
143
+ * shard only — they don't get split.
144
+ *
145
+ * See `docs/adaptive-resolution-design.md` §3.6.
146
+ */
147
+ chunkIngressMessage(participant: string, content: ContentBlock[]): IngressChunkResult | null;
58
148
  initialize(ctx: StrategyContext): Promise<void>;
149
+ /**
150
+ * Register the three Chronicle state slots this strategy uses.
151
+ * Idempotent — chronicle throws if a state is already registered, which we
152
+ * swallow (the existing slot is what we want).
153
+ */
154
+ protected registerStates(): void;
155
+ /**
156
+ * Load summaries, counter, and pending merges from chronicle into the
157
+ * in-memory mirrors. Called on every (re)initialize so branch switches
158
+ * pick up the new branch's state.
159
+ */
160
+ protected loadPersistedState(): void;
161
+ /** Persist the current pins + counter as a single snapshot. */
162
+ protected persistPins(): void;
163
+ /** Persist the current resolutions snapshot. Only stores non-zero entries
164
+ * to keep the slot compact. */
165
+ protected persistResolutions(): void;
166
+ /** Persist the current locked-id snapshot. */
167
+ protected persistLocks(): void;
168
+ /**
169
+ * Pin a range of messages so they aren't compressed and render raw at
170
+ * their original position. Returns the pin id.
171
+ */
172
+ pinRange(firstMessageId: string, lastMessageId: string, opts?: {
173
+ name?: string;
174
+ }): string;
175
+ /**
176
+ * Mark a single message as a "document" — semantically a body of
177
+ * information the agent wants to retain in full. Functionally a
178
+ * single-message pin with `kind: 'document'`.
179
+ */
180
+ markDocument(messageId: string, opts?: {
181
+ name?: string;
182
+ }): string;
183
+ /** Remove a pin or document mark by id. Returns true if removed. */
184
+ unpin(pinId: string): boolean;
185
+ /** Read-only list of all current pins. */
186
+ listPins(): ReadonlyArray<ProtectedRange>;
187
+ /**
188
+ * Look up a single summary by id. Returns null if not found.
189
+ */
190
+ getSummary(id: string): SummaryEntry | null;
191
+ /**
192
+ * Search summaries by substring or regex over their content.
193
+ *
194
+ * Result ordering: matches by descending hit count, then by descending
195
+ * `created` timestamp (newest first within the same hit count).
196
+ *
197
+ * Default behavior: only "live" (unmerged) summaries are searched. Set
198
+ * `includeMerged: true` to also include summaries that have been folded
199
+ * into a higher level.
200
+ */
201
+ searchSummaries(query: SearchQuery): SearchResult[];
202
+ /**
203
+ * Whether a given message position is inside any protected range.
204
+ * Uses a position map (computed by caller) so callers can avoid
205
+ * repeated per-message lookups in tight loops.
206
+ */
207
+ protected isPositionPinned(position: number, pinPositions: Set<number>): boolean;
208
+ /**
209
+ * Build a set of message-store positions covered by any pin. O(N pins · K range).
210
+ * Returns positions for which the message exists; orphan pins (deleted
211
+ * messages) are silently skipped.
212
+ */
213
+ protected pinnedPositions(messages: StoredMessage[]): Set<number>;
214
+ /**
215
+ * Append a summary to the in-memory list and to the chronicle AppendLog.
216
+ * Single point so subclasses inherit persistence.
217
+ */
218
+ protected pushSummary(entry: SummaryEntry): void;
219
+ /**
220
+ * Mark a summary as merged into a higher-level summary, updating the
221
+ * chronicle copy at the same index. Index is the position in `this.summaries`.
222
+ */
223
+ protected setMergedInto(entry: SummaryEntry, mergedIntoId: string): void;
224
+ /**
225
+ * Allocate the next summary-id counter value and persist the new counter.
226
+ */
227
+ protected nextSummaryIdCounter(): number;
228
+ /**
229
+ * Push to the merge queue and persist the new queue snapshot.
230
+ */
231
+ protected enqueueMerge(merge: {
232
+ level: SummaryLevel;
233
+ sourceIds: string[];
234
+ }): void;
235
+ /**
236
+ * Pop from the merge queue and persist the new queue snapshot.
237
+ */
238
+ protected dequeueMerge(): {
239
+ level: SummaryLevel;
240
+ sourceIds: string[];
241
+ } | undefined;
242
+ /**
243
+ * Translate produce ops emitted by the picker into concrete work items on
244
+ * the strategy's own queues. Two cases:
245
+ *
246
+ * - `level === 1`: the picker has asked for L1 coverage on a raw chunk.
247
+ * In the autobio chunker model, each chunk maps to exactly one L1, so
248
+ * we locate the chunk whose messages fall in `op.range` and ensure
249
+ * it is queued for L1 compression. If the chunker hasn't realized the
250
+ * message yet, we skip silently — the next `rebuildChunks` will pick
251
+ * it up.
252
+ *
253
+ * - `level >= 2`: the picker has asked for an L_n covering a contiguous
254
+ * range. We gather unmerged L_{n-1} summaries whose source ranges
255
+ * fall within that range (de-duplicated against entries already in
256
+ * `mergeQueue`) and enqueue a single merge over them. The merge fires
257
+ * on the next `tick()`.
258
+ *
259
+ * The handler is conservative: it never enqueues a singleton or empty
260
+ * merge, and it never re-enqueues an id that's already pending. That
261
+ * keeps the next-compile picker loop convergent even when the same
262
+ * produce op gets re-emitted before the work completes.
263
+ */
264
+ protected handleProducedOps(ops: readonly FoldOp[]): void;
265
+ /**
266
+ * Ensure that chunks whose message range overlaps [firstMsgId..lastMsgId]
267
+ * are queued for L1 compression. No-op if the matching chunk is already
268
+ * compressed or already in the queue.
269
+ */
270
+ protected enqueueL1ForRange(firstMsgId: MessageId, lastMsgId: MessageId): void;
271
+ /**
272
+ * Enqueue an L_{targetLevel} merge over unmerged L_{targetLevel-1}
273
+ * summaries whose source ranges fall within [firstMsgId..lastMsgId].
274
+ * No-op if fewer than 2 viable sources are available (a singleton merge
275
+ * would just rename a summary without consolidating).
276
+ */
277
+ protected enqueueMergeForRange(targetLevel: number, firstMsgId: MessageId, lastMsgId: MessageId): void;
59
278
  checkReadiness(): ReadinessState;
60
279
  onNewMessage(message: StoredMessage, ctx: StrategyContext): Promise<void>;
280
+ /**
281
+ * Background-drain loop: keeps calling tick() while there's queued work,
282
+ * subject to the speculation cap and preflight hook. Recurses via
283
+ * `queueMicrotask` so one chunk's compression doesn't block the
284
+ * scheduling of the next.
285
+ *
286
+ * Stops if a tick fails to make progress (queue size unchanged) — guards
287
+ * against runaway recursion when tick is a no-op (e.g. no membrane
288
+ * configured, or a subclass override that doesn't process the queue).
289
+ */
290
+ protected driveSpeculativeDrain(ctx: StrategyContext): void;
291
+ /**
292
+ * Whether the strategy's pending+queued L1 budget has reached the cap
293
+ * configured by `maxSpeculativeL1s`. If no cap is set, always false.
294
+ */
295
+ protected isAtSpeculativeCap(): boolean;
296
+ /**
297
+ * Preflight hook for whether speculative compression should fire on
298
+ * `onNewMessage`. Returns true by default (current eager behavior).
299
+ * Subclasses can override for predictive scheduling — e.g. only fire
300
+ * when the live tail token count is approaching some threshold.
301
+ */
302
+ protected shouldCompressPreflight(): boolean;
61
303
  tick(ctx: StrategyContext): Promise<void>;
304
+ /**
305
+ * Snapshot of compression progress. Intended for external observers
306
+ * (warmup scripts, dashboards) that need to track convergence without
307
+ * reaching into protected fields. Values are point-in-time copies; mutating
308
+ * them does not affect strategy state.
309
+ */
310
+ getProgressSnapshot(): AutobiographicalProgressSnapshot;
62
311
  select(store: MessageStoreView, log: ContextLogView, budget: TokenBudget): ContextEntry[];
63
312
  /**
64
313
  * Get summary statistics for observability.
@@ -72,6 +321,43 @@ export declare class AutobiographicalStrategy implements ResettableStrategy {
72
321
  l3: number;
73
322
  pendingMerges: number;
74
323
  };
324
+ /**
325
+ * Richer per-render stats: requires a message store view to compute the
326
+ * head + tail (recent window) sizes. Returns counts AND token sums per
327
+ * summary level, so observers can see "how much of the agent's context
328
+ * is in raw tail vs folded into L1/L2/L3."
329
+ *
330
+ * Useful for TUI / dashboards. The token sums use the strategy's own
331
+ * token estimates (which match what `select()` uses for budget math).
332
+ */
333
+ getRenderStats(store: MessageStoreView): {
334
+ head: {
335
+ messages: number;
336
+ tokens: number;
337
+ };
338
+ tail: {
339
+ messages: number;
340
+ tokens: number;
341
+ };
342
+ summaries: {
343
+ l1: {
344
+ count: number;
345
+ tokens: number;
346
+ };
347
+ l2: {
348
+ count: number;
349
+ tokens: number;
350
+ };
351
+ l3: {
352
+ count: number;
353
+ tokens: number;
354
+ };
355
+ };
356
+ pending: {
357
+ chunks: number;
358
+ merges: number;
359
+ };
360
+ };
75
361
  protected selectLegacy(store: MessageStoreView, _log: ContextLogView, budget: TokenBudget): ContextEntry[];
76
362
  /**
77
363
  * Emit recent-window messages, evicting OLDEST-first when the budget is tight.
@@ -109,28 +395,123 @@ export declare class AutobiographicalStrategy implements ResettableStrategy {
109
395
  /**
110
396
  * Check if unmerged summary counts exceed the merge threshold.
111
397
  * Enqueues merge operations if so.
398
+ *
399
+ * Skips L1s/L2s that are already in a pending merge — without this guard,
400
+ * each new summary above threshold re-enqueues a merge for the same
401
+ * already-eligible siblings, producing N near-identical higher-level
402
+ * summaries when the queue eventually drains.
112
403
  */
113
404
  protected checkMergeThreshold(): void;
405
+ /**
406
+ * Bottom-up speculative pre-producer (design doc §3.5 / §7.2).
407
+ *
408
+ * Recursive variant of `checkMergeThreshold` for the unbounded L_n
409
+ * design. Walks every level present in the archive; for any level k
410
+ * with ≥ N orphans (no parent), enqueues an L_{k+1} merge. After that
411
+ * L_{k+1} is produced and `executeMerge` calls this again, the recursion
412
+ * naturally cascades: 6 L1s → 1 L2; 6 L2s → 1 L3; 6 L3s → 1 L4; ...
413
+ *
414
+ * Only fires when `config.speculativeProduction` is true. Default true
415
+ * for adaptiveResolution=true, false otherwise. The non-speculative path
416
+ * (above) preserves the original L1→L2→L3 behavior for non-adaptive
417
+ * deployments.
418
+ */
419
+ protected checkMergeThresholdRecursive(): void;
114
420
  /**
115
421
  * Merge N summaries at one level into a single summary at the next level.
116
422
  * Uses self-voice consolidation prompt.
117
423
  */
118
424
  protected executeMerge(targetLevel: SummaryLevel, sourceIds: string[], ctx: StrategyContext): Promise<void>;
425
+ /**
426
+ * Select context entries using the adaptive-resolution picker.
427
+ *
428
+ * Builds per-message PickerChunks from compressible messages, runs the
429
+ * configured FoldingStrategy under token-budget pressure, and emits the
430
+ * resulting per-message resolutions as ContextEntry[]. Adjacent messages
431
+ * sharing the same L_k ancestor emit the recall pair once.
432
+ *
433
+ * See `docs/adaptive-resolution-design.md` §3, §5.
434
+ */
435
+ protected selectAdaptive(store: MessageStoreView, budget: TokenBudget): ContextEntry[];
436
+ /**
437
+ * Walk an entries array; for every run of consecutive entries that
438
+ * (a) have sourceRelation: 'copy' (raw, not a synthesized recall pair)
439
+ * (b) have sourceMessageId pointing to messages in the same bodyGroup
440
+ * merge them into one composite entry whose body is the byte-faithful
441
+ * concatenation of their text content. Other entries pass through.
442
+ *
443
+ * Reindexes the returned array.
444
+ */
445
+ protected mergeAdjacentBodyGroupRaw(entries: ContextEntry[], store: MessageStoreView): ContextEntry[];
446
+ /** Get (lazily constructing) the configured picker instance. */
447
+ protected getAdaptivePicker(): Picker;
448
+ /**
449
+ * Walk the summary tree to find the L_k ancestor of a message.
450
+ * Returns null if no ancestor exists at that level (e.g., L_k not yet produced).
451
+ *
452
+ * Takes a pre-built summariesById map to avoid O(summaries) lookups per
453
+ * call — for a chronicle with thousands of summaries and hundreds of
454
+ * middle messages, the O(n) `find` would dominate compile latency.
455
+ */
456
+ protected findAncestorAt(messageId: MessageId, level: number, chunksByMessageId: ReadonlyMap<MessageId, Chunk>, summariesById?: ReadonlyMap<string, SummaryEntry>): SummaryEntry | null;
119
457
  /**
120
458
  * Select context entries using hierarchical compression with budget carryover.
121
459
  * Matches moltbot's budget waterfall: L3 → L2 → L1 with unused budget flowing down.
122
460
  */
123
461
  protected selectHierarchical(store: MessageStoreView, budget: TokenBudget): ContextEntry[];
124
462
  /**
125
- * Build the compression instruction for an L1 chunk.
126
- * Override in subclasses for phase-aware prompts.
463
+ * Build the compression instruction for an L1 chunk in the hierarchical
464
+ * path. Override in subclasses for domain-specific prompts (e.g.,
465
+ * phase-aware prompts in KnowledgeStrategy).
466
+ *
467
+ * Default returns the KV-preserving first-person instruction matching
468
+ * the hermes-autobio spec. The doc/reading-mode variant is exposed via
469
+ * {@link getReadingChunkInstruction}.
127
470
  */
128
471
  protected getCompressionInstruction(chunk: Chunk, targetTokens: number): string;
472
+ /**
473
+ * Build the compression instruction for an L1 chunk that is part of a
474
+ * substantially larger sharded message (reading mode). Override in
475
+ * subclasses if domain logic needs to vary the reading-mode prompt.
476
+ *
477
+ * Default returns the reading-mode instruction that asks the model to
478
+ * reflect on what reading was like rather than form a memory "of what
479
+ * the chunk contained", which prevents voice drift into the content
480
+ * author's perspective.
481
+ */
482
+ protected getReadingChunkInstruction(chunk: Chunk, totalTokens: number, targetTokens: number): string;
483
+ /**
484
+ * If the chunk is part of a substantially larger sharded message (total
485
+ * bodyGroup tokens ≥ 2× the chunk's own tokens), return reading-context
486
+ * metadata for the reading instruction. The 2× threshold means the
487
+ * chunk represents a portion of something significantly larger — the
488
+ * agent is reading, not conversing.
489
+ *
490
+ * Returns null when the chunk is a whole message (no bodyGroup), or
491
+ * when bodyGroup total is < 2× chunk size (degenerate case — chunk
492
+ * effectively IS the whole message). In those cases the standard
493
+ * (non-reading) instruction is appropriate.
494
+ */
495
+ protected detectDocContext(chunk: Chunk, ctx: StrategyContext): {
496
+ totalTokens: number;
497
+ chunkTokens: number;
498
+ } | null;
129
499
  /**
130
500
  * Build the merge instruction for combining summaries into a higher level.
131
501
  * Override in subclasses for domain-specific merge prompts.
502
+ *
503
+ * Default returns the KV-preserving merge instruction. The reading-mode
504
+ * variant (used when all leaves share a bodyGroup of substantial size)
505
+ * is exposed via {@link getReadingMergeInstruction}.
132
506
  */
133
507
  protected getMergeInstruction(targetLevel: SummaryLevel, sources: SummaryEntry[], targetTokens: number): string;
508
+ /**
509
+ * Build the reading-mode merge instruction. Used when all leaf messages
510
+ * underlying the merge share a bodyGroup of substantial size — the agent
511
+ * has been reading a doc rather than conversing. Override in subclasses
512
+ * if domain logic needs to vary the reading-mode merge prompt.
513
+ */
514
+ protected getReadingMergeInstruction(targetLevel: SummaryLevel, sources: SummaryEntry[], totalTokens: number, targetTokens: number): string;
134
515
  /**
135
516
  * Select L1 summaries within a budget. Returns selected summaries and tokens used.
136
517
  * Override in subclasses for asymmetric budget allocation (e.g., cap research, prioritize synthesis).
@@ -139,6 +520,26 @@ export declare class AutobiographicalStrategy implements ResettableStrategy {
139
520
  selected: SummaryEntry[];
140
521
  tokensUsed: number;
141
522
  };
523
+ /**
524
+ * True if `projectedTotal` exceeds `max` AND the strategy is configured
525
+ * to enforce budget. When `enforceBudget: false`, always returns false
526
+ * — the rendering pipeline emits the full ideal context regardless of
527
+ * budget overage. Caller's API will reject if it exceeds the model's
528
+ * context window; the philosophy is "surface overage, don't hide it."
529
+ */
530
+ protected isOverBudget(projectedTotal: number, max: number): boolean;
531
+ /**
532
+ * Sort selected summaries by source-range start position, so per-pair
533
+ * recall emission appears in chronological order. Falls back to the
534
+ * created timestamp for summaries whose source-range first message is
535
+ * no longer in the store.
536
+ */
537
+ protected sortSummariesChronologically(summaries: SummaryEntry[], messages: StoredMessage[]): SummaryEntry[];
538
+ /**
539
+ * Render the per-pair recall header from the configured template.
540
+ * Substitutions: {id} {level} {first} {last}.
541
+ */
542
+ protected buildRecallHeader(summary: SummaryEntry): string;
142
543
  /**
143
544
  * Reset the head window to start from a new message ID.
144
545
  * Old head window messages become compressible on the next chunk rebuild.
@@ -158,8 +559,10 @@ export declare class AutobiographicalStrategy implements ResettableStrategy {
158
559
  */
159
560
  protected extractText(content: ContentBlock[]): string;
160
561
  /**
161
- * Get messages in the compressible zone: outside both head window and recent window.
162
- * Returns messages from [0, headStart) [headEnd, recentStart).
562
+ * Get messages in the compressible zone: outside both head window and
563
+ * recent window AND not inside any pinned range. Returns messages from
564
+ * [0, headStart) ∪ [headEnd, recentStart) minus any positions covered
565
+ * by a pin or document mark.
163
566
  */
164
567
  protected getCompressibleMessages(store: MessageStoreView): StoredMessage[];
165
568
  /**
@@ -188,6 +591,20 @@ export declare class AutobiographicalStrategy implements ResettableStrategy {
188
591
  * a tool_use message and its tool_result response.
189
592
  */
190
593
  private trimOrphanedToolUse;
594
+ /**
595
+ * Prune tool_use / tool_result blocks in-place:
596
+ * 1. Truncate `tool_use.input` blocks whose serialized JSON exceeds
597
+ * `toolUseInputMaxTokens`.
598
+ * 2. For each tool name, keep only the last N `tool_result` blocks
599
+ * per `toolResultMaxLastN`; older ones get their `content` replaced
600
+ * with a brief marker referencing the tool name and how many newer
601
+ * results exist below.
602
+ *
603
+ * Both passes are no-ops when the corresponding config is unset/0.
604
+ * Pruning runs AFTER selection and orphan-trimming, so it doesn't
605
+ * affect chunk formation or the recall/pin layout.
606
+ */
607
+ protected pruneToolEntries(entries: ContextEntry[]): void;
191
608
  protected isChunkOldEnough(chunk: Chunk): boolean;
192
609
  protected formatChunkForCompression(chunk: Chunk): string;
193
610
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"autobiographical.d.ts","sourceRoot":"","sources":["../../../src/strategies/autobiographical.ts"],"names":[],"mappings":"AAAA,OAAO,KA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