Skip to content

feat(runtime): align platform runtime contexts#31

Merged
magic-alt merged 1 commit into
mainfrom
feature/platform-runtime-alignment
May 21, 2026
Merged

feat(runtime): align platform runtime contexts#31
magic-alt merged 1 commit into
mainfrom
feature/platform-runtime-alignment

Conversation

@magic-alt
Copy link
Copy Markdown
Owner

Summary

  • Add BacktestRuntime, SandboxRuntime, and LiveRuntime contexts that boot shared kernel services.
  • Align MetricCollector and Tracer with the V6 MetricsPort and TracerPort contracts.
  • Add /api/v2/info exposing API version, contract_version, and runtime policy metadata.
  • Update architecture/API docs and CHANGELOG.

PR 28/29/30 Checks

  • Re-ran engines, adapters, and plugin SDK regression tests.
  • No issues found requiring fixes.

Tests

python -m pytest tests/test_runtime_contexts.py tests/test_api_v2_observability.py \
  tests/engines/test_engines_layer.py tests/test_adapters_convergence.py \
  tests/test_plugin_spi_sdk.py -v
powershell -ExecutionPolicy Bypass -File scripts/local_ci.ps1 -Jobs test -SkipInstall

Result: 1274 passed, 35 skipped

Copilot AI review requested due to automatic review settings May 21, 2026 00:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces V6 “runtime contexts” (Backtest/Sandbox/Live) as thin wrappers that boot a shared kernel service set, aligns the in-process observability utilities (MetricCollector, Tracer) to the V6 MetricsPort/TracerPort contracts, and adds a new /api/v2/info endpoint exposing contract/runtime metadata for operational introspection.

Changes:

  • Added BacktestRuntime, SandboxRuntime, and LiveRuntime contexts that register runtime/metrics/tracer/plugin-registry into a PlatformKernel lifecycle.
  • Updated MetricCollector and Tracer to satisfy MetricsPort and TracerPort (tagged metrics + context-managed spans with attributes).
  • Added /api/v2/info plus corresponding docs and tests; updated CHANGELOG.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_runtime_contexts.py Adds tests for runtime context policy metadata, kernel boot lifecycle, and port conformance.
tests/test_api_v2_observability.py Extends API v2 tests to validate /api/v2/info and refactors span assertion formatting.
src/runtime/contexts.py Implements the runtime context classes and lifecycle integration with PlatformKernel.
src/runtime/init.py Exposes runtime context API at src.runtime.
src/platform/runtime.py Adds platform-layer re-exports for runtime contexts.
src/platform/api_v2.py Wires runtime contexts into the API app state and adds /api/v2/info.
src/core/monitoring.py Updates tracer spans to be context managers with attributes; adds tagged metric helpers to match ports.
docs/architecture/open-platform.md Documents Phase 6 runtime contexts and /api/v2/info.
docs/ARCHITECTURE_TARGET_STATE.md Updates target-state architecture notes to include runtime contexts and /api/v2/info.
docs/api/rest-api.md Adds /api/v2/info to the endpoint overview.
CHANGELOG.md Records the new runtime contexts, observability alignment, /api/v2/info, and related tests.
Comments suppressed due to low confidence (1)

src/runtime/contexts.py:151

  • _on_stop only records the stop counter when self.metrics is a concrete MetricCollector. If a custom MetricsPort is injected, runtime stop metrics will be silently skipped. Consider calling self.metrics.incr(...) directly to honor the port abstraction.
        self.state = RuntimeState.STOPPED
        if isinstance(self.metrics, MetricCollector):
            self.metrics.incr("runtime_stop_total", tags={"runtime": self.mode.value})

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/platform/api_v2.py
Comment on lines +307 to +315
return ApiEnvelope(
data={
"name": "Unified Quant Platform",
"version": app.version,
"contract_version": CONTRACT_VERSION,
"runtimes": {
name: runtime.info()
for name, runtime in request.app.state.runtime_contexts.items()
},
Comment thread src/runtime/contexts.py
Comment on lines +139 to +143
if isinstance(self.metrics, MetricCollector):
self.metrics.incr("runtime_start_total", tags={"runtime": self.mode.value})
if isinstance(self.tracer, Tracer):
with self.tracer.start_span(
f"runtime.{self.mode.value}.start",
Comment thread src/runtime/contexts.py
Comment on lines +72 to +76
self.plugin_registry = plugin_registry or PluginRegistry(
contract_version=CONTRACT_VERSION
)
self.config = self._build_config(config or {})
self.state = RuntimeState.CREATED
@magic-alt magic-alt merged commit ab87e7e into main May 21, 2026
14 checks passed
@magic-alt magic-alt deleted the feature/platform-runtime-alignment branch May 21, 2026 01:10
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.

2 participants