@semiont/make-meaning 0.5.29 → 0.5.30

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,95 @@ 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:anchored-text-by-checksum-requested",
11239
+ "browse:resources-requested",
11240
+ "browse:annotations-requested",
11241
+ "browse:annotation-requested",
11242
+ "browse:events-requested",
11243
+ "browse:annotation-history-requested",
11244
+ "browse:referenced-by-requested",
11245
+ "browse:entity-types-requested",
11246
+ "browse:tag-schemas-requested",
11247
+ "browse:agents-requested",
11248
+ "browse:directory-requested"
11249
+ ];
11250
+
11251
+ // src/clone-token-manager.ts
11252
+ var CLONE_TOKEN_CHANNELS = [
11253
+ "yield:clone-token-requested",
11254
+ "yield:clone-resource-requested",
11255
+ "yield:clone-create"
11256
+ ];
11257
+
11258
+ // src/service-channels.ts
11259
+ var SMELTER_AWAITED_OPERATIONS = [
11260
+ "browse:resource-requested",
11261
+ "browse:annotations-requested",
11262
+ "browse:resources-requested"
11263
+ ];
11264
+ replyChannelsFor(SMELTER_AWAITED_OPERATIONS);
11265
+ var WEAVER_AWAITED_OPERATIONS = [
11266
+ "browse:resources-requested",
11267
+ "browse:events-requested",
11268
+ "browse:annotations-requested"
11269
+ ];
11270
+ replyChannelsFor(WEAVER_AWAITED_OPERATIONS);
11271
+ var LIBRARIAN_INBOUND_CHANNELS = [
11272
+ ...MATCHER_CHANNELS,
11273
+ ...GATHERER_CHANNELS,
11274
+ "gather:summary-requested",
11275
+ "weave:applied",
11276
+ "smelt:settled"
11277
+ ];
11278
+ var LIBRARIAN_OUTBOUND_CHANNELS = replyChannelsFor(LIBRARIAN_INBOUND_CHANNELS);
11279
+ var ARCHIVIST_INBOUND_CHANNELS = [
11280
+ ...STOWER_CHANNELS,
11281
+ ...BROWSER_CHANNELS,
11282
+ ...CLONE_TOKEN_CHANNELS,
11283
+ "mark:create-request",
11284
+ "smelt:settled",
11285
+ // The annotation-context read moved here with the bytes (SINGLE-KB-MOUNT D5).
11286
+ "browse:annotation-context-requested"
11287
+ ];
11288
+ var ARCHIVIST_OUTBOUND_STRAYS = [
11289
+ "mark:body-update-failed",
11290
+ // op keyed 'bind:update-body' (gateway handler re-emits mark:update-body)
11291
+ "yield:move-failed"
11292
+ // yield:mv has no registered operation; failure is direct-subscribed
11293
+ ];
11294
+ [
11295
+ ...ARCHIVIST_OUTBOUND_STRAYS,
11296
+ ...replyChannelsFor(ARCHIVIST_INBOUND_CHANNELS)
11297
+ ];
11298
+ function registerGatherSummaryHandler(eventBus, gatherer, parentLogger) {
11299
+ const logger2 = parentLogger.child({ component: "annotation-lookups" });
11300
+ eventBus.get("gather:summary-requested").subscribe(async (command) => {
11301
+ const { correlationId } = command;
11302
+ const annId = command.annotationId;
11303
+ const resId = command.resourceId;
11304
+ try {
11305
+ const response = await gatherer.generateAnnotationSummary(
11306
+ annotationId(annId),
11307
+ resourceId(resId)
11308
+ );
11309
+ eventBus.get("gather:summary-result").next({
11310
+ correlationId,
11311
+ response
11312
+ });
11313
+ } catch (error) {
11314
+ logger2.warn("gather:summary failed", { correlationId, error: error.message });
11315
+ eventBus.get("gather:summary-failed").next({
11316
+ correlationId,
11317
+ message: error.message
11318
+ });
11319
+ }
11320
+ });
11321
+ }
11322
+
11240
11323
  // src/service.ts
11241
11324
  function assertMakeMeaningConfig(config2) {
11242
11325
  if (!config2.services?.graph) {
@@ -11272,26 +11355,8 @@ if (config.services.vectors.type === "memory") {
11272
11355
  throw new Error("services.vectors.type 'memory' is a test-only sink; the Librarian requires a server-backed vector store");
11273
11356
  }
11274
11357
  var workerSecret = process.env.SEMIONT_WORKER_SECRET ?? "";
11275
- var healthPort = 9094;
11358
+ var healthPort = 24104;
11276
11359
  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
11360
  async function authenticate() {
11296
11361
  if (!workerSecret) {
11297
11362
  logger.warn("No SEMIONT_WORKER_SECRET set \u2014 using empty token");
@@ -11365,7 +11430,12 @@ async function main() {
11365
11430
  const httpTransport = new HttpTransport({
11366
11431
  baseUrl: baseUrl$1(baseUrl),
11367
11432
  token$: tokenSubject,
11368
- tokenRefresher: refreshToken
11433
+ tokenRefresher: refreshToken,
11434
+ // Exactly the inbound roster — never the full bridged set, whose global
11435
+ // reply fan-out is the worker-OOM failure mode. This process awaits no
11436
+ // wire replies (busRequest's isSubscribed gate fails fast if one is ever
11437
+ // added without growing the roster), so inbound IS the subscription.
11438
+ channels: LIBRARIAN_INBOUND_CHANNELS
11369
11439
  });
11370
11440
  const contentReads = archivistContentReads(config);
11371
11441
  const weaveProgress = createWeaveProgress(localBus);
@@ -11389,15 +11459,14 @@ async function main() {
11389
11459
  await gatherer.initialize();
11390
11460
  registerGatherSummaryHandler(localBus, gatherer, logger);
11391
11461
  const pumps = [];
11392
- httpTransport.actor.addChannels([...INBOUND_CHANNELS]);
11393
- for (const channel of INBOUND_CHANNELS) {
11462
+ for (const channel of LIBRARIAN_INBOUND_CHANNELS) {
11394
11463
  pumps.push(
11395
11464
  httpTransport.stream(channel).subscribe((payload) => {
11396
11465
  localBus.get(channel).next(payload);
11397
11466
  })
11398
11467
  );
11399
11468
  }
11400
- const outbound = outboundChannels();
11469
+ const outbound = LIBRARIAN_OUTBOUND_CHANNELS;
11401
11470
  for (const channel of outbound) {
11402
11471
  pumps.push(
11403
11472
  localBus.get(channel).subscribe((payload) => {
@@ -11410,7 +11479,7 @@ async function main() {
11410
11479
  })
11411
11480
  );
11412
11481
  }
11413
- logger.info("Bus pumps attached", { inbound: INBOUND_CHANNELS.length, outbound: outbound.length });
11482
+ logger.info("Bus pumps attached", { inbound: LIBRARIAN_INBOUND_CHANNELS.length, outbound: outbound.length });
11414
11483
  const server = createServer((req, res) => {
11415
11484
  if (req.url === "/health") {
11416
11485
  res.writeHead(200, { "Content-Type": "application/json" });
@@ -11439,7 +11508,7 @@ async function main() {
11439
11508
  };
11440
11509
  process.on("SIGTERM", shutdown);
11441
11510
  process.on("SIGINT", shutdown);
11442
- logger.info("Librarian serving", { channels: INBOUND_CHANNELS.length });
11511
+ logger.info("Librarian serving", { channels: LIBRARIAN_INBOUND_CHANNELS.length });
11443
11512
  }
11444
11513
  main().catch((error) => {
11445
11514
  logger.error("Fatal", { error: error instanceof Error ? error.message : String(error), stack: error instanceof Error ? error.stack : void 0 });