Skip to content

Feat/169 hot reload config - #187

Merged
elizabetheonoja-art merged 2 commits into
Utility-Protocol:mainfrom
Chigybillionz:feat/169-hot-reload-config
Aug 22, 2026
Merged

Feat/169 hot reload config#187
elizabetheonoja-art merged 2 commits into
Utility-Protocol:mainfrom
Chigybillionz:feat/169-hot-reload-config

Conversation

@Chigybillionz

Copy link
Copy Markdown
Contributor
**PR Title**
Feat: Implement hot-reload configuration management with schema validation

**PR Description**

**Summary**
This PR introduces a system-wide runtime configuration manager with hot-reloading capabilities, allowing the application to dynamically fetch, validate, and apply configuration changes (e.g., canary routing percentages, telemetry modes) without requiring server restarts or page reloads.

Issue
Closes #169

Root Cause
Previously, configurations were exclusively bound to build-time or load-time process.env variables. This static approach blocked the ability to dynamically orchestrate blue-green deployments or toggle features in real-time across the client-side system.

**Solution Implemented**
Implemented a `ConfigurationManager` singleton that actively polls a remote configuration source. Incoming payloads are strictly validated against our existing `RUNTIME_CONFIG_RULES` definitions to guarantee schema compliance. The configuration state is seamlessly propagated to the UI layer using a new `useRuntimeConfig` hook, powered by React 19's `useSyncExternalStore` for optimized, tear-free rendering.

**Key Changes**
- Created `ConfigurationManager` for background polling and schema validation.
- Created `useRuntimeConfig` hook to consume the dynamic config state.
- Updated `RuntimeConfigAuditPanel` to calculate audit drift in real-time based on the hot-reloaded state.
---
**Affected Files**
- `src/config/ConfigurationManager.ts` — [Added core polling, validation, and event-emitting logic]
- `src/hooks/useRuntimeConfig.ts` — [Added React bridge hook for real-time updates]
- `src/components/ops/RuntimeConfigAuditPanel.tsx` — [Refactored to consume the dynamic config hook]
- `tests/config/ConfigurationManager.test.ts` — [Added unit tests for manager logic]
- `tests/hooks/useRuntimeConfig.test.ts` — [Added unit tests for hook initialization]

**Trade-offs / Considerations**
- **Schema Validation Library:** Rather than introducing a new dependency like `zod` specifically for this, the manager re-uses the existing `parseRuntimeConfigValue` utilities in `runtimeConfigAudit.ts`. This satisfies the security/schema requirements while keeping the bundle size small.
- **Polling vs WebSockets:** Implemented standard polling (every 30s by default) as the initial transport layer. This can easily be swapped out for SSE or WebSockets in the `ConfigurationManager` if the latency requirement dictates it in the future.
- **Infrastructure:** The actual blue-green/canary rollout strategies mentioned in the ticket will require DevOps to implement the corresponding backend routing. This PR handles the client-side consumption of those dynamically shifting configurations.

Testing
Unit tests were written for both the ConfigurationManager and the useRuntimeConfig hook.

Please comfirm the changes!

@elizabetheonoja-art
elizabetheonoja-art merged commit ba047c3 into Utility-Protocol:main Aug 22, 2026
5 of 11 checks passed
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.

Configuration Management with Hot-Reload and Schema Validation

2 participants