review: address Opus findings on the subdevice flat-href fallback
- coordinator: _poll_subdevice_flat_hrefs called sess.pace() outside its try block and re-read self._session instead of using the caller's already-None-checked reference -- a session closed mid-poll (async_close() doesn't hold _session_lock) could crash the whole poll cycle instead of just dropping that one sibling. Now takes sess from the caller and guards pace() the same as get(). - coordinator: skip flat hrefs already covered by the hot/warm sub-poll tiers -- those are refreshed every few seconds by _run_subpolls already, so re-fetching them again on the once-per-summary-poll flat pass only adds GETs, not freshness. Matters because, unlike the Collection path (always one GET), a flat subdevice's summary-poll cost scales with its href count. - subdevices.py module docstring: corrected an overclaim inherited from PR #199 that GET /<uuid>/device/0 had been "confirmed live" on jhkwon19's unit. Only an individual /information/vs/0 read was ever actually confirmed; the Collection endpoint itself has never been observed to answer on any known unit, which is exactly what issue #205 exposes. - SKILL.md: fixed the numofsubdevice cross-check formula to match what coordinator.py actually compares (len(materialized) + 1, not len(subdevices) + len(subdevices_skipped)). - Documented, not yet guarded against: a firmware that echoes state back under any unrecognized prefix instead of 4.04ing could pass the flat probe and the liveness gate, materializing a phantom duplicate of the master. Every board seen so far genuinely 4.04s on paths it doesn't own. - Added test coverage the review flagged as missing: a materialized (not just skipped) flat subdevice re-polling end-to-end through to canonical_resources, the hot/warm skip itself, zero-master-hrefs and two-UUID no-cross-contamination edge cases, and a golden file for the #205 fixture (SKILL.md's "fixture + golden + test" discipline).
This commit is contained in:
8 files changed
+270
-26
No files matched your search
@@ -961,6 +961,30 @@ def test_registry_reproduces_golden_state_keys_for_airconditioner_fac_bora_2in1(
|
||||
)
|
||||
|
||||
|
||||
def test_registry_reproduces_golden_state_keys_for_airconditioner_fac_bora_205_flat():
|
||||
"""jhkwon19's same physical TP2X_FAC_BORA_21K unit as the _2in1 fixture
|
||||
above, but a later capture (issue #205) where /<uuid>/device/0 doesn't
|
||||
answer -- contrary to what that fixture's own seed batch assumed the
|
||||
Collection endpoint would do. device0/oic_res are real; the only
|
||||
UUID-prefixed data is the one href ever actually confirmed live
|
||||
(/information/vs/0, same real capture the _2in1 fixture uses), fed
|
||||
through registry.subdevices.enumerate_subdevices' per-href flat
|
||||
fallback instead of a Collection batch. /information/vs/0 alone binds
|
||||
no entity, so the candidate is found but never materializes -- this
|
||||
golden has no `subdevice_...`-prefixed keys at all, same shape as
|
||||
tests/fixtures/golden/airconditioner_fac_bora.json, which is the point:
|
||||
a device whose sibling can't yet be confirmed live must regress to
|
||||
exactly the master-only state, never a phantom or partial subdevice."""
|
||||
name = 'airconditioner_fac_bora_205_flat'
|
||||
golden = json.loads((GOLDEN / f'{name}.json').read_text())
|
||||
state_keys = _new_subdevice_aware_state_keys(name)
|
||||
assert set(state_keys) == set(golden['state_keys']), (
|
||||
f"state_keys mismatch:\n"
|
||||
f" extra: {sorted(set(state_keys) - set(golden['state_keys']))}\n"
|
||||
f" missing: {sorted(set(golden['state_keys']) - set(state_keys))}"
|
||||
)
|
||||
|
||||
|
||||
def test_registry_reproduces_golden_state_keys_for_air_purifier_avt_ww():
|
||||
"""AVT-WW-TP1-23-AXX500 (issue #190) -- next-gen BESPOKE Cube Air board;
|
||||
reports device_type 'unknown' with empty oneUiVersion because 'VTWW' as a
|
||||
|
||||
Reference in new issue
Block a user