test(inference,#1275): regression test for no-CPU-fallback alpha contract#1282
Merged
Conversation
…ract
Add `tests/no_cpu_fallback_contract.rs` — three forbidden-strings
ratchets that fail the build if a future PR weakens the
no-CPU-fallback contract:
1. `select_best_device_panics_loudly_on_no_gpu` — asserts
`inference/model.rs::select_best_device` keeps the
`panic!("No GPU device available for inference. CPU fallback is
disabled.")` loud-fail and tries CUDA + Metal before panicking.
2. `ort_providers_documents_no_cpu_fallback_contract` — asserts
`ort_providers.rs` keeps the "CPU fallback is forbidden" comment
that documents the rule from source.
3. `llamacpp_adapter_uses_loud_fail_for_no_local_model` — asserts
`LlamaCppAdapter` uses the typed `NoLocalModelLoadable` error
(shipped in #1093 / lane A PR-2) rather than a silent skip.
Pattern: same forbidden-strings ratchet shape as lane F PR-2 (#1129
TS persona forbidden-strings), applied to the Rust inference layer.
A test failure points the future-PR-author at the exact contract
they're about to weaken.
Closes the acceptance criterion #3 of #1262 ("regression test per
fallback path"). Final PR (4 of 4) for the silent CPU fallback audit.
Verified:
- cargo test --features metal --test no_cpu_fallback_contract:
3 passed, 0 failed
Lane: alpha flywheel #1272 lane 6.
Audit: #1262 (comment)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
tests/no_cpu_fallback_contract.rs— three forbidden-strings ratchets that fail the build if a future PR weakens the no-CPU-fallback alpha contract:select_best_device_panics_loudly_on_no_gpu— assertsinference/model.rs::select_best_devicekeeps the `panic!("No GPU device available for inference. CPU fallback is disabled.")` loud-fail and tries CUDA + Metal before panicking.ort_providers_documents_no_cpu_fallback_contract— assertsort_providers.rskeeps the "CPU fallback is forbidden" comment that documents the rule from source.llamacpp_adapter_uses_loud_fail_for_no_local_model— assertsLlamaCppAdapteruses the typedNoLocalModelLoadableerror (shipped in docs(vdd): record RTX Qwen2.5-Omni result #1093 / lane A PR-2) rather than a silent skip.Why
Without a regression test, the no-CPU-fallback contract is invariant by inspection only. A test makes it invariant by construction; future PRs that want to reintroduce a fallback (the audit at #1262 found three separate dead-code remnants of past attempts) hit the test rather than ship.
Pattern: same forbidden-strings ratchet shape as lane F PR-2 (#1129 — TS persona forbidden-strings), applied to the Rust inference layer. A test failure points the future-PR-author at the exact contract they're about to weaken.
Audit context
Final PR (4 of 4) for #1262 (silent CPU model fallbacks audit). Closes acceptance criterion #3 of #1262 ("regression test per fallback path").
Sibling PRs:
compute_router.rs(213 LOC)vendored/metal_deltanet.rs(164 LOC)Audit: #1262 (comment)
Lane: alpha flywheel #1272 lane 6.
Test plan
cargo test --features metal --test no_cpu_fallback_contract— 3 passed, 0 failed🤖 Generated with Claude Code