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:
ZacharyZhang-NY committed 2026-07-23 16:55:39 -04:00
1 parent ff0fb56c67
commit a02b555e66
1458 files changed
+10729 -21750

No files matched your search

@@ -1,7 +1,5 @@
use super::*;
// -- accept_ghost ---------------------------------------------------------
#[test]
fn accept_full_returns_entire_ghost_and_clears() {
let mut sc = SuggestionController::new();
@@ -96,8 +94,6 @@ fn accept_one_word_progressive() {
assert!(!sc.has_ghost());
}
// -- progressive matching -------------------------------------------------
#[test]
fn progressive_match_trims_matching_char() {
let mut sc = SuggestionController::new();
@@ -195,8 +191,6 @@ fn progressive_match_empty_suffix_clears() {
assert!(!sc.has_ghost());
}
// -- set_ghost / clear_ghost / generation ---------------------------------
#[test]
fn set_ghost_increments_generation() {
let mut sc = SuggestionController::new();
@@ -232,8 +226,6 @@ fn clear_ghost_resets_all_fields() {
assert_eq!(sc.ghost.source, SuggestionSource::None);
}
// -- text_changed ---------------------------------------------------------
fn enabled_controller() -> SuggestionController {
let mut sc = SuggestionController::new();
sc.enabled = true;
@@ -350,8 +342,6 @@ fn text_changed_increments_generation_on_debounce() {
assert!(g2 > g1);
}
// -- on_debounce_expired --------------------------------------------------
#[test]
fn debounce_expired_matching_generation_returns_true() {
let mut sc = enabled_controller();
@@ -371,8 +361,6 @@ fn debounce_expired_stale_generation_returns_false() {
assert!(!sc.on_debounce_expired(stale_gen));
}
// -- on_suggestions_loaded ------------------------------------------------
fn make_response(
generation: u64,
ghost_suffix: Option<&str>,
@@ -449,8 +437,6 @@ fn suggestions_loaded_replaces_existing_ghost() {
assert_eq!(sc.ghost.source, SuggestionSource::AI);
}
// -- on_suggestions_loaded: dropdown population ----------------------------
#[test]
fn suggestions_loaded_populates_dropdown() {
let mut sc = enabled_controller();
@@ -553,8 +539,6 @@ fn accept_ghost_closes_dropdown() {
assert!(sc.dropdown.items.is_empty());
}
// -- SuggestResponseParsed::from_json -------------------------------------
#[test]
fn parse_response_with_ghost_and_completions() {
let json = serde_json::json!({
@@ -774,8 +758,6 @@ fn parse_completion_truncated_flag() {
assert!(!malformed.truncated);
}
// -- validated_replace_range -----------------------------------------------
fn anchored_controller(request_text: &str) -> SuggestionController {
let mut sc = enabled_controller();
sc.dropdown.request_text = request_text.to_owned();
@@ -870,8 +852,6 @@ fn validated_range_mid_char_boundary_rejects() {
);
}
// -- common_prefix_fill ------------------------------------------------
fn span_item(
token: &str,
range: std::ops::Range<usize>,
@@ -992,8 +972,6 @@ fn common_prefix_fill_multibyte_boundary_trim() {
assert!(sc.common_prefix_fill("cat caf").is_none());
}
// -- tab_decision --------------------------------------------------------
/// Anchored controller whose items are current for `request_text` typed
/// with the cursor at its end — the state right after a landing.
fn decision_controller(request_text: &str) -> SuggestionController {
@@ -1164,8 +1142,6 @@ fn tab_decision_lcp_with_complete_escape_fills() {
);
}
// -- accept_completion: splice resolution ---------------------------------
fn accept_controller(request_text: &str, items: Vec<CompletionItemParsed>) -> SuggestionController {
let mut sc = anchored_controller(request_text);
sc.dropdown.items = items;
@@ -1249,8 +1225,6 @@ fn accept_completion_stale_range_resolves_stale() {
assert!(sc.dropdown.items.is_empty());
}
// -- accept_completion / async-race invalidation ---------------------------
fn item(text: &str, source: SuggestionSource) -> CompletionItemParsed {
CompletionItemParsed {
display: text.to_owned(),
@@ -1374,8 +1348,6 @@ fn non_matching_edit_tears_down_ghostless_dropdown() {
assert!(sc.dropdown.items.is_empty());
}
// -- always-on Tab completion (no KIGI_SUGGESTIONS) ------------------------
/// Tab-triggered fetches work with the as-you-type pipeline OFF — the
/// arming bumps the generation and the landing response still installs
/// its dropdown items.
@@ -1490,8 +1462,6 @@ fn disabled_controller_ignores_response_ghost() {
assert_eq!(sc.dropdown.items.len(), 1);
}
// -- SuggestionSource::parse_source ---------------------------------------
#[test]
fn source_parse_known_values() {
assert_eq!(
@@ -1518,23 +1488,18 @@ fn source_parse_unknown_returns_none() {
);
}
// -- end-to-end pipeline: text_changed → debounce → loaded ----------------
#[test]
fn full_pipeline_text_change_debounce_load() {
let mut sc = enabled_controller();
// 1. User types "g"
let action = sc.text_changed("g", false, false);
let current_gen = match action {
Some(SuggestionAction::Debounce { generation }) => generation,
other => panic!("expected Debounce, got {other:?}"),
};
// 2. Debounce expires — generation still matches
assert!(sc.on_debounce_expired(current_gen));
// 3. Response arrives with matching generation
sc.set_last_request_text("g");
sc.on_suggestions_loaded(
make_response(current_gen, Some("it commit"), SuggestionSource::History),
@@ -1543,7 +1508,6 @@ fn full_pipeline_text_change_debounce_load() {
);
assert_eq!(sc.ghost_text(), Some("it commit"));
// 4. User types "i" — progressive match trims ghost
let action = sc.text_changed("gi", false, false);
assert_eq!(action, Some(SuggestionAction::Matched));
assert_eq!(sc.ghost_text(), Some("t commit"));
@@ -1553,14 +1517,12 @@ fn full_pipeline_text_change_debounce_load() {
fn rapid_typing_discards_stale_debounce() {
let mut sc = enabled_controller();
// User types "g"
let action1 = sc.text_changed("g", false, false);
let gen1 = match action1 {
Some(SuggestionAction::Debounce { generation }) => generation,
_ => panic!("expected Debounce"),
};
// User types "gi" before debounce fires
let action2 = sc.text_changed("gi", false, false);
let gen2 = match action2 {
Some(SuggestionAction::Debounce { generation }) => generation,
@@ -1578,10 +1540,8 @@ fn rapid_typing_discards_stale_debounce() {
fn slash_during_pending_debounce_suppresses() {
let mut sc = enabled_controller();
// User types "git"
sc.text_changed("git", false, false);
// User types "/" — slash becomes active
let result = sc.text_changed("/", true, false);
assert!(result.is_none());
assert!(!sc.has_ghost());