Skip to content

refactor: eliminate global state dependencies with explicit injection#123

Open
kangeunchan wants to merge 2 commits intoaltuslabsxyz:mainfrom
kangeunchan:refactor/eliminate-global-state
Open

refactor: eliminate global state dependencies with explicit injection#123
kangeunchan wants to merge 2 commits intoaltuslabsxyz:mainfrom
kangeunchan:refactor/eliminate-global-state

Conversation

@kangeunchan
Copy link
Collaborator

Enhancement Description

Eliminate global state dependencies by replacing global logger/registry usage with explicit dependency injection.

Summary

This PR removes global mutable dependencies from critical paths and makes initialization/wiring explicit.

Previously, global dependencies created hidden coupling:

  • logger usage depended on global defaults in multiple packages
  • registry/service lookups were not fully explicit
  • tests required broader setup due to implicit shared state

Now collaborators are passed explicitly through constructors/wiring.

What Changed

1) Replaced global logger usage with injected loggers

Updated across application/daemon/infrastructure paths including:

  • internal/application/service.go
  • internal/application/version/service.go
  • internal/daemon/server/server.go
  • internal/infrastructure/* (targeted logger call sites)

2) Replaced global registry access with explicit dependencies

Updated daemon/server and related wiring:

  • internal/daemon/server/network_service.go
  • internal/daemon/server/plugins.go
  • internal/daemon/server/wiring.go

3) Updated composition roots and startup wiring

Updated:

  • cmd/devnet-builder/main.go
  • internal/di/container.go
  • internal/di/container_v2.go

4) Tests

Added/updated tests:

  • internal/daemon/server/network_service_test.go
  • internal/daemon/server/wiring_test.go
  • tests/unit/resume_usecase_test.go

Why This Is Needed

This is a reliability and testability refactor.
Removing global state improves isolation, reduces hidden side effects, and clarifies lifecycle boundaries.

Behavior Notes / Regression Impact

No intentional feature/CLI behavior change.
Initialization paths are now explicit and easier to reason about.

Validation Performed

  • go test ./internal/daemon/server/...
  • go test ./internal/application/...
  • go test ./...
  • golangci-lint run

Signed-off-by: kangeunchan <kangeunchan080310@gmail.com>
… loggers

Signed-off-by: kangeunchan <kangeunchan080310@gmail.com>
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