@camstack/server 1.2.194 → 1.2.195

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.
@@ -524,6 +524,14 @@ async function startAgent(configPath) {
524
524
  // cap). A pin to ANOTHER node still bypasses the sibling → onUnownedCall.
525
525
  ownNodeId: agentNodeId,
526
526
  onUnownedCall,
527
+ // NO `capUsageObserver` here, deliberately. `getCapUsageRegistry()` is a
528
+ // per-process singleton and the reader (`nodes.getCapUsageGraph`) runs on
529
+ // hub-main; recording in the agent would produce a map nobody ever reads,
530
+ // which is exactly the shape that made this graph return `[]` for
531
+ // months. An agent's addon traffic is a KNOWN blind spot of the graph —
532
+ // see `LocalChildRegistryOptions.capUsageObserver`. Closing it needs the
533
+ // caller identity to survive `$hub-cap-fwd`'s envelope, which today it
534
+ // does not.
527
535
  });
528
536
  await agentUdsRegistry.start();
529
537
  // E1: apply child manifest + cleanup from the UDS lifecycle (agent-local children).
@@ -623,8 +623,34 @@ function buildNodesProvider(agentRegistry, moleculer, addonRegistry, getNodeRoot
623
623
  }
624
624
  return result;
625
625
  },
626
+ /**
627
+ * Observed caller → provider → cap edges over the last `windowSeconds`.
628
+ *
629
+ * **Read the blind spots before drawing a conclusion.** This reads
630
+ * hub-main's `CapUsageRegistry`, written by the hub's `LocalChildRegistry`
631
+ * on every `cap-call-out` a hub-local forked addon sends. It therefore does
632
+ * NOT contain: hub-main → hub-main in-process calls (one shared `ctx.api`
633
+ * client, no per-caller identity), a runner's own co-located calls, or any
634
+ * traffic originating on an agent. An edge missing here means "not seen on
635
+ * this plane", never "did not happen" — the full list is on
636
+ * `LocalChildRegistryOptions.capUsageObserver`.
637
+ */
626
638
  getCapUsageGraph: async (input) => {
627
639
  const reg = (0, system_1.getCapUsageRegistry)();
640
+ const stats = reg.getStats();
641
+ if (stats.droppedTriples > 0) {
642
+ // The registry is bounded (it lives on hub-main — D181). If it ever
643
+ // truncates, the operator asking this question is told, because a
644
+ // silently incomplete diagnostic is the defect this surface exists to
645
+ // fix (D237).
646
+ logger?.warn('cap-usage graph is truncated — the triple ceiling was reached', {
647
+ meta: {
648
+ triples: stats.triples,
649
+ maxTriples: stats.maxTriples,
650
+ droppedTriples: stats.droppedTriples,
651
+ },
652
+ });
653
+ }
628
654
  return reg.getGraph({ windowSeconds: input.windowSeconds, nowMs: Date.now() });
629
655
  },
630
656
  setProcessLogLevel: async (input) => {
@@ -396,6 +396,14 @@ class MoleculerService {
396
396
  // across a socket too — and one that hangs is cut off on both.
397
397
  capTimeoutMs: (capName, method) => this.capabilityService.getRegistry()?.getDefinition(capName)?.methods?.[method]
398
398
  ?.timeoutMs,
399
+ // Feed the cap-usage graph from the one place that sees a forked
400
+ // addon's outbound `ctx.api` traffic AND runs in the process that reads
401
+ // it back (`nodes.getCapUsageGraph` → `cap-providers.ts`). The
402
+ // runner-side observer in `addon-context-factory.ts` writes to the
403
+ // RUNNER's own module singleton, which hub-main never sees — which is
404
+ // why the graph answered `[]` on a hub running 64 addons. Blind spots
405
+ // that remain are listed on `LocalChildRegistryOptions.capUsageObserver`.
406
+ capUsageObserver: (obs) => (0, system_1.getCapUsageRegistry)().recordCall(obs),
399
407
  logger: {
400
408
  info: (msg, meta) => logger.info(msg, meta !== null && meta !== undefined
401
409
  ? { meta: meta }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/server",
3
- "version": "1.2.194",
3
+ "version": "1.2.195",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist",