mnemocyte 0.3.0 → 0.5.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.
@@ -43,8 +43,9 @@ interface JsonObject {
43
43
  /**
44
44
  * Identifies which backend a {@link MnemocyteClient} is using.
45
45
  *
46
- * Selected automatically by {@link createMnemocyte} based on whether
47
- * {@link MnemocyteConfig.databaseUrl} was provided.
46
+ * Selected automatically by {@link createMnemocyte} from the configured
47
+ * {@link MnemocyteConfig.store} or {@link MnemocyteConfig.databaseUrl}, with
48
+ * in-memory storage used when neither is supplied.
48
49
  */
49
50
  type MnemocyteBackend = "in-memory" | "postgres";
50
51
  /**
@@ -111,17 +112,25 @@ interface ProviderResilienceConfig {
111
112
  /**
112
113
  * Maximum time, in milliseconds, that a single provider attempt may
113
114
  * run before a {@link MnemocyteError} with code `"TIMEOUT"` is thrown.
114
- * Defaults to `0` which disables the timeout.
115
+ * Must be a non-negative finite number. Defaults to `0` which disables the
116
+ * timeout.
115
117
  */
116
118
  timeoutMs?: number;
117
119
  /**
118
- * Maximum number of retry attempts after the initial call. `0`
119
- * disables retries (default).
120
+ * Maximum number of retry attempts after the initial call. Must be a
121
+ * non-negative integer. `0` disables retries (default).
120
122
  */
121
123
  retries?: number;
122
- /** Base backoff delay (ms) used before the first retry. Defaults to `100`. */
124
+ /**
125
+ * Base backoff delay (ms) used before the first retry. Must be a
126
+ * non-negative finite number. Defaults to `100`.
127
+ */
123
128
  baseDelayMs?: number;
124
- /** Maximum backoff delay (ms) used between retries. Defaults to `2000`. */
129
+ /**
130
+ * Maximum backoff delay (ms) used between retries. Must be a non-negative
131
+ * finite number. Values below `baseDelayMs` are normalized up to the base
132
+ * delay. Defaults to `2000`.
133
+ */
125
134
  maxDelayMs?: number;
126
135
  /**
127
136
  * Optional predicate deciding whether `error` should trigger a retry.
@@ -133,6 +142,17 @@ interface ProviderResilienceConfig {
133
142
  */
134
143
  shouldRetry?: (error: unknown, attempt: number) => boolean;
135
144
  }
145
+ declare const mnemocyteStoreConfigBrand: unique symbol;
146
+ /**
147
+ * Opaque storage-adapter value accepted by {@link MnemocyteConfig.store}.
148
+ *
149
+ * Obtain this value from a supported adapter factory such as `drizzleStore()`
150
+ * from `mnemocyte/stores/drizzle`. The underlying `MemoryStore` contract stays
151
+ * internal; this type intentionally exposes no adapter implementation methods.
152
+ */
153
+ interface MnemocyteStoreConfig {
154
+ readonly [mnemocyteStoreConfigBrand]: true;
155
+ }
136
156
  /**
137
157
  * Configuration passed to {@link createMnemocyte}.
138
158
  */
