seldon-runtime 0.1.1.dev2__py3-none-any.whl → 0.1.1.dev3__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.
@@ -1,3 +1,3 @@
1
1
  """Standalone Seldon Functions interpreter and local execution client."""
2
2
 
3
- __version__ = "0.1.1.dev2"
3
+ __version__ = "0.1.1.dev3"
@@ -16,18 +16,20 @@ from dataclasses import dataclass
16
16
  from pathlib import Path
17
17
  from typing import Any, Literal, Protocol
18
18
 
19
- from pydantic import BaseModel, ConfigDict, Field, ValidationError
19
+ from pydantic import BaseModel, ConfigDict, Field, ValidationError, model_validator
20
20
 
21
21
  from .contracts import FunctionSpec, Plan, digest
22
22
  from .executor import Execution, execute
23
+ from .native_adapter import native_request, validate_native_config, validate_native_model
24
+ from .native_schema import NATIVE_CONTRACT_ERRORS
23
25
  from .output_budget import resolve
24
26
  from .program_validation import validate_program
25
27
  from .provider_error import ProviderError
26
28
 
27
29
  MAX_ARTIFACT_BYTES = 2 * 1024 * 1024
28
- RUNTIME_VERSION = "0.1.1.dev2"
30
+ RUNTIME_VERSION = "0.1.1.dev3"
29
31
  _SHA256 = r"^[0-9a-f]{64}$"
