Repository navigation
feat(v0.5): overlay override-rules — per-context rule exemption/replacement - #52
Merged
Merged
Conversation
…cement Overlays can now remove base rules from the effective set by id, and pair an override with an add-rules reusing the same id to replace a rule (relax a severity, exempt a vendored/generated zone, etc.). modify-rules stays reserved (its diff semantics are underspecified). - schema.rs: override-rules is accepted; each overridden id must name a real base rule (OverrideUnknownRule otherwise). The duplicate-id check now works over effective base ids (base minus overridden) plus added ids, so a same-id replacement is legal, not a collision. Overridden base rules are still fully validated at load. - eval.rs: effective_rules drops overridden base rules; exposed pub(crate) - action.rs: rule_index reuses effective_rules, so the planner and the evaluator share one set and a finding never resolves to an overridden rule - docs/engine-v0-design.adoc: new overlay-algebra section - 93 tests (5 new: override disables / replaces at eval level, unknown-id and same-id-replacement and modify-rules-reserved at schema level) - versions unified at 0.5.0 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JSVSF9HhKUhDrEV4xkMEXq
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.
What & why
First v0.5 "engine depth" increment. Overlays could already add rules; now they can override base rules — the piece real multi-context policies need. Deliberately touches none of the v0.4 wire contracts (facts/diff/findings/SARIF unchanged).
Semantics
override-rules { ids }— removes those base rules from the effective set. Use it to exempt a context (a vendored or generated zone) from a base rule.add-rules(same id) — replaces a rule: e.g. keep the check but drop its severity from error to warning for one context.modify-rulesstays reserved — its diff semantics are genuinely underspecified, and load-time rejection keepsevaluatetotal.Implementation (three places, kept consistent)
schema.rs— acceptsoverride-rules; each overridden id must name a real base rule (OverrideUnknownRuleotherwise). The duplicate-id check now operates over effective base ids (base minus overridden) plus overlay-added ids, so a same-id replacement is legal rather than a false collision. Overridden base rules are still fully validated at load — evaluation skips them, but a later un-override must not resurrect a malformed rule.eval.rs—effective_rulesdrops overridden base rules; promoted topub(crate).action.rs— the planner'srule_indexnow reuseseffective_rules, so evaluator and planner share exactly one set and a finding can never resolve to an overridden-away rule.Verification
cargo test --workspace— 93 tests (5 new: override-disables and override-with-replacement at the eval level; unknown-id, same-id-replacement, and modify-rules-still-reserved at the schema level)cargo clippy --workspace --all-targets -- -D warningsandcargo fmt --checkcleanreadme-presentrule, then passes clean (exit 0) once an overlay overrides that rule awayplasma check .self-check: 0 violations, 110 rules satisfiedNext in v0.5 (not in this PR)
Content facts +
file-matches-patternis the other big depth item — but it adds afile_contentslayer to the FactSet, which ripples into the frozenplasma facts/plasma diffwire contracts (snapshot size vs. completeness is a real tradeoff). I've left it for a deliberate decision rather than bundling it here. Morefixaction types (CreateFile) also remain.🤖 Generated with Claude Code
https://claude.ai/code/session_01JSVSF9HhKUhDrEV4xkMEXq
Generated by Claude Code