P1: Apply commenting style guide to packages/Bus/Sources/Bus/WebviewBridge.swift #67

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

Goal

Bring packages/Bus/Sources/Bus/WebviewBridge.swift up to the standard in .planning/code-commenting-guide.md. Load-bearing actor — Swift ↔ JS typed message bus, protocol version gating, harness parity.

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 this bridge exists, transport, protocol version contract)
    • Type-level /// docstring with Overview + Topics + Threading + See Also
    • Method-level docstrings on public + key private methods (send, receive, protocol negotiation)
    • ASCII diagram of message flow (Swift → WKScriptMessageHandler → JS dispatcher, and the inbound path)
    • "Before you edit" invariants block (bus-harness parity, no evaluateJavaScript outside the gated path, protocol version bump rules, single-writer HudState invariant)
    • 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/Bus/Sources/Bus/WebviewBridge.swift` up to the standard in `.planning/code-commenting-guide.md`. Load-bearing actor — Swift ↔ JS typed message bus, protocol version gating, harness parity. ## 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 this bridge exists, transport, protocol version contract) - Type-level `///` docstring with Overview + Topics + Threading + See Also - Method-level docstrings on public + key private methods (send, receive, protocol negotiation) - ASCII diagram of message flow (Swift → WKScriptMessageHandler → JS dispatcher, and the inbound path) - "Before you edit" invariants block (bus-harness parity, no `evaluateJavaScript` outside the gated path, protocol version bump rules, single-writer HudState invariant) - 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#67