P1: Apply commenting style guide to packages/MCP/Sources/MCP/MCPClient.swift #69

Open
opened 2026-05-12 19:21:13 +00:00 by KofTwentyTwo · 0 comments
KofTwentyTwo commented 2026-05-12 19:21:13 +00:00 (Migrated from github.com)

Goal

Bring packages/MCP/Sources/MCP/MCPClient.swift up to the standard in .planning/code-commenting-guide.md. Load-bearing actor — MCP client transport, request/response correlation, tool-call surface.

Constraints

  • ONE atomic commit. No code behavior changes — comments + docstrings only.
  • 18/18 boundary gates green.
  • Apply the guide's 5 comment shapes:
    • 5-line opener at top of file (WHY MCPClient exists, what it owns, transport contract)
    • Type-level /// docstring with Overview + Topics + Threading + See Also
    • Method-level docstrings on public + key private methods (connect, list tools, call tool, shutdown)
    • ASCII diagram of request/response flow (call → JSON-RPC → stdout → correlate → return)
    • "Before you edit" invariants block (Swift SDK contract vs hand-rolled NDJSON; restart mutex; sanitization expectations; requiresConfirmation propagation)
    • MARK dividers as a table of contents

Anti-patterns to remove

  • Plan-ID-only comments — rewrite WHY-first.
  • Stale references to closed Plan IDs or removed types.
  • Bare TODO: / FIXME: without issue link.

Follow the canonical pattern

Use the AppDelegate.swift P0 rewrite (#65) as the canonical applied pattern.

Parent epic

#64

Source

.planning/code-commenting-guide.md → Migration plan → P1

## Goal Bring `packages/MCP/Sources/MCP/MCPClient.swift` up to the standard in `.planning/code-commenting-guide.md`. Load-bearing actor — MCP client transport, request/response correlation, tool-call surface. ## Constraints - ONE atomic commit. No code behavior changes — comments + docstrings only. - 18/18 boundary gates green. - Apply the guide's 5 comment shapes: - 5-line opener at top of file (WHY MCPClient exists, what it owns, transport contract) - Type-level `///` docstring with Overview + Topics + Threading + See Also - Method-level docstrings on public + key private methods (connect, list tools, call tool, shutdown) - ASCII diagram of request/response flow (call → JSON-RPC → stdout → correlate → return) - "Before you edit" invariants block (Swift SDK contract vs hand-rolled NDJSON; restart mutex; sanitization expectations; requiresConfirmation propagation) - MARK dividers as a table of contents ## Anti-patterns to remove - Plan-ID-only comments — rewrite WHY-first. - Stale references to closed Plan IDs or removed types. - Bare `TODO:` / `FIXME:` without issue link. ## Follow the canonical pattern Use the AppDelegate.swift P0 rewrite (#65) as the canonical applied pattern. ## Parent epic #64 ## Source .planning/code-commenting-guide.md → Migration plan → P1
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: KofTwentyTwo/Jarvis#69