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

+2 -1
View File
@@ -81,7 +81,8 @@ impl SamplerActor {
cmd = self.cmd_rx.recv() => {
match cmd {
Some(cmd) => self.handle_command(cmd),
None => break, // all handles dropped
// all handles dropped
None => break,
}
}
}
@@ -465,7 +465,7 @@ type ErrorCell = Arc<Mutex<Option<SamplingError>>>;
/// Wrap a raw chunk stream so its first error is captured into a
/// shared cell. The wrapped stream still yields the original
/// `Result<T, SamplingError>` items unchanged so the L2 transform sees
/// `Result<T, SamplingError>` items `unchanged` so the L2 transform sees
/// them and converts them to `SamplingErrorInfo` for events.
fn tee_errors<'a, T: Send + 'a>(
raw: BoxStream<'a, SamplingResult<T>>,
+9 -18
View File
@@ -1,9 +1,7 @@
//! Actor-internal state.
//!
//! All fields are touched only from the actor task, so no mutex /
//! atomic synchronization is needed -- the actor's command-loop
//! serialization gives us a "single-threaded with shared state"
//! discipline matching the hunk-tracker pattern.
//! Every field is touched only from the actor task, so the command loop
//! serializes all access and no mutex or atomic is needed.
use std::collections::HashMap;
@@ -14,14 +12,12 @@ use crate::types::RequestId;
/// In-flight request bookkeeping.
///
/// `cancel_token` is owned by the actor (cloned into the spawned
/// per-request task). The completion oneshot is moved into the
/// per-request task at spawn time and is therefore not stored here.
/// The completion oneshot is moved into the per-request task at spawn time,
/// so only the cancel token remains reachable from the actor.
pub(crate) struct ActiveRequest {
pub(crate) cancel_token: CancellationToken,
}
/// Actor-owned state.
pub(crate) struct ActorState {
pub(crate) active_requests: HashMap<RequestId, ActiveRequest>,
pub(crate) config: SamplerConfig,
@@ -37,9 +33,8 @@ impl ActorState {
}
}
/// Register a newly-spawned request. Returns the previous entry if
/// the same `request_id` was already in flight (callers should
/// cancel the previous token before overwriting).
/// Returns the displaced entry when `request_id` was already in flight;
/// the caller must cancel that token, nothing else will.
pub(crate) fn register(
&mut self,
request_id: RequestId,
@@ -48,14 +43,12 @@ impl ActorState {
self.active_requests.insert(request_id, active)
}
/// Remove a request from the active set without cancelling its
/// token. Used by the cleanup signal sent from per-request tasks
/// when they exit normally.
/// Drops the entry without cancelling its token, for per-request tasks
/// signalling cleanup after they exit normally.
pub(crate) fn remove(&mut self, request_id: &RequestId) -> Option<ActiveRequest> {
self.active_requests.remove(request_id)
}
/// Cancel and remove an in-flight request.
pub(crate) fn cancel(&mut self, request_id: &RequestId) -> bool {
if let Some(active) = self.active_requests.remove(request_id) {
active.cancel_token.cancel();
@@ -65,8 +58,7 @@ impl ActorState {
}
}
/// Replace the default config. The next request submitted without
/// an override will use this.
/// Applies to every later request that carries no per-request override.
pub(crate) fn update_config(&mut self, config: SamplerConfig) {
self.config = config;
}
@@ -78,7 +70,6 @@ mod tests {
use crate::client::ApiBackend;
use indexmap::IndexMap;
/// Minimal config builder for tests in this module.
fn cfg() -> SamplerConfig {
SamplerConfig {
api_key: None,