Skip to content

fix: Make runtime resilient for dev/CI environments#43

Merged
lan17 merged 3 commits intomainfrom
feat/dev-runtime-resilience
Mar 4, 2026
Merged

fix: Make runtime resilient for dev/CI environments#43
lan17 merged 3 commits intomainfrom
feat/dev-runtime-resilience

Conversation

@lan17
Copy link
Owner

@lan17 lan17 commented Mar 2, 2026

Summary

Make runtime startup resilient in dev/CI while keeping cleaner abstraction boundaries and stronger typed telemetry.

Changes

1. VLM run_mode: never is handled in runtime assembly (not plugin loader)

  • Files:
    • src/homesec/runtime/assembly.py
    • src/homesec/runtime/disabled_vlm.py
    • src/homesec/plugins/analyzers/__init__.py
  • load_analyzer() is now a pure plugin loader again.
  • Runtime assembly now decides activation:
    • if vlm.run_mode == never, it injects DisabledVLMAnalyzer
    • otherwise, it loads the configured analyzer plugin.
  • Net effect: when disabled, startup no longer initializes OpenAI analyzer/env checks.

2. Typed VLM skip reasons (no magic strings)

  • Files:
    • src/homesec/models/enums.py
    • src/homesec/models/events.py
    • src/homesec/repository/clip_repository.py
    • src/homesec/pipeline/core.py
  • Added VLMSkipReason enum.
  • VLMSkippedEvent.reason now uses typed enum values.
  • Pipeline skip logic now emits explicit reasons:
    • run_mode_never
    • no_trigger_classes

3. Worker-level coverage for disabled VLM startup

  • File: tests/homesec/test_runtime_worker.py
  • Added a worker lifecycle test that guards load_analyzer from being called when run_mode=never.

4. RTSP session-limit fallback profile cleanup

  • Files:
    • src/homesec/sources/rtsp/core.py
    • tests/homesec/rtsp/test_runtime.py
  • Session-limit fallback now reuses build_default_recording_profile() instead of hand-building a profile in RTSPSource.
  • Added regression test to lock this behavior.

5. Existing RTSP/dev resiliency changes retained in this PR

  • Files:
    • src/homesec/sources/rtsp/core.py
    • dev/fake-camera/mediamtx.yml
  • Keeps the session-limit startup fallback path and MediaMTX stability tuning (readTimeout, writeTimeout, writeQueueSize, maxReaders).

Tests

Added/updated tests:

  • tests/homesec/test_runtime_assembly.py
  • tests/homesec/test_runtime_worker.py
  • tests/homesec/test_pipeline.py
  • tests/homesec/test_pipeline_events.py
  • tests/homesec/rtsp/test_runtime.py

Validation run locally

  • make typecheck
  • uv run ruff check on touched files ✅
  • uv run pytest tests/homesec/test_pipeline.py tests/homesec/test_runtime_assembly.py tests/homesec/test_runtime_worker.py tests/homesec/rtsp/test_runtime.py
  • tests/homesec/test_pipeline_events.py requires valid local Postgres auth; in this environment DB-backed event tests fail with InvalidPasswordError for homesec@localhost:5432.

lan17 added 2 commits March 2, 2026 17:22
1. Skip VLM plugin init when run_mode=never (no-op analyzer)
   - Avoids requiring OPENAI_API_KEY when VLM analysis is disabled
   - Returns safe defaults (low risk, skipped) for any analyze() calls

2. Graceful fallback when RTSP session-limit preflight fails
   - Session-limit check can fail in constrained environments
   - Falls back to single-stream defaults instead of crashing
   - Other preflight stages (probe, negotiation) still fail-fast

3. Update MediaMTX config for dev fake camera
   - Add maxReaders, readTimeout, writeTimeout, writeQueueSize
@lan17 lan17 changed the title Make runtime resilient for dev/CI environments fix: Make runtime resilient for dev/CI environments Mar 2, 2026
@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 88.67925% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.48%. Comparing base (d0a725b) to head (bcd1c18).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/homesec/sources/rtsp/core.py 50.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #43      +/-   ##
==========================================
+ Coverage   82.88%   83.48%   +0.60%     
==========================================
  Files         107      108       +1     
  Lines        9679     9714      +35     
==========================================
+ Hits         8022     8110      +88     
+ Misses       1657     1604      -53     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lan17 lan17 merged commit c89ea3d into main Mar 4, 2026
5 checks passed
@lan17 lan17 deleted the feat/dev-runtime-resilience branch March 4, 2026 19:44
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.

1 participant