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
@@ -34,3 +34,32 @@ def test_missing_geometry_does_not_offer_a_broken_overlay_command():
data={"result": {"coverage": {"status": "unavailable"}}},
)
assert saved_presentation_preview(result) is None
def test_pollution_impact_keeps_a_saved_overlay_reference_for_history():
result = QueryResult(source="run_contaminant_simulation", source_ref="calculation:pollution",
evidence_id="pollution:impact", queried_at=datetime.now(timezone.utc), semantics="analysis", origin="synthetic",
data={"result": {"impact": {"phase": "after_contamination_before_intervention"},
"map_payload": {"type": "FeatureCollection", "features": [{"geometry": "saved"}]},
"coverage": {"status": "ready", "groups": {"contaminant_exposure": {"node_ids": ["Q1"], "mapped_node_count": 1}}}}})
preview = saved_presentation_preview(result)
assert preview["command"]["evidence_id"] == "pollution:impact"
assert preview["command"]["title"] == "水污染传播预计影响范围(处置前情景)"
assert "data" not in preview["command"] and preview["groups"]["contaminant_exposure"]["node_count"] == 1
result.data["result"]["impact"]["phase"] = "unknown"
assert saved_presentation_preview(result) is None
def test_burst_impact_hint_uses_saved_evidence_and_distinct_pre_intervention_title():
result = QueryResult(
source="run_burst_simulation", source_ref="mcp:burst", evidence_id="mcp:burst",
queried_at=datetime.now(timezone.utc), semantics="analysis", origin="system_data", truncated=False,
data={"result": {"impact": {"phase": "after_burst_before_intervention"},
"map_payload": {"type": "FeatureCollection", "features": [{"large": "geometry"}]}}},
)
hint = saved_presentation_preview(result)
assert hint["command"]["evidence_id"] == "mcp:burst"
assert "爆管后、处置前" in hint["command"]["title"]
assert "data" not in hint["command"]
result.data["result"].pop("impact")
assert saved_presentation_preview(result) is None