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

@@ -153,7 +153,6 @@ mod tests {
#[test]
fn not_available_in_minimal() {
// Native terminal selection replaces the in-app copy path in minimal.
assert!(!CopyCommand.available_in_minimal());
}
}
@@ -140,7 +140,6 @@ mod tests {
#[test]
fn not_available_in_minimal() {
// The dashboard is out of scope in scrollback-native minimal mode.
assert!(!DashboardCommand.available_in_minimal());
}
}
@@ -106,7 +106,6 @@ fn list_path_completions(cwd: &Path, query: &str) -> Vec<ArgItem> {
(parent.to_path_buf(), prefix.to_string())
};
// Resolve relative paths against cwd.
let resolved = if dir_to_list.is_relative() {
cwd.join(&dir_to_list)
} else {
@@ -148,7 +147,7 @@ fn list_path_completions(cwd: &Path, query: &str) -> Vec<ArgItem> {
}
}
// Sort: directories first, then alphabetical. Truncate after sort.
// Directories first, then alphabetical.
items.sort_by(|a, b| {
let a_dir = a.display.ends_with('/');
let b_dir = b.display.ends_with('/');
@@ -140,8 +140,6 @@ mod tests {
use super::*;
use crate::acp::model_state::ModelState;
// -- parse_fork_args ---------------------------------------------------
#[test]
fn parse_empty_returns_none_directive_and_no_override() {
let parsed = parse_fork_args("").expect("empty args parse");
@@ -255,8 +253,6 @@ mod tests {
assert_eq!(parsed.directive.as_deref(), Some("investigate"));
}
// -- ForkCommand SlashCommand impl ------------------------------------
fn make_ctx(models: &ModelState) -> CommandExecCtx<'_> {
let bundle = Box::leak(Box::new(crate::app::bundle::BundleState::default()));
CommandExecCtx {
@@ -17,7 +17,6 @@ impl SlashCommand for GboomCommand {
}
fn description(&self) -> &str {
// Never shown: the command is hidden from the dropdown.
"Hidden easter egg"
}
@@ -25,7 +24,6 @@ impl SlashCommand for GboomCommand {
"/gboom"
}
/// Easter egg: typeable, never listed.
fn visible(&self, _ctx: &AppCtx) -> bool {
false
}
@@ -3,7 +3,6 @@
use crate::app::actions::Action;
use crate::slash::command::{CommandExecCtx, CommandResult, SlashCommand};
/// Exit the current session and return to the welcome screen.
pub struct HomeCommand;
impl SlashCommand for HomeCommand {
@@ -10,7 +10,6 @@
use crate::app::actions::Action;
use crate::slash::command::{CommandExecCtx, CommandResult, SlashCommand};
/// Open the interactive Claude settings import modal in the active session.
pub struct ImportClaudeCommand;
impl SlashCommand for ImportClaudeCommand {
@@ -68,7 +68,6 @@ mod tests {
#[test]
fn not_available_in_minimal() {
// Native terminal scrollback replaces in-app scrolling in minimal.
assert!(!JumpCommand.available_in_minimal());
}
}
@@ -211,14 +211,22 @@ mod tests {
// suffix, and zero-valued tokens. Each must fall through to the model
// with no host-side cadence.
for input in [
"5x do x", // bad suffix
"5 do x", // no suffix
"m do x", // too short / no digits
"55mm do x", // multi-char suffix
"0m do x", // zero value (tool would reject)
"0s do x", // zero value
"abc do x", // alphabetic
"99999999999999999999m do x", // overflows u64 -> parse Err branch
// bad suffix
"5x do x",
// no suffix
"5 do x",
// too short / no digits
"m do x",
// multi-char suffix
"55mm do x",
// zero value (tool would reject)
"0m do x",
// zero value
"0s do x",
// alphabetic
"abc do x",
// overflows u64 -> parse Err branch
"99999999999999999999m do x",
] {
let (interval, prompt) = parse_loop_args(input);
assert_eq!(interval, None, "input {input:?} must not yield a token");
@@ -228,7 +236,7 @@ mod tests {
#[test]
fn natural_language_intervals_are_not_defaulted_host_side() {
// The host no longer parses natural-language intervals or substitutes a
// The host does not parse natural-language intervals or substitute a
// default — these all fall through to the model with no interval token.
for input in [
"every 30 minutes do x",
@@ -135,7 +135,6 @@ mod tests {
use crate::slash::command::{CommandExecCtx, CommandResult};
use crate::slash::registry::CommandRegistry;
use agent_client_protocol as acp;
/// Build a ModelState with two models for testing.
fn sample_models() -> ModelState {
let mut models = ModelState::default();
let id_fast = acp::ModelId::new(Arc::from("kigi-4.5"));
@@ -420,8 +420,8 @@ mod tests {
#[test]
fn run_rejects_unoffered_effort_with_effort_error_not_unknown_model() {
// Regression: previously `resolve_effort_token_for` returned None and
// the handler fell through to `Unknown model: Reasoning X none`.
// Guards against a rejected effort token falling through to
// `Unknown model: Reasoning X none` instead of an effort error.
let mut state = ModelState::default();
let (id, info) = model_with_reasoning("reasoning-x", "Reasoning X");
state.available.insert(id, info);
@@ -24,7 +24,6 @@ impl SlashCommand for SessionInfoCommand {
}
fn run(&self, ctx: &mut CommandExecCtx, _args: &str) -> CommandResult {
// Check if we have an active session
if ctx.session_id.is_none() {
return CommandResult::Error("No active session".to_string());
}
@@ -9,7 +9,6 @@
use crate::app::actions::Action;
use crate::slash::command::{CommandExecCtx, CommandResult, SlashCommand};
/// List background tasks, subagents, and scheduled tasks.
pub struct TasksCommand;
impl SlashCommand for TasksCommand {
@@ -64,7 +64,6 @@ impl SlashCommand for TerminalSetupCommand {
let mut out = String::new();
// -- Environment --
out.push_str("Environment\n");
out.push_str(&format!(" terminal {}\n", ctx.brand));
if let Some(v) = crate::terminal::xtversion::detected() {
@@ -122,7 +121,6 @@ impl SlashCommand for TerminalSetupCommand {
out.push_str(&format!(" newline Alt+Enter ({detail})\n"));
}
// -- Clipboard --
out.push_str("\nClipboard routes\n");
out.push_str(&format!(
" native {} (tool: {})\n",
@@ -142,7 +140,6 @@ impl SlashCommand for TerminalSetupCommand {
crate::clipboard::wayland_data_control_label()
));
// -- Diagnostics --
if warnings.is_empty() {
out.push_str("\nNo issues found.\n");
} else {
@@ -168,8 +168,6 @@ mod tests {
assert!(!ThemeCommand.available_in_minimal());
}
// -- suggest_args ---------------------------------------------------------
#[test]
fn suggest_args_prepends_auto_option() {
with_test_env(|| {
@@ -277,8 +275,6 @@ mod tests {
});
}
// -- run (dispatches Action::SetTheme) ------------------------------------
/// `/theme <name>` returns `Action::SetTheme(<canonical>)` —
/// the dispatcher handles in-memory state + disk write + toast.
#[test]
@@ -408,8 +404,6 @@ mod tests {
});
}
// -- preview_arg ----------------------------------------------------------
#[test]
fn preview_auto_applies_resolved_theme() {
with_test_env(|| {
@@ -447,9 +441,7 @@ mod tests {
});
}
// -- cancel_preview -------------------------------------------------------
/// `cancel_preview` restores the previously-applied theme.
/// `cancel_preview` restores the theme that was applied before the preview.
#[test]
fn cancel_preview_restores_previous_kind() {
with_test_env(|| {
@@ -484,8 +476,6 @@ mod tests {
});
}
// -- error handling -------------------------------------------------------
#[test]
fn run_unknown_lists_auto_in_available() {
with_test_env(|| {