§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
+10 -10
View File
@@ -472,7 +472,7 @@ impl MemoryIndex {
///
/// An empty string means no claim is active. A non-empty claim means
/// a session currently owns the reindex lock (or a crashed session left
/// a stale one). Used by `grok memory doctor` to detect stuck states.
/// a stale one). Used by `kigi memory doctor` to detect stuck states.
pub fn get_reindex_claim(&self) -> String {
self.db
.query_row(
@@ -485,7 +485,7 @@ impl MemoryIndex {
/// Return all distinct file paths that have at least one indexed chunk.
///
/// Used by `grok memory doctor` to detect orphaned chunks (chunks whose
/// Used by `kigi memory doctor` to detect orphaned chunks (chunks whose
/// source file has since been deleted).
pub fn all_indexed_paths(&self) -> Result<Vec<String>, rusqlite::Error> {
let mut stmt = self
@@ -1179,13 +1179,13 @@ mod tests {
///
/// 1. Index a file.
/// 2. Delete the file from disk (simulates a user removing a session log).
/// 3. Run the same orphan-removal logic as `grok memory reindex`:
/// 3. Run the same orphan-removal logic as `kigi memory reindex`:
/// compare `all_indexed_paths()` against current files and call
/// `delete_path()` for paths that no longer exist.
/// 4. Verify the stale chunks are gone and are no longer searchable.
///
/// This proves that `grok memory reindex`'s Phase 1 actually fixes the
/// state that `grok memory doctor` warns about.
/// This proves that `kigi memory reindex`'s Phase 1 actually fixes the
/// state that `kigi memory doctor` warns about.
#[test]
fn test_reindex_maintenance_removes_orphaned_chunks() {
let tmp = TempDir::new().unwrap();
@@ -1206,7 +1206,7 @@ mod tests {
// Delete the file — now it is orphaned in the index.
std::fs::remove_file(&file).unwrap();
// Simulate `grok memory reindex` Phase 1: compare indexed vs current.
// Simulate `kigi memory reindex` Phase 1: compare indexed vs current.
let current: std::collections::BTreeSet<String> = vec![].into_iter().collect(); // empty = no files
let indexed = idx.all_indexed_paths().unwrap();
for path in &indexed {
@@ -1225,7 +1225,7 @@ mod tests {
/// A fresh (non-stale) reindex claim blocks `try_claim_reindex`.
///
/// Verifies that `grok memory reindex` Phase 0 correctly bails when a
/// Verifies that `kigi memory reindex` Phase 0 correctly bails when a
/// live session holds a fresh claim — i.e., the CLI cannot steal a live
/// session's lock and then mutate the index concurrently.
#[test]
@@ -1256,10 +1256,10 @@ mod tests {
idx.release_claim();
}
/// `grok memory reindex` Phase 3 resets the stale reindex claim.
/// `kigi memory reindex` Phase 3 resets the stale reindex claim.
///
/// Verifies that `release_claim()` clears `meta.reindex_claim` so that
/// `grok memory doctor` no longer reports a stale lock after reindex runs.
/// `kigi memory doctor` no longer reports a stale lock after reindex runs.
#[test]
fn test_reindex_maintenance_resets_stale_claim() {
let tmp = TempDir::new().unwrap();
@@ -1274,7 +1274,7 @@ mod tests {
"claim must be set before Phase 3"
);
// Simulate `grok memory reindex` Phase 3: release the claim.
// Simulate `kigi memory reindex` Phase 3: release the claim.
idx.release_claim();
assert_eq!(