§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:
@@ -7,7 +7,7 @@
|
||||
//!
|
||||
//! The three **common** active-agent sections (background tasks, TODO list,
|
||||
//! running subagents) are formatted by
|
||||
//! [`kigi_compaction::reminder`] so grok-chat and grok-build stay in lockstep.
|
||||
//! [`kigi_compaction::reminder`] so kigi-chat and kigi stay in lockstep.
|
||||
//! Harness-only sections (edited files, AGENTS.md, skills, MCP, memory) stay here.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//! grok-build's L5 wiring onto the shared full-replace engine
|
||||
//! kigi's L5 wiring onto the shared full-replace engine
|
||||
//! (`kigi_compaction::code_compaction`).
|
||||
//!
|
||||
//! The shared engine drives the sample → retry → degenerate/failure
|
||||
//! classification loop via [`sample_full_replace_summary`](kigi_compaction::sample_full_replace_summary);
|
||||
//! this module adapts grok-build's transport and telemetry to its two seams:
|
||||
//! this module adapts kigi's transport and telemetry to its two seams:
|
||||
//!
|
||||
//! - [`ShellCompactionSampler`] wraps
|
||||
//! [`generate_session_compact`](crate::session::helpers::session_compact::generate_session_compact)
|
||||
@@ -42,7 +42,7 @@ use crate::session::helpers::session_compact::{
|
||||
};
|
||||
|
||||
/// Wraps `generate_session_compact` as the shared engine's
|
||||
/// [`CompactionSampler`] for grok-build's full-replace pass.
|
||||
/// [`CompactionSampler`] for kigi's full-replace pass.
|
||||
///
|
||||
/// Holds the per-call request context the seam does not carry (tools, client,
|
||||
/// session, config) and stashes the last successful [`CompactOutput`] so the
|
||||
@@ -51,8 +51,8 @@ use crate::session::helpers::session_compact::{
|
||||
///
|
||||
/// The summarization prompt is selected here by `use_short_prompt` (the
|
||||
/// short-prompt harness uses the short self-summarization prompt; everyone
|
||||
/// else the structured grok-build prompt), so the shared `CompactionPrompt`
|
||||
/// the engine passes is ignored — the engine builds the grok-build prompt,
|
||||
/// else the structured kigi prompt), so the shared `CompactionPrompt`
|
||||
/// the engine passes is ignored — the engine builds the kigi prompt,
|
||||
/// which equals what `build_compaction_chat_history(.., false)` appends, and
|
||||
/// the short-prompt harness needs its own variant the engine can't produce.
|
||||
pub(crate) struct ShellCompactionSampler {
|
||||
@@ -118,7 +118,7 @@ impl CompactionSampler for ShellCompactionSampler {
|
||||
_timeout: Duration,
|
||||
) -> Result<LlmCompactionOutput, CompactionSampleError> {
|
||||
// Append the harness-selected summarization prompt as the final user
|
||||
// message (compat short vs structured grok-build), ignoring the shared
|
||||
// message (compat short vs structured kigi), ignoring the shared
|
||||
// engine's `_prompt` (see the struct doc).
|
||||
let chat_history = build_compaction_chat_history(
|
||||
turns.to_vec(),
|
||||
@@ -151,7 +151,7 @@ impl CompactionSampler for ShellCompactionSampler {
|
||||
}
|
||||
}
|
||||
|
||||
/// Map grok-build's [`CompactFailure`] onto the shared engine's
|
||||
/// Map kigi's [`CompactFailure`] onto the shared engine's
|
||||
/// [`CompactionSampleError`] so the shared retry loop classifies it the same
|
||||
/// way the in-shell loop did:
|
||||
///
|
||||
@@ -207,7 +207,7 @@ struct ObserverState {
|
||||
last_error_msg: Option<String>,
|
||||
}
|
||||
|
||||
/// [`FullReplaceObserver`] that reproduces grok-build's per-attempt telemetry:
|
||||
/// [`FullReplaceObserver`] that reproduces kigi's per-attempt telemetry:
|
||||
/// `CompactionAttempt` rows, rejection counters, the `CompactionRetryDegraded`
|
||||
/// event, and the warn/error tracing — without the shared engine depending on
|
||||
/// a telemetry backend.
|
||||
|
||||
@@ -328,7 +328,7 @@ mod tests {
|
||||
.as_deref(),
|
||||
Some(default_suggest_model())
|
||||
);
|
||||
// OAuth catalogs exclude grok-build-0.1 → skip the request entirely,
|
||||
// OAuth catalogs exclude kigi-0.1 → skip the request entirely,
|
||||
// never a doomed call (and never the session model).
|
||||
assert_eq!(
|
||||
effective_suggest_model(&Pin::Unpinned, None, |_| false),
|
||||
|
||||
@@ -61,7 +61,10 @@ pub fn find_latest_compaction_checkpoint(
|
||||
continue;
|
||||
};
|
||||
|
||||
if env.method != Some("_x.ai/session/update") {
|
||||
if !env
|
||||
.method
|
||||
.is_some_and(crate::session::storage::is_ext_session_update_method)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ use reqwest::StatusCode;
|
||||
/// `<summary_request>` only -- the surrounding `<user_query>` is implicit
|
||||
/// because we push this as a `ConversationItem::user`.
|
||||
///
|
||||
/// All other agents (grok-build, etc.) continue to use the detailed
|
||||
/// All other agents (kigi, etc.) continue to use the detailed
|
||||
/// structured prompt built inline in `generate_session_compact`.
|
||||
pub(crate) const SELF_SUMMARIZATION_PROMPT: &str = r#"<summary_request>
|
||||
Please summarize the conversation so far. This summary (everything after your
|
||||
@@ -376,10 +376,10 @@ pub(crate) async fn generate_session_compact(
|
||||
.with_tool_choice(ToolChoice::none());
|
||||
}
|
||||
let sid = session_id.to_string();
|
||||
message.x_grok_conv_id = Some(sid.clone());
|
||||
message.x_grok_req_id = Some(format!("xai-compact-{}", uuid::Uuid::new_v4()));
|
||||
message.x_grok_session_id = Some(sid);
|
||||
message.x_grok_agent_id = Some(crate::util::agent_id::agent_id());
|
||||
message.x_kigi_conv_id = Some(sid.clone());
|
||||
message.x_kigi_req_id = Some(format!("xai-compact-{}", uuid::Uuid::new_v4()));
|
||||
message.x_kigi_session_id = Some(sid);
|
||||
message.x_kigi_agent_id = Some(crate::util::agent_id::agent_id());
|
||||
tracing::info!(
|
||||
compact_model = % sampling_config.model, num_messages = num_messages,
|
||||
"Sending compact request (streaming)"
|
||||
@@ -471,10 +471,10 @@ pub(crate) async fn generate_session_compact(
|
||||
hosted_tools,
|
||||
model: Some(sampling_config.model.to_owned()),
|
||||
temperature: Some(1.0),
|
||||
x_grok_conv_id: Some(session_id.to_string()),
|
||||
x_grok_req_id: Some(format!("xai-compact-{}", uuid::Uuid::new_v4())),
|
||||
x_grok_session_id: Some(session_id.to_string()),
|
||||
x_grok_agent_id: Some(crate::util::agent_id::agent_id()),
|
||||
x_kigi_conv_id: Some(session_id.to_string()),
|
||||
x_kigi_req_id: Some(format!("xai-compact-{}", uuid::Uuid::new_v4())),
|
||||
x_kigi_session_id: Some(session_id.to_string()),
|
||||
x_kigi_agent_id: Some(crate::util::agent_id::agent_id()),
|
||||
..Default::default()
|
||||
};
|
||||
let stream_result = client.conversation_stream_responses(request).await;
|
||||
@@ -593,10 +593,10 @@ pub(crate) async fn generate_session_compact(
|
||||
hosted_tools,
|
||||
model: Some(sampling_config.model.to_owned()),
|
||||
temperature: Some(1.0),
|
||||
x_grok_conv_id: Some(session_id.to_string()),
|
||||
x_grok_req_id: Some(format!("xai-compact-{}", uuid::Uuid::new_v4())),
|
||||
x_grok_session_id: Some(session_id.to_string()),
|
||||
x_grok_agent_id: Some(crate::util::agent_id::agent_id()),
|
||||
x_kigi_conv_id: Some(session_id.to_string()),
|
||||
x_kigi_req_id: Some(format!("xai-compact-{}", uuid::Uuid::new_v4())),
|
||||
x_kigi_session_id: Some(session_id.to_string()),
|
||||
x_kigi_agent_id: Some(crate::util::agent_id::agent_id()),
|
||||
..Default::default()
|
||||
};
|
||||
let stream_result = client.conversation_stream_messages(request).await;
|
||||
@@ -1127,13 +1127,13 @@ mod compacted_history_shape_tests {
|
||||
);
|
||||
assert_eq!(compacted.len(), 5);
|
||||
}
|
||||
/// Regression guard: grok-build must DROP the working
|
||||
/// tail post-compaction. A prior change routed grok-build to keep `recent_messages`,
|
||||
/// Regression guard: kigi must DROP the working
|
||||
/// tail post-compaction. A prior change routed kigi to keep `recent_messages`,
|
||||
/// which survive only as `Tool call omitted...` stubs (dead tokens). Mirrors
|
||||
/// `summary_before_recent_compaction_with_no_user_query_yields_three_messages` for grok-build
|
||||
/// `summary_before_recent_compaction_with_no_user_query_yields_three_messages` for kigi
|
||||
/// (`summary_before_recent = false`).
|
||||
#[tokio::test]
|
||||
async fn grok_build_compaction_drops_working_tail_regression_206460() {
|
||||
async fn kigi_compaction_drops_working_tail_regression_206460() {
|
||||
let conversation = vec![
|
||||
ConversationItem::system("You are a helpful assistant."),
|
||||
ConversationItem::user(
|
||||
@@ -1163,7 +1163,7 @@ mod compacted_history_shape_tests {
|
||||
let dropped = full.for_compaction();
|
||||
assert!(
|
||||
dropped.recent_messages.is_empty(),
|
||||
"grok-build must drop recent_messages post-compaction",
|
||||
"kigi must drop recent_messages post-compaction",
|
||||
);
|
||||
let compacted = build_compacted_history(
|
||||
"You are a helpful assistant.",
|
||||
@@ -1177,7 +1177,7 @@ mod compacted_history_shape_tests {
|
||||
.iter()
|
||||
.any(|i| matches!(i, ConversationItem::ToolResult(_))
|
||||
|| i.text_content() == "Tool call omitted..."),
|
||||
"no tail (ToolResult or stub) may leak into the grok-build compacted history",
|
||||
"no tail (ToolResult or stub) may leak into the kigi compacted history",
|
||||
);
|
||||
}
|
||||
/// Verify that the auto-continue prompt (sent after compaction) is also
|
||||
|
||||
@@ -62,7 +62,7 @@ pub(crate) fn recap_instruction(tag: &str) -> String {
|
||||
/// 1. Optionally strips reasoning/thinking blocks (`strip_reasoning`). This is
|
||||
/// only needed on the Anthropic Messages backend, which rejects thinking
|
||||
/// blocks sent without a top-level `thinking` config. Every other backend
|
||||
/// (grok/SGLang via ChatCompletions/Responses) keeps reasoning VERBATIM so
|
||||
/// (kigi/SGLang via ChatCompletions/Responses) keeps reasoning VERBATIM so
|
||||
/// the conversation prefix is byte-identical to the last turn and the
|
||||
/// provider's prefix KV cache stays warm — which is the whole reason we
|
||||
/// append the instruction after the prefix. Mirrors compaction's
|
||||
@@ -89,7 +89,7 @@ pub(crate) fn build_recap_items(
|
||||
}
|
||||
|
||||
/// Cap on the effective context window for recap budgeting: the verified
|
||||
/// `max_prompt_length` for current `grok-build` / `grok-4.5` product backends
|
||||
/// `max_prompt_length` for current `kigi` / `kigi-4.5` product backends
|
||||
/// (`500000`). Applied via `min(window, CAP)`, so a smaller real window still
|
||||
/// wins (e.g. a 256k legacy model or a debug override).
|
||||
const RECAP_CONTEXT_WINDOW_CAP: u64 = 500_000;
|
||||
@@ -110,10 +110,10 @@ const RECAP_BUDGET_HEADROOM_TOKENS: u64 = 4_000;
|
||||
/// `ic_400_prompt_too_long` on long sessions. Not an absolute guarantee — a
|
||||
/// degenerate tiny window, an oversized retained `System` prefix, or estimator
|
||||
/// optimism can still exceed the real limit (the 85% + headroom + 500k cap make
|
||||
/// that unlikely for normal grok-build sessions).
|
||||
/// that unlikely for normal kigi sessions).
|
||||
///
|
||||
/// * Fast path — if the whole snapshot already fits, returns
|
||||
/// `build_recap_items(...)` verbatim (keeps the grok prefix KV cache warm;
|
||||
/// `build_recap_items(...)` verbatim (keeps the kigi prefix KV cache warm;
|
||||
/// honors the caller's `strip_reasoning`).
|
||||
/// * Over budget — strip reasoning (the prefix cache is lost once we trim),
|
||||
/// normalize the trailing boundary ([`pop_trailing_tool_run`]),
|
||||
@@ -136,7 +136,7 @@ pub(crate) fn budget_recap_items(
|
||||
let snapshot_budget = prompt_budget.saturating_sub(estimate_item_tokens(&instruction));
|
||||
|
||||
// Un-stripped estimate is a safe upper bound (stripping only shrinks); the
|
||||
// verbatim path keeps the grok prefix cache warm.
|
||||
// verbatim path keeps the kigi prefix cache warm.
|
||||
let pre_tokens = estimate_conversation_tokens(&conversation);
|
||||
if pre_tokens <= snapshot_budget {
|
||||
return build_recap_items(conversation, tag, strip_reasoning);
|
||||
@@ -690,13 +690,13 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn budget_over_budget_strips_reasoning_even_on_grok() {
|
||||
fn budget_over_budget_strips_reasoning_even_on_kigi() {
|
||||
let conv = vec![
|
||||
mk_reasoning("r1"),
|
||||
ConversationItem::assistant("did stuff"),
|
||||
ConversationItem::user("z".repeat(40_000)),
|
||||
];
|
||||
// grok backend => strip_reasoning=false, but the over-budget branch must
|
||||
// kigi backend => strip_reasoning=false, but the over-budget branch must
|
||||
// strip reasoning anyway (the prefix cache is already lost once trimmed).
|
||||
let out = budget_recap_items(conv, "system-reminder", false, 8_000);
|
||||
assert!(
|
||||
@@ -707,19 +707,19 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn budget_fast_path_keeps_reasoning_on_grok() {
|
||||
fn budget_fast_path_keeps_reasoning_on_kigi() {
|
||||
let conv = vec![
|
||||
mk_reasoning("r1"),
|
||||
ConversationItem::assistant("did stuff"),
|
||||
ConversationItem::user("small"),
|
||||
];
|
||||
// Fits under a large window on grok (strip_reasoning=false) => verbatim,
|
||||
// Fits under a large window on kigi (strip_reasoning=false) => verbatim,
|
||||
// reasoning kept so the prefix KV cache stays warm.
|
||||
let out = budget_recap_items(conv, "system-reminder", false, 256_000);
|
||||
assert!(
|
||||
out.iter()
|
||||
.any(|i| matches!(i, ConversationItem::Reasoning(_))),
|
||||
"fits path on grok must keep reasoning verbatim"
|
||||
"fits path on kigi must keep reasoning verbatim"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user