@chenhw7/dsh-memory 0.1.3 → 0.4.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 (81) hide show
  1. package/README.md +102 -120
  2. package/README.zh-CN.md +104 -119
  3. package/cordis.patch.yml +13 -8
  4. package/lib/client/index.js +1591 -195
  5. package/lib/context/conflict.d.ts +19 -2
  6. package/lib/context/conflict.d.ts.map +1 -1
  7. package/lib/context/conflict.js +33 -0
  8. package/lib/context/conflict.js.map +1 -1
  9. package/lib/context/index.d.ts +34 -10
  10. package/lib/context/index.d.ts.map +1 -1
  11. package/lib/context/index.js +195 -24
  12. package/lib/context/index.js.map +1 -1
  13. package/lib/context/policy.d.ts +28 -1
  14. package/lib/context/policy.d.ts.map +1 -1
  15. package/lib/context/policy.js +60 -3
  16. package/lib/context/policy.js.map +1 -1
  17. package/lib/index.d.ts +27 -7
  18. package/lib/index.d.ts.map +1 -1
  19. package/lib/index.js +22 -0
  20. package/lib/index.js.map +1 -1
  21. package/lib/notes/index.d.ts +66 -0
  22. package/lib/notes/index.d.ts.map +1 -0
  23. package/lib/notes/index.js +180 -0
  24. package/lib/notes/index.js.map +1 -0
  25. package/lib/notes/render.d.ts +32 -0
  26. package/lib/notes/render.d.ts.map +1 -0
  27. package/lib/notes/render.js +68 -0
  28. package/lib/notes/render.js.map +1 -0
  29. package/lib/notes/scope.d.ts +35 -0
  30. package/lib/notes/scope.d.ts.map +1 -0
  31. package/lib/notes/scope.js +44 -0
  32. package/lib/notes/scope.js.map +1 -0
  33. package/lib/notes/settings.d.ts +35 -0
  34. package/lib/notes/settings.d.ts.map +1 -0
  35. package/lib/notes/settings.js +36 -0
  36. package/lib/notes/settings.js.map +1 -0
  37. package/lib/notes/writer.d.ts +32 -0
  38. package/lib/notes/writer.d.ts.map +1 -0
  39. package/lib/notes/writer.js +71 -0
  40. package/lib/notes/writer.js.map +1 -0
  41. package/lib/remote/index.d.ts +31 -4
  42. package/lib/remote/index.d.ts.map +1 -1
  43. package/lib/remote/index.js +44 -7
  44. package/lib/remote/index.js.map +1 -1
  45. package/lib/remote/typert.remote-client.d.ts +7 -2
  46. package/lib/remote/typert.remote-client.js +8 -2
  47. package/lib/review/accumulator.d.ts +53 -18
  48. package/lib/review/accumulator.d.ts.map +1 -1
  49. package/lib/review/accumulator.js +176 -36
  50. package/lib/review/accumulator.js.map +1 -1
  51. package/lib/review/dedup.d.ts +16 -3
  52. package/lib/review/dedup.d.ts.map +1 -1
  53. package/lib/review/dedup.js +21 -4
  54. package/lib/review/dedup.js.map +1 -1
  55. package/lib/review/extract.d.ts +81 -5
  56. package/lib/review/extract.d.ts.map +1 -1
  57. package/lib/review/extract.js +224 -31
  58. package/lib/review/extract.js.map +1 -1
  59. package/lib/review/index.d.ts +15 -2
  60. package/lib/review/index.d.ts.map +1 -1
  61. package/lib/review/index.js +137 -55
  62. package/lib/review/index.js.map +1 -1
  63. package/lib/scanner.d.ts +15 -0
  64. package/lib/scanner.d.ts.map +1 -1
  65. package/lib/scanner.js +20 -0
  66. package/lib/scanner.js.map +1 -1
  67. package/lib/store/bm25.d.ts +48 -0
  68. package/lib/store/bm25.d.ts.map +1 -0
  69. package/lib/store/bm25.js +115 -0
  70. package/lib/store/bm25.js.map +1 -0
  71. package/lib/store/index.d.ts +26 -3
  72. package/lib/store/index.d.ts.map +1 -1
  73. package/lib/store/index.js +111 -68
  74. package/lib/store/index.js.map +1 -1
  75. package/lib/tool/index.d.ts +3 -1
  76. package/lib/tool/index.d.ts.map +1 -1
  77. package/lib/tool/index.js +52 -9
  78. package/lib/tool/index.js.map +1 -1
  79. package/lib/types.d.ts +17 -1
  80. package/lib/types.d.ts.map +1 -1
  81. package/package.json +44 -30
@@ -1,9 +1,17 @@
1
1
  /**
2
2
  * The periodic-review projection accumulator: a pure, synchronous fold over
3
- * `user/message` events (keyword/correction signals) and `tool/result` events
4
- * (tool-call failures) that collects candidate memory fragments. No LLM runs
5
- * here — the {@link agent/pre-step} listener drains the accumulator once it
6
- * reaches the configured threshold and runs one extraction call.
3
+ * session events that collects candidate memory fragments. No LLM runs here —
4
+ * the {@link agent/pre-step} listener drains the accumulator once it reaches
5
+ * the configured threshold and runs one extraction call.
6
+ *
7
+ * Signal sources (§5 of docs/PROJECT_NOTES.md):
8
+ * - `user/message` — keyword hits (explicit "remember" intent) and corrections
9
+ * (the user revises a prior statement).
10
+ * - `tool/call` + `tool/result` — **failure-streak pairing**: consecutive
11
+ * same-signature tool failures followed by a success emit one
12
+ * `pitfall-resolved` candidate (the workaround is verified by the success).
13
+ * One-shot failures no longer become candidates; the compaction/dispose
14
+ * flush still sees full events as the safety net.
7
15
  *
8
16
  * @module @chenhw7/dsh-memory/review/accumulator
9
17
  */
@@ -17,21 +25,47 @@ declare module '@deepseek-ai/dsh-session-projection/types' {
17
25
  'memory-review-candidates': AccumulatorView;
18
26
  }
19
27
  }
28
+ /** The signal emitted when a failure streak is resolved by a success. */
29
+ export declare const PITFALL_RESOLVED_SIGNAL = "pitfall-resolved";
20
30
  /** One candidate fragment collected by the accumulator. */
21
31
  export interface MemoryCandidate {
22
32
  /** The text fragment that matched a signal. */
23
33
  readonly text: string;
24
- /** Which signal class matched (`keyword`, `correction`, or `tool-failure`). */
34
+ /** Which signal class matched (`keyword`, `correction`, or `pitfall-resolved`). */
25
35
  readonly signal: string;
26
36
  /** Seq of the session event the fragment came from. */
27
37
  readonly seq: number;
28
38
  }
39
+ /** A registered tool call awaiting its result, keyed by callId. */
40
+ export interface OpenCall {
41
+ /** The invoked tool's name. */
42
+ readonly name: string;
43
+ /** The normalized signature (toolName + normalized primary argument). */
44
+ readonly signature: string;
45
+ /** Seq of the `tool/call` event. */
46
+ readonly seq: number;
47
+ }
48
+ /** One open failure streak for a signature. */
49
+ export interface OpenStreak {
50
+ /** Consecutive failure count so far. */
51
+ readonly count: number;
52
+ /** Truncated description of the most recent failure (error identity + text). */
53
+ readonly lastErrorText: string;
54
+ /** Seq of the first failure in the streak. */
55
+ readonly firstSeq: number;
56
+ /** Seq of the most recent failure (drives LRU eviction). */
57
+ readonly lastSeq: number;
58
+ }
29
59
  /** Internal accumulator state (plain JSON per the projection contract). */
30
60
  export interface AccumulatorState {
31
61
  /** Collected candidate fragments, in collection order. */
32
62
  readonly candidates: readonly MemoryCandidate[];
33
63
  /** Number of candidates collected so far (a derived length, cached for the threshold check). */
34
64
  readonly count: number;
65
+ /** Tool calls awaiting their results, keyed by callId (capped). */
66
+ readonly openCalls: Record<string, OpenCall>;
67
+ /** Open failure streaks, keyed by signature (capped, LRU-evicted). */
68
+ readonly openStreaks: Record<string, OpenStreak>;
35
69
  }
36
70
  /** The wire payload (read-side projection) is the accumulator state itself. */
37
71
  export type AccumulatorView = AccumulatorState;
@@ -51,27 +85,28 @@ export declare function messageText(event: SessionEvent): string | undefined;
51
85
  */
52
86
  export declare function detectSignal(text: string): string | undefined;
53
87
  /**
54
- * Extract a failure fragment from a `tool/result` event that carries an error.
55
- * @param event - a `tool/result` session event.
56
- * @returns the failure description text, or `undefined` when the event has no error.
88
+ * Normalize a tool invocation into a failure-streak signature:
89
+ * `toolName:argument-key`. Shell-like `command` arguments collapse to the
90
+ * first two tokens (`npm test`, `pnpm build`); path-like arguments use the
91
+ * path; everything else falls back to the bare tool name. Unparsable
92
+ * argument JSON also falls back to the bare tool name.
93
+ * @param name - the invoked tool's name.
94
+ * @param argumentsJson - the raw arguments JSON string from the `tool/call` event.
95
+ * @returns the normalized signature (≤ {@link SIGNATURE_LIMIT} chars).
57
96
  */
58
- export declare function toolFailureText(event: SessionEvent): string | undefined;
97
+ export declare function toolSignature(name: string, argumentsJson: string): string;
59
98
  /**
60
99
  * The projection's `apply` transition: fold one committed event into the
61
100
  * accumulator. Returns the SAME state reference for events that do not
62
- * contribute a candidate (the registry's `Object.is` gate).
63
- *
64
- * Signal sources:
65
- * - `user/message` — keyword hits (explicit "remember" intent) and corrections
66
- * (user revises a prior statement).
67
- * - `tool/result` — tool-call failures (§3.6 richer signals): a failed tool
68
- * execution may carry a durable workaround worth remembering.
101
+ * contribute any change (the registry's `Object.is` gate).
69
102
  *
70
103
  * @param state - the state covering all prior events.
71
104
  * @param event - the next committed session event.
72
- * @returns the next state (same reference when the event contributes nothing).
105
+ * @param pitfallThreshold - consecutive same-signature failures required
106
+ * before a following success emits a `pitfall-resolved` candidate.
107
+ * @returns the next state (same reference when the event changes nothing).
73
108
  */
74
- export declare function applyAccumulator(state: AccumulatorState, event: SessionEvent): AccumulatorState;
109
+ export declare function applyAccumulator(state: AccumulatorState, event: SessionEvent, pitfallThreshold?: number): AccumulatorState;
75
110
  /** Zod schema for the accumulator's wire payload. */
76
111
  export declare const accumulatorSchema: ZodType<AccumulatorView>;
77
112
  //# sourceMappingURL=accumulator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"accumulator.d.ts","sourceRoot":"","sources":["../../src/review/accumulator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAClC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE5D,6EAA6E;AAC7E,eAAO,MAAM,4BAA4B,6BAA6B,CAAA;AAEtE,OAAO,QAAQ,2CAA2C,CAAC;IACzD,UAAU,oBAAoB;QAC5B,sEAAsE;QACtE,0BAA0B,EAAE,eAAe,CAAA;KAC5C;CACF;AAED,2DAA2D;AAC3D,MAAM,WAAW,eAAe;IAC9B,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,uDAAuD;IACvD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB;AAED,2EAA2E;AAC3E,MAAM,WAAW,gBAAgB;IAC/B,0DAA0D;IAC1D,QAAQ,CAAC,UAAU,EAAE,SAAS,eAAe,EAAE,CAAA;IAC/C,gGAAgG;IAChG,QAAQ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;AAUD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CA0BzE;AAiCD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,EAAE,gBAAgB,SAAI,GAAG,gBAAgB,CAoDrH;AAED,qDAAqD;AACrD,eAAO,MAAM,iBAAiB,EAAE,OAAO,CAAC,eAAe,CAkBrD,CAAA"}
@@ -1,34 +1,76 @@
1
1
  /**
2
2
  * The periodic-review projection accumulator: a pure, synchronous fold over
3
- * `user/message` events (keyword/correction signals) and `tool/result` events
4
- * (tool-call failures) that collects candidate memory fragments. No LLM runs
5
- * here — the {@link agent/pre-step} listener drains the accumulator once it
6
- * reaches the configured threshold and runs one extraction call.
3
+ * session events that collects candidate memory fragments. No LLM runs here —
4
+ * the {@link agent/pre-step} listener drains the accumulator once it reaches
5
+ * the configured threshold and runs one extraction call.
6
+ *
7
+ * Signal sources (§5 of docs/PROJECT_NOTES.md):
8
+ * - `user/message` — keyword hits (explicit "remember" intent) and corrections
9
+ * (the user revises a prior statement).
10
+ * - `tool/call` + `tool/result` — **failure-streak pairing**: consecutive
11
+ * same-signature tool failures followed by a success emit one
12
+ * `pitfall-resolved` candidate (the workaround is verified by the success).
13
+ * One-shot failures no longer become candidates; the compaction/dispose
14
+ * flush still sees full events as the safety net.
7
15
  *
8
16
  * @module @chenhw7/dsh-memory/review/accumulator
9
17
  */
10
18
  import { z as zod } from 'zod';
11
19
  /** The projection key this unit owns in the {@link SessionProjectionMap}. */
12
20
  export const MEMORY_REVIEW_PROJECTION_KEY = 'memory-review-candidates';
13
- /** Keyword hits in user messages: explicit instruction to remember. */
21
+ /** The signal emitted when a failure streak is resolved by a success. */
22
+ export const PITFALL_RESOLVED_SIGNAL = 'pitfall-resolved';
23
+ /**
24
+ * Keyword hits in user messages: explicit instruction to remember. The
25
+ * collection layer only widens the funnel — admission conservatism (explicit
26
+ * demand or repeated theme) is enforced by the extraction prompt, so a
27
+ * missed pattern here is free loss while a false hit is cheap.
28
+ */
14
29
  const KEYWORD_PATTERNS = [
30
+ // Chinese explicit-remember intents.
15
31
  { name: 'keyword', re: /记住/ },
16
32
  { name: 'keyword', re: /别忘了/ },
17
33
  { name: 'keyword', re: /以后都/ },
34
+ { name: 'keyword', re: /记下来/ },
35
+ { name: 'keyword', re: /记一下/ },
36
+ { name: 'keyword', re: /帮我记/ },
37
+ // English explicit-remember intents.
18
38
  { name: 'keyword', re: /remember\s+that/i },
19
39
  { name: 'keyword', re: /don'?t\s+forget/i },
20
40
  { name: 'keyword', re: /from\s+now\s+on/i },
41
+ { name: 'keyword', re: /keep\s+in\s+mind/i },
42
+ { name: 'keyword', re: /make\s+a\s+note/i },
43
+ { name: 'keyword', re: /for\s+the\s+record/i },
21
44
  ];
22
- /** Correction signals in user messages: the user revises a prior statement. */
45
+ /**
46
+ * Correction signals in user messages: the user revises a prior statement.
47
+ * Same funnel philosophy as the keyword patterns above.
48
+ */
23
49
  const CORRECTION_PATTERNS = [
50
+ // Chinese revisions of a prior statement.
24
51
  { name: 'correction', re: /不对/ },
25
52
  { name: 'correction', re: /不要/ },
53
+ { name: 'correction', re: /其实是?/ },
54
+ { name: 'correction', re: /应该是/ },
55
+ { name: 'correction', re: /搞错了/ },
56
+ { name: 'correction', re: /说错了/ },
57
+ // English revisions of a prior statement.
26
58
  { name: 'correction', re: /no,?\s+i\s+said/i },
27
59
  { name: 'correction', re: /that'?s\s+wrong/i },
28
60
  { name: 'correction', re: /actually/i },
61
+ { name: 'correction', re: /i\s+meant/i },
62
+ { name: 'correction', re: /no,?\s+it'?s/i },
29
63
  ];
64
+ /** Cap on concurrently open tool calls retained in the projection state. */
65
+ const OPEN_CALLS_CAP = 64;
66
+ /** Cap on concurrently tracked failure streaks (LRU-evicted). */
67
+ const OPEN_STREAKS_CAP = 8;
68
+ /** Maximum length of one normalized signature. */
69
+ const SIGNATURE_LIMIT = 120;
70
+ /** Maximum length of the stored per-streak error text. */
71
+ const STREAK_ERROR_TEXT_LIMIT = 500;
30
72
  /** The empty-log state for the accumulator. */
31
- export const emptyAccumulator = { candidates: [], count: 0 };
73
+ export const emptyAccumulator = { candidates: [], count: 0, openCalls: {}, openStreaks: {} };
32
74
  /**
33
75
  * Extract plain text from a message event's content blocks.
34
76
  * @param event - a `user/message` or `assistant/message` session event.
@@ -70,44 +112,94 @@ export function detectSignal(text) {
70
112
  return undefined;
71
113
  }
72
114
  /**
73
- * Extract a failure fragment from a `tool/result` event that carries an error.
74
- * @param event - a `tool/result` session event.
75
- * @returns the failure description text, or `undefined` when the event has no error.
115
+ * Argument keys that carry the "primary target" of a tool call, used to
116
+ * specialize a signature: `command`-style keys collapse to the first two
117
+ * tokens; path-style keys use the path value verbatim.
76
118
  */
77
- export function toolFailureText(event) {
78
- if (event.type !== 'tool/result')
79
- return undefined;
119
+ const COMMAND_KEYS = ['command', 'cmd'];
120
+ const PATH_KEYS = ['path', 'file', 'filePath', 'file_path', 'targetFile', 'target_file'];
121
+ /**
122
+ * Normalize a tool invocation into a failure-streak signature:
123
+ * `toolName:argument-key`. Shell-like `command` arguments collapse to the
124
+ * first two tokens (`npm test`, `pnpm build`); path-like arguments use the
125
+ * path; everything else falls back to the bare tool name. Unparsable
126
+ * argument JSON also falls back to the bare tool name.
127
+ * @param name - the invoked tool's name.
128
+ * @param argumentsJson - the raw arguments JSON string from the `tool/call` event.
129
+ * @returns the normalized signature (≤ {@link SIGNATURE_LIMIT} chars).
130
+ */
131
+ export function toolSignature(name, argumentsJson) {
132
+ let signature = name;
133
+ try {
134
+ const args = JSON.parse(argumentsJson);
135
+ if (args !== null && typeof args === 'object') {
136
+ const record = args;
137
+ for (const key of COMMAND_KEYS) {
138
+ const value = record[key];
139
+ if (typeof value === 'string' && value.trim().length > 0) {
140
+ const tokens = value.trim().split(/\s+/).slice(0, 2).join(' ');
141
+ signature = `${name}:${tokens}`;
142
+ return signature.slice(0, SIGNATURE_LIMIT);
143
+ }
144
+ }
145
+ for (const key of PATH_KEYS) {
146
+ const value = record[key];
147
+ if (typeof value === 'string' && value.trim().length > 0) {
148
+ signature = `${name}:${value.trim()}`;
149
+ return signature.slice(0, SIGNATURE_LIMIT);
150
+ }
151
+ }
152
+ }
153
+ }
154
+ catch {
155
+ // Unparsable arguments fall back to the bare tool name.
156
+ }
157
+ return signature.slice(0, SIGNATURE_LIMIT);
158
+ }
159
+ /**
160
+ * Extract a truncated failure description from a `tool/result` event that
161
+ * carries an error: the error identity plus the result's text blocks (nested
162
+ * inside each `tool-result` block's `content`).
163
+ * @param event - a `tool/result` session event with `data.error` present.
164
+ * @returns the failure description text (≤ {@link STREAK_ERROR_TEXT_LIMIT} chars).
165
+ */
166
+ function failureDescription(event) {
80
167
  const data = event.data;
81
- if (data.error === undefined)
82
- return undefined;
83
- // Extract text from the result content if available, plus the error code.
84
168
  const parts = [];
85
- const content = data.message?.content;
86
- if (content !== undefined) {
87
- for (const block of content) {
88
- if (block.type === 'text' && typeof block.text === 'string')
89
- parts.push(block.text);
169
+ for (const block of data.message?.content ?? []) {
170
+ if (block.type !== 'tool-result')
171
+ continue;
172
+ for (const inner of block.content) {
173
+ if (inner.type === 'text' && typeof inner.text === 'string')
174
+ parts.push(inner.text);
90
175
  }
91
176
  }
92
177
  const errorInfo = `tool error: ${data.error.name} (${data.error.code})`;
93
- return parts.length > 0 ? `${errorInfo} — ${parts.join(' ')}` : errorInfo;
178
+ const text = parts.length > 0 ? `${errorInfo} — ${parts.join(' ')}` : errorInfo;
179
+ return text.slice(0, STREAK_ERROR_TEXT_LIMIT);
180
+ }
181
+ /** Evict the oldest entries of a plain-JSON record by a numeric seq accessor, in-place. */
182
+ function evictToCap(record, cap, seqOf) {
183
+ const keys = Object.keys(record);
184
+ if (keys.length <= cap)
185
+ return;
186
+ const sorted = [...keys].sort((a, b) => seqOf(record[a]) - seqOf(record[b]));
187
+ for (const key of sorted.slice(0, keys.length - cap)) {
188
+ delete record[key];
189
+ }
94
190
  }
95
191
  /**
96
192
  * The projection's `apply` transition: fold one committed event into the
97
193
  * accumulator. Returns the SAME state reference for events that do not
98
- * contribute a candidate (the registry's `Object.is` gate).
99
- *
100
- * Signal sources:
101
- * - `user/message` — keyword hits (explicit "remember" intent) and corrections
102
- * (user revises a prior statement).
103
- * - `tool/result` — tool-call failures (§3.6 richer signals): a failed tool
104
- * execution may carry a durable workaround worth remembering.
194
+ * contribute any change (the registry's `Object.is` gate).
105
195
  *
106
196
  * @param state - the state covering all prior events.
107
197
  * @param event - the next committed session event.
108
- * @returns the next state (same reference when the event contributes nothing).
198
+ * @param pitfallThreshold - consecutive same-signature failures required
199
+ * before a following success emits a `pitfall-resolved` candidate.
200
+ * @returns the next state (same reference when the event changes nothing).
109
201
  */
110
- export function applyAccumulator(state, event) {
202
+ export function applyAccumulator(state, event, pitfallThreshold = 2) {
111
203
  if (event.type === 'user/message') {
112
204
  const text = messageText(event);
113
205
  if (text === undefined)
@@ -116,14 +208,51 @@ export function applyAccumulator(state, event) {
116
208
  if (signal === undefined)
117
209
  return state;
118
210
  const candidate = { text, signal, seq: event.seq };
119
- return { candidates: [...state.candidates, candidate], count: state.count + 1 };
211
+ return { ...state, candidates: [...state.candidates, candidate], count: state.count + 1 };
212
+ }
213
+ if (event.type === 'tool/call') {
214
+ const callId = String(event.data.callId);
215
+ const openCalls = { ...state.openCalls, [callId]: { name: event.data.name, signature: toolSignature(event.data.name, event.data.arguments), seq: event.seq } };
216
+ evictToCap(openCalls, OPEN_CALLS_CAP, call => call.seq);
217
+ return { ...state, openCalls };
120
218
  }
121
219
  if (event.type === 'tool/result') {
122
- const text = toolFailureText(event);
123
- if (text === undefined)
220
+ const block = event.data.message?.content?.[0];
221
+ const callId = block !== undefined && block.type === 'tool-result' ? String(block.toolCallId) : undefined;
222
+ const call = callId !== undefined ? state.openCalls[callId] : undefined;
223
+ if (call === undefined)
124
224
  return state;
125
- const candidate = { text, signal: 'tool-failure', seq: event.seq };
126
- return { candidates: [...state.candidates, candidate], count: state.count + 1 };
225
+ const openCalls = { ...state.openCalls };
226
+ delete openCalls[callId];
227
+ if (event.data.error !== undefined) {
228
+ // Failure: start or extend the streak for this signature.
229
+ const existing = state.openStreaks[call.signature];
230
+ const streak = {
231
+ count: (existing?.count ?? 0) + 1,
232
+ lastErrorText: failureDescription(event),
233
+ firstSeq: existing?.firstSeq ?? event.seq,
234
+ lastSeq: event.seq,
235
+ };
236
+ const openStreaks = { ...state.openStreaks, [call.signature]: streak };
237
+ evictToCap(openStreaks, OPEN_STREAKS_CAP, s => s.lastSeq);
238
+ return { ...state, openCalls, openStreaks };
239
+ }
240
+ // Success: resolve the streak if it reached the threshold; either way the
241
+ // call is closed (result received) and the streak ends.
242
+ const streak = state.openStreaks[call.signature];
243
+ if (streak === undefined)
244
+ return { ...state, openCalls };
245
+ const openStreaks = { ...state.openStreaks };
246
+ delete openStreaks[call.signature];
247
+ if (streak.count < pitfallThreshold) {
248
+ return { ...state, openCalls, openStreaks };
249
+ }
250
+ const candidate = {
251
+ text: `tool "${call.name}" (signature: ${call.signature}) failed ${streak.count} time(s) before succeeding. Last error: ${streak.lastErrorText}. Streak spans seqs ${streak.firstSeq}–${streak.lastSeq}, resolved by the call at seq ${call.seq}.`,
252
+ signal: PITFALL_RESOLVED_SIGNAL,
253
+ seq: event.seq,
254
+ };
255
+ return { ...state, openCalls, openStreaks, candidates: [...state.candidates, candidate], count: state.count + 1 };
127
256
  }
128
257
  return state;
129
258
  }
@@ -135,5 +264,16 @@ export const accumulatorSchema = zod.object({
135
264
  seq: zod.number(),
136
265
  })),
137
266
  count: zod.number(),
267
+ openCalls: zod.record(zod.string(), zod.object({
268
+ name: zod.string(),
269
+ signature: zod.string(),
270
+ seq: zod.number(),
271
+ })),
272
+ openStreaks: zod.record(zod.string(), zod.object({
273
+ count: zod.number(),
274
+ lastErrorText: zod.string(),
275
+ firstSeq: zod.number(),
276
+ lastSeq: zod.number(),
277
+ })),
138
278
  });
139
279
  //# sourceMappingURL=accumulator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"accumulator.js","sourceRoot":"","sources":["../../src/review/accumulator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,IAAI,GAAG,EAAE,MAAM,KAAK,CAAA;AAI9B,6EAA6E;AAC7E,MAAM,CAAC,MAAM,4BAA4B,GAAG,0BAA0B,CAAA;AA8BtE,uEAAuE;AACvE,MAAM,gBAAgB,GAA8D;IAClF,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE;IAC7B,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE;IAC9B,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE;IAC9B,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,kBAAkB,EAAE;IAC3C,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,kBAAkB,EAAE;IAC3C,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,kBAAkB,EAAE;CAC5C,CAAA;AAED,+EAA+E;AAC/E,MAAM,mBAAmB,GAA8D;IACrF,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE;IAChC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE;IAChC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,kBAAkB,EAAE;IAC9C,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,kBAAkB,EAAE;IAC9C,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,WAAW,EAAE;CACxC,CAAA;AAED,+CAA+C;AAC/C,MAAM,CAAC,MAAM,gBAAgB,GAAqB,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAA;AAE9E;;;;GAIG;AACH,MAAM,UAAU,WAA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M,EAAE;QACpB,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE;KAClB,CAAC,CAAC;IACH,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE;IACnB,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC;QAC7C,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE;QAClB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE;QACvB,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE;KAClB,CAAC,CAAC;IACH,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC;QAC/C,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE;QACnB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE;QAC3B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE;QACtB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE;KACtB,CAAC,CAAC;CACJ,CAAC,CAAA"}
@@ -44,13 +44,26 @@ export interface DedupCandidate {
44
44
  * @returns the existing entry id to merge into, or `undefined` for a new entry.
45
45
  */
46
46
  export declare function findDuplicate(candidateContent: string, candidateScope: string, existing: readonly DedupCandidate[], threshold?: number): string | undefined;
47
+ /**
48
+ * Upper bound on merged content produced by {@link mergeContent}. Past this
49
+ * cap the merge falls back to keeping the longer side instead of appending,
50
+ * so repeated near-duplicate merges can never grow an entry without bound.
51
+ * True re-summarization of oversized entries belongs to the curator pass.
52
+ */
53
+ export declare const MERGE_CHAR_LIMIT = 600;
47
54
  /**
48
55
  * Merge two memory contents into one. When the new content is a strict
49
- * superset (contains the old text as a substring), the new content wins
56
+ * superset (contains the old text as a substring), the longer content wins
50
57
  * outright. Otherwise, append the new content as an addendum so no
51
- * information is lost.
58
+ * information is lost — unless the concatenation would exceed `maxChars`,
59
+ * in which case the longer side wins instead, bounding entry growth while
60
+ * staying deterministic and LLM-free.
61
+ *
62
+ * @param oldContent - the stored content.
63
+ * @param newContent - the incoming candidate content.
64
+ * @param maxChars - upper bound for the concatenated form (default {@link MERGE_CHAR_LIMIT}).
52
65
  */
53
- export declare function mergeContent(oldContent: string, newContent: string): string;
66
+ export declare function mergeContent(oldContent: string, newContent: string, maxChars?: number): string;
54
67
  /**
55
68
  * Project a MemoryEntry to the minimal shape findDuplicate needs.
56
69
  */
@@ -1 +1 @@
1
- {"version":3,"file":"dedup.d.ts","sourceRoot":"","sources":["../../src/review/dedup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAyC9C;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAerD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAQxE;AAED,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC3B,gBAAgB,EAAE,MAAM,EACxB,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,SAAS,cAAc,EAAE,EACnC,SAAS,GAAE,MAAa,GACvB,MAAM,GAAG,SAAS,CAepB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAK3E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc,CAEnE;AAID,4DAA4D;AAC5D,MAAM,MA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,MAAM,CAQhH;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc,CAEnE;AAID,4DAA4D;AAC5D,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,QAAQ,GAAG,KAAK,CAAA;AAEzD,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,QAKkD,CAAA;AAElF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAEpF;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAK5D"}
@@ -118,17 +118,34 @@ export function findDuplicate(candidateContent, candidateScope, existing, thresh
118
118
  }
119
119
  return bestId;
120
120
  }
121
+ /**
122
+ * Upper bound on merged content produced by {@link mergeContent}. Past this
123
+ * cap the merge falls back to keeping the longer side instead of appending,
124
+ * so repeated near-duplicate merges can never grow an entry without bound.
125
+ * True re-summarization of oversized entries belongs to the curator pass.
126
+ */
127
+ export const MERGE_CHAR_LIMIT = 600;
121
128
  /**
122
129
  * Merge two memory contents into one. When the new content is a strict
123
- * superset (contains the old text as a substring), the new content wins
130
+ * superset (contains the old text as a substring), the longer content wins
124
131
  * outright. Otherwise, append the new content as an addendum so no
125
- * information is lost.
132
+ * information is lost — unless the concatenation would exceed `maxChars`,
133
+ * in which case the longer side wins instead, bounding entry growth while
134
+ * staying deterministic and LLM-free.
135
+ *
136
+ * @param oldContent - the stored content.
137
+ * @param newContent - the incoming candidate content.
138
+ * @param maxChars - upper bound for the concatenated form (default {@link MERGE_CHAR_LIMIT}).
126
139
  */
127
- export function mergeContent(oldContent, newContent) {
140
+ export function mergeContent(oldContent, newContent, maxChars = MERGE_CHAR_LIMIT) {
128
141
  if (oldContent.includes(newContent) || newContent.includes(oldContent)) {
129
142
  return newContent.length >= oldContent.length ? newContent : oldContent;
130
143
  }
131
- return `${oldContent} ${newContent}`;
144
+ const merged = `${oldContent} ${newContent}`;
145
+ if (merged.length <= maxChars)
146
+ return merged;
147
+ // Over the cap: prefer the more informative side rather than growing forever.
148
+ return newContent.length >= oldContent.length ? newContent : oldContent;
132
149
  }
133
150
  /**
134
151
  * Project a MemoryEntry to the minimal shape findDuplicate needs.
@@ -1 +1 @@
1
- {"version":3,"file":"dedup.js","sourceRoot":"","sources":["../../src/review/dedup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO;IACnE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI;IACrE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IACrE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM;CACjE,CAAC,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,aAAa;IACb,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IAClB,KAAK;IACL,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IAC5B,QAAQ;IACR,GAAG,EAAE,GAAG,EAAE,GAAG;IACb,QAAQ;IACR,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,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