Skip to content

Code refactor - Phase 1#5

Merged
johnwatso merged 35 commits intomainfrom
CodeRefactor
Mar 13, 2026
Merged

Code refactor - Phase 1#5
johnwatso merged 35 commits intomainfrom
CodeRefactor

Conversation

@johnwatso
Copy link
Copy Markdown
Owner

The goal was to break up AppModel.swift and DiscordService.swift into smaller services and reduce the amount of logic living in those files.

Major extractions
• Gateway parsing → GatewayEventDispatcher.swift
• WebSocket transport → DiscordGatewayConnection.swift
• Command execution → CommandProcessor.swift
• Rule pipeline → RuleExecutionService.swift
• AI → DiscordAIService.swift
• Wiki → WikiLookupService.swift

Discord REST split into clients
• DiscordMessageRESTClient
• DiscordGuildRESTClient
• DiscordInteractionRESTClient
• DiscordIdentityRESTClient

State stores extracted
• VoicePresenceStore (app-side voice tracking)
• VoiceRuleStateStore (Discord rule timing state)

Safety / architecture guarantees kept intact
• SwiftMesh ownership unchanged (AppModel+Gateway.swift still owns mesh sync + requests)
• Dual output safety model preserved:
• ActionDispatcher.canSend
• DiscordService.outputAllowed

Facade cleanup
AppModel now shares AI, wiki, identity, message, and guild clients directly, so read-only operations no longer route through DiscordService. Output helpers (typing, reactions, pin/unpin, threads) now go through the same guarded send path.

Testing
Throughout the refactor I repeatedly ran:
• swift build
• targeted unit tests for new services
• mesh safety gates:
• MeshSyncTests
• MeshFailoverTests
• ClusterSecurityTests

Overall result: DiscordService is now significantly slimmer and the codebase is much more modular.

@johnwatso johnwatso merged commit 1f8e341 into main Mar 13, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant