@camstack/addon-pipeline-orchestrator 1.2.705 → 1.2.707

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.mjs CHANGED
@@ -6126,7 +6126,7 @@ var ZodIssueCode = {
6126
6126
  var ZodFirstPartyTypeKind;
6127
6127
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6128
6128
  //#endregion
6129
- //#region ../types/dist/runtime-capabilities-qX7BpOYT.mjs
6129
+ //#region ../types/dist/runtime-capabilities-B36VcCR6.mjs
6130
6130
  /**
6131
6131
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6132
6132
  * window to float samples (D455).
@@ -10232,14 +10232,104 @@ var SubscribeAudioChunksInputSchema = object({
10232
10232
  var SubscribeAudioChunksResultSchema = object({
10233
10233
  /** Opaque id passed to `pullAudioChunks` / `unsubscribeAudioChunks`. */
10234
10234
  subscriptionId: string() });
10235
- var BrokerStatsSchema = object({
10236
- status: _enum([
10237
- "idle",
10238
- "connecting",
10239
- "streaming",
10240
- "error",
10241
- "stopped"
10235
+ var BrokerStatusSchema = _enum([
10236
+ "idle",
10237
+ "connecting",
10238
+ "streaming",
10239
+ "error",
10240
+ "stopped"
10241
+ ]);
10242
+ /**
10243
+ * The encode a derived stream's feeder was last spawned with — the read-only
10244
+ * "effective encode". Read off the ffmpeg argv that runs, so it cannot drift
10245
+ * from what the operator's profile and the carrier's rules resolved to.
10246
+ */
10247
+ var DerivedEffectiveEncodeSchema = object({
10248
+ /** `-c:v` of the argv (`libx264`, a hardware encoder, `copy`); null when absent. */
10249
+ encoder: string().nullable(),
10250
+ /** Output frame rate; null when the source cadence passes through unmeasured. */
10251
+ fps: number$1().nullable(),
10252
+ gopFrames: number$1(),
10253
+ /** ABR target (`-b:v`), kbps. */
10254
+ targetKbps: number$1().nullable(),
10255
+ /** Ceiling (`-maxrate`), kbps. */
10256
+ capKbps: number$1().nullable(),
10257
+ bufsizeKbps: number$1().nullable(),
10258
+ /**
10259
+ * `copy` = source audio untouched, `aac` = re-encoded, `profile` = operator's
10260
+ * encode, `none` = the operator dropped the track.
10261
+ */
10262
+ audio: _enum([
10263
+ "copy",
10264
+ "aac",
10265
+ "profile",
10266
+ "none"
10267
+ ])
10268
+ });
10269
+ /**
10270
+ * A derived stream's source: a **profile** slot (follows whatever physical
10271
+ * stream that profile is assigned to) or a **camStream** (pinned to one
10272
+ * physical stream regardless of assignment).
10273
+ */
10274
+ var DerivedSourceRefSchema = union([object({
10275
+ kind: literal("profile"),
10276
+ profile: _enum([
10277
+ "high",
10278
+ "mid",
10279
+ "low"
10280
+ ])
10281
+ }), object({
10282
+ kind: literal("camStream"),
10283
+ camStreamId: string()
10284
+ })]);
10285
+ object({
10286
+ width: number$1().nullable(),
10287
+ height: number$1().nullable(),
10288
+ fps: number$1().nullable(),
10289
+ idrIntervalMs: number$1().nullable(),
10290
+ /** `h264` / `h265` when observed. */
10291
+ videoCodec: _enum(["h264", "h265"]).nullable(),
10292
+ /** Upper-cased SDP name (`AAC`, `PCMU`) when the source has an audio track. */
10293
+ audioCodec: string().nullable()
10294
+ });
10295
+ /**
10296
+ * The full effective encode of a derived-stream profile: the stats the broker
10297
+ * publishes in `getBrokerStats.derivedEncode` plus the resolved geometry, the
10298
+ * flags that say WHY a number differs from the request, and the ffmpeg output
10299
+ * argv. One function (`computeDerivedEncode`) produces it for both the
10300
+ * broker's start path and `previewDerivedEncode`.
10301
+ */
10302
+ var DerivedEncodePreviewSchema = DerivedEffectiveEncodeSchema.extend({
10303
+ /** Final picture size; `null` when neither the profile nor the source names it. */
10304
+ width: number$1().nullable(),
10305
+ height: number$1().nullable(),
10306
+ /** `h264` / `h265` re-encode, `copy` remux; `null` is never returned (the encoder always resolves). */
10307
+ videoCodec: _enum([
10308
+ "h264",
10309
+ "h265",
10310
+ "copy"
10242
10311
  ]),
10312
+ requestedFps: number$1().nullable(),
10313
+ /** The requested fps exceeded the source and the source cadence won. */
10314
+ fpsClampedToSource: boolean(),
10315
+ /** Lowest bitrate accepted for this geometry x fps; `null` when unknown. */
10316
+ floorKbps: number$1().nullable(),
10317
+ /** The explicit bitrate was below the floor and was raised to it. */
10318
+ raisedToFloor: boolean(),
10319
+ /** What the profile asked for when it was raised; `null` otherwise. */
10320
+ requestedKbps: number$1().nullable(),
10321
+ /** Seconds between keyframes; `null` when the output cadence is unknown. */
10322
+ keyframeIntervalSec: number$1().nullable(),
10323
+ /** The ffmpeg argv, with the source loopback URL in `-i`. */
10324
+ args: array(string())
10325
+ });
10326
+ /** Result of `previewDerivedEncode`: a plan, or the reason there is none. */
10327
+ var PreviewDerivedEncodeResultSchema = discriminatedUnion("kind", [object({
10328
+ kind: literal("preview"),
10329
+ preview: DerivedEncodePreviewSchema
10330
+ }), object({ kind: literal("no-source") })]);
10331
+ var BrokerStatsSchema = object({
10332
+ status: BrokerStatusSchema,
10243
10333
  inputFps: number$1(),
10244
10334
  encodedSubscribers: number$1(),
10245
10335
  uptimeMs: number$1(),
@@ -10279,7 +10369,9 @@ var BrokerStatsSchema = object({
10279
10369
  * alone that the mute is on the packet path and not merely persisted.
10280
10370
  */
10281
10371
  audioMuted: boolean().optional(),
10282
- audioMutedDropped: number$1().optional()
10372
+ audioMutedDropped: number$1().optional(),
10373
+ /** Present for a derived broker once its feeder has spawned at least once. */
10374
+ derivedEncode: DerivedEffectiveEncodeSchema.optional()
10283
10375
  });
10284
10376
  /**
10285
10377
  * Exporter-facing "profile restream" entry. Returned by
@@ -23263,7 +23355,7 @@ function sleep(ms) {
23263
23355
  return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
23264
23356
  }
23265
23357
  //#endregion
23266
- //#region ../types/dist/implemented-methods-wFScvZ40.mjs
23358
+ //#region ../types/dist/implemented-methods-BUBqZ2a0.mjs
23267
23359
  /**
23268
23360
  * The ffmpeg build every CamStack node downloads, per platform and arch.
23269
23361
  *
@@ -26035,10 +26127,16 @@ looseObject({
26035
26127
  TargetSchema.omit({ id: true });
26036
26128
  var EncodeProfileSchema = object({
26037
26129
  video: object({
26130
+ /**
26131
+ * `h264` / `h265` re-encode into that codec; `source` re-encodes in whatever
26132
+ * codec the source speaks (a resize that keeps the codec); `copy` remuxes
26133
+ * with no encode at all (so no resize either).
26134
+ */
26038
26135
  codec: _enum([
26039
26136
  "h264",
26040
26137
  "h265",
26041
- "copy"
26138
+ "copy",
26139
+ "source"
26042
26140
  ]),
26043
26141
  profile: _enum([
26044
26142
  "baseline",
@@ -26090,12 +26188,14 @@ var EncodeProfileSchema = object({
26090
26188
  singleSlicePerFrame: boolean().optional()
26091
26189
  }),
26092
26190
  audio: union([literal("passthrough"), object({
26191
+ /** `none` drops the audio track (`-an`); `copy` carries the source's. */
26093
26192
  codec: _enum([
26094
26193
  "opus",
26095
26194
  "aac",
26096
26195
  "pcmu",
26097
26196
  "pcma",
26098
- "copy"
26197
+ "copy",
26198
+ "none"
26099
26199
  ]),
26100
26200
  bitrateKbps: number$1().int().positive().optional(),
26101
26201
  sampleRateHz: number$1().int().positive().optional(),
@@ -56238,7 +56338,11 @@ method(object({
56238
56338
  }).nullable(), {
56239
56339
  kind: "mutation",
56240
56340
  auth: "admin"
56241
- }), method(_void(), array(CameraStreamSchema).readonly()), method(_void(), array(ProfileSlotSchema).readonly()), method(object({ brokerId: string() }), BrokerStatsSchema), method(object({ brokerId: string() }), object({
56341
+ }), method(_void(), array(CameraStreamSchema).readonly()), method(_void(), array(ProfileSlotSchema).readonly()), method(object({ brokerId: string() }), BrokerStatsSchema), method(object({
56342
+ deviceId: number$1().int().nonnegative(),
56343
+ profile: EncodeProfileSchema,
56344
+ source: DerivedSourceRefSchema.optional()
56345
+ }), PreviewDerivedEncodeResultSchema), method(object({ brokerId: string() }), object({
56242
56346
  probed: boolean(),
56243
56347
  summary: string()
56244
56348
  }), {
@@ -73863,7 +73967,13 @@ var pipelineExecutorCapability = {
73863
73967
  /** Pool deaths inside the current window. */
73864
73968
  deaths: number$1(),
73865
73969
  /** The last death's message. */
73866
- lastError: string()
73970
+ lastError: string(),
73971
+ /**
73972
+ * Present when the device is ABSENT rather than dead: the runtime
73973
+ * itself enumerates no such device (`no-gpu-device` — OpenVINO sees
73974
+ * no supported GPU; driver/runtime does not support this iGPU).
73975
+ */
73976
+ absentReason: _enum(["no-gpu-device"]).optional()
73867
73977
  })).readonly() })),
73868
73978
  /**
73869
73979
  * Re-arm a terminally `failed` inference device on `nodeId`: forget its
@@ -74881,7 +74991,8 @@ var StatelessStepRefusalSchema = _enum([
74881
74991
  "unknown-step",
74882
74992
  "model-not-servable",
74883
74993
  "unreadable-frame",
74884
- "execution-failed"
74994
+ "execution-failed",
74995
+ "no-eligible-device"
74885
74996
  ]);
74886
74997
  /**
74887
74998
  * Answer to `runStatelessStep` — a discriminated union rather than a nullable
@@ -81734,7 +81845,8 @@ var InferenceDeviceExclusionReasonSchema = _enum([
81734
81845
  "unavailable",
81735
81846
  "cannot-host-camera-root",
81736
81847
  "accelerator-preferred",
81737
- "root-switched-off"
81848
+ "root-switched-off",
81849
+ "no-gpu-device"
81738
81850
  ]);
81739
81851
  var NodeInferenceDeviceSchema = object({
81740
81852
  /** Stable per-node device key, e.g. `openvino:npu`, `edgetpu:usb`, `cpu`. */
@@ -81767,7 +81879,13 @@ var NodeInferenceDeviceSchema = object({
81767
81879
  enabled: boolean(),
81768
81880
  /** Relative balancer weight for the enabled device (default 1). */
81769
81881
  weight: number$1(),
81770
- /** Per-device concurrent-session cap; null = unlimited (multi-device C4). */
81882
+ /**
81883
+ * Per-device concurrent-session cap; null = unlimited (multi-device C4). A
81884
+ * limit: a camera no device can take within its cap stays on the node's
81885
+ * default pool — EXCEPT when that default pool is an excluded device
81886
+ * (`defaultPoolExcluded`), where it goes over the cap on the least-loaded
81887
+ * eligible device instead (#610).
81888
+ */
81771
81889
  maxSessions: number$1().nullable(),
81772
81890
  /** Object-detection model the executor defaults to for this deviceKey. */
81773
81891
  defaultModelId: string(),
@@ -81817,7 +81935,15 @@ var NodeInferenceDevicesSchema = object({
81817
81935
  nodeId: string(),
81818
81936
  /** False when the node's platform-probe was unreachable (no live device set). */
81819
81937
  reachable: boolean(),
81820
- devices: array(NodeInferenceDeviceSchema).readonly()
81938
+ devices: array(NodeInferenceDeviceSchema).readonly(),
81939
+ /**
81940
+ * The election left NO device and one was excluded because the operator
81941
+ * turned it off or it is not functional (#610): the runner's default pool is
81942
+ * that device, so work with no explicit device (a stateless step, a bench with
81943
+ * no `deviceKey`) is refused rather than run there. Absent = an orchestrator
81944
+ * older than the field, or an unreachable node: nothing is claimed (D315).
81945
+ */
81946
+ defaultPoolExcluded: boolean().optional()
81821
81947
  });
81822
81948
  /**
81823
81949
  * The CLUSTER switch of one pipeline step (D1065):
@@ -82232,6 +82358,11 @@ var pipelineOrchestratorCapability = {
82232
82358
  * `PipelineSettingsStore.buildNodeInferenceDevices` when placing sessions
82233
82359
  * and the per-(node,device) base provisioning via
82234
82360
  * `buildNodeInferenceDeviceSteps`.
82361
+ * `maxSessions` is a LIMIT, with one exception: when the node's default
82362
+ * pool is itself an excluded device (turned off or not functional) a
82363
+ * camera that would overflow every cap is placed over the cap on the
82364
+ * least-loaded eligible device, because the default pool must never serve
82365
+ * it (#610). The overflow is logged, naming any pin it overrode.
82235
82366
  */
82236
82367
  setAgentInferenceDevices: method(object({
82237
82368
  agentNodeId: string(),
@@ -105424,6 +105555,13 @@ Object.freeze({
105424
105555
  access: "view",
105425
105556
  role: "admin"
105426
105557
  },
105558
+ "streamBroker.previewDerivedEncode": {
105559
+ capName: "stream-broker",
105560
+ capScope: "system",
105561
+ addonId: null,
105562
+ access: "view",
105563
+ role: "admin"
105564
+ },
105427
105565
  "streamBroker.probeStream": {
105428
105566
  capName: "stream-broker",
105429
105567
  capScope: "system",
@@ -109755,6 +109893,11 @@ Object.freeze({
109755
109893
  form: "single",
109756
109894
  optional: false
109757
109895
  }],
109896
+ "streamBroker.previewDerivedEncode": [{
109897
+ name: "deviceId",
109898
+ form: "single",
109899
+ optional: false
109900
+ }],
109758
109901
  "streamBroker.produceEventMedia": [{
109759
109902
  name: "deviceId",
109760
109903
  form: "single",
@@ -115771,11 +115914,11 @@ function inferenceDeviceCaps(stored) {
115771
115914
  function isCpuFallback(view) {
115772
115915
  return view.backend === "cpu";
115773
115916
  }
115774
- function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsable, isRootSwitchedOn) {
115917
+ function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsable, isRootSwitchedOn, absentReason) {
115775
115918
  const eligible = {};
115776
115919
  const excluded = [];
115777
115920
  const merged = mergeInferenceDevices(probed, stored);
115778
- const acceleratorServes = merged.some((d) => !isCpuFallback(d) && d.enabled && d.available && (!canRunRoot || canRunRoot(d.format)) && (!isRootSwitchedOn || isRootSwitchedOn(d.key)));
115921
+ const acceleratorServes = merged.some((d) => !isCpuFallback(d) && d.enabled && d.available && (absentReason?.(d.key) ?? null) === null && (!canRunRoot || canRunRoot(d.format)) && (!isRootSwitchedOn || isRootSwitchedOn(d.key)));
115779
115922
  for (const d of merged) {
115780
115923
  if (!d.enabled) {
115781
115924
  excluded.push({
@@ -115793,6 +115936,15 @@ function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsa
115793
115936
  });
115794
115937
  continue;
115795
115938
  }
115939
+ const absent = absentReason?.(d.key) ?? null;
115940
+ if (absent !== null) {
115941
+ excluded.push({
115942
+ key: d.key,
115943
+ reason: absent,
115944
+ format: d.format
115945
+ });
115946
+ continue;
115947
+ }
115796
115948
  if (isPoolUsable && !isPoolUsable(d.key)) {
115797
115949
  excluded.push({
115798
115950
  key: d.key,
@@ -115852,6 +116004,45 @@ function annotateInferenceDeviceExclusions(merged, eligibility) {
115852
116004
  exclusion: reasonByKey.get(view.key) ?? null
115853
116005
  }));
115854
116006
  }
116007
+ /**
116008
+ * The device key of the node's selected engine — the runner's DEFAULT pool — as
116009
+ * the node's catalog reports it; null when the catalog is not known.
116010
+ */
116011
+ function defaultEngineKeyOf(catalog) {
116012
+ if (catalog === null) return null;
116013
+ const { backend, device } = catalog.selectedEngine;
116014
+ if (backend === "cpu") return "cpu";
116015
+ return device ? `${backend}:${device}` : backend;
116016
+ }
116017
+ /** Excluded because the hardware is down or the operator turned it off (not the CPU's opt-in `disabled`). */
116018
+ function isNonFunctionalOrOff(e) {
116019
+ if (e.reason === "unavailable" || e.reason === "no-gpu-device") return true;
116020
+ return e.reason === "disabled" && !e.key.startsWith("cpu");
116021
+ }
116022
+ /**
116023
+ * Is the runner's default pool (the node's selected engine) a device the
116024
+ * election EXCLUDED? `defaultKey` is the device key of that engine
116025
+ * (`inferenceDeviceKey` of the node catalog's `selectedEngine`). When the
116026
+ * engine's device was excluded as non-functional (`unavailable`, `no-gpu-device`)
116027
+ * or turned off by the operator (`disabled`) the answer is true — whether or not
116028
+ * OTHER devices are eligible, which is exactly when an at-cap overflow would
116029
+ * otherwise land on it. Exclusions that are not the operator's or the
116030
+ * hardware's word (`cannot-host-camera-root`, `root-switched-off`,
116031
+ * `accelerator-preferred`) do not count. #610.
116032
+ *
116033
+ * `defaultKey` null = the node's engine is not known: nothing is claimed while
116034
+ * any device is eligible (fail-open, D315/D49); with NOTHING eligible the
116035
+ * first non-functional/off exclusion stands in for it.
116036
+ */
116037
+ function isDefaultPoolExcluded(eligibility, defaultKey = null) {
116038
+ if (defaultKey !== null) {
116039
+ if (defaultKey in eligibility.eligible) return false;
116040
+ const own = eligibility.excluded.find((e) => e.key === defaultKey);
116041
+ if (own !== void 0) return isNonFunctionalOrOff(own);
116042
+ }
116043
+ if (Object.keys(eligibility.eligible).length > 0) return false;
116044
+ return eligibility.excluded.some(isNonFunctionalOrOff);
116045
+ }
115855
116046
  function resolveNodeInferenceUsability(eligibility) {
115856
116047
  const eligibleKeys = Object.keys(eligibility.eligible).toSorted();
115857
116048
  const unavailableKeys = eligibility.excluded.filter((e) => e.reason === "unavailable").map((e) => e.key).toSorted();
@@ -122226,6 +122417,33 @@ function deviceAsLoad(deviceKey, load) {
122226
122417
  };
122227
122418
  }
122228
122419
  /**
122420
+ * Nothing could take the camera within its caps. While the node's default pool
122421
+ * is usable it serves, as it always did. When the default pool is an excluded
122422
+ * device it must not: place on the least-loaded eligible device, over its cap
122423
+ * (per-weight attached cameras, ties by key) and name any pin that was overridden.
122424
+ */
122425
+ function atCapSelection(eligibleKeys, loadByKey, input) {
122426
+ const pin = input.pinnedDeviceKey ?? null;
122427
+ const best = eligibleKeys.map((key) => ({
122428
+ key,
122429
+ score: (loadByKey.get(key)?.attachedCameras ?? 0) / Math.max(input.eligible[key] ?? 1, 1e-6)
122430
+ })).toSorted((a, b) => a.score - b.score || a.key.localeCompare(b.key))[0];
122431
+ if (input.defaultPoolExcluded !== true || best === void 0) return {
122432
+ kind: "default-pool",
122433
+ reason: best === void 0 ? "no-eligible-device" : pin ? "pin-unplaceable" : "all-devices-at-cap",
122434
+ eligibleKeys
122435
+ };
122436
+ return {
122437
+ kind: "selected",
122438
+ deviceKey: best.key,
122439
+ reason: "over-cap",
122440
+ tieBreak: null,
122441
+ eligibleKeys,
122442
+ tiedKeys: [best.key],
122443
+ ...pin !== null && pin !== best.key ? { pinOverridden: pin } : {}
122444
+ };
122445
+ }
122446
+ /**
122229
122447
  * Elect the inference device for one camera on one node.
122230
122448
  *
122231
122449
  * Order (each step short-circuits): pin → capacity → fair tie-break. A pin is
@@ -122242,10 +122460,14 @@ function pickInferenceDevice(input) {
122242
122460
  eligibleKeys
122243
122461
  };
122244
122462
  const pin = input.pinnedDeviceKey ?? null;
122245
- if (eligibleKeys.length === 1 && !pin) return {
122246
- kind: "default-pool",
122247
- reason: "single-eligible-device",
122248
- eligibleKeys
122463
+ const sole = eligibleKeys.length === 1 ? eligibleKeys[0] : void 0;
122464
+ if (sole !== void 0 && !pin) return {
122465
+ kind: "selected",
122466
+ deviceKey: sole,
122467
+ reason: "sole-eligible",
122468
+ tieBreak: null,
122469
+ eligibleKeys,
122470
+ tiedKeys: eligibleKeys
122249
122471
  };
122250
122472
  const loadByKey = new Map((input.loads ?? []).map((l) => [l.deviceKey, l]));
122251
122473
  const healthyKeys = eligibleKeys.filter((k) => !isDeviceSaturated(loadByKey.get(k)));
@@ -122269,11 +122491,7 @@ function pickInferenceDevice(input) {
122269
122491
  };
122270
122492
  }), input.previousDeviceKey ?? null);
122271
122493
  const election = outcome.election;
122272
- if (election.kind === "none") return {
122273
- kind: "default-pool",
122274
- reason: "all-devices-at-cap",
122275
- eligibleKeys
122276
- };
122494
+ if (election.kind === "none") return atCapSelection(eligibleKeys, loadByKey, input);
122277
122495
  history?.noteElected(historyScope, election.key);
122278
122496
  return {
122279
122497
  kind: "selected",
@@ -122298,11 +122516,7 @@ function pickInferenceDevice(input) {
122298
122516
  eligibleNodes: consideredKeys
122299
122517
  };
122300
122518
  const decision = balance(balancerInput);
122301
- if (!decision || decision.kind !== "assigned") return {
122302
- kind: "default-pool",
122303
- reason: pin ? "pin-unplaceable" : "all-devices-at-cap",
122304
- eligibleKeys
122305
- };
122519
+ if (!decision || decision.kind !== "assigned") return atCapSelection(eligibleKeys, loadByKey, input);
122306
122520
  if (decision.reason === "manual") return {
122307
122521
  kind: "selected",
122308
122522
  deviceKey: decision.agentNodeId,
@@ -122792,6 +123006,7 @@ function jumpTargetKeys(roster, electedDeviceKey) {
122792
123006
  * module header.
122793
123007
  */
122794
123008
  async function resolveAttachPipeline(input, store) {
123009
+ if (defaultPoolIsExcluded(input)) return noEligibleDeviceRefusal(input);
122795
123010
  const roster = buildJumpRoster({
122796
123011
  deviceKey: input.deviceKey,
122797
123012
  eligible: input.eligible,
@@ -122813,6 +123028,7 @@ async function resolveAttachPipeline(input, store) {
122813
123028
  * camera behind it (D3, D49).
122814
123029
  */
122815
123030
  async function resolveAttachPipelineIfCatalogCached(input, store) {
123031
+ if (defaultPoolIsExcluded(input)) return noEligibleDeviceRefusal(input);
122816
123032
  const roster = buildJumpRoster({
122817
123033
  deviceKey: input.deviceKey,
122818
123034
  eligible: input.eligible,
@@ -122833,17 +123049,36 @@ function defaultPoolOf(input) {
122833
123049
  function rootRefusal(input, droppedRoots) {
122834
123050
  return {
122835
123051
  kind: "root-refused",
123052
+ cause: "root-unrunnable",
122836
123053
  nodeId: input.nodeId,
122837
123054
  deviceKey: input.deviceKey,
122838
123055
  droppedRoots
122839
123056
  };
122840
123057
  }
123058
+ /** No device elected AND the default pool is an excluded device (#610). */
123059
+ function defaultPoolIsExcluded(input) {
123060
+ return input.deviceKey === void 0 && input.defaultPoolExcluded === true;
123061
+ }
123062
+ function noEligibleDeviceRefusal(input) {
123063
+ return {
123064
+ kind: "root-refused",
123065
+ cause: "no-eligible-device",
123066
+ nodeId: input.nodeId,
123067
+ deviceKey: void 0,
123068
+ droppedRoots: []
123069
+ };
123070
+ }
123071
+ /** The pending reason a refusal is shown under — on the camera status and the load overview. */
123072
+ function refusalPendingReason(refusal) {
123073
+ return refusal.cause === "no-eligible-device" ? `no-eligible-device:${refusal.nodeId}` : `root-unrunnable:${refusal.nodeId}/${refusal.deviceKey ?? "default-pool"}`;
123074
+ }
122841
123075
  /**
122842
123076
  * Whose provisioning an attach applies. The elected device when there is one.
122843
123077
  * With NO elected device the runner's default pool serves the camera; when the
122844
- * node has exactly one eligible device the balancer returns
122845
- * `single-eligible-device` and that default pool IS that device (a Mac's
122846
- * `coreml:all`, an N100 with only its iGPU on), so its model pin and the
123078
+ * node has exactly one eligible device (a Mac's `coreml:all`, an N100 with only
123079
+ * its iGPU on) that default pool IS that device. The balancer now elects such a
123080
+ * device itself (`sole-eligible`), so this branch serves a default-pool
123081
+ * dispatch on a one-device node; its model pin and the
122847
123082
  * camera's override stored under its key apply (D745 — before, the empty key
122848
123083
  * was read, which no store writes, and the pin was silently never run).
122849
123084
  * Otherwise `''`: the node's folded settings with no hardware fields.
@@ -123267,9 +123502,20 @@ var PlacementService = class {
123267
123502
  caps,
123268
123503
  pinnedDeviceKey,
123269
123504
  currentDeviceKey: input.currentDeviceKey,
123270
- rotation: this.deps.inferenceRotation
123505
+ rotation: this.deps.inferenceRotation,
123506
+ defaultPoolExcluded: this.deps.isDefaultPoolExcluded?.(input.nodeId) === true
123271
123507
  });
123272
123508
  const deviceKey = selectedDeviceKey(selection);
123509
+ if (selection.kind === "selected" && selection.pinOverridden !== void 0) this.deps.ctx().logger.warn("pinned inference device at cap and the default pool is excluded: placed over cap elsewhere", {
123510
+ tags: {
123511
+ deviceId: input.deviceId,
123512
+ nodeId: input.nodeId
123513
+ },
123514
+ meta: {
123515
+ pin: selection.pinOverridden,
123516
+ chosen: selection.deviceKey
123517
+ }
123518
+ });
123273
123519
  this.deps.ctx().logger.info("inference device selection", {
123274
123520
  tags: {
123275
123521
  deviceId: input.deviceId,
@@ -123291,7 +123537,8 @@ var PlacementService = class {
123291
123537
  kind: "elected",
123292
123538
  deviceKey,
123293
123539
  eligible,
123294
- caps
123540
+ caps,
123541
+ defaultPoolExcluded: this.deps.isDefaultPoolExcluded?.(input.nodeId) === true
123295
123542
  };
123296
123543
  }
123297
123544
  /**
@@ -123307,7 +123554,8 @@ var PlacementService = class {
123307
123554
  nodeId: input.nodeId,
123308
123555
  deviceKey: election.deviceKey,
123309
123556
  eligible: election.eligible,
123310
- caps: election.caps
123557
+ caps: election.caps,
123558
+ defaultPoolExcluded: election.defaultPoolExcluded
123311
123559
  };
123312
123560
  if (input.read.kind === "await-catalog") return resolveAttachPipeline(attachInput, this.deps.settingsStore);
123313
123561
  const outcome = await resolveAttachPipelineIfCatalogCached(attachInput, this.deps.settingsStore);
@@ -123330,7 +123578,8 @@ var PlacementService = class {
123330
123578
  return resolveAttachPipeline({
123331
123579
  ...input,
123332
123580
  eligible,
123333
- caps
123581
+ caps,
123582
+ defaultPoolExcluded: this.deps.isDefaultPoolExcluded?.(input.nodeId) === true
123334
123583
  }, this.deps.settingsStore);
123335
123584
  }
123336
123585
  /**
@@ -123731,7 +123980,7 @@ var PlacementService = class {
123731
123980
  read: { kind: "cached-catalog" }
123732
123981
  });
123733
123982
  if (placement.kind !== "resolved") {
123734
- const reason = placement.kind === "root-refused" ? `root-unrunnable:${placement.nodeId}/${placement.deviceKey ?? "default-pool"}` : `${placement.what}-unavailable:${placement.nodeId}`;
123983
+ const reason = placement.kind === "root-refused" ? refusalPendingReason(placement) : `${placement.what}-unavailable:${placement.nodeId}`;
123735
123984
  skipped.push({
123736
123985
  deviceId,
123737
123986
  targetNodeId: decision.agentNodeId,
@@ -124115,9 +124364,10 @@ var PlacementService = class {
124115
124364
  * re-place it. The camera stays pending instead, once-per-change logged.
124116
124365
  */
124117
124366
  leavePendingRootRefused(deviceId, refusal) {
124118
- const reason = `root-unrunnable:${refusal.nodeId}/${refusal.deviceKey ?? "default-pool"}`;
124367
+ const reason = refusalPendingReason(refusal);
124119
124368
  if (!this.setPendingIfChanged(deviceId, reason)) return;
124120
- this.deps.ctx().logger.error("attach refused — the elected device cannot run the camera root; camera left pending", {
124369
+ const noDevice = refusal.cause === "no-eligible-device";
124370
+ this.deps.ctx().logger.error(noDevice ? "attach refused — no eligible inference device on the node; camera left pending (no default-pool fallback)" : "attach refused — the elected device cannot run the camera root; camera left pending", {
124121
124371
  tags: {
124122
124372
  deviceId,
124123
124373
  nodeId: refusal.nodeId
@@ -124126,7 +124376,7 @@ var PlacementService = class {
124126
124376
  reason,
124127
124377
  deviceKey: refusal.deviceKey ?? null,
124128
124378
  droppedRoots: refusal.droppedRoots.join(","),
124129
- hint: "the root is never jumped: enable a device on this node whose format ships the root model, or disable the device that cannot"
124379
+ hint: noDevice ? "every inference device of this node is disabled in load balancing or not functional: enable one (or fix its runtime) and the camera is placed on the next round" : "the root is never jumped: enable a device on this node whose format ships the root model, or disable the device that cannot"
124130
124380
  }
124131
124381
  });
124132
124382
  }
@@ -129864,9 +130114,20 @@ var SessionDispatchController = class {
129864
130114
  shareHistory: this.deps.shareHistory,
129865
130115
  historyScope: targetNodeId
129866
130116
  } : {},
129867
- previousDeviceKey
130117
+ previousDeviceKey,
130118
+ defaultPoolExcluded: this.deps.isDefaultPoolExcluded?.(targetNodeId) === true
129868
130119
  });
129869
130120
  const deviceKey = selectedDeviceKey(selection);
130121
+ if (selection.kind === "selected" && selection.pinOverridden !== void 0) log.warn("pinned inference device at cap and the default pool is excluded: placed over cap elsewhere", {
130122
+ tags: {
130123
+ deviceId,
130124
+ nodeId: targetNodeId
130125
+ },
130126
+ meta: {
130127
+ pin: selection.pinOverridden,
130128
+ chosen: selection.deviceKey
130129
+ }
130130
+ });
129870
130131
  log.info("inference device selection", {
129871
130132
  tags: {
129872
130133
  deviceId,
@@ -129896,14 +130157,16 @@ var SessionDispatchController = class {
129896
130157
  nodeId: targetNodeId,
129897
130158
  deviceKey,
129898
130159
  eligible: enabledDevices,
129899
- caps: deviceCaps
130160
+ caps: deviceCaps,
130161
+ defaultPoolExcluded: this.deps.isDefaultPoolExcluded?.(targetNodeId) === true
129900
130162
  }, this.deps.settingsStore);
129901
130163
  if (outcome.kind === "root-refused") {
129902
- const reason = `root-unrunnable:${targetNodeId}/${outcome.deviceKey ?? "default-pool"}`;
130164
+ const reason = refusalPendingReason(outcome);
129903
130165
  this.deps.sessionAffinity?.forget(deviceId);
129904
130166
  if (this.sessionRefusals.get(deviceId) !== reason) {
129905
130167
  this.sessionRefusals.set(deviceId, reason);
129906
- log.error("detection session refused — the elected device cannot run the camera root", {
130168
+ const noDevice = outcome.cause === "no-eligible-device";
130169
+ log.error(noDevice ? "detection session refused — no eligible inference device on the node (no default-pool fallback)" : "detection session refused — the elected device cannot run the camera root", {
129907
130170
  tags: {
129908
130171
  deviceId,
129909
130172
  nodeId: targetNodeId
@@ -129912,7 +130175,7 @@ var SessionDispatchController = class {
129912
130175
  reason,
129913
130176
  deviceKey: outcome.deviceKey ?? null,
129914
130177
  droppedRoots: outcome.droppedRoots.join(","),
129915
- hint: "the root is never jumped: enable a device on this node whose format ships the root model, or disable the device that cannot; said once until the refusal changes"
130178
+ hint: noDevice ? "every inference device of this node is disabled in load balancing or not functional; said once until the refusal changes" : "the root is never jumped: enable a device on this node whose format ships the root model, or disable the device that cannot; said once until the refusal changes"
129916
130179
  }
129917
130180
  });
129918
130181
  }
@@ -131241,6 +131504,7 @@ async function buildOrchestratorControllers(deps) {
131241
131504
  getEligibleInferenceDevices: (nodeId) => deps.getEligibleInferenceDevices(nodeId, "await-catalog"),
131242
131505
  getEligibleInferenceDevicesIfCached: (nodeId) => deps.getEligibleInferenceDevicesIfCached(nodeId),
131243
131506
  isNodeInferenceUsable: (nodeId) => deps.isNodeInferenceUsable(nodeId),
131507
+ isDefaultPoolExcluded: (nodeId) => deps.isDefaultPoolExcluded(nodeId),
131244
131508
  getInferenceDeviceCaps: (nodeId) => deps.getInferenceDeviceCaps(nodeId),
131245
131509
  readPipelineDevicePin: (deviceId) => deps.readPipelineDevicePin(deviceId),
131246
131510
  inferenceRotation,
@@ -131281,6 +131545,7 @@ async function buildOrchestratorControllers(deps) {
131281
131545
  readPipelinePin: (deviceId) => deps.readPipelinePin(deviceId),
131282
131546
  getEligibleInferenceDevices: (nodeId, read) => deps.getEligibleInferenceDevices(nodeId, read),
131283
131547
  isNodeInferenceUsable: (nodeId) => deps.isNodeInferenceUsable(nodeId),
131548
+ isDefaultPoolExcluded: (nodeId) => deps.isDefaultPoolExcluded(nodeId),
131284
131549
  getInferenceDeviceCaps: (nodeId) => deps.getInferenceDeviceCaps(nodeId),
131285
131550
  readPipelineDevicePin: (deviceId) => deps.readPipelineDevicePin(deviceId),
131286
131551
  inferenceRotation,
@@ -134203,6 +134468,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
134203
134468
  forgetInferenceDeviceProbe: (nodeId) => this.forgetInferenceDeviceProbe(nodeId),
134204
134469
  noteShareTopologyChange: (trigger) => this.noteShareChange(trigger),
134205
134470
  isNodeInferenceUsable: (nodeId) => this.isNodeInferenceUsable(nodeId),
134471
+ isDefaultPoolExcluded: (nodeId) => this.isDefaultPoolExcluded(nodeId),
134206
134472
  getInferenceDeviceCaps: (nodeId) => this.getInferenceDeviceCaps(nodeId),
134207
134473
  readPipelineDevicePin: (deviceId) => this.readPipelineDevicePin(deviceId),
134208
134474
  subscribeToAudioAnalyzerReadiness: (nodeId) => this.subscribeToAudioAnalyzerReadiness(nodeId),
@@ -135088,14 +135354,15 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135088
135354
  const stored = node?.inferenceDevices ?? {};
135089
135355
  const { probed, reachable } = await this.probeNodeInferenceDevices(nodeId);
135090
135356
  const catalog = await this.settingsStore.getCatalogForNode(nodeId);
135091
- const canRunRoot = catalog ? makeRootCapabilityGuard(catalog) : void 0;
135357
+ const eligibility = resolveInferenceDeviceEligibility(probed, stored, catalog ? makeRootCapabilityGuard(catalog) : void 0, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey), catalog ? makeRootSwitchGuard(catalog, await this.settingsStore.readClusterStepModes(), node) : void 0, this.absentReasonFor(nodeId));
135092
135358
  return {
135093
135359
  nodeId,
135094
135360
  reachable,
135095
- devices: annotateInferenceDeviceExclusions(mergeInferenceDevices(probed, stored), resolveInferenceDeviceEligibility(probed, stored, canRunRoot, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey), catalog ? makeRootSwitchGuard(catalog, await this.settingsStore.readClusterStepModes(), node) : void 0)).map((row) => !reachable && row.presence === "absent" ? {
135361
+ devices: annotateInferenceDeviceExclusions(mergeInferenceDevices(probed, stored), eligibility).map((row) => !reachable && row.presence === "absent" ? {
135096
135362
  ...row,
135097
135363
  presence: "unknown"
135098
- } : row)
135364
+ } : row),
135365
+ ...reachable ? { defaultPoolExcluded: isDefaultPoolExcluded(eligibility, defaultEngineKeyOf(catalog)) } : {}
135099
135366
  };
135100
135367
  }
135101
135368
  /**
@@ -135167,6 +135434,9 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135167
135434
  * again, not elected against the list it left with.
135168
135435
  */
135169
135436
  forgetInferenceDeviceProbe(nodeId) {
135437
+ this.absentInferenceDevices.delete(nodeId);
135438
+ this.defaultPoolExcluded.delete(nodeId);
135439
+ this.defaultKeyUnknownLogged.delete(nodeId);
135170
135440
  if (!this.lastInferenceDeviceProbe.delete(nodeId)) return;
135171
135441
  this.ctx.logger.info("inference device probe forgotten — the node left", {
135172
135442
  tags: { nodeId },
@@ -135252,7 +135522,8 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135252
135522
  });
135253
135523
  return;
135254
135524
  }
135255
- this.noteInferenceDeviceHealth(nodeId, poolHealth, probe.probed.map((d) => d.key));
135525
+ this.noteInferenceDeviceHealth(nodeId, poolHealth === null ? null : poolHealth.refused, probe.probed.map((d) => d.key));
135526
+ if (poolHealth !== null) this.noteAbsentInferenceDevices(nodeId, poolHealth.absent);
135256
135527
  const previous = this.lastInferenceDeviceProbe.get(nodeId);
135257
135528
  this.lastInferenceDeviceProbe.set(nodeId, probe.probed);
135258
135529
  if (previous === void 0 || probedDeviceSignature(previous) !== probedDeviceSignature(probe.probed)) {
@@ -135275,10 +135546,22 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135275
135546
  /** Eligibility from a device list + catalog; records usability like every dispatch read. */
135276
135547
  async electableDevices(nodeId, probed, catalog) {
135277
135548
  const node = (await this.settingsStore.readAgentSettingsMap())[nodeId];
135278
- const eligibility = resolveInferenceDeviceEligibility(probed, node?.inferenceDevices ?? {}, catalog ? makeRootCapabilityGuard(catalog) : void 0, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey), catalog ? makeRootSwitchGuard(catalog, await this.settingsStore.readClusterStepModes(), node) : void 0);
135549
+ const eligibility = resolveInferenceDeviceEligibility(probed, node?.inferenceDevices ?? {}, catalog ? makeRootCapabilityGuard(catalog) : void 0, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey), catalog ? makeRootSwitchGuard(catalog, await this.settingsStore.readClusterStepModes(), node) : void 0, this.absentReasonFor(nodeId));
135279
135550
  const { eligible, excluded } = eligibility;
135280
135551
  this.logInferenceDeviceShrinkage(nodeId, eligible, excluded);
135281
135552
  this.noteNodeInferenceUsability(nodeId, resolveNodeInferenceUsability(eligibility));
135553
+ if (probed.length === 0) this.defaultPoolExcluded.delete(nodeId);
135554
+ else {
135555
+ const defaultKey = defaultEngineKeyOf(catalog);
135556
+ if (defaultKey === null && !this.defaultKeyUnknownLogged.has(nodeId)) {
135557
+ this.defaultKeyUnknownLogged.add(nodeId);
135558
+ this.ctx.logger.warn("default inference engine of the node is unknown: its default pool is treated as not excluded while any device is eligible", {
135559
+ tags: { nodeId },
135560
+ meta: { nodeId }
135561
+ });
135562
+ }
135563
+ this.defaultPoolExcluded.set(nodeId, isDefaultPoolExcluded(eligibility, defaultKey));
135564
+ }
135282
135565
  return eligible;
135283
135566
  }
135284
135567
  /**
@@ -135329,6 +135612,17 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135329
135612
  }
135330
135613
  });
135331
135614
  }
135615
+ /**
135616
+ * Nodes whose LAST eligibility read left no eligible device while the
135617
+ * operator had turned one off or it was not functional (#610) — the runner's
135618
+ * default pool would be that device, so a camera there is refused instead.
135619
+ * Written by the same read the election makes; never by a clock.
135620
+ */
135621
+ defaultPoolExcluded = /* @__PURE__ */ new Map();
135622
+ defaultKeyUnknownLogged = /* @__PURE__ */ new Set();
135623
+ isDefaultPoolExcluded(nodeId) {
135624
+ return this.defaultPoolExcluded.get(nodeId) === true;
135625
+ }
135332
135626
  /** Can this node be given cameras? Read synchronously by the two dispatch
135333
135627
  * paths before they hand `eligibleNodes` to the balancer. */
135334
135628
  isNodeInferenceUsable(nodeId) {
@@ -135357,6 +135651,34 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135357
135651
  */
135358
135652
  inferenceDeviceUsability = new InferenceDeviceUsabilityMirror();
135359
135653
  /**
135654
+ * Per node, the devices the executor reports the RUNTIME does not enumerate,
135655
+ * with the named reason. Replaced wholesale by each answered health read (an
135656
+ * empty answer clears it — the driver was fixed); a failed read never reaches
135657
+ * it. Read synchronously by the eligibility resolution.
135658
+ */
135659
+ absentInferenceDevices = /* @__PURE__ */ new Map();
135660
+ absentReasonFor(nodeId) {
135661
+ return (deviceKey) => this.absentInferenceDevices.get(nodeId)?.get(deviceKey) ?? null;
135662
+ }
135663
+ noteAbsentInferenceDevices(nodeId, absent) {
135664
+ const before = this.absentInferenceDevices.get(nodeId);
135665
+ const signature = (m) => [...m ?? []].map(([k, r]) => `${k}=${r}`).toSorted().join(",");
135666
+ if (signature(before) === signature(absent)) return;
135667
+ if (absent.size === 0) this.absentInferenceDevices.delete(nodeId);
135668
+ else this.absentInferenceDevices.set(nodeId, absent);
135669
+ this.ctx.logger.warn("inference devices: the runtime reports devices it does not see", {
135670
+ tags: { nodeId },
135671
+ meta: {
135672
+ nodeId,
135673
+ absent: [...absent].map(([deviceKey, reason]) => ({
135674
+ deviceKey,
135675
+ reason
135676
+ }))
135677
+ }
135678
+ });
135679
+ this.noteShareChange(`devices:${nodeId}`);
135680
+ }
135681
+ /**
135360
135682
  * Ask ONE node's detection executor which of its inference devices it is
135361
135683
  * currently refusing.
135362
135684
  *
@@ -135372,7 +135694,13 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135372
135694
  try {
135373
135695
  const api = this.ctx.api;
135374
135696
  if (!api) return null;
135375
- return (await api.pipelineExecutor.getInferenceDeviceHealth.query({ nodeId })).unhealthy.map((entry) => entry.deviceKey);
135697
+ const health = await api.pipelineExecutor.getInferenceDeviceHealth.query({ nodeId });
135698
+ const absent = /* @__PURE__ */ new Map();
135699
+ for (const entry of health.unhealthy) if (entry.absentReason !== void 0) absent.set(entry.deviceKey, entry.absentReason);
135700
+ return {
135701
+ refused: health.unhealthy.filter((e) => e.absentReason === void 0).map((e) => e.deviceKey),
135702
+ absent
135703
+ };
135376
135704
  } catch (err) {
135377
135705
  this.ctx.logger.warn("inference device health read failed — mirror left unchanged", {
135378
135706
  tags: { nodeId },
@@ -135736,7 +136064,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135736
136064
  if (probed === void 0) continue;
135737
136065
  const stored = blob[nodeId]?.inferenceDevices ?? {};
135738
136066
  const catalog = this.settingsStore.peekCatalogForAgent(nodeId);
135739
- const eligibility = resolveInferenceDeviceEligibility(probed, stored, catalog ? makeRootCapabilityGuard(catalog) : void 0, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey), catalog ? makeRootSwitchGuard(catalog, clusterModes, blob[nodeId]) : void 0);
136067
+ const eligibility = resolveInferenceDeviceEligibility(probed, stored, catalog ? makeRootCapabilityGuard(catalog) : void 0, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey), catalog ? makeRootSwitchGuard(catalog, clusterModes, blob[nodeId]) : void 0, this.absentReasonFor(nodeId));
135740
136068
  out[nodeId] = annotateInferenceDeviceExclusions(mergeInferenceDevices(probed, stored), eligibility).map((d) => ({
135741
136069
  key: d.key,
135742
136070
  available: d.available,