Skip to content

[codex] Add optional staged lifecycle stack - #156

Merged
LimiNode merged 4 commits into
refactor/market-data-router-implementationfrom
feat/lifecycle-stack
Sep 2, 2026
Merged

[codex] Add optional staged lifecycle stack#156
LimiNode merged 4 commits into
refactor/market-data-router-implementationfrom
feat/lifecycle-stack

Conversation

@LimiNode

@LimiNode LimiNode commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • add the optional lifecycle::ILifecycleModule contract for owner-loop modules with process(), idempotent shutdown(), and terminal is_stopped()
  • add a non-owning lifecycle::LifecycleStack that processes dependencies forward and shuts dependents down one stage at a time in reverse registration order
  • integrate MarketDataRouter and BaseTradingPlatform with the common lifecycle interface while preserving their direct APIs
  • keep startup explicit because platform run(bool), component initialize(), and application bot startup do not share one semantic contract
  • add a runnable Router integration example and synchronized canonical English/Russian lifecycle guides

Lifecycle Contract

  • register lower-level dependencies first and dependents last, for example platform -> router -> bot
  • process() runs forward through modules that still participate in the current stage
  • shutdown() starts with the last dependent and does not request shutdown of the next lower module until the current module reports is_stopped()
  • lower-level executors keep processing while asynchronous dependents drain
  • module references are non-owning and must outlive the stack and its complete shutdown
  • the stack is owner-loop confined, creates no thread, owns no retry/timeout policy, and does not call shutdown from its destructor
  • use is optional; direct platform, Router, bot, and node lifecycle calls remain supported

Router Integration

  • MarketDataRouter::is_stopped() maps to its existing is_shutdown_complete() state
  • a stack registered as platform -> router keeps the platform owner loop alive until late subscribe/unsubscribe completions and Router physical cleanup finish
  • failed Router cleanup deliberately keeps the stack non-terminal until the application applies its existing retry policy

Documentation

  • guides/lifecycle-stack.md: canonical English contract
  • guides/lifecycle-stack.ru.md: synchronized Russian contract
  • README, AGENTS, project overview, platform/API guides, implementation notes, build guide, and both Router guides link or summarize the new API

Verification

  • lifecycle_stack_test: 3 passed
  • market_data_router_test: 21 passed
  • market_data_subscriber_base_test: 15 passed
  • lifecycle_event_safety_test: 8 passed
  • header_only_odr_test: 4 passed
  • lifecycle_stack_example: ran successfully and drained a deferred routed unsubscribe
  • project header guard scan: 224 guarded files, bad=0, duplicates=0
  • modified Markdown local-link smoke: 39 file links, missing=0
  • paired lifecycle guide structure: 7 sections and 16 code fences in each language
  • git diff --check

Local MinGW compilation used -Wa,-mbig-obj for large umbrella translation units.

Stack

Depends on #155 (refactor/market-data-router-implementation).

Introduce the optional ILifecycleModule contract and a non-owning LifecycleStack that processes dependencies forward and shuts them down one stage at a time in reverse order. Integrate MarketDataRouter and BaseTradingPlatform, add a routed-cleanup example and focused tests, and document the contract in synchronized English and Russian guides.
Run the lifecycle stack test and example on Ubuntu and Windows smoke jobs. Document that nested lifecycle stacks must remain acyclic while keeping cycle detection outside the optional stack implementation.
@LimiNode
LimiNode marked this pull request as ready for review September 2, 2026 21:31
@LimiNode
LimiNode merged commit 84feeec into refactor/market-data-router-implementation Sep 2, 2026
2 checks passed
@LimiNode
LimiNode deleted the feat/lifecycle-stack branch September 2, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant