T3-to-Vox Domain 5 Implementation Spec: @rule Mentions, Dynamic Variables, Weighted Fuzzy Search, Signed Webhooks, CLI Session Importer & Route Racing (2026)
This document specifies the exact Rust and TypeScript implementation for Phases 224–225 (T3-RULES-SEARCH-01..04 and T3-WEBHOOK-IMPORT-01..04) of Milestone v4.1. It details how to extend mentions.rs with @rule:<name> and attach: Always user rules (thom-chat), add $variable system prompt interpolation (helioschat), wire regenerate-with-stored-posture vs. in-place assistant message editing and 100-entry promptHistory, combine 3-mode weighted fuzzy search with markdown-link-stripped trigram search (t3code ThreadSearch.ts), upgrade webhook_intake.rs with signed/filtered/deduped webhook & cron triggers, import external ~/.claude, ~/.codex, and ~/.cursor sessions, and add 6-tier staggered route racing (150ms head start).
1. Phase 224: @rule Mentions, Dynamic $variable Prompts, Regenerate-with-Posture & 3-Mode Fuzzy/Trigram Search (T3-RULES-SEARCH-01..04)
Section titled “1. Phase 224: @rule Mentions, Dynamic $variable Prompts, Regenerate-with-Posture & 3-Mode Fuzzy/Trigram Search (T3-RULES-SEARCH-01..04)”1.1 @rule:<name> Manual & Always User Rules (crates/vox-orchestrator-mcp/src/chat_tools/chat/mentions.rs)
Section titled “1.1 @rule:<name> Manual & Always User Rules (crates/vox-orchestrator-mcp/src/chat_tools/chat/mentions.rs)”- Source Inspiration:
TGlide/thom-chatconvex/schema.ts(user_rules) &src/routes/_chat.tsx:690-740(parseRulesFromText). - Legacy Code Replaced: File-path-only
MENTION_REincrates/vox-orchestrator-mcp/src/chat_tools/chat/mentions.rs:14-68that treats@rule:fooas a missing workspace file path ([Mentioned file not found: rule:foo]). - Implementation Design:
- Introduce
UserRuleEntry { id: String, name: String, attach: RuleAttachMode, rule_body: String }whereRuleAttachModeisAlways | Manualandnameis validated against^[a-zA-Z0-9_-]+$(excluding reserved@file,@workspace,@web). - Before resolving file
@mentionsinresolve_mentions, extract all@<rule_name>tokens matching configuredManualrules, strip the raw@<rule_name>tokens from the user prompt text, deduplicate the matchedManualrules with all enabledAlwaysrules, and append a consolidated<user_rules>block at the end of the turn payload.
- Introduce
1.2 Dynamic System Prompt $variable Interpolation (crates/vox-orchestrator-mcp/src/chat_tools/mod.rs & preamble_and_retrieval.rs)
Section titled “1.2 Dynamic System Prompt $variable Interpolation (crates/vox-orchestrator-mcp/src/chat_tools/mod.rs & preamble_and_retrieval.rs)”- Source Inspiration:
helioschat/appsrc/lib/utils/systemPromptVariables.ts. - Legacy Code Replaced: Static string assembly in
build_system_prompt_with_skill(crates/vox-orchestrator-mcp/src/chat_tools/mod.rs:88-90). - Mechanics:
- Single-pass
$variableresolver (interpolate_system_prompt_variables) supporting bothhelioschat’s 5 standard variables and 3 Vox-native workspace variables:$current_datetime— ISO-8601 timestamp with local offset$user_timezone— IANA timezone identifier$user_locale— BCP-47 locale tag$user_language— primary language code$user_platform— OS/arch (std::env::consts::OS/ARCH)$workspace_root— canonical repository root name$git_branch— active Git/VCS branch$active_spoke— active Vox routing spoke (coding,research,planning,review,general)
- Single-pass
1.3 Regenerate-with-Stored-Posture vs. In-Place Assistant Edit & 100-Entry promptHistory (crates/vox-orchestrator-mcp/src/chat_tools/chat/history.rs & crates/vox-gui/ui)
Section titled “1.3 Regenerate-with-Stored-Posture vs. In-Place Assistant Edit & 100-Entry promptHistory (crates/vox-orchestrator-mcp/src/chat_tools/chat/history.rs & crates/vox-gui/ui)”- Source Inspiration:
helioschat/appsrc/routes/+page.svelte:132-297,shaltielshmid/NotT3ChatChatPage.razor, andt3codecomposer history. - Mechanics:
- Per-Message Stored Generation Posture: Every persisted assistant message stores
GenerationPostureSnapshot { model_id, provider, reasoning_effort, web_search_enabled, temperature, top_p }. - Regenerate (
vox_chat_regenerate): Truncates from the target assistant message (or user message) onward and re-runs the turn reusing the message’s storedGenerationPostureSnapshotby default, or substituting a newly chosenmodel_overridefrom the regenerate dropdown. - In-Place Assistant Edit (
vox_chat_edit_message_in_place): Mutates an assistant message’scontentin-place in the session transcript without truncating subsequent turns, enabling manual clean-up of model outputs before continuing a long thread. - 100-Entry
promptHistory(ArrowUp/ArrowDown): Persists the last 100 submitted prompts in local storage; pressingArrowUpat line 0 stashes the current unsent text intocurrentDraftand walks backward through history, whileArrowDownwalks forward and restorescurrentDraftat the bottom.
- Per-Message Stored Generation Posture: Every persisted assistant message stores
1.4 3-Mode Weighted Fuzzy Search, Link-Stripped Trigram Search & In-Thread Occurrence Jumper (crates/vox-search & crates/vox-gui/ui)
Section titled “1.4 3-Mode Weighted Fuzzy Search, Link-Stripped Trigram Search & In-Thread Occurrence Jumper (crates/vox-search & crates/vox-gui/ui)”- Source Inspiration:
TGlide/thom-chatsrc/lib/fuzzy-search.ts,t3codeapps/server/src/search/ThreadSearch.ts, andapps/web/src/components/ThreadFind.ts. - Mechanics:
- Markdown-Link URL Stripper (
strip_markdown_link_urls): Before indexing or matching chat messages, replaces[label](url)withlabelso long URLs inside markdown links never pollute trigram or fuzzy search scores. - Weighted
calculate_match_score(min_score = 0.3):- Exact match:
1.0 - Substring match:
0.8 + 0.2 * (query.len() as f32 / target.len() as f32) - All-words match:
0.9 - Partial-words match:
(matched_words / total_words) * 0.7 - Prefix match:
0.6 - Character-order fuzzy match:
(matched_chars / query.len()) * 0.5 + (max_consecutive / query.len()) * 0.2 - Recency tie-breaker (
+0.05max boost for threads updated within 24h) and title boost (1.4xvs.1.0xcontent).
- Exact match:
- In-Thread Find (
ThreadFind): Searches across both message bodies and inline plan artifacts within the active thread, exposingnext_match/prev_matchoccurrence jumpers.
- Markdown-Link URL Stripper (
2. Phase 225: Signed/Filtered Webhook Ingress, Cron Scheduled Tasks, CLI Session Importer & 6-Tier Route Racing (T3-WEBHOOK-IMPORT-01..04)
Section titled “2. Phase 225: Signed/Filtered Webhook Ingress, Cron Scheduled Tasks, CLI Session Importer & 6-Tier Route Racing (T3-WEBHOOK-IMPORT-01..04)”2.1 Replace Minimal webhook_intake.rs with Signed/Filtered Webhook Ingress & Scheduled Tasks (crates/vox-orchestrator-mcp/src/server_state/webhook_intake.rs)
Section titled “2.1 Replace Minimal webhook_intake.rs with Signed/Filtered Webhook Ingress & Scheduled Tasks (crates/vox-orchestrator-mcp/src/server_state/webhook_intake.rs)”- Source Inspiration:
t3codeapps/server/src/scheduledTasks/ScheduledTasksService.ts&packages/contracts/src/scheduledTasks.ts. - Legacy Code Replaced & Deleted:
- Replace the minimal 64-line
crates/vox-orchestrator-mcp/src/server_state/webhook_intake.rsand delete the deprecatedVOX_WEBHOOK_GITLAB_TOKENwarning stub at lines 27–32.
- Replace the minimal 64-line
- Mechanics:
- Signed Webhook Verification (
vox_crypto::keyed_hash): VerifiesX-Vox-Signature-256(orX-Hub-Signature-256) usingvox_crypto::keyed_hashand Clavis secretSecretId::VoxWebhookSigningSecret. - Idempotency Deduplication (
webhook_dedupe): Tracks(webhook_id, delivery_id, received_at_ms)with a 24h TTL so retried deliveries never spawn duplicate agent turns. - Header & JSONPath Payload Filtering + Rate/Queue Caps: Matches incoming headers and dot-path JSON fields before waking a task; enforces
WEBHOOK_RATE_LIMIT_PER_MINUTE = 60andMAX_QUEUED_SCHEDULED_RUNS = 20. - Cron & Interval Scheduled Tasks: Supports
ScheduleTrigger::Cron(String),ScheduleTrigger::IntervalMs(u64), andScheduleTrigger::Webhook(WebhookFilterSpec)with configurable thread target (NewThreadvs.ReuseLastThread).
- Signed Webhook Verification (
2.2 External CLI Agent Session Scanner & Importer (crates/vox-orchestrator/src/session/external_importer.rs)
Section titled “2.2 External CLI Agent Session Scanner & Importer (crates/vox-orchestrator/src/session/external_importer.rs)”- Source Inspiration:
t3codeapps/server/src/sessionImport/AgentSessionScanner.ts&AgentSessionImporter.ts, plushelioschatsrc/lib/utils/dataExport.ts. - Mechanics:
- Discovers and imports external coding agent sessions into Vox threads (
vox session import-external):- Claude Code (
~/.claude/projects/**.jsonl): Parses user/assistant turns, tool uses, and token usage metadata. - Codex CLI (
~/.codex/sessions/**.jsonl): Parses rollout items, command executions, and patches. - Cursor (
~/.cursor/chats/<workspace-hash>/<session-id>/store.db): Reads SQLitemeta(hex-encoded JSON root blob pointer) and recursively walksblobsDAG nodes to reconstruct the conversation history.
- Claude Code (
- Also exposes
vox session export-bundleandvox session import-bundle(helioschatdataExport.tsparity) for single-file portable JSON backup and restore of threads, branches, user rules, and pinned skills.
- Discovers and imports external coding agent sessions into Vox threads (
2.3 6-Tier Staggered Route Racing (crates/vox-gui/ui/src/transport/routeRacer.ts)
Section titled “2.3 6-Tier Staggered Route Racing (crates/vox-gui/ui/src/transport/routeRacer.ts)”- Source Inspiration:
t3codepackages/client-runtime/src/connection.ts&packages/shared/src/route-Order.ts. - Mechanics:
- Ranks candidate daemon endpoints in priority order:
LoopbackWs (0) < LanDirect (1) < TailscaleDirect (2) < CloudflareTunnel (3) < RelayWebRtc (4) < RelayWs (5). - Races candidates with a
150msstaggered head start (STAGGER_DELAY_MS = 150): Tieri + 1starts dialing150msafter Tieriif Tierihas not yet connected, aborting slower dials as soon as the highest-priority reachable transport completes handshake. - Runs a background better-route probe every
60_000ms(BETTER_ROUTE_PROBE_INTERVAL_MS = 60_000) when connected on a lower-priority relay, with a300_000ms(5m) failure cooldown per failed candidate.
- Ranks candidate daemon endpoints in priority order:
3. Verification Gates (Phases 224–225)
Section titled “3. Verification Gates (Phases 224–225)”timeout 900s cargo test -p vox-orchestrator-mcp --lib chat_tools::chat::mentions::tests(verifying@rule:<name>manual extraction, prompt stripping, andAlwaysrule deduplication).timeout 900s cargo test -p vox-orchestrator-mcp --lib chat_tools::tests::system_prompt_variable_interpolation(verifying all 8$variablesubstitutions).timeout 900s cargo test -p vox-orchestrator-mcp --lib server_state::webhook_intake::tests(verifyingvox_crypto::keyed_hashsignature verification,webhook_dedupeidempotency, and60/minrate limit).timeout 900s cargo test -p vox-orchestrator --lib session::external_importer::tests(verifying Claude JSONL, Codex JSONL, and Cursor SQLite hex-blob session import round-trips).