2.5 KiB
2.5 KiB
id, title, status, wave, depends_on, plan
| id | title | status | wave | depends_on | plan | |||
|---|---|---|---|---|---|---|---|---|
| task-05 | Registry + service + lifecycle state machine + Provide | pending | 2 |
|
docs/plans/plugins/plan.md |
Registry + service + lifecycle state machine + Provide
Title
The core plugin Service: in-memory registry loaded from the FS store, lifecycle
state machine, and a Provide(...) constructor following the repo provider pattern.
Inputs
- Spec
docs/specs/plugins/requirements/plugins.md→ "State machine" (registered→active→ disabled→uninstalled, error branch), "Permissions", registration flow. - Depends on:
internal/plugins/manifest(task-01),internal/plugins/store(task-02),internal/plugins/state(task-03). - Provider pattern reference:
internal/jira/provider.goProvide(...) (*Service, cleanup, error)and howinternal/backendapp/services.goinitJiraServicecalls it.
Acceptance
internal/plugins/registry.go:Registrywrappingmap[string]*store.Recordwith mutex;Load()from FS store,Get,List,Add,Remove,SetStatus.internal/plugins/service.go:Servicewith methodsRegister(manifest) (*store.Record, store.Credentials, error),List(),Get(id),UpdateConfig(id, map),Uninstall(id),Enable(id),Disable(id),SetStatus(id, status),AuthenticatePlugin(apiKey) (*store.Record, error). Status transitions enforce the spec state machine (reject invalid transitions with a typed error).internal/plugins/provider.go:Provide(cfg, stateDB, secretAdapter, eventBus, log) (*Service, func() error, error)constructing FS store (dir~/.kandev/plugins, overridable via cfg/env for tests), state store, registry (Load on startup). Health poller + delivery are wired in later tasks — expose setters/fields so task-06/07 can attach.- Status enum +
Statustype ininternal/plugins/types.go.
Files
apps/backend/internal/plugins/types.goapps/backend/internal/plugins/registry.go+registry_test.goapps/backend/internal/plugins/service.go+service_test.goapps/backend/internal/plugins/provider.go+provider_test.go
Verification
go test ./internal/plugins/...fromapps/backendmake -C apps/backend lint
Output contract
Report: state-machine transition table implemented, Provide signature (so wiring task-09 matches), extension points left for delivery/health. Do not edit manifest/store/state packages (import only).
Dependencies
task-01, task-02, task-03.