Repository navigation
Assistant answers bind mirror admission and private accounting - #835
Merged
Merged
Conversation
Fix mirror admission before model work so a later source activation cannot widen an ordinary answer. Mark private output first and retain required stream accounting through owned cancellation cleanup; SDKs require terminal completion. Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Keep the registration-only admission lookup within the package contract while preserving the conservative privacy boundary. Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Attach the server-owned mark after typed output serialization and keep it through structured and text protocol unwrapping. Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Active registrations mark responses before ACL filtering. Compare inactive responses with the same content and no flag; keep active and stale-evidence expectations intact. Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Capture ordinary responses before registration so inactive-source assertions retain complete JSON, download bytes and header comparisons without removing privacy metadata from expected values. Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
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: #825
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):
Assistant answers flag mirrored source access before output and fix mirror admission for the answer's lifetime. Streaming SDKs reject incomplete answers.
Why
A delegated tool call's privacy state does not return to the outer model answer. The bridge classifies the authorized namespace's active mirrored registrations before checking spend, marks the complete answer, and fixes a separate signed
answer_mirrorsrestriction on its token. An initially ordinary answer cannot acquire a mirror leg when a source becomes active later. The caller'ssession_protectionpromise retains its separate meaning; ordinary delegated children omit both claims.Normal operation models do not carry the request's privacy mark. The transports attach it after serialization and preserve it through MCP structured and text results; a marked search summary follows a first JSON marker block.
Using the capability promise alone permits late activation. An answer registry would add shared state without replacing per-document authorization. The signed restriction keeps ordinary namespace reads and current ACL checks intact.
Final usage exists after incremental text. A marked response therefore owns its accounting lifetime beyond HTTP headers, joins producer cleanup despite repeated cancellation, and confirms its required private cost row before terminal completion. Partial text remains provisional. Whole responses and checked source frames keep their accounting-before-publication boundary.
Scope and risk
The change covers assistant admission, first-output flags, required stream accounting, shared HTTP/MCP success and error flags, generated output types, and SDK completion detection. The regressions exercise late activation, strict claims and descendant restrictions, first SSE/whole flags, failed private delivery, repeated cancellation, protocol unwrapping and incomplete EOF. The native signed-read fixture adds an anyone-readable mirror and ordinary-document control for CI. Its inactive-source branch compares complete responses, including download bytes and headers, with unmarked baselines captured before registration. Active-source baselines retain the flag even when ACL checks exclude every private row.
Durable SDK stream observation, automatic-capture qualification and fleet readiness remain separate work. Mirrored-source creation stays disabled.
Compatibility, rollout and rollback
assistant.askadds optionalmirrored: bool, default false. Marked chat responses begin withmirrored: true; marked SSE begins withdata: {"mirrored":true}. Marked error payloads retain the flag after protocol unwrapping. SDKs require[DONE]before returning a completed answer, ignore subsequent text and retain transport-error handling.answer_mirrorsis a strict server-issued Boolean. Missing admission is false. No caller field, header, mint endpoint or CLI flag sets it.Tests
sdk/typescript/src/assistant.test.tspass with one worker. The assistant reads registration presence through the knowledge app layer; the package contract and its allowlist remain unchanged.python -m pytest -q -n 0 tests/unit/test_assistant_mirror_boundary.py tests/unit/test_session_protection_declaration.py::test_the_bridge_fixes_the_callers_declaration_in_the_answer.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated: Codex wrote the change; independent source review and exact-head CI are required before merge.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist