@kybernesis/brain-contracts 0.2.0 → 0.6.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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/storage.d.ts +593 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +31 -0
- package/dist/storage.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,593 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage provider interfaces — the swappable seam (Stage 1).
|
|
3
|
+
*
|
|
4
|
+
* `brain-core` business logic depends ONLY on these interfaces, obtained via
|
|
5
|
+
* the `setStorageProvider`/`getStorage` seam in brain-core (which mirrors
|
|
6
|
+
* `setLLMProvider`). Each backend package (brain-storage-sqlite today; a
|
|
7
|
+
* libsql impl in Stage 3) implements them with its own dialect.
|
|
8
|
+
*
|
|
9
|
+
* DESIGN RULES (load-bearing — see docs/specs/storage-provider-di-spec.md):
|
|
10
|
+
* - Every method is async. Inserts return `Promise<number>` (the new id), so
|
|
11
|
+
* the impl owns `RETURNING` vs `lastInsertRowid` internally.
|
|
12
|
+
* - No method ever exposes a driver handle (`better-sqlite3.Database`, a libsql
|
|
13
|
+
* client, …). The seam speaks domain operations, never SQL.
|
|
14
|
+
* - Returned object fields are snake_case, matching the v0.2.0 realignment and
|
|
15
|
+
* guarded by schema-naming.test.ts.
|
|
16
|
+
* - The 3 within-kind transactions (mergeEntities, deleteEntity, the vector
|
|
17
|
+
* chunk insert) are IMPL-INTERNAL to their methods — no public transaction
|
|
18
|
+
* primitive is exposed in Stage 1 (decision ①: keep per-kind best-effort
|
|
19
|
+
* semantics; cross-kind unit-of-work is a reserved Stage-3 addition).
|
|
20
|
+
* - Param names stay camelCase at the input edge (unchanged public surface);
|
|
21
|
+
* only RETURNED fields are snake_case.
|
|
22
|
+
*
|
|
23
|
+
* NOTE: as of 0.6.0 (gate U0) the bundle has TWO planes — five CRUD
|
|
24
|
+
* `*Repository` interfaces under `.repositories` (frozen since 0.5.0) and three
|
|
25
|
+
* DB-focused domain interfaces under `.domain` (SearchQueries, FactRetrievalQueries,
|
|
26
|
+
* SleepMaintenance), declared now to freeze the shape and populated per gate
|
|
27
|
+
* (U1 search, U2 fact-retrieval, U3 sleep). See the BUSINESS PLANE section below
|
|
28
|
+
* and docs/specs/storage-untangle-0.6.0-kickoff.md.
|
|
29
|
+
*/
|
|
30
|
+
import type { TenantContext } from './tenant.js';
|
|
31
|
+
import type { TimelineEvent, TimelineEventInput } from './timeline.js';
|
|
32
|
+
import type { Entity, EntityMention, Contradiction, EntityInsight } from './entity.js';
|
|
33
|
+
import type { Fact } from './fact.js';
|
|
34
|
+
import type { EntityType, RelationshipType, InsightType, EventType, FactCategory } from './constants.js';
|
|
35
|
+
export interface TimelineQuery {
|
|
36
|
+
start?: string;
|
|
37
|
+
end?: string;
|
|
38
|
+
type?: EventType;
|
|
39
|
+
search?: string;
|
|
40
|
+
entities?: string[];
|
|
41
|
+
topics?: string[];
|
|
42
|
+
limit?: number;
|
|
43
|
+
offset?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface TimelineStats {
|
|
46
|
+
totalEvents: number;
|
|
47
|
+
byType: Record<EventType, number>;
|
|
48
|
+
dateRange: {
|
|
49
|
+
earliest: string | null;
|
|
50
|
+
latest: string | null;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export interface VectorChunkInput {
|
|
54
|
+
/** Embedding vector; impl marshals to its own binding format. */
|
|
55
|
+
embedding: number[];
|
|
56
|
+
ts: string;
|
|
57
|
+
source?: string;
|
|
58
|
+
content: string;
|
|
59
|
+
origin_id?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface VectorSearchRow {
|
|
62
|
+
ts: string;
|
|
63
|
+
source: string | null;
|
|
64
|
+
content: string;
|
|
65
|
+
origin_id: string | null;
|
|
66
|
+
distance: number;
|
|
67
|
+
}
|
|
68
|
+
export interface TimelineRepository {
|
|
69
|
+
ensureSchema(t: TenantContext): Promise<void>;
|
|
70
|
+
addEvent(t: TenantContext, event: TimelineEventInput): Promise<number>;
|
|
71
|
+
removeEventByPath(t: TenantContext, sourcePath: string): Promise<boolean>;
|
|
72
|
+
updateEvent(t: TenantContext, id: number, updates: Partial<Omit<TimelineEventInput, 'source_path'>>): Promise<void>;
|
|
73
|
+
deleteEventById(t: TenantContext, id: number): Promise<boolean>;
|
|
74
|
+
getEventById(t: TenantContext, id: number): Promise<TimelineEvent | null>;
|
|
75
|
+
getEventByPath(t: TenantContext, sourcePath: string): Promise<TimelineEvent | null>;
|
|
76
|
+
query(t: TenantContext, query: TimelineQuery): Promise<TimelineEvent[]>;
|
|
77
|
+
findRecentDuplicate(t: TenantContext, title: string, withinHours: number): Promise<{
|
|
78
|
+
id: number;
|
|
79
|
+
title: string;
|
|
80
|
+
} | null>;
|
|
81
|
+
incrementEventCount(t: TenantContext, eventId: number): Promise<void>;
|
|
82
|
+
stats(t: TenantContext): Promise<TimelineStats>;
|
|
83
|
+
/** DISTINCT source_paths whose title/tags/entities LIKE the (lowercased) term. (ops.ts recall) */
|
|
84
|
+
findSourcePathsMatching(t: TenantContext, termLower: string, limit: number): Promise<string[]>;
|
|
85
|
+
}
|
|
86
|
+
export interface EntityRelatedHit {
|
|
87
|
+
entity: Entity;
|
|
88
|
+
relationship: string;
|
|
89
|
+
strength: number;
|
|
90
|
+
}
|
|
91
|
+
export interface TypedRelationship {
|
|
92
|
+
entity: Entity;
|
|
93
|
+
relationship: RelationshipType;
|
|
94
|
+
direction: 'outgoing' | 'incoming';
|
|
95
|
+
confidence: number;
|
|
96
|
+
rationale?: string;
|
|
97
|
+
}
|
|
98
|
+
export interface EntityGraphStats {
|
|
99
|
+
totalEntities: number;
|
|
100
|
+
totalMentions: number;
|
|
101
|
+
totalRelations: number;
|
|
102
|
+
byType: Record<EntityType, number>;
|
|
103
|
+
}
|
|
104
|
+
export interface EntityRepository {
|
|
105
|
+
ensureSchema(t: TenantContext): Promise<void>;
|
|
106
|
+
findOrCreateEntity(t: TenantContext, name: string, type: EntityType, timestamp: string): Promise<Entity>;
|
|
107
|
+
addEntityAlias(t: TenantContext, entityId: number, alias: string): Promise<void>;
|
|
108
|
+
addEntityMention(t: TenantContext, entityId: number, conversationId: string, sourcePath: string, context: string, timestamp: string, sourceType?: string, confidence?: number): Promise<void>;
|
|
109
|
+
linkEntities(t: TenantContext, sourceId: number, targetId: number, relationship?: RelationshipType): Promise<void>;
|
|
110
|
+
linkEntitiesWithType(t: TenantContext, sourceId: number, targetId: number, options: {
|
|
111
|
+
relationship: RelationshipType;
|
|
112
|
+
confidence?: number;
|
|
113
|
+
rationale?: string;
|
|
114
|
+
method?: string;
|
|
115
|
+
}): Promise<void>;
|
|
116
|
+
getTypedRelationships(t: TenantContext, entityId: number): Promise<TypedRelationship[]>;
|
|
117
|
+
getEntityContext(t: TenantContext, nameOrId: string | number): Promise<{
|
|
118
|
+
entity: Entity;
|
|
119
|
+
mentions: EntityMention[];
|
|
120
|
+
relatedEntities: EntityRelatedHit[];
|
|
121
|
+
} | null>;
|
|
122
|
+
searchEntities(t: TenantContext, query: string, options?: {
|
|
123
|
+
type?: EntityType;
|
|
124
|
+
limit?: number;
|
|
125
|
+
}): Promise<Entity[]>;
|
|
126
|
+
getRecentEntities(t: TenantContext, limit?: number): Promise<Entity[]>;
|
|
127
|
+
getMostMentionedEntities(t: TenantContext, options?: {
|
|
128
|
+
type?: EntityType;
|
|
129
|
+
limit?: number;
|
|
130
|
+
}): Promise<Entity[]>;
|
|
131
|
+
stats(t: TenantContext): Promise<EntityGraphStats>;
|
|
132
|
+
detectEntitiesInQuery(t: TenantContext, query: string): Promise<{
|
|
133
|
+
entities: string[];
|
|
134
|
+
remainingQuery: string;
|
|
135
|
+
}>;
|
|
136
|
+
mergeEntities(t: TenantContext, keepId: number, removeId: number, reason: string, confidence?: number, aiRationale?: string, mergedBy?: string): Promise<{
|
|
137
|
+
mentions_moved: number;
|
|
138
|
+
relations_moved: number;
|
|
139
|
+
}>;
|
|
140
|
+
deleteEntity(t: TenantContext, entityId: number, reason: string, mergedBy?: string): Promise<void>;
|
|
141
|
+
getEntityProfile(t: TenantContext, entityId: number): Promise<{
|
|
142
|
+
profile: string;
|
|
143
|
+
generated_at: string;
|
|
144
|
+
fact_count: number;
|
|
145
|
+
} | null>;
|
|
146
|
+
saveEntityProfile(t: TenantContext, entityId: number, profile: string, factCount: number): Promise<void>;
|
|
147
|
+
createContradiction(t: TenantContext, entityId: number, factAId: number, factBId: number, factA: string, factB: string, description: string): Promise<number>;
|
|
148
|
+
getOpenContradictions(t: TenantContext, entityId: number): Promise<Contradiction[]>;
|
|
149
|
+
resolveContradiction(t: TenantContext, contradictionId: number, resolvedBy: string): Promise<void>;
|
|
150
|
+
applyContradictions(t: TenantContext, entityId: number, factIds: number[]): Promise<void>;
|
|
151
|
+
saveEntityInsight(t: TenantContext, entityId: number, insightType: InsightType, insight: string, reasoning: string, confidence: number, sourceEntityIds?: number[], expiresAt?: string): Promise<number>;
|
|
152
|
+
getEntityInsights(t: TenantContext, entityId: number, minConfidence?: number): Promise<EntityInsight[]>;
|
|
153
|
+
markInsightsStale(t: TenantContext, entityId: number): Promise<void>;
|
|
154
|
+
getEntitiesForReasoning(t: TenantContext, limit?: number, staleDays?: number, recencyDays?: number): Promise<Array<{
|
|
155
|
+
id: number;
|
|
156
|
+
name: string;
|
|
157
|
+
type: string;
|
|
158
|
+
}>>;
|
|
159
|
+
markEntityReasoned(t: TenantContext, entityId: number): Promise<void>;
|
|
160
|
+
pinEntity(t: TenantContext, entityId: number, pinned?: boolean): Promise<void>;
|
|
161
|
+
listPinned(t: TenantContext, type?: EntityType): Promise<Entity[]>;
|
|
162
|
+
/** Bump access_count + last_accessed for an entity. (ops.ts recall tracking) */
|
|
163
|
+
trackAccess(t: TenantContext, entityId: number): Promise<void>;
|
|
164
|
+
}
|
|
165
|
+
/** Insert shape for storeFact — server fills id/created_at/is_latest/access_count/is_retracted. */
|
|
166
|
+
export type StoreFactInput = Omit<Fact, 'id' | 'created_at' | 'is_latest' | 'access_count' | 'is_retracted'>;
|
|
167
|
+
export interface FactRepository {
|
|
168
|
+
ensureFactsTable(t: TenantContext): Promise<void>;
|
|
169
|
+
storeFact(t: TenantContext, fact: StoreFactInput): Promise<number>;
|
|
170
|
+
retractFact(t: TenantContext, factId: number, retractedBy?: string): Promise<void>;
|
|
171
|
+
reinforceFact(t: TenantContext, factId: number): Promise<void>;
|
|
172
|
+
getFactById(t: TenantContext, factId: number): Promise<Fact | null>;
|
|
173
|
+
getFactsForEntity(t: TenantContext, entity: string, options?: {
|
|
174
|
+
latestOnly?: boolean;
|
|
175
|
+
limit?: number;
|
|
176
|
+
category?: FactCategory;
|
|
177
|
+
}): Promise<Fact[]>;
|
|
178
|
+
markFactSuperseded(t: TenantContext, oldFactId: number, newFactId: number): Promise<void>;
|
|
179
|
+
factsCount(t: TenantContext): Promise<number>;
|
|
180
|
+
listFacts(t: TenantContext, options?: {
|
|
181
|
+
limit?: number;
|
|
182
|
+
offset?: number;
|
|
183
|
+
latestOnly?: boolean;
|
|
184
|
+
category?: FactCategory;
|
|
185
|
+
}): Promise<Fact[]>;
|
|
186
|
+
listTemporalFacts(t: TenantContext, options?: {
|
|
187
|
+
includeExpired?: boolean;
|
|
188
|
+
limit?: number;
|
|
189
|
+
}): Promise<Fact[]>;
|
|
190
|
+
searchFactsFts(t: TenantContext, query: string, limit?: number): Promise<Fact[]>;
|
|
191
|
+
/**
|
|
192
|
+
* Active (latest, non-expired) fact CONTENTS for a category. (user-profile.ts)
|
|
193
|
+
* order 'frecency' = confidence DESC, access_count DESC (fallback confidence-only
|
|
194
|
+
* if access_count column is absent); 'recent' = timestamp DESC.
|
|
195
|
+
*/
|
|
196
|
+
getFactContentsByCategory(t: TenantContext, category: string, limit: number, order: 'frecency' | 'recent'): Promise<string[]>;
|
|
197
|
+
}
|
|
198
|
+
export interface MemoryEdgeHit {
|
|
199
|
+
related_path: string;
|
|
200
|
+
confidence: number;
|
|
201
|
+
shared_tags: string;
|
|
202
|
+
}
|
|
203
|
+
/** sleep_runs checkpoint columns (crash-forensics; see where a run died). */
|
|
204
|
+
export interface SleepCheckpointRow {
|
|
205
|
+
checkpoint_step: string | null;
|
|
206
|
+
checkpoint_data: string | null;
|
|
207
|
+
}
|
|
208
|
+
/** timeline_events columns the decay step reads (non-archive batch). [U3b] */
|
|
209
|
+
export interface DecayCandidateRow {
|
|
210
|
+
id: number;
|
|
211
|
+
title: string | null;
|
|
212
|
+
source_path: string;
|
|
213
|
+
timestamp: string;
|
|
214
|
+
priority: number | null;
|
|
215
|
+
decay_score: number | null;
|
|
216
|
+
access_count: number | null;
|
|
217
|
+
is_pinned: number | null;
|
|
218
|
+
}
|
|
219
|
+
/** timeline_events columns the tag step reads (stale/missing tags). [U3b] */
|
|
220
|
+
export interface TagCandidateRow {
|
|
221
|
+
id: number;
|
|
222
|
+
source_path: string;
|
|
223
|
+
title: string | null;
|
|
224
|
+
summary: string | null;
|
|
225
|
+
tags_json: string | null;
|
|
226
|
+
topics_json: string | null;
|
|
227
|
+
}
|
|
228
|
+
/** memory_edges aggregate for a path: edge count + summed confidence. [U3c] */
|
|
229
|
+
export interface SleepEdgeStats {
|
|
230
|
+
count: number;
|
|
231
|
+
total_confidence: number;
|
|
232
|
+
}
|
|
233
|
+
/** A memory_edges reference (id + endpoints) for the link retype pass. [U3c] */
|
|
234
|
+
export interface MemoryEdgeRef {
|
|
235
|
+
id: number;
|
|
236
|
+
from_path: string;
|
|
237
|
+
to_path: string;
|
|
238
|
+
}
|
|
239
|
+
/** Insert payload for a new memory_edge (method/timestamps are impl-filled). [U3c] */
|
|
240
|
+
export interface MemoryEdgeInput {
|
|
241
|
+
from_path: string;
|
|
242
|
+
to_path: string;
|
|
243
|
+
relation: string;
|
|
244
|
+
confidence: number;
|
|
245
|
+
shared_tags: string;
|
|
246
|
+
rationale: string;
|
|
247
|
+
}
|
|
248
|
+
/** timeline_events columns the tier step evaluates. [U3c] */
|
|
249
|
+
export interface TierCandidateRow {
|
|
250
|
+
id: number;
|
|
251
|
+
source_path: string;
|
|
252
|
+
priority: number | null;
|
|
253
|
+
decay_score: number | null;
|
|
254
|
+
tier: string | null;
|
|
255
|
+
last_accessed: string | null;
|
|
256
|
+
access_count: number | null;
|
|
257
|
+
is_pinned: number | null;
|
|
258
|
+
}
|
|
259
|
+
/** timeline_events columns the link step reads. [U3c] */
|
|
260
|
+
export interface LinkCandidateRow {
|
|
261
|
+
id: number;
|
|
262
|
+
source_path: string;
|
|
263
|
+
title: string;
|
|
264
|
+
tier: string | null;
|
|
265
|
+
tags_json: string | null;
|
|
266
|
+
topics_json: string | null;
|
|
267
|
+
entities_json: string | null;
|
|
268
|
+
}
|
|
269
|
+
/** A consolidation group keyed by normalized title (channel-prefix/ellipsis stripped IN SQL). [U3d] */
|
|
270
|
+
export interface ConsolidationGroup {
|
|
271
|
+
normalized_title: string;
|
|
272
|
+
cnt: number;
|
|
273
|
+
ids: string;
|
|
274
|
+
first_ts: string;
|
|
275
|
+
last_ts: string;
|
|
276
|
+
}
|
|
277
|
+
/** An entity row for hygiene scanning (phase 1 artifacts, phase 5 profiles). [U3e] */
|
|
278
|
+
export interface HygieneEntityRow {
|
|
279
|
+
id: number;
|
|
280
|
+
name: string;
|
|
281
|
+
type: string;
|
|
282
|
+
mention_count: number;
|
|
283
|
+
}
|
|
284
|
+
/** A same-normalized-name / different-type group (entity-hygiene phase 2). [U3e] */
|
|
285
|
+
export interface SameNameGroup {
|
|
286
|
+
normalized_name: string;
|
|
287
|
+
ids: string;
|
|
288
|
+
types: string;
|
|
289
|
+
names: string;
|
|
290
|
+
mention_counts: string;
|
|
291
|
+
}
|
|
292
|
+
/** An entity row for variant detection (phase 3 — includes normalized_name). [U3e] */
|
|
293
|
+
export interface VariantEntityRow {
|
|
294
|
+
id: number;
|
|
295
|
+
name: string;
|
|
296
|
+
normalized_name: string;
|
|
297
|
+
type: string;
|
|
298
|
+
mention_count: number;
|
|
299
|
+
}
|
|
300
|
+
/** Mention contexts + related-entity names for one entity (AI-assessment input). [U3e] */
|
|
301
|
+
export interface HygieneEntityProfile {
|
|
302
|
+
contexts: string[];
|
|
303
|
+
related: string[];
|
|
304
|
+
}
|
|
305
|
+
/** A prune candidate (entity-hygiene phase 4 — passed all 5 KAD filters). [U3e] */
|
|
306
|
+
export interface PruneCandidateRow {
|
|
307
|
+
id: number;
|
|
308
|
+
name: string;
|
|
309
|
+
type: string;
|
|
310
|
+
mention_count: number;
|
|
311
|
+
}
|
|
312
|
+
/** A resummarize queue entry (maintenance_queue task='resummarize'). [U3f] */
|
|
313
|
+
export interface ResummarizeQueueItem {
|
|
314
|
+
queue_id: number;
|
|
315
|
+
item_id: string;
|
|
316
|
+
}
|
|
317
|
+
/** timeline_events columns the summarize step reads for one item. [U3f] */
|
|
318
|
+
export interface SummaryEventRow {
|
|
319
|
+
id: number;
|
|
320
|
+
source_path: string;
|
|
321
|
+
title: string | null;
|
|
322
|
+
tier: string | null;
|
|
323
|
+
summary: string | null;
|
|
324
|
+
tags_json: string | null;
|
|
325
|
+
entities_json: string | null;
|
|
326
|
+
}
|
|
327
|
+
/** An unordered related-edge neighbour for the summarize context block. [U3f] */
|
|
328
|
+
export interface SummaryEdgeRow {
|
|
329
|
+
related_path: string;
|
|
330
|
+
shared_tags: string;
|
|
331
|
+
}
|
|
332
|
+
/** An unprocessed conversation to extract facts from (observe step). [U3f] */
|
|
333
|
+
export interface UnprocessedConversationRow {
|
|
334
|
+
id: number;
|
|
335
|
+
source_path: string;
|
|
336
|
+
title: string;
|
|
337
|
+
summary: string;
|
|
338
|
+
timestamp: string;
|
|
339
|
+
entities_json: string | null;
|
|
340
|
+
topics_json: string | null;
|
|
341
|
+
}
|
|
342
|
+
/** Mention stats for the reasoning induction prompt. [U3f] */
|
|
343
|
+
export interface EntityStatsRow {
|
|
344
|
+
mention_count: number;
|
|
345
|
+
first_seen: string;
|
|
346
|
+
last_seen: string;
|
|
347
|
+
}
|
|
348
|
+
/** A co-occurring entity + relation strength (reasoning induction). [U3f] */
|
|
349
|
+
export interface EntityCooccurrenceRow {
|
|
350
|
+
name: string;
|
|
351
|
+
strength: number;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* SleepRepository — CRUD/persistence for the maintenance engine.
|
|
355
|
+
*
|
|
356
|
+
* The cohesive sleep store (decision 1): its impl opens whichever DB kinds a
|
|
357
|
+
* method needs (sleep.db for run-state/edges/queue/transitions, timeline.db for
|
|
358
|
+
* event reads/writes, entityGraph.db for the observe entity lookup). It carries
|
|
359
|
+
* NO business thresholds — those live in the brain-core steps (JS) or, where the
|
|
360
|
+
* heuristic is encoded in SQL, in SleepMaintenance. Cross-kind writes stay
|
|
361
|
+
* best-effort (separate files; no unit-of-work — decision 2).
|
|
362
|
+
*
|
|
363
|
+
* Grows green per sub-gate to match the frozen design in
|
|
364
|
+
* docs/specs/storage-untangle-0.6.0-progress.md (U3a infra ✓; U3b decay/tag;
|
|
365
|
+
* U3c tier/link; U3d consolidate; U3e entity-hygiene; U3f summarize/observe).
|
|
366
|
+
*/
|
|
367
|
+
export interface SleepRepository {
|
|
368
|
+
ensureSchema(t: TenantContext): Promise<void>;
|
|
369
|
+
/** id of an in-flight run (status='running'), or null. Concurrency guard. */
|
|
370
|
+
findRunningRun(t: TenantContext): Promise<number | null>;
|
|
371
|
+
/** INSERT a 'running' sleep_runs row; returns its id. */
|
|
372
|
+
startRun(t: TenantContext): Promise<number>;
|
|
373
|
+
completeRun(t: TenantContext, runId: number, metricsJson: string): Promise<void>;
|
|
374
|
+
failRun(t: TenantContext, runId: number, errorMessage: string): Promise<void>;
|
|
375
|
+
recordTelemetry(t: TenantContext, runId: number, step: string, eventType: string, count: number, durationMs: number, metadataJson: string): Promise<void>;
|
|
376
|
+
saveCheckpoint(t: TenantContext, runId: number, step: string, dataJson: string): Promise<void>;
|
|
377
|
+
getLastCheckpoint(t: TenantContext, runId: number): Promise<SleepCheckpointRow | null>;
|
|
378
|
+
/** Reap >2h-old 'running' rows to 'failed'; returns rows changed. */
|
|
379
|
+
recoverStaleRuns(t: TenantContext): Promise<number>;
|
|
380
|
+
/** memory_edges neighbours of a source path, by confidence DESC. [] if no table. */
|
|
381
|
+
getRelatedEdges(t: TenantContext, sourcePath: string, limit: number): Promise<MemoryEdgeHit[]>;
|
|
382
|
+
/** Non-archive events for the decay batch (priority DESC). */
|
|
383
|
+
fetchDecayCandidates(t: TenantContext, limit: number): Promise<DecayCandidateRow[]>;
|
|
384
|
+
/** Write a computed decay_score + priority for one event. */
|
|
385
|
+
updateEventDecay(t: TenantContext, itemId: number, decayScore: number, priority: number): Promise<void>;
|
|
386
|
+
/** Events with stale/missing tags (enriched before `staleDate`, priority DESC). */
|
|
387
|
+
fetchTagCandidates(t: TenantContext, staleDate: string, limit: number): Promise<TagCandidateRow[]>;
|
|
388
|
+
/** Write refreshed tags_json + bump last_enriched for one event. */
|
|
389
|
+
updateEventTags(t: TenantContext, itemId: number, tagsJson: string): Promise<void>;
|
|
390
|
+
/** Edge count + summed confidence touching a path (tier relationship score, link cap). */
|
|
391
|
+
getEdgeStats(t: TenantContext, sourcePath: string): Promise<SleepEdgeStats>;
|
|
392
|
+
/** Does an edge already connect these two paths (either direction)? */
|
|
393
|
+
edgeExists(t: TenantContext, pathA: string, pathB: string): Promise<boolean>;
|
|
394
|
+
insertMemoryEdge(t: TenantContext, edge: MemoryEdgeInput): Promise<void>;
|
|
395
|
+
/** Edges of a given relation (e.g. 'related') for the retype pass. */
|
|
396
|
+
listEdgesByRelation(t: TenantContext, relation: string, limit: number): Promise<MemoryEdgeRef[]>;
|
|
397
|
+
updateEdgeRelation(t: TenantContext, edgeId: number, relation: string): Promise<void>;
|
|
398
|
+
/** Upsert a 'resummarize' maintenance_queue entry for an event. */
|
|
399
|
+
enqueueResummarize(t: TenantContext, itemId: number, priority: number): Promise<void>;
|
|
400
|
+
/** Append a tier_transitions audit row (best-effort; impl swallows errors). */
|
|
401
|
+
recordTierTransition(t: TenantContext, itemId: number, fromTier: string | null, toTier: string, reason: string): Promise<void>;
|
|
402
|
+
/** timeline_events batch for tier evaluation. */
|
|
403
|
+
fetchTierCandidates(t: TenantContext, limit: number): Promise<TierCandidateRow[]>;
|
|
404
|
+
/** Write a new tier for one event. */
|
|
405
|
+
updateEventTier(t: TenantContext, itemId: number, tier: string): Promise<void>;
|
|
406
|
+
/** timeline_events with tags/topics, for link candidate building (priority DESC). */
|
|
407
|
+
fetchLinkCandidates(t: TenantContext, limit: number): Promise<LinkCandidateRow[]>;
|
|
408
|
+
/** Pending 'resummarize' queue items (priority DESC). */
|
|
409
|
+
fetchResummarizeQueue(t: TenantContext, limit: number): Promise<ResummarizeQueueItem[]>;
|
|
410
|
+
/** Mark a queue item processed. */
|
|
411
|
+
markQueueProcessed(t: TenantContext, queueId: number): Promise<void>;
|
|
412
|
+
/** Mark a queue item processed with an error message. */
|
|
413
|
+
markQueueError(t: TenantContext, queueId: number, error: string): Promise<void>;
|
|
414
|
+
/** One event's columns for summarization, or null. */
|
|
415
|
+
getEventForSummary(t: TenantContext, itemId: number): Promise<SummaryEventRow | null>;
|
|
416
|
+
/** Write a refreshed summary + bump last_enriched. */
|
|
417
|
+
updateEventSummary(t: TenantContext, itemId: number, summary: string): Promise<void>;
|
|
418
|
+
/** Up-to-`limit` related neighbours (unordered) for the summarize context block. */
|
|
419
|
+
getSummaryEdges(t: TenantContext, sourcePath: string, limit: number): Promise<SummaryEdgeRow[]>;
|
|
420
|
+
/** Exact-name → entity id (observe contradiction recording). null if none. */
|
|
421
|
+
findEntityIdByName(t: TenantContext, nameLower: string): Promise<number | null>;
|
|
422
|
+
/** Mention stats for one entity (reasoning induction prompt), or null. */
|
|
423
|
+
fetchEntityStats(t: TenantContext, entityId: number): Promise<EntityStatsRow | null>;
|
|
424
|
+
}
|
|
425
|
+
export interface VectorRepository {
|
|
426
|
+
/** Can the vector backend be opened for this tenant? (loads sqlite-vec) */
|
|
427
|
+
available(t: TenantContext): Promise<boolean>;
|
|
428
|
+
hasOrigin(t: TenantContext, originId: string): Promise<boolean>;
|
|
429
|
+
insertChunk(t: TenantContext, chunk: VectorChunkInput): Promise<number>;
|
|
430
|
+
search(t: TenantContext, embedding: number[], limit: number): Promise<VectorSearchRow[]>;
|
|
431
|
+
stats(t: TenantContext): Promise<{
|
|
432
|
+
count: number;
|
|
433
|
+
available: boolean;
|
|
434
|
+
}>;
|
|
435
|
+
}
|
|
436
|
+
/** A timeline event row in the minimal shape hybrid-search's channels consume. */
|
|
437
|
+
export interface SearchEventRow {
|
|
438
|
+
id: number;
|
|
439
|
+
title: string;
|
|
440
|
+
summary: string;
|
|
441
|
+
source_path: string;
|
|
442
|
+
timestamp: string;
|
|
443
|
+
type: string;
|
|
444
|
+
}
|
|
445
|
+
/** FTS candidate row carrying the columns post-fetch metadata scoring needs. */
|
|
446
|
+
export interface MetadataCandidateRow {
|
|
447
|
+
id: number;
|
|
448
|
+
source_path: string;
|
|
449
|
+
title: string;
|
|
450
|
+
summary: string;
|
|
451
|
+
type: string;
|
|
452
|
+
timestamp: string;
|
|
453
|
+
tier: string | null;
|
|
454
|
+
priority: number | null;
|
|
455
|
+
tags_json: string | null;
|
|
456
|
+
}
|
|
457
|
+
/** Score-factor columns for one source_path (hybrid-search enrichment pass). */
|
|
458
|
+
export interface SearchEnrichRow {
|
|
459
|
+
tier: string | null;
|
|
460
|
+
priority: number | null;
|
|
461
|
+
tags_json: string | null;
|
|
462
|
+
entities_json: string | null;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Hybrid-search candidate/factor SQL (read-only). The SCORING stays in
|
|
466
|
+
* brain-core (RRF fusion, metadata weights, tier boosts, segment dedup) — these
|
|
467
|
+
* methods only fetch candidates and the columns scoring needs. SQL relocated
|
|
468
|
+
* verbatim from brain-core/hybrid-search.ts at gate U1; behaviour held constant.
|
|
469
|
+
*/
|
|
470
|
+
export interface SearchQueries {
|
|
471
|
+
/** Temporal channel: events whose title/summary LIKE `%term%` (case-insensitive), newest first. */
|
|
472
|
+
temporalCandidates(t: TenantContext, term: string, limit: number): Promise<SearchEventRow[]>;
|
|
473
|
+
/** Keyword channel: FTS5 MATCH candidates (sanitizes the query internally; [] if it sanitizes empty). */
|
|
474
|
+
metadataCandidates(t: TenantContext, query: string, limit: number): Promise<MetadataCandidateRow[]>;
|
|
475
|
+
/** Entity channel (expandQuery): events mentioned by entities named in the query. Cross-kind (entity+timeline). */
|
|
476
|
+
entityAugmentedCandidates(t: TenantContext, query: string): Promise<SearchEventRow[]>;
|
|
477
|
+
/** Enrichment: score-factor columns for a source_path, or null if absent. */
|
|
478
|
+
enrichByPath(t: TenantContext, sourcePath: string): Promise<SearchEnrichRow | null>;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* A fact row in the shape fact-retrieval's scoring consumes. `source_conversation_id`
|
|
482
|
+
* is absent on bridge candidates (that query doesn't select it).
|
|
483
|
+
*/
|
|
484
|
+
export interface RetrievalFactRow {
|
|
485
|
+
id: number;
|
|
486
|
+
content: string;
|
|
487
|
+
category: string;
|
|
488
|
+
confidence: number;
|
|
489
|
+
timestamp: string;
|
|
490
|
+
entities_json: string;
|
|
491
|
+
source_conversation_id?: string | null;
|
|
492
|
+
}
|
|
493
|
+
/** One supporting-context segment (Layer 3). */
|
|
494
|
+
export interface SupportingSegmentRow {
|
|
495
|
+
source_path: string;
|
|
496
|
+
summary: string;
|
|
497
|
+
timestamp: string;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* 4-layer fact-retrieval candidate SQL (read-only). The SCORING stays in
|
|
501
|
+
* brain-core: hop-distance penalty LUT {0:1.0,1:0.7,2:0.5,3:0.3}, scene ×0.6,
|
|
502
|
+
* bridge `1.05 + min(setsConnected-2,5)*0.03`, source-priority tie-break, the
|
|
503
|
+
* word-overlap dedup and token-budget assembly. These methods only fetch
|
|
504
|
+
* candidates and the columns scoring needs. SQL relocated verbatim from
|
|
505
|
+
* brain-core/fact-retrieval.ts at gate U2; behaviour held constant.
|
|
506
|
+
*
|
|
507
|
+
* `traverseEntityGraph` INVERTS the old handle-passing (it used to take a raw
|
|
508
|
+
* `Database`): the BFS over entity_relations runs inside the impl and returns
|
|
509
|
+
* `{id, hopDistance}` so the penalty LUT applies in brain-core.
|
|
510
|
+
*/
|
|
511
|
+
export interface FactRetrievalQueries {
|
|
512
|
+
/** Layer 1: facts FTS5 MATCH (caller passes the already-sanitized query), latest+unexpired only. */
|
|
513
|
+
searchFactsByFts(t: TenantContext, ftsQuery: string, limit: number): Promise<RetrievalFactRow[]>;
|
|
514
|
+
/** Layer 2: BFS over entity_relations from the seeds; returns each reached entity id + its hop distance. */
|
|
515
|
+
traverseEntityGraph(t: TenantContext, seedIds: number[], maxHops: number, maxEntities: number): Promise<Array<{
|
|
516
|
+
id: number;
|
|
517
|
+
hopDistance: number;
|
|
518
|
+
}>>;
|
|
519
|
+
/** The source_conversation_id of a fact, or null. */
|
|
520
|
+
getFactConversationId(t: TenantContext, factId: number): Promise<string | null>;
|
|
521
|
+
/** Layer 2.5 scene: latest+unexpired facts in the same conversation, nearest by id, excluding `excludeFactId`. */
|
|
522
|
+
nearbyFactsInConversation(t: TenantContext, conversationId: string, excludeFactId: number, limit: number): Promise<RetrievalFactRow[]>;
|
|
523
|
+
/** Layer 2.5 bridge: latest+unexpired fact candidates to test for cross-cluster entity overlap. */
|
|
524
|
+
listBridgeCandidates(t: TenantContext, limit: number): Promise<RetrievalFactRow[]>;
|
|
525
|
+
/** Layer 3: timeline segments under a conversation's source_path prefix, oldest first. */
|
|
526
|
+
findSupportingSegments(t: TenantContext, parentPath: string, limit: number): Promise<SupportingSegmentRow[]>;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* SleepMaintenance — the maintenance-engine policy that is encoded IN the SQL.
|
|
530
|
+
*
|
|
531
|
+
* Deliberately SMALL: most sleep "policy" (tier OR-thresholds, decay formula,
|
|
532
|
+
* Jaccard + confidence boosts, artifact/variant detection) is JS and stays in the
|
|
533
|
+
* brain-core steps. Only where the heuristic lives inside the statement itself — a
|
|
534
|
+
* normalization GROUP BY, a multi-clause prune WHERE, a policy-bearing UPDATE, an
|
|
535
|
+
* unprocessed-detection NOT EXISTS — does it relocate here VERBATIM (decision 3:
|
|
536
|
+
* keep SQL, assert parity, don't rewrite as JS).
|
|
537
|
+
*
|
|
538
|
+
* Cross-kind atomicity: tier/summarize write timeline.db AND sleep.db (separate
|
|
539
|
+
* files); best-effort is PRESERVED (decision 2 — no unit-of-work). Empty until
|
|
540
|
+
* U3b; grows green per sub-gate to the frozen design in
|
|
541
|
+
* docs/specs/storage-untangle-0.6.0-progress.md.
|
|
542
|
+
*/
|
|
543
|
+
export interface SleepMaintenance {
|
|
544
|
+
/** Mark expired temporal facts is_latest=0; returns rows changed. */
|
|
545
|
+
expireTemporalFacts(t: TenantContext): Promise<number>;
|
|
546
|
+
/** MAX(updated_at) over decayed facts — the weekly-decay gate. null if never. */
|
|
547
|
+
lastFactConfidenceDecayAt(t: TenantContext): Promise<string | null>;
|
|
548
|
+
/** Weekly confidence decay (×0.95 floor 0.15) for old ai-extraction/chat facts; rows changed. */
|
|
549
|
+
decayFactConfidence(t: TenantContext): Promise<number>;
|
|
550
|
+
/** Groups of duplicate normalized titles (≥ threshold), highest-count first. */
|
|
551
|
+
fetchConsolidationGroups(t: TenantContext, threshold: number, limit: number): Promise<ConsolidationGroup[]>;
|
|
552
|
+
/** Sum access_count over a set of event ids (pre-merge tally). */
|
|
553
|
+
sumAccessCounts(t: TenantContext, ids: number[]): Promise<number>;
|
|
554
|
+
/** Fold removeIds into keepId: add `addedAccess` to keep's access_count, delete the rest. */
|
|
555
|
+
consolidateInto(t: TenantContext, keepId: number, removeIds: number[], addedAccess: number): Promise<void>;
|
|
556
|
+
/** Phase 0: delete orphaned entity_relations + entity_mentions. */
|
|
557
|
+
cleanOrphans(t: TenantContext): Promise<void>;
|
|
558
|
+
/** Phase 1: every entity (artifact-pattern scan happens in JS). */
|
|
559
|
+
fetchAllEntities(t: TenantContext): Promise<HygieneEntityRow[]>;
|
|
560
|
+
/** Phase 2: GROUP BY normalized_name HAVING COUNT(DISTINCT type) > 1. */
|
|
561
|
+
fetchSameNameGroups(t: TenantContext): Promise<SameNameGroup[]>;
|
|
562
|
+
/** Phase 3: top entities by mention_count for JS variant detection. */
|
|
563
|
+
fetchVariantEntities(t: TenantContext, limit: number): Promise<VariantEntityRow[]>;
|
|
564
|
+
/** Mention contexts + related names for AI-assessment of one entity. */
|
|
565
|
+
fetchEntityProfile(t: TenantContext, entityId: number): Promise<HygieneEntityProfile>;
|
|
566
|
+
/** Phase 4: the 5-clause prune filter (Bug B11B — all filters, verbatim). */
|
|
567
|
+
fetchPruneCandidates(t: TenantContext, pruneDate: string): Promise<PruneCandidateRow[]>;
|
|
568
|
+
/** Phase 5: high-mention entities (>=3) for narrative-profile generation. */
|
|
569
|
+
fetchProfileCandidates(t: TenantContext, limit: number): Promise<Pick<HygieneEntityRow, 'id' | 'name' | 'type'>[]>;
|
|
570
|
+
/** Event ids whose summary is missing/short/raw/over-long and not enriched in 3 days. */
|
|
571
|
+
fetchStaleSummaryIds(t: TenantContext, limit: number): Promise<number[]>;
|
|
572
|
+
/** Conversations with no observation/fact/realtime children yet (NOT EXISTS detection). */
|
|
573
|
+
fetchUnprocessedConversations(t: TenantContext, limit: number): Promise<UnprocessedConversationRow[]>;
|
|
574
|
+
/** Co-occurring entities (strength > 1) for the reasoning induction prompt. */
|
|
575
|
+
fetchEntityCooccurrence(t: TenantContext, entityId: number, limit: number): Promise<EntityCooccurrenceRow[]>;
|
|
576
|
+
}
|
|
577
|
+
export interface StorageProvider {
|
|
578
|
+
/** Data plane — CRUD persistence primitives, one per DB kind. */
|
|
579
|
+
repositories: {
|
|
580
|
+
timeline: TimelineRepository;
|
|
581
|
+
entities: EntityRepository;
|
|
582
|
+
facts: FactRepository;
|
|
583
|
+
sleep: SleepRepository;
|
|
584
|
+
vectors: VectorRepository;
|
|
585
|
+
};
|
|
586
|
+
/** Business plane — DB-focused domain queries, organized by capability. */
|
|
587
|
+
domain: {
|
|
588
|
+
search: SearchQueries;
|
|
589
|
+
factRetrieval: FactRetrievalQueries;
|
|
590
|
+
sleep: SleepMaintenance;
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EACb,aAAa,EACb,aAAa,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAOzG,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAClC,SAAS,EAAE;QAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC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AAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IAGnH,yFAAyF;IACzF,oBAAoB,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACzE,2FAA2F;IAC3F,6BAA6B,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAAC;IACtG,+EAA+E;IAC/E,uBAAuB,CAAC,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAAC;CAC9G;AAOD,MAAM,WAAW,eAAe;IAC9B,iEAAiE;IACjE,YAAY,EAAE;QACZ,QAAQ,EAAE,kBAAkB,CAAC;QAC7B,QAAQ,EAAE,gBAAgB,CAAC;QAC3B,KAAK,EAAE,cAAc,CAAC;QACtB,KAAK,EAAE,eAAe,CAAC;QACvB,OAAO,EAAE,gBAAgB,CAAC;KAC3B,CAAC;IACF,2EAA2E;IAC3E,MAAM,EAAE;QACN,MAAM,EAAE,aAAa,CAAC;QACtB,aAAa,EAAE,oBAAoB,CAAC;QACpC,KAAK,EAAE,gBAAgB,CAAC;KACzB,CAAC;CACH"}
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage provider interfaces — the swappable seam (Stage 1).
|
|
3
|
+
*
|
|
4
|
+
* `brain-core` business logic depends ONLY on these interfaces, obtained via
|
|
5
|
+
* the `setStorageProvider`/`getStorage` seam in brain-core (which mirrors
|
|
6
|
+
* `setLLMProvider`). Each backend package (brain-storage-sqlite today; a
|
|
7
|
+
* libsql impl in Stage 3) implements them with its own dialect.
|
|
8
|
+
*
|
|
9
|
+
* DESIGN RULES (load-bearing — see docs/specs/storage-provider-di-spec.md):
|
|
10
|
+
* - Every method is async. Inserts return `Promise<number>` (the new id), so
|
|
11
|
+
* the impl owns `RETURNING` vs `lastInsertRowid` internally.
|
|
12
|
+
* - No method ever exposes a driver handle (`better-sqlite3.Database`, a libsql
|
|
13
|
+
* client, …). The seam speaks domain operations, never SQL.
|
|
14
|
+
* - Returned object fields are snake_case, matching the v0.2.0 realignment and
|
|
15
|
+
* guarded by schema-naming.test.ts.
|
|
16
|
+
* - The 3 within-kind transactions (mergeEntities, deleteEntity, the vector
|
|
17
|
+
* chunk insert) are IMPL-INTERNAL to their methods — no public transaction
|
|
18
|
+
* primitive is exposed in Stage 1 (decision ①: keep per-kind best-effort
|
|
19
|
+
* semantics; cross-kind unit-of-work is a reserved Stage-3 addition).
|
|
20
|
+
* - Param names stay camelCase at the input edge (unchanged public surface);
|
|
21
|
+
* only RETURNED fields are snake_case.
|
|
22
|
+
*
|
|
23
|
+
* NOTE: as of 0.6.0 (gate U0) the bundle has TWO planes — five CRUD
|
|
24
|
+
* `*Repository` interfaces under `.repositories` (frozen since 0.5.0) and three
|
|
25
|
+
* DB-focused domain interfaces under `.domain` (SearchQueries, FactRetrievalQueries,
|
|
26
|
+
* SleepMaintenance), declared now to freeze the shape and populated per gate
|
|
27
|
+
* (U1 search, U2 fact-retrieval, U3 sleep). See the BUSINESS PLANE section below
|
|
28
|
+
* and docs/specs/storage-untangle-0.6.0-kickoff.md.
|
|
29
|
+
*/
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG"}
|
package/package.json
CHANGED