-
Notifications
You must be signed in to change notification settings - Fork 110
Architecture & Anti Drift Safeguards
This document explains the architectural separation between the OWNd OpenWebNet protocol library and the MyHOME Home Assistant custom integration, along with the multi-tiered Anti-Drift Sentinel System designed to ensure both codebases never diverge.
Starting with MyHOME v2.0 and OWNd 2.0, the OpenWebNet protocol stack and the Home Assistant integration are cleanly decoupled into two dedicated repositories:
graph TD
subgraph "Core Protocol Layer (OWNd)"
A[OWNd Python Library] --> A1[OpenWebNet Frame Encoders / Decoders]
A --> A2[Socket & Transport Handlers]
A --> A3[Authentication Nonce / HMAC / SHA-256]
A --> A4[Hardware Gateway Profiles]
A --> A5[Event / Command Session Schedulers]
end
subgraph "Home Automation Layer (MyHOME)"
B[MyHOME Integration] --> B1[Config Flow & Options UI]
B --> B2[Platform Entities Light, Climate, Cover, Sensor, etc.]
B --> B3[HA Device & Entity Registries]
B --> B4[Diagnostics & In-Band Bus Monitor WebSocket]
end
A -->|Published via PyPI: OWNd==2.0.0b2| B
- Single Source of Truth: Protocol decoding, dimension parsing, and frame syntax rules exist in one authoritative library rather than duplicated or vendored across multiple projects.
-
Reusability: Other automation frameworks, standalone CLI tools, diagnostic bridges, and testing scripts can leverage
OWNdwithout pulling in Home Assistant dependencies. - Independent Release Cadence: Protocol fixes and newly decoded WHO dimensions can be tested and released on PyPI independently.
When a core protocol library and a downstream consumer live in separate repositories, three critical divergence risks arise:
-
Breaking Contract Changes: A parameter change, field renaming, or return type modification in
OWNdpasses allOWNdunit tests but breaksMyHOMEentities or listeners. -
Parser Regressions: A change to a regular expression or frame parsing logic in
OWNdcauses downstream entity state updates or device triggers to silently fail. -
Dependency Desynchronization:
MyHOMEpins a specific release inmanifest.json, but development branches assume newer unreleased features (or vice versa).
To permanently prevent these issues, the project implements a 3-Pillar Anti-Drift Architecture.
graph TD
subgraph "Pillar 1: Shift-Left Downstream Canary (OWNd)"
O1[OWNd PR or Commit] --> O2[Build Candidate OWNd Wheel]
O2 --> O3[Checkout MyHOME integration]
O3 --> O4[Run full MyHOME 934-test suite]
O4 -->|Any failure| O5[Block OWNd PR from Merging]
O4 -->|All green| O6[Allow OWNd Merge]
end
subgraph "Pillar 2: Upstream Canary CI (MyHOME)"
M1[Nightly Cron 04:00 UTC] --> M2[Install git+master of OWNd]
M2 --> M3[Run MyHOME Test Suite & Enforcers]
M3 -->|Alert on failure| M4[Proactive Warning Before PyPI Release]
end
subgraph "Pillar 3: Automated Release Bump"
R1[OWNd PyPI Release] --> R2[repository_dispatch Webhook]
R2 --> R3[Auto-Bump manifest.json & PR in MyHOME]
end
The most effective safeguard is Shift-Left Testing: stopping breaking changes before they are ever merged into OWNd.
In OpenWebNet-HA/OWNd/.github/workflows/ci.yml, every PR and push to master triggers a downstream verification job:
- The runner builds and installs the candidate
OWNdwheel. - It clones the active development branch of
OpenWebNet-HA/MyHOME(v2-phase1-architectureormaster). - It runs the complete 934+ automated unit test suite of
MyHOMEwith strict 100.0% line coverage enforcement.
downstream-myhome-compat:
name: Downstream MyHOME Integration Canary
runs-on: ubuntu-latest
steps:
- name: Checkout OWNd
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build local OWNd candidate
run: pip install .
- name: Checkout MyHOME Integration
uses: actions/checkout@v4
with:
repository: OpenWebNet-HA/MyHOME
ref: v2-phase1-architecture
path: myhome-repo
- name: Install MyHOME Test Dependencies
working-directory: myhome-repo
run: |
pip install pytest pytest-cov pytest-asyncio homeassistant python-dateutil pytz \
pytest-homeassistant-custom-component pytest-socket "syrupy>=4.6.0,<5.0.0" time-machine
- name: Execute MyHOME Test Suite against Candidate OWNd
working-directory: myhome-repo
run: pytestImportant
A pull request to OWNd cannot merge if it breaks any behavior, parser, or assumption in MyHOME.
To detect upstream changes before they are tagged and released to PyPI, MyHOME runs a nightly scheduled workflow (.github/workflows/ownd-upstream-compat.yml):
- Runs daily at 04:00 UTC and on manual
workflow_dispatch. - Installs the cutting-edge development head of
OWNd:pip install git+https://github.com/OpenWebNet-HA/OWNd.git@master
- Runs the complete test suite. If an unreleased commit in
OWNdtriggers a deprecation warning, subtle behavioral divergence, or test failure, the team is alerted immediately.
To keep production and development dependencies in lock-step:
-
Strict Version Pinning:
custom_components/myhome/manifest.jsonpins exact releases:{ "requirements": [ "OWNd==2.0.0b2" ] } -
Automated Dependency Bootstrap:
In
tests/conftest.py, an auto-bootstrap hook inspectsmanifest.jsonand ensures CI and local testing environments automatically synchronize with the declaredrequirements:try: import OWNd except ImportError: # Automatically reads manifest.json and installs required OWNd wheel
-
PyPI Release Webhook:
When
OWNdtags and publishes a new release to PyPI (e.g.2.0.0b3), a GitHub Actionsrepository_dispatchevent notifiesMyHOME. A dedicated workflow automatically updatesmanifest.json, regenerates the lockfile/specs, verifies 100% coverage, and opens a pre-validated PR.
Both repositories enforce automated zero-tolerance quality gates:
| Quality Gate | Standard | Enforced By |
|---|---|---|
| Statement Coverage | Strict 100.0% (0 missing lines across all 25 modules) | scripts/verify_ownd_coverage.py |
| Linting & Formatting | 0 Ruff Violations | ruff check . |
| Home Assistant Standards | 5/5 Architectural Rules | tests/test_ha_standards.py |
| Upstream Compatibility |
dev, beta, stable
|
.github/workflows/ha-upstream-compat.yml |
By combining Shift-Left testing in OWNd with nightly canary builds and automated release bumping in MyHOME, protocol drift is structurally impossible.