@semiont/make-meaning 0.3.0 → 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 CHANGED
@@ -12,7 +12,7 @@ This package implements the actor model from [ARCHITECTURE.md](../../docs/ARCHIT
12
12
 
13
13
  - **Stower** (write) — the single write gateway to the Knowledge Base
14
14
  - **Gatherer** (read) — handles all browse reads, context assembly (passage + graph neighborhood + optional inference summary), and entity type listing
15
- - **Binder** (search/link) — context-driven search with multi-source retrieval, composite structural scoring, optional LLM semantic scoring, and graph queries
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, binder, cloneTokenManager } = makeMeaning;
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
- - **Binder** — subscribes to search and referenced-by queries on EventBus
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-*"| BINDER["Binder<br/>(search/link)"]
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
- BINDER -->|query| KB
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
- BINDER -->|"bind:search-results,<br/>bind:referenced-by-result"| BUS
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,BINDER,CTM actor
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
- - `Binder` — Search/link actor (context-driven search, entity resolution, referenced-by queries)
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
@@ -122,7 +122,7 @@ declare class GraphDBConsumer {
122
122
  * - Content Store (SHA-256 addressed, deduplicated) — via RepresentationStore
123
123
  * - Graph (eventually consistent relationship projection) — via GraphDatabase
124
124
  *
125
- * The Gatherer and Binder are the only actors that read from these stores directly.
125
+ * The Gatherer and Matcher are the only actors that read from these stores directly.
126
126
  */
127
127
 
128
128
  interface KnowledgeBase {
@@ -181,14 +181,14 @@ declare class Gatherer {
181
181
  }
182
182
 
183
183
  /**
184
- * Binder Actor
184
+ * Matcher Actor
185
185
  *
186
186
  * Bridge between the event bus and the knowledge base for entity resolution.
187
187
  * Subscribes to bind search events and referenced-by queries, queries KB stores
188
188
  * (graph, views), and emits results back to the bus.
189
189
  *
190
190
  * From ARCHITECTURE.md:
191
- * "When an Analyst or Linker Agent emits a bind event, the Binder receives it
191
+ * "When an Analyst or Linker Agent emits a bind event, the Matcher receives it
192
192
  * from the bus, searches the KB stores for matching resources, and resolves
193
193
  * references — linking a mention to its referent."
194
194
  *
@@ -196,13 +196,13 @@ declare class Gatherer {
196
196
  * - bind:search-requested — search for binding candidates
197
197
  * - bind:referenced-by-requested — find annotations that reference a resource
198
198
  *
199
- * The Binder handles only the read side (searching for candidates).
199
+ * The Matcher handles only the read side (searching for candidates).
200
200
  * The write side (annotation.body.updated) stays in the route where
201
201
  * userId is available from auth context. That domain event still flows
202
202
  * through the bus via EventStore auto-publish.
203
203
  */
204
204
 
205
- declare class Binder {
205
+ declare class Matcher {
206
206
  private kb;
207
207
  private eventBus;
208
208
  private inferenceClient?;
@@ -251,7 +251,7 @@ declare class Binder {
251
251
  * The Knowledge Base has exactly three actor interfaces:
252
252
  * - Stower (write) — this actor
253
253
  * - Gatherer (read context)
254
- * - Binder (read search)
254
+ * - Matcher (read search)
255
255
  *
256
256
  * No other code should call eventStore.appendEvent() or repStore.store().
257
257
  *
@@ -355,7 +355,7 @@ interface MakeMeaningService {
355
355
  graphConsumer: GraphDBConsumer;
356
356
  stower: Stower;
357
357
  gatherer: Gatherer;
358
- binder: Binder;
358
+ matcher: Matcher;
359
359
  cloneTokenManager: CloneTokenManager;
360
360
  stop: () => Promise<void>;
361
361
  }
@@ -923,4 +923,4 @@ declare function generateReferenceSuggestions(referenceTitle: string, client: In
923
923
  declare const PACKAGE_NAME = "@semiont/make-meaning";
924
924
  declare const VERSION = "0.1.0";
925
925
 
926
- export { AnnotationContext, AnnotationOperations, BACKUP_FORMAT, type BackupContentReader, type BackupEventStoreReader, type BackupExporterOptions, type BackupImportResult, type BackupImporterOptions, type BackupManifestHeader, type BackupStreamSummary, Binder, 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, 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 };
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 };
package/dist/index.js CHANGED
@@ -10753,21 +10753,23 @@ Summary:`;
10753
10753
  citedByCount: citedByMap.size,
10754
10754
  siblingEntityTypes: siblingEntityTypes.size
10755
10755
  });
10756
- const generationContext = sourceContext ? {
10756
+ const generationContext = {
10757
10757
  annotation,
10758
10758
  sourceResource: sourceDoc,
10759
- sourceContext: {
10760
- before: sourceContext.before || "",
10761
- selected: sourceContext.selected,
10762
- after: sourceContext.after || ""
10763
- },
10764
10759
  metadata: {
10765
10760
  resourceType: "document",
10766
10761
  language: sourceDoc.language,
10767
10762
  entityTypes: annotationEntityTypes
10768
10763
  },
10769
10764
  graphContext
10770
- } : void 0;
10765
+ };
10766
+ if (sourceContext) {
10767
+ generationContext.sourceContext = {
10768
+ before: sourceContext.before || "",
10769
+ selected: sourceContext.selected,
10770
+ after: sourceContext.after || ""
10771
+ };
10772
+ }
10771
10773
  const response = {
10772
10774
  annotation,
10773
10775
  sourceResource: sourceDoc,
@@ -11541,12 +11543,12 @@ var Gatherer = class {
11541
11543
  }
11542
11544
  };
11543
11545
 
11544
- // src/binder.ts
11546
+ // src/matcher.ts
11545
11547
  var import_rxjs4 = __toESM(require_cjs(), 1);
11546
11548
  var import_operators4 = __toESM(require_operators(), 1);
11547
11549
  import { resourceId as resourceId2 } from "@semiont/core";
11548
11550
  import { getExactText, getResourceId as getResourceId4, getResourceEntityTypes as getResourceEntityTypes5, getTargetSource as getTargetSource2, getTargetSelector as getTargetSelector2 } from "@semiont/api-client";
11549
- var Binder = class {
11551
+ var Matcher = class {
11550
11552
  constructor(kb, eventBus, logger, inferenceClient) {
11551
11553
  this.kb = kb;
11552
11554
  this.eventBus = eventBus;
@@ -11556,8 +11558,8 @@ var Binder = class {
11556
11558
  subscriptions = [];
11557
11559
  logger;
11558
11560
  async initialize() {
11559
- this.logger.info("Binder actor initialized");
11560
- const errorHandler = (err) => this.logger.error("Binder pipeline error", { error: err });
11561
+ this.logger.info("Matcher actor initialized");
11562
+ const errorHandler = (err) => this.logger.error("Matcher pipeline error", { error: err });
11561
11563
  const search$ = this.eventBus.get("bind:search-requested").pipe(
11562
11564
  (0, import_operators4.concatMap)((event) => (0, import_rxjs4.from)(this.handleSearch(event)))
11563
11565
  );
@@ -11572,7 +11574,9 @@ var Binder = class {
11572
11574
  async handleSearch(event) {
11573
11575
  try {
11574
11576
  const context = event.context;
11575
- const searchTerm = context.sourceContext?.selected ?? "";
11577
+ const selectedText = context.sourceContext?.selected ?? "";
11578
+ const userHint = context.userHint ?? "";
11579
+ const searchTerm = [selectedText, userHint].filter(Boolean).join(" ");
11576
11580
  this.logger.debug("Searching for binding candidates", {
11577
11581
  referenceId: event.referenceId,
11578
11582
  searchTerm,
@@ -11756,7 +11760,7 @@ var Binder = class {
11756
11760
  */
11757
11761
  async inferenceSemanticScore(searchTerm, context, candidates) {
11758
11762
  if (!this.inferenceClient) return /* @__PURE__ */ new Map();
11759
- const passage = context.sourceContext?.selected ?? searchTerm;
11763
+ const passage = [context.sourceContext?.selected, context.userHint].filter(Boolean).join(" \u2014 ") || searchTerm;
11760
11764
  const entityTypes = context.metadata?.entityTypes ?? [];
11761
11765
  const graphConnections = context.graphContext?.connections;
11762
11766
  const connections = graphConnections ?? [];
@@ -11867,7 +11871,7 @@ No explanations.`;
11867
11871
  sub.unsubscribe();
11868
11872
  }
11869
11873
  this.subscriptions = [];
11870
- this.logger.info("Binder actor stopped");
11874
+ this.logger.info("Matcher actor stopped");
11871
11875
  }
11872
11876
  };
11873
11877
 
@@ -12470,9 +12474,9 @@ async function startMakeMeaning(config, eventBus, logger) {
12470
12474
  const gathererLogger = logger.child({ component: "gatherer" });
12471
12475
  const gatherer = new Gatherer(kb, eventBus, inferenceClient, gathererLogger, config);
12472
12476
  await gatherer.initialize();
12473
- const binderLogger = logger.child({ component: "binder" });
12474
- const binder = new Binder(kb, eventBus, binderLogger, inferenceClient);
12475
- await binder.initialize();
12477
+ const matcherLogger = logger.child({ component: "matcher" });
12478
+ const matcher = new Matcher(kb, eventBus, matcherLogger, inferenceClient);
12479
+ await matcher.initialize();
12476
12480
  const cloneTokenLogger = logger.child({ component: "clone-token-manager" });
12477
12481
  const cloneTokenManager = new CloneTokenManager(kb, eventBus, cloneTokenLogger);
12478
12482
  await cloneTokenManager.initialize();
@@ -12527,7 +12531,7 @@ async function startMakeMeaning(config, eventBus, logger) {
12527
12531
  graphConsumer,
12528
12532
  stower,
12529
12533
  gatherer,
12530
- binder,
12534
+ matcher,
12531
12535
  cloneTokenManager,
12532
12536
  stop: async () => {
12533
12537
  logger.info("Stopping Make-Meaning service");
@@ -12540,7 +12544,7 @@ async function startMakeMeaning(config, eventBus, logger) {
12540
12544
  workers.tag.stop()
12541
12545
  ]);
12542
12546
  await gatherer.stop();
12543
- await binder.stop();
12547
+ await matcher.stop();
12544
12548
  jobStatusSubscription.unsubscribe();
12545
12549
  await cloneTokenManager.stop();
12546
12550
  await stower.stop();
@@ -13479,13 +13483,13 @@ export {
13479
13483
  AnnotationContext,
13480
13484
  AnnotationOperations,
13481
13485
  BACKUP_FORMAT,
13482
- Binder,
13483
13486
  CloneTokenManager,
13484
13487
  FORMAT_VERSION,
13485
13488
  Gatherer,
13486
13489
  GraphContext,
13487
13490
  GraphDBConsumer,
13488
13491
  LLMContext,
13492
+ Matcher,
13489
13493
  PACKAGE_NAME,
13490
13494
  ResourceContext,
13491
13495
  ResourceOperations,