Skip to content

Add semantic source-of-truth tagging + grouped layer toggles#75

Merged
marota merged 1 commit into
masterfrom
claude/overflow-semantic-tags-and-layers
May 5, 2026
Merged

Add semantic source-of-truth tagging + grouped layer toggles#75
marota merged 1 commit into
masterfrom
claude/overflow-semantic-tags-and-layers

Conversation

@marota

@marota marota commented May 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

The overflow graph and its interactive HTML viewer now expose
semantic layer toggles driven by source-of-truth boolean flags
the recommender propagates onto graph nodes and edges, replacing
brittle colour / shape heuristics.

OverflowGraph (alphaDeesp/core/graphs/overflow_graph.py)

  • set_hubs_shape tags every hub with is_hub=True (and also
    in_red_loop=True + on_constrained_path=True so hubs always
    show under those layers regardless of how the recommender's
    lists are built).
  • New tag_red_loops(lines, nodes) and
    tag_constrained_path(lines, nodes) helpers consume the
    recommender's pre-computed lists.
  • highlight_significant_line_loading tags is_monitored=True
    on every monitored entry and is_overload=True on the strict
    subset that is contingency-overloaded — is_overload is a
    strict subset of is_monitored.

Interactive HTML viewer (alphaDeesp/core/interactive_html.py)

  • _build_layer_index scans data-attr-* flags on both nodes
    and edges and emits semantic layers (Hubs, Red-loop paths,
    Constrained path, Overloads, Low margin lines).
  • Layers are grouped into three labelled sections — Structural
    Paths / Individual entities properties / Flow redispatch
    values — via _LAYER_SECTIONS and rendered in _SECTION_ORDER
    with <h3 class=\"layer-section-header\"> markers.
  • Membership-based dim model: an element is visible iff at
    least one of its claiming layers is checked; opacity drops to
    0.12 otherwise. No display:none — click / hover stay
    live so the operator can still hit dimmed elements.
  • Endpoint-node inclusion: edge-only layers also dim /
    highlight the bbox-endpoint nodes of their claimed edges, so
    toggling "Overloads" alone keeps the substations the
    overload connects visible.
  • Select-all / Unselect-all link row above the layer list,
    dispatching the same change event as individual checkboxes.
  • _align_edge_ids_with_svg() regression guard: graphviz's
    SVG and JSON outputs assign edge ids in independent orders, so
    data-source / data-target on <g class=\"edge\"> ended
    up disagreeing with the edge's <title> endpoints. We now
    re-key the JSON edge model from the SVG title strings.

Test plan

  • pytest alphaDeesp/tests/test_overflow_graph.py — new
    assertions for the is_hub / in_red_loop / is_monitored
    / is_overload / on_constrained_path attributes, the
    strict overload-subset semantics, and the new taggers.
  • pytest alphaDeesp/tests/test_interactive_html.py — new
    semantic layer keys, section grouping, membership dim model,
    endpoint-node inclusion, edge-id alignment guard, and the
    Select-all / Unselect-all row.
  • Downstream verification: Expert_op4grid_recommender
    (companion PR) wires the lists into the new taggers.
  • Downstream verification: Co-Study4Grid (companion PR)
    injects the action-pin overlay on top of the viewer.

🤖 Generated with Claude Code

The overflow graph now carries explicit boolean flags driving the
HTML viewer's layer toggles, replacing brittle colour/shape
heuristics. The viewer surfaces three labelled sections (Structural
Paths / Individual entities properties / Flow redispatch values)
with a Select-all / Unselect-all row and dim-instead-of-hide
behaviour so unchecked elements stay visible at low opacity.

OverflowGraph:
- set_hubs_shape sets is_hub on hub nodes (also tagged as
  in_red_loop AND on_constrained_path so they show under those
  layers regardless of recommender list contents).
- New tag_red_loops(lines, nodes) and tag_constrained_path(lines,
  nodes) helpers driven by the recommender's lists.
- highlight_significant_line_loading sets is_monitored on every
  monitored line and is_overload on the strict subset of overloaded
  contingency lines (is_overload is a strict subset of
  is_monitored).

Interactive HTML viewer:
- _build_layer_index scans data-attr-* on nodes AND edges and emits
  semantic layers (Hubs, Red-loop paths, Constrained path,
  Overloads, Low margin lines).
- Layers are grouped into three sections via _LAYER_SECTIONS and
  rendered in _SECTION_ORDER with section headers.
- Membership-based dim model: an element is visible iff at least
  one of its claiming layers is checked; opacity drops to 0.12
  otherwise (no display:none, so click/hover stay live).
- Endpoint-node inclusion: edge-only layers also dim/highlight the
  bbox-endpoint nodes of their claimed edges.
- Select-all / Unselect-all link row above the layer list.
- _align_edge_ids_with_svg() regression guard: re-keys the JSON
  edge model from SVG <title> endpoints so the data-source /
  data-target attributes always match the (src, dst) endpoints
  graphviz baked into the title.

Tests:
- test_overflow_graph.py covers the new is_hub / in_red_loop /
  is_monitored / is_overload / on_constrained_path attributes,
  the strict overload-subset semantics, and the constrained-path /
  red-loop taggers.
- test_interactive_html.py covers the new semantic layer keys,
  section grouping, membership dim model, endpoint-node inclusion,
  edge-id alignment guard, and the Select-all / Unselect-all row.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@marota marota merged commit e942ce3 into master May 5, 2026
2 checks passed
marota added a commit that referenced this pull request May 5, 2026
Release containing the semantic source-of-truth tagging and grouped
layer toggles for the interactive overflow-graph viewer (PR #75).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant