@hasna/mementos 0.14.70 → 0.14.71

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.
@@ -12,9 +12,24 @@ export interface GdprErasureResult {
12
12
  }
13
13
  /**
14
14
  * Erase all memories containing the given PII identifier.
15
- * Replaces value, summary, and key with "[REDACTED]".
16
- * Clears tags and metadata that might contain PII.
15
+ *
16
+ * Replaces `value` with "[REDACTED]", clears `summary`, `tags` and `metadata`,
17
+ * and rewrites `key` to `[REDACTED]:<random token>` — per-row, for the reason
18
+ * given at the UPDATE below. Nothing derived from the original key or imported
19
+ * row id is retained.
20
+ *
21
+ * The erase runs in ONE TRANSACTION and is therefore all-or-nothing: a caller
22
+ * never observes a partially-erased subject, and a failed attempt leaves the
23
+ * store fully intact so a retry starts from a clean, still-fully-matching set.
24
+ *
17
25
  * Preserves the audit trail (audit_log entries have hashes, not content).
26
+ *
27
+ * NOTE: an erased memory is no longer reachable by its original key, so a later
28
+ * `save` under that key creates a NEW record rather than merging into the
29
+ * tombstone. That is deliberate: silently resurrecting an erased row and
30
+ * re-associating it with the data subject is precisely what erasure must
31
+ * prevent. Every foreign key into `memories` references `memories(id)` — no
32
+ * relational integrity depends on `key`, which is a human lookup handle only.
18
33
  */
19
34
  export declare function gdprErase(identifier: string, options?: {
20
35
  project_id?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"gdpr.d.ts","sourceRoot":"","sources":["../../src/lib/gdpr.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG1D,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IACP,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACd,EACN,EAAE,CAAC,EAAE,QAAQ,GACZ,iBAAiB,CA+FnB"}
1
+ {"version":3,"file":"gdpr.d.ts","sourceRoot":"","sources":["../../src/lib/gdpr.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG1D,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IACP,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACd,EACN,EAAE,CAAC,EAAE,QAAQ,GACZ,iBAAiB,CA8JnB"}
package/dist/mcp/index.js CHANGED
@@ -12074,18 +12074,23 @@ function gdprErase(identifier, options = {}, db) {
12074
12074
  timestamp
12075
12075
  };
12076
12076
  }
12077
- const memoryIds = [];
12078
- for (const row of rows) {
12079
- d.run(`UPDATE memories SET
12077
+ const memoryIds = d.transaction(() => {
12078
+ const ids = [];
12079
+ for (const row of rows) {
12080
+ const redactedKey = `[REDACTED]:${crypto.randomUUID()}`;
12081
+ d.run(`UPDATE memories SET
12082
+ key = ?,
12080
12083
  value = '[REDACTED]',
12081
12084
  summary = NULL,
12082
12085
  tags = '[]',
12083
12086
  metadata = '{}',
12084
12087
  updated_at = ?
12085
- WHERE id = ?`, [timestamp, row.id]);
12086
- d.run("DELETE FROM memory_tags WHERE memory_id = ?", [row.id]);
12087
- memoryIds.push(row.id);
12088
- }
12088
+ WHERE id = ?`, [redactedKey, timestamp, row.id]);
12089
+ d.run("DELETE FROM memory_tags WHERE memory_id = ?", [row.id]);
12090
+ ids.push(row.id);
12091
+ }
12092
+ return ids;
12093
+ });
12089
12094
  return {
12090
12095
  erased_count: memoryIds.length,
12091
12096
  memory_ids: memoryIds,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/mementos",
3
- "version": "0.14.70",
3
+ "version": "0.14.71",
4
4
  "description": "Universal memory system for AI agents - CLI + MCP server + library API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",