@@ -140,10 +160,19 @@ interface MnemocyteConfig {
140
160
  /**
141
161
  * Postgres connection string. When set, the client uses the Postgres
142
162
  * backend (requires the `pgvector` extension and a rendered migration
143
- * with `mnemocyte_meta.embedding_dimensions` matching the embedder).
144
- * When omitted, an in-memory backend is used.
163
+ * with `mnemocyte_meta.embedding_dimensions` matching the embedder and
164
+ * `embedding_model` metadata available). Must use the `postgres:` or
165
+ * `postgresql:` protocol.
166
+ * Cannot be combined with {@link MnemocyteConfig.store}. When both storage
167
+ * fields are omitted, an in-memory backend is used.
145
168
  */
146
169
  databaseUrl?: string;
170
+ /**
171
+ * Caller-supplied storage adapter. Use `drizzleStore(db)` from
172
+ * `mnemocyte/stores/drizzle` for a caller-owned postgres.js Drizzle instance.
173
+ * Cannot be combined with {@link MnemocyteConfig.databaseUrl}.
174
+ */
175
+ store?: MnemocyteStoreConfig;
147
176
  /** Required embedder used to vectorise content for storage and retrieval. */
148
177
  embedder: Embedder;
149
178
  /** Default values applied to {@link RecallInput} when properties are omitted. */
@@ -191,8 +220,9 @@ interface AuditConfig {
191
220
  * (e.g. OpenAI, Cohere, a local model) in a small interface.
192
221
  *
193
222
  * Mnemocyte records {@link Embedder.model} and {@link Embedder.dimensions}
194
- * on every stored memory and uses them to detect incompatible vectors
195
- * (e.g. when the model is swapped).
223
+ * on every stored memory. The Postgres backend also records both values as
224
+ * installation metadata and rejects embedding-dependent operations when the
225
+ * configured embedder is incompatible.
196
226
  */
197
227
  interface Embedder {
198
228
  /** Stable identifier for the underlying model (e.g. `"text-embedding-3-small"`). */
@@ -484,7 +514,10 @@ interface BuildContextInput {
484
514
  * Input for {@link MnemocyteClient.prune}. All fields are optional, but
485
515
  * at least one selector must be set; calling `prune({})` is rejected with
486
516
  * a `"VALIDATION"` {@link MnemocyteError} so memories cannot be deleted
487
- * accidentally. Specified filters are combined with AND semantics.
517
+ * accidentally. Runtime values are validated before storage access; malformed
518
+ * dates, enums, arrays, booleans, and signals are rejected. `false` selector
519
+ * flags and empty selector arrays do not count as effective selectors after
520
+ * normalization. Specified filters are combined with AND semantics.
488
521
  */
489
522
  interface PruneInput {
490
523
  /** Restrict pruning to a single entity. */
@@ -518,7 +551,11 @@ interface PruneInput {
518
551
  * @defaultValue `false`
519
552
  */
520
553
  dryRun?: boolean;
521
- /** Optional cancellation signal. */
554
+ /**
555
+ * Optional cancellation signal. A pre-aborted signal prevents storage work.
556
+ * In-flight Postgres pruning requests server-query cancellation, but a
557
+ * deletion that has already committed cannot be undone.
558
+ */
522
559
  signal?: AbortSignal;
523
560
  }
524
561
  /**
@@ -566,7 +603,10 @@ interface FindDuplicatesInput {
566
603
  includeSuperseded?: boolean;
567
604
  /** Include expired memories in the scan. @defaultValue `false` */
568
605
  includeExpired?: boolean;
569
- /** Optional cancellation signal. */
606
+ /**
607
+ * Optional cancellation signal. In-memory scans check it cooperatively;
608
+ * Postgres requests cancellation of the active duplicate-search query.
609
+ */
570
610
  signal?: AbortSignal;
571
611
  }
572
612
  /**
@@ -606,6 +646,17 @@ interface AuditEvent {
606
646
  /** When the change was recorded. */
607
647
  timestamp: Date;
608
648
  }
649
+ /**
650
+ * Stable composite position for deterministic audit-log pagination.
651
+ *
652
+ * @experimental Part of Phase 6 (consolidation tooling). Shape may change.
653
+ */
654
+ interface AuditLogCursor {
655
+ /** Event timestamp at the page boundary. */
656
+ timestamp: Date;
657
+ /** Event ID used to break timestamp ties. */
658
+ id: string;
659
+ }
609
660
  /**
610
661
  * Input for {@link MnemocyteClient.listAuditLog}.
611
662
  *
@@ -619,11 +670,32 @@ interface ListAuditLogInput {
619
670
  * @defaultValue `50`
620
671
  */
621
672
  limit?: number;
622
- /** Only return entries strictly before this timestamp. */
673
+ /**
674
+ * Only return entries strictly before this timestamp. This is a filter, not
675
+ * a complete pagination cursor: events sharing the timestamp are excluded.
676
+ */
623
677
  before?: Date;
624
- /** Only return entries strictly after this timestamp. */
678
+ /**
679
+ * Only return entries strictly after this timestamp. This is a filter, not
680
+ * a complete pagination cursor: events sharing the timestamp are excluded.
681
+ */
625
682
  after?: Date;
626
- /** Optional cancellation signal. */
683
+ /**
684
+ * Return entries strictly older than this stable `(timestamp, id)` position.
685
+ *
686
+ * @experimental Prefer this over `before` for complete pagination.
687
+ */
688
+ beforeCursor?: AuditLogCursor;
689
+ /**
690
+ * Return entries strictly newer than this stable `(timestamp, id)` position.
691
+ *
692
+ * @experimental Prefer this over `after` for complete pagination.
693
+ */
694
+ afterCursor?: AuditLogCursor;
695
+ /**
696
+ * Optional cancellation signal. In-memory scans check it cooperatively;
697
+ * Postgres requests cancellation of the active audit-log query.
698
+ */
627
699
  signal?: AbortSignal;
628
700
  }
629
701
  /**
@@ -641,18 +713,27 @@ interface ConsolidateInput {
641
713
  /** Memory that should win the merge. Must not itself be superseded. */
642
714
  survivorId: string;
643
715
  /**
644
- * Memories to mark as superseded by the survivor. Already-superseded
645
- * entries in this list are skipped silently for idempotency. Must
646
- * not contain {@link ConsolidateInput.survivorId}.
716
+ * Memories to mark as superseded by the survivor. Entries already
717
+ * superseded by this same survivor are skipped for idempotency. If any
718
+ * entry points to a different survivor, the entire call rejects with
719
+ * `"CONFLICT"`. Must not contain duplicates or
720
+ * {@link ConsolidateInput.survivorId}.
647
721
  */
648
722
  supersededIds: readonly string[];
649
723
  /**
650
724
  * When `true`, the survivor's `tags` becomes the union of its own
651
- * tags and the tags of every memory that was actually superseded.
725
+ * mutation-time tags and the tags of every memory that was actually
726
+ * superseded.
652
727
  * @defaultValue `true`
653
728
  */
654
729
  mergeTags?: boolean;
655
- /** Optional cancellation signal. */
730
+ /**
731
+ * Optional cancellation signal. Postgres checks it between transaction
732
+ * steps and immediately before the transaction callback returns. A
733
+ * statement already in flight may finish before the next check rolls the
734
+ * transaction back. An abort after the final check, including while commit
735
+ * is in flight, may still leave the consolidation committed.
736
+ */
656
737
  signal?: AbortSignal;
657
738
  }
658
739
  /**
@@ -665,7 +746,7 @@ interface ConsolidateResult {
665
746
  survivorId: string;
666
747
  /**
667
748
  * Number of memories actually marked as superseded. Excludes entries
668
- * that were already superseded (idempotent skip).
749
+ * that already pointed to this survivor (idempotent skip).
669
750
  */
670
751
  supersededCount: number;
671
752
  /** The IDs that were newly superseded during this call. */
@@ -744,12 +825,20 @@ interface MnemocyteClient {
744
825
  *
745
826
  * @throws {MnemocyteError} `"NOT_FOUND"` if the memory does not exist
746
827
  * or does not belong to `entityId`.
828
+ * @throws {MnemocyteError} `"CONFLICT"` if another memory still
829
+ * references this memory as its consolidation survivor.
747
830
  */
748
831
  forget(input: {
749
832
  entityId: string;
750
833
  memoryId: string;
751
834
  }): Promise<void>;
752
- /** Delete every memory belonging to `entityId`. */
835
+ /**
836
+ * Delete every memory belonging to `entityId`.
837
+ *
838
+ * @throws {MnemocyteError} `"CONFLICT"` if any selected memory is still
839
+ * referenced as a consolidation survivor, including by another selected
840
+ * memory.
841
+ */
753
842
  forgetAll(input: {
754
843
  entityId: string;
755
844
  }): Promise<void>;
@@ -760,6 +849,10 @@ interface MnemocyteClient {
760
849
  * `"VALIDATION"` {@link MnemocyteError} to avoid accidental full
761
850
  * deletion. Pass `dryRun: true` to count without deleting.
762
851
  *
852
+ * @throws {MnemocyteError} `"CONFLICT"` when a non-dry-run prune selects
853
+ * a memory that still has consolidation dependents. The prune deletes
854
+ * nothing in that case.
855
+ *
763
856
  * @example Evict expired or stale memories for an entity
764
857
  * ```ts
765
858
  * await client.prune({
@@ -832,7 +925,10 @@ interface MnemocyteClient {
832
925
  }): Promise<EntityStats | GlobalStats>;
833
926
  /**
834
927
  * Release any underlying resources (e.g. the Postgres connection pool).
835
- * Safe to call multiple times. The client must not be used afterward.
928
+ * New operations are rejected once closing starts. The returned promise
929
+ * waits for operations that already started, then closes the store. Safe to
930
+ * call multiple times; concurrent calls share the same close operation.
931
+ * If closing the store fails, the client reopens so callers may retry.
836
932
  */
837
933
  close(): Promise<void>;
838
934
  }
@@ -846,20 +942,26 @@ interface ExperimentalMnemocyteClient {
846
942
  /**
847
943
  * Consolidate likely-duplicate memories into a single survivor by
848
944
  * marking the others as superseded. Optionally unions their tags
849
- * onto the survivor. Idempotent for memories that are already
850
- * superseded.
945
+ * onto the survivor. Idempotent when every already-superseded loser
946
+ * points to the requested survivor.
851
947
  *
852
948
  * Emits one `"memory.superseded"` audit event per newly superseded
853
949
  * memory when {@link MnemocyteConfig.audit}.`enabled` is `true`.
950
+ * A survivor cannot later be deleted while any superseded memory still
951
+ * references it; deletion attempts fail with `"CONFLICT"`.
854
952
  *
855
953
  * @experimental Part of Phase 6 (consolidation tooling). API may change.
856
954
  *
857
- * @throws {MnemocyteError} `"VALIDATION"` for empty `supersededIds`,
858
- * a `survivorId` that also appears in `supersededIds`, or a survivor
859
- * that is itself already superseded.
955
+ * @throws {MnemocyteError} `"VALIDATION"` for empty or duplicate
956
+ * `supersededIds`, a `survivorId` that also appears in `supersededIds`, or
957
+ * a survivor that is itself already superseded.
860
958
  * @throws {MnemocyteError} `"NOT_FOUND"` if the survivor or any
861
- * non-already-superseded memory in `supersededIds` does not belong
862
- * to `entityId`.
959
+ * memory in `supersededIds` does not belong to `entityId`.
960
+ * @throws {MnemocyteError} `"CONFLICT"` if any memory in
961
+ * `supersededIds` already points to a different survivor, or if the
962
+ * survivor is deleted or becomes superseded between shared preflight and
963
+ * the atomic store mutation. The whole call is rejected before any loser,
964
+ * survivor tags, or audit events are changed.
863
965
  *
864
966
  * @example
865
967
  * ```ts
@@ -876,5 +978,5 @@ interface ExperimentalMnemocyteClient {
876
978
  consolidate(input: ConsolidateInput): Promise<ConsolidateResult>;
877
979
  }
878
980
  //#endregion
879
- export { RecallInput as A, MnemocyteObservation as C, ProviderResilienceConfig as D, ObservabilityConfig as E, RetrievalScoreWeights as F, RetrievalScores as I, TokenCounter as L, RememberManyInput as M, RetrievalConfig as N, PruneInput as O, RetrievalExplanation as P, MnemocyteConfig as S, MnemocyteOperation as T, Memory as _, ConsolidateResult as a, MnemocyteBackend as b, Embedder as c, FindDuplicatesInput as d, GlobalStats as f, ListAuditLogInput as g, JsonValue as h, ConsolidateInput as i, RememberInput as j, PruneResult as k, EntityStats as l, JsonObject as m, AuditEvent as n, ContextFormat as o, ImportanceLevel as p, BuildContextInput as r, DuplicatePair as s, AuditConfig as t, ExperimentalMnemocyteClient as u, MemoryType as v, MnemocyteObservationPhase as w, MnemocyteClient as x, MemoryWithScore as y };
880
- //# sourceMappingURL=types-gOPLre4V.d.mts.map
981
+ export { PruneInput as A, MnemocyteConfig as C, MnemocyteStoreConfig as D, MnemocyteOperation as E, RetrievalConfig as F, RetrievalExplanation as I, RetrievalScoreWeights as L, RecallInput as M, RememberInput as N, ObservabilityConfig as O, RememberManyInput as P, RetrievalScores as R, MnemocyteClient as S, MnemocyteObservationPhase as T, ListAuditLogInput as _, ConsolidateInput as a, MemoryWithScore as b, DuplicatePair as c, ExperimentalMnemocyteClient as d, FindDuplicatesInput as f, JsonValue as g, JsonObject as h, BuildContextInput as i, PruneResult as j, ProviderResilienceConfig as k, Embedder as l, ImportanceLevel as m, AuditEvent as n, ConsolidateResult as o, GlobalStats as p, AuditLogCursor as r, ContextFormat as s, AuditConfig as t, EntityStats as u, Memory as v, MnemocyteObservation as w, MnemocyteBackend as x, MemoryType as y, TokenCounter as z };
982
+ //# sourceMappingURL=types-XUWYDoXM.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-XUWYDoXM.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;AAYA;;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AA;EAAA,IAAqB,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;EAyBxC,KAAA,CAAM,KAAA,EAAO,UAAA,GAAa,OAAA,CAAQ,WAAA;;;;;;;;;;;;;;;;;;;;EAoBlC,cAAA,CAAe,KAAA,EAAO,mBAAA,GAAsB,OAAA,CAAQ,aAAA;;;;;;;;;;;;;;;;;;;;;EAqBpD,YAAA,CAAa,KAAA,EAAO,iBAAA,GAAoB,OAAA,CAAQ,UAAA;;;;;;;;EAQhD,YAAA,EAAc,2BAAA;;;;;EAKd,KAAA,CAAM,KAAA;IAAU,QAAA;EAAA,IAAsB,OAAA,CAAQ,WAAA,GAAc,WAAA;;;;;;;;EAQ5D,KAAA,IAAS,OAAA;AAAA;;;;;;;UASO,2BAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqChB,WAAA,CAAY,KAAA,EAAO,gBAAA,GAAmB,OAAA,CAAQ,iBAAA;AAAA"}
@@ -8,7 +8,8 @@ CREATE TABLE "mnemocyte_events" (
8
8
  --> statement-breakpoint
9
9
  CREATE TABLE "mnemocyte_meta" (
10
10
  "key" text PRIMARY KEY NOT NULL,
11
- "embedding_dimensions" integer NOT NULL
11
+ "embedding_dimensions" integer NOT NULL,
12
+ "embedding_model" text
12
13
  );
13
14
  --> statement-breakpoint
14
15
  INSERT INTO "mnemocyte_meta" ("key", "embedding_dimensions") VALUES ('installation', {{EMBEDDING_DIMENSIONS}});
@@ -0,0 +1,15 @@
1
+ ALTER TABLE "mnemocyte_meta" ADD COLUMN "embedding_model" text;
2
+ --> statement-breakpoint
3
+ UPDATE "mnemocyte_meta"
4
+ SET "embedding_model" = (
5
+ SELECT min("embedding_model")
6
+ FROM "mnemocyte_memories"
7
+ HAVING count(DISTINCT "embedding_model") = 1
8
+ )
9
+ WHERE
10
+ "key" = 'installation'
11
+ AND "embedding_model" IS NULL
12
+ AND (
13
+ SELECT count(DISTINCT "embedding_model")
14
+ FROM "mnemocyte_memories"
15
+ ) = 1;
@@ -0,0 +1,315 @@
1
+ {
2
+ "id": "b7cab9b6-6cbf-40c0-8796-50150531a577",
3
+ "prevId": "59920203-e7f9-4cdd-9580-1c7b42ac242e",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.mnemocyte_events": {
8
+ "name": "mnemocyte_events",
9
+ "schema": "",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "text",
14
+ "primaryKey": true,
15
+ "notNull": true
16
+ },
17
+ "entity_id": {
18
+ "name": "entity_id",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": true
22
+ },
23
+ "description": {
24
+ "name": "description",
25
+ "type": "text",
26
+ "primaryKey": false,
27
+ "notNull": true
28
+ },
29
+ "metadata": {
30
+ "name": "metadata",
31
+ "type": "jsonb",
32
+ "primaryKey": false,
33
+ "notNull": true,
34
+ "default": "'{}'::jsonb"
35
+ },
36
+ "timestamp": {
37
+ "name": "timestamp",
38
+ "type": "timestamp with time zone",
39
+ "primaryKey": false,
40
+ "notNull": true,
41
+ "default": "now()"
42
+ }
43
+ },
44
+ "indexes": {
45
+ "mnemocyte_events_entity_time_idx": {
46
+ "name": "mnemocyte_events_entity_time_idx",
47
+ "columns": [
48
+ {
49
+ "expression": "entity_id",
50
+ "isExpression": false,
51
+ "asc": true,
52
+ "nulls": "last"
53
+ },
54
+ {
55
+ "expression": "timestamp",
56
+ "isExpression": false,
57
+ "asc": true,
58
+ "nulls": "last"
59
+ }
60
+ ],
61
+ "isUnique": false,
62
+ "concurrently": false,
63
+ "method": "btree",
64
+ "with": {}
65
+ }
66
+ },
67
+ "foreignKeys": {},
68
+ "compositePrimaryKeys": {},
69
+ "uniqueConstraints": {},
70
+ "policies": {},
71
+ "checkConstraints": {},
72
+ "isRLSEnabled": false
73
+ },
74
+ "public.mnemocyte_memories": {
75
+ "name": "mnemocyte_memories",
76
+ "schema": "",
77
+ "columns": {
78
+ "id": {
79
+ "name": "id",
80
+ "type": "text",
81
+ "primaryKey": true,
82
+ "notNull": true
83
+ },
84
+ "entity_id": {
85
+ "name": "entity_id",
86
+ "type": "text",
87
+ "primaryKey": false,
88
+ "notNull": true
89
+ },
90
+ "content": {
91
+ "name": "content",
92
+ "type": "text",
93
+ "primaryKey": false,
94
+ "notNull": true
95
+ },
96
+ "type": {
97
+ "name": "type",
98
+ "type": "text",
99
+ "primaryKey": false,
100
+ "notNull": true,
101
+ "default": "'fact'"
102
+ },
103
+ "importance": {
104
+ "name": "importance",
105
+ "type": "text",
106
+ "primaryKey": false,
107
+ "notNull": true,
108
+ "default": "'normal'"
109
+ },
110
+ "tags": {
111
+ "name": "tags",
112
+ "type": "text[]",
113
+ "primaryKey": false,
114
+ "notNull": true,
115
+ "default": "'{}'::text[]"
116
+ },
117
+ "source": {
118
+ "name": "source",
119
+ "type": "text",
120
+ "primaryKey": false,
121
+ "notNull": false
122
+ },
123
+ "metadata": {
124
+ "name": "metadata",
125
+ "type": "jsonb",
126
+ "primaryKey": false,
127
+ "notNull": true,
128
+ "default": "'{}'::jsonb"
129
+ },
130
+ "confidence": {
131
+ "name": "confidence",
132
+ "type": "real",
133
+ "primaryKey": false,
134
+ "notNull": true,
135
+ "default": 1
136
+ },
137
+ "embedding": {
138
+ "name": "embedding",
139
+ "type": "vector(1536)",
140
+ "primaryKey": false,
141
+ "notNull": false
142
+ },
143
+ "embedding_model": {
144
+ "name": "embedding_model",
145
+ "type": "text",
146
+ "primaryKey": false,
147
+ "notNull": true
148
+ },
149
+ "embedding_dimensions": {
150
+ "name": "embedding_dimensions",
151
+ "type": "integer",
152
+ "primaryKey": false,
153
+ "notNull": true
154
+ },
155
+ "superseded_by": {
156
+ "name": "superseded_by",
157
+ "type": "text",
158
+ "primaryKey": false,
159
+ "notNull": false
160
+ },
161
+ "superseded_at": {
162
+ "name": "superseded_at",
163
+ "type": "timestamp with time zone",
164
+ "primaryKey": false,
165
+ "notNull": false
166
+ },
167
+ "expires_at": {
168
+ "name": "expires_at",
169
+ "type": "timestamp with time zone",
170
+ "primaryKey": false,
171
+ "notNull": false
172
+ },
173
+ "last_accessed_at": {
174
+ "name": "last_accessed_at",
175
+ "type": "timestamp with time zone",
176
+ "primaryKey": false,
177
+ "notNull": false
178
+ },
179
+ "access_count": {
180
+ "name": "access_count",
181
+ "type": "integer",
182
+ "primaryKey": false,
183
+ "notNull": true,
184
+ "default": 0
185
+ },
186
+ "created_at": {
187
+ "name": "created_at",
188
+ "type": "timestamp with time zone",
189
+ "primaryKey": false,
190
+ "notNull": true,
191
+ "default": "now()"
192
+ },
193
+ "updated_at": {
194
+ "name": "updated_at",
195
+ "type": "timestamp with time zone",
196
+ "primaryKey": false,
197
+ "notNull": true,
198
+ "default": "now()"
199
+ }
200
+ },
201
+ "indexes": {
202
+ "mnemocyte_memories_entity_idx": {
203
+ "name": "mnemocyte_memories_entity_idx",
204
+ "columns": [
205
+ {
206
+ "expression": "entity_id",
207
+ "isExpression": false,
208
+ "asc": true,
209
+ "nulls": "last"
210
+ }
211
+ ],
212
+ "isUnique": false,
213
+ "concurrently": false,
214
+ "method": "btree",
215
+ "with": {}
216
+ },
217
+ "mnemocyte_memories_entity_type_idx": {
218
+ "name": "mnemocyte_memories_entity_type_idx",
219
+ "columns": [
220
+ {
221
+ "expression": "entity_id",
222
+ "isExpression": false,
223
+ "asc": true,
224
+ "nulls": "last"
225
+ },
226
+ {
227
+ "expression": "type",
228
+ "isExpression": false,
229
+ "asc": true,
230
+ "nulls": "last"
231
+ }
232
+ ],
233
+ "isUnique": false,
234
+ "concurrently": false,
235
+ "method": "btree",
236
+ "with": {}
237
+ },
238
+ "mnemocyte_memories_embedding_hnsw_idx": {
239
+ "name": "mnemocyte_memories_embedding_hnsw_idx",
240
+ "columns": [
241
+ {
242
+ "expression": "embedding",
243
+ "isExpression": false,
244
+ "asc": true,
245
+ "nulls": "last",
246
+ "opclass": "vector_cosine_ops"
247
+ }
248
+ ],
249
+ "isUnique": false,
250
+ "concurrently": false,
251
+ "method": "hnsw",
252
+ "with": {}
253
+ }
254
+ },
255
+ "foreignKeys": {
256
+ "mnemocyte_memories_superseded_by_mnemocyte_memories_id_fk": {
257
+ "name": "mnemocyte_memories_superseded_by_mnemocyte_memories_id_fk",
258
+ "tableFrom": "mnemocyte_memories",
259
+ "tableTo": "mnemocyte_memories",
260
+ "columnsFrom": ["superseded_by"],
261
+ "columnsTo": ["id"],
262
+ "onDelete": "no action",
263
+ "onUpdate": "no action"
264
+ }
265
+ },
266
+ "compositePrimaryKeys": {},
267
+ "uniqueConstraints": {},
268
+ "policies": {},
269
+ "checkConstraints": {},
270
+ "isRLSEnabled": false
271
+ },
272
+ "public.mnemocyte_meta": {
273
+ "name": "mnemocyte_meta",
274
+ "schema": "",
275
+ "columns": {
276
+ "key": {
277
+ "name": "key",
278
+ "type": "text",
279
+ "primaryKey": true,
280
+ "notNull": true
281
+ },
282
+ "embedding_dimensions": {
283
+ "name": "embedding_dimensions",
284
+ "type": "integer",
285
+ "primaryKey": false,
286
+ "notNull": true
287
+ },
288
+ "embedding_model": {
289
+ "name": "embedding_model",
290
+ "type": "text",
291
+ "primaryKey": false,
292
+ "notNull": false
293
+ }
294
+ },
295
+ "indexes": {},
296
+ "foreignKeys": {},
297
+ "compositePrimaryKeys": {},
298
+ "uniqueConstraints": {},
299
+ "policies": {},
300
+ "checkConstraints": {},
301
+ "isRLSEnabled": false
302
+ }
303
+ },
304
+ "enums": {},
305
+ "schemas": {},
306
+ "sequences": {},
307
+ "roles": {},
308
+ "policies": {},
309
+ "views": {},
310
+ "_meta": {
311
+ "columns": {},
312
+ "schemas": {},
313
+ "tables": {}
314
+ }
315
+ }
@@ -15,6 +15,13 @@
15
15
  "when": 1779455085280,
16
16
  "tag": "0001_add_mnemocyte_meta",
17
17
  "breakpoints": true
18
+ },
19
+ {
20
+ "idx": 2,
21
+ "version": "7",
22
+ "when": 1784201870906,
23
+ "tag": "0002_add_embedding_model",
24
+ "breakpoints": true
18
25
  }
19
26
  ]
20
27
  }