Skip to content

feat: add pluggable config layers and strategy registries#12

Merged
Sunnylincc merged 4 commits intomainfrom
codex/add-pluggable-configuration-system
Mar 5, 2026
Merged

feat: add pluggable config layers and strategy registries#12
Sunnylincc merged 4 commits intomainfrom
codex/add-pluggable-configuration-system

Conversation

@Sunnylincc
Copy link
Owner

@Sunnylincc Sunnylincc commented Mar 5, 2026

Motivation

Evolve the existing flat configuration into a composable configuration layer to support separation and extensibility across runtime, storage, model, and router components.

Eliminate hard-coded strategy branches in the codebase (router/distill/storage/consolidation) and replace them with a plugin-style registry system to enable easier extension and implementation replacement.

Support configuration merging between environment variables and programmatic configuration, with clear precedence rules, and print the final effective configuration at startup for easier debugging.

Introduce configuration validation to detect invalid combinations early (e.g., mismatched embedder dimensions or SQLite limitations with very small embedding dimensions).

Description

Split HippoConfig into four layered dataclasses:
RuntimeConfig, StorageConfig, ModelConfig, and RouterConfig, while preserving compatibility accessors for legacy flat fields (e.g., db_path, embedding_dim, working_memory_turns).
(hippocortex/config.py)

Added merged() to combine environment-derived configuration (HippoConfig.from_env()) with code-provided configuration, where code configuration overrides environment values.
Added validate() to detect invalid configuration combinations.
(hippocortex/config.py)

Introduced a strategy registry module hippocortex/registry.py, providing registration and lookup interfaces for router/distill/storage/consolidation strategies.
Default implementations are registered (memory_v1, auto/heuristic/llm, memory/sqlite, replay_v1).
(hippocortex/registry.py)

Updated ReplayConsolidator to support configurable distill_strategy and strategy_name.
The distillation function is now resolved via the registry at runtime instead of being hard-coded.
(hippocortex/consolidation/replay.py)

Refactored HippoCortex initialization to construct semantic_store, router, and consolidator via the registry.
Added validation to ensure the embedder dimension matches the configured dimension, and print the final effective configuration during startup.
The default() method now uses HippoConfig.from_env().merged(config) to implement environment + code override logic.
(hippocortex/init.py)

Added and updated tests to cover the new features and validation logic, including a new test module tests/test_config_registry.py.
Existing tests were adjusted to work with the layered configuration API.
(tests/*)

Testing

Ran pytest -q; all tests passed: 14 passed.

Added unit tests in tests/test_config_registry.py covering:

Environment + code configuration merging

Invalid configuration combinations

Errors for unknown strategies

Existing tests related to semantic storage and working memory were also updated and passed, confirming that the registry and configuration migration remain backward-compatible with existing behavior.


Codex Task

@Sunnylincc Sunnylincc merged commit 3197c93 into main Mar 5, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant