process TODO.md step6

This commit is contained in:
SepComet
2026-03-29 09:53:33 +08:00
parent d3d25c8921
commit 4826bf15a5
20 changed files with 668 additions and 10 deletions
@@ -0,0 +1,14 @@
## ADDED Requirements
### Requirement: Multi-session server lifecycle can be owned by a runtime entry point
The multi-session lifecycle model SHALL support being created, owned, and torn down through a concrete server runtime entry point. Starting the entry point MUST provide access to the `MultiSessionManager` through the hosted `ServerNetworkHost`, and stopping the entry point MUST clear managed sessions without requiring callers to remove peers individually.
#### Scenario: Entry point startup exposes multi-session lifecycle ownership
- **WHEN** a server runtime entry point starts successfully
- **THEN** the hosted `ServerNetworkHost` exposes its `MultiSessionManager` for per-peer lifecycle observation
- **THEN** callers do not need to manually construct or inject a separate multi-session coordinator
#### Scenario: Entry point shutdown clears all managed peers
- **WHEN** the server runtime entry point is stopped while one or more managed sessions exist
- **THEN** the hosted `ServerNetworkHost` removes all managed sessions as part of shutdown
- **THEN** no unrelated external cleanup step is required to reset multi-session lifecycle state
@@ -0,0 +1,14 @@
## ADDED Requirements
### Requirement: Server startup and shutdown preserve explicit session lifecycle sequencing
When sessions are hosted through the server runtime entry point, the shared networking layer SHALL preserve explicit startup and shutdown sequencing boundaries for session lifecycle services. The runtime MUST NOT report server startup success until transport startup has completed, and shutdown MUST transition hosted sessions through the existing disconnect/cleanup path instead of abandoning lifecycle state.
#### Scenario: Startup success is reported only after transport startup completes
- **WHEN** a host starts the server runtime entry point
- **THEN** the runtime does not report success before required transport startup finishes
- **THEN** any sessions created after startup begin from the existing server-side lifecycle model
#### Scenario: Shutdown routes through existing lifecycle cleanup
- **WHEN** the caller stops a running server runtime entry point
- **THEN** hosted sessions are disconnected or removed through the existing session lifecycle cleanup path
- **THEN** subsequent lifecycle inspection reflects a stopped runtime rather than stale active sessions
@@ -0,0 +1,35 @@
## ADDED Requirements
### Requirement: Server runtime entry point assembles a host from validated configuration
The shared networking layer SHALL provide a concrete server runtime entry point that accepts validated bootstrap configuration for reliable transport startup and optional sync transport startup. The entry point MUST construct the server host using the existing shared integration components instead of requiring callers to manually assemble transports and session lifecycle services.
#### Scenario: Start server runtime with reliable transport only
- **WHEN** a host starts the server runtime entry point with a valid reliable port and no sync port
- **THEN** the entry point creates a `ServerNetworkHost` using the shared networking integration path
- **THEN** the reliable transport is started and the runtime exposes the started host to the caller
#### Scenario: Start server runtime with reliable and sync transports
- **WHEN** a host starts the server runtime entry point with both reliable and sync ports configured
- **THEN** the entry point creates the server host with both transport lanes configured
- **THEN** the runtime starts both transports before reporting startup success
### Requirement: Server runtime entry point owns startup failure rollback and shutdown
The server runtime entry point SHALL own startup/shutdown sequencing for the created server host. If startup fails after any transport or host resource has begun initializing, the entry point MUST stop already-started resources before surfacing the failure. The shutdown path MUST be safe to call repeatedly and MUST leave the server host with no remaining managed sessions.
#### Scenario: Startup failure rolls back started resources
- **WHEN** reliable transport startup succeeds and a later startup step fails before the runtime reports success
- **THEN** the entry point stops the already-started transport resources
- **THEN** the failure is surfaced to the caller without leaving a partially running server runtime
#### Scenario: Repeated shutdown is safe
- **WHEN** the caller stops the server runtime entry point more than once
- **THEN** shutdown does not throw because the runtime was already stopped
- **THEN** the underlying server host remains in a fully stopped state with its managed sessions cleared
### Requirement: Server runtime entry point exposes the integration surface needed by host processes
The server runtime entry point SHALL expose the started `ServerNetworkHost` and the minimal runtime handle required for host processes to drive message draining, lifecycle evaluation, and eventual shutdown.
#### Scenario: Host process drives the shared server lifecycle through the runtime handle
- **WHEN** startup completes successfully
- **THEN** the caller can access the started `ServerNetworkHost` through the runtime handle
- **THEN** the caller can use that handle to invoke message draining, lifecycle updates, and shutdown without reconstructing networking components