@camstack/addon-pipeline-orchestrator 1.2.716 → 1.2.717

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.
package/dist/index.js CHANGED
@@ -5207,9 +5207,9 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
5207
5207
  */
5208
5208
  EventCategory["DeviceStateChanged"] = "device.state-changed";
5209
5209
  /**
5210
- * A device COMMAND (a vocabulary action, D920/D983) settled in the hub's
5211
- * transition audit (D1022): confirmed, already in place, unconfirmed or
5212
- * failed. Never a device's own change. Payload: `DeviceCommandSettledEvent`
5210
+ * A device COMMAND (a vocabulary action, D920/D983) completed, as the hub's
5211
+ * command audit saw it (D1022, D1084): the call returned (`ok`) or threw
5212
+ * (`failed`). Never a device's own change, and never proof the device obeyed. Payload: `DeviceCommandSettledEvent`
5213
5213
  * (`{deviceId, action, outcome, actor, at}`, no arguments). It feeds
5214
5214
  * the Notification Center `device-command` kind. Telemetry (D8): losing one
5215
5215
  * costs a notification, never state; the audit row is the record.
@@ -7745,6 +7745,15 @@ var BaseAddon = class {
7745
7745
  /** The instance kinds whose switch move this process already ran (or tried), by record kind name. */
7746
7746
  switchMoved = /* @__PURE__ */ new Set();
7747
7747
  lastDeclared = [];
7748
+ /**
7749
+ * Every switch migration this process added to a declaration so far, by id. The engine replaces
7750
+ * an owner's catalogue on each declare, so a later one (a late kind) carries them all: dropping
7751
+ * an earlier id would read its applied ledger row as a newer database.
7752
+ */
7753
+ switchDeclared = /* @__PURE__ */ new Map();
7754
+ /** The seq each kind's move got, fixed at its first declare so its id and seq never change. */
7755
+ switchSeqs = /* @__PURE__ */ new Map();
7756
+ moveInDeclared = false;
7748
7757
  registrySwitchBound() {
7749
7758
  const api = this.ctx.migrationApi;
7750
7759
  const spec = this.registrySwitchSpec;
@@ -7755,7 +7764,7 @@ var BaseAddon = class {
7755
7764
  return [];
7756
7765
  }
7757
7766
  const date = "2026-11-06";
7758
- const moveIn = spec === null ? [] : migrationSet([registrySwitchToBodyMigration({
7767
+ const moveIn = spec === null || this.moveInDeclared ? [] : migrationSet([registrySwitchToBodyMigration({
7759
7768
  addonId: this.ctx.id,
7760
7769
  date,
7761
7770
  seq: 1e3,
@@ -7765,12 +7774,15 @@ var BaseAddon = class {
7765
7774
  records: switchRecordsOverMigrationApi(a),
7766
7775
  kind: spec.kind
7767
7776
  })).bind(api);
7768
- const moveBack = kinds.flatMap(({ kind }, index) => {
7777
+ if (spec !== null) this.moveInDeclared = true;
7778
+ const moveBack = kinds.flatMap(({ kind }) => {
7769
7779
  this.switchMoved.add(kind.name);
7780
+ const seq = 1001 + this.switchSeqs.size;
7781
+ this.switchSeqs.set(kind.name, seq);
7770
7782
  return migrationSet([bodySwitchToRegistryMigration({
7771
7783
  addonId: this.ctx.id,
7772
7784
  date: "2026-11-19",
7773
- seq: 1001 + index,
7785
+ seq,
7774
7786
  kindName: kind.name,
7775
7787
  ...spec === null ? {} : { followsDate: date }
7776
7788
  })], (a) => bodySwitchPortsOver({
@@ -7808,7 +7820,8 @@ var BaseAddon = class {
7808
7820
  async runBound(declared, options) {
7809
7821
  this.lastDeclared = declared;
7810
7822
  const added = this.registrySwitchBound();
7811
- const migrations = [...declared, ...added];
7823
+ for (const m of added) this.switchDeclared.set(m.meta.id, m);
7824
+ const migrations = [...declared, ...[...this.switchDeclared.values()].filter((m) => !declared.some((d) => d.meta.id === m.meta.id))];
7812
7825
  const widened = options?.only === void 0 || added.length === 0 ? options : {
7813
7826
  ...options,
7814
7827
  only: [...new Set([...options.only, ...added.map((m) => m.meta.id)])]
@@ -10639,6 +10652,11 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
10639
10652
  * water, cooling, solar), its system modes and its power. One main read-only
10640
10653
  * `heat-pump-status` cap carries all of it; `heat-pump-control` sets it (D1026). */
10641
10654
  DeviceType["HeatPump"] = "heat-pump";
10655
+ /** A road vehicle reached through its maker's connected-car account: odometer, range,
10656
+ * openings, tyre warnings and the 12 V battery in one read-only `vehicle` cap; where it
10657
+ * is in `location`; fuel, fluids and service in `consumables`. Its lock and its cabin
10658
+ * climate are accessory children (`lock-vehicle`, `climate-vehicle`). */
10659
+ DeviceType["Vehicle"] = "vehicle";
10642
10660
  /** A home energy installation (any vendor): solar, grid, house, a metered heat pump
10643
10661
  * and the storage as branches of one bus. One read-only `energy-system` cap carries
10644
10662
  * every value; the storage is a field of it, never the `battery` cap (#513, #522). */
@@ -34710,7 +34728,16 @@ var DEFAULT_IDLE_EVICT_FACTOR = 5;
34710
34728
  var TtlMemo = class {
34711
34729
  opts;
34712
34730
  entries = /* @__PURE__ */ new Map();
34713
- inFlight = /* @__PURE__ */ new Map();
34731
+ /**
34732
+ * In-flight reads per (key, mode). A `refresh` never joins a `miss`: a miss
34733
+ * may wait unboundedly on a departed node, and the refresher joining it
34734
+ * would never land an observation. A `miss` may join a `refresh`, which is
34735
+ * bounded.
34736
+ */
34737
+ inFlight = {
34738
+ miss: /* @__PURE__ */ new Map(),
34739
+ refresh: /* @__PURE__ */ new Map()
34740
+ };
34714
34741
  /**
34715
34742
  * Per-key invalidation counter. A read stores its result only if the key's
34716
34743
  * generation is still the one it started under, so a read already in flight
@@ -34732,6 +34759,14 @@ var TtlMemo = class {
34732
34759
  this.ttlMs = opts.ttlMs ?? 1e4;
34733
34760
  this.now = opts.now ?? Date.now;
34734
34761
  }
34762
+ /** The in-flight read of `mode` for `key`, if any. Read-only diagnostic seam. */
34763
+ inFlightInfo(key, mode) {
34764
+ const read = this.inFlight[mode].get(key);
34765
+ return read === void 0 ? null : {
34766
+ mode,
34767
+ startedAt: read.startedAt
34768
+ };
34769
+ }
34735
34770
  /** Number of keys currently held. Test/diagnostic seam. */
34736
34771
  get size() {
34737
34772
  return this.entries.size;
@@ -34812,7 +34847,8 @@ var TtlMemo = class {
34812
34847
  */
34813
34848
  invalidate(key) {
34814
34849
  this.entries.delete(key);
34815
- this.inFlight.delete(key);
34850
+ this.inFlight.miss.delete(key);
34851
+ this.inFlight.refresh.delete(key);
34816
34852
  this.generations.set(key, (this.generations.get(key) ?? 0) + 1);
34817
34853
  }
34818
34854
  /**
@@ -34822,7 +34858,19 @@ var TtlMemo = class {
34822
34858
  * is what re-warms a key immediately after {@link invalidate}.
34823
34859
  */
34824
34860
  async refresh(key) {
34825
- await this.read(key, "refresh").catch(() => void 0);
34861
+ await this.refreshOutcome(key);
34862
+ }
34863
+ /** {@link refresh}, reporting how the read ended. Never throws. */
34864
+ async refreshOutcome(key) {
34865
+ try {
34866
+ await this.read(key, "refresh");
34867
+ return { ok: true };
34868
+ } catch (error) {
34869
+ return {
34870
+ ok: false,
34871
+ error
34872
+ };
34873
+ }
34826
34874
  }
34827
34875
  /**
34828
34876
  * Re-read every key still in use and drop the ones nobody has asked for in
@@ -34844,35 +34892,46 @@ var TtlMemo = class {
34844
34892
  /** Drop everything — used on shutdown so no stale state survives. */
34845
34893
  clear() {
34846
34894
  this.entries.clear();
34847
- this.inFlight.clear();
34895
+ this.inFlight.miss.clear();
34896
+ this.inFlight.refresh.clear();
34848
34897
  this.generations.clear();
34849
34898
  this.lastKnown.clear();
34850
34899
  }
34851
34900
  /**
34852
- * One shared in-flight read per key; stores the result on success. A
34853
- * refresh that finds a miss's read in flight joins it — the waiting caller
34854
- * chose to wait, and the refresher never awaits the promise it is handed.
34901
+ * One shared in-flight read per (key, mode); stores the result on success. A
34902
+ * miss joins a miss, else a refresh (bounded). A refresh joins only a
34903
+ * refresh: the refresher exists to observe a node nobody is waiting on, so
34904
+ * it must never inherit a dispatch's unbounded wait.
34855
34905
  */
34856
34906
  read(key, mode) {
34857
- const existing = this.inFlight.get(key);
34858
- if (existing) return existing;
34907
+ const existing = mode === "miss" ? this.inFlight.miss.get(key) ?? this.inFlight.refresh.get(key) : this.inFlight.refresh.get(key);
34908
+ if (existing) return existing.promise;
34859
34909
  const generation = this.generations.get(key) ?? 0;
34860
- const pending = this.opts.load(key, mode).then((value) => {
34910
+ const startedAt = this.now();
34911
+ const slot = this.inFlight[mode];
34912
+ const promise = this.opts.load(key, mode).then((value) => {
34861
34913
  const at = this.now();
34914
+ const prior = this.entries.get(key);
34862
34915
  const stored = {
34863
34916
  value,
34864
34917
  readAt: at,
34865
- usedAt: this.entries.get(key)?.usedAt ?? at
34918
+ startedAt,
34919
+ usedAt: prior?.usedAt ?? at
34866
34920
  };
34867
- this.lastKnown.set(key, stored);
34921
+ const lastKnown = this.lastKnown.get(key);
34922
+ if (lastKnown === void 0 || lastKnown.startedAt <= startedAt) this.lastKnown.set(key, stored);
34868
34923
  if ((this.generations.get(key) ?? 0) !== generation) return value;
34924
+ if (prior !== void 0 && prior.startedAt > startedAt) return value;
34869
34925
  this.entries.set(key, stored);
34870
34926
  return value;
34871
34927
  }).finally(() => {
34872
- if (this.inFlight.get(key) === pending) this.inFlight.delete(key);
34928
+ if (slot.get(key)?.promise === promise) slot.delete(key);
34873
34929
  });
34874
- this.inFlight.set(key, pending);
34875
- return pending;
34930
+ slot.set(key, {
34931
+ promise,
34932
+ startedAt
34933
+ });
34934
+ return promise;
34876
34935
  }
34877
34936
  };
34878
34937
  //#endregion
@@ -35052,6 +35111,8 @@ var SUBJECT_PRESENCE_RECHECK_MS = Math.floor(SUBJECT_PRESENT_STALE_MS / 2);
35052
35111
  * in the line preserves the exact number.
35053
35112
  */
35054
35113
  var REFIRE_LOG_SAMPLE_EVERY = 100;
35114
+ /** An unchanged recovery-refresh line is repeated at most this often per node. */
35115
+ var UNUSABLE_REFRESH_LOG_EVERY_MS = 6e4;
35055
35116
  /**
35056
35117
  * Freshness window for the balancer inputs a session dispatch reads (see
35057
35118
  * {@link TtlMemo}). Re-exported from the shared default so a test can assert
@@ -35321,10 +35382,52 @@ var SessionDispatchController = class {
35321
35382
  this.agentLoads.refresh(CLUSTER_KEY),
35322
35383
  this.nodeCaps.refresh(CLUSTER_KEY),
35323
35384
  this.nodeWeights.refresh(CLUSTER_KEY),
35324
- this.eligibleInferenceDevices.refreshAll(),
35385
+ this.refreshEligibleInferenceDevices(),
35325
35386
  this.inferenceDeviceCaps.refreshAll()
35326
35387
  ]).catch(() => void 0);
35327
35388
  }
35389
+ /**
35390
+ * Re-read the eligibility of every node in use, plus every node the usability
35391
+ * mirror holds unusable. The latter is dropped before election, so nothing
35392
+ * `get`s its key and `refreshAll` would never touch it — it could never be
35393
+ * re-observed, and so never recover. A failed read changes nothing (D49).
35394
+ */
35395
+ async refreshEligibleInferenceDevices() {
35396
+ await Promise.all([this.eligibleInferenceDevices.refreshAll(), ...this.deps.unusableInferenceNodeIds().map((n) => this.refreshUnusableNodeEligibility(n))]);
35397
+ }
35398
+ /** Per unusable node: the last recovery-refresh line logged and when. */
35399
+ unusableRefreshLogged = /* @__PURE__ */ new Map();
35400
+ /**
35401
+ * One recovery refresh of an unusable node, logged on change and at most once
35402
+ * a minute per node: whether it JOINED a refresh already in flight (and that
35403
+ * read's age) and how it ended. Without this a node that never recovers
35404
+ * leaves no trace of why.
35405
+ */
35406
+ async refreshUnusableNodeEligibility(nodeId) {
35407
+ const joined = this.eligibleInferenceDevices.inFlightInfo(nodeId, "refresh");
35408
+ const startedAt = Date.now();
35409
+ const outcome = await this.eligibleInferenceDevices.refreshOutcome(nodeId);
35410
+ const result = outcome.ok ? "settled-ok" : `failed: ${outcome.error instanceof Error ? outcome.error.message : String(outcome.error)}`;
35411
+ const line = `${joined === null ? "own read" : `joined in-flight ${joined.mode}`} · ${outcome.ok ? "ok" : "failed"}`;
35412
+ const last = this.unusableRefreshLogged.get(nodeId);
35413
+ const at = Date.now();
35414
+ if (last !== void 0 && last.line === line && at - last.at < UNUSABLE_REFRESH_LOG_EVERY_MS) return;
35415
+ this.unusableRefreshLogged.set(nodeId, {
35416
+ line,
35417
+ at
35418
+ });
35419
+ this.deps.logger.info("unusable node eligibility refresh", {
35420
+ tags: { nodeId },
35421
+ meta: {
35422
+ joined: joined === null ? null : {
35423
+ mode: joined.mode,
35424
+ ageMs: startedAt - joined.startedAt
35425
+ },
35426
+ outcome: result,
35427
+ tookMs: at - startedAt
35428
+ }
35429
+ });
35430
+ }
35328
35431
  /** Arm the periodic refresh once; a no-op afterwards and after shutdown. */
35329
35432
  ensureBalancerRefreshTimer() {
35330
35433
  if (this.balancerRefreshTimer !== null || this.shuttingDown) return;
@@ -35333,7 +35436,7 @@ var SessionDispatchController = class {
35333
35436
  this.agentLoads.refreshAll(),
35334
35437
  this.nodeCaps.refreshAll(),
35335
35438
  this.nodeWeights.refreshAll(),
35336
- this.eligibleInferenceDevices.refreshAll(),
35439
+ this.refreshEligibleInferenceDevices(),
35337
35440
  this.inferenceDeviceCaps.refreshAll()
35338
35441
  ]).catch(() => void 0);
35339
35442
  }, BALANCER_REFRESH_INTERVAL_MS);
@@ -37223,6 +37326,7 @@ async function buildOrchestratorControllers(deps) {
37223
37326
  readPipelinePin: (deviceId) => deps.readPipelinePin(deviceId),
37224
37327
  getEligibleInferenceDevices: (nodeId, read) => deps.getEligibleInferenceDevices(nodeId, read),
37225
37328
  isNodeInferenceUsable: (nodeId) => deps.isNodeInferenceUsable(nodeId),
37329
+ unusableInferenceNodeIds: () => deps.unusableInferenceNodeIds(),
37226
37330
  isDefaultPoolExcluded: (nodeId) => deps.isDefaultPoolExcluded(nodeId),
37227
37331
  getInferenceDeviceCaps: (nodeId) => deps.getInferenceDeviceCaps(nodeId),
37228
37332
  readPipelineDevicePin: (deviceId) => deps.readPipelineDevicePin(deviceId),
@@ -40146,6 +40250,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
40146
40250
  forgetInferenceDeviceProbe: (nodeId) => this.forgetInferenceDeviceProbe(nodeId),
40147
40251
  noteShareTopologyChange: (trigger) => this.noteShareChange(trigger),
40148
40252
  isNodeInferenceUsable: (nodeId) => this.isNodeInferenceUsable(nodeId),
40253
+ unusableInferenceNodeIds: () => this.nodeInferenceUsability.unusableNodeIds(),
40149
40254
  isDefaultPoolExcluded: (nodeId) => this.isDefaultPoolExcluded(nodeId),
40150
40255
  getInferenceDeviceCaps: (nodeId) => this.getInferenceDeviceCaps(nodeId),
40151
40256
  readPipelineDevicePin: (deviceId) => this.readPipelineDevicePin(deviceId),
package/dist/index.mjs CHANGED
@@ -5179,9 +5179,9 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
5179
5179
  */
5180
5180
  EventCategory["DeviceStateChanged"] = "device.state-changed";
5181
5181
  /**
5182
- * A device COMMAND (a vocabulary action, D920/D983) settled in the hub's
5183
- * transition audit (D1022): confirmed, already in place, unconfirmed or
5184
- * failed. Never a device's own change. Payload: `DeviceCommandSettledEvent`
5182
+ * A device COMMAND (a vocabulary action, D920/D983) completed, as the hub's
5183
+ * command audit saw it (D1022, D1084): the call returned (`ok`) or threw
5184
+ * (`failed`). Never a device's own change, and never proof the device obeyed. Payload: `DeviceCommandSettledEvent`
5185
5185
  * (`{deviceId, action, outcome, actor, at}`, no arguments). It feeds
5186
5186
  * the Notification Center `device-command` kind. Telemetry (D8): losing one
5187
5187
  * costs a notification, never state; the audit row is the record.
@@ -7717,6 +7717,15 @@ var BaseAddon = class {
7717
7717
  /** The instance kinds whose switch move this process already ran (or tried), by record kind name. */
7718
7718
  switchMoved = /* @__PURE__ */ new Set();
7719
7719
  lastDeclared = [];
7720
+ /**
7721
+ * Every switch migration this process added to a declaration so far, by id. The engine replaces
7722
+ * an owner's catalogue on each declare, so a later one (a late kind) carries them all: dropping
7723
+ * an earlier id would read its applied ledger row as a newer database.
7724
+ */
7725
+ switchDeclared = /* @__PURE__ */ new Map();
7726
+ /** The seq each kind's move got, fixed at its first declare so its id and seq never change. */
7727
+ switchSeqs = /* @__PURE__ */ new Map();
7728
+ moveInDeclared = false;
7720
7729
  registrySwitchBound() {
7721
7730
  const api = this.ctx.migrationApi;
7722
7731
  const spec = this.registrySwitchSpec;
@@ -7727,7 +7736,7 @@ var BaseAddon = class {
7727
7736
  return [];
7728
7737
  }
7729
7738
  const date = "2026-11-06";
7730
- const moveIn = spec === null ? [] : migrationSet([registrySwitchToBodyMigration({
7739
+ const moveIn = spec === null || this.moveInDeclared ? [] : migrationSet([registrySwitchToBodyMigration({
7731
7740
  addonId: this.ctx.id,
7732
7741
  date,
7733
7742
  seq: 1e3,
@@ -7737,12 +7746,15 @@ var BaseAddon = class {
7737
7746
  records: switchRecordsOverMigrationApi(a),
7738
7747
  kind: spec.kind
7739
7748
  })).bind(api);
7740
- const moveBack = kinds.flatMap(({ kind }, index) => {
7749
+ if (spec !== null) this.moveInDeclared = true;
7750
+ const moveBack = kinds.flatMap(({ kind }) => {
7741
7751
  this.switchMoved.add(kind.name);
7752
+ const seq = 1001 + this.switchSeqs.size;
7753
+ this.switchSeqs.set(kind.name, seq);
7742
7754
  return migrationSet([bodySwitchToRegistryMigration({
7743
7755
  addonId: this.ctx.id,
7744
7756
  date: "2026-11-19",
7745
- seq: 1001 + index,
7757
+ seq,
7746
7758
  kindName: kind.name,
7747
7759
  ...spec === null ? {} : { followsDate: date }
7748
7760
  })], (a) => bodySwitchPortsOver({
@@ -7780,7 +7792,8 @@ var BaseAddon = class {
7780
7792
  async runBound(declared, options) {
7781
7793
  this.lastDeclared = declared;
7782
7794
  const added = this.registrySwitchBound();
7783
- const migrations = [...declared, ...added];
7795
+ for (const m of added) this.switchDeclared.set(m.meta.id, m);
7796
+ const migrations = [...declared, ...[...this.switchDeclared.values()].filter((m) => !declared.some((d) => d.meta.id === m.meta.id))];
7784
7797
  const widened = options?.only === void 0 || added.length === 0 ? options : {
7785
7798
  ...options,
7786
7799
  only: [...new Set([...options.only, ...added.map((m) => m.meta.id)])]
@@ -10611,6 +10624,11 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
10611
10624
  * water, cooling, solar), its system modes and its power. One main read-only
10612
10625
  * `heat-pump-status` cap carries all of it; `heat-pump-control` sets it (D1026). */
10613
10626
  DeviceType["HeatPump"] = "heat-pump";
10627
+ /** A road vehicle reached through its maker's connected-car account: odometer, range,
10628
+ * openings, tyre warnings and the 12 V battery in one read-only `vehicle` cap; where it
10629
+ * is in `location`; fuel, fluids and service in `consumables`. Its lock and its cabin
10630
+ * climate are accessory children (`lock-vehicle`, `climate-vehicle`). */
10631
+ DeviceType["Vehicle"] = "vehicle";
10614
10632
  /** A home energy installation (any vendor): solar, grid, house, a metered heat pump
10615
10633
  * and the storage as branches of one bus. One read-only `energy-system` cap carries
10616
10634
  * every value; the storage is a field of it, never the `battery` cap (#513, #522). */
@@ -34682,7 +34700,16 @@ var DEFAULT_IDLE_EVICT_FACTOR = 5;
34682
34700
  var TtlMemo = class {
34683
34701
  opts;
34684
34702
  entries = /* @__PURE__ */ new Map();
34685
- inFlight = /* @__PURE__ */ new Map();
34703
+ /**
34704
+ * In-flight reads per (key, mode). A `refresh` never joins a `miss`: a miss
34705
+ * may wait unboundedly on a departed node, and the refresher joining it
34706
+ * would never land an observation. A `miss` may join a `refresh`, which is
34707
+ * bounded.
34708
+ */
34709
+ inFlight = {
34710
+ miss: /* @__PURE__ */ new Map(),
34711
+ refresh: /* @__PURE__ */ new Map()
34712
+ };
34686
34713
  /**
34687
34714
  * Per-key invalidation counter. A read stores its result only if the key's
34688
34715
  * generation is still the one it started under, so a read already in flight
@@ -34704,6 +34731,14 @@ var TtlMemo = class {
34704
34731
  this.ttlMs = opts.ttlMs ?? 1e4;
34705
34732
  this.now = opts.now ?? Date.now;
34706
34733
  }
34734
+ /** The in-flight read of `mode` for `key`, if any. Read-only diagnostic seam. */
34735
+ inFlightInfo(key, mode) {
34736
+ const read = this.inFlight[mode].get(key);
34737
+ return read === void 0 ? null : {
34738
+ mode,
34739
+ startedAt: read.startedAt
34740
+ };
34741
+ }
34707
34742
  /** Number of keys currently held. Test/diagnostic seam. */
34708
34743
  get size() {
34709
34744
  return this.entries.size;
@@ -34784,7 +34819,8 @@ var TtlMemo = class {
34784
34819
  */
34785
34820
  invalidate(key) {
34786
34821
  this.entries.delete(key);
34787
- this.inFlight.delete(key);
34822
+ this.inFlight.miss.delete(key);
34823
+ this.inFlight.refresh.delete(key);
34788
34824
  this.generations.set(key, (this.generations.get(key) ?? 0) + 1);
34789
34825
  }
34790
34826
  /**
@@ -34794,7 +34830,19 @@ var TtlMemo = class {
34794
34830
  * is what re-warms a key immediately after {@link invalidate}.
34795
34831
  */
34796
34832
  async refresh(key) {
34797
- await this.read(key, "refresh").catch(() => void 0);
34833
+ await this.refreshOutcome(key);
34834
+ }
34835
+ /** {@link refresh}, reporting how the read ended. Never throws. */
34836
+ async refreshOutcome(key) {
34837
+ try {
34838
+ await this.read(key, "refresh");
34839
+ return { ok: true };
34840
+ } catch (error) {
34841
+ return {
34842
+ ok: false,
34843
+ error
34844
+ };
34845
+ }
34798
34846
  }
34799
34847
  /**
34800
34848
  * Re-read every key still in use and drop the ones nobody has asked for in
@@ -34816,35 +34864,46 @@ var TtlMemo = class {
34816
34864
  /** Drop everything — used on shutdown so no stale state survives. */
34817
34865
  clear() {
34818
34866
  this.entries.clear();
34819
- this.inFlight.clear();
34867
+ this.inFlight.miss.clear();
34868
+ this.inFlight.refresh.clear();
34820
34869
  this.generations.clear();
34821
34870
  this.lastKnown.clear();
34822
34871
  }
34823
34872
  /**
34824
- * One shared in-flight read per key; stores the result on success. A
34825
- * refresh that finds a miss's read in flight joins it — the waiting caller
34826
- * chose to wait, and the refresher never awaits the promise it is handed.
34873
+ * One shared in-flight read per (key, mode); stores the result on success. A
34874
+ * miss joins a miss, else a refresh (bounded). A refresh joins only a
34875
+ * refresh: the refresher exists to observe a node nobody is waiting on, so
34876
+ * it must never inherit a dispatch's unbounded wait.
34827
34877
  */
34828
34878
  read(key, mode) {
34829
- const existing = this.inFlight.get(key);
34830
- if (existing) return existing;
34879
+ const existing = mode === "miss" ? this.inFlight.miss.get(key) ?? this.inFlight.refresh.get(key) : this.inFlight.refresh.get(key);
34880
+ if (existing) return existing.promise;
34831
34881
  const generation = this.generations.get(key) ?? 0;
34832
- const pending = this.opts.load(key, mode).then((value) => {
34882
+ const startedAt = this.now();
34883
+ const slot = this.inFlight[mode];
34884
+ const promise = this.opts.load(key, mode).then((value) => {
34833
34885
  const at = this.now();
34886
+ const prior = this.entries.get(key);
34834
34887
  const stored = {
34835
34888
  value,
34836
34889
  readAt: at,
34837
- usedAt: this.entries.get(key)?.usedAt ?? at
34890
+ startedAt,
34891
+ usedAt: prior?.usedAt ?? at
34838
34892
  };
34839
- this.lastKnown.set(key, stored);
34893
+ const lastKnown = this.lastKnown.get(key);
34894
+ if (lastKnown === void 0 || lastKnown.startedAt <= startedAt) this.lastKnown.set(key, stored);
34840
34895
  if ((this.generations.get(key) ?? 0) !== generation) return value;
34896
+ if (prior !== void 0 && prior.startedAt > startedAt) return value;
34841
34897
  this.entries.set(key, stored);
34842
34898
  return value;
34843
34899
  }).finally(() => {
34844
- if (this.inFlight.get(key) === pending) this.inFlight.delete(key);
34900
+ if (slot.get(key)?.promise === promise) slot.delete(key);
34845
34901
  });
34846
- this.inFlight.set(key, pending);
34847
- return pending;
34902
+ slot.set(key, {
34903
+ promise,
34904
+ startedAt
34905
+ });
34906
+ return promise;
34848
34907
  }
34849
34908
  };
34850
34909
  //#endregion
@@ -35024,6 +35083,8 @@ var SUBJECT_PRESENCE_RECHECK_MS = Math.floor(SUBJECT_PRESENT_STALE_MS / 2);
35024
35083
  * in the line preserves the exact number.
35025
35084
  */
35026
35085
  var REFIRE_LOG_SAMPLE_EVERY = 100;
35086
+ /** An unchanged recovery-refresh line is repeated at most this often per node. */
35087
+ var UNUSABLE_REFRESH_LOG_EVERY_MS = 6e4;
35027
35088
  /**
35028
35089
  * Freshness window for the balancer inputs a session dispatch reads (see
35029
35090
  * {@link TtlMemo}). Re-exported from the shared default so a test can assert
@@ -35293,10 +35354,52 @@ var SessionDispatchController = class {
35293
35354
  this.agentLoads.refresh(CLUSTER_KEY),
35294
35355
  this.nodeCaps.refresh(CLUSTER_KEY),
35295
35356
  this.nodeWeights.refresh(CLUSTER_KEY),
35296
- this.eligibleInferenceDevices.refreshAll(),
35357
+ this.refreshEligibleInferenceDevices(),
35297
35358
  this.inferenceDeviceCaps.refreshAll()
35298
35359
  ]).catch(() => void 0);
35299
35360
  }
35361
+ /**
35362
+ * Re-read the eligibility of every node in use, plus every node the usability
35363
+ * mirror holds unusable. The latter is dropped before election, so nothing
35364
+ * `get`s its key and `refreshAll` would never touch it — it could never be
35365
+ * re-observed, and so never recover. A failed read changes nothing (D49).
35366
+ */
35367
+ async refreshEligibleInferenceDevices() {
35368
+ await Promise.all([this.eligibleInferenceDevices.refreshAll(), ...this.deps.unusableInferenceNodeIds().map((n) => this.refreshUnusableNodeEligibility(n))]);
35369
+ }
35370
+ /** Per unusable node: the last recovery-refresh line logged and when. */
35371
+ unusableRefreshLogged = /* @__PURE__ */ new Map();
35372
+ /**
35373
+ * One recovery refresh of an unusable node, logged on change and at most once
35374
+ * a minute per node: whether it JOINED a refresh already in flight (and that
35375
+ * read's age) and how it ended. Without this a node that never recovers
35376
+ * leaves no trace of why.
35377
+ */
35378
+ async refreshUnusableNodeEligibility(nodeId) {
35379
+ const joined = this.eligibleInferenceDevices.inFlightInfo(nodeId, "refresh");
35380
+ const startedAt = Date.now();
35381
+ const outcome = await this.eligibleInferenceDevices.refreshOutcome(nodeId);
35382
+ const result = outcome.ok ? "settled-ok" : `failed: ${outcome.error instanceof Error ? outcome.error.message : String(outcome.error)}`;
35383
+ const line = `${joined === null ? "own read" : `joined in-flight ${joined.mode}`} · ${outcome.ok ? "ok" : "failed"}`;
35384
+ const last = this.unusableRefreshLogged.get(nodeId);
35385
+ const at = Date.now();
35386
+ if (last !== void 0 && last.line === line && at - last.at < UNUSABLE_REFRESH_LOG_EVERY_MS) return;
35387
+ this.unusableRefreshLogged.set(nodeId, {
35388
+ line,
35389
+ at
35390
+ });
35391
+ this.deps.logger.info("unusable node eligibility refresh", {
35392
+ tags: { nodeId },
35393
+ meta: {
35394
+ joined: joined === null ? null : {
35395
+ mode: joined.mode,
35396
+ ageMs: startedAt - joined.startedAt
35397
+ },
35398
+ outcome: result,
35399
+ tookMs: at - startedAt
35400
+ }
35401
+ });
35402
+ }
35300
35403
  /** Arm the periodic refresh once; a no-op afterwards and after shutdown. */
35301
35404
  ensureBalancerRefreshTimer() {
35302
35405
  if (this.balancerRefreshTimer !== null || this.shuttingDown) return;
@@ -35305,7 +35408,7 @@ var SessionDispatchController = class {
35305
35408
  this.agentLoads.refreshAll(),
35306
35409
  this.nodeCaps.refreshAll(),
35307
35410
  this.nodeWeights.refreshAll(),
35308
- this.eligibleInferenceDevices.refreshAll(),
35411
+ this.refreshEligibleInferenceDevices(),
35309
35412
  this.inferenceDeviceCaps.refreshAll()
35310
35413
  ]).catch(() => void 0);
35311
35414
  }, BALANCER_REFRESH_INTERVAL_MS);
@@ -37195,6 +37298,7 @@ async function buildOrchestratorControllers(deps) {
37195
37298
  readPipelinePin: (deviceId) => deps.readPipelinePin(deviceId),
37196
37299
  getEligibleInferenceDevices: (nodeId, read) => deps.getEligibleInferenceDevices(nodeId, read),
37197
37300
  isNodeInferenceUsable: (nodeId) => deps.isNodeInferenceUsable(nodeId),
37301
+ unusableInferenceNodeIds: () => deps.unusableInferenceNodeIds(),
37198
37302
  isDefaultPoolExcluded: (nodeId) => deps.isDefaultPoolExcluded(nodeId),
37199
37303
  getInferenceDeviceCaps: (nodeId) => deps.getInferenceDeviceCaps(nodeId),
37200
37304
  readPipelineDevicePin: (deviceId) => deps.readPipelineDevicePin(deviceId),
@@ -40118,6 +40222,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
40118
40222
  forgetInferenceDeviceProbe: (nodeId) => this.forgetInferenceDeviceProbe(nodeId),
40119
40223
  noteShareTopologyChange: (trigger) => this.noteShareChange(trigger),
40120
40224
  isNodeInferenceUsable: (nodeId) => this.isNodeInferenceUsable(nodeId),
40225
+ unusableInferenceNodeIds: () => this.nodeInferenceUsability.unusableNodeIds(),
40121
40226
  isDefaultPoolExcluded: (nodeId) => this.isDefaultPoolExcluded(nodeId),
40122
40227
  getInferenceDeviceCaps: (nodeId) => this.getInferenceDeviceCaps(nodeId),
40123
40228
  readPipelineDevicePin: (deviceId) => this.readPipelineDevicePin(deviceId),
@@ -30,7 +30,7 @@ async function d(e) {
30
30
  }
31
31
  }
32
32
  async function f() {
33
- return l ||= d(() => import("./_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-AvJjxvAe.mjs")).catch((e) => {
33
+ return l ||= d(() => import("./_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-DMzP_4Qp.mjs")).catch((e) => {
34
34
  throw l = void 0, e;
35
35
  }), l;
36
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-pipeline-orchestrator",
3
- "version": "1.2.716",
3
+ "version": "1.2.717",
4
4
  "description": "Hub-side camera-to-agent load balancer — tracks runner capacity and dispatches attachCamera calls to the optimal pipeline-runner instance",
5
5
  "keywords": [
6
6
  "camstack",
@@ -76,7 +76,7 @@
76
76
  }
77
77
  ],
78
78
  "requires": {
79
- "server": ">=1.2.938"
79
+ "server": ">=1.2.942"
80
80
  }
81
81
  },
82
82
  "files": [