Skip to content

feat(config): centralise all config via pydantic-settings env loader (#32)#146

Merged
Devnil434 merged 2 commits into
Devnil434:mainfrom
ArokyaMatthew:feat/pydantic-settings-env-loader-32
Jun 13, 2026
Merged

feat(config): centralise all config via pydantic-settings env loader (#32)#146
Devnil434 merged 2 commits into
Devnil434:mainfrom
ArokyaMatthew:feat/pydantic-settings-env-loader-32

Conversation

@ArokyaMatthew

Copy link
Copy Markdown
Contributor

Summary

Closes #32

Centralises all scattered configuration (hardcoded constants, inline thresholds, .env.example drift) into a single pydantic-settings BaseSettings class at libs/config/settings.py.

Problem

The existing settings.py had critical bugs:

  • lingering_threshold_sec, movement_threshold_px, near_keypad_dist_px, keypad_center_x, keypad_center_y were 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 values
  • max_events_per_track (50) was hardcoded in memory.py and ring_buffer.py with no env override
  • track_ttl_seconds (86400) was hardcoded in memory.py and action_bridge.py with no env override
  • .env.example was missing most settings fields

Changes

libs/config/settings.py

  • Deduplicated all fields — each appears exactly once with the correct default from the issue spec
  • Added max_events_per_track: int = 50 and track_ttl_seconds: int = 86_400
  • Organised fields into logical groups (Redis, Memory, Action classifier, Detection, Tracker, VLM/LLM, Reasoning, Backend, Kafka)

services/memory/memory.py

  • TRACK_TTL_SECONDS and EVENT_TTL_SECONDS now read from settings.track_ttl_seconds
  • MAX_EVENTS_PER_TRACK now reads from settings.max_events_per_track

services/memory/ring_buffer.py

  • MAX_EVENTS_PER_TRACK now reads from settings.max_events_per_track

services/memory/action_bridge.py

  • TRACK_TTL_SECONDS now reads from settings.track_ttl_seconds

.env.example

  • Expanded to document all settings fields with their defaults, grouped by category

tests/test_settings.py (new — 26 tests)

Class Tests Coverage
TestDefaults 13 Verifies every default matches the issue's contract
TestEnvOverrides 11 Uses monkeypatch.setenv() to verify env vars override defaults
TestSingleton 2 Verifies the module-level settings instance is importable and valid

Acceptance Criteria Checklist

  • Remove hardcoded thresholds from production code
  • Use centralised settings
  • .env.example updated
  • Environment overrides tested (11 override tests with monkeypatch)
  • Existing tests remain green

Test Results

tests/test_settings.py — 26 passed
tests/test_reasoning_fixtures.py — 4 passed
tests/test_policy_loader.py — 2 passed

Screenshots

image image

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Devnil434, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4b322bd9-dfc9-414c-aecf-b3d6d9d9a76d

📥 Commits

Reviewing files that changed from the base of the PR and between 8de0807 and dd09107.

📒 Files selected for processing (6)
  • .env.example
  • libs/config/settings.py
  • services/memory/action_bridge.py
  • services/memory/memory.py
  • services/memory/ring_buffer.py
  • tests/test_settings.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Devnil434 Devnil434 merged commit fd8efa1 into Devnil434:main Jun 13, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

# Issue #26 — Add pydantic-settings env loader for all config

2 participants