Repository navigation
RFC 008 slice 0b: registries, report schema, and severity policy #1045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f453274
Add validation registries, report, and severity policy: RFC 008 slice…
zkwentz 617bbb8
Address #1045 review: entry-point instantiation, registry validation,…
zkwentz 9ce8a95
Address #1045 review: detection table lists only implemented parsers
zkwentz 8e331e8
fix: harden validation policy verdicts
burtenshaw 792e7b2
test(validation): drop slice checkpoint tests
cursoragent 21f7c6b
chore(validation): regenerate report.schema.json for TypeSpec tags
cursoragent 6a2eb27
fix(validation): allow a null ValidationReport.manifest
cursoragent 0675969
fix(validation): reject duplicate severity-policy check ids
cursoragent ae67cff
docs(validation): describe the 0b contract, not slice 0a
cursoragent 76449f7
test(validation): drop sermons and rename lying tests
cursoragent 5ad69bc
chore: refresh validation stack
burtenshaw 5ffa176
chore: refresh validation stack
burtenshaw 6f98b03
fix: support legacy entry points
burtenshaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| """Grader protocol and registry. | ||
|
|
||
| Selection reads the manifest only — the signature never reaches | ||
| [`~openenv.validation.graders.GraderRegistry.select`]. Write a grader once and it works | ||
| with every format whose parser supplies the manifest fields. | ||
| """ | ||
|
|
||
| from dataclasses import dataclass | ||
| from importlib.metadata import entry_points | ||
| from pathlib import Path | ||
| from typing import Protocol, runtime_checkable | ||
|
|
||
| from ..manifest import CapabilitiesSpec, NormalizedManifest | ||
| from ..providers import RunningSubject | ||
| from ..report import CheckResult | ||
| from ..types import Level, ProviderCapability | ||
|
|
||
| ENTRY_POINT_GROUP = "openenv.validation.graders" | ||
| """Third-party graders register under this entry-point group — zero core changes.""" | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class Subject: | ||
| """ | ||
| The one argument every grader receives. | ||
|
|
||
| Attributes: | ||
| root (`Path`): | ||
| Package source tree. | ||
| manifest ([`~openenv.validation.manifest.NormalizedManifest`]): | ||
| The parsed, normalized manifest. | ||
| image_ref (`str`, *optional*): | ||
| Built image reference; `None` under `--skip-build`. | ||
| running ([`~openenv.validation.providers.RunningSubject`], *optional*): | ||
| The started sandbox; `None` at the static level. | ||
| outputs_dir (`Path`): | ||
| Where trajectory records and replay artifacts are written. | ||
| """ | ||
|
|
||
| root: Path | ||
| manifest: NormalizedManifest | ||
| image_ref: str | None | ||
| running: RunningSubject | None | ||
| outputs_dir: Path | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class Grader(Protocol): | ||
| """ | ||
| One check. Emits a [`~openenv.validation.report.CheckResult`] with a | ||
| [`~openenv.validation.types.CheckStatus`]; never a severity. | ||
|
|
||
| Attributes: | ||
| check_id (`str`): | ||
| Stable, policy-addressed id, e.g. `"semantic.oracle_max"`. | ||
| level ([`~openenv.validation.types.Level`]): | ||
| The validation level this check belongs to. | ||
| requires_capabilities (`frozenset[str]`): | ||
| `CapabilitiesSpec` field names that must be truthy for this grader to apply. | ||
| requires_provider (`frozenset` of [`~openenv.validation.types.ProviderCapability`]): | ||
| Provider capabilities this grader needs; missing ones SKIP the check. | ||
| depends_on (`tuple[str, ...]`): | ||
| Check ids; any non-PASS dependency SKIPs this check with the dependency | ||
| named (this encodes "L2 determinism is a precondition of L3 semantics"). | ||
| """ | ||
|
|
||
| check_id: str | ||
| level: Level | ||
| requires_capabilities: frozenset[str] | ||
| requires_provider: frozenset[ProviderCapability] | ||
| depends_on: tuple[str, ...] | ||
|
|
||
| def applies_to(self, manifest: NormalizedManifest) -> bool: ... | ||
|
|
||
| def run(self, subject: Subject) -> CheckResult: ... | ||
|
zkwentz marked this conversation as resolved.
Dismissed
|
||
|
|
||
|
|
||
| class GraderRegistry: | ||
| """ | ||
| Holds all known graders and selects the applicable subset per run. | ||
|
|
||
| Core graders are registered directly; third parties register via the | ||
| `"openenv.validation.graders"` entry-point group. | ||
| """ | ||
|
|
||
| def __init__(self) -> None: | ||
| self._graders: dict[str, Grader] = {} | ||
|
|
||
| def register(self, grader: Grader) -> None: | ||
| """ | ||
| Register a grader by its check id. | ||
|
|
||
| Args: | ||
| grader ([`~openenv.validation.graders.Grader`]): | ||
| The grader to register. Its `requires_capabilities` must name real | ||
| `CapabilitiesSpec` fields — a typo'd capability is rejected here | ||
| rather than crashing (or silently deselecting) at selection time. | ||
| """ | ||
| if grader.check_id in self._graders: | ||
| raise ValueError( | ||
| f"grader already registered for check id {grader.check_id!r}" | ||
| ) | ||
| unknown = set(grader.requires_capabilities) - set(CapabilitiesSpec.model_fields) | ||
| if unknown: | ||
| raise ValueError( | ||
| f"grader {grader.check_id!r} requires unknown capabilities: " | ||
| f"{sorted(unknown)}; valid names are CapabilitiesSpec fields" | ||
| ) | ||
| self._graders[grader.check_id] = grader | ||
|
|
||
| def load_entry_points(self) -> int: | ||
| """ | ||
| Register third-party graders from the entry-point group. | ||
|
|
||
| An entry point may name a grader instance or a zero-argument grader class; | ||
| classes are instantiated. (An `isinstance(..., Grader)` test cannot make the | ||
| distinction — a grader class with class-level attributes already satisfies | ||
| the runtime-checkable protocol.) | ||
|
|
||
| Returns: | ||
| `int`: the number of graders loaded. | ||
| """ | ||
| loaded = 0 | ||
| discovered = entry_points() | ||
| if hasattr(discovered, "select"): | ||
| selected = discovered.select(group=ENTRY_POINT_GROUP) | ||
| else: | ||
| selected = discovered.get(ENTRY_POINT_GROUP, ()) | ||
|
|
||
| for ep in selected: | ||
| candidate = ep.load() | ||
| grader = candidate() if isinstance(candidate, type) else candidate | ||
| self.register(grader) | ||
|
cursor[bot] marked this conversation as resolved.
Resolved
|
||
| loaded += 1 | ||
| return loaded | ||
|
|
||
| def select(self, manifest: NormalizedManifest, max_level: Level) -> list[Grader]: | ||
| """ | ||
| Select the graders that apply to a manifest, up to a level ceiling. | ||
|
|
||
| Selection reads the manifest only: capabilities select contract graders, type | ||
| tags select domain graders. The signature never reaches this method's inputs. | ||
|
|
||
| Args: | ||
| manifest ([`~openenv.validation.manifest.NormalizedManifest`]): | ||
| The parsed manifest. | ||
| max_level ([`~openenv.validation.types.Level`]): | ||
| Ceiling; graders above it are not selected. | ||
|
|
||
| Returns: | ||
| `list` of [`~openenv.validation.graders.Grader`], ordered by (level, check id). | ||
| """ | ||
| selected = [] | ||
| for grader in self._graders.values(): | ||
| if grader.level > max_level: | ||
| continue | ||
| if not all( | ||
| getattr(manifest.capabilities, field) | ||
|
zkwentz marked this conversation as resolved.
Resolved
|
||
| for field in grader.requires_capabilities | ||
| ): | ||
| continue | ||
| if not grader.applies_to(manifest): | ||
| continue | ||
| selected.append(grader) | ||
| return sorted(selected, key=lambda g: (g.level, g.check_id)) | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| """Parser protocol and registry. | ||
|
|
||
| A parser owns everything format-specific; after `parse()` returns, the format has left | ||
| the pipeline. The registry is the only place a [`~openenv.validation.types.SignatureKind`] | ||
| selects behavior. | ||
| """ | ||
|
|
||
| from pathlib import Path | ||
| from typing import Protocol, runtime_checkable | ||
|
|
||
| from ..manifest import NormalizedManifest | ||
| from ..signature import UnsupportedPackageError | ||
| from ..types import SignatureKind | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class Parser(Protocol): | ||
| """ | ||
| Parses one package format into the normalized manifest. | ||
|
|
||
| A parse is a pure read: it never imports or executes package code. | ||
| """ | ||
|
|
||
| signature: SignatureKind | ||
|
|
||
| def parse(self, package_root: Path) -> NormalizedManifest: ... | ||
|
zkwentz marked this conversation as resolved.
Dismissed
|
||
|
|
||
|
|
||
| class ParserRegistry: | ||
| """ | ||
| Maps detected signatures to registered parsers. | ||
|
|
||
| A detected signature with no registered parser raises | ||
| [`~openenv.validation.signature.UnsupportedPackageError`] with category | ||
| `"parser-not-implemented"` — recognized, never guessed. | ||
| """ | ||
|
|
||
| def __init__(self) -> None: | ||
| self._parsers: dict[SignatureKind, Parser] = {} | ||
|
|
||
| def register(self, parser: Parser) -> None: | ||
| """ | ||
| Register a parser for its signature. | ||
|
|
||
| Args: | ||
| parser ([`~openenv.validation.parsers.Parser`]): | ||
| The parser to register. Replaces any parser previously registered for | ||
| the same signature. | ||
| """ | ||
| self._parsers[parser.signature] = parser | ||
|
|
||
| def parser_for(self, signature: SignatureKind) -> Parser: | ||
| """ | ||
| Return the parser registered for a detected signature. | ||
|
|
||
| Args: | ||
| signature ([`~openenv.validation.types.SignatureKind`]): | ||
| The detected package signature. | ||
|
|
||
| Returns: | ||
| [`~openenv.validation.parsers.Parser`]: the registered parser. | ||
| """ | ||
| parser = self._parsers.get(signature) | ||
| if parser is None: | ||
| raise UnsupportedPackageError( | ||
| "parser-not-implemented", | ||
| f"no parser registered for signature {signature.value!r}", | ||
| ) | ||
| return parser | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| { | ||
| "policy_version": "v1", | ||
| "bounds": { | ||
| "max_oracle_tolerance": 0.1, | ||
| "min_floor_margin": 0.1, | ||
| "max_variance_tolerance": 0.2, | ||
| "max_episode_timeout_s": 3600.0 | ||
| }, | ||
| "entries": [ | ||
|
zkwentz marked this conversation as resolved.
Resolved
|
||
| {"check_id": "static.manifest", "level": 1, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "static.reproducible_build", "level": 1, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "static.image_hygiene", "level": 1, "lane": "local", "severity": "warn"}, | ||
| {"check_id": "static.layout", "level": 1, "lane": "local", "severity": "warn"}, | ||
| {"check_id": "static.sbom", "level": 1, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "static.oci_labels", "level": 1, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "static.resource_declaration", "level": 1, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "static.timeout_ceiling", "level": 1, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "static.dependency_pinning", "level": 1, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "static.task_distribution_pinning", "level": 1, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "runtime.reward_well_formed", "level": 2, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "runtime.rubric_introspectable", "level": 2, "lane": "local", "severity": "warn"}, | ||
| {"check_id": "runtime.observation_schema", "level": 2, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "runtime.state_contract", "level": 2, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "runtime.trajectory_record", "level": 2, "lane": "local", "severity": "warn"}, | ||
| {"check_id": "runtime.reward_attribution", "level": 2, "lane": "local", "severity": "warn"}, | ||
| {"check_id": "runtime.tool_declaration_accuracy", "level": 2, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "runtime.task_declaration_accuracy", "level": 2, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "runtime.seed_control", "level": 2, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "runtime.episode_determinism", "level": 2, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "runtime.network_policy", "level": 2, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "runtime.host_containment", "level": 2, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "runtime.resource_bounds", "level": 2, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "runtime.episode_isolation", "level": 2, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "runtime.oracle_containment", "level": 2, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "semantic.oracle_max", "level": 3, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "semantic.floor_gap", "level": 3, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "semantic.canary_floor", "level": 3, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "semantic.no_solution_leakage", "level": 3, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "semantic.verifier_determinism", "level": 3, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "semantic.verifier_portability", "level": 3, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "semantic.resource_envelope", "level": 3, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "semantic.replayability", "level": 3, "lane": "local", "severity": "fail"}, | ||
| {"check_id": "hub.layer_isolation", "level": 1, "lane": "hub", "severity": "warn"}, | ||
| {"check_id": "hub.time_to_first_work", "level": 2, "lane": "hub", "severity": "warn"}, | ||
| {"check_id": "hub.cosign_signature", "level": 1, "lane": "hub", "severity": "warn"}, | ||
| {"check_id": "hub.cross_host_determinism", "level": 2, "lane": "hub", "severity": "fail"}, | ||
| {"check_id": "hub.immutable_versioning", "level": 1, "lane": "hub", "severity": "fail"}, | ||
| {"check_id": "statistical.reward_reachability", "level": 4, "lane": "hub", "severity": "fail"}, | ||
| {"check_id": "statistical.difficulty_separation", "level": 4, "lane": "hub", "severity": "fail"}, | ||
| {"check_id": "statistical.headroom", "level": 4, "lane": "hub", "severity": "warn"}, | ||
| {"check_id": "statistical.variance_bound", "level": 4, "lane": "hub", "severity": "fail"}, | ||
| {"check_id": "statistical.training_signal", "level": 4, "lane": "hub", "severity": "advisory"}, | ||
| {"check_id": "statistical.adversarial_floor", "level": 4, "lane": "hub", "severity": "fail"}, | ||
| {"check_id": "statistical.gameability_gap", "level": 4, "lane": "hub", "severity": "warn"} | ||
| ] | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.