@prmichaelsen/remember-mcp 0.1.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 (95) hide show
  1. package/.env.example +65 -0
  2. package/AGENT.md +840 -0
  3. package/README.md +72 -0
  4. package/agent/design/.gitkeep +0 -0
  5. package/agent/design/access-control-result-pattern.md +458 -0
  6. package/agent/design/action-audit-memory-types.md +637 -0
  7. package/agent/design/common-template-fields.md +282 -0
  8. package/agent/design/complete-tool-set.md +407 -0
  9. package/agent/design/content-types-expansion.md +521 -0
  10. package/agent/design/cross-database-id-strategy.md +358 -0
  11. package/agent/design/default-template-library.md +423 -0
  12. package/agent/design/firestore-wrapper-analysis.md +606 -0
  13. package/agent/design/llm-provider-abstraction.md +691 -0
  14. package/agent/design/location-handling-architecture.md +523 -0
  15. package/agent/design/memory-templates-design.md +364 -0
  16. package/agent/design/permissions-storage-architecture.md +680 -0
  17. package/agent/design/relationship-storage-strategy.md +361 -0
  18. package/agent/design/remember-mcp-implementation-tasks.md +417 -0
  19. package/agent/design/remember-mcp-progress.yaml +141 -0
  20. package/agent/design/requirements-enhancements.md +468 -0
  21. package/agent/design/requirements.md +56 -0
  22. package/agent/design/template-storage-strategy.md +412 -0
  23. package/agent/design/template-suggestion-system.md +853 -0
  24. package/agent/design/trust-escalation-prevention.md +343 -0
  25. package/agent/design/trust-system-implementation.md +592 -0
  26. package/agent/design/user-preferences.md +683 -0
  27. package/agent/design/weaviate-collection-strategy.md +461 -0
  28. package/agent/milestones/.gitkeep +0 -0
  29. package/agent/milestones/milestone-1-project-foundation.md +121 -0
  30. package/agent/milestones/milestone-2-core-memory-system.md +150 -0
  31. package/agent/milestones/milestone-3-relationships-graph.md +116 -0
  32. package/agent/milestones/milestone-4-user-preferences.md +103 -0
  33. package/agent/milestones/milestone-5-template-system.md +126 -0
  34. package/agent/milestones/milestone-6-auth-multi-tenancy.md +124 -0
  35. package/agent/milestones/milestone-7-trust-permissions.md +133 -0
  36. package/agent/milestones/milestone-8-testing-quality.md +137 -0
  37. package/agent/milestones/milestone-9-deployment-documentation.md +147 -0
  38. package/agent/patterns/.gitkeep +0 -0
  39. package/agent/patterns/bootstrap.md +1271 -0
  40. package/agent/patterns/firebase-admin-sdk-v8-usage.md +950 -0
  41. package/agent/patterns/firestore-users-pattern-best-practices.md +347 -0
  42. package/agent/patterns/library-services.md +454 -0
  43. package/agent/patterns/testing-colocated.md +316 -0
  44. package/agent/progress.yaml +395 -0
  45. package/agent/tasks/.gitkeep +0 -0
  46. package/agent/tasks/task-1-initialize-project-structure.md +266 -0
  47. package/agent/tasks/task-2-install-dependencies.md +199 -0
  48. package/agent/tasks/task-3-setup-weaviate-client.md +330 -0
  49. package/agent/tasks/task-4-setup-firestore-client.md +362 -0
  50. package/agent/tasks/task-5-create-basic-mcp-server.md +114 -0
  51. package/agent/tasks/task-6-create-integration-tests.md +195 -0
  52. package/agent/tasks/task-7-finalize-milestone-1.md +363 -0
  53. package/agent/tasks/task-8-setup-utility-scripts.md +382 -0
  54. package/agent/tasks/task-9-create-server-factory.md +404 -0
  55. package/dist/config.d.ts +26 -0
  56. package/dist/constants/content-types.d.ts +60 -0
  57. package/dist/firestore/init.d.ts +14 -0
  58. package/dist/firestore/paths.d.ts +53 -0
  59. package/dist/firestore/paths.spec.d.ts +2 -0
  60. package/dist/server-factory.d.ts +40 -0
  61. package/dist/server-factory.js +1741 -0
  62. package/dist/server-factory.spec.d.ts +2 -0
  63. package/dist/server.d.ts +3 -0
  64. package/dist/server.js +1690 -0
  65. package/dist/tools/create-memory.d.ts +94 -0
  66. package/dist/tools/delete-memory.d.ts +47 -0
  67. package/dist/tools/search-memory.d.ts +88 -0
  68. package/dist/types/memory.d.ts +183 -0
  69. package/dist/utils/logger.d.ts +7 -0
  70. package/dist/weaviate/client.d.ts +39 -0
  71. package/dist/weaviate/client.spec.d.ts +2 -0
  72. package/dist/weaviate/schema.d.ts +29 -0
  73. package/esbuild.build.js +60 -0
  74. package/esbuild.watch.js +25 -0
  75. package/jest.config.js +31 -0
  76. package/jest.e2e.config.js +17 -0
  77. package/package.json +68 -0
  78. package/src/.gitkeep +0 -0
  79. package/src/config.ts +56 -0
  80. package/src/constants/content-types.ts +454 -0
  81. package/src/firestore/init.ts +68 -0
  82. package/src/firestore/paths.spec.ts +75 -0
  83. package/src/firestore/paths.ts +124 -0
  84. package/src/server-factory.spec.ts +60 -0
  85. package/src/server-factory.ts +215 -0
  86. package/src/server.ts +243 -0
  87. package/src/tools/create-memory.ts +198 -0
  88. package/src/tools/delete-memory.ts +126 -0
  89. package/src/tools/search-memory.ts +216 -0
  90. package/src/types/memory.ts +276 -0
  91. package/src/utils/logger.ts +42 -0
  92. package/src/weaviate/client.spec.ts +58 -0
  93. package/src/weaviate/client.ts +114 -0
  94. package/src/weaviate/schema.ts +288 -0
  95. package/tsconfig.json +26 -0
@@ -0,0 +1,343 @@
1
+ # Trust Escalation Prevention
2
+
3
+ **Concept**: Automatic trust reduction for repeated unauthorized access attempts
4
+ **Created**: 2026-02-11
5
+ **Status**: Design Specification
6
+
7
+ ---
8
+
9
+ ## Overview
10
+
11
+ To prevent trust escalation attacks, the system automatically reduces trust levels when users repeatedly attempt to access memories they don't have sufficient trust for. After 3 attempts, access to that specific memory is blocked.
12
+
13
+ **Important**: Trust levels only apply to **cross-user access**. Users always have full access to their own memories regardless of trust level.
14
+
15
+ ---
16
+
17
+ ## Rules
18
+
19
+ ### 1. **Trust Reduction**
20
+ - Each failed access attempt: **-0.1 trust level**
21
+ - Applies only to cross-user access attempts
22
+ - Automatic and immediate
23
+ - Logged for audit
24
+
25
+ ### 2. **Access Blocking**
26
+ - After **3 failed attempts**: Memory access blocked
27
+ - Block is memory-specific (not user-wide)
28
+ - Persists until owner manually resets
29
+ - All attempts logged
30
+
31
+ ### 3. **Owner Access**
32
+ - **Users always have full access to their own memories**
33
+ - Trust levels do NOT apply to self-access
34
+ - Trust 0 memories are fully accessible by owner
35
+ - Trust only restricts cross-user access
36
+
37
+ ---
38
+
39
+ ## Implementation
40
+
41
+ ### Access Check Logic
42
+
43
+ ```typescript
44
+ async function checkMemoryAccess(
45
+ memory_id: string,
46
+ accessor_user_id: string,
47
+ memory: Memory
48
+ ): Promise<boolean> {
49
+ // RULE: Users always have full access to their own memories
50
+ if (accessor_user_id === memory.user_id) {
51
+ return true; // ✅ Owner access - no trust check needed
52
+ }
53
+
54
+ // Cross-user access - check trust
55
+ const permission = await getPermission(memory.user_id, accessor_user_id);
56
+
57
+ if (!permission) {
58
+ throw new Error('No permission granted');
59
+ }
60
+
61
+ // Check if memory is blocked for this accessor
62
+ const blockKey = `${accessor_user_id}:${memory_id}`;
63
+ if (await isMemoryBlocked(blockKey)) {
64
+ await logAccessAttempt({
65
+ accessor_user_id,
66
+ memory_id,
67
+ required_trust: memory.trust,
68
+ actual_trust: permission.trust_level,
69
+ blocked: true,
70
+ reason: 'Memory blocked due to repeated unauthorized attempts'
71
+ });
72
+
73
+ throw new Error('Access blocked - contact memory owner to reset');
74
+ }
75
+
76
+ // Check trust level
77
+ if (permission.trust_level < memory.trust) {
78
+ // Insufficient trust - apply penalty
79
+ await handleInsufficientTrust(
80
+ memory.user_id,
81
+ accessor_user_id,
82
+ memory_id,
83
+ permission.trust_level,
84
+ memory.trust
85
+ );
86
+
87
+ return false;
88
+ }
89
+
90
+ // Access granted
91
+ return true;
92
+ }
93
+ ```
94
+
95
+ ### Trust Reduction Handler
96
+
97
+ ```typescript
98
+ async function handleInsufficientTrust(
99
+ owner_user_id: string,
100
+ accessor_user_id: string,
101
+ memory_id: string,
102
+ current_trust: number,
103
+ required_trust: number
104
+ ): Promise<void> {
105
+ const blockKey = `${accessor_user_id}:${memory_id}`;
106
+
107
+ // Increment attempt count
108
+ const attemptCount = await incrementAttemptCount(blockKey);
109
+
110
+ // Reduce trust by 0.1
111
+ const new_trust = Math.max(0, current_trust - 0.1);
112
+ await updateTrustLevel(
113
+ owner_user_id,
114
+ accessor_user_id,
115
+ new_trust,
116
+ `Automatic reduction: unauthorized access attempt to memory ${memory_id} (attempt ${attemptCount}/3)`
117
+ );
118
+
119
+ // Log attempt
120
+ await logAccessAttempt({
121
+ accessor_user_id,
122
+ memory_id,
123
+ required_trust,
124
+ actual_trust: current_trust,
125
+ new_trust,
126
+ attempt_number: attemptCount,
127
+ blocked: false,
128
+ timestamp: new Date()
129
+ });
130
+
131
+ // After 3 attempts, block access
132
+ if (attemptCount >= 3) {
133
+ await blockMemoryAccess(blockKey);
134
+
135
+ // Notify owner
136
+ await notifyOwner(owner_user_id, {
137
+ type: 'trust_violation',
138
+ accessor: accessor_user_id,
139
+ memory_id,
140
+ attempts: attemptCount,
141
+ action: 'blocked',
142
+ message: `User ${accessor_user_id} made 3 unauthorized access attempts. Access to memory ${memory_id} has been blocked.`
143
+ });
144
+
145
+ // Log block
146
+ await logAccessAttempt({
147
+ accessor_user_id,
148
+ memory_id,
149
+ required_trust,
150
+ actual_trust: new_trust,
151
+ new_trust,
152
+ attempt_number: attemptCount,
153
+ blocked: true,
154
+ timestamp: new Date()
155
+ });
156
+ }
157
+
158
+ throw new Error(`Insufficient trust (${current_trust.toFixed(2)} < ${required_trust.toFixed(2)}). Trust reduced to ${new_trust.toFixed(2)}. ${3 - attemptCount} attempts remaining before block.`);
159
+ }
160
+ ```
161
+
162
+ ---
163
+
164
+ ## Owner Controls
165
+
166
+ ### Reset Block
167
+
168
+ ```typescript
169
+ async function resetMemoryBlock(
170
+ owner_user_id: string,
171
+ accessor_user_id: string,
172
+ memory_id: string,
173
+ reason: string
174
+ ): Promise<void> {
175
+ const blockKey = `${accessor_user_id}:${memory_id}`;
176
+
177
+ // Unblock access
178
+ await unblockMemoryAccess(blockKey);
179
+ await resetAttemptCount(blockKey);
180
+
181
+ // Log reset
182
+ await logBlockReset({
183
+ owner_user_id,
184
+ accessor_user_id,
185
+ memory_id,
186
+ reason,
187
+ timestamp: new Date()
188
+ });
189
+
190
+ // Note: Trust restoration is a separate action
191
+ // Owner must explicitly restore trust if desired
192
+ }
193
+ ```
194
+
195
+ **Note**: Resetting the block only unblocks access to that specific memory. Trust level remains at the reduced level. Owner must separately restore trust if they want to increase it.
196
+
197
+ ### View Access Attempts
198
+
199
+ ```typescript
200
+ async function getAccessAttempts(
201
+ owner_user_id: string,
202
+ filters?: {
203
+ accessor_user_id?: string;
204
+ memory_id?: string;
205
+ blocked_only?: boolean;
206
+ since?: Date;
207
+ }
208
+ ): Promise<AccessAttemptLog[]> {
209
+ return await queryAccessAttempts({
210
+ owner_user_id,
211
+ ...filters,
212
+ order_by: 'timestamp DESC',
213
+ limit: 100
214
+ });
215
+ }
216
+ ```
217
+
218
+ ---
219
+
220
+ ## Example Scenarios
221
+
222
+ ### Scenario 1: Legitimate Mistake
223
+
224
+ ```
225
+ User Bob tries to access Alice's trust 0.8 memory
226
+ Bob's trust level: 0.7
227
+
228
+ Attempt 1: Trust reduced to 0.6, "2 attempts remaining"
229
+ Bob realizes mistake, stops trying
230
+ Alice reviews logs, sees it was accidental
231
+ Alice manually increases Bob's trust back to 0.7
232
+ ```
233
+
234
+ ### Scenario 2: Malicious Attempts
235
+
236
+ ```
237
+ User Eve tries to access Alice's trust 0.9 memory
238
+ Eve's trust level: 0.5
239
+
240
+ Attempt 1: Trust reduced to 0.4, "2 attempts remaining"
241
+ Attempt 2: Trust reduced to 0.3, "1 attempt remaining"
242
+ Attempt 3: Trust reduced to 0.2, ACCESS BLOCKED
243
+
244
+ Alice receives notification
245
+ Alice reviews logs, sees repeated attempts
246
+ Alice decides to revoke Eve's access entirely
247
+ ```
248
+
249
+ ### Scenario 3: Owner Access (No Restrictions)
250
+
251
+ ```
252
+ Alice accesses her own trust 0.0 memory
253
+ ✅ Full access granted immediately
254
+ No trust check performed
255
+ No logging of "attempts"
256
+ Trust levels don't apply to self-access
257
+ ```
258
+
259
+ ---
260
+
261
+ ## Data Structures
262
+
263
+ ### AccessAttemptLog
264
+
265
+ ```typescript
266
+ interface AccessAttemptLog {
267
+ id: uuid;
268
+ owner_user_id: string;
269
+ accessor_user_id: string;
270
+ memory_id: string;
271
+
272
+ // Trust levels
273
+ required_trust: float;
274
+ actual_trust: float;
275
+ new_trust: float;
276
+
277
+ // Attempt tracking
278
+ attempt_number: int;
279
+ blocked: boolean;
280
+ reason: string;
281
+
282
+ // Metadata
283
+ timestamp: datetime;
284
+ ip_address: string;
285
+ user_agent: string;
286
+ }
287
+ ```
288
+
289
+ ### MemoryBlock
290
+
291
+ ```typescript
292
+ interface MemoryBlock {
293
+ block_key: string; // "{accessor_user_id}:{memory_id}"
294
+ owner_user_id: string;
295
+ accessor_user_id: string;
296
+ memory_id: string;
297
+
298
+ // Block details
299
+ blocked_at: datetime;
300
+ attempt_count: int;
301
+ final_trust_level: float;
302
+
303
+ // Reset info
304
+ reset_at: datetime | null;
305
+ reset_by: string | null;
306
+ reset_reason: string | null;
307
+ }
308
+ ```
309
+
310
+ ---
311
+
312
+ ## Benefits
313
+
314
+ 1. **Automatic Protection**: No owner intervention needed
315
+ 2. **Graduated Response**: Warning before blocking
316
+ 3. **Audit Trail**: All attempts logged
317
+ 4. **Owner Control**: Can reset blocks and restore trust
318
+ 5. **Deters Attacks**: Makes trust escalation costly
319
+ 6. **Fair**: Allows for mistakes (3 attempts)
320
+
321
+ ---
322
+
323
+ ## Monitoring
324
+
325
+ ### Metrics to Track
326
+
327
+ 1. **Attempt Rate**: Failed access attempts per hour
328
+ 2. **Block Rate**: Memories blocked per day
329
+ 3. **Trust Reduction**: Average trust reduction per user
330
+ 4. **Reset Rate**: How often owners reset blocks
331
+ 5. **Repeat Offenders**: Users with multiple blocks
332
+
333
+ ### Alerts
334
+
335
+ - Alert owner after 2 failed attempts
336
+ - Alert admin if user has >5 blocks
337
+ - Alert admin if trust reduction rate is high
338
+
339
+ ---
340
+
341
+ **Status**: Design Specification
342
+ **Key Rule**: Trust levels only apply to cross-user access, not self-access
343
+ **Implementation**: Automatic trust reduction with owner override capability