Repository navigation
Rule severity levels with category defaults - #120
Conversation
|
Claude encountered an error after 3m 19s —— View job I'll analyze this and get back to you. |
|
Claude encountered an error after 3m 8s —— View job I'll analyze this and get back to you. |
df4c010 to
e04e647
Compare
| if (v.file === label) { | ||
| errors[`rule:${v.ruleId}`] = { kind: 'rule', message: `[${v.ruleId}] ${v.description}` }; | ||
| const target = v.severity === 'error' ? errors : warnings; | ||
| target[`rule:${v.ruleId}`] = { kind: 'rule', message: `[${v.ruleId}] ${v.description}`, severity: v.severity }; | ||
| } |
There was a problem hiding this comment.
CLAUDE.md compliance: plugin/* not updated for this behavior change.
structured-context/src/validate.ts
Lines 376 to 379 in e04e647
With this change, only severity === 'error' rule violations land in errors; the rest go to warnings. Since no bundled schema rule currently uses the validation category (all are workflow/best-practice/coherence, which default to warning/info), every bundled-rule violation that used to appear in errors now lands in warnings instead.
plugin/scripts/on-stop.ts (line 105: const FRESH_ERRORS = result.errors ?? {};) and plugin/scripts/pre-edit.ts (line 86: const ERRORS = result.errors ?? {};) both read only result.errors to detect newly-introduced rule violations and block the session on new ones. Neither file is touched by this PR, so these hooks will now silently stop flagging newly-introduced bundled-rule violations as session-blocking errors — an unreviewed regression in plugin/*.
CLAUDE.md's "Definition of done" states: "There are several places that need reviewing and updating with any new feature or change added: ... plugin/* - includes skills, commands, hooks, and scripts; update any affected parts"
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
1 similar comment
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Rule violations now carry a severity of error, warning or info. Each rule category supplies a default (validation -> error, coherence and workflow -> warning, best-practice -> info), and a rule may set an optional `severity` field to override it. Only error severity violations fail validation: `validate` and `validate-file` exit non-zero and JSON output reports `valid: false` only for errors. Warning and info violations are still reported. - Add `severity` to the rule metadata contract and generated metaschema - Attach effective severity to RuleViolation; export severity types from the API - validate: per-severity summary counts, details grouped by severity, `ruleViolations` array in JSON output - validate-file: warning/info rule violations go under `warnings` - schemas show: list category default severity and per-rule overrides - Update docs, README and plugin skill references Claude-Session: https://claude.ai/code/session_01EJgagmpxDYVYr7fp9C6cZi
With rule severity levels, rule violations below 'error' go to `warnings`, which the hooks ignored. The pre-edit hook now also records a warnings baseline. The Stop hook still blocks with exit 2 for new errors. For new warnings (except info-level), it returns them as hookSpecificOutput.additionalContext, so Claude sees them without a hook error. Also set a schema in the hook-test fixture config: the hook tests failed after the default schema fallback was removed. Claude-Session: https://claude.ai/code/session_01EJgagmpxDYVYr7fp9C6cZi
e122bce to
14802df
Compare
Closes #60.
severity(error|warning|info). If it's omitted, the category default applies: validation → error, coherence/workflow → warning, best-practice → info.errorviolations failvalidate(exit 1).validate-filereports warning and info violations underwarnings.validate --jsonaddsseverityto rule errors and aruleViolationsarray covering every violation.errorCountnow includes global-scope rule errors.schemas showshows category defaults and per-rule overrides.DEFAULT_SEVERITY_BY_CATEGORY/ruleSeverity()insrc/schema/validate-rules.ts. It's the hook point for future CLI/config overrides and cascade gating (Layered rule evaluation: cascade gating and coverage annotation #115).Notes:
validationcategory, so none of them is an error by default any more.https://claude.ai/code/session_01EJgagmpxDYVYr7fp9C6cZi