filament_deficit.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. """Filament-deficit check used by every queue dispatch path.
  2. The PrintModal warns when an assigned spool can't satisfy a print's per-slot
  3. filament weight (``Pre-print checks now also warn when the spool has
  4. insufficient material`` — #720). That check only runs when the user clicks
  5. "Print" inside PrintModal; ``QueuePage`` Play button, ``start_queue_item``
  6. route, and the VP intake + scheduler auto-dispatch path all skip it (#1496).
  7. This module is the single source of truth for the check. Both the route
  8. handler (``POST /print-queue/{id}/start``) and the dispatch scheduler call
  9. ``compute_deficit_for_queue_item`` against live spool state.
  10. Design notes:
  11. * The 3MF parser is the same one used by PrintModal: per-slot ``used_grams``
  12. comes from ``extract_filament_requirements`` (#1188's filament-overrides
  13. pipeline) or — when the item points at an unsliced library file — falls
  14. through to the file's archive copy. Anything that yields no requirements
  15. is treated as "no deficit" so a malformed or stripped 3MF never blocks.
  16. * Both internal-inventory and Spoolman modes are covered. Internal mode
  17. resolves via ``SpoolAssignment`` joined to ``Spool`` (``label_weight``
  18. minus ``weight_used``). Spoolman mode resolves via
  19. ``SpoolmanSlotAssignment`` then ``SpoolmanClient.get_spool`` for the live
  20. remaining weight; if Spoolman is unreachable we return no deficit rather
  21. than wedge the queue on a flaky network call.
  22. * The ``disable_filament_warnings`` user setting is respected at the
  23. service boundary — callers do not have to know about it.
  24. """
  25. from __future__ import annotations
  26. import json
  27. import logging
  28. from collections import defaultdict
  29. from dataclasses import dataclass
  30. from pathlib import Path
  31. from sqlalchemy import select
  32. from sqlalchemy.ext.asyncio import AsyncSession
  33. from sqlalchemy.orm import selectinload
  34. from backend.app.core.config import settings as app_settings
  35. from backend.app.models.print_queue import PrintQueueItem
  36. from backend.app.models.spool_assignment import SpoolAssignment
  37. from backend.app.models.spoolman_slot_assignment import SpoolmanSlotAssignment
  38. from backend.app.services.filament_requirements import extract_filament_requirements
  39. logger = logging.getLogger(__name__)
  40. @dataclass(frozen=True)
  41. class FilamentDeficit:
  42. """One slot's filament shortfall."""
  43. slot_id: int
  44. ams_id: int | None
  45. tray_id: int | None
  46. filament_type: str
  47. required_grams: float
  48. remaining_grams: float | None # None = could not determine
  49. def to_dict(self) -> dict:
  50. return {
  51. "slot_id": self.slot_id,
  52. "ams_id": self.ams_id,
  53. "tray_id": self.tray_id,
  54. "filament_type": self.filament_type,
  55. "required_grams": self.required_grams,
  56. "remaining_grams": self.remaining_grams,
  57. }
  58. def _global_to_ams_key(global_tray_id: int) -> tuple[int, int]:
  59. """Inverse of ``ams_id * 4 + tray_id`` — matches ``usage_tracker``."""
  60. if global_tray_id >= 254:
  61. return (255, global_tray_id - 254)
  62. if global_tray_id >= 128:
  63. return (global_tray_id, 0)
  64. return (global_tray_id // 4, global_tray_id % 4)
  65. def _resolve_source_3mf(item: PrintQueueItem) -> Path | None:
  66. """Locate the 3MF file backing this queue item (archive or library).
  67. ``LibraryFile.file_path`` is stored relative to ``base_dir`` (rows written
  68. before that convention hold absolute paths, which is why every reader
  69. guards on ``is_absolute``). Resolving a relative one against the process
  70. working directory finds nothing, and a source that cannot be found is
  71. treated as "nothing to verify" — so this check silently passed every
  72. library-backed item, which is every Slicer Pipeline job and everything
  73. queued from the Library page (#2779).
  74. """
  75. if item.archive is not None and item.archive.file_path:
  76. return app_settings.base_dir / item.archive.file_path
  77. if item.library_file is not None and item.library_file.file_path:
  78. library_path = Path(item.library_file.file_path)
  79. if library_path.is_absolute():
  80. return library_path
  81. # SEC-PATH-OK: file_path is DB-stored and generated by the Library
  82. # ingest (archive/library/files/<uuid>.<ext>), never request input. The
  83. # same value already resolves the file for upload in print_queue.py and
  84. # print_scheduler.py — this check reads what the printer is about to be
  85. # sent, so it must resolve it identically.
  86. return app_settings.base_dir / item.library_file.file_path
  87. return None
  88. async def _spoolman_remaining_grams(spoolman_spool_id: int) -> float | None:
  89. """Live remaining grams for a Spoolman spool, or None if unavailable."""
  90. try:
  91. from backend.app.services.spoolman import (
  92. SpoolmanClientError,
  93. SpoolmanNotFoundError,
  94. get_spoolman_client,
  95. )
  96. except ImportError:
  97. return None
  98. try:
  99. client = await get_spoolman_client()
  100. if client is None:
  101. return None
  102. spool = await client.get_spool(spoolman_spool_id)
  103. except (SpoolmanNotFoundError, SpoolmanClientError):
  104. return None
  105. except Exception as e:
  106. logger.debug("Spoolman fetch failed for spool %s: %s", spoolman_spool_id, e)
  107. return None
  108. if not spool:
  109. return None
  110. # Spoolman exposes either an absolute remaining_weight, or used_weight +
  111. # filament.weight. Either is sufficient — prefer remaining_weight when
  112. # present (the user may have overridden it).
  113. remaining = spool.get("remaining_weight")
  114. if isinstance(remaining, (int, float)) and remaining >= 0:
  115. return float(remaining)
  116. used = spool.get("used_weight")
  117. filament = spool.get("filament") or {}
  118. total = filament.get("weight")
  119. if isinstance(used, (int, float)) and isinstance(total, (int, float)) and total > 0:
  120. return max(0.0, float(total) - float(used))
  121. return None
  122. async def _is_spoolman_mode(db: AsyncSession) -> bool:
  123. """Check whether the user has opted in to Spoolman inventory mode."""
  124. try:
  125. from backend.app.api.routes.settings import get_setting
  126. spoolman_enabled = await get_setting(db, "spoolman_enabled")
  127. return bool(spoolman_enabled) and spoolman_enabled.lower() == "true"
  128. except Exception:
  129. return False
  130. async def _warnings_disabled(db: AsyncSession) -> bool:
  131. """Honour the ``disable_filament_warnings`` setting (#720)."""
  132. try:
  133. from backend.app.api.routes.settings import get_setting
  134. disabled = await get_setting(db, "disable_filament_warnings")
  135. return bool(disabled) and disabled.lower() == "true"
  136. except Exception:
  137. return False
  138. def _normalize_color_for_id(raw: str | None) -> str:
  139. """Canonicalise a hex colour for identity comparison.
  140. Strips the leading ``#``, uppercases, and drops the alpha channel when
  141. the hex is 8 chars long (``RRGGBBAA``) so a fully-opaque 8-char hex
  142. matches a 6-char hex of the same RGB. Empty / None → empty string.
  143. """
  144. s = (raw or "").strip().lstrip("#").upper()
  145. if len(s) == 8: # RRGGBBAA → strip alpha
  146. s = s[:6]
  147. return s
  148. def _material_identity_internal(spool) -> str:
  149. """Strict same-material key for backup-peer matching in internal mode.
  150. Requires a Bambu filament preset ID (``slicer_filament``, e.g. ``GFA00``)
  151. AND a matching colour. The preset identifies the filament profile (PETG
  152. HF, PLA Basic, etc.) — same hot-end behaviour — but the firmware's
  153. switch logic also requires the spool to be the same colour (otherwise
  154. every PETG HF spool would back every other PETG HF spool regardless of
  155. colour, which would dye prints mid-run). Spools without a preset
  156. (user-tagged / non-Bambu) get a per-spool unique key so they NEVER
  157. pair with anything else; without the Bambu preset the firmware can't
  158. trust the backup decision.
  159. """
  160. preset = (spool.slicer_filament or "").strip() if spool else ""
  161. if preset:
  162. color = _normalize_color_for_id(spool.rgba if spool else None)
  163. return f"preset:{preset}|color:{color}"
  164. # Unique-per-spool key prevents grouping. Use the spool's primary key so
  165. # the same spool always resolves to the same key within a request.
  166. spool_id = getattr(spool, "id", None) if spool else None
  167. return f"unmatched:{spool_id}"
  168. def _material_identity_spoolman(spool: dict | None) -> str:
  169. """Strict same-material key for backup-peer matching in Spoolman mode.
  170. Two spools pair only when they reference the same Spoolman ``filament``
  171. catalog entry (same ``filament.id``) AND share the same colour. The
  172. catalog entry pins the profile (PETG HF / PLA Basic / ...); the colour
  173. pins the variant. Spools without a resolvable filament id get a
  174. per-spool unique key so they never pair.
  175. """
  176. if not spool:
  177. return "unmatched:none"
  178. filament = spool.get("filament") or {}
  179. fil_id = filament.get("id")
  180. if isinstance(fil_id, (int, str)) and str(fil_id).strip():
  181. # Prefer the per-spool override colour when set (Spoolman lets the user
  182. # tag a spool with a colour distinct from the filament catalog
  183. # default); fall back to the filament catalog colour.
  184. color = _normalize_color_for_id(
  185. (spool.get("color_hex") if isinstance(spool.get("color_hex"), str) else None) or filament.get("color_hex")
  186. )
  187. return f"filament:{fil_id}|color:{color}"
  188. spool_id = spool.get("id")
  189. return f"unmatched:{spool_id}"
  190. def _ams_id_from_global(global_tray_id: int) -> int:
  191. """Inverse of ``_global_to_ams_key`` returning ams_id only."""
  192. return _global_to_ams_key(global_tray_id)[0]
  193. def _extruder_side_for_ams(
  194. ams_id: int,
  195. ams_extruder_map: dict[str, int],
  196. is_dual_extruder: bool,
  197. ) -> int:
  198. """Resolve the extruder index (0=right, 1=left) for a given AMS unit.
  199. Single-extruder printers collapse everything to 0. On dual-extruder
  200. printers (H2D / H2C / X2D), the firmware can't cross extruders even with
  201. AMS Filament Backup ON, so the pool must be scoped per-side.
  202. """
  203. if not is_dual_extruder:
  204. return 0
  205. return int(ams_extruder_map.get(str(ams_id), 0))
  206. def _parse_ams_mapping(raw: str | None) -> list[int] | None:
  207. if not raw:
  208. return None
  209. try:
  210. parsed = json.loads(raw)
  211. except (json.JSONDecodeError, TypeError):
  212. return None
  213. if not isinstance(parsed, list):
  214. return None
  215. return [v for v in parsed if isinstance(v, int)]
  216. async def _get_printer_backup_context(
  217. printer_id: int,
  218. ) -> tuple[bool, dict[str, int], bool]:
  219. """Return ``(backup_on, ams_extruder_map, is_dual_extruder)`` for the printer.
  220. Read from the live MQTT state via ``printer_manager`` (no DB round-trip).
  221. Defaults conservatively to ``backup_on=False`` when the state is missing
  222. or the printer is offline — same fallback as today (per-slot deficit
  223. accounting), so an offline printer is never treated as backup-capable.
  224. """
  225. try:
  226. from backend.app.services.printer_manager import printer_manager
  227. from backend.app.utils.printer_models import is_dual_nozzle_model
  228. except ImportError:
  229. return False, {}, False
  230. state = printer_manager.get_status(printer_id)
  231. if state is None:
  232. return False, {}, False
  233. backup_on = state.ams_filament_backup is True
  234. ams_extruder_map = dict(state.ams_extruder_map or {})
  235. model = printer_manager.get_model(printer_id)
  236. is_dual = bool(model and is_dual_nozzle_model(model))
  237. return backup_on, ams_extruder_map, is_dual
  238. async def compute_deficit_for_queue_item(
  239. db: AsyncSession,
  240. item: PrintQueueItem,
  241. ) -> list[FilamentDeficit]:
  242. """Return per-slot filament shortfalls for ``item``, or [] when it's safe to dispatch.
  243. Returns an empty list whenever any of the following hold:
  244. * The ``disable_filament_warnings`` setting is on.
  245. * The item has no resolved ``printer_id`` (model-based assignment not
  246. yet picked a printer — the scheduler re-runs the check after it does).
  247. * No source 3MF is available, or the 3MF carries no per-slot
  248. requirements (treated as "nothing to verify" rather than an error,
  249. matching the PrintModal behaviour).
  250. * No AMS mapping is set yet — the scheduler computes the mapping just
  251. before dispatch; until it does we cannot map slot → tray.
  252. * Spoolman mode is on but the Spoolman server is unreachable. We do not
  253. wedge the queue on a network blip.
  254. #1762: when the printer reports ``ams_filament_backup=True`` in MQTT
  255. status, available material is pooled across ALL same-material spools on
  256. the printer (within the same extruder side for dual-nozzle models, since
  257. firmware can't cross extruders even with the backup bit set). Per-slot
  258. shortfalls are then only emitted if the POOL is too small for the
  259. print's total required of that material — matching how the printer
  260. actually behaves with Filament Backup ON.
  261. """
  262. if await _warnings_disabled(db):
  263. return []
  264. if item.printer_id is None:
  265. return []
  266. # Refresh the relationships we need without assuming the caller eagerly
  267. # loaded them — both the route and the scheduler call this from contexts
  268. # with different loading strategies.
  269. refreshed = await db.execute(
  270. select(PrintQueueItem)
  271. .options(
  272. selectinload(PrintQueueItem.archive),
  273. selectinload(PrintQueueItem.library_file),
  274. )
  275. .where(PrintQueueItem.id == item.id)
  276. )
  277. item = refreshed.scalar_one_or_none() or item
  278. source_path = _resolve_source_3mf(item)
  279. if source_path is None:
  280. # No archive and no library file — nothing was ever attached to check.
  281. return []
  282. if not source_path.exists():
  283. # Dispatch is not blocked: the upload that follows needs the same file
  284. # and fails within seconds, where wedging the queue here would strand
  285. # it. But skipping a safety check must leave a trace — a silent skip is
  286. # what hid #2779 for every library-backed item.
  287. logger.warning(
  288. "Filament check skipped for queue item %s: source 3MF not found at %s",
  289. item.id,
  290. source_path,
  291. )
  292. return []
  293. requirements = extract_filament_requirements(source_path, item.plate_id)
  294. if not requirements:
  295. return []
  296. mapping = _parse_ams_mapping(item.ams_mapping)
  297. if not mapping:
  298. return []
  299. spoolman_mode = await _is_spoolman_mode(db)
  300. backup_on, ams_extruder_map, is_dual = await _get_printer_backup_context(item.printer_id)
  301. # ------------------------------------------------------------------ phase 1
  302. # Resolve each requirement to (ams_id, tray_id, identity, remaining_grams).
  303. # Slot identity is the identity of the spool *assigned to that slot*. A
  304. # ``None`` remaining means "couldn't determine" — treated as "no deficit"
  305. # below (preserved from pre-#1762 behaviour for non-backup paths too).
  306. @dataclass
  307. class _ReqRow:
  308. slot_id: int
  309. ams_id: int
  310. tray_id: int
  311. global_tray_id: int
  312. required: float
  313. identity: str
  314. remaining: float | None
  315. filament_type: str
  316. extruder: int
  317. resolved: list[_ReqRow] = []
  318. for req in requirements:
  319. slot_id = req.get("slot_id")
  320. used_grams = req.get("used_grams")
  321. if not isinstance(slot_id, int) or slot_id <= 0:
  322. continue
  323. if not isinstance(used_grams, (int, float)) or used_grams <= 0:
  324. continue
  325. idx = slot_id - 1
  326. if idx >= len(mapping):
  327. continue
  328. global_tray_id = mapping[idx]
  329. if global_tray_id is None or global_tray_id < 0:
  330. continue
  331. ams_id, tray_id = _global_to_ams_key(global_tray_id)
  332. identity = "attrs:|||"
  333. remaining: float | None = None
  334. if spoolman_mode:
  335. sm_result = await db.execute(
  336. select(SpoolmanSlotAssignment).where(
  337. SpoolmanSlotAssignment.printer_id == item.printer_id,
  338. SpoolmanSlotAssignment.ams_id == ams_id,
  339. SpoolmanSlotAssignment.tray_id == tray_id,
  340. )
  341. )
  342. sm_assignment = sm_result.scalar_one_or_none()
  343. if sm_assignment is None:
  344. continue
  345. # Live remaining_weight from Spoolman. The fetch also resolves the
  346. # filament identity for pooling (material + colour + name).
  347. from backend.app.services.spoolman import (
  348. SpoolmanClientError,
  349. SpoolmanNotFoundError,
  350. get_spoolman_client,
  351. )
  352. try:
  353. client = await get_spoolman_client()
  354. spool_dict = await client.get_spool(sm_assignment.spoolman_spool_id) if client else None
  355. except (SpoolmanNotFoundError, SpoolmanClientError):
  356. spool_dict = None
  357. except Exception as e:
  358. logger.debug("Spoolman fetch failed for spool %s: %s", sm_assignment.spoolman_spool_id, e)
  359. spool_dict = None
  360. if spool_dict:
  361. identity = _material_identity_spoolman(spool_dict)
  362. rw = spool_dict.get("remaining_weight")
  363. if isinstance(rw, (int, float)) and rw >= 0:
  364. remaining = float(rw)
  365. else:
  366. used = spool_dict.get("used_weight")
  367. total = (spool_dict.get("filament") or {}).get("weight")
  368. if isinstance(used, (int, float)) and isinstance(total, (int, float)) and total > 0:
  369. remaining = max(0.0, float(total) - float(used))
  370. else:
  371. internal_result = await db.execute(
  372. select(SpoolAssignment)
  373. .options(selectinload(SpoolAssignment.spool))
  374. .where(
  375. SpoolAssignment.printer_id == item.printer_id,
  376. SpoolAssignment.ams_id == ams_id,
  377. SpoolAssignment.tray_id == tray_id,
  378. )
  379. )
  380. assignment = internal_result.scalar_one_or_none()
  381. if assignment is None or assignment.spool is None:
  382. continue
  383. spool = assignment.spool
  384. identity = _material_identity_internal(spool)
  385. label_weight = float(spool.label_weight or 0)
  386. weight_used = float(spool.weight_used or 0)
  387. if label_weight <= 0:
  388. continue
  389. remaining = max(0.0, label_weight - weight_used)
  390. if remaining is None:
  391. # Unable to determine remaining grams — preserve pre-#1762 behaviour
  392. # (don't block on undetermined data).
  393. continue
  394. resolved.append(
  395. _ReqRow(
  396. slot_id=slot_id,
  397. ams_id=ams_id,
  398. tray_id=tray_id,
  399. global_tray_id=global_tray_id,
  400. required=float(used_grams),
  401. identity=identity,
  402. remaining=remaining,
  403. filament_type=str(req.get("type", "")),
  404. extruder=_extruder_side_for_ams(ams_id, ams_extruder_map, is_dual),
  405. )
  406. )
  407. # ------------------------------------------------------------------ phase 2
  408. # When backup is OFF, fall back to today's per-slot accounting (one-line
  409. # equivalence of the original loop), so this path is a strict no-op
  410. # behaviour-wise vs. the pre-#1762 code.
  411. if not backup_on:
  412. return [
  413. FilamentDeficit(
  414. slot_id=row.slot_id,
  415. ams_id=row.ams_id,
  416. tray_id=row.tray_id,
  417. filament_type=row.filament_type,
  418. required_grams=row.required,
  419. remaining_grams=row.remaining,
  420. )
  421. for row in resolved
  422. if row.remaining is not None and row.remaining < row.required
  423. ]
  424. # ------------------------------------------------------------------ phase 3
  425. # Backup ON: build (identity, extruder)-keyed pool and required-sum maps
  426. # from EVERY assigned spool on the printer (not just the slots in the
  427. # print's mapping). Then emit deficits only when the pool for a slot's
  428. # material is too small for the print's total required of that material.
  429. pool_by_key: dict[tuple[str, int], float] = defaultdict(float)
  430. required_by_key: dict[tuple[str, int], float] = defaultdict(float)
  431. if spoolman_mode:
  432. sm_all = await db.execute(
  433. select(SpoolmanSlotAssignment).where(SpoolmanSlotAssignment.printer_id == item.printer_id)
  434. )
  435. from backend.app.services.spoolman import (
  436. SpoolmanClientError,
  437. SpoolmanNotFoundError,
  438. get_spoolman_client,
  439. )
  440. try:
  441. client = await get_spoolman_client()
  442. except Exception:
  443. client = None
  444. for sa in sm_all.scalars().all():
  445. if client is None:
  446. break
  447. try:
  448. spool_dict = await client.get_spool(sa.spoolman_spool_id)
  449. except (SpoolmanNotFoundError, SpoolmanClientError):
  450. continue
  451. except Exception as e:
  452. logger.debug("Spoolman pool fetch failed for spool %s: %s", sa.spoolman_spool_id, e)
  453. continue
  454. if not spool_dict:
  455. continue
  456. identity = _material_identity_spoolman(spool_dict)
  457. rw = spool_dict.get("remaining_weight")
  458. r: float | None = None
  459. if isinstance(rw, (int, float)) and rw >= 0:
  460. r = float(rw)
  461. else:
  462. used = spool_dict.get("used_weight")
  463. total = (spool_dict.get("filament") or {}).get("weight")
  464. if isinstance(used, (int, float)) and isinstance(total, (int, float)) and total > 0:
  465. r = max(0.0, float(total) - float(used))
  466. if r is None:
  467. continue
  468. extruder = _extruder_side_for_ams(sa.ams_id, ams_extruder_map, is_dual)
  469. pool_by_key[(identity, extruder)] += r
  470. else:
  471. internal_all = await db.execute(
  472. select(SpoolAssignment)
  473. .options(selectinload(SpoolAssignment.spool))
  474. .where(SpoolAssignment.printer_id == item.printer_id)
  475. )
  476. for assignment in internal_all.scalars().all():
  477. spool = assignment.spool
  478. if spool is None:
  479. continue
  480. label_weight = float(spool.label_weight or 0)
  481. weight_used = float(spool.weight_used or 0)
  482. if label_weight <= 0:
  483. continue
  484. r = max(0.0, label_weight - weight_used)
  485. identity = _material_identity_internal(spool)
  486. extruder = _extruder_side_for_ams(assignment.ams_id, ams_extruder_map, is_dual)
  487. pool_by_key[(identity, extruder)] += r
  488. for row in resolved:
  489. required_by_key[(row.identity, row.extruder)] += row.required
  490. deficits: list[FilamentDeficit] = []
  491. for row in resolved:
  492. key = (row.identity, row.extruder)
  493. # Pool insufficient for the print's TOTAL required of this material on
  494. # this extruder side → real deficit. The per-slot remaining still gets
  495. # surfaced so the UI can point at the slot the user assigned.
  496. if pool_by_key[key] < required_by_key[key]:
  497. deficits.append(
  498. FilamentDeficit(
  499. slot_id=row.slot_id,
  500. ams_id=row.ams_id,
  501. tray_id=row.tray_id,
  502. filament_type=row.filament_type,
  503. required_grams=row.required,
  504. remaining_grams=row.remaining,
  505. )
  506. )
  507. return deficits
  508. # Re-export the most useful pieces for callers that just want the data.
  509. __all__ = [
  510. "FilamentDeficit",
  511. "compute_deficit_for_queue_item",
  512. ]