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:
@@ -23,10 +23,11 @@ def adopt_legacy_investigation_graph(diagram: InvestigationDiagram) -> Investiga
|
||||
def update_investigation_graph(
|
||||
previous: InvestigationDiagram | None, update: InvestigationGraphUpdate,
|
||||
) -> InvestigationDiagram:
|
||||
"""Upsert nodes and append explicit edges; never delete a path or erase a failed attempt.
|
||||
"""Patch saved nodes or add labelled nodes and explicit edges; never erase a path.
|
||||
|
||||
A retry uses a new node id. Relationships describe activity for readers and
|
||||
impose no ordering or completion requirements on the Agent.
|
||||
Unspecified fields retain their saved values. A failed attempt remains
|
||||
failed, and a retry uses a new node id. Relationships impose no execution
|
||||
ordering or completion requirements on the Agent.
|
||||
"""
|
||||
if previous is not None:
|
||||
previous = adopt_legacy_investigation_graph(previous)
|
||||
@@ -47,15 +48,19 @@ def update_investigation_graph(
|
||||
if existing is None:
|
||||
require(not in_source(node.node_id), "GRAPH_LEGACY_NODE_CONFLICT",
|
||||
"This id belongs to the original Mermaid; use a new node id", status=409)
|
||||
require(node.label is not None, "GRAPH_NODE_LABEL_REQUIRED",
|
||||
"A new graph node requires a label; use an existing node_id for a partial update", status=422)
|
||||
nodes[node.node_id] = InvestigationDiagramNodeRef.model_validate(node.model_dump(exclude_unset=True))
|
||||
continue
|
||||
require(not in_source(node.node_id) or existing.label == node.label,
|
||||
require(not in_source(node.node_id) or node.label is None or existing.label == node.label,
|
||||
"GRAPH_LEGACY_NODE_CONFLICT", "Keep the original node label; use a new node for a new step", status=409)
|
||||
require(existing.status != "failed" or (
|
||||
("status" not in node.model_fields_set or node.status == "failed")
|
||||
and existing.label == node.label
|
||||
and (node.label is None or existing.label == node.label)
|
||||
), "GRAPH_FAILED_ATTEMPT_IMMUTABLE", "Keep the failed attempt; use a new node for a retry", status=409)
|
||||
changes = node.model_dump(exclude_unset=True)
|
||||
if node.label is None:
|
||||
changes.pop("label", None)
|
||||
if existing.status == "failed" and existing.detail and not changes.get("detail"):
|
||||
changes.pop("detail", None)
|
||||
for field in ("evidence_refs", "action_refs", "map_targets"):
|
||||
|
||||
Reference in New Issue
Block a user