Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b65646a
feat(quality): load Reliability error-handling rules from quality config
westonplatter Nov 3, 2026
dbb0ed1
feat(quality): score Reliability error handling from quality config
westonplatter Nov 3, 2026
70580c1
docs(quality): document error_handling in the quality config
westonplatter Nov 3, 2026
3f16fdd
refactor(quality): tidy error_handling loading
westonplatter Nov 3, 2026
a982459
fix(quality): match custom terms that start or end with punctuation
westonplatter Nov 3, 2026
8f590f9
fix(quality): keep custom quality_config digests stable across packag…
westonplatter Nov 4, 2026
41b2728
Merge branch 'main' into feat/reliability-error-handling-config
rng1995 Nov 6, 2026
7ef7002
Merge branch 'main' into feat/reliability-error-handling-config
chrisknvidia Nov 9, 2026
2444198
Merge remote-tracking branch 'upstream/main' into feat/reliability-er…
westonplatter Nov 11, 2026
2914166
feat(quality-config): let a custom file omit expected_headers
westonplatter Nov 11, 2026
176e753
docs(quality): explain that points: 0 differs between the two sections
westonplatter Nov 11, 2026
ca287e4
docs(quality): narrow the scripts and lib rows to the files checked
westonplatter Nov 11, 2026
8f939cb
fix(quality): match multi-word error-handling terms across whitespace
westonplatter Nov 11, 2026
31e2458
docs(quality): describe the quality config file as a whole
westonplatter Nov 11, 2026
61eb038
refactor(quality-config): rename load_quality_config_with_provenance
westonplatter Nov 11, 2026
0c04fab
refactor(quality-config): restore the quality_config_provenance name
westonplatter Nov 11, 2026
ac48cf1
docs(changelog): note the quality_config_provenance signature change
westonplatter Nov 11, 2026
a5d7f36
refactor(quality-config): name the loader load_quality_config_with_pr…
westonplatter Nov 11, 2026
461b560
docs(quality): say lib skips only for .py or .sh files directly in sc…
westonplatter Nov 11, 2026
1242bc3
Merge upstream/main into feat/reliability-error-handling-config
westonplatter Nov 12, 2026
69cff7a
Merge upstream/main into feat/reliability-error-handling-config
westonplatter Nov 12, 2026
8bda96b
Merge upstream/main into feat/reliability-error-handling-config
westonplatter Nov 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ All notable changes to SkillEvaluator are documented in this file.
approved reusable workflow wrappers. Direct callers retain the existing setup;
signed evaluator identity and exact consumer workflow approvals remain required.

- Add an `error_handling` section to the `--quality-config` file for
Comment thread
westonplatter marked this conversation as resolved.
Resolved
Reliability's three error-handling rules: the `SKILL.md` mention check and
the `scripts` and `lib` code checks. Each sets `points`, `message`,
`suggestion`, and its `terms` or `markers`; `points: 0` turns a rule off.
The section is optional and merges with the packaged values. Without a
custom file, scores and findings are unchanged. The packaged
`quality_config` digest changes once, because `quality-default.yaml` gained
the section. A custom file's digest covers only the rules that file sets, so
existing custom files keep their digests and a digest changes only when the
file's rules change.
- Include `skillevaluator ci init`, `ci status` and `ci demo` in the Python
package. Guided GitHub onboarding discovers skills, configures checks and
optional public hosted reports, and opens a reviewable setup PR. An optional
Expand Down
23 changes: 21 additions & 2 deletions docs/tier1-validation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ For `validate`, the default set is `schema`, `version`, `security`, `pii`, `lice
If a quality score changes unexpectedly, inspect the finding message rather than adding keywords. The checker rewards usable instructions and evidence in their relevant context, not vocabulary alone.
</Tip>

**Expected headings.** Reliability deducts points when `SKILL.md` lacks an expected heading. The packaged `quality-default.yaml` expects `## Prerequisites` (or `## Requirements`), `## Limitations`, and `## Troubleshooting` (or `## Common Issues` or `## FAQ`), each worth 5 points. Pass `--quality-config PATH` to `quality-check`, `tier1`, or `validate` to use your own list instead. The file replaces the packaged defaults rather than merging with them, so copy any default entries you want to keep.
**Expected headings.** Reliability deducts points when `SKILL.md` lacks an expected heading. The packaged `quality-default.yaml` expects `## Prerequisites` (or `## Requirements`), `## Limitations`, and `## Troubleshooting` (or `## Common Issues` or `## FAQ`), each worth 5 points. Pass `--quality-config PATH` to `quality-check`, `tier1`, or `validate` to use your own list instead. The `expected_headers` list replaces the packaged list rather than merging with it, so copy any default entries you want to keep. A custom file must include `expected_headers`, even as `expected_headers: []`.

```yaml title="quality.yaml"
expected_headers:
Expand Down Expand Up @@ -359,7 +359,26 @@ For `validate`, the default set is `schema`, `version`, `security`, `pii`, `lice

An entry is satisfied when the heading or any alternative appears anywhere in `SKILL.md` as text, so `## Security` also matches `### Security Notes` or a heading inside a code block.

The file is checked before any validation runs. A file that is missing, unreadable, not UTF-8, invalid YAML, has an unknown key (such as `point` instead of `points`), or lists the same heading twice is a usage error: the command exits with code 2 and names the file and the problem. `validate` checks the file even when `--checks` leaves out `quality`.
**Error-handling checks.** Reliability also runs three error-handling rules, set in the `error_handling` section of the same file. Unlike `expected_headers`, this section is optional and merges with the packaged values: an omitted rule or key keeps its packaged value, and a list you set replaces the packaged list. Set `points: 0` to turn a rule off; it then adds no finding.
Comment thread
westonplatter marked this conversation as resolved.
Resolved

```yaml title="quality.yaml"
expected_headers: []
Comment thread
westonplatter marked this conversation as resolved.
Resolved
error_handling:
mentioned:
terms: [error, failure, rollback, retry]
scripts:
points: 0
```

| Rule | Deducts when | Packaged points | List field |
| --- | --- | --- | --- |
| `mentioned` | `SKILL.md` contains none of the `terms` | `10` | `terms`: whole words, any case. `error` matches `Error` but not `errorless` |
| `scripts` | A `.py` file under `scripts/` or `tools/` has neither a `try:`/`except` pair nor any of the `markers` | `5` | `markers`: case-sensitive text found anywhere in the file, such as `raise` or `if not ` |
Comment thread
westonplatter marked this conversation as resolved.
Resolved
| `lib` | A module in the skill's Python package has neither a `try:`/`except` pair nor any of the `markers` | `5` | `markers`: as for `scripts` |

Each rule also takes `message` and `suggestion`. The `scripts` and `lib` findings append up to three file names to the message, as in `Scripts may lack error handling: run.py`. The `try:`/`except` pair always counts as error handling and is not configurable. See the packaged `quality-default.yaml` for every default term and marker. The `quality_config` digest in the report covers only the rules your file sets, not the packaged values it leaves out, so the digest changes only when your file's rules change.

The file is checked before any validation runs. A file that is missing, unreadable, not UTF-8, invalid YAML, has an unknown key (such as `point` instead of `points`), lists the same heading twice, has a negative or non-numeric `points`, an empty `terms` or `markers` list, or a repeated entry in one of those lists is a usage error: the command exits with code 2 and names the file and the problem. `validate` checks the file even when `--checks` leaves out `quality`.

```text title="Example error"
Error: Invalid value for '--quality-config': quality.yaml: unknown key(s) in expected_headers[0]: point (allowed: alternatives, heading, message, points, suggestion)
Expand Down
23 changes: 23 additions & 0 deletions src/skillevaluator/config/quality-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,26 @@ expected_headers:
points: 5
message: "No troubleshooting section documented"
suggestion: "Add '## Troubleshooting' with Error/Cause/Solution patterns"

# Reliability error-handling rules. A custom file may set any subset of these;
# omitted blocks and keys keep the values below. Set points to 0 to turn a rule off.
error_handling:
# SKILL.md mentions none of the terms (whole word, any case).
mentioned:
points: 10
message: "No mention of error handling or validation"
suggestion: "Document expected errors and how to handle them"
terms: [error, errors, exception, exceptions, invalid, fail, fails, failed, failure, failures, failing,
validate, validates, validated, validating, validation, validations]
# A script has neither try/except nor any marker (case-sensitive substring).
scripts:
points: 5
message: "Scripts may lack error handling"
suggestion: "Scripts should handle errors explicitly"
markers: ["if not ", "if error", "raise", "assert", "ValueError", "FileNotFoundError"]
# A lib module has neither try/except nor any marker (case-sensitive substring).
lib:
points: 5
message: "Lib modules may lack error handling"
suggestion: "Library code should handle errors explicitly with try/except or raise"
markers: ["raise", "assert", "ValueError", "TypeError", "RuntimeError"]
150 changes: 128 additions & 22 deletions src/skillevaluator/quality_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

DEFAULT_QUALITY_CONFIG = files("skillevaluator.config").joinpath("quality-default.yaml")
_ATX_HEADING_RE = re.compile(r"^(#{1,6})[ \t]+(.+?)(?:[ \t]+#+)?[ \t]*$")
_TOP_LEVEL_KEYS = frozenset({"expected_headers"})
_TOP_LEVEL_KEYS = frozenset({"expected_headers", "error_handling"})
_EXPECTED_HEADER_KEYS = frozenset({"heading", "alternatives", "points", "message", "suggestion"})
_ERROR_HANDLING_LIST_KEYS = {"mentioned": "terms", "scripts": "markers", "lib": "markers"}


class QualityConfigError(ValueError):
Expand All @@ -34,10 +35,37 @@ class ExpectedHeader(TypedDict):
suggestion: str


class MentionedRule(TypedDict):
"""Deduction when SKILL.md mentions none of the error-handling terms (whole word, any case)."""

points: int | float
message: str
suggestion: str
terms: list[str]


class CodeErrorHandlingRule(TypedDict):
"""Deduction for Python files with neither try/except nor any marker (case-sensitive substring)."""

points: int | float
message: str
suggestion: str
markers: list[str]


class ErrorHandlingConfig(TypedDict):
"""Reliability error-handling rules; a rule with points 0 is skipped."""

mentioned: MentionedRule
scripts: CodeErrorHandlingRule
lib: CodeErrorHandlingRule


class QualityConfig(TypedDict):
"""Validated deterministic quality configuration."""

expected_headers: list[ExpectedHeader]
error_handling: ErrorHandlingConfig


class QualityConfigProvenance(TypedDict):
Expand All @@ -64,6 +92,66 @@ def _reject_unknown_keys(mapping: dict, allowed: frozenset[str], source: str, lo
)


def _validate_points(points: object, source: str, location: str) -> int | float:
try:
valid_points = (
not isinstance(points, bool) and isinstance(points, (int, float)) and isfinite(points) and points >= 0
)
except OverflowError: # isfinite() on an int too large for a float
valid_points = False
if not valid_points:
raise QualityConfigError(f"{source}: {location}.points must be a non-negative number")
return points


def _validate_text(value: object, source: str, location: str) -> str:
if not isinstance(value, str) or not value.strip():
raise QualityConfigError(f"{source}: {location} must be a non-empty string when set")
return value


def _validate_entries(value: object, source: str, location: str, *, ignore_case: bool) -> list[str]:
if not isinstance(value, list) or not value:
raise QualityConfigError(f"{source}: {location} must be a non-empty list")
seen: set[str] = set()
for index, entry in enumerate(value):
if not isinstance(entry, str) or not entry.strip():
raise QualityConfigError(f"{source}: {location}[{index}] must be a non-blank string")
key = entry.casefold() if ignore_case else entry
if key in seen:
raise QualityConfigError(f"{source}: duplicate entry '{entry}' in {location}")
seen.add(key)
return list(value)


def _parse_error_handling(raw: object, source: str, base: ErrorHandlingConfig | None) -> ErrorHandlingConfig:
if not isinstance(raw, dict):
raise QualityConfigError(f"{source}: error_handling must be a mapping")
_reject_unknown_keys(raw, frozenset(_ERROR_HANDLING_LIST_KEYS), source, "error_handling")
parsed = {}
for name, list_key in _ERROR_HANDLING_LIST_KEYS.items():
location = f"error_handling.{name}"
block = raw.get(name) if base is None else raw.get(name, {})
if not isinstance(block, dict):
raise QualityConfigError(f"{source}: {location} must be a mapping")
allowed = frozenset({"points", "message", "suggestion", list_key})
_reject_unknown_keys(block, allowed, source, location)
if base is None:
missing = sorted(allowed - block.keys())
if missing:
raise QualityConfigError(f"{source}: {location} is missing key(s): {', '.join(missing)}")
merged = block if base is None else {**base[name], **block}
parsed[name] = {
"points": _validate_points(merged["points"], source, location),
"message": _validate_text(merged["message"], source, f"{location}.message"),
"suggestion": _validate_text(merged["suggestion"], source, f"{location}.suggestion"),
list_key: _validate_entries(
merged[list_key], source, f"{location}.{list_key}", ignore_case=list_key == "terms"
),
}
return parsed # type: ignore[return-value]


class _UniqueKeySafeLoader(yaml.SafeLoader):
"""SafeLoader that rejects repeated mapping keys instead of keeping the last value."""

Expand Down Expand Up @@ -94,6 +182,26 @@ def _yaml_error_detail(exc: yaml.YAMLError) -> str:


def load_quality_config(path: Path | None = None) -> QualityConfig:
"""Load and validate the packaged config, or a custom file merged over it."""
return _load(path)[0]


def load_quality_config_with_provenance(path: Path | None = None) -> tuple[QualityConfig, QualityConfigProvenance]:
"""Load the config and describe it. Only the file name is kept, so reports do not leak local paths.

The digest covers the rules the file itself defines. For a custom file, packaged values it
omits are left out, so its digest changes only when its own rules change.
"""
config, declared = _load(path)
provenance: QualityConfigProvenance = {
"source": "custom" if path else "packaged",
"file": path.name if path else None,
"digest": quality_config_digest(declared),
}
return config, provenance


def _load(path: Path | None) -> tuple[QualityConfig, dict]:
source = str(path) if path else "packaged quality-default.yaml"
try:
text = path.read_text(encoding="utf-8") if path else DEFAULT_QUALITY_CONFIG.read_text(encoding="utf-8")
Expand Down Expand Up @@ -129,15 +237,7 @@ def load_quality_config(path: Path | None = None) -> QualityConfig:
_normalize_heading(value, source, f"{location}.alternatives[{alternative_index}]")
for alternative_index, value in enumerate(raw_alternatives)
]
points = rule.get("points", 5)
try:
valid_points = (
not isinstance(points, bool) and isinstance(points, (int, float)) and isfinite(points) and points >= 0
)
except OverflowError: # isfinite() on an int too large for a float
valid_points = False
if not valid_points:
raise QualityConfigError(f"{source}: {location}.points must be a non-negative number")
points = _validate_points(rule.get("points", 5), source, location)
# message and suggestion are optional; omitted ones get generic text naming the headings.
accepted_display = " or ".join(f"'{accepted}'" for accepted in (heading, *alternatives))
message = rule.get("message", f"Missing expected heading: {accepted_display}")
Expand All @@ -146,8 +246,7 @@ def load_quality_config(path: Path | None = None) -> QualityConfig:
f"Add a {accepted_display} section" if not alternatives else f"Add one of these sections: {accepted_display}",
)
for field, value in (("message", message), ("suggestion", suggestion)):
if not isinstance(value, str) or not value.strip():
raise QualityConfigError(f"{source}: {location}.{field} must be a non-empty string when set")
_validate_text(value, source, f"{location}.{field}")

for accepted in (heading, *alternatives):
if accepted in seen_headings:
Expand All @@ -166,19 +265,26 @@ def load_quality_config(path: Path | None = None) -> QualityConfig:
}
)

return {"expected_headers": expected_headers}
if path is None:
error_handling = _parse_error_handling(raw.get("error_handling"), source, base=None)
config: QualityConfig = {"expected_headers": expected_headers, "error_handling": error_handling}
return config, dict(config)
raw_error_handling = raw.get("error_handling", {})
packaged = load_quality_config()["error_handling"]
error_handling = _parse_error_handling(raw_error_handling, source, base=packaged)
declared: dict = {"expected_headers": expected_headers}
declared_error_handling = {
name: {key: error_handling[name][key] for key in block}
for name, block in raw_error_handling.items()
if block
}
if declared_error_handling:
declared["error_handling"] = declared_error_handling
return {"expected_headers": expected_headers, "error_handling": error_handling}, declared


def quality_config_digest(config: QualityConfig) -> str:
def quality_config_digest(config: QualityConfig | dict) -> str:
"""Return a stable digest of the normalized rules, independent of file formatting."""
canonical = json.dumps(config, sort_keys=True, separators=(",", ":")).encode()
return f"sha256:{hashlib.sha256(canonical).hexdigest()}"


def quality_config_provenance(path: Path | None, config: QualityConfig) -> QualityConfigProvenance:
"""Describe the effective config. Only the file name is kept, so reports do not leak local paths."""
return {
"source": "custom" if path else "packaged",
"file": path.name if path else None,
"digest": quality_config_digest(config),
}
Loading