# P00-01: Dual REST and SSE Connections - Status: Connection isolation and 30-minute soak passed; end-to-end tray-hidden wiring remains pending - Date recorded: 2026-07-18 - MVP gate: Required before formal dual-connection development ## Objective Verify that one Tauri process can maintain independent companion and operations REST/SSE sessions while the main window is hidden, without event mixing or shared failure state. ## Environment - Host: Windows 11 x64 - Mock transport: loopback only - Rust toolchain: rustc/cargo 1.97.1 - MSVC C++ build tools: verified by native builds - Forgejo: HTTP Git reachable and baseline pushed; no CI result exists ## Minimal validation implementation The Spike is expected to provide: - Two independently constructed REST clients. - Two independently constructed SSE clients. - Local companion and operations profile bindings. - Per-session cancellation, retry, Last-Event-ID, and deduplication state. - A dual-instance Mock Gateway with health, server-info, capabilities, authentication, SSE, disconnect, and duplicate-event controls. - Sanitized metrics and state snapshots. The Rust connection object must overwrite or ignore any remote profile_id when producing a locally routed event. ## Required execution 1. Start Mock A and Mock B on loopback using dynamically allocated ports. 2. Connect both slots and confirm independent health and capability responses. 3. Stream uniquely attributable events from both mocks. 4. Inject identical conversation_id, message_id, and event payload values. 5. Inject a conflicting remote profile_id and confirm the local binding wins. 6. Replay an event_id and confirm it is delivered once. 7. Stop A, verify B continues, then repeat in the other direction. 8. Hide the main window to the tray and verify both streams continue. 9. Run a 30-minute soak and record CPU, memory, reconnect count, event count, and duplicates suppressed. ## Actual execution result Passed for the isolated connection layer. Two loopback Mock Gateways and two independent Rust GatewayClients verified local profile binding, per-slot state/cancellation/Last-Event-ID/deduplication, duplicate suppression, server identity checks, one-slot disconnect/reconnect, and continued events from the unaffected slot. The first long run completed the event loop but exposed a test-harness shutdown defect: the two SSE Response values were still alive when graceful Mock shutdown began. The run was correctly recorded as failed, the streams were explicitly dropped before shutdown, event-count output was added, and the full test was restarted from zero. The corrected soak passed after 1800.02 seconds with 1800 companion events and 1801 operations events and no server-instance cross-routing assertion. Process samples ranged from about 11.4 to 12.1 MiB working set, about 2.0 to 2.4 MiB private memory, and 1.38 seconds cumulative CPU at the final pre-exit sample. Tauri development launch, tray creation, close-to-hide handling, and process responsiveness were verified separately. P00 does not yet wire saved Gateway profiles into the application setup, so a combined end-to-end run that hides the real Tauri window while these two configured streams remain active is still pending formal connection integration. ## Log summary Commands: `cargo test --workspace` and `cargo test -p mock-gateway --test soak -- --ignored --nocapture`. Results: connection/reconnect/dedup integration tests passed; corrected soak passed with the counts and resources above. ## Known limitations - Real AstrBot Gateway compatibility is unverified. - The provisional protocol may change after a real Gateway review. - A loopback Mock does not validate TLS, proxy, certificate, or real-network behavior. ## Security impact Profile binding at the Rust connection boundary is mandatory. A merged SSE stream or remote-controlled profile identity could route an operations proposal to the wrong local policy context. ## Recommendation Keep connection ownership per slot and add deterministic clock/backoff injection for unit tests. Do not proceed to formal dual-chat UI until the isolation, failure, and soak checks have recorded results.