@prmichaelsen/remember-mcp 2.7.11 → 3.0.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/.env.example +6 -0
- package/AGENT.md +224 -21
- package/CHANGELOG.md +155 -915
- package/README.md +130 -1
- package/agent/commands/acp.command-create.md +372 -0
- package/agent/commands/acp.design-create.md +224 -0
- package/agent/commands/acp.init.md +39 -5
- package/agent/commands/acp.package-create.md +894 -0
- package/agent/commands/acp.package-info.md +211 -0
- package/agent/commands/acp.package-install.md +206 -33
- package/agent/commands/acp.package-list.md +279 -0
- package/agent/commands/acp.package-publish.md +540 -0
- package/agent/commands/acp.package-remove.md +292 -0
- package/agent/commands/acp.package-search.md +306 -0
- package/agent/commands/acp.package-update.md +360 -0
- package/agent/commands/acp.package-validate.md +539 -0
- package/agent/commands/acp.pattern-create.md +326 -0
- package/agent/commands/acp.plan.md +552 -0
- package/agent/commands/acp.proceed.md +111 -86
- package/agent/commands/acp.project-create.md +672 -0
- package/agent/commands/acp.project-list.md +224 -0
- package/agent/commands/acp.project-set.md +226 -0
- package/agent/commands/acp.report.md +2 -0
- package/agent/commands/acp.resume.md +237 -0
- package/agent/commands/acp.sync.md +55 -15
- package/agent/commands/acp.task-create.md +390 -0
- package/agent/commands/acp.validate.md +61 -10
- package/agent/commands/acp.version-check-for-updates.md +5 -5
- package/agent/commands/acp.version-check.md +6 -6
- package/agent/commands/acp.version-update.md +6 -6
- package/agent/commands/command.template.md +43 -0
- package/agent/commands/git.commit.md +5 -3
- package/agent/design/soft-delete-system.md +291 -0
- package/agent/manifest.template.yaml +13 -0
- package/agent/milestones/milestone-13-soft-delete-system.md +306 -0
- package/agent/package.template.yaml +36 -0
- package/agent/progress.template.yaml +3 -0
- package/agent/progress.yaml +238 -6
- package/agent/scripts/acp.common.sh +1536 -0
- package/agent/scripts/{install.sh → acp.install.sh} +82 -26
- package/agent/scripts/acp.package-create.sh +925 -0
- package/agent/scripts/acp.package-info.sh +270 -0
- package/agent/scripts/acp.package-install.sh +596 -0
- package/agent/scripts/acp.package-list.sh +263 -0
- package/agent/scripts/acp.package-publish.sh +420 -0
- package/agent/scripts/acp.package-remove.sh +272 -0
- package/agent/scripts/acp.package-search.sh +156 -0
- package/agent/scripts/acp.package-update.sh +438 -0
- package/agent/scripts/acp.package-validate.sh +855 -0
- package/agent/scripts/acp.project-list.sh +121 -0
- package/agent/scripts/acp.project-set.sh +138 -0
- package/agent/scripts/{uninstall.sh → acp.uninstall.sh} +25 -15
- package/agent/scripts/{check-for-updates.sh → acp.version-check-for-updates.sh} +24 -14
- package/agent/scripts/{version.sh → acp.version-check.sh} +20 -8
- package/agent/scripts/{update.sh → acp.version-update.sh} +44 -25
- package/agent/scripts/acp.yaml-parser.sh +853 -0
- package/agent/scripts/acp.yaml-validate.sh +205 -0
- package/agent/tasks/task-68-fix-missing-space-properties.md +192 -0
- package/agent/tasks/task-69-add-comprehensive-tool-debugging.md +454 -0
- package/agent/tasks/task-70-add-soft-delete-schema-fields.md +165 -0
- package/agent/tasks/task-71-implement-delete-confirmation-flow.md +257 -0
- package/agent/tasks/task-72-add-deleted-filter-to-search-tools.md +18 -0
- package/agent/tasks/task-73-update-relationship-handling.md +18 -0
- package/agent/tasks/task-74-add-unit-tests-soft-delete.md +18 -0
- package/agent/tasks/task-75-update-documentation-changelog.md +26 -0
- package/dist/config.d.ts +18 -0
- package/dist/server-factory.js +788 -355
- package/dist/server.js +788 -355
- package/dist/tools/delete-memory.d.ts +5 -30
- package/dist/tools/find-similar.d.ts +8 -1
- package/dist/tools/query-memory.d.ts +8 -1
- package/dist/tools/search-memory.d.ts +6 -0
- package/dist/tools/search-relationship.d.ts +8 -1
- package/dist/types/memory.d.ts +8 -0
- package/dist/types/space-memory.d.ts +3 -0
- package/dist/utils/debug.d.ts +52 -0
- package/dist/utils/debug.spec.d.ts +5 -0
- package/dist/utils/weaviate-filters.d.ts +19 -0
- package/dist/weaviate/client.d.ts +1 -1
- package/package.json +1 -1
- package/src/config.ts +33 -0
- package/src/tools/confirm.ts +113 -8
- package/src/tools/create-relationship.ts +14 -1
- package/src/tools/delete-memory.ts +91 -63
- package/src/tools/find-similar.ts +30 -5
- package/src/tools/publish.ts +19 -1
- package/src/tools/query-memory.ts +18 -5
- package/src/tools/query-space.ts +36 -3
- package/src/tools/search-memory.ts +18 -5
- package/src/tools/search-relationship.ts +19 -5
- package/src/tools/search-space.ts +36 -3
- package/src/tools/update-memory.ts +8 -0
- package/src/types/memory.ts +11 -0
- package/src/types/space-memory.ts +5 -0
- package/src/utils/debug.spec.ts +257 -0
- package/src/utils/debug.ts +138 -0
- package/src/utils/weaviate-filters.ts +28 -1
- package/src/weaviate/client.ts +47 -3
- package/src/weaviate/schema.ts +17 -0
- package/src/weaviate/space-schema.spec.ts +5 -2
- package/src/weaviate/space-schema.ts +17 -5
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
# Task 69: Add Comprehensive Tool Debugging
|
|
2
|
+
|
|
3
|
+
**Milestone**: M8 (Testing & Quality)
|
|
4
|
+
**Estimated Time**: 4-6 hours
|
|
5
|
+
**Dependencies**: None
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Implement comprehensive debugging capabilities for all MCP tools that can be enabled via a `REMEMBER_MCP_DEBUG_LEVEL` environment variable, providing detailed insights into tool execution, parameter validation, database operations, and error conditions.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Context
|
|
17
|
+
|
|
18
|
+
Currently, debugging tool issues in production requires analyzing Cloud Run logs with limited context. Adding configurable debug logging will:
|
|
19
|
+
- Enable detailed tracing of tool execution flow
|
|
20
|
+
- Show parameter validation and transformation
|
|
21
|
+
- Log database queries and responses
|
|
22
|
+
- Track timing and performance metrics
|
|
23
|
+
- Provide context for error conditions
|
|
24
|
+
|
|
25
|
+
This will significantly improve troubleshooting and development experience.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Steps
|
|
30
|
+
|
|
31
|
+
### 1. Define Debug Levels
|
|
32
|
+
|
|
33
|
+
Create debug level constants and configuration.
|
|
34
|
+
|
|
35
|
+
**File**: [`src/config.ts`](../../src/config.ts)
|
|
36
|
+
|
|
37
|
+
**Add**:
|
|
38
|
+
```typescript
|
|
39
|
+
export enum DebugLevel {
|
|
40
|
+
NONE = 0, // No debug output (production default)
|
|
41
|
+
ERROR = 1, // Only errors
|
|
42
|
+
WARN = 2, // Warnings and errors
|
|
43
|
+
INFO = 3, // Info, warnings, and errors
|
|
44
|
+
DEBUG = 4, // Debug, info, warnings, and errors
|
|
45
|
+
TRACE = 5, // Everything including parameter dumps
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const debugConfig = {
|
|
49
|
+
level: ((): DebugLevel => {
|
|
50
|
+
const level = process.env.REMEMBER_MCP_DEBUG_LEVEL?.toUpperCase();
|
|
51
|
+
switch (level) {
|
|
52
|
+
case 'TRACE': return DebugLevel.TRACE;
|
|
53
|
+
case 'DEBUG': return DebugLevel.DEBUG;
|
|
54
|
+
case 'INFO': return DebugLevel.INFO;
|
|
55
|
+
case 'WARN': return DebugLevel.WARN;
|
|
56
|
+
case 'ERROR': return DebugLevel.ERROR;
|
|
57
|
+
case 'NONE': return DebugLevel.NONE;
|
|
58
|
+
default: return DebugLevel.NONE;
|
|
59
|
+
}
|
|
60
|
+
})(),
|
|
61
|
+
enabled: (level: DebugLevel): boolean => {
|
|
62
|
+
return debugConfig.level >= level;
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 2. Create Debug Utility
|
|
68
|
+
|
|
69
|
+
Create centralized debug logging utility.
|
|
70
|
+
|
|
71
|
+
**File**: [`src/utils/debug.ts`](../../src/utils/debug.ts) (new file)
|
|
72
|
+
|
|
73
|
+
**Content**:
|
|
74
|
+
```typescript
|
|
75
|
+
import { debugConfig, DebugLevel } from '../config.js';
|
|
76
|
+
import { logger } from './logger.js';
|
|
77
|
+
|
|
78
|
+
export interface DebugContext {
|
|
79
|
+
tool: string;
|
|
80
|
+
userId?: string;
|
|
81
|
+
operation?: string;
|
|
82
|
+
[key: string]: any;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export class DebugLogger {
|
|
86
|
+
private context: DebugContext;
|
|
87
|
+
|
|
88
|
+
constructor(context: DebugContext) {
|
|
89
|
+
this.context = context;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
trace(message: string, data?: any): void {
|
|
93
|
+
if (debugConfig.enabled(DebugLevel.TRACE)) {
|
|
94
|
+
logger.debug(`[TRACE] ${message}`, {
|
|
95
|
+
...this.context,
|
|
96
|
+
...data,
|
|
97
|
+
debugLevel: 'TRACE',
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
debug(message: string, data?: any): void {
|
|
103
|
+
if (debugConfig.enabled(DebugLevel.DEBUG)) {
|
|
104
|
+
logger.debug(`[DEBUG] ${message}`, {
|
|
105
|
+
...this.context,
|
|
106
|
+
...data,
|
|
107
|
+
debugLevel: 'DEBUG',
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
info(message: string, data?: any): void {
|
|
113
|
+
if (debugConfig.enabled(DebugLevel.INFO)) {
|
|
114
|
+
logger.info(`[INFO] ${message}`, {
|
|
115
|
+
...this.context,
|
|
116
|
+
...data,
|
|
117
|
+
debugLevel: 'INFO',
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
warn(message: string, data?: any): void {
|
|
123
|
+
if (debugConfig.enabled(DebugLevel.WARN)) {
|
|
124
|
+
logger.warn(`[WARN] ${message}`, {
|
|
125
|
+
...this.context,
|
|
126
|
+
...data,
|
|
127
|
+
debugLevel: 'WARN',
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
error(message: string, data?: any): void {
|
|
133
|
+
if (debugConfig.enabled(DebugLevel.ERROR)) {
|
|
134
|
+
logger.error(`[ERROR] ${message}`, {
|
|
135
|
+
...this.context,
|
|
136
|
+
...data,
|
|
137
|
+
debugLevel: 'ERROR',
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Dump full object (TRACE only)
|
|
143
|
+
dump(label: string, obj: any): void {
|
|
144
|
+
if (debugConfig.enabled(DebugLevel.TRACE)) {
|
|
145
|
+
logger.debug(`[DUMP] ${label}`, {
|
|
146
|
+
...this.context,
|
|
147
|
+
dump: JSON.stringify(obj, null, 2),
|
|
148
|
+
debugLevel: 'TRACE',
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Time operation (DEBUG and above)
|
|
154
|
+
async time<T>(label: string, fn: () => Promise<T>): Promise<T> {
|
|
155
|
+
if (!debugConfig.enabled(DebugLevel.DEBUG)) {
|
|
156
|
+
return fn();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const start = Date.now();
|
|
160
|
+
this.debug(`${label} - Starting`);
|
|
161
|
+
|
|
162
|
+
try {
|
|
163
|
+
const result = await fn();
|
|
164
|
+
const duration = Date.now() - start;
|
|
165
|
+
this.debug(`${label} - Completed`, { durationMs: duration });
|
|
166
|
+
return result;
|
|
167
|
+
} catch (error) {
|
|
168
|
+
const duration = Date.now() - start;
|
|
169
|
+
this.error(`${label} - Failed`, {
|
|
170
|
+
durationMs: duration,
|
|
171
|
+
error: error instanceof Error ? error.message : String(error),
|
|
172
|
+
});
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function createDebugLogger(context: DebugContext): DebugLogger {
|
|
179
|
+
return new DebugLogger(context);
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### 3. Add Debug Logging to Tools
|
|
184
|
+
|
|
185
|
+
Update all 17 MCP tools with debug logging.
|
|
186
|
+
|
|
187
|
+
**Pattern for Each Tool**:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
import { createDebugLogger } from '../utils/debug.js';
|
|
191
|
+
|
|
192
|
+
export async function handleToolName(args: ToolArgs, userId: string): Promise<string> {
|
|
193
|
+
const debug = createDebugLogger({
|
|
194
|
+
tool: 'remember_tool_name',
|
|
195
|
+
userId,
|
|
196
|
+
operation: 'tool_operation',
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
try {
|
|
200
|
+
debug.info('Tool invoked');
|
|
201
|
+
debug.trace('Tool arguments', { args });
|
|
202
|
+
|
|
203
|
+
// Parameter validation
|
|
204
|
+
debug.debug('Validating parameters');
|
|
205
|
+
// ... validation code ...
|
|
206
|
+
debug.debug('Parameters validated');
|
|
207
|
+
|
|
208
|
+
// Database operations
|
|
209
|
+
const result = await debug.time('Fetch from database', async () => {
|
|
210
|
+
debug.trace('Query parameters', { queryParams });
|
|
211
|
+
const data = await collection.query.fetchObjectById(id);
|
|
212
|
+
debug.trace('Query result', { resultCount: data.length });
|
|
213
|
+
return data;
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
debug.info('Tool completed successfully');
|
|
217
|
+
return JSON.stringify(result, null, 2);
|
|
218
|
+
} catch (error) {
|
|
219
|
+
debug.error('Tool failed', {
|
|
220
|
+
error: error instanceof Error ? error.message : String(error),
|
|
221
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
222
|
+
});
|
|
223
|
+
throw error;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**Tools to Update** (17 total):
|
|
229
|
+
- Memory tools (6): create, search, delete, update, find-similar, query
|
|
230
|
+
- Relationship tools (4): create, update, search, delete
|
|
231
|
+
- Preference tools (2): set, get
|
|
232
|
+
- Space tools (5): publish, confirm, deny, search-space, query-space
|
|
233
|
+
|
|
234
|
+
### 4. Add Debug Logging to Database Clients
|
|
235
|
+
|
|
236
|
+
Add debug logging to Weaviate and Firestore clients.
|
|
237
|
+
|
|
238
|
+
**File**: [`src/weaviate/client.ts`](../../src/weaviate/client.ts)
|
|
239
|
+
|
|
240
|
+
**Add**:
|
|
241
|
+
```typescript
|
|
242
|
+
import { createDebugLogger } from '../utils/debug.js';
|
|
243
|
+
|
|
244
|
+
export async function fetchMemoryWithAllProperties(
|
|
245
|
+
collection: any,
|
|
246
|
+
memoryId: string
|
|
247
|
+
) {
|
|
248
|
+
const debug = createDebugLogger({
|
|
249
|
+
tool: 'weaviate-client',
|
|
250
|
+
operation: 'fetchMemoryWithAllProperties',
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
debug.debug('Fetching memory', { memoryId, collectionName: collection.name });
|
|
254
|
+
|
|
255
|
+
try {
|
|
256
|
+
const result = await debug.time('Fetch with all properties', async () => {
|
|
257
|
+
return await collection.query.fetchObjectById(memoryId, {
|
|
258
|
+
returnProperties: ALL_MEMORY_PROPERTIES,
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
debug.trace('Fetch result', {
|
|
263
|
+
found: !!result,
|
|
264
|
+
propertyCount: result?.properties ? Object.keys(result.properties).length : 0,
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
return result;
|
|
268
|
+
} catch (error) {
|
|
269
|
+
debug.warn('Fetch with all properties failed, falling back', {
|
|
270
|
+
error: error instanceof Error ? error.message : String(error),
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
return await debug.time('Fetch without property specification', async () => {
|
|
274
|
+
return await collection.query.fetchObjectById(memoryId);
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### 5. Update Configuration Documentation
|
|
281
|
+
|
|
282
|
+
Document the debug environment variable.
|
|
283
|
+
|
|
284
|
+
**File**: [`.env.example`](../../.env.example)
|
|
285
|
+
|
|
286
|
+
**Add**:
|
|
287
|
+
```bash
|
|
288
|
+
# Debug Configuration (optional)
|
|
289
|
+
# Controls debug logging verbosity
|
|
290
|
+
# Values: NONE (default), ERROR, WARN, INFO, DEBUG, TRACE
|
|
291
|
+
# TRACE includes full parameter dumps (use with caution in production)
|
|
292
|
+
REMEMBER_MCP_DEBUG_LEVEL=NONE
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**File**: [`README.md`](../../README.md)
|
|
296
|
+
|
|
297
|
+
**Add section**:
|
|
298
|
+
```markdown
|
|
299
|
+
## Debugging
|
|
300
|
+
|
|
301
|
+
Enable detailed debug logging with the `REMEMBER_MCP_DEBUG_LEVEL` environment variable:
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
# No debug output (production default)
|
|
305
|
+
REMEMBER_MCP_DEBUG_LEVEL=NONE
|
|
306
|
+
|
|
307
|
+
# Only errors
|
|
308
|
+
REMEMBER_MCP_DEBUG_LEVEL=ERROR
|
|
309
|
+
|
|
310
|
+
# Warnings and errors
|
|
311
|
+
REMEMBER_MCP_DEBUG_LEVEL=WARN
|
|
312
|
+
|
|
313
|
+
# Info, warnings, and errors
|
|
314
|
+
REMEMBER_MCP_DEBUG_LEVEL=INFO
|
|
315
|
+
|
|
316
|
+
# Debug, info, warnings, and errors (recommended for development)
|
|
317
|
+
REMEMBER_MCP_DEBUG_LEVEL=DEBUG
|
|
318
|
+
|
|
319
|
+
# Everything including parameter dumps (use with caution)
|
|
320
|
+
REMEMBER_MCP_DEBUG_LEVEL=TRACE
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
**Example**:
|
|
324
|
+
```bash
|
|
325
|
+
# Enable debug logging for development
|
|
326
|
+
REMEMBER_MCP_DEBUG_LEVEL=DEBUG npm run dev
|
|
327
|
+
|
|
328
|
+
# Enable trace logging for troubleshooting
|
|
329
|
+
REMEMBER_MCP_DEBUG_LEVEL=TRACE npm start
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
**Note**: TRACE level includes full parameter dumps and may expose sensitive data. Use only in development.
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### 6. Add Unit Tests
|
|
336
|
+
|
|
337
|
+
Create tests for debug utility.
|
|
338
|
+
|
|
339
|
+
**File**: [`src/utils/debug.spec.ts`](../../src/utils/debug.spec.ts) (new file)
|
|
340
|
+
|
|
341
|
+
**Tests**:
|
|
342
|
+
- Debug level parsing from environment variable
|
|
343
|
+
- Debug level filtering (only logs at or above configured level)
|
|
344
|
+
- Context propagation
|
|
345
|
+
- Time measurement
|
|
346
|
+
- Parameter dumping (TRACE only)
|
|
347
|
+
|
|
348
|
+
### 7. Test Debug Levels
|
|
349
|
+
|
|
350
|
+
Verify debug logging works at each level.
|
|
351
|
+
|
|
352
|
+
**Test Cases**:
|
|
353
|
+
1. NONE: No debug output
|
|
354
|
+
2. ERROR: Only errors logged
|
|
355
|
+
3. WARN: Warnings and errors logged
|
|
356
|
+
4. INFO: Info, warnings, and errors logged
|
|
357
|
+
5. DEBUG: Debug, info, warnings, and errors logged
|
|
358
|
+
6. TRACE: Everything including parameter dumps
|
|
359
|
+
|
|
360
|
+
**Verification**:
|
|
361
|
+
```bash
|
|
362
|
+
# Test each level
|
|
363
|
+
REMEMBER_MCP_DEBUG_LEVEL=NONE npm run dev
|
|
364
|
+
REMEMBER_MCP_DEBUG_LEVEL=ERROR npm run dev
|
|
365
|
+
REMEMBER_MCP_DEBUG_LEVEL=DEBUG npm run dev
|
|
366
|
+
REMEMBER_MCP_DEBUG_LEVEL=TRACE npm run dev
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## Verification
|
|
372
|
+
|
|
373
|
+
- [ ] Debug levels defined in config.ts
|
|
374
|
+
- [ ] Debug utility created (src/utils/debug.ts)
|
|
375
|
+
- [ ] All 17 tools updated with debug logging
|
|
376
|
+
- [ ] Database clients updated with debug logging
|
|
377
|
+
- [ ] .env.example updated with debug variable
|
|
378
|
+
- [ ] README.md updated with debug documentation
|
|
379
|
+
- [ ] Unit tests created for debug utility
|
|
380
|
+
- [ ] All debug levels tested and working
|
|
381
|
+
- [ ] TypeScript compiles without errors
|
|
382
|
+
- [ ] All tests passing
|
|
383
|
+
- [ ] No performance impact when debug disabled (NONE)
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## Benefits
|
|
388
|
+
|
|
389
|
+
### Development
|
|
390
|
+
- Faster debugging with detailed execution traces
|
|
391
|
+
- Easy parameter inspection
|
|
392
|
+
- Performance profiling with timing
|
|
393
|
+
- Clear error context
|
|
394
|
+
|
|
395
|
+
### Production
|
|
396
|
+
- Configurable verbosity for troubleshooting
|
|
397
|
+
- No performance impact when disabled
|
|
398
|
+
- Structured logs for Cloud Run filtering
|
|
399
|
+
- Safe parameter dumping (TRACE only)
|
|
400
|
+
|
|
401
|
+
### Troubleshooting
|
|
402
|
+
- Reproduce issues with debug logs
|
|
403
|
+
- Understand tool execution flow
|
|
404
|
+
- Identify bottlenecks
|
|
405
|
+
- Diagnose database query issues
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
## Files to Create
|
|
410
|
+
|
|
411
|
+
- [`src/utils/debug.ts`](../../src/utils/debug.ts) - Debug utility
|
|
412
|
+
- [`src/utils/debug.spec.ts`](../../src/utils/debug.spec.ts) - Unit tests
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## Files to Modify
|
|
417
|
+
|
|
418
|
+
- [`src/config.ts`](../../src/config.ts) - Add debug configuration
|
|
419
|
+
- [`.env.example`](../../.env.example) - Add debug variable
|
|
420
|
+
- [`README.md`](../../README.md) - Add debug documentation
|
|
421
|
+
- All 17 tool files - Add debug logging
|
|
422
|
+
- [`src/weaviate/client.ts`](../../src/weaviate/client.ts) - Add debug logging
|
|
423
|
+
- [`src/firestore/init.ts`](../../src/firestore/init.ts) - Add debug logging
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## Performance Considerations
|
|
428
|
+
|
|
429
|
+
- Debug checks are fast (simple comparison)
|
|
430
|
+
- No overhead when debug disabled (NONE)
|
|
431
|
+
- Timing only adds ~1ms overhead (DEBUG+)
|
|
432
|
+
- Parameter dumps only at TRACE level
|
|
433
|
+
- Structured logging already in place
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
|
|
437
|
+
## Security Considerations
|
|
438
|
+
|
|
439
|
+
- TRACE level may expose sensitive data
|
|
440
|
+
- Document TRACE as development-only
|
|
441
|
+
- Never use TRACE in production
|
|
442
|
+
- Sanitize sensitive fields in dumps
|
|
443
|
+
- Use INFO/DEBUG for production troubleshooting
|
|
444
|
+
|
|
445
|
+
---
|
|
446
|
+
|
|
447
|
+
## Next Steps
|
|
448
|
+
|
|
449
|
+
After completing this task:
|
|
450
|
+
1. Test debug logging in development
|
|
451
|
+
2. Deploy with DEBUG level to staging
|
|
452
|
+
3. Monitor performance impact
|
|
453
|
+
4. Document common debug patterns
|
|
454
|
+
5. Create troubleshooting guide using debug logs
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Task 70: Add Soft Delete Schema Fields
|
|
2
|
+
|
|
3
|
+
**Milestone**: M13 (Soft Delete System)
|
|
4
|
+
**Estimated Time**: 2-3 hours
|
|
5
|
+
**Dependencies**: None
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Add three new fields to the Weaviate schema to support soft delete functionality: `deleted_at` (timestamp), `deleted_by` (user ID), and `deletion_reason` (optional text). These fields enable tracking when memories are deleted, who deleted them, and why, while keeping the data in the database for potential future recovery.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Steps
|
|
17
|
+
|
|
18
|
+
### 1. Update Memory Schema ([`src/weaviate/schema.ts`](../../src/weaviate/schema.ts))
|
|
19
|
+
|
|
20
|
+
Add three new properties to the `createMemoryCollection` function:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
// After existing properties (around line 150)
|
|
24
|
+
|
|
25
|
+
// Soft delete fields
|
|
26
|
+
{
|
|
27
|
+
name: 'deleted_at',
|
|
28
|
+
dataType: 'date' as any,
|
|
29
|
+
description: 'Timestamp when memory was soft-deleted (null = not deleted)',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'deleted_by',
|
|
33
|
+
dataType: 'text' as any,
|
|
34
|
+
description: 'User ID who deleted the memory',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'deletion_reason',
|
|
38
|
+
dataType: 'text' as any,
|
|
39
|
+
description: 'Optional reason for deletion',
|
|
40
|
+
},
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Note**: `deleted_at` is nullable. Missing or `null` value means memory is not deleted.
|
|
44
|
+
|
|
45
|
+
### 2. Update Public Collection Schema ([`src/weaviate/space-schema.ts`](../../src/weaviate/space-schema.ts))
|
|
46
|
+
|
|
47
|
+
Add the same three fields to `ensurePublicCollection` function:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
// After existing properties
|
|
51
|
+
|
|
52
|
+
// Soft delete fields
|
|
53
|
+
{
|
|
54
|
+
name: 'deleted_at',
|
|
55
|
+
dataType: 'date' as any,
|
|
56
|
+
description: 'Timestamp when memory was soft-deleted (null = not deleted)',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'deleted_by',
|
|
60
|
+
dataType: 'text' as any,
|
|
61
|
+
description: 'User ID who deleted the memory',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'deletion_reason',
|
|
65
|
+
dataType: 'text' as any,
|
|
66
|
+
description: 'Optional reason for deletion',
|
|
67
|
+
},
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 3. Update Memory Type Definitions ([`src/types/memory.ts`](../../src/types/memory.ts))
|
|
71
|
+
|
|
72
|
+
Add fields to `Memory` interface:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
export interface Memory {
|
|
76
|
+
// ... existing fields
|
|
77
|
+
|
|
78
|
+
// Soft delete fields
|
|
79
|
+
deleted_at?: Date | null;
|
|
80
|
+
deleted_by?: string;
|
|
81
|
+
deletion_reason?: string;
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 4. Update SpaceMemory Type ([`src/types/space-memory.ts`](../../src/types/space-memory.ts))
|
|
86
|
+
|
|
87
|
+
Add fields to `SpaceMemory` interface:
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
export interface SpaceMemory {
|
|
91
|
+
// ... existing fields
|
|
92
|
+
|
|
93
|
+
// Soft delete fields
|
|
94
|
+
deleted_at?: Date | null;
|
|
95
|
+
deleted_by?: string;
|
|
96
|
+
deletion_reason?: string;
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 5. Update ALL_MEMORY_PROPERTIES Constant ([`src/weaviate/client.ts`](../../src/weaviate/client.ts))
|
|
101
|
+
|
|
102
|
+
Add new fields to the properties array:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
const ALL_MEMORY_PROPERTIES = [
|
|
106
|
+
// ... existing properties
|
|
107
|
+
'deleted_at',
|
|
108
|
+
'deleted_by',
|
|
109
|
+
'deletion_reason',
|
|
110
|
+
];
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 6. Build and Test
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npm run build
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Expected**: TypeScript compiles without errors
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Verification
|
|
124
|
+
|
|
125
|
+
- [ ] `deleted_at` field added to Memory schema (date, nullable)
|
|
126
|
+
- [ ] `deleted_by` field added to Memory schema (text)
|
|
127
|
+
- [ ] `deletion_reason` field added to Memory schema (text)
|
|
128
|
+
- [ ] Same 3 fields added to Memory_public schema
|
|
129
|
+
- [ ] Fields added to Memory interface in types
|
|
130
|
+
- [ ] Fields added to SpaceMemory interface in types
|
|
131
|
+
- [ ] Fields added to ALL_MEMORY_PROPERTIES constant
|
|
132
|
+
- [ ] TypeScript compiles without errors
|
|
133
|
+
- [ ] Build successful
|
|
134
|
+
- [ ] No breaking changes to existing code
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Files Modified
|
|
139
|
+
|
|
140
|
+
- [`src/weaviate/schema.ts`](../../src/weaviate/schema.ts) - Add 3 fields to Memory schema
|
|
141
|
+
- [`src/weaviate/space-schema.ts`](../../src/weaviate/space-schema.ts) - Add 3 fields to public collection
|
|
142
|
+
- [`src/types/memory.ts`](../../src/types/memory.ts) - Add fields to Memory interface
|
|
143
|
+
- [`src/types/space-memory.ts`](../../src/types/space-memory.ts) - Add fields to SpaceMemory interface
|
|
144
|
+
- [`src/weaviate/client.ts`](../../src/weaviate/client.ts) - Add fields to ALL_MEMORY_PROPERTIES
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Files Created
|
|
149
|
+
|
|
150
|
+
None
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Notes
|
|
155
|
+
|
|
156
|
+
- **Nullable Field**: `deleted_at` being nullable is critical. Missing or `null` = not deleted.
|
|
157
|
+
- **No Migration Needed**: Existing memories will implicitly have `deleted_at: null`
|
|
158
|
+
- **Weaviate Behavior**: `isNull(true)` filter correctly handles missing fields
|
|
159
|
+
- **Optional Fields**: `deleted_by` and `deletion_reason` are optional in TypeScript but will be set when memory is deleted
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Next Task
|
|
164
|
+
|
|
165
|
+
Task 71: Implement Delete Confirmation Flow
|