Repository navigation
Closed
Labels
Description
Parent
What to build
Land the foundational multi-controller mechanics through the REST transport, end-to-end. REST is chosen as the tracer because it has the loosest naming rules and the smallest surface, so the foundation can be exercised without dragging EPICS/Tango/GraphQL specifics into this slice. After this slice, a single FastCS process can serve N controllers over REST with stable id-based routes, with subsequent slices adding the other transports atop the same foundation.
Scope:
Controller.idset exactly once by the launcher between__init__andinitialise(). Reading before set raises a clear runtime error; setting twice raises.Controller.__repr__includes the id when set.fastcs.yamlconfig schema:controllers:is a dict keyed by id, each value carrying atype:discriminator and acontroller:options block. Single-class registration may omittype:. The launcher does not hard-code the filename.launch()accepts a list of Controller classes. Type discriminator value defaults to__name__; optionaltype_name: ClassVar[str]overrides.- Uniform
Transport.connect(controller_apis: list[ControllerAPI], loop)signature applied to every transport. Existing transports (EPICS CA, EPICS PVA, GraphQL, Tango) accept a list-of-one and behave as before — they will adopt true multi-controller in subsequent slices. - REST transport routes
GET /{id}/{sub}/{attr}for every configured controller. One combined OpenAPI schema describes all controllers. - Per-transport REST id validator runs at
connect()time; illegal characters fail fast with a clear startup error. - Logging: FastCS startup line lists controller ids;
Controller.__repr__surfaces id. - IPython shell context generalises the existing parallel-top-level-variables pattern (see
src/fastcs/control_system.py:103) to parallel dicts:controllers: dict[id, Controller]andcontroller_apis: dict[id, ControllerAPI]. This satisfies user story 26 without introducing aController.apiback-pointer, leaving ADR 0006 untouched. - Deep modules with their own unit tests:
- D1: Controller registry / discriminator resolution (dynamic Pydantic model, single-class type inference,
type_nameoverrides). - D2: PV-prefix derivation utility (path[0] verbatim, path[1:] snake-to-Pascal). Code lands here; EPICS adopts in EPICS CA multi-root softioc with id-based PV prefix #354.
- D3-REST: REST id validator.
- D1: Controller registry / discriminator resolution (dynamic Pydantic model, single-class type inference,
- New
tests/test_multi_controller.pywith the lifecycle and api-path scenarios from the PRD's testing decisions (id available frominitialise()onward; raises if read in__init__;set_idraises if called twice;controller_apis["X"].path == [id]for root,[id, sub]for sub-controllers). tests/test_launch.pygains targeted cases for type discriminator resolution, single-class type inference, and duplicate-id rejection (handled by Pydantic'sdict[str, ...]).- REST end-to-end test: two controllers wired into one process with distinct route prefixes and no clash.
User stories from #351 covered: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 17, 19, 22, 24, 25, 26, 27, 33.
Acceptance criteria
-
Controller.idlifecycle implemented with the documented errors;__repr__includes id when set -
fastcs.yamlschema parses dict-keyed-by-idcontrollers:block withtype:discriminator and single-class inference -
Transport.connect()signature uniformly takeslist[ControllerAPI]across all transports - REST transport serves
GET /{id}/{sub}/{attr}for every configured controller with a combined OpenAPI schema - REST id validator fails fast with a clear startup error on illegal ids
- FastCS startup log lists controller ids; IPython shell exposes parallel
controllersandcontroller_apisdicts - D1, D2, D3-REST modules each ship with unit tests in this slice
-
tests/test_multi_controller.pycovers the four PRD lifecycle/api-path scenarios via REST -
tests/test_launch.pycovers discriminator resolution, single-class inference, duplicate-id rejection - Existing test suite remains green; existing transports accept the new signature without regression
Blocked by
None - can start immediately
Activity
EPICS CA multi-root softioc with id-based PV prefix