§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
@@ -242,7 +242,7 @@ fn rule(action: RuleAction, pattern: &str) -> PermissionRule {
#[tokio::test]
#[serial]
async fn mcp_tool_grant_persists_and_short_circuits_next_request() {
run_actor_test(ClientType::GrokPager, |handle, gw, cwd| async move {
run_actor_test(ClientType::KigiPager, |handle, gw, cwd| async move {
// First request prompts; user picks tool-scope.
gw.expect_allow_always_mcp_tool("linear__list");
let d = request(&handle, mcp("linear__list"), "1").await;
@@ -300,7 +300,7 @@ async fn mcp_tool_grant_persists_and_short_circuits_next_request() {
#[tokio::test]
#[serial]
async fn fallback_client_plain_allow_always_persists_mcp_tool() {
// Regression: Generic / GrokWeb / Extension clients
// Regression: Generic / KigiWeb / Extension clients
// submit the legacy `"always-allow"` option id. The prompter maps that
// to plain `PromptOutcome::AllowAlways`, and the manager's plain arm
// must persist tool-scope into `allowed_mcp_tools`.
@@ -362,7 +362,7 @@ async fn policy_ask_suppresses_mcp_tool_allowlist() {
make_session_id(),
gw.sender.clone(),
cwd.clone(),
ClientType::GrokPager,
ClientType::KigiPager,
Some(policy),
vec![], // deny_read_globs
vec![],
@@ -412,7 +412,7 @@ async fn policy_ask_suppresses_mcp_server_allowlist() {
make_session_id(),
gw.sender.clone(),
cwd.clone(),
ClientType::GrokPager,
ClientType::KigiPager,
Some(policy),
vec![], // deny_read_globs
vec![],
@@ -456,7 +456,7 @@ async fn policy_deny_takes_precedence_over_mcp_allowlist() {
make_session_id(),
gw.sender.clone(),
cwd.clone(),
ClientType::GrokPager,
ClientType::KigiPager,
Some(policy),
vec![], // deny_read_globs
vec![],
@@ -482,7 +482,7 @@ async fn policy_allow_short_circuits_before_mcp_allowlist() {
let policy = PermissionConfig::new(vec![rule(RuleAction::Allow, "linear__*")]);
run_actor_test_with_policy(
ClientType::GrokPager,
ClientType::KigiPager,
Some(policy),
|handle, _gw, _cwd| async move {
let d = request(&handle, mcp("linear__list"), "1").await;
@@ -499,7 +499,7 @@ async fn empty_server_prefix_falls_back_to_tool_scope() {
// somehow makes it through, the prompter must downgrade to tool-scope
// and persist via `AllowAlwaysMcpTool` — never write an empty server
// prefix into `allowed_mcp_servers`.
run_actor_test(ClientType::GrokPager, |handle, gw, cwd| async move {
run_actor_test(ClientType::KigiPager, |handle, gw, cwd| async move {
let meta = serde_json::json!({
"kind": "server",
"server": "",
@@ -531,7 +531,7 @@ async fn allow_always_mcp_tool_ignores_client_supplied_tool_name() {
// only. The manager MUST persist the name from `AccessKind::MCPTool`
// so a buggy or malicious client cannot whitelist a different tool
// than the one the user saw in the prompt.
run_actor_test(ClientType::GrokPager, |handle, gw, cwd| async move {
run_actor_test(ClientType::KigiPager, |handle, gw, cwd| async move {
// Request approves `linear__list`, but the response claims a
// different tool name (e.g. `notion__fetch`).
let meta = serde_json::json!({
@@ -571,7 +571,7 @@ async fn allow_always_mcp_server_rejects_mismatched_prefix() {
// canonical server prefix derived from the access kind. On mismatch,
// the manager downgrades to tool-scope on the access-kind name -- the
// smallest blast radius the user actually approved.
run_actor_test(ClientType::GrokPager, |handle, gw, cwd| async move {
run_actor_test(ClientType::KigiPager, |handle, gw, cwd| async move {
// Approve `linear__list` (canonical server prefix is `linear`),
// but the client claims `notion` as the server.
let meta = serde_json::json!({
@@ -613,7 +613,7 @@ async fn allow_always_mcp_server_rejects_mismatched_prefix() {
async fn allow_always_mcp_server_persists_canonical_prefix_on_match() {
// Sanity: a client that supplies the correct canonical prefix
// succeeds (this is the common case post-fix).
run_actor_test(ClientType::GrokPager, |handle, gw, cwd| async move {
run_actor_test(ClientType::KigiPager, |handle, gw, cwd| async move {
let meta = serde_json::json!({
"kind": "server",
"server": "linear",
@@ -645,7 +645,7 @@ async fn allow_always_mcp_server_downgrades_when_access_has_no_separator() {
// malformed `ToolInput::MCPTool`), the canonical prefix is None and
// server-scope is unreachable. The manager downgrades to tool-scope
// on the raw access name rather than persisting the client prefix.
run_actor_test(ClientType::GrokPager, |handle, gw, cwd| async move {
run_actor_test(ClientType::KigiPager, |handle, gw, cwd| async move {
let meta = serde_json::json!({
"kind": "server",
"server": "linear",
@@ -681,7 +681,7 @@ async fn dont_ask_policy_denies_without_prompting() {
// No scripted gateway responses: if the manager tried to prompt,
// the gateway would block forever, proving dont_ask short-circuits.
run_actor_test_with_policy(
ClientType::GrokPager,
ClientType::KigiPager,
Some(policy),
|handle, _gw, _cwd| async move {
let d = request(&handle, mcp("linear__list"), "1").await;
@@ -716,7 +716,7 @@ async fn deny_rule_enforced_in_yolo_mode_bash() {
}]);
run_actor_test_full(
ClientType::GrokPager,
ClientType::KigiPager,
Some(policy),
true,
|handle, _gw, _cwd| async move {
@@ -752,7 +752,7 @@ async fn deny_rule_enforced_in_yolo_mode_mcp() {
}]);
run_actor_test_full(
ClientType::GrokPager,
ClientType::KigiPager,
Some(policy),
true,
|handle, _gw, _cwd| async move {
@@ -783,7 +783,7 @@ async fn deny_rule_enforced_in_yolo_mode_edit() {
}]);
run_actor_test_full(
ClientType::GrokPager,
ClientType::KigiPager,
Some(policy),
true,
|handle, _gw, _cwd| async move {
@@ -814,7 +814,7 @@ async fn deny_rule_enforced_in_yolo_mode_web_fetch() {
}]);
run_actor_test_full(
ClientType::GrokPager,
ClientType::KigiPager,
Some(policy),
true,
|handle, _gw, _cwd| async move {
@@ -848,7 +848,7 @@ async fn deny_rule_enforced_in_yolo_mode_web_fetch() {
#[serial]
async fn yolo_mode_without_deny_rules_approves_everything() {
run_actor_test_full(
ClientType::GrokPager,
ClientType::KigiPager,
None,
true,
|handle, _gw, _cwd| async move {