Coverage for src/governed_harness/extensions/contracts.py: 0%
16 statements
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-12 16:06 +0000
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-12 16:06 +0000
1from __future__ import annotations
3from dataclasses import dataclass
4from pathlib import Path
5from typing import Any, Protocol
8@dataclass(frozen=True)
9class DetectionResult:
10 profile_id: str
11 confidence: float
12 evidence: tuple[str, ...]
15@dataclass(frozen=True)
16class NormalizedResult:
17 status: str
18 kind: str
19 summary: str
20 evidence_refs: tuple[str, ...]
21 finding_refs: tuple[str, ...] = ()
24class ProjectDetector(Protocol):
25 def detect(self, workspace: Path) -> DetectionResult:
26 """Detect the project in ``workspace`` (or whether the validator applies to ``context``)."""
29class TechnologyProfile(Protocol):
30 def capabilities(self) -> tuple[str, ...]:
31 """The capabilities the extension declares."""
33 def default_validators(self) -> tuple[str, ...]:
34 """The identifiers of the validators the profile enables by default."""
36 def default_commands(self) -> dict[str, tuple[str, ...]]:
37 """The commands the profile uses by default, by name."""
39 def default_policies(self) -> dict[str, Any]:
40 """The policies the profile sets by default."""
43class Validator(Protocol):
44 def detect(self, context: dict[str, Any]) -> bool:
45 """Detect the project in ``workspace`` (or whether the validator applies to ``context``)."""
47 def execute(self, context: dict[str, Any]) -> Any:
48 """Run the validator on ``context`` and return its raw result."""
50 def parse(self, raw_result: Any) -> Any:
51 """Parse the raw result of the validator."""
53 def normalize(self, parsed_result: Any) -> NormalizedResult:
54 """Normalize the parsed result into a ``NormalizedResult``."""
57class AgentProvider(Protocol):
58 def capabilities(self) -> tuple[str, ...]:
59 """The capabilities the extension declares."""
61 def start(self, request: dict[str, Any]) -> str:
62 """Start a session for ``request`` and return its identifier."""
64 def resume(self, session: str) -> None:
65 """Resume the session."""
67 def cancel(self, session: str) -> None:
68 """Cancel the session."""
70 def collect_events(self, session: str) -> list[dict[str, Any]]:
71 """Return the events the session produced."""
73 def collect_usage(self, session: str) -> dict[str, Any]:
74 """Return the resource usage of the session."""
77class Reporter(Protocol):
78 def render(self, execution: dict[str, Any], format: str) -> bytes:
79 """Render ``execution`` in ``format`` as bytes."""