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.
74 lines
3.2 KiB
Rust
74 lines
3.2 KiB
Rust
//! Observability seam for the full-replace (kigi) pass.
|
|
//!
|
|
//! The shared orchestrator reports per-attempt and terminal outcomes through
|
|
//! this trait so each harness can emit its own telemetry (kigi:
|
|
//! `CompactionAttempt` rows, `CompactionRetryDegraded` events, span records,
|
|
//! request-artifact persistence) without the shared crate depending on a
|
|
//! telemetry backend. Mirrors
|
|
//! [`IntraCompactionObserver`](crate::intra_compaction::IntraCompactionObserver)
|
|
//! / [`InterCompactionObserver`](crate::inter_compaction::InterCompactionObserver).
|
|
//!
|
|
//! Emission points are part of the behavior contract: the kigi observer
|
|
//! preserves the pre-migration `CompactionAttempt`/`CompactionRetryDegraded`
|
|
//! semantics byte-for-byte.
|
|
|
|
use std::time::Duration;
|
|
|
|
/// Classified outcome of a single full-replace sample attempt.
|
|
///
|
|
/// The harness turns this into its per-attempt telemetry row. `summary` is the
|
|
/// raw model output (the harness bounds/captures it as needed); it is borrowed
|
|
/// for the duration of the callback so no allocation happens on the hot path.
|
|
#[derive(Debug)]
|
|
pub enum FullReplaceAttemptOutcome<'a> {
|
|
/// A usable, non-degenerate summary was produced; the pass will succeed.
|
|
Success {
|
|
/// Raw model summary text.
|
|
summary: &'a str,
|
|
},
|
|
/// The model returned an empty / whitespace-only response.
|
|
EmptyResponse {
|
|
/// Whether the orchestrator will retry after this attempt.
|
|
will_retry: bool,
|
|
},
|
|
/// The cleaned summary seed was too short to carry the conversation's task
|
|
/// state; retried like a transient failure.
|
|
Degenerate {
|
|
/// Raw model summary text (still captured for offline inspection).
|
|
summary: &'a str,
|
|
/// Whether the orchestrator will retry after this attempt.
|
|
will_retry: bool,
|
|
},
|
|
/// The sampler returned an error.
|
|
Failure {
|
|
/// Rendered error message.
|
|
message: &'a str,
|
|
/// Whether re-sending the *same* input cannot help (auth / schema /
|
|
/// size). Transient failures (timeout / stream blip / 5xx) are `false`.
|
|
deterministic: bool,
|
|
/// Whether the failure was a context-length overflow — the signal the
|
|
/// harness uses to step its input ladder rather than suppress.
|
|
context_overflow: bool,
|
|
/// Whether the orchestrator will retry after this attempt (always
|
|
/// `false` for deterministic failures and context overflows).
|
|
will_retry: bool,
|
|
},
|
|
}
|
|
|
|
/// Receives full-replace compaction outcomes. All methods default to no-ops so
|
|
/// harnesses without telemetry (and tests) can use `()`.
|
|
pub trait FullReplaceObserver: Send + Sync {
|
|
/// One sample attempt finished with the given classified outcome.
|
|
/// `attempt` is 1-based and cumulative across the pass.
|
|
fn on_attempt(&self, _attempt: u32, _outcome: &FullReplaceAttemptOutcome<'_>) {}
|
|
|
|
/// The pass succeeded after `attempts` total attempts.
|
|
fn on_success(&self, _attempts: u32, _summary_chars: usize, _elapsed: Duration) {}
|
|
|
|
/// The pass failed terminally after `attempts` total attempts.
|
|
fn on_error(&self, _attempts: u32) {}
|
|
}
|
|
|
|
/// No-op observer for tests and harnesses without telemetry.
|
|
impl FullReplaceObserver for () {}
|