Integrating Micboard Settings
Use the canonical SettingsService singleton for every runtime read:
from micboard.services.settings.settings_service import settings as micboard_settingsScoped configurable values
Pass the scope already owned by the workflow. Do not rediscover tenant context inside the settings layer.
poll_interval = micboard_settings.get( "polling_interval_seconds", 300, organization=device.organization, site=device.site, manufacturer=device.manufacturer,)The most specific stored value wins. If no stored value matches, resolution continues through host MICBOARD_CONFIG, package defaults, the registered definition default, and the explicit default.
Deployment controls
Process safety, transport bounds, and tenancy feature flags use MICBOARD_* Django settings:
max_devices = micboard_settings.get("MICBOARD_REALTIME_MAX_DEVICES", 128)if micboard_settings.msp_enabled: ...These values are deliberately host-owned. Database settings cannot override them.
Typed writes
Views, forms, and commands must delegate writes to SettingsPersistenceService. Build the DTO accepted by the service and pass the authenticated actor plus explicit scope. The service validates authorization, definition type, serialized value, and scope before upsert, then invalidates caches.
Never:
- import
SettingsRegistryfrom its internal module in runtime code; - call
Setting.objects.update_or_create(...)outside the settings persistence service; - add a wrapper, alias, or re-export for a removed settings API;
- read
settings.MICBOARD_*orgetattr(settings, "MICBOARD_*", ...)directly.
Performance
Resolution is cached per definition and exact scope. Prefer one service read per logical workflow and pass the resolved value down when processing a batch. Database-backed settings should not be loaded in a row loop.
Testing an integration
Cover:
- the explicit default;
- definition and
MICBOARD_CONFIGfallback; - global-to-specific database precedence;
- isolation from a different organization/site/manufacturer;
- immutable host precedence for
MICBOARD_*controls; - persistence authorization and automatic cache invalidation.
Run:
uv run --no-sync pytest tests/test_settings.py tests/test_settings_service.py \ tests/services/settings tests/test_settings_architecture.pyuv run --no-sync ruff check micboard/services/settings tests/services/settingsuv run --no-sync python -m mypy micboard/services/settingsSee Settings Management and ADR-005: Unify Settings Proxy for the complete contract.
