feat(safety): model-backed steering layers for hybrid safety control loop (ADR-013)#6
Merged
Merged
Conversation
- Implement SafetyConfig, SafetyModeSelector, and ContrastiveSteerer in el-safety (ADR-013 hybrid safety control loop with model-backed tiers) - Wire el-engine-candle QwenChatProvider to the ADR-005/012 safety seam: lightweight token-anchor guard + hard-ban filter + checkpointed rollback - Add --safety / --guard-word CLI options to el-chat for demo/test control - Fix: local_load_permit now passes actual GGUF header bytes to verify() so a real SignatureVerifier swap receives artifact content, not path bytes - Fix: with_safety(SecDecoding|Csd) without an expert model now downgrades to Lightweight, keeping cfg.safety consistent with ports.safety - Apply cargo fmt across all affected crates
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
SafetyConfig,SafetyModeSelector, andContrastiveSteererinel-safety— base-vs-safety-model logit steering with device-class gating (SecDecoding downgrades to Lightweight on mid-range devices)QwenChatProviderinel-engine-candleto the ADR-005/012 safety seam: lightweight token-anchor chunk guard + hard-banLightweightFilter+ checkpointed rollback — every reply flows throughInferenceSession::generate, nothing bypassed--safety/--guard-wordCLI flags toel-chatso the control loop can be exercised interactively without a harmful promptlocal_load_permitnow passes the first 64 bytes of the GGUF file toverify(), so a realSignatureVerifierswap receives actual artifact content rather than the path stringwith_safety(SecDecoding|Csd)without a wired expert model now downgrades toLightweight, keepingcfg.safetyconsistent with whatports.safetyactually deliverscargo fmt --allapplied across all affected cratesTest plan
cargo check --all— clean (verified locally)cargo fmt --all -- --check— clean (verified locally)cargo test -p el-safety— safety steerer unit testscargo test -p el-engine-candle— provenance gate + safety wiring testscargo test -p el-runtime— session rollback / fail-closed testscargo run -p el-chat -- --guard-word bomb— confirm guard fires and emits the refusal