Skip to content
This repository was archived by the owner on Oct 16, 2026. It is now read-only.

Reduce code-health debt: Swift format, dedupe, coverage (#26) - #45

Merged
sarthakagrawal927 merged 3 commits into
mainfrom
claude/motion-26-debt
Oct 8, 2026
Merged

sarthakagrawal927 merged 3 commits into
mainfrom
claude/motion-26-debt

Conversation

@sarthakagrawal927

Copy link
Copy Markdown
Member

Progress on #26 (does not close it).

What changed

  • Swift formatting. Adds .swift-format with the Fleet Swift convention already used by pace, live and significanthobbies (4 spaces, 120 columns, keep existing line breaks), then applies swift-format format. The changes are whitespace, line breaks, and semicolon and multi-declaration splits only. The ratchet now passes --configuration .swift-format explicitly.
    • Measured against the old implicit default (2 spaces, 100 columns), main has 4,553 diagnostics. Against the adopted config, main has 363 before formatting and 8 after.
    • The 8 left are lint-only: 7 SCREAMING_CASE constants, which are kept because they mirror protocol.ts and dev config, and 1 @retroactive Identifiable on URL.
  • Swift refactors (behavior-preserving).
    • Split CompositeExporter.export (parked v2) from 180 lines to 97 by extracting helpers for head-trim, the camera-inset transform, the video composition, the timeline and the export session.
    • Moved the add-only Photos save into a shared PhotosVideoSaver, used by ScreenRecorder (v1) and RecordingController (parked v2). Messages, add-only permission and state transitions are unchanged.
    • Dropped one unused SwiftUI environment read.
  • TypeScript duplication. Moved the shared score-HUD preamble and hand-joint lookup into games/canvas-utils, which removes all 3 TS clone groups.
  • Tests (no snapshots). Covers:
    • the relay server: join/role enforcement, presence, direction-gated relay, ping/pong, pose rate limit, send-after-close
    • the native JS bridge
    • the keyboard debug controller
    • canvas helpers
    • the update logic of Reach & Dodge, Slice and Motion Maker, made deterministic by mocking Math.random

Ratchets (before → after)

Gate Before After
Coverage lines / branches / functions / statements 6.43 / 10.12 / 7.01 / 6.53 % 39.46 / 37.76 / 43.55 / 39.95 % (min set to 39.4 / 37.7 / 43.5 / 39.9)
Complexity violations / max length 3 / 180 2 / 149
Duplication groups / lines 5 / 65 0 / 0
Swift-format diagnostics 4,553 8
Periphery findings 68 66

Checks

  • pnpm check passes: 17 files, 82 tests, format/lint/typecheck/build, plus the coverage, unused, complexity, duplication, cycles, dependency (0 critical/high), suppression and hygiene gates.
  • Local unsigned simulator build (xcodegen generate && pod install --deployment + xcodebuild ... CODE_SIGNING_ALLOWED=NO build) succeeds. pnpm quality:swift passes with MOTION_INDEX_STORE set (Periphery 3.8.0).

Not done (still on #26)

  • The 2 remaining complexity violations are in PoseEstimator (buildAndEmit, computeHands). That is the live v1 Vision hot path, so I left it until it can be checked on a device.
  • PartyKit's esbuild 0.21.5 moderate advisory.
  • iOS test target.
  • The other 66 Periphery findings. Most are parked-v2 recording/protocol-mirror code, which is kept on purpose.
  • Camera/ReplayKit verification on a physical device.

🤖 Generated with Claude Code

sarthakagrawal927 and others added 3 commits October 9, 2026 02:19
Adopt the Fleet Swift convention (4-space indent, 120 columns, as in pace,
live and significanthobbies) and apply swift-format. Formatting is
behavior-neutral: whitespace, line breaks, semicolon and multi-declaration
splits only.

Extract helpers from the parked v2 CompositeExporter.export (180 -> 97
lines) and share the add-only Photos save step between ScreenRecorder (v1)
and RecordingController (parked v2) via PhotosVideoSaver. Messages, the
add-only permission scope and state transitions are unchanged. Drop one
unused SwiftUI environment read in SetupView.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the shared score-HUD preamble and hand-joint lookup into
games/canvas-utils, removing the three TypeScript clone groups.

Add behavior tests for the relay server (join/role enforcement, presence,
direction-gated relay, ping, pose rate limit, send-after-close), the native
JS bridge, the keyboard debug controller, canvas helpers, and the update
logic of Reach & Dodge, Slice and Motion Maker (deterministic via a mocked
Math.random).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
coverage lines 6.4 -> 39.4, branches 10.06 -> 37.7, functions 7.01 -> 43.5,
statements 6.49 -> 39.9; complexity violations 3 -> 2, max length 180 -> 149;
duplication 5 groups / 65 lines -> 0; Swift format 4553 -> 8 diagnostics
(now explicitly against .swift-format); Periphery 68 -> 66 findings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sarthakagrawal927
sarthakagrawal927 merged commit 11041e8 into main Oct 8, 2026
2 checks passed
@sarthakagrawal927
sarthakagrawal927 deleted the claude/motion-26-debt branch October 16, 2026 19:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant