evalrouter-sdk 0.4.4a1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. evalrouter/__init__.py +26 -0
  2. evalrouter/agents.py +63 -0
  3. evalrouter/langsmith.py +18 -0
  4. evalrouter/py.typed +0 -0
  5. evalrouter/tracing.py +5 -0
  6. evalrouter/types.py +9 -0
  7. evalrouter_contracts/__init__.py +11 -0
  8. evalrouter_contracts/bundle.py +46 -0
  9. evalrouter_contracts/components.py +181 -0
  10. evalrouter_contracts/models.py +288 -0
  11. evalrouter_contracts/protocol.py +221 -0
  12. evalrouter_contracts/py.typed +0 -0
  13. evalrouter_contracts/templates.py +136 -0
  14. evalrouter_contracts/validation.py +329 -0
  15. evalrouter_sdk-0.4.4a1.dist-info/METADATA +306 -0
  16. evalrouter_sdk-0.4.4a1.dist-info/RECORD +49 -0
  17. evalrouter_sdk-0.4.4a1.dist-info/WHEEL +4 -0
  18. evalrouter_sdk-0.4.4a1.dist-info/licenses/LICENSE +29 -0
  19. kimpton_evalrouter/__init__.py +263 -0
  20. kimpton_evalrouter/_acp_agents.py +702 -0
  21. kimpton_evalrouter/_acp_controller.py +746 -0
  22. kimpton_evalrouter/_acp_launch.py +229 -0
  23. kimpton_evalrouter/_acp_registry/LICENSE +176 -0
  24. kimpton_evalrouter/_acp_registry/registry-2026-10-06.json +1547 -0
  25. kimpton_evalrouter/_boundary.py +162 -0
  26. kimpton_evalrouter/_client_run.py +1405 -0
  27. kimpton_evalrouter/_client_trace.py +819 -0
  28. kimpton_evalrouter/_client_trace_otel.py +208 -0
  29. kimpton_evalrouter/_forecasts.py +101 -0
  30. kimpton_evalrouter/_helpers.py +138 -0
  31. kimpton_evalrouter/_in_code.py +522 -0
  32. kimpton_evalrouter/_local_state.py +14 -0
  33. kimpton_evalrouter/_progress.py +289 -0
  34. kimpton_evalrouter/_repository_checkout.py +331 -0
  35. kimpton_evalrouter/_resolution.py +550 -0
  36. kimpton_evalrouter/_resources.py +3027 -0
  37. kimpton_evalrouter/_task_adapters/__init__.py +90 -0
  38. kimpton_evalrouter/_task_adapters/a1_prompt_answer.py +44 -0
  39. kimpton_evalrouter/_task_adapters/a2_environment.py +62 -0
  40. kimpton_evalrouter/_task_adapters/a3_file_task.py +237 -0
  41. kimpton_evalrouter/_task_adapters/a4_repository.py +115 -0
  42. kimpton_evalrouter/_task_mcp.py +374 -0
  43. kimpton_evalrouter/_transport.py +546 -0
  44. kimpton_evalrouter/_web_routes.py +113 -0
  45. kimpton_evalrouter/agents.py +723 -0
  46. kimpton_evalrouter/langsmith.py +1279 -0
  47. kimpton_evalrouter/py.typed +0 -0
  48. kimpton_evalrouter/tracing.py +996 -0
  49. kimpton_evalrouter/types.py +5603 -0
evalrouter/__init__.py ADDED
@@ -0,0 +1,26 @@
1
+ """The public EvalRouter SDK; legacy imports retain the same objects."""
2
+
3
+ from kimpton_evalrouter import (
4
+ APIError,
5
+ Client,
6
+ ClientError,
7
+ EvalRouter,
8
+ RequestOptions,
9
+ RequestTimeout,
10
+ WaitCancelled,
11
+ types,
12
+ )
13
+ from kimpton_evalrouter import (
14
+ __version__ as __version__,
15
+ )
16
+
17
+ __all__ = [
18
+ "Client",
19
+ "EvalRouter",
20
+ "APIError",
21
+ "ClientError",
22
+ "RequestOptions",
23
+ "RequestTimeout",
24
+ "WaitCancelled",
25
+ "types",
26
+ ]
evalrouter/agents.py ADDED
@@ -0,0 +1,63 @@
1
+ """Evaluate agents on EvalRouter tasks on this machine (registry, local ACP or in-code agents)."""
2
+
3
+ from kimpton_evalrouter.agents import (
4
+ Agent,
5
+ AgentContext,
6
+ AgentEvaluation,
7
+ AgentRun,
8
+ AttemptEvent,
9
+ AttemptInfo,
10
+ AttemptOutcome,
11
+ EvaluationResult,
12
+ Gateway,
13
+ LocalAgent,
14
+ PreparedAgent,
15
+ RegistryAgent,
16
+ TaskTools,
17
+ benchmark,
18
+ compare,
19
+ define_agent,
20
+ environment,
21
+ evaluate,
22
+ evaluate_agents,
23
+ evaluate_async,
24
+ local_agent,
25
+ parse_agent,
26
+ private_benchmark,
27
+ quote,
28
+ quote_async,
29
+ registry_agent,
30
+ suite,
31
+ usd_to_micro,
32
+ )
33
+
34
+ __all__ = [
35
+ "Agent",
36
+ "AgentContext",
37
+ "AgentEvaluation",
38
+ "AgentRun",
39
+ "AttemptEvent",
40
+ "AttemptInfo",
41
+ "AttemptOutcome",
42
+ "EvaluationResult",
43
+ "Gateway",
44
+ "LocalAgent",
45
+ "PreparedAgent",
46
+ "RegistryAgent",
47
+ "TaskTools",
48
+ "benchmark",
49
+ "compare",
50
+ "define_agent",
51
+ "environment",
52
+ "evaluate",
53
+ "evaluate_agents",
54
+ "evaluate_async",
55
+ "local_agent",
56
+ "parse_agent",
57
+ "private_benchmark",
58
+ "quote",
59
+ "quote_async",
60
+ "registry_agent",
61
+ "suite",
62
+ "usd_to_micro",
63
+ ]
@@ -0,0 +1,18 @@
1
+ """Import LangSmith traces with ``python -m evalrouter.langsmith``."""
2
+
3
+ from kimpton_evalrouter.langsmith import (
4
+ LangSmithConnector,
5
+ Project,
6
+ SyncResult,
7
+ discover_projects,
8
+ sync_once,
9
+ watch,
10
+ )
11
+ from kimpton_evalrouter.langsmith import (
12
+ main as _main,
13
+ )
14
+
15
+ __all__ = ["LangSmithConnector", "Project", "SyncResult", "discover_projects", "sync_once", "watch"]
16
+
17
+ if __name__ == "__main__":
18
+ raise SystemExit(_main())
evalrouter/py.typed ADDED
File without changes
evalrouter/tracing.py ADDED
@@ -0,0 +1,5 @@
1
+ """Capture framework traces with the optional ``evalrouter[tracing]`` extra."""
2
+
3
+ from kimpton_evalrouter.tracing import CapturedSpan, TraceCapture
4
+
5
+ __all__ = ["CapturedSpan", "TraceCapture"]
evalrouter/types.py ADDED
@@ -0,0 +1,9 @@
1
+ """Alias the reviewed public types without creating duplicate type identities."""
2
+
3
+ import sys as _sys
4
+
5
+ from kimpton_evalrouter import types as _legacy_types
6
+ from kimpton_evalrouter.types import * # noqa: F403
7
+
8
+ __all__ = _legacy_types.__all__
9
+ _sys.modules[__name__] = _legacy_types
@@ -0,0 +1,11 @@
1
+ """Normative package-v1 contracts: models, canonicalization and offline validation.
2
+
3
+ This package is the one authoritative validator. The public `evalrouter`
4
+ distribution bundles it (its `[benchmark]` extra supplies pydantic), and the
5
+ internal `kimpton-evalrouter-contracts` workspace package serves the private
6
+ `kimpton-evalrouter-authoring` tools and the EvalRouter API. It reads bytes,
7
+ computes digests and refuses invalid packages; it never imports contributed
8
+ code, opens a network connection, signs anything or carries operator state.
9
+ """
10
+
11
+ __version__ = "0.4.4a1"
@@ -0,0 +1,46 @@
1
+ """Deterministic ZIPs of declared files only; exclusive publication after validation."""
2
+
3
+ import os
4
+ import tempfile
5
+ import zipfile
6
+ from pathlib import Path
7
+
8
+ from .validation import DirectoryReader, PackageError, canonical, manifest, validate
9
+
10
+
11
+ def bundle(source: Path, destination: Path) -> dict:
12
+ reader = DirectoryReader(source)
13
+ package = manifest(reader)
14
+ destination.parent.mkdir(parents=True, exist_ok=True)
15
+ fd, temporary = tempfile.mkstemp(prefix=".evalrouter-bundle-", dir=destination.parent)
16
+ os.close(fd)
17
+ temp = Path(temporary)
18
+ try:
19
+ with zipfile.ZipFile(temp, "w", compression=zipfile.ZIP_STORED) as archive:
20
+ for name in sorted(["evalrouter.json", *(file.path for file in package.files)]):
21
+ entry = zipfile.ZipInfo(name, date_time=(1980, 1, 1, 0, 0, 0))
22
+ entry.create_system = 3
23
+ entry.external_attr = 0o100644 << 16
24
+ with archive.open(entry, "w") as output:
25
+ if name == "evalrouter.json":
26
+ output.write(canonical(package.model_dump()))
27
+ else:
28
+ limit = next(f.size_bytes for f in package.files if f.path == name)
29
+ with reader.open(name) as stream:
30
+ copied = 0
31
+ while chunk := stream.read(min(1024 * 1024, limit + 1 - copied)):
32
+ copied += len(chunk)
33
+ if copied > limit:
34
+ raise PackageError(
35
+ f"{name}: file grew beyond its declared size"
36
+ )
37
+ output.write(chunk)
38
+ # Validate the actual immutable snapshot, not merely the source folder.
39
+ report = validate(temp)
40
+ try:
41
+ os.link(temp, destination)
42
+ except FileExistsError as exc:
43
+ raise PackageError("Bundle destination already exists; choose a new path") from exc
44
+ return report
45
+ finally:
46
+ temp.unlink(missing_ok=True)
@@ -0,0 +1,181 @@
1
+ """`evalrouter.native-components.v1`: the typed component graph a native package points at.
2
+
3
+ Native packages only. `parameters` exists solely on `NativeProtocol`, so a
4
+ declarative `text.v1` package and a `koliseum` original package have nowhere to
5
+ carry the pointer and are out of scope for this contract.
6
+
7
+ The pointer rides `protocol.parameters` rather than a new envelope field because
8
+ `package_sha256` is `sha256(canonical(package.model_dump()))` with no
9
+ `exclude_defaults`: adding even an optional defaulted field to
10
+ `EvaluationPackage` would move the digest of every historical package.
11
+ """
12
+
13
+ import hashlib
14
+ import re
15
+ from typing import Annotated, Literal
16
+
17
+ from pydantic import AfterValidator, Field, model_validator
18
+
19
+ from .models import Contract, Digest, PackagePath, Slug, safe_path
20
+
21
+ CONTRACT = "evalrouter.native-components.v1"
22
+ POINTER_KEYS = ("component_contract", "component_path", "component_sha256")
23
+ INDEX_LIMIT = 256 * 1024
24
+
25
+ #: Critical extensions this build understands. An unrecognized critical key is a
26
+ #: refusal before preparation, quote, or execution; unknown optional keys
27
+ #: round-trip and contribute nothing to compiled semantics.
28
+ RECOGNIZED_CRITICAL_EXTENSIONS: frozenset[str] = frozenset()
29
+
30
+ #: Model operations a component may request, mapped onto declared capabilities.
31
+ OPERATION_CAPABILITY = {
32
+ "generate": "text_generation",
33
+ "continuation_loglikelihood": "continuation_loglikelihood",
34
+ }
35
+ Operation = Literal["generate", "continuation_loglikelihood"]
36
+
37
+
38
+ def entrypoint_target(value: str) -> str:
39
+ """Split `<declared package path>:<symbol>` and return the path part."""
40
+ path, separator, symbol = value.rpartition(":")
41
+ if not separator or not path or not re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*", symbol):
42
+ raise ValueError("Entrypoints are <declared code path>:<symbol>")
43
+ return safe_path(path)
44
+
45
+
46
+ def checked_entrypoint(value: str) -> str:
47
+ entrypoint_target(value)
48
+ return value
49
+
50
+
51
+ Entrypoint = Annotated[
52
+ str,
53
+ Field(pattern=r"^[a-zA-Z0-9_./:-]+$", max_length=200),
54
+ AfterValidator(checked_entrypoint),
55
+ ]
56
+ ExtensionName = Annotated[
57
+ str, Field(pattern=r"^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*\.v[1-9][0-9]*$", max_length=120)
58
+ ]
59
+ ExtensionKey = Annotated[str, Field(pattern=r"^[a-z][a-z0-9_]*$", max_length=80)]
60
+ #: An extension body is arbitrary JSON so that an unknown *optional* extension
61
+ #: written by a later build round-trips byte-exactly through this one instead of
62
+ #: refusing the whole package. Object keys stay snake_case at every level, which
63
+ #: is the only shape restriction; pydantic-core's own recursion guard bounds
64
+ #: depth, and `INDEX_LIMIT` bounds total size.
65
+ type ExtensionValue = (
66
+ str | int | float | bool | None | list[ExtensionValue] | dict[ExtensionKey, ExtensionValue]
67
+ )
68
+ ExtensionBody = dict[ExtensionKey, ExtensionValue]
69
+
70
+
71
+ def canonical_bytes(value: dict) -> bytes:
72
+ """Canonical JSON bytes.
73
+
74
+ `canonical` is imported lazily because `validation` imports this module and
75
+ `packages/koliseum-benchmarks` imports `canonical` from `validation`, where
76
+ it must keep living.
77
+ """
78
+ from .validation import canonical
79
+
80
+ return canonical(value)
81
+
82
+
83
+ def definition_digest(definition: dict) -> str:
84
+ """SHA-256 over the canonical bytes of a component's `definition` only."""
85
+ return hashlib.sha256(canonical_bytes(definition)).hexdigest()
86
+
87
+
88
+ class TasksDefinition(Contract):
89
+ #: `Literal[False]` rather than `bool`: `binding` is `Literal["package-dataset"]`
90
+ #: in v1, so no `true` value can ever compile. Typing it here puts the refusal
91
+ #: at the component-document seam that `validate()` reports, instead of letting
92
+ #: `validate()` bless a package the compiler always rejects. The material-bound
93
+ #: case arrives with `MaterialReceipt` in a later contract version.
94
+ binding: Literal["package-dataset"]
95
+ material_required: Literal[False]
96
+ selection: Literal["all"]
97
+ task_id_field: str = Field(min_length=1, max_length=120)
98
+
99
+
100
+ class RunnerDefinition(Contract):
101
+ dependency_lock: PackagePath
102
+ entrypoint: Entrypoint
103
+ framework: str = Field(min_length=1, max_length=80)
104
+ framework_version: str = Field(min_length=1, max_length=40)
105
+ kind: Literal["inspect", "lm-eval", "sandbox"]
106
+
107
+
108
+ class ModelInterfaceDefinition(Contract):
109
+ operations: list[Operation] = Field(min_length=1, max_length=8)
110
+
111
+ @model_validator(mode="after")
112
+ def unique(self):
113
+ if len(set(self.operations)) != len(self.operations):
114
+ raise ValueError("Model interface operations must be unique")
115
+ return self
116
+
117
+
118
+ class GraderDefinition(Contract):
119
+ aggregation: Literal["mean", "native"]
120
+ entrypoint: Entrypoint
121
+ metric: Slug
122
+
123
+
124
+ class Component(Contract):
125
+ """Wrapper/definition split: the digest covers the definition, never itself."""
126
+
127
+ sha256: Digest
128
+
129
+ @model_validator(mode="after")
130
+ def digest(self):
131
+ if definition_digest(self.definition.model_dump()) != self.sha256:
132
+ raise ValueError("Component sha256 must equal the digest of its definition")
133
+ return self
134
+
135
+
136
+ class TasksComponent(Component):
137
+ definition: TasksDefinition
138
+ schema_version: Literal["evalrouter.component.tasks.v1"]
139
+
140
+
141
+ class RunnerComponent(Component):
142
+ definition: RunnerDefinition
143
+ schema_version: Literal["evalrouter.component.runner.v1"]
144
+
145
+
146
+ class ModelInterfaceComponent(Component):
147
+ definition: ModelInterfaceDefinition
148
+ schema_version: Literal["evalrouter.component.model-interface.v1"]
149
+
150
+
151
+ class GraderComponent(Component):
152
+ definition: GraderDefinition
153
+ schema_version: Literal["evalrouter.component.grader.v1"]
154
+
155
+
156
+ class ComponentSet(Contract):
157
+ """Keyed by family name, so duplicates are structurally impossible."""
158
+
159
+ grader: GraderComponent
160
+ model_interface: ModelInterfaceComponent
161
+ runner: RunnerComponent
162
+ tasks: TasksComponent
163
+
164
+
165
+ class Extensions(Contract):
166
+ """Both maps are required: an omitted section is not the same as an empty one."""
167
+
168
+ critical: dict[ExtensionName, ExtensionBody] = Field(max_length=50)
169
+ optional: dict[ExtensionName, ExtensionBody] = Field(max_length=50)
170
+
171
+
172
+ class NativeComponentsIndex(Contract):
173
+ components: ComponentSet
174
+ extensions: Extensions
175
+ schema_version: Literal["evalrouter.native-components.v1"]
176
+
177
+ def digest(self) -> str:
178
+ return hashlib.sha256(canonical_bytes(self.model_dump())).hexdigest()
179
+
180
+ def unrecognized_critical(self) -> list[str]:
181
+ return sorted(set(self.extensions.critical) - RECOGNIZED_CRITICAL_EXTENSIONS)
@@ -0,0 +1,288 @@
1
+ """Versioned contributor declarations, separate from platform admission receipts."""
2
+
3
+ import re
4
+ from pathlib import PurePosixPath
5
+ from typing import Annotated, Literal
6
+ from urllib.parse import urlsplit
7
+
8
+ from pydantic import AfterValidator, BaseModel, ConfigDict, Field, model_validator
9
+
10
+
11
+ def safe_path(value: str) -> str:
12
+ parts = value.split("/")
13
+ if (
14
+ not value
15
+ or len(value) > 240
16
+ or "\\" in value
17
+ or any(p in {"", ".", ".."} or p.startswith(".") for p in parts)
18
+ or any(ord(c) < 32 or ord(c) == 127 for c in value)
19
+ or PurePosixPath(value).is_absolute()
20
+ or ":" in value
21
+ ):
22
+ raise ValueError("Use a relative POSIX path without hidden files or traversal")
23
+ return value
24
+
25
+
26
+ def public_url(value: str) -> str:
27
+ url = urlsplit(value)
28
+ if (
29
+ url.scheme != "https"
30
+ or not url.hostname
31
+ or url.username is not None
32
+ or url.password is not None
33
+ or url.query
34
+ or url.fragment
35
+ or any(c.isspace() for c in value)
36
+ ):
37
+ raise ValueError("Source URLs must use HTTPS without credentials, query, or fragment")
38
+ return value
39
+
40
+
41
+ Slug = Annotated[str, Field(pattern=r"^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$", max_length=80)]
42
+ Digest = Annotated[str, Field(pattern=r"^[0-9a-f]{64}$")]
43
+ PackagePath = Annotated[str, AfterValidator(safe_path)]
44
+ SourceURL = Annotated[str, Field(max_length=2048), AfterValidator(public_url)]
45
+ Category = Literal[
46
+ "knowledge",
47
+ "instruction-following",
48
+ "math",
49
+ "reasoning",
50
+ "commonsense",
51
+ "factuality",
52
+ "long-context",
53
+ "rag",
54
+ "multilingual",
55
+ "safety",
56
+ "coding",
57
+ "tools",
58
+ "agents",
59
+ "agent-robustness",
60
+ "professional-work",
61
+ "vision",
62
+ "audio",
63
+ "video",
64
+ "embeddings",
65
+ "reranking",
66
+ "games",
67
+ "forecasting",
68
+ ]
69
+ Capability = Literal[
70
+ "text_generation",
71
+ "chat_format",
72
+ "completions_format",
73
+ "bounded_output",
74
+ "continuation_loglikelihood",
75
+ "tokenizer_alignment",
76
+ "tool_calls",
77
+ "multi_turn",
78
+ "image_input",
79
+ "audio_input",
80
+ "video_input",
81
+ "embeddings",
82
+ "reranking",
83
+ "sandbox",
84
+ "browser",
85
+ "desktop",
86
+ "judge",
87
+ "retrieval",
88
+ ]
89
+
90
+
91
+ class Contract(BaseModel):
92
+ model_config = ConfigDict(extra="forbid", strict=True, allow_inf_nan=False)
93
+
94
+
95
+ class FileRecord(Contract):
96
+ path: PackagePath
97
+ sha256: Digest
98
+ size_bytes: int = Field(ge=0, le=256 * 1024 * 1024)
99
+ role: Literal[
100
+ "dataset", "license", "code", "dependencies", "documentation", "fixtures", "asset"
101
+ ]
102
+
103
+
104
+ class Repository(Contract):
105
+ url: SourceURL
106
+ commit: str = Field(pattern=r"^[0-9a-f]{40}$")
107
+
108
+
109
+ class Rights(Contract):
110
+ scope: Literal["code", "data", "tests", "assets"]
111
+ identifier: str = Field(min_length=1, max_length=120)
112
+ document: PackagePath
113
+ commercial_execution: Literal["allowed", "restricted", "unknown"]
114
+ redistribution: Literal["allowed", "restricted", "unknown"]
115
+ display: Literal["allowed", "restricted", "unknown"]
116
+ attribution: str = Field(min_length=1, max_length=2000)
117
+
118
+
119
+ class Dataset(Contract):
120
+ path: PackagePath
121
+ format: Literal["evalrouter.tasks.v1", "native"]
122
+ split: str = Field(min_length=1, max_length=120)
123
+ task_count: int = Field(ge=1, le=10_000_000)
124
+ languages: list[str] = Field(min_length=1, max_length=200)
125
+ exclusions: list[str] = Field(default_factory=list, max_length=1000)
126
+
127
+
128
+ class Limits(Contract):
129
+ max_requests_per_task: int = Field(ge=1, le=1000)
130
+ max_input_tokens: int = Field(ge=1, le=2_000_000)
131
+ max_output_tokens: int = Field(ge=1, le=200_000)
132
+ max_task_seconds: int = Field(ge=1, le=86400)
133
+ max_memory_mib: int = Field(ge=64, le=131072)
134
+ max_disk_mib: int = Field(ge=1, le=1048576)
135
+ max_tool_steps: int = Field(ge=0, le=10000)
136
+ network_hosts: list[str] = Field(default_factory=list, max_length=50)
137
+
138
+ @model_validator(mode="after")
139
+ def hostnames(self):
140
+ if any(not re.fullmatch(r"[a-z0-9]+(?:[.-][a-z0-9]+)*", x) for x in self.network_hosts):
141
+ raise ValueError("Network destinations must be explicit lower-case hostnames")
142
+ return self
143
+
144
+
145
+ class DeclarativeProtocol(Contract):
146
+ kind: Literal["declarative"]
147
+ template: Literal["text.v1"]
148
+ instruction: str = Field(max_length=20000)
149
+ scorer: Literal["exact_match"]
150
+ strip_whitespace: bool = False
151
+ case_sensitive: bool = True
152
+ temperature: float = Field(ge=0, le=2)
153
+ fixtures: PackagePath
154
+
155
+
156
+ class NativeProtocol(Contract):
157
+ kind: Literal["inspect", "lm-eval", "sandbox"]
158
+ entrypoint: str = Field(pattern=r"^[a-zA-Z0-9_./:-]+$", max_length=200)
159
+ dependency_lock: PackagePath
160
+ source: Repository
161
+ parameters: dict[str, str | int | float | bool] = Field(default_factory=dict, max_length=100)
162
+
163
+
164
+ class OriginalProtocol(Contract):
165
+ """Internal content-addressed programs. This is not text.v1 admission."""
166
+
167
+ kind: Literal["koliseum"]
168
+ program_sha256: Digest
169
+ grader: Slug
170
+ dependency_lock: PackagePath
171
+ execution_class: Literal["trusted.koliseum-text.v1", "code.koliseum.v1"]
172
+
173
+
174
+ class Metric(Contract):
175
+ name: Slug
176
+ direction: Literal["higher", "lower"]
177
+ aggregation: Literal["mean", "native"]
178
+ minimum: float
179
+ maximum: float
180
+
181
+ @model_validator(mode="after")
182
+ def order(self):
183
+ if self.minimum >= self.maximum:
184
+ raise ValueError("Metric minimum must be below maximum")
185
+ return self
186
+
187
+
188
+ class EvaluationPackage(Contract):
189
+ schema_version: Literal["evalrouter.package.v1"]
190
+ namespace: Slug
191
+ name: Slug
192
+ version: str = Field(pattern=r"^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$")
193
+ title: str = Field(min_length=1, max_length=200)
194
+ description: str = Field(min_length=1, max_length=4000)
195
+ category: Category
196
+ authors: list[str] = Field(min_length=1, max_length=50)
197
+ maintainer: str = Field(min_length=1, max_length=200)
198
+ source: Repository | None = None
199
+ references: list[SourceURL] = Field(default_factory=list, max_length=50)
200
+ visibility: Literal["private", "catalog"] = "private"
201
+ synthetic: bool = False
202
+ files: list[FileRecord] = Field(min_length=1, max_length=1000)
203
+ rights: list[Rights] = Field(min_length=2, max_length=100)
204
+ dataset: Dataset
205
+ protocol: Annotated[
206
+ DeclarativeProtocol | NativeProtocol | OriginalProtocol, Field(discriminator="kind")
207
+ ]
208
+ capabilities: list[Capability] = Field(min_length=1, max_length=30)
209
+ limits: Limits
210
+ metrics: list[Metric] = Field(min_length=1, max_length=30)
211
+ limitations: list[str] = Field(min_length=1, max_length=50)
212
+ changelog: str = Field(min_length=1, max_length=4000)
213
+
214
+ @model_validator(mode="after")
215
+ def references_and_protocol(self):
216
+ files = {f.path: f for f in self.files}
217
+ if len(files) != len(self.files) or len({p.casefold() for p in files}) != len(files):
218
+ raise ValueError("Package paths must be unique, including case-insensitive filesystems")
219
+ if "evalrouter.json" in {p.casefold() for p in files}:
220
+ raise ValueError("The manifest cannot be included in its own file table")
221
+ if sum(f.size_bytes for f in self.files) > 512 * 1024 * 1024:
222
+ raise ValueError("Package exceeds the 512 MiB v1 limit")
223
+ if len(set(self.capabilities)) != len(self.capabilities):
224
+ raise ValueError("Capabilities must be unique")
225
+ if len({m.name for m in self.metrics}) != len(self.metrics):
226
+ raise ValueError("Metric names must be unique")
227
+ if not {"code", "data"}.issubset(r.scope for r in self.rights):
228
+ raise ValueError("Declare code and data rights separately")
229
+ for role, scope in (("fixtures", "tests"), ("asset", "assets")):
230
+ if any(f.role == role for f in self.files) and not any(
231
+ r.scope == scope for r in self.rights
232
+ ):
233
+ raise ValueError(f"Declare {scope} rights separately")
234
+ for right in self.rights:
235
+ if right.document not in files or files[right.document].role != "license":
236
+ raise ValueError(
237
+ "Every rights statement must reference a declared license document"
238
+ )
239
+ if self.dataset.path not in files or files[self.dataset.path].role != "dataset":
240
+ raise ValueError("Dataset must reference a declared dataset file")
241
+ if isinstance(self.protocol, DeclarativeProtocol):
242
+ if self.dataset.format != "evalrouter.tasks.v1":
243
+ raise ValueError("Declarative text tasks require evalrouter.tasks.v1 data")
244
+ if not {"text_generation", "bounded_output"}.issubset(self.capabilities):
245
+ raise ValueError("Declarative text requires text generation and bounded output")
246
+ if set(self.capabilities) - {"text_generation", "bounded_output", "chat_format"}:
247
+ raise ValueError("text.v1 cannot claim tools, media, or other native capabilities")
248
+ if (
249
+ self.limits.max_requests_per_task != 1
250
+ or self.limits.max_tool_steps
251
+ or self.limits.network_hosts
252
+ ):
253
+ raise ValueError("text.v1 permits one model request and no custom tools or network")
254
+ fixtures = files.get(self.protocol.fixtures)
255
+ if not fixtures or fixtures.role != "fixtures":
256
+ raise ValueError("Declare the grading fixture file")
257
+ if len(self.metrics) != 1 or self.metrics[0].model_dump() != {
258
+ "name": "accuracy",
259
+ "direction": "higher",
260
+ "aggregation": "mean",
261
+ "minimum": 0.0,
262
+ "maximum": 1.0,
263
+ }:
264
+ raise ValueError("text.v1 exact_match reports mean accuracy in [0, 1]")
265
+ else:
266
+ lock = files.get(self.protocol.dependency_lock)
267
+ if not lock or lock.role != "dependencies":
268
+ raise ValueError("Native packages require a declared dependency lock")
269
+ if not any(f.role == "code" for f in self.files):
270
+ raise ValueError("Native packages must include the pinned source code")
271
+ return self
272
+
273
+ @property
274
+ def identity(self) -> str:
275
+ return f"{self.namespace}/{self.name}@{self.version}"
276
+
277
+
278
+ class Task(Contract):
279
+ id: str = Field(min_length=1, max_length=200)
280
+ input: str = Field(max_length=2_000_000)
281
+ target: str = Field(max_length=200_000)
282
+ stratum: str = Field(default="default", min_length=1, max_length=200)
283
+
284
+
285
+ class GradingFixture(Contract):
286
+ target: str = Field(max_length=200000)
287
+ output: str = Field(max_length=200000)
288
+ expected_score: int = Field(ge=0, le=1)