@pella-labs/pinakes 0.1.5 → 0.1.6

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.
@@ -0,0 +1,115 @@
1
+ CREATE TABLE `kg_audit` (
2
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
3
+ `ts` integer NOT NULL,
4
+ `tool_name` text NOT NULL,
5
+ `scope_requested` text NOT NULL,
6
+ `caller_ctx` text,
7
+ `response_tokens` integer,
8
+ `error` text
9
+ );
10
+ --> statement-breakpoint
11
+ CREATE TABLE `kg_chunks` (
12
+ `id` text PRIMARY KEY NOT NULL,
13
+ `node_id` text NOT NULL,
14
+ `chunk_index` integer NOT NULL,
15
+ `text` text NOT NULL,
16
+ `chunk_sha` text NOT NULL,
17
+ `token_count` integer NOT NULL,
18
+ `created_at` integer NOT NULL,
19
+ FOREIGN KEY (`node_id`) REFERENCES `kg_nodes`(`id`) ON UPDATE no action ON DELETE cascade
20
+ );
21
+ --> statement-breakpoint
22
+ CREATE INDEX `idx_kg_chunks_node` ON `kg_chunks` (`node_id`);--> statement-breakpoint
23
+ CREATE TABLE `kg_edges` (
24
+ `src_id` text NOT NULL,
25
+ `dst_id` text NOT NULL,
26
+ `edge_kind` text NOT NULL,
27
+ PRIMARY KEY(`src_id`, `dst_id`, `edge_kind`),
28
+ FOREIGN KEY (`src_id`) REFERENCES `kg_nodes`(`id`) ON UPDATE no action ON DELETE cascade,
29
+ FOREIGN KEY (`dst_id`) REFERENCES `kg_nodes`(`id`) ON UPDATE no action ON DELETE cascade
30
+ );
31
+ --> statement-breakpoint
32
+ CREATE INDEX `idx_kg_edges_src` ON `kg_edges` (`src_id`);--> statement-breakpoint
33
+ CREATE INDEX `idx_kg_edges_dst` ON `kg_edges` (`dst_id`);--> statement-breakpoint
34
+ CREATE TABLE `kg_gaps` (
35
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
36
+ `scope` text NOT NULL,
37
+ `topic` text NOT NULL,
38
+ `first_seen_at` integer NOT NULL,
39
+ `mentions_count` integer DEFAULT 1 NOT NULL,
40
+ `resolved_at` integer
41
+ );
42
+ --> statement-breakpoint
43
+ CREATE TABLE `kg_log` (
44
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
45
+ `ts` integer NOT NULL,
46
+ `scope` text NOT NULL,
47
+ `kind` text NOT NULL,
48
+ `source_uri` text,
49
+ `payload` text
50
+ );
51
+ --> statement-breakpoint
52
+ CREATE INDEX `idx_kg_log_ts` ON `kg_log` ("ts" DESC);--> statement-breakpoint
53
+ CREATE TABLE `kg_meta` (
54
+ `key` text PRIMARY KEY NOT NULL,
55
+ `value` text
56
+ );
57
+ --> statement-breakpoint
58
+ CREATE TABLE `kg_nodes` (
59
+ `id` text PRIMARY KEY NOT NULL,
60
+ `scope` text NOT NULL,
61
+ `source_uri` text NOT NULL,
62
+ `section_path` text NOT NULL,
63
+ `kind` text DEFAULT 'section' NOT NULL,
64
+ `title` text,
65
+ `content` text NOT NULL,
66
+ `source_sha` text NOT NULL,
67
+ `token_count` integer NOT NULL,
68
+ `created_at` integer NOT NULL,
69
+ `updated_at` integer NOT NULL,
70
+ `last_accessed_at` integer NOT NULL
71
+ );
72
+ --> statement-breakpoint
73
+ CREATE INDEX `idx_kg_nodes_scope_uri` ON `kg_nodes` (`scope`,`source_uri`);--> statement-breakpoint
74
+ CREATE INDEX `idx_kg_nodes_last_accessed` ON `kg_nodes` (`last_accessed_at`);--> statement-breakpoint
75
+
76
+ -- ============================================================================
77
+ -- Virtual tables (drizzle-kit doesn't emit these — appended by hand)
78
+ -- ============================================================================
79
+
80
+ -- FTS5 over kg_chunks. External-content table: the FTS5 index references
81
+ -- rows in kg_chunks by rowid, so we don't pay for duplicate text storage.
82
+ -- Tokenizer: unicode61 with diacritics removal. NOT trigram (CLAUDE.md
83
+ -- §Database Rules #9 — trigram triples DB size, presearch.md §Loop 0 gotcha).
84
+ -- Phase 2 only populates this via the triggers below; the FTS5 query path
85
+ -- itself lands in Phase 4 (currently the repository uses LIKE).
86
+ CREATE VIRTUAL TABLE `kg_chunks_fts` USING fts5(
87
+ text,
88
+ content='kg_chunks',
89
+ content_rowid='rowid',
90
+ tokenize='unicode61 remove_diacritics 2'
91
+ );--> statement-breakpoint
92
+
93
+ -- Sync triggers — every kg_chunks insert/delete/update mirrors into kg_chunks_fts.
94
+ -- The 'delete' marker rows are how external-content FTS5 tables handle deletes.
95
+ CREATE TRIGGER `kg_chunks_fts_ai` AFTER INSERT ON `kg_chunks` BEGIN
96
+ INSERT INTO `kg_chunks_fts`(`rowid`, `text`) VALUES (new.`rowid`, new.`text`);
97
+ END;--> statement-breakpoint
98
+
99
+ CREATE TRIGGER `kg_chunks_fts_ad` AFTER DELETE ON `kg_chunks` BEGIN
100
+ INSERT INTO `kg_chunks_fts`(`kg_chunks_fts`, `rowid`, `text`) VALUES('delete', old.`rowid`, old.`text`);
101
+ END;--> statement-breakpoint
102
+
103
+ CREATE TRIGGER `kg_chunks_fts_au` AFTER UPDATE ON `kg_chunks` BEGIN
104
+ INSERT INTO `kg_chunks_fts`(`kg_chunks_fts`, `rowid`, `text`) VALUES('delete', old.`rowid`, old.`text`);
105
+ INSERT INTO `kg_chunks_fts`(`rowid`, `text`) VALUES (new.`rowid`, new.`text`);
106
+ END;--> statement-breakpoint
107
+
108
+ -- sqlite-vec virtual table for chunk embeddings. 384 dims is the MiniLM
109
+ -- output size. If we ever swap embedders to a different dim, this table
110
+ -- must be dropped and re-created and all chunks re-embedded — that's a
111
+ -- distinct migration path stamped via kg_meta.schema_version.
112
+ -- Joins to kg_chunks via rowid.
113
+ -- Requires sqlite-vec extension to be loaded on the connection BEFORE this
114
+ -- statement runs; src/db/client.ts loads it before invoking migrate().
115
+ CREATE VIRTUAL TABLE kg_chunks_vec USING vec0(embedding FLOAT[384]);
@@ -0,0 +1 @@
1
+ ALTER TABLE `kg_nodes` ADD `confidence` text DEFAULT 'extracted' NOT NULL;
@@ -0,0 +1,496 @@
1
+ {
2
+ "version": "6",
3
+ "dialect": "sqlite",
4
+ "id": "b3e9b0d1-ad8e-4ff9-8e7c-664ddb109318",
5
+ "prevId": "00000000-0000-0000-0000-000000000000",
6
+ "tables": {
7
+ "kg_audit": {
8
+ "name": "kg_audit",
9
+ "columns": {
10
+ "id": {
11
+ "name": "id",
12
+ "type": "integer",
13
+ "primaryKey": true,
14
+ "notNull": true,
15
+ "autoincrement": true
16
+ },
17
+ "ts": {
18
+ "name": "ts",
19
+ "type": "integer",
20
+ "primaryKey": false,
21
+ "notNull": true,
22
+ "autoincrement": false
23
+ },
24
+ "tool_name": {
25
+ "name": "tool_name",
26
+ "type": "text",
27
+ "primaryKey": false,
28
+ "notNull": true,
29
+ "autoincrement": false
30
+ },
31
+ "scope_requested": {
32
+ "name": "scope_requested",
33
+ "type": "text",
34
+ "primaryKey": false,
35
+ "notNull": true,
36
+ "autoincrement": false
37
+ },
38
+ "caller_ctx": {
39
+ "name": "caller_ctx",
40
+ "type": "text",
41
+ "primaryKey": false,
42
+ "notNull": false,
43
+ "autoincrement": false
44
+ },
45
+ "response_tokens": {
46
+ "name": "response_tokens",
47
+ "type": "integer",
48
+ "primaryKey": false,
49
+ "notNull": false,
50
+ "autoincrement": false
51
+ },
52
+ "error": {
53
+ "name": "error",
54
+ "type": "text",
55
+ "primaryKey": false,
56
+ "notNull": false,
57
+ "autoincrement": false
58
+ }
59
+ },
60
+ "indexes": {},
61
+ "foreignKeys": {},
62
+ "compositePrimaryKeys": {},
63
+ "uniqueConstraints": {},
64
+ "checkConstraints": {}
65
+ },
66
+ "kg_chunks": {
67
+ "name": "kg_chunks",
68
+ "columns": {
69
+ "id": {
70
+ "name": "id",
71
+ "type": "text",
72
+ "primaryKey": true,
73
+ "notNull": true,
74
+ "autoincrement": false
75
+ },
76
+ "node_id": {
77
+ "name": "node_id",
78
+ "type": "text",
79
+ "primaryKey": false,
80
+ "notNull": true,
81
+ "autoincrement": false
82
+ },
83
+ "chunk_index": {
84
+ "name": "chunk_index",
85
+ "type": "integer",
86
+ "primaryKey": false,
87
+ "notNull": true,
88
+ "autoincrement": false
89
+ },
90
+ "text": {
91
+ "name": "text",
92
+ "type": "text",
93
+ "primaryKey": false,
94
+ "notNull": true,
95
+ "autoincrement": false
96
+ },
97
+ "chunk_sha": {
98
+ "name": "chunk_sha",
99
+ "type": "text",
100
+ "primaryKey": false,
101
+ "notNull": true,
102
+ "autoincrement": false
103
+ },
104
+ "token_count": {
105
+ "name": "token_count",
106
+ "type": "integer",
107
+ "primaryKey": false,
108
+ "notNull": true,
109
+ "autoincrement": false
110
+ },
111
+ "created_at": {
112
+ "name": "created_at",
113
+ "type": "integer",
114
+ "primaryKey": false,
115
+ "notNull": true,
116
+ "autoincrement": false
117
+ }
118
+ },
119
+ "indexes": {
120
+ "idx_kg_chunks_node": {
121
+ "name": "idx_kg_chunks_node",
122
+ "columns": [
123
+ "node_id"
124
+ ],
125
+ "isUnique": false
126
+ }
127
+ },
128
+ "foreignKeys": {
129
+ "kg_chunks_node_id_kg_nodes_id_fk": {
130
+ "name": "kg_chunks_node_id_kg_nodes_id_fk",
131
+ "tableFrom": "kg_chunks",
132
+ "tableTo": "kg_nodes",
133
+ "columnsFrom": [
134
+ "node_id"
135
+ ],
136
+ "columnsTo": [
137
+ "id"
138
+ ],
139
+ "onDelete": "cascade",
140
+ "onUpdate": "no action"
141
+ }
142
+ },
143
+ "compositePrimaryKeys": {},
144
+ "uniqueConstraints": {},
145
+ "checkConstraints": {}
146
+ },
147
+ "kg_edges": {
148
+ "name": "kg_edges",
149
+ "columns": {
150
+ "src_id": {
151
+ "name": "src_id",
152
+ "type": "text",
153
+ "primaryKey": false,
154
+ "notNull": true,
155
+ "autoincrement": false
156
+ },
157
+ "dst_id": {
158
+ "name": "dst_id",
159
+ "type": "text",
160
+ "primaryKey": false,
161
+ "notNull": true,
162
+ "autoincrement": false
163
+ },
164
+ "edge_kind": {
165
+ "name": "edge_kind",
166
+ "type": "text",
167
+ "primaryKey": false,
168
+ "notNull": true,
169
+ "autoincrement": false
170
+ }
171
+ },
172
+ "indexes": {
173
+ "idx_kg_edges_src": {
174
+ "name": "idx_kg_edges_src",
175
+ "columns": [
176
+ "src_id"
177
+ ],
178
+ "isUnique": false
179
+ },
180
+ "idx_kg_edges_dst": {
181
+ "name": "idx_kg_edges_dst",
182
+ "columns": [
183
+ "dst_id"
184
+ ],
185
+ "isUnique": false
186
+ }
187
+ },
188
+ "foreignKeys": {
189
+ "kg_edges_src_id_kg_nodes_id_fk": {
190
+ "name": "kg_edges_src_id_kg_nodes_id_fk",
191
+ "tableFrom": "kg_edges",
192
+ "tableTo": "kg_nodes",
193
+ "columnsFrom": [
194
+ "src_id"
195
+ ],
196
+ "columnsTo": [
197
+ "id"
198
+ ],
199
+ "onDelete": "cascade",
200
+ "onUpdate": "no action"
201
+ },
202
+ "kg_edges_dst_id_kg_nodes_id_fk": {
203
+ "name": "kg_edges_dst_id_kg_nodes_id_fk",
204
+ "tableFrom": "kg_edges",
205
+ "tableTo": "kg_nodes",
206
+ "columnsFrom": [
207
+ "dst_id"
208
+ ],
209
+ "columnsTo": [
210
+ "id"
211
+ ],
212
+ "onDelete": "cascade",
213
+ "onUpdate": "no action"
214
+ }
215
+ },
216
+ "compositePrimaryKeys": {
217
+ "kg_edges_src_id_dst_id_edge_kind_pk": {
218
+ "columns": [
219
+ "src_id",
220
+ "dst_id",
221
+ "edge_kind"
222
+ ],
223
+ "name": "kg_edges_src_id_dst_id_edge_kind_pk"
224
+ }
225
+ },
226
+ "uniqueConstraints": {},
227
+ "checkConstraints": {}
228
+ },
229
+ "kg_gaps": {
230
+ "name": "kg_gaps",
231
+ "columns": {
232
+ "id": {
233
+ "name": "id",
234
+ "type": "integer",
235
+ "primaryKey": true,
236
+ "notNull": true,
237
+ "autoincrement": true
238
+ },
239
+ "scope": {
240
+ "name": "scope",
241
+ "type": "text",
242
+ "primaryKey": false,
243
+ "notNull": true,
244
+ "autoincrement": false
245
+ },
246
+ "topic": {
247
+ "name": "topic",
248
+ "type": "text",
249
+ "primaryKey": false,
250
+ "notNull": true,
251
+ "autoincrement": false
252
+ },
253
+ "first_seen_at": {
254
+ "name": "first_seen_at",
255
+ "type": "integer",
256
+ "primaryKey": false,
257
+ "notNull": true,
258
+ "autoincrement": false
259
+ },
260
+ "mentions_count": {
261
+ "name": "mentions_count",
262
+ "type": "integer",
263
+ "primaryKey": false,
264
+ "notNull": true,
265
+ "autoincrement": false,
266
+ "default": 1
267
+ },
268
+ "resolved_at": {
269
+ "name": "resolved_at",
270
+ "type": "integer",
271
+ "primaryKey": false,
272
+ "notNull": false,
273
+ "autoincrement": false
274
+ }
275
+ },
276
+ "indexes": {},
277
+ "foreignKeys": {},
278
+ "compositePrimaryKeys": {},
279
+ "uniqueConstraints": {},
280
+ "checkConstraints": {}
281
+ },
282
+ "kg_log": {
283
+ "name": "kg_log",
284
+ "columns": {
285
+ "id": {
286
+ "name": "id",
287
+ "type": "integer",
288
+ "primaryKey": true,
289
+ "notNull": true,
290
+ "autoincrement": true
291
+ },
292
+ "ts": {
293
+ "name": "ts",
294
+ "type": "integer",
295
+ "primaryKey": false,
296
+ "notNull": true,
297
+ "autoincrement": false
298
+ },
299
+ "scope": {
300
+ "name": "scope",
301
+ "type": "text",
302
+ "primaryKey": false,
303
+ "notNull": true,
304
+ "autoincrement": false
305
+ },
306
+ "kind": {
307
+ "name": "kind",
308
+ "type": "text",
309
+ "primaryKey": false,
310
+ "notNull": true,
311
+ "autoincrement": false
312
+ },
313
+ "source_uri": {
314
+ "name": "source_uri",
315
+ "type": "text",
316
+ "primaryKey": false,
317
+ "notNull": false,
318
+ "autoincrement": false
319
+ },
320
+ "payload": {
321
+ "name": "payload",
322
+ "type": "text",
323
+ "primaryKey": false,
324
+ "notNull": false,
325
+ "autoincrement": false
326
+ }
327
+ },
328
+ "indexes": {
329
+ "idx_kg_log_ts": {
330
+ "name": "idx_kg_log_ts",
331
+ "columns": [
332
+ "\"ts\" DESC"
333
+ ],
334
+ "isUnique": false
335
+ }
336
+ },
337
+ "foreignKeys": {},
338
+ "compositePrimaryKeys": {},
339
+ "uniqueConstraints": {},
340
+ "checkConstraints": {}
341
+ },
342
+ "kg_meta": {
343
+ "name": "kg_meta",
344
+ "columns": {
345
+ "key": {
346
+ "name": "key",
347
+ "type": "text",
348
+ "primaryKey": true,
349
+ "notNull": true,
350
+ "autoincrement": false
351
+ },
352
+ "value": {
353
+ "name": "value",
354
+ "type": "text",
355
+ "primaryKey": false,
356
+ "notNull": false,
357
+ "autoincrement": false
358
+ }
359
+ },
360
+ "indexes": {},
361
+ "foreignKeys": {},
362
+ "compositePrimaryKeys": {},
363
+ "uniqueConstraints": {},
364
+ "checkConstraints": {}
365
+ },
366
+ "kg_nodes": {
367
+ "name": "kg_nodes",
368
+ "columns": {
369
+ "id": {
370
+ "name": "id",
371
+ "type": "text",
372
+ "primaryKey": true,
373
+ "notNull": true,
374
+ "autoincrement": false
375
+ },
376
+ "scope": {
377
+ "name": "scope",
378
+ "type": "text",
379
+ "primaryKey": false,
380
+ "notNull": true,
381
+ "autoincrement": false
382
+ },
383
+ "source_uri": {
384
+ "name": "source_uri",
385
+ "type": "text",
386
+ "primaryKey": false,
387
+ "notNull": true,
388
+ "autoincrement": false
389
+ },
390
+ "section_path": {
391
+ "name": "section_path",
392
+ "type": "text",
393
+ "primaryKey": false,
394
+ "notNull": true,
395
+ "autoincrement": false
396
+ },
397
+ "kind": {
398
+ "name": "kind",
399
+ "type": "text",
400
+ "primaryKey": false,
401
+ "notNull": true,
402
+ "autoincrement": false,
403
+ "default": "'section'"
404
+ },
405
+ "title": {
406
+ "name": "title",
407
+ "type": "text",
408
+ "primaryKey": false,
409
+ "notNull": false,
410
+ "autoincrement": false
411
+ },
412
+ "content": {
413
+ "name": "content",
414
+ "type": "text",
415
+ "primaryKey": false,
416
+ "notNull": true,
417
+ "autoincrement": false
418
+ },
419
+ "source_sha": {
420
+ "name": "source_sha",
421
+ "type": "text",
422
+ "primaryKey": false,
423
+ "notNull": true,
424
+ "autoincrement": false
425
+ },
426
+ "token_count": {
427
+ "name": "token_count",
428
+ "type": "integer",
429
+ "primaryKey": false,
430
+ "notNull": true,
431
+ "autoincrement": false
432
+ },
433
+ "created_at": {
434
+ "name": "created_at",
435
+ "type": "integer",
436
+ "primaryKey": false,
437
+ "notNull": true,
438
+ "autoincrement": false
439
+ },
440
+ "updated_at": {
441
+ "name": "updated_at",
442
+ "type": "integer",
443
+ "primaryKey": false,
444
+ "notNull": true,
445
+ "autoincrement": false
446
+ },
447
+ "last_accessed_at": {
448
+ "name": "last_accessed_at",
449
+ "type": "integer",
450
+ "primaryKey": false,
451
+ "notNull": true,
452
+ "autoincrement": false
453
+ }
454
+ },
455
+ "indexes": {
456
+ "idx_kg_nodes_scope_uri": {
457
+ "name": "idx_kg_nodes_scope_uri",
458
+ "columns": [
459
+ "scope",
460
+ "source_uri"
461
+ ],
462
+ "isUnique": false
463
+ },
464
+ "idx_kg_nodes_last_accessed": {
465
+ "name": "idx_kg_nodes_last_accessed",
466
+ "columns": [
467
+ "last_accessed_at"
468
+ ],
469
+ "isUnique": false
470
+ }
471
+ },
472
+ "foreignKeys": {},
473
+ "compositePrimaryKeys": {},
474
+ "uniqueConstraints": {},
475
+ "checkConstraints": {}
476
+ }
477
+ },
478
+ "views": {},
479
+ "enums": {},
480
+ "_meta": {
481
+ "schemas": {},
482
+ "tables": {},
483
+ "columns": {}
484
+ },
485
+ "internal": {
486
+ "indexes": {
487
+ "idx_kg_log_ts": {
488
+ "columns": {
489
+ "\"ts\" DESC": {
490
+ "isExpression": true
491
+ }
492
+ }
493
+ }
494
+ }
495
+ }
496
+ }