feature-flag-policy
Cargo feature flags for crates/xberg — ORT-incompatible targets (WASM, Android x86_64 emulator), type-only and tract inference companion features, WASM/Android-safe variants, PDF backend, mutually-exclusive ORT variants, platform-conditional deps, aggregate feature sets, and build profiles. Load when adding, wiring, or debugging a Cargo feature, or when reasoning about what compiles on WASM/Android/Windows/macOS-intel targets.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-15
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- feature-flag-policy
- description
- Cargo feature flags for crates/xberg — ORT-incompatible targets (WASM, Android x86_64 emulator), type-only and tract inference companion features, WASM/Android-safe variants, PDF backend, mutually-exclusive ORT variants, platform-conditional deps, aggregate feature sets, and build profiles. Load when adding, wiring, or debugging a Cargo feature, or when reasoning about what compiles on WASM/Android/Windows/macOS-intel targets.
03 SKILL.md 正文
Feature Flag Policy
All features in crates/xberg/Cargo.toml.
ORT-Incompatible Targets (WASM, Android x86_64 emulator)
Only ORT-dependent paths are incompatible. The same paths block both WASM (no native ORT linkage at all) and the x86_64-linux-android emulator triple (no pyke prebuilt; aarch64-linux-android does ship a prebuilt and gets full ORT):
paddle-ocr— ONNX Runtime + native C++ deps: not WASM-safe; no Android x86_64 prebuiltlayout-detection— depends on ONNX Runtime layout models: not WASM-safe; no Android x86_64 prebuilt (RT-DETR + table classifier are available off-ORT via thelayout-tractsibling, below)embeddings— depends on ONNX Runtime sentence-transformer models: not WASM-safe; no Android x86_64 prebuiltauto-rotate— depends on ONNX Runtime orientation classifier: not WASM-safe; no Android x86_64 prebuilt (available off-ORT via theauto-rotate-tractsibling, below)
Pure-Rust type-only companion features expose the public config/result types for the above without pulling in ORT:
layout-types—LayoutDetectionConfig,TableModel,BBox,DetectionResult,LayoutClass,LayoutDetection,RecognizedTable.layout-detectionimplieslayout-types.auto-rotate-types—OrientationResult.auto-rotateimpliesauto-rotate-types.embedding-presets—EmbeddingPreset(already existed; pure-Rust preset metadata).
Pure-Rust tract inference variants run select ONNX models where native ORT cannot link, loading the
same .onnx artifacts through the tract engine (CPU-only, no native library):
layout-detection(ORT) →layout-tract(tract): RT-DETR layout detection + the PP-LCNet wired/wireless table classifier run on WASM and the Android x86_64 emulator. TATR, SLANeXT, PP-DocLayout-V3, and YOLO stay ONNX Runtime-only (tract 0.23.4 op-coverage gaps).auto-rotate(ORT) →auto-rotate-tract(tract): PP-LCNet document-orientation on WASM and the Android x86_64 emulator.
WASM/Android-safe variants:
ocr(native) →ocr-wasm(usestesseract-wasm+ safe image deps) — Android keeps nativeocrexcel(native) →excel-wasm(dropstokio-runtime) — Android keeps nativeexceltree-sitter(native dlopen) →tree-sitter-wasm(statically-linked grammar pack). NOT inwasm-target: the 306-language grammar pack pushes the browser.wasmpast jsDelivr's 50 MB per-file cap, breaking the CDN-hosted demo. WASM has no code intelligence; Android keeps nativetree-sitter.liter-llm— works on WASM via the upstreamwasm-httpfeature; included inno-ort-targetstopwords— pure-Rust, included inno-ort-targetkeywords— pure-Rust YAKE/RAKE, included inno-ort-target
The no-ort-target aggregate is the shared no-ORT base used by both wasm-target and android-target. wasm-target = no-ort-target + excel-wasm + ocr-wasm + layout-tract + auto-rotate-tract (NO tree-sitter — see above). android-target = no-ort-target + excel + tree-sitter + ocr + api + mcp + layout-tract + auto-rotate-tract.
PDF Backend
pdf— the canonical PDF feature, backed by the pure-Rustpdf_oxidecrate. This is the primary/default PDF extraction pipeline; there is no separatepdf-oxidefeature. Included informats,full,no-ort-target, andwasm-target.
ORT Variants (Mutually Exclusive)
ort-bundled— downloads official Microsoft ORT binaries; default when OCR/ML features activeort-dynamic— load ORT from system; only when system ORT is guaranteed present
Platform-Conditional
xberg-paddle-ocr,hf-hub,pprof— excluded onwasm32ureq:rustlson non-Windows;native-tlson Windowsxberg-ffiandxberg-dartcargo dependencies are target-conditional:cfg(target_os = "android")(both ABIs —aarch64andx86_64) andcfg(target_os = "ios")selectandroid-target, the pure-Rust tract ML surface with no ONNX Runtime;cfg(target_os = "windows")selectswindows-target(full ORT ML viaort-bundled);cfg(all(target_os = "macos", target_arch = "x86_64"))selectsmacos-intel-target. All other targets (Linux, macOS arm64) get the full ORT-enabled feature set. Android and iOS run inference throughtract, not ORT, on every ABI — there is no arch split that gives arm64 Android phones a native ORT build.
Aggregate Sets
| Feature | Description |
|---|---|
formats |
All document formats + api/mcp/otel/chunking; no OCR, no ML |
full |
formats + ocr + paddle-ocr + layout + embeddings + tree-sitter + liter-llm |
no-ort-target |
Pure-Rust base: every capability that does not depend on ONNX Runtime |
wasm-target |
no-ort-target + excel-wasm + ocr-wasm + layout-tract + auto-rotate-tract (no tree-sitter — grammar pack exceeds CDN 50 MB cap) |
android-target |
no-ort-target + excel + tree-sitter + ocr + api + mcp + layout-tract + auto-rotate-tract (for x86_64-linux-android emulator) |
Build Profiles
release— LTO thin, codegen-units=1, stripprofiling— inherits release, retains debug infoxberg-wasmoverride:opt-level="z"(size-optimized)sevenz-rust2,zipoverride:opt-level=2(prevents SIGBUS on macOS ARM64)
04 同仓库更多 Skills
impeccable
Use when the user wants to design, redesign, shape, critique, audit, polish, clarify, distill, harden, optimize, adapt, animate, colorize, extract, or otherwise improve a frontend interface. Covers websites, landing pages, dashboards, product UI, app shells, components, forms, settings, onboarding, and empty states. Handles UX review, visual hierarchy, information architecture, cognitive load, accessibility, performance, responsive behavior, theming, anti-patterns, typography, fonts, spacing, layout, alignment, color, motion, micro-interactions, UX copy, error states, edge cases, i18n, and reusable design systems or tokens. Also use for bland designs that need to become bolder or more delightful, loud designs that should become quieter, live browser iteration on UI elements, or ambitious visual effects that should feel technically extraordinary. Not for backend-only or non-UI tasks.
wasm-constraints
WASM build constraints for the crates/xberg-wasm crate — the wasm-target feature set, no-tokio sync-only internal APIs, the mandatory SyncExtractor trait for WASM-compatible extractors, the 2 MB HTML size limit, size-optimized build config (opt-level="z"), and the async-wrapper/sync-internal API pattern. Load when building for wasm32, adding or modifying a WASM-compatible extractor, or debugging WASM build/runtime failures.
release-versioning
How xberg versions are synced and released — Cargo.toml is the single source of truth, `task version:sync` propagates it to alef-managed binding manifests AND the integrations under integrations/, which are versioned and published in lockstep with core (including -rc.N). Load before bumping a version, editing the version-sync task, or touching an integration's version/xberg dependency.
plugin-architecture-patterns
Plugin architecture, registration, and trait patterns
mime-detection-routing
MIME type detection and extractor routing in core/mime.rs and core/extractor/bytes.rs — the extension→EXT_TO_MIME→validate→registry→extractor flow, key detection functions, the 118+ case-insensitive extension map, priority-based registry selection, wildcard MIME families, and how to add a new MIME type. Load when adding a format, wiring an extractor to a MIME type, or debugging why a file routes to the wrong (or no) extractor.
format-specific-extraction
Format-specific document extraction workflows