Skip to content

refactor: eliminate primitive obsession, duplicate code, and trivial tests#302

Merged
Aaronontheweb merged 2 commits intodevfrom
claude-wt-code-refactor
Mar 20, 2026
Merged

refactor: eliminate primitive obsession, duplicate code, and trivial tests#302
Aaronontheweb merged 2 commits intodevfrom
claude-wt-code-refactor

Conversation

@Aaronontheweb
Copy link
Copy Markdown
Collaborator

Summary

Comprehensive code quality refactoring addressing primitive obsession, duplicate code, magic strings, trivial tests, and TimeProvider violations.

  • ChannelType enum: Replace magic strings ("slack", "tui", "headless", "signalr", "reminder") with a strongly-typed ChannelType enum across the entire pipeline. Wire boundaries (SignalR hub) parse strings to enum at the edge.
  • SessionId.ToMemoryDomain(): Extract duplicated ResolveDomain logic from 6 files into a single method on the SessionId value object.
  • MemoryCheckpointRequest type safety: Replace raw string SessionId with SessionId value object and string TriggerType with CheckpointTriggerType enum. Add VerifiedToolFinding and CompactionBoundary enum values.
  • SessionOutputTypes constants: Extract 16 magic string discriminators from SessionOutputDtoMapper into compile-time constants.
  • TimeProvider fixes: Inject TimeProvider into SqliteGetMemoriesTool and NullMemoryCheckpointSink.
  • Test cleanup: Delete trivial tests (SubAgentConfigTests, NullScannerTests), consolidate 5 property tests into 1, replace Task.Delay polling with SemaphoreSlim signaling.
  • BuildInfo dedup: Expose ResolveCommitHash from shared BuildInfo and delegate from the daemon facade.

Net result: -65 lines (245 added, 310 removed) across 38 files.

Test plan

  • dotnet build — 0 errors, 0 warnings
  • dotnet test — 1,121 tests passed, 0 failed across 7 test projects
  • Verify CI passes on PR

…tests

Replace magic channel-type strings with a ChannelType enum across the
entire pipeline (IChannel, MessageSource, SessionPipelineOptions,
DeliveryFailed, SessionRegistry, DaemonClient). Wire boundaries (SignalR
hub) parse strings to enum at the edge via TryFromWireValue.

Extract SessionId.ToMemoryDomain() to replace 6 duplicate copies of
ResolveDomain scattered across memory tools, recall coordinator,
LlmSessionActor, and SubAgentActor.

Strengthen MemoryCheckpointRequest by replacing raw string SessionId and
TriggerType with SessionId value object and CheckpointTriggerType enum.
Add VerifiedToolFinding and CompactionBoundary enum values that were
previously inline string literals.

Extract SessionOutputTypes constants from SessionOutputDtoMapper to
prevent typos between ToDto/FromDto discriminator strings.

Fix TimeProvider violations: inject TimeProvider into SqliteGetMemoriesTool
and NullMemoryCheckpointSink instead of using DateTimeOffset.UtcNow and
TimeProvider.System directly.

Replace Task.Delay polling in WebhookNotificationServiceTests with
SemaphoreSlim signaling for deterministic test synchronization.

Deduplicate BuildInfo.ResolveCommitHash by exposing the shared
implementation and delegating from the daemon-specific facade.

Delete trivial tests (SubAgentConfigTests, NullScannerTests) and
consolidate 5 McpToolAdapter property tests into a single fact.
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