Skip to content

refactor: route Global path consumers through the service - #41632

Merged
kitlangton merged 5 commits into
v2from
refactor/global-service-consumers
Aug 11, 2026
Merged

refactor: route Global path consumers through the service#41632
kitlangton merged 5 commits into
v2from
refactor/global-service-consumers

Conversation

@kitlangton

@kitlangton kitlangton commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

What

  • Shrink production use of static Global.Path to the logging bootstrap and Global.make() internals.
  • Route application-graph path consumers through the acquired Global.Service.
  • Make database migrations declare Global.Service in their effect environment instead of reading a module-scope static path.

Why

Static paths are names only and do not carry acquisition guarantees. Import-time directory creation was removed in #41619, while Global.Service guarantees acquired directories and a canonical temporary directory. Declared service dependencies are also injectable and testable.

How

  • Database path resolution, models.dev caching, ripgrep installation, formatter executable discovery, shell selection, and PTY/command shell resolution now use a graph-provided Global service. The synchronous which helper receives the acquired bin path from its callers.
  • Mini host paths are passed from the CLI handler's Global service, and managed server startup changes directory through the same provided service graph.
  • Migration effects may require Global.Service; the runner lets that single requirement propagate through its transactions so the enclosing application or test runtime provides it once. The legacy credential migration and V1 migration use the acquired data path, and migration tests inject a fake Global value through their suite helpers.
  • TUI theme discovery receives the acquired config directory from Tui.run rather than reading the static path table.
  • The server application graph exposes its configured Global.node alongside Database and the other application services, so V1Migration.layer receives the same acquired instance. This also keeps embedded SDK runtimes self-contained: without Global in the server context, createEmbeddedRoutes leaked an unsatisfied environment into ManagedRuntime.make and SDK construction failed to typecheck.
  • Downstream tests that construct Database layers directly now provide the newly declared dependency through their existing fixtures.

Testing

  • bunx tsgo --noEmit in packages/util, packages/core, and packages/cli
  • bun run typecheck in packages/tui, packages/server, and packages/sdk-next
  • Pre-push bun turbo typecheck --concurrency=3: 33/33 packages passed
  • Full core suite before the simplify follow-up: 1,634 passed, 16 skipped, 0 failed. The follow-up run passed 1,633 with 16 skipped; its sole failure was an unrelated plugin fixture assertion polluted by two plugins in the machine's current OpenCode config, and it reproduced in isolation.
  • Focused database migration, V1 migration, models.dev, ripgrep, formatter, shell, command, PTY, session-create, mini-host, TUI theme, server process, SDK embedded, and util tests passed
  • CLI service suite: 24 passed; one failed-service registration case timed out identically on unmodified origin/v2 in this local environment

@kitlangton
kitlangton merged commit 41c5853 into v2 Aug 11, 2026
10 checks passed
@kitlangton
kitlangton deleted the refactor/global-service-consumers branch August 11, 2026 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant