§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
@@ -8,9 +8,9 @@
//! - **DivideAndConquer** → `config.dnc_chunk_token_limit` → N chunks.
//!
//! Everything else — turn filtering, prior-compaction user-query
//! extraction, chunk summarisation, and the final `<grok_user_queries>`
//! extraction, chunk summarisation, and the final `<kigi_user_queries>`
//! + `<chunk_summary>` assembly — is shared. The harness supplies the
//! candidate items, the *current* user-queries preamble (Grok chat
//! candidate items, the *current* user-queries preamble (Kigi chat
//! extracts it from the raw `ChatCompletionRequest`), the sampler, the
//! token counter, and an observer for metrics.
@@ -40,7 +40,7 @@ const UNBOUNDED_CHUNK_LIMIT: u32 = u32::MAX;
/// into a harness message type.
#[derive(Debug, Clone)]
pub struct ChunkedCompactionOutput {
/// `<grok_user_queries>` preamble + `<chunk_summary index="i">` blocks.
/// `<kigi_user_queries>` preamble + `<chunk_summary index="i">` blocks.
/// The harness wraps this into its summary-carrier message.
pub combined_text: String,
/// Thinking-channel output: `<chunk_analysis>` blocks. Empty when the
@@ -53,7 +53,7 @@ pub struct ChunkedCompactionOutput {
/// Steps:
/// 1. Filter items with
/// [`filter_turns_for_inter_compaction`](crate::history::filter::filter_turns_for_inter_compaction).
/// 2. [`separate_prior_user_queries`] — split prior `<grok_user_queries>`
/// 2. [`separate_prior_user_queries`] — split prior `<kigi_user_queries>`
/// blocks out of every prior compaction summary item. The LLM never sees
/// them. Shared with intra-compaction's `History` target so both
/// pipelines handle re-compactions identically.
@@ -66,11 +66,11 @@ pub struct ChunkedCompactionOutput {
/// `thinking` channels into the analysis text.
///
/// `current_user_queries` is the harness-extracted preamble for *this*
/// round's user messages (Grok chat: verbatim from the raw request, with
/// round's user messages (Kigi chat: verbatim from the raw request, with
/// attachment refs). `conversation_id` / `response_id` are threaded
/// through for log correlation only.
///
/// Observer events (the Grok chat observer maps them to the
/// Observer events (the Kigi chat observer maps them to the
/// pre-unification metrics):
/// - [`InterCompactionObserver::on_recompaction`] when prior-compaction
/// summary items are found.
@@ -127,7 +127,7 @@ pub async fn sample_compaction_chunked<T: CompactionItemBuilder + Send + Sync>(
)));
}
// Step 2 — split prior `<grok_user_queries>` out of every prior
// Step 2 — split prior `<kigi_user_queries>` out of every prior
// compaction summary item. The LLM never sees them (it would re-emit
// them verbatim and snowball across rounds); they are reattached to
// the final summary via `assemble_user_queries_preamble`. Shared with
@@ -28,7 +28,7 @@ pub struct InterCompactionConfig {
/// (Basic strategy ignores this and emits a single chunk.)
pub dnc_chunk_token_limit: u32,
/// User messages with character count > this threshold are truncated
/// (middle-cut) when assembling the `<grok_user_queries>` preamble.
/// (middle-cut) when assembling the `<kigi_user_queries>` preamble.
/// Applies to both Basic and DivideAndConquer.
pub user_message_compact_threshold: u32,
}
@@ -4,7 +4,7 @@
//!
//! Harness wiring (turn selection from the conversation store, raw-request
//! user-query extraction, summary-message assembly, persistence) stays
//! per-harness; the Grok chat host wraps this pipeline.
//! per-harness; the Kigi chat host wraps this pipeline.
pub mod compact;
pub mod config;