30
- Capability = Literal["chat", "structured_output", "tools"]
32
+ Capability = Literal["chat", "structured_output", "tools", "choice", "extract"]
31
33
  OptimizerContract = Literal[
32
34
  "optimizer-correctness-v1",
33
35
  "optimizer-correctness-v2",
@@ -51,11 +53,25 @@ class _Data(BaseModel):
51
53
  class ModelRequirements(_Data):
52
54
  """Execution capabilities, not endpoint discovery or proof of model quality."""
53
55
 
54
- protocol: Literal["openai-chat-completions"]
56
+ protocol: Literal["openai-chat-completions", "fastino_gliner", "system_one"]
55
57
  capabilities: tuple[Capability, ...] = Field(min_length=1, max_length=3)
56
58
  context_length: int = Field(strict=True, ge=1, le=100_000_000)
57
59
  max_output_tokens: int = Field(strict=True, ge=1, le=10_000_000)
58
60
  revision: str | None = Field(max_length=256)
61
+ upstream_model: str | None = Field(default=None, min_length=1, max_length=256)
62
+ native_modes: tuple[Literal["legacy", "pairs", "spans", "records"], ...] = ()
63
+ native_answers: tuple[Literal["choice", "boolean", "noul", "score"], ...] = ()
64
+ native_max_levels: int = Field(default=10, strict=True, ge=2, le=10)
65
+ native_profile: dict[str, Any] = Field(default_factory=dict)
66
+
67
+ @model_validator(mode="after")
68
+ def valid_native_contract(self):
69
+ validate_native_model(self)
70
+ return self
71
+
72
+ @property
73
+ def upstream_model_name(self):
74
+ return self.upstream_model
59
75
 
60
76
 
61
77
  class Evidence(_Data):
@@ -70,8 +86,8 @@ class ArtifactManifest(_Data):
70
86
  version: Literal["compiler-artifact-v1"]
71
87
  compiler_version: str = Field(min_length=1, max_length=64, pattern=r"^[a-zA-Z0-9.+_-]+$")
72
88
  # Explicit reviewed reader compatibility, never a version-prefix/range guess.
73
- # dev2 changes asset delivery only; dev1's token and plan semantics are frozen.
74
- runtime_version: Literal["0.1.1.dev1", "0.1.1.dev2"]
89
+ # dev3 adds explicit native bindings; older artifacts retain their restrictions.
90
+ runtime_version: Literal["0.1.1.dev1", "0.1.1.dev2", "0.1.1.dev3"]
75
91
  optimizer_contract_version: OptimizerContract
76
92
  instruction_envelope: Literal["instruction-envelope-v1"] | None
77
93
  conditional: bool = Field(strict=True)
@@ -124,6 +140,8 @@ def _required_capabilities(plan: Plan, spec: FunctionSpec) -> dict[str, set[str]
124
140
  for step in plan.steps:
125
141
  if step.op == "llm":
126
142
  add(step.model, calls[step.call], output_schema=step.output_schema)
143
+ elif step.op in {"choice", "extract"}:
144
+ required.setdefault(step.model, set()).add(step.op)
127
145
  if plan.fallback:
128
146
  for call in spec.calls:
129
147
  add(call.model, call)
@@ -141,11 +159,13 @@ def _parse(data: bytes) -> ArtifactManifest:
141
159
  if raw.get("spec", {}).get("reference_binding") is not None:
142
160
  raise ValueError
143
161
  if any(
144
- step.get("op") in {"generated_kernel", "choice", "extract"}
145
- for step in raw.get("plan", {}).get("steps", [])
162
+ step.get("op") == "generated_kernel" for step in raw.get("plan", {}).get("steps", [])
146
163
  ):
147
164
  raise ValueError
148
165
  manifest = ArtifactManifest.model_validate(raw)
166
+ native = [step for step in manifest.plan.steps if step.op in {"choice", "extract"}]
167
+ if native and manifest.runtime_version != RUNTIME_VERSION:
168
+ raise ValueError
149
169
  if (
150
170
  digest({k: v for k, v in raw.items() if k != "manifest_digest"})
151
171
  != manifest.manifest_digest
@@ -178,6 +198,8 @@ def _parse(data: bytes) -> ArtifactManifest:
178
198
  raise ValueError
179
199
  if len(set(model.capabilities)) != len(model.capabilities):
180
200
  raise ValueError
201
+ for step in native:
202
+ validate_native_config(manifest.models[step.model], step.op, step.config)
181
203
  return manifest
182
204
  except ArtifactError:
183
205
  raise
@@ -196,6 +218,11 @@ def _bindings(manifest, bindings):
196
218
  if not isinstance(actual, ModelRequirements) or (
197
219
  actual.protocol != required.protocol
198
220
  or actual.revision != required.revision
221
+ or actual.upstream_model != required.upstream_model
222
+ or actual.native_profile != required.native_profile
223
+ or actual.native_max_levels != required.native_max_levels
224
+ or not set(required.native_modes) <= set(actual.native_modes)
225
+ or not set(required.native_answers) <= set(actual.native_answers)
199
226
  or actual.context_length < required.context_length
200
227
  # Omitted max_tokens preserves endpoint-default behavior, so an
201
228
  # enlarged endpoint output ceiling cannot silently enlarge the bound.
@@ -233,18 +260,21 @@ class Artifact:
233
260
 
234
261
  async def provider(model, payload):
235
262
  required = manifest.models[model]
236
- needed = {"chat"}
237
- if payload.get("tools"):
263
+ primitive = payload.get("primitive")
264
+ needed = {primitive["kind"]} if isinstance(primitive, dict) else {"chat"}
265
+ if not primitive and payload.get("tools"):
238
266
  needed.add("tools")
239
- if payload.get("response_format"):
267
+ if not primitive and payload.get("response_format"):
240
268
  needed.add("structured_output")
241
- if "primitive" in payload or not needed <= set(required.capabilities):
269
+ if not needed <= set(required.capabilities):
242
270
  raise ArtifactError("model_capability_mismatch")
271
+ if primitive:
272
+ native_request(required, payload)
243
273
  bounded, _, _ = resolve(
244
274
  payload,
245
275
  required,
246
276
  manifest.spec.output_token_policy,
247
- body=lambda value, _: value,
277
+ body=lambda value, _: native_request(required, value)[1] if primitive else value,
248
278
  estimator_for=lambda _: None,
249
279
  )
250
280
  try:
@@ -275,6 +305,10 @@ class Artifact:
275
305
  upstream_status=429 if exc.upstream_status == 429 else None,
276
306
  provider_dispatched=exc.provider_dispatched,
277
307
  ) from None
308
+ except ValueError as exc:
309
+ if str(exc) in NATIVE_CONTRACT_ERRORS | {"invalid_provider_output"}:
310
+ raise ValueError(str(exc)) from None
311
+ raise ArtifactError("execution_failed") from None
278
312
  except Exception:
279
313
  raise ArtifactError("execution_failed") from None
280
314
 
@@ -297,7 +331,12 @@ class Artifact:
297
331
  except asyncio.CancelledError:
298
332
  raise
299
333
  except Exception as exc:
300
- safe = {"token_limit", "context_unverified", "output_schema", "invalid_provider_output"}
334
+ safe = NATIVE_CONTRACT_ERRORS | {
335
+ "token_limit",
336
+ "context_unverified",
337
+ "output_schema",
338
+ "invalid_provider_output",
339
+ }
301
340
  code = (
302
341
  str(exc) if isinstance(exc, ValueError) and str(exc) in safe else "execution_failed"
303
342
  )
@@ -0,0 +1,160 @@
1
+ """Portable native model contracts shared by compiler transport and artifact execution.
2
+
3
+ Capabilities are explicit operator declarations, not proof of model quality. No
4
+ endpoint, credential lookup, network call or model download belongs here.
5
+ """
6
+
7
+ from types import SimpleNamespace
8
+
9
+ from .contracts import check_question
10
+ from .gliner_normalize import normalize as gliner_normalize
11
+ from .gliner_normalize import request as gliner_request
12
+ from .system_one import HOST_VALUES, unwrap
13
+ from .system_one import normalize as system_normalize
14
+ from .system_one import request as system_request
15
+
16
+ NATIVE_PROTOCOLS = frozenset({"fastino_gliner", "system_one"})
17
+
18
+
19
+ def validate_native_model(model):
20
+ caps = set(model.capabilities)
21
+ modes = set(model.native_modes)
22
+ answers = set(model.native_answers)
23
+ if len(caps) != len(model.capabilities) or len(modes) != len(model.native_modes):
24
+ raise ValueError("model_capabilities_invalid")
25
+ if model.protocol == "openai-chat-completions":
26
+ if (
27
+ "chat" not in caps
28
+ or not caps <= {"chat", "structured_output", "tools"}
29
+ or modes
30
+ or answers
31
+ or model.native_profile
32
+ or model.native_max_levels != 10
33
+ ):
34
+ raise ValueError("model_capabilities_invalid")
35
+ return
36
+ if model.protocol not in NATIVE_PROTOCOLS or not model.upstream_model or not model.revision:
37
+ raise ValueError("model_capabilities_invalid")
38
+ expected = "extract" if model.protocol == "fastino_gliner" else "choice"
39
+ allowed = {"legacy", "spans", "records"} if expected == "extract" else {"legacy", "pairs"}
40
+ if caps != {expected} or not modes or not modes <= allowed:
41
+ raise ValueError("model_capabilities_invalid")
42
+ if len(answers) != len(model.native_answers) or not answers <= {
43
+ "choice",
44
+ "boolean",
45
+ "noul",
46
+ "score",
47
+ }:
48
+ raise ValueError("model_capabilities_invalid")
49
+ if expected == "extract" and answers:
50
+ raise ValueError("model_capabilities_invalid")
51
+ if expected == "choice" and (not answers or not answers & {"choice", "boolean"}):
52
+ raise ValueError("model_capabilities_invalid")
53
+ profile = model.native_profile
54
+ if not isinstance(profile, dict) or set(profile) - {"host"}:
55
+ raise ValueError("wire_profile_unsupported")
56
+ host = profile.get("host", {})
57
+ allowed_host = {"route"} if expected == "extract" else {"route", *HOST_VALUES}
58
+ if not isinstance(host, dict) or set(host) - allowed_host:
59
+ raise ValueError("wire_profile_unsupported")
60
+ route = host.get("route")
61
+ if route is not None and (
62
+ not isinstance(route, str)
63
+ or not route
64
+ or len(route) > 256
65
+ or any(
66
+ char not in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-/"
67
+ for char in route
68
+ )
69
+ or route.startswith("/")
70
+ or "//" in route
71
+ ):
72
+ raise ValueError("wire_profile_unsupported")
73
+ for key, allowed_values in HOST_VALUES.items():
74
+ if key in host and (not isinstance(host[key], str) or host[key] not in allowed_values):
75
+ raise ValueError("wire_profile_unsupported")
76
+
77
+
78
+ def validate_native_payload(model, payload):
79
+ validate_native_model(model)
80
+ primitive = payload.get("primitive")
81
+ if not isinstance(primitive, dict) or set(primitive) - {"kind", "config", "source"}:
82
+ raise ValueError("model_capability_unsupported")
83
+ kind = primitive.get("kind")
84
+ config = primitive.get("config")
85
+ if kind not in model.capabilities or not isinstance(config, dict):
86
+ raise ValueError("model_capability_unsupported")
87
+ mode = config.get("mode") or "legacy"
88
+ if mode not in model.native_modes:
89
+ raise ValueError("primitive_mode_unqualified")
90
+ if kind == "choice":
91
+ questions = config.get("questions", {})
92
+ if not isinstance(questions, dict) or not 1 <= len(questions) <= (
93
+ 160 if mode == "pairs" else 128
94
+ ):
95
+ raise ValueError("model_capability_unsupported")
96
+ for question in questions.values():
97
+ check_question(question)
98
+ answer = question.get("type")
99
+ if answer == "choice":
100
+ options = question.get("options")
101
+ if (
102
+ not isinstance(options, list)
103
+ or not 1 <= len(options) <= 128
104
+ or any(not isinstance(option, str) or not option for option in options)
105
+ or len(set(options)) != len(options)
106
+ ):
107
+ raise ValueError("invalid_primitive_configuration")
108
+ if answer == "boolean" and set(model.native_answers) & {"boolean", "choice"}:
109
+ continue
110
+ if answer not in model.native_answers:
111
+ raise ValueError("model_capability_unsupported")
112
+ if answer == "score" and len(question.get("levels", [])) > model.native_max_levels:
113
+ raise ValueError("model_capability_unsupported")
114
+ if mode == "pairs":
115
+ pairs = config.get("pairs")
116
+ if (
117
+ not isinstance(pairs, list)
118
+ or not 1 <= len(pairs) <= 160
119
+ or any(not isinstance(pair, dict) for pair in pairs)
120
+ or {pair.get("id") for pair in pairs} != set(questions)
121
+ ):
122
+ raise ValueError("model_capability_unsupported")
123
+ elif mode == "spans":
124
+ labels = config.get("labels")
125
+ if (
126
+ not isinstance(labels, dict)
127
+ or not 1 <= len(labels) <= 32
128
+ or any(not isinstance(k, str) or not isinstance(v, str) for k, v in labels.items())
129
+ ):
130
+ raise ValueError("model_capability_unsupported")
131
+ else:
132
+ schema = config.get("schema")
133
+ if not isinstance(schema, dict) or not isinstance(schema.get("properties"), dict):
134
+ raise ValueError("model_capability_unsupported")
135
+ if not 1 <= len(schema["properties"]) <= 128:
136
+ raise ValueError("model_capability_unsupported")
137
+
138
+
139
+ def native_request(model, payload):
140
+ """Validate native capabilities, then produce the existing hosted wire shape."""
141
+ validate_native_payload(model, payload)
142
+ target = SimpleNamespace(upstream_model_name=model.upstream_model)
143
+ request = gliner_request if model.protocol == "fastino_gliner" else system_request
144
+ return request(target, payload, model.native_profile)
145
+
146
+
147
+ def validate_native_config(model, kind, config):
148
+ """Check a candidate before search without requiring materialized input text."""
149
+ validate_native_payload(model, {"primitive": {"kind": kind, "config": config}})
150
+
151
+
152
+ def normalize_native(model, payload, raw):
153
+ """Decode the native envelope and preserve grounded/schema failure semantics."""
154
+ validate_native_payload(model, payload)
155
+ if model.protocol == "system_one":
156
+ raw = unwrap(raw, model.native_profile)
157
+ if not isinstance(raw, dict):
158
+ raise ValueError("invalid_provider_output")
159
+ normalize = gliner_normalize if model.protocol == "fastino_gliner" else system_normalize
160
+ return normalize(payload, raw)
@@ -0,0 +1,180 @@
1
+ """``system_one`` wire protocol: System One decisions (Jev and further hosts).
2
+
3
+ The host profile (``route``, ``state_form``, ``legend_format``) comes from the frozen
4
+ card. Without a profile (legacy runs and revisions) requests are exactly the
5
+ pre-registry bytes: route ``systemone`` and ``state.messages``.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import math
11
+
12
+ PROFILE_VERSION = "system_one-v1"
13
+ STATE_FORMS = frozenset({"messages", "json", "text"})
14
+ LEGEND_FORMATS = frozenset({"object", "array"})
15
+ # ``none``: the System One body is the response (Jev, SubQ, Drex).
16
+ # ``workers_ai``: Cloudflare wraps it as ``{"result": …, "success": true, "errors":
17
+ # [], "messages": []}`` (recorded Clef fixtures, 2026-11-01).
18
+ ENVELOPES = frozenset({"none", "workers_ai"})
19
+ HOST_VALUES = {
20
+ "state_form": STATE_FORMS,
21
+ "legend_format": LEGEND_FORMATS,
22
+ "envelope": ENVELOPES,
23
+ }
24
+
25
+
26
+ def route(profile=None):
27
+ return ((profile or {}).get("host") or {}).get("route", "systemone")
28
+
29
+
30
+ def unwrap(raw, profile=None):
31
+ """The System One body inside the host's response envelope, or ``None``.
32
+
33
+ ``None`` (an envelope that reports failure or holds no object) becomes an
34
+ invalid provider response, the same as a non-object body.
35
+ """
36
+ envelope = ((profile or {}).get("host") or {}).get("envelope", "none")
37
+ if envelope not in ENVELOPES:
38
+ raise ValueError("wire_profile_unsupported")
39
+ if envelope == "none":
40
+ return raw
41
+ if not isinstance(raw, dict) or raw.get("success") is not True:
42
+ return None
43
+ result = raw.get("result")
44
+ return result if isinstance(result, dict) else None
45
+
46
+
47
+ def state(payload, profile=None):
48
+ """Request ``state`` in the card's ``state_form`` (capability-registry AC-D2).
49
+
50
+ ``messages`` (Jev today) sends the ordered messages; ``json`` sends the bound
51
+ input object (the JSON body of the last user message when it is one, else the
52
+ messages wrapped in an object); ``text`` sends ``"{role}: {content}"`` lines
53
+ joined by a blank line and never ``state.messages``.
54
+ """
55
+ import json
56
+
57
+ form = ((profile or {}).get("host") or {}).get("state_form", "messages")
58
+ messages = payload["messages"]
59
+ if form not in STATE_FORMS:
60
+ raise ValueError("wire_profile_unsupported")
61
+ if form == "messages":
62
+ return {"messages": messages}
63
+ if form == "text":
64
+ return {"text": "\n\n".join(f"{m['role']}: {m.get('content') or ''}" for m in messages)}
65
+ last = next((m for m in reversed(messages) if m.get("role") == "user"), None)
66
+ try:
67
+ value = json.loads(last["content"]) if last else None
68
+ except (TypeError, ValueError):
69
+ value = None
70
+ return value if isinstance(value, dict) else {"messages": messages}
71
+
72
+
73
+ # Deterministic contract failure (``primitives.SCHEMA_MISMATCH``): the host answered,
74
+ # but not in the shape the question requires. Not a retry signal.
75
+ SCHEMA_MISMATCH = "native_output_schema_mismatch"
76
+
77
+
78
+ def _instructions(name):
79
+ return f"Apply the complete ordered request in state. Return the value for output field {name}."
80
+
81
+
82
+ def question(name, config):
83
+ """Wire question for one plan question (capability-registry 2.5, AC-C2).
84
+
85
+ ``boolean`` and ``choice`` keep the pre-registry two-option and labelled
86
+ ``choice`` encodings, so legacy requests are byte-identical. ``noul`` asks for a
87
+ probability of ``true``; ``score`` sends the ordered levels as ``criteria``.
88
+ """
89
+ kind = config["type"]
90
+ if kind == "noul":
91
+ return {
92
+ "type": "noul",
93
+ "instructions": _instructions(name),
94
+ "criteria": {"true": "true", "false": "false"},
95
+ }
96
+ if kind == "score":
97
+ return {"type": "score", "instructions": _instructions(name), "criteria": config["levels"]}
98
+ options = ["false", "true"] if kind == "boolean" else config["options"]
99
+ if not options or len(options) > 128 or any(not isinstance(v, str) for v in options):
100
+ raise ValueError("invalid_primitive_configuration")
101
+ return {
102
+ "type": "choice",
103
+ "criteria": {v: v for v in options},
104
+ "instructions": _instructions(name),
105
+ }
106
+
107
+
108
+ def request(target, payload, profile=None):
109
+ """``(route, body)`` for a choice step."""
110
+ if ((profile or {}).get("host") or {}).get("envelope", "none") not in ENVELOPES:
111
+ raise ValueError("wire_profile_unsupported")
112
+ primitive = payload["primitive"]
113
+ questions = {}
114
+ for name, config in primitive["config"]["questions"].items():
115
+ questions[name] = question(name, config)
116
+ if primitive["config"].get("mode") == "pairs":
117
+ pair = next(p for p in primitive["config"]["pairs"] if p["id"] == name)
118
+ questions[name]["instructions"] = (
119
+ "Apply the original matching instructions and context in state. "
120
+ f"Decide whether mention {pair['mention_id']} refers to candidate "
121
+ f"{pair['candidate_id']}. Return true only when the identity match "
122
+ "is supported; otherwise false. Stage inputs identify the records."
123
+ )
124
+ return route(profile), {
125
+ "model": target.upstream_model_name,
126
+ "state": state(payload, profile),
127
+ "questions": questions,
128
+ }
129
+
130
+
131
+ def _number(value):
132
+ return not isinstance(value, bool) and isinstance(value, (int, float)) and value == value
133
+
134
+
135
+ def _legend_matches(legend, levels):
136
+ """The host's ``legend`` (array, or object keyed by level index) names ``levels``."""
137
+ if legend is None:
138
+ return True
139
+ if isinstance(legend, list):
140
+ return legend == levels
141
+ if isinstance(legend, dict):
142
+ return legend == {str(i): level for i, level in enumerate(levels)}
143
+ return False
144
+
145
+
146
+ def answer(config, raw_answer):
147
+ """Normalized value for one question, or a typed ``ValueError``."""
148
+ kind = config["type"]
149
+ if kind == "noul":
150
+ probability = raw_answer.get("noul")
151
+ if not _number(probability) or not 0 <= probability <= 1:
152
+ raise ValueError(SCHEMA_MISMATCH)
153
+ return probability > config["threshold"]
154
+ if kind == "score":
155
+ levels = config["levels"]
156
+ score = raw_answer.get("score")
157
+ if (
158
+ not _number(score)
159
+ or not 0 <= score <= len(levels) - 1
160
+ or not _legend_matches(raw_answer.get("legend"), levels)
161
+ ):
162
+ raise ValueError(SCHEMA_MISMATCH)
163
+ return levels[min(int(math.floor(score + 0.5)), len(levels) - 1)]
164
+ choice = raw_answer.get("choice")
165
+ options = ["false", "true"] if kind == "boolean" else config["options"]
166
+ if choice not in options:
167
+ raise ValueError("invalid_provider_output")
168
+ return choice == "true" if kind == "boolean" else choice
169
+
170
+
171
+ def normalize(payload, raw):
172
+ primitive = payload["primitive"]
173
+ answers = raw.get("answers", {})
174
+ if not isinstance(answers, dict):
175
+ raise ValueError("invalid_provider_output")
176
+ result = {}
177
+ for field, config in primitive["config"]["questions"].items():
178
+ raw_answer = answers.get(field)
179
+ result[field] = answer(config, raw_answer if isinstance(raw_answer, dict) else {})
180
+ return result
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seldon-runtime
3
- Version: 0.1.1.dev2
3
+ Version: 0.1.1.dev3
4
4
  Summary: Standalone Seldon Functions interpreter and local execution client
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Source, https://github.com/Deep-Insight-Labs/seldon-runtime
@@ -31,15 +31,22 @@ for eligible Seldon Functions. The package name is **`seldon-runtime`**, and the
31
31
  Python import is `seldon_runtime`. This project is separate from SeldonIO.
32
32
 
33
33
  A single generic runtime executes authorized Function bundles on your hardware.
34
- Optimization and hosted comparison happen on Seldon. The runtime contains no
34
+ Compile with the public [Seldon Compiler](https://github.com/Deep-Insight-Labs/seldon-compiler)
35
+ or use a private Seldon deployment. The runtime contains no
35
36
  optimizer, billing service, dashboard or server infrastructure. Its first local
36
37
  model adapter uses pinned GLiNER2 open weights for extraction and classification.
37
38
 
38
- The current preview, [`0.1.1.dev1`](https://pypi.org/project/seldon-runtime/0.1.1.dev1/),
39
+ The current preview, [`0.1.1.dev2`](https://pypi.org/project/seldon-runtime/0.1.1.dev2/),
39
40
  is available on PyPI. Hosted bundle execution requires a Seldon deployment with
40
41
  bundle delivery enabled for your workspace. The separate standalone artifact reader
41
- uses caller-supplied model bindings without a Seldon service; its compiler exporter
42
- is still in development.
42
+ uses caller-supplied model bindings without a Seldon service. The public compiler
43
+ CLI can compile Functions, produce comparison reports and explicitly export
44
+ selected artifacts today; it requires no platform account. This standalone path is separate from hosted Runner bundle
45
+ eligibility and fallback.
46
+
47
+ The source checkout targets **0.1.1.dev3 (unreleased)**, adding standalone native
48
+ artifact bindings. Install this checkout with `python -m pip install .` to use
49
+ that capability; the published dev2 package does not accept native artifacts.
43
50
 
44
51
  ## Install
45
52
 
@@ -51,14 +58,14 @@ On Linux, install CPU PyTorch explicitly to avoid downloading CUDA dependencies:
51
58
 
52
59
  ```sh
53
60
  python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
54
- python -m pip install 'seldon-runtime[gliner]==0.1.1.dev1'
61
+ python -m pip install 'seldon-runtime[gliner]==0.1.1.dev2'
55
62
  ```
56
63
 
57
64
  On macOS:
58
65
 
59
66
  ```sh
60
67
  python -m pip install torch
61
- python -m pip install 'seldon-runtime[gliner]==0.1.1.dev1'
68
+ python -m pip install 'seldon-runtime[gliner]==0.1.1.dev2'
62
69
  ```
63
70
 
64
71
  In a uv environment, use `uv pip install` for the same commands. In a Linux uv
@@ -66,22 +73,21 @@ project, persist the dedicated torch index:
66
73
 
67
74
  ```sh
68
75
  uv add torch --index pytorch=https://download.pytorch.org/whl/cpu
69
- uv add 'seldon-runtime[gliner]==0.1.1.dev1'
76
+ uv add 'seldon-runtime[gliner]==0.1.1.dev2'
70
77
  ```
71
78
 
72
- The model weights and tokenizer files download on first use. Cache the pinned
73
- snapshot in advance for restricted networks. Token-chunked plans also need the
74
- tiktoken BPE cache (`TIKTOKEN_CACHE_DIR`). Model weights are not bundled in the wheel.
79
+ Optional GLiNER model weights and their tokenizer files download on first use.
80
+ Cache the pinned snapshot in advance for restricted networks; these model assets
81
+ are not bundled in the wheel.
75
82
 
76
- The unreleased `0.1.1.dev2` candidate removes the separate tiktoken cache prerequisite:
77
- its wheel and source distribution include the fixed `o200k_base` vocabulary used
78
- for Seldon token budgets and chunking. The runtime verifies its hash and constructs
83
+ Since `0.1.1.dev2`, the wheel and source distribution include the fixed `o200k_base`
84
+ vocabulary used for Seldon token budgets and chunking. The runtime verifies its hash and constructs
79
85
  the encoding directly; it never downloads or repairs missing/corrupt tokenizer
80
86
  data. No network or writable cache is required for these operations. Optional
81
87
  GLiNER weights and their own tokenizer files still require advance preparation.
82
88
  See [third-party notices](THIRD_PARTY_NOTICES.md) and
83
89
  [asset provenance](seldon_runtime/data/provenance.json) for sources and license basis.
84
- The published dev1 installation commands above retain their original prerequisites.
90
+ Older dev1 installations still require a prepared tiktoken BPE cache.
85
91
 
86
92
  ## Run a Function locally
87
93
 
@@ -151,12 +157,12 @@ Always close the runner to stop background tasks and attempt a bounded flush.
151
157
 
152
158
  ## Development
153
159
 
154
- ### Standalone compiler artifacts (unreleased)
160
+ ### Standalone compiler artifacts (preview)
155
161
 
156
162
  The separate compiler-artifact reader executes locally compiled user-owned plans.
157
163
  It does not use `Runner.load`, hosted Function IDs, a Seldon API key, refresh or
158
- telemetry. This reader is under development; a public compiler/exporter is not yet
159
- available. The existing hosted-bundle instructions above remain unchanged.
164
+ telemetry. The public compiler CLI produces these artifacts. The existing
165
+ hosted-bundle instructions above remain unchanged.
160
166
 
161
167
  An export directory contains one `manifest.json`, at most 2 MiB. Plan and spec are
162
168
  inline; no file paths, URLs, credentials or executable Python are supported. The
@@ -169,10 +175,10 @@ a development environment with `python -m pip install '.[schema]'` followed by
169
175
  that generator's `--check` mode, independently of the runtime compatibility matrix.
170
176
 
171
177
  The manifest freezes the compiler version and an explicit runtime version. New
172
- exports target the current producer version (`0.1.1.dev2` in this unreleased
173
- candidate). The dev2 reader accepts the reviewed set `0.1.1.dev1` and `0.1.1.dev2`;
174
- original dev1 manifests retain their pin and hashes. This packaging fix preserves
175
- token and plan semantics. dev0 and future versions are rejected until explicitly
178
+ exports target the source runtime version (`0.1.1.dev3`). Its reader accepts
179
+ the reviewed set `0.1.1.dev1`, `0.1.1.dev2` and `0.1.1.dev3`; original manifests retain
180
+ their pin and hashes. Native artifacts must declare dev3; older runtime contracts
181
+ remain chat/deterministic-only. dev0 and future versions are rejected until explicitly
176
182
  reviewed; there is no version-prefix or range-based compatibility inference.
177
183
  The manifest also freezes the optimizer contract (v1–v8), evaluation semantics,
178
184
  instruction envelope, conditional
@@ -209,16 +215,30 @@ policy before invoking a provider; your transport still owns TLS, credential ori
209
215
  binding, response-size limits and protocol decoding. Known transport failures use
210
216
  `ProviderError`; untyped failures stop without automatic fallback or retry.
211
217
 
212
- This initial handoff supports OpenAI-compatible chat steps and supported deterministic
213
- operators, including versioned chunking/conditional graphs. Native `choice`/`extract`
214
- adapters and research `generated_kernel` steps are explicitly rejected. A model
218
+ The source dev3 handoff supports OpenAI-compatible chat, native `choice`/`extract`
219
+ and deterministic operators, including versioned chunking/conditional graphs.
220
+ Native bindings declare `protocol="system_one"` with `capabilities=("choice",)` or
221
+ `protocol="fastino_gliner"` with `capabilities=("extract",)`, a nonempty `upstream_model`
222
+ and `revision`, and explicit `native_modes`. Supported modes are `legacy`/`pairs`
223
+ for System One and `legacy`/`spans`/`records` for GLiNER. System One also declares
224
+ `native_answers` (`choice`, `boolean`, `noul`, `score`) and `native_max_levels` (2–10).
225
+ `native_profile` carries only the host's reviewed wire-shape options under `host`;
226
+ it cannot carry endpoints or credentials. These identities must match the caller's
227
+ binding; unsupported operations and modes fail before provider dispatch.
228
+
229
+ The runtime supplies `native_adapter.native_request(model, payload)` and
230
+ `normalize_native(model, payload, raw)` for transports. The binding still returns
231
+ normalized output and owns its HTTP or local-model execution; the artifact never
232
+ downloads model weights or contacts an endpoint on its own. Context fitting uses
233
+ the native wire body and the frozen output policy, including GLiNER encoder rules.
234
+ Research `generated_kernel` steps remain explicitly rejected. A model
215
235
  revision is an operator-supplied identity, not proof of immutable upstream weights.
216
236
  Artifacts may contain sensitive prompts/spec text. Digest checks detect corruption,
217
237
  not malicious replacement of both the content and its digest; trust the producer
218
238
  separately. Linux/macOS filesystem APIs are used; Windows is not qualified.
219
239
 
220
240
  The standalone fixture in `tests/fixtures/compiler-artifact` is generated from the
221
- runtime test factory, pending a real compiler producer. Installed wheel/sdist probes
241
+ runtime test factory. Installed wheel/sdist probes
222
242
  exercise its nonconstant execution through the real interpreter with a deterministic
223
243
  provider callback. They do not qualify a live model, compiler selection quality or
224
244
  the complete compiler-to-runtime lifecycle.
@@ -264,8 +284,8 @@ Linux ARM64 CPU; other hardware and Windows are not claimed as qualified.
264
284
  ## Releases
265
285
 
266
286
  The publishing workflow is `.github/workflows/runtime-publish.yml` in
267
- `Deep-Insight-Labs/seldon-runtime`. Register project `seldon-runtime` as a trusted
268
- publisher on TestPyPI with environment `testpypi`, and on PyPI with environment
287
+ `Deep-Insight-Labs/seldon-runtime`. Trusted publishers are configured for project
288
+ `seldon-runtime` on TestPyPI with environment `testpypi` and PyPI with environment
269
289
  `pypi`. A `runtime-v<version>` tag must match `pyproject.toml` and `__version__`.
270
290
 
271
291
  Publication is disabled unless `SELDON_RUNTIME_TESTPYPI_PUBLISH_ENABLED` and
@@ -1,5 +1,5 @@
1
- seldon_runtime/__init__.py,sha256=vOg02ySikVLCay3IWDJ8_z93jswB78cU-dRMe2ZEJCs,102
2
- seldon_runtime/artifact.py,sha256=JkH5jGxaXnVi6BcbhwDyG_rpH5NdOMgLD_wbR1RuyQY,12711
1
+ seldon_runtime/__init__.py,sha256=I9th4pNcY4WaXvEYmzucby2RnGx_S3YoZQWFbdoKaYk,102
2
+ seldon_runtime/artifact.py,sha256=G8_OlWv4VthZyvdc8be8xIcXwJ2meTsUeqWk7oUzHpA,14858
3
3
  seldon_runtime/attempt_bound.py,sha256=uXGBUBg09Uie75EfSTs_QfSn52tntoJDb8YQ6V_w9GY,1258
4
4
  seldon_runtime/components.py,sha256=y9l9MuYXNT3yuEWWlDDBec7Vb88Z0_5cKEZTuqyOpQE,12215
5
5
  seldon_runtime/conditional.py,sha256=x0Yg0l8T_KlhKvKLVYutbpNGow2vqZRnN9qfcu5jORQ,10867
@@ -13,6 +13,7 @@ seldon_runtime/json_pointer.py,sha256=r__ji3JyTNDn-bGfc9oVIoA1FAq2UBvbQ-05UBi6_8
13
13
  seldon_runtime/local.py,sha256=I9sKUsSZsTjEn4fDrjCzfzscPjb0xXBijhWXjIR6hbM,6873
14
14
  seldon_runtime/local_models.py,sha256=ubqPSabFaXr7E9_1TmMRjl09M20SHqCZmxNqbr_Fo_0,1210
15
15
  seldon_runtime/local_telemetry.py,sha256=fd2u7d7Fr6OOPS50CkmS5tSAXT0DfWrGE-X-Izwa0mw,3405
16
+ seldon_runtime/native_adapter.py,sha256=LKtOUi4c-lrMeHiwcbL3n8bUJO5e5A2mYD4GYLobvto,7139
16
17
  seldon_runtime/native_schema.py,sha256=M2V3FdlGRxeBJ6RjGTb8iLcqmmMhclK6Auh1nh8ic1M,1515
17
18
  seldon_runtime/output_budget.py,sha256=Q4NULJWvBlYJmjn_k9QS4z5AVbXqbxP4zkBQIQbM37Y,8214
18
19
  seldon_runtime/program_validation.py,sha256=s9gF1foKC8j6TVxMfVGdw-u5m4qlPKZ20PS1PDscKVc,6044
@@ -20,16 +21,17 @@ seldon_runtime/provider_error.py,sha256=IM9H1rDFN-obkDlzDr0f-CXbf5RsYu5jXsj3chTN
20
21
  seldon_runtime/research_kernels.py,sha256=cMOSYJQD67ngbhcCvkq6pNxrHrgAluBgcMxICo9n-Xw,2162
21
22
  seldon_runtime/runner.py,sha256=AAcZoFr4caUT6BEtjCelc58zvul2wT2hZOAigE2_g9k,20911
22
23
  seldon_runtime/semantic.py,sha256=5P49s3lwphHril-DMQDYqcJjwCzSCSCCMQExEx2y0WQ,30161
24
+ seldon_runtime/system_one.py,sha256=p7vXIo1j-3B2mWGKS43cUCLZ-N4hh2ScrYcVst50BVk,7119
23
25
  seldon_runtime/telemetry.py,sha256=2ik9i1vTnTx5U42tPMhsmDC_EcernSov_dxgzAF04uE,6984
24
26
  seldon_runtime/templates.py,sha256=zp48gE-ZEsvd3aU-bH8W7d8-MtS35AqzmSQtpuz7W-4,4379
25
27
  seldon_runtime/tokenizer.py,sha256=k3XrK3WdyqX2TXga-yFdXfA7hAutiHWPyRXU-2txMqk,2159
26
28
  seldon_runtime/tool_wire.py,sha256=s2x3TgbjP26hwe_twAS-ArlbLhEXUQUpohK4VoeXgwE,4279
27
29
  seldon_runtime/data/o200k_base.tiktoken,sha256=RGqVOMtsNI41FhINfAiwn1fDZJXirP_-WaW_iwz7Gi0,3613922
28
30
  seldon_runtime/data/provenance.json,sha256=nagan6hzVlnwrFuCm_HswBgn8EYPQ_Q16-d7FJ7Whk8,847
29
- seldon_runtime-0.1.1.dev2.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
30
- seldon_runtime-0.1.1.dev2.dist-info/licenses/NOTICE,sha256=EqBHq_jwh5GaGUPaaOicfkve1QvR9sRF3iHj6BQaZ-k,674
31
- seldon_runtime-0.1.1.dev2.dist-info/licenses/THIRD_PARTY_NOTICES.md,sha256=Nh_1NO9xL86j3OQFXPbBsO__nZKxBe_RXzRViv2cJpk,3232
32
- seldon_runtime-0.1.1.dev2.dist-info/METADATA,sha256=ETUQWLaSJi_VoLZkksGbElQMGmPTVEjdcaY1n_WO4_g,13859
33
- seldon_runtime-0.1.1.dev2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
34
- seldon_runtime-0.1.1.dev2.dist-info/top_level.txt,sha256=OIOoWE_VYJXj3yVmPF3EeSqNJ5DNWZbmSEWB5JMLcTU,15
35
- seldon_runtime-0.1.1.dev2.dist-info/RECORD,,
31
+ seldon_runtime-0.1.1.dev3.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
32
+ seldon_runtime-0.1.1.dev3.dist-info/licenses/NOTICE,sha256=EqBHq_jwh5GaGUPaaOicfkve1QvR9sRF3iHj6BQaZ-k,674
33
+ seldon_runtime-0.1.1.dev3.dist-info/licenses/THIRD_PARTY_NOTICES.md,sha256=Nh_1NO9xL86j3OQFXPbBsO__nZKxBe_RXzRViv2cJpk,3232
34
+ seldon_runtime-0.1.1.dev3.dist-info/METADATA,sha256=rWG2bpJ5bUR2X3IGb-HYtj6wXTxk4oqDqGHP9zfeB08,15223
35
+ seldon_runtime-0.1.1.dev3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
36
+ seldon_runtime-0.1.1.dev3.dist-info/top_level.txt,sha256=OIOoWE_VYJXj3yVmPF3EeSqNJ5DNWZbmSEWB5JMLcTU,15
37
+ seldon_runtime-0.1.1.dev3.dist-info/RECORD,,