@semiont/make-meaning 0.5.29 → 0.5.31

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.
@@ -1,7 +1,7 @@
1
1
  import { createServer } from 'http';
2
2
  import { HttpTransport } from '@semiont/http-transport';
3
3
  import { archivistContentReads } from '@semiont/content';
4
- import { accessToken, EventBus, baseUrl as baseUrl$1, retryWithBackoff, isTransientFetchError, STARTUP_FETCH_RETRY, errField, deriveViews, resourceId, getResourceId, getResourceEntityTypes, annotationId, BUS_OPERATIONS, getTargetSource, getBodySource, getStorageUri, getPrimaryRepresentation, decodeRepresentation, getTargetSelector, getTextPositionSelector } from '@semiont/core';
4
+ import { replyChannelsFor, accessToken, EventBus, baseUrl as baseUrl$1, retryWithBackoff, isTransientFetchError, STARTUP_FETCH_RETRY, errField, deriveViews, resourceId, getResourceId, getResourceEntityTypes, annotationId, getTargetSource, getBodySource, getStorageUri, getPrimaryRepresentation, decodeRepresentation, getTargetSelector, getTextPositionSelector } from '@semiont/core';
5
5
  import { loadEnvironmentConfig, SemiontState } from '@semiont/core/node';
6
6
  import { FilesystemViewStorage } from '@semiont/event-sourcing';
7
7
  import { getGraphDatabase, compareByRecencyThenId } from '@semiont/graph';
@@ -11164,30 +11164,24 @@ var Gatherer = class {
11164
11164
  this.logger.info("Gatherer actor stopped");
11165
11165
  }
11166
11166
  };
11167
- function registerGatherSummaryHandler(eventBus, gatherer, parentLogger) {
11168
- const logger2 = parentLogger.child({ component: "annotation-lookups" });
11169
- eventBus.get("gather:summary-requested").subscribe(async (command) => {
11170
- const { correlationId } = command;
11171
- const annId = command.annotationId;
11172
- const resId = command.resourceId;
11173
- try {
11174
- const response = await gatherer.generateAnnotationSummary(
11175
- annotationId(annId),
11176
- resourceId(resId)
11177
- );
11178
- eventBus.get("gather:summary-result").next({
11179
- correlationId,
11180
- response
11181
- });
11182
- } catch (error) {
11183
- logger2.warn("gather:summary failed", { correlationId, error: error.message });
11184
- eventBus.get("gather:summary-failed").next({
11185
- correlationId,
11186
- message: error.message
11187
- });
11188
- }
11189
- });
11190
- }
11167
+ var STOWER_CHANNELS = [
11168
+ "yield:create",
11169
+ "yield:clone-persist",
11170
+ "yield:update",
11171
+ "yield:mv",
11172
+ "mark:create",
11173
+ "mark:commit",
11174
+ "mark:delete",
11175
+ "mark:update-body",
11176
+ "frame:add-entity-type",
11177
+ "frame:add-tag-schema",
11178
+ "mark:archive",
11179
+ "mark:unarchive",
11180
+ "mark:update-entity-types",
11181
+ "job:start",
11182
+ "job:complete",
11183
+ "job:fail"
11184
+ ];
11191
11185
 
11192
11186
  // src/config.ts
11193
11187
  function requireKBName(config2) {
@@ -11237,6 +11231,94 @@ function resolveActorInference(config2, actor) {
11237
11231
  );
11238
11232
  }
11239
11233
 
11234
+ // src/browser.ts
11235
+ var BROWSER_CHANNELS = [
11236
+ "browse:resource-requested",
11237
+ "browse:anchored-text-requested",
11238
+ "browse:resources-requested",
11239
+ "browse:annotations-requested",
11240
+ "browse:annotation-requested",
11241
+ "browse:events-requested",
11242
+ "browse:annotation-history-requested",
11243
+ "browse:referenced-by-requested",
11244
+ "browse:entity-types-requested",
11245
+ "browse:tag-schemas-requested",
11246
+ "browse:agents-requested",
11247
+ "browse:directory-requested"
11248
+ ];
11249
+
11250
+ // src/clone-token-manager.ts
11251
+ var CLONE_TOKEN_CHANNELS = [
11252
+ "yield:clone-token-requested",
11253
+ "yield:clone-resource-requested",
11254
+ "yield:clone-create"
11255
+ ];
11256
+
11257
+ // src/service-channels.ts
11258
+ var SMELTER_AWAITED_OPERATIONS = [
11259
+ "browse:resource-requested",
11260
+ "browse:annotations-requested",
11261
+ "browse:resources-requested"
11262
+ ];
11263
+ replyChannelsFor(SMELTER_AWAITED_OPERATIONS);
11264
+ var WEAVER_AWAITED_OPERATIONS = [
11265
+ "browse:resources-requested",
11266
+ "browse:events-requested",
11267
+ "browse:annotations-requested"
11268
+ ];
11269
+ replyChannelsFor(WEAVER_AWAITED_OPERATIONS);
11270
+ var LIBRARIAN_INBOUND_CHANNELS = [
11271
+ ...MATCHER_CHANNELS,
11272
+ ...GATHERER_CHANNELS,
11273
+ "gather:summary-requested",
11274
+ "weave:applied",
11275
+ "smelt:settled"
11276
+ ];
11277
+ var LIBRARIAN_OUTBOUND_CHANNELS = replyChannelsFor(LIBRARIAN_INBOUND_CHANNELS);
11278
+ var ARCHIVIST_INBOUND_CHANNELS = [
11279
+ ...STOWER_CHANNELS,
11280
+ ...BROWSER_CHANNELS,
11281
+ ...CLONE_TOKEN_CHANNELS,
11282
+ "mark:create-request",
11283
+ "smelt:settled",
11284
+ // The annotation-context read moved here with the bytes (SINGLE-KB-MOUNT D5).
11285
+ "browse:annotation-context-requested"
11286
+ ];
11287
+ var ARCHIVIST_OUTBOUND_STRAYS = [
11288
+ "mark:body-update-failed",
11289
+ // op keyed 'bind:update-body' (gateway handler re-emits mark:update-body)
11290
+ "yield:move-failed"
11291
+ // yield:mv has no registered operation; failure is direct-subscribed
11292
+ ];
11293
+ [
11294
+ ...ARCHIVIST_OUTBOUND_STRAYS,
11295
+ ...replyChannelsFor(ARCHIVIST_INBOUND_CHANNELS)
11296
+ ];
11297
+ function registerGatherSummaryHandler(eventBus, gatherer, parentLogger) {
11298
+ const logger2 = parentLogger.child({ component: "annotation-lookups" });
11299
+ eventBus.get("gather:summary-requested").subscribe(async (command) => {
11300
+ const { correlationId } = command;
11301
+ const annId = command.annotationId;
11302
+ const resId = command.resourceId;
11303
+ try {
11304
+ const response = await gatherer.generateAnnotationSummary(
11305
+ annotationId(annId),
11306
+ resourceId(resId)
11307
+ );
11308
+ eventBus.get("gather:summary-result").next({
11309
+ correlationId,
11310
+ response
11311
+ });
11312
+ } catch (error) {
11313
+ logger2.warn("gather:summary failed", { correlationId, error: error.message });
11314
+ eventBus.get("gather:summary-failed").next({
11315
+ correlationId,
11316
+ message: error.message
11317
+ });
11318
+ }
11319
+ });
11320
+ }
11321
+
11240
11322
  // src/service.ts
11241
11323
  function assertMakeMeaningConfig(config2) {
11242
11324
  if (!config2.services?.graph) {
@@ -11272,26 +11354,8 @@ if (config.services.vectors.type === "memory") {
11272
11354
  throw new Error("services.vectors.type 'memory' is a test-only sink; the Librarian requires a server-backed vector store");
11273
11355
  }
11274
11356
  var workerSecret = process.env.SEMIONT_WORKER_SECRET ?? "";
11275
- var healthPort = 9094;
11357
+ var healthPort = 24104;
11276
11358
  var logger = createProcessLogger("librarian");
11277
- var INBOUND_CHANNELS = [
11278
- ...MATCHER_CHANNELS,
11279
- ...GATHERER_CHANNELS,
11280
- "gather:summary-requested",
11281
- "weave:applied",
11282
- "smelt:settled"
11283
- ];
11284
- function outboundChannels() {
11285
- const out = /* @__PURE__ */ new Set();
11286
- for (const ch of INBOUND_CHANNELS) {
11287
- const op = BUS_OPERATIONS[ch];
11288
- if (!op) continue;
11289
- out.add(op.result);
11290
- out.add(op.failure);
11291
- if ("progress" in op && op.progress) out.add(op.progress);
11292
- }
11293
- return [...out];
11294
- }
11295
11359
  async function authenticate() {
11296
11360
  if (!workerSecret) {
11297
11361
  logger.warn("No SEMIONT_WORKER_SECRET set \u2014 using empty token");
@@ -11365,7 +11429,12 @@ async function main() {
11365
11429
  const httpTransport = new HttpTransport({
11366
11430
  baseUrl: baseUrl$1(baseUrl),
11367
11431
  token$: tokenSubject,
11368
- tokenRefresher: refreshToken
11432
+ tokenRefresher: refreshToken,
11433
+ // Exactly the inbound roster — never the full bridged set, whose global
11434
+ // reply fan-out is the worker-OOM failure mode. This process awaits no
11435
+ // wire replies (busRequest's isSubscribed gate fails fast if one is ever
11436
+ // added without growing the roster), so inbound IS the subscription.
11437
+ channels: LIBRARIAN_INBOUND_CHANNELS
11369
11438
  });
11370
11439
  const contentReads = archivistContentReads(config);
11371
11440
  const weaveProgress = createWeaveProgress(localBus);
@@ -11389,15 +11458,14 @@ async function main() {
11389
11458
  await gatherer.initialize();
11390
11459
  registerGatherSummaryHandler(localBus, gatherer, logger);
11391
11460
  const pumps = [];
11392
- httpTransport.actor.addChannels([...INBOUND_CHANNELS]);
11393
- for (const channel of INBOUND_CHANNELS) {
11461
+ for (const channel of LIBRARIAN_INBOUND_CHANNELS) {
11394
11462
  pumps.push(
11395
11463
  httpTransport.stream(channel).subscribe((payload) => {
11396
11464
  localBus.get(channel).next(payload);
11397
11465
  })
11398
11466
  );
11399
11467
  }
11400
- const outbound = outboundChannels();
11468
+ const outbound = LIBRARIAN_OUTBOUND_CHANNELS;
11401
11469
  for (const channel of outbound) {
11402
11470
  pumps.push(
11403
11471
  localBus.get(channel).subscribe((payload) => {
@@ -11410,7 +11478,7 @@ async function main() {
11410
11478
  })
11411
11479
  );
11412
11480
  }
11413
- logger.info("Bus pumps attached", { inbound: INBOUND_CHANNELS.length, outbound: outbound.length });
11481
+ logger.info("Bus pumps attached", { inbound: LIBRARIAN_INBOUND_CHANNELS.length, outbound: outbound.length });
11414
11482
  const server = createServer((req, res) => {
11415
11483
  if (req.url === "/health") {
11416
11484
  res.writeHead(200, { "Content-Type": "application/json" });
@@ -11439,7 +11507,7 @@ async function main() {
11439
11507
  };
11440
11508
  process.on("SIGTERM", shutdown);
11441
11509
  process.on("SIGINT", shutdown);
11442
- logger.info("Librarian serving", { channels: INBOUND_CHANNELS.length });
11510
+ logger.info("Librarian serving", { channels: LIBRARIAN_INBOUND_CHANNELS.length });
11443
11511
  }
11444
11512
  main().catch((error) => {
11445
11513
  logger.error("Fatal", { error: error instanceof Error ? error.message : String(error), stack: error instanceof Error ? error.stack : void 0 });