bread-utils extracts genuinely duplicated logic found across breadbox, breadclip, breadmon, breadcrumbs, bos-settings, and breadhelp: - hypr: Hyprland socket1 request/response client (breadbox's get_active_workspace + breadclip's position.rs hyprctl_json were near-identical), socket2 path resolution (breadmon), and a version-tolerant `fullscreen` field parser (Hyprland has shipped both bool and int representations across versions). - singleton: correct flock-based single-instance toggle, replacing the TOCTOU-prone read-pid/check-proc/kill/write-pid pattern duplicated verbatim between breadbox and breadclip (breadclip's own comment says "matches breadbox pattern"). - proc: breadcrumbs' timeout-guarded subprocess runner, promoted verbatim as the one implementation in the ecosystem that already got this right. - atomic + xdg: atomic (temp-then-rename) file writes with an optional .bak-before-overwrite variant, and XDG path helpers that never fall back to a literal "~/..." string (the exact breadclip-core and breadpad-shared bug: PathBuf never expands `~`). - tomlcfg (feature "toml"): the load_doc/save_doc TOML-editing discipline bos-settings and breadhelp both implemented byte-for-byte identically in the same fix pass that introduced it. - gtk_popup (feature "gtk"): layer-shell overlay window setup, visible-row navigation, and click-outside-close, deduplicated from breadbox and breadclip (~150 duplicated lines, per both apps' own "same as breadbox" comments). bread-onnx extracts the embedding pipeline (tokenize -> tensor build -> mean-pool -> L2-normalize) duplicated near-verbatim between breadarr and breadsearch, a shared execution-provider session builder with loud EP- registration logging, and a model download+integrity helper. Defaults AMD iGPU acceleration to ort::ep::MIGraphX (not ROCm) per this machine's own breadsearch-gpu-backends lesson: ROCMExecutionProvider silently no-ops to CPU on distro ROCm onnxruntime builds compiled with --use_migraphx. Both crates build and pass their own test suites standalone. Consumer migrations follow in subsequent commits.
32 lines
1.5 KiB
Rust
32 lines
1.5 KiB
Rust
//! Shared ONNX Runtime plumbing for the bread ecosystem.
|
|
//!
|
|
//! Extracted from breadarr, breadsearch, and breadpad during the
|
|
//! 2026-07-16 ecosystem-wide utility audit — see each module's doc comment
|
|
//! for the original file:line duplication it replaces.
|
|
//!
|
|
//! **Important**: [`session::build_session`] logs execution-provider
|
|
//! selection via the `tracing` crate, but does *not* initialize a
|
|
//! subscriber itself. Without one, ONNX Runtime's own "successfully
|
|
//! registered `XExecutionProvider`" log line (and this crate's own
|
|
//! selection logging) go nowhere — which is exactly how a GPU execution
|
|
//! provider can silently no-op back to CPU with zero visible error (see
|
|
//! [`provider`]'s doc comment for the concrete history behind this). All
|
|
//! three current consumers already call `tracing_subscriber::fmt().init()`
|
|
//! (or an `EnvFilter`-configured equivalent) at startup; any new consumer
|
|
//! must do the same before calling [`session::build_session`].
|
|
//!
|
|
//! - [`provider`] — the [`provider::Provider`] enum and the
|
|
//! MIGraphX-not-ROCm default rationale.
|
|
//! - [`session`] — session construction with EP fallback + loud logging.
|
|
//! - [`embedding`] — the shared tokenize → tensor → mean-pool → normalize
|
|
//! pipeline for BERT-family embedding models.
|
|
//! - [`download`] — model download with atomic write + optional SHA-256
|
|
//! integrity check.
|
|
|
|
pub mod download;
|
|
pub mod embedding;
|
|
pub mod provider;
|
|
pub mod session;
|
|
|
|
pub use provider::Provider;
|
|
pub use session::build_session;
|