Repository navigation
TypeScript streams and sessions retain contributor protection - #849
Merged
Merged
Conversation
Observe the native response body before releasing marked frames and keep every contributing handle across buffered automatic work. Explicit actions retain observation without becoming automatic capture. Signed-off-by: zlareb1 <[email protected]>
A shared monotonic patch could expire a freshly loaded model-call policy before the bearer test reached its first request. Exercise the same attributed token rotation at two clock epochs without changing the policy clock. Signed-off-by: zlareb1 <[email protected]>
7 tasks done
This was referenced Nov 18, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #840
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
TypeScript streams and Session buffers retain protection for every contributing conversation. Automatic transcript and extraction work stop after protection while explicit actions remain available.
Why
A streaming caller can read through a reader, a body method or a clone. Each route must wait for durable protection before receiving a marked frame. Guarding the native response body gives those routes the same boundary without buffering the complete answer.
Scope and risk
Bound successful SSE responses use a native guarded Response. It retains status, headers and response metadata through ordinary clones. Complete frames preserve their original bytes; marked frames wait for every retained handle's durable acknowledgement. Framing supports CR, LF, split CRLF, multiline data, comments, an initial BOM and split UTF-8. An unfinished frame is limited to 4 MiB. Invalid frames, partial EOF, unsupported media types and compression refuse and protect the retained handles.
Cancellation and read failures protect the contributors and join bounded owned cleanup before returning failure. Original source read errors retain their identity. Unbound raw responses retain their original identity and behavior. Native clone queues follow platform tee behavior; the frame limit does not bound caller-created clone queues. BYOB readers remain unsupported and refuse.
The typed assistant parses the same newline forms and multiline data, preserves constant protection failures, and accepts an optional SessionCapture alongside its question for automatic invocations. It requires the completion marker before returning an answer and continues draining after that marker so later protection metadata is observed.
Session snapshots its constructor capture and retains every bound handle it later uses. Automatic recall, transcript and extraction requests carry those contributors through credential waits and dispatch. A first marked recall can return; optional history is omitted after protection. Pending and carry-over text are discarded on protection instead of retried. A synchronous buffer read clears known local taint; asynchronous owner boundaries also check durable state. A clean failed extraction preserves old-before-new retry order only after another bounded state check. Zero carry-over sends no prior batch.
Explicit offload, fetch and note use observation-only controls. They remain available after protection and mark all retained families on marked or malformed replies, including after client rebinding. The same observation-only control is available on ordinary calls and raw streams.
Framework callbacks, durable storage backends, restored host lineage and fleet qualification remain separate work. This change sends no capability declaration and does not enable mirrored-source creation.
Compatibility, rollout and rollback
capturecontrols; call options add observation-onlyobserve. All are SDK controls outside wire arguments. The existing configured transport timeout is readable and bounds Session state checks.Tests
vitest run --pool=forks --maxWorkers=1 --no-file-parallelism src/protected-stream.test.ts src/protected-stream-lifetime.test.ts src/protected-stream-protocol.test.ts src/assistant-protection.test.ts src/assistant.test.ts: 59 pass in the focused local check. These cover durable-before-first-byte across readers/body methods/clones, framing and bounds, metadata, cancellation, abort, source failures, pending storage, contributor forwarding and existing assistant completion/timeout behavior.vitest run --pool=forks --maxWorkers=1 --no-file-parallelism src/session-capture-protection.test.ts src/session.test.ts: 22 pass, including contributor retention, buffer cleanup, explicit actions, optional-history authentication, pending stores, primary backend errors, concurrent clean retries and ordinary Session behavior.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated: Codex wrote the change; fresh independent whole-diff review and final-head CI are required before merge.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist