§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
@@ -15,7 +15,7 @@ use crate::session::{
use crate::terminal::AsyncTerminalRunner;
use crate::tools::ToolContext;
use kigi_acp_lib::AcpAgentGatewaySender as GatewaySender;
use kigi_tools::implementations::grok_build::task::types::*;
use kigi_tools::implementations::kigi::task::types::*;
use kigi_workspace::file_system::AsyncFileSystem;
use kigi_hunk_tracker::HunkTrackerHandle;
use super::*;
@@ -156,8 +156,8 @@ impl SubagentCoordinator {
pub fn outstanding_reply_for_prompt(
&self,
prompt_id: &str,
) -> kigi_tools::implementations::grok_build::task::types::SubagentOutstandingReply {
kigi_tools::implementations::grok_build::task::types::SubagentOutstandingReply {
) -> kigi_tools::implementations::kigi::task::types::SubagentOutstandingReply {
kigi_tools::implementations::kigi::task::types::SubagentOutstandingReply {
live_ids: self.outstanding_for_prompt(prompt_id),
background_live: self.background_live_for_prompt(prompt_id),
subagent_usage_not_applied: self.subagent_usage_not_applied(prompt_id),
@@ -15,7 +15,7 @@ use crate::session::{
use crate::terminal::AsyncTerminalRunner;
use crate::tools::ToolContext;
use kigi_acp_lib::AcpAgentGatewaySender as GatewaySender;
use kigi_tools::implementations::grok_build::task::types::*;
use kigi_tools::implementations::kigi::task::types::*;
use kigi_workspace::file_system::AsyncFileSystem;
use kigi_hunk_tracker::HunkTrackerHandle;
use super::*;
@@ -323,7 +323,7 @@ impl SubagentCoordinator {
/// asynchronously after dropping the coordinator borrow.
///
/// Returns an empty `Vec` if no active subagents match the given
/// parent session ID. Callers (e.g. the `x.ai/subagent/list_running`
/// parent session ID. Callers (e.g. the `kigi/subagent/list_running`
/// ACP handler) should treat an empty result as a normal "no running
/// subagents" response, not an error.
pub(crate) fn list_running_for_parent(
@@ -15,7 +15,7 @@ use crate::session::{
use crate::terminal::AsyncTerminalRunner;
use crate::tools::ToolContext;
use kigi_acp_lib::AcpAgentGatewaySender as GatewaySender;
use kigi_tools::implementations::grok_build::task::types::*;
use kigi_tools::implementations::kigi::task::types::*;
use kigi_workspace::file_system::AsyncFileSystem;
use kigi_hunk_tracker::HunkTrackerHandle;
use super::*;
@@ -306,7 +306,7 @@ pub(crate) async fn handle_subagent_request(
subagent_id = % request.id, error = % e,
"Could not resolve worktree base dir, using temp dir for subagent worktree"
);
std::env::temp_dir().join("grok-subagent-worktrees").join(&request.id)
std::env::temp_dir().join("kigi-subagent-worktrees").join(&request.id)
}
};
let source_clone = source_cwd;
@@ -396,7 +396,7 @@ pub(crate) async fn handle_subagent_request(
);
}
{
use kigi_tools::implementations::grok_build::task::MAX_SUBAGENT_DEPTH;
use kigi_tools::implementations::kigi::task::MAX_SUBAGENT_DEPTH;
use kigi_tools::types::tool::ToolKind;
let child_depth = ctx.parent_depth + 1;
if child_depth >= MAX_SUBAGENT_DEPTH {
@@ -754,10 +754,10 @@ pub(crate) async fn handle_subagent_request(
}
}
if let Some(scope) = agent_memory_scope {
use kigi_tools::implementations::grok_build;
use kigi_tools::implementations::kigi;
use kigi_tools::implementations::opencode;
let memory_tools: Vec<kigi_tools::registry::types::ToolConfig> = vec![
(& grok_build::ReadFileTool).into(), (& grok_build::SearchReplaceTool)
(& kigi::ReadFileTool).into(), (& kigi::SearchReplaceTool)
.into(), (& opencode::OpenCodeWriteTool).into(),
];
for tc in memory_tools {
@@ -1570,7 +1570,7 @@ pub(crate) async fn handle_subagent_request(
let mut worktree_removed = false;
if let Some(ref wt_path) = worktree_path {
if snapshot_dispose_enabled {
let ref_name = format!("refs/grok/subagents/{}", request.id);
let ref_name = format!("refs/kigi/subagents/{}", request.id);
let source_repo = resolve_subagent_source_repo(&ctx);
match crate::session::worktree::snapshot_subagent_worktree(
wt_path,
@@ -23,7 +23,7 @@ use crate::tools::ToolContext;
use agent_client_protocol as acp;
use kigi_acp_lib::AcpAgentGatewaySender as GatewaySender;
use kigi_hunk_tracker::HunkTrackerHandle;
use kigi_tools::implementations::grok_build::task::types::*;
use kigi_tools::implementations::kigi::task::types::*;
use kigi_workspace::file_system::AsyncFileSystem;
use std::collections::HashMap;
use std::path::{Path, PathBuf};
@@ -197,7 +197,7 @@ pub(crate) struct SubagentSpawnContext {
/// Parent's scheduler handle. When `Some`, the subagent reuses the
/// parent's scheduler actor so scheduled tasks survive subagent exit.
pub parent_scheduler_handle:
Option<kigi_tools::implementations::grok_build::scheduler::types::SchedulerHandle>,
Option<kigi_tools::implementations::kigi::scheduler::types::SchedulerHandle>,
/// Parent's session environment variables (.envrc + color settings).
/// Shared so the child inherits the same env without re-loading.
pub session_env: Arc<HashMap<String, String>>,
@@ -207,10 +207,10 @@ pub(crate) struct SubagentSpawnContext {
/// Resolved sampling config for web_search.
pub web_search_config: kigi_tools::implementations::WebSearchConfig,
/// Resolved config for web fetch.
pub web_fetch_config: kigi_tools::implementations::grok_build::web_fetch::WebFetchConfig,
pub web_fetch_config: kigi_tools::implementations::kigi::web_fetch::WebFetchConfig,
/// Resolved config for the deploy service.
pub app_builder_deployer_config:
kigi_tools::implementations::grok_build::deploy_app::AppBuilderDeployerConfig,
kigi_tools::implementations::kigi::deploy_app::AppBuilderDeployerConfig,
/// Whether the write_file tool is enabled.
pub write_file_enabled: bool,
/// Whether goal mode (`/goal`) is enabled.
@@ -301,7 +301,7 @@ pub(crate) struct SubagentSpawnContext {
/// goes through `agent/config.rs::sampling_config_for_model`
/// which always sets that field to `None`.
pub attribution_callback: Option<kigi_sampler::SharedAttributionCallback>,
/// Parent session's agent name (e.g. "grok-build").
/// Parent session's agent name (e.g. "kigi").
pub parent_agent_name: Option<String>,
/// `agent_type` of the parent's current model — the harness-flavor fallback
/// when `parent_agent_name` is not a recognized harness, e.g. a custom
@@ -1639,12 +1639,12 @@ pub(crate) fn subagent_harness_flavor_is_representable(_agent_type: &str) -> boo
/// Apply the harness-dependent toolset/prompt re-selection to a resolved
/// agent definition.
///
/// The harness flavor (alternate vs grok-build) normally follows the PARENT
/// agent: `GrokBuildOrchestrator` parents give children
/// The harness flavor (alternate vs kigi) normally follows the PARENT
/// agent: `KigiOrchestrator` parents give children
/// the alternate harness; the orchestrator keeps children lean, and other parents
/// inherit the file-tool override (hashline vs standard). A `/goal` role may
/// pass `harness_agent_type` to OVERRIDE that flavor regardless of the parent
/// (so a grok-build session can run an alternate-harness verifier and vice-versa);
/// (so a kigi session can run an alternate-harness verifier and vice-versa);
/// `None` for every non-goal spawn ⇒ the parent decides (unchanged). The base
/// toolset stays role-dependent on `subagent_type` (general-purpose →
/// implementer, else explorer), so the role keeps a capable toolset on the
@@ -2170,7 +2170,7 @@ fn emit_subagent_notification(
.ok();
if let Some(params) = params {
let ext_notification =
acp::ExtNotification::new("x.ai/session_notification", params.into());
acp::ExtNotification::new("kigi/session_notification", params.into());
gateway.forward_fire_and_forget(ext_notification);
}
}
@@ -2224,7 +2224,7 @@ fn goal_tick_cmd_tx(
///
/// Notifications are **not** persisted to JSONL — they are transient UI
/// hints, not authoritative lifecycle events. The TUI can resync via
/// `x.ai/subagent/list_running` on reconnect.
/// `kigi/subagent/list_running` on reconnect.
fn spawn_progress_publisher(
signals_handle: crate::session::signals::SessionSignalsHandle,
gateway: GatewaySender,
@@ -2289,7 +2289,7 @@ fn spawn_progress_publisher(
}
if let Some(params) = params {
let ext_notification =
acp::ExtNotification::new("x.ai/session_notification", params.into());
acp::ExtNotification::new("kigi/session_notification", params.into());
gateway.forward_fire_and_forget(ext_notification);
}
}
@@ -119,11 +119,11 @@ fn subagent_max_turns_definition_wins_else_inherits_parent() {
fn resume_worktree_action_covers_three_outcomes() {
use super::{ResumeWorktreeAction, resume_worktree_action};
assert_eq!(
resume_worktree_action(true, Some("refs/grok/subagents/x")),
resume_worktree_action(true, Some("refs/kigi/subagents/x")),
ResumeWorktreeAction::Rehydrate
);
assert_eq!(
resume_worktree_action(false, Some("refs/grok/subagents/x")),
resume_worktree_action(false, Some("refs/kigi/subagents/x")),
ResumeWorktreeAction::Rehydrate
);
assert_eq!(resume_worktree_action(true, None), ResumeWorktreeAction::Reuse);
@@ -1099,7 +1099,7 @@ fn dummy_tracker(
force_compact: Arc::new(AtomicBool::new(false)),
permission_handle: kigi_workspace::permission::PermissionHandle::allow_all(),
attribution_callback: None,
agent_name: "grok-build".to_string(),
agent_name: "kigi".to_string(),
session_default_agent_profile: None,
allowed_subagent_types: None,
hook_registry: None,
@@ -1938,7 +1938,7 @@ async fn bootstrap_fork_live_parent_chat_state_is_forked_with_marker() {
const MARKER: &str = "UNIQUE_LIVE_FORK_MARKER_xyz789";
let req = bootstrap_test_request(true);
let mut ctx = ctx_with_toggle(HashMap::new());
let chat = spawn_test_parent_chat_state("grok-4.5");
let chat = spawn_test_parent_chat_state("kigi-4.5");
chat.replace_conversation(
vec![
ConversationItem::system("parent system"),
@@ -2127,7 +2127,7 @@ async fn handle_subagent_request_rejects_nonexistent_cwd() {
#[tokio::test]
async fn handle_subagent_request_rejects_file_as_cwd() {
let tmp_dir = tempfile::TempDir::new().unwrap();
let tmp_file = tmp_dir.path().join("grok-test-cwd-file");
let tmp_file = tmp_dir.path().join("kigi-test-cwd-file");
std::fs::write(&tmp_file, b"not a directory").unwrap();
let ctx = ctx_with_toggle(HashMap::new());
let coordinator = std::cell::RefCell::new(SubagentCoordinator::new());
@@ -2359,7 +2359,7 @@ fn subagent_await_budget_default_and_override() {
fn summarize_tool_config_uses_name_override_and_strips_namespace() {
use kigi_tools::registry::types::{ToolConfig, ToolServerConfig};
use kigi_tools::types::tool::ToolKind;
let mut read = ToolConfig::from_id("GrokBuild:read_file");
let mut read = ToolConfig::from_id("Kigi:read_file");
read.kind = Some(ToolKind::Read);
let mut read_dup = ToolConfig::from_id("Codex:read_file");
read_dup.kind = Some(ToolKind::Read);
@@ -2410,7 +2410,7 @@ fn describe_subagent_type_not_allowed_outside_allow_list() {
other => panic!("expected NotAllowed, got {other:?}"),
}
}
/// Regression: on the DEFAULT grok-build host —
/// Regression: on the DEFAULT kigi host —
/// the primary `/goal` host — the `general-purpose` toolset's only
/// file-mutator is `search_replace` (`ToolKind::Edit`); the `write`
/// tool (`ToolKind::Write`) is injection-only and absent from the
@@ -2465,7 +2465,7 @@ fn subagent_keeps_default_flavor_when_parent_model_is_non_strict() {
let mut ctx = ctx_with_toggle(HashMap::new());
ctx.parent_agent_name = Some("ai-oncall-bot".to_string());
ctx.parent_model_agent_type = Some(
BuiltinAgentName::GrokBuildPlan.as_ref().to_string(),
BuiltinAgentName::KigiPlan.as_ref().to_string(),
);
let mut def = resolve_agent_definition("general-purpose", &ctx).expect("resolves");
resolve_subagent_toolset("general-purpose", None, &ctx, &mut def);
@@ -2696,7 +2696,7 @@ async fn background_unknown_type_emits_subagent_finished_notification() {
while let Ok(msg) = gateway_rx.try_recv() {
if let kigi_acp_lib::AcpClientMessage::ExtNotification(args) = msg {
let req: &acp::ExtNotification = &args.request;
assert_eq!(req.method.as_ref(), "x.ai/session_notification");
assert_eq!(req.method.as_ref(), "kigi/session_notification");
let body = req.params.get();
assert!(body.contains("subagent_finished"));
assert!(body.contains(& subagent_id));
@@ -3090,8 +3090,8 @@ fn subagent_auth_type_rule() {
use kigi_chat_state::AuthType;
let session = acp::AuthMethodId::new(CACHED_TOKEN_AUTH_METHOD_ID);
let api_key = acp::AuthMethodId::new(XAI_API_KEY_METHOD_ID);
let byok = byok_model_entry("grok-byok");
let plain = test_model_entry("grok-plain");
let byok = byok_model_entry("kigi-byok");
let plain = test_model_entry("kigi-plain");
assert_eq!(super::subagent_auth_type(Some(& byok), & session), AuthType::ApiKey);
assert_eq!(super::subagent_auth_type(Some(& byok), & api_key), AuthType::ApiKey);
assert_eq!(
@@ -3104,14 +3104,14 @@ fn subagent_auth_type_rule() {
#[test]
fn fresh_tool_model_accepts_visible_key_and_internal_id() {
let mut models = indexmap::IndexMap::new();
models.insert("grok-3".to_string(), test_model_entry("grok-3-2025-02-15"));
models.insert("kigi-3".to_string(), test_model_entry("kigi-3-2025-02-15"));
assert!(
super::handle_request::task_model_override_error(Some("grok-3"),
super::handle_request::task_model_override_error(Some("kigi-3"),
ModelOverrideProvenance::Tool, false, & models, false,).is_none(),
"key lookup should succeed"
);
assert!(
super::handle_request::task_model_override_error(Some("grok-3-2025-02-15"),
super::handle_request::task_model_override_error(Some("kigi-3-2025-02-15"),
ModelOverrideProvenance::Tool, false, & models, false,).is_none(),
"info().model lookup should succeed"
);
@@ -3182,7 +3182,7 @@ fn fresh_tool_model_rejects_unknown_and_nonavailable_entries() {
format!("Unknown Task.model slug '{requested}'. Valid model slugs: alpha, zeta. \
Omit `model` to inherit the parent model.")
);
assert!(! error.contains("grok models"));
assert!(! error.contains("kigi models"));
}
assert!(
super::handle_request::task_model_override_error(Some("oauth-only"),
@@ -343,7 +343,7 @@ fn resumable_source_returns_info_for_completed_subagent() {
child_cwd: "/workspace".into(),
worktree_path: Some(PathBuf::from("/tmp/worktree-1")),
snapshot_ref: None,
effective_model_id: "grok-3".into(),
effective_model_id: "kigi-3".into(),
block_waited: false,
explicitly_killed: false,
},
@@ -479,16 +479,16 @@ fn snapshot_ref_field_in_meta_roundtrips() {
persona: None,
resumed_from: None,
child_cwd: None,
worktree_path: Some("/tmp/grok-wt/sa-snap".into()),
snapshot_ref: Some("refs/grok/subagent-snapshots/sa-snap".into()),
worktree_path: Some("/tmp/kigi-wt/sa-snap".into()),
snapshot_ref: Some("refs/kigi/subagent-snapshots/sa-snap".into()),
effective_model_id: None,
};
let json = serde_json::to_string(&meta).unwrap();
assert!(json.contains("snapshot_ref"));
assert!(json.contains("refs/grok/subagent-snapshots/sa-snap"));
assert!(json.contains("refs/kigi/subagent-snapshots/sa-snap"));
let parsed: SubagentMeta = serde_json::from_str(&json).unwrap();
assert_eq!(
parsed.snapshot_ref.as_deref(), Some("refs/grok/subagent-snapshots/sa-snap")
parsed.snapshot_ref.as_deref(), Some("refs/kigi/subagent-snapshots/sa-snap")
);
}
#[test]
@@ -528,7 +528,7 @@ fn snapshot_test_meta(id: &str) -> SubagentMeta {
persona: None,
resumed_from: None,
child_cwd: None,
worktree_path: Some("/tmp/grok-wt/subagent-x".into()),
worktree_path: Some("/tmp/kigi-wt/subagent-x".into()),
snapshot_ref: None,
effective_model_id: None,
}
@@ -540,14 +540,14 @@ fn update_subagent_meta_snapshot_ref_persists_to_disk() {
let dir = tempfile::TempDir::new().unwrap();
assert!(write_subagent_meta(dir.path(), & snapshot_test_meta("sa-write")));
assert!(
update_subagent_meta_snapshot_ref(dir.path(), "refs/grok/subagents/sa-write",
update_subagent_meta_snapshot_ref(dir.path(), "refs/kigi/subagents/sa-write",
"completed"), "persisting the ref into an existing meta.json must report success"
);
let data = std::fs::read_to_string(dir.path().join("meta.json")).unwrap();
let reread: SubagentMeta = serde_json::from_str(&data).unwrap();
assert_eq!(reread.snapshot_ref.as_deref(), Some("refs/grok/subagents/sa-write"));
assert_eq!(reread.snapshot_ref.as_deref(), Some("refs/kigi/subagents/sa-write"));
assert_eq!(reread.status, "completed");
assert_eq!(reread.worktree_path.as_deref(), Some("/tmp/grok-wt/subagent-x"));
assert_eq!(reread.worktree_path.as_deref(), Some("/tmp/kigi-wt/subagent-x"));
}
/// Missing meta.json → the writer reports failure (it `warn!`s), so the
/// completion path keeps the worktree instead of removing it ref-less.
@@ -555,7 +555,7 @@ fn update_subagent_meta_snapshot_ref_persists_to_disk() {
fn update_subagent_meta_snapshot_ref_reports_failure_when_meta_missing() {
let dir = tempfile::TempDir::new().unwrap();
assert!(
! update_subagent_meta_snapshot_ref(dir.path(), "refs/grok/subagents/sa-missing",
! update_subagent_meta_snapshot_ref(dir.path(), "refs/kigi/subagents/sa-missing",
"completed")
);
}
@@ -569,12 +569,12 @@ fn snapshot_ref_write_promotes_nonterminal_status_to_terminal() {
meta.status = "running".into();
assert!(write_subagent_meta(dir.path(), & meta));
assert!(
update_subagent_meta_snapshot_ref(dir.path(), "refs/grok/subagents/x",
update_subagent_meta_snapshot_ref(dir.path(), "refs/kigi/subagents/x",
"completed")
);
let data = std::fs::read_to_string(dir.path().join("meta.json")).unwrap();
let reread: SubagentMeta = serde_json::from_str(&data).unwrap();
assert_eq!(Some("refs/grok/subagents/x"), reread.snapshot_ref.as_deref());
assert_eq!(Some("refs/kigi/subagents/x"), reread.snapshot_ref.as_deref());
assert_eq!("completed", reread.status);
}
/// The coordinator setter stamps the snapshot ref onto the in-memory
@@ -600,17 +600,17 @@ async fn set_completed_snapshot_ref_updates_in_memory_entry() {
.unwrap();
assert!(before.snapshot_ref.is_none());
coordinator
.set_completed_snapshot_ref("sa-mem", "refs/grok/subagents/sa-mem".into());
.set_completed_snapshot_ref("sa-mem", "refs/kigi/subagents/sa-mem".into());
let after = coordinator
.resumable_source_for("sa-mem", "session-A", Path::new("/tmp"))
.unwrap();
assert_eq!(after.snapshot_ref.as_deref(), Some("refs/grok/subagents/sa-mem"));
assert_eq!(after.snapshot_ref.as_deref(), Some("refs/kigi/subagents/sa-mem"));
}
/// Unknown id is a no-op (entry already TTL-evicted; meta.json still holds it).
#[test]
fn set_completed_snapshot_ref_unknown_id_is_noop() {
let mut coordinator = SubagentCoordinator::new();
coordinator.set_completed_snapshot_ref("ghost", "refs/grok/subagents/ghost".into());
coordinator.set_completed_snapshot_ref("ghost", "refs/kigi/subagents/ghost".into());
assert!(
coordinator.resumable_source_for("ghost", "session-A", Path::new("/tmp"))
.is_none()
@@ -719,7 +719,7 @@ async fn completion_snapshot_sequence_persists_ref_then_removes_worktree() {
let meta_dir = temp.path().join("meta");
write_subagent_meta(&meta_dir, &snapshot_test_meta("glue-1"));
let mut coordinator = coordinator_with_completed("glue-1");
let ref_name = "refs/grok/subagents/glue-1";
let ref_name = "refs/kigi/subagents/glue-1";
let snapshot_ref = crate::session::worktree::snapshot_subagent_worktree(
&wt,
&repo,
@@ -744,7 +744,7 @@ async fn completion_snapshot_sequence_persists_ref_then_removes_worktree() {
/// the tracker-retained direct `worktree_path` plus the snapshot_ref.
#[tokio::test]
async fn gate_on_completion_clears_model_facing_worktree_path_but_resume_retains_it() {
let wt = PathBuf::from("/tmp/grok-wt/subagent-disp-1");
let wt = PathBuf::from("/tmp/kigi-wt/subagent-disp-1");
let mut coordinator = SubagentCoordinator::new();
let mut tracker = dummy_tracker("disp-1", "session-A", "explore", "task");
tracker.worktree_path = Some(wt.clone());
@@ -762,21 +762,21 @@ async fn gate_on_completion_clears_model_facing_worktree_path_but_resume_retains
}
coordinator.move_to_completed("disp-1", "task".into(), "explore".into(), result);
coordinator
.set_completed_snapshot_ref("disp-1", "refs/grok/subagents/disp-1".into());
.set_completed_snapshot_ref("disp-1", "refs/kigi/subagents/disp-1".into());
let listed = coordinator.completed.get("disp-1").expect("completed entry");
assert_eq!(None, listed.result.worktree_path);
let src = coordinator
.resumable_source_for("disp-1", "session-A", Path::new("/tmp"))
.unwrap();
assert_eq!(Some(wt), src.worktree_path);
assert_eq!(Some("refs/grok/subagents/disp-1"), src.snapshot_ref.as_deref());
assert_eq!(Some("refs/kigi/subagents/disp-1"), src.snapshot_ref.as_deref());
}
/// Gate on but the worktree was NOT removed (snapshot/persist/remove failed):
/// the model-facing `result.worktree_path` is RETAINED so the parent can still
/// locate the preserved dir.
#[tokio::test]
async fn gate_on_completion_retains_worktree_path_when_not_removed() {
let wt = PathBuf::from("/tmp/grok-wt/subagent-keep-1");
let wt = PathBuf::from("/tmp/kigi-wt/subagent-keep-1");
let mut coordinator = SubagentCoordinator::new();
coordinator.insert(dummy_tracker("keep-1", "session-A", "explore", "task"));
let mut result = SubagentResult {
@@ -817,7 +817,7 @@ async fn disposal_completes_before_subagent_is_observable() {
write_subagent_meta(&meta_dir, &snapshot_test_meta("order-1"));
let mut coordinator = SubagentCoordinator::new();
coordinator.insert(dummy_tracker("order-1", "session-A", "explore", "task"));
let ref_name = "refs/grok/subagents/order-1";
let ref_name = "refs/kigi/subagents/order-1";
let snapshot_ref = crate::session::worktree::snapshot_subagent_worktree(
&wt,
&repo,
@@ -989,7 +989,7 @@ fn resume_inherited_cwd_requires_existing_non_worktree_dir() {
};
assert_eq!(resume_inherited_cwd(Some(& present)), Some(existing.as_str()));
let missing = ResumeSourceData {
child_cwd: "/no/such/dir/grok-missing".into(),
child_cwd: "/no/such/dir/kigi-missing".into(),
..present.clone()
};
assert_eq!(resume_inherited_cwd(Some(& missing)), None);
@@ -1120,7 +1120,7 @@ fn token_estimation_accounts_for_images() {
#[test]
fn durable_fallback_roundtrips_child_cwd_and_worktree() {
let dir = std::env::temp_dir()
.join("grok-test-durable-resume")
.join("kigi-test-durable-resume")
.join(uuid::Uuid::now_v7().to_string());
let _ = std::fs::create_dir_all(&dir);
let meta = SubagentMeta {
@@ -1143,22 +1143,22 @@ fn durable_fallback_roundtrips_child_cwd_and_worktree() {
persona: Some("implementer".into()),
resumed_from: None,
child_cwd: Some("/workspace/project".into()),
worktree_path: Some("/tmp/grok-wt/sa-dur".into()),
worktree_path: Some("/tmp/kigi-wt/sa-dur".into()),
snapshot_ref: None,
effective_model_id: Some("grok-3".into()),
effective_model_id: Some("kigi-3".into()),
};
write_subagent_meta(&dir, &meta);
let data = std::fs::read_to_string(dir.join("meta.json")).unwrap();
let loaded: SubagentMeta = serde_json::from_str(&data).unwrap();
assert_eq!(loaded.child_cwd.as_deref(), Some("/workspace/project"));
assert_eq!(loaded.worktree_path.as_deref(), Some("/tmp/grok-wt/sa-dur"));
assert_eq!(loaded.worktree_path.as_deref(), Some("/tmp/kigi-wt/sa-dur"));
assert_eq!(loaded.status, "completed");
let _ = std::fs::remove_dir_all(&dir);
}
#[test]
fn durable_fallback_rejects_running_status() {
let dir = std::env::temp_dir()
.join("grok-test-durable-status")
.join("kigi-test-durable-status")
.join(uuid::Uuid::now_v7().to_string());
let parent_dir = dir.join("subagents").join("sa-running");
let _ = std::fs::create_dir_all(&parent_dir);
@@ -1227,7 +1227,7 @@ fn drain_cancelled_finish_broadcasts(
let kigi_acp_lib::AcpClientMessage::ExtNotification(args) = msg else {
continue;
};
assert_eq!(args.request.method.as_ref(), "x.ai/session_notification");
assert_eq!(args.request.method.as_ref(), "kigi/session_notification");
let notification: SessionNotification = serde_json::from_str(
args.request.params.get(),
)
@@ -1666,11 +1666,11 @@ fn resume_allows_matching_identity() {
snapshot_ref: None,
subagent_type: "general-purpose".into(),
persona: Some("implementer".into()),
model_id: Some("grok-3".into()),
model_id: Some("kigi-3".into()),
};
assert_eq!("general-purpose", source.subagent_type);
assert_eq!(Some("implementer"), source.persona.as_deref());
assert_eq!(Some("grok-3"), source.model_id.as_deref());
assert_eq!(Some("kigi-3"), source.model_id.as_deref());
}
#[test]
fn resume_identity_does_not_gate_on_model() {
@@ -1682,21 +1682,21 @@ fn resume_identity_does_not_gate_on_model() {
snapshot_ref: None,
subagent_type: "general-purpose".into(),
persona: None,
model_id: Some("grok-3".into()),
model_id: Some("kigi-3".into()),
};
assert!(
kigi_subagent_resolution::validate_resume_identity("general-purpose", None, &
source,).is_ok()
);
assert_eq!(
source.model_id.as_deref(), Some("grok-3"),
source.model_id.as_deref(), Some("kigi-3"),
"source model remains available for pinning"
);
}
#[test]
fn durable_meta_roundtrips_effective_model_id() {
let dir = std::env::temp_dir()
.join("grok-test-model-roundtrip")
.join("kigi-test-model-roundtrip")
.join(uuid::Uuid::now_v7().to_string());
let _ = std::fs::create_dir_all(&dir);
let meta = SubagentMeta {
@@ -1721,24 +1721,24 @@ fn durable_meta_roundtrips_effective_model_id() {
child_cwd: Some("/workspace".into()),
worktree_path: None,
snapshot_ref: None,
effective_model_id: Some("grok-3".into()),
effective_model_id: Some("kigi-3".into()),
};
write_subagent_meta(&dir, &meta);
let data = std::fs::read_to_string(dir.join("meta.json")).unwrap();
let loaded: SubagentMeta = serde_json::from_str(&data).unwrap();
assert_eq!(
loaded.effective_model_id.as_deref(), Some("grok-3"),
loaded.effective_model_id.as_deref(), Some("kigi-3"),
"model ID should round-trip through meta.json"
);
let _ = std::fs::remove_dir_all(&dir);
}
#[test]
fn resume_model_pinning_overrides_default_resolution() {
let source_model = Some("grok-3".to_string());
let resolved_model = "grok-light";
let source_model = Some("kigi-3".to_string());
let resolved_model = "kigi-light";
let needs_pin = source_model.as_deref() != Some(resolved_model);
assert!(needs_pin, "resolved model differs from source — pinning should trigger");
let resolved_same = "grok-3";
let resolved_same = "kigi-3";
let no_pin = source_model.as_deref() == Some(resolved_same);
assert!(no_pin, "same model — no pinning needed");
}
@@ -2108,19 +2108,19 @@ fn ctx_with_parent_chat_state(
#[tokio::test]
async fn read_parent_sampling_config_keeps_auto_catalog_id_with_routing_slug() {
let mut models = indexmap::IndexMap::new();
models.insert("auto".to_string(), test_model_entry("grok-4.5"));
let ctx = ctx_with_parent_chat_state("auto", "grok-4.5", "composer-2-fast", models);
models.insert("auto".to_string(), test_model_entry("kigi-4.5"));
let ctx = ctx_with_parent_chat_state("auto", "kigi-4.5", "composer-2-fast", models);
let (config, model_id) = read_parent_sampling_config(&ctx).await;
assert_eq!(config.model, "grok-4.5");
assert_eq!(config.model, "kigi-4.5");
assert_eq!(model_id.0.as_ref(), "auto");
}
#[tokio::test]
async fn read_parent_sampling_config_keeps_auto_when_catalog_has_slug_key_only() {
let mut models = indexmap::IndexMap::new();
models.insert("grok-4.5".to_string(), test_model_entry("grok-4.5"));
let ctx = ctx_with_parent_chat_state("auto", "grok-4.5", "auto", models);
models.insert("kigi-4.5".to_string(), test_model_entry("kigi-4.5"));
let ctx = ctx_with_parent_chat_state("auto", "kigi-4.5", "auto", models);
let (config, model_id) = read_parent_sampling_config(&ctx).await;
assert_eq!(config.model, "grok-4.5");
assert_eq!(config.model, "kigi-4.5");
assert_eq!(model_id.0.as_ref(), "auto");
}
#[tokio::test]
@@ -2161,11 +2161,11 @@ async fn read_parent_sampling_config_ignores_global_default() {
}
#[tokio::test]
async fn read_parent_sampling_config_resolves_backend_search_from_catalog() {
let mut entry = test_model_entry("grok-4.5");
let mut entry = test_model_entry("kigi-4.5");
entry.info.supports_backend_search = true;
let mut models = indexmap::IndexMap::new();
models.insert("auto".to_string(), entry);
let mut ctx = ctx_with_parent_chat_state("auto", "grok-4.5", "auto", models);
let mut ctx = ctx_with_parent_chat_state("auto", "kigi-4.5", "auto", models);
ctx.sampling_config.supports_backend_search = false;
let (config, _model_id) = read_parent_sampling_config(&ctx).await;
assert!(
@@ -2201,11 +2201,11 @@ async fn read_parent_sampling_config_fallback_resolves_backend_search_from_catal
#[tokio::test]
async fn read_parent_sampling_config_resolves_compactions_remaining_from_catalog() {
use kigi_sampling_types::CompactionsRemaining;
let mut entry = test_model_entry("grok-4.5");
let mut entry = test_model_entry("kigi-4.5");
entry.info.compactions_remaining = Some(CompactionsRemaining::Dynamic(true));
let mut models = indexmap::IndexMap::new();
models.insert("auto".to_string(), entry);
let mut ctx = ctx_with_parent_chat_state("auto", "grok-4.5", "auto", models);
let mut ctx = ctx_with_parent_chat_state("auto", "kigi-4.5", "auto", models);
ctx.sampling_config.compactions_remaining = None;
let (config, _model_id) = read_parent_sampling_config(&ctx).await;
assert_eq!(
@@ -2360,7 +2360,7 @@ async fn fork_context_pins_parent_model_over_overrides() {
#[tokio::test]
async fn resolve_subagent_inherits_parent_model_without_pins() {
use kigi_agent::config::ModelOverride;
for parent_model in ["grok-4.5", "composer-2-fast", "my-custom-byok-model"] {
for parent_model in ["kigi-4.5", "composer-2-fast", "my-custom-byok-model"] {
let mut ctx = ctx_with_toggle(HashMap::new());
ctx.sampling_config.model = parent_model.to_string();
ctx.model_id = acp::ModelId::new(parent_model);
@@ -2379,12 +2379,12 @@ async fn resolve_subagent_inherits_parent_model_without_pins() {
}
/// An explicit `[subagents.models]` pin routes the subagent to that
/// model regardless of the parent model — both a light parent
/// (`grok-4.5`) and a custom parent (`composer-2-fast`)
/// (`kigi-4.5`) and a custom parent (`composer-2-fast`)
/// honor the pin identically now that the heavy-model gate is gone.
#[tokio::test]
async fn resolve_subagent_config_override_pin_applies_for_any_parent() {
use kigi_agent::config::ModelOverride;
for parent_model in ["grok-4.5", "composer-2-fast"] {
for parent_model in ["kigi-4.5", "composer-2-fast"] {
let mut ctx = ctx_with_toggle(HashMap::new());
ctx.sampling_config.model = parent_model.to_string();
ctx.model_id = acp::ModelId::new(parent_model);
@@ -2411,8 +2411,8 @@ async fn resolve_subagent_config_override_pin_applies_for_any_parent() {
async fn resolve_subagent_agent_definition_pin_applies_for_light_parent() {
use kigi_agent::config::ModelOverride;
let mut ctx = ctx_with_toggle(HashMap::new());
ctx.sampling_config.model = "grok-4.5".to_string();
ctx.model_id = acp::ModelId::new("grok-4.5");
ctx.sampling_config.model = "kigi-4.5".to_string();
ctx.model_id = acp::ModelId::new("kigi-4.5");
ctx.available_models
.insert("pinned-model".to_string(), test_model_entry("pinned-model"));
let agent_model = ModelOverride::Override("pinned-model".to_string());
@@ -2431,8 +2431,8 @@ async fn resolve_subagent_agent_definition_pin_applies_for_light_parent() {
async fn resolve_subagent_config_override_wins_over_agent_definition() {
use kigi_agent::config::ModelOverride;
let mut ctx = ctx_with_toggle(HashMap::new());
ctx.sampling_config.model = "grok-4.5".to_string();
ctx.model_id = acp::ModelId::new("grok-4.5");
ctx.sampling_config.model = "kigi-4.5".to_string();
ctx.model_id = acp::ModelId::new("kigi-4.5");
ctx.available_models
.insert("config-pin".to_string(), test_model_entry("config-pin"));
ctx.available_models
@@ -2454,8 +2454,8 @@ async fn resolve_subagent_config_override_wins_over_agent_definition() {
async fn resolve_subagent_config_override_unknown_model_falls_through_to_inherit() {
use kigi_agent::config::ModelOverride;
let mut ctx = ctx_with_toggle(HashMap::new());
ctx.sampling_config.model = "grok-4.5".to_string();
ctx.model_id = acp::ModelId::new("grok-4.5");
ctx.sampling_config.model = "kigi-4.5".to_string();
ctx.model_id = acp::ModelId::new("kigi-4.5");
ctx.subagent_model_overrides
.insert("explore".to_string(), "does-not-exist".to_string());
let (config, model_id) = resolve_subagent_sampling_config(
@@ -2464,8 +2464,8 @@ async fn resolve_subagent_config_override_unknown_model_falls_through_to_inherit
&ctx,
)
.await;
assert_eq!(config.model, "grok-4.5");
assert_eq!(model_id.0.as_ref(), "grok-4.5");
assert_eq!(config.model, "kigi-4.5");
assert_eq!(model_id.0.as_ref(), "kigi-4.5");
}
/// An unresolvable `AgentDefinition.model` pin (model absent from
/// `available_models`) falls through to inherit the parent model.
@@ -2473,8 +2473,8 @@ async fn resolve_subagent_config_override_unknown_model_falls_through_to_inherit
async fn resolve_subagent_agent_definition_unknown_model_falls_through_to_inherit() {
use kigi_agent::config::ModelOverride;
let mut ctx = ctx_with_toggle(HashMap::new());
ctx.sampling_config.model = "grok-4.5".to_string();
ctx.model_id = acp::ModelId::new("grok-4.5");
ctx.sampling_config.model = "kigi-4.5".to_string();
ctx.model_id = acp::ModelId::new("kigi-4.5");
let agent_model = ModelOverride::Override("does-not-exist".to_string());
let (config, model_id) = resolve_subagent_sampling_config(
"explore",
@@ -2482,8 +2482,8 @@ async fn resolve_subagent_agent_definition_unknown_model_falls_through_to_inheri
&ctx,
)
.await;
assert_eq!(config.model, "grok-4.5");
assert_eq!(model_id.0.as_ref(), "grok-4.5");
assert_eq!(config.model, "kigi-4.5");
assert_eq!(model_id.0.as_ref(), "kigi-4.5");
}
#[test]
fn key_prefix_truncates_to_8_chars() {