|
| 1 | +## ADDED Requirements |
| 2 | + |
| 3 | +### Requirement: Standardized module lifecycle states and lazy activation |
| 4 | +Runtime modules SHALL follow a Loaded/Active/Error state machine, gate initialization on host binding, and lazily activate detail views. |
| 5 | + |
| 6 | +#### Scenario: Host not bound keeps module Loaded |
| 7 | +- **WHEN** a module is discovered/installed and the host is not yet bound |
| 8 | +- **THEN** the runtime loads manifest/menu metadata only |
| 9 | +- **AND** marks the module state as `Loaded` |
| 10 | +- **AND** defers module initialization, services, and detail view creation. |
| 11 | + |
| 12 | +#### Scenario: Host binding activates eligible modules |
| 13 | +- **WHEN** the host binds |
| 14 | +- **THEN** the runtime initializes all Ready+enabled modules using the lifecycle pipeline |
| 15 | +- **AND** updates their state to `Active` upon success |
| 16 | +- **AND** records diagnostics for any module that fails to activate. |
| 17 | + |
| 18 | +#### Scenario: Lazy detail load on first navigation |
| 19 | +- **WHEN** a user first navigates to a module’s detail view |
| 20 | +- **THEN** the runtime asynchronously loads and renders the module detail/page |
| 21 | +- **AND** supports cancellation/timeout for the detail load |
| 22 | +- **AND** surfaces errors and sets the module state to `Error` if detail load fails. |
| 23 | + |
| 24 | +#### Scenario: Initialization failure transitions to Error |
| 25 | +- **WHEN** module initialization or detail load fails |
| 26 | +- **THEN** the module state becomes `Error` |
| 27 | +- **AND** diagnostics are recorded for recovery |
| 28 | +- **AND** the module is not reused until a retry/repair is attempted. |
| 29 | + |
| 30 | +### Requirement: Unified unload and cleanup pipeline |
| 31 | +Runtime modules MUST expose and execute a standardized cleanup path on unload/disable to remove registrations and release resources. |
| 32 | + |
| 33 | +#### Scenario: Unload cleans registrations and resources |
| 34 | +- **WHEN** a non-system module is unloaded or disabled |
| 35 | +- **THEN** the runtime invokes module-provided deregistration hooks for menus/navigation/messages/subscriptions |
| 36 | +- **AND** disposes the module-scoped ServiceProvider, caches, and other scoped resources |
| 37 | +- **AND** removes the module’s UI/navigation projections from the host |
| 38 | +- **AND** unloads the module AssemblyLoadContext and returns the module to the `Loaded` state (metadata only). |
| 39 | + |
| 40 | +#### Scenario: System modules protected from unload |
| 41 | +- **WHEN** an unload is requested for a system module |
| 42 | +- **THEN** the runtime rejects the request with a clear diagnostic. |
0 commit comments