headroom/wiki
DM 64783d8824
fix: skip Magika backend on x86 CPUs without AVX2 (#1162)
## Description

Adds a narrow runtime AVX2 guard before initializing the Magika/ONNX
Runtime detector on x86/x86_64. On x86/x86_64 CPUs without AVX2,
Headroom falls back to existing non-Magika detection tiers instead of
crashing during ONNX Runtime initialization. AVX2-capable systems retain
existing behavior.

Refs #1005

## Type of Change

- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [x] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring (no functional changes)

## Changes Made

- Adds a Magika/ONNX Runtime CPU support guard before `Session::new()`.
- Returns a normal Magika init error on x86/x86_64 hosts without AVX2,
allowing the existing detection chain to fall through to non-Magika
tiers.
- Keeps AVX2-capable x86/x86_64 behavior unchanged.
- Does not apply the x86-specific AVX2 gate on non-x86 targets.
- Adds CPU-aware Rust tests and a short troubleshooting note.

## Testing

- [ ] Unit tests pass (`pytest`)
- [ ] Linting passes (`ruff check .`)
- [ ] Type checking passes (`mypy headroom`)
- [x] New tests added for new functionality
- [x] Manual testing performed

### Test Output

```text
$ cargo test -p headroom-core --lib --locked
833 passed; 0 failed; 1 ignored

$ cargo test --workspace --locked
passed

$ cargo clippy -p headroom-core --locked -- -D warnings
clean
```

## Real Behavior Proof

- Environment: x86_64 Linux host with AVX but no AVX2 (Intel Xeon
E5-2697 v2 on Proxmox), local build from this branch.
- Exact command / steps: `python -X faulthandler -c 'from headroom._core
import detect_content_type; print(detect_content_type("hello world"))'`
- Observed result: before — process exited with `Fatal Python error:
Illegal instruction`; after — command completed successfully returning
`DetectionResult(content_type="text", ...)`, and full `cargo test -p
headroom-core --lib --locked` passed with 833/0/1.
- Not tested: generic no-AVX CPUs, alternate ONNX Runtime builds,
non-x86 platforms.

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] I have updated the CHANGELOG.md if applicable

## Screenshots (if applicable)

N/A

## Additional Notes

This partially addresses #1005 by handling one concrete native crash
class: the Magika detector initializes ONNX Runtime through ort/ort-sys,
whose precompiled runtime can contain AVX2-family instructions. On
AVX-only x86_64 hosts, that initialization can SIGILL before Headroom
can fall back.

Scope:

- This does not introduce generic no-AVX wheels.
- This does not redesign Rust-core packaging.
- This does not disable the Rust core globally.
- This only prevents the Magika/ONNX detector tier from loading on
x86/x86_64 CPUs where AVX2 is unavailable.
- Non-Magika detection tiers continue to run.
- On non-x86 targets, this x86-specific AVX2 gate is not applied.

Changelog omitted: small native detector fallback fix with no public API
change.

Co-authored-by: AI Agent <ai-agent@homelab.internal>
2026-06-30 13:34:17 -05:00
..
overrides new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
plans fix: add anthropic pre-upstream timeouts 2026-04-21 09:48:32 +07:00
screenshots new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
stylesheets new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
agno.md docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
api.md docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
ARCHITECTURE.md docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
benchmarks.md fix(telemetry): switch anonymous telemetry to opt-in (off by default) (#1223) 2026-06-20 21:26:04 -07:00
ccr.md docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
cli.md fix(cli): harden all CLI surfaces + fix docs accuracy (#1491) 2026-06-27 14:48:43 -07:00
compression.md fix(cli): proxy/perf/wrap UX cleanup + perf --hours correctness 2026-05-07 16:43:35 -07:00
configuration.md docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
docker-install.md fix: align docker image versions with releases 2026-04-17 12:17:49 -05:00
errors.md new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
filesystem-contract.md docs: document HEADROOM_CONFIG_DIR / HEADROOM_WORKSPACE_DIR filesystem contract 2026-04-16 19:24:17 -05:00
getting-started.md docs: use headroom-ai package name in install commands (#1014) (#1257) 2026-06-22 19:25:00 -05:00
image-compression.md new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
index.md docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
integration-guide.md fix(copilot): restore generic endpoint for non-subscription OAuth (#610) (#612) 2026-06-04 16:27:54 -07:00
langchain.md new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
LATENCY_BENCHMARKS.md new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
learn.md fix(cli): harden all CLI surfaces + fix docs accuracy (#1491) 2026-06-27 14:48:43 -07:00
LIMITATIONS.md docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
macos-deployment.md docs: correct macOS troubleshooting Python floor to 3.10+ (#981) 2026-06-15 11:09:59 -05:00
mcp.md docs: document HEADROOM_CONFIG_DIR / HEADROOM_WORKSPACE_DIR filesystem contract 2026-04-16 19:24:17 -05:00
memory.md feat(memory): add opt-in Apple-GPU (MPS) embedding runtime (#766) 2026-06-11 12:59:20 -05:00
metrics.md fix(cli): harden all CLI surfaces + fix docs accuracy (#1491) 2026-06-27 14:48:43 -07:00
network-diff-capture.md feat: add differential network capture harness (#761) 2026-06-08 22:18:31 -07:00
persistent-installs.md docs: document HEADROOM_CONFIG_DIR / HEADROOM_WORKSPACE_DIR filesystem contract 2026-04-16 19:24:17 -05:00
proxy.md fix(cli): harden all CLI surfaces + fix docs accuracy (#1491) 2026-06-27 14:48:43 -07:00
quickstart.md fix(cli): harden all CLI surfaces + fix docs accuracy (#1491) 2026-06-27 14:48:43 -07:00
sdk.md new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
shared-context.md new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
strands.md docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
text-compression.md new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
transforms.md docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
troubleshooting.md fix: skip Magika backend on x86 CPUs without AVX2 (#1162) 2026-06-30 13:34:17 -05:00
typescript-sdk.md chore: remove committed node_modules + stray/internal markdown (repo hygiene) (#1528) 2026-06-27 23:32:54 -07:00
vertex.md chore: remove committed node_modules + stray/internal markdown (repo hygiene) (#1528) 2026-06-27 23:32:54 -07:00