Repository navigation
feat(rules): cascade gating for rule evaluation - #148
Merged
Merged
Conversation
Schema failures, hierarchy violations and gating rule violations suppress rule evaluation for a node's main-hierarchy subtree, avoiding wasted downstream checks on inputs already known to be bad. Gated coverage is reported in validate output (human and --json) so callers can see what wasn't evaluated and why. Rules gain `gatesDescendants`, defaulting to true for error severity and false for warning/info. `sctx validate-file` applies the same gating, so a file's rule results match its entry in a full validate run, and reports a `gated` info entry when its rules were skipped. Adds `--depth <n>` to scope validation to a breadth-first hierarchy depth, and `--include-gated` to evaluate gated rules while still reporting them.
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
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.
Closes #115. 579 tests pass; typecheck and biome clean.
Second commit bumps biome to 2.5.15 and fixes one lint error in a test.
Mechanism
Gating only applies to rule evaluation (
$metadata.rules), and only when the schema declares a main hierarchy. Without one,validateRulesruns exactly as before.nodeErrors), reasonschemahierarchyViolations), reasonhierarchyevaluateRulesWithGating(src/schema/gating.ts) walks the main hierarchy breadth-first from roots and orphans. At each node:gatesDescendantsis true: the node's other rules still run, and its subtree is gatedscope: globalrulescoverageGates: [{file, nodeTitle, reason: schema|hierarchy|rule, ruleId?, gatedFiles[]}]in--json, plus a "Coverage" section and a "Rule checks gated" count in text output.Configurable
gatesDescendants$metadata.ruleserrorseverity, false forwarning/info. Explicit true/false overrides.--include-gatedsctx validate,sctx validate-file--depth <n>sctx validateskippedByDepth.--depthisn't gating. It's manual scoping, and it applies to every check, not just rules.validate-file
Same gating as
validate: rules run for the whole space and the output is restricted to the file, sovalidate-file Fequalsvalidaterestricted to F (tested for every fixture file, with and without--include-gated). A gated file gets agated:<file>info entry underwarningssaying why its rules weren't checked.--depthis not supported.What gating does NOT touch
validateGraph: broken links, ordering, duplicates): always runs. Failures are seeds.Open points
--depthdo not surface as broken-link errors (covered by a test).validate-file --semantic F, it lazily judges only gate-capable semantic rules on F's ancestors (top-down, stopping at the first gate), then F's own rules.tests/schema/schema-composition.test.tstripsnoUnsafeOptionalChainingon biome 2.5.1. It's pre-existing on main and I haven't touched it.