F3: Kimi inference pipeline + full grok cloud-surface excision
Sampler / inference (PRD F3):
- kimi_compat.rs: single adaptation point for the Kimi chat/completions
dialect (thinking-field mapping, model_id stripping, empty-content
tool-call message fix, stream_options.include_usage), with kimi-cli
source citations
- Rate-limit handling reworked for Kimi/Moonshot semantics; UA kigi/{version}
- /models replaces the xAI models-v2 endpoint everywhere; idle model
refresh carries X-Msh-* device headers only (X-XAI-Token-Auth and
x-grok-client-mode/CLIENT_MODE_HEADER machinery deleted)
Cloud-surface excision (PRD §5, zero-egress):
- remote/ conversations lane, cli-chat-proxy-types crate, prod/ dir,
share command, credit bar: deleted (single local session lane;
paginate() replaces merge_and_paginate)
- Subscription/tier gate stack deleted end-to-end: AppView
gate/tier/team/ZDR fields, app/subscription.rs watch loop,
dispatch/billing.rs paywall + SuperGrok upsell, free-usage-exhausted
chain, tier-restricted commands, GateInfo, RemoteSettings gate fields,
SettingsUpdateNotification gate fields
- /privacy + coding-data-sharing setting deleted (backed by a dead xAI
RPC; Kigi is zero-egress — nothing to share or retain remotely)
Auth UX correctness (user-reported):
- Device-flow fixtures now mirror the live Kimi payload shape
(https://www.kimi.com/code/authorize_device?user_code=..., verified
against auth.kimi.com); the fabricated auth.kimi.com/device?code=...
URLs are gone
- open_browser_detached is a no-op under cfg(test): unit tests drove
wiremock fixture URLs into the real browser (root cause of the
"garbage mock link" ABCD-1234 tabs)
- Welcome/pager-minimal rebrand: Grok Build -> Kigi, grok.com ->
kimi.com, "Sign in to Grok" -> "Sign in to Kimi"
This commit is contained in:
@@ -43,15 +43,11 @@ pub fn test_sampler_config(
|
||||
.map(|(k, v)| (k.to_string(), v.to_string()))
|
||||
.collect(),
|
||||
context_window: 256_000,
|
||||
client_version: None,
|
||||
force_http1: false,
|
||||
max_retries: None,
|
||||
stream_tool_calls: false,
|
||||
idle_timeout_secs: None,
|
||||
client_identifier: None,
|
||||
reasoning_effort: None,
|
||||
deployment_id: None,
|
||||
user_id: None,
|
||||
origin_client: None,
|
||||
attribution_callback: None,
|
||||
bearer_resolver: None,
|
||||
|
||||
@@ -431,7 +431,7 @@ fn git_rebase_refresh_storm_e2e() {
|
||||
// serve HTTP and never read the process environment.
|
||||
unsafe {
|
||||
std::env::set_var("KIGI_SHARE_DIR", kigi_home.path());
|
||||
std::env::set_var("KIGI_CLI_CHAT_PROXY_BASE_URL", server.url());
|
||||
std::env::set_var("KIGI_CODE_BASE_URL", server.url());
|
||||
std::env::set_var("KIGI_XAI_API_BASE_URL", server.url());
|
||||
std::env::set_var("XAI_API_KEY", "test-key-for-ci");
|
||||
std::env::set_var("KIGI_TELEMETRY_ENABLED", "false");
|
||||
|
||||
@@ -625,7 +625,7 @@ async fn full_session_load_e2e() {
|
||||
std::env::set_var("KIGI_SHARE_DIR", kigi_home.path());
|
||||
std::env::set_var("KIGI_INSTRUMENTATION", "log");
|
||||
std::env::set_var("KIGI_INSTRUMENTATION_LOG", &instr_log);
|
||||
std::env::set_var("KIGI_CLI_CHAT_PROXY_BASE_URL", server.url());
|
||||
std::env::set_var("KIGI_CODE_BASE_URL", server.url());
|
||||
std::env::set_var("KIGI_XAI_API_BASE_URL", server.url());
|
||||
std::env::set_var("XAI_API_KEY", "test-key-for-ci");
|
||||
std::env::set_var("KIGI_TELEMETRY_ENABLED", "false");
|
||||
|
||||
@@ -147,7 +147,7 @@ pub fn signed_dk_body(
|
||||
requirements: Option<&str>,
|
||||
) -> String {
|
||||
let payload = SignedPayload {
|
||||
version: prod_mc_cli_chat_proxy_types::SIGNED_PAYLOAD_VERSION,
|
||||
version: kigi_config::signed_policy::SIGNED_PAYLOAD_VERSION,
|
||||
deployment_id: Some(deployment_id.to_owned()),
|
||||
team_id: None,
|
||||
managed_config: managed.map(str::to_owned),
|
||||
|
||||
@@ -38,7 +38,7 @@ async fn sync_fail_closed_policy(home: &std::path::Path, kp: &ring::signature::E
|
||||
/// provisioned key with no config row.
|
||||
fn signed_dk_empty_body(kp: &ring::signature::Ed25519KeyPair, deployment_id: &str) -> String {
|
||||
let payload = SignedPayload {
|
||||
version: prod_mc_cli_chat_proxy_types::SIGNED_PAYLOAD_VERSION,
|
||||
version: kigi_config::signed_policy::SIGNED_PAYLOAD_VERSION,
|
||||
deployment_id: Some(deployment_id.to_owned()),
|
||||
team_id: None,
|
||||
managed_config: None,
|
||||
|
||||
@@ -1267,7 +1267,7 @@ impl ConfigTestHarness {
|
||||
home,
|
||||
workdir: git_workdir(),
|
||||
env: vec![
|
||||
("KIGI_CLI_CHAT_PROXY_BASE_URL".into(), server.url()),
|
||||
("KIGI_CODE_BASE_URL".into(), server.url()),
|
||||
("KIGI_TELEMETRY_ENABLED".into(), "false".into()),
|
||||
("KIGI_FEEDBACK_ENABLED".into(), "false".into()),
|
||||
("KIGI_TRACE_UPLOAD".into(), "false".into()),
|
||||
|
||||
@@ -136,7 +136,7 @@ async fn leader_soak_churning_clients_no_leaks_no_zombies() {
|
||||
// code reads these process-globals (same pattern as session_load_perf).
|
||||
unsafe {
|
||||
std::env::set_var("KIGI_SHARE_DIR", kigi_home.path());
|
||||
std::env::set_var("KIGI_CLI_CHAT_PROXY_BASE_URL", server.url());
|
||||
std::env::set_var("KIGI_CODE_BASE_URL", server.url());
|
||||
std::env::set_var("KIGI_XAI_API_BASE_URL", server.url());
|
||||
std::env::set_var("XAI_API_KEY", "test-key-for-ci");
|
||||
std::env::set_var("KIGI_TELEMETRY_ENABLED", "false");
|
||||
|
||||
@@ -1,258 +0,0 @@
|
||||
//! Integration test: MockInferenceServer `/v1/settings` endpoint and
|
||||
//! remote settings settings refresh infrastructure.
|
||||
//!
|
||||
//! Tests the mock endpoint directly (no binary needed) and verifies
|
||||
//! the `fetch_settings_blocking` client round-trips correctly with
|
||||
//! runtime-mutated mock settings.
|
||||
//!
|
||||
//! Run locally:
|
||||
//! ```bash
|
||||
//! cargo test -p kigi-shell --test test_settings_refresh
|
||||
//! ```
|
||||
|
||||
use std::future::Future;
|
||||
|
||||
use kigi_shell::util::config::RemoteSettings;
|
||||
use kigi_test_support::*;
|
||||
|
||||
async fn with_local_set<F, Fut>(f: F)
|
||||
where
|
||||
F: FnOnce() -> Fut,
|
||||
Fut: Future<Output = ()>,
|
||||
{
|
||||
tokio::task::LocalSet::new().run_until(f()).await;
|
||||
}
|
||||
|
||||
/// Verify the mock `/v1/settings` endpoint returns 404 when no settings
|
||||
/// are configured (the default). This preserves backward compatibility:
|
||||
/// existing tests that never call `set_settings` see a 404, and
|
||||
/// `fetch_settings_blocking` returns `None`.
|
||||
#[tokio::test]
|
||||
async fn test_settings_endpoint_returns_404_when_unconfigured() {
|
||||
with_local_set(|| async {
|
||||
let server = MockInferenceServer::start()
|
||||
.await
|
||||
.expect("start mock server");
|
||||
|
||||
let resp = reqwest::get(format!("{}/settings", server.url()))
|
||||
.await
|
||||
.expect("request failed");
|
||||
assert_eq!(resp.status(), 404);
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Verify the mock `/v1/settings` endpoint returns configured settings
|
||||
/// and that `set_settings` runtime mutation is reflected immediately.
|
||||
#[tokio::test]
|
||||
async fn test_settings_endpoint_returns_configured_settings() {
|
||||
with_local_set(|| async {
|
||||
let server = MockInferenceServer::start()
|
||||
.await
|
||||
.expect("start mock server");
|
||||
|
||||
// Configure initial settings
|
||||
server.set_settings(RemoteSettings {
|
||||
tips: Some(vec!["tip_v1".into()]),
|
||||
leader_mode: Some(false),
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
// Fetch and verify
|
||||
let resp = reqwest::get(format!("{}/settings", server.url()))
|
||||
.await
|
||||
.expect("request failed");
|
||||
assert_eq!(resp.status(), 200);
|
||||
let settings: RemoteSettings = resp.json().await.expect("parse failed");
|
||||
assert_eq!(settings.tips, Some(vec!["tip_v1".into()]));
|
||||
assert_eq!(settings.leader_mode, Some(false));
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Verify that `set_settings` updates are visible to subsequent requests
|
||||
/// (runtime mutation for multi-session test scenarios).
|
||||
#[tokio::test]
|
||||
async fn test_settings_endpoint_reflects_runtime_mutations() {
|
||||
with_local_set(|| async {
|
||||
let server = MockInferenceServer::start()
|
||||
.await
|
||||
.expect("start mock server");
|
||||
|
||||
// Initial settings
|
||||
server.set_settings(RemoteSettings {
|
||||
tips: Some(vec!["tip_v1".into()]),
|
||||
..Default::default()
|
||||
});
|
||||
let settings: RemoteSettings = reqwest::get(format!("{}/settings", server.url()))
|
||||
.await
|
||||
.unwrap()
|
||||
.json()
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(settings.tips, Some(vec!["tip_v1".into()]));
|
||||
|
||||
// Mutate settings (simulating a remote feature flag change)
|
||||
server.set_settings(RemoteSettings {
|
||||
tips: Some(vec!["tip_v2".into()]),
|
||||
leader_mode: Some(true),
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
// Subsequent request sees the updated values
|
||||
let settings: RemoteSettings = reqwest::get(format!("{}/settings", server.url()))
|
||||
.await
|
||||
.unwrap()
|
||||
.json()
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(settings.tips, Some(vec!["tip_v2".into()]));
|
||||
assert_eq!(settings.leader_mode, Some(true));
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Verify `fetch_settings_blocking` round-trips through the mock server.
|
||||
/// This is the actual client function used by `refresh_remote_settings`.
|
||||
#[tokio::test]
|
||||
async fn test_fetch_settings_blocking_round_trip() {
|
||||
with_local_set(|| async {
|
||||
let server = MockInferenceServer::start()
|
||||
.await
|
||||
.expect("start mock server");
|
||||
|
||||
// Without settings configured: returns None (404 from mock)
|
||||
let auth = kigi_shell::auth::KimiAuth {
|
||||
key: "test-key".into(),
|
||||
..Default::default()
|
||||
};
|
||||
let result = tokio::task::spawn_blocking({
|
||||
let url = server.url().to_string();
|
||||
let auth = auth.clone();
|
||||
move || kigi_shell::remote::fetch_settings_blocking(&url, &auth, None)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(
|
||||
result.is_none(),
|
||||
"Expected None when settings not configured"
|
||||
);
|
||||
|
||||
// With settings configured: returns Some(settings)
|
||||
server.set_settings(RemoteSettings {
|
||||
tips: Some(vec!["fetched_tip".into()]),
|
||||
..Default::default()
|
||||
});
|
||||
let result = tokio::task::spawn_blocking({
|
||||
let url = server.url().to_string();
|
||||
let auth = auth.clone();
|
||||
move || kigi_shell::remote::fetch_settings_blocking(&url, &auth, None)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let settings = result.expect("Expected Some when settings are configured");
|
||||
assert_eq!(settings.tips, Some(vec!["fetched_tip".into()]));
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Verify the `doom_loop_recovery` settings object survives the
|
||||
/// `/v1/settings` round-trip, that its absence deserializes to `None` (old
|
||||
/// servers), and that a partial object keeps its unset fields `None`.
|
||||
#[tokio::test]
|
||||
async fn test_doom_loop_recovery_settings_round_trip() {
|
||||
use kigi_shell::util::config::DoomLoopRecoverySettings;
|
||||
|
||||
with_local_set(|| async {
|
||||
let server = MockInferenceServer::start()
|
||||
.await
|
||||
.expect("start mock server");
|
||||
|
||||
// Absent from the payload ⇒ None on the client.
|
||||
server.set_settings(RemoteSettings::default());
|
||||
let settings: RemoteSettings = reqwest::get(format!("{}/settings", server.url()))
|
||||
.await
|
||||
.unwrap()
|
||||
.json()
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(settings.doom_loop_recovery, None);
|
||||
|
||||
server.set_settings(RemoteSettings {
|
||||
doom_loop_recovery: Some(DoomLoopRecoverySettings {
|
||||
enabled: Some(true),
|
||||
max_threshold: Some(16),
|
||||
max_retries: Some(1),
|
||||
}),
|
||||
..Default::default()
|
||||
});
|
||||
let settings: RemoteSettings = reqwest::get(format!("{}/settings", server.url()))
|
||||
.await
|
||||
.unwrap()
|
||||
.json()
|
||||
.await
|
||||
.unwrap();
|
||||
let recovery = settings.doom_loop_recovery.expect("object round-trips");
|
||||
assert_eq!(recovery.enabled, Some(true));
|
||||
assert_eq!(recovery.max_threshold, Some(16));
|
||||
assert_eq!(recovery.max_retries, Some(1));
|
||||
|
||||
// Partial object: only the set field comes through; the rest stay
|
||||
// None so the resolver falls through per-field.
|
||||
server.set_settings(RemoteSettings {
|
||||
doom_loop_recovery: Some(DoomLoopRecoverySettings {
|
||||
max_threshold: Some(32),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
});
|
||||
let settings: RemoteSettings = reqwest::get(format!("{}/settings", server.url()))
|
||||
.await
|
||||
.unwrap()
|
||||
.json()
|
||||
.await
|
||||
.unwrap();
|
||||
let recovery = settings.doom_loop_recovery.expect("object round-trips");
|
||||
assert_eq!(recovery.enabled, None);
|
||||
assert_eq!(recovery.max_threshold, Some(32));
|
||||
assert_eq!(recovery.max_retries, None);
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Verify that the mock server's request log correctly tracks
|
||||
/// GET /v1/settings requests for assertion in multi-session tests.
|
||||
#[tokio::test]
|
||||
async fn test_settings_requests_appear_in_request_log() {
|
||||
with_local_set(|| async {
|
||||
let server = MockInferenceServer::start()
|
||||
.await
|
||||
.expect("start mock server");
|
||||
server.set_settings(RemoteSettings::default());
|
||||
|
||||
assert_eq!(server.request_count(), 0);
|
||||
|
||||
// First request
|
||||
let _ = reqwest::get(format!("{}/settings", server.url()))
|
||||
.await
|
||||
.unwrap();
|
||||
let settings_reqs: Vec<_> = server
|
||||
.requests()
|
||||
.into_iter()
|
||||
.filter(|r| r.method == "GET" && r.path.contains("/settings"))
|
||||
.collect();
|
||||
assert_eq!(settings_reqs.len(), 1, "Expected 1 settings request");
|
||||
|
||||
// Second request (simulating /new refresh)
|
||||
let _ = reqwest::get(format!("{}/settings", server.url()))
|
||||
.await
|
||||
.unwrap();
|
||||
let settings_reqs: Vec<_> = server
|
||||
.requests()
|
||||
.into_iter()
|
||||
.filter(|r| r.method == "GET" && r.path.contains("/settings"))
|
||||
.collect();
|
||||
assert_eq!(settings_reqs.len(), 2, "Expected 2 settings requests");
|
||||
})
|
||||
.await;
|
||||
}
|
||||
Reference in New Issue
Block a user