@camstack/addon-pipeline-orchestrator 1.2.706 → 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
  }), {
@@ -74915,7 +75019,8 @@ var StatelessStepRefusalSchema = _enum([
74915
75019
  "unknown-step",
74916
75020
  "model-not-servable",
74917
75021
  "unreadable-frame",
74918
- "execution-failed"
75022
+ "execution-failed",
75023
+ "no-eligible-device"
74919
75024
  ]);
74920
75025
  /**
74921
75026
  * Answer to `runStatelessStep` — a discriminated union rather than a nullable
@@ -81802,7 +81907,13 @@ var NodeInferenceDeviceSchema = object({
81802
81907
  enabled: boolean(),
81803
81908
  /** Relative balancer weight for the enabled device (default 1). */
81804
81909
  weight: number$1(),
81805
- /** 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
+ */
81806
81917
  maxSessions: number$1().nullable(),
81807
81918
  /** Object-detection model the executor defaults to for this deviceKey. */
81808
81919
  defaultModelId: string(),
@@ -81852,7 +81963,15 @@ var NodeInferenceDevicesSchema = object({
81852
81963
  nodeId: string(),
81853
81964
  /** False when the node's platform-probe was unreachable (no live device set). */
81854
81965
  reachable: boolean(),
81855
- 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()
81856
81975
  });
81857
81976
  /**
81858
81977
  * The CLUSTER switch of one pipeline step (D1065):
@@ -82267,6 +82386,11 @@ var pipelineOrchestratorCapability = {
82267
82386
  * `PipelineSettingsStore.buildNodeInferenceDevices` when placing sessions
82268
82387
  * and the per-(node,device) base provisioning via
82269
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.
82270
82394
  */
82271
82395
  setAgentInferenceDevices: method(object({
82272
82396
  agentNodeId: string(),
@@ -105459,6 +105583,13 @@ Object.freeze({
105459
105583
  access: "view",
105460
105584
  role: "admin"
105461
105585
  },
105586
+ "streamBroker.previewDerivedEncode": {
105587
+ capName: "stream-broker",
105588
+ capScope: "system",
105589
+ addonId: null,
105590
+ access: "view",
105591
+ role: "admin"
105592
+ },
105462
105593
  "streamBroker.probeStream": {
105463
105594
  capName: "stream-broker",
105464
105595
  capScope: "system",
@@ -109790,6 +109921,11 @@ Object.freeze({
109790
109921
  form: "single",
109791
109922
  optional: false
109792
109923
  }],
109924
+ "streamBroker.previewDerivedEncode": [{
109925
+ name: "deviceId",
109926
+ form: "single",
109927
+ optional: false
109928
+ }],
109793
109929
  "streamBroker.produceEventMedia": [{
109794
109930
  name: "deviceId",
109795
109931
  form: "single",
@@ -115896,6 +116032,45 @@ function annotateInferenceDeviceExclusions(merged, eligibility) {
115896
116032
  exclusion: reasonByKey.get(view.key) ?? null
115897
116033
  }));
115898
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
+ }
115899
116074
  function resolveNodeInferenceUsability(eligibility) {
115900
116075
  const eligibleKeys = Object.keys(eligibility.eligible).toSorted();
115901
116076
  const unavailableKeys = eligibility.excluded.filter((e) => e.reason === "unavailable").map((e) => e.key).toSorted();
@@ -122270,6 +122445,33 @@ function deviceAsLoad(deviceKey, load) {
122270
122445
  };
122271
122446
  }
122272
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
+ /**
122273
122475
  * Elect the inference device for one camera on one node.
122274
122476
  *
122275
122477
  * Order (each step short-circuits): pin → capacity → fair tie-break. A pin is
@@ -122317,11 +122519,7 @@ function pickInferenceDevice(input) {
122317
122519
  };
122318
122520
  }), input.previousDeviceKey ?? null);
122319
122521
  const election = outcome.election;
122320
- if (election.kind === "none") return {
122321
- kind: "default-pool",
122322
- reason: "all-devices-at-cap",
122323
- eligibleKeys
122324
- };
122522
+ if (election.kind === "none") return atCapSelection(eligibleKeys, loadByKey, input);
122325
122523
  history?.noteElected(historyScope, election.key);
122326
122524
  return {
122327
122525
  kind: "selected",
@@ -122346,11 +122544,7 @@ function pickInferenceDevice(input) {
122346
122544
  eligibleNodes: consideredKeys
122347
122545
  };
122348
122546
  const decision = balance(balancerInput);
122349
- if (!decision || decision.kind !== "assigned") return {
122350
- kind: "default-pool",
122351
- reason: pin ? "pin-unplaceable" : "all-devices-at-cap",
122352
- eligibleKeys
122353
- };
122547
+ if (!decision || decision.kind !== "assigned") return atCapSelection(eligibleKeys, loadByKey, input);
122354
122548
  if (decision.reason === "manual") return {
122355
122549
  kind: "selected",
122356
122550
  deviceKey: decision.agentNodeId,
@@ -122840,6 +123034,7 @@ function jumpTargetKeys(roster, electedDeviceKey) {
122840
123034
  * module header.
122841
123035
  */
122842
123036
  async function resolveAttachPipeline(input, store) {
123037
+ if (defaultPoolIsExcluded(input)) return noEligibleDeviceRefusal(input);
122843
123038
  const roster = buildJumpRoster({
122844
123039
  deviceKey: input.deviceKey,
122845
123040
  eligible: input.eligible,
@@ -122861,6 +123056,7 @@ async function resolveAttachPipeline(input, store) {
122861
123056
  * camera behind it (D3, D49).
122862
123057
  */
122863
123058
  async function resolveAttachPipelineIfCatalogCached(input, store) {
123059
+ if (defaultPoolIsExcluded(input)) return noEligibleDeviceRefusal(input);
122864
123060
  const roster = buildJumpRoster({
122865
123061
  deviceKey: input.deviceKey,
122866
123062
  eligible: input.eligible,
@@ -122881,11 +123077,29 @@ function defaultPoolOf(input) {
122881
123077
  function rootRefusal(input, droppedRoots) {
122882
123078
  return {
122883
123079
  kind: "root-refused",
123080
+ cause: "root-unrunnable",
122884
123081
  nodeId: input.nodeId,
122885
123082
  deviceKey: input.deviceKey,
122886
123083
  droppedRoots
122887
123084
  };
122888
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
+ }
122889
123103
  /**
122890
123104
  * Whose provisioning an attach applies. The elected device when there is one.
122891
123105
  * With NO elected device the runner's default pool serves the camera; when the
@@ -123316,9 +123530,20 @@ var PlacementService = class {
123316
123530
  caps,
123317
123531
  pinnedDeviceKey,
123318
123532
  currentDeviceKey: input.currentDeviceKey,
123319
- rotation: this.deps.inferenceRotation
123533
+ rotation: this.deps.inferenceRotation,
123534
+ defaultPoolExcluded: this.deps.isDefaultPoolExcluded?.(input.nodeId) === true
123320
123535
  });
123321
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
+ });
123322
123547
  this.deps.ctx().logger.info("inference device selection", {
123323
123548
  tags: {
123324
123549
  deviceId: input.deviceId,
@@ -123340,7 +123565,8 @@ var PlacementService = class {
123340
123565
  kind: "elected",
123341
123566
  deviceKey,
123342
123567
  eligible,
123343
- caps
123568
+ caps,
123569
+ defaultPoolExcluded: this.deps.isDefaultPoolExcluded?.(input.nodeId) === true
123344
123570
  };
123345
123571
  }
123346
123572
  /**
@@ -123356,7 +123582,8 @@ var PlacementService = class {
123356
123582
  nodeId: input.nodeId,
123357
123583
  deviceKey: election.deviceKey,
123358
123584
  eligible: election.eligible,
123359
- caps: election.caps
123585
+ caps: election.caps,
123586
+ defaultPoolExcluded: election.defaultPoolExcluded
123360
123587
  };
123361
123588
  if (input.read.kind === "await-catalog") return resolveAttachPipeline(attachInput, this.deps.settingsStore);
123362
123589
  const outcome = await resolveAttachPipelineIfCatalogCached(attachInput, this.deps.settingsStore);
@@ -123379,7 +123606,8 @@ var PlacementService = class {
123379
123606
  return resolveAttachPipeline({
123380
123607
  ...input,
123381
123608
  eligible,
123382
- caps
123609
+ caps,
123610
+ defaultPoolExcluded: this.deps.isDefaultPoolExcluded?.(input.nodeId) === true
123383
123611
  }, this.deps.settingsStore);
123384
123612
  }
123385
123613
  /**
@@ -123780,7 +124008,7 @@ var PlacementService = class {
123780
124008
  read: { kind: "cached-catalog" }
123781
124009
  });
123782
124010
  if (placement.kind !== "resolved") {
123783
- 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}`;
123784
124012
  skipped.push({
123785
124013
  deviceId,
123786
124014
  targetNodeId: decision.agentNodeId,
@@ -124164,9 +124392,10 @@ var PlacementService = class {
124164
124392
  * re-place it. The camera stays pending instead, once-per-change logged.
124165
124393
  */
124166
124394
  leavePendingRootRefused(deviceId, refusal) {
124167
- const reason = `root-unrunnable:${refusal.nodeId}/${refusal.deviceKey ?? "default-pool"}`;
124395
+ const reason = refusalPendingReason(refusal);
124168
124396
  if (!this.setPendingIfChanged(deviceId, reason)) return;
124169
- 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", {
124170
124399
  tags: {
124171
124400
  deviceId,
124172
124401
  nodeId: refusal.nodeId
@@ -124175,7 +124404,7 @@ var PlacementService = class {
124175
124404
  reason,
124176
124405
  deviceKey: refusal.deviceKey ?? null,
124177
124406
  droppedRoots: refusal.droppedRoots.join(","),
124178
- 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"
124179
124408
  }
124180
124409
  });
124181
124410
  }
@@ -129913,9 +130142,20 @@ var SessionDispatchController = class {
129913
130142
  shareHistory: this.deps.shareHistory,
129914
130143
  historyScope: targetNodeId
129915
130144
  } : {},
129916
- previousDeviceKey
130145
+ previousDeviceKey,
130146
+ defaultPoolExcluded: this.deps.isDefaultPoolExcluded?.(targetNodeId) === true
129917
130147
  });
129918
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
+ });
129919
130159
  log.info("inference device selection", {
129920
130160
  tags: {
129921
130161
  deviceId,
@@ -129945,14 +130185,16 @@ var SessionDispatchController = class {
129945
130185
  nodeId: targetNodeId,
129946
130186
  deviceKey,
129947
130187
  eligible: enabledDevices,
129948
- caps: deviceCaps
130188
+ caps: deviceCaps,
130189
+ defaultPoolExcluded: this.deps.isDefaultPoolExcluded?.(targetNodeId) === true
129949
130190
  }, this.deps.settingsStore);
129950
130191
  if (outcome.kind === "root-refused") {
129951
- const reason = `root-unrunnable:${targetNodeId}/${outcome.deviceKey ?? "default-pool"}`;
130192
+ const reason = refusalPendingReason(outcome);
129952
130193
  this.deps.sessionAffinity?.forget(deviceId);
129953
130194
  if (this.sessionRefusals.get(deviceId) !== reason) {
129954
130195
  this.sessionRefusals.set(deviceId, reason);
129955
- 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", {
129956
130198
  tags: {
129957
130199
  deviceId,
129958
130200
  nodeId: targetNodeId
@@ -129961,7 +130203,7 @@ var SessionDispatchController = class {
129961
130203
  reason,
129962
130204
  deviceKey: outcome.deviceKey ?? null,
129963
130205
  droppedRoots: outcome.droppedRoots.join(","),
129964
- 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"
129965
130207
  }
129966
130208
  });
129967
130209
  }
@@ -131290,6 +131532,7 @@ async function buildOrchestratorControllers(deps) {
131290
131532
  getEligibleInferenceDevices: (nodeId) => deps.getEligibleInferenceDevices(nodeId, "await-catalog"),
131291
131533
  getEligibleInferenceDevicesIfCached: (nodeId) => deps.getEligibleInferenceDevicesIfCached(nodeId),
131292
131534
  isNodeInferenceUsable: (nodeId) => deps.isNodeInferenceUsable(nodeId),
131535
+ isDefaultPoolExcluded: (nodeId) => deps.isDefaultPoolExcluded(nodeId),
131293
131536
  getInferenceDeviceCaps: (nodeId) => deps.getInferenceDeviceCaps(nodeId),
131294
131537
  readPipelineDevicePin: (deviceId) => deps.readPipelineDevicePin(deviceId),
131295
131538
  inferenceRotation,
@@ -131330,6 +131573,7 @@ async function buildOrchestratorControllers(deps) {
131330
131573
  readPipelinePin: (deviceId) => deps.readPipelinePin(deviceId),
131331
131574
  getEligibleInferenceDevices: (nodeId, read) => deps.getEligibleInferenceDevices(nodeId, read),
131332
131575
  isNodeInferenceUsable: (nodeId) => deps.isNodeInferenceUsable(nodeId),
131576
+ isDefaultPoolExcluded: (nodeId) => deps.isDefaultPoolExcluded(nodeId),
131333
131577
  getInferenceDeviceCaps: (nodeId) => deps.getInferenceDeviceCaps(nodeId),
131334
131578
  readPipelineDevicePin: (deviceId) => deps.readPipelineDevicePin(deviceId),
131335
131579
  inferenceRotation,
@@ -134252,6 +134496,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
134252
134496
  forgetInferenceDeviceProbe: (nodeId) => this.forgetInferenceDeviceProbe(nodeId),
134253
134497
  noteShareTopologyChange: (trigger) => this.noteShareChange(trigger),
134254
134498
  isNodeInferenceUsable: (nodeId) => this.isNodeInferenceUsable(nodeId),
134499
+ isDefaultPoolExcluded: (nodeId) => this.isDefaultPoolExcluded(nodeId),
134255
134500
  getInferenceDeviceCaps: (nodeId) => this.getInferenceDeviceCaps(nodeId),
134256
134501
  readPipelineDevicePin: (deviceId) => this.readPipelineDevicePin(deviceId),
134257
134502
  subscribeToAudioAnalyzerReadiness: (nodeId) => this.subscribeToAudioAnalyzerReadiness(nodeId),
@@ -135137,14 +135382,15 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135137
135382
  const stored = node?.inferenceDevices ?? {};
135138
135383
  const { probed, reachable } = await this.probeNodeInferenceDevices(nodeId);
135139
135384
  const catalog = await this.settingsStore.getCatalogForNode(nodeId);
135140
- 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));
135141
135386
  return {
135142
135387
  nodeId,
135143
135388
  reachable,
135144
- 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, this.absentReasonFor(nodeId))).map((row) => !reachable && row.presence === "absent" ? {
135389
+ devices: annotateInferenceDeviceExclusions(mergeInferenceDevices(probed, stored), eligibility).map((row) => !reachable && row.presence === "absent" ? {
135145
135390
  ...row,
135146
135391
  presence: "unknown"
135147
- } : row)
135392
+ } : row),
135393
+ ...reachable ? { defaultPoolExcluded: isDefaultPoolExcluded(eligibility, defaultEngineKeyOf(catalog)) } : {}
135148
135394
  };
135149
135395
  }
135150
135396
  /**
@@ -135217,6 +135463,8 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135217
135463
  */
135218
135464
  forgetInferenceDeviceProbe(nodeId) {
135219
135465
  this.absentInferenceDevices.delete(nodeId);
135466
+ this.defaultPoolExcluded.delete(nodeId);
135467
+ this.defaultKeyUnknownLogged.delete(nodeId);
135220
135468
  if (!this.lastInferenceDeviceProbe.delete(nodeId)) return;
135221
135469
  this.ctx.logger.info("inference device probe forgotten — the node left", {
135222
135470
  tags: { nodeId },
@@ -135330,6 +135578,18 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135330
135578
  const { eligible, excluded } = eligibility;
135331
135579
  this.logInferenceDeviceShrinkage(nodeId, eligible, excluded);
135332
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
+ }
135333
135593
  return eligible;
135334
135594
  }
135335
135595
  /**
@@ -135380,6 +135640,17 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
135380
135640
  }
135381
135641
  });
135382
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
+ }
135383
135654
  /** Can this node be given cameras? Read synchronously by the two dispatch
135384
135655
  * paths before they hand `eligibleNodes` to the balancer. */
135385
135656
  isNodeInferenceUsable(nodeId) {