Skip to content

Commit e53ff16

Browse files
committed
fix(middleware): keep response streams unit-local
Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
1 parent c8fc5dd commit e53ff16

1 file changed

Lines changed: 22 additions & 28 deletions

File tree

proto/supervisor_middleware.proto

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ message HttpResponsePreflight {
175175
// Validated service configuration. Limited to 64 KiB encoded.
176176
google.protobuf.Struct config = 6;
177177
// Effective minimum of platform, registration, and binding limits. Applies to
178-
// whole-body input/replacement and each stream replacement. Stream inputs use
179-
// at most floor(max_payload_bytes / 2).
178+
// whole-body input/replacement and each stream input/replacement. Stream
179+
// inputs use at most min(64 KiB, max_payload_bytes).
180180
uint64 max_payload_bytes = 7;
181181
// Modes derived independently for this stage. OpenShell first determines
182182
// response-shape eligibility from the original final response head, then
@@ -187,13 +187,9 @@ message HttpResponsePreflight {
187187
// omits WHOLE_BODY_BYTES. An eligible unknown-length response may select
188188
// WHOLE_BODY_BYTES and later fail with whole_body_over_capacity according to
189189
// this stage's on_error. STREAM_BYTES is omitted when
190-
// floor(max_payload_bytes / 2) is zero. Selecting an unlisted mode fails
191-
// according to on_error.
190+
// max_payload_bytes is zero. Selecting an unlisted mode fails according to
191+
// on_error.
192192
repeated HttpResponseBodyMode permitted_body_modes = 8;
193-
// Allows a STREAM_BYTES stage to retain input bytes for a later replacement.
194-
// True only for fail-closed stages. Fail-open stages must account for every
195-
// input unit in their results and cannot retain bytes across units.
196-
bool deferral_permitted = 9;
197193
}
198194

199195
// Selects skip, inspect, or block. Diagnostic fields apply to every action.
@@ -269,9 +265,10 @@ enum HttpResponseBodyMode {
269265
// whole_body_over_capacity and follow this stage's on_error.
270266
HTTP_RESPONSE_BODY_MODE_WHOLE_BODY_BYTES = 2;
271267
// Receive normalized units ending with end_of_stream. Each input is at most
272-
// min(64 KiB, floor(max_payload_bytes / 2)), and each replacement must fit
273-
// max_payload_bytes. The full body may exceed the limit. STREAM_BYTES has no
274-
// total response-lifetime deadline.
268+
// min(64 KiB, max_payload_bytes), and each replacement must fit
269+
// max_payload_bytes. Each result fully accounts for its input unit; V1 does
270+
// not permit retaining input across units. The full body may exceed the
271+
// limit. STREAM_BYTES has no total response-lifetime deadline.
275272
HTTP_RESPONSE_BODY_MODE_STREAM_BYTES = 3;
276273
}
277274

@@ -283,25 +280,25 @@ message HttpResponseBodyUnit {
283280
oneof payload {
284281
// Bytes without transfer framing. A body-capable response with no body bytes
285282
// has present empty data in sequence 1. STREAM_BYTES input size is at most
286-
// min(64 KiB, floor(max_payload_bytes / 2)). A unit may be shorter to
287-
// preserve flushing.
283+
// min(64 KiB, max_payload_bytes). A unit may be shorter to preserve
284+
// flushing.
288285
bytes data = 2;
289286
}
290287
// Marks the final body unit. Every normally completed body inspection receives
291288
// exactly one. For a body-capable response with no body bytes, this is the
292289
// empty sequence-1 unit. OpenShell does not read ahead, so it may send an empty
293-
// final unit after the last nonempty unit. The matching result must flush all
294-
// retained bytes. Trailers and session_end may follow. A stage ended by
295-
// skip_remaining, block, or failure receives no later final unit.
290+
// final unit after the last nonempty unit. Trailers and session_end may
291+
// follow. A stage ended by skip_remaining, block, or failure receives no
292+
// later final unit.
296293
bool end_of_stream = 3;
297294
}
298295

299296
// Result for one body unit. Units are processed in lockstep; V1 does not
300-
// support ownership transfer. Diagnostic fields apply to every action. Invalid
301-
// diagnostics make the entire result a middleware failure handled according to
302-
// on_error. OpenShell enforces input and replacement size bounds and validates
303-
// the event lifecycle. It cannot distinguish bytes intentionally deleted from
304-
// bytes retained privately by middleware.
297+
// support ownership transfer or cross-unit retention. Diagnostic fields apply
298+
// to every action. Invalid diagnostics make the entire result a middleware
299+
// failure handled according to on_error. OpenShell retains the current input
300+
// until it validates the result, so fail-open can continue from the last input
301+
// OpenShell still owns.
305302
message HttpResponseBodyResult {
306303
// Must match the next unit. Zero, gaps, duplicates, and regressions fail.
307304
uint64 sequence = 1;
@@ -335,25 +332,22 @@ message HttpResponseBodyPassThrough {}
335332

336333
// Finalizes this unit and ends the stage. This stage receives no later body or
337334
// trailer events. The current and later units continue through other stages.
338-
// Any retained bytes must be in transform. For WHOLE_BODY_BYTES, this equals
339-
// its nested action.
335+
// For WHOLE_BODY_BYTES, this equals its nested action.
340336
message HttpResponseBodySkipRemaining {
341337
// Exactly one action for the current unit.
342338
oneof current {
343339
// Forward the current unit unchanged.
344340
HttpResponseBodyPassThrough pass_through = 1;
345-
// Replace the current unit and flush all retained bytes.
341+
// Replace the current unit.
346342
HttpResponseBodyTransform transform = 2;
347343
}
348344
}
349345

350346
// Replaces the complete input unit.
351347
message HttpResponseBodyTransform {
352348
// Required replacement, limited to max_payload_bytes. Present empty data
353-
// deletes the input unit. When deferral_permitted, middleware may retain at
354-
// most floor(max_payload_bytes / 2) input bytes for a later replacement.
355-
// Otherwise it must not retain input across units. The transform for a normal
356-
// final unit or skip_remaining.transform must flush every retained byte.
349+
// deletes the input unit. The replacement fully accounts for this input unit;
350+
// middleware must not retain input bytes for a later unit in V1.
357351
oneof replacement {
358352
// Normalized replacement bytes.
359353
bytes data = 1;

0 commit comments

Comments
 (0)