# Public API
```rust
use std::{future::Future, sync::Arc};
use kcode_k1_chat_core::{ChatError, ChatEvent, ChatView, Llm, Runtime};
pub trait Candidate {
type Chat: Send + Sync + 'static;
fn open(
runtime: Arc<dyn Runtime>,
initial_primary: String,
llm: Arc<dyn Llm>,
) -> (Self::Chat, tokio::sync::mpsc::UnboundedReceiver<ChatEvent>);
fn append(chat: &Self::Chat, text: String) -> impl Future<Output = Result<(), ChatError>> + Send;
fn restart(chat: &Self::Chat) -> impl Future<Output = Result<(), ChatError>> + Send;
fn view(chat: &Self::Chat) -> impl Future<Output = Result<ChatView, ChatError>> + Send;
fn finalize(chat: Self::Chat) -> impl Future<Output = Result<ChatView, ChatError>> + Send + 'static;
}
pub fn verify_initial_primary_delta_output_order_and_no_self_trigger<C: Candidate>();
pub fn verify_retry_schedule_stall_pending_and_fresh_restart<C: Candidate>();
pub fn verify_blocked_threads_are_independent<C: Candidate>();
pub fn verify_finalize_waits_closes_and_stalled_finalize_returns<C: Candidate>();
pub fn verify_dropped_text_and_activity_receivers_stall_cleanly<C: Candidate>();
```
`Candidate` only translates these operations to the candidate chat implementation. Each verifier is synchronous and one-shot: it returns when the contract holds and otherwise panics at the failing operation or assertion. Call verifiers from ordinary synchronous tests, not from an existing Tokio runtime. Each invocation creates a paused current-thread runtime, owns and releases its gates, finalizes its chats, and checks event-stream closure where applicable.
- `verify_initial_primary_delta_output_order_and_no_self_trigger` verifies initial-primary retention, empty-input rejection, exact per-object deltas, output-before-pending ordering, one text event, and absence of output-only inference. Performance: Not yet benchmarked; verifier-owned work and fixture state are bounded, while completion depends on candidate operations making cooperative progress.
- `verify_retry_schedule_stall_pending_and_fresh_restart` verifies five attempts, virtual 10/20/40/80-second retry boundaries, live attempts, same-object identical retry deltas, fifth-error stalling, pending accumulation, and a fresh full-primary restart. Performance: Not yet benchmarked; verifier-owned work and fixture state are bounded and 150 seconds are advanced virtually, while completion depends on candidate operations making cooperative progress.
- `verify_blocked_threads_are_independent` verifies that a gated inference in one chat does not impede another chat on the same current-thread executor. Performance: Not yet benchmarked; verifier-owned work and fixture state are bounded, while completion depends on candidate operations making cooperative progress.
- `verify_finalize_waits_closes_and_stalled_finalize_returns` verifies that finalization waits through queued and terminal tool results, closes events, and returns without waiting when already stalled. Performance: Not yet benchmarked; verifier-owned work and fixture state are bounded, while completion depends on candidate operations making cooperative progress.
- `verify_dropped_text_and_activity_receivers_stall_cleanly` verifies clean stalls after failed text or activity delivery, completion of active tool work, and fresh-object restart deltas. Performance: Not yet benchmarked; verifier-owned work and fixture state are bounded, while completion depends on candidate operations making cooperative progress.