No reviewers
Labels
No labels
blocked
bug
enhancement
high-priority
low-priority
needs-info
needs-triage
ready-for-agent
ready-for-human
referenced
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gabogg/hikcentral!112
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/door-transition-async-cleanup"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Addresses #95 and #102. The async webhook route previously ran synchronous SQLite ingestion on the event loop. Door transition inputs also traveled as untyped dictionaries, and the telemetry engine had duplicate state mappings with labels that differed from the server.
Architectural Impact
DoorStateManager.handle_webhook_event_asyncruns the existing synchronous ingestion in a worker thread, serializes concurrent webhooks, and returns persisted transition batches to the event loop for broadcast before the overview message. The controller also builds the overview in a worker thread.DoorTransitionInputis the typed contract from polling, webhook, and reconciliation through the repository. The transition broadcaster uses the door cache's canonicalexclusionSourceand no longer performs a synchronous database fallback on async paths. The frontend now shares one numeric state presentation map and uses the server's door-state labels.Verification
rtk pytest -q: 330 passed, 1 skipped.node --test tests/frontend/*.test.js: all 6 test files passed.python3 scripts/check_docs.py: 33 Markdown files and 72 HTTP operations checked.Checklist
Addresses #95. Addresses #102.
Second-pass follow-ups
Small follow-ups are recorded on #95 and #102. These issues remain open after this PR merges. The second-pass review found no merge blocker.
Review of PR #112 (
634db84...ea81ad3) against issues #95 and #102.Standards
app/services/door_service.py:567-592and:752-777each build a near-identicalDoorTransitionInput(...)with the same state fields,trigger_source="POLLING_SYNC", timestamp formatting, anddetails_json. This duplication predates the PR as dict literals, but remains in the changed hunks. A shared constructor could prevent the two polling paths from drifting. No hard documented-standard violations found.Spec
app/services/door_service.py:806-814, cancelling the request duringawait asyncio.to_thread(...)runsfinallyimmediately. The worker thread can continue after the batch list is drained and the lock released. If it persists and appends a transition afterward, that transition is never broadcast; a second webhook can also overlap the first worker. Keep the lock and batch collection active until the worker completes, including on cancellation, then emit the completed batches on the event loop.Summary: Standards: 1 low severity judgement call (worst: duplicated polling construction). Spec: 1 functional finding (worst: lost broadcast on cancellation).
Second-pass review of PR #112 at
f11feeaagainst issues #95 and #102. The cancellation fix and shared polling transition constructor address the first review's findings. No major merge blocker found.Standards
tests/test_door_transition_broadcast.py:153,160,189,296), contrary todocs/standards/code-standards.md§2.2. Tracked in issue #102.Spec
self.doors, raisingRuntimeError: dictionary changed size during iteration. A deterministic reproduction confirmed it; the already persisted transition still broadcasts. Tracked in issue #95.person_directory.request()because it has no running event loop. The monitor can start lookup later. Tracked in issue #95.doors_updateis still normalized to CLOSED by_ingestDoors()despite the new state presentation helper. This behavior predates this PR; a direct frontend reproduction confirmed it. Tracked in issue #102.Verification: 330 Python tests passed, 1 skipped; all 6 frontend test files passed; Ruff checks and PR CI passed. Summary: Standards 1 minor (worst: missing test annotations); Spec 3 minor (worst: intermittent threaded-overview race).