feat(config): centralise all config via pydantic-settings env loader (#32)#146
Conversation
|
Warning Review limit reached
More reviews will be available in 57 minutes and 36 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Closes #32
Centralises all scattered configuration (hardcoded constants, inline thresholds,
.env.exampledrift) into a singlepydantic-settingsBaseSettingsclass atlibs/config/settings.py.Problem
The existing
settings.pyhad critical bugs:lingering_threshold_sec,movement_threshold_px,near_keypad_dist_px,keypad_center_x,keypad_center_ywere declared three times with conflicting defaults (5.0/10.0, 10.0/15.0/5.0, etc.) — only the last declaration wins in Python, silently overriding earlier valuesmax_events_per_track(50) was hardcoded inmemory.pyandring_buffer.pywith no env overridetrack_ttl_seconds(86400) was hardcoded inmemory.pyandaction_bridge.pywith no env override.env.examplewas missing most settings fieldsChanges
libs/config/settings.pymax_events_per_track: int = 50andtrack_ttl_seconds: int = 86_400services/memory/memory.pyTRACK_TTL_SECONDSandEVENT_TTL_SECONDSnow read fromsettings.track_ttl_secondsMAX_EVENTS_PER_TRACKnow reads fromsettings.max_events_per_trackservices/memory/ring_buffer.pyMAX_EVENTS_PER_TRACKnow reads fromsettings.max_events_per_trackservices/memory/action_bridge.pyTRACK_TTL_SECONDSnow reads fromsettings.track_ttl_seconds.env.exampletests/test_settings.py(new — 26 tests)TestDefaultsTestEnvOverridesmonkeypatch.setenv()to verify env vars override defaultsTestSingletonsettingsinstance is importable and validAcceptance Criteria Checklist
.env.exampleupdatedmonkeypatch)Test Results
Screenshots