typedb / typedb-studio

TypeDB Studio (IDE)
https://typedb.com
Mozilla Public License 2.0
191 stars 44 forks source link

Inferred ownership edges are not explainable #751

Open james-whiteside opened 1 year ago

james-whiteside commented 1 year ago

Description

Inferred ownership edges are not explainable or highlighted in green.

Environment

  1. TypeDB version: 2.18.0
  2. OS of TypeDB server: MacOS 12.6.1
  3. Studio version: 23a501103bc8a2eb514967dc8c2ad36ddb5b5df9
  4. OS of Studio: MacOS 12.6.1

Reproducible Steps

Run queries in order:

define

ent sub entity, owns att, plays rel:rol;
rel sub relation, relates rol;
att sub attribute, value string;

rule create-relation:
    when {
        $ent1 isa ent, has att "entity-1";
        $ent2 isa ent, has att "entity-2";
        $ent3 isa ent, has att "entity-3";
    } then {
        (rol: $ent1, rol: $ent2) isa rel;
    };

rule create-attribute:
    when {
        $ent1 isa ent, has att "entity-1";
        $ent4 isa ent, has att "entity-4";
    } then {
        $ent1 has att "attribute";
    };

rule create-ownership:
    when {
        $ent2 isa ent, has att "entity-2";
        $att "ownership" isa att;
        $ent5 isa ent, has att "entity-5";
    } then {
        $ent2 has $att;
    };

insert
$ent1 isa ent, has att "entity-1";
$ent2 isa ent, has att "entity-2";
$ent3 isa ent, has att "entity-3";
$ent4 isa ent, has att "entity-4";
$ent5 isa ent, has att "entity-5";
$att "ownership" isa att;

match
$t isa thing;
not { $t == "entity-3"; };
not { $t == "entity-4"; };
not { $t == "entity-5"; };
not { $t has att "entity-3"; };
not { $t has att "entity-4"; };
not { $t has att "entity-5"; };

Expected Output

Ownership edge between the owner of "entity-2" and the attribute "ownership" should be explainable.

Actual Output

It is not.

james-whiteside commented 1 year ago

Seeing as ownerships are represented as edges in the graph visualisation, it may involve a major refactor to make them clickable buttons to trigger explanations. If this is the case, then we can work around this temporarily by making clicking on the attribute itself the trigger to explain the ownership. While this would normally conflict with explaining an inferred attribute itself, this is not currently the case as the server does not allow directly explaining attributes unless they have no owners in the graph (whether this is a bug or feature is a controversial topic). This means that the server is only able to return one response in a given situation, so there should be no ambiguity in how to handle the request for explanation. The ideal would be of course to double click on the ownership itself to explain it. What is important is that: a) we can explain ownerships, b) the explanation is correct, and c) there is no danger of throwing an error halfway through a demo. If we have time, we'll record the demo in advance so can retake, but this may not be possible.

alexjpwalker commented 1 year ago

We have a fix for this, but I'm leaving it on a feature branch for now due to performance concerns.

james-whiteside commented 1 year ago

Some of the red highlighting on explanation edges is inconsistent in the fix. Will likely need to revisist that aspect.