Help with sub-relationship in rule (possible bug?)


#1

I get the following error when I load my schema:

INVALID_ARGUMENT: InvalidKBException-A structural validation error has occurred. Please correct the [`2`] errors found.
Attempting to define a rule containing a relation pattern with role [predecessor_container] which cannot be played in relation [node_order]
Attempting to define a rule containing a relation pattern with role [successor_container] which cannot be played in relation [node_order]
. Please check server logs for the stack trace.

Here’s the relevant parts of my schema:

container_order sub relationship is-abstract
    relates predecessor_container as container
    relates successor_container as container;

node_order sub container_order
    relates predecessor_node as node
    relates successor_node as node;

exchange_to_node_order
when {
    (container: $pm, node: $pn, exchange: $exchange) isa node_exchange has first true;
    (container: $sm, node: $sn, exchange: $exchange) isa node_exchange has first false;
} then {
    (
        predecessor_container: $pm, successor_container: $sm,
        predecessor_node: $pn, successor_node: $sn
    ) isa node_order;
};

Am I doing anything wrong? Is this a bug? It works when I flatten the node_order relationship like:

node_order sub relationship
    relates predecessor_container as container
    relates successor_container as container
    relates predecessor_node as node
    relates successor_node as node;

#2

The short answer is that it is the outcome of how relationships are subclassed and what properties are inherited. Relationships are treated as any other type in this case: they inherit the plays and has properties of parents. relates property is not currently inherited.


#3

can relationships play roles? I thought only entities played roles, and only relationships related roles


#4

Relationships relate roles which in turn can be played by either entities, relationships or attributes.