From 7678f073292a01b2c71c3cba26850d7296e69226 Mon Sep 17 00:00:00 2001 From: cfal Date: Thu, 19 Nov 2026 15:55:56 +0000 Subject: [PATCH] cre/confidentialworkflow: add signed execution limits and preserve execution duration Add optional HTTP and WASM limits to WorkflowExecution and carry the execution_duration_ms field from main so capability-development consumers retain billing data. Keep the embedded proto in sync. --- .../confidentialworkflow/v1alpha/client.proto | 43 +++++++++++++++++++ cre/go/installer/pkg/embedded_gen.go | 43 +++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/cre/capabilities/compute/confidentialworkflow/v1alpha/client.proto b/cre/capabilities/compute/confidentialworkflow/v1alpha/client.proto index c73c39e8..bc570dbb 100644 --- a/cre/capabilities/compute/confidentialworkflow/v1alpha/client.proto +++ b/cre/capabilities/compute/confidentialworkflow/v1alpha/client.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package capabilities.compute.confidentialworkflow.v1alpha; +import "google/protobuf/duration.proto"; import "google/protobuf/empty.proto"; import "sdk/v1alpha/sdk.proto"; import "tools/generator/v1alpha/cre_metadata.proto"; @@ -52,6 +53,43 @@ message WorkflowExecution { // restrictions on the capabilities and the secrets.bool // This is sent to avoid overhead when a TEE is not compromised, the DON will verify the restrictions on its end as well. sdk.v1alpha.Restrictions restrictions = 10; + + // limits carries the CRE limits the workflow DON resolved for this execution. + // Being part of PublicData, it is covered by ComputeRequest.Hash() and signed + // by the DON quorum. When absent, the enclave applies no CRE limits. + ExecutionLimits limits = 11; +} + +// ExecutionLimits holds CRE limits resolved by the workflow DON. An unset field +// is not applied; the enclave decides how to apply the rest. +message ExecutionLimits { + HTTPActionLimits http_action = 1; + WASMLimits wasm = 2; +} + +// HTTPActionLimits mirrors PerWorkflow.HTTPAction.* for in-enclave http-actions. +message HTTPActionLimits { + optional uint32 call_limit = 1; + optional uint64 request_size_limit_bytes = 2; + optional uint64 response_size_limit_bytes = 3; + google.protobuf.Duration connection_timeout = 4; +} + +// WASMLimits mirrors the PerWorkflow limits CRE applies around the WASM host. +// Binary sizes are omitted because the DON enforces them at registration, and +// the response size limit travels as sdk_execute_request.max_response_size. +message WASMLimits { + optional uint64 memory_limit_bytes = 1; + google.protobuf.Duration execution_timeout = 2; + optional bool response_limit_enforced = 3; + optional uint32 capability_concurrency_limit = 4; + optional uint64 log_line_limit_bytes = 5; + optional uint32 log_event_limit = 6; + optional bool user_metric_enabled = 7; + optional uint64 user_metric_payload_limit_bytes = 8; + optional uint32 user_metric_name_length_limit = 9; + optional uint32 user_metric_labels_per_metric = 10; + optional uint32 user_metric_label_value_length = 11; } // ConfidentialWorkflowRequest is the input provided to the confidential workflows capability. @@ -74,6 +112,11 @@ message ConfidentialWorkflowResponse { // the same sdk.v1alpha.ExecutionResult as the serialized execution_result // bytes field; the two are independent on the wire. sdk.v1alpha.ExecutionResult sdk_execution_result = 2; + // execution_duration_ms is the enclave-measured wall-clock duration of the + // WASM execution in milliseconds, used to meter confidential compute + // (cre:workflow:compute). Presence distinguishes an unavailable measurement + // from a measured zero; older enclaves leave it unset. + optional int64 execution_duration_ms = 3; } message ProvidedTeesResponse { diff --git a/cre/go/installer/pkg/embedded_gen.go b/cre/go/installer/pkg/embedded_gen.go index 165fd778..af5d9368 100755 --- a/cre/go/installer/pkg/embedded_gen.go +++ b/cre/go/installer/pkg/embedded_gen.go @@ -1455,6 +1455,7 @@ const computeConfidentialworkflowV1alphaClientEmbedded = `syntax = "proto3"; package capabilities.compute.confidentialworkflow.v1alpha; +import "google/protobuf/duration.proto"; import "google/protobuf/empty.proto"; import "sdk/v1alpha/sdk.proto"; import "tools/generator/v1alpha/cre_metadata.proto"; @@ -1505,6 +1506,43 @@ message WorkflowExecution { // restrictions on the capabilities and the secrets.bool // This is sent to avoid overhead when a TEE is not compromised, the DON will verify the restrictions on its end as well. sdk.v1alpha.Restrictions restrictions = 10; + + // limits carries the CRE limits the workflow DON resolved for this execution. + // Being part of PublicData, it is covered by ComputeRequest.Hash() and signed + // by the DON quorum. When absent, the enclave applies no CRE limits. + ExecutionLimits limits = 11; +} + +// ExecutionLimits holds CRE limits resolved by the workflow DON. An unset field +// is not applied; the enclave decides how to apply the rest. +message ExecutionLimits { + HTTPActionLimits http_action = 1; + WASMLimits wasm = 2; +} + +// HTTPActionLimits mirrors PerWorkflow.HTTPAction.* for in-enclave http-actions. +message HTTPActionLimits { + optional uint32 call_limit = 1; + optional uint64 request_size_limit_bytes = 2; + optional uint64 response_size_limit_bytes = 3; + google.protobuf.Duration connection_timeout = 4; +} + +// WASMLimits mirrors the PerWorkflow limits CRE applies around the WASM host. +// Binary sizes are omitted because the DON enforces them at registration, and +// the response size limit travels as sdk_execute_request.max_response_size. +message WASMLimits { + optional uint64 memory_limit_bytes = 1; + google.protobuf.Duration execution_timeout = 2; + optional bool response_limit_enforced = 3; + optional uint32 capability_concurrency_limit = 4; + optional uint64 log_line_limit_bytes = 5; + optional uint32 log_event_limit = 6; + optional bool user_metric_enabled = 7; + optional uint64 user_metric_payload_limit_bytes = 8; + optional uint32 user_metric_name_length_limit = 9; + optional uint32 user_metric_labels_per_metric = 10; + optional uint32 user_metric_label_value_length = 11; } // ConfidentialWorkflowRequest is the input provided to the confidential workflows capability. @@ -1527,6 +1565,11 @@ message ConfidentialWorkflowResponse { // the same sdk.v1alpha.ExecutionResult as the serialized execution_result // bytes field; the two are independent on the wire. sdk.v1alpha.ExecutionResult sdk_execution_result = 2; + // execution_duration_ms is the enclave-measured wall-clock duration of the + // WASM execution in milliseconds, used to meter confidential compute + // (cre:workflow:compute). Presence distinguishes an unavailable measurement + // from a measured zero; older enclaves leave it unset. + optional int64 execution_duration_ms = 3; } message ProvidedTeesResponse {