Open-source inference server and production cluster for all the models your agent needs.
Python bgecolbertdata-pipelinedeep-learningembeddingsinferenceinference-serverinformation-retrievalllmmlmlopsnatural-language-processingnlppythonrerankingretrievalretrieval-augmented-generationsemantic-searchspladevector-search
feat(remote): report remote admissions in worker health (#578)
Krisztian Gajdara85c04f18243
diff --git a/packages/sie_gateway/docs/architecture-guide.md b/packages/sie_gateway/docs/architecture-guide.mdindex a6f55f543..31a2e3304 100644--- a/packages/sie_gateway/docs/architecture-guide.md+++ b/packages/sie_gateway/docs/architecture-guide.md@@ -939,6 +939,16 @@ Missing, malformed or oversized metadata clears the previous inventory withoutdiscarding the heartbeat. The wire budget is 64 KiB and 256 children; unknownfields and duplicate positive process IDs are rejected.+A process that holds a model's remote profile also reports that profile's+`remote_contract_sha256`, the `remote_execution_sha256` of its serving code and,+for a hybrid `encode` or `score` model, an `admission`: the local execution+identities its current evidence covers, the model contract, the outputs, the+expiry and a digest. The gateway checks the digests and identity formats, at most+eight identities, outputs from `dense`, `sparse`, `multivector` and `score`, and a+positive expiry, and drops a malformed inventory. The fields are absent when empty.+A gateway that predates them still accepts inventories from processes without a+remote profile and drops those that carry one.+Sidecars probe on dedicated IPC connections independently of readiness pingsand health publication, with afive-second timeout and a ten-second observation lifetime. Shutdown tombstonesdiff --git a/packages/sie_gateway/openapi.json b/packages/sie_gateway/openapi.jsonindex 756a6409c..7669b6241 100644--- a/packages/sie_gateway/openapi.json+++ b/packages/sie_gateway/openapi.json@@ -2587,6 +2587,46 @@],"type": "object"},+ "NumericalAdmissionObservation": {+ "additionalProperties": false,+ "properties": {+ "expires_at_unix_ms": {+ "format": "int64",+ "minimum": 0,+ "type": "integer"+ },+ "kind": {+ "type": "string"+ },+ "local_identities": {+ "items": {+ "type": "string"+ },+ "type": "array"+ },+ "model_contract_sha256": {+ "type": "string"+ },+ "outputs": {+ "items": {+ "type": "string"+ },+ "type": "array"+ },+ "sha256": {+ "type": "string"+ }+ },+ "required": [+ "sha256",+ "kind",+ "local_identities",+ "model_contract_sha256",+ "outputs",+ "expires_at_unix_ms"+ ],+ "type": "object"+ },"NumericalProcessInventory": {"additionalProperties": false,"properties": {@@ -2638,6 +2678,17 @@"NumericalProfileObservation": {"additionalProperties": false,"properties": {+ "admission": {+ "oneOf": [+ {+ "type": "null"+ },+ {+ "$ref": "#/components/schemas/NumericalAdmissionObservation",+ "description": "The local execution identities current evidence covers for the remote profile."+ }+ ]+ },"local_identity": {"type": ["string",@@ -2652,6 +2703,20 @@},"model_id": {"type": "string"+ },+ "remote_contract_sha256": {+ "description": "The contract of the model's remote profile on this process's upstream.",+ "type": [+ "string",+ "null"+ ]+ },+ "remote_execution_sha256": {+ "description": "The serving code that runs the remote profile in this process.",+ "type": [+ "string",+ "null"+ ]}},"required": [diff --git a/packages/sie_gateway/src/types/worker.rs b/packages/sie_gateway/src/types/worker.rsindex 638f91bd3..56c2f2aab 100644--- a/packages/sie_gateway/src/types/worker.rs+++ b/packages/sie_gateway/src/types/worker.rs@@ -305,6 +305,50 @@ pub struct NumericalProfileObservation {pub model_id: String,pub model_contract_sha256: Option<String>,pub local_identity: Option<String>,+ /// The contract of the model's remote profile on this process's upstream.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub remote_contract_sha256: Option<String>,+ /// The serving code that runs the remote profile in this process.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub remote_execution_sha256: Option<String>,+ /// The local execution identities current evidence covers for the remote profile.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub admission: Option<NumericalAdmissionObservation>,+}++#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]+#[serde(deny_unknown_fields)]+pub struct NumericalAdmissionObservation {+ pub sha256: String,+ pub kind: String,+ pub local_identities: Vec<String>,+ pub model_contract_sha256: String,+ pub outputs: Vec<String>,+ pub expires_at_unix_ms: u64,+}++pub const MAX_ADMITTED_IDENTITIES: usize = 8;+const NUMERICAL_OUTPUTS: [&str; 4] = ["dense", "multivector", "score", "sparse"];++impl NumericalAdmissionObservation {+ fn valid(&self) -> bool {+ let mut identities = HashSet::new();+ let mut outputs = HashSet::new();+ sha256_digest(&self.sha256)+ && matches!(self.kind.as_str(), "openai" | "sie")+ && !self.local_identities.is_empty()+ && self.local_identities.len() <= MAX_ADMITTED_IDENTITIES+ && self+ .local_identities+ .iter()+ .all(|identity| local_identity_digest(identity) && identities.insert(identity))+ && sha256_digest(&self.model_contract_sha256)+ && !self.outputs.is_empty()+ && self.outputs.iter().all(|output| {+ NUMERICAL_OUTPUTS.contains(&output.as_str()) && outputs.insert(output)+ })+ && self.expires_at_unix_ms > 0+ }}fn sha256_digest(value: &str) -> bool {@@ -388,6 +432,18 @@ impl NumericalProcessInventory {.local_identity.as_deref().is_some_and(|id| !local_identity_digest(id))+ || profile+ .remote_contract_sha256+ .as_deref()+ .is_some_and(|id| !sha256_digest(id))+ || profile+ .remote_execution_sha256+ .as_deref()+ .is_some_and(|id| !sha256_digest(id))+ || profile+ .admission+ .as_ref()+ .is_some_and(|admission| !admission.valid()){return false;}@@ -596,6 +652,90 @@ mod tests {}}+ fn inventory_with_admission(admission: serde_json::Value) -> serde_json::Value {+ let mut value = inventory();+ let profile = &mut value["children"][0]["snapshot"]["profiles"][0];+ profile["remote_contract_sha256"] = serde_json::json!("e".repeat(64));+ profile["remote_execution_sha256"] = serde_json::json!("f".repeat(64));+ profile["admission"] = admission;+ value+ }++ fn admission() -> serde_json::Value {+ serde_json::json!({+ "sha256": "1".repeat(64),+ "kind": "sie",+ "local_identities": [format!("v2:sha256:{}", "2".repeat(64))],+ "model_contract_sha256": "b".repeat(64),+ "outputs": ["score"],+ "expires_at_unix_ms": 1,+ })+ }++ fn parsed(value: serde_json::Value) -> Option<NumericalProcessInventory> {+ serde_json::from_value::<WorkerStatusMessage>(serde_json::json!({+ "numerical_process_inventory": value+ }))+ .unwrap()+ .numerical_process_inventory+ }++ #[test]+ fn remote_admissions_are_carried_and_malformed_ones_drop_the_inventory() {+ let inventory = parsed(inventory_with_admission(admission())).unwrap();+ let profile = &inventory.children[0].snapshot.as_ref().unwrap().profiles[0];+ let carried = profile.admission.as_ref().unwrap();+ assert_eq!(carried.kind, "sie");+ assert_eq!(carried.local_identities.len(), 1);+ assert_eq!(+ profile.remote_execution_sha256.as_deref(),+ Some("f".repeat(64).as_str())+ );+ let identity = format!("v2:sha256:{}", "2".repeat(64));+ for (field, value) in [+ ("sha256", serde_json::json!("x")),+ ("kind", serde_json::json!("vendor")),+ ("local_identities", serde_json::json!([])),+ ("local_identities", serde_json::json!([identity, identity])),+ (+ "local_identities",+ serde_json::json!((0..=MAX_ADMITTED_IDENTITIES)+ .map(|index| format!("v2:sha256:{index:064x}"))+ .collect::<Vec<_>>()),+ ),+ ("model_contract_sha256", serde_json::json!("x")),+ ("outputs", serde_json::json!(["tokens"])),+ ("outputs", serde_json::json!(["score", "score"])),+ ("expires_at_unix_ms", serde_json::json!(0)),+ ("unexpected", serde_json::json!(true)),+ ] {+ let mut invalid = admission();+ invalid[field] = value;+ assert!(+ parsed(inventory_with_admission(invalid)).is_none(),+ "{field}"+ );+ }+ let mut contract = inventory_with_admission(serde_json::Value::Null);+ contract["children"][0]["snapshot"]["profiles"][0]["remote_contract_sha256"] =+ serde_json::json!("x");+ assert!(parsed(contract).is_none());+ }++ #[test]+ fn an_observation_without_remote_facts_serializes_as_before() {+ let inventory = parsed(inventory()).unwrap();+ let encoded =+ serde_json::to_value(&inventory.children[0].snapshot.as_ref().unwrap().profiles[0])+ .unwrap();+ let mut keys: Vec<_> = encoded.as_object().unwrap().keys().cloned().collect();+ keys.sort();+ assert_eq!(+ keys,+ ["local_identity", "model_contract_sha256", "model_id"]+ );+ }+fn make_worker(health: WorkerHealth, mem_used: i64, mem_total: i64) -> WorkerState {WorkerState {url: "http://w1:8080".into(),diff --git a/packages/sie_sdk/src/sie_sdk/types.py b/packages/sie_sdk/src/sie_sdk/types.pyindex 7e48b5fd2..d5b99fd1c 100644--- a/packages/sie_sdk/src/sie_sdk/types.py+++ b/packages/sie_sdk/src/sie_sdk/types.py@@ -925,10 +925,24 @@ class ResponseResult(TypedDict, total=False):request: RequestMetadata+class NumericalAdmissionObservation(TypedDict):+ """Local execution identities that current evidence covers for a model's remote profile."""++ sha256: str+ kind: Literal["openai", "sie"]+ local_identities: list[str]+ model_contract_sha256: str+ outputs: list[str]+ expires_at_unix_ms: int++class NumericalProfileObservation(TypedDict):model_id: strmodel_contract_sha256: str | Nonelocal_identity: str | None+ remote_contract_sha256: NotRequired[str | None]+ remote_execution_sha256: NotRequired[str | None]+ admission: NotRequired[NumericalAdmissionObservation | None]class NumericalProfileSnapshot(TypedDict):diff --git a/packages/sie_server/REMOTE_BACKENDS.md b/packages/sie_server/REMOTE_BACKENDS.mdindex 2b006ee88..88825e044 100644--- a/packages/sie_server/REMOTE_BACKENDS.md+++ b/packages/sie_server/REMOTE_BACKENDS.md@@ -363,8 +363,10 @@ and resolved profile settings. Unknown identities remain refused.Configuration load and each bridge compare bounded metadata obtained through`SIEClient` with the deployment's configured credential, TLS and proxy policy.-A successful observation lasts at most 30 seconds; a failed observation lasts-2 seconds. The next check after expiry refreshes metadata. A concurrent refresh+A successful observation lasts at most 30 seconds. A read that completes+replaces it, including with a refusal; a read that fails leaves it to expire on+its own and holds off the next read for 2 seconds. The next check after expiry+refreshes metadata. A concurrent refreshrefuses another bridge instead of waiting or starting a second metadata request.Changes to the installed upstream discard the previous observation.@@ -484,6 +486,10 @@ inventory is omitted whole. Failed probes, legacy heartbeats and observationsolder than ten seconds do not retain a previous process's inventory. Normalhealth publication does not wait for these probes, and diagnostics use dedicatedIPC connections so they do not occupy serving or readiness connection slots.+A remote-lane process also reports, for each model with a hybrid `encode` or+`score` policy, the local identities its current evidence covers, as an+`admission` with an expiry and a digest, together with the remote profile's+contract and serving-code digests.These observations and the evidence file grant no gateway routing authority.An `observed` child can still lack a local identity. Numerical gateway routingdiff --git a/packages/sie_server/src/sie_server/config/hybrid_admission.py b/packages/sie_server/src/sie_server/config/hybrid_admission.pyindex ec4d7eb1a..3cb5cebd7 100644--- a/packages/sie_server/src/sie_server/config/hybrid_admission.py+++ b/packages/sie_server/src/sie_server/config/hybrid_admission.py@@ -24,6 +24,7 @@ from sie_server.config.equivalence import ()from sie_server.config.fleet_equivalence import equivalence_record_digest, read_equivalence_evidencefrom sie_server.config.model import ModelConfig+from sie_server.config.sie_identity import sie_upstream_identityfrom sie_server.config.upstreams import UpstreamKind, installed_upstreamsfrom sie_server.core.profile_identity import local_profile_identity, serving_code_digest@@ -35,6 +36,7 @@ class NumericalAdmission:"""The local execution identities that a remote profile's current evidence covers."""sha256: str+ kind: strlocal_identities: frozenset[str]model_contract_sha256: stroutputs: frozenset[str]@@ -115,6 +117,7 @@ def openai_admission(config: ModelConfig, *, now: datetime | None = None) -> Num"records": sorted(equivalence_record_digest(record) for record in admitted),}),+ kind=UpstreamKind.OPENAI.value,local_identities=frozenset(record.local_identity for record in admitted),model_contract_sha256=contract["model_contract_sha256"],outputs=contract["outputs"],@@ -122,6 +125,60 @@ def openai_admission(config: ModelConfig, *, now: datetime | None = None) -> Num)+def sie_admission(config: ModelConfig, *, wait: bool = True, now: datetime | None = None) -> NumericalAdmission | str:+ """Return the admission an SIE upstream's fresh identity grants, or a fixed refusal reason.++ The upstream's execution identity is the one identity admitted. Without+ ``wait`` the upstream is never contacted on the caller's thread.+ """+ observed = sie_upstream_identity(config, wait=wait)+ if isinstance(observed, str):+ return observed+ revision, identity, remaining_s = observed+ if revision != config.hf_revision:+ return "hybrid upstream weights differ from local"+ outputs = frozenset(set(config.outputs) & _NUMERICAL_OUTPUTS)+ if not outputs:+ return "hybrid model declares no numerical outputs"+ profile_name = config.routing.fallback_profile if config.routing is not None else None+ if profile_name is None:+ return "model does not declare a hybrid remote profile"+ return NumericalAdmission(+ sha256=canonical_digest(+ {+ "version": 1,+ "kind": UpstreamKind.SIE.value,+ "model": config.sie_id,+ "remote_profile": profile_name,+ "remote_contract_sha256": remote_profile_contract_digest(config, profile_name, installed_upstreams()),+ "revision": revision,+ "identity": identity,+ }+ ),+ kind=UpstreamKind.SIE.value,+ local_identities=frozenset({identity}),+ model_contract_sha256=model_contract_digest(config),+ outputs=outputs,+ expires_at=(now or datetime.now(UTC)) + timedelta(seconds=remaining_s),+ )+++def remote_admission(+ config: ModelConfig, *, wait: bool = True, now: datetime | None = None+) -> NumericalAdmission | str:+ """Return the admission of the model's remote profile on this process's upstream, or a refusal reason."""+ routing = config.routing+ if routing is None or routing.policy not in {"fallback", "threshold"} or routing.fallback_profile is None:+ return "model does not declare a hybrid remote profile"+ upstream_name = config.resolve_profile(routing.fallback_profile).loadtime.get("upstream")+ upstream = installed_upstreams().get(upstream_name) if isinstance(upstream_name, str) else None+ if upstream is None:+ return "hybrid remote profile names no installed upstream"+ if upstream.kind is UpstreamKind.SIE:+ return sie_admission(config, wait=wait, now=now)+ return openai_admission(config, now=now)++def openai_equivalence_refusal(config: ModelConfig,*,diff --git a/packages/sie_server/src/sie_server/config/sie_identity.py b/packages/sie_server/src/sie_server/config/sie_identity.pyindex 957dc6cba..45eeaa843 100644--- a/packages/sie_server/src/sie_server/config/sie_identity.py+++ b/packages/sie_server/src/sie_server/config/sie_identity.py@@ -32,6 +32,7 @@ _MAX_METADATA_BYTES = 64 << 10_METADATA_DEADLINE_S = 5.0_IDENTITY_AGE_S = 30.0_REFUSAL_AGE_S = 2.0+_REFRESH_AHEAD = 2 / 3_MAX_CACHE_ENTRIES = 128_IDENTITY = re.compile(r"^v[12]:sha256:[0-9a-f]{64}$")_REVISION = re.compile(r"[0-9a-f]{40}")@@ -114,61 +115,95 @@ class _Observation:upstream: Upstreamvalue: tuple[str, str] | None = Nonechecked_at: float = 0.0- loading: bool = True+ failed_at: float | None = None+ loading: bool = False++ def lifetime(self) -> float:+ return _IDENTITY_AGE_S if self.value is not None else _REFUSAL_AGE_S++ def fresh(self, now: float) -> bool:+ return self.checked_at > 0 and 0 <= now - self.checked_at < self.lifetime()++ def current(self, now: float) -> tuple[tuple[str, str] | None, float]:+ return (self.value, now - self.checked_at) if self.fresh(now) else (None, 0.0)_LOCK = threading.Lock()_OBSERVATIONS: OrderedDict[tuple[int, str, str], _Observation] = OrderedDict()-def _fresh_identity(upstream_name: str, upstream: Upstream, remote_model: str) -> tuple[str, str] | None:- key = id(upstream), upstream_name, remote_model- with _LOCK:- existing = _OBSERVATIONS.get(key)- if existing is not None:- _OBSERVATIONS.move_to_end(key)- age = time.monotonic() - existing.checked_at- if existing.loading:- return None- if 0 <= age < (_IDENTITY_AGE_S if existing.value is not None else _REFUSAL_AGE_S):- return existing.value- elif len(_OBSERVATIONS) >= _MAX_CACHE_ENTRIES:- candidate = next((candidate for candidate, entry in _OBSERVATIONS.items() if not entry.loading), None)- if candidate is None:- return None- del _OBSERVATIONS[candidate]- observation = _Observation(upstream)- _OBSERVATIONS[key] = observation- value = None+def _refresh(observation: _Observation, upstream_name: str, upstream: Upstream, remote_model: str) -> None:+ """Replace the observation with a completed read.++ A read that fails keeps the previous observation until its own expiry and+ holds off the next read for the refusal age.+ """+ completed, value = False, Nonetry:value = _read_identity(upstream_name, upstream, remote_model)+ completed = Trueexcept (UpstreamUnavailableError, UpstreamCredentialError, httpx.HTTPError, OSError, ValueError, RecursionError):passfinally:with _LOCK:- observation.value = value- observation.checked_at = time.monotonic()+ now = time.monotonic()+ if completed:+ observation.value, observation.checked_at, observation.failed_at = value, now, None+ else:+ observation.failed_at = nowobservation.loading = False- return value-def _shown(value: object, pattern: re.Pattern[str]) -> str:- return value if isinstance(value, str) and pattern.fullmatch(value) else "<invalid>"+def _identity_observation(+ upstream_name: str, upstream: Upstream, remote_model: str, *, wait: bool = True+) -> tuple[tuple[str, str] | None, float]:+ """Return the current observation and its age in seconds.+ With ``wait`` an expired observation is refreshed before returning. Without+ it the refresh runs in the background, starting before expiry, and the+ caller never waits on the upstream. A refresh already in flight is never+ started twice.+ """+ key = id(upstream), upstream_name, remote_model+ with _LOCK:+ observation = _OBSERVATIONS.get(key)+ if observation is None:+ if len(_OBSERVATIONS) >= _MAX_CACHE_ENTRIES:+ candidate = next((candidate for candidate, entry in _OBSERVATIONS.items() if not entry.loading), None)+ if candidate is None:+ return None, 0.0+ del _OBSERVATIONS[candidate]+ observation = _Observation(upstream)+ _OBSERVATIONS[key] = observation+ _OBSERVATIONS.move_to_end(key)+ now = time.monotonic()+ current = observation.current(now)+ backing_off = observation.failed_at is not None and 0 <= now - observation.failed_at < _REFUSAL_AGE_S+ early = current[1] < observation.lifetime() * _REFRESH_AHEAD+ if observation.loading or backing_off or (observation.fresh(now) and (wait or early)):+ return current+ observation.loading = True+ if not wait:+ threading.Thread(+ target=_refresh, args=(observation, upstream_name, upstream, remote_model), daemon=True+ ).start()+ return current+ _refresh(observation, upstream_name, upstream, remote_model)+ with _LOCK:+ return observation.current(time.monotonic())-def _shown_identity(revision: object, identity: object) -> str:- return f"(hf_revision={_shown(revision, _REVISION)}, identity={_shown(identity, _IDENTITY)})"+def _fresh_identity(upstream_name: str, upstream: Upstream, remote_model: str) -> tuple[str, str] | None:+ return _identity_observation(upstream_name, upstream, remote_model)[0]-def sie_identity_refusal(config: ModelConfig, *, device: str, engine_config: EngineConfig | None = None) -> str | None:- """Admit only fresh matching weights and a known local execution identity."""++def _sie_contract(config: ModelConfig) -> tuple[str, Upstream, str] | str:+ """The upstream name, upstream and upstream model of a hybrid SIE profile, or a refusal reason."""if not remote_serving_enabled():return "remote serving is disabled"routing = config.routingif routing is None or routing.policy not in {"fallback", "threshold"} or routing.fallback_profile is None:return "model does not declare a hybrid remote profile"- if not device or device == "cuda" or (device.startswith("cuda:") and not device.partition(":")[2].isdigit()):- return "hybrid execution device is ambiguous"remote = config.resolve_profile(routing.fallback_profile)upstream_name, remote_model = remote.loadtime.get("upstream"), remote.loadtime.get("upstream_model")upstream = installed_upstreams().get(upstream_name) if isinstance(upstream_name, str) else None@@ -193,10 +228,44 @@ def sie_identity_refusal(config: ModelConfig, *, device: str, engine_config: Engreturn "hybrid remote profile differs from local runtime defaults"except (TypeError, ValueError, RecursionError):return "hybrid runtime defaults cannot be identified"+ return upstream_name, upstream, remote_model+++def sie_upstream_identity(config: ModelConfig, *, wait: bool = True) -> tuple[str, str, float] | str:+ """The upstream's weights revision, identity and remaining validity in seconds, or a refusal reason."""+ contract = _sie_contract(config)+ if isinstance(contract, str):+ return contract+ observed, age = _identity_observation(*contract, wait=wait)+ if observed is None:+ return "hybrid upstream identity is unavailable or outside its age"+ return observed[0], observed[1], max(0.0, _IDENTITY_AGE_S - age)+++def _shown(value: object, pattern: re.Pattern[str]) -> str:+ return value if isinstance(value, str) and pattern.fullmatch(value) else "<invalid>"+++def _shown_identity(revision: object, identity: object) -> str:+ return f"(hf_revision={_shown(revision, _REVISION)}, identity={_shown(identity, _IDENTITY)})"+++def sie_identity_refusal(config: ModelConfig, *, device: str, engine_config: EngineConfig | None = None) -> str | None:+ """Admit only fresh matching weights and a known local execution identity."""+ if not remote_serving_enabled():+ return "remote serving is disabled"+ routing = config.routing+ if routing is None or routing.policy not in {"fallback", "threshold"} or routing.fallback_profile is None:+ return "model does not declare a hybrid remote profile"+ if not device or device == "cuda" or (device.startswith("cuda:") and not device.partition(":")[2].isdigit()):+ return "hybrid execution device is ambiguous"+ contract = _sie_contract(config)+ if isinstance(contract, str):+ return contractidentity = local_profile_identity(config, "default", device=device, engine_config=engine_config)if identity is None:return "hybrid local execution cannot be identified"- observed = _fresh_identity(upstream_name, upstream, remote_model)+ observed = _fresh_identity(*contract)if observed is None:return "hybrid upstream identity is unavailable or outside its age"if observed != (config.hf_revision, identity):diff --git a/packages/sie_server/src/sie_server/ipc_server.py b/packages/sie_server/src/sie_server/ipc_server.pyindex a22f39c03..7af6c920e 100644--- a/packages/sie_server/src/sie_server/ipc_server.py+++ b/packages/sie_server/src/sie_server/ipc_server.py@@ -19,11 +19,13 @@ import msgspecfrom sie_server.adapter_call_loop import handle_run_batchfrom sie_server.adapters._generation_base import GenerationUnsupportedFieldError-from sie_server.config.equivalence import model_contract_digest+from sie_server.config.equivalence import model_contract_digest, remote_profile_contract_digest+from sie_server.config.hybrid_admission import remote_admissionfrom sie_server.config.model import ModelConfig+from sie_server.config.upstreams import installed_upstreamsfrom sie_server.core.gpu_health import gpu_is_healthy_asyncfrom sie_server.core.grammar_routing import resolve_grammar_serving_model-from sie_server.core.profile_identity import local_profile_identity, runtime_instance_id+from sie_server.core.profile_identity import local_profile_identity, runtime_instance_id, serving_code_digestfrom sie_server.core.readiness import is_readyfrom sie_server.ipc_types import (IPC_VERSION,@@ -52,6 +54,7 @@ from sie_server.ipc_types import (GenerateEvent,IpcResponseChunkV1,ItemOutcome,+ NumericalAdmissionObservation,NumericalProfileObservation,NumericalProfileSnapshotRequest,NumericalProfileSnapshotResponse,@@ -88,6 +91,7 @@ _LEN_BYTES = _LEN_STRUCT.size# via the payload store, not via IPC._MAX_FRAME_BYTES = 32 * 1024 * 1024_MAX_NUMERICAL_PROFILES = 1024+_MAX_ADMITTED_IDENTITIES = 8_MAX_NUMERICAL_MODEL_ID_BYTES = 1024# A negotiated response may exceed one legacy IPC frame, but remains tightly@@ -190,6 +194,34 @@ class _IpcGenerateMessage:await self._sink.send(GenerateEvent(kind="in_progress"))+def _observe_remote_profile(observation: NumericalProfileObservation, config: ModelConfig) -> None:+ """Report this process's contract and admission for a model's remote profile, if it serves one."""+ routing = config.routing+ profile = routing.fallback_profile if routing is not None and routing.fallback_profile else "default"+ remote_contract = remote_profile_contract_digest(config, profile, installed_upstreams())+ if remote_contract is None:+ return+ observation.remote_contract_sha256 = remote_contract+ observation.remote_execution_sha256 = serving_code_digest()+ if config.tasks.encode is None and config.tasks.score is None:+ return+ admission = remote_admission(config, wait=False)+ if (+ isinstance(admission, str)+ or not admission.outputs+ or len(admission.local_identities) > _MAX_ADMITTED_IDENTITIES+ ):+ return+ observation.admission = NumericalAdmissionObservation(+ sha256=admission.sha256,+ kind=admission.kind,+ local_identities=sorted(admission.local_identities),+ model_contract_sha256=admission.model_contract_sha256,+ outputs=sorted(admission.outputs),+ expires_at_unix_ms=int(admission.expires_at.timestamp() * 1000),+ )++class IpcServer:"""UDS msgpack RPC server fronting the QueueExecutor.@@ -808,7 +840,10 @@ class IpcServer:contract = model_contract_digest(config)else:complete = False- observations.append(NumericalProfileObservation(name, identity, contract))+ observation = NumericalProfileObservation(name, identity, contract)+ if isinstance(config, ModelConfig) and config.synthetic_profile_variant_source is None:+ _observe_remote_profile(observation, config)+ observations.append(observation)return NumericalProfileSnapshotResponse(runtime_instance_id(), observations, complete)def _handle_worker_capabilities(self, _req: WorkerCapabilitiesRequest) -> WorkerCapabilitiesResponse:diff --git a/packages/sie_server/src/sie_server/ipc_types.py b/packages/sie_server/src/sie_server/ipc_types.pyindex fdce5143a..9a1625dbb 100644--- a/packages/sie_server/src/sie_server/ipc_types.py+++ b/packages/sie_server/src/sie_server/ipc_types.py@@ -271,10 +271,22 @@ class NumericalProfileSnapshotRequest(msgspec.Struct):pass-class NumericalProfileObservation(msgspec.Struct):+class NumericalAdmissionObservation(msgspec.Struct):+ sha256: str+ kind: str+ local_identities: list[str]+ model_contract_sha256: str+ outputs: list[str]+ expires_at_unix_ms: int+++class NumericalProfileObservation(msgspec.Struct, omit_defaults=True):model_id: strlocal_identity: str | None = Nonemodel_contract_sha256: str | None = None+ remote_contract_sha256: str | None = None+ remote_execution_sha256: str | None = None+ admission: NumericalAdmissionObservation | None = Noneclass NumericalProfileSnapshotResponse(msgspec.Struct):diff --git a/packages/sie_server/tests/config/test_hybrid_admission.py b/packages/sie_server/tests/config/test_hybrid_admission.pyindex 33fb4bf9b..575a1709f 100644--- a/packages/sie_server/tests/config/test_hybrid_admission.py+++ b/packages/sie_server/tests/config/test_hybrid_admission.py@@ -11,6 +11,7 @@ from types import SimpleNamespacefrom typing import Anyfrom unittest.mock import AsyncMock, MagicMock+import msgspecimport pytestimport yamlfrom fastapi import FastAPI, HTTPException, Request@@ -33,7 +34,8 @@ from sie_server.config.routing import validate_model_routingfrom sie_server.config.upstreams import EquivalencePolicy, Upstream, install_upstreamsfrom sie_server.core.loader import expand_profile_variantsfrom sie_server.core.registry import ModelRegistry-from sie_server.ipc_types import ReplaceModelConfigEntry, ReplaceModelConfigsRequest+from sie_server.ipc_server import IpcServer+from sie_server.ipc_types import NumericalProfileSnapshotRequest, ReplaceModelConfigEntry, ReplaceModelConfigsRequestfrom sie_server.queue_executor import QueueExecutorNOW = datetime(2026, 10, 3, tzinfo=UTC)@@ -618,3 +620,74 @@ async def test_queue_worker_bridge_still_requires_current_evidence(assert refused.value.headers["X-SIE-Fallback-Error"] == "INFERENCE_ERROR"assert not hasattr(request.state, "serving_route")registry.start_load_async.assert_awaited_once_with(config.sie_id, "cpu")+++def _remote_lane_server(config: ModelConfig, tmp_path: Path) -> IpcServer:+ registry = ModelRegistry(device="cpu", enable_hot_reload=False)+ registry.add_config(config)+ return IpcServer(str(tmp_path / "w.sock"), QueueExecutor(registry), worker_id="w")+++async def _snapshot(server: IpcServer) -> dict[str, Any]:+ response = await server._handle_numerical_profile_snapshot(NumericalProfileSnapshotRequest())+ return {profile.model_id: profile for profile in response.profiles}+++async def test_remote_lane_snapshot_advertises_the_current_admission(admission: tuple, tmp_path: Path) -> None:+ config, upstream, path, data = admission+ _refresh_record(path, data)+ server = _remote_lane_server(config, tmp_path)+ observed = await _snapshot(server)+ bare = observed[config.sie_id]+ current = hybrid_admission.openai_admission(config)+ assert isinstance(current, hybrid_admission.NumericalAdmission)+ assert bare.remote_contract_sha256 == remote_profile_contract_digest(config, "remote", {"vendor": upstream})+ assert bare.remote_execution_sha256 == hybrid_admission.serving_code_digest()+ assert bare.admission is not None+ assert bare.admission.sha256 == current.sha256+ assert bare.admission.kind == "openai"+ assert bare.admission.local_identities == [IDENTITY]+ assert bare.admission.outputs == ["dense"]+ assert bare.admission.model_contract_sha256 == model_contract_digest(config)+ assert bare.admission.expires_at_unix_ms == int(current.expires_at.timestamp() * 1000)+ variant = observed[config.sie_id + ":remote"]+ assert (variant.admission, variant.remote_contract_sha256) == (None, None)+ data["measured_at"] = (datetime.now(UTC) - timedelta(minutes=5)).isoformat()+ path.write_text(json.dumps(data))+ expired = (await _snapshot(server))[config.sie_id]+ assert expired.admission is None+ assert expired.remote_contract_sha256 == bare.remote_contract_sha256+ path.unlink()+ assert (await _snapshot(server))[config.sie_id].admission is None+++async def test_snapshot_omits_an_admission_naming_more_identities_than_the_bound(+ admission: tuple, tmp_path: Path+) -> None:+ config, _, path, data = admission+ now = datetime.now(UTC).isoformat()+ identities = [IDENTITY, *(f"v1:sha256:{index:064x}" for index in range(8))]+ path.write_text(+ _bundle(*(_identity_record(data, identity, config, measured_at=now) for identity in identities[:8]))+ )+ server = _remote_lane_server(config, tmp_path)+ assert len((await _snapshot(server))[config.sie_id].admission.local_identities) == 8+ path.write_text(_bundle(*(_identity_record(data, identity, config, measured_at=now) for identity in identities)))+ assert len(hybrid_admission.openai_admission(config).local_identities) == 9+ assert (await _snapshot(server))[config.sie_id].admission is None+++async def test_process_without_the_upstream_reports_no_remote_contract_or_admission(+ admission: tuple, tmp_path: Path+) -> None:+ config, _, path, data = admission+ _refresh_record(path, data)+ server = _remote_lane_server(config, tmp_path)+ install_upstreams({}, remote_serving=False)+ observation = (await _snapshot(server))[config.sie_id]+ assert (observation.remote_contract_sha256, observation.remote_execution_sha256, observation.admission) == (+ None,+ None,+ None,+ )+ assert set(msgspec.to_builtins(observation)) <= {"model_id", "local_identity", "model_contract_sha256"}diff --git a/packages/sie_server/tests/config/test_sie_identity.py b/packages/sie_server/tests/config/test_sie_identity.pyindex 8993b13b4..63e5a7387 100644--- a/packages/sie_server/tests/config/test_sie_identity.py+++ b/packages/sie_server/tests/config/test_sie_identity.py@@ -2,6 +2,7 @@import jsonimport threading+import timefrom concurrent.futures import ThreadPoolExecutorfrom types import SimpleNamespacefrom unittest.mock import AsyncMock, MagicMock@@ -12,12 +13,16 @@ import yamlfrom fastapi import HTTPException, Requestfrom opentelemetry import tracefrom sie_server.api.routing import route_request-from sie_server.config import sie_identity+from sie_server.config import hybrid_admission, sie_identity+from sie_server.config.equivalence import model_contract_digest, remote_profile_contract_digestfrom sie_server.config.model import ModelConfigfrom sie_server.config.routing import validate_model_routingfrom sie_server.config.upstreams import Upstream, install_upstreamsfrom sie_server.core.loader import expand_profile_variantsfrom sie_server.core.registry import ModelRegistry+from sie_server.ipc_server import IpcServer+from sie_server.ipc_types import NumericalProfileSnapshotRequest+from sie_server.queue_executor import QueueExecutorIDENTITY = "v1:sha256:" + "b" * 64REVISION = "a" * 40@@ -384,3 +389,160 @@ def test_reused_mutated_config_cannot_admit_stale_profile_metadata(remote, sectiwith pytest.raises(ValueError, match="settings changed after resolution"):validate_model_routing(config, device="cpu")assert len(remote[1]) == 1+++def test_sie_admission_admits_the_upstream_identity_for_matching_weights(remote) -> None:+ admitted = hybrid_admission.sie_admission(model())+ assert isinstance(admitted, hybrid_admission.NumericalAdmission)+ assert admitted.kind == "sie"+ assert admitted.local_identities == {IDENTITY}+ assert admitted.outputs == {"dense"}+ assert admitted.model_contract_sha256 == model_contract_digest(model())+ dispatched = hybrid_admission.remote_admission(model())+ assert isinstance(dispatched, hybrid_admission.NumericalAdmission)+ assert dispatched.sha256 == admitted.sha256+ _upstream, _requests, _constructions, payload = remote+ payload[0] = httpx.Response(200, json=metadata(revision="c" * 40))+ sie_identity._OBSERVATIONS.clear()+ assert hybrid_admission.sie_admission(model()) == "hybrid upstream weights differ from local"+++def test_admission_without_waiting_never_reads_the_upstream_on_the_callers_thread(remote, monkeypatch) -> None:+ _upstream, requests, _constructions, _payload = remote+ entered, release = threading.Event(), threading.Event()+ read = sie_identity._read_identity++ def slow(*args):+ entered.set()+ assert release.wait(5)+ return read(*args)++ monkeypatch.setattr(sie_identity, "_read_identity", slow)+ assert (+ hybrid_admission.sie_admission(model(), wait=False)+ == "hybrid upstream identity is unavailable or outside its age"+ )+ assert entered.wait(5)+ assert (+ hybrid_admission.sie_admission(model(), wait=False)+ == "hybrid upstream identity is unavailable or outside its age"+ )+ release.set()+ deadline = time.monotonic() + 5+ while isinstance(hybrid_admission.sie_admission(model(), wait=False), str):+ assert time.monotonic() < deadline+ time.sleep(0.01)+ assert len(requests) == 1+++def test_admission_refreshes_ahead_of_expiry_without_losing_the_current_identity(remote, monkeypatch) -> None:+ _upstream, requests, _constructions, _payload = remote+ clock = [1000.0]+ monkeypatch.setattr(sie_identity.time, "monotonic", lambda: clock[0])+ first = hybrid_admission.sie_admission(model())+ assert isinstance(first, hybrid_admission.NumericalAdmission)+ clock[0] += 25.0+ refreshed = threading.Event()+ original = sie_identity._refresh++ def tracked(*args):+ original(*args)+ refreshed.set()++ monkeypatch.setattr(sie_identity, "_refresh", tracked)+ current = hybrid_admission.sie_admission(model(), wait=False)+ assert isinstance(current, hybrid_admission.NumericalAdmission)+ assert refreshed.wait(5)+ assert len(requests) == 2+++def _tracked_refresh(monkeypatch) -> threading.Event:+ refreshed = threading.Event()+ original = sie_identity._refresh++ def tracked(*args):+ original(*args)+ refreshed.set()++ monkeypatch.setattr(sie_identity, "_refresh", tracked)+ return refreshed+++def test_a_failed_refresh_keeps_the_current_identity_until_it_expires(remote, monkeypatch) -> None:+ _upstream, requests, _constructions, payload = remote+ clock = [1000.0]+ monkeypatch.setattr(sie_identity.time, "monotonic", lambda: clock[0])+ first = hybrid_admission.sie_admission(model())+ assert isinstance(first, hybrid_admission.NumericalAdmission)+ payload[0] = httpx.Response(503)+ refreshed = _tracked_refresh(monkeypatch)+ clock[0] += 25.0++ assert isinstance(hybrid_admission.sie_admission(model(), wait=False), hybrid_admission.NumericalAdmission)+ assert refreshed.wait(5)+ kept = sie_identity.sie_upstream_identity(model(), wait=False)+ assert kept == (REVISION, IDENTITY, 5.0)+ assert len(requests) == 2++ clock[0] += 6.0+ refreshed.clear()+ assert (+ hybrid_admission.sie_admission(model(), wait=False)+ == "hybrid upstream identity is unavailable or outside its age"+ )+ assert refreshed.wait(5)+ assert len(requests) == 3+ clock[0] += 3.0+ assert sie_identity.sie_upstream_identity(model()) == "hybrid upstream identity is unavailable or outside its age"+ assert len(requests) == 4+++def test_a_completed_refusal_replaces_the_identity_at_once(remote, monkeypatch) -> None:+ _upstream, requests, _constructions, payload = remote+ clock = [1000.0]+ monkeypatch.setattr(sie_identity.time, "monotonic", lambda: clock[0])+ assert isinstance(hybrid_admission.sie_admission(model()), hybrid_admission.NumericalAdmission)+ payload[0] = httpx.Response(404, json={"detail": {"code": "MODEL_NOT_FOUND", "message": "gone"}})+ refreshed = _tracked_refresh(monkeypatch)+ clock[0] += 25.0++ hybrid_admission.sie_admission(model(), wait=False)+ assert refreshed.wait(5)++ assert (+ hybrid_admission.sie_admission(model(), wait=False)+ == "hybrid upstream identity is unavailable or outside its age"+ )+ assert len(requests) == 2+++async def test_remote_lane_snapshot_reports_the_sie_admission(remote, tmp_path, monkeypatch) -> None:+ monkeypatch.setenv("SIE_IPC_SOCKET_PATH", str(tmp_path / "ipc.sock"))+ registry = ModelRegistry(device="cpu", enable_hot_reload=False)+ registry.add_config(model())+ assert isinstance(hybrid_admission.sie_admission(model()), hybrid_admission.NumericalAdmission)+ server = IpcServer(str(tmp_path / "w.sock"), QueueExecutor(registry), worker_id="w")+ response = await server._handle_numerical_profile_snapshot(NumericalProfileSnapshotRequest())+ observed = {profile.model_id: profile for profile in response.profiles}+ bare = observed["local/model"]+ assert bare.admission is not None+ assert bare.admission.kind == "sie"+ assert bare.admission.local_identities == [IDENTITY]+ assert bare.admission.sha256 == hybrid_admission.sie_admission(model()).sha256+ assert bare.remote_contract_sha256 == remote_profile_contract_digest(model(), "remote", {"team": remote[0]})+ assert observed["local/model:remote"].admission is None+++async def test_snapshot_reports_no_admission_for_a_model_without_numerical_outputs(remote, tmp_path) -> None:+ data = model().model_dump(mode="json")+ data["tasks"] = {"encode": {}}+ empty = ModelConfig.model_validate(data)+ assert not set(empty.outputs) & {"dense", "sparse", "multivector", "score"}+ assert hybrid_admission.sie_admission(empty) == "hybrid model declares no numerical outputs"+ registry = ModelRegistry(device="cpu", enable_hot_reload=False)+ registry.add_config(empty)+ server = IpcServer(str(tmp_path / "w.sock"), QueueExecutor(registry), worker_id="w")+ response = await server._handle_numerical_profile_snapshot(NumericalProfileSnapshotRequest())+ bare = next(profile for profile in response.profiles if profile.model_id == "local/model")+ assert bare.admission is None+ assert bare.remote_contract_sha256 is not Nonediff --git a/packages/sie_server_sidecar/docs/architecture-guide.md b/packages/sie_server_sidecar/docs/architecture-guide.mdindex 561ecdb46..ef6bb0216 100644--- a/packages/sie_server_sidecar/docs/architecture-guide.md+++ b/packages/sie_server_sidecar/docs/architecture-guide.md@@ -347,17 +347,26 @@ retain an absent identity; failures return an incomplete snapshot without errordetails. A roster contains at most 1,024 models, with each model ID limited to1,024 UTF-8 bytes. Truncation or an invalid configuration makes it incomplete.+A process that holds the upstream of a model's remote profile also reports, on+the bare model, that profile's `remote_contract_sha256` and the+`remote_execution_sha256` of its serving code. For a model with `encode` or+`score` tasks and a hybrid routing policy it adds the current `admission`: the+local execution identities that passing, fresh evidence covers (at most eight),+the model contract, the admitted outputs, the expiry and an admission digest.+An SIE upstream's identity is refreshed in the background, so a snapshot never+waits on the upstream. Empty fields are omitted, so a process without a remote+profile reports the same shape as before.+The adapter pool retains one observation for every configured child, includingunavailable and legacy backends. Missing fields are incomplete, malformed-digests are invalid, and a duplicated process incarnation invalidates both+digests or admissions are invalid, and a duplicated process incarnation invalidates bothchildren. Each call refreshes the observations so a replacement process doesnot inherit the previous incarnation. The Candle backend does not implementthis optional method and is reported as unavailable.These observations do not change readiness, execution authority, or routing.-They provide inputs for collecting process-bound numerical evidence; accepting-that evidence still requires the entire reachable fleet and a queue execution-fence that pins the proof, configuration, and process incarnation.+Admitting a numerical bridge from them also requires the identity of every live+local process and an execution fence at the remote process.### Execution authority protocol amendment (#415)diff --git a/packages/sie_server_sidecar/src/backend/adapter_pool.rs b/packages/sie_server_sidecar/src/backend/adapter_pool.rsindex f42570bf7..ba30942c1 100644--- a/packages/sie_server_sidecar/src/backend/adapter_pool.rs+++ b/packages/sie_server_sidecar/src/backend/adapter_pool.rs@@ -21,11 +21,11 @@ use crate::backend::{BackendError, InferenceBackend};use crate::ipc_client::{IpcClient, IpcError};use crate::ipc_types::{ApplyModelConfigRequest, ApplyModelConfigResponse, BatchOutcome, DrainResponse,- EnsureModelReadyResponse, GenerateEvent, NumericalProfileSnapshotResponse, PingResponse,- ProcessEncodeBatchRequest, ProcessExtractBatchRequest, ProcessGenerateRequest,- ProcessScoreBatchRequest, ReplaceModelConfigsRequest, ReplaceModelConfigsResponse,- RunBatchRequest, SetPinnedModelsResponse, SignalGenerateCancelResponse,- WorkerCapabilitiesResponse,+ EnsureModelReadyResponse, GenerateEvent, NumericalAdmissionObservation,+ NumericalProfileSnapshotResponse, PingResponse, ProcessEncodeBatchRequest,+ ProcessExtractBatchRequest, ProcessGenerateRequest, ProcessScoreBatchRequest,+ ReplaceModelConfigsRequest, ReplaceModelConfigsResponse, RunBatchRequest,+ SetPinnedModelsResponse, SignalGenerateCancelResponse, WorkerCapabilitiesResponse,};use crate::runtime_state::RuntimeState;@@ -58,6 +58,29 @@ fn local_identity_digest(identity: &str) -> bool {.any(|prefix| identity.strip_prefix(prefix).is_some_and(sha256_digest))}+const MAX_ADMITTED_IDENTITIES: usize = 8;+const NUMERICAL_OUTPUTS: [&str; 4] = ["dense", "multivector", "score", "sparse"];++fn valid_admission(admission: &NumericalAdmissionObservation) -> bool {+ let mut identities = HashSet::new();+ let mut outputs = HashSet::new();+ sha256_digest(&admission.sha256)+ && matches!(admission.kind.as_str(), "openai" | "sie")+ && !admission.local_identities.is_empty()+ && admission.local_identities.len() <= MAX_ADMITTED_IDENTITIES+ && admission+ .local_identities+ .iter()+ .all(|identity| local_identity_digest(identity) && identities.insert(identity))+ && sha256_digest(&admission.model_contract_sha256)+ && !admission.outputs.is_empty()+ && admission+ .outputs+ .iter()+ .all(|output| NUMERICAL_OUTPUTS.contains(&output.as_str()) && outputs.insert(output))+ && admission.expires_at_unix_ms > 0+}+fn valid_numerical_snapshot(snapshot: &NumericalProfileSnapshotResponse) -> bool {let mut models = HashSet::new();snapshot@@ -77,6 +100,15 @@ fn valid_numerical_snapshot(snapshot: &NumericalProfileSnapshotResponse) -> bool.local_identity.as_deref().is_none_or(local_identity_digest)+ && profile+ .remote_contract_sha256+ .as_deref()+ .is_none_or(sha256_digest)+ && profile+ .remote_execution_sha256+ .as_deref()+ .is_none_or(sha256_digest)+ && profile.admission.as_ref().is_none_or(valid_admission)})}@@ -1196,6 +1228,88 @@ mod tests {}}+ fn snapshot_with_admission(admission: serde_json::Value) -> NumericalProfileSnapshotResponse {+ serde_json::from_value(serde_json::json!({+ "runtime_instance_id": "a".repeat(64),+ "complete": true,+ "profiles": [{+ "model_id": "m",+ "local_identity": null,+ "model_contract_sha256": "d".repeat(64),+ "remote_contract_sha256": "e".repeat(64),+ "remote_execution_sha256": "f".repeat(64),+ "admission": admission,+ }],+ }))+ .unwrap()+ }++ fn admission() -> serde_json::Value {+ serde_json::json!({+ "sha256": "1".repeat(64),+ "kind": "openai",+ "local_identities": [format!("v2:sha256:{}", "2".repeat(64))],+ "model_contract_sha256": "d".repeat(64),+ "outputs": ["dense", "sparse"],+ "expires_at_unix_ms": 1,+ })+ }++ #[test]+ fn numerical_snapshots_validate_remote_admissions() {+ assert!(valid_numerical_snapshot(&snapshot_with_admission(+ admission()+ )));+ assert!(valid_numerical_snapshot(&snapshot_with_admission(+ serde_json::Value::Null+ )));+ let identity = format!("v2:sha256:{}", "2".repeat(64));+ for (field, value) in [+ ("sha256", serde_json::json!("x")),+ ("kind", serde_json::json!("other")),+ ("local_identities", serde_json::json!([])),+ ("local_identities", serde_json::json!([identity, identity])),+ ("local_identities", serde_json::json!(["v2:sha256:short"])),+ (+ "local_identities",+ serde_json::json!((0..=MAX_ADMITTED_IDENTITIES)+ .map(|index| format!("v2:sha256:{index:064x}"))+ .collect::<Vec<_>>()),+ ),+ ("model_contract_sha256", serde_json::json!("x")),+ ("outputs", serde_json::json!([])),+ ("outputs", serde_json::json!(["tokens"])),+ ("outputs", serde_json::json!(["dense", "dense"])),+ ("expires_at_unix_ms", serde_json::json!(0)),+ ] {+ let mut invalid = admission();+ invalid[field] = value;+ assert!(+ !valid_numerical_snapshot(&snapshot_with_admission(invalid)),+ "{field}"+ );+ }+ let mut contract = snapshot_with_admission(serde_json::Value::Null);+ contract.profiles[0].remote_contract_sha256 = Some("x".into());+ assert!(!valid_numerical_snapshot(&contract));+ }++ #[test]+ fn an_observation_without_remote_facts_keeps_its_wire_shape() {+ let snapshot: NumericalProfileSnapshotResponse = serde_json::from_value(serde_json::json!({+ "runtime_instance_id": "a".repeat(64), "complete": true,+ "profiles": [{"model_id": "m", "local_identity": null, "model_contract_sha256": "d".repeat(64)}],+ }))+ .unwrap();+ let encoded = serde_json::to_value(&snapshot.profiles[0]).unwrap();+ let mut keys: Vec<_> = encoded.as_object().unwrap().keys().cloned().collect();+ keys.sort();+ assert_eq!(+ keys,+ ["local_identity", "model_contract_sha256", "model_id"]+ );+ }+#[tokio::test]async fn numerical_inventory_preserves_missing_legacy_and_replaced_processes() {async fn spawn_snapshot_worker(diff --git a/packages/sie_server_sidecar/src/health_publisher.rs b/packages/sie_server_sidecar/src/health_publisher.rsindex 5be0aeb6f..c4591eff8 100644--- a/packages/sie_server_sidecar/src/health_publisher.rs+++ b/packages/sie_server_sidecar/src/health_publisher.rs@@ -653,6 +653,9 @@ mod tests {model_id: format!("{index}{}", "x".repeat(1020)),model_contract_sha256: Some("b".repeat(64)),local_identity: None,+ remote_contract_sha256: None,+ remote_execution_sha256: None,+ admission: None,}).collect(),}),diff --git a/packages/sie_server_sidecar/src/protocol/ipc_types.rs b/packages/sie_server_sidecar/src/protocol/ipc_types.rsindex 5e15f4bf0..e526e3d21 100644--- a/packages/sie_server_sidecar/src/protocol/ipc_types.rs+++ b/packages/sie_server_sidecar/src/protocol/ipc_types.rs@@ -441,6 +441,16 @@ pub struct NumericalProfileSnapshotRequest {// No caller-supplied process or profile identity.}+#[derive(Debug, Clone, Serialize, Deserialize)]+pub struct NumericalAdmissionObservation {+ pub sha256: String,+ pub kind: String,+ pub local_identities: Vec<String>,+ pub model_contract_sha256: String,+ pub outputs: Vec<String>,+ pub expires_at_unix_ms: u64,+}+#[derive(Debug, Clone, Serialize, Deserialize)]pub struct NumericalProfileObservation {pub model_id: String,@@ -448,6 +458,12 @@ pub struct NumericalProfileObservation {pub local_identity: Option<String>,#[serde(default)]pub model_contract_sha256: Option<String>,+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub remote_contract_sha256: Option<String>,+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub remote_execution_sha256: Option<String>,+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub admission: Option<NumericalAdmissionObservation>,}#[derive(Debug, Clone, Default, Serialize, Deserialize)]diff --git a/packages/sie_ts_sdk/src/index.ts b/packages/sie_ts_sdk/src/index.tsindex 1b88aa9b0..4e9f66cea 100644--- a/packages/sie_ts_sdk/src/index.ts+++ b/packages/sie_ts_sdk/src/index.ts@@ -96,6 +96,7 @@ export type {NumericalProcessObservation,NumericalProfileSnapshot,NumericalProfileObservation,+ NumericalAdmissionObservation,ModelSummary,ServerInfo,GPUMetrics,diff --git a/packages/sie_ts_sdk/src/types.ts b/packages/sie_ts_sdk/src/types.tsindex 64fbf4072..96fc376c7 100644--- a/packages/sie_ts_sdk/src/types.ts+++ b/packages/sie_ts_sdk/src/types.ts@@ -744,6 +744,19 @@ export interface NumericalProfileObservation {model_id: string;model_contract_sha256: string | null;local_identity: string | null;+ remote_contract_sha256?: string | null;+ remote_execution_sha256?: string | null;+ admission?: NumericalAdmissionObservation | null;+}++/** Local execution identities that current evidence covers for a model's remote profile. */+export interface NumericalAdmissionObservation {+ sha256: string;+ kind: "openai" | "sie";+ local_identities: string[];+ model_contract_sha256: string;+ outputs: string[];+ expires_at_unix_ms: number;}export interface ClusterWorkerInfo {