Skip to content

[refactor] Remove type pollution from ports with explicit boundary DTOs #111

@kangeunchan

Description

@kangeunchan

Enhancement Description

Replace interface{}-based port APIs with explicit boundary DTOs to restore type safety and correct dependency direction.

Background

Ports currently use interface{} in signatures and import plugin types, undermining compile-time safety and violating dependency inversion.

Scope

Replace interface{} in ports with explicit DTOs

  • Files: internal/application/ports/provisioner.go
  • Files: internal/application/ports/repositories.go
  • Files: internal/application/ports/services.go

Introduce boundary DTOs and adapters

  • Files: internal/application/dto/** (new, if needed)
  • Files: internal/infrastructure/** (adapters converting plugin/infrastructure types to DTOs)

Remove plugin imports from ports

  • Files: internal/application/ports/provisioner.go

Non-Goals

  • Changing semantics of port methods beyond type changes
  • Broad renaming across public APIs (keep changes minimal and localized)
  • Refactoring unrelated infrastructure code

Risks and Open Questions

  • DTO design must be stable and not leak infrastructure/plugin concerns
  • Adapter conversions must be well-tested to avoid subtle field mapping bugs
  • Some interface{} usage may be entrenched; prioritize most harmful ones first if needed

Validation Plan

Unit and Integration Checks

  • go test ./... for ports, adapters, and affected use cases
  • Unit tests ensuring DTO mapping correctness
  • Compile-time checks confirming ports are plugin-free

End-to-End Checks

  • Smoke: provisioning and other port-using flows still function
  • Ensure no runtime type assertions remain in application layer

Evidence Required in Issue Updates

  • Before/after examples of port signatures
  • Evidence that ports no longer import plugin packages (go list/grep snippet)

Acceptance Criteria

  • Zero interface{} in port signatures (logging varargs excluded)
  • Ports do not import plugin packages
  • All conversions occur in adapters
  • Compiler/IDE type support improved (no type assertions in app layer)

Deliverables

  • PR introducing DTOs and updating ports
  • PR updating infrastructure adapters and wiring

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions