§9 acceptance: grep-zero sweep — every internal x.ai/grok identifier renamed

The PRD's first acceptance gate now holds: grep -RinE '\bx\.ai\b|grok'
crates/ --include='*.rs' → 0 matches (exempt: NOTICE and third-party
license archives, README provenance, and the required 'Based on Grok
Build Open Source' attribution, now sourced from version_attribution.txt).

Wire-visible renames (both sides in this repo, changed in lockstep):
- Auth method id 'grok.com' → 'kimi-code' (AuthMethodKind::KimiCode).
- Every x.ai/* and _x.ai/* ACP ext method and meta key → kigi/* /
  _kigi/* (~200 names; grokShell → kigiShell). Session-file replay keeps
  a read-side alias for the legacy '_x.ai/session/update' method so
  existing updates.jsonl histories load; writes emit only the new name
  (both directions test-pinned).
- Agent types grok-build* → kigi* with a documented legacy-prefix alias
  at resolution time so persisted sessions keep resolving.
- ToolNamespace/BuiltinAgentName GrokBuild* → Kigi* (wire snake_case
  kigi/kigi_concise/kigi_hashline; schema regenerated); grok_build
  implementation dirs renamed to kigi*.
- x-grok-* headers → x-kigi-*, __GROK_* sentinels → __KIGI_*, themes
  grokday/groknight → kigiday/kiginight (old persisted values fall back
  to the default theme), web_fetch allowlist xAI hosts → kimi.com +
  moonshot platforms, changelog CDN → this repo, grok-build changelog
  archives deleted.
- BYOK default endpoint removed: [endpoints] api_base_url is now truly
  optional with NO default — consumers fail fast with the flag name when
  unset (no silent x.ai egress). Mock harnesses inject it explicitly.
- System-prompt identity fixed: 'released by xAI' → 'an unofficial
  community CLI for Kimi' (template + regenerated encrypted form).

Also repaired pre-existing grok-era test debt found by the sweep: the
stale trace_classify default-model pin, the grok-pager UA label test,
pty-harness stale-binary reuse and non-hermetic moonshot routing (a PTY
test could previously reach the real api.moonshot.cn), and the outdated
oauth fixture scope key.

Gates: §9 grep 0; fmt clean; workspace check/clippy 0/0 (-D warnings);
FULL cargo test --workspace: 234 suites, 21,961 passed, 0 failed;
deny advisories ok.
This commit is contained in:
ZacharyZhang-NY committed 2026-07-18 02:48:46 -04:00
1 parent 86e3724310
commit 6f31415ed6
1056 files changed
+8410 -18307

No files matched your search

@@ -1,7 +1,7 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
use super::*;
/// Regression: a machine-wide `x.ai/models/update` broadcast
/// Regression: a machine-wide `kigi/models/update` broadcast
/// carries each model's static catalog-default effort (`high`), not the
/// session's chosen `xhigh`, and must not clobber the per-session choice.
#[test]
@@ -44,20 +44,20 @@
let mut app = make_app_with_agent("sess-1");
let agent = app.agents.get_mut(&AgentId(0)).unwrap();
let id_3 = acp::ModelId::new(std::sync::Arc::from("grok-3"));
let id_3 = acp::ModelId::new(std::sync::Arc::from("kigi-3"));
agent
.session
.models
.available
.insert(id_3.clone(), make_model_info("grok-3"));
.insert(id_3.clone(), make_model_info("kigi-3"));
agent.session.models.current = Some(id_3);
let notif = make_models_update_notif("grok-4", &["grok-3", "grok-4"]);
let notif = make_models_update_notif("kigi-4", &["kigi-3", "kigi-4"]);
handle_models_update(&notif, &mut app);
assert_eq!(
app.models.current.as_ref().map(|id| id.0.as_ref()),
Some("grok-3"),
Some("kigi-3"),
"app.models.current must preserve active agent's model, not remote settings default"
);
@@ -69,7 +69,7 @@
.current
.as_ref()
.map(|id| id.0.as_ref()),
Some("grok-3"),
Some("kigi-3"),
"agent's per-session model must be preserved"
);
}
@@ -79,21 +79,21 @@
let mut app = make_app_with_agent("sess-1");
let agent = app.agents.get_mut(&AgentId(0)).unwrap();
let id_3 = acp::ModelId::new(std::sync::Arc::from("grok-3"));
let id_3 = acp::ModelId::new(std::sync::Arc::from("kigi-3"));
agent
.session
.models
.available
.insert(id_3.clone(), make_model_info("grok-3"));
.insert(id_3.clone(), make_model_info("kigi-3"));
agent.session.models.current = Some(id_3);
// grok-3 removed from catalog.
let notif = make_models_update_notif("grok-4.3", &["grok-4.3", "grok-4.5"]);
// kigi-3 removed from catalog.
let notif = make_models_update_notif("kigi-4.3", &["kigi-4.3", "kigi-4.5"]);
handle_models_update(&notif, &mut app);
assert_eq!(
app.models.current.as_ref().map(|id| id.0.as_ref()),
Some("grok-4.3"),
Some("kigi-4.3"),
"app.models.current must use shell default when agent model removed"
);
@@ -105,7 +105,7 @@
.current
.as_ref()
.map(|id| id.0.as_ref()),
Some("grok-4.3"),
Some("kigi-4.3"),
"agent must fall back to shell default when its model is removed"
);
}
@@ -115,12 +115,12 @@
let (tx, _rx) = tokio::sync::mpsc::unbounded_channel();
let mut app = AppView::new(tx, ModelState::default(), Vec::new());
let notif = make_models_update_notif("grok-4", &["grok-3", "grok-4"]);
let notif = make_models_update_notif("kigi-4", &["kigi-3", "kigi-4"]);
handle_models_update(&notif, &mut app);
assert_eq!(
app.models.current.as_ref().map(|id| id.0.as_ref()),
Some("grok-4"),
Some("kigi-4"),
"without an active agent, shell default must be used"
);
}
@@ -130,21 +130,21 @@
let mut app = make_app_with_agent("sess-1");
let agent = app.agents.get_mut(&AgentId(0)).unwrap();
let id_4 = acp::ModelId::new(std::sync::Arc::from("grok-4"));
let id_4 = acp::ModelId::new(std::sync::Arc::from("kigi-4"));
agent
.session
.models
.available
.insert(id_4.clone(), make_model_info("grok-4"));
.insert(id_4.clone(), make_model_info("kigi-4"));
agent.session.models.current = Some(id_4);
let notif = make_models_update_notif("grok-4", &["grok-3", "grok-4"]);
let notif = make_models_update_notif("kigi-4", &["kigi-3", "kigi-4"]);
handle_models_update(&notif, &mut app);
assert_eq!(
app.models.current.as_ref().map(|id| id.0.as_ref()),
Some("grok-4"),
"app.models.current must be grok-4 when agent and shell agree"
Some("kigi-4"),
"app.models.current must be kigi-4 when agent and shell agree"
);
let agent = app.agents.get(&AgentId(0)).unwrap();
assert_eq!(
@@ -154,8 +154,8 @@
.current
.as_ref()
.map(|id| id.0.as_ref()),
Some("grok-4"),
"agent model must remain grok-4"
Some("kigi-4"),
"agent model must remain kigi-4"
);
}
@@ -166,33 +166,33 @@
{
let agent_a = app.agents.get_mut(&AgentId(0)).unwrap();
let id_3 = acp::ModelId::new(std::sync::Arc::from("grok-3"));
let id_3 = acp::ModelId::new(std::sync::Arc::from("kigi-3"));
agent_a
.session
.models
.available
.insert(id_3.clone(), make_model_info("grok-3"));
.insert(id_3.clone(), make_model_info("kigi-3"));
agent_a.session.models.current = Some(id_3);
}
{
let agent_b = app.agents.get_mut(&AgentId(1)).unwrap();
let id_5 = acp::ModelId::new(std::sync::Arc::from("grok-4.5"));
let id_5 = acp::ModelId::new(std::sync::Arc::from("kigi-4.5"));
agent_b
.session
.models
.available
.insert(id_5.clone(), make_model_info("grok-4.5"));
.insert(id_5.clone(), make_model_info("kigi-4.5"));
agent_b.session.models.current = Some(id_5);
}
// grok-5 removed from catalog.
let notif = make_models_update_notif("grok-4", &["grok-3", "grok-4"]);
// kigi-5 removed from catalog.
let notif = make_models_update_notif("kigi-4", &["kigi-3", "kigi-4"]);
handle_models_update(&notif, &mut app);
assert_eq!(
app.models.current.as_ref().map(|id| id.0.as_ref()),
Some("grok-3"),
Some("kigi-3"),
);
let agent_a = app.agents.get(&AgentId(0)).unwrap();
assert_eq!(
@@ -202,11 +202,11 @@
.current
.as_ref()
.map(|id| id.0.as_ref()),
Some("grok-3"),
Some("kigi-3"),
"agent A's model must be preserved"
);
// B's grok-5 was removed — must fall back to shell's grok-4, not A's grok-3.
// B's kigi-5 was removed — must fall back to shell's kigi-4, not A's kigi-3.
let agent_b = app.agents.get(&AgentId(1)).unwrap();
assert_eq!(
agent_b
@@ -215,7 +215,7 @@
.current
.as_ref()
.map(|id| id.0.as_ref()),
Some("grok-4"),
Some("kigi-4"),
"inactive agent must fall back to shell default, not active agent's model"
);
}
@@ -228,12 +228,12 @@
fn model_changed_updates_state_silently_on_follower() {
let mut app = make_app_with_agent("sess-1");
let agent = app.agents.get_mut(&AgentId(0)).unwrap();
seed_models(agent, "grok-3", &["grok-3", "grok-4"]);
seed_models(agent, "kigi-3", &["kigi-3", "kigi-4"]);
let scrollback_before = agent.scrollback.len();
// Follower: no local switch in flight.
assert!(!agent.session.model_switch_pending);
let notif = model_changed_ext("sess-1", "grok-4", None);
let notif = model_changed_ext("sess-1", "kigi-4", None);
let changed = handle_ext_notification(&notif, &mut app);
assert!(
changed,
@@ -248,7 +248,7 @@
.current
.as_ref()
.map(|id| id.0.as_ref()),
Some("grok-4"),
Some("kigi-4"),
"follower must mirror the remote switch into its local model state",
);
assert_eq!(
@@ -325,13 +325,13 @@
fn model_changed_skipped_when_local_switch_in_flight() {
let mut app = make_app_with_agent("sess-1");
let agent = app.agents.get_mut(&AgentId(0)).unwrap();
seed_models(agent, "grok-3", &["grok-3", "grok-4"]);
seed_models(agent, "kigi-3", &["kigi-3", "kigi-4"]);
// Invoker: a local switch is in flight (set by Action::SwitchModel /
// set_default_model before the SetSessionModelRequest is sent).
agent.session.model_switch_pending = true;
let scrollback_before = agent.scrollback.len();
let notif = model_changed_ext("sess-1", "grok-4", None);
let notif = model_changed_ext("sess-1", "kigi-4", None);
let changed = handle_ext_notification(&notif, &mut app);
assert!(
!changed,
@@ -346,7 +346,7 @@
.current
.as_ref()
.map(|id| id.0.as_ref()),
Some("grok-3"),
Some("kigi-3"),
"models.current must stay at the pre-response snapshot — \
SwitchModelComplete owns the final apply + system message"
);
@@ -370,9 +370,9 @@
fn model_changed_dropped_when_model_unknown_to_catalog() {
let mut app = make_app_with_agent("sess-1");
let agent = app.agents.get_mut(&AgentId(0)).unwrap();
seed_models(agent, "grok-3", &["grok-3", "grok-4"]);
seed_models(agent, "kigi-3", &["kigi-3", "kigi-4"]);
let notif = model_changed_ext("sess-1", "grok-99-unknown", None);
let notif = model_changed_ext("sess-1", "kigi-99-unknown", None);
let changed = handle_ext_notification(&notif, &mut app);
assert!(
!changed,
@@ -387,7 +387,7 @@
.current
.as_ref()
.map(|id| id.0.as_ref()),
Some("grok-3"),
Some("kigi-3"),
"models.current must stay on the previously-known model"
);
}
@@ -395,15 +395,15 @@
/// `reasoning_effort` round-trips through the broadcast: the follower
/// applies it alongside the model id so the prompt header / status bar
/// show the right effort without waiting for a subsequent
/// `x.ai/models/update`.
/// `kigi/models/update`.
#[test]
fn model_changed_applies_reasoning_effort_on_follower() {
use kigi_shell::sampling::types::ReasoningEffort;
let mut app = make_app_with_agent("sess-1");
let agent = app.agents.get_mut(&AgentId(0)).unwrap();
seed_models(agent, "grok-3", &["grok-3", "grok-4"]);
seed_models(agent, "kigi-3", &["kigi-3", "kigi-4"]);
let notif = model_changed_ext("sess-1", "grok-4", Some("high"));
let notif = model_changed_ext("sess-1", "kigi-4", Some("high"));
assert!(handle_ext_notification(&notif, &mut app));
let agent = app.agents.get(&AgentId(0)).unwrap();
@@ -423,9 +423,9 @@
fn model_changed_dropped_for_unknown_session_id() {
let mut app = make_app_with_agent("sess-1");
let agent = app.agents.get_mut(&AgentId(0)).unwrap();
seed_models(agent, "grok-3", &["grok-3", "grok-4"]);
seed_models(agent, "kigi-3", &["kigi-3", "kigi-4"]);
let notif = model_changed_ext("sess-OTHER", "grok-4", None);
let notif = model_changed_ext("sess-OTHER", "kigi-4", None);
let changed = handle_ext_notification(&notif, &mut app);
assert!(!changed);
@@ -437,7 +437,7 @@
.current
.as_ref()
.map(|id| id.0.as_ref()),
Some("grok-3"),
Some("kigi-3"),
"unrelated-session broadcast must not touch this agent's model"
);
}