docs(comments): rewrite comments across all crates to the guidelines

Sweep every first-party crate source (1956 .rs files) to the project comment
guidelines: delete redundant restatements, decorative banners, change
narration, and end-of-line comments; keep and tighten the crucial ones
(invariants, bug rationale, SAFETY blocks, ported-source attribution).

No functional code changed. Every edit is proven comment-only against the
prior tree by a comment-stripping lexer (string/char/raw-string aware) plus a
separate doctest-fence check. Where removing a comment made rustfmt or clippy
want to re-lay-out adjacent code, the minimal triggering comment is restored so
code tokens stay byte-identical.

Gates green: cargo fmt --all --check (0 diffs), cargo check and cargo clippy
--workspace --all-targets (0 warnings).

Adds scripts/check_codegen_comment_guidelines.py — the enforcement gate for
these guidelines (flags banners, end-of-line comments, change narration, and
commented-out code).
This commit is contained in:
2026-07-23 16:55:39 -04:00
parent ff0fb56c67
commit a02b555e66
1458 changed files with 10729 additions and 21750 deletions
+3 -12
View File
@@ -5,7 +5,6 @@
//! Each value resolves as an env-var override when set, else the compiled
//! production default.
/// The complete set of first-party endpoints.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct KigiEndpoints {
/// Kimi Code subscription inference API (OpenAI chat/completions compatible).
@@ -40,26 +39,18 @@ fn resolve(var: &str, compiled: &'static str) -> String {
}
}
/// Subscription inference base URL: `KIGI_CODE_BASE_URL` override when set,
/// else the compiled production endpoint.
pub fn coding_api_base_url() -> String {
resolve(CODE_BASE_URL_ENV, PRODUCTION_ENDPOINTS.coding_api_base_url)
}
/// OAuth host: `KIGI_OAUTH_HOST` override when set, else the compiled
/// production endpoint.
pub fn oauth_host() -> String {
resolve(OAUTH_HOST_ENV, PRODUCTION_ENDPOINTS.oauth_host)
}
/// GitHub Releases API endpoint for the self-updater:
/// `KIGI_UPDATE_BASE_URL` override when set, else the compiled production
/// endpoint. The updater's channel/rollback semantics layer on top of it.
pub fn update_base_url() -> String {
resolve(UPDATE_BASE_URL_ENV, PRODUCTION_ENDPOINTS.update_base_url)
}
/// Subscription upgrade page shown in rate-limit and upsell surfaces.
pub fn upgrade_page_url() -> &'static str {
PRODUCTION_ENDPOINTS.upgrade_page_url
}
@@ -70,8 +61,8 @@ fn env_lock() -> std::sync::MutexGuard<'static, ()> {
ENV_LOCK.lock().unwrap_or_else(|p| p.into_inner())
}
/// RAII env-var override for tests: constructors snapshot the prior value
/// under [`ENV_LOCK`], `Drop` restores it, panics included.
/// RAII env-var override for tests: the constructors snapshot the prior value
/// under [`ENV_LOCK`] and `Drop` restores it, panics included.
pub struct EnvVarGuard {
key: &'static str,
prev: Option<String>,
@@ -101,7 +92,7 @@ impl EnvVarGuard {
}
}
/// Update the value while still holding the env lock.
/// Overwrite the value without releasing [`ENV_LOCK`].
pub fn set_value(&self, value: &str) {
unsafe { std::env::set_var(self.key, value) };
}