82: Remove lifecycle operations from the TickerService API

This commit is contained in:
2026-09-03 20:34:49 +02:00
parent 461044a998
commit ddbf6f047d
11 changed files with 155 additions and 34 deletions
@@ -5,7 +5,7 @@
Provide AssetAZ callers with typed latest prices backed by explicitly enabled, durable observation histories.
## Requirements
### Requirement: Price sources are discovered and lifecycle-managed
Nenjim SHALL be able to construct and register each price source independently in an initialized but unstarted state without supplying a ticker or sink. The ticker SHALL receive the public Nenjim Registry through constructor injection and resolve its explicitly configured `PriceSource` component IDs, while ordinary ticker clients SHALL NOT receive a public operation for adding or managing sources. The ticker SHALL fail clearly when a configured ID is missing or names a component that does not implement `PriceSource`; it SHALL NOT silently select the first source listed for the interface. The ticker SHALL identify each resolved source by its `TradingPair` and stable source name, reject duplicate identities clearly, start each active source by passing itself as `PriceSink`, and stop every source it started. Source names SHALL be non-empty safe directory components and SHALL reject `/`, `\`, `..`, and control characters without rewriting them. A source SHALL announce typed prices and timestamps only through the sink received at start and SHALL remain unaware of its persistence path. A repeated source start SHALL reject the call before replacing its existing sink.
Nenjim SHALL be able to construct and register each price source independently in an initialized but unstarted state without supplying a ticker or sink. The ticker SHALL receive the public Nenjim Registry through constructor injection and resolve its explicitly configured `PriceSource` component IDs, while ordinary ticker clients SHALL receive only the latest-price domain API and SHALL NOT receive public source-registration, start, stop, restart, or other lifecycle operations. The same reference implementation object SHALL implement both `TickerService` and `NenjimProcess`; the Hub SHALL start it only through its `NenjimProcess` view. The ticker SHALL fail clearly when a configured ID is missing or names a component that does not implement `PriceSource`; it SHALL NOT silently select the first source listed for the interface. The ticker SHALL identify each resolved source by its `TradingPair` and stable source name, reject duplicate identities clearly, and start each active source by passing itself as `PriceSink`. If startup fails, the ticker SHALL stop every source already started during that attempt before reporting the failure, but SHALL expose no general Ticker stop operation. Source names SHALL be non-empty safe directory components and SHALL reject `/`, `\`, `..`, and control characters without rewriting them. A source SHALL announce typed prices and timestamps only through the sink received at start and SHALL remain unaware of its persistence path. A repeated source start SHALL reject the call before replacing its existing sink.
#### Scenario: Sources are constructed independently
- **WHEN** the NenjimHub constructs and registers a price source before constructing or starting the ticker
@@ -21,7 +21,11 @@ Nenjim SHALL be able to construct and register each price source independently i
#### Scenario: Ordinary clients cannot manage sources
- **WHEN** a caller uses the public `TickerService` contract
- **THEN** the contract exposes ticker lifecycle and latest-price queries but no source-registration operation
- **THEN** the contract exposes only latest-price queries and no source-registration, start, stop, restart, or other lifecycle operation
#### Scenario: Hub starts Ticker through its process view
- **WHEN** the configured Ticker process is reached in the Hub startup plan
- **THEN** the same object registered as `TickerService` and `NenjimProcess` is started through `NenjimProcess`
#### Scenario: Distinct configured sources are accepted
- **WHEN** the ticker resolves two configured sources with different source names or trading pairs
@@ -36,8 +40,8 @@ Nenjim SHALL be able to construct and register each price source independently i
- **THEN** ticker initialization or startup fails clearly without rewriting the source name or creating filesystem content
#### Scenario: Active source lifecycle is managed
- **WHEN** the ticker starts and later stops with an active Registry-resolved source
- **THEN** it calls `start` with itself as `PriceSink` and subsequently stops the source without leaving source-owned resources running
- **WHEN** one active source starts successfully and a later active source makes Ticker startup fail
- **THEN** the ticker stops every source started during that attempt and reports the startup failure without exposing a general stop operation
#### Scenario: Repeated source start preserves existing sink
- **WHEN** an already-started source receives another start call with a different sink