Skip to content

refactor(appkit): introduce CoreServiceRegistry and ServiceLocator#371

Closed
ditadi wants to merge 1 commit into
mainfrom
taskflow/service-registry
Closed

refactor(appkit): introduce CoreServiceRegistry and ServiceLocator#371
ditadi wants to merge 1 commit into
mainfrom
taskflow/service-registry

Conversation

@ditadi
Copy link
Copy Markdown
Contributor

@ditadi ditadi commented May 11, 2026

Stack

Review independently — this PR is groundwork, no behaviour change.


AppKit's core previously ran a hardcoded boot sequence for cache +
telemetry. This refactor introduces a generic registry so the core no
longer names concrete services:

  • CoreServiceFactory<T> — interface every core service implements,
    returning { instance, shutdown } (or null for intentional opt-outs).
  • CoreServiceRegistry — boots a list of factories in declared order,
    shuts down in reverse, doubles as a typed locator via get<T>(name).
  • bootstrap-factories.ts — composes the list _createApp boots,
    living next to the concrete service modules so core/appkit.ts stays
    free of concrete-class imports.

Cache and Telemetry are migrated to expose .factory() static methods
and flow through the registry. Behaviour is identical: same boot order,
same shutdown order, same opt-out semantics.

Plugins now receive a typed services: ServiceLocator through
attachContext, in addition to the existing per-service fields kept
for backwards compatibility (cache, telemetry, plus a taskflow
placeholder typed as unknown for forward compat). New plugins should
consume services.get<T>(name); the named legacy fields are marked
@deprecated.

This PR is groundwork — no behaviour change, no public-API removal.
The purpose is to make room for a third core service (TaskFlow) without
re-threading the cross-package attachContext contract: adding a new
service now only touches the service module and bootstrap-factories.ts.
TaskFlow itself is intentionally NOT in this PR; it lands in a follow-up.

Verified: pnpm -r typecheck, pnpm build, full pnpm test
(122 files, 2255 tests) all green.

Signed-off-by: ditadi victordperd@gmail.com


Stack created with GitHub Stacks CLIGive Feedback 💬

AppKit's core previously ran a hardcoded boot sequence for cache +
telemetry. This refactor introduces a generic registry so the core no
longer names concrete services:

- `CoreServiceFactory<T>` — interface every core service implements,
  returning `{ instance, shutdown }` (or `null` for intentional opt-outs).
- `CoreServiceRegistry` — boots a list of factories in declared order,
  shuts down in reverse, doubles as a typed locator via `get<T>(name)`.
- `bootstrap-factories.ts` — composes the list `_createApp` boots,
  living next to the concrete service modules so `core/appkit.ts` stays
  free of concrete-class imports.

Cache and Telemetry are migrated to expose `.factory()` static methods
and flow through the registry. Behaviour is identical: same boot order,
same shutdown order, same opt-out semantics.

Plugins now receive a typed `services: ServiceLocator` through
`attachContext`, in addition to the existing per-service fields kept
for backwards compatibility (`cache`, `telemetry`, plus a `taskflow`
placeholder typed as `unknown` for forward compat). New plugins should
consume `services.get<T>(name)`; the named legacy fields are marked
`@deprecated`.

This PR is groundwork — no behaviour change, no public-API removal.
The purpose is to make room for a third core service (TaskFlow) without
re-threading the cross-package `attachContext` contract: adding a new
service now only touches the service module and `bootstrap-factories.ts`.
TaskFlow itself is intentionally NOT in this PR; it lands in a follow-up.

Verified: pnpm -r typecheck, pnpm build, full pnpm test
(122 files, 2255 tests) all green.

Signed-off-by: ditadi <victordperd@gmail.com>
@ditadi ditadi requested a review from a team as a code owner May 11, 2026 15:59
@ditadi ditadi requested a review from calvarjorge May 11, 2026 15:59
@ditadi ditadi marked this pull request as draft May 11, 2026 16:00
@ditadi
Copy link
Copy Markdown
Contributor Author

ditadi commented May 11, 2026

Superseded by #374 — replatformed onto git stack with branch name stack/taskflow/service-registry.

@ditadi ditadi closed this May 11, 2026
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