P1: Apply commenting style guide to packages/MCP/Sources/MCP/MCPRuntime.swift #68

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

Goal

Bring packages/MCP/Sources/MCP/MCPRuntime.swift up to the standard in .planning/code-commenting-guide.md. Load-bearing actor — MCP server lifecycle, child-process spawn gate, tool registry.

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 MCPRuntime exists, what it owns, threading model)
    • Type-level /// docstring with Overview + Topics + Threading + See Also
    • Method-level docstrings on public + key private methods (spawn, restart, tool list, dispatch)
    • ASCII diagram of MCP server lifecycle (spawn → handshake → tools/list → call/loop → shutdown)
    • "Before you edit" invariants block (FD_CLOEXEC on every long-lived parent FD, minimal env, per-helper codesign / entitlements, share inProcessToolRegistry, never --deep)
    • 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/MCPRuntime.swift` up to the standard in `.planning/code-commenting-guide.md`. Load-bearing actor — MCP server lifecycle, child-process spawn gate, tool registry. ## 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 MCPRuntime exists, what it owns, threading model) - Type-level `///` docstring with Overview + Topics + Threading + See Also - Method-level docstrings on public + key private methods (spawn, restart, tool list, dispatch) - ASCII diagram of MCP server lifecycle (spawn → handshake → tools/list → call/loop → shutdown) - "Before you edit" invariants block (FD_CLOEXEC on every long-lived parent FD, minimal env, per-helper codesign / entitlements, share `inProcessToolRegistry`, never `--deep`) - 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#68