Skip to content

Instantly share code, notes, and snippets.

@pimlock
Last active September 19, 2026 00:59
Show Gist options
  • Select an option

  • Save pimlock/01bb1d85b79536ca5b219214da2a5598 to your computer and use it in GitHub Desktop.

Select an option

Save pimlock/01bb1d85b79536ca5b219214da2a5598 to your computer and use it in GitHub Desktop.
Interactive OpenShell two-mode walkthrough: buffers, middleware storage and streaming
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>OpenShell · Two body modes</title><style>
:root{color-scheme:dark;--bg:#101514;--card:#19201e;--line:#35433c;--ink:#eff5ed;--muted:#b1c1b6;--green:#b9ee78;--blue:#94caff;--amber:#ffd17e;--purple:#d1b3ff}
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.5 system-ui,sans-serif}main{max-width:1260px;margin:auto;padding:32px 24px 60px}h1{font-size:clamp(28px,4vw,44px);line-height:1.15;margin:12px 0}h2{font-size:18px;margin:0 0 8px}p{margin:8px 0 16px}.eyebrow{color:var(--green);letter-spacing:.12em;font-size:12px}a{color:var(--blue)}.muted,small{color:var(--muted)}.intro{max-width:850px}.toolbar,.controls{display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin:20px 0}select,button{background:var(--card);color:var(--ink);border:1px solid var(--line);border-radius:8px;padding:10px;font:inherit}button{cursor:pointer}button:hover{border-color:var(--green)}button:disabled{opacity:.4;cursor:default}button.primary{background:var(--green);color:#182215}input[type=range]{flex:1;min-width:130px;accent-color:var(--green)}label{display:flex;align-items:center;gap:9px}input[type=checkbox]{accent-color:var(--green)}.event{background:#202b23;border:1px solid #526c42;border-radius:12px;padding:20px;min-height:155px}.event code{display:block;font-size:clamp(15px,2vw,21px);overflow-wrap:anywhere;color:var(--green);margin:8px 0}.event p{margin:8px 0 0}.badge{font-size:12px;padding:3px 8px;border:1px solid var(--line);border-radius:99px;color:var(--muted)}.grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin-top:18px}.card{border:1px solid var(--line);background:var(--card);border-radius:12px;padding:17px;min-height:235px}.card.open{grid-column:span 2}.subgrid{display:grid;grid-template-columns:1fr 1fr;gap:16px}.well{min-height:64px;border:1px dashed var(--line);border-radius:8px;padding:9px;display:flex;gap:6px;flex-wrap:wrap;align-content:flex-start;margin:10px 0}.chunk{display:inline-flex;flex-direction:column;gap:3px;background:#23392f;border:1px solid #6d9b7e;border-radius:6px;padding:7px 10px;font:14px ui-monospace,monospace;white-space:pre-wrap;overflow-wrap:anywhere;max-width:100%}.chunk small{font:10px system-ui;color:inherit;opacity:.85}.tentative .chunk{background:#3e3221;border-color:#a48149;color:var(--amber)}.owned .chunk{background:#30293d;border-color:#8d76ae;color:var(--purple)}.delivered .chunk{background:#223747;border-color:#658fab;color:var(--blue)}.empty{color:var(--muted);font-size:13px;padding:8px}.meter{height:5px;background:#0e1310;border-radius:9px;overflow:hidden;margin:8px 0}.meter span{display:block;height:100%;background:var(--green)}.metric{font:12px ui-monospace,monospace;color:var(--muted)}.head{padding:8px 10px;border-radius:6px;background:#101713;font-size:13px;margin:10px 0}.flow{color:var(--muted);font-size:13px;margin:14px 0}.legend{display:flex;gap:18px;flex-wrap:wrap;font-size:13px;margin:18px 0}.legend span::before{content:'●';margin-right:6px}.legend span:nth-child(1){color:var(--green)}.legend span:nth-child(2){color:var(--amber)}.legend span:nth-child(3){color:var(--purple)}.legend span:nth-child(4){color:var(--blue)}details{border:1px solid var(--line);border-radius:10px;padding:14px;margin-top:20px}summary{cursor:pointer}ol{padding-left:24px}li{padding:4px}li button{font-size:13px;text-align:left;padding:6px 10px;width:100%}li button[aria-current=true]{border-color:var(--green);color:var(--green)}.note{border-left:3px solid var(--amber);padding:8px 14px;background:#27231a;margin:18px 0;font-size:14px}footer{margin-top:28px;font-size:13px;color:var(--muted)}:focus-visible{outline:2px solid var(--blue);outline-offset:3px}@media(max-width:760px){main{padding:20px 14px}.grid{grid-template-columns:1fr}.card.open{grid-column:auto}.subgrid{grid-template-columns:1fr}.card{min-height:0}.toolbar{align-items:stretch;flex-direction:column}}
select{min-width:0;max-width:100%;flex:1}.card{min-width:0}.toolbar label{min-width:0}@media(max-width:760px){.toolbar label{width:100%}.toolbar select{width:0}}
</style></head>
<body><main>
<div class="eyebrow">NEW PROPOSAL / BUFFERED + STREAM / FAIL CLOSED</div>
<h1>Where the bytes live</h1>
<p class="intro muted">The same walkthrough, with a simpler contract. Windowing and spooling belong to middleware. OpenShell gathers a bounded body in BUFFERED or pumps bounded transport queues in STREAM. There are no recovery copies, ACKs or prefix commits.</p>
<div class="toolbar"><label>Scenario <select id="scenario" aria-label="Scenario"></select></label><label><input id="gate" type="checkbox">Next stage is BUFFERED, instead of direct upstream</label></div>
<p id="description"></p>
<div class="controls"><button id="prev">← Previous</button><button id="next" class="primary">Next →</button><button id="reset">Reset</button><input id="scrub" type="range" min="0" value="0" aria-label="Event position"><span id="position" class="metric"></span></div>
<section class="event" aria-live="polite"><span id="phase" class="badge"></span><code id="event"></code><p id="explanation"></p></section>
<div class="legend"><span>Buffered input</span><span>Transport queue</span><span>Middleware storage</span><span>Released bytes</span></div>
<div class="grid">
<section class="card open"><h2>OpenShell · current stage</h2><div id="current-head" class="head"></div><div class="subgrid"><div><b>BUFFERED input in RAM</b><div id="input" class="well"></div><div class="meter"><span id="input-meter"></span></div><div id="input-count" class="metric"></div></div><div><b>Transport output queue</b><div id="queue" class="well tentative"></div><div class="meter"><span id="queue-meter"></span></div><div id="queue-count" class="metric"></div></div></div><p id="ownership" class="muted"></p></section>
<section class="card"><h2>Middleware · window or spool</h2><div id="storage" class="well owned"></div><p id="middleware-note" class="muted"></p></section>
<section class="card"><h2>Released to next stage</h2><div id="released" class="well delivered"></div><p class="muted">Cumulative history, not another retained buffer. Each validated stream output moves onward as capacity permits.</p></section>
<section class="card"><h2 id="downstream-title">Next stage / transport</h2><div id="downstream" class="well"></div><p id="downstream-note" class="muted"></p><button id="release-gate" hidden>Accept next stage BufferedResult</button></section>
<section class="card"><h2>Upstream sees</h2><div id="upstream-head" class="head"></div><div id="upstream" class="well delivered"></div><p id="upstream-note" class="muted"></p></section>
</div>
<div class="flow">Request: middleware output → next stage → upstream. Response: the same supported modes deliver to the sandbox. Body-aware policy checks may require an additional bounded gate.</div>
<div class="note" id="invariant"></div>
<details><summary>Event timeline · click to jump</summary><ol id="timeline"></ol></details>
<details><summary>What this model does and does not show</summary>
<p>Snapshots follow validated events. OpenShell never spools. BUFFERED input is held for evaluation and successful Unchanged results, never as a failure fallback. STREAM has bounded transport queues but no recovery originals. Middleware windows and spools are its own responsibility.</p>
<p>The queue scenario shows output waiting for capacity. Other snapshots show queues after draining; empty queues do not imply zero transport memory. RPC copies, kernel buffers and aggregate admission must also be bounded in production. The 8/16-byte examples are illustrative, not production defaults.</p>
<p>The optional next stage is BUFFERED with a 64-byte RAM cap. It withholds its head and gathered bytes until its own BufferedResult succeeds. First-stage Finish does not automatically release that gate. On failure its incomplete body is discarded, not forwarded.</p>
<p>Header-only handling is preflight Continue, not a third body mode. Continue is successful skipping before body delivery, not fail-open. Midstream skip_remaining is deferred. STREAM middleware may stop inspecting and echo later bytes but remains on the data path.</p>
<p>OutputStart freezes headers and may precede input EOF. Finish must follow consumption of InputEnd. Errors always stop delivery; already transmitted bytes cannot be undone. Response support is negotiated separately; the new duplex STREAM requires a corresponding runner, not merely a schema rename.</p>
<p>This is a design simulation, not the production proxy. The trusted signature scenario is request-only and does not grant remote services credential or Authorization-header access.</p>
</details>
<footer>Current proposal: <a href="https://gist.github.com/pimlock/c33582aadad2e246d2538a710589b4cc">proto and examples</a> · <a href="https://gist.github.com/pimlock/5d67d4452d44ef2a9523ed295e96f87d">state diagrams</a>. Historical alternatives: <a href="https://gist.github.com/pimlock/fa4fcc0d85154f926ffa564ac13688de">earlier proto</a> · <a href="https://gist.github.com/pimlock/5772ab74a72b470280135ed271eb43f5">earlier diagrams</a> · <a href="https://gist.github.com/pimlock/54eac8a56ecfb627e9298693a2becad9">previous walkthrough</a>. This file works offline with no external scripts or fonts.</footer>
</main><script>
'use strict';
const b=(name,text)=>({name,text});
const bytes=xs=>xs.reduce((n,x)=>n+new TextEncoder().encode(x.text).length,0);
const A=b('window','se'),B=b('window','cret'),C=b('window','ok'),R=b('replacement','[redacted]');
function frames(rows){let s={os:[],queue:[],mw:[],sent:[],head:false,done:false,failed:false,eof:false,phase:'Negotiation',note:'No retained body.'};return rows.map(([event,why,patch={}])=>{s={...s,...patch};return {...s,event,why};});}
const windowRows=[
['PreflightResult(inspect.stream) → Begin','Select STREAM. The head remains withheld until OutputStart.',{phase:'Receiving'}],
['M → O: OutputStart()','The redactor knows its final headers. It can now return output at any time.',{head:true,phase:'Streaming'}],
['O → M: InputChunk("se")','Middleware holds the prefix. OpenShell keeps no recovery copy after transport delivery.',{mw:[A],note:'Working window in middleware RAM.'}],
['O → M: InputChunk("cret")','The secret spans two messages. Middleware keeps both until it has enough context.',{mw:[A,B]}],
['O → M: InputChunk("ok")','Eight bytes are in middleware, not in an OpenShell recovery window.',{mw:[A,B,C]}],
['M → O: OutputChunk("[redacted]")','The whole replacement is returned in one message and forwarded. Middleware drops its resolved prefix and keeps "ok". No commit or ACK follows.',{mw:[C],sent:[R]}],
['O → M: InputEnd','Middleware consumes EOF and trailers, then flushes its own window.',{eof:true,phase:'Flushing'}],
['M → O: OutputChunk("ok")','The remaining bytes pass onward. No output/input sequence accounting is required.',{mw:[],sent:[R,C]}],
['M → O: Finish()','Successful stream completion after input EOF.',{done:true,phase:'Complete'}]
];
const immediateRows=[
['PreflightResult(inspect.stream) → Begin','All failures will stop delivery. There is no recovery mode.',{phase:'Receiving'}],
['O → M: InputChunk("alpha")','Middleware consumes the prefix and chooses its final head.',{note:'Process prefix without storing a whole body.'}],
['M → O: OutputStart()','Release the head before input EOF.',{head:true,phase:'Input and output active'}],
['M → O: OutputChunk("ALPHA")','Output arrives before the next input chunk. This correspondence is incidental, not required.',{sent:[b('output','ALPHA')]}],
['O → M: InputChunk("beta")','Input continues independently under transport backpressure.',{}],
['M → O: OutputChunk("BETA")','Forward output without waiting for a prefix commit.',{sent:[b('output','ALPHA'),b('output','BETA')]}],
['O → M: InputEnd','EOF is consumed. Finish is now permitted.',{eof:true,phase:'Awaiting finish'}],
['M → O: Finish()','No sequence IDs or ownership acknowledgements were exchanged.',{done:true,phase:'Complete'}]
];
const bufferedRows=[
['PreflightResult(inspect.buffered, max_body_bytes=16) → Begin','Hold the head and collect input in bounded OpenShell RAM.',{phase:'Gathering'}],
['OpenShell reads "token="','No body message has reached middleware yet.',{os:[b('part','token=')]}],
['OpenShell reads "secret"','The 12-byte body fits the selected 16-byte cap.',{os:[b('part','token='),b('part','secret')]}],
['EOF; O → M: BufferedBody("token=secret")','One complete body and trailers are delivered. OpenShell holds the input for evaluation, not recovery.',{eof:true,phase:'Awaiting result',note:'Middleware inspects the complete small document.'}],
['M → O: BufferedResult(replacement="token=[redacted]")','Validate the terminal result and framing, discard input and release selected head/body.',{os:[],sent:[b('replacement','token=[redacted]')],head:true,done:true,phase:'Complete'}]
];
const signingRows=[
['PreflightResult(inspect.stream) → Begin','The trusted signer chooses to wait for EOF. STREAM itself permits earlier output.',{phase:'Receiving',note:'Prepare middleware-owned spool and hash.'}],
['O → M: InputChunk("alpha")','Middleware hashes and stores its input. OpenShell has only bounded transport queues.',{mw:[b('spool','alpha')]}],
['O → M: InputChunk("beta")','Middleware storage grows without ownership ACKs.',{mw:[b('spool','alpha'),b('spool','beta')]}],
['O → M: InputEnd','Finalize the full-body hash and authorized signature.',{eof:true,phase:'Signing'}],
['M → O: OutputStart(signature headers, output_body_bytes=9)','Release final headers. Authorization writes are restricted to the trusted internal signer.',{head:true,phase:'Returning body'}],
['M → O: OutputChunk("alpha")','Middleware streams the unchanged body back from its own spool.',{sent:[b('output','alpha')]}],
['M → O: OutputChunk("beta")','The entire output is returned. Completion still requires Finish.',{sent:[b('output','alpha'),b('output','beta')]}],
['M → O: Finish()','Check the declared output length and finish. Middleware cleans up its own spool.',{mw:[],done:true,phase:'Complete',note:'Spool removed by middleware.'}]
];
const scenarios={
window:{name:'STREAM · middleware-owned redaction window',mode:'STREAM',desc:'The redactor retains its working window. OpenShell does not track resolved input prefixes. The entire [redacted] replacement is one OutputChunk.',invariant:'Windowing is an implementation choice inside STREAM. No WindowResult, prefix commits or recovery copies exist.',rows:windowRows},
immediate:{name:'STREAM · output before EOF',mode:'STREAM',desc:'Independent input and output. A processor starts returning bytes after a prefix, while more input is still arriving.',invariant:'OutputChunk must follow OutputStart. Finish must follow InputEnd. Early output does not cancel input.',rows:immediateRows},
buffered:{name:'BUFFERED · small whole-body redaction',mode:'BUFFERED',desc:'One complete body within a RAM ceiling; one terminal result. Failure never forwards the original.',invariant:'No InputEnd or Finish event. BufferedBody includes the complete body and trailers. Overflow fails closed.',rows:bufferedRows},
signing:{name:'STREAM · whole-body signature header',mode:'STREAM',desc:'The signer needs all input before calculating a header. It manages the spool and returns the body afterward.',invariant:'Waiting for EOF is the signing algorithm’s choice. OpenShell never spools and cannot replay missing input.',rows:signingRows},
transform:{name:'STREAM · large whole-body transformation',mode:'STREAM',desc:'Middleware stores input and constructs a different output. The tiny sample represents a larger pack or document rewrite.',invariant:'The same STREAM API handles full-body rewrites. Production Git signing still needs separate identity, key and isolation decisions.',rows:[
['PreflightResult(inspect.stream) → Begin','Hold the head until middleware knows its replacement.',{phase:'Receiving',note:'Middleware owns input and replacement storage.'}],
['O → M: InputChunk("old")','Store input in middleware, not OpenShell.',{mw:[b('input spool','old')]}],
['O → M: InputEnd','Validate input and build replacement.',{eof:true,phase:'Transforming'}],
['Middleware prepares "new-pack"','Replacement length and chunking may differ from input.',{mw:[b('output spool','new-pack')]}],
['M → O: OutputStart(output_body_bytes=8)','The final head is ready.',{head:true,phase:'Returning body'}],
['M → O: OutputChunk("new-pack")','Forward replacement with bounded queues.',{sent:[b('replacement','new-pack')]}],
['M → O: Finish()','Validate length and clean up middleware storage.',{mw:[],done:true,phase:'Complete'}]
]},
pressure:{name:'STREAM · transport backpressure',mode:'STREAM',desc:'OpenShell still has bounded transport queues. They hold bytes waiting to be forwarded, not originals for recovery.',invariant:'A full output queue pauses further output reads. The independent input pump remains serviceable subject to its own bounds; no ACK or commit message unblocks output.',rows:[
...immediateRows.slice(0,3),
['M → O: OutputChunk("ALPHA"); recipient temporarily busy','One validated output waits in the bounded queue. It has not reached the next stage.',{queue:[b('queued output','ALPHA')],phase:'Backpressure'}],
['Output capacity becomes available','Drain the queue and forward the bytes. This is local flow control, not a middleware commit.',{queue:[],sent:[b('output','ALPHA')],phase:'Streaming'}],
['O → M: InputEnd','The source ends after "alpha" in this example.',{eof:true}],
['M → O: Finish()','Queues have drained and output is complete.',{done:true,phase:'Complete'}]
]},
streamFailure:{name:'STREAM · failure after partial output',mode:'STREAM',desc:'Failure after a replacement prefix has been returned. The original tail exists only in middleware.',invariant:'There is no bypass or replay. Fail closed means stop delivery; previously transmitted bytes cannot be undone.',rows:[
...windowRows.slice(0,6),
['Middleware RPC fails','Abort. Middleware’s held "ok" is unavailable; OpenShell must not substitute or replay it.',{failed:true,phase:'Aborted',note:'Failed service owns the remaining bytes; its cleanup is separate.'}]
]},
bufferedFailure:{name:'BUFFERED · failure before output',mode:'BUFFERED',desc:'Even though OpenShell still holds a full input body, mandatory fail-closed behavior rejects instead of forwarding it.',invariant:'Retaining bytes for buffered evaluation does not imply a recovery guarantee.',rows:[
...bufferedRows.slice(0,4),
['Middleware times out','Discard buffered input and stop. Send a local error before commitment; no body fallback.',{os:[],failed:true,phase:'Rejected'}]
]},
skip:{name:'Preflight Continue · no body processing',mode:'NONE',desc:'A successful decision before body transfer. This is not a third body mode and not fail-open.',invariant:'No Begin, body events or Finish reach this middleware. Failure during Preflight would reject, not Continue.',rows:[
['O → M: Preflight','Offer eligible modes and visible head.',{}],
['M → O: PreflightResult(continue_without_body)','Validate any allowed head changes; body skips only this stage.',{head:true,phase:'Stage complete'}],
['Transport forwards "hello"','No middleware body event occurs; later stages may still inspect these bytes.',{sent:[b('body','hello')]}],
['Transport reaches EOF','This is surrounding transport completion, not a Finish message to the skipped stage.',{done:true,eof:true,phase:'Body complete'}]
]}
};
for(const s of Object.values(scenarios))s.frames=frames(s.rows);
const $=id=>document.getElementById(id);let selected='window',index=0,gateAccepted=false;
function showBytes(id,items){const target=$(id);target.replaceChildren();if(!items.length){const e=document.createElement('span');e.className='empty';e.textContent='∅ empty';target.append(e);return;}for(const x of items){const e=document.createElement('span'),label=document.createElement('small'),text=document.createElement('span');e.className='chunk';label.textContent=x.name;text.textContent=x.text;e.append(label,text);target.append(e);}}
function render(){
const scene=scenarios[selected],s=scene.frames[index],gated=$('gate').checked,forward=!gated||gateAccepted;
$('description').textContent=scene.desc;$('phase').textContent=s.phase;$('event').textContent=s.event;$('explanation').textContent=s.why;$('position').textContent=(index+1)+' / '+scene.frames.length;
$('scrub').max=scene.frames.length-1;$('scrub').value=index;$('prev').disabled=index===0;$('next').disabled=index===scene.frames.length-1;
showBytes('input',s.os);showBytes('queue',s.queue);showBytes('storage',s.mw);showBytes('released',s.sent);showBytes('downstream',gated&&!gateAccepted&&!s.failed?s.sent:[]);showBytes('upstream',forward?s.sent:[]);
$('input-count').textContent=bytes(s.os)+' / 16 B gathered';$('queue-count').textContent=bytes(s.queue)+' / 16 B queued';$('input-meter').style.width=(100*bytes(s.os)/16)+'%';$('queue-meter').style.width=(100*bytes(s.queue)/16)+'%';
$('current-head').textContent=s.head?'Head released by this stage':'Head withheld by this stage';
$('ownership').textContent=scene.mode==='BUFFERED'?'Input is held for bounded evaluation. It is never used as a failure fallback.':scene.mode==='STREAM'?'No recovery originals. Middleware owns its working data. Queue storage is flow control only.':'No body processing in this stage.';
$('middleware-note').textContent=s.note;$('downstream-title').textContent=gated?'Next stage · BUFFERED':'Next stage · direct transport';
$('downstream-note').textContent=gated?(s.failed?'Abort: discard the incomplete buffered body; do not release it.':gateAccepted?'Terminal result accepted; bounded RAM released.':'Hold received bytes and the outgoing head: '+bytes(s.sent)+' / 64 B. Await this stage’s own result.'):'Validated output is forwarded as transport capacity permits.';
$('release-gate').hidden=!gated;$('release-gate').disabled=!s.done||s.failed||gateAccepted;$('release-gate').textContent=gateAccepted?'Next stage result accepted':'Accept next stage BufferedResult';
$('upstream-head').textContent=s.head&&forward?'Headers received':'No headers received';
$('upstream-note').textContent=s.failed?(s.head&&forward?'Partial delivery aborted. Visible bytes cannot be undone.':'Middleware body was not released upstream; a local error is possible.'):(s.done&&forward?'Selected body delivery is complete in this model.':'Only the bytes shown have been released so far.');
$('invariant').textContent=scene.invariant;$('timeline').replaceChildren();
scene.frames.forEach((f,i)=>{const li=document.createElement('li'),button=document.createElement('button');button.textContent=f.event;button.setAttribute('aria-current',String(i===index));button.onclick=()=>jump(i);li.append(button);$('timeline').append(li);});
}
function jump(i){index=i;gateAccepted=false;render();}
for(const [key,s]of Object.entries(scenarios)){const o=document.createElement('option');o.value=key;o.textContent=s.name;$('scenario').append(o);}
$('scenario').onchange=()=>{selected=$('scenario').value;jump(0);};$('next').onclick=()=>jump(Math.min(index+1,scenarios[selected].frames.length-1));$('prev').onclick=()=>jump(Math.max(0,index-1));$('reset').onclick=()=>jump(0);$('scrub').oninput=()=>jump(Number($('scrub').value));$('gate').onchange=()=>{gateAccepted=false;render();};$('release-gate').onclick=()=>{gateAccepted=true;render();};render();
</script></body></html>

Interactive walkthrough: BUFFERED and STREAM

Companions: proto and exchanges and state diagrams.

Download buffer-walkthrough.html and open it in a browser. GitHub displays the HTML source rather than executing it. The document is standalone and works offline with no server, external scripts, fonts or dependencies.

This is a new proposal. Historical gists remain unchanged. The only body modes are BUFFERED and STREAM; every middleware failure fails closed. Header-only handling is a successful preflight Continue decision.

Try these scenarios

  1. STREAM windowed redaction: input accumulates in middleware's working window. OpenShell has no recovery originals. The whole [redacted] replacement comes back in one OutputChunk and proceeds immediately when capacity permits.
  2. Enable the BUFFERED next-stage toggle. Returned output now gathers in that stage's bounded RAM while upstream sees nothing. After the first stage finishes, accept the next stage's own result to release its head/body.
  3. STREAM early output: OutputStart and OutputChunk precede InputEnd; input keeps flowing independently. Finish still requires consumption of InputEnd.
  4. BUFFERED redaction: OpenShell collects a small whole body in RAM and validates one terminal result. It never spills to disk or falls back on failure.
  5. STREAM signing: middleware owns a spool, waits for EOF, calculates the trusted signature header and returns the unchanged body. Waiting is its algorithm's decision, not a separate body mode.
  6. STREAM whole-body rewrite: middleware stores input, builds replacement output and returns it with potentially different length/chunking.
  7. STREAM backpressure: a validated output chunk sits in a bounded transport queue while the recipient is busy, then drains without any commit or ACK message.
  8. Failure scenarios: STREAM may leave a partially delivered prefix; BUFFERED failure rejects even though its original body was still available. Neither bypasses the middleware. A later buffering stage can still prevent exposure.
  9. Preflight Continue: body bypasses this stage before any body delivery occurs; later stages remain active. This is a success, not fail-open.

The panels distinguish buffered input, transport queues, middleware storage, cumulative released-byte history, downstream buffering and upstream visibility. Byte caps are tiny for readability, not proposed production defaults. RPC copies, kernel buffers and aggregate admission also need bounds in an implementation.

For responses, the recipient is the sandbox. Both hooks use shared types but advertise only their implemented eligible subset. STREAM requires the new duplex runtime; an existing lockstep response runner does not gain that behavior through a schema rename. Body-aware policy re-evaluation may impose an additional gate.

Verified in Chromium on desktop and mobile: 9 scenarios, 120 frame/gate combinations, buffer bounds, head/output ordering, fail-closed behavior and UI controls. This validates the illustration, not an implementation of the protocol.

Design history

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment