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
+9 -17
View File
@@ -42,9 +42,7 @@ use std::io;
mod process_scope;
pub use process_scope::{ProcessScope, global_process_scope};
// ---------------------------------------------------------------------------
// TTY detach — pre_exec building block
// ---------------------------------------------------------------------------
/// Detach from the controlling TTY by starting a new session.
///
@@ -83,9 +81,7 @@ pub fn detach_from_tty() -> io::Result<()> {
Ok(())
}
// ---------------------------------------------------------------------------
// tokio::process::Command wrapper
// ---------------------------------------------------------------------------
/// Detach a `tokio::process::Command` from the parent's controlling TTY/console.
///
@@ -108,9 +104,7 @@ pub fn detach_command(cmd: &mut tokio::process::Command) {
}
}
// ---------------------------------------------------------------------------
// std::process::Command wrapper
// ---------------------------------------------------------------------------
/// Detach a `std::process::Command` from the parent's controlling TTY/console.
///
@@ -138,9 +132,7 @@ pub fn detach_std_command(cmd: &mut std::process::Command) {
}
}
// ---------------------------------------------------------------------------
// Process group lifecycle
// ---------------------------------------------------------------------------
/// Configure a command so the spawned child becomes the leader of a new
/// process group.
@@ -367,9 +359,7 @@ impl Drop for ProcessGroup {
}
}
// ---------------------------------------------------------------------------
// Environment variable helpers
// ---------------------------------------------------------------------------
/// Returns environment variables that prevent CLI tools from launching any
/// interactive program that would block waiting for user input — pagers,
@@ -450,9 +440,7 @@ fn noop_cmd() -> &'static str {
}
}
// ---------------------------------------------------------------------------
// Stderr redirection — shield TUI output from C-library noise
// ---------------------------------------------------------------------------
/// The dup'd stderr fd that writes to the real terminal. Set once by
/// [`redirect_native_stderr`]. Stored as [`OwnedFd`](std::os::unix::io::OwnedFd)
@@ -492,7 +480,8 @@ pub fn redirect_native_stderr() {
// at process start.
let duped = unsafe { libc::dup(2) };
if duped < 0 {
return; // best-effort; don't crash
// best-effort; don't crash
return;
}
// Store the duped fd (as OwnedFd) before redirecting.
@@ -718,7 +707,7 @@ mod tests {
assert_eq!(env.get("GPG_TTY"), Some(&String::new()));
}
// ── stderr redirect integration tests ────────────────────────
// stderr redirect integration tests
//
// The redirect/dup/restore cycle mutates process-global state
// (fd 2 and a `OnceLock`), so the full flow runs in a subprocess
@@ -770,7 +759,8 @@ mod tests {
#[test]
fn stderr_redirect_roundtrip_body() {
if std::env::var("__XAI_STDERR_REDIRECT_SUBPROCESS").is_err() {
return; // skip when not invoked as subprocess
// skip when not invoked as subprocess
return;
}
use std::io::Write;
@@ -832,7 +822,8 @@ mod tests {
new_process_group(&mut cmd);
let mut group = ProcessGroup::new().expect("create ProcessGroup");
#[allow(clippy::disallowed_methods)] // test: exercises ProcessGroup directly
// test: exercises ProcessGroup directly
#[allow(clippy::disallowed_methods)]
let mut child = cmd.spawn().expect("spawn child");
group.attach(&child).expect("attach child to group");
@@ -866,7 +857,8 @@ mod tests {
new_process_group(&mut cmd);
let mut group = ProcessGroup::new().expect("create ProcessGroup");
#[allow(clippy::disallowed_methods)] // test: exercises ProcessGroup + grandchild kill
// test: exercises ProcessGroup + grandchild kill
#[allow(clippy::disallowed_methods)]
let mut child = cmd.spawn().expect("spawn leader");
group.attach(&child).expect("attach leader to group");