§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:
2026-07-18 02:48:46 -04:00
parent 86e3724310
commit 6f31415ed6
1056 changed files with 8410 additions and 18307 deletions
@@ -280,7 +280,7 @@ pub struct SessionSignals {
/// Number of edit-and-retry actions (user rewinds and submits a different prompt)
pub edit_and_retry_count: u32,
// === Bash tool patterns (grok_build) ===
// === Bash tool patterns (kigi) ===
/// Number of times the bash tool was used for a bare `echo "<msg>"` (or close
/// variant). Tracked for usage statistics.
#[serde(default)]
@@ -1928,20 +1928,20 @@ mod tests {
let actor_handle = tokio::spawn(actor.run());
// Set primary model
handle.set_primary_model("grok-3");
handle.set_primary_model("kigi-3");
let snapshot = handle.snapshot().await.unwrap();
assert_eq!(snapshot.primary_model_id, Some("grok-3".to_string()));
assert_eq!(snapshot.models_used, vec!["grok-3".to_string()]);
assert_eq!(snapshot.primary_model_id, Some("kigi-3".to_string()));
assert_eq!(snapshot.models_used, vec!["kigi-3".to_string()]);
// Record additional model usage
handle.record_model_usage("grok-4");
handle.record_model_usage("grok-3"); // Duplicate
handle.record_model_usage("kigi-4");
handle.record_model_usage("kigi-3"); // Duplicate
let snapshot = handle.snapshot().await.unwrap();
assert_eq!(snapshot.models_used.len(), 2);
assert!(snapshot.models_used.contains(&"grok-3".to_string()));
assert!(snapshot.models_used.contains(&"grok-4".to_string()));
assert!(snapshot.models_used.contains(&"kigi-3".to_string()));
assert!(snapshot.models_used.contains(&"kigi-4".to_string()));
handle.shutdown();
actor_handle.await.unwrap();
@@ -2501,7 +2501,7 @@ mod tests {
"bash".to_string(),
"search_replace".to_string(),
],
vec!["grok-3".to_string(), "grok-4".to_string()],
vec!["kigi-3".to_string(), "kigi-4".to_string()],
);
let snapshot = handle.snapshot().await.unwrap();
@@ -2520,21 +2520,21 @@ mod tests {
// Model tracking (newly restored)
assert_eq!(snapshot.models_used.len(), 2);
assert!(snapshot.models_used.contains(&"grok-3".to_string()));
assert!(snapshot.models_used.contains(&"grok-4".to_string()));
assert!(snapshot.models_used.contains(&"kigi-3".to_string()));
assert!(snapshot.models_used.contains(&"kigi-4".to_string()));
// After seeding, new tool calls should accumulate correctly
handle.record_tool_call("bash"); // existing tool
handle.record_tool_call("grep"); // new tool
handle.record_model_usage("grok-3"); // existing model
handle.record_model_usage("grok-4.5"); // new model
handle.record_model_usage("kigi-3"); // existing model
handle.record_model_usage("kigi-4.5"); // new model
let snapshot = handle.snapshot().await.unwrap();
assert_eq!(snapshot.tool_call_count, 14); // 12 + 2
assert_eq!(snapshot.tools_used.len(), 4); // bash not duplicated, grep added
assert!(snapshot.tools_used.contains(&"grep".to_string()));
assert_eq!(snapshot.models_used.len(), 3); // grok-3 not duplicated, grok-5 added
assert!(snapshot.models_used.contains(&"grok-4.5".to_string()));
assert_eq!(snapshot.models_used.len(), 3); // kigi-3 not duplicated, kigi-5 added
assert!(snapshot.models_used.contains(&"kigi-4.5".to_string()));
handle.shutdown();
actor_handle.await.unwrap();
@@ -2553,7 +2553,7 @@ mod tests {
handle1.record_tool_failure("bash");
handle1.record_error();
handle1.record_assistant_message();
handle1.record_model_usage("grok-3");
handle1.record_model_usage("kigi-3");
// Record inference metrics with ITL intervals for turn 1
handle1.record_inference_metrics(InferenceLatencyStats {
@@ -2572,7 +2572,7 @@ mod tests {
handle1.record_tool_call("search_replace");
handle1.record_cancellation();
handle1.record_assistant_message();
handle1.record_model_usage("grok-4");
handle1.record_model_usage("kigi-4");
handle1.increment_turn(); // turn 3
handle1.record_tool_call("bash");
@@ -2639,14 +2639,14 @@ mod tests {
assert!(restored.tools_used.contains(&"read_file".to_string()));
assert!(restored.tools_used.contains(&"search_replace".to_string()));
assert_eq!(restored.models_used.len(), 2);
assert!(restored.models_used.contains(&"grok-3".to_string()));
assert!(restored.models_used.contains(&"grok-4".to_string()));
assert!(restored.models_used.contains(&"kigi-3".to_string()));
assert!(restored.models_used.contains(&"kigi-4".to_string()));
assert_eq!(restored.latency_sample_count, 2);
assert_eq!(restored.avg_time_to_first_token_ms, 150);
assert_eq!(restored.avg_response_time_ms, 1500);
assert_eq!(restored.min_time_to_first_token_ms, 100);
assert_eq!(restored.max_time_to_first_token_ms, 200);
// ITL stats must survive the restore (regression test for grok-critique bug)
// ITL stats must survive the restore (regression test for kigi-critique bug)
assert_eq!(
restored.itl_p50_ms, snapshot.itl_p50_ms,
"itl_p50_ms should survive restore"
@@ -2669,7 +2669,7 @@ mod tests {
assert_eq!(restored.itl_sample_count, 1);
// Phase 2b: Take a turn-end snapshot *without* recording new ITL data.
// This is the exact scenario the grok-critique bug describes: the
// This is the exact scenario the kigi-critique bug describes: the
// TakeTurnEndSnapshot handler calls update_session_itl_percentiles()
// which must NOT wipe persisted ITL p50/p99 when itl_digest is None.
handle2.increment_turn(); // turn 4 (no ITL data recorded this turn)
@@ -2694,7 +2694,7 @@ mod tests {
handle2.increment_turn(); // turn 5
handle2.record_tool_call("grep"); // new tool
handle2.record_tool_call("bash"); // existing tool (should dedup)
handle2.record_model_usage("grok-3"); // existing model (should dedup)
handle2.record_model_usage("kigi-3"); // existing model (should dedup)
handle2.record_error();
handle2.record_assistant_message();
@@ -2709,7 +2709,7 @@ mod tests {
assert_eq!(after_turn.error_count, 3); // 2 + 1
assert_eq!(after_turn.tools_used.len(), 4); // bash not duplicated, grep added
assert!(after_turn.tools_used.contains(&"grep".to_string()));
assert_eq!(after_turn.models_used.len(), 2); // grok-3 not duplicated
assert_eq!(after_turn.models_used.len(), 2); // kigi-3 not duplicated
// Latency: (100+200+300)/3 = 200
assert_eq!(after_turn.latency_sample_count, 3);
assert_eq!(after_turn.avg_time_to_first_token_ms, 200);