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

@@ -4,12 +4,9 @@ use std::collections::HashMap;
use serde::{Deserialize, Serialize};
/// Per-tool wire-traveling capabilities. Defaults conservatively (no
/// progress, no cancel, single concurrency, no hooks).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ToolCapabilities {
/// Streaming declaration. `None` — the default for every tool today —
/// means the tool never emits partial-result progress.
/// `None` means the tool never emits partial-result progress.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub streaming: Option<StreamingSpec>,
@@ -17,8 +14,7 @@ pub struct ToolCapabilities {
#[serde(default)]
pub supports_cancel: bool,
/// Maximum concurrent invocations the tool will accept. `None` is
/// unlimited.
/// `None` is unlimited.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_concurrency: Option<u32>,
@@ -26,7 +22,6 @@ pub struct ToolCapabilities {
#[serde(default)]
pub is_read_only: bool,
/// Lifecycle hooks the tool opts in to receive.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub hooks: Vec<HookKind>,
@@ -43,17 +38,14 @@ pub struct ToolCapabilities {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub timeout_ms: Option<u64>,
/// Multi-agent write-coordination scope. Tools that mutate external
/// state must declare `Write` so the computer hub routes them to the
/// leader agent only. Absence is treated as `Read`.
/// Absence is treated as [`ToolScope::Read`].
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tool_scope: Option<ToolScope>,
}
/// How a tool streams partial results. Declared once in
/// [`ToolCapabilities::streaming`] and consumed at the source to stamp a
/// self-describing progress envelope; downstream layers dispatch on that
/// envelope rather than the tool's identity.
/// How a tool streams partial results. The spec is stamped onto a
/// self-describing progress envelope at the source, so downstream layers
/// dispatch on the envelope rather than on the tool's identity.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct StreamingSpec {
/// Stable snake_case discriminator the tool stamps on its
@@ -67,7 +59,6 @@ pub struct StreamingSpec {
pub max_delta_bytes: Option<u32>,
}
/// Lifecycle hook a tool may opt in to receive.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum HookKind {
@@ -86,21 +77,19 @@ pub enum HookKind {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ToolScope {
/// Tool does not mutate external state.
Read,
/// Tool mutates external state.
Write,
}
/// Per-tool notification schemas. Keys are the notification `kind` strings
/// the computer hub validates against.
/// Keys are the notification `kind` strings the computer hub validates
/// against.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct NotificationSchemas {
/// Schemas for notifications the tool emits to subscribers.
/// Notifications the tool emits to subscribers.
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
pub outbound: HashMap<String, serde_json::Value>,
/// Schemas for notifications the harness sends to the tool.
/// Notifications the harness sends to the tool.
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
pub inbound: HashMap<String, serde_json::Value>,
}