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
fix(sdk): document terminal streaming execution evidence
Attila Laszlo Nagyf3a05ba287f4
diff --git a/packages/sie_gateway/docs/architecture-guide.md b/packages/sie_gateway/docs/architecture-guide.mdindex 0dba034b9..c5e2383db 100644--- a/packages/sie_gateway/docs/architecture-guide.md+++ b/packages/sie_gateway/docs/architecture-guide.md@@ -57,7 +57,7 @@ Rules enforced on the inference path:- Ordinary encode, score, and extract use pool-queue dispatch; capped logical batch pools and generation use worker direct-dispatch. Both paths use JetStream, with no direct-HTTP fallback. `src/handlers/proxy.rs` is the JetStream submission handler despite its name.- If the queue transport is unavailable (no usable NATS client at init), the gateway returns `503`. It does not fall back to direct mode.- Unknown model ids fast-fail with `404` whenever the in-memory `ModelRegistry` has been populated (either by the filesystem seed or by a successful bootstrap / delta from `sie-config`). In the pre-bootstrap edge case where the registry is still empty — no seed, no export applied yet — the proxy falls back to the caller-supplied bundle (or `"default"`) so an unseeded gateway can still publish work to a cold pool that a caller pinned via `X-SIE-Pool`. Once any model is registered, this fallback is disabled and the 404 contract applies.-- Automatic pool selection only considers healthy workers whose reported `bundle_config_hash` matches the gateway's expected hash. Explicit `X-SIE-Pool` selects a logical pool; the gateway publishes to that pool's backing queue pool (`PoolSpec.queue_pool`, default `default`) and stamps the logical pool into the work item as `admission_pool`. Deliveries whose hash is not the worker-sidecar's current hash, or logical pools that do not assign that worker, are NAKed before backend IPC. Successful non-streaming results echo the execution hash; the gateway emits `X-SIE-Model-Revision` only when every successful result matches the hash and immutable revision captured atomically at routing time. Streaming responses omit this post-execution attestation because headers precede the terminal result.+- Automatic pool selection only considers healthy workers whose reported `bundle_config_hash` matches the gateway's expected hash. Explicit `X-SIE-Pool` selects a logical pool; the gateway publishes to that pool's backing queue pool (`PoolSpec.queue_pool`, default `default`) and stamps the logical pool into the work item as `admission_pool`. Deliveries whose hash is not the worker-sidecar's current hash, or logical pools that do not assign that worker, are NAKed before backend IPC. Successful non-streaming results echo the execution hash; the gateway emits `X-SIE-Model-Revision` only when every successful result matches the hash and immutable revision captured atomically at routing time. The header value is the lowercase 64-hex executed bundle/config SHA-256, not the catalog weights revision (for example, a 40-hex Hugging Face commit). Buffered generation also follows this rule even though it internally collects worker chunks. True SSE responses (`stream: true`) always omit the header because headers precede the terminal result. Successful terminal SSE events may instead carry the worker-origin `execution_identity_sha256` / `execution_binding_sha256` pair, both lowercase 64-hex digests; absence remains valid for older or self-hosted deployments and does not attest execution. These digests are distinct from both the weights revision and the bundle/config hash.- On scale-from-zero — i.e. no healthy worker registered for the `(bundle, machine_profile)` tuple and the caller did not pin an explicit pool — the gateway records pending demand for KEDA and returns a retryable `503` provisioning response with `Retry-After: 60`, `X-SIE-Error-Code: PROVISIONING`, and gateway version headers. SIE-native surfaces use the SDK retry envelope (`{"error":{"code","message"}}`); OpenAI-compatible surfaces (`/v1/generate`, `/v1/embeddings`, `/v1/chat/completions`, `/v1/completions`, `/v1/responses`) use the OpenAI error envelope, because standard OpenAI clients parse 2xx as successful model output. This applies whether or not the caller set `X-SIE-MACHINE-PROFILE`; default-routing clients get the same contract as profile-pinned clients.- On no-consumer conditions for the JetStream publish, the gateway treats the miss as the same pre-execution provisioning state and returns the same retryable `503 PROVISIONING` contract (`Retry-After: 60`, `X-SIE-Error-Code: PROVISIONING`, and surface-specific error envelope). On backpressure conditions the gateway returns `503` with `Retry-After: 5`. Backpressure is evaluated twice: pool-wide against the `WORK_POOL_{pool}` stream's pending count (`SIE_GATEWAY_MAX_STREAM_PENDING`), and per lane (`pool`/`machine_profile`/`bundle`) against a gateway-local in-flight work-item count (`SIE_GATEWAY_MAX_LANE_IN_FLIGHT_ITEMS`). The per-lane decision is always computed and recorded on `sie.gateway.queue.lane_admission.decisions`, but it only sheds when `SIE_GATEWAY_LANE_BACKPRESSURE_ENFORCE` is set; with the flag off (the default) the pool-wide check is the sole gate. Both sheds produce the same `503` contract and both record pending demand for the exact physical lane so KEDA scales it.- On queue result timeouts the gateway returns `504` with `X-SIE-Error-Code: GATEWAY_TIMEOUT` and `Retry-After: 5`. This means the gateway accepted and published the work item, but no worker result reached the gateway before `SIE_GATEWAY_REQUEST_TIMEOUT`; it must not be collapsed into worker-emitted `MODEL_LOADING`, which remains a separate retryable `503 MODEL_LOADING` signal.diff --git a/packages/sie_gateway/openapi.json b/packages/sie_gateway/openapi.jsonindex e06f3e02e..fedb046d6 100644--- a/packages/sie_gateway/openapi.json+++ b/packages/sie_gateway/openapi.json@@ -1519,6 +1519,16 @@}]},+ "execution_binding_sha256": {+ "description": "Worker-origin execution binding, only on a successful terminal event\ntogether with execution_identity_sha256. Both are lowercase SHA-256 digests.",+ "pattern": "^[0-9a-f]{64}$",+ "type": "string"+ },+ "execution_identity_sha256": {+ "description": "Worker-origin execution identity, only on a successful terminal event.\nOptional complete pair with execution_binding_sha256; older or\nself-hosted deployments may omit both. Not a catalog weights revision\nor the executed bundle/config hash.",+ "pattern": "^[0-9a-f]{64}$",+ "type": "string"+ },"finish_reason": {"type": ["string",@@ -4158,22 +4168,23 @@}},"X-SIE-Execution-Binding-SHA256": {- "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available",+ "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Execution-Identity-SHA256": {- "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available",+ "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Model-Revision": {- "description": "Immutable deployed bundle/config execution revision that handled the request, when available",+ "description": "Executed bundle/config SHA-256, distinct from the catalog weights revision (for example, a 40-hex Hugging Face commit). Buffered responses only: present when the routing snapshot has a model revision and all successful worker results report its expected config hash. Omitted when evidence is unavailable or mismatched, and always omitted on SSE because headers precede terminal execution evidence.","schema": {+ "pattern": "^[0-9a-f]{64}$","type": "string"}},@@ -4454,22 +4465,23 @@}},"X-SIE-Execution-Binding-SHA256": {- "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available",+ "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Execution-Identity-SHA256": {- "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available",+ "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Model-Revision": {- "description": "Immutable deployed bundle/config execution revision that handled the request, when available",+ "description": "Executed bundle/config SHA-256, distinct from the catalog weights revision (for example, a 40-hex Hugging Face commit). Buffered responses only: present when the routing snapshot has a model revision and all successful worker results report its expected config hash. Omitted when evidence is unavailable or mismatched, and always omitted on SSE because headers precede terminal execution evidence.","schema": {+ "pattern": "^[0-9a-f]{64}$","type": "string"}},@@ -4659,22 +4671,23 @@}},"X-SIE-Execution-Binding-SHA256": {- "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available",+ "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Execution-Identity-SHA256": {- "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available",+ "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Model-Revision": {- "description": "Immutable deployed bundle/config execution revision that handled the request, when available",+ "description": "Executed bundle/config SHA-256, distinct from the catalog weights revision (for example, a 40-hex Hugging Face commit). Buffered responses only: present when the routing snapshot has a model revision and all successful worker results report its expected config hash. Omitted when evidence is unavailable or mismatched, and always omitted on SSE because headers precede terminal execution evidence.","schema": {+ "pattern": "^[0-9a-f]{64}$","type": "string"}},@@ -5250,22 +5263,23 @@}},"X-SIE-Execution-Binding-SHA256": {- "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available",+ "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Execution-Identity-SHA256": {- "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available",+ "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Model-Revision": {- "description": "Immutable deployed bundle/config execution revision that handled the request, when available",+ "description": "Executed bundle/config SHA-256, distinct from the catalog weights revision (for example, a 40-hex Hugging Face commit). Buffered responses only: present when the routing snapshot has a model revision and all successful worker results report its expected config hash. Omitted when evidence is unavailable or mismatched, and always omitted on SSE because headers precede terminal execution evidence.","schema": {+ "pattern": "^[0-9a-f]{64}$","type": "string"}},@@ -5595,22 +5609,23 @@}},"X-SIE-Execution-Binding-SHA256": {- "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available",+ "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Execution-Identity-SHA256": {- "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available",+ "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Model-Revision": {- "description": "Immutable deployed bundle/config execution revision that handled the request, when available",+ "description": "Executed bundle/config SHA-256, distinct from the catalog weights revision (for example, a 40-hex Hugging Face commit). Buffered responses only: present when the routing snapshot has a model revision and all successful worker results report its expected config hash. Omitted when evidence is unavailable or mismatched, and always omitted on SSE because headers precede terminal execution evidence.","schema": {+ "pattern": "^[0-9a-f]{64}$","type": "string"}},@@ -5941,22 +5956,23 @@}},"X-SIE-Execution-Binding-SHA256": {- "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available",+ "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Execution-Identity-SHA256": {- "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available",+ "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Model-Revision": {- "description": "Immutable deployed bundle/config execution revision that handled the request, when available",+ "description": "Executed bundle/config SHA-256, distinct from the catalog weights revision (for example, a 40-hex Hugging Face commit). Buffered responses only: present when the routing snapshot has a model revision and all successful worker results report its expected config hash. Omitted when evidence is unavailable or mismatched, and always omitted on SSE because headers precede terminal execution evidence.","schema": {+ "pattern": "^[0-9a-f]{64}$","type": "string"}},@@ -6266,22 +6282,23 @@}},"X-SIE-Execution-Binding-SHA256": {- "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available",+ "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Execution-Identity-SHA256": {- "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available",+ "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Model-Revision": {- "description": "Immutable deployed bundle/config execution revision that handled the request, when available",+ "description": "Executed bundle/config SHA-256, distinct from the catalog weights revision (for example, a 40-hex Hugging Face commit). Buffered responses only: present when the routing snapshot has a model revision and all successful worker results report its expected config hash. Omitted when evidence is unavailable or mismatched, and always omitted on SSE because headers precede terminal execution evidence.","schema": {+ "pattern": "^[0-9a-f]{64}$","type": "string"}},@@ -7254,22 +7271,23 @@}},"X-SIE-Execution-Binding-SHA256": {- "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available",+ "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Execution-Identity-SHA256": {- "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available",+ "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Model-Revision": {- "description": "Immutable deployed bundle/config execution revision that handled the request, when available",+ "description": "Executed bundle/config SHA-256, distinct from the catalog weights revision (for example, a 40-hex Hugging Face commit). Buffered responses only: present when the routing snapshot has a model revision and all successful worker results report its expected config hash. Omitted when evidence is unavailable or mismatched, and always omitted on SSE because headers precede terminal execution evidence.","schema": {+ "pattern": "^[0-9a-f]{64}$","type": "string"}},@@ -7544,22 +7562,23 @@}},"X-SIE-Execution-Binding-SHA256": {- "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available",+ "description": "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Execution-Identity-SHA256": {- "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available",+ "description": "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.","schema": {"pattern": "^[0-9a-f]{64}$","type": "string"}},"X-SIE-Model-Revision": {- "description": "Immutable deployed bundle/config execution revision that handled the request, when available",+ "description": "Executed bundle/config SHA-256, distinct from the catalog weights revision (for example, a 40-hex Hugging Face commit). Buffered responses only: present when the routing snapshot has a model revision and all successful worker results report its expected config hash. Omitted when evidence is unavailable or mismatched, and always omitted on SSE because headers precede terminal execution evidence.","schema": {+ "pattern": "^[0-9a-f]{64}$","type": "string"}},diff --git a/packages/sie_gateway/src/handlers/proxy.rs b/packages/sie_gateway/src/handlers/proxy.rsindex 98783cfdd..332894fac 100644--- a/packages/sie_gateway/src/handlers/proxy.rs+++ b/packages/sie_gateway/src/handlers/proxy.rs@@ -14595,10 +14595,10 @@ mod tests {async fn publish_generate_streaming_sse(&self,- _target: PublishTarget,- _display_model: &str,+ target: PublishTarget,+ display_model: &str,_engine: &str,- _bundle_config_hash: &str,+ bundle_config_hash: &str,_params: &WorkParams,_admission_pool: &str,) -> Result<@@ -14610,7 +14610,39 @@ mod tests {),String,> {- unreachable!("bounded target proof uses non-streaming requests")+ self.targets+ .lock()+ .expect("target probe lock")+ .push((display_model.to_string(), target));+ let (tx, rx) = oneshot::channel();+ let mut collector = crate::queue::streaming::StreamCollector::new(+ tx,+ display_model.to_string(),+ "default".to_string(),+ );+ let tap = collector.install_chunk_tap();+ let terminal = serde_json::from_value(json!({+ "kind": "chunk", "request_id": "request-1", "attempt_id": "attempt-1",+ "seq": 0, "text_delta": "ok", "done": true, "is_first": true,+ "finish_reason": "stop",+ "usage": {"prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 2},+ "executed_bundle_config_hash": bundle_config_hash,+ "execution_identity_sha256": "c".repeat(64),+ "execution_binding_sha256": "d".repeat(64)+ }))+ .unwrap();+ assert_eq!(+ collector.apply(terminal),+ crate::queue::streaming::ChunkApplied::Terminal+ );+ let outcome = collector.build_outcome().unwrap();+ collector.sender.take().unwrap().send(outcome).unwrap();+ Ok((+ "request-1".to_string(),+ rx,+ tap,+ DispatchDurability::accepted(),+ ))}async fn publish_cancel(&self, _request_id: &str) {}@@ -15033,6 +15065,78 @@ mod tests {}}+ #[tokio::test]+ async fn native_sse_revision_contract_distinguishes_catalog_and_execution_evidence() {+ let (state, _) = mixed_governed_generation_state(false).await;+ let weights_revision = "0123456789abcdef0123456789abcdef01234567";+ state+ .model_registry+ .add_model_config(+ serde_json::from_value(json!({+ "sie_id": "org/g",+ "hf_revision": weights_revision,+ "profiles": {"default": {+ "adapter_path": "sie_server.adapters.sentence_transformer:Adapter",+ "max_batch_tokens": 4096+ }}+ }))+ .unwrap(),+ )+ .unwrap();+ let (execution_hash, catalog_revision, _) = state+ .model_registry+ .bundle_execution_evidence("default", "default", "org/g");+ assert_eq!(catalog_revision.as_deref(), Some(weights_revision));+ assert_eq!(execution_hash.len(), 64);+ assert_ne!(execution_hash, weights_revision);+ let mut worker = worker_msg("default", "l4", "default");+ worker.bundle_config_hash = execution_hash;+ state+ .registry+ .update_worker("http://worker-l4:8080", worker)+ .await;++ let response = proxy_request(+ State(state),+ json_request(+ "/v1/generate/org%2Fg",+ json!({+ "prompt": "hello", "max_new_tokens": 4, "stream": true+ }),+ ),+ "generate",+ )+ .await;+ assert_eq!(response.status(), StatusCode::OK);+ assert_eq!(response.headers()["content-type"], "text/event-stream");+ for header in [+ "x-sie-model-revision",+ "x-sie-execution-identity-sha256",+ "x-sie-execution-binding-sha256",+ ] {+ assert!(!response.headers().contains_key(header));+ }+ let bytes = tokio::time::timeout(+ Duration::from_secs(5),+ axum::body::to_bytes(response.into_body(), 16384),+ )+ .await+ .unwrap()+ .unwrap();+ let body = std::str::from_utf8(&bytes).unwrap();+ let events: Vec<serde_json::Value> = body+ .lines()+ .filter_map(|line| line.strip_prefix("data: "))+ .filter(|data| *data != "[DONE]")+ .map(|data| serde_json::from_str(data).unwrap())+ .collect();+ let terminal = events.iter().find(|event| event["done"] == true).unwrap();+ assert_eq!(terminal["execution_identity_sha256"], "c".repeat(64));+ assert_eq!(terminal["execution_binding_sha256"], "d".repeat(64));+ assert!(body.contains("data: [DONE]"));+ assert!(!body.contains(weights_revision));+ }+#[tokio::test]async fn non_streaming_model_rejects_all_streaming_ingresses_before_publish() {let (state, probe) = mixed_governed_generation_state(false).await;diff --git a/packages/sie_gateway/src/openapi.rs b/packages/sie_gateway/src/openapi.rsindex 6c2f62c95..650b2c33c 100644--- a/packages/sie_gateway/src/openapi.rs+++ b/packages/sie_gateway/src/openapi.rs@@ -1358,14 +1358,14 @@ fn inject_inference_response_headers(paths: &mut serde_json::Map<String, Value>)let queue_success_headers = json!({"X-SIE-Version": header("Gateway package version that handled the request"),"X-SIE-Server-Version": header("Gateway-compatible server version advertised by this gateway"),- "X-SIE-Model-Revision": header(- "Immutable deployed bundle/config execution revision that handled the request, when available",+ "X-SIE-Model-Revision": sha256_header(+ "Executed bundle/config SHA-256, distinct from the catalog weights revision (for example, a 40-hex Hugging Face commit). Buffered responses only: present when the routing snapshot has a model revision and all successful worker results report its expected config hash. Omitted when evidence is unavailable or mismatched, and always omitted on SSE because headers precede terminal execution evidence.",),"X-SIE-Execution-Identity-SHA256": sha256_header(- "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available",+ "Worker-origin SHA-256 identity of the immutable release and realized serving resources, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.",),"X-SIE-Execution-Binding-SHA256": sha256_header(- "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available",+ "Worker-origin runtime-independent SHA-256 binding of the release and deployment route, when available on buffered responses. SSE carries optional execution evidence in the successful terminal event instead of headers.",),"X-SIE-Request-Id": header("Gateway request id for queue-backed inference"),"X-SIE-Worker": header("Logical queue worker tag that produced the response"),@@ -2029,6 +2029,18 @@ pub struct GenerateChunk {pub logprobs: Option<Vec<Value>>,#[serde(default, skip_serializing_if = "Option::is_none")]pub error: Option<GenerateChunkError>,+ /// Worker-origin execution identity, only on a successful terminal event.+ /// Optional complete pair with execution_binding_sha256; older or+ /// self-hosted deployments may omit both. Not a catalog weights revision+ /// or the executed bundle/config hash.+ #[schema(pattern = "^[0-9a-f]{64}$", nullable = false)]+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub execution_identity_sha256: Option<String>,+ /// Worker-origin execution binding, only on a successful terminal event+ /// together with execution_identity_sha256. Both are lowercase SHA-256 digests.+ #[schema(pattern = "^[0-9a-f]{64}$", nullable = false)]+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub execution_binding_sha256: Option<String>,}// ── /v1/chat/completions schemas ──────────────────────────────────@@ -3507,6 +3519,19 @@ mod tests {chunk["properties"]["error"]["oneOf"][1]["$ref"],"#/components/schemas/GenerateChunkError");+ for field in ["execution_identity_sha256", "execution_binding_sha256"] {+ assert_eq!(chunk["properties"][field]["pattern"], "^[0-9a-f]{64}$");+ assert!(!chunk["required"]+ .as_array()+ .unwrap()+ .contains(&json!(field)));+ }+ let revision = &spec["paths"]["/v1/generate/{model}"]["post"]["responses"]["200"]+ ["headers"]["X-SIE-Model-Revision"];+ assert_eq!(revision["schema"]["pattern"], "^[0-9a-f]{64}$");+ let description = revision["description"].as_str().unwrap();+ assert!(description.contains("catalog weights revision"));+ assert!(description.contains("always omitted on SSE"));let chunk_error = &spec["components"]["schemas"]["GenerateChunkError"];assert_eq!(chunk_error["properties"]["param"]["type"],diff --git a/packages/sie_sdk/README.md b/packages/sie_sdk/README.mdindex 7cd1400ad..304caeaff 100644--- a/packages/sie_sdk/README.md+++ b/packages/sie_sdk/README.md@@ -49,6 +49,23 @@ client = SIEClient()```+## Generation execution evidence++`SIEClient.last_model_revision` retains the `X-SIE-Model-Revision` response+header from the latest call in the current thread. On buffered gateway+responses, this is the lowercase 64-hex executed bundle/config SHA-256 when+worker evidence matches the routing snapshot. It is distinct from a catalog+weights revision such as a 40-hex Hugging Face commit.++Gateway SSE responses omit that header: headers are sent before terminal+execution evidence is available. Fully consuming `stream_generate()` leaves+`last_model_revision` as `None`. A successful terminal `GenerateChunk` may+instead carry `execution_identity_sha256` and `execution_binding_sha256` as+an optional complete pair of lowercase 64-hex SHA-256 digests. Both Python+clients preserve those fields. Older or self-hosted deployments may omit+both; absence is compatible, but cannot prove which deployment executed.+The terminal digests are distinct from the weights revision and config hash.+## Object storage and model cachesInstall the `storage` extra to use `s3://`, `gs://`, `abfs(s)://`, or nativediff --git a/packages/sie_sdk/src/sie_sdk/client/sync.py b/packages/sie_sdk/src/sie_sdk/client/sync.pyindex a74909c6a..24bf24f50 100644--- a/packages/sie_sdk/src/sie_sdk/client/sync.py+++ b/packages/sie_sdk/src/sie_sdk/client/sync.py@@ -521,7 +521,12 @@ class SIEClient:"""Return the deployed execution revision observed on the latest call in this thread.The property name is retained for wire compatibility with- ``X-SIE-Model-Revision``.+ ``X-SIE-Model-Revision``. On a gateway buffered response this is the+ lowercase 64-hex executed bundle/config SHA-256, not the catalog's+ weights revision (for example, a 40-hex Hugging Face commit).+ It is ``None`` when the header is absent, including gateway SSE:+ headers precede the terminal execution evidence. Fully consuming a+ stream does not populate this property from terminal chunk fields."""value = getattr(self._request_state, "last_model_revision", None)return str(value) if value is not None else None@@ -3012,6 +3017,12 @@ class SIEClient:Yields :class:`GenerateChunk` events; the terminal chunk carries``done: true`` plus ``usage`` / ``ttft_ms``. Error semantics match:meth:`stream_chat_completions`.++ Successful terminal chunks may carry the optional complete pair+ ``execution_identity_sha256`` / ``execution_binding_sha256``.+ These worker-origin digests are distinct from the catalog weights+ revision and :attr:`last_model_revision`; gateway SSE omits the+ ``X-SIE-Model-Revision`` header."""resolved_grammar = validate_generate_grammar(grammar) if grammar is not None else Nonepool_name, resolved_gpu = self._resolve_pool_and_gpu(gpu)diff --git a/packages/sie_sdk/src/sie_sdk/types.py b/packages/sie_sdk/src/sie_sdk/types.pyindex 0e0beff56..d65bb8ce6 100644--- a/packages/sie_sdk/src/sie_sdk/types.py+++ b/packages/sie_sdk/src/sie_sdk/types.py@@ -658,6 +658,12 @@ class GenerateChunk(TypedDict, total=False):finish_reason: Termination reason (terminal chunk only).usage: Prompt / completion / total token counts (terminal chunk only).ttft_ms: Time-to-first-token in milliseconds (terminal chunk only).+ execution_identity_sha256: Optional worker-origin execution identity.+ Present only on a successful terminal chunk, together with+ ``execution_binding_sha256``; both are lowercase 64-hex SHA-256+ digests. Absence is valid for older or self-hosted deployments.+ execution_binding_sha256: Optional worker-origin execution binding,+ with the same successful-terminal, complete-pair contract.error: ``{code, message, param?, retry_after_s?}`` when generationfailed mid-stream. ``retry_after_s`` is meaningful only for``RESOURCE_EXHAUSTED``.@@ -671,6 +677,8 @@ class GenerateChunk(TypedDict, total=False):finish_reason: FinishReasonusage: GenerationUsagettft_ms: float+ execution_identity_sha256: str+ execution_binding_sha256: strerror: GenerateChunkErrordiff --git a/packages/sie_sdk/tests/client/test_chat.py b/packages/sie_sdk/tests/client/test_chat.pyindex 96afcf512..1353194c5 100644--- a/packages/sie_sdk/tests/client/test_chat.py+++ b/packages/sie_sdk/tests/client/test_chat.py@@ -18,6 +18,7 @@ from unittest.mock import MagicMock, patchimport pytestfrom sie_sdk import SIEClientfrom sie_sdk.client.errors import RequestError, ResourceExhaustedError, ServerError+from sie_sdk.types import GenerateChunkdef _ok_json(payload: dict[str, Any]) -> MagicMock:@@ -234,6 +235,35 @@ def test_stream_generate_yields_chunks_and_normalizes_model_path() -> None:client.close()[email protected]("with_evidence", [False, True])+def test_stream_generate_preserves_optional_terminal_execution_evidence(with_evidence: bool) -> None:+ terminal: GenerateChunk = {+ "request_id": "request-1",+ "seq": 1,+ "text_delta": "",+ "done": True,+ "finish_reason": "stop",+ }+ if with_evidence:+ terminal.update(execution_identity_sha256="a" * 64, execution_binding_sha256="b" * 64)+ delta = {"request_id": "request-1", "seq": 0, "text_delta": "Hello", "done": False}+ with patch("sie_sdk.client.sync.httpx.Client") as mock_client:+ mock_client.return_value.stream.return_value = _FakeStream(lines=_sse(delta, dict(terminal)))+ with SIEClient("http://localhost:8080") as client:+ client._request_state.last_model_revision = "c" * 64+ chunks: list[GenerateChunk] = list(client.stream_generate("org/model", "hi", max_new_tokens=8))+ assert client.last_model_revision is None+ assert chunks[-1] == terminal+ assert "execution_identity_sha256" not in chunks[0]+ assert "execution_binding_sha256" not in chunks[0]+ if with_evidence:+ assert chunks[-1]["execution_identity_sha256"] == "a" * 64+ assert chunks[-1]["execution_binding_sha256"] == "b" * 64+ else:+ assert "execution_identity_sha256" not in chunks[-1]+ assert "execution_binding_sha256" not in chunks[-1]++def test_stream_generate_validates_extra_body_grammar_before_request() -> None:with patch("sie_sdk.client.sync.httpx.Client") as mc:client = SIEClient("http://localhost:8080")diff --git a/packages/sie_sdk/tests/client/test_chat_async.py b/packages/sie_sdk/tests/client/test_chat_async.pyindex 4f840fbfe..4d8ee0034 100644--- a/packages/sie_sdk/tests/client/test_chat_async.py+++ b/packages/sie_sdk/tests/client/test_chat_async.py@@ -14,6 +14,7 @@ from unittest.mock import AsyncMock, MagicMock, patchimport pytestfrom sie_sdk import SIEAsyncClientfrom sie_sdk.client.errors import RequestError, ResourceExhaustedError, ServerError+from sie_sdk.types import GenerateChunkclass _FakeRaw:@@ -232,6 +233,38 @@ async def test_async_stream_generate_yields_and_normalizes_path() -> None:await client.close()[email protected]("with_evidence", [False, True])+async def test_stream_generate_preserves_optional_terminal_execution_evidence(with_evidence: bool) -> None:+ terminal: GenerateChunk = {+ "request_id": "request-1",+ "seq": 1,+ "text_delta": "",+ "done": True,+ "finish_reason": "stop",+ }+ if with_evidence:+ terminal.update(execution_identity_sha256="a" * 64, execution_binding_sha256="b" * 64)+ delta = {"request_id": "request-1", "seq": 0, "text_delta": "Hello", "done": False}+ client = SIEAsyncClient("http://localhost:8080")+ _patch_session(client, post_returns=_FakeRaw(line_bytes=_sse_bytes(delta, dict(terminal))))+ try:+ chunks: list[GenerateChunk] = [+ chunk async for chunk in client.stream_generate("org/model", "hi", max_new_tokens=8)+ ]+ finally:+ await client.close()+ assert chunks[-1] == terminal+ assert "execution_identity_sha256" not in chunks[0]+ assert "execution_binding_sha256" not in chunks[0]+ if with_evidence:+ assert chunks[-1]["execution_identity_sha256"] == "a" * 64+ assert chunks[-1]["execution_binding_sha256"] == "b" * 64+ else:+ assert "execution_identity_sha256" not in chunks[-1]+ assert "execution_binding_sha256" not in chunks[-1]++@pytest.mark.asyncioasync def test_async_stream_generate_validates_extra_body_grammar_before_request() -> None:client = SIEAsyncClient("http://localhost:8080")diff --git a/packages/sie_ts_sdk/src/types.ts b/packages/sie_ts_sdk/src/types.tsindex 14c21d7ad..a27d5d79b 100644--- a/packages/sie_ts_sdk/src/types.ts+++ b/packages/sie_ts_sdk/src/types.ts@@ -1416,6 +1416,14 @@ export interface GenerateChunk {usage?: ChatUsage;/** Time-to-first-token, milliseconds. Terminal chunk only. */ttft_ms?: number;+ /**+ * Worker-origin execution identity, only on a successful terminal chunk.+ * Optional complete pair with execution_binding_sha256; both are lowercase+ * 64-hex SHA-256 digests. Older or self-hosted deployments may omit both.+ */+ execution_identity_sha256?: string;+ /** Worker-origin execution binding, with the same terminal complete-pair contract. */+ execution_binding_sha256?: string;/** Populated when the worker / gateway errored mid-stream. */error?: GenerationChunkError;}diff --git a/packages/sie_ts_sdk/tests/streaming.test.ts b/packages/sie_ts_sdk/tests/streaming.test.tsindex 1cbd7902b..5e459efee 100644--- a/packages/sie_ts_sdk/tests/streaming.test.ts+++ b/packages/sie_ts_sdk/tests/streaming.test.ts@@ -573,6 +573,37 @@ describe("SIEClient.streamGenerate", () => {expect(last?.ttft_ms).toBe(123.4);});+ it.each([false, true])(+ "preserves optional terminal execution evidence (%s)",+ async (withEvidence) => {+ const evidence: Partial<GenerateChunk> = withEvidence+ ? { execution_identity_sha256: "a".repeat(64), execution_binding_sha256: "b".repeat(64) }+ : {};+ mockFetch.mockResolvedValueOnce(+ sseResponse([+ generateChunk(0, "Hello"),+ generateChunk(1, "", { done: true, finish_reason: "stop", ...evidence }),+ ]),+ );+ const client = new SIEClient("http://localhost:8080");+ const chunks: GenerateChunk[] = [];+ for await (const chunk of client.streamGenerate("org/model", "hi", { maxNewTokens: 8 })) {+ chunks.push(chunk);+ }+ expect(chunks[0]).not.toHaveProperty("execution_identity_sha256");+ expect(chunks[0]).not.toHaveProperty("execution_binding_sha256");+ const terminal = chunks[1];+ expect(terminal?.done).toBe(true);+ if (withEvidence) {+ expect(terminal?.execution_identity_sha256).toBe(evidence.execution_identity_sha256);+ expect(terminal?.execution_binding_sha256).toBe(evidence.execution_binding_sha256);+ } else {+ expect(terminal).not.toHaveProperty("execution_identity_sha256");+ expect(terminal).not.toHaveProperty("execution_binding_sha256");+ }+ },+ );+it("throws SIEStreamError when chunk.error is present", async () => {mockFetch.mockResolvedValueOnce(sseResponse([