Skip to content

Fix: Coalesce parent-child sync notifications to dirty locks #683

Description

@tykeal

Part of #670

Summary

Scope parent/child synchronization to the parent and affected children only, and
publish one coalesced final result after the sync transaction completes. Intermediate child
ADDING/DELETING states are intentionally not surfaced during parent sync.

Scope / changes

  • Refactor parent sync methods at coordinator.py:2359-2405 and child slot updates at
    coordinator.py:2407-2510 to return/collect dirty entry IDs.
  • Add a parent-sync transaction/suppression mechanism so set_pin_on_lock()
    (coordinator.py:1523-1625) and clear_pin_from_lock() (coordinator.py:1627-1706) can
    update provider/local state without scheduling per-slot notifications mid-transaction.
  • Ensure child unlock parent access-limit decrement at coordinator.py:996-1026 schedules the
    parent entry ID; local count decrement at coordinator.py:1027-1034 schedules the current
    lock.
  • Preserve provider retry behavior from _update_child_code_slots() at
    coordinator.py:2480-2509.
  • Extend tests/test_coordinator_sync.py, which already exercises parent/child sync starting at
    tests/test_coordinator_sync.py:84, with dirty-ID and notification assertions.

Plan reference

§5.4 scoped notifications, §5.6, §7.2, §7.3, §7.6,
§8 PR 5; decisions 3 and 4; 2026-07-07 guard-regression and shippability findings.

Dependencies

Depends on: #682

Acceptance criteria

  • Parent slot changes notify only the parent and affected non-overriding children.
  • Children with override_parent=True are not mutated and not notified for copied parent fields.
  • Parent-sync set/clear operations publish one final coalesced notification per affected lock,
    not intermediate ADDING/DELETING fan-outs.
  • Child unlock access-limit decrement notifies the parent coordinator, not siblings.
  • Re-run the plan §7.2 guard regression for parent/child paths and prove fan-out remains deferred
    and scoped to the dirty parent/child entry set.
  • Targeted validation: pytest tests/test_coordinator_sync.py.
  • Broader validation, run with task-10 before release: pytest tests/test_coordinator_sync.py tests/test_debounce.py tests/test_entity.py, ruff check custom_components/ tests/,
    mypy custom_components/keymaster/.

Risk / notes

Most important reviewer focus is missed child notifications and noisy
intermediate sync status (§8 risk table). Transaction cleanup must be exception-safe. Do not ship
this without task-10's quick/debounce scoping.

Size

L

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions