@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.js CHANGED
@@ -6154,7 +6154,7 @@ var ZodIssueCode = {
6154
6154
  var ZodFirstPartyTypeKind;
6155
6155
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6156
6156
  //#endregion
6157
- //#region ../types/dist/runtime-capabilities-qX7BpOYT.mjs
6157
+ //#region ../types/dist/runtime-capabilities-B36VcCR6.mjs
6158
6158
  /**
6159
6159
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6160
6160
  * window to float samples (D455).
@@ -10260,14 +10260,104 @@ var SubscribeAudioChunksInputSchema = object({
10260
10260
  var SubscribeAudioChunksResultSchema = object({
10261
10261
  /** Opaque id passed to `pullAudioChunks` / `unsubscribeAudioChunks`. */
10262
10262
  subscriptionId: string() });
10263
- var BrokerStatsSchema = object({
10264
- status: _enum([
10265
- "idle",
10266
- "connecting",
10267
- "streaming",
10268
- "error",
10269
- "stopped"
10263
+ var BrokerStatusSchema = _enum([
10264
+ "idle",
10265
+ "connecting",
10266
+ "streaming",
10267
+ "error",
10268
+ "stopped"
10269
+ ]);
10270
+ /**
10271
+ * The encode a derived stream's feeder was last spawned with — the read-only
10272
+ * "effective encode". Read off the ffmpeg argv that runs, so it cannot drift
10273
+ * from what the operator's profile and the carrier's rules resolved to.
10274
+ */
10275
+ var DerivedEffectiveEncodeSchema = object({
10276
+ /** `-c:v` of the argv (`libx264`, a hardware encoder, `copy`); null when absent. */
10277
+ encoder: string().nullable(),
10278
+ /** Output frame rate; null when the source cadence passes through unmeasured. */
10279
+ fps: number$1().nullable(),
10280
+ gopFrames: number$1(),
10281
+ /** ABR target (`-b:v`), kbps. */
10282
+ targetKbps: number$1().nullable(),
10283
+ /** Ceiling (`-maxrate`), kbps. */
10284
+ capKbps: number$1().nullable(),
10285
+ bufsizeKbps: number$1().nullable(),
10286
+ /**
10287
+ * `copy` = source audio untouched, `aac` = re-encoded, `profile` = operator's
10288
+ * encode, `none` = the operator dropped the track.
10289
+ */
10290
+ audio: _enum([
10291
+ "copy",
10292
+ "aac",
10293
+ "profile",
10294
+ "none"
10295
+ ])
10296
+ });
10297
+ /**
10298
+ * A derived stream's source: a **profile** slot (follows whatever physical
10299
+ * stream that profile is assigned to) or a **camStream** (pinned to one
10300
+ * physical stream regardless of assignment).
10301
+ */
10302
+ var DerivedSourceRefSchema = union([object({
10303
+ kind: literal("profile"),
10304
+ profile: _enum([
10305
+ "high",
10306
+ "mid",
10307
+ "low"
10308
+ ])
10309
+ }), object({
10310
+ kind: literal("camStream"),
10311
+ camStreamId: string()
10312
+ })]);
10313
+ object({
10314
+ width: number$1().nullable(),
10315
+ height: number$1().nullable(),
10316
+ fps: number$1().nullable(),
10317
+ idrIntervalMs: number$1().nullable(),
10318
+ /** `h264` / `h265` when observed. */
10319
+ videoCodec: _enum(["h264", "h265"]).nullable(),
10320
+ /** Upper-cased SDP name (`AAC`, `PCMU`) when the source has an audio track. */
10321
+ audioCodec: string().nullable()
10322
+ });
10323
+ /**
10324
+ * The full effective encode of a derived-stream profile: the stats the broker
10325
+ * publishes in `getBrokerStats.derivedEncode` plus the resolved geometry, the
10326
+ * flags that say WHY a number differs from the request, and the ffmpeg output
10327
+ * argv. One function (`computeDerivedEncode`) produces it for both the
10328
+ * broker's start path and `previewDerivedEncode`.
10329
+ */
10330
+ var DerivedEncodePreviewSchema = DerivedEffectiveEncodeSchema.extend({
10331
+ /** Final picture size; `null` when neither the profile nor the source names it. */
10332
+ width: number$1().nullable(),
10333
+ height: number$1().nullable(),
10334
+ /** `h264` / `h265` re-encode, `copy` remux; `null` is never returned (the encoder always resolves). */
10335
+ videoCodec: _enum([
10336
+ "h264",
10337
+ "h265",
10338
+ "copy"
10270
10339
  ]),
10340
+ requestedFps: number$1().nullable(),
10341
+ /** The requested fps exceeded the source and the source cadence won. */
10342
+ fpsClampedToSource: boolean(),
10343
+ /** Lowest bitrate accepted for this geometry x fps; `null` when unknown. */
10344
+ floorKbps: number$1().nullable(),
10345
+ /** The explicit bitrate was below the floor and was raised to it. */
10346
+ raisedToFloor: boolean(),
10347
+ /** What the profile asked for when it was raised; `null` otherwise. */
10348
+ requestedKbps: number$1().nullable(),
10349
+ /** Seconds between keyframes; `null` when the output cadence is unknown. */
10350
+ keyframeIntervalSec: number$1().nullable(),
10351
+ /** The ffmpeg argv, with the source loopback URL in `-i`. */
10352
+ args: array(string())
10353
+ });
10354
+ /** Result of `previewDerivedEncode`: a plan, or the reason there is none. */
10355
+ var PreviewDerivedEncodeResultSchema = discriminatedUnion("kind", [object({
10356
+ kind: literal("preview"),
10357
+ preview: DerivedEncodePreviewSchema
10358
+ }), object({ kind: literal("no-source") })]);
10359
+ var BrokerStatsSchema = object({
10360
+ status: BrokerStatusSchema,
10271
10361
  inputFps: number$1(),
10272
10362
  encodedSubscribers: number$1(),
10273
10363
  uptimeMs: number$1(),
@@ -10307,7 +10397,9 @@ var BrokerStatsSchema = object({
10307
10397
  * alone that the mute is on the packet path and not merely persisted.
10308
10398
  */
10309
10399
  audioMuted: boolean().optional(),
10310
- audioMutedDropped: number$1().optional()
10400
+ audioMutedDropped: number$1().optional(),
10401
+ /** Present for a derived broker once its feeder has spawned at least once. */
10402
+ derivedEncode: DerivedEffectiveEncodeSchema.optional()
10311
10403
  });
10312
10404
  /**
10313
10405
  * Exporter-facing "profile restream" entry. Returned by
@@ -23291,7 +23383,7 @@ function sleep(ms) {
23291
23383
  return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
23292
23384
  }
23293
23385
  //#endregion
23294
- //#region ../types/dist/implemented-methods-wFScvZ40.mjs
23386
+ //#region ../types/dist/implemented-methods-BUBqZ2a0.mjs
23295
23387
  /**
23296
23388
  * The ffmpeg build every CamStack node downloads, per platform and arch.
23297
23389
  *
@@ -26063,10 +26155,16 @@ looseObject({
26063
26155
  TargetSchema.omit({ id: true });
26064
26156
  var EncodeProfileSchema = object({
26065
26157
  video: object({
26158
+ /**
26159
+ * `h264` / `h265` re-encode into that codec; `source` re-encodes in whatever
26160
+ * codec the source speaks (a resize that keeps the codec); `copy` remuxes
26161
+ * with no encode at all (so no resize either).
26162
+ */
26066
26163
  codec: _enum([
26067
26164
  "h264",
26068
26165
  "h265",
26069
- "copy"
26166
+ "copy",
26167
+ "source"
26070
26168
  ]),
26071
26169
  profile: _enum([
26072
26170
  "baseline",
@@ -26118,12 +26216,14 @@ var EncodeProfileSchema = object({
26118
26216
  singleSlicePerFrame: boolean().optional()
26119
26217
  }),
26120
26218
  audio: union([literal("passthrough"), object({
26219
+ /** `none` drops the audio track (`-an`); `copy` carries the source's. */
26121
26220
  codec: _enum([
26122
26221
  "opus",
26123
26222
  "aac",
26124
26223
  "pcmu",
26125
26224
  "pcma",
26126
- "copy"
26225
+ "copy",
26226
+ "none"
26127
26227
  ]),
26128
26228
  bitrateKbps: number$1().int().positive().optional(),
26129
26229
  sampleRateHz: number$1().int().positive().optional(),
@@ -56266,7 +56366,11 @@ method(object({
56266
56366
  }).nullable(), {
56267
56367
  kind: "mutation",
56268
56368
  auth: "admin"
56269
- }), method(_void(), array(CameraStreamSchema).readonly()), method(_void(), array(ProfileSlotSchema).readonly()), method(object({ brokerId: string() }), BrokerStatsSchema), method(object({ brokerId: string() }), object({
56369
+ }), method(_void(), array(CameraStreamSchema).readonly()), method(_void(), array(ProfileSlotSchema).readonly()), method(object({ brokerId: string() }), BrokerStatsSchema), method(object({
56370
+ deviceId: number$1().int().nonnegative(),
56371
+ profile: EncodeProfileSchema,
56372
+ source: DerivedSourceRefSchema.optional()
56373
+ }), PreviewDerivedEncodeResultSchema), method(object({ brokerId: string() }), object({
56270
56374
  probed: boolean(),
56271
56375
  summary: string()
56272
56376
  }), {
@@ -73891,7 +73995,13 @@ var pipelineExecutorCapability = {
73891
73995
  /** Pool deaths inside the current window. */
73892
73996
  deaths: number$1(),
73893
73997
  /** The last death's message. */
73894
- lastError: string()
73998
+ lastError: string(),
73999
+ /**
74000
+ * Present when the device is ABSENT rather than dead: the runtime
74001
+ * itself enumerates no such device (`no-gpu-device` — OpenVINO sees
74002
+ * no supported GPU; driver/runtime does not support this iGPU).
74003
+ */
74004
+ absentReason: _enum(["no-gpu-device"]).optional()
73895
74005
  })).readonly() })),
73896
74006
  /**
73897
74007
  * Re-arm a terminally `failed` inference device on `nodeId`: forget its
@@ -74909,7 +75019,8 @@ var StatelessStepRefusalSchema = _enum([
74909
75019
  "unknown-step",
74910
75020
  "model-not-servable",
74911
75021
  "unreadable-frame",
74912
- "execution-failed"
75022
+ "execution-failed",
75023
+ "no-eligible-device"
74913
75024
  ]);
74914
75025
  /**
74915
75026
  * Answer to `runStatelessStep` — a discriminated union rather than a nullable
@@ -81762,7 +81873,8 @@ var InferenceDeviceExclusionReasonSchema = _enum([
81762
81873
  "unavailable",
81763
81874
  "cannot-host-camera-root",
81764
81875
  "accelerator-preferred",
81765
- "root-switched-off"
81876
+ "root-switched-off",
81877
+ "no-gpu-device"
81766
81878
  ]);
81767
81879
  var NodeInferenceDeviceSchema = object({
81768
81880
  /** Stable per-node device key, e.g. `openvino:npu`, `edgetpu:usb`, `cpu`. */
@@ -81795,7 +81907,13 @@ var NodeInferenceDeviceSchema = object({
81795
81907
  enabled: boolean(),
81796
81908
  /** Relative balancer weight for the enabled device (default 1). */
81797
81909
  weight: number$1(),
81798
- /** Per-device concurrent-session cap; null = unlimited (multi-device C4). */
81910
+ /**
81911
+ * Per-device concurrent-session cap; null = unlimited (multi-device C4). A
81912
+ * limit: a camera no device can take within its cap stays on the node's
81913
+ * default pool — EXCEPT when that default pool is an excluded device
81914
+ * (`defaultPoolExcluded`), where it goes over the cap on the least-loaded
81915
+ * eligible device instead (#610).
81916
+ */
81799
81917
  maxSessions: number$1().nullable(),
81800
81918
  /** Object-detection model the executor defaults to for this deviceKey. */
81801
81919
  defaultModelId: string(),
@@ -81845,7 +81963,15 @@ var NodeInferenceDevicesSchema = object({
81845
81963
  nodeId: string(),
81846
81964
  /** False when the node's platform-probe was unreachable (no live device set). */
81847
81965
  reachable: boolean(),
81848
- devices: array(NodeInferenceDeviceSchema).readonly()
81966
+ devices: array(NodeInferenceDeviceSchema).readonly(),
81967
+ /**
81968
+ * The election left NO device and one was excluded because the operator
81969
+ * turned it off or it is not functional (#610): the runner's default pool is
81970
+ * that device, so work with no explicit device (a stateless step, a bench with
81971
+ * no `deviceKey`) is refused rather than run there. Absent = an orchestrator
81972
+ * older than the field, or an unreachable node: nothing is claimed (D315).
81973
+ */
81974
+ defaultPoolExcluded: boolean().optional()
81849
81975
  });
81850
81976
  /**
81851
81977
  * The CLUSTER switch of one pipeline step (D1065):
@@ -82260,6 +82386,11 @@ var pipelineOrchestratorCapability = {
82260
82386
  * `PipelineSettingsStore.buildNodeInferenceDevices` when placing sessions
82261
82387
  * and the per-(node,device) base provisioning via
82262
82388
  * `buildNodeInferenceDeviceSteps`.
82389
+ * `maxSessions` is a LIMIT, with one exception: when the node's default
82390
+ * pool is itself an excluded device (turned off or not functional) a
82391
+ * camera that would overflow every cap is placed over the cap on the
82392
+ * least-loaded eligible device, because the default pool must never serve
82393
+ * it (#610). The overflow is logged, naming any pin it overrode.
82263
82394
  */
82264
82395
  setAgentInferenceDevices: method(object({
82265
82396
  agentNodeId: string(),
@@ -105452,6 +105583,13 @@ Object.freeze({
105452
105583
  access: "view",
105453
105584
  role: "admin"
105454
105585
  },
105586
+ "streamBroker.previewDerivedEncode": {
105587
+ capName: "stream-broker",
105588
+ capScope: "system",
105589
+ addonId: null,
105590
+ access: "view",
105591
+ role: "admin"
105592
+ },
105455
105593
  "streamBroker.probeStream": {
105456
105594
  capName: "stream-broker",
105457
105595
  capScope: "system",
@@ -109783,6 +109921,11 @@ Object.freeze({
109783
109921
  form: "single",
109784
109922
  optional: false
109785
109923
  }],
109924
+ "streamBroker.previewDerivedEncode": [{
109925
+ name: "deviceId",
109926
+ form: "single",
109927
+ optional: false
109928
+ }],
109786
109929
  "streamBroker.produceEventMedia": [{
109787
109930
  name: "deviceId",
109788
109931
  form: "single",
@@ -115799,11 +115942,11 @@ function inferenceDeviceCaps(stored) {
115799
115942
  function isCpuFallback(view) {
115800
115943
  return view.backend === "cpu";
115801
115944
  }
115802
- function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsable, isRootSwitchedOn) {
115945
+ function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsable, isRootSwitchedOn, absentReason) {
115803
115946
  const eligible = {};
115804
115947
  const excluded = [];
115805
115948
  const merged = mergeInferenceDevices(probed, stored);
115806
- const acceleratorServes = merged.some((d) => !isCpuFallback(d) && d.enabled && d.available && (!canRunRoot || canRunRoot(d.format)) && (!isRootSwitchedOn || isRootSwitchedOn(d.key)));
115949
+ const acceleratorServes = merged.some((d) => !isCpuFallback(d) && d.enabled && d.available && (absentReason?.(d.key) ?? null) === null && (!canRunRoot || canRunRoot(d.format)) && (!isRootSwitchedOn || isRootSwitchedOn(d.key)));
115807
115950
  for (const d of merged) {
115808
115951
  if (!d.enabled) {
115809
115952
  excluded.push({
@@ -115821,6 +115964,15 @@ function resolveInferenceDeviceEligibility(probed, stored, canRunRoot, isPoolUsa
115821
115964
  });
115822
115965
  continue;
115823
115966
  }
115967
+ const absent = absentReason?.(d.key) ?? null;
115968
+ if (absent !== null) {
115969
+ excluded.push({
115970
+ key: d.key,
115971
+ reason: absent,
115972
+ format: d.format
115973
+ });
115974
+ continue;
115975
+ }
115824
115976
  if (isPoolUsable && !isPoolUsable(d.key)) {
115825
115977
  excluded.push({
115826
115978
  key: d.key,
@@ -115880,6 +116032,45 @@ function annotateInferenceDeviceExclusions(merged, eligibility) {
115880
116032
  exclusion: reasonByKey.get(view.key) ?? null
115881
116033
  }));
115882
116034
  }
116035
+ /**
116036
+ * The device key of the node's selected engine — the runner's DEFAULT pool — as
116037
+ * the node's catalog reports it; null when the catalog is not known.
116038
+ */
116039
+ function defaultEngineKeyOf(catalog) {
116040
+ if (catalog === null) return null;
116041
+ const { backend, device } = catalog.selectedEngine;
116042
+ if (backend === "cpu") return "cpu";
116043
+ return device ? `${backend}:${device}` : backend;
116044
+ }
116045
+ /** Excluded because the hardware is down or the operator turned it off (not the CPU's opt-in `disabled`). */
116046
+ function isNonFunctionalOrOff(e) {
116047
+ if (e.reason === "unavailable" || e.reason === "no-gpu-device") return true;
116048
+ return e.reason === "disabled" && !e.key.startsWith("cpu");
116049
+ }
116050
+ /**
116051
+ * Is the runner's default pool (the node's selected engine) a device the
116052
+ * election EXCLUDED? `defaultKey` is the device key of that engine
116053
+ * (`inferenceDeviceKey` of the node catalog's `selectedEngine`). When the
116054
+ * engine's device was excluded as non-functional (`unavailable`, `no-gpu-device`)
116055
+ * or turned off by the operator (`disabled`) the answer is true — whether or not
116056
+ * OTHER devices are eligible, which is exactly when an at-cap overflow would
116057
+ * otherwise land on it. Exclusions that are not the operator's or the
116058
+ * hardware's word (`cannot-host-camera-root`, `root-switched-off`,
116059
+ * `accelerator-preferred`) do not count. #610.
116060
+ *
116061
+ * `defaultKey` null = the node's engine is not known: nothing is claimed while
116062
+ * any device is eligible (fail-open, D315/D49); with NOTHING eligible the
116063
+ * first non-functional/off exclusion stands in for it.
116064
+ */
116065
+ function isDefaultPoolExcluded(eligibility, defaultKey = null) {
116066
+ if (defaultKey !== null) {
116067
+ if (defaultKey in eligibility.eligible) return false;
116068
+ const own = eligibility.excluded.find((e) => e.key === defaultKey);
116069
+ if (own !== void 0) return isNonFunctionalOrOff(own);
116070
+ }
116071
+ if (Object.keys(eligibility.eligible).length > 0) return false;
116072
+ return eligibility.excluded.some(isNonFunctionalOrOff);
116073
+ }
115883
116074
  function resolveNodeInferenceUsability(eligibility) {
115884
116075
  const eligibleKeys = Object.keys(eligibility.eligible).toSorted();
115885
116076
  const unavailableKeys = eligibility.excluded.filter((e) => e.reason === "unavailable").map((e) => e.key).toSorted();
@@ -122254,6 +122445,33 @@ function deviceAsLoad(deviceKey, load) {
122254
122445
  };
122255
122446
  }
122256
122447
  /**
122448
+ * Nothing could take the camera within its caps. While the node's default pool
122449
+ * is usable it serves, as it always did. When the default pool is an excluded
122450
+ * device it must not: place on the least-loaded eligible device, over its cap
122451
+ * (per-weight attached cameras, ties by key) and name any pin that was overridden.
122452
+ */
122453
+ function atCapSelection(eligibleKeys, loadByKey, input) {
122454
+ const pin = input.pinnedDeviceKey ?? null;
122455
+ const best = eligibleKeys.map((key) => ({
122456
+ key,
122457
+ score: (loadByKey.get(key)?.attachedCameras ?? 0) / Math.max(input.eligible[key] ?? 1, 1e-6)
122458
+ })).toSorted((a, b) => a.score - b.score || a.key.localeCompare(b.key))[0];
122459
+ if (input.defaultPoolExcluded !== true || best === void 0) return {
122460
+ kind: "default-pool",
122461
+ reason: best === void 0 ? "no-eligible-device" : pin ? "pin-unplaceable" : "all-devices-at-cap",
122462
+ eligibleKeys
122463
+ };
122464
+ return {
122465
+ kind: "selected",
122466
+ deviceKey: best.key,
122467
+ reason: "over-cap",
122468
+ tieBreak: null,
122469
+ eligibleKeys,
122470
+ tiedKeys: [best.key],
122471
+ ...pin !== null && pin !== best.key ? { pinOverridden: pin } : {}
122472
+ };
122473
+ }
122474
+ /**
122257
122475
  * Elect the inference device for one camera on one node.
122258
122476
  *
122259
122477
  * Order (each step short-circuits): pin → capacity → fair tie-break. A pin is
@@ -122270,10 +122488,14 @@ function pickInferenceDevice(input) {
122270
122488
  eligibleKeys
122271
122489
  };
122272
122490
  const pin = input.pinnedDeviceKey ?? null;
122273
- if (eligibleKeys.length === 1 && !pin) return {
122274
- kind: "default-pool",
122275
- reason: "single-eligible-device",
122276
- eligibleKeys
122491
+ const sole = eligibleKeys.length === 1 ? eligibleKeys[0] : void 0;
122492
+ if (sole !== void 0 && !pin) return {
122493
+ kind: "selected",
122494
+ deviceKey: sole,
122495
+ reason: "sole-eligible",
122496
+ tieBreak: null,
122497
+ eligibleKeys,
122498
+ tiedKeys: eligibleKeys
122277
122499
  };
122278
122500
  const loadByKey = new Map((input.loads ?? []).map((l) => [l.deviceKey, l]));
122279
122501
  const healthyKeys = eligibleKeys.filter((k) => !isDeviceSaturated(loadByKey.get(k)));
@@ -122297,11 +122519,7 @@ function pickInferenceDevice(input) {
122297
122519
  };
122298
122520
  }), input.previousDeviceKey ?? null);
122299
122521
  const election = outcome.election;
122300
- if (election.kind === "none") return {
122301
- kind: "default-pool",
122302
- reason: "all-devices-at-cap",
122303
- eligibleKeys
122304
- };
122522
+ if (election.kind === "none") return atCapSelection(eligibleKeys, loadByKey, input);
122305
122523
  history?.noteElected(historyScope, election.key);
122306
122524
  return {
122307
122525
  kind: "selected",
@@ -122326,11 +122544,7 @@ function pickInferenceDevice(input) {
122326
122544
  eligibleNodes: consideredKeys
122327
122545
  };
122328
122546
  const decision = balance(balancerInput);
122329
- if (!decision || decision.kind !== "assigned") return {
122330
- kind: "default-pool",
122331
- reason: pin ? "pin-unplaceable" : "all-devices-at-cap",
122332
- eligibleKeys
122333
- };
122547
+ if (!decision || decision.kind !== "assigned") return atCapSelection(eligibleKeys, loadByKey, input);
122334
122548
  if (decision.reason === "manual") return {
122335
122549
  kind: "selected",
122336
122550
  deviceKey: decision.agentNodeId,
@@ -122820,6 +123034,7 @@ function jumpTargetKeys(roster, electedDeviceKey) {
122820
123034
  * module header.
122821
123035
  */
122822
123036
  async function resolveAttachPipeline(input, store) {
123037
+ if (defaultPoolIsExcluded(input)) return noEligibleDeviceRefusal(input);
122823
123038
  const roster = buildJumpRoster({
122824
123039
  deviceKey: input.deviceKey,
122825
123040
  eligible: input.eligible,
@@ -122841,6 +123056,7 @@ async function resolveAttachPipeline(input, store) {
122841
123056
  * camera behind it (D3, D49).
122842
123057
  */
122843
123058
  async function resolveAttachPipelineIfCatalogCached(input, store) {
123059
+ if (defaultPoolIsExcluded(input)) return noEligibleDeviceRefusal(input);
122844
123060
  const roster = buildJumpRoster({
122845
123061
  deviceKey: input.deviceKey,
122846
123062
  eligible: input.eligible,
@@ -122861,17 +123077,36 @@ function defaultPoolOf(input) {
122861
123077
  function rootRefusal(input, droppedRoots) {
122862
123078
  return {
122863
123079
  kind: "root-refused",
123080
+ cause: "root-unrunnable",
122864
123081
  nodeId: input.nodeId,
122865
123082
  deviceKey: input.deviceKey,
122866
123083
  droppedRoots
122867
123084
  };
122868
123085
  }
123086
+ /** No device elected AND the default pool is an excluded device (#610). */
123087
+ function defaultPoolIsExcluded(input) {
123088
+ return input.deviceKey === void 0 && input.defaultPoolExcluded === true;
123089
+ }
123090
+ function noEligibleDeviceRefusal(input) {
123091
+ return {
123092
+ kind: "root-refused",
123093
+ cause: "no-eligible-device",
123094
+ nodeId: input.nodeId,
123095
+ deviceKey: void 0,
123096
+ droppedRoots: []
123097
+ };
123098
+ }
123099
+ /** The pending reason a refusal is shown under — on the camera status and the load overview. */
123100
+ function refusalPendingReason(refusal) {
123101
+ return refusal.cause === "no-eligible-device" ? `no-eligible-device:${refusal.nodeId}` : `root-unrunnable:${refusal.nodeId}/${refusal.deviceKey ?? "default-pool"}`;
123102
+ }
122869
123103
  /**
122870
123104
  * Whose provisioning an attach applies. The elected device when there is one.
122871
123105
  * With NO elected device the runner's default pool serves the camera; when the
122872
- * node has exactly one eligible device the balancer returns
122873
- * `single-eligible-device` and that default pool IS that device (a Mac's
122874
- * `coreml:all`, an N100 with only its iGPU on), so its model pin and the
123106
+ * node has exactly one eligible device (a Mac's `coreml:all`, an N100 with only
123107
+ * its iGPU on) that default pool IS that device. The balancer now elects such a
123108
+ * device itself (`sole-eligible`), so this branch serves a default-pool
123109
+ * dispatch on a one-device node; its model pin and the
122875
123110
  * camera's override stored under its key apply (D745 — before, the empty key
122876
123111
  * was read, which no store writes, and the pin was silently never run).
122877
123112
  * Otherwise `''`: the node's folded settings with no hardware fields.
@@ -123295,9 +123530,20 @@ var PlacementService = class {
123295
123530
  caps,
123296
123531
  pinnedDeviceKey,
123297
123532
  currentDeviceKey: input.currentDeviceKey,
123298
- rotation: this.deps.inferenceRotation
123533
+ rotation: this.deps.inferenceRotation,
123534
+ defaultPoolExcluded: this.deps.isDefaultPoolExcluded?.(input.nodeId) === true
123299
123535
  });
123300
123536
  const deviceKey = selectedDeviceKey(selection);
123537
+ 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", {
123538
+ tags: {
123539
+ deviceId: input.deviceId,
123540
+ nodeId: input.nodeId
123541
+ },
123542
+ meta: {
123543
+ pin: selection.pinOverridden,
123544
+ chosen: selection.deviceKey
123545
+ }
123546
+ });
123301
123547
  this.deps.ctx().logger.info("inference device selection", {
123302
123548
  tags: {
123303
123549
  deviceId: input.deviceId,
@@ -123319,7 +123565,8 @@ var PlacementService = class {
123319
123565
  kind: "elected",
123320
123566
  deviceKey,
123321
123567
  eligible,
123322
- caps
123568
+ caps,
123569
+ defaultPoolExcluded: this.deps.isDefaultPoolExcluded?.(input.nodeId) === true
123323
123570
  };
123324
123571
  }
123325
123572
  /**
@@ -123335,7 +123582,8 @@ var PlacementService = class {
123335
123582
  nodeId: input.nodeId,
123336
123583
  deviceKey: election.deviceKey,
123337
123584
  eligible: election.eligible,
123338
- caps: election.caps
123585
+ caps: election.caps,
123586
+ defaultPoolExcluded: election.defaultPoolExcluded
123339
123587
  };
123340
123588
  if (input.read.kind === "await-catalog") return resolveAttachPipeline(attachInput, this.deps.settingsStore);
123341
123589
  const outcome = await resolveAttachPipelineIfCatalogCached(attachInput, this.deps.settingsStore);
@@ -123358,7 +123606,8 @@ var PlacementService = class {
123358
123606
  return resolveAttachPipeline({
123359
123607
  ...input,
123360
123608
  eligible,
123361
- caps
123609
+ caps,
123610
+ defaultPoolExcluded: this.deps.isDefaultPoolExcluded?.(input.nodeId) === true
123362
123611
  }, this.deps.settingsStore);
123363
123612
  }
123364
123613
  /**
@@ -123759,7 +124008,7 @@ var PlacementService = class {
123759
124008
  read: { kind: "cached-catalog" }
123760
124009
  });
123761
124010
  if (placement.kind !== "resolved") {
123762
- const reason = placement.kind === "root-refused" ? `root-unrunnable:${placement.nodeId}/${placement.deviceKey ?? "default-pool"}` : `${placement.what}-unavailable:${placement.nodeId}`;
124011
+ const reason = placement.kind === "root-refused" ? refusalPendingReason(placement) : `${placement.what}-unavailable:${placement.nodeId}`;
123763
124012
  skipped.push({
123764
124013
  deviceId,
123765
124014
  targetNodeId: decision.agentNodeId,
@@ -124143,9 +124392,10 @@ var PlacementService = class {
124143
124392
  * re-place it. The camera stays pending instead, once-per-change logged.
124144
124393
  */
124145
124394
  leavePendingRootRefused(deviceId, refusal) {
124146
- const reason = `root-unrunnable:${refusal.nodeId}/${refusal.deviceKey ?? "default-pool"}`;
124395
+ const reason = refusalPendingReason(refusal);
124147
124396
  if (!this.setPendingIfChanged(deviceId, reason)) return;
124148
- this.deps.ctx().logger.error("attach refused — the elected device cannot run the camera root; camera left pending", {
124397
+ const noDevice = refusal.cause === "no-eligible-device";
124398
+ 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", {
124149
124399
  tags: {
124150
124400
  deviceId,
124151
124401
  nodeId: refusal.nodeId
@@ -124154,7 +124404,7 @@ var PlacementService = class {
124154
124404
  reason,
124155
124405
  deviceKey: refusal.deviceKey ?? null,
124156
124406
  droppedRoots: refusal.droppedRoots.join(","),
124157
- hint: "the root is never jumped: enable a device on this node whose format ships the root model, or disable the device that cannot"
124407
+ 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"
124158
124408
  }
124159
124409
  });
124160
124410
  }
@@ -129892,9 +130142,20 @@ var SessionDispatchController = class {
129892
130142
  shareHistory: this.deps.shareHistory,
129893
130143
  historyScope: targetNodeId
129894
130144
  } : {},
129895
- previousDeviceKey
130145
+ previousDeviceKey,
130146
+ defaultPoolExcluded: this.deps.isDefaultPoolExcluded?.(targetNodeId) === true
129896
130147
  });
129897
130148
  const deviceKey = selectedDeviceKey(selection);
130149
+ 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", {
130150
+ tags: {
130151
+ deviceId,
130152
+ nodeId: targetNodeId
130153
+ },
130154
+ meta: {
130155
+ pin: selection.pinOverridden,
130156
+ chosen: selection.deviceKey
130157
+ }
130158
+ });
129898
130159
  log.info("inference device selection", {
129899
130160
  tags: {
129900
130161
  deviceId,
@@ -129924,14 +130185,16 @@ var SessionDispatchController = class {
129924
130185
  nodeId: targetNodeId,
129925
130186
  deviceKey,
129926
130187
  eligible: enabledDevices,
129927
- caps: deviceCaps
130188
+ caps: deviceCaps,
130189
+ defaultPoolExcluded: this.deps.isDefaultPoolExcluded?.(targetNodeId) === true
129928
130190
  }, this.deps.settingsStore);
129929
130191
  if (outcome.kind === "root-refused") {
129930
- const reason = `root-unrunnable:${targetNodeId}/${outcome.deviceKey ?? "default-pool"}`;
130192
+ const reason = refusalPendingReason(outcome);
129931
130193
  this.deps.sessionAffinity?.forget(deviceId);
129932
130194
  if (this.sessionRefusals.get(deviceId) !== reason) {
129933
130195
  this.sessionRefusals.set(deviceId, reason);
129934
- log.error("detection session refused — the elected device cannot run the camera root", {
130196
+ const noDevice = outcome.cause === "no-eligible-device";
130197
+ 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", {
129935
130198
  tags: {
129936
130199
  deviceId,
129937
130200
  nodeId: targetNodeId
@@ -129940,7 +130203,7 @@ var SessionDispatchController = class {
129940
130203
  reason,
129941
130204
  deviceKey: outcome.deviceKey ?? null,
129942
130205
  droppedRoots: outcome.droppedRoots.join(","),
129943
- 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"
130206
+ 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"
129944
130207
  }
129945
130208
  });
129946
130209
  }
@@ -131269,6 +131532,7 @@ async function buildOrchestratorControllers(deps) {
131269
131532
  getEligibleInferenceDevices: (nodeId) => deps.getEligibleInferenceDevices(nodeId, "await-catalog"),
131270
131533
  getEligibleInferenceDevicesIfCached: (nodeId) => deps.getEligibleInferenceDevicesIfCached(nodeId),
131271
131534
  isNodeInferenceUsable: (nodeId) => deps.isNodeInferenceUsable(nodeId),
131535
+ isDefaultPoolExcluded: (nodeId) => deps.isDefaultPoolExcluded(nodeId),
131272
131536
  getInferenceDeviceCaps: (nodeId) => deps.getInferenceDeviceCaps(nodeId),
131273
131537
  readPipelineDevicePin: (deviceId) => deps.readPipelineDevicePin(deviceId),
131274
131538
  inferenceRotation,
@@ -131309,6 +131573,7 @@ async function buildOrchestratorControllers(deps) {
131309
131573
  readPipelinePin: (deviceId) => deps.readPipelinePin(deviceId),
131310
131574
  getEligibleInferenceDevices: (nodeId, read) => deps.getEligibleInferenceDevices(nodeId, read),
131311
131575
  isNodeInferenceUsable: (nodeId) => deps.isNodeInferenceUsable(nodeId),
131576
+ isDefaultPoolExcluded: (nodeId) => deps.isDefaultPoolExcluded(nodeId),
131312
131577
  getInferenceDeviceCaps: (nodeId) => deps.getInferenceDeviceCaps(nodeId),
131313
131578
  readPipelineDevicePin: (deviceId) => deps.readPipelineDevicePin(deviceId),
131314
131579
  inferenceRotation,
@@ -134231,6 +134496,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
134231
134496
  forgetInferenceDeviceProbe: (nodeId) => this.forgetInferenceDeviceProbe(nodeId),
134232
134497
  noteShareTopologyChange: (trigger) => this.noteShareChange(trigger),
134233
134498
  isNodeInferenceUsable: (nodeId) => this.isNodeInferenceUsable(nodeId),
134499
+ isDefaultPoolExcluded: (nodeId) => this.isDefaultPoolExcluded(nodeId),
134234
134500
  getInferenceDeviceCaps: (nodeId) => this.getInferenceDeviceCaps(nodeId),
134235
134501
  readPipelineDevicePin: (deviceId) => this.readPipelineDevicePin(deviceId),
134236
134502
  subscribeToAudioAnalyzerReadiness: (nodeId) => this.subscribeToAudioAnalyzerReadiness(nodeId),
@@ -135116,14 +135382,15 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135116
135382
  const stored = node?.inferenceDevices ?? {};
135117
135383
  const { probed, reachable } = await this.probeNodeInferenceDevices(nodeId);
135118
135384
  const catalog = await this.settingsStore.getCatalogForNode(nodeId);
135119
- const canRunRoot = catalog ? makeRootCapabilityGuard(catalog) : void 0;
135385
+ 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));
135120
135386
  return {
135121
135387
  nodeId,
135122
135388
  reachable,
135123
- 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" ? {
135389
+ devices: annotateInferenceDeviceExclusions(mergeInferenceDevices(probed, stored), eligibility).map((row) => !reachable && row.presence === "absent" ? {
135124
135390
  ...row,
135125
135391
  presence: "unknown"
135126
- } : row)
135392
+ } : row),
135393
+ ...reachable ? { defaultPoolExcluded: isDefaultPoolExcluded(eligibility, defaultEngineKeyOf(catalog)) } : {}
135127
135394
  };
135128
135395
  }
135129
135396
  /**
@@ -135195,6 +135462,9 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135195
135462
  * again, not elected against the list it left with.
135196
135463
  */
135197
135464
  forgetInferenceDeviceProbe(nodeId) {
135465
+ this.absentInferenceDevices.delete(nodeId);
135466
+ this.defaultPoolExcluded.delete(nodeId);
135467
+ this.defaultKeyUnknownLogged.delete(nodeId);
135198
135468
  if (!this.lastInferenceDeviceProbe.delete(nodeId)) return;
135199
135469
  this.ctx.logger.info("inference device probe forgotten — the node left", {
135200
135470
  tags: { nodeId },
@@ -135280,7 +135550,8 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135280
135550
  });
135281
135551
  return;
135282
135552
  }
135283
- this.noteInferenceDeviceHealth(nodeId, poolHealth, probe.probed.map((d) => d.key));
135553
+ this.noteInferenceDeviceHealth(nodeId, poolHealth === null ? null : poolHealth.refused, probe.probed.map((d) => d.key));
135554
+ if (poolHealth !== null) this.noteAbsentInferenceDevices(nodeId, poolHealth.absent);
135284
135555
  const previous = this.lastInferenceDeviceProbe.get(nodeId);
135285
135556
  this.lastInferenceDeviceProbe.set(nodeId, probe.probed);
135286
135557
  if (previous === void 0 || probedDeviceSignature(previous) !== probedDeviceSignature(probe.probed)) {
@@ -135303,10 +135574,22 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135303
135574
  /** Eligibility from a device list + catalog; records usability like every dispatch read. */
135304
135575
  async electableDevices(nodeId, probed, catalog) {
135305
135576
  const node = (await this.settingsStore.readAgentSettingsMap())[nodeId];
135306
- 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);
135577
+ 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));
135307
135578
  const { eligible, excluded } = eligibility;
135308
135579
  this.logInferenceDeviceShrinkage(nodeId, eligible, excluded);
135309
135580
  this.noteNodeInferenceUsability(nodeId, resolveNodeInferenceUsability(eligibility));
135581
+ if (probed.length === 0) this.defaultPoolExcluded.delete(nodeId);
135582
+ else {
135583
+ const defaultKey = defaultEngineKeyOf(catalog);
135584
+ if (defaultKey === null && !this.defaultKeyUnknownLogged.has(nodeId)) {
135585
+ this.defaultKeyUnknownLogged.add(nodeId);
135586
+ 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", {
135587
+ tags: { nodeId },
135588
+ meta: { nodeId }
135589
+ });
135590
+ }
135591
+ this.defaultPoolExcluded.set(nodeId, isDefaultPoolExcluded(eligibility, defaultKey));
135592
+ }
135310
135593
  return eligible;
135311
135594
  }
135312
135595
  /**
@@ -135357,6 +135640,17 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135357
135640
  }
135358
135641
  });
135359
135642
  }
135643
+ /**
135644
+ * Nodes whose LAST eligibility read left no eligible device while the
135645
+ * operator had turned one off or it was not functional (#610) — the runner's
135646
+ * default pool would be that device, so a camera there is refused instead.
135647
+ * Written by the same read the election makes; never by a clock.
135648
+ */
135649
+ defaultPoolExcluded = /* @__PURE__ */ new Map();
135650
+ defaultKeyUnknownLogged = /* @__PURE__ */ new Set();
135651
+ isDefaultPoolExcluded(nodeId) {
135652
+ return this.defaultPoolExcluded.get(nodeId) === true;
135653
+ }
135360
135654
  /** Can this node be given cameras? Read synchronously by the two dispatch
135361
135655
  * paths before they hand `eligibleNodes` to the balancer. */
135362
135656
  isNodeInferenceUsable(nodeId) {
@@ -135385,6 +135679,34 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135385
135679
  */
135386
135680
  inferenceDeviceUsability = new InferenceDeviceUsabilityMirror();
135387
135681
  /**
135682
+ * Per node, the devices the executor reports the RUNTIME does not enumerate,
135683
+ * with the named reason. Replaced wholesale by each answered health read (an
135684
+ * empty answer clears it — the driver was fixed); a failed read never reaches
135685
+ * it. Read synchronously by the eligibility resolution.
135686
+ */
135687
+ absentInferenceDevices = /* @__PURE__ */ new Map();
135688
+ absentReasonFor(nodeId) {
135689
+ return (deviceKey) => this.absentInferenceDevices.get(nodeId)?.get(deviceKey) ?? null;
135690
+ }
135691
+ noteAbsentInferenceDevices(nodeId, absent) {
135692
+ const before = this.absentInferenceDevices.get(nodeId);
135693
+ const signature = (m) => [...m ?? []].map(([k, r]) => `${k}=${r}`).toSorted().join(",");
135694
+ if (signature(before) === signature(absent)) return;
135695
+ if (absent.size === 0) this.absentInferenceDevices.delete(nodeId);
135696
+ else this.absentInferenceDevices.set(nodeId, absent);
135697
+ this.ctx.logger.warn("inference devices: the runtime reports devices it does not see", {
135698
+ tags: { nodeId },
135699
+ meta: {
135700
+ nodeId,
135701
+ absent: [...absent].map(([deviceKey, reason]) => ({
135702
+ deviceKey,
135703
+ reason
135704
+ }))
135705
+ }
135706
+ });
135707
+ this.noteShareChange(`devices:${nodeId}`);
135708
+ }
135709
+ /**
135388
135710
  * Ask ONE node's detection executor which of its inference devices it is
135389
135711
  * currently refusing.
135390
135712
  *
@@ -135400,7 +135722,13 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135400
135722
  try {
135401
135723
  const api = this.ctx.api;
135402
135724
  if (!api) return null;
135403
- return (await api.pipelineExecutor.getInferenceDeviceHealth.query({ nodeId })).unhealthy.map((entry) => entry.deviceKey);
135725
+ const health = await api.pipelineExecutor.getInferenceDeviceHealth.query({ nodeId });
135726
+ const absent = /* @__PURE__ */ new Map();
135727
+ for (const entry of health.unhealthy) if (entry.absentReason !== void 0) absent.set(entry.deviceKey, entry.absentReason);
135728
+ return {
135729
+ refused: health.unhealthy.filter((e) => e.absentReason === void 0).map((e) => e.deviceKey),
135730
+ absent
135731
+ };
135404
135732
  } catch (err) {
135405
135733
  this.ctx.logger.warn("inference device health read failed — mirror left unchanged", {
135406
135734
  tags: { nodeId },
@@ -135764,7 +136092,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135764
136092
  if (probed === void 0) continue;
135765
136093
  const stored = blob[nodeId]?.inferenceDevices ?? {};
135766
136094
  const catalog = this.settingsStore.peekCatalogForAgent(nodeId);
135767
- const eligibility = resolveInferenceDeviceEligibility(probed, stored, catalog ? makeRootCapabilityGuard(catalog) : void 0, (deviceKey) => this.inferenceDeviceUsability.isUsable(nodeId, deviceKey), catalog ? makeRootSwitchGuard(catalog, clusterModes, blob[nodeId]) : void 0);
136095
+ 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));
135768
136096
  out[nodeId] = annotateInferenceDeviceExclusions(mergeInferenceDevices(probed, stored), eligibility).map((d) => ({
135769
136097
  key: d.key,
135770
136098
  available: d.available,