@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.
- package/dist/src/adaptive/chunker.d.ts +70 -0
- package/dist/src/adaptive/chunker.d.ts.map +1 -0
- package/dist/src/adaptive/chunker.js +233 -0
- package/dist/src/adaptive/chunker.js.map +1 -0
- package/dist/src/adaptive/folding-strategy.d.ts +118 -0
- package/dist/src/adaptive/folding-strategy.d.ts.map +1 -0
- package/dist/src/adaptive/folding-strategy.js +12 -0
- package/dist/src/adaptive/folding-strategy.js.map +1 -0
- package/dist/src/adaptive/index.d.ts +17 -0
- package/dist/src/adaptive/index.d.ts.map +1 -0
- package/dist/src/adaptive/index.js +23 -0
- package/dist/src/adaptive/index.js.map +1 -0
- package/dist/src/adaptive/picker.d.ts +103 -0
- package/dist/src/adaptive/picker.d.ts.map +1 -0
- package/dist/src/adaptive/picker.js +357 -0
- package/dist/src/adaptive/picker.js.map +1 -0
- package/dist/src/adaptive/render.d.ts +39 -0
- package/dist/src/adaptive/render.d.ts.map +1 -0
- package/dist/src/adaptive/render.js +104 -0
- package/dist/src/adaptive/render.js.map +1 -0
- package/dist/src/adaptive/strategies/flat-profile.d.ts +19 -0
- package/dist/src/adaptive/strategies/flat-profile.d.ts.map +1 -0
- package/dist/src/adaptive/strategies/flat-profile.js +86 -0
- package/dist/src/adaptive/strategies/flat-profile.js.map +1 -0
- package/dist/src/adaptive/strategies/oldest-first.d.ts +19 -0
- package/dist/src/adaptive/strategies/oldest-first.d.ts.map +1 -0
- package/dist/src/adaptive/strategies/oldest-first.js +39 -0
- package/dist/src/adaptive/strategies/oldest-first.js.map +1 -0
- package/dist/src/context-manager.d.ts +74 -2
- package/dist/src/context-manager.d.ts.map +1 -1
- package/dist/src/context-manager.js +150 -10
- package/dist/src/context-manager.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/message-store.d.ts +36 -1
- package/dist/src/message-store.d.ts.map +1 -1
- package/dist/src/message-store.js +134 -8
- package/dist/src/message-store.js.map +1 -1
- package/dist/src/strategies/autobiographical.d.ts +422 -5
- package/dist/src/strategies/autobiographical.d.ts.map +1 -1
- package/dist/src/strategies/autobiographical.js +2248 -98
- package/dist/src/strategies/autobiographical.js.map +1 -1
- package/dist/src/strategies/index.d.ts +1 -1
- package/dist/src/strategies/index.d.ts.map +1 -1
- package/dist/src/strategies/index.js.map +1 -1
- package/dist/src/types/index.d.ts +2 -2
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +1 -1
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/message.d.ts +38 -0
- package/dist/src/types/message.d.ts.map +1 -1
- package/dist/src/types/strategy.d.ts +302 -10
- package/dist/src/types/strategy.d.ts.map +1 -1
- package/dist/src/types/strategy.js +28 -0
- package/dist/src/types/strategy.js.map +1 -1
- package/dist/test/adaptive/branching.test.d.ts +20 -0
- package/dist/test/adaptive/branching.test.d.ts.map +1 -0
- package/dist/test/adaptive/branching.test.js +176 -0
- package/dist/test/adaptive/branching.test.js.map +1 -0
- package/dist/test/adaptive/chunker.test.d.ts +2 -0
- package/dist/test/adaptive/chunker.test.d.ts.map +1 -0
- package/dist/test/adaptive/chunker.test.js +120 -0
- package/dist/test/adaptive/chunker.test.js.map +1 -0
- package/dist/test/adaptive/deep-levels.test.d.ts +10 -0
- package/dist/test/adaptive/deep-levels.test.d.ts.map +1 -0
- package/dist/test/adaptive/deep-levels.test.js +167 -0
- package/dist/test/adaptive/deep-levels.test.js.map +1 -0
- package/dist/test/adaptive/doc-plus-chat.test.d.ts +10 -0
- package/dist/test/adaptive/doc-plus-chat.test.d.ts.map +1 -0
- package/dist/test/adaptive/doc-plus-chat.test.js +194 -0
- package/dist/test/adaptive/doc-plus-chat.test.js.map +1 -0
- package/dist/test/adaptive/hard-fail.test.d.ts +9 -0
- package/dist/test/adaptive/hard-fail.test.d.ts.map +1 -0
- package/dist/test/adaptive/hard-fail.test.js +154 -0
- package/dist/test/adaptive/hard-fail.test.js.map +1 -0
- package/dist/test/adaptive/harness.d.ts +109 -0
- package/dist/test/adaptive/harness.d.ts.map +1 -0
- package/dist/test/adaptive/harness.js +263 -0
- package/dist/test/adaptive/harness.js.map +1 -0
- package/dist/test/adaptive/ingestion.test.d.ts +13 -0
- package/dist/test/adaptive/ingestion.test.d.ts.map +1 -0
- package/dist/test/adaptive/ingestion.test.js +306 -0
- package/dist/test/adaptive/ingestion.test.js.map +1 -0
- package/dist/test/adaptive/integration.test.d.ts +12 -0
- package/dist/test/adaptive/integration.test.d.ts.map +1 -0
- package/dist/test/adaptive/integration.test.js +247 -0
- package/dist/test/adaptive/integration.test.js.map +1 -0
- package/dist/test/adaptive/long-chronicle.test.d.ts +13 -0
- package/dist/test/adaptive/long-chronicle.test.d.ts.map +1 -0
- package/dist/test/adaptive/long-chronicle.test.js +186 -0
- package/dist/test/adaptive/long-chronicle.test.js.map +1 -0
- package/dist/test/adaptive/persistence.test.d.ts +11 -0
- package/dist/test/adaptive/persistence.test.d.ts.map +1 -0
- package/dist/test/adaptive/persistence.test.js +200 -0
- package/dist/test/adaptive/persistence.test.js.map +1 -0
- package/dist/test/adaptive/picker.test.d.ts +2 -0
- package/dist/test/adaptive/picker.test.d.ts.map +1 -0
- package/dist/test/adaptive/picker.test.js +333 -0
- package/dist/test/adaptive/picker.test.js.map +1 -0
- package/dist/test/adaptive/render.test.d.ts +2 -0
- package/dist/test/adaptive/render.test.d.ts.map +1 -0
- package/dist/test/adaptive/render.test.js +109 -0
- package/dist/test/adaptive/render.test.js.map +1 -0
- package/dist/test/adaptive/shard-immutability.test.d.ts +14 -0
- package/dist/test/adaptive/shard-immutability.test.d.ts.map +1 -0
- package/dist/test/adaptive/shard-immutability.test.js +184 -0
- package/dist/test/adaptive/shard-immutability.test.js.map +1 -0
- package/dist/test/adaptive/strategy-integration.test.d.ts +9 -0
- package/dist/test/adaptive/strategy-integration.test.d.ts.map +1 -0
- package/dist/test/adaptive/strategy-integration.test.js +293 -0
- package/dist/test/adaptive/strategy-integration.test.js.map +1 -0
- package/dist/test/message-store-sequence.test.d.ts +25 -0
- package/dist/test/message-store-sequence.test.d.ts.map +1 -0
- package/dist/test/message-store-sequence.test.js +157 -0
- package/dist/test/message-store-sequence.test.js.map +1 -0
- package/dist/test/non-blocking-compile.test.d.ts +22 -0
- package/dist/test/non-blocking-compile.test.d.ts.map +1 -0
- package/dist/test/non-blocking-compile.test.js +114 -0
- package/dist/test/non-blocking-compile.test.js.map +1 -0
- package/dist/test/pins.test.d.ts +10 -0
- package/dist/test/pins.test.d.ts.map +1 -0
- package/dist/test/pins.test.js +164 -0
- package/dist/test/pins.test.js.map +1 -0
- package/dist/test/recall-positioning.test.d.ts +16 -0
- package/dist/test/recall-positioning.test.d.ts.map +1 -0
- package/dist/test/recall-positioning.test.js +181 -0
- package/dist/test/recall-positioning.test.js.map +1 -0
- package/dist/test/search.test.d.ts +10 -0
- package/dist/test/search.test.d.ts.map +1 -0
- package/dist/test/search.test.js +141 -0
- package/dist/test/search.test.js.map +1 -0
- package/dist/test/speculation-cap.test.d.ts +17 -0
- package/dist/test/speculation-cap.test.d.ts.map +1 -0
- package/dist/test/speculation-cap.test.js +157 -0
- package/dist/test/speculation-cap.test.js.map +1 -0
- package/dist/test/strategy-persistence.test.d.ts +15 -0
- package/dist/test/strategy-persistence.test.d.ts.map +1 -0
- package/dist/test/strategy-persistence.test.js +244 -0
- package/dist/test/strategy-persistence.test.js.map +1 -0
- package/dist/test/tool-pruning.test.d.ts +10 -0
- package/dist/test/tool-pruning.test.d.ts.map +1 -0
- package/dist/test/tool-pruning.test.js +140 -0
- package/dist/test/tool-pruning.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/adaptive/chunker.ts +323 -0
- package/src/adaptive/folding-strategy.ts +129 -0
- package/src/adaptive/index.ts +51 -0
- package/src/adaptive/picker.ts +442 -0
- package/src/adaptive/render.ts +115 -0
- package/src/adaptive/strategies/flat-profile.ts +96 -0
- package/src/adaptive/strategies/oldest-first.ts +48 -0
- package/src/context-manager.ts +174 -10
- package/src/index.ts +1 -1
- package/src/message-store.ts +147 -8
- package/src/strategies/autobiographical.ts +2468 -166
- package/src/strategies/index.ts +1 -1
- package/src/types/index.ts +14 -1
- package/src/types/message.ts +43 -0
- package/src/types/strategy.ts +332 -10
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { JsStore } from '@animalabs/chronicle';
|
|
2
|
+
import type { Membrane, ContentBlock } from '@animalabs/membrane';
|
|
2
3
|
import type { StoredMessage, MessageId, Sequence } from './message.js';
|
|
3
4
|
import type { ContextEntry, TokenBudget } from './context.js';
|
|
4
5
|
/**
|
|
@@ -45,6 +46,22 @@ export interface StrategyContext {
|
|
|
45
46
|
membrane?: Membrane;
|
|
46
47
|
/** Current sequence number */
|
|
47
48
|
currentSequence: Sequence;
|
|
49
|
+
/**
|
|
50
|
+
* Underlying Chronicle store. Strategies may register their own state slots
|
|
51
|
+
* (via `store.registerState`) for durable strategy state that needs to
|
|
52
|
+
* survive process restart and follow Chronicle branches.
|
|
53
|
+
*
|
|
54
|
+
* State IDs should be scoped under `namespace` to avoid collisions with
|
|
55
|
+
* other strategies or with the message/context-log states.
|
|
56
|
+
*/
|
|
57
|
+
store: JsStore;
|
|
58
|
+
/**
|
|
59
|
+
* Namespace under which this strategy should scope its state IDs.
|
|
60
|
+
* Use as a prefix: e.g. `${namespace}/autobio:summaries`. Always defined;
|
|
61
|
+
* defaults to a stable per-manager value when no caller-supplied namespace
|
|
62
|
+
* exists, so strategies never need to handle the unscoped case.
|
|
63
|
+
*/
|
|
64
|
+
namespace: string;
|
|
48
65
|
}
|
|
49
66
|
/**
|
|
50
67
|
* Result of readiness check.
|
|
@@ -93,6 +110,36 @@ export interface ContextStrategy {
|
|
|
93
110
|
* This is the core method that determines what goes in the context window.
|
|
94
111
|
*/
|
|
95
112
|
select(store: MessageStoreView, log: ContextLogView, budget: TokenBudget): ContextEntry[];
|
|
113
|
+
/**
|
|
114
|
+
* Optional: at ingestion time, decide whether to split this incoming
|
|
115
|
+
* message into multiple shards (because it's too large to be a single
|
|
116
|
+
* fold unit). If returned, the framework stores each shard as a separate
|
|
117
|
+
* StoredMessage with the shared `bodyGroupId` and per-shard `shardIndex`,
|
|
118
|
+
* and the render path will reassemble them into one API message at
|
|
119
|
+
* compile time.
|
|
120
|
+
*
|
|
121
|
+
* Return null or undefined to skip chunking (message stored as one record).
|
|
122
|
+
*
|
|
123
|
+
* See `docs/adaptive-resolution-design.md` §3.6.
|
|
124
|
+
*/
|
|
125
|
+
chunkIngressMessage?(participant: string, content: ContentBlock[]): IngressChunkResult | null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Result of a strategy's ingestion-time chunking decision.
|
|
129
|
+
*/
|
|
130
|
+
export interface IngressChunkResult {
|
|
131
|
+
/** Stable id shared by all shards of this message. */
|
|
132
|
+
bodyGroupId: string;
|
|
133
|
+
/**
|
|
134
|
+
* The shards in source order. Each becomes a separate StoredMessage.
|
|
135
|
+
* Concatenating the shards' text content must reproduce the original
|
|
136
|
+
* message body byte-for-byte.
|
|
137
|
+
*/
|
|
138
|
+
shards: Array<{
|
|
139
|
+
content: ContentBlock[];
|
|
140
|
+
/** Order within the bodyGroup, starting at 0. */
|
|
141
|
+
shardIndex: number;
|
|
142
|
+
}>;
|
|
96
143
|
}
|
|
97
144
|
/**
|
|
98
145
|
* Strategy that supports resetting the head window for topic transitions.
|
|
@@ -108,6 +155,103 @@ export interface ResettableStrategy extends ContextStrategy {
|
|
|
108
155
|
* Type guard for strategies that support head window reset.
|
|
109
156
|
*/
|
|
110
157
|
export declare function isResettableStrategy(s: ContextStrategy): s is ResettableStrategy;
|
|
158
|
+
/**
|
|
159
|
+
* Strategy that supports protected ranges (pins + documents).
|
|
160
|
+
* Pinned ranges are excluded from compression and render raw at their
|
|
161
|
+
* original chronological position. Implemented by AutobiographicalStrategy.
|
|
162
|
+
*/
|
|
163
|
+
export interface PinnableStrategy extends ContextStrategy {
|
|
164
|
+
pinRange(firstMessageId: string, lastMessageId: string, opts?: {
|
|
165
|
+
name?: string;
|
|
166
|
+
}): string;
|
|
167
|
+
markDocument(messageId: string, opts?: {
|
|
168
|
+
name?: string;
|
|
169
|
+
}): string;
|
|
170
|
+
unpin(pinId: string): boolean;
|
|
171
|
+
listPins(): ReadonlyArray<ProtectedRange>;
|
|
172
|
+
}
|
|
173
|
+
/** Type guard for strategies that support pins / documents. */
|
|
174
|
+
export declare function isPinnableStrategy(s: ContextStrategy): s is PinnableStrategy;
|
|
175
|
+
/**
|
|
176
|
+
* Query for `searchSummaries`. At least one of `text` or `regex` should be
|
|
177
|
+
* provided to constrain results; otherwise all summaries pass.
|
|
178
|
+
*/
|
|
179
|
+
export interface SearchQuery {
|
|
180
|
+
/** Case-insensitive substring match against summary content. */
|
|
181
|
+
text?: string;
|
|
182
|
+
/** Regex match against summary content (overrides `text` if both set). */
|
|
183
|
+
regex?: RegExp;
|
|
184
|
+
/** Filter by summary level(s). Default: all levels. */
|
|
185
|
+
levels?: SummaryLevel[];
|
|
186
|
+
/** Maximum number of results to return. Default: 50. */
|
|
187
|
+
limit?: number;
|
|
188
|
+
/**
|
|
189
|
+
* Include summaries that have been merged into a higher-level summary.
|
|
190
|
+
* Default: false (only "live" unmerged summaries are returned).
|
|
191
|
+
*/
|
|
192
|
+
includeMerged?: boolean;
|
|
193
|
+
}
|
|
194
|
+
/** Result of a single search match. */
|
|
195
|
+
export interface SearchResult {
|
|
196
|
+
summary: SummaryEntry;
|
|
197
|
+
/** Number of times the query pattern matched in the summary content. */
|
|
198
|
+
matches: number;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Strategy that supports searching its summary archive. Implemented by
|
|
202
|
+
* AutobiographicalStrategy.
|
|
203
|
+
*/
|
|
204
|
+
export interface SearchableStrategy extends ContextStrategy {
|
|
205
|
+
searchSummaries(query: SearchQuery): SearchResult[];
|
|
206
|
+
getSummary(id: string): SummaryEntry | null;
|
|
207
|
+
}
|
|
208
|
+
/** Type guard for strategies that support search. */
|
|
209
|
+
export declare function isSearchableStrategy(s: ContextStrategy): s is SearchableStrategy;
|
|
210
|
+
/**
|
|
211
|
+
* Per-render observability stats from a strategy. Counts and token sums for
|
|
212
|
+
* head / tail / summaries / pending work, suitable for TUIs and dashboards
|
|
213
|
+
* that want to display "how much of the context is folded vs raw" at a
|
|
214
|
+
* glance. Token sums use the strategy's own estimates so they line up with
|
|
215
|
+
* the numbers `select()` uses for budget math.
|
|
216
|
+
*/
|
|
217
|
+
export interface RenderStats {
|
|
218
|
+
head: {
|
|
219
|
+
messages: number;
|
|
220
|
+
tokens: number;
|
|
221
|
+
};
|
|
222
|
+
tail: {
|
|
223
|
+
messages: number;
|
|
224
|
+
tokens: number;
|
|
225
|
+
};
|
|
226
|
+
summaries: {
|
|
227
|
+
l1: {
|
|
228
|
+
count: number;
|
|
229
|
+
tokens: number;
|
|
230
|
+
};
|
|
231
|
+
l2: {
|
|
232
|
+
count: number;
|
|
233
|
+
tokens: number;
|
|
234
|
+
};
|
|
235
|
+
l3: {
|
|
236
|
+
count: number;
|
|
237
|
+
tokens: number;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
pending: {
|
|
241
|
+
chunks: number;
|
|
242
|
+
merges: number;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Strategy that can produce render-time observability stats. Implemented by
|
|
247
|
+
* AutobiographicalStrategy. Optional capability — strategies that don't
|
|
248
|
+
* implement it simply have `ContextManager.getRenderStats()` return `null`.
|
|
249
|
+
*/
|
|
250
|
+
export interface RenderStatsCapableStrategy extends ContextStrategy {
|
|
251
|
+
getRenderStats(store: MessageStoreView): RenderStats;
|
|
252
|
+
}
|
|
253
|
+
/** Type guard for strategies that produce render stats. */
|
|
254
|
+
export declare function isRenderStatsCapable(s: ContextStrategy): s is RenderStatsCapableStrategy;
|
|
111
255
|
/**
|
|
112
256
|
* Configuration for the Autobiographical strategy.
|
|
113
257
|
*/
|
|
@@ -156,42 +300,190 @@ export interface AutobiographicalConfig {
|
|
|
156
300
|
l2BudgetTokens?: number;
|
|
157
301
|
/** Token budget for L1 summaries in select() (default: 30000) */
|
|
158
302
|
l1BudgetTokens?: number;
|
|
303
|
+
/**
|
|
304
|
+
* When true (default), each selected summary emits as its own positioned
|
|
305
|
+
* Q/A recall pair, sorted chronologically by source range. When false,
|
|
306
|
+
* all selected summaries are concatenated into one Q/A pair between head
|
|
307
|
+
* and tail (legacy behavior pre-2026-05-10).
|
|
308
|
+
*
|
|
309
|
+
* Per-region positioning is the spec-faithful behavior: it lets the agent
|
|
310
|
+
* see each memory in its temporal place rather than as a wall of unrelated
|
|
311
|
+
* recollections from another speaker. Without it, hierarchical compression
|
|
312
|
+
* is structurally similar to the dual-recall corruption pattern that
|
|
313
|
+
* caused Lena's context degradation on Hermes.
|
|
314
|
+
*/
|
|
315
|
+
positionedRecallPairs?: boolean;
|
|
316
|
+
/**
|
|
317
|
+
* Template for the per-pair recall question header. Substitutions:
|
|
318
|
+
* {id} — summary id (e.g. "L1-3")
|
|
319
|
+
* {level} — summary level (1, 2, or 3)
|
|
320
|
+
* {first} — first source message id
|
|
321
|
+
* {last} — last source message id
|
|
322
|
+
* Default: '[Recall {id}]'.
|
|
323
|
+
*
|
|
324
|
+
* Only used when `positionedRecallPairs` is true.
|
|
325
|
+
*/
|
|
326
|
+
recallHeaderTemplate?: string;
|
|
327
|
+
/**
|
|
328
|
+
* Per-tool retention limit: keep at most the last N `tool_result` blocks
|
|
329
|
+
* for each tool name. Older results get their content replaced with a
|
|
330
|
+
* brief marker referencing the tool name and how many newer results exist.
|
|
331
|
+
*
|
|
332
|
+
* Two shapes accepted:
|
|
333
|
+
* - `number`: applies as a global default across all tools.
|
|
334
|
+
* - `Record<toolName, number>`: per-tool limit; tools not listed are
|
|
335
|
+
* unlimited.
|
|
336
|
+
*
|
|
337
|
+
* Default: undefined (no pruning). Use a small number (1–5) for tools
|
|
338
|
+
* that produce verbose, mostly-stale output (e.g. file listings, http
|
|
339
|
+
* fetches, log queries).
|
|
340
|
+
*/
|
|
341
|
+
toolResultMaxLastN?: number | Record<string, number>;
|
|
342
|
+
/**
|
|
343
|
+
* Truncate `tool_use` block inputs whose serialized JSON exceeds this
|
|
344
|
+
* many tokens. The truncated input becomes `{ "_truncated": true,
|
|
345
|
+
* "_originalTokens": N }` plus a head slice of the original input
|
|
346
|
+
* keys for context. Default: 0 (no truncation).
|
|
347
|
+
*/
|
|
348
|
+
toolUseInputMaxTokens?: number;
|
|
349
|
+
/**
|
|
350
|
+
* Cap on the number of speculative L1 summaries the strategy will hold
|
|
351
|
+
* (queued + unmerged). When `count(unmerged L1s) + count(queued chunks)`
|
|
352
|
+
* exceeds this cap, `onNewMessage`'s auto-tick is held back. Chunks
|
|
353
|
+
* still form and queue, but compression is deferred until a manual
|
|
354
|
+
* `tick()` or `compile()` triggers it.
|
|
355
|
+
*
|
|
356
|
+
* Default: undefined (no cap; compression fires eagerly on every
|
|
357
|
+
* new message when `autoTickOnNewMessage` is true).
|
|
358
|
+
*/
|
|
359
|
+
maxSpeculativeL1s?: number;
|
|
360
|
+
/**
|
|
361
|
+
* When false, the rendering pipeline emits the full ideal context (head
|
|
362
|
+
* window + all selected summaries + all recent messages) without
|
|
363
|
+
* truncating to fit `budget.maxTokens`. The caller's API will reject if
|
|
364
|
+
* the result exceeds the model's context window — the philosophy is
|
|
365
|
+
* "surface the overage rather than silently lose content."
|
|
366
|
+
*
|
|
367
|
+
* Default: true (legacy budget-aware truncation: stops emitting recall
|
|
368
|
+
* pairs and recent messages when the running total exceeds maxTokens).
|
|
369
|
+
*
|
|
370
|
+
* Recommended setting for long-lived agents on large-context models
|
|
371
|
+
* (e.g. opus-4-7 with 1M context): false. The window is generous enough
|
|
372
|
+
* that overflow is rare, and when it does happen you want to know.
|
|
373
|
+
*/
|
|
374
|
+
enforceBudget?: boolean;
|
|
375
|
+
/**
|
|
376
|
+
* Enable picker-driven adaptive resolution. When true, `select()` uses
|
|
377
|
+
* the FoldingStrategy + Picker to choose per-message resolution under
|
|
378
|
+
* token-budget pressure rather than the threshold-driven `checkMergeThreshold`
|
|
379
|
+
* path. Default: false (existing hierarchical behavior preserved).
|
|
380
|
+
*/
|
|
381
|
+
adaptiveResolution?: boolean;
|
|
382
|
+
/**
|
|
383
|
+
* Folding strategy name when adaptiveResolution is on. One of:
|
|
384
|
+
* 'flat-profile' (default) — level-equalizing
|
|
385
|
+
* 'oldest-first' — chronological
|
|
386
|
+
* Custom strategies can be plugged in by the host application.
|
|
387
|
+
*/
|
|
388
|
+
foldingStrategy?: 'flat-profile' | 'oldest-first';
|
|
389
|
+
/**
|
|
390
|
+
* Slack ratio (hysteresis) for the picker. The picker folds until total
|
|
391
|
+
* tokens ≤ budget * (1 - slack), and stays quiet while between slack
|
|
392
|
+
* and budget. Default 0.1.
|
|
393
|
+
*/
|
|
394
|
+
compressionSlackRatio?: number;
|
|
395
|
+
/**
|
|
396
|
+
* Enable bottom-up speculative pre-production of higher-level summaries.
|
|
397
|
+
* When a new L_k summary is produced, if N siblings exist that would share
|
|
398
|
+
* an L_{k+1} parent, the L_{k+1} is enqueued for production immediately
|
|
399
|
+
* (no picker request needed). Default true when adaptiveResolution is on.
|
|
400
|
+
*/
|
|
401
|
+
speculativeProduction?: boolean;
|
|
159
402
|
}
|
|
160
403
|
/**
|
|
161
404
|
* Compression level in the hierarchical pyramid.
|
|
405
|
+
*
|
|
406
|
+
* Historically constrained to 1 | 2 | 3. As of the adaptive-resolution design
|
|
407
|
+
* (`docs/adaptive-resolution-design.md`), levels are unbounded: the picker
|
|
408
|
+
* can recursively produce L4, L5, ... as needed. The narrower literal type
|
|
409
|
+
* is kept as `LegacySummaryLevel` for code that still assumes the old shape.
|
|
162
410
|
*/
|
|
163
|
-
export type SummaryLevel =
|
|
411
|
+
export type SummaryLevel = number;
|
|
412
|
+
/**
|
|
413
|
+
* The narrow level type used by pre-adaptive-resolution code paths.
|
|
414
|
+
* Prefer `SummaryLevel` for new code.
|
|
415
|
+
*/
|
|
416
|
+
export type LegacySummaryLevel = 1 | 2 | 3;
|
|
164
417
|
/**
|
|
165
418
|
* A summary entry in the hierarchical memory pyramid.
|
|
166
419
|
* L1: compressed from raw message chunks.
|
|
167
|
-
*
|
|
168
|
-
* L3: merged from mergeThreshold L2s.
|
|
420
|
+
* L_{k>1}: merged from mergeThreshold L_{k-1}s.
|
|
169
421
|
*/
|
|
170
422
|
export interface SummaryEntry {
|
|
171
423
|
/** Unique ID (e.g., "L1-0", "L2-3") */
|
|
172
424
|
id: string;
|
|
173
|
-
/** Compression level */
|
|
425
|
+
/** Compression level (1, 2, 3, ... — unbounded in the adaptive-resolution design) */
|
|
174
426
|
level: SummaryLevel;
|
|
175
427
|
/** The summary text */
|
|
176
428
|
content: string;
|
|
177
|
-
/** Estimated token count (content.length / 4) */
|
|
429
|
+
/** Estimated token count (content.length / 4 or tokenizer-cached) */
|
|
178
430
|
tokens: number;
|
|
179
|
-
/**
|
|
180
|
-
|
|
181
|
-
|
|
431
|
+
/**
|
|
432
|
+
* Level of the sources: 0 = raw messages, k = L_k summaries.
|
|
433
|
+
* Pre-adaptive code uses 0 | 1 | 2; new code may produce higher values.
|
|
434
|
+
*/
|
|
435
|
+
sourceLevel: number;
|
|
436
|
+
/** IDs of source items (message IDs for L1, summary IDs for L_{k>1}) */
|
|
182
437
|
sourceIds: string[];
|
|
183
438
|
/** Range of original message IDs covered */
|
|
184
439
|
sourceRange: {
|
|
185
440
|
first: string;
|
|
186
441
|
last: string;
|
|
187
442
|
};
|
|
188
|
-
/**
|
|
443
|
+
/**
|
|
444
|
+
* The L_{level+1} summary this one is a source for, if produced.
|
|
445
|
+
* Pure archive metadata in the adaptive-resolution design — display
|
|
446
|
+
* decisions live on per-chunk `currentResolution`, not here.
|
|
447
|
+
*/
|
|
448
|
+
parentId?: string;
|
|
449
|
+
/**
|
|
450
|
+
* @deprecated Renamed to `parentId` in the adaptive-resolution design.
|
|
451
|
+
* Kept for read compatibility with chronicles produced by the old
|
|
452
|
+
* threshold-driven path. New writes should set `parentId` only.
|
|
453
|
+
*/
|
|
189
454
|
mergedInto?: string;
|
|
190
455
|
/** Creation timestamp */
|
|
191
456
|
created: number;
|
|
192
457
|
/** Phase type tag (used by KnowledgeStrategy for asymmetric budget) */
|
|
193
458
|
phaseType?: string;
|
|
194
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* Helper: read the parent pointer from a summary, accepting either the
|
|
462
|
+
* new `parentId` field or the deprecated `mergedInto` alias.
|
|
463
|
+
*/
|
|
464
|
+
export declare function getSummaryParentId(s: SummaryEntry): string | undefined;
|
|
465
|
+
/**
|
|
466
|
+
* A range of messages protected from compression. Pins keep a span of raw
|
|
467
|
+
* messages visible at their original position in the rendered context.
|
|
468
|
+
*
|
|
469
|
+
* - `kind: 'pin'` — generic protected range (any first/last span).
|
|
470
|
+
* - `kind: 'document'` — typically a single message containing a body of
|
|
471
|
+
* information the agent wants to retain in full; semantically identical
|
|
472
|
+
* to a single-message pin, distinguished by metadata for tooling.
|
|
473
|
+
*/
|
|
474
|
+
export interface ProtectedRange {
|
|
475
|
+
/** Stable id assigned at pin time. */
|
|
476
|
+
id: string;
|
|
477
|
+
/** First message id of the protected range (inclusive). */
|
|
478
|
+
firstMessageId: string;
|
|
479
|
+
/** Last message id of the protected range (inclusive). */
|
|
480
|
+
lastMessageId: string;
|
|
481
|
+
kind: 'pin' | 'document';
|
|
482
|
+
/** Optional human-readable label. */
|
|
483
|
+
name?: string;
|
|
484
|
+
/** Creation timestamp (ms since epoch). */
|
|
485
|
+
created: number;
|
|
486
|
+
}
|
|
195
487
|
/**
|
|
196
488
|
* Phase type for knowledge extraction workflows.
|
|
197
489
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../../src/types/strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../../src/types/strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAe,MAAM,cAAc,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uBAAuB;IACvB,MAAM,IAAI,aAAa,EAAE,CAAC;IAC1B,6BAA6B;IAC7B,GAAG,CAAC,EAAE,EAAE,SAAS,GAAG,aAAa,GAAG,IAAI,CAAC;IACzC,yCAAyC;IACzC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,EAAE,CAAC;IACxC,8BAA8B;IAC9B,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,EAAE,CAAC;IACxC,8BAA8B;IAC9B,MAAM,IAAI,MAAM,CAAC;IACjB,oCAAoC;IACpC,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAAC;CAChD;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,sBAAsB;IACtB,MAAM,IAAI,YAAY,EAAE,CAAC;IACzB,wCAAwC;IACxC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE,CAAC;IACvC,6BAA6B;IAC7B,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE,CAAC;IACvC,4BAA4B;IAC5B,MAAM,IAAI,MAAM,CAAC;IACjB,mCAAmC;IACnC,cAAc,CAAC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,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;6EACyE;IACzE,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,eAAO,MAAM,+BAA+B,EAAE,sBAuB7C,CAAC"}
|
|
@@ -4,6 +4,32 @@
|
|
|
4
4
|
export function isResettableStrategy(s) {
|
|
5
5
|
return 'resetHeadWindow' in s && typeof s.resetHeadWindow === 'function';
|
|
6
6
|
}
|
|
7
|
+
/** Type guard for strategies that support pins / documents. */
|
|
8
|
+
export function isPinnableStrategy(s) {
|
|
9
|
+
return ('pinRange' in s &&
|
|
10
|
+
typeof s.pinRange === 'function' &&
|
|
11
|
+
'unpin' in s &&
|
|
12
|
+
typeof s.unpin === 'function');
|
|
13
|
+
}
|
|
14
|
+
/** Type guard for strategies that support search. */
|
|
15
|
+
export function isSearchableStrategy(s) {
|
|
16
|
+
return ('searchSummaries' in s &&
|
|
17
|
+
typeof s.searchSummaries === 'function' &&
|
|
18
|
+
'getSummary' in s &&
|
|
19
|
+
typeof s.getSummary === 'function');
|
|
20
|
+
}
|
|
21
|
+
/** Type guard for strategies that produce render stats. */
|
|
22
|
+
export function isRenderStatsCapable(s) {
|
|
23
|
+
return ('getRenderStats' in s &&
|
|
24
|
+
typeof s.getRenderStats === 'function');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Helper: read the parent pointer from a summary, accepting either the
|
|
28
|
+
* new `parentId` field or the deprecated `mergedInto` alias.
|
|
29
|
+
*/
|
|
30
|
+
export function getSummaryParentId(s) {
|
|
31
|
+
return s.parentId ?? s.mergedInto;
|
|
32
|
+
}
|
|
7
33
|
/**
|
|
8
34
|
* Default configuration for Autobiographical strategy.
|
|
9
35
|
*/
|
|
@@ -28,5 +54,7 @@ Write naturally, as recollection of what you experienced.`,
|
|
|
28
54
|
summaryContextLabel: 'What do you remember from earlier?',
|
|
29
55
|
summaryParticipant: 'Claude',
|
|
30
56
|
maxMessageTokens: 0,
|
|
57
|
+
positionedRecallPairs: true,
|
|
58
|
+
recallHeaderTemplate: '[Recall {id}]',
|
|
31
59
|
};
|
|
32
60
|
//# sourceMappingURL=strategy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../src/types/strategy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../src/types/strategy.ts"],"names":[],"mappings":"AA+KA;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,CAAkB;IACrD,OAAO,iBAAiB,IAAI,CAAC,IAAI,OAAQ,CAAwB,CAAC,eAAe,KAAK,UAAU,CAAC;AACnG,CAAC;AAcD,+DAA+D;AAC/D,MAAM,UAAU,kBAAkB,CAAC,CAAkB;IACnD,OAAO,CACL,UAAU,IAAI,CAAC;QACf,OAAQ,CAAsB,CAAC,QAAQ,KAAK,UAAU;QACtD,OAAO,IAAI,CAAC;QACZ,OAAQ,CAAsB,CAAC,KAAK,KAAK,UAAU,CACpD,CAAC;AACJ,CAAC;AAsCD,qDAAqD;AACrD,MAAM,UAAU,oBAAoB,CAAC,CAAkB;IACrD,OAAO,CACL,iBAAiB,IAAI,CAAC;QACtB,OAAQ,CAAwB,CAAC,eAAe,KAAK,UAAU;QAC/D,YAAY,IAAI,CAAC;QACjB,OAAQ,CAAwB,CAAC,UAAU,KAAK,UAAU,CAC3D,CAAC;AACJ,CAAC;AA6BD,2DAA2D;AAC3D,MAAM,UAAU,oBAAoB,CAAC,CAAkB;IACrD,OAAO,CACL,gBAAgB,IAAI,CAAC;QACrB,OAAQ,CAAgC,CAAC,cAAc,KAAK,UAAU,CACvE,CAAC;AACJ,CAAC;AAiOD;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,CAAe;IAChD,OAAO,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,UAAU,CAAC;AACpC,CAAC;AA+DD;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAA2B;IACrE,iBAAiB,EAAE,IAAI;IACvB,kBAAkB,EAAE,KAAK;IACzB,gBAAgB,EAAE,CAAC;IACnB,sBAAsB,EAAE,IAAI;IAC5B,qBAAqB,EAAE,IAAI;IAC3B,oBAAoB,EAAE,KAAK;IAC3B,mBAAmB,EAAE,qMAAqM;IAC1N,iBAAiB,EAAE;;;;;;;;;0DASqC;IACxD,mBAAmB,EAAE,oCAAoC;IACzD,kBAAkB,EAAE,QAAQ;IAC5B,gBAAgB,EAAE,CAAC;IACnB,qBAAqB,EAAE,IAAI;IAC3B,oBAAoB,EAAE,eAAe;CACtC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests that branching a chronicle correctly inherits and diverges
|
|
3
|
+
* adaptive-resolution state.
|
|
4
|
+
*
|
|
5
|
+
* Per the design doc §8 open question #4: "Branching semantics for on-chunk
|
|
6
|
+
* state. New chronicle branches inherit chunk state at the fork point via
|
|
7
|
+
* the existing branch-scoped slot model. An agent unfold on branch A does
|
|
8
|
+
* not leak into branch B."
|
|
9
|
+
*
|
|
10
|
+
* Adaptive state lives in two places:
|
|
11
|
+
* - On the StoredMessage itself (bodyGroupId, shardIndex, currentResolution,
|
|
12
|
+
* lockedByAgent — set at append time, immutable for that record)
|
|
13
|
+
* - In strategy state slots (autobio:resolutions, autobio:locks,
|
|
14
|
+
* autobio:summaries)
|
|
15
|
+
*
|
|
16
|
+
* The chronicle's branch model copy-on-writes the state slots, so the fork
|
|
17
|
+
* sees state-at-fork-point and can diverge without affecting the parent.
|
|
18
|
+
*/
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=branching.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branching.test.d.ts","sourceRoot":"","sources":["../../../test/adaptive/branching.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests that branching a chronicle correctly inherits and diverges
|
|
3
|
+
* adaptive-resolution state.
|
|
4
|
+
*
|
|
5
|
+
* Per the design doc §8 open question #4: "Branching semantics for on-chunk
|
|
6
|
+
* state. New chronicle branches inherit chunk state at the fork point via
|
|
7
|
+
* the existing branch-scoped slot model. An agent unfold on branch A does
|
|
8
|
+
* not leak into branch B."
|
|
9
|
+
*
|
|
10
|
+
* Adaptive state lives in two places:
|
|
11
|
+
* - On the StoredMessage itself (bodyGroupId, shardIndex, currentResolution,
|
|
12
|
+
* lockedByAgent — set at append time, immutable for that record)
|
|
13
|
+
* - In strategy state slots (autobio:resolutions, autobio:locks,
|
|
14
|
+
* autobio:summaries)
|
|
15
|
+
*
|
|
16
|
+
* The chronicle's branch model copy-on-writes the state slots, so the fork
|
|
17
|
+
* sees state-at-fork-point and can diverge without affecting the parent.
|
|
18
|
+
*/
|
|
19
|
+
import { describe, it, before, after, beforeEach } from 'node:test';
|
|
20
|
+
import assert from 'node:assert/strict';
|
|
21
|
+
import { rmSync, existsSync } from 'node:fs';
|
|
22
|
+
import { ContextManager, AutobiographicalStrategy } from '../../src/index.js';
|
|
23
|
+
const TEST_STORE_PATH = './test-adaptive-branching-store';
|
|
24
|
+
function cleanup() {
|
|
25
|
+
if (existsSync(TEST_STORE_PATH)) {
|
|
26
|
+
rmSync(TEST_STORE_PATH, { recursive: true, force: true });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function makeMockMembrane() {
|
|
30
|
+
let callCount = 0;
|
|
31
|
+
return {
|
|
32
|
+
complete: async () => {
|
|
33
|
+
callCount++;
|
|
34
|
+
return {
|
|
35
|
+
content: [{ type: 'text', text: `[mock summary #${callCount}]` }],
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
get callCount() {
|
|
39
|
+
return callCount;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
describe('AutobiographicalStrategy — branching semantics', () => {
|
|
44
|
+
before(() => cleanup());
|
|
45
|
+
after(() => cleanup());
|
|
46
|
+
beforeEach(() => cleanup());
|
|
47
|
+
it('fork inherits resolutions at fork point; divergence does not leak back', async () => {
|
|
48
|
+
const mock = makeMockMembrane();
|
|
49
|
+
const strategy = new AutobiographicalStrategy({
|
|
50
|
+
adaptiveResolution: true,
|
|
51
|
+
targetChunkTokens: 100,
|
|
52
|
+
recentWindowTokens: 200,
|
|
53
|
+
});
|
|
54
|
+
const manager = await ContextManager.open({
|
|
55
|
+
path: TEST_STORE_PATH,
|
|
56
|
+
strategy,
|
|
57
|
+
membrane: mock,
|
|
58
|
+
});
|
|
59
|
+
// Build up some history
|
|
60
|
+
const ids = [];
|
|
61
|
+
for (let i = 0; i < 20; i++) {
|
|
62
|
+
ids.push(manager.addMessage('User', [{ type: 'text', text: `Turn ${i}. ` + 'word '.repeat(40) }]));
|
|
63
|
+
}
|
|
64
|
+
while (!manager.isReady()) {
|
|
65
|
+
await manager.tick();
|
|
66
|
+
}
|
|
67
|
+
// Force some folds
|
|
68
|
+
await manager.compile({ maxTokens: 3000, reserveForResponse: 200 });
|
|
69
|
+
const parentResolutions = new Map(strategy.resolutions);
|
|
70
|
+
const parentBranchName = manager.store.currentBranch().name;
|
|
71
|
+
// Fork
|
|
72
|
+
const forkName = await manager.fork('test-fork');
|
|
73
|
+
const forkResolutions = new Map(strategy.resolutions);
|
|
74
|
+
// Fork should inherit parent's resolutions at fork point
|
|
75
|
+
assert.equal(forkResolutions.size, parentResolutions.size);
|
|
76
|
+
for (const [id, level] of parentResolutions) {
|
|
77
|
+
assert.equal(forkResolutions.get(id), level, `fork should inherit resolution for ${id}`);
|
|
78
|
+
}
|
|
79
|
+
// Diverge on the fork — add more turns, force deeper folding
|
|
80
|
+
for (let i = 20; i < 40; i++) {
|
|
81
|
+
manager.addMessage('User', [{ type: 'text', text: `Fork-only turn ${i}. ` + 'word '.repeat(40) }]);
|
|
82
|
+
}
|
|
83
|
+
while (!manager.isReady()) {
|
|
84
|
+
await manager.tick();
|
|
85
|
+
}
|
|
86
|
+
await manager.compile({ maxTokens: 2000, reserveForResponse: 200 });
|
|
87
|
+
const forkDivergedResolutions = new Map(strategy.resolutions);
|
|
88
|
+
const forkDivergedMessageCount = manager.getAllMessages().length;
|
|
89
|
+
// Switch back to parent
|
|
90
|
+
await manager.switchBranch(parentBranchName);
|
|
91
|
+
const parentResolutionsAfterSwitch = new Map(strategy.resolutions);
|
|
92
|
+
const parentMessageCount = manager.getAllMessages().length;
|
|
93
|
+
// Parent should still have its ORIGINAL state — the fork's divergence
|
|
94
|
+
// didn't leak back.
|
|
95
|
+
assert.equal(parentMessageCount, 20, 'parent should still have 20 messages');
|
|
96
|
+
assert.notEqual(parentMessageCount, forkDivergedMessageCount);
|
|
97
|
+
assert.equal(parentResolutionsAfterSwitch.size, parentResolutions.size);
|
|
98
|
+
for (const [id, level] of parentResolutions) {
|
|
99
|
+
assert.equal(parentResolutionsAfterSwitch.get(id), level, `parent ${id}: expected unchanged resolution L${level} after fork diverged`);
|
|
100
|
+
}
|
|
101
|
+
manager.close();
|
|
102
|
+
});
|
|
103
|
+
it('locks on fork do not affect parent', async () => {
|
|
104
|
+
const mock = makeMockMembrane();
|
|
105
|
+
const strategy = new AutobiographicalStrategy({
|
|
106
|
+
adaptiveResolution: true,
|
|
107
|
+
targetChunkTokens: 100,
|
|
108
|
+
});
|
|
109
|
+
const manager = await ContextManager.open({
|
|
110
|
+
path: TEST_STORE_PATH,
|
|
111
|
+
strategy,
|
|
112
|
+
membrane: mock,
|
|
113
|
+
});
|
|
114
|
+
const ids = [];
|
|
115
|
+
for (let i = 0; i < 10; i++) {
|
|
116
|
+
ids.push(manager.addMessage('User', [{ type: 'text', text: `M${i}` }]));
|
|
117
|
+
}
|
|
118
|
+
const parentBranch = manager.store.currentBranch().name;
|
|
119
|
+
await manager.fork('lock-fork');
|
|
120
|
+
// Lock on the fork
|
|
121
|
+
strategy.lockChunk(ids[3]);
|
|
122
|
+
strategy.lockChunk(ids[7]);
|
|
123
|
+
const forkLocks = new Set(strategy.locked);
|
|
124
|
+
assert.equal(forkLocks.size, 2);
|
|
125
|
+
// Switch back to parent — locks should be empty
|
|
126
|
+
await manager.switchBranch(parentBranch);
|
|
127
|
+
const parentLocks = strategy.locked;
|
|
128
|
+
assert.equal(parentLocks.size, 0, 'parent should not see fork-only locks');
|
|
129
|
+
// Switch back to fork — locks should still be there
|
|
130
|
+
await manager.switchBranch('lock-fork');
|
|
131
|
+
const forkLocksAfter = strategy.locked;
|
|
132
|
+
assert.equal(forkLocksAfter.size, 2);
|
|
133
|
+
assert.ok(forkLocksAfter.has(ids[3]));
|
|
134
|
+
assert.ok(forkLocksAfter.has(ids[7]));
|
|
135
|
+
manager.close();
|
|
136
|
+
});
|
|
137
|
+
it('summaries on fork do not affect parent', async () => {
|
|
138
|
+
const mock = makeMockMembrane();
|
|
139
|
+
const strategy = new AutobiographicalStrategy({
|
|
140
|
+
adaptiveResolution: true,
|
|
141
|
+
targetChunkTokens: 80,
|
|
142
|
+
mergeThreshold: 3,
|
|
143
|
+
recentWindowTokens: 50,
|
|
144
|
+
});
|
|
145
|
+
const manager = await ContextManager.open({
|
|
146
|
+
path: TEST_STORE_PATH,
|
|
147
|
+
strategy,
|
|
148
|
+
membrane: mock,
|
|
149
|
+
});
|
|
150
|
+
// Build enough for some summaries
|
|
151
|
+
for (let i = 0; i < 20; i++) {
|
|
152
|
+
manager.addMessage('User', [{ type: 'text', text: `T${i}. ` + 'word '.repeat(20) }]);
|
|
153
|
+
}
|
|
154
|
+
while (!manager.isReady()) {
|
|
155
|
+
await manager.tick();
|
|
156
|
+
}
|
|
157
|
+
const parentSummaryCount = strategy.summaries.length;
|
|
158
|
+
const parentBranch = manager.store.currentBranch().name;
|
|
159
|
+
// Fork and add more content → more summaries on fork only
|
|
160
|
+
await manager.fork('sum-fork');
|
|
161
|
+
for (let i = 20; i < 50; i++) {
|
|
162
|
+
manager.addMessage('User', [{ type: 'text', text: `T${i}. ` + 'word '.repeat(20) }]);
|
|
163
|
+
}
|
|
164
|
+
while (!manager.isReady()) {
|
|
165
|
+
await manager.tick();
|
|
166
|
+
}
|
|
167
|
+
const forkSummaryCount = strategy.summaries.length;
|
|
168
|
+
assert.ok(forkSummaryCount > parentSummaryCount, `fork should have more summaries (${forkSummaryCount}) than parent (${parentSummaryCount})`);
|
|
169
|
+
// Switch back to parent
|
|
170
|
+
await manager.switchBranch(parentBranch);
|
|
171
|
+
const parentSummaryCountAfter = strategy.summaries.length;
|
|
172
|
+
assert.equal(parentSummaryCountAfter, parentSummaryCount, `parent should still have ${parentSummaryCount} summaries after fork diverged`);
|
|
173
|
+
manager.close();
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
//# sourceMappingURL=branching.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branching.test.js","sourceRoot":"","sources":["../../../test/adaptive/branching.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9E,MAAM,eAAe,GAAG,iCAAiC,CAAC;AAE1D,SAAS,OAAO;IACd,IAAI,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QAChC,MAAM,CAAC,eAAe,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB;IACvB,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,OAAO;QACL,QAAQ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