@fgv/ts-agent-memory 5.1.0-36 → 5.1.0-39

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 (197) hide show
  1. package/.rush/temp/{f6a88bfdd66517ccb98c2c7ae1be6e6fe9e15d38.tar.log → b82cf6bdece20481260e6bab946179eeec9d7b46.tar.log} +116 -2
  2. package/.rush/temp/chunked-rush-logs/ts-agent-memory.build.chunks.jsonl +4 -4
  3. package/.rush/temp/operation/build/all.log +4 -4
  4. package/.rush/temp/operation/build/log-chunks.jsonl +4 -4
  5. package/.rush/temp/operation/build/state.json +1 -1
  6. package/.rush/temp/shrinkwrap-deps.json +222 -221
  7. package/config/jest.config.json +1 -1
  8. package/dist/index.js +2 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/packlets/ingest/cycleGuard.js +111 -0
  11. package/dist/packlets/ingest/cycleGuard.js.map +1 -0
  12. package/dist/packlets/ingest/hostStages.js +6 -0
  13. package/dist/packlets/ingest/hostStages.js.map +1 -0
  14. package/dist/packlets/ingest/index.js +9 -0
  15. package/dist/packlets/ingest/index.js.map +1 -0
  16. package/dist/packlets/ingest/model.js +6 -0
  17. package/dist/packlets/ingest/model.js.map +1 -0
  18. package/dist/packlets/ingest/orchestrator.js +438 -0
  19. package/dist/packlets/ingest/orchestrator.js.map +1 -0
  20. package/dist/packlets/retrieve/index.js +1 -0
  21. package/dist/packlets/retrieve/index.js.map +1 -1
  22. package/dist/packlets/retrieve/temporalRetrievers.js +172 -0
  23. package/dist/packlets/retrieve/temporalRetrievers.js.map +1 -0
  24. package/dist/packlets/store/fileTreeMemoryStore.js +323 -41
  25. package/dist/packlets/store/fileTreeMemoryStore.js.map +1 -1
  26. package/dist/packlets/tools/index.js +6 -0
  27. package/dist/packlets/tools/index.js.map +1 -0
  28. package/dist/packlets/tools/memoryTools.js +337 -0
  29. package/dist/packlets/tools/memoryTools.js.map +1 -0
  30. package/dist/packlets/types/identityCodec.js +115 -0
  31. package/dist/packlets/types/identityCodec.js.map +1 -1
  32. package/dist/packlets/types/index.js +1 -0
  33. package/dist/packlets/types/index.js.map +1 -1
  34. package/dist/packlets/types/temporal.js +85 -0
  35. package/dist/packlets/types/temporal.js.map +1 -0
  36. package/dist/packlets/types/writePolicy.js +96 -0
  37. package/dist/packlets/types/writePolicy.js.map +1 -1
  38. package/dist/test/unit/converters/antagonistRoundTrip.test.js +95 -0
  39. package/dist/test/unit/converters/antagonistRoundTrip.test.js.map +1 -0
  40. package/dist/test/unit/ingest/antagonistCycleAndParity.test.js +273 -0
  41. package/dist/test/unit/ingest/antagonistCycleAndParity.test.js.map +1 -0
  42. package/dist/test/unit/ingest/cycleGuard.test.js +54 -0
  43. package/dist/test/unit/ingest/cycleGuard.test.js.map +1 -0
  44. package/dist/test/unit/ingest/orchestrator.test.js +913 -0
  45. package/dist/test/unit/ingest/orchestrator.test.js.map +1 -0
  46. package/dist/test/unit/retrieve/temporalRetrievers.test.js +182 -0
  47. package/dist/test/unit/retrieve/temporalRetrievers.test.js.map +1 -0
  48. package/dist/test/unit/store/antagonistTemporalBoundary.test.js +120 -0
  49. package/dist/test/unit/store/antagonistTemporalBoundary.test.js.map +1 -0
  50. package/dist/test/unit/store/fileTreeMemoryStore.test.js +74 -7
  51. package/dist/test/unit/store/fileTreeMemoryStore.test.js.map +1 -1
  52. package/dist/test/unit/store/temporalStore.test.js +398 -0
  53. package/dist/test/unit/store/temporalStore.test.js.map +1 -0
  54. package/dist/test/unit/tools/memoryTools.test.js +572 -0
  55. package/dist/test/unit/tools/memoryTools.test.js.map +1 -0
  56. package/dist/test/unit/types/temporalCodec.test.js +203 -0
  57. package/dist/test/unit/types/temporalCodec.test.js.map +1 -0
  58. package/dist/test/unit/types/temporalPolicy.test.js +62 -0
  59. package/dist/test/unit/types/temporalPolicy.test.js.map +1 -0
  60. package/dist/ts-agent-memory.d.ts +1042 -10
  61. package/dist/tsdoc-metadata.json +1 -1
  62. package/etc/ts-agent-memory.api.md +284 -0
  63. package/lib/index.d.ts +2 -0
  64. package/lib/index.d.ts.map +1 -1
  65. package/lib/index.js +2 -0
  66. package/lib/index.js.map +1 -1
  67. package/lib/packlets/ingest/cycleGuard.d.ts +41 -0
  68. package/lib/packlets/ingest/cycleGuard.d.ts.map +1 -0
  69. package/lib/packlets/ingest/cycleGuard.js +115 -0
  70. package/lib/packlets/ingest/cycleGuard.js.map +1 -0
  71. package/lib/packlets/ingest/hostStages.d.ts +88 -0
  72. package/lib/packlets/ingest/hostStages.d.ts.map +1 -0
  73. package/lib/packlets/ingest/hostStages.js +7 -0
  74. package/lib/packlets/ingest/hostStages.js.map +1 -0
  75. package/lib/packlets/ingest/index.d.ts +5 -0
  76. package/lib/packlets/ingest/index.d.ts.map +1 -0
  77. package/lib/packlets/ingest/index.js +25 -0
  78. package/lib/packlets/ingest/index.js.map +1 -0
  79. package/lib/packlets/ingest/model.d.ts +177 -0
  80. package/lib/packlets/ingest/model.d.ts.map +1 -0
  81. package/lib/packlets/ingest/model.js +7 -0
  82. package/lib/packlets/ingest/model.js.map +1 -0
  83. package/lib/packlets/ingest/orchestrator.d.ts +206 -0
  84. package/lib/packlets/ingest/orchestrator.d.ts.map +1 -0
  85. package/lib/packlets/ingest/orchestrator.js +442 -0
  86. package/lib/packlets/ingest/orchestrator.js.map +1 -0
  87. package/lib/packlets/retrieve/index.d.ts +1 -0
  88. package/lib/packlets/retrieve/index.d.ts.map +1 -1
  89. package/lib/packlets/retrieve/index.js +1 -0
  90. package/lib/packlets/retrieve/index.js.map +1 -1
  91. package/lib/packlets/retrieve/temporalRetrievers.d.ts +78 -0
  92. package/lib/packlets/retrieve/temporalRetrievers.d.ts.map +1 -0
  93. package/lib/packlets/retrieve/temporalRetrievers.js +178 -0
  94. package/lib/packlets/retrieve/temporalRetrievers.js.map +1 -0
  95. package/lib/packlets/store/fileTreeMemoryStore.d.ts +118 -9
  96. package/lib/packlets/store/fileTreeMemoryStore.d.ts.map +1 -1
  97. package/lib/packlets/store/fileTreeMemoryStore.js +322 -40
  98. package/lib/packlets/store/fileTreeMemoryStore.js.map +1 -1
  99. package/lib/packlets/tools/index.d.ts +2 -0
  100. package/lib/packlets/tools/index.d.ts.map +1 -0
  101. package/lib/packlets/tools/index.js +22 -0
  102. package/lib/packlets/tools/index.js.map +1 -0
  103. package/lib/packlets/tools/memoryTools.d.ts +139 -0
  104. package/lib/packlets/tools/memoryTools.d.ts.map +1 -0
  105. package/lib/packlets/tools/memoryTools.js +341 -0
  106. package/lib/packlets/tools/memoryTools.js.map +1 -0
  107. package/lib/packlets/types/identityCodec.d.ts +86 -0
  108. package/lib/packlets/types/identityCodec.d.ts.map +1 -1
  109. package/lib/packlets/types/identityCodec.js +118 -1
  110. package/lib/packlets/types/identityCodec.js.map +1 -1
  111. package/lib/packlets/types/index.d.ts +1 -0
  112. package/lib/packlets/types/index.d.ts.map +1 -1
  113. package/lib/packlets/types/index.js +1 -0
  114. package/lib/packlets/types/index.js.map +1 -1
  115. package/lib/packlets/types/temporal.d.ts +40 -0
  116. package/lib/packlets/types/temporal.d.ts.map +1 -0
  117. package/lib/packlets/types/temporal.js +92 -0
  118. package/lib/packlets/types/temporal.js.map +1 -0
  119. package/lib/packlets/types/writePolicy.d.ts +49 -0
  120. package/lib/packlets/types/writePolicy.d.ts.map +1 -1
  121. package/lib/packlets/types/writePolicy.js +98 -1
  122. package/lib/packlets/types/writePolicy.js.map +1 -1
  123. package/lib/test/unit/converters/antagonistRoundTrip.test.d.ts +10 -0
  124. package/lib/test/unit/converters/antagonistRoundTrip.test.d.ts.map +1 -0
  125. package/lib/test/unit/converters/antagonistRoundTrip.test.js +97 -0
  126. package/lib/test/unit/converters/antagonistRoundTrip.test.js.map +1 -0
  127. package/lib/test/unit/ingest/antagonistCycleAndParity.test.d.ts +9 -0
  128. package/lib/test/unit/ingest/antagonistCycleAndParity.test.d.ts.map +1 -0
  129. package/lib/test/unit/ingest/antagonistCycleAndParity.test.js +275 -0
  130. package/lib/test/unit/ingest/antagonistCycleAndParity.test.js.map +1 -0
  131. package/lib/test/unit/ingest/cycleGuard.test.d.ts +2 -0
  132. package/lib/test/unit/ingest/cycleGuard.test.d.ts.map +1 -0
  133. package/lib/test/unit/ingest/cycleGuard.test.js +56 -0
  134. package/lib/test/unit/ingest/cycleGuard.test.js.map +1 -0
  135. package/lib/test/unit/ingest/orchestrator.test.d.ts +2 -0
  136. package/lib/test/unit/ingest/orchestrator.test.d.ts.map +1 -0
  137. package/lib/test/unit/ingest/orchestrator.test.js +915 -0
  138. package/lib/test/unit/ingest/orchestrator.test.js.map +1 -0
  139. package/lib/test/unit/retrieve/temporalRetrievers.test.d.ts +2 -0
  140. package/lib/test/unit/retrieve/temporalRetrievers.test.d.ts.map +1 -0
  141. package/lib/test/unit/retrieve/temporalRetrievers.test.js +184 -0
  142. package/lib/test/unit/retrieve/temporalRetrievers.test.js.map +1 -0
  143. package/lib/test/unit/store/antagonistTemporalBoundary.test.d.ts +9 -0
  144. package/lib/test/unit/store/antagonistTemporalBoundary.test.d.ts.map +1 -0
  145. package/lib/test/unit/store/antagonistTemporalBoundary.test.js +122 -0
  146. package/lib/test/unit/store/antagonistTemporalBoundary.test.js.map +1 -0
  147. package/lib/test/unit/store/fileTreeMemoryStore.test.js +74 -7
  148. package/lib/test/unit/store/fileTreeMemoryStore.test.js.map +1 -1
  149. package/lib/test/unit/store/temporalStore.test.d.ts +2 -0
  150. package/lib/test/unit/store/temporalStore.test.d.ts.map +1 -0
  151. package/lib/test/unit/store/temporalStore.test.js +400 -0
  152. package/lib/test/unit/store/temporalStore.test.js.map +1 -0
  153. package/lib/test/unit/tools/memoryTools.test.d.ts +2 -0
  154. package/lib/test/unit/tools/memoryTools.test.d.ts.map +1 -0
  155. package/lib/test/unit/tools/memoryTools.test.js +574 -0
  156. package/lib/test/unit/tools/memoryTools.test.js.map +1 -0
  157. package/lib/test/unit/types/temporalCodec.test.d.ts +2 -0
  158. package/lib/test/unit/types/temporalCodec.test.d.ts.map +1 -0
  159. package/lib/test/unit/types/temporalCodec.test.js +205 -0
  160. package/lib/test/unit/types/temporalCodec.test.js.map +1 -0
  161. package/lib/test/unit/types/temporalPolicy.test.d.ts +2 -0
  162. package/lib/test/unit/types/temporalPolicy.test.d.ts.map +1 -0
  163. package/lib/test/unit/types/temporalPolicy.test.js +64 -0
  164. package/lib/test/unit/types/temporalPolicy.test.js.map +1 -0
  165. package/package.json +19 -19
  166. package/rush-logs/ts-agent-memory.build.cache.log +1 -1
  167. package/rush-logs/ts-agent-memory.build.log +4 -4
  168. package/src/index.ts +2 -0
  169. package/src/packlets/ingest/cycleGuard.ts +142 -0
  170. package/src/packlets/ingest/hostStages.ts +111 -0
  171. package/src/packlets/ingest/index.ts +9 -0
  172. package/src/packlets/ingest/model.ts +184 -0
  173. package/src/packlets/ingest/orchestrator.ts +797 -0
  174. package/src/packlets/retrieve/index.ts +1 -0
  175. package/src/packlets/retrieve/temporalRetrievers.ts +210 -0
  176. package/src/packlets/store/fileTreeMemoryStore.ts +460 -66
  177. package/src/packlets/tools/index.ts +6 -0
  178. package/src/packlets/tools/memoryTools.ts +579 -0
  179. package/src/packlets/types/identityCodec.ts +184 -0
  180. package/src/packlets/types/index.ts +1 -0
  181. package/src/packlets/types/temporal.ts +96 -0
  182. package/src/packlets/types/writePolicy.ts +127 -0
  183. package/src/test/unit/converters/antagonistRoundTrip.test.ts +110 -0
  184. package/src/test/unit/ingest/antagonistCycleAndParity.test.ts +362 -0
  185. package/src/test/unit/ingest/cycleGuard.test.ts +68 -0
  186. package/src/test/unit/ingest/orchestrator.test.ts +1158 -0
  187. package/src/test/unit/retrieve/temporalRetrievers.test.ts +226 -0
  188. package/src/test/unit/store/antagonistTemporalBoundary.test.ts +158 -0
  189. package/src/test/unit/store/fileTreeMemoryStore.test.ts +98 -7
  190. package/src/test/unit/store/temporalStore.test.ts +469 -0
  191. package/src/test/unit/tools/memoryTools.test.ts +771 -0
  192. package/src/test/unit/types/temporalCodec.test.ts +259 -0
  193. package/src/test/unit/types/temporalPolicy.test.ts +96 -0
  194. package/temp/build/lint/_eslint-5eVG3S6w.json +122 -46
  195. package/temp/build/typescript/ts_8nwakTlr.json +1 -1
  196. package/temp/ts-agent-memory.api.json +11984 -6314
  197. package/temp/ts-agent-memory.api.md +284 -0
@@ -0,0 +1,771 @@
1
+ /*
2
+ * Copyright (c) 2026 Erik Fortune
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import '@fgv/ts-utils-jest';
7
+ import { Converter, Converters, Result, fail, succeed } from '@fgv/ts-utils';
8
+ import { FileTree, JsonObject } from '@fgv/ts-json-base';
9
+ import { AiAssist } from '@fgv/ts-extras';
10
+ import {
11
+ AdmissionDecision,
12
+ BodyConverterRegistry,
13
+ DEFAULT_MEMORY_TOOLS,
14
+ FileTreeMemoryStore,
15
+ HybridRetriever,
16
+ IBodyConverterRegistry,
17
+ IIdentityCodec,
18
+ IIndexedMemoryRecord,
19
+ IMemoryRecord,
20
+ IMemoryStore,
21
+ IMemoryToolResultItem,
22
+ IMemoryWriteResult,
23
+ IWritePolicy,
24
+ Kind,
25
+ KnowledgeIdentityCodec,
26
+ LinkTraversalRetriever,
27
+ MemoryIndex,
28
+ IIdentityCodecResult,
29
+ MemoryScopeKey,
30
+ MemoryToolName,
31
+ MtmIdentityCodec,
32
+ RecencyRetriever,
33
+ ScoreUnionMergeStrategy,
34
+ StructuredFilterRetriever,
35
+ TagRetriever,
36
+ createMemoryTools,
37
+ envelopeConverter
38
+ } from '../../../index';
39
+
40
+ const knowledgeKind: Kind = 'knowledge' as Kind;
41
+ const mtmKind: Kind = 'mtm' as Kind;
42
+
43
+ // ---------------------------------------------------------------------------
44
+ // Fixtures
45
+ // ---------------------------------------------------------------------------
46
+
47
+ function mutableRoot(): FileTree.IMutableFileTreeDirectoryItem {
48
+ const tree = FileTree.inMemory([], { mutable: true }).orThrow();
49
+ const root = tree.getDirectory('/').orThrow();
50
+ if (!FileTree.isMutableDirectoryItem(root)) {
51
+ throw new Error('expected a mutable root directory');
52
+ }
53
+ return root;
54
+ }
55
+
56
+ function registryWith(
57
+ entries: ReadonlyArray<{ kind: Kind; converter?: Converter<string> }>
58
+ ): IBodyConverterRegistry {
59
+ const registry = BodyConverterRegistry.create().orThrow();
60
+ for (const entry of entries) {
61
+ registry.register(entry.kind, entry.converter ?? Converters.string);
62
+ }
63
+ return registry;
64
+ }
65
+
66
+ const codecs: ReadonlyMap<Kind, IIdentityCodec> = new Map<Kind, IIdentityCodec>([
67
+ [knowledgeKind, new KnowledgeIdentityCodec()],
68
+ [mtmKind, new MtmIdentityCodec()]
69
+ ]);
70
+
71
+ /** A write policy that always rejects — exercises the admit-reject → fail path. */
72
+ class RejectingPolicy implements IWritePolicy {
73
+ public readonly mutableFields: ReadonlyArray<string> = ['body'];
74
+ public admit(): Result<AdmissionDecision> {
75
+ return succeed({ decision: 'reject', reason: 'blocked by test policy' });
76
+ }
77
+ public applyUpdate(existing: IMemoryRecord<unknown>): Result<IMemoryRecord<unknown>> {
78
+ return succeed(existing);
79
+ }
80
+ }
81
+
82
+ function makeStore(
83
+ params: {
84
+ registry?: IBodyConverterRegistry;
85
+ writePolicies?: ReadonlyMap<Kind, IWritePolicy>;
86
+ } = {}
87
+ ): FileTreeMemoryStore {
88
+ return FileTreeMemoryStore.create({
89
+ root: mutableRoot(),
90
+ registry: params.registry ?? registryWith([{ kind: knowledgeKind }, { kind: mtmKind }]),
91
+ codecs,
92
+ writePolicies: params.writePolicies
93
+ }).orThrow();
94
+ }
95
+
96
+ interface IEntrySpec {
97
+ readonly id: string;
98
+ readonly scope?: string;
99
+ readonly kind?: string;
100
+ readonly entityId?: string;
101
+ readonly tags?: ReadonlyArray<string>;
102
+ readonly updated?: number;
103
+ readonly links?: ReadonlyArray<string>;
104
+ }
105
+
106
+ function makeEntry(spec: IEntrySpec): IIndexedMemoryRecord {
107
+ const record: IMemoryRecord<unknown> = {
108
+ envelope: envelopeConverter
109
+ .convert({
110
+ id: spec.id,
111
+ entityId: spec.entityId ?? spec.id,
112
+ kind: spec.kind ?? 'knowledge',
113
+ tags: spec.tags ?? [],
114
+ links: (spec.links ?? []).map((target) => ({ type: 'rel', target })),
115
+ created: 0,
116
+ updated: spec.updated ?? 0,
117
+ seq: 0,
118
+ contentHash: 'h',
119
+ provenance: { source: 'agent' }
120
+ })
121
+ .orThrow(),
122
+ body: `body-${spec.id}`
123
+ };
124
+ return { scope: (spec.scope ?? 'knowledge') as MemoryScopeKey, record };
125
+ }
126
+
127
+ function makeIndex(specs: ReadonlyArray<IEntrySpec>): MemoryIndex {
128
+ const index = MemoryIndex.create().orThrow();
129
+ index.rebuild(specs.map(makeEntry)).orThrow();
130
+ return index;
131
+ }
132
+
133
+ /**
134
+ * A HybridRetriever (structured + tag) over the given entries — the seedless
135
+ * `memory_search` backing. A bare `LinkTraversalRetriever` is intentionally NOT
136
+ * composed here: it hard-fails a seedless query, so link traversal is the
137
+ * separate `memory_context` retriever.
138
+ */
139
+ function makeRetriever(specs: ReadonlyArray<IEntrySpec>): HybridRetriever {
140
+ const index = makeIndex(specs);
141
+ return HybridRetriever.create(
142
+ [
143
+ RecencyRetriever.create(index).orThrow(),
144
+ StructuredFilterRetriever.create(index).orThrow(),
145
+ TagRetriever.create(index).orThrow()
146
+ ],
147
+ ScoreUnionMergeStrategy.create().orThrow()
148
+ ).orThrow();
149
+ }
150
+
151
+ /** A LinkTraversalRetriever over the given entries — the `memory_context` backing. */
152
+ function makeLinkRetriever(specs: ReadonlyArray<IEntrySpec>): LinkTraversalRetriever {
153
+ return LinkTraversalRetriever.create(makeIndex(specs)).orThrow();
154
+ }
155
+
156
+ /** Build the full five-tool suite for structural / annotation inspection. */
157
+ function allTools(
158
+ overrides: Partial<Parameters<typeof createMemoryTools>[0]> = {}
159
+ ): ReadonlyArray<AiAssist.IAiClientTool> {
160
+ return createMemoryTools({
161
+ store: overrides.store ?? makeStore(),
162
+ retriever: overrides.retriever ?? makeRetriever([]),
163
+ registry: overrides.registry ?? registryWith([{ kind: knowledgeKind }, { kind: mtmKind }]),
164
+ codecs,
165
+ tools: ['memory_write', 'memory_read', 'memory_search', 'memory_context', 'memory_delete'],
166
+ ...overrides
167
+ });
168
+ }
169
+
170
+ function toolByName(
171
+ tools: ReadonlyArray<AiAssist.IAiClientTool>,
172
+ name: MemoryToolName
173
+ ): AiAssist.IAiClientTool {
174
+ const tool = tools.find((t) => t.config.name === name);
175
+ if (tool === undefined) {
176
+ throw new Error(`tool '${name}' not found`);
177
+ }
178
+ return tool;
179
+ }
180
+
181
+ /** The property names declared by a tool's JSON-schema. */
182
+ function schemaProperties(tool: AiAssist.IAiClientTool): string[] {
183
+ const json = tool.config.parametersSchema.toJson() as JsonObject;
184
+ return Object.keys((json.properties as JsonObject) ?? {});
185
+ }
186
+
187
+ // ---------------------------------------------------------------------------
188
+ // Tests
189
+ // ---------------------------------------------------------------------------
190
+
191
+ describe('createMemoryTools', () => {
192
+ describe('tool subset selection', () => {
193
+ test('defaults to the read-only set (excludes memory_write / memory_delete)', () => {
194
+ const tools = createMemoryTools({
195
+ store: makeStore(),
196
+ retriever: makeRetriever([]),
197
+ registry: registryWith([{ kind: knowledgeKind }])
198
+ });
199
+ expect(tools.map((t) => t.config.name)).toEqual(['memory_search', 'memory_context']);
200
+ expect(DEFAULT_MEMORY_TOOLS).toEqual(['memory_search', 'memory_context']);
201
+ });
202
+
203
+ test('includes memory_write / memory_delete only when named', () => {
204
+ const tools = createMemoryTools({
205
+ store: makeStore(),
206
+ retriever: makeRetriever([]),
207
+ registry: registryWith([{ kind: knowledgeKind }]),
208
+ codecs,
209
+ tools: ['memory_write', 'memory_delete']
210
+ });
211
+ expect(tools.map((t) => t.config.name)).toEqual(['memory_write', 'memory_delete']);
212
+ });
213
+
214
+ test('returns tools in a stable builder order regardless of selection order', () => {
215
+ const tools = createMemoryTools({
216
+ store: makeStore(),
217
+ retriever: makeRetriever([]),
218
+ registry: registryWith([{ kind: knowledgeKind }]),
219
+ codecs,
220
+ tools: ['memory_delete', 'memory_search', 'memory_write']
221
+ });
222
+ expect(tools.map((t) => t.config.name)).toEqual(['memory_write', 'memory_search', 'memory_delete']);
223
+ });
224
+
225
+ test('an empty selection yields no tools', () => {
226
+ const tools = createMemoryTools({
227
+ store: makeStore(),
228
+ retriever: makeRetriever([]),
229
+ registry: registryWith([{ kind: knowledgeKind }]),
230
+ tools: []
231
+ });
232
+ expect(tools).toEqual([]);
233
+ });
234
+ });
235
+
236
+ describe('scope isolation (adoption gate)', () => {
237
+ test('NO tool schema declares a scope (or scope-widening) property', () => {
238
+ const tools = allTools();
239
+ expect(tools).toHaveLength(5);
240
+ for (const tool of tools) {
241
+ const props = schemaProperties(tool);
242
+ expect(props.length).toBeGreaterThan(0);
243
+ for (const prop of props) {
244
+ expect(prop.toLowerCase()).not.toContain('scope');
245
+ }
246
+ }
247
+ });
248
+ });
249
+
250
+ describe('behavior annotations (Component 4)', () => {
251
+ test('read-only tools are readOnlyHint with openWorldHint false', () => {
252
+ const tools = allTools();
253
+ for (const name of ['memory_search', 'memory_context', 'memory_read'] as const) {
254
+ expect(toolByName(tools, name).config.annotations).toEqual({
255
+ readOnlyHint: true,
256
+ openWorldHint: false
257
+ });
258
+ }
259
+ });
260
+
261
+ test('memory_write is non-destructive, non-idempotent, closed-world', () => {
262
+ expect(toolByName(allTools(), 'memory_write').config.annotations).toEqual({
263
+ destructiveHint: false,
264
+ idempotentHint: false,
265
+ openWorldHint: false
266
+ });
267
+ });
268
+
269
+ test('memory_delete is destructive, idempotent, closed-world', () => {
270
+ expect(toolByName(allTools(), 'memory_delete').config.annotations).toEqual({
271
+ destructiveHint: true,
272
+ idempotentHint: true,
273
+ openWorldHint: false
274
+ });
275
+ });
276
+ });
277
+
278
+ describe('parametersSchema validation', () => {
279
+ test('memory_write accepts a well-formed record and rejects a missing body', () => {
280
+ const schema = toolByName(allTools(), 'memory_write').config.parametersSchema;
281
+ expect(schema.convert({ kind: 'knowledge', entityId: 'doc-1', body: 'hello' })).toSucceed();
282
+ expect(
283
+ schema.convert({
284
+ kind: 'knowledge',
285
+ entityId: 'doc-1',
286
+ body: 'hello',
287
+ tags: ['a'],
288
+ links: [{ type: 'rel', target: 'doc-2', confidence: 0.5 }]
289
+ })
290
+ ).toSucceed();
291
+ expect(schema.convert({ kind: 'knowledge', entityId: 'doc-1' })).toFail();
292
+ });
293
+
294
+ test('memory_read / memory_delete require kind and entityId', () => {
295
+ for (const name of ['memory_read', 'memory_delete'] as const) {
296
+ const schema = toolByName(allTools(), name).config.parametersSchema;
297
+ expect(schema.convert({ kind: 'knowledge', entityId: 'doc-1' })).toSucceed();
298
+ expect(schema.convert({ kind: 'knowledge' })).toFail();
299
+ }
300
+ });
301
+
302
+ test('memory_search rejects a non-integer limit and accepts an all-optional query', () => {
303
+ const schema = toolByName(allTools(), 'memory_search').config.parametersSchema;
304
+ expect(schema.convert({})).toSucceed();
305
+ expect(schema.convert({ tag: 'x', limit: 3 })).toSucceed();
306
+ expect(schema.convert({ limit: 'three' })).toFail();
307
+ });
308
+
309
+ test('memory_context requires a from seed', () => {
310
+ const schema = toolByName(allTools(), 'memory_context').config.parametersSchema;
311
+ expect(schema.convert({ from: 'doc-1' })).toSucceed();
312
+ expect(schema.convert({ hops: 2 })).toFail();
313
+ });
314
+ });
315
+
316
+ describe('memory_write', () => {
317
+ async function write(
318
+ tool: AiAssist.IAiClientTool,
319
+ args: Record<string, unknown>
320
+ ): Promise<Result<unknown>> {
321
+ return tool.execute(args);
322
+ }
323
+
324
+ test('writes a new record (outcome: written) and round-trips through memory_read', async () => {
325
+ const store = makeStore();
326
+ const tools = createMemoryTools({
327
+ store,
328
+ retriever: makeRetriever([]),
329
+ registry: registryWith([{ kind: knowledgeKind }]),
330
+ codecs,
331
+ tools: ['memory_write', 'memory_read']
332
+ });
333
+ const writeTool = toolByName(tools, 'memory_write');
334
+ expect(
335
+ await write(writeTool, { kind: 'knowledge', entityId: 'doc-1', body: 'first', tags: ['t'] })
336
+ ).toSucceedAndSatisfy((value) => {
337
+ const result = value as IMemoryWriteResult;
338
+ expect(result.outcome).toBe('written');
339
+ expect(result.id).toBe('doc-1');
340
+ expect(result.entityId).toBe('doc-1');
341
+ });
342
+ expect(
343
+ await toolByName(tools, 'memory_read').execute({ kind: 'knowledge', entityId: 'doc-1' })
344
+ ).toSucceedAndSatisfy((value) => {
345
+ const read = value as { found: boolean; item: IMemoryToolResultItem };
346
+ expect(read.found).toBe(true);
347
+ expect(read.item.body).toBe('first');
348
+ expect(read.item.tags).toEqual(['t']);
349
+ });
350
+ });
351
+
352
+ test('persists authored links (with confidence) on the written record', async () => {
353
+ const store = makeStore();
354
+ const tools = createMemoryTools({
355
+ store,
356
+ retriever: makeRetriever([]),
357
+ registry: registryWith([{ kind: knowledgeKind }]),
358
+ codecs,
359
+ tools: ['memory_write', 'memory_read']
360
+ });
361
+ expect(
362
+ await toolByName(tools, 'memory_write').execute({
363
+ kind: 'knowledge',
364
+ entityId: 'doc-1',
365
+ body: 'linked',
366
+ links: [
367
+ { type: 'rel', target: 'doc-2', confidence: 0.9 },
368
+ { type: 'rel', target: 'doc-3' }
369
+ ]
370
+ })
371
+ ).toSucceedAndSatisfy((v) => expect((v as IMemoryWriteResult).outcome).toBe('written'));
372
+ expect(
373
+ await toolByName(tools, 'memory_read').execute({ kind: 'knowledge', entityId: 'doc-1' })
374
+ ).toSucceedAndSatisfy(() => undefined);
375
+ });
376
+
377
+ test('an identical re-put of the same entity is a dedup no-op (outcome: deduped)', async () => {
378
+ const store = makeStore();
379
+ const tool = toolByName(allTools({ store }), 'memory_write');
380
+ expect(await write(tool, { kind: 'knowledge', entityId: 'doc-1', body: 'same' })).toSucceedAndSatisfy(
381
+ (v) => expect((v as IMemoryWriteResult).outcome).toBe('written')
382
+ );
383
+ expect(await write(tool, { kind: 'knowledge', entityId: 'doc-1', body: 'same' })).toSucceedAndSatisfy(
384
+ (v) => expect((v as IMemoryWriteResult).outcome).toBe('deduped')
385
+ );
386
+ });
387
+
388
+ test('content-scope dedup under a different entity reports deduped', async () => {
389
+ const store = makeStore();
390
+ const tool = toolByName(allTools({ store }), 'memory_write');
391
+ expect(await write(tool, { kind: 'knowledge', entityId: 'doc-a', body: 'shared' })).toSucceed();
392
+ // Knowledge dedups scope-wide: identical body under a different docId is a no-op
393
+ // that returns the existing (different-entity) record.
394
+ expect(await write(tool, { kind: 'knowledge', entityId: 'doc-b', body: 'shared' })).toSucceedAndSatisfy(
395
+ (v) => expect((v as IMemoryWriteResult).outcome).toBe('deduped')
396
+ );
397
+ });
398
+
399
+ test('an update with new content reports written', async () => {
400
+ const store = makeStore();
401
+ const tool = toolByName(allTools({ store }), 'memory_write');
402
+ expect(await write(tool, { kind: 'knowledge', entityId: 'doc-1', body: 'v1' })).toSucceed();
403
+ expect(await write(tool, { kind: 'knowledge', entityId: 'doc-1', body: 'v2' })).toSucceedAndSatisfy(
404
+ (v) => expect((v as IMemoryWriteResult).outcome).toBe('written')
405
+ );
406
+ });
407
+
408
+ test('maps an MTM composite entityId to its turn stem', async () => {
409
+ const store = makeStore();
410
+ const tools = createMemoryTools({
411
+ store,
412
+ retriever: makeRetriever([]),
413
+ registry: registryWith([{ kind: knowledgeKind }, { kind: mtmKind }]),
414
+ codecs,
415
+ tools: ['memory_write', 'memory_read']
416
+ });
417
+ expect(
418
+ await toolByName(tools, 'memory_write').execute({
419
+ kind: 'mtm',
420
+ entityId: 'conv-1:7',
421
+ body: 'turn body'
422
+ })
423
+ ).toSucceedAndSatisfy((value) => {
424
+ const result = value as IMemoryWriteResult;
425
+ expect(result.id).toBe('turn-7');
426
+ expect(result.entityId).toBe('conv-1:7');
427
+ });
428
+ // Read back via the same composite entityId.
429
+ expect(
430
+ await toolByName(tools, 'memory_read').execute({ kind: 'mtm', entityId: 'conv-1:7' })
431
+ ).toSucceedAndSatisfy((value) => {
432
+ expect((value as { found: boolean }).found).toBe(true);
433
+ });
434
+ });
435
+
436
+ test('a body the kind converter rejects fails the write', async () => {
437
+ const rejectBad: Converter<string> = Converters.string.map((s) =>
438
+ s === 'BAD' ? fail('body not allowed') : succeed(s)
439
+ );
440
+ const registry = registryWith([{ kind: knowledgeKind, converter: rejectBad }]);
441
+ const store = makeStore({ registry });
442
+ const tool = toolByName(allTools({ store, registry }), 'memory_write');
443
+ expect(await write(tool, { kind: 'knowledge', entityId: 'doc-1', body: 'BAD' })).toFailWith(
444
+ /invalid body|body not allowed/i
445
+ );
446
+ });
447
+
448
+ test('a policy admit-reject surfaces as a failure', async () => {
449
+ const store = makeStore({
450
+ writePolicies: new Map<Kind, IWritePolicy>([[knowledgeKind, new RejectingPolicy()]])
451
+ });
452
+ const tool = toolByName(allTools({ store }), 'memory_write');
453
+ expect(await write(tool, { kind: 'knowledge', entityId: 'doc-1', body: 'x' })).toFailWith(
454
+ /rejected by policy|blocked by test policy/i
455
+ );
456
+ });
457
+
458
+ test('fails when no codec is available for the kind', async () => {
459
+ const store = makeStore();
460
+ const tool = toolByName(
461
+ createMemoryTools({
462
+ store,
463
+ retriever: makeRetriever([]),
464
+ registry: registryWith([{ kind: knowledgeKind }]),
465
+ tools: ['memory_write'] // no codecs / defaultCodec supplied
466
+ }),
467
+ 'memory_write'
468
+ );
469
+ expect(await write(tool, { kind: 'knowledge', entityId: 'doc-1', body: 'x' })).toFailWith(
470
+ /no identity codec available/i
471
+ );
472
+ });
473
+
474
+ test('rejects a kind with no registered converter', async () => {
475
+ const tool = toolByName(allTools(), 'memory_write');
476
+ expect(await write(tool, { kind: 'unregistered', entityId: 'doc-1', body: 'x' })).toFailWith(
477
+ /no registered body converter/i
478
+ );
479
+ });
480
+
481
+ test('rejects a kind outside the kinds whitelist', async () => {
482
+ const tool = toolByName(allTools({ kinds: [mtmKind] }), 'memory_write');
483
+ expect(await write(tool, { kind: 'knowledge', entityId: 'doc-1', body: 'x' })).toFailWith(
484
+ /not enabled for memory tools/i
485
+ );
486
+ });
487
+
488
+ test('propagates a store.get failure (does not mask a real fault as a fresh write)', async () => {
489
+ const failingStore: IMemoryStore = {
490
+ get: async () => fail('disk fault'),
491
+ getById: async () => fail('unused'),
492
+ list: async () => succeed([]),
493
+ put: async (record) => succeed(record),
494
+ delete: async () => fail('unused')
495
+ };
496
+ const tool = toolByName(
497
+ createMemoryTools({
498
+ store: failingStore,
499
+ retriever: makeRetriever([]),
500
+ registry: registryWith([{ kind: knowledgeKind }]),
501
+ codecs,
502
+ tools: ['memory_write']
503
+ }),
504
+ 'memory_write'
505
+ );
506
+ expect(await write(tool, { kind: 'knowledge', entityId: 'doc-1', body: 'x' })).toFailWith(
507
+ /disk fault/i
508
+ );
509
+ });
510
+
511
+ test('rejects a versioned/temporal kind', async () => {
512
+ const versionedCodec: IIdentityCodec = {
513
+ encode: (entityId): Result<IIdentityCodecResult> =>
514
+ succeed({ scope: 'knowledge' as MemoryScopeKey, idStem: entityId as string, isVersioned: true }),
515
+ decode: (): Result<never> => fail('unused'),
516
+ verifyRoundTrip: (): Result<true> => succeed(true)
517
+ };
518
+ const tool = toolByName(
519
+ createMemoryTools({
520
+ store: makeStore(),
521
+ retriever: makeRetriever([]),
522
+ registry: registryWith([{ kind: knowledgeKind }]),
523
+ codecs: new Map<Kind, IIdentityCodec>([[knowledgeKind, versionedCodec]]),
524
+ tools: ['memory_write']
525
+ }),
526
+ 'memory_write'
527
+ );
528
+ expect(await write(tool, { kind: 'knowledge', entityId: 'doc-1', body: 'x' })).toFailWith(
529
+ /versioned\/temporal kind .* is not supported/i
530
+ );
531
+ });
532
+
533
+ test('rejects malformed arguments', async () => {
534
+ const tool = toolByName(allTools(), 'memory_write');
535
+ expect(await write(tool, { kind: 'knowledge', entityId: 'doc-1' })).toFailWith(/invalid arguments/i);
536
+ });
537
+ });
538
+
539
+ describe('memory_read', () => {
540
+ test('returns found:false when the record is absent', async () => {
541
+ const tool = toolByName(allTools(), 'memory_read');
542
+ expect(await tool.execute({ kind: 'knowledge', entityId: 'missing' })).toSucceedWith({ found: false });
543
+ });
544
+
545
+ test('applies the handleFor hook to the returned item', async () => {
546
+ const store = makeStore();
547
+ const tools = createMemoryTools({
548
+ store,
549
+ retriever: makeRetriever([]),
550
+ registry: registryWith([{ kind: knowledgeKind }]),
551
+ codecs,
552
+ tools: ['memory_write', 'memory_read'],
553
+ handleFor: (r) => `mnemonic:${r.envelope.id}`
554
+ });
555
+ await toolByName(tools, 'memory_write').execute({ kind: 'knowledge', entityId: 'doc-1', body: 'b' });
556
+ expect(
557
+ await toolByName(tools, 'memory_read').execute({ kind: 'knowledge', entityId: 'doc-1' })
558
+ ).toSucceedAndSatisfy((value) => {
559
+ const read = value as { found: boolean; item: IMemoryToolResultItem };
560
+ expect(read.item.handle).toBe('mnemonic:doc-1');
561
+ });
562
+ });
563
+
564
+ test('propagates a store failure (bad entityId)', async () => {
565
+ const tool = toolByName(allTools(), 'memory_read');
566
+ expect(await tool.execute({ kind: 'knowledge', entityId: ' ' })).toFail();
567
+ });
568
+ });
569
+
570
+ describe('memory_search', () => {
571
+ test('returns projected results keyed by raw MemoryId when no handleFor is supplied', async () => {
572
+ const retriever = makeRetriever([
573
+ { id: 'doc-1', tags: ['topic'] },
574
+ { id: 'doc-2', tags: ['topic'] }
575
+ ]);
576
+ const tool = toolByName(
577
+ createMemoryTools({
578
+ store: makeStore(),
579
+ retriever,
580
+ registry: registryWith([{ kind: knowledgeKind }])
581
+ }),
582
+ 'memory_search'
583
+ );
584
+ expect(await tool.execute({ tag: 'topic' })).toSucceedAndSatisfy((value) => {
585
+ const out = value as { count: number; results: ReadonlyArray<IMemoryToolResultItem> };
586
+ expect(out.count).toBe(2);
587
+ expect(out.results.map((r) => r.handle).sort()).toEqual(['doc-1', 'doc-2']);
588
+ });
589
+ });
590
+
591
+ test('uses the host handle (mnemonic) as the agent-visible key when handleFor is supplied', async () => {
592
+ const retriever = makeRetriever([{ id: 'doc-1', tags: ['topic'] }]);
593
+ const tool = toolByName(
594
+ createMemoryTools({
595
+ store: makeStore(),
596
+ retriever,
597
+ registry: registryWith([{ kind: knowledgeKind }]),
598
+ handleFor: (r) => `@${r.envelope.id}`
599
+ }),
600
+ 'memory_search'
601
+ );
602
+ expect(await tool.execute({ tag: 'topic', limit: 5 })).toSucceedAndSatisfy((value) => {
603
+ const out = value as { results: ReadonlyArray<IMemoryToolResultItem> };
604
+ expect(out.results[0].handle).toBe('@doc-1');
605
+ });
606
+ });
607
+
608
+ test('falls back to the raw id when a throwing handleFor would otherwise escape', async () => {
609
+ const retriever = makeRetriever([{ id: 'doc-1', tags: ['topic'] }]);
610
+ const tool = toolByName(
611
+ createMemoryTools({
612
+ store: makeStore(),
613
+ retriever,
614
+ registry: registryWith([{ kind: knowledgeKind }]),
615
+ handleFor: () => {
616
+ throw new Error('host handle hook blew up');
617
+ }
618
+ }),
619
+ 'memory_search'
620
+ );
621
+ // A throwing host callback must not crash the search; the item degrades to the raw id.
622
+ expect(await tool.execute({ tag: 'topic', limit: 5 })).toSucceedAndSatisfy((value) => {
623
+ const out = value as { results: ReadonlyArray<IMemoryToolResultItem> };
624
+ expect(out.results[0].handle).toBe('doc-1');
625
+ });
626
+ });
627
+
628
+ test('loud-degrades on the unwired semantic axis', async () => {
629
+ const retriever = makeRetriever([{ id: 'doc-1' }]);
630
+ const tool = toolByName(
631
+ createMemoryTools({
632
+ store: makeStore(),
633
+ retriever,
634
+ registry: registryWith([{ kind: knowledgeKind }])
635
+ }),
636
+ 'memory_search'
637
+ );
638
+ expect(await tool.execute({ semantic: 'find me' })).toFailWith(
639
+ /semantic recall requires a vector index/i
640
+ );
641
+ });
642
+
643
+ test('rejects a kind outside the kinds whitelist', async () => {
644
+ const retriever = makeRetriever([{ id: 'doc-1' }]);
645
+ const tool = toolByName(
646
+ createMemoryTools({
647
+ store: makeStore(),
648
+ retriever,
649
+ registry: registryWith([{ kind: knowledgeKind }]),
650
+ kinds: [knowledgeKind]
651
+ }),
652
+ 'memory_search'
653
+ );
654
+ expect(await tool.execute({ kind: 'mtm' })).toFailWith(/no registered body converter|not enabled/i);
655
+ });
656
+
657
+ test('filters by a validated kind', async () => {
658
+ const retriever = makeRetriever([
659
+ { id: 'doc-1', kind: 'knowledge' },
660
+ { id: 'turn-0', kind: 'mtm', scope: 'conversations/conv-1' }
661
+ ]);
662
+ const tool = toolByName(
663
+ createMemoryTools({
664
+ store: makeStore(),
665
+ retriever,
666
+ registry: registryWith([{ kind: knowledgeKind }, { kind: mtmKind }])
667
+ }),
668
+ 'memory_search'
669
+ );
670
+ expect(await tool.execute({ kind: 'knowledge' })).toSucceedAndSatisfy((value) => {
671
+ const out = value as { results: ReadonlyArray<IMemoryToolResultItem> };
672
+ expect(out.results.map((r) => r.handle)).toEqual(['doc-1']);
673
+ });
674
+ });
675
+
676
+ test('rejects malformed arguments', async () => {
677
+ const tool = toolByName(allTools(), 'memory_search');
678
+ expect(await tool.execute({ limit: 'nope' })).toFailWith(/invalid arguments/i);
679
+ });
680
+ });
681
+
682
+ describe('memory_context', () => {
683
+ test('returns the neighbors reachable from a seed', async () => {
684
+ const retriever = makeLinkRetriever([
685
+ { id: 'a', links: ['b', 'c'] },
686
+ { id: 'b', updated: 20 },
687
+ { id: 'c', updated: 10 }
688
+ ]);
689
+ const tool = toolByName(
690
+ createMemoryTools({
691
+ store: makeStore(),
692
+ retriever,
693
+ registry: registryWith([{ kind: knowledgeKind }])
694
+ }),
695
+ 'memory_context'
696
+ );
697
+ expect(await tool.execute({ from: 'a' })).toSucceedAndSatisfy((value) => {
698
+ const out = value as { seed: string; count: number; results: ReadonlyArray<IMemoryToolResultItem> };
699
+ expect(out.seed).toBe('a');
700
+ expect(out.results.map((r) => r.handle)).toEqual(['b', 'c']);
701
+ });
702
+ });
703
+
704
+ test('honors hops, kind, tag, and limit filters', async () => {
705
+ const retriever = makeLinkRetriever([
706
+ { id: 'a', links: ['b'] },
707
+ { id: 'b', links: ['c'], tags: ['keep'] },
708
+ { id: 'c', tags: ['keep'] }
709
+ ]);
710
+ const tool = toolByName(
711
+ createMemoryTools({
712
+ store: makeStore(),
713
+ retriever,
714
+ registry: registryWith([{ kind: knowledgeKind }])
715
+ }),
716
+ 'memory_context'
717
+ );
718
+ expect(
719
+ await tool.execute({ from: 'a', hops: 2, tag: 'keep', kind: 'knowledge', limit: 5 })
720
+ ).toSucceedAndSatisfy((value) => {
721
+ const out = value as { results: ReadonlyArray<IMemoryToolResultItem> };
722
+ expect(out.results.map((r) => r.handle).sort()).toEqual(['b', 'c']);
723
+ });
724
+ });
725
+
726
+ test('rejects an invalid seed id', async () => {
727
+ const tool = toolByName(allTools(), 'memory_context');
728
+ expect(await tool.execute({ from: 'a/b' })).toFail();
729
+ });
730
+
731
+ test('rejects malformed arguments', async () => {
732
+ const tool = toolByName(allTools(), 'memory_context');
733
+ expect(await tool.execute({ hops: 1 })).toFailWith(/invalid arguments/i);
734
+ });
735
+ });
736
+
737
+ describe('memory_delete', () => {
738
+ test('deletes an existing record', async () => {
739
+ const store = makeStore();
740
+ const tools = createMemoryTools({
741
+ store,
742
+ retriever: makeRetriever([]),
743
+ registry: registryWith([{ kind: knowledgeKind }]),
744
+ codecs,
745
+ tools: ['memory_write', 'memory_delete', 'memory_read']
746
+ });
747
+ await toolByName(tools, 'memory_write').execute({ kind: 'knowledge', entityId: 'doc-1', body: 'b' });
748
+ expect(
749
+ await toolByName(tools, 'memory_delete').execute({ kind: 'knowledge', entityId: 'doc-1' })
750
+ ).toSucceedWith({ deleted: true, id: 'doc-1', entityId: 'doc-1', kind: 'knowledge' });
751
+ expect(
752
+ await toolByName(tools, 'memory_read').execute({ kind: 'knowledge', entityId: 'doc-1' })
753
+ ).toSucceedWith({ found: false });
754
+ });
755
+
756
+ test('propagates a store failure when the record is absent', async () => {
757
+ const tool = toolByName(allTools(), 'memory_delete');
758
+ expect(await tool.execute({ kind: 'knowledge', entityId: 'missing' })).toFailWith(/no record found/i);
759
+ });
760
+
761
+ test('rejects a kind outside the whitelist', async () => {
762
+ const tool = toolByName(allTools({ kinds: [knowledgeKind] }), 'memory_delete');
763
+ expect(await tool.execute({ kind: 'mtm', entityId: 'conv-1:0' })).toFailWith(/not enabled/i);
764
+ });
765
+
766
+ test('rejects malformed arguments', async () => {
767
+ const tool = toolByName(allTools(), 'memory_delete');
768
+ expect(await tool.execute({ kind: 'knowledge' })).toFailWith(/invalid arguments/i);
769
+ });
770
+ });
771
+ });