@coasys/ad4m 0.13.0-test-9 → 0.13.0-test-interpretation-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.
Files changed (44) hide show
  1. package/lib/index.cjs +370 -8
  2. package/lib/index.js +371 -9
  3. package/lib/src/ai/AIClient.js +3 -1
  4. package/lib/src/apiClient.d.ts +4 -1
  5. package/lib/src/apiClient.js +7 -3
  6. package/lib/src/generated/api/RunInterpretationRequest.d.ts +19 -0
  7. package/lib/src/generated/api/RunInterpretationRequest.js +1 -0
  8. package/lib/src/generated/api/TranscriptTurn.d.ts +7 -0
  9. package/lib/src/generated/api/TranscriptTurn.js +2 -0
  10. package/lib/src/generated/api/index.d.ts +2 -0
  11. package/lib/src/index.d.ts +2 -0
  12. package/lib/src/index.js +2 -0
  13. package/lib/src/model/ModelQueryBuilder.js +1 -1
  14. package/lib/src/model/decorators.d.ts +25 -0
  15. package/lib/src/model/decorators.js +1 -1
  16. package/lib/src/model/shacl-gen.d.ts +8 -1
  17. package/lib/src/model/shacl-gen.js +21 -1
  18. package/lib/src/perspectives/AutoProcessor.d.ts +89 -0
  19. package/lib/src/perspectives/AutoProcessor.js +5 -0
  20. package/lib/src/perspectives/InterpretationModels.d.ts +71 -0
  21. package/lib/src/perspectives/InterpretationModels.js +190 -0
  22. package/lib/src/perspectives/PerspectiveClient.d.ts +37 -0
  23. package/lib/src/perspectives/PerspectiveClient.js +54 -0
  24. package/lib/src/perspectives/PerspectiveProxy.d.ts +43 -1
  25. package/lib/src/perspectives/PerspectiveProxy.js +53 -1
  26. package/lib/src/shacl/SHACLShape.d.ts +14 -0
  27. package/lib/src/shacl/SHACLShape.js +45 -0
  28. package/package.json +6 -2
  29. package/src/ai/AIClient.ts +3 -1
  30. package/src/apiClient.ts +7 -3
  31. package/src/generated/api/RunInterpretationRequest.ts +18 -0
  32. package/src/generated/api/TranscriptTurn.ts +6 -0
  33. package/src/generated/api/index.ts +2 -0
  34. package/src/index.ts +2 -0
  35. package/src/model/ModelQueryBuilder.ts +1 -1
  36. package/src/model/decorators.ts +29 -0
  37. package/src/model/shacl-gen.ts +22 -0
  38. package/src/model/shacl-roundtrip.test.ts +76 -0
  39. package/src/perspectives/AutoProcessor.ts +107 -0
  40. package/src/perspectives/InterpretationModels.ts +145 -0
  41. package/src/perspectives/PerspectiveClient.ts +75 -0
  42. package/src/perspectives/PerspectiveProxy.ts +61 -1
  43. package/src/shacl/SHACLShape.test.ts +26 -0
  44. package/src/shacl/SHACLShape.ts +82 -4
package/lib/index.cjs CHANGED
@@ -167,20 +167,24 @@ class ApiClient {
167
167
  * Send an RPC call over the WebSocket connection.
168
168
  * @param type - The operation type (e.g. 'agent.get', 'perspective.all')
169
169
  * @param params - Optional parameters to include in the message
170
+ * @param timeoutMs - Optional per-call timeout override in ms. Defaults to
171
+ * [[DEFAULT_TIMEOUT_MS]]. Use for long-running calls (LLM prompts,
172
+ * holochain ops) that legitimately exceed the default.
170
173
  * @returns Promise that resolves with the result from the server
171
174
  */
172
- async call(type, params) {
175
+ async call(type, params, timeoutMs) {
173
176
  await this._ready();
174
177
  const id = nextId();
175
178
  // Put params under a "params" key to avoid collision with
176
179
  // protocol fields "id" and "type" (e.g. params might contain
177
180
  // { id: modelId } or { type: "db" }).
178
181
  const message = { id, type, params: params || {} };
182
+ const effectiveTimeout = timeoutMs ?? DEFAULT_TIMEOUT_MS;
179
183
  return new Promise((resolve, reject) => {
180
184
  const timer = setTimeout(() => {
181
185
  this._pendingCalls.delete(id);
182
- reject(new RpcError(408, `RPC call '${type}' timed out after ${DEFAULT_TIMEOUT_MS}ms`));
183
- }, DEFAULT_TIMEOUT_MS);
186
+ reject(new RpcError(408, `RPC call '${type}' timed out after ${effectiveTimeout}ms`));
187
+ }, effectiveTimeout);
184
188
  this._pendingCalls.set(id, {
185
189
  resolve: resolve,
186
190
  reject,
@@ -1233,6 +1237,15 @@ class SHACLShape {
1233
1237
  target: `literal:string:${JSON.stringify(this.destructor_actions)}`
1234
1238
  });
1235
1239
  }
1240
+ // Class-level interpretation hint — read by the Rust model query as
1241
+ // `ModelShape.interpretation_hint` and fed to the generic LLM extractor.
1242
+ if (this.interpretationHint) {
1243
+ links.push({
1244
+ source: this.nodeShapeUri,
1245
+ predicate: "ad4m://interpretation_hint",
1246
+ target: `literal:string:${this.interpretationHint}`
1247
+ });
1248
+ }
1236
1249
  // Property shapes (each gets a named URI: {namespace}/{ClassName}.{propertyName})
1237
1250
  for (let i = 0; i < this.properties.length; i++) {
1238
1251
  const prop = this.properties[i];
@@ -1432,6 +1445,20 @@ class SHACLShape {
1432
1445
  target: `literal:string:${JSON.stringify(prop.transform)}`
1433
1446
  });
1434
1447
  }
1448
+ if (prop.interpretationHint) {
1449
+ links.push({
1450
+ source: propShapeId,
1451
+ predicate: "ad4m://interpretation_hint",
1452
+ target: `literal:string:${prop.interpretationHint}`
1453
+ });
1454
+ }
1455
+ if (prop.identity) {
1456
+ links.push({
1457
+ source: propShapeId,
1458
+ predicate: "ad4m://identity",
1459
+ target: `literal:string:true`
1460
+ });
1461
+ }
1435
1462
  }
1436
1463
  return links;
1437
1464
  }
@@ -1464,6 +1491,11 @@ class SHACLShape {
1464
1491
  // Ignore parse errors
1465
1492
  }
1466
1493
  }
1494
+ // Class-level interpretation hint (mirror of the emit in toLinks())
1495
+ const classHintLink = links.find(l => l.source === shapeUri && l.predicate === "ad4m://interpretation_hint");
1496
+ if (classHintLink) {
1497
+ shape.interpretationHint = classHintLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
1498
+ }
1467
1499
  // Find all property shapes
1468
1500
  const propShapeLinks = links.filter(l => l.source === shapeUri && l.predicate === "sh://property");
1469
1501
  for (const propLink of propShapeLinks) {
@@ -1651,6 +1683,15 @@ class SHACLShape {
1651
1683
  val = val.substring(8);
1652
1684
  prop.filter = val === 'true';
1653
1685
  }
1686
+ const interpretationHintLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://interpretation_hint");
1687
+ if (interpretationHintLink) {
1688
+ prop.interpretationHint = interpretationHintLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
1689
+ }
1690
+ const identityLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://identity");
1691
+ if (identityLink) {
1692
+ prop.identity =
1693
+ identityLink.target.replace(/^literal:\/\/string:|^literal:string:/, '') === 'true';
1694
+ }
1654
1695
  const transformLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://transform");
1655
1696
  if (transformLink) {
1656
1697
  const jsonStr = transformLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
@@ -1682,6 +1723,7 @@ class SHACLShape {
1682
1723
  node_shape_uri: this.nodeShapeUri,
1683
1724
  target_class: this.targetClass,
1684
1725
  parent_shapes: this.parentShapes.length > 0 ? this.parentShapes : undefined,
1726
+ interpretation_hint: this.interpretationHint,
1685
1727
  properties: this.properties.map(p => ({
1686
1728
  path: p.path,
1687
1729
  name: p.name,
@@ -1709,6 +1751,8 @@ class SHACLShape {
1709
1751
  where_predicates: p.wherePredicates,
1710
1752
  filter: p.filter,
1711
1753
  transform: p.transform,
1754
+ interpretation_hint: p.interpretationHint,
1755
+ identity: p.identity,
1712
1756
  })),
1713
1757
  constructor_actions: this.constructor_actions,
1714
1758
  destructor_actions: this.destructor_actions,
@@ -1754,6 +1798,8 @@ class SHACLShape {
1754
1798
  wherePredicates: p.where_predicates,
1755
1799
  filter: p.filter,
1756
1800
  transform: p.transform,
1801
+ interpretationHint: p.interpretation_hint,
1802
+ identity: p.identity,
1757
1803
  });
1758
1804
  }
1759
1805
  if (json.constructor_actions) {
@@ -1767,6 +1813,9 @@ class SHACLShape {
1767
1813
  shape.addParentShape(ps);
1768
1814
  }
1769
1815
  }
1816
+ if (json.interpretation_hint) {
1817
+ shape.interpretationHint = json.interpretation_hint;
1818
+ }
1770
1819
  return shape;
1771
1820
  }
1772
1821
  }
@@ -1801,7 +1850,14 @@ function buildSHACL(subjectName, target, properties, allRelationsMeta, conforman
1801
1850
  * `getMemoizedSHACL`; safe to omit when calling `buildSHACL`
1802
1851
  * directly (e.g. from a one-off SDNA build tool).
1803
1852
  */
1804
- seedCache) {
1853
+ seedCache,
1854
+ /**
1855
+ * Natural-language hint declared on the `@Model` decorator that
1856
+ * steers the generic LLM extractor when producing instances of
1857
+ * this class. Attached to the SHACL shape node and re-emitted as
1858
+ * an `ad4m://interpretation_hint` link by `SHACLShape.toLinks()`.
1859
+ */
1860
+ interpretationHint) {
1805
1861
  const obj = target.prototype;
1806
1862
  // ── Determine namespace from first property or relation ─────────────
1807
1863
  let namespace = "ad4m://";
@@ -1829,6 +1885,9 @@ seedCache) {
1829
1885
  const shapeUri = `${namespace}${subjectName}Shape`;
1830
1886
  const targetClass = `${namespace}${subjectName}`;
1831
1887
  const shape = new SHACLShape(shapeUri, targetClass);
1888
+ if (interpretationHint) {
1889
+ shape.interpretationHint = interpretationHint;
1890
+ }
1832
1891
  // ── Seed the memoisation cache while we keep building ──────────────
1833
1892
  // Any subsequent `target.generateSHACL()` call from inside this
1834
1893
  // function (typically when walking a self-referential or
@@ -1915,6 +1974,16 @@ seedCache) {
1915
1974
  if (propMeta.transform) {
1916
1975
  propShape.transform = propMeta.transform;
1917
1976
  }
1977
+ // Natural-language interpretation hint (read by the generic LLM
1978
+ // extractor via ShapeProperty.interpretation_hint).
1979
+ if (propMeta.interpretationHint) {
1980
+ propShape.interpretationHint = propMeta.interpretationHint;
1981
+ }
1982
+ // Declared-identity dedup key for the generic LLM interpreter
1983
+ // (emitted as `ad4m://identity` by SHACLShape.toLinks()).
1984
+ if (propMeta.identity) {
1985
+ propShape.identity = true;
1986
+ }
1918
1987
  // ── Setter actions ──────────────────────────────────────────────
1919
1988
  if (propMeta.prologSetter) {
1920
1989
  console.warn(`[SHACL Generation] Custom Prolog setter for property '${propName}' in class '${subjectName}' is not yet supported. ` +
@@ -2559,7 +2628,7 @@ function Model$1(opts) {
2559
2628
  return buildSDNA(opts.name, target.prototype, getPropertiesMetadata(target), getRelationsMetadata(target));
2560
2629
  };
2561
2630
  target.generateSHACL = function () {
2562
- return getMemoizedSHACL(target, (seed) => buildSHACL(opts.name, target, getPropertiesMetadata(target), getRelationsMetadata(target), buildConformanceFilter, seed));
2631
+ return getMemoizedSHACL(target, (seed) => buildSHACL(opts.name, target, getPropertiesMetadata(target), getRelationsMetadata(target), buildConformanceFilter, seed, opts.interpretationHint));
2563
2632
  };
2564
2633
  Object.defineProperty(target, 'type', { configurable: true });
2565
2634
  };
@@ -3785,6 +3854,58 @@ class PerspectiveProxy {
3785
3854
  async get(query) {
3786
3855
  return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").queryLinks(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, query);
3787
3856
  }
3857
+ /**
3858
+ * Runs generic LLM interpretation over a conversation transcript, turning it
3859
+ * into typed instances of this perspective's own SHACL subject classes
3860
+ * (steered by each class's `@InterpretationHint`). The target shapes are
3861
+ * resolved automatically from the perspective's registered classes, so you
3862
+ * pass only the transcript. New instances are written as links into this
3863
+ * perspective; the returned placements list each instance's base URI and
3864
+ * the links written for it.
3865
+ *
3866
+ * @param transcript ordered `{ speaker, text }` turns
3867
+ * @param basePrefix URI namespace for new instance identities, e.g. `soa://ext/`
3868
+ * @param classes local names of the subject classes to extract into; omit for all
3869
+ */
3870
+ async runInterpretation(transcript, basePrefix, classes) {
3871
+ return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").runInterpretation(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, transcript, basePrefix, classes);
3872
+ }
3873
+ /**
3874
+ * Register a neighbourhood auto-processor on this perspective. The executor
3875
+ * then runs interpretation automatically over new source items (like Flux
3876
+ * per channel), coordinating which peer processes each batch. Returns the
3877
+ * processor id. Subscribe to progress via {@link addAutoProcessorEventListener}.
3878
+ */
3879
+ async addAutoProcessor(config) {
3880
+ return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addAutoProcessor(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, config);
3881
+ }
3882
+ /**
3883
+ * Pending interpretation overlays on this perspective — LLM suggestions the
3884
+ * §4 divergence gate staged rather than applied, awaiting human accept/reject.
3885
+ */
3886
+ async interpretationOverlays() {
3887
+ return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").interpretationOverlays(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
3888
+ }
3889
+ /**
3890
+ * Accept an interpretation overlay's suggestion(s): the LLM's staged value
3891
+ * becomes the real, human-owned value and the overlay is deleted. Pass
3892
+ * `property` to accept a single predicate; omit it for the whole base.
3893
+ */
3894
+ async acceptInterpretation(base, property) {
3895
+ return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").acceptInterpretation(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, base, property);
3896
+ }
3897
+ /**
3898
+ * Reject an interpretation overlay's suggestion(s). Omit `property` to reject
3899
+ * the whole base — a rejected `create` deletes the suggested instance, a
3900
+ * rejected `update` drops the overlay and keeps the real value.
3901
+ */
3902
+ async rejectInterpretation(base, property) {
3903
+ return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").rejectInterpretation(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, base, property);
3904
+ }
3905
+ /** Subscribe to this perspective's auto-processor step signals. */
3906
+ async addAutoProcessorEventListener(cb) {
3907
+ return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addAutoProcessorEventListener(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, cb);
3908
+ }
3788
3909
  /**
3789
3910
  * Executes a Prolog query against the perspective's knowledge base.
3790
3911
  * This is a powerful way to find complex patterns in the graph.
@@ -3869,7 +3990,7 @@ class PerspectiveProxy {
3869
3990
  * internally in Rust, registers a subscription, runs the initial query, and
3870
3991
  * pushes updated results when relevant links change.
3871
3992
  *
3872
- * The subscription reuses the same GraphQL subscription channel as subscribeQuery().
3993
+ * The subscription reuses the same WS-RPC subscription channel as subscribeQuery().
3873
3994
  * Use keepAliveQuery() / disposeQuerySubscription() with the returned subscriptionId.
3874
3995
  *
3875
3996
  * @param className - The model class name
@@ -5615,6 +5736,60 @@ class PerspectiveClient {
5615
5736
  async linkMutations(uuid, mutations, status) {
5616
5737
  return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.linkMutations', { uuid, mutations, status });
5617
5738
  }
5739
+ /**
5740
+ * Run generic LLM interpretation over a transcript into this perspective's own
5741
+ * SHACL subject classes. The target shapes are resolved server-side from the
5742
+ * perspective's registered subject classes, so you pass only the transcript.
5743
+ * Returns the freshly minted instances (their base URIs + the links written).
5744
+ *
5745
+ * The server-side call prompts an LLM (up to `INTERPRETATION_MAX_ATTEMPTS`
5746
+ * retries on parse failure), so it can legitimately take minutes on slower
5747
+ * or CPU-only models. We raise the default 30s RPC timeout here to 20 min
5748
+ * (matches the CI `--timeout 1200000` for the interpretation tests).
5749
+ */
5750
+ async runInterpretation(uuid, transcript, basePrefix, classes) {
5751
+ const RUN_INTERPRETATION_TIMEOUT_MS = 20 * 60 * 1000;
5752
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.runInterpretation', { uuid, transcript, basePrefix, classes }, RUN_INTERPRETATION_TIMEOUT_MS);
5753
+ }
5754
+ /**
5755
+ * Register a neighbourhood auto-processor on this perspective. The executor's
5756
+ * watch loop then runs interpretation automatically over new source items
5757
+ * (like Flux per channel), coordinating which peer processes each batch via
5758
+ * the shared-graph ProcessingClaim, and emits step signals on the events
5759
+ * WebSocket (subscribe via {@link addAutoProcessorEventListener}).
5760
+ * Returns the processor id.
5761
+ */
5762
+ async addAutoProcessor(uuid, config) {
5763
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.addAutoProcessor', { uuid, ...config });
5764
+ }
5765
+ /** Pending interpretation overlays (LLM suggestions awaiting human accept/reject). */
5766
+ async interpretationOverlays(uuid) {
5767
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.interpretationOverlays', { uuid });
5768
+ }
5769
+ /** Accept an overlay's suggestion(s): the LLM value becomes the real value and
5770
+ * the overlay is deleted. Omit `property` to accept the whole base. */
5771
+ async acceptInterpretation(uuid, base, property) {
5772
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.acceptInterpretation', { uuid, base, property });
5773
+ }
5774
+ /** Reject an overlay's suggestion(s). Omit `property` to reject the whole base
5775
+ * (a rejected `create` deletes the suggested instance). */
5776
+ async rejectInterpretation(uuid, base, property) {
5777
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.rejectInterpretation', { uuid, base, property });
5778
+ }
5779
+ /**
5780
+ * Subscribe to auto-processor step signals. `cb` fires for every
5781
+ * `auto-processor-event` on `uuid` (BatchReady → Claimed/BackedOff/… →
5782
+ * Processed), letting a UI show progress and await the next batch.
5783
+ */
5784
+ async addAutoProcessorEventListener(uuid, cb) {
5785
+ const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5786
+ if (data.type === 'auto-processor-event' && data.perspectiveUuid === uuid) {
5787
+ cb(data);
5788
+ }
5789
+ });
5790
+ __classPrivateFieldGet$9(this, _PerspectiveClient_unsubscribers, "f").push(unsub);
5791
+ await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").waitForSubscription();
5792
+ }
5618
5793
  async addLinkExpression(uuid, link, status = 'shared', batchId) {
5619
5794
  return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.addLinkExpression', { uuid, link, status, batchId });
5620
5795
  }
@@ -13942,7 +14117,9 @@ class AIClient {
13942
14117
  async embed(modelId, text) {
13943
14118
  const aiEmbed = await __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.embed', { modelId, text });
13944
14119
  const compressed = base64Js.toByteArray(aiEmbed);
13945
- const decompressed = JSON.parse(pako.inflate(compressed, { to: 'string' }));
14120
+ // Decode to a string via TextDecoder rather than pako's `{ to: 'string' }`
14121
+ // option: newer @types/pako dropped that overload, which broke the build.
14122
+ const decompressed = JSON.parse(new TextDecoder().decode(pako.inflate(compressed)));
13946
14123
  return decompressed;
13947
14124
  }
13948
14125
  async openTranscriptionStream(modelId, streamCallback, params) {
@@ -15175,7 +15352,7 @@ class ModelQueryBuilder {
15175
15352
  return JSON.stringify(results, (_, v) => typeof v === 'function' ? undefined : v);
15176
15353
  };
15177
15354
  lastResultFingerprint = buildFingerprint(initialResults);
15178
- // Listen for subscription updates via the same GraphQL subscription channel.
15355
+ // Listen for subscription updates via the same WS-RPC subscription channel.
15179
15356
  // When Rust re-runs the model query and finds changed results, it pushes them.
15180
15357
  const unsubscribe = this.perspective.client.subscribeToQueryUpdates(subscriptionId, (rawResult) => {
15181
15358
  try {
@@ -17548,6 +17725,191 @@ class PerspectiveHandle {
17548
17725
  }
17549
17726
  }
17550
17727
 
17728
+ /**
17729
+ * TypeScript @Model classes mirroring the Rust-side SDNA for the generic
17730
+ * interpretation subsystem. Apps can import these to query the perspective
17731
+ * graph for interpretation history and pending overlay proposals without
17732
+ * knowing the raw link predicates.
17733
+ *
17734
+ * Registration:
17735
+ * await InterpretationOverlay.register(perspective);
17736
+ * await InterpretationRun.register(perspective);
17737
+ * await AutoProcessorConfig.register(perspective);
17738
+ *
17739
+ * Querying:
17740
+ * const pending = await InterpretationOverlay.findAll(perspective);
17741
+ * const runs = await InterpretationRun.findAll(perspective);
17742
+ * const configs = await AutoProcessorConfig.findAll(perspective);
17743
+ */
17744
+ var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
17745
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
17746
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17747
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
17748
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
17749
+ };
17750
+ var __metadata = (undefined && undefined.__metadata) || function (k, v) {
17751
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
17752
+ };
17753
+ // ── AutoProcessorConfig ─────────────────────────────────────────────────────
17754
+ // Mirrors the Rust `auto_processor::config::AutoProcessorConfig` SDNA.
17755
+ // One node per registered processor; the node URI is
17756
+ // `ad4m://autoprocessor/<processorId>`.
17757
+ exports.AutoProcessorConfig = class AutoProcessorConfig extends Ad4mModel {
17758
+ constructor() {
17759
+ super(...arguments);
17760
+ this.type = "ad4m://AutoProcessor";
17761
+ /** Unique processor id — the dedup key for auto-processor instances. */
17762
+ this.processorId = "";
17763
+ /** SPARQL SELECT that gathers source items each pass. */
17764
+ this.sourceScopeQuery = "";
17765
+ /** Class URIs (SHACL targetClass) to materialise each pass. */
17766
+ this.interpretationClasses = [];
17767
+ /** Quiet-window (ms) after the last new item before a pass runs. */
17768
+ this.debounceMs = "200";
17769
+ /** Maximum items per pass. */
17770
+ this.batchMax = "32";
17771
+ /** How long a won claim is authoritative before peers may re-claim (ms). */
17772
+ this.claimTtlMs = "60000";
17773
+ }
17774
+ };
17775
+ __decorate([
17776
+ Flag({ through: "rdf://type", value: "ad4m://AutoProcessor" }),
17777
+ __metadata("design:type", String)
17778
+ ], exports.AutoProcessorConfig.prototype, "type", void 0);
17779
+ __decorate([
17780
+ Property({ through: "ad4m://processor_id", required: true, identity: true }),
17781
+ __metadata("design:type", String)
17782
+ ], exports.AutoProcessorConfig.prototype, "processorId", void 0);
17783
+ __decorate([
17784
+ Property({ through: "ad4m://source_scope_query", required: true }),
17785
+ __metadata("design:type", String)
17786
+ ], exports.AutoProcessorConfig.prototype, "sourceScopeQuery", void 0);
17787
+ __decorate([
17788
+ Optional({ through: "ad4m://base_prefix", resolveLanguage: "literal" }),
17789
+ __metadata("design:type", String)
17790
+ ], exports.AutoProcessorConfig.prototype, "basePrefix", void 0);
17791
+ __decorate([
17792
+ HasMany({ through: "ad4m://interpretation_class" }),
17793
+ __metadata("design:type", Array)
17794
+ ], exports.AutoProcessorConfig.prototype, "interpretationClasses", void 0);
17795
+ __decorate([
17796
+ Property({ through: "ad4m://debounce_ms", required: true }),
17797
+ __metadata("design:type", String)
17798
+ ], exports.AutoProcessorConfig.prototype, "debounceMs", void 0);
17799
+ __decorate([
17800
+ Optional({ through: "ad4m://batch_min", resolveLanguage: "literal" }),
17801
+ __metadata("design:type", String)
17802
+ ], exports.AutoProcessorConfig.prototype, "batchMin", void 0);
17803
+ __decorate([
17804
+ Property({ through: "ad4m://batch_max", required: true }),
17805
+ __metadata("design:type", String)
17806
+ ], exports.AutoProcessorConfig.prototype, "batchMax", void 0);
17807
+ __decorate([
17808
+ Optional({ through: "ad4m://max_wait_ms", resolveLanguage: "literal" }),
17809
+ __metadata("design:type", String)
17810
+ ], exports.AutoProcessorConfig.prototype, "maxWaitMs", void 0);
17811
+ __decorate([
17812
+ Property({ through: "ad4m://claim_ttl_ms", required: true }),
17813
+ __metadata("design:type", String)
17814
+ ], exports.AutoProcessorConfig.prototype, "claimTtlMs", void 0);
17815
+ __decorate([
17816
+ Optional({ through: "ad4m://source_window_ms", resolveLanguage: "literal" }),
17817
+ __metadata("design:type", String)
17818
+ ], exports.AutoProcessorConfig.prototype, "sourceWindowMs", void 0);
17819
+ __decorate([
17820
+ Optional({ through: "ad4m://dedup_strategy", resolveLanguage: "literal" }),
17821
+ __metadata("design:type", String)
17822
+ ], exports.AutoProcessorConfig.prototype, "dedupStrategy", void 0);
17823
+ exports.AutoProcessorConfig = __decorate([
17824
+ Model$1({ name: "AutoProcessorConfig" })
17825
+ ], exports.AutoProcessorConfig);
17826
+ // ── InterpretationRun ───────────────────────────────────────────────────────
17827
+ // Mirrors the Rust `interpretation::overlay::InterpretationRun` SDNA.
17828
+ // One node per completed pass; the node URI is `ad4m://interp/run/<runId>`.
17829
+ exports.InterpretationRun = class InterpretationRun extends Ad4mModel {
17830
+ constructor() {
17831
+ super(...arguments);
17832
+ this.type = "ad4m://interpretation-run";
17833
+ /** UUID for this run — the dedup key across run nodes. */
17834
+ this.runId = "";
17835
+ /**
17836
+ * Source item IDs consumed by this pass.
17837
+ * Stored as multiple links with the same predicate; the processed-turn
17838
+ * cursor uses these to avoid re-interpreting a turn.
17839
+ */
17840
+ this.sources = [];
17841
+ }
17842
+ };
17843
+ __decorate([
17844
+ Flag({ through: "ad4m://type", value: "ad4m://interpretation-run" }),
17845
+ __metadata("design:type", String)
17846
+ ], exports.InterpretationRun.prototype, "type", void 0);
17847
+ __decorate([
17848
+ Property({ through: "ad4m://interp/run_id", required: true, identity: true }),
17849
+ __metadata("design:type", String)
17850
+ ], exports.InterpretationRun.prototype, "runId", void 0);
17851
+ __decorate([
17852
+ Optional({ through: "ad4m://interp/model", resolveLanguage: "literal" }),
17853
+ __metadata("design:type", String)
17854
+ ], exports.InterpretationRun.prototype, "model", void 0);
17855
+ __decorate([
17856
+ Optional({ through: "ad4m://interp/prompt_version", resolveLanguage: "literal" }),
17857
+ __metadata("design:type", String)
17858
+ ], exports.InterpretationRun.prototype, "promptVersion", void 0);
17859
+ __decorate([
17860
+ Optional({ through: "ad4m://interp/ran_at", resolveLanguage: "literal" }),
17861
+ __metadata("design:type", String)
17862
+ ], exports.InterpretationRun.prototype, "ranAt", void 0);
17863
+ __decorate([
17864
+ Optional({ through: "ad4m://interp/processor", resolveLanguage: "literal" }),
17865
+ __metadata("design:type", String)
17866
+ ], exports.InterpretationRun.prototype, "processor", void 0);
17867
+ __decorate([
17868
+ HasMany({ through: "ad4m://interp/sources" }),
17869
+ __metadata("design:type", Array)
17870
+ ], exports.InterpretationRun.prototype, "sources", void 0);
17871
+ exports.InterpretationRun = __decorate([
17872
+ Model$1({ name: "InterpretationRun" })
17873
+ ], exports.InterpretationRun);
17874
+ // ── InterpretationOverlay ───────────────────────────────────────────────────
17875
+ // Mirrors the Rust `interpretation::overlay::InterpretationOverlay` SDNA.
17876
+ // An overlay sits on the *same* base URI as the proposed instance — it is a
17877
+ // pending LLM suggestion awaiting human accept/reject.
17878
+ //
17879
+ // The dynamic "inferred" values are stored as links with predicates of the
17880
+ // form `ad4m://interp/inferred/<realPredicate>` and are NOT captured here as
17881
+ // fixed @Property fields because the predicates vary per class. Read them
17882
+ // directly via perspective.get({ source: overlay.baseExpression }).
17883
+ //
17884
+ // Accept → perspective.acceptInterpretationOverlay(base) [deletes the overlay]
17885
+ // Reject → perspective.rejectInterpretationOverlay(base) [drops the suggestion]
17886
+ //
17887
+ // Note: `findAll` finds ALL nodes that currently carry a `kind` link, i.e.
17888
+ // all pending proposals. Accepted/rejected overlays are removed from the
17889
+ // graph and will not appear.
17890
+ exports.InterpretationOverlay = class InterpretationOverlay extends Ad4mModel {
17891
+ constructor() {
17892
+ super(...arguments);
17893
+ /**
17894
+ * Whether the LLM authored the whole instance (`"create"`) or proposed
17895
+ * changes to an existing one (`"update"`). This is the discriminator link
17896
+ * that makes a node identifiable as an overlay.
17897
+ */
17898
+ this.kind = "";
17899
+ }
17900
+ };
17901
+ __decorate([
17902
+ Property({ through: "ad4m://interp/kind", required: true, resolveLanguage: "literal" }),
17903
+ __metadata("design:type", String)
17904
+ ], exports.InterpretationOverlay.prototype, "kind", void 0);
17905
+ __decorate([
17906
+ Optional({ through: "ad4m://interp/run", resolveLanguage: "literal" }),
17907
+ __metadata("design:type", String)
17908
+ ], exports.InterpretationOverlay.prototype, "run", void 0);
17909
+ exports.InterpretationOverlay = __decorate([
17910
+ Model$1({ name: "InterpretationOverlay" })
17911
+ ], exports.InterpretationOverlay);
17912
+
17551
17913
  /**
17552
17914
  * SPARQL binding helpers — typed shapes and parsers for `querySparql<T>()`.
17553
17915
  *