@semiont/make-meaning 0.5.30 → 0.5.32

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,5 +1,5 @@
1
- import { archivistContentReads, createAnchoredTextStore, EXTRACTORS, calculateChecksum } from '@semiont/content';
2
- import { replyChannelsFor, createTomlConfigLoader, accessToken, baseUrl as baseUrl$1, retryWithBackoff, isTransientFetchError, STARTUP_FETCH_RETRY, burstBuffer, errField, resourceId, textExtractionOf, busRequest, getResourceEntityTypes, chunkText, getTargetSelector, getExactText, annotationId, getPrimaryMediaType, getPrimaryRepresentation } from '@semiont/core';
1
+ import { archivistContentReads, createAnchoredTextStore, derivingExtractorFor, calculateChecksum } from '@semiont/content';
2
+ import { replyChannelsFor, createTomlConfigLoader, accessToken, baseUrl as baseUrl$1, retryWithBackoff, isTransientFetchError, STARTUP_FETCH_RETRY, burstBuffer, errField, resourceId, textSourceOf, decodeRepresentation, busRequest, getResourceEntityTypes, chunkText, getTargetSelector, getExactText, annotationId, getPrimaryMediaType, yieldsGeometryOf, getPrimaryRepresentation } from '@semiont/core';
3
3
  import { registerVectorIndexSizeProvider, withActorSpan } from '@semiont/observability';
4
4
  import '@semiont/ontology';
5
5
  import '@semiont/graph';
@@ -10060,8 +10060,8 @@ var Smelter = class _Smelter {
10060
10060
  if (!rid) return;
10061
10061
  const { data, contentType } = await this.content.getBinary(resourceId(rid));
10062
10062
  const bytes = Buffer.from(data);
10063
- const extractor = EXTRACTORS[textExtractionOf(contentType)];
10064
- if (!extractor?.yieldsGeometry) {
10063
+ const extractor = derivingExtractorFor(contentType);
10064
+ if (!extractor) {
10065
10065
  this.logger.info("Re-anchor found no geometry-capable extractor", { resourceId: rid, contentType });
10066
10066
  return;
10067
10067
  }
@@ -10100,15 +10100,12 @@ var Smelter = class _Smelter {
10100
10100
  const { data, contentType } = await this.content.getBinary(resourceId(resourceId6));
10101
10101
  const bytes = Buffer.from(data);
10102
10102
  const checksum = calculateChecksum(bytes);
10103
- const extractor = EXTRACTORS[textExtractionOf(contentType)];
10104
- if (!extractor) {
10105
- this.logger.debug("Skipping resource with no extractor for its media type", { resourceId: resourceId6, contentType });
10103
+ const extractor = derivingExtractorFor(contentType);
10104
+ if (!extractor && textSourceOf(contentType) === "none") {
10105
+ this.logger.debug("Skipping resource with no way to read its media type", { resourceId: resourceId6, contentType });
10106
10106
  return { kind: "skipped", checksum, reason: "no-extractor" };
10107
10107
  }
10108
- const extracted = await extractor.extract(bytes, contentType, {
10109
- key: checksum,
10110
- store: this.anchoredStore
10111
- });
10108
+ const extracted = extractor ? await extractor.extract(bytes, contentType, { key: checksum, store: this.anchoredStore }) : { kind: "extracted", text: decodeRepresentation(bytes, contentType), method: "text-passthrough" };
10112
10109
  if (extracted.kind === "declined") {
10113
10110
  this.logger.debug("Extractor declined", { resourceId: resourceId6, contentType, reason: extracted.declined });
10114
10111
  return { kind: "skipped", checksum, reason: extracted.declined };
@@ -10523,22 +10520,24 @@ var Smelter = class _Smelter {
10523
10520
  * representation's checksum (the bytes the smelter would read), the
10524
10521
  * current entity-type set (the discriminator the stamps must carry), and
10525
10522
  * whether the media type's extractor derives geometry (whether an
10526
- * anchored-text artifact should exist). Embeddable an extractor exists
10527
- * for the media type's strategy the same registry the live fetch
10528
- * resolves, and `yieldsGeometry` is declared on the extractor itself, so
10529
- * every gate here and the live fetch's behavior are twins by construction.
10523
+ * anchored-text artifact should exist). Both answers are core's, keyed by the
10524
+ * media type's strategy: embeddable the type has any text-reading strategy
10525
+ * at all, and geometry that strategy derives it. Until READ-VS-EXTRACT P2
10526
+ * embeddability was asked as `EXTRACTORS[strategy] !== null` true, but a
10527
+ * second statement of `strategy !== 'none'`, answered by resolving an
10528
+ * implementation to learn a fact about a media type.
10530
10529
  * Shared by `reconcile()` and the `smelt:rebuild-anchors` planner.
10531
10530
  */
10532
10531
  classifyEmbeddable(resources) {
10533
10532
  const embeddable = /* @__PURE__ */ new Map();
10534
10533
  for (const resource of resources) {
10535
10534
  const mediaType = getPrimaryMediaType(resource);
10536
- const extractor = mediaType ? EXTRACTORS[textExtractionOf(mediaType)] : null;
10537
- if (resource["@id"] && extractor) {
10535
+ const readable = mediaType !== void 0 && textSourceOf(mediaType) !== "none";
10536
+ if (resource["@id"] && mediaType && readable) {
10538
10537
  embeddable.set(resource["@id"], {
10539
10538
  checksum: getPrimaryRepresentation(resource)?.checksum,
10540
10539
  entityTypes: getResourceEntityTypes(resource),
10541
- yieldsGeometry: extractor.yieldsGeometry
10540
+ yieldsGeometry: yieldsGeometryOf(mediaType)
10542
10541
  });
10543
10542
  }
10544
10543
  }
@@ -10590,7 +10589,6 @@ var STOWER_CHANNELS = [
10590
10589
  var BROWSER_CHANNELS = [
10591
10590
  "browse:resource-requested",
10592
10591
  "browse:anchored-text-requested",
10593
- "browse:anchored-text-by-checksum-requested",
10594
10592
  "browse:resources-requested",
10595
10593
  "browse:annotations-requested",
10596
10594
  "browse:annotation-requested",
@@ -10650,6 +10648,17 @@ var ARCHIVIST_OUTBOUND_STRAYS = [
10650
10648
  ...ARCHIVIST_OUTBOUND_STRAYS,
10651
10649
  ...replyChannelsFor(ARCHIVIST_INBOUND_CHANNELS)
10652
10650
  ];
10651
+ async function runBootPass(pass, run, logger2, onState) {
10652
+ try {
10653
+ const summary = await run();
10654
+ onState?.({ phase: "done", summary });
10655
+ } catch (error) {
10656
+ logger2.error(`Boot pass '${pass}' failed \u2014 continuing with a store that may be behind`, {
10657
+ pass,
10658
+ error: errField(error)
10659
+ });
10660
+ }
10661
+ }
10653
10662
  var configPath = join(homedir(), ".semiontconfig");
10654
10663
  var tomlReader = {
10655
10664
  readIfExists: (p) => existsSync(p) ? readFileSync(p, "utf-8") : null
@@ -10815,7 +10824,7 @@ async function main() {
10815
10824
  };
10816
10825
  process.on("SIGTERM", shutdown);
10817
10826
  process.on("SIGINT", shutdown);
10818
- await smelter.reconcile();
10827
+ await runBootPass("reconcile", () => smelter.reconcile(), logger);
10819
10828
  }
10820
10829
  main().catch((error) => {
10821
10830
  logger.error("Fatal", { error: error instanceof Error ? error.message : String(error), stack: error instanceof Error ? error.stack : void 0 });