@semiont/make-meaning 0.2.46 → 0.3.1
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/README.md +9 -9
- package/dist/index.d.ts +290 -32
- package/dist/index.js +1375 -224
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
This package implements the actor model from [ARCHITECTURE.md](../../docs/ARCHITECTURE.md). It owns the **Knowledge Base** and the actors that interface with it:
|
|
12
12
|
|
|
13
13
|
- **Stower** (write) — the single write gateway to the Knowledge Base
|
|
14
|
-
- **Gatherer** (read) — handles all browse reads, context assembly, and entity type listing
|
|
15
|
-
- **
|
|
14
|
+
- **Gatherer** (read) — handles all browse reads, context assembly (passage + graph neighborhood + optional inference summary), and entity type listing
|
|
15
|
+
- **Matcher** (search/link) — context-driven search with multi-source retrieval, composite structural scoring, optional LLM semantic scoring, and graph queries
|
|
16
16
|
- **CloneTokenManager** (yield) — manages clone token lifecycle for resource cloning
|
|
17
17
|
|
|
18
18
|
All actors subscribe to the EventBus via RxJS pipelines. They expose only `initialize()` and `stop()` — no public business methods. Callers communicate with actors by putting events on the bus.
|
|
@@ -39,7 +39,7 @@ const eventBus = new EventBus();
|
|
|
39
39
|
const makeMeaning = await startMakeMeaning(config, eventBus, logger);
|
|
40
40
|
|
|
41
41
|
// Access components
|
|
42
|
-
const { kb, jobQueue, stower, gatherer,
|
|
42
|
+
const { kb, jobQueue, stower, gatherer, matcher, cloneTokenManager } = makeMeaning;
|
|
43
43
|
|
|
44
44
|
// Graceful shutdown
|
|
45
45
|
await makeMeaning.stop();
|
|
@@ -49,7 +49,7 @@ This single call initializes:
|
|
|
49
49
|
- **KnowledgeBase** — groups EventStore, ViewStorage, RepresentationStore, GraphDatabase
|
|
50
50
|
- **Stower** — subscribes to write commands on EventBus
|
|
51
51
|
- **Gatherer** — subscribes to browse reads, gather context, and entity type listing on EventBus
|
|
52
|
-
- **
|
|
52
|
+
- **Matcher** — subscribes to search and referenced-by queries on EventBus
|
|
53
53
|
- **CloneTokenManager** — subscribes to clone token operations on EventBus
|
|
54
54
|
- **GraphDBConsumer** — event-to-graph synchronization (RxJS burst-buffered pipeline)
|
|
55
55
|
- **JobQueue** — background job processing queue + job status subscription
|
|
@@ -111,17 +111,17 @@ graph TB
|
|
|
111
111
|
|
|
112
112
|
BUS -->|"yield:create, mark:create,<br/>mark:delete, job:*"| STOWER["Stower<br/>(write)"]
|
|
113
113
|
BUS -->|"browse:*, gather:*,<br/>mark:entity-types-*"| GATHERER["Gatherer<br/>(read)"]
|
|
114
|
-
BUS -->|"bind:search-*,<br/>bind:referenced-by-*"|
|
|
114
|
+
BUS -->|"bind:search-*,<br/>bind:referenced-by-*"| MATCHER["Matcher<br/>(search/link)"]
|
|
115
115
|
BUS -->|"yield:clone-*"| CTM["CloneTokenManager<br/>(clone)"]
|
|
116
116
|
|
|
117
117
|
STOWER -->|persist| KB["Knowledge Base"]
|
|
118
118
|
GATHERER -->|query| KB
|
|
119
|
-
|
|
119
|
+
MATCHER -->|query| KB
|
|
120
120
|
CTM -->|query| KB
|
|
121
121
|
|
|
122
122
|
STOWER -->|"yield:created, mark:created"| BUS
|
|
123
123
|
GATHERER -->|"browse:*-result,<br/>gather:complete"| BUS
|
|
124
|
-
|
|
124
|
+
MATCHER -->|"bind:search-results,<br/>bind:referenced-by-result"| BUS
|
|
125
125
|
CTM -->|"yield:clone-token-generated,<br/>yield:clone-resource-result"| BUS
|
|
126
126
|
|
|
127
127
|
classDef bus fill:#e8a838,stroke:#b07818,stroke-width:3px,color:#000,font-weight:bold
|
|
@@ -130,7 +130,7 @@ graph TB
|
|
|
130
130
|
classDef caller fill:#4a90a4,stroke:#2c5f7a,stroke-width:2px,color:#fff
|
|
131
131
|
|
|
132
132
|
class BUS bus
|
|
133
|
-
class STOWER,GATHERER,
|
|
133
|
+
class STOWER,GATHERER,MATCHER,CTM actor
|
|
134
134
|
class KB kb
|
|
135
135
|
class Routes,Workers,EBC caller
|
|
136
136
|
```
|
|
@@ -181,7 +181,7 @@ The EventBus is created by the backend (or script) and passed into `startMakeMea
|
|
|
181
181
|
|
|
182
182
|
- `Stower` — Write gateway actor
|
|
183
183
|
- `Gatherer` — Read actor (browse reads, context assembly, entity type listing)
|
|
184
|
-
- `
|
|
184
|
+
- `Matcher` — Search/link actor (context-driven search, entity resolution, referenced-by queries)
|
|
185
185
|
- `CloneTokenManager` — Clone token lifecycle actor (yield domain)
|
|
186
186
|
|
|
187
187
|
### Operations
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import { JobQueue, ReferenceAnnotationWorker, GenerationWorker, HighlightAnnotationWorker, AssessmentAnnotationWorker, CommentAnnotationWorker, TagAnnotationWorker } from '@semiont/jobs';
|
|
2
2
|
import { EventStore, ViewStorage } from '@semiont/event-sourcing';
|
|
3
|
-
import {
|
|
3
|
+
import { FilesystemServiceConfig, GraphServiceConfig, InferenceServiceConfig, Logger, StoredEvent, ResourceId, EventBus, components, UserId, CreationMethod, AnnotationId, ResourceAnnotations, AnnotationCategory, GraphPath, GraphConnection } from '@semiont/core';
|
|
4
4
|
export { AssembledAnnotation, applyBodyOperations, assembleAnnotation } from '@semiont/core';
|
|
5
5
|
import { InferenceClient } from '@semiont/inference';
|
|
6
6
|
import { GraphDatabase } from '@semiont/graph';
|
|
7
7
|
import { RepresentationStore } from '@semiont/content';
|
|
8
|
+
import { Writable, Readable } from 'node:stream';
|
|
9
|
+
|
|
10
|
+
/** Narrow config type — only the fields make-meaning actually reads */
|
|
11
|
+
interface MakeMeaningConfig {
|
|
12
|
+
services: {
|
|
13
|
+
filesystem?: FilesystemServiceConfig;
|
|
14
|
+
graph?: GraphServiceConfig;
|
|
15
|
+
inference?: InferenceServiceConfig;
|
|
16
|
+
};
|
|
17
|
+
_metadata?: {
|
|
18
|
+
projectRoot: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
8
21
|
|
|
9
22
|
/**
|
|
10
23
|
* GraphDB Consumer
|
|
@@ -27,7 +40,6 @@ import { RepresentationStore } from '@semiont/content';
|
|
|
27
40
|
*/
|
|
28
41
|
|
|
29
42
|
declare class GraphDBConsumer {
|
|
30
|
-
private config;
|
|
31
43
|
private eventStore;
|
|
32
44
|
private graphDb;
|
|
33
45
|
private static readonly GRAPH_RELEVANT_EVENTS;
|
|
@@ -39,7 +51,7 @@ declare class GraphDBConsumer {
|
|
|
39
51
|
private pipelineSubscription;
|
|
40
52
|
private lastProcessed;
|
|
41
53
|
private readonly logger;
|
|
42
|
-
constructor(
|
|
54
|
+
constructor(eventStore: EventStore, graphDb: GraphDatabase, logger: Logger);
|
|
43
55
|
initialize(): Promise<void>;
|
|
44
56
|
/**
|
|
45
57
|
* Subscribe globally to ALL events, pre-filter to graph-relevant types,
|
|
@@ -110,7 +122,7 @@ declare class GraphDBConsumer {
|
|
|
110
122
|
* - Content Store (SHA-256 addressed, deduplicated) — via RepresentationStore
|
|
111
123
|
* - Graph (eventually consistent relationship projection) — via GraphDatabase
|
|
112
124
|
*
|
|
113
|
-
* The Gatherer and
|
|
125
|
+
* The Gatherer and Matcher are the only actors that read from these stores directly.
|
|
114
126
|
*/
|
|
115
127
|
|
|
116
128
|
interface KnowledgeBase {
|
|
@@ -148,14 +160,13 @@ declare function createKnowledgeBase(eventStore: EventStore, basePath: string, p
|
|
|
148
160
|
*/
|
|
149
161
|
|
|
150
162
|
declare class Gatherer {
|
|
151
|
-
private publicURL;
|
|
152
163
|
private kb;
|
|
153
164
|
private eventBus;
|
|
154
165
|
private inferenceClient;
|
|
155
166
|
private config?;
|
|
156
167
|
private subscriptions;
|
|
157
168
|
private readonly logger;
|
|
158
|
-
constructor(
|
|
169
|
+
constructor(kb: KnowledgeBase, eventBus: EventBus, inferenceClient: InferenceClient, logger: Logger, config?: MakeMeaningConfig | undefined);
|
|
159
170
|
initialize(): Promise<void>;
|
|
160
171
|
private handleAnnotationGather;
|
|
161
172
|
private handleResourceGather;
|
|
@@ -170,14 +181,14 @@ declare class Gatherer {
|
|
|
170
181
|
}
|
|
171
182
|
|
|
172
183
|
/**
|
|
173
|
-
*
|
|
184
|
+
* Matcher Actor
|
|
174
185
|
*
|
|
175
186
|
* Bridge between the event bus and the knowledge base for entity resolution.
|
|
176
187
|
* Subscribes to bind search events and referenced-by queries, queries KB stores
|
|
177
188
|
* (graph, views), and emits results back to the bus.
|
|
178
189
|
*
|
|
179
190
|
* From ARCHITECTURE.md:
|
|
180
|
-
* "When an Analyst or Linker Agent emits a bind event, the
|
|
191
|
+
* "When an Analyst or Linker Agent emits a bind event, the Matcher receives it
|
|
181
192
|
* from the bus, searches the KB stores for matching resources, and resolves
|
|
182
193
|
* references — linking a mention to its referent."
|
|
183
194
|
*
|
|
@@ -185,21 +196,46 @@ declare class Gatherer {
|
|
|
185
196
|
* - bind:search-requested — search for binding candidates
|
|
186
197
|
* - bind:referenced-by-requested — find annotations that reference a resource
|
|
187
198
|
*
|
|
188
|
-
* The
|
|
199
|
+
* The Matcher handles only the read side (searching for candidates).
|
|
189
200
|
* The write side (annotation.body.updated) stays in the route where
|
|
190
201
|
* userId is available from auth context. That domain event still flows
|
|
191
202
|
* through the bus via EventStore auto-publish.
|
|
192
203
|
*/
|
|
193
204
|
|
|
194
|
-
declare class
|
|
205
|
+
declare class Matcher {
|
|
195
206
|
private kb;
|
|
196
207
|
private eventBus;
|
|
197
|
-
private
|
|
208
|
+
private inferenceClient?;
|
|
198
209
|
private subscriptions;
|
|
199
210
|
private readonly logger;
|
|
200
|
-
constructor(kb: KnowledgeBase, eventBus: EventBus, logger: Logger,
|
|
211
|
+
constructor(kb: KnowledgeBase, eventBus: EventBus, logger: Logger, inferenceClient?: InferenceClient | undefined);
|
|
201
212
|
initialize(): Promise<void>;
|
|
202
213
|
private handleSearch;
|
|
214
|
+
/**
|
|
215
|
+
* Context-driven search: multi-source retrieval + composite scoring
|
|
216
|
+
*
|
|
217
|
+
* Retrieval sources:
|
|
218
|
+
* 1. Name match — graph.searchResources(searchTerm)
|
|
219
|
+
* 2. Entity type match — graph.listResources({ entityTypes })
|
|
220
|
+
* 3. Graph neighborhood — connections from GatheredContext
|
|
221
|
+
*
|
|
222
|
+
* Ranking signals:
|
|
223
|
+
* - Entity type overlap (Jaccard similarity)
|
|
224
|
+
* - Bidirectionality (already connected both ways)
|
|
225
|
+
* - Citation weight (well-connected = important)
|
|
226
|
+
* - Name match quality (exact > prefix > contains)
|
|
227
|
+
* - Recency (newer resources scored higher)
|
|
228
|
+
*/
|
|
229
|
+
private contextDrivenSearch;
|
|
230
|
+
/**
|
|
231
|
+
* LLM-based semantic relevance scoring (GraphRAG-style)
|
|
232
|
+
*
|
|
233
|
+
* Batches candidates into a single prompt asking the LLM to score
|
|
234
|
+
* each candidate's semantic relevance given the passage and graph context.
|
|
235
|
+
*
|
|
236
|
+
* @returns Map of resourceId → score (0-1)
|
|
237
|
+
*/
|
|
238
|
+
private inferenceSemanticScore;
|
|
203
239
|
private handleReferencedBy;
|
|
204
240
|
stop(): Promise<void>;
|
|
205
241
|
}
|
|
@@ -215,7 +251,7 @@ declare class Binder {
|
|
|
215
251
|
* The Knowledge Base has exactly three actor interfaces:
|
|
216
252
|
* - Stower (write) — this actor
|
|
217
253
|
* - Gatherer (read context)
|
|
218
|
-
* -
|
|
254
|
+
* - Matcher (read search)
|
|
219
255
|
*
|
|
220
256
|
* No other code should call eventStore.appendEvent() or repStore.store().
|
|
221
257
|
*
|
|
@@ -234,18 +270,17 @@ declare class Binder {
|
|
|
234
270
|
* - job:fail → job.failed
|
|
235
271
|
*/
|
|
236
272
|
|
|
237
|
-
type ResourceDescriptor$
|
|
273
|
+
type ResourceDescriptor$3 = components['schemas']['ResourceDescriptor'];
|
|
238
274
|
interface CreateResourceResult {
|
|
239
275
|
resourceId: ResourceId;
|
|
240
|
-
resource: ResourceDescriptor$
|
|
276
|
+
resource: ResourceDescriptor$3;
|
|
241
277
|
}
|
|
242
278
|
declare class Stower {
|
|
243
279
|
private kb;
|
|
244
|
-
private publicURL;
|
|
245
280
|
private eventBus;
|
|
246
281
|
private subscription;
|
|
247
282
|
private readonly logger;
|
|
248
|
-
constructor(kb: KnowledgeBase,
|
|
283
|
+
constructor(kb: KnowledgeBase, eventBus: EventBus, logger: Logger);
|
|
249
284
|
initialize(): Promise<void>;
|
|
250
285
|
private handleYieldCreate;
|
|
251
286
|
private handleMarkCreate;
|
|
@@ -320,11 +355,11 @@ interface MakeMeaningService {
|
|
|
320
355
|
graphConsumer: GraphDBConsumer;
|
|
321
356
|
stower: Stower;
|
|
322
357
|
gatherer: Gatherer;
|
|
323
|
-
|
|
358
|
+
matcher: Matcher;
|
|
324
359
|
cloneTokenManager: CloneTokenManager;
|
|
325
360
|
stop: () => Promise<void>;
|
|
326
361
|
}
|
|
327
|
-
declare function startMakeMeaning(config:
|
|
362
|
+
declare function startMakeMeaning(config: MakeMeaningConfig, eventBus: EventBus, logger: Logger): Promise<MakeMeaningService>;
|
|
328
363
|
|
|
329
364
|
/**
|
|
330
365
|
* Entity Types Bootstrap Service
|
|
@@ -338,7 +373,7 @@ declare function startMakeMeaning(config: EnvironmentConfig, eventBus: EventBus,
|
|
|
338
373
|
* Bootstrap entity types projection if it doesn't exist.
|
|
339
374
|
* Uses a system user ID (00000000-0000-0000-0000-000000000000) for bootstrap events.
|
|
340
375
|
*/
|
|
341
|
-
declare function bootstrapEntityTypes(eventBus: EventBus, config:
|
|
376
|
+
declare function bootstrapEntityTypes(eventBus: EventBus, config: MakeMeaningConfig, logger?: Logger): Promise<void>;
|
|
342
377
|
/**
|
|
343
378
|
* Reset the bootstrap flag (used for testing)
|
|
344
379
|
*/
|
|
@@ -354,7 +389,230 @@ declare function resetBootstrap(): void;
|
|
|
354
389
|
/**
|
|
355
390
|
* Read entity types from view storage projection
|
|
356
391
|
*/
|
|
357
|
-
declare function readEntityTypesProjection(config:
|
|
392
|
+
declare function readEntityTypesProjection(config: MakeMeaningConfig): Promise<string[]>;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Exchange Format Manifest Types
|
|
396
|
+
*
|
|
397
|
+
* Defines the metadata structures for backup archives.
|
|
398
|
+
* The manifest is the first entry in an archive and describes its contents.
|
|
399
|
+
*/
|
|
400
|
+
declare const BACKUP_FORMAT: "semiont-backup";
|
|
401
|
+
declare const FORMAT_VERSION = 1;
|
|
402
|
+
interface BackupManifestHeader {
|
|
403
|
+
format: typeof BACKUP_FORMAT;
|
|
404
|
+
version: number;
|
|
405
|
+
exportedAt: string;
|
|
406
|
+
sourceUrl: string;
|
|
407
|
+
stats: {
|
|
408
|
+
streams: number;
|
|
409
|
+
events: number;
|
|
410
|
+
blobs: number;
|
|
411
|
+
contentBytes: number;
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
interface BackupStreamSummary {
|
|
415
|
+
stream: string;
|
|
416
|
+
eventCount: number;
|
|
417
|
+
firstChecksum: string;
|
|
418
|
+
lastChecksum: string;
|
|
419
|
+
}
|
|
420
|
+
declare const LINKED_DATA_FORMAT: "semiont-linked-data";
|
|
421
|
+
interface LinkedDataManifest {
|
|
422
|
+
'@context': Record<string, string>;
|
|
423
|
+
'@type': string;
|
|
424
|
+
'semiont:format': typeof LINKED_DATA_FORMAT;
|
|
425
|
+
'semiont:version': number;
|
|
426
|
+
'dct:created': string;
|
|
427
|
+
'prov:wasGeneratedBy': {
|
|
428
|
+
'@type': string;
|
|
429
|
+
'prov:used': string;
|
|
430
|
+
};
|
|
431
|
+
'semiont:entityTypes': string[];
|
|
432
|
+
'void:entities': number;
|
|
433
|
+
}
|
|
434
|
+
declare function isBackupManifest(obj: unknown): obj is BackupManifestHeader;
|
|
435
|
+
declare function validateManifestVersion(version: number): void;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Backup Exporter
|
|
439
|
+
*
|
|
440
|
+
* Produces a lossless tar.gz archive of the system of record:
|
|
441
|
+
* - Event log (all streams, JSONL format)
|
|
442
|
+
* - Content store (content-addressed blobs)
|
|
443
|
+
*
|
|
444
|
+
* Reads events via EventStore and content via RepresentationStore.
|
|
445
|
+
* The archive can restore a complete knowledge base.
|
|
446
|
+
*/
|
|
447
|
+
|
|
448
|
+
/** Subset of EventStore used by the backup exporter. */
|
|
449
|
+
interface BackupEventStoreReader {
|
|
450
|
+
log: {
|
|
451
|
+
storage: {
|
|
452
|
+
getAllResourceIds(): Promise<ResourceId[]>;
|
|
453
|
+
};
|
|
454
|
+
getEvents(resourceId: ResourceId): Promise<StoredEvent[]>;
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
/** Subset of RepresentationStore used by the backup exporter. */
|
|
458
|
+
interface BackupContentReader {
|
|
459
|
+
retrieve(checksum: string, mediaType: string): Promise<Buffer>;
|
|
460
|
+
}
|
|
461
|
+
interface BackupExporterOptions {
|
|
462
|
+
eventStore: BackupEventStoreReader;
|
|
463
|
+
content: BackupContentReader;
|
|
464
|
+
sourceUrl: string;
|
|
465
|
+
logger?: Logger;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Export a full backup of the knowledge base to a tar.gz stream.
|
|
469
|
+
*
|
|
470
|
+
* Archive structure:
|
|
471
|
+
* .semiont/manifest.jsonl - Format metadata + per-stream checksums
|
|
472
|
+
* .semiont/events/__system__.jsonl - System events
|
|
473
|
+
* .semiont/events/{resourceId}.jsonl - Per-resource events
|
|
474
|
+
* {checksum}.{ext} - Content blobs (root level)
|
|
475
|
+
*/
|
|
476
|
+
declare function exportBackup(options: BackupExporterOptions, output: Writable): Promise<BackupManifestHeader>;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Event Replay
|
|
480
|
+
*
|
|
481
|
+
* Replays parsed JSONL event streams through the EventBus.
|
|
482
|
+
* Each domain event is translated to the corresponding command event
|
|
483
|
+
* (e.g. resource.created → yield:create), emitted, and the result
|
|
484
|
+
* event is awaited before proceeding (backpressure).
|
|
485
|
+
*
|
|
486
|
+
* Content blobs are resolved lazily via a lookup function so that
|
|
487
|
+
* the caller controls memory strategy (streaming, on-disk, etc.).
|
|
488
|
+
*/
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Resolves a content blob by its checksum.
|
|
492
|
+
* Returned by the caller so replay doesn't dictate memory strategy.
|
|
493
|
+
*/
|
|
494
|
+
type ContentBlobResolver = (checksum: string) => Buffer | undefined;
|
|
495
|
+
interface ReplayStats {
|
|
496
|
+
eventsReplayed: number;
|
|
497
|
+
resourcesCreated: number;
|
|
498
|
+
annotationsCreated: number;
|
|
499
|
+
entityTypesAdded: number;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Backup Importer
|
|
504
|
+
*
|
|
505
|
+
* Restores a knowledge base from a backup tar.gz archive.
|
|
506
|
+
* Replays events through the EventBus → Stower pipeline so all
|
|
507
|
+
* derived state (materialized views, graph) rebuilds naturally.
|
|
508
|
+
*
|
|
509
|
+
* Accepts a Readable stream so callers can pipe directly from disk
|
|
510
|
+
* or network without buffering the entire archive first.
|
|
511
|
+
* Content blobs are resolved lazily via a closure over the parsed
|
|
512
|
+
* tar entries, avoiding a separate copy of all blob data in memory.
|
|
513
|
+
*/
|
|
514
|
+
|
|
515
|
+
interface BackupImporterOptions {
|
|
516
|
+
eventBus: EventBus;
|
|
517
|
+
logger?: Logger;
|
|
518
|
+
}
|
|
519
|
+
interface BackupImportResult {
|
|
520
|
+
manifest: BackupManifestHeader;
|
|
521
|
+
stats: ReplayStats;
|
|
522
|
+
hashChainValid: boolean;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Import a backup archive by replaying events through the EventBus.
|
|
526
|
+
*
|
|
527
|
+
* Flow:
|
|
528
|
+
* 1. Stream and decompress tar.gz entries
|
|
529
|
+
* 2. Parse .semiont/manifest.jsonl → validate format
|
|
530
|
+
* 3. Build blob resolver over root-level content entries
|
|
531
|
+
* 4. Replay .semiont/events/__system__.jsonl (entity types)
|
|
532
|
+
* 5. Replay each .semiont/events/{resourceId}.jsonl (resources, annotations)
|
|
533
|
+
*
|
|
534
|
+
* Events flow: importer → EventBus → Stower → EventStore + Views
|
|
535
|
+
*/
|
|
536
|
+
declare function importBackup(archive: Readable, options: BackupImporterOptions): Promise<BackupImportResult>;
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Linked Data Exporter
|
|
540
|
+
*
|
|
541
|
+
* Produces a JSON-LD tar.gz archive from the current state of the knowledge base.
|
|
542
|
+
* Reads materialized views (not the event log) for a fast, current-state export.
|
|
543
|
+
*
|
|
544
|
+
* Archive structure:
|
|
545
|
+
* .semiont/manifest.jsonld - JSON-LD manifest with format metadata
|
|
546
|
+
* .semiont/resources/{resourceId}.jsonld - One JSON-LD document per resource
|
|
547
|
+
* {checksum}.{ext} - Content blobs (root level)
|
|
548
|
+
*/
|
|
549
|
+
|
|
550
|
+
type ResourceDescriptor$2 = components['schemas']['ResourceDescriptor'];
|
|
551
|
+
type Annotation$3 = components['schemas']['Annotation'];
|
|
552
|
+
/** Subset of ViewStorage used by the linked-data exporter. */
|
|
553
|
+
interface LinkedDataViewReader {
|
|
554
|
+
getAll(): Promise<Array<{
|
|
555
|
+
resource: ResourceDescriptor$2;
|
|
556
|
+
annotations: {
|
|
557
|
+
annotations: Annotation$3[];
|
|
558
|
+
};
|
|
559
|
+
}>>;
|
|
560
|
+
}
|
|
561
|
+
/** Subset of RepresentationStore used by the linked-data exporter. */
|
|
562
|
+
interface LinkedDataContentReader {
|
|
563
|
+
retrieve(checksum: string, mediaType: string): Promise<Buffer>;
|
|
564
|
+
}
|
|
565
|
+
interface LinkedDataExporterOptions {
|
|
566
|
+
views: LinkedDataViewReader;
|
|
567
|
+
content: LinkedDataContentReader;
|
|
568
|
+
sourceUrl: string;
|
|
569
|
+
entityTypes: string[];
|
|
570
|
+
includeArchived?: boolean;
|
|
571
|
+
logger?: Logger;
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Export the knowledge base as a JSON-LD tar.gz archive.
|
|
575
|
+
*/
|
|
576
|
+
declare function exportLinkedData(options: LinkedDataExporterOptions, output: Writable): Promise<LinkedDataManifest>;
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Linked Data Importer
|
|
580
|
+
*
|
|
581
|
+
* Creates resources from a JSON-LD tar.gz archive exported by the linked-data exporter.
|
|
582
|
+
* Unlike the backup importer, this is lossy — new resources are created (new IDs),
|
|
583
|
+
* no event history is preserved. Entity types are restored from the manifest.
|
|
584
|
+
*
|
|
585
|
+
* Parses .semiont/manifest.jsonld for format validation and entity types,
|
|
586
|
+
* then processes each .semiont/resources/{resourceId}.jsonld to create
|
|
587
|
+
* resources and annotations via the EventBus → Stower pipeline.
|
|
588
|
+
*/
|
|
589
|
+
|
|
590
|
+
interface LinkedDataImporterOptions {
|
|
591
|
+
eventBus: EventBus;
|
|
592
|
+
userId: UserId;
|
|
593
|
+
logger?: Logger;
|
|
594
|
+
}
|
|
595
|
+
interface LinkedDataImportResult {
|
|
596
|
+
manifest: LinkedDataManifest;
|
|
597
|
+
resourcesCreated: number;
|
|
598
|
+
annotationsCreated: number;
|
|
599
|
+
entityTypesAdded: number;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Import a JSON-LD archive by creating resources through the EventBus.
|
|
603
|
+
*
|
|
604
|
+
* Flow:
|
|
605
|
+
* 1. Stream and decompress tar.gz entries
|
|
606
|
+
* 2. Parse .semiont/manifest.jsonld → validate format
|
|
607
|
+
* 3. Build blob resolver over root-level content entries
|
|
608
|
+
* 4. Add entity types from manifest via mark:add-entity-type
|
|
609
|
+
* 5. For each .semiont/resources/{id}.jsonld:
|
|
610
|
+
* a. Parse JSON-LD document
|
|
611
|
+
* b. Resolve content blob by checksum from representations
|
|
612
|
+
* c. Emit yield:create → await yield:created
|
|
613
|
+
* d. For each annotation: emit mark:create → await mark:created
|
|
614
|
+
*/
|
|
615
|
+
declare function importLinkedData(archive: Readable, options: LinkedDataImporterOptions): Promise<LinkedDataImportResult>;
|
|
358
616
|
|
|
359
617
|
/**
|
|
360
618
|
* Resource Operations
|
|
@@ -420,7 +678,7 @@ declare class AnnotationOperations {
|
|
|
420
678
|
/**
|
|
421
679
|
* Create a new annotation via EventBus → Stower
|
|
422
680
|
*/
|
|
423
|
-
static createAnnotation(request: CreateAnnotationRequest, userId: UserId, creator: Agent, eventBus: EventBus
|
|
681
|
+
static createAnnotation(request: CreateAnnotationRequest, userId: UserId, creator: Agent, eventBus: EventBus): Promise<CreateAnnotationResult>;
|
|
424
682
|
/**
|
|
425
683
|
* Update annotation body via EventBus → Stower
|
|
426
684
|
*/
|
|
@@ -428,7 +686,7 @@ declare class AnnotationOperations {
|
|
|
428
686
|
/**
|
|
429
687
|
* Delete an annotation via EventBus → Stower
|
|
430
688
|
*/
|
|
431
|
-
static deleteAnnotation(id: string,
|
|
689
|
+
static deleteAnnotation(id: string, resourceIdStr: string, userId: UserId, eventBus: EventBus, kb: KnowledgeBase, logger?: Logger): Promise<void>;
|
|
432
690
|
}
|
|
433
691
|
|
|
434
692
|
/**
|
|
@@ -490,7 +748,7 @@ declare class AnnotationContext {
|
|
|
490
748
|
/**
|
|
491
749
|
* Build LLM context for an annotation
|
|
492
750
|
*
|
|
493
|
-
* @param
|
|
751
|
+
* @param annotationId - Bare annotation ID
|
|
494
752
|
* @param resourceId - Source resource ID
|
|
495
753
|
* @param kb - Knowledge base stores
|
|
496
754
|
* @param options - Context building options
|
|
@@ -498,7 +756,7 @@ declare class AnnotationContext {
|
|
|
498
756
|
* @returns Rich context for LLM processing
|
|
499
757
|
* @throws Error if annotation or resource not found
|
|
500
758
|
*/
|
|
501
|
-
static buildLLMContext(
|
|
759
|
+
static buildLLMContext(annotationId: AnnotationId, resourceId: ResourceId, kb: KnowledgeBase, options?: BuildContextOptions, inferenceClient?: InferenceClient, logger?: Logger): Promise<AnnotationLLMContextResponse>;
|
|
502
760
|
/**
|
|
503
761
|
* Get resource annotations from view storage (fast path)
|
|
504
762
|
* Throws if view missing
|
|
@@ -597,7 +855,7 @@ declare class GraphContext {
|
|
|
597
855
|
* Get all resources referencing this resource (backlinks)
|
|
598
856
|
* Requires graph traversal - must use graph database
|
|
599
857
|
*/
|
|
600
|
-
static getBacklinks(resourceId: ResourceId, kb: KnowledgeBase
|
|
858
|
+
static getBacklinks(resourceId: ResourceId, kb: KnowledgeBase): Promise<Annotation[]>;
|
|
601
859
|
/**
|
|
602
860
|
* Find shortest path between two resources
|
|
603
861
|
* Requires graph traversal - must use graph database
|
|
@@ -617,7 +875,7 @@ declare class GraphContext {
|
|
|
617
875
|
* Build graph representation with nodes and edges for a resource and its connections
|
|
618
876
|
* Retrieves connections from graph and builds visualization-ready structure
|
|
619
877
|
*/
|
|
620
|
-
static buildGraphRepresentation(resourceId: ResourceId, maxRelated: number, kb: KnowledgeBase
|
|
878
|
+
static buildGraphRepresentation(resourceId: ResourceId, maxRelated: number, kb: KnowledgeBase): Promise<GraphRepresentation>;
|
|
621
879
|
}
|
|
622
880
|
|
|
623
881
|
/**
|
|
@@ -639,18 +897,18 @@ declare class LLMContext {
|
|
|
639
897
|
* Get comprehensive LLM context for a resource
|
|
640
898
|
* Includes: main resource, related resources, annotations, graph, content, summary, references
|
|
641
899
|
*/
|
|
642
|
-
static getResourceContext(resourceId: ResourceId, options: LLMContextOptions, kb: KnowledgeBase,
|
|
900
|
+
static getResourceContext(resourceId: ResourceId, options: LLMContextOptions, kb: KnowledgeBase, inferenceClient: InferenceClient): Promise<ResourceLLMContextResponse>;
|
|
643
901
|
}
|
|
644
902
|
|
|
645
903
|
/**
|
|
646
904
|
* Resource Generation Functions
|
|
647
905
|
*
|
|
648
|
-
* Application-specific resource generation logic
|
|
649
|
-
* - Markdown resource generation from topics
|
|
906
|
+
* Application-specific resource generation logic:
|
|
650
907
|
* - Resource summary generation
|
|
651
908
|
* - Reference suggestion generation
|
|
652
|
-
* - Language handling and template processing
|
|
653
909
|
*
|
|
910
|
+
* NOTE: generateResourceFromTopic lives in @semiont/jobs (canonical location)
|
|
911
|
+
* because make-meaning depends on jobs, not vice versa.
|
|
654
912
|
*/
|
|
655
913
|
|
|
656
914
|
/**
|
|
@@ -665,4 +923,4 @@ declare function generateReferenceSuggestions(referenceTitle: string, client: In
|
|
|
665
923
|
declare const PACKAGE_NAME = "@semiont/make-meaning";
|
|
666
924
|
declare const VERSION = "0.1.0";
|
|
667
925
|
|
|
668
|
-
export { AnnotationContext, AnnotationOperations,
|
|
926
|
+
export { AnnotationContext, AnnotationOperations, BACKUP_FORMAT, type BackupContentReader, type BackupEventStoreReader, type BackupExporterOptions, type BackupImportResult, type BackupImporterOptions, type BackupManifestHeader, type BackupStreamSummary, type BuildContextOptions, CloneTokenManager, type ContentBlobResolver, type CreateAnnotationResult, type CreateResourceInput, type CreateResourceResult, FORMAT_VERSION, Gatherer, GraphContext, GraphDBConsumer, type GraphEdge, type GraphNode, type GraphRepresentation, type KnowledgeBase, LLMContext, type LLMContextOptions, type LinkedDataContentReader, type LinkedDataExporterOptions, type LinkedDataImportResult, type LinkedDataImporterOptions, type LinkedDataViewReader, type ListResourcesFilters, type MakeMeaningConfig, type MakeMeaningService, Matcher, PACKAGE_NAME, type ReplayStats, ResourceContext, ResourceOperations, Stower, type UpdateAnnotationBodyResult, type UpdateResourceInput, VERSION, bootstrapEntityTypes, createKnowledgeBase, exportBackup, exportLinkedData, generateReferenceSuggestions, generateResourceSummary, importBackup, importLinkedData, isBackupManifest, readEntityTypesProjection, resetBootstrap, startMakeMeaning, validateManifestVersion };
|