Skip to content

refactor(protocols): strip audit-process residue from comments - #1310

Merged
slin1237 merged 1 commit into
mainfrom
refactor/audit-c2-comment-hygiene
Apr 22, 2026
Merged

slin1237 merged 1 commit into
mainfrom
refactor/audit-c2-comment-hygiene

Conversation

@slin1237

@slin1237 slin1237 commented Apr 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Pure comment hygiene: removes audit-process markers (`// P7:`, "Cycle-1 REJECT", "per audit", Postel narrative, etc.) from `crates/protocols/src/`. No semantic changes.

Scope: non-test code in `crates/protocols/src/responses.rs` (lines 1-2397). Tests at L2398+ are intentionally skipped to avoid conflicts with a parallel task that extracts the test module to a sibling file. `common.rs`, `chat.rs`, and the rest of `crates/protocols/src` were already clean.

Rules applied

  • KEEP: spec references with line / SDK path (e.g. `OpenAI spec: `summary: array of SummaryTextContent`), per-field `///` docs describing what a field is / means / permits, SAFETY / NOTE invariants
  • DROP: audit task-id markers (`P1`, `P5 fail-fast contract`), cycle-narrative ("Replaces the prior Vec wire-type that broke bidirectional interoperability"), PR-body-in-source prose ("This type deliberately does NOT live in common.rs…"), SDK-evidence narrative ("This mirrors the OpenAI Python SDK 2.8.x TypedDict…")
  • PRUNE: multi-paragraph design narratives on `ResponsesToolChoice` / `Function` variant / `ImageGenerationCall` → one-paragraph kernel retaining the wire-shape contract and the actionable invariant

Changes

`crates/protocols/src/responses.rs` only (1 file, +10 / -32):

  1. `ResponsesToolChoice` type-level doc: dropped the "deliberately does NOT live in common.rs" rationale paragraph; kept the 8-variant wire-shape and tag-pinning paragraphs.
  2. `ResponsesToolChoice::Function` variant doc: pruned from 3 paragraphs to 1 — kept wire shape + legacy nested acceptance + tag-pinning invariant; dropped Postel narrative.
  3. `ImageInputMask` doc: `P1 InputImage` → `InputImage`.
  4. `ResponseInputOutputItem::ImageGenerationCall` doc: dropped the "OpenAI Python SDK 2.8.x TypedDict Required[Optional[...]]" paragraph; kept HTTP spec shape and server-side strictness note.
  5. `SimpleInputMessage.type` field doc: dropped "— P5 fail-fast contract" marker.
  6. `SimpleInputMessageTypeTag` type-level doc: dropped "(P5 fail-fast contract)" marker.
  7. `SummaryTextContent` type-level doc: dropped "Replaces the prior `Vec` wire-type that broke bidirectional interoperability with spec-compliant clients." cycle-narrative.

Net: +10 / -32 lines.

Acceptance

  • `grep -nE "cycle-?[12]|per audit|per Lead|Postel|per §|Worker flagged|per SDK v2" crates/protocols/src/` → 0 hits in non-test code (one remaining hit at responses.rs:3164 is inside `mod tests` and will be addressed by the parallel test-extraction worker)
  • `cargo test -p openai-protocol --lib` → 94 passed
  • `cargo clippy -p openai-protocol --lib --tests -- -D warnings` → clean
  • `cargo check -p openai-protocol --lib --tests` → green
  • `cargo doc --no-deps -p openai-protocol` → no new warnings (9 pre-existing warnings in `interactions.rs` / `messages.rs` unchanged, unrelated to this PR)

Hard rules honored

  • No changes to any declared `pub` item, struct field, enum variant, `#[serde(...)]` attribute, function body, or test.
  • No new comments added; only removal / pruning.
  • No file renames or moves.
  • `git commit -s` with DCO sign-off.

Refs: `.claude/_audit/responses-api-gap-audit.md §C2`

Summary by CodeRabbit

  • Documentation
    • Clarified and streamlined documentation for response types to better reflect serialization behavior and wire format conventions. No functional changes to the API.

Pure comment hygiene on crates/protocols/src/responses.rs (non-test
code only). Removes audit-process residue that leaked into doc
comments:

- Drop audit task-id markers ("P1", "P5 fail-fast contract") from
  per-variant and per-field docs.
- Drop "Postel's law: liberal on input, conservative on output"
  narrative from the `ResponsesFunctionToolChoice::Function` doc;
  keep the wire-shape kernel and the tag-pinning invariant.
- Drop the "This type deliberately does NOT live in common.rs…"
  split-rationale paragraph from `ResponsesToolChoice`.
- Drop the "OpenAI Python SDK 2.8.x TypedDict" narrative from
  `ResponseInputOutputItem::ImageGenerationCall`; keep the HTTP
  spec shape and the server-side strictness note.
- Drop the "Replaces the prior Vec<String> wire-type that broke
  bidirectional interoperability" cycle-narrative from
  `SummaryTextContent`.

Scope: lines 1-2397 of responses.rs (non-test code). Tests
(mod tests at L2398+) are skipped to avoid conflicts with a
parallel test-extraction task. common.rs, chat.rs, and the rest
of crates/protocols/src were already clean.

No semantic changes: no `pub` items, struct fields, enum variants,
`#[serde(...)]` attributes, function bodies, or tests were touched.
No new comments added; only removal / pruning of existing ones.

Acceptance:
- grep residue pattern on crates/protocols/src/ non-test code: 0 hits
- cargo check -p openai-protocol --lib --tests: green
- cargo clippy -p openai-protocol --lib --tests -- -D warnings: green
- cargo test -p openai-protocol --lib: 94 passed
- cargo doc --no-deps -p openai-protocol: no new warnings
  (9 pre-existing warnings in interactions.rs / messages.rs, unchanged)

Refs: .claude/_audit/responses-api-gap-audit.md §C2
Signed-off-by: Simo Lin <linsimo.mark@gmail.com>
@coderabbitai

coderabbitai Bot commented Apr 22, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5de2c9b6-ec0d-4482-80f6-e62222749b23

📥 Commits

Reviewing files that changed from the base of the PR and between 3397a6a and 8bae876.

📒 Files selected for processing (1)
  • crates/protocols/src/responses.rs

📝 Walkthrough

Walkthrough

Documentation and comments in the responses module were updated and simplified. Changes include narrowing descriptions of ResponsesToolChoice::Function behavior, adjusting ImageInputMask wording, trimming docstrings for clarity, and removing outdated wire-shape interoperability notes. No functional or structural code changes were made.

Changes

Cohort / File(s) Summary
Documentation Updates
crates/protocols/src/responses.rs
Updated docstrings for ResponsesToolChoice, ImageInputMask, ResponseInputOutputItem::ImageGenerationCall, SimpleInputMessage, and ResponseReasoningContent. Removed multi-line comment blocks and outdated wire-shape notes; clarified serialization behavior descriptions.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested labels

protocols

Suggested reviewers

  • CatherineSue
  • claude
  • key4ng

Poem

📚✨ A rabbit hops through docs so neat,
Trimming words that aren't concrete,
Old wire-shapes fade away with glee,
Comments cleared for clarity!
Cleaner prose, a joyful feat~ 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: removing audit-process residual comments from the protocols crate. It is concise, specific, and directly reflects the PR's pure documentation hygiene work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/audit-c2-comment-hygiene

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the protocols Protocols crate changes label Apr 22, 2026
@slin1237
slin1237 merged commit c82b857 into main Apr 22, 2026
15 of 16 checks passed
@slin1237
slin1237 deleted the refactor/audit-c2-comment-hygiene branch April 22, 2026 13:53

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment-only cleanup — strips internal priority labels (P1/P5), verbose SDK version references, and historical rationale from doc comments. No code changes. Remaining comments are accurate and concise. LGTM.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request simplifies documentation in crates/protocols/src/responses.rs by removing historical context, internal project references, and architectural explanations. A review comment suggests that the removal of the explanation for ResponsesToolChoice eliminates critical context regarding specification alignment and recommends its restoration to prevent future misuse of the API.

@@ -174,13 +174,6 @@ impl<'de> Deserialize<'de> for ResponsesFunctionToolChoice {
/// whose `type` does not belong to that variant. Without the tag pinning,
/// the `#[serde(untagged)]` enum would accept any object shape that
/// happened to fit the field set of an earlier variant.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The removed paragraph explaining why ResponsesToolChoice is kept separate from common.rs contains critical architectural context. It warns that merging these types would cause the Chat API to incorrectly accept Responses-specific variants (like Mcp or Shell), leading to spec-invalid payloads. This aligns with the repository's priority to prioritize alignment with external specifications over internal consistency and to surface spec divergences at the edge.

/// happened to fit the field set of an earlier variant.
///
/// This type is kept separate from common.rs to prevent the Chat API
/// from incorrectly accepting Responses-specific variants (like Mcp or
/// Shell) which are not part of the Chat spec.
References
  1. For protocol data structures that mirror an external API, prioritize alignment with the external specification over internal consistency.
  2. Prioritize fail-fast behavior for unknown or new types to ensure spec divergences are surfaced at the edge as errors rather than silently confusing downstream consumers.

@slin1237

Copy link
Copy Markdown
Member Author

Thanks @gemini-code-assist — good catch. The original paragraph did carry a real architectural invariant (Chat vs Responses tool_choice must stay unshared to prevent spec-invalid payloads on /v1/chat/completions). Restored as a concise NOTE: in 153fc12, dropping the audit-narrative framing but keeping the invariant.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

protocols Protocols crate changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant