feat(investigations): add event impact and work-order feedback flows

Add isolated burst and pollution impact evidence, parallel work-order workflows, persisted notifications and graph updates.

Checkpoint current code. Known follow-ups remain for large pollution result previews and graceful geometry failure.
This commit is contained in:
2026-11-14 15:14:02 +08:00
parent 471ad92a47
commit 2e4f6cb93b
49 changed files with 1826 additions and 93 deletions
+12 -1
View File
@@ -19,9 +19,20 @@ def current_calibration(document: dict, start: datetime) -> dict | None:
return None
def pollution_signal(document: dict, event: dict) -> bool:
"""Water-quality measurements have their own incident investigation workflow."""
if event.get("category") == "data_quality":
return False
devices = {item["device_id"]: item.get("device_type") for item in document.get("devices", [])}
ids = event.get("device_ids") or next((item.get("device_ids", [])
for item in (document.get("config") or {}).get("rules", [])
if item["rule_id"] == event.get("rule_id")), [])
return bool(ids) and all(devices.get(device) in {"quality", "water_quality"} for device in ids)
def diagnostic_signal(document: dict, event: dict) -> bool:
"""Never revive a persisted fixed-percentage event as new diagnosis evidence."""
if event.get("category") == "data_quality":
if event.get("category") == "data_quality" or pollution_signal(document, event):
return False
if not weighted_diagnosis(document):
return True