Skip to content

refactor: deepen three architectural seams across auth and metrics#129

Merged
allisson merged 2 commits into
mainfrom
improve-codebase
May 23, 2026
Merged

refactor: deepen three architectural seams across auth and metrics#129
allisson merged 2 commits into
mainfrom
improve-codebase

Conversation

@allisson
Copy link
Copy Markdown
Owner

Summary

  • HashToken absorbed into TokenUseCase — raw bearer tokens now flow directly to Authenticate and Revoke; SHA-256 hashing is an internal implementation detail. TokenService.HashToken removed; TokenHandler and the authentication middleware drop their tokenService dependency.
  • Dead ClientHandler.auditLogUseCase field deleted — the dependency was injected but never called across all 294 lines of the handler; removed from the struct, constructor, and DI wiring.
  • Metrics decorators eliminatedBusinessMetrics inlined into all seven use case structs via a named-return + defer pattern. metrics.Record gains a nil guard so callers pass nil when metrics are disabled. Deleted 10 decorator files (5 implementations + 5 test suites, ~2 500 lines).

Test plan

  • make test — 1 447 unit tests pass
  • make test-with-db — 1 717 tests pass (unit + integration)
  • Confirm deleted decorator tests are not missed: they only tested forwarding behaviour, not business logic

🤖 Generated with Claude Code

allisson and others added 2 commits May 23, 2026 20:18
Three candidates from the architecture review:

1. HashToken absorbed into TokenUseCase — raw bearer tokens flow directly
   to Authenticate/Revoke; SHA-256 hashing is internal. TokenService no
   longer exposes HashToken, and TokenHandler drops its tokenService field.

2. Dead ClientHandler.auditLogUseCase field removed — the dependency was
   injected but never called across all 294 lines of the handler.

3. Metrics decorators eliminated — BusinessMetrics inlined into all seven
   use case structs via a named-return defer pattern. metrics.Record gains
   a nil guard so callers pass nil when metrics are disabled. Deleted 10
   decorator files (5 implementations + 5 test files).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@allisson allisson merged commit c142e3d into main May 23, 2026
3 checks passed
@allisson allisson deleted the improve-codebase branch May 23, 2026 23:31
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