T3-to-Vox Domain 1 Implementation Spec: Deterministic IDs, Wire Interning, Atomic Stream Resumption & Guest Share (2026)
This document specifies the exact Rust and TypeScript implementation for Phases 216–217 (T3-WIRE-ID-01..04 and T3-STREAM-GUEST-01..04) of Milestone v4.1. It details how to replace ad-hoc ID generation and uncompressed orchestrator snapshots with VoxIdAllocatorV2 (allocate + derive colon-separated URI-encoded deterministic IDs), ForwardCompatibleEnvelope<T>, WireIdTableInterner (orchestrationV2IdTable.ts), LiveBodyDeduper (orchestrationV2DedupedBodies.ts), omit_idle_subagents cold-connect filtering, NotT3Chat-style Mutex-locked atomic mid-stream multi-tab resumption, CommandOutputHub \r folding, host-moderated Live Guest Share, and ThreadRunQueue with mid-turn promote_to_steer and rate-limit auto-recovery (limit_recovery).
1. Phase 216: VoxIdAllocatorV2, ForwardCompatibleEnvelope & Wire Compression (T3-WIRE-ID-01..04)
Section titled “1. Phase 216: VoxIdAllocatorV2, ForwardCompatibleEnvelope & Wire Compression (T3-WIRE-ID-01..04)”1.1 VoxIdAllocatorV2 (crates/vox-orchestrator/src/session/id_allocator.rs)
Section titled “1.1 VoxIdAllocatorV2 (crates/vox-orchestrator/src/session/id_allocator.rs)”- Source Inspiration:
t3codepackages/provider-core/src/server/IdAllocator.ts:183-433(IdAllocatorV2). - Legacy Code Replaced: Ad-hoc
uuid::Uuid::new_v4().to_string()and monotonic string concatenation scattered acrosscrates/vox-orchestrator/src/session/state.rsandcrates/vox-orchestrator-mcp/src/chat_tools/chat/message.rs. - Zero-Dependency Implementation Design (Stdlib RFC 3986 Percent-Encoding — Zero
Cargo.lockChanges):pub struct VoxIdAllocatorV2;/// RFC 3986 unreserved character percent-encoding (`A-Z`, `a-z`, `0-9`, `-`, `_`, `.`, `~`)/// implemented in pure `std` so zero external crate dependencies (`urlencoding`) are added.pub fn percent_encode_id_segment(input: &str) -> String {const HEX: &[u8; 16] = b"0123456789ABCDEF";let mut out = String::with_capacity(input.len());for &b in input.as_bytes() {if b.is_ascii_alphanumeric() || matches!(b, b'-' | b'_' | b'.' | b'~') {out.push(b as char);} else {out.push('%');out.push(HEX[(b >> 4) as usize] as char);out.push(HEX[(b & 0x0f) as usize] as char);}}out}impl VoxIdAllocatorV2 {/// Mints a fresh random UUIDv4 with canonical entity prefix (`thread:<uuid>`, `run:<uuid>`, etc.).pub fn allocate(prefix: &str) -> String {format!("{prefix}:{}", uuid::Uuid::new_v4())}/// Deterministic URI-component-encoded colon-joined ID (`prefix:part1:part2...`)./// Replaying the same provider/actor event stream yields identical entity IDs without a lookup table.pub fn derive(prefix: &str, parts: &[(&str, &str)]) -> String {let mut out = String::from(prefix);for (k, v) in parts {out.push(':');out.push_str(k);out.push(':');out.push_str(&percent_encode_id_segment(v));}out}} - Required Derived Constructors:
derive_run_from_thread_ordinal(thread_id, ordinal),derive_run_attempt(run_id, attempt_ordinal),derive_node_from_provider_item(driver, turn_id, native_item_id),derive_turn_item_from_provider_item(driver, turn_id, native_item_id, segment), andderive_subagent_from_task(driver, thread_id, native_task_id).
1.2 ForwardCompatibleEnvelope<T> (crates/vox-orchestrator/src/models/wire_envelope.rs)
Section titled “1.2 ForwardCompatibleEnvelope<T> (crates/vox-orchestrator/src/models/wire_envelope.rs)”- Source Inspiration:
t3codepackages/shared/src/ForwardCompatibleUnion.ts. - Implementation Design:
Provides#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]#[serde(untagged)]pub enum ForwardCompatibleEnvelope<T> {Known(T),Unknown(serde_json::Value),}
into_known_or_raw()so older GUI/MCP clients never fail deserialization when a newervox-orchestratoremits a newly added turn-event or turn-item variant.
1.3 WireIdTableInterner & LiveBodyDeduper (crates/vox-orchestrator-mcp/src/dei_tools/wire_compression.rs)
Section titled “1.3 WireIdTableInterner & LiveBodyDeduper (crates/vox-orchestrator-mcp/src/dei_tools/wire_compression.rs)”- Source Inspiration:
t3codepackages/contracts/src/orchestrationV2IdTable.ts(80455376),packages/shared/src/orchestrationV2DedupedBodies.ts(e19fe083), andapps/server/src/orchestration-v2/WireProjection.ts. - Legacy Code Replaced: Uncompressed snapshot serialization in
crates/vox-orchestrator-mcp/src/dei_tools/orchestrator_snapshot.rsandcrates/vox-orchestrator-mcp/src/chat_tools/chat/history.rs. - Mechanics:
intern_record_ids(payload: &mut Value) -> Vec<String>: Walks top-level arrays and nesteditemobjects; for every key equal to"id"or ending with"_id"/"Id"(or string array ending with"_ids"/"Ids"), interns the string intoids: Vec<String>and replaces the field value with its integer indexu32.expand_record_ids(payload: &mut Value, ids: &[String])restores the original strings losslessly.LiveBodyDeduper(LIVE_DEDUPE_MEMORY = 32): Tracks the last 32 transmitted(item_id, vox_crypto::fast_hash(body.as_bytes()))pairs (XXH3-64viavox_crypto::fast_hash) per subscription foruser_message.text,assistant_message.text,checkpoint.files, andsubagent.{prompt, result}. When an identical body is re-emitted onturn-item.updatedor in a bounded snapshot wheremessagesalready carries the text, the field is cleared andtext_omitted: true/files_omitted: true/prompt_omitted: true/result_omitted: trueis set.- Cold-Connect Idle Subagent Filter (
omit_idle_subagents: bool): Inspired byt3codepackages/client-runtime/src/state/threadFamilies.ts(67c3afbd), shell snapshot queries withomit_idle_subagents = trueexclude child subagent threads whose status isCompleted | Cancelled | Failed | Interrupted, reducing cold-connect thread-list payloads by ~33% while exposingget_thread_family(root_thread_id)on demand.
2. Phase 217: Atomic Mid-Stream Multi-Tab Join, CommandOutputHub, Live Guest Share & ThreadRunQueue (T3-STREAM-GUEST-01..04)
Section titled “2. Phase 217: Atomic Mid-Stream Multi-Tab Join, CommandOutputHub, Live Guest Share & ThreadRunQueue (T3-STREAM-GUEST-01..04)”2.1 Atomic Mid-Stream Multi-Tab Join (crates/vox-orchestrator/src/models/spec.rs & salvage_and_stream.rs)
Section titled “2.1 Atomic Mid-Stream Multi-Tab Join (crates/vox-orchestrator/src/models/spec.rs & salvage_and_stream.rs)”- Source Inspiration:
shaltielshmid/NotT3Chatbackend/Program.cs:623-707, 750-795(StreamingMessagewithSemaphoreSlim(1)lock). - Legacy Code Replaced: Unsynchronized
AgentEventKind::TokenStreamedemission incrates/vox-orchestrator-mcp/src/chat_tools/chat/agent_loop/salvage_and_stream.rs:90-95. - Implementation Design:
- Upgrade
ResumableTurnStreamRegistryto hold a per-turnArc<tokio::sync::Mutex<ActiveTurnStreamState>>containing:chunks: Vec<SequencedTurnChunk>accumulated_text: Stringaccumulated_reasoning: Stringsubscribers: Vec<tokio::sync::mpsc::UnboundedSender<SequencedTurnChunk>>
subscribe_or_replay(turn_id, after_seq): Acquires the per-turnMutex, snapshots all chunks withseq > after_seq, registers a newmpsc::UnboundedSenderinsubscribers, and only then releases theMutex. Becauseappend_chunkacquires the exact same per-turnMutexwhen appending a token and fanning out tosubscribers, a tab refreshing or joining mid-stream is mathematically guaranteed zero dropped tokens and zero duplicated tokens at the join boundary.
- Upgrade
2.2 CommandOutputHub & \r Progress-Bar Folding (crates/vox-orchestrator/src/terminal_output.rs)
Section titled “2.2 CommandOutputHub & \r Progress-Bar Folding (crates/vox-orchestrator/src/terminal_output.rs)”- Source Inspiration:
t3codeapps/server/src/orchestration-v2/CommandOutputHub.ts&packages/shared/src/terminalOutput.ts:206(normalizeTerminalOutput). - Mechanics:
- Constants:
MAX_CHUNKS_PER_STREAM = 64,MAX_BYTES_PER_STREAM = 262_144(256 KiB),TERMINAL_OUTPUT_TAIL_CHARS = 65_536(64 KiB),LIVE_LINES = 64. normalize_terminal_output(raw: &str) -> String: Resolves bare carriage returns (\rnot followed by\n) by overwriting the current line from column 0, collapsing cargo/npm/pip progress-bar spam into clean final lines before persisting tool output into the transcript.
- Constants:
2.3 Host-Moderated Live Guest Share (crates/vox-orchestrator-mcp/src/guest_share.rs)
Section titled “2.3 Host-Moderated Live Guest Share (crates/vox-orchestrator-mcp/src/guest_share.rs)”- Source Inspiration:
t3codepackages/contracts/src/guestShare.ts,apps/server/src/guest/GuestShareService.ts, andapps/server/src/orchestration-v2/GuestShareDecider.ts(fb76594d). - Crypto & Secret Compliance (
AGENTS.md):- Uses Clavis secret
SecretId::VoxGuestShareSigningKeyresolved viavox_secrets::resolve_secret(SecretId::VoxGuestShareSigningKey, None, None). - Derives a 32-byte key via
vox_crypto::secure_hash(secret.as_bytes())and signs<share_id>usingvox_crypto::keyed_hash(&key_32, share_id.as_bytes())(BLAKE3 MAC), encoding the first 16 bytes (128-bittag) withvox_crypto::hex_encode(&mac[..16])(invite token format:<share_id>.<hex_mac_128bit>).
- Uses Clavis secret
- Mechanics:
- Constants:
GUEST_SHARE_TTL_MS = 86_400_000(24h),GUEST_MESSAGE_MAX_LENGTH = 4_000,GUEST_NAME_MAX_LENGTH = 40,GUEST_PENDING_MESSAGE_LIMIT = 3,GUEST_RESOLVED_MESSAGE_LIMIT = 20,SNAPSHOT_ROW_LIMIT = 600,SNAPSHOT_USER_TURN_LIMIT = 20. - Single-browser redemption (
redeem_guest_share) bindsguest_name; subsequent redemption attempts with a different session cookie fail withGuestShareError::AlreadyRedeemed. - Guest message submissions enter
pendingstatus (GuestMessageStatus::Pending). The host owner either Approves (approve_guest_message, which dispatches"Message from guest {name}, sent by the owner:\n\n{text}") or Dismisses (dismiss_guest_message, which purges any pending guest attachments).
- Constants:
2.4 ThreadRunQueue, Mid-Turn promote_to_steer, Rate-Limit Auto-Recovery & awaited Background Settlement (crates/vox-orchestrator/src/session/run_queue.rs)
Section titled “2.4 ThreadRunQueue, Mid-Turn promote_to_steer, Rate-Limit Auto-Recovery & awaited Background Settlement (crates/vox-orchestrator/src/session/run_queue.rs)”- Source Inspiration:
t3codeapps/server/src/orchestration-v2/Decider.ts(queued-message.enqueue,queued-message.promote-to-steer,limit.auto-resume,limit.snooze) &packages/provider-core/src/server/ThreadToolkit.ts(t3_background_wait). - Legacy Code Replaced: Single-flight blocking turn rejection in
crates/vox-orchestrator-mcp/src/chat_tools/chat/message.rswhen a session already has an active turn running. - Mechanics:
- Queued Runs (
queued_runs: VecDeque<QueuedRunEntry>): When a user submits a prompt whileThreadRuntimeStatus::Running, the message is appended toqueued_runswith full editing, reordering, and cancellation support (vox_chat_queue_edit,vox_chat_queue_reorder,vox_chat_queue_cancel). - Mid-Turn Promote-to-Steer (
promote_to_steer(thread_id, queued_run_id)): Removes the queued message fromqueued_runsand injects it immediately into the activeagent_loopiteration as a live steering user message before the next tool-batch or LLM round-trip, without aborting the running turn. - Rate-Limit Auto-Recovery (
LimitRecoveryState): When a provider returns a429or quota exhaustion with a parsablereset_attimestamp, the thread transitions toWaitingRateLimit { run_id, reset_at_ms, auto_resume: true, snoozed_until_ms: None }and schedules an automatic turn resume timer (with user toggles forauto_resumeandsnooze). - Selective Background Work Settlement (
awaited: bool): Subagents and background shells spawned during a turn carryawaited: bool. The turn state machine entersSettlingBackgroundWorkat turn end only for children withawaited == true; fire-and-forget daemons (awaited == false) continue running in the background without blocking turn completion.
- Queued Runs (
3. Verification Gates (Phases 216–217)
Section titled “3. Verification Gates (Phases 216–217)”timeout 900s cargo test -p vox-orchestrator --lib session::id_allocator(verifying deterministicderiveidempotency andpercent_encode_id_segmentacross 1,000 replayed events).timeout 900s cargo test -p vox-orchestrator-mcp --lib dei_tools::wire_compression(verifying round-tripintern_record_ids/expand_record_idsandLiveBodyDeduper).timeout 900s cargo test -p vox-orchestrator --lib models::spec::tests::atomic_mid_stream_multi_tab_join(verifying zero dropped/duplicated tokens under concurrent producer + mid-stream subscriber join).timeout 900s cargo test -p vox-orchestrator --lib session::run_queue::tests(verifyingpromote_to_steer,LimitRecoveryStateauto-resume, andawaitedbackground work settlement).timeout 900s cargo test -p vox-orchestrator-mcp --lib guest_share::tests(verifying BLAKE3keyed_hashtoken verification, single redemption, 3-message pending cap, and owner approve/dismiss transitions).