UJG / Editor's Draft /
GitHub
Table of Contents
  • 1Overview
  • 2Terminology
  • 3State
    • 3.1State-scoped entry transitions
    • 3.2StateCollection
  • 4Transitions
    • 4.1Transition
    • 4.2AdjacentTransition
    • 4.3OutgoingTransition
    • 4.4InvokingTransition
    • 4.5EntrySelector
  • 5Command
  • 6Journey
    • 6.1JourneyEntry
    • 6.2JourneyExit
  • 7JourneyEntryIndex
  • 8CompositeState
  • 9Normative Artifacts
    • 9.1Ontology
    • 9.2JSON-LD Context
    • 9.3Validation
  • 10Graph Integrity and Resolution
W3C Community Group Draft Report

Graph

draft

Status of this Document

This report was published by the User Journey Graph Community Group . It is not a W3C Standard nor is it on the W3C Standards Track. Please note that under the W3C Community Contributor License Agreement (CLA) there is a limited opt-out and other conditions apply. Learn more about W3C Community and Business Groups .

Last Update
2026-11-13
Editors
  • Seva Dolgopolov
Group
User Journey Graph Community Group
Repository
View Source
License
W3C-Software-and-Document

1. Overview

This module defines the vocabulary for intended user flow. It extends [UJG Core] to support structured, interactive graphs with composition through one or more child-Journey references, exported exits from nested journeys, organization tags, and state-scoped navigation and invocation affordances. Graph describes intended topology and possible movement; it does not prescribe execution, scheduling, condition evaluation, or event processing.

2. Terminology

  • Journey: A named container for local traversable user flow topology.

  • Local vertex: A node of one Journey's local topology: a State or CompositeState listed in its stateRefs, or a JourneyExit listed in its exitRefs. Transitions and AdjacentTransitions connect local vertices of the same Journey.

  • JourneyEntry: An explicit entry contract for a Journey.

  • JourneyEntryIndex: A catalogue of addressable JourneyEntry contracts that does not define traversal.

  • State: A discrete node in the experience (e.g., a screen, modal). A State is the only local vertex that offers entry transitions.

  • State occurrence: A concrete experienced occurrence of a State during traversal.

  • Transition: A structural directed edge between local vertices of a Journey.

  • AdjacentTransition: A structural edge between two local vertices of a Journey, or between two members of a StateCollection, that sit next to each other in the same experience frame and share a border. The user can cross that border in either direction.

  • Command: A stable semantic identity of an intentional invocation in the modeled experience.

  • CompositeState: A local vertex that nests one or more child Journeys in its parent Journey. It is not a State.

  • Composite scope: The set of child Journeys referenced by one CompositeState.

  • Co-present: Journeys are co-present when the user can perceive and act on each of them at the same time in the same experience frame: the viewport, window, screen, or dialog session that stays in place while its content changes.

  • JourneyExit: A terminal local vertex and exported completion contract declared by a Journey.

  • OutgoingTransition: A navigational affordance that enters a Journey through a JourneyEntry.

  • InvokingTransition: An affordance that invokes a Journey through a JourneyEntry and resumes the source State occurrence when that Journey reaches one of its exits.

  • Entry transition: An OutgoingTransition or InvokingTransition: an affordance available at a State that enters a Journey through a JourneyEntry, named in the Graph or selected when the transition is taken.

  • EntrySelector: A Graph node that lets an entry transition enter a JourneyEntry selected each time the transition is taken, instead of one named in the Graph.

  • StateCollection: A Graph node that lets one State or CompositeState, its member State, stand for several similar parts of an experience, its members.

  • Collection member: One of the parts of an experience that a StateCollection's member State stands for, such as one row of a list.

  • Member transition: A Transition or AdjacentTransition listed in a StateCollection's memberTransitionRefs. It moves the user from one member to another member of the same collection.


3. State

A State is the graph node for a discrete point in an intended user experience, such as a page, screen, modal, or other user-visible step. It is a leaf of the local topology: it does not contain Journeys. Nested composition is the job of a CompositeState, which is a separate class.

This section defines the State node. A State also lists the entry transitions it offers, as described in the State-scoped entry transitions subsection below; the transition classes themselves are defined in the Transitions section.

  1. A State MUST be identified by an IRI.

  2. A State MUST declare exactly one label.

  3. A State MAY declare one or more tags.

  4. Multiple concrete occurrences of the same State MAY exist within an active Journey; Graph does not define occurrence identity, cardinality, lifecycle, or materialization.

When one State stands for many similar parts of an experience, such as the rows of a list, a StateCollection declares those parts as its members, as described in the StateCollection subsection below.

classDiagram
  class State {
    id
    label
    tags
  }

Example JSON node:

json
{
  "@type": "State",
  "@id": "urn:ujg:state:search-form",
  "label": "Search form",
  "tags": [
    "phase:search"
  ]
}
{
  "@type": "State",
  "@id": "urn:ujg:state:search-form",
  "label": "Search form",
  "tags": [
    "phase:search"
  ]
}

3.1. State-scoped entry transitions

A State lists the entry transitions it offers in entryTransitionRefs. Entry transitions are for navigation and invocation options, not for ordinary internal progression through a journey.

An entry transition is a node of its own, so several States can list the same one, such as a link offered on several pages.

  1. Only a State MAY declare entryTransitionRefs. A CompositeState, a Journey, and every other Graph class MUST NOT.

  2. Each entryTransitionRefs value MUST reference an OutgoingTransition or an InvokingTransition. One State MAY list both.

  3. Each State that lists an entry transition is an effective source of that transition, at its own occurrences only.

  4. An entry transition is not inherited. It is not available at a State merely because that State is nested in a CompositeState, shares a child Journey with the State that lists it, or is a sibling of it.

  5. Entry transitions are not members of the enclosing Journey's transitionRefs.

  6. An entry transition's destination, its fixed toEntryRef or its EntrySelector, is the same at every State that lists it. Consumers MUST NOT reinterpret that destination relative to the source state.

  7. When the intended destination entry varies with the source, Producers MUST use source-specific OutgoingTransitions or InvokingTransitions instead of one shared transition.

Share one entry transition across States only when the same destination entry is correct from each of them. A shared transition cannot express “re-enter whichever state is currently active.” When an affordance preserves one of several possible source states—such as a state-preserving locale switch—model a separate OutgoingTransition for each source state and target a JourneyEntry whose stateRef is that state. The entries and transitions are distinct even when the affordances have the same label and locale metadata.

A CompositeState lists no entry transitions. While it is current, the current States of its child Journeys offer theirs.

While an InvokingTransition is in progress, its retained source is suspended, so entry transitions available at the source are not offered inside the invoked Journey. They are available there only when the invoked Journey's own States list them.

A State of Journey J that lists an InvokingTransition into J lets J invoke itself. Each activation enters J again and retains the current State occurrence of J, so invocations of J nest. For example, the States of a privacy settings Journey normally do not list the entry transition that opens the privacy settings.

classDiagram
  class State {
    entryTransitionRefs
  }
  class OutgoingTransition {
    toEntryRef
    entrySelectorRef
  }
  class InvokingTransition {
    toEntryRef
    entrySelectorRef
  }
  class JourneyEntry
  class EntrySelector

  State --> OutgoingTransition : entryTransitionRefs
  State --> InvokingTransition : entryTransitionRefs
  OutgoingTransition --> JourneyEntry : toEntryRef
  InvokingTransition --> JourneyEntry : toEntryRef
  OutgoingTransition --> EntrySelector : entrySelectorRef
  InvokingTransition --> EntrySelector : entrySelectorRef

Example JSON nodes:

json
{
  "@type": "State",
  "@id": "urn:ujg:state:w3c-searchpage-form",
  "label": "Search form",
  "entryTransitionRefs": [
    "urn:ujg:ot:w3c-searchpage-form-back-home"
  ]
}
{
  "@type": "State",
  "@id": "urn:ujg:state:w3c-searchpage-form",
  "label": "Search form",
  "entryTransitionRefs": [
    "urn:ujg:ot:w3c-searchpage-form-back-home"
  ]
}
json
[
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:w3c-homepage",
    "defaultEntryRef": "urn:ujg:entry:w3c-homepage",
    "entryRefs": ["urn:ujg:entry:w3c-homepage"],
    "stateRefs": ["urn:ujg:state:w3c-root-homepage"]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:w3c-homepage",
    "stateRef": "urn:ujg:state:w3c-root-homepage"
  },
  {
    "@type": "State",
    "@id": "urn:ujg:state:w3c-root-homepage",
    "label": "W3C homepage"
  },
  {
    "@type": "OutgoingTransition",
    "@id": "urn:ujg:ot:w3c-searchpage-form-back-home",
    "label": "Back to home page",
    "toEntryRef": "urn:ujg:entry:w3c-homepage"
  }
]
[
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:w3c-homepage",
    "defaultEntryRef": "urn:ujg:entry:w3c-homepage",
    "entryRefs": ["urn:ujg:entry:w3c-homepage"],
    "stateRefs": ["urn:ujg:state:w3c-root-homepage"]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:w3c-homepage",
    "stateRef": "urn:ujg:state:w3c-root-homepage"
  },
  {
    "@type": "State",
    "@id": "urn:ujg:state:w3c-root-homepage",
    "label": "W3C homepage"
  },
  {
    "@type": "OutgoingTransition",
    "@id": "urn:ujg:ot:w3c-searchpage-form-back-home",
    "label": "Back to home page",
    "toEntryRef": "urn:ujg:entry:w3c-homepage"
  }
]

This is a "Back to home page" navigation affordance, not an internal Transition. The source Journey references the destination entry contract, never the destination State directly.

An example that mixes navigation and invocation is shown in the InvokingTransition section.

3.2. StateCollection

A StateCollection lets one State stand for many similar parts of an experience, such as the rows of a list, the cards of a feed, or the slides of a carousel. Each part is a member. The State, called the member State, is modeled once, and every member offers what it offers. The collection also lists the member transitions: the ways the user gets from one member to another, such as scrolling to the next card or pressing "Next". Which member the user reaches is not part of the Graph.

When each part has steps of its own, the member State is a CompositeState, so each member gets its own child Journeys.

The repeated parts…Model
behave the same and have no steps of their ownA StateCollection whose member State is a State
behave the same, and each has steps of its ownA StateCollection whose member State is a CompositeState
behave differentlySeparate States or Journeys
  1. A StateCollection lets its member State, a State or CompositeState, stand for several distinct parts of an experience: its members. Every member offers what the member State offers. Being at a member is an occurrence of the member State.

  2. Members are independent. Taking a transition at one member does not take it at another. A Transition from the member State to itself that the Journey lists leaves and re-enters the member where it is taken. Other members change only through a declared effect.

  3. A member transition leaves the member it starts from and enters another member of the same collection, as any transition leaves its from vertex and enters its to vertex. Graph names neither member: both are known only when the movement happens.

    • A member AdjacentTransition crosses the border between neighboring members, in either direction.

    • A member Transition describes a move that has its own Command, guard, or effect. When the member State is a CompositeState, a child exit of the member it leaves can trigger it through fromExitRef, and it can select a child entry of the member it enters through toEntryRef, as a parent Transition of a CompositeState does.

  4. The user moves from one member to another only through member transitions. Membership alone implies no order, neighbors, progression, synchronization, or priority among members.

  5. Entering the member State from another vertex enters one of its members, and Graph does not name which. Leaving the member State for another vertex leaves the collection. An InvokingTransition activated at a member retains that member, and completion resumes it.

  6. Members belong to one occurrence of the Journey that owns the member State. A member transition stays inside that Journey occurrence and inside every CompositeState occurrence that contains that Journey occurrence. Each occurrence of the Journey, for example as the child of different CompositeStates or as an invoked Journey, has its own members.

  7. When the member State is a CompositeState, each member has its own child Journey occurrences. A member transition leaves the child Journeys of the member it leaves and enters the member it moves to, as any Transition from and into a CompositeState does.

  8. Graph does not define how many members exist or which they are, nor how members are told apart, ordered, added, removed, loaded, or presented.

  9. Producers SHOULD declare a StateCollection when one State or CompositeState stands for several parts that the user moves between, instead of declaring one State per part. Parts that behave differently are different States. Parts that offer the same affordances behave the same, even when one of those affordances enters a different entry at each part. Producers SHOULD NOT add a member Transition that adds nothing to a member AdjacentTransition of the same collection: no Command, child entry or exit selection, guard, or effect.

An entry transition that the member State lists is offered at each member. With an EntrySelector, the entry it enters can differ from member to member.

classDiagram
  class StateCollection {
    id
    label
    memberStateRef
    memberTransitionRefs
  }
  class Journey {
    stateRefs
  }
  class State
  class CompositeState
  class Transition
  class AdjacentTransition

  StateCollection --> State : memberStateRef
  StateCollection --> CompositeState : memberStateRef
  StateCollection --> Transition : memberTransitionRefs
  StateCollection --> AdjacentTransition : memberTransitionRefs
  Journey --> State : stateRefs
  Journey --> CompositeState : stateRefs

In the example below, "Toggle item" acts at the member where it is taken and stays there. Crossing the border to a neighboring member, or invoking "Next item", moves to another member; neither names which one.

json
[
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:item-list",
    "label": "Item list",
    "defaultEntryRef": "urn:ujg:entry:item-list",
    "entryRefs": ["urn:ujg:entry:item-list"],
    "stateRefs": ["urn:ujg:state:list-item"],
    "transitionRefs": ["urn:ujg:transition:list-item-toggle"]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:item-list",
    "stateRef": "urn:ujg:state:list-item"
  },
  {
    "@type": "State",
    "@id": "urn:ujg:state:list-item",
    "label": "List item"
  },
  {
    "@type": "Transition",
    "@id": "urn:ujg:transition:list-item-toggle",
    "label": "Toggle item",
    "from": "urn:ujg:state:list-item",
    "to": "urn:ujg:state:list-item",
    "commandRef": "urn:ujg:command:toggle-item"
  },
  {
    "@type": "StateCollection",
    "@id": "urn:ujg:collection:list-items",
    "label": "List items",
    "memberStateRef": "urn:ujg:state:list-item",
    "memberTransitionRefs": [
      "urn:ujg:adjacent:list-item-neighbors",
      "urn:ujg:transition:list-item-next"
    ]
  },
  {
    "@type": "AdjacentTransition",
    "@id": "urn:ujg:adjacent:list-item-neighbors",
    "from": "urn:ujg:state:list-item",
    "to": "urn:ujg:state:list-item"
  },
  {
    "@type": "Transition",
    "@id": "urn:ujg:transition:list-item-next",
    "label": "Next item",
    "from": "urn:ujg:state:list-item",
    "to": "urn:ujg:state:list-item",
    "commandRef": "urn:ujg:command:next-item"
  },
  {
    "@type": "Command",
    "@id": "urn:ujg:command:toggle-item",
    "label": "Toggle item"
  },
  {
    "@type": "Command",
    "@id": "urn:ujg:command:next-item",
    "label": "Next item"
  }
]
[
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:item-list",
    "label": "Item list",
    "defaultEntryRef": "urn:ujg:entry:item-list",
    "entryRefs": ["urn:ujg:entry:item-list"],
    "stateRefs": ["urn:ujg:state:list-item"],
    "transitionRefs": ["urn:ujg:transition:list-item-toggle"]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:item-list",
    "stateRef": "urn:ujg:state:list-item"
  },
  {
    "@type": "State",
    "@id": "urn:ujg:state:list-item",
    "label": "List item"
  },
  {
    "@type": "Transition",
    "@id": "urn:ujg:transition:list-item-toggle",
    "label": "Toggle item",
    "from": "urn:ujg:state:list-item",
    "to": "urn:ujg:state:list-item",
    "commandRef": "urn:ujg:command:toggle-item"
  },
  {
    "@type": "StateCollection",
    "@id": "urn:ujg:collection:list-items",
    "label": "List items",
    "memberStateRef": "urn:ujg:state:list-item",
    "memberTransitionRefs": [
      "urn:ujg:adjacent:list-item-neighbors",
      "urn:ujg:transition:list-item-next"
    ]
  },
  {
    "@type": "AdjacentTransition",
    "@id": "urn:ujg:adjacent:list-item-neighbors",
    "from": "urn:ujg:state:list-item",
    "to": "urn:ujg:state:list-item"
  },
  {
    "@type": "Transition",
    "@id": "urn:ujg:transition:list-item-next",
    "label": "Next item",
    "from": "urn:ujg:state:list-item",
    "to": "urn:ujg:state:list-item",
    "commandRef": "urn:ujg:command:next-item"
  },
  {
    "@type": "Command",
    "@id": "urn:ujg:command:toggle-item",
    "label": "Toggle item"
  },
  {
    "@type": "Command",
    "@id": "urn:ujg:command:next-item",
    "label": "Next item"
  }
]

4. Transitions

Graph has four transition classes. A Transition is ordinary directed progression inside one Journey. An AdjacentTransition connects two vertices of one Journey that share a border, and the user can cross it in either direction. OutgoingTransition and InvokingTransition are entry transitions: affordances available at a State that enter a Journey through an explicit JourneyEntry. The two entry transition classes differ only in what happens to the source State occurrence.

flowchart TB
  subgraph T["Transition"]
    direction LR
    T1["State A<br/>not retained"] -->|"progress (from → to)"| T2["State B<br/>same Journey"]
  end

  subgraph A["AdjacentTransition"]
    direction LR
    A1["State A<br/>not retained"] <-->|"cross shared border (from ↔ to)"| A2["State B<br/>same frame"]
  end

  subgraph O["OutgoingTransition"]
    direction LR
    O1["Source State<br/>not retained"] -->|"navigate (toEntryRef)"| O2["Journey B<br/>entered via JourneyEntry"]
  end

  subgraph I["InvokingTransition"]
    direction LR
    I1["Source State occurrence<br/>retained, suspended"] -->|"invoke (toEntryRef)"| I2["Invoked Journey<br/>entered via JourneyEntry"]
    I2 -.->|"resume at own JourneyExit"| I1
  end

  T ~~~ A
  A ~~~ O
  O ~~~ I
–TransitionAdjacentTransitionOutgoingTransitionInvokingTransition
SourceExplicit local from vertexEither local vertex, from or toState where the affordance is availableState where the affordance is available
DestinationLocal to vertex, or another member for a member transitionThe other local vertex, or a neighboring member for a member transitiontoEntryRef entry contract, or an entry selected through an EntrySelectortoEntryRef entry contract, or an entry selected through an EntrySelector
Declared throughtransitionRefs on a Journey, or memberTransitionRefs on a StateCollectiontransitionRefs on a Journey, or memberTransitionRefs on a StateCollectionentryTransitionRefs on a StateentryTransitionRefs on a State
Source State occurrenceNot retainedNot retainedNot retainedRetained and suspended until the invocation completes or is cancelled
MeaningOrdinary progression inside one JourneyCross a border that two vertices share in one experience frame, in either directionLeave local progression and enter a Journey through an entry contractEnter a Journey through an entry contract, then resume the source when that Journey exits

An entry transition has no from property. Its effective source is each State that lists it in entryTransitionRefs. Transition, OutgoingTransition, and InvokingTransition can reference a Command with commandRef. An AdjacentTransition cannot.

An entry transition either names its JourneyEntry with toEntryRef or, when the entry is known only when the transition is taken, references an EntrySelector, described at the end of this section.

4.1. Transition

A Transition is a structural directed edge between local vertices of a Journey. It models ordinary progression inside the local topology of a Journey.

A Transition is not owned by either endpoint state. It is owned by a journey through transitionRefs, or, as a member transition, by a StateCollection through memberTransitionRefs.

A Transition applies to every concrete occurrence of the local vertex its from value references. The Transition itself remains one stable Graph node.

A Transition describes movement in one direction only. Movement back to its from vertex is another Transition, unless the two vertices share a border, in which case one AdjacentTransition describes both directions.

The presence of multiple child Journeys in one CompositeState does not create implicit Transitions between them.

  1. A Transition MUST be identified by an IRI, declare exactly one from, and declare exactly one to.

  2. A Transition MAY declare one label.

  3. A Transition MAY reference one Command with commandRef.

  4. When listed in a Journey's transitionRefs, from MUST reference a State or CompositeState in that journey's stateRefs.

  5. When listed in a Journey's transitionRefs, to MUST reference a State or CompositeState in that journey's stateRefs, or a JourneyExit in that journey's exitRefs.

  6. Transition endpoints MUST stay local to the enclosing Journey.

  7. toEntryRef MAY be used only on parent transitions into CompositeState nodes, and fromExitRef only on parent transitions from them, as defined under CompositeState.

  8. A Transition MUST remain one Graph node regardless of how many concrete occurrences its endpoints have; per-instance transition properties are outside Graph.

  9. A child Journey's Transition MUST NOT connect directly to a State, CompositeState, or JourneyExit owned only by another child Journey.

classDiagram
  class State
  class CompositeState
  class JourneyExit
  class Command

  class Transition {
    id
    label
    from
    to
    commandRef
  }

  Transition --> State : from
  Transition --> CompositeState : from
  Transition --> State : to
  Transition --> CompositeState : to
  Transition --> JourneyExit : to
  Transition --> Command : commandRef

Example JSON node:

json
{
  "@type": "Transition",
  "@id": "urn:ujg:transition:search-form-to-results",
  "label": "Submit search",
  "from": "urn:ujg:state:search-form",
  "to": "urn:ujg:state:results",
  "commandRef": "urn:ujg:command:submit-search"
}
{
  "@type": "Transition",
  "@id": "urn:ujg:transition:search-form-to-results",
  "label": "Submit search",
  "from": "urn:ujg:state:search-form",
  "to": "urn:ujg:state:results",
  "commandRef": "urn:ujg:command:submit-search"
}

4.2. AdjacentTransition

An AdjacentTransition connects two local vertices of a Journey that sit next to each other in the same experience frame and share a border. The user can cross that border in either direction, so one AdjacentTransition describes movement both ways.

from and to name the vertex before and the vertex after the border in the frame's reading order. That order does not restrict movement. As with a Transition, crossing the border leaves one vertex and makes the other current. Crossing back makes the first vertex current again, so a State offers its entry transitions again. Parts of a frame that the user acts on at the same time are not adjacent vertices.

A member AdjacentTransition connects neighboring members of a StateCollection. Its from and to are both the member State, and which neighbor it reaches is known only when the user crosses the border. Crossing it leaves one member and enters the other.

  1. An AdjacentTransition describes movement from its from vertex to its to vertex and from its to vertex to its from vertex. Each movement leaves the vertex it starts from, as taking a Transition does.

  2. An AdjacentTransition MUST remain one Graph node regardless of the direction of movement and of how many concrete occurrences its endpoints have.

  3. Moving across an AdjacentTransition into a CompositeState selects no child entry, as for a Transition without toEntryRef. Moving across it out of a CompositeState leaves the CompositeState and all of its child Journeys.

  4. Producers SHOULD NOT also declare a Transition between the same two vertices, in either direction, that adds nothing to the adjacency: no Command, child entry or exit selection, guard, or effect. The AdjacentTransition already describes that movement. For a member AdjacentTransition, this applies to the member Transitions of the same collection, not to a Transition from the member State to itself that a Journey lists.

Adjacent vertices occur, for example, as consecutive sections of a scrolling view or as pages of a pager that shows one page at a time. Use a Transition when a movement has its own Command, guard, effect, or child-entry selection. Both can connect the same two vertices: the AdjacentTransition describes crossing the border, and the Transition describes that particular movement.

classDiagram
  class State
  class CompositeState

  class AdjacentTransition {
    id
    label
    from
    to
  }

  AdjacentTransition --> State : from
  AdjacentTransition --> CompositeState : from
  AdjacentTransition --> State : to
  AdjacentTransition --> CompositeState : to

Example JSON node:

json
{
  "@type": "AdjacentTransition",
  "@id": "urn:ujg:adjacent:section-1-section-2",
  "from": "urn:ujg:state:section-1",
  "to": "urn:ujg:state:section-2"
}
{
  "@type": "AdjacentTransition",
  "@id": "urn:ujg:adjacent:section-1-section-2",
  "from": "urn:ujg:state:section-1",
  "to": "urn:ujg:state:section-2"
}

4.3. OutgoingTransition

An OutgoingTransition is a navigational affordance that enters a Journey through an explicit JourneyEntry. It does not declare structural progression in the source Journey's local topology.

The destination entry's stateRef identifies the first local State or CompositeState of the destination Journey. Consumers do not bypass the entry contract by linking the outgoing affordance directly to that state.

  1. An OutgoingTransition MUST be identified by an IRI and MAY declare one label.

  2. An OutgoingTransition's destination entry is either fixed by toEntryRef or selected when the transition is taken, through the EntrySelector that entrySelectorRef references.

  3. An OutgoingTransition MAY reference one Command with commandRef.

  4. The destination entry, fixed or selected, MUST be a JourneyEntry owned by exactly one Journey.

  5. The destination entry's stateRef MUST reference a State or CompositeState in that owner Journey's stateRefs.

  6. The destination entry MAY belong to the Journey where the affordance is available. Such a target is explicit Journey re-entry, including when the entry points to the effective source state.

  7. An OutgoingTransition MUST NOT declare from, fromExitRef, to, or entryTransitionRefs, target a JourneyExit, appear in transitionRefs, or model ordinary internal progression.

A JourneyEntryIndex may catalogue the destination entry for discovery, but index membership is not required for navigation. The entry remains owned by its declaring Journey.

classDiagram
  class OutgoingTransition {
    toEntryRef
    entrySelectorRef
    commandRef
  }
  class Journey {
    entryRefs
    stateRefs
  }
  class JourneyEntry {
    stateRef
  }
  class EntrySelector
  class State
  class CompositeState
  class Command

  OutgoingTransition --> JourneyEntry : toEntryRef
  OutgoingTransition --> EntrySelector : entrySelectorRef
  Journey --> JourneyEntry : entryRefs
  JourneyEntry --> State : stateRef
  JourneyEntry --> CompositeState : stateRef
  OutgoingTransition --> Command : commandRef

Cross-Journey navigation names the destination entry rather than its State:

json
[
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:home",
    "defaultEntryRef": "urn:ujg:entry:home",
    "entryRefs": ["urn:ujg:entry:home"],
    "stateRefs": ["urn:ujg:state:home"]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:home",
    "label": "Home entry",
    "stateRef": "urn:ujg:state:home"
  },
  {
    "@type": "State",
    "@id": "urn:ujg:state:home",
    "label": "Home"
  },
  {
    "@type": "OutgoingTransition",
    "@id": "urn:ujg:ot:go-home",
    "label": "Home",
    "toEntryRef": "urn:ujg:entry:home",
    "commandRef": "urn:ujg:command:go-home"
  },
  {
    "@type": "Command",
    "@id": "urn:ujg:command:go-home",
    "label": "Go home"
  }
]
[
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:home",
    "defaultEntryRef": "urn:ujg:entry:home",
    "entryRefs": ["urn:ujg:entry:home"],
    "stateRefs": ["urn:ujg:state:home"]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:home",
    "label": "Home entry",
    "stateRef": "urn:ujg:state:home"
  },
  {
    "@type": "State",
    "@id": "urn:ujg:state:home",
    "label": "Home"
  },
  {
    "@type": "OutgoingTransition",
    "@id": "urn:ujg:ot:go-home",
    "label": "Home",
    "toEntryRef": "urn:ujg:entry:home",
    "commandRef": "urn:ujg:command:go-home"
  },
  {
    "@type": "Command",
    "@id": "urn:ujg:command:go-home",
    "label": "Go home"
  }
]

The same pattern represents same-state re-entry: the OutgoingTransition targets a JourneyEntry whose stateRef is the state where the affordance is available. This remains explicit re-entry, not an implicit relative target.

json
[
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:confirmation",
    "defaultEntryRef": "urn:ujg:entry:confirmation",
    "entryRefs": ["urn:ujg:entry:confirmation"],
    "stateRefs": ["urn:ujg:state:confirmation"]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:confirmation",
    "stateRef": "urn:ujg:state:confirmation"
  },
  {
    "@type": "State",
    "@id": "urn:ujg:state:confirmation",
    "label": "Confirmation",
    "entryTransitionRefs": ["urn:ujg:ot:reenter-confirmation"]
  },
  {
    "@type": "OutgoingTransition",
    "@id": "urn:ujg:ot:reenter-confirmation",
    "label": "Re-enter confirmation",
    "toEntryRef": "urn:ujg:entry:confirmation"
  }
]
[
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:confirmation",
    "defaultEntryRef": "urn:ujg:entry:confirmation",
    "entryRefs": ["urn:ujg:entry:confirmation"],
    "stateRefs": ["urn:ujg:state:confirmation"]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:confirmation",
    "stateRef": "urn:ujg:state:confirmation"
  },
  {
    "@type": "State",
    "@id": "urn:ujg:state:confirmation",
    "label": "Confirmation",
    "entryTransitionRefs": ["urn:ujg:ot:reenter-confirmation"]
  },
  {
    "@type": "OutgoingTransition",
    "@id": "urn:ujg:ot:reenter-confirmation",
    "label": "Re-enter confirmation",
    "toEntryRef": "urn:ujg:entry:confirmation"
  }
]

4.4. InvokingTransition

An InvokingTransition invokes a Journey through an explicit JourneyEntry. It has the same source and destination model as an OutgoingTransition. The difference is lifecycle: the source State occurrence is retained, and it resumes when the invoked Journey reaches one of its exits.

  1. An InvokingTransition MUST be identified by an IRI and MAY declare one label. It names its destination entry as an OutgoingTransition does, fixed by toEntryRef or selected through an EntrySelector, and MAY reference one Command with commandRef. It MUST NOT declare from, fromExitRef, to, or entryTransitionRefs, target a JourneyExit, appear in transitionRefs, model ordinary internal progression, or also be typed OutgoingTransition.

  2. The effective source of an InvokingTransition is each State that lists it in entryTransitionRefs, exactly as for an OutgoingTransition.

  3. The destination entry, fixed or selected, MUST be a JourneyEntry owned by exactly one Journey, and the entry's stateRef MUST reference a State or CompositeState in that owner Journey's stateRefs. That Journey is the invoked Journey. With an EntrySelector, each activation has its own invoked Journey. The invoked Journey MUST declare at least one exitRefs value.

  4. The invoked Journey MAY be the Journey where the affordance is available. Each activation is a separate, nested invocation.

  5. Activating an InvokingTransition enters the invoked Journey through its destination entry and retains the source State occurrence, including any active composite scope. The source occurrence is not left. While the invocation is in progress, the retained source occurrence, together with any composite scope retained with it, is suspended: no Transition, AdjacentTransition, or entry transition is taken from the source occurrence, and no parent Transition or AdjacentTransition is taken from a retained CompositeState. State occurrences inside that composite scope that are not the source, such as States of a sibling child Journey, are not suspended and keep their own transitions and entry transitions. A parent Transition that a sibling's child exit triggers meanwhile is taken after the invocation completes, and not at all if it is cancelled.

  6. Reaching a JourneyExit listed in the invoked Journey's own exitRefs completes the invocation. The retained source occurrence then resumes without entering a JourneyEntry or taking a Transition. A child JourneyExit reached inside a CompositeState of the invoked Journey is not completion; it follows the CompositeState rules.

  7. The reached JourneyExit is the outcome of the invocation. Graph assigns no per-outcome continuation.

  8. An invocation is cancelled, not completed, when the invoked Journey is left in any way other than reaching one of its own exits. Traversing an OutgoingTransition from any State occurrence of the invoked Journey, including one inside its composite scopes, leaves the invoked Journey, even when the destination entry belongs to the invoked Journey itself. Activating an InvokingTransition from inside the invoked Journey does not leave it.

  9. An invocation is also cancelled when its retained source occurrence is left before the invocation completes, for example because an OutgoingTransition is taken from a State of a sibling child Journey, which is not suspended. The invoked Journey is then left as well, which cancels any invocation nested inside it. A sibling child Journey reaching a JourneyExit does not leave the source.

  10. When an invocation is cancelled, Consumers MUST NOT infer a return, and the retained source occurrence MUST NOT be resumed. A source occurrence that is still retained is left, including its active composite scope. If that source occurrence is inside a Journey that was itself invoked, that Journey is left as well, which cancels its invocation in turn. Cancellation therefore releases every retained occurrence in the invocation chain.

  11. An InvokingTransition does not add the invoked Journey to any subjourneyRefs. The invoked Journey occurrence is not a child of any CompositeState occurrence, even when the same Journey is listed in some CompositeState's subjourneyRefs. The CompositeState rules for child exits therefore do not apply to its exits, and completion never leaves a CompositeState, neither one that lists the invoked Journey nor one that contains the source.

  12. Graph does not define invocation identifiers or association data between source and invoked occurrences.

classDiagram
  class InvokingTransition {
    toEntryRef
    entrySelectorRef
    commandRef
  }
  class Journey {
    entryRefs
    stateRefs
    exitRefs
  }
  class JourneyEntry {
    stateRef
  }
  class EntrySelector
  class JourneyExit
  class Command

  InvokingTransition --> JourneyEntry : toEntryRef
  InvokingTransition --> EntrySelector : entrySelectorRef
  Journey --> JourneyEntry : entryRefs
  Journey --> JourneyExit : exitRefs
  InvokingTransition --> Command : commandRef

A privacy settings dialog invoked from an article page. Either exit completes the invocation, and the Article State occurrence resumes. settings-saved and settings-dismissed are distinguishable outcomes, but neither is a destination.

json
[
  {
    "@type": "State",
    "@id": "urn:ujg:state:article",
    "label": "Article",
    "entryTransitionRefs": ["urn:ujg:it:adjust-privacy-settings"]
  },
  {
    "@type": "InvokingTransition",
    "@id": "urn:ujg:it:adjust-privacy-settings",
    "label": "Adjust privacy settings",
    "toEntryRef": "urn:ujg:entry:privacy-settings",
    "commandRef": "urn:ujg:command:adjust-privacy-settings"
  },
  {
    "@type": "Command",
    "@id": "urn:ujg:command:adjust-privacy-settings",
    "label": "Adjust privacy settings"
  },
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:privacy-settings",
    "defaultEntryRef": "urn:ujg:entry:privacy-settings",
    "entryRefs": ["urn:ujg:entry:privacy-settings"],
    "stateRefs": ["urn:ujg:state:privacy-settings"],
    "transitionRefs": [
      "urn:ujg:transition:privacy-settings-save",
      "urn:ujg:transition:privacy-settings-dismiss"
    ],
    "exitRefs": [
      "urn:ujg:exit:settings-saved",
      "urn:ujg:exit:settings-dismissed"
    ]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:privacy-settings",
    "stateRef": "urn:ujg:state:privacy-settings"
  },
  {
    "@type": "State",
    "@id": "urn:ujg:state:privacy-settings",
    "label": "Privacy settings"
  },
  {
    "@type": "Transition",
    "@id": "urn:ujg:transition:privacy-settings-save",
    "label": "Save",
    "from": "urn:ujg:state:privacy-settings",
    "to": "urn:ujg:exit:settings-saved"
  },
  {
    "@type": "Transition",
    "@id": "urn:ujg:transition:privacy-settings-dismiss",
    "label": "Back",
    "from": "urn:ujg:state:privacy-settings",
    "to": "urn:ujg:exit:settings-dismissed"
  },
  {
    "@type": "JourneyExit",
    "@id": "urn:ujg:exit:settings-saved",
    "label": "Settings saved"
  },
  {
    "@type": "JourneyExit",
    "@id": "urn:ujg:exit:settings-dismissed",
    "label": "Settings dismissed"
  }
]
[
  {
    "@type": "State",
    "@id": "urn:ujg:state:article",
    "label": "Article",
    "entryTransitionRefs": ["urn:ujg:it:adjust-privacy-settings"]
  },
  {
    "@type": "InvokingTransition",
    "@id": "urn:ujg:it:adjust-privacy-settings",
    "label": "Adjust privacy settings",
    "toEntryRef": "urn:ujg:entry:privacy-settings",
    "commandRef": "urn:ujg:command:adjust-privacy-settings"
  },
  {
    "@type": "Command",
    "@id": "urn:ujg:command:adjust-privacy-settings",
    "label": "Adjust privacy settings"
  },
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:privacy-settings",
    "defaultEntryRef": "urn:ujg:entry:privacy-settings",
    "entryRefs": ["urn:ujg:entry:privacy-settings"],
    "stateRefs": ["urn:ujg:state:privacy-settings"],
    "transitionRefs": [
      "urn:ujg:transition:privacy-settings-save",
      "urn:ujg:transition:privacy-settings-dismiss"
    ],
    "exitRefs": [
      "urn:ujg:exit:settings-saved",
      "urn:ujg:exit:settings-dismissed"
    ]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:privacy-settings",
    "stateRef": "urn:ujg:state:privacy-settings"
  },
  {
    "@type": "State",
    "@id": "urn:ujg:state:privacy-settings",
    "label": "Privacy settings"
  },
  {
    "@type": "Transition",
    "@id": "urn:ujg:transition:privacy-settings-save",
    "label": "Save",
    "from": "urn:ujg:state:privacy-settings",
    "to": "urn:ujg:exit:settings-saved"
  },
  {
    "@type": "Transition",
    "@id": "urn:ujg:transition:privacy-settings-dismiss",
    "label": "Back",
    "from": "urn:ujg:state:privacy-settings",
    "to": "urn:ujg:exit:settings-dismissed"
  },
  {
    "@type": "JourneyExit",
    "@id": "urn:ujg:exit:settings-saved",
    "label": "Settings saved"
  },
  {
    "@type": "JourneyExit",
    "@id": "urn:ujg:exit:settings-dismissed",
    "label": "Settings dismissed"
  }
]

Several pages can share entry transitions of both classes. "Privacy policy" navigates away from the current page. "Adjust privacy settings" invokes the privacy settings Journey from the example above and returns to the current page when that Journey exits. Each page's State lists the same two transitions; each node's class determines its semantics.

json
[
  {
    "@type": "State",
    "@id": "urn:ujg:state:article",
    "label": "Article",
    "entryTransitionRefs": [
      "urn:ujg:ot:privacy-policy",
      "urn:ujg:it:adjust-privacy-settings"
    ]
  },
  {
    "@type": "State",
    "@id": "urn:ujg:state:search-results",
    "label": "Search results",
    "entryTransitionRefs": [
      "urn:ujg:ot:privacy-policy",
      "urn:ujg:it:adjust-privacy-settings"
    ]
  },
  {
    "@type": "OutgoingTransition",
    "@id": "urn:ujg:ot:privacy-policy",
    "label": "Privacy policy",
    "toEntryRef": "urn:ujg:entry:privacy-policy"
  },
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:privacy-policy",
    "defaultEntryRef": "urn:ujg:entry:privacy-policy",
    "entryRefs": ["urn:ujg:entry:privacy-policy"],
    "stateRefs": ["urn:ujg:state:privacy-policy"]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:privacy-policy",
    "stateRef": "urn:ujg:state:privacy-policy"
  },
  {
    "@type": "State",
    "@id": "urn:ujg:state:privacy-policy",
    "label": "Privacy policy"
  }
]
[
  {
    "@type": "State",
    "@id": "urn:ujg:state:article",
    "label": "Article",
    "entryTransitionRefs": [
      "urn:ujg:ot:privacy-policy",
      "urn:ujg:it:adjust-privacy-settings"
    ]
  },
  {
    "@type": "State",
    "@id": "urn:ujg:state:search-results",
    "label": "Search results",
    "entryTransitionRefs": [
      "urn:ujg:ot:privacy-policy",
      "urn:ujg:it:adjust-privacy-settings"
    ]
  },
  {
    "@type": "OutgoingTransition",
    "@id": "urn:ujg:ot:privacy-policy",
    "label": "Privacy policy",
    "toEntryRef": "urn:ujg:entry:privacy-policy"
  },
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:privacy-policy",
    "defaultEntryRef": "urn:ujg:entry:privacy-policy",
    "entryRefs": ["urn:ujg:entry:privacy-policy"],
    "stateRefs": ["urn:ujg:state:privacy-policy"]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:privacy-policy",
    "stateRef": "urn:ujg:state:privacy-policy"
  },
  {
    "@type": "State",
    "@id": "urn:ujg:state:privacy-policy",
    "label": "Privacy policy"
  }
]

Mapping and Metrics do not yet account for InvokingTransition. Mapping gives the invoked Journey's steps their own local scope, so its exits end no CompositeState occurrence. Otherwise, until they do, Mapping treats both the entry into the invoked Journey and the resumption of the source State as unexplained movements, so each completed invocation adds two derived jumps, and two to unexplainedMovementCount, across the execution's JourneyMappings.

4.5. EntrySelector

An EntrySelector lets one entry transition lead to a different entry each time it is taken, such as an "Open" link on every row of a list where one row opens an article and the next a topic page. The link is modeled once, and so is whether it navigates or invokes. Which JourneyEntry it enters comes from the row, or more generally from the occurrence of the State where the user takes it, and the Graph does not name it.

The transition references the selector with entrySelectorRef instead of naming an entry with toEntryRef. The selector can list the Journeys that the entry may belong to in candidateJourneyRefs. When the rows are the members of a StateCollection, each member can open a different entry.

The destination entry…Model
is the same at every occurrence, and only the content shown there differstoEntryRef
depends on which State lists the affordanceOne entry transition per source State, as described under State-scoped entry transitions
differs between occurrences of the same State, such as between the members of a StateCollectionentrySelectorRef
  1. An entry transition that references an EntrySelector enters a JourneyEntry that Graph does not name. The entry is known only when the transition is taken, and it can differ between occurrences of the State that lists the transition.

  2. When the selection resolves, the transition enters exactly one JourneyEntry, and the movement is the one its class defines. An OutgoingTransition leaves the source State occurrence. An InvokingTransition retains it, and the Journey that owns the selected entry is the invoked Journey of that activation.

  3. When the selector declares candidateJourneyRefs, the selected entry belongs to one of those Journeys. Without candidates, it can belong to any Journey, including one defined in a document that becomes available only when the transition is taken.

  4. When the selection resolves to no JourneyEntry, the transition enters no Journey, and Consumers MUST NOT infer traversal from it. An invocation cannot select an entry whose Journey declares no exits, because reaching one of those exits is what resumes the source.

  5. Selecting an entry adds no State, Transition, or JourneyEntry to the Graph. The selection does not depend on which State lists the transition: when the destination does, Producers use source-specific entry transitions, as described under State-scoped entry transitions.

  6. Graph does not define how candidate entries are produced, listed, ranked, or loaded, or how an occurrence resolves to an entry.

  7. Producers SHOULD use toEntryRef when every occurrence enters the same entry. Producers SHOULD declare candidateJourneyRefs when the possible Journeys are known: the candidates state where the user can go, and they let Consumers tell an explained movement from drift.

The candidates belong to the selector, not to the transitions that reference it. When an InvokingTransition references a selector, every candidate Journey declares exits, also when OutgoingTransitions share that selector.

classDiagram
  class OutgoingTransition {
    entrySelectorRef
    commandRef
  }
  class InvokingTransition {
    entrySelectorRef
    commandRef
  }
  class EntrySelector {
    id
    label
    candidateJourneyRefs
  }
  class Journey {
    entryRefs
  }
  class JourneyEntry

  OutgoingTransition --> EntrySelector : entrySelectorRef
  InvokingTransition --> EntrySelector : entrySelectorRef
  EntrySelector --> Journey : candidateJourneyRefs
  Journey --> JourneyEntry : entryRefs

In the example below, each item of a list offers "Open item". Which entry it opens comes with the item: an entry of the Article Journey or of the Topic Journey. The candidate Journeys are declared elsewhere.

json
[
  {
    "@type": "State",
    "@id": "urn:ujg:state:list-item",
    "label": "List item",
    "entryTransitionRefs": ["urn:ujg:ot:open-item"]
  },
  {
    "@type": "OutgoingTransition",
    "@id": "urn:ujg:ot:open-item",
    "label": "Open item",
    "entrySelectorRef": "urn:ujg:selector:item-destination",
    "commandRef": "urn:ujg:command:open-item"
  },
  {
    "@type": "Command",
    "@id": "urn:ujg:command:open-item",
    "label": "Open item"
  },
  {
    "@type": "EntrySelector",
    "@id": "urn:ujg:selector:item-destination",
    "label": "Item destination",
    "candidateJourneyRefs": [
      "urn:ujg:journey:article",
      "urn:ujg:journey:topic"
    ]
  }
]
[
  {
    "@type": "State",
    "@id": "urn:ujg:state:list-item",
    "label": "List item",
    "entryTransitionRefs": ["urn:ujg:ot:open-item"]
  },
  {
    "@type": "OutgoingTransition",
    "@id": "urn:ujg:ot:open-item",
    "label": "Open item",
    "entrySelectorRef": "urn:ujg:selector:item-destination",
    "commandRef": "urn:ujg:command:open-item"
  },
  {
    "@type": "Command",
    "@id": "urn:ujg:command:open-item",
    "label": "Open item"
  },
  {
    "@type": "EntrySelector",
    "@id": "urn:ujg:selector:item-destination",
    "label": "Item destination",
    "candidateJourneyRefs": [
      "urn:ujg:journey:article",
      "urn:ujg:journey:topic"
    ]
  }
]

5. Command

A Command identifies the stable semantic identity of an intentional invocation in the modeled experience.

A Command can be referenced by Transition, OutgoingTransition, and InvokingTransition nodes through commandRef. Multiple transitions may reference the same Command. Sharing a commandRef establishes only common invocation identity. Graph does not assign branching, selection, ordering, resolution, execution-result, or effect semantics to that relationship.

A Command is not a transition endpoint and does not replace Transition, OutgoingTransition, or InvokingTransition. Structural, automatic, expiry-driven, or otherwise non-invoked transitions can remain without commandRef.

An AdjacentTransition never references a Command: crossing a shared border is not an intentional invocation. A commanded movement between the same two vertices is a separate Transition with commandRef.

  1. A Command MUST be identified by an IRI.

  2. A Command MAY declare one label and one or more tags.

  3. A Command MUST NOT declare from, to, branching, condition resolution, effect execution, visual representation, runtime execution, or execution-result semantics.

  4. commandRef MAY appear on a Transition, OutgoingTransition, or InvokingTransition and MUST reference a Command.

  5. A Transition, OutgoingTransition, or InvokingTransition MUST NOT reference more than one Command.

  6. Absence of commandRef makes no claim that the transition represents an intentional invocation.

classDiagram
  class Command {
    id
    label
    tags
  }
  class Transition {
    commandRef
  }
  class OutgoingTransition {
    commandRef
  }
  class InvokingTransition {
    commandRef
  }

  Transition --> Command : commandRef
  OutgoingTransition --> Command : commandRef
  InvokingTransition --> Command : commandRef

Example JSON node:

json
{
  "@type": "Command",
  "@id": "urn:ujg:command:start-registration",
  "label": "Start registration"
}
{
  "@type": "Command",
  "@id": "urn:ujg:command:start-registration",
  "label": "Start registration"
}

Example transition associated with a command:

json
{
  "@type": "Transition",
  "@id": "urn:ujg:transition:start-registration",
  "from": "urn:ujg:state:registration-open",
  "to": "urn:ujg:state:registration-form",
  "commandRef": "urn:ujg:command:start-registration"
}
{
  "@type": "Transition",
  "@id": "urn:ujg:transition:start-registration",
  "from": "urn:ujg:state:registration-open",
  "to": "urn:ujg:state:registration-form",
  "commandRef": "urn:ujg:command:start-registration"
}

6. Journey

A Journey is the local container for intended flow topology. It lists the experiential states that belong to the journey, the terminal exits exported by the journey, and, when present, the transitions that connect those local vertices. Member transitions are listed by their StateCollection instead.

Use Journey when the modeled object owns local traversal, progression, or structural order. If the model only needs to list known entry points into pages, surfaces, flows, or journeys, use JourneyEntryIndex instead.

The subsections below define the two contracts a Journey declares besides its states and transitions: its entries (entryRefs) and its exits (exitRefs).

  1. A Journey MUST be identified by an IRI and declare at least one entryRefs value and one stateRefs value.

  2. A Journey MAY declare one defaultEntryRef; if present, it MUST also appear in entryRefs.

  3. entryRefs, stateRefs, transitionRefs, and exitRefs MUST reference nodes of the corresponding Graph classes. transitionRefs values are Transitions or AdjacentTransitions.

  4. A Journey's local vertices are its stateRefs plus its exitRefs.

  5. stateRefs lists the Journey's State and CompositeState vertices. It MUST describe local experiential topology, not destinations that are merely reachable through OutgoingTransition navigation or InvokingTransition invocation.

  6. A Journey MUST NOT declare entryTransitionRefs. Entry transitions are listed by the States that offer them.

  7. A State or CompositeState MUST NOT be listed in the stateRefs of more than one Journey. To reuse topology, reuse the Journey: it can be referenced by more than one CompositeState and entered through OutgoingTransitions and InvokingTransitions.

classDiagram
  class Journey {
    id
    label
    defaultEntryRef
    entryRefs
    stateRefs
    transitionRefs
    exitRefs
  }

  class JourneyEntry {
    id
    stateRef
  }

  class State {
    id
    label
  }

  class CompositeState {
    id
    label
  }

  class JourneyExit {
    id
    label
  }

  class Transition {
    id
    from
    to
  }

  class AdjacentTransition {
    id
    from
    to
  }

  Journey --> JourneyEntry : defaultEntryRef
  Journey --> JourneyEntry : entryRefs
  JourneyEntry --> State : stateRef
  JourneyEntry --> CompositeState : stateRef
  Journey --> State : stateRefs
  Journey --> CompositeState : stateRefs
  Journey --> JourneyExit : exitRefs
  Journey --> Transition : transitionRefs
  Journey --> AdjacentTransition : transitionRefs
  Transition --> State : from
  Transition --> CompositeState : from
  Transition --> State : to
  Transition --> CompositeState : to
  Transition --> JourneyExit : to
  AdjacentTransition --> State : from
  AdjacentTransition --> CompositeState : from
  AdjacentTransition --> State : to
  AdjacentTransition --> CompositeState : to

Example JSON node:

json
[
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:site-search",
    "label": "Site search",
    "defaultEntryRef": "urn:ujg:entry:site-search-default",
    "entryRefs": [
      "urn:ujg:entry:site-search-default"
    ],
    "stateRefs": [
      "urn:ujg:state:search-form",
      "urn:ujg:state:results"
    ],
    "transitionRefs": [
      "urn:ujg:transition:search-form-to-results"
    ]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:site-search-default",
    "stateRef": "urn:ujg:state:search-form"
  }
]
[
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:site-search",
    "label": "Site search",
    "defaultEntryRef": "urn:ujg:entry:site-search-default",
    "entryRefs": [
      "urn:ujg:entry:site-search-default"
    ],
    "stateRefs": [
      "urn:ujg:state:search-form",
      "urn:ujg:state:results"
    ],
    "transitionRefs": [
      "urn:ujg:transition:search-form-to-results"
    ]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:site-search-default",
    "stateRef": "urn:ujg:state:search-form"
  }
]

A single-state journey can omit transitionRefs:

json
[
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:privacy-policy",
    "label": "Privacy policy",
    "defaultEntryRef": "urn:ujg:entry:privacy-policy-default",
    "entryRefs": [
      "urn:ujg:entry:privacy-policy-default"
    ],
    "stateRefs": [
      "urn:ujg:state:privacy-policy"
    ]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:privacy-policy-default",
    "stateRef": "urn:ujg:state:privacy-policy"
  }
]
[
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:privacy-policy",
    "label": "Privacy policy",
    "defaultEntryRef": "urn:ujg:entry:privacy-policy-default",
    "entryRefs": [
      "urn:ujg:entry:privacy-policy-default"
    ],
    "stateRefs": [
      "urn:ujg:state:privacy-policy"
    ]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:privacy-policy-default",
    "stateRef": "urn:ujg:state:privacy-policy"
  }
]

A journey can also omit defaultEntryRef when no entry is semantically a general fallback. In that case, entry selection is unresolved by Graph unless an execution or materialization context selects exactly one listed JourneyEntry.

json
[
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:workshop-detail",
    "label": "Workshop detail",
    "entryRefs": [
      "urn:ujg:entry:workshop-registration-open",
      "urn:ujg:entry:workshop-waitlist-open",
      "urn:ujg:entry:workshop-registration-closed"
    ],
    "stateRefs": [
      "urn:ujg:state:workshop-registration-open",
      "urn:ujg:state:workshop-waitlist-open",
      "urn:ujg:state:workshop-registration-closed"
    ]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:workshop-registration-open",
    "label": "Registration open",
    "stateRef": "urn:ujg:state:workshop-registration-open"
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:workshop-waitlist-open",
    "label": "Waitlist open",
    "stateRef": "urn:ujg:state:workshop-waitlist-open"
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:workshop-registration-closed",
    "label": "Registration closed",
    "stateRef": "urn:ujg:state:workshop-registration-closed"
  }
]
[
  {
    "@type": "Journey",
    "@id": "urn:ujg:journey:workshop-detail",
    "label": "Workshop detail",
    "entryRefs": [
      "urn:ujg:entry:workshop-registration-open",
      "urn:ujg:entry:workshop-waitlist-open",
      "urn:ujg:entry:workshop-registration-closed"
    ],
    "stateRefs": [
      "urn:ujg:state:workshop-registration-open",
      "urn:ujg:state:workshop-waitlist-open",
      "urn:ujg:state:workshop-registration-closed"
    ]
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:workshop-registration-open",
    "label": "Registration open",
    "stateRef": "urn:ujg:state:workshop-registration-open"
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:workshop-waitlist-open",
    "label": "Waitlist open",
    "stateRef": "urn:ujg:state:workshop-waitlist-open"
  },
  {
    "@type": "JourneyEntry",
    "@id": "urn:ujg:entry:workshop-registration-closed",
    "label": "Registration closed",
    "stateRef": "urn:ujg:state:workshop-registration-closed"
  }
]

6.1. JourneyEntry

A JourneyEntry is an explicit entry contract for a Journey. It identifies the local State or CompositeState where traversal begins without making that entry node part of the local transition topology.

  1. A JourneyEntry MUST be identified by an IRI and declare exactly one stateRef.

  2. stateRef MUST reference a State or CompositeState listed in the declaring Journey's stateRefs.

  3. A JourneyEntry MUST be listed in exactly one Journey's entryRefs.

  4. A JourneyEntry MUST NOT be used as a Transition or AdjacentTransition endpoint.

  5. A JourneyEntry MAY declare one label and one or more tags.

Top-level traversal of a Journey begins at an explicitly selected JourneyEntry. If no entry is explicitly selected and the Journey declares defaultEntryRef, traversal begins at the stateRef of that default entry. If neither applies, entry selection remains unresolved by Graph.

When Graph leaves entry selection unresolved, a materialization or execution context may select one listed entry. Consumers do not infer a default from entryRefs order, and contextual entry selection does not change Graph topology. If no entry can be selected, traversal into that Journey remains unresolved; that does not make the Graph invalid.

classDiagram
  class Journey {
    defaultEntryRef
    entryRefs
    stateRefs
  }
  class JourneyEntry {
    id
    stateRef
  }
  class State
  class CompositeState

  Journey --> JourneyEntry : defaultEntryRef
  Journey --> JourneyEntry : entryRefs
  JourneyEntry --> State : stateRef
  JourneyEntry --> CompositeState : stateRef

Example JSON node:

json
{
  "@type": "JourneyEntry",
  "@id": "urn:ujg:entry:site-search-default",
  "label": "Default search entry",
  "stateRef": "urn:ujg:state:search-form"
}
{
  "@type": "JourneyEntry",
  "@id": "urn:ujg:entry:site-search-default",
  "label": "Default search entry",
  "stateRef": "urn:ujg:state:search-form"
}

6.2. JourneyExit

A JourneyExit is a terminal local graph vertex and exported completion contract declared by a Journey. It represents a terminal journey outcome that can be reached by a local Transition.

A parent journey can use exported exits to distinguish which outcome of a child journey was reached, without directly referencing child states.

  1. A JourneyExit MUST be identified by an IRI and listed in exactly one Journey's exitRefs.

  2. A JourneyExit MAY declare one label and one or more tags.

  3. A JourneyExit MAY be the to endpoint of a Transition in the declaring Journey.

  4. A JourneyExit is terminal: it MUST NOT be a from endpoint or expose entry transitions.

  5. A JourneyExit MUST NOT model runtime facts, submitted values, analytics facts, or ordinary internal child movement.

  6. A JourneyExit is neither a State nor a CompositeState: a node MUST NOT be typed JourneyExit and also State or CompositeState.

If a completion point is an actual user-visible screen, page, modal, or step, it should remain a normal State. A journey can then transition from that state to a JourneyExit that represents the exported terminal outcome.

Informative pattern:

text
CheckoutForm -> SuccessScreen -> CheckoutCompleteExit
CheckoutForm -> SuccessScreen -> CheckoutCompleteExit
classDiagram
  class Journey {
    stateRefs
    exitRefs
  }
  class State
  class JourneyExit
  class Transition

  Journey --> State : stateRefs
  Journey --> JourneyExit : exitRefs
  Transition --> State : from
  Transition --> JourneyExit : to

Example JSON nodes:

json
{
  "@type": "JourneyExit",
  "@id": "urn:ujg:exit:checkout-complete",
  "label": "Checkout complete"
}
{
  "@type": "JourneyExit",
  "@id": "urn:ujg:exit:checkout-complete",
  "label": "Checkout complete"
}
json
{
  "@type": "Transition",
  "@id": "urn:ujg:transition:checkout-form-to-complete",
  "label": "Submit checkout",
  "from": "urn:ujg:state:checkout-form",
  "to": "urn:ujg:exit:checkout-complete"
}
{
  "@type": "Transition",
  "@id": "urn:ujg:transition:checkout-form-to-complete",
  "label": "Submit checkout",
  "from": "urn:ujg:state:checkout-form",
  "to": "urn:ujg:exit:checkout-complete"
}

7. JourneyEntryIndex

A JourneyEntryIndex is a Graph class and Core Node that acts as a catalogue of addressable JourneyEntry contracts. It is not a subclass of Journey and does not define traversal. A Consumer MUST NOT infer that indexed entries are reachable from one another, ordered as a path, or part of a parent-owned progression.

Use Journey when modeling local topology. Use JourneyEntryIndex when listing known entry points into modeled journeys. A root Journey should only be used when the root itself owns real traversal, progression, or structural order.

In common use, a JourneyEntryIndex lists default or named JourneyEntry contracts for modeled pages, surfaces, flows, or journeys. The referenced entries remain owned by their declaring Journey.

  1. A JourneyEntryIndex MUST be identified by an IRI and declare at least one entryRefs value.

  2. Each entryRefs value MUST reference a JourneyEntry owned by exactly one Journey.

  3. A JourneyEntryIndex is a catalogue only: it MUST NOT own topology, entries, states, transitions, exits, or child-journey mappings.

  4. entryRefs on a JourneyEntryIndex MUST NOT imply order, reachability, progression, a user path, or parent continuation.

JourneyEntryIndex is intended for top-level page maps, product surface indexes, search-result target indexes, documentation indexes, entry catalogues, and other collections of known journey entry points. Do not use JourneyEntryIndex to model page-segment order, local journey progression, child completion, runtime observations, or experience annotations.

classDiagram
  class JourneyEntryIndex {
    id
    label
    entryRefs
  }

  class JourneyEntry {
    stateRef
  }

  class State
  class CompositeState
  JourneyEntryIndex --> JourneyEntry : entryRefs
  JourneyEntry --> State : stateRef
  JourneyEntry --> CompositeState : stateRef

Example JSON node:

json
{
  "@type": "JourneyEntryIndex",
  "@id": "urn:ujg:index:site-pages",
  "label": "Site page index",
  "entryRefs": [
    "urn:ujg:entry:home-page-default",
    "urn:ujg:entry:search-page-default",
    "urn:ujg:entry:profile-page-default"
  ]
}
{
  "@type": "JourneyEntryIndex",
  "@id": "urn:ujg:index:site-pages",
  "label": "Site page index",
  "entryRefs": [
    "urn:ujg:entry:home-page-default",
    "urn:ujg:entry:search-page-default",
    "urn:ujg:entry:profile-page-default"
  ]
}

The indexed entries are known entry contracts. Their order above does not define a path from the home page to search to profile.


8. CompositeState

A CompositeState nests Journeys: it is a step of the parent Journey that is itself a Journey, with its own steps, entries, and exits. The parent Journey treats it as one local vertex that can enter a chosen child entry and react to a child exit. With several child Journeys, the user is in each of them at once, such as page content beside a sticky header. It is not a State: it offers no affordances itself.

  1. A CompositeState MUST be identified by an IRI, declare exactly one label, and declare one or more subjourneyRefs, each resolving to a Journey. It MAY declare one or more tags.

  2. A CompositeState MUST NOT be typed State or JourneyExit, and MUST NOT declare stateRefs or entryTransitionRefs.

  3. When a CompositeState nests several child Journeys, they MUST be co-present and independent: a movement in one never moves another. Parts that are co-present but not independent belong to one Journey.

  4. The parent Journey treats the CompositeState as one local vertex: it can be a Transition or AdjacentTransition from or to and a JourneyEntry stateRef. Child States are never listed by the parent, and nested composition is never flattened.

  5. While a CompositeState occurrence is current, the user is at the current State of each child Journey, through nested CompositeStates. Each of those States offers its own entry transitions.

  6. subjourneyRefs is an unordered set. Consumers MUST NOT infer order, priority, dependency, synchronization, or joint completion between child Journeys.

  7. A Journey MAY be a child of more than one CompositeState. Each reference is a separate child occurrence.

  8. A parent Transition into a CompositeState MAY select one child entry with toEntryRef, owned by exactly one child Journey. It selects nothing for the other child Journeys.

  9. Reaching a child JourneyExit does not leave the CompositeState. A parent Transition whose from is the CompositeState and whose fromExitRef is that exit is taken when the exit is reached; without one, the CompositeState stays current. Taking any parent Transition from a CompositeState, or crossing a parent AdjacentTransition out of it, leaves it and all of its child Journeys.

classDiagram
  class CompositeState {
    id
    label
    tags
    subjourneyRefs 1..*
  }
  class Journey {
    entryRefs
    stateRefs
    exitRefs
  }
  class JourneyEntry
  class JourneyExit
  class Transition {
    from
    to
    toEntryRef
    fromExitRef
  }

  Journey --> CompositeState : stateRefs
  CompositeState --> Journey : subjourneyRefs
  Journey --> JourneyEntry : entryRefs
  Journey --> JourneyExit : exitRefs
  Transition --> CompositeState : from/to
  Transition --> JourneyEntry : toEntryRef
  Transition --> JourneyExit : fromExitRef

A CompositeState with one child Journey is valid, and several CompositeStates can reference the same Journey, so a Journey's topology and the entry transitions its States list can be declared once and reused at several points of a graph.

A sticky header that stays in the viewport while page content scrolls is co-present with that content and independent of it. Each page can reference the same header Journey:

json
[
  {
    "@type": "CompositeState",
    "@id": "urn:ujg:state:home-page",
    "label": "Home page",
    "subjourneyRefs": ["urn:ujg:journey:home-content", "urn:ujg:journey:sticky-header"]
  },
  {
    "@type": "CompositeState",
    "@id": "urn:ujg:state:article-page",
    "label": "Article page",
    "subjourneyRefs": ["urn:ujg:journey:article-content", "urn:ujg:journey:sticky-header"]
  }
]
[
  {
    "@type": "CompositeState",
    "@id": "urn:ujg:state:home-page",
    "label": "Home page",
    "subjourneyRefs": ["urn:ujg:journey:home-content", "urn:ujg:journey:sticky-header"]
  },
  {
    "@type": "CompositeState",
    "@id": "urn:ujg:state:article-page",
    "label": "Article page",
    "subjourneyRefs": ["urn:ujg:journey:article-content", "urn:ujg:journey:sticky-header"]
  }
]

A one-page checkout shows shipping and payment side by side:

text
Checkout CompositeState
  Shipping Journey: Address -> DeliveryOption -> Confirmed
  Payment Journey:  Authorizing -> PaymentFailureExit
Checkout CompositeState
  Shipping Journey: Address -> DeliveryOption -> Confirmed
  Payment Journey:  Authorizing -> PaymentFailureExit

A parent Transition can enter Checkout at a specific shipping entry. That selects nothing for Payment:

json
{
  "@type": "Transition",
  "@id": "urn:ujg:transition:cart-to-checkout",
  "label": "Start checkout",
  "from": "urn:ujg:state:cart",
  "to": "urn:ujg:state:checkout",
  "toEntryRef": "urn:ujg:entry:shipping-address"
}
{
  "@type": "Transition",
  "@id": "urn:ujg:transition:cart-to-checkout",
  "label": "Start checkout",
  "from": "urn:ujg:state:cart",
  "to": "urn:ujg:state:checkout",
  "toEntryRef": "urn:ujg:entry:shipping-address"
}

A parent Transition can react to the payment failure. Reaching PaymentFailureExit takes it and leaves Checkout. Without it, Payment is complete and Shipping continues:

json
{
  "@type": "Transition",
  "@id": "urn:ujg:transition:checkout-to-payment-error",
  "label": "Show payment error",
  "from": "urn:ujg:state:checkout",
  "to": "urn:ujg:state:payment-error",
  "fromExitRef": "urn:ujg:exit:payment-failed"
}
{
  "@type": "Transition",
  "@id": "urn:ujg:transition:checkout-to-payment-error",
  "label": "Show payment error",
  "from": "urn:ujg:state:checkout",
  "to": "urn:ujg:state:payment-error",
  "fromExitRef": "urn:ujg:exit:payment-failed"
}

9. Normative Artifacts

This module is published through the following artifacts:

  • graph.ttl: ontology, published at https://ujg.specs.openuji.org/ed/ns/graph

  • graph.context.jsonld: JSON-LD term mappings, published at https://ujg.specs.openuji.org/ed/ns/graph.context.jsonld

  • graph.shape.ttl: SHACL validation rules, published at https://ujg.specs.openuji.org/ed/ns/graph.shape

Examples on this page use compact JSON-LD fragments. Complete documents can use the aggregate context https://ujg.specs.openuji.org/ed/ns/context.jsonld, which preserves Graph's compact stateRef term for JourneyEntry.

9.1. Ontology

The normative Graph ontology is defined below and is published at https://ujg.specs.openuji.org/ed/ns/graph. It is the authoritative structural definition for Graph classes and properties, including Journey, JourneyEntry, JourneyEntryIndex, State, CompositeState, Transition, AdjacentTransition, Command, JourneyExit, OutgoingTransition, InvokingTransition, StateCollection, EntrySelector, defaultEntryRef, entryRefs, stateRef, exitRefs, toEntryRef, fromExitRef, commandRef, subjourneyRefs, entryTransitionRefs, memberStateRef, memberTransitionRefs, entrySelectorRef, and candidateJourneyRefs.

turtle
@prefix ujg: <https://ujg.specs.openuji.org/ed/ns/core#> .
@prefix ujggraph: <https://ujg.specs.openuji.org/ed/ns/graph#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dct: <http://purl.org/dc/terms/> .


<https://ujg.specs.openuji.org/ed/ns/graph#> a owl:Ontology ;
  rdfs:label "UJG Graph Editor's Draft Vocabulary"@en ;
  dct:description "UJG Graph ontology declaration" .

### Classes

ujggraph:Journey a owl:Class ;
  rdfs:subClassOf ujg:Node .

ujggraph:JourneyEntry a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  rdfs:label "Journey Entry" ;
  rdfs:comment "An explicit entry contract for a Journey. A JourneyEntry points to the local State or CompositeState where traversal begins." .

ujggraph:JourneyEntryIndex a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  rdfs:label "Journey Index" ;
  rdfs:comment "A catalogue of addressable JourneyEntry contracts. A JourneyEntryIndex does not define traversal, ordering, reachability, or parent-owned progression." .

ujggraph:State a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  rdfs:label "State" ;
  rdfs:comment "A discrete node in the experience. A State is the only local vertex that declares entryTransitionRefs." .

ujggraph:CompositeState a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  owl:disjointWith ujggraph:State ;
  rdfs:label "Composite State" ;
  rdfs:comment "A local vertex that contains one or more child Journeys through subjourneyRefs. A CompositeState is a sibling of State, not a subclass of it, and it does not declare entryTransitionRefs." .

ujggraph:Transition a owl:Class ;
  rdfs:subClassOf ujg:Node .

ujggraph:AdjacentTransition a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  owl:disjointWith ujggraph:Transition, ujggraph:OutgoingTransition, ujggraph:InvokingTransition ;
  rdfs:label "Adjacent Transition" ;
  rdfs:comment "A structural edge between two local vertices of a Journey, or between two neighboring members of a StateCollection, that sit next to each other in the same experience frame and share a border. It describes movement across that border in both directions. It is not a Transition." .

ujggraph:Command a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  rdfs:label "Command" ;
  rdfs:comment "A stable semantic identity of an intentional invocation in the modeled experience." .

ujggraph:JourneyExit a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  owl:disjointWith ujggraph:State, ujggraph:CompositeState ;
  rdfs:label "Journey Exit" ;
  rdfs:comment "A terminal local graph vertex and exported completion contract of a journey." .

ujggraph:OutgoingTransition a owl:Class ;
  rdfs:subClassOf ujg:Node .

ujggraph:InvokingTransition a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  owl:disjointWith ujggraph:OutgoingTransition ;
  rdfs:label "Invoking Transition" ;
  rdfs:comment "An affordance that invokes a Journey through a JourneyEntry and resumes the source State occurrence when that Journey reaches one of its exits." .

ujggraph:StateCollection a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  owl:disjointWith ujggraph:Journey, ujggraph:JourneyEntry, ujggraph:JourneyEntryIndex, ujggraph:State, ujggraph:CompositeState, ujggraph:Transition, ujggraph:AdjacentTransition, ujggraph:OutgoingTransition, ujggraph:InvokingTransition, ujggraph:Command, ujggraph:JourneyExit ;
  rdfs:label "State Collection" ;
  rdfs:comment "Lets one State or CompositeState, its member State, stand for several similar parts of an experience, its members. It lists the member transitions that move the user from one member to another. It is not a local vertex and names no member." .

ujggraph:EntrySelector a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  owl:disjointWith ujggraph:Journey, ujggraph:JourneyEntry, ujggraph:JourneyEntryIndex, ujggraph:State, ujggraph:CompositeState, ujggraph:Transition, ujggraph:AdjacentTransition, ujggraph:OutgoingTransition, ujggraph:InvokingTransition, ujggraph:Command, ujggraph:JourneyExit, ujggraph:StateCollection ;
  rdfs:label "Entry Selector" ;
  rdfs:comment "States that the JourneyEntry an OutgoingTransition or InvokingTransition enters is selected each time the transition is taken, not named in the Graph. It can list the candidate Journeys the selected entry belongs to. It names no entry." .

### Properties

ujggraph:label a owl:DatatypeProperty ;
  rdfs:domain ujg:Node ;
  rdfs:range xsd:string .

ujggraph:tags a owl:DatatypeProperty ;
  rdfs:domain ujg:Node ;
  rdfs:range xsd:string .

ujggraph:defaultEntryRef a owl:ObjectProperty ;
  rdfs:domain ujggraph:Journey ;
  rdfs:range ujggraph:JourneyEntry ;
  rdfs:label "default entry ref" ;
  rdfs:comment "References the JourneyEntry used, when declared, if traversal starts without a more specific entry selection." .

ujggraph:entryRefs a owl:ObjectProperty ;
  rdfs:range ujggraph:JourneyEntry ;
  rdfs:label "entry refs" ;
  rdfs:comment "References explicit JourneyEntry contracts. On Journey, entryRefs declares entries owned by that journey. On JourneyEntryIndex, entryRefs lists addressable entries without traversal semantics." .

ujggraph:stateRef a owl:ObjectProperty ;
  rdfs:domain ujggraph:JourneyEntry ;
  rdfs:range [
    a owl:Class ;
    owl:unionOf (
      ujggraph:State
      ujggraph:CompositeState
    )
  ] ;
  rdfs:label "state ref" ;
  rdfs:comment "References the local State or CompositeState where a JourneyEntry begins traversal." .

ujggraph:stateRefs a owl:ObjectProperty ;
  rdfs:range [
    a owl:Class ;
    owl:unionOf (
      ujggraph:State
      ujggraph:CompositeState
    )
  ] ;
  rdfs:comment "References State and CompositeState vertices. On Journey, stateRefs lists experiential local vertices." .

ujggraph:transitionRefs a owl:ObjectProperty ;
  rdfs:domain ujggraph:Journey ;
  rdfs:range [
    a owl:Class ;
    owl:unionOf (
      ujggraph:Transition
      ujggraph:AdjacentTransition
    )
  ] ;
  rdfs:comment "References the local Transition and AdjacentTransition nodes of a Journey. Member transitions are listed by StateCollection memberTransitionRefs instead." .

ujggraph:exitRefs a owl:ObjectProperty ;
  rdfs:domain ujggraph:Journey ;
  rdfs:range ujggraph:JourneyExit ;
  rdfs:label "exit refs" ;
  rdfs:comment "References the terminal exported local vertices declared by a journey." .

ujggraph:from a owl:ObjectProperty ;
  rdfs:domain [
    a owl:Class ;
    owl:unionOf (
      ujggraph:Transition
      ujggraph:AdjacentTransition
    )
  ] ;
  rdfs:range [
    a owl:Class ;
    owl:unionOf (
      ujggraph:State
      ujggraph:CompositeState
    )
  ] ;
  rdfs:comment "References the source local vertex of a Transition, or the vertex before the shared border of an AdjacentTransition. On a member transition of a StateCollection, it is the member State." .

ujggraph:to a owl:ObjectProperty ;
  rdfs:domain [
    a owl:Class ;
    owl:unionOf (
      ujggraph:Transition
      ujggraph:AdjacentTransition
    )
  ] ;
  rdfs:range [
    a owl:Class ;
    owl:unionOf (
      ujggraph:State
      ujggraph:CompositeState
      ujggraph:JourneyExit
    )
  ] ;
  rdfs:comment "References the destination local vertex of a Transition, or the vertex after the shared border of an AdjacentTransition. An AdjacentTransition's to value is never a JourneyExit. On a member transition of a StateCollection, it is the member State." .

ujggraph:fromExitRef a owl:ObjectProperty ;
  rdfs:domain ujggraph:Transition ;
  rdfs:range ujggraph:JourneyExit ;
  rdfs:label "from exit ref" ;
  rdfs:comment "Identifies the exported JourneyExit completed by one child journey of the CompositeState used as the transition's from value. This property is not a transition endpoint." .

ujggraph:toEntryRef a owl:ObjectProperty ;
  rdfs:domain [
    a owl:Class ;
    owl:unionOf (
      ujggraph:Transition
      ujggraph:OutgoingTransition
      ujggraph:InvokingTransition
    )
  ] ;
  rdfs:range ujggraph:JourneyEntry ;
  rdfs:label "to entry ref" ;
  rdfs:comment "Selects a JourneyEntry. On a Transition, it refines entry into one child Journey of the CompositeState used as to. On an OutgoingTransition, it identifies the fixed destination Journey entry contract. On an InvokingTransition, it identifies the fixed entry contract of the invoked Journey. An OutgoingTransition or InvokingTransition whose entry is selected when it is taken uses entrySelectorRef instead." .

ujggraph:commandRef a owl:ObjectProperty ;
  rdfs:range ujggraph:Command ;
  rdfs:label "command ref" ;
  rdfs:comment "Associates a Transition, OutgoingTransition, or InvokingTransition with the stable semantic identity of an intentional invocation." .

ujggraph:subjourneyRefs a owl:ObjectProperty ;
  rdfs:domain ujggraph:CompositeState ;
  rdfs:range ujggraph:Journey ;
  rdfs:label "subjourney refs" ;
  rdfs:comment "References one or more child Journeys contained by a CompositeState." .

ujggraph:entryTransitionRefs a owl:ObjectProperty ;
  rdfs:domain ujggraph:State ;
  rdfs:range [
    a owl:Class ;
    owl:unionOf (
      ujggraph:OutgoingTransition
      ujggraph:InvokingTransition
    )
  ] ;
  rdfs:label "entry transition refs" ;
  rdfs:comment "References the entry transitions (OutgoingTransition or InvokingTransition nodes) available at a State. Only a State declares it. The listed transitions are available at occurrences of that State only: they are not inherited by States nested in a CompositeState, and a CompositeState does not declare them." .

ujggraph:memberStateRef a owl:ObjectProperty ;
  rdfs:domain ujggraph:StateCollection ;
  rdfs:range [
    a owl:Class ;
    owl:unionOf (
      ujggraph:State
      ujggraph:CompositeState
    )
  ] ;
  rdfs:label "member state ref" ;
  rdfs:comment "References the State or CompositeState that every member of a StateCollection is an occurrence of." .

ujggraph:memberTransitionRefs a owl:ObjectProperty ;
  rdfs:domain ujggraph:StateCollection ;
  rdfs:range [
    a owl:Class ;
    owl:unionOf (
      ujggraph:Transition
      ujggraph:AdjacentTransition
    )
  ] ;
  rdfs:label "member transition refs" ;
  rdfs:comment "References the Transition and AdjacentTransition nodes that move from one member of a StateCollection to another member. Their from and to values are the member State. A member transition leaves the member it starts from and enters another member; neither member is named in the Graph. They are not listed in any Journey's transitionRefs." .

ujggraph:entrySelectorRef a owl:ObjectProperty ;
  rdfs:domain [
    a owl:Class ;
    owl:unionOf (
      ujggraph:OutgoingTransition
      ujggraph:InvokingTransition
    )
  ] ;
  rdfs:range ujggraph:EntrySelector ;
  rdfs:label "entry selector ref" ;
  rdfs:comment "References the EntrySelector of an OutgoingTransition or InvokingTransition whose destination entry is selected each time the transition is taken. It is the alternative to toEntryRef." .

ujggraph:candidateJourneyRefs a owl:ObjectProperty ;
  rdfs:domain ujggraph:EntrySelector ;
  rdfs:range ujggraph:Journey ;
  rdfs:label "candidate journey refs" ;
  rdfs:comment "References the Journeys that an entry selected through an EntrySelector can belong to. Without it, the selected entry can belong to any Journey." .
@prefix ujg: <https://ujg.specs.openuji.org/ed/ns/core#> .
@prefix ujggraph: <https://ujg.specs.openuji.org/ed/ns/graph#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dct: <http://purl.org/dc/terms/> .


<https://ujg.specs.openuji.org/ed/ns/graph#> a owl:Ontology ;
  rdfs:label "UJG Graph Editor's Draft Vocabulary"@en ;
  dct:description "UJG Graph ontology declaration" .

### Classes

ujggraph:Journey a owl:Class ;
  rdfs:subClassOf ujg:Node .

ujggraph:JourneyEntry a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  rdfs:label "Journey Entry" ;
  rdfs:comment "An explicit entry contract for a Journey. A JourneyEntry points to the local State or CompositeState where traversal begins." .

ujggraph:JourneyEntryIndex a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  rdfs:label "Journey Index" ;
  rdfs:comment "A catalogue of addressable JourneyEntry contracts. A JourneyEntryIndex does not define traversal, ordering, reachability, or parent-owned progression." .

ujggraph:State a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  rdfs:label "State" ;
  rdfs:comment "A discrete node in the experience. A State is the only local vertex that declares entryTransitionRefs." .

ujggraph:CompositeState a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  owl:disjointWith ujggraph:State ;
  rdfs:label "Composite State" ;
  rdfs:comment "A local vertex that contains one or more child Journeys through subjourneyRefs. A CompositeState is a sibling of State, not a subclass of it, and it does not declare entryTransitionRefs." .

ujggraph:Transition a owl:Class ;
  rdfs:subClassOf ujg:Node .

ujggraph:AdjacentTransition a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  owl:disjointWith ujggraph:Transition, ujggraph:OutgoingTransition, ujggraph:InvokingTransition ;
  rdfs:label "Adjacent Transition" ;
  rdfs:comment "A structural edge between two local vertices of a Journey, or between two neighboring members of a StateCollection, that sit next to each other in the same experience frame and share a border. It describes movement across that border in both directions. It is not a Transition." .

ujggraph:Command a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  rdfs:label "Command" ;
  rdfs:comment "A stable semantic identity of an intentional invocation in the modeled experience." .

ujggraph:JourneyExit a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  owl:disjointWith ujggraph:State, ujggraph:CompositeState ;
  rdfs:label "Journey Exit" ;
  rdfs:comment "A terminal local graph vertex and exported completion contract of a journey." .

ujggraph:OutgoingTransition a owl:Class ;
  rdfs:subClassOf ujg:Node .

ujggraph:InvokingTransition a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  owl:disjointWith ujggraph:OutgoingTransition ;
  rdfs:label "Invoking Transition" ;
  rdfs:comment "An affordance that invokes a Journey through a JourneyEntry and resumes the source State occurrence when that Journey reaches one of its exits." .

ujggraph:StateCollection a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  owl:disjointWith ujggraph:Journey, ujggraph:JourneyEntry, ujggraph:JourneyEntryIndex, ujggraph:State, ujggraph:CompositeState, ujggraph:Transition, ujggraph:AdjacentTransition, ujggraph:OutgoingTransition, ujggraph:InvokingTransition, ujggraph:Command, ujggraph:JourneyExit ;
  rdfs:label "State Collection" ;
  rdfs:comment "Lets one State or CompositeState, its member State, stand for several similar parts of an experience, its members. It lists the member transitions that move the user from one member to another. It is not a local vertex and names no member." .

ujggraph:EntrySelector a owl:Class ;
  rdfs:subClassOf ujg:Node ;
  owl:disjointWith ujggraph:Journey, ujggraph:JourneyEntry, ujggraph:JourneyEntryIndex, ujggraph:State, ujggraph:CompositeState, ujggraph:Transition, ujggraph:AdjacentTransition, ujggraph:OutgoingTransition, ujggraph:InvokingTransition, ujggraph:Command, ujggraph:JourneyExit, ujggraph:StateCollection ;
  rdfs:label "Entry Selector" ;
  rdfs:comment "States that the JourneyEntry an OutgoingTransition or InvokingTransition enters is selected each time the transition is taken, not named in the Graph. It can list the candidate Journeys the selected entry belongs to. It names no entry." .

### Properties

ujggraph:label a owl:DatatypeProperty ;
  rdfs:domain ujg:Node ;
  rdfs:range xsd:string .

ujggraph:tags a owl:DatatypeProperty ;
  rdfs:domain ujg:Node ;
  rdfs:range xsd:string .

ujggraph:defaultEntryRef a owl:ObjectProperty ;
  rdfs:domain ujggraph:Journey ;
  rdfs:range ujggraph:JourneyEntry ;
  rdfs:label "default entry ref" ;
  rdfs:comment "References the JourneyEntry used, when declared, if traversal starts without a more specific entry selection." .

ujggraph:entryRefs a owl:ObjectProperty ;
  rdfs:range ujggraph:JourneyEntry ;
  rdfs:label "entry refs" ;
  rdfs:comment "References explicit JourneyEntry contracts. On Journey, entryRefs declares entries owned by that journey. On JourneyEntryIndex, entryRefs lists addressable entries without traversal semantics." .

ujggraph:stateRef a owl:ObjectProperty ;
  rdfs:domain ujggraph:JourneyEntry ;
  rdfs:range [
    a owl:Class ;
    owl:unionOf (
      ujggraph:State
      ujggraph:CompositeState
    )
  ] ;
  rdfs:label "state ref" ;
  rdfs:comment "References the local State or CompositeState where a JourneyEntry begins traversal." .

ujggraph:stateRefs a owl:ObjectProperty ;
  rdfs:range [
    a owl:Class ;
    owl:unionOf (
      ujggraph:State
      ujggraph:CompositeState
    )
  ] ;
  rdfs:comment "References State and CompositeState vertices. On Journey, stateRefs lists experiential local vertices." .

ujggraph:transitionRefs a owl:ObjectProperty ;
  rdfs:domain ujggraph:Journey ;
  rdfs:range [
    a owl:Class ;
    owl:unionOf (
      ujggraph:Transition
      ujggraph:AdjacentTransition
    )
  ] ;
  rdfs:comment "References the local Transition and AdjacentTransition nodes of a Journey. Member transitions are listed by StateCollection memberTransitionRefs instead." .

ujggraph:exitRefs a owl:ObjectProperty ;
  rdfs:domain ujggraph:Journey ;
  rdfs:range ujggraph:JourneyExit ;
  rdfs:label "exit refs" ;
  rdfs:comment "References the terminal exported local vertices declared by a journey." .

ujggraph:from a owl:ObjectProperty ;
  rdfs:domain [
    a owl:Class ;
    owl:unionOf (
      ujggraph:Transition
      ujggraph:AdjacentTransition
    )
  ] ;
  rdfs:range [
    a owl:Class ;
    owl:unionOf (
      ujggraph:State
      ujggraph:CompositeState
    )
  ] ;
  rdfs:comment "References the source local vertex of a Transition, or the vertex before the shared border of an AdjacentTransition. On a member transition of a StateCollection, it is the member State." .

ujggraph:to a owl:ObjectProperty ;
  rdfs:domain [
    a owl:Class ;
    owl:unionOf (
      ujggraph:Transition
      ujggraph:AdjacentTransition
    )
  ] ;
  rdfs:range [
    a owl:Class ;
    owl:unionOf (
      ujggraph:State
      ujggraph:CompositeState
      ujggraph:JourneyExit
    )
  ] ;
  rdfs:comment "References the destination local vertex of a Transition, or the vertex after the shared border of an AdjacentTransition. An AdjacentTransition's to value is never a JourneyExit. On a member transition of a StateCollection, it is the member State." .

ujggraph:fromExitRef a owl:ObjectProperty ;
  rdfs:domain ujggraph:Transition ;
  rdfs:range ujggraph:JourneyExit ;
  rdfs:label "from exit ref" ;
  rdfs:comment "Identifies the exported JourneyExit completed by one child journey of the CompositeState used as the transition's from value. This property is not a transition endpoint." .

ujggraph:toEntryRef a owl:ObjectProperty ;
  rdfs:domain [
    a owl:Class ;
    owl:unionOf (
      ujggraph:Transition
      ujggraph:OutgoingTransition
      ujggraph:InvokingTransition
    )
  ] ;
  rdfs:range ujggraph:JourneyEntry ;
  rdfs:label "to entry ref" ;
  rdfs:comment "Selects a JourneyEntry. On a Transition, it refines entry into one child Journey of the CompositeState used as to. On an OutgoingTransition, it identifies the fixed destination Journey entry contract. On an InvokingTransition, it identifies the fixed entry contract of the invoked Journey. An OutgoingTransition or InvokingTransition whose entry is selected when it is taken uses entrySelectorRef instead." .

ujggraph:commandRef a owl:ObjectProperty ;
  rdfs:range ujggraph:Command ;
  rdfs:label "command ref" ;
  rdfs:comment "Associates a Transition, OutgoingTransition, or InvokingTransition with the stable semantic identity of an intentional invocation." .

ujggraph:subjourneyRefs a owl:ObjectProperty ;
  rdfs:domain ujggraph:CompositeState ;
  rdfs:range ujggraph:Journey ;
  rdfs:label "subjourney refs" ;
  rdfs:comment "References one or more child Journeys contained by a CompositeState." .

ujggraph:entryTransitionRefs a owl:ObjectProperty ;
  rdfs:domain ujggraph:State ;
  rdfs:range [
    a owl:Class ;
    owl:unionOf (
      ujggraph:OutgoingTransition
      ujggraph:InvokingTransition
    )
  ] ;
  rdfs:label "entry transition refs" ;
  rdfs:comment "References the entry transitions (OutgoingTransition or InvokingTransition nodes) available at a State. Only a State declares it. The listed transitions are available at occurrences of that State only: they are not inherited by States nested in a CompositeState, and a CompositeState does not declare them." .

ujggraph:memberStateRef a owl:ObjectProperty ;
  rdfs:domain ujggraph:StateCollection ;
  rdfs:range [
    a owl:Class ;
    owl:unionOf (
      ujggraph:State
      ujggraph:CompositeState
    )
  ] ;
  rdfs:label "member state ref" ;
  rdfs:comment "References the State or CompositeState that every member of a StateCollection is an occurrence of." .

ujggraph:memberTransitionRefs a owl:ObjectProperty ;
  rdfs:domain ujggraph:StateCollection ;
  rdfs:range [
    a owl:Class ;
    owl:unionOf (
      ujggraph:Transition
      ujggraph:AdjacentTransition
    )
  ] ;
  rdfs:label "member transition refs" ;
  rdfs:comment "References the Transition and AdjacentTransition nodes that move from one member of a StateCollection to another member. Their from and to values are the member State. A member transition leaves the member it starts from and enters another member; neither member is named in the Graph. They are not listed in any Journey's transitionRefs." .

ujggraph:entrySelectorRef a owl:ObjectProperty ;
  rdfs:domain [
    a owl:Class ;
    owl:unionOf (
      ujggraph:OutgoingTransition
      ujggraph:InvokingTransition
    )
  ] ;
  rdfs:range ujggraph:EntrySelector ;
  rdfs:label "entry selector ref" ;
  rdfs:comment "References the EntrySelector of an OutgoingTransition or InvokingTransition whose destination entry is selected each time the transition is taken. It is the alternative to toEntryRef." .

ujggraph:candidateJourneyRefs a owl:ObjectProperty ;
  rdfs:domain ujggraph:EntrySelector ;
  rdfs:range ujggraph:Journey ;
  rdfs:label "candidate journey refs" ;
  rdfs:comment "References the Journeys that an entry selected through an EntrySelector can belong to. Without it, the selected entry can belong to any Journey." .

9.2. JSON-LD Context

The normative Graph JSON-LD context is defined below and is published at https://ujg.specs.openuji.org/ed/ns/graph.context.jsonld. It provides the compact JSON-LD term mappings for the Graph vocabulary used by the examples on this page.

json-ld
{
  "@context": {
    "@version": 1.1,

    "ujggraph": "https://ujg.specs.openuji.org/ed/ns/graph#",
    "xsd": "http://www.w3.org/2001/XMLSchema#",

    "Journey": "ujggraph:Journey",
    "JourneyEntry": "ujggraph:JourneyEntry",
    "JourneyEntryIndex": "ujggraph:JourneyEntryIndex",
    "State": "ujggraph:State",
    "CompositeState": "ujggraph:CompositeState",
    "Transition": "ujggraph:Transition",
    "AdjacentTransition": "ujggraph:AdjacentTransition",
    "Command": "ujggraph:Command",
    "JourneyExit": "ujggraph:JourneyExit",
    "OutgoingTransition": "ujggraph:OutgoingTransition",
    "InvokingTransition": "ujggraph:InvokingTransition",
    "StateCollection": "ujggraph:StateCollection",
    "EntrySelector": "ujggraph:EntrySelector",

    "label": "ujggraph:label",
    "tags": {
      "@id": "ujggraph:tags",
      "@container": "@set"
    },
    "defaultEntryRef": {
      "@id": "ujggraph:defaultEntryRef",
      "@type": "@id"
    },
    "entryRefs": {
      "@id": "ujggraph:entryRefs",
      "@type": "@id",
      "@container": "@set"
    },
    "stateRef": {
      "@id": "ujggraph:stateRef",
      "@type": "@id"
    },
    "stateRefs": {
      "@id": "ujggraph:stateRefs",
      "@type": "@id",
      "@container": "@set"
    },
    "transitionRefs": {
      "@id": "ujggraph:transitionRefs",
      "@type": "@id",
      "@container": "@set"
    },
    "exitRefs": {
      "@id": "ujggraph:exitRefs",
      "@type": "@id",
      "@container": "@set"
    },
    "from": {
      "@id": "ujggraph:from",
      "@type": "@id"
    },
    "to": {
      "@id": "ujggraph:to",
      "@type": "@id"
    },
    "fromExitRef": {
      "@id": "ujggraph:fromExitRef",
      "@type": "@id"
    },
    "toEntryRef": {
      "@id": "ujggraph:toEntryRef",
      "@type": "@id"
    },
    "commandRef": {
      "@id": "ujggraph:commandRef",
      "@type": "@id"
    },
    "subjourneyRefs": {
      "@id": "ujggraph:subjourneyRefs",
      "@type": "@id",
      "@container": "@set"
    },
    "entryTransitionRefs": {
      "@id": "ujggraph:entryTransitionRefs",
      "@type": "@id",
      "@container": "@set"
    },
    "memberStateRef": {
      "@id": "ujggraph:memberStateRef",
      "@type": "@id"
    },
    "memberTransitionRefs": {
      "@id": "ujggraph:memberTransitionRefs",
      "@type": "@id",
      "@container": "@set"
    },
    "entrySelectorRef": {
      "@id": "ujggraph:entrySelectorRef",
      "@type": "@id"
    },
    "candidateJourneyRefs": {
      "@id": "ujggraph:candidateJourneyRefs",
      "@type": "@id",
      "@container": "@set"
    }
  }
}
{
  "@context": {
    "@version": 1.1,

    "ujggraph": "https://ujg.specs.openuji.org/ed/ns/graph#",
    "xsd": "http://www.w3.org/2001/XMLSchema#",

    "Journey": "ujggraph:Journey",
    "JourneyEntry": "ujggraph:JourneyEntry",
    "JourneyEntryIndex": "ujggraph:JourneyEntryIndex",
    "State": "ujggraph:State",
    "CompositeState": "ujggraph:CompositeState",
    "Transition": "ujggraph:Transition",
    "AdjacentTransition": "ujggraph:AdjacentTransition",
    "Command": "ujggraph:Command",
    "JourneyExit": "ujggraph:JourneyExit",
    "OutgoingTransition": "ujggraph:OutgoingTransition",
    "InvokingTransition": "ujggraph:InvokingTransition",
    "StateCollection": "ujggraph:StateCollection",
    "EntrySelector": "ujggraph:EntrySelector",

    "label": "ujggraph:label",
    "tags": {
      "@id": "ujggraph:tags",
      "@container": "@set"
    },
    "defaultEntryRef": {
      "@id": "ujggraph:defaultEntryRef",
      "@type": "@id"
    },
    "entryRefs": {
      "@id": "ujggraph:entryRefs",
      "@type": "@id",
      "@container": "@set"
    },
    "stateRef": {
      "@id": "ujggraph:stateRef",
      "@type": "@id"
    },
    "stateRefs": {
      "@id": "ujggraph:stateRefs",
      "@type": "@id",
      "@container": "@set"
    },
    "transitionRefs": {
      "@id": "ujggraph:transitionRefs",
      "@type": "@id",
      "@container": "@set"
    },
    "exitRefs": {
      "@id": "ujggraph:exitRefs",
      "@type": "@id",
      "@container": "@set"
    },
    "from": {
      "@id": "ujggraph:from",
      "@type": "@id"
    },
    "to": {
      "@id": "ujggraph:to",
      "@type": "@id"
    },
    "fromExitRef": {
      "@id": "ujggraph:fromExitRef",
      "@type": "@id"
    },
    "toEntryRef": {
      "@id": "ujggraph:toEntryRef",
      "@type": "@id"
    },
    "commandRef": {
      "@id": "ujggraph:commandRef",
      "@type": "@id"
    },
    "subjourneyRefs": {
      "@id": "ujggraph:subjourneyRefs",
      "@type": "@id",
      "@container": "@set"
    },
    "entryTransitionRefs": {
      "@id": "ujggraph:entryTransitionRefs",
      "@type": "@id",
      "@container": "@set"
    },
    "memberStateRef": {
      "@id": "ujggraph:memberStateRef",
      "@type": "@id"
    },
    "memberTransitionRefs": {
      "@id": "ujggraph:memberTransitionRefs",
      "@type": "@id",
      "@container": "@set"
    },
    "entrySelectorRef": {
      "@id": "ujggraph:entrySelectorRef",
      "@type": "@id"
    },
    "candidateJourneyRefs": {
      "@id": "ujggraph:candidateJourneyRefs",
      "@type": "@id",
      "@container": "@set"
    }
  }
}

9.3. Validation

The normative Graph SHACL shape is defined below and is published at https://ujg.specs.openuji.org/ed/ns/graph.shape. It is the authoritative validation artifact for Graph structural constraints.

turtle
@prefix ujggraph: <https://ujg.specs.openuji.org/ed/ns/graph#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ujggraphshape: <https://ujg.specs.openuji.org/ed/ns/graph.shape#> .


ujggraphshape:StateLikeShape a sh:NodeShape ;
  sh:nodeKind sh:IRI ;
  sh:or (
    [ sh:class ujggraph:State ]
    [ sh:class ujggraph:CompositeState ]
  ) .

ujggraphshape:LocalVertexLikeShape a sh:NodeShape ;
  sh:nodeKind sh:IRI ;
  sh:or (
    [ sh:class ujggraph:State ]
    [ sh:class ujggraph:CompositeState ]
    [ sh:class ujggraph:JourneyExit ]
  ) .

ujggraphshape:EntryTransitionLikeShape a sh:NodeShape ;
  sh:nodeKind sh:IRI ;
  sh:or (
    [ sh:class ujggraph:OutgoingTransition ]
    [ sh:class ujggraph:InvokingTransition ]
  ) .

ujggraphshape:CommandShape a sh:NodeShape ;
  sh:targetClass ujggraph:Command ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:tags ;
    sh:datatype xsd:string ;
  ] ;

  sh:property [
    sh:path ujggraph:from ;
    sh:maxCount 0 ;
    sh:message "A Command must not declare from; use commandRef from a Transition, OutgoingTransition, or InvokingTransition." ;
  ] ;

  sh:property [
    sh:path ujggraph:to ;
    sh:maxCount 0 ;
    sh:message "A Command must not declare to; use commandRef from a Transition, OutgoingTransition, or InvokingTransition." ;
  ] ;

  sh:property [
    sh:path ujggraph:toEntryRef ;
    sh:maxCount 0 ;
    sh:message "A Command must not declare toEntryRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:fromExitRef ;
    sh:maxCount 0 ;
    sh:message "A Command must not declare fromExitRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "A Command must not declare subjourneyRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "A Command must not declare entryTransitionRefs." ;
  ] .

ujggraphshape:JourneyShape a sh:NodeShape ;
  sh:targetClass ujggraph:Journey ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:defaultEntryRef ;
    sh:maxCount 1 ;
    sh:class ujggraph:JourneyEntry ;
    sh:nodeKind sh:IRI ;
  ] ;

  sh:property [
    sh:path ujggraph:entryRefs ;
    sh:minCount 1 ;
    sh:class ujggraph:JourneyEntry ;
    sh:nodeKind sh:IRI ;
  ] ;

  sh:property [
    sh:path ujggraph:stateRefs ;
    sh:minCount 1 ;
    sh:node ujggraphshape:StateLikeShape ;
  ] ;

  sh:property [
    sh:path ujggraph:transitionRefs ;
    sh:nodeKind sh:IRI ;
    sh:or (
      [ sh:class ujggraph:Transition ]
      [ sh:class ujggraph:AdjacentTransition ]
    ) ;
    sh:message "Each transitionRefs value must reference a Transition or an AdjacentTransition." ;
  ] ;

  sh:property [
    sh:path ujggraph:exitRefs ;
    sh:class ujggraph:JourneyExit ;
    sh:nodeKind sh:IRI ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "A Journey must not declare entryTransitionRefs. List entry transitions on the States that offer them." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "A Journey must not declare subjourneyRefs; only CompositeState declares child Journey references." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A journey's defaultEntryRef must be listed in the same journey's entryRefs." ;
    sh:select """
      SELECT $this ?entry
      WHERE {
        $this ujggraph:defaultEntryRef ?entry .

        FILTER (NOT EXISTS {
          $this ujggraph:entryRefs ?entry .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyEntry listed in entryRefs must have a stateRef listed in the same journey's stateRefs." ;
    sh:select """
      SELECT $this ?entry ?state
      WHERE {
        $this ujggraph:entryRefs ?entry .
        ?entry ujggraph:stateRef ?state .

        FILTER (NOT EXISTS {
          $this ujggraph:stateRefs ?state .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyEntry must be listed in the entryRefs of exactly one journey." ;
    sh:select """
      SELECT $this ?entry
      WHERE {
        $this ujggraph:entryRefs ?entry .

        FILTER (
          EXISTS {
            ?otherJourney a ujggraph:Journey ;
                          ujggraph:entryRefs ?entry .
            FILTER ($this != ?otherJourney)
          }
          || NOT EXISTS {
            ?declaringJourney a ujggraph:Journey ;
                              ujggraph:entryRefs ?entry .
          }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A transition in transitionRefs has a from value that is not listed in this journey's stateRefs." ;
    sh:select """
      SELECT $this ?transition ?from
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:from ?from .

        FILTER (NOT EXISTS {
          $this ujggraph:stateRefs ?from .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A transition in transitionRefs has a from value that references a JourneyExit." ;
    sh:select """
      SELECT $this ?transition ?from
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:from ?from .
        ?from a ujggraph:JourneyExit .
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A transition in transitionRefs has a to value that is not listed in this journey's stateRefs or exitRefs." ;
    sh:select """
      SELECT $this ?transition ?to
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:to ?to .

        FILTER (
          NOT EXISTS { $this ujggraph:stateRefs ?to . }
          && NOT EXISTS { $this ujggraph:exitRefs ?to . }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyExit must be listed in the exitRefs of exactly one journey." ;
    sh:select """
      SELECT $this ?exit
      WHERE {
        $this ujggraph:exitRefs ?exit .

        FILTER (
          EXISTS {
            ?otherJourney ujggraph:exitRefs ?exit .
            FILTER ($this != ?otherJourney)
          }
          || NOT EXISTS {
            ?declaringJourney ujggraph:exitRefs ?exit .
          }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyExit used as Transition.to must be listed in the same enclosing journey's exitRefs." ;
    sh:select """
      SELECT $this ?transition ?exit
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:to ?exit .
        ?exit a ujggraph:JourneyExit .

        FILTER (NOT EXISTS {
          $this ujggraph:exitRefs ?exit .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A transition with fromExitRef must have a from value listed in the enclosing journey's stateRefs." ;
    sh:select """
      SELECT $this ?transition ?from
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:fromExitRef ?exit ;
                    ujggraph:from ?from .

        FILTER (NOT EXISTS {
          $this ujggraph:stateRefs ?from .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A transition with toEntryRef must have a to value listed in the enclosing journey's stateRefs." ;
    sh:select """
      SELECT $this ?transition ?to
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:toEntryRef ?entry ;
                    ujggraph:to ?to .

        FILTER (NOT EXISTS {
          $this ujggraph:stateRefs ?to .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A transition with toEntryRef must have a to value that references a CompositeState." ;
    sh:select """
      SELECT $this ?transition ?to
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:toEntryRef ?entry ;
                    ujggraph:to ?to .

        FILTER (NOT EXISTS {
          ?to a ujggraph:CompositeState .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "The toEntryRef of a parent transition must be listed in the entryRefs of exactly one Journey referenced by the target CompositeState's subjourneyRefs." ;
    sh:select """
      SELECT $this ?transition ?to ?entry
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:toEntryRef ?entry ;
                    ujggraph:to ?to .

        FILTER (NOT EXISTS {
          ?to ujggraph:subjourneyRefs ?childJourney .
          ?childJourney ujggraph:entryRefs ?entry .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "The toEntryRef of a parent transition must not be listed in more than one Journey referenced by the target CompositeState's subjourneyRefs." ;
    sh:select """
      SELECT $this ?transition ?to ?entry
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:toEntryRef ?entry ;
                    ujggraph:to ?to .
        ?to ujggraph:subjourneyRefs ?childJourneyA, ?childJourneyB .
        ?childJourneyA ujggraph:entryRefs ?entry .
        ?childJourneyB ujggraph:entryRefs ?entry .

        FILTER (?childJourneyA != ?childJourneyB)
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A transition with fromExitRef must have a from value that references a CompositeState." ;
    sh:select """
      SELECT $this ?transition ?from
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:fromExitRef ?exit ;
                    ujggraph:from ?from .

        FILTER (NOT EXISTS {
          ?from a ujggraph:CompositeState .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "The fromExitRef of a parent transition must be listed in the exitRefs of exactly one Journey referenced by the source CompositeState's subjourneyRefs." ;
    sh:select """
      SELECT $this ?transition ?from ?exit
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:fromExitRef ?exit ;
                    ujggraph:from ?from .

        FILTER (NOT EXISTS {
          ?from ujggraph:subjourneyRefs ?childJourney .
          ?childJourney ujggraph:exitRefs ?exit .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "The fromExitRef of a parent transition must not be listed in more than one Journey referenced by the source CompositeState's subjourneyRefs." ;
    sh:select """
      SELECT $this ?transition ?from ?exit
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:fromExitRef ?exit ;
                    ujggraph:from ?from .
        ?from ujggraph:subjourneyRefs ?childJourneyA, ?childJourneyB .
        ?childJourneyA ujggraph:exitRefs ?exit .
        ?childJourneyB ujggraph:exitRefs ?exit .

        FILTER (?childJourneyA != ?childJourneyB)
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A transition with fromExitRef must have a to value listed in the enclosing journey's stateRefs or exitRefs." ;
    sh:select """
      SELECT $this ?transition ?to
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:fromExitRef ?exit ;
                    ujggraph:to ?to .

        FILTER (
          NOT EXISTS { $this ujggraph:stateRefs ?to . }
          && NOT EXISTS { $this ujggraph:exitRefs ?to . }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A journey must not contain more than one transition with the same from value and the same fromExitRef value." ;
    sh:select """
      SELECT $this ?from ?exit ?transition ?otherTransition
      WHERE {
        $this ujggraph:transitionRefs ?transition, ?otherTransition .
        ?transition ujggraph:from ?from ;
                    ujggraph:fromExitRef ?exit .
        ?otherTransition ujggraph:from ?from ;
                         ujggraph:fromExitRef ?exit .
        FILTER (?transition != ?otherTransition)
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:severity sh:Warning ;
    sh:message "A state in Journey.stateRefs is not an entry state or a local transition endpoint. Verify that it belongs to the journey's experiential local topology and is not only a linked destination." ;
    sh:select """
      SELECT $this ?state
      WHERE {
        $this ujggraph:stateRefs ?state .

        FILTER (NOT EXISTS {
          $this ujggraph:entryRefs ?entry .
          ?entry ujggraph:stateRef ?state .
        })

        FILTER (NOT EXISTS {
          $this ujggraph:transitionRefs ?transition .
          ?transition ujggraph:from ?state .
        })

        FILTER (NOT EXISTS {
          $this ujggraph:transitionRefs ?transition .
          ?transition ujggraph:to ?state .
        })
      }
    """ ;
  ] .

ujggraphshape:JourneyEntryShape a sh:NodeShape ;
  sh:targetClass ujggraph:JourneyEntry ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:stateRef ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:node ujggraphshape:StateLikeShape ;
  ] ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:tags ;
    sh:datatype xsd:string ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntry must not declare subjourneyRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntry must not declare entryTransitionRefs." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyEntry must be listed in the entryRefs of exactly one journey." ;
    sh:select """
      SELECT $this
      WHERE {
        FILTER (
          NOT EXISTS {
            ?journey a ujggraph:Journey ;
                     ujggraph:entryRefs $this .
          }
          || EXISTS {
            ?journeyA a ujggraph:Journey ;
                      ujggraph:entryRefs $this .
            ?journeyB a ujggraph:Journey ;
                      ujggraph:entryRefs $this .
            FILTER (?journeyA != ?journeyB)
          }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyEntry must not be used as the from or to value of a Transition or AdjacentTransition." ;
    sh:select """
      SELECT $this ?transition
      WHERE {
        {
          ?transition ujggraph:from $this .
        }
        UNION
        {
          ?transition ujggraph:to $this .
        }
      }
    """ ;
  ] .

ujggraphshape:JourneyEntryIndexShape a sh:NodeShape ;
  sh:targetClass ujggraph:JourneyEntryIndex ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:entryRefs ;
    sh:minCount 1 ;
    sh:class ujggraph:JourneyEntry ;
    sh:nodeKind sh:IRI ;
  ] ;

  sh:property [
    sh:path ujggraph:transitionRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare transitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:exitRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare exitRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:from ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare from." ;
  ] ;

  sh:property [
    sh:path ujggraph:to ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare to." ;
  ] ;

  sh:property [
    sh:path ujggraph:fromExitRef ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare fromExitRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:toEntryRef ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare toEntryRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:defaultEntryRef ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare defaultEntryRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:stateRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare stateRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:stateRef ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare stateRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare subjourneyRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare entryTransitionRefs." ;
  ] .

ujggraphshape:StateShape a sh:NodeShape ;
  sh:targetClass ujggraph:State ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:tags ;
    sh:datatype xsd:string ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:node ujggraphshape:EntryTransitionLikeShape ;
    sh:nodeKind sh:IRI ;
    sh:message "Each entryTransitionRefs value must reference an OutgoingTransition or an InvokingTransition." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A State must not be listed in the stateRefs of more than one journey." ;
    sh:select """
      SELECT $this
      WHERE {
        ?journeyA ujggraph:stateRefs $this .
        ?journeyB ujggraph:stateRefs $this .
        FILTER (?journeyA != ?journeyB)
      }
    """ ;
  ] .

ujggraphshape:CompositeStateShape a sh:NodeShape ;
  sh:targetClass ujggraph:CompositeState ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:tags ;
    sh:datatype xsd:string ;
  ] ;

  sh:property [
    sh:path ujggraph:stateRefs ;
    sh:maxCount 0 ;
    sh:message "A CompositeState must not use stateRefs; use subjourneyRefs to reference one or more child Journeys." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "A CompositeState must not declare entryTransitionRefs. Entry transitions are listed by the States that offer them." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:class ujggraph:Journey ;
    sh:nodeKind sh:IRI ;
    sh:minCount 1 ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A CompositeState must not also be typed State or JourneyExit." ;
    sh:select """
      SELECT $this
      WHERE {
        { $this a ujggraph:State . }
        UNION
        { $this a ujggraph:JourneyExit . }
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A CompositeState must not be listed in the stateRefs of more than one journey." ;
    sh:select """
      SELECT $this
      WHERE {
        ?journeyA ujggraph:stateRefs $this .
        ?journeyB ujggraph:stateRefs $this .
        FILTER (?journeyA != ?journeyB)
      }
    """ ;
  ] .

ujggraphshape:TransitionShape a sh:NodeShape ;
  sh:targetClass ujggraph:Transition ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:from ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:node ujggraphshape:StateLikeShape ;
  ] ;

  sh:property [
    sh:path ujggraph:to ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:node ujggraphshape:LocalVertexLikeShape ;
  ] ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:fromExitRef ;
    sh:class ujggraph:JourneyExit ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:toEntryRef ;
    sh:class ujggraph:JourneyEntry ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:commandRef ;
    sh:class ujggraph:Command ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "A Transition must not declare entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "A Transition must not declare subjourneyRefs." ;
  ] .

ujggraphshape:AdjacentTransitionShape a sh:NodeShape ;
  sh:targetClass ujggraph:AdjacentTransition ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:from ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:node ujggraphshape:StateLikeShape ;
    sh:message "An AdjacentTransition must declare exactly one from value that references a State or CompositeState." ;
  ] ;

  sh:property [
    sh:path ujggraph:to ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:node ujggraphshape:StateLikeShape ;
    sh:message "An AdjacentTransition must declare exactly one to value that references a State or CompositeState, never a JourneyExit." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "An AdjacentTransition must connect two different vertices; from and to must differ unless a StateCollection lists it in memberTransitionRefs, where both are the member State." ;
    sh:select """
      SELECT $this ?vertex
      WHERE {
        $this ujggraph:from ?vertex ;
              ujggraph:to ?vertex .

        FILTER (NOT EXISTS {
          ?collection a ujggraph:StateCollection ;
                      ujggraph:memberTransitionRefs $this .
        })
      }
    """ ;
  ] ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:commandRef ;
    sh:maxCount 0 ;
    sh:message "An AdjacentTransition must not declare commandRef. Model a command-driven movement as a Transition with commandRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:toEntryRef ;
    sh:maxCount 0 ;
    sh:message "An AdjacentTransition must not declare toEntryRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:fromExitRef ;
    sh:maxCount 0 ;
    sh:message "An AdjacentTransition must not declare fromExitRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "An AdjacentTransition must not declare entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "An AdjacentTransition must not declare subjourneyRefs." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "An AdjacentTransition must not also be typed Transition, OutgoingTransition, or InvokingTransition." ;
    sh:select """
      SELECT $this
      WHERE {
        { $this a ujggraph:Transition . }
        UNION
        { $this a ujggraph:OutgoingTransition . }
        UNION
        { $this a ujggraph:InvokingTransition . }
      }
    """ ;
  ] .

ujggraphshape:AdjacentTransitionDuplicateShape a sh:NodeShape ;
  sh:targetClass ujggraph:AdjacentTransition ;
  sh:severity sh:Warning ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A Transition without commandRef, toEntryRef, or fromExitRef connects the same two vertices as this AdjacentTransition, or moves between the same StateCollection's members. Unless it carries a guard or an effect, it duplicates one direction of the adjacency." ;
    sh:select """
      SELECT $this ?transition
      WHERE {
        $this ujggraph:from ?a ;
              ujggraph:to ?b .
        ?transition a ujggraph:Transition .
        {
          ?transition ujggraph:from ?a ;
                      ujggraph:to ?b .
        }
        UNION
        {
          ?transition ujggraph:from ?b ;
                      ujggraph:to ?a .
        }
        FILTER (?transition != $this)
        FILTER (NOT EXISTS { ?transition ujggraph:commandRef ?command . })
        FILTER (NOT EXISTS { ?transition ujggraph:toEntryRef ?entry . })
        FILTER (NOT EXISTS { ?transition ujggraph:fromExitRef ?exit . })
        FILTER (
          EXISTS {
            ?collection ujggraph:memberTransitionRefs $this, ?transition .
          }
          || (
            NOT EXISTS { ?collectionA ujggraph:memberTransitionRefs $this . }
            && NOT EXISTS { ?collectionB ujggraph:memberTransitionRefs ?transition . }
          )
        )
      }
    """ ;
  ] .

ujggraphshape:JourneyExitShape a sh:NodeShape ;
  sh:targetClass ujggraph:JourneyExit ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:tags ;
    sh:datatype xsd:string ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyExit must not declare entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyExit must not declare subjourneyRefs." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyExit must not also be typed State or CompositeState." ;
    sh:select """
      SELECT $this
      WHERE {
        { $this a ujggraph:State . }
        UNION
        { $this a ujggraph:CompositeState . }
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyExit must be listed in the exitRefs of exactly one journey." ;
    sh:select """
      SELECT $this
      WHERE {
        FILTER (
          NOT EXISTS { ?journey ujggraph:exitRefs $this . }
          || EXISTS {
            ?journeyA ujggraph:exitRefs $this .
            ?journeyB ujggraph:exitRefs $this .
            FILTER (?journeyA != ?journeyB)
          }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyExit must not be used as the from value of a Transition or AdjacentTransition." ;
    sh:select """
      SELECT $this ?transition
      WHERE {
        ?transition ujggraph:from $this .
      }
    """ ;
  ] .

ujggraphshape:OutgoingTransitionShape a sh:NodeShape ;
  sh:targetClass ujggraph:OutgoingTransition ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:to ;
    sh:maxCount 0 ;
    sh:message "An OutgoingTransition must not declare to; target a JourneyEntry with toEntryRef or select one through entrySelectorRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:toEntryRef ;
    sh:class ujggraph:JourneyEntry ;
    sh:node ujggraphshape:JourneyEntryShape ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:entrySelectorRef ;
    sh:class ujggraph:EntrySelector ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "An OutgoingTransition must declare exactly one of toEntryRef or entrySelectorRef." ;
    sh:select """
      SELECT $this
      WHERE {
        FILTER (
          (
            EXISTS { $this ujggraph:toEntryRef ?entry . }
            && EXISTS { $this ujggraph:entrySelectorRef ?selector . }
          )
          || (
            NOT EXISTS { $this ujggraph:toEntryRef ?entry . }
            && NOT EXISTS { $this ujggraph:entrySelectorRef ?selector . }
          )
        )
      }
    """ ;
  ] ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:commandRef ;
    sh:class ujggraph:Command ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:from ;
    sh:maxCount 0 ;
    sh:message "An OutgoingTransition must not declare from. Its sources are the States that list it in entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:fromExitRef ;
    sh:maxCount 0 ;
    sh:message "An OutgoingTransition must not declare fromExitRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "An OutgoingTransition must not declare entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "An OutgoingTransition must not declare subjourneyRefs." ;
  ] .

ujggraphshape:InvokingTransitionShape a sh:NodeShape ;
  sh:targetClass ujggraph:InvokingTransition ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:to ;
    sh:maxCount 0 ;
    sh:message "An InvokingTransition must not declare to; target a JourneyEntry with toEntryRef or select one through entrySelectorRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:toEntryRef ;
    sh:class ujggraph:JourneyEntry ;
    sh:node ujggraphshape:JourneyEntryShape ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:entrySelectorRef ;
    sh:class ujggraph:EntrySelector ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "An InvokingTransition must declare exactly one of toEntryRef or entrySelectorRef." ;
    sh:select """
      SELECT $this
      WHERE {
        FILTER (
          (
            EXISTS { $this ujggraph:toEntryRef ?entry . }
            && EXISTS { $this ujggraph:entrySelectorRef ?selector . }
          )
          || (
            NOT EXISTS { $this ujggraph:toEntryRef ?entry . }
            && NOT EXISTS { $this ujggraph:entrySelectorRef ?selector . }
          )
        )
      }
    """ ;
  ] ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:commandRef ;
    sh:class ujggraph:Command ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:from ;
    sh:maxCount 0 ;
    sh:message "An InvokingTransition must not declare from. Its sources are the States that list it in entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:fromExitRef ;
    sh:maxCount 0 ;
    sh:message "An InvokingTransition must not declare fromExitRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "An InvokingTransition must not declare entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "An InvokingTransition must not declare subjourneyRefs." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "An InvokingTransition must not also be typed OutgoingTransition." ;
    sh:select """
      SELECT $this
      WHERE {
        $this a ujggraph:OutgoingTransition .
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "The Journey that owns an InvokingTransition's toEntryRef must declare at least one exitRefs value." ;
    sh:select """
      SELECT $this ?entry ?journey
      WHERE {
        $this ujggraph:toEntryRef ?entry .
        ?journey a ujggraph:Journey ;
                 ujggraph:entryRefs ?entry .

        FILTER (NOT EXISTS {
          ?journey ujggraph:exitRefs ?exit .
        })
      }
    """ ;
  ];

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "Each candidate Journey of an InvokingTransition's EntrySelector must declare at least one exitRefs value." ;
    sh:select """
      SELECT $this ?selector ?journey
      WHERE {
        $this ujggraph:entrySelectorRef ?selector .
        ?selector ujggraph:candidateJourneyRefs ?journey .

        FILTER (NOT EXISTS {
          ?journey ujggraph:exitRefs ?exit .
        })
      }
    """ ;
  ] .

ujggraphshape:StateCollectionShape a sh:NodeShape ;
  sh:targetClass ujggraph:StateCollection ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:memberStateRef ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:node ujggraphshape:StateLikeShape ;
    sh:message "A StateCollection must declare exactly one memberStateRef that references a State or CompositeState." ;
  ] ;

  sh:property [
    sh:path ujggraph:memberTransitionRefs ;
    sh:minCount 1 ;
    sh:nodeKind sh:IRI ;
    sh:or (
      [ sh:class ujggraph:Transition ]
      [ sh:class ujggraph:AdjacentTransition ]
    ) ;
    sh:message "A StateCollection must declare at least one memberTransitionRefs value, and each must reference a Transition or an AdjacentTransition." ;
  ] ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:tags ;
    sh:datatype xsd:string ;
  ] ;

  sh:property [
    sh:path ujggraph:from ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare from." ;
  ] ;

  sh:property [
    sh:path ujggraph:to ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare to." ;
  ] ;

  sh:property [
    sh:path ujggraph:toEntryRef ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare toEntryRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:fromExitRef ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare fromExitRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:commandRef ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare commandRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare subjourneyRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:transitionRefs ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare transitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:stateRefs ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare stateRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:stateRef ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare stateRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryRefs ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare entryRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:exitRefs ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare exitRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:defaultEntryRef ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare defaultEntryRef." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A StateCollection must not also be typed Journey, JourneyEntry, JourneyEntryIndex, State, CompositeState, Transition, AdjacentTransition, OutgoingTransition, InvokingTransition, Command, or JourneyExit." ;
    sh:select """
      SELECT $this
      WHERE {
        { $this a ujggraph:Journey . }
        UNION
        { $this a ujggraph:JourneyEntry . }
        UNION
        { $this a ujggraph:JourneyEntryIndex . }
        UNION
        { $this a ujggraph:State . }
        UNION
        { $this a ujggraph:CompositeState . }
        UNION
        { $this a ujggraph:Transition . }
        UNION
        { $this a ujggraph:AdjacentTransition . }
        UNION
        { $this a ujggraph:OutgoingTransition . }
        UNION
        { $this a ujggraph:InvokingTransition . }
        UNION
        { $this a ujggraph:Command . }
        UNION
        { $this a ujggraph:JourneyExit . }
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "The member State of a StateCollection must be listed in the stateRefs of a Journey." ;
    sh:select """
      SELECT $this ?state
      WHERE {
        $this ujggraph:memberStateRef ?state .

        FILTER (NOT EXISTS {
          ?journey ujggraph:stateRefs ?state .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A State or CompositeState must not be the member State of more than one StateCollection." ;
    sh:select """
      SELECT $this ?state ?otherCollection
      WHERE {
        $this ujggraph:memberStateRef ?state .
        ?otherCollection a ujggraph:StateCollection ;
                         ujggraph:memberStateRef ?state .
        FILTER (?otherCollection != $this)
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "Each member transition of a StateCollection must have the member State as both its from and its to value." ;
    sh:select """
      SELECT $this ?transition
      WHERE {
        $this ujggraph:memberStateRef ?state ;
              ujggraph:memberTransitionRefs ?transition .

        FILTER (
          NOT EXISTS { ?transition ujggraph:from ?state . }
          || NOT EXISTS { ?transition ujggraph:to ?state . }
          || EXISTS {
            ?transition ujggraph:from ?from .
            FILTER (?from != ?state)
          }
          || EXISTS {
            ?transition ujggraph:to ?to .
            FILTER (?to != ?state)
          }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A member transition must not also be listed in a Journey's transitionRefs." ;
    sh:select """
      SELECT $this ?transition ?journey
      WHERE {
        $this ujggraph:memberTransitionRefs ?transition .
        ?journey ujggraph:transitionRefs ?transition .
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A member transition must not be listed in the memberTransitionRefs of more than one StateCollection." ;
    sh:select """
      SELECT $this ?transition ?otherCollection
      WHERE {
        $this ujggraph:memberTransitionRefs ?transition .
        ?otherCollection a ujggraph:StateCollection ;
                         ujggraph:memberTransitionRefs ?transition .
        FILTER (?otherCollection != $this)
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A member transition with toEntryRef or fromExitRef requires a CompositeState member State." ;
    sh:select """
      SELECT $this ?transition ?state
      WHERE {
        $this ujggraph:memberStateRef ?state ;
              ujggraph:memberTransitionRefs ?transition .
        { ?transition ujggraph:toEntryRef ?boundary . }
        UNION
        { ?transition ujggraph:fromExitRef ?boundary . }

        FILTER (NOT EXISTS {
          ?state a ujggraph:CompositeState .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "The toEntryRef of a member transition must be listed in the entryRefs of exactly one Journey referenced by the member State's subjourneyRefs." ;
    sh:select """
      SELECT $this ?transition ?entry
      WHERE {
        $this ujggraph:memberStateRef ?state ;
              ujggraph:memberTransitionRefs ?transition .
        ?state a ujggraph:CompositeState .
        ?transition ujggraph:toEntryRef ?entry .

        FILTER (
          NOT EXISTS {
            ?state ujggraph:subjourneyRefs ?childJourney .
            ?childJourney ujggraph:entryRefs ?entry .
          }
          || EXISTS {
            ?state ujggraph:subjourneyRefs ?childJourneyA, ?childJourneyB .
            ?childJourneyA ujggraph:entryRefs ?entry .
            ?childJourneyB ujggraph:entryRefs ?entry .
            FILTER (?childJourneyA != ?childJourneyB)
          }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "The fromExitRef of a member transition must be listed in the exitRefs of exactly one Journey referenced by the member State's subjourneyRefs." ;
    sh:select """
      SELECT $this ?transition ?exit
      WHERE {
        $this ujggraph:memberStateRef ?state ;
              ujggraph:memberTransitionRefs ?transition .
        ?state a ujggraph:CompositeState .
        ?transition ujggraph:fromExitRef ?exit .

        FILTER (
          NOT EXISTS {
            ?state ujggraph:subjourneyRefs ?childJourney .
            ?childJourney ujggraph:exitRefs ?exit .
          }
          || EXISTS {
            ?state ujggraph:subjourneyRefs ?childJourneyA, ?childJourneyB .
            ?childJourneyA ujggraph:exitRefs ?exit .
            ?childJourneyB ujggraph:exitRefs ?exit .
            FILTER (?childJourneyA != ?childJourneyB)
          }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A member transition with fromExitRef must not share its member State and fromExitRef value with another member transition or with a transition in a Journey's transitionRefs." ;
    sh:select """
      SELECT $this ?transition ?otherTransition ?exit
      WHERE {
        $this ujggraph:memberStateRef ?state ;
              ujggraph:memberTransitionRefs ?transition .
        ?transition ujggraph:fromExitRef ?exit .
        ?otherTransition ujggraph:from ?state ;
                         ujggraph:fromExitRef ?exit .
        FILTER (?otherTransition != ?transition)
        FILTER (
          EXISTS { $this ujggraph:memberTransitionRefs ?otherTransition . }
          || EXISTS { ?journey ujggraph:transitionRefs ?otherTransition . }
        )
      }
    """ ;
  ] .

ujggraphshape:MemberStateRefSubjectShape a sh:NodeShape ;
  sh:targetSubjectsOf ujggraph:memberStateRef ;
  sh:class ujggraph:StateCollection ;
  sh:message "Only a StateCollection declares memberStateRef." .

ujggraphshape:MemberTransitionRefsSubjectShape a sh:NodeShape ;
  sh:targetSubjectsOf ujggraph:memberTransitionRefs ;
  sh:class ujggraph:StateCollection ;
  sh:message "Only a StateCollection declares memberTransitionRefs." .

ujggraphshape:EntrySelectorShape a sh:NodeShape ;
  sh:targetClass ujggraph:EntrySelector ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:candidateJourneyRefs ;
    sh:class ujggraph:Journey ;
    sh:nodeKind sh:IRI ;
    sh:message "Each candidateJourneyRefs value must reference a Journey." ;
  ] ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:tags ;
    sh:datatype xsd:string ;
  ] ;

  sh:property [
    sh:path ujggraph:from ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare from." ;
  ] ;

  sh:property [
    sh:path ujggraph:to ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare to." ;
  ] ;

  sh:property [
    sh:path ujggraph:toEntryRef ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare toEntryRef; it names no entry." ;
  ] ;

  sh:property [
    sh:path ujggraph:fromExitRef ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare fromExitRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:commandRef ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare commandRef; declare it on the entry transition that references the selector." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare subjourneyRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:transitionRefs ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare transitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:stateRefs ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare stateRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:stateRef ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare stateRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryRefs ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare entryRefs; list candidate Journeys in candidateJourneyRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:exitRefs ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare exitRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:defaultEntryRef ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare defaultEntryRef." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "An EntrySelector must not also be typed Journey, JourneyEntry, JourneyEntryIndex, State, CompositeState, Transition, AdjacentTransition, OutgoingTransition, InvokingTransition, Command, JourneyExit, or StateCollection." ;
    sh:select """
      SELECT $this
      WHERE {
        { $this a ujggraph:Journey . }
        UNION
        { $this a ujggraph:JourneyEntry . }
        UNION
        { $this a ujggraph:JourneyEntryIndex . }
        UNION
        { $this a ujggraph:State . }
        UNION
        { $this a ujggraph:CompositeState . }
        UNION
        { $this a ujggraph:Transition . }
        UNION
        { $this a ujggraph:AdjacentTransition . }
        UNION
        { $this a ujggraph:OutgoingTransition . }
        UNION
        { $this a ujggraph:InvokingTransition . }
        UNION
        { $this a ujggraph:Command . }
        UNION
        { $this a ujggraph:JourneyExit . }
        UNION
        { $this a ujggraph:StateCollection . }
      }
    """ ;
  ] .

ujggraphshape:EntrySelectorRefSubjectShape a sh:NodeShape ;
  sh:targetSubjectsOf ujggraph:entrySelectorRef ;
  sh:or (
    [ sh:class ujggraph:OutgoingTransition ]
    [ sh:class ujggraph:InvokingTransition ]
  ) ;
  sh:message "Only an OutgoingTransition or InvokingTransition declares entrySelectorRef." .

ujggraphshape:CandidateJourneyRefsSubjectShape a sh:NodeShape ;
  sh:targetSubjectsOf ujggraph:candidateJourneyRefs ;
  sh:class ujggraph:EntrySelector ;
  sh:message "Only an EntrySelector declares candidateJourneyRefs." .
@prefix ujggraph: <https://ujg.specs.openuji.org/ed/ns/graph#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ujggraphshape: <https://ujg.specs.openuji.org/ed/ns/graph.shape#> .


ujggraphshape:StateLikeShape a sh:NodeShape ;
  sh:nodeKind sh:IRI ;
  sh:or (
    [ sh:class ujggraph:State ]
    [ sh:class ujggraph:CompositeState ]
  ) .

ujggraphshape:LocalVertexLikeShape a sh:NodeShape ;
  sh:nodeKind sh:IRI ;
  sh:or (
    [ sh:class ujggraph:State ]
    [ sh:class ujggraph:CompositeState ]
    [ sh:class ujggraph:JourneyExit ]
  ) .

ujggraphshape:EntryTransitionLikeShape a sh:NodeShape ;
  sh:nodeKind sh:IRI ;
  sh:or (
    [ sh:class ujggraph:OutgoingTransition ]
    [ sh:class ujggraph:InvokingTransition ]
  ) .

ujggraphshape:CommandShape a sh:NodeShape ;
  sh:targetClass ujggraph:Command ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:tags ;
    sh:datatype xsd:string ;
  ] ;

  sh:property [
    sh:path ujggraph:from ;
    sh:maxCount 0 ;
    sh:message "A Command must not declare from; use commandRef from a Transition, OutgoingTransition, or InvokingTransition." ;
  ] ;

  sh:property [
    sh:path ujggraph:to ;
    sh:maxCount 0 ;
    sh:message "A Command must not declare to; use commandRef from a Transition, OutgoingTransition, or InvokingTransition." ;
  ] ;

  sh:property [
    sh:path ujggraph:toEntryRef ;
    sh:maxCount 0 ;
    sh:message "A Command must not declare toEntryRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:fromExitRef ;
    sh:maxCount 0 ;
    sh:message "A Command must not declare fromExitRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "A Command must not declare subjourneyRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "A Command must not declare entryTransitionRefs." ;
  ] .

ujggraphshape:JourneyShape a sh:NodeShape ;
  sh:targetClass ujggraph:Journey ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:defaultEntryRef ;
    sh:maxCount 1 ;
    sh:class ujggraph:JourneyEntry ;
    sh:nodeKind sh:IRI ;
  ] ;

  sh:property [
    sh:path ujggraph:entryRefs ;
    sh:minCount 1 ;
    sh:class ujggraph:JourneyEntry ;
    sh:nodeKind sh:IRI ;
  ] ;

  sh:property [
    sh:path ujggraph:stateRefs ;
    sh:minCount 1 ;
    sh:node ujggraphshape:StateLikeShape ;
  ] ;

  sh:property [
    sh:path ujggraph:transitionRefs ;
    sh:nodeKind sh:IRI ;
    sh:or (
      [ sh:class ujggraph:Transition ]
      [ sh:class ujggraph:AdjacentTransition ]
    ) ;
    sh:message "Each transitionRefs value must reference a Transition or an AdjacentTransition." ;
  ] ;

  sh:property [
    sh:path ujggraph:exitRefs ;
    sh:class ujggraph:JourneyExit ;
    sh:nodeKind sh:IRI ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "A Journey must not declare entryTransitionRefs. List entry transitions on the States that offer them." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "A Journey must not declare subjourneyRefs; only CompositeState declares child Journey references." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A journey's defaultEntryRef must be listed in the same journey's entryRefs." ;
    sh:select """
      SELECT $this ?entry
      WHERE {
        $this ujggraph:defaultEntryRef ?entry .

        FILTER (NOT EXISTS {
          $this ujggraph:entryRefs ?entry .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyEntry listed in entryRefs must have a stateRef listed in the same journey's stateRefs." ;
    sh:select """
      SELECT $this ?entry ?state
      WHERE {
        $this ujggraph:entryRefs ?entry .
        ?entry ujggraph:stateRef ?state .

        FILTER (NOT EXISTS {
          $this ujggraph:stateRefs ?state .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyEntry must be listed in the entryRefs of exactly one journey." ;
    sh:select """
      SELECT $this ?entry
      WHERE {
        $this ujggraph:entryRefs ?entry .

        FILTER (
          EXISTS {
            ?otherJourney a ujggraph:Journey ;
                          ujggraph:entryRefs ?entry .
            FILTER ($this != ?otherJourney)
          }
          || NOT EXISTS {
            ?declaringJourney a ujggraph:Journey ;
                              ujggraph:entryRefs ?entry .
          }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A transition in transitionRefs has a from value that is not listed in this journey's stateRefs." ;
    sh:select """
      SELECT $this ?transition ?from
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:from ?from .

        FILTER (NOT EXISTS {
          $this ujggraph:stateRefs ?from .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A transition in transitionRefs has a from value that references a JourneyExit." ;
    sh:select """
      SELECT $this ?transition ?from
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:from ?from .
        ?from a ujggraph:JourneyExit .
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A transition in transitionRefs has a to value that is not listed in this journey's stateRefs or exitRefs." ;
    sh:select """
      SELECT $this ?transition ?to
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:to ?to .

        FILTER (
          NOT EXISTS { $this ujggraph:stateRefs ?to . }
          && NOT EXISTS { $this ujggraph:exitRefs ?to . }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyExit must be listed in the exitRefs of exactly one journey." ;
    sh:select """
      SELECT $this ?exit
      WHERE {
        $this ujggraph:exitRefs ?exit .

        FILTER (
          EXISTS {
            ?otherJourney ujggraph:exitRefs ?exit .
            FILTER ($this != ?otherJourney)
          }
          || NOT EXISTS {
            ?declaringJourney ujggraph:exitRefs ?exit .
          }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyExit used as Transition.to must be listed in the same enclosing journey's exitRefs." ;
    sh:select """
      SELECT $this ?transition ?exit
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:to ?exit .
        ?exit a ujggraph:JourneyExit .

        FILTER (NOT EXISTS {
          $this ujggraph:exitRefs ?exit .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A transition with fromExitRef must have a from value listed in the enclosing journey's stateRefs." ;
    sh:select """
      SELECT $this ?transition ?from
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:fromExitRef ?exit ;
                    ujggraph:from ?from .

        FILTER (NOT EXISTS {
          $this ujggraph:stateRefs ?from .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A transition with toEntryRef must have a to value listed in the enclosing journey's stateRefs." ;
    sh:select """
      SELECT $this ?transition ?to
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:toEntryRef ?entry ;
                    ujggraph:to ?to .

        FILTER (NOT EXISTS {
          $this ujggraph:stateRefs ?to .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A transition with toEntryRef must have a to value that references a CompositeState." ;
    sh:select """
      SELECT $this ?transition ?to
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:toEntryRef ?entry ;
                    ujggraph:to ?to .

        FILTER (NOT EXISTS {
          ?to a ujggraph:CompositeState .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "The toEntryRef of a parent transition must be listed in the entryRefs of exactly one Journey referenced by the target CompositeState's subjourneyRefs." ;
    sh:select """
      SELECT $this ?transition ?to ?entry
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:toEntryRef ?entry ;
                    ujggraph:to ?to .

        FILTER (NOT EXISTS {
          ?to ujggraph:subjourneyRefs ?childJourney .
          ?childJourney ujggraph:entryRefs ?entry .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "The toEntryRef of a parent transition must not be listed in more than one Journey referenced by the target CompositeState's subjourneyRefs." ;
    sh:select """
      SELECT $this ?transition ?to ?entry
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:toEntryRef ?entry ;
                    ujggraph:to ?to .
        ?to ujggraph:subjourneyRefs ?childJourneyA, ?childJourneyB .
        ?childJourneyA ujggraph:entryRefs ?entry .
        ?childJourneyB ujggraph:entryRefs ?entry .

        FILTER (?childJourneyA != ?childJourneyB)
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A transition with fromExitRef must have a from value that references a CompositeState." ;
    sh:select """
      SELECT $this ?transition ?from
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:fromExitRef ?exit ;
                    ujggraph:from ?from .

        FILTER (NOT EXISTS {
          ?from a ujggraph:CompositeState .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "The fromExitRef of a parent transition must be listed in the exitRefs of exactly one Journey referenced by the source CompositeState's subjourneyRefs." ;
    sh:select """
      SELECT $this ?transition ?from ?exit
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:fromExitRef ?exit ;
                    ujggraph:from ?from .

        FILTER (NOT EXISTS {
          ?from ujggraph:subjourneyRefs ?childJourney .
          ?childJourney ujggraph:exitRefs ?exit .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "The fromExitRef of a parent transition must not be listed in more than one Journey referenced by the source CompositeState's subjourneyRefs." ;
    sh:select """
      SELECT $this ?transition ?from ?exit
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:fromExitRef ?exit ;
                    ujggraph:from ?from .
        ?from ujggraph:subjourneyRefs ?childJourneyA, ?childJourneyB .
        ?childJourneyA ujggraph:exitRefs ?exit .
        ?childJourneyB ujggraph:exitRefs ?exit .

        FILTER (?childJourneyA != ?childJourneyB)
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A transition with fromExitRef must have a to value listed in the enclosing journey's stateRefs or exitRefs." ;
    sh:select """
      SELECT $this ?transition ?to
      WHERE {
        $this ujggraph:transitionRefs ?transition .
        ?transition ujggraph:fromExitRef ?exit ;
                    ujggraph:to ?to .

        FILTER (
          NOT EXISTS { $this ujggraph:stateRefs ?to . }
          && NOT EXISTS { $this ujggraph:exitRefs ?to . }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A journey must not contain more than one transition with the same from value and the same fromExitRef value." ;
    sh:select """
      SELECT $this ?from ?exit ?transition ?otherTransition
      WHERE {
        $this ujggraph:transitionRefs ?transition, ?otherTransition .
        ?transition ujggraph:from ?from ;
                    ujggraph:fromExitRef ?exit .
        ?otherTransition ujggraph:from ?from ;
                         ujggraph:fromExitRef ?exit .
        FILTER (?transition != ?otherTransition)
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:severity sh:Warning ;
    sh:message "A state in Journey.stateRefs is not an entry state or a local transition endpoint. Verify that it belongs to the journey's experiential local topology and is not only a linked destination." ;
    sh:select """
      SELECT $this ?state
      WHERE {
        $this ujggraph:stateRefs ?state .

        FILTER (NOT EXISTS {
          $this ujggraph:entryRefs ?entry .
          ?entry ujggraph:stateRef ?state .
        })

        FILTER (NOT EXISTS {
          $this ujggraph:transitionRefs ?transition .
          ?transition ujggraph:from ?state .
        })

        FILTER (NOT EXISTS {
          $this ujggraph:transitionRefs ?transition .
          ?transition ujggraph:to ?state .
        })
      }
    """ ;
  ] .

ujggraphshape:JourneyEntryShape a sh:NodeShape ;
  sh:targetClass ujggraph:JourneyEntry ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:stateRef ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:node ujggraphshape:StateLikeShape ;
  ] ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:tags ;
    sh:datatype xsd:string ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntry must not declare subjourneyRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntry must not declare entryTransitionRefs." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyEntry must be listed in the entryRefs of exactly one journey." ;
    sh:select """
      SELECT $this
      WHERE {
        FILTER (
          NOT EXISTS {
            ?journey a ujggraph:Journey ;
                     ujggraph:entryRefs $this .
          }
          || EXISTS {
            ?journeyA a ujggraph:Journey ;
                      ujggraph:entryRefs $this .
            ?journeyB a ujggraph:Journey ;
                      ujggraph:entryRefs $this .
            FILTER (?journeyA != ?journeyB)
          }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyEntry must not be used as the from or to value of a Transition or AdjacentTransition." ;
    sh:select """
      SELECT $this ?transition
      WHERE {
        {
          ?transition ujggraph:from $this .
        }
        UNION
        {
          ?transition ujggraph:to $this .
        }
      }
    """ ;
  ] .

ujggraphshape:JourneyEntryIndexShape a sh:NodeShape ;
  sh:targetClass ujggraph:JourneyEntryIndex ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:entryRefs ;
    sh:minCount 1 ;
    sh:class ujggraph:JourneyEntry ;
    sh:nodeKind sh:IRI ;
  ] ;

  sh:property [
    sh:path ujggraph:transitionRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare transitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:exitRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare exitRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:from ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare from." ;
  ] ;

  sh:property [
    sh:path ujggraph:to ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare to." ;
  ] ;

  sh:property [
    sh:path ujggraph:fromExitRef ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare fromExitRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:toEntryRef ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare toEntryRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:defaultEntryRef ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare defaultEntryRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:stateRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare stateRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:stateRef ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare stateRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare subjourneyRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyEntryIndex must not declare entryTransitionRefs." ;
  ] .

ujggraphshape:StateShape a sh:NodeShape ;
  sh:targetClass ujggraph:State ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:tags ;
    sh:datatype xsd:string ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:node ujggraphshape:EntryTransitionLikeShape ;
    sh:nodeKind sh:IRI ;
    sh:message "Each entryTransitionRefs value must reference an OutgoingTransition or an InvokingTransition." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A State must not be listed in the stateRefs of more than one journey." ;
    sh:select """
      SELECT $this
      WHERE {
        ?journeyA ujggraph:stateRefs $this .
        ?journeyB ujggraph:stateRefs $this .
        FILTER (?journeyA != ?journeyB)
      }
    """ ;
  ] .

ujggraphshape:CompositeStateShape a sh:NodeShape ;
  sh:targetClass ujggraph:CompositeState ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:tags ;
    sh:datatype xsd:string ;
  ] ;

  sh:property [
    sh:path ujggraph:stateRefs ;
    sh:maxCount 0 ;
    sh:message "A CompositeState must not use stateRefs; use subjourneyRefs to reference one or more child Journeys." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "A CompositeState must not declare entryTransitionRefs. Entry transitions are listed by the States that offer them." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:class ujggraph:Journey ;
    sh:nodeKind sh:IRI ;
    sh:minCount 1 ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A CompositeState must not also be typed State or JourneyExit." ;
    sh:select """
      SELECT $this
      WHERE {
        { $this a ujggraph:State . }
        UNION
        { $this a ujggraph:JourneyExit . }
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A CompositeState must not be listed in the stateRefs of more than one journey." ;
    sh:select """
      SELECT $this
      WHERE {
        ?journeyA ujggraph:stateRefs $this .
        ?journeyB ujggraph:stateRefs $this .
        FILTER (?journeyA != ?journeyB)
      }
    """ ;
  ] .

ujggraphshape:TransitionShape a sh:NodeShape ;
  sh:targetClass ujggraph:Transition ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:from ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:node ujggraphshape:StateLikeShape ;
  ] ;

  sh:property [
    sh:path ujggraph:to ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:node ujggraphshape:LocalVertexLikeShape ;
  ] ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:fromExitRef ;
    sh:class ujggraph:JourneyExit ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:toEntryRef ;
    sh:class ujggraph:JourneyEntry ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:commandRef ;
    sh:class ujggraph:Command ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "A Transition must not declare entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "A Transition must not declare subjourneyRefs." ;
  ] .

ujggraphshape:AdjacentTransitionShape a sh:NodeShape ;
  sh:targetClass ujggraph:AdjacentTransition ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:from ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:node ujggraphshape:StateLikeShape ;
    sh:message "An AdjacentTransition must declare exactly one from value that references a State or CompositeState." ;
  ] ;

  sh:property [
    sh:path ujggraph:to ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:node ujggraphshape:StateLikeShape ;
    sh:message "An AdjacentTransition must declare exactly one to value that references a State or CompositeState, never a JourneyExit." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "An AdjacentTransition must connect two different vertices; from and to must differ unless a StateCollection lists it in memberTransitionRefs, where both are the member State." ;
    sh:select """
      SELECT $this ?vertex
      WHERE {
        $this ujggraph:from ?vertex ;
              ujggraph:to ?vertex .

        FILTER (NOT EXISTS {
          ?collection a ujggraph:StateCollection ;
                      ujggraph:memberTransitionRefs $this .
        })
      }
    """ ;
  ] ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:commandRef ;
    sh:maxCount 0 ;
    sh:message "An AdjacentTransition must not declare commandRef. Model a command-driven movement as a Transition with commandRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:toEntryRef ;
    sh:maxCount 0 ;
    sh:message "An AdjacentTransition must not declare toEntryRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:fromExitRef ;
    sh:maxCount 0 ;
    sh:message "An AdjacentTransition must not declare fromExitRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "An AdjacentTransition must not declare entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "An AdjacentTransition must not declare subjourneyRefs." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "An AdjacentTransition must not also be typed Transition, OutgoingTransition, or InvokingTransition." ;
    sh:select """
      SELECT $this
      WHERE {
        { $this a ujggraph:Transition . }
        UNION
        { $this a ujggraph:OutgoingTransition . }
        UNION
        { $this a ujggraph:InvokingTransition . }
      }
    """ ;
  ] .

ujggraphshape:AdjacentTransitionDuplicateShape a sh:NodeShape ;
  sh:targetClass ujggraph:AdjacentTransition ;
  sh:severity sh:Warning ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A Transition without commandRef, toEntryRef, or fromExitRef connects the same two vertices as this AdjacentTransition, or moves between the same StateCollection's members. Unless it carries a guard or an effect, it duplicates one direction of the adjacency." ;
    sh:select """
      SELECT $this ?transition
      WHERE {
        $this ujggraph:from ?a ;
              ujggraph:to ?b .
        ?transition a ujggraph:Transition .
        {
          ?transition ujggraph:from ?a ;
                      ujggraph:to ?b .
        }
        UNION
        {
          ?transition ujggraph:from ?b ;
                      ujggraph:to ?a .
        }
        FILTER (?transition != $this)
        FILTER (NOT EXISTS { ?transition ujggraph:commandRef ?command . })
        FILTER (NOT EXISTS { ?transition ujggraph:toEntryRef ?entry . })
        FILTER (NOT EXISTS { ?transition ujggraph:fromExitRef ?exit . })
        FILTER (
          EXISTS {
            ?collection ujggraph:memberTransitionRefs $this, ?transition .
          }
          || (
            NOT EXISTS { ?collectionA ujggraph:memberTransitionRefs $this . }
            && NOT EXISTS { ?collectionB ujggraph:memberTransitionRefs ?transition . }
          )
        )
      }
    """ ;
  ] .

ujggraphshape:JourneyExitShape a sh:NodeShape ;
  sh:targetClass ujggraph:JourneyExit ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:tags ;
    sh:datatype xsd:string ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyExit must not declare entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "A JourneyExit must not declare subjourneyRefs." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyExit must not also be typed State or CompositeState." ;
    sh:select """
      SELECT $this
      WHERE {
        { $this a ujggraph:State . }
        UNION
        { $this a ujggraph:CompositeState . }
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyExit must be listed in the exitRefs of exactly one journey." ;
    sh:select """
      SELECT $this
      WHERE {
        FILTER (
          NOT EXISTS { ?journey ujggraph:exitRefs $this . }
          || EXISTS {
            ?journeyA ujggraph:exitRefs $this .
            ?journeyB ujggraph:exitRefs $this .
            FILTER (?journeyA != ?journeyB)
          }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A JourneyExit must not be used as the from value of a Transition or AdjacentTransition." ;
    sh:select """
      SELECT $this ?transition
      WHERE {
        ?transition ujggraph:from $this .
      }
    """ ;
  ] .

ujggraphshape:OutgoingTransitionShape a sh:NodeShape ;
  sh:targetClass ujggraph:OutgoingTransition ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:to ;
    sh:maxCount 0 ;
    sh:message "An OutgoingTransition must not declare to; target a JourneyEntry with toEntryRef or select one through entrySelectorRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:toEntryRef ;
    sh:class ujggraph:JourneyEntry ;
    sh:node ujggraphshape:JourneyEntryShape ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:entrySelectorRef ;
    sh:class ujggraph:EntrySelector ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "An OutgoingTransition must declare exactly one of toEntryRef or entrySelectorRef." ;
    sh:select """
      SELECT $this
      WHERE {
        FILTER (
          (
            EXISTS { $this ujggraph:toEntryRef ?entry . }
            && EXISTS { $this ujggraph:entrySelectorRef ?selector . }
          )
          || (
            NOT EXISTS { $this ujggraph:toEntryRef ?entry . }
            && NOT EXISTS { $this ujggraph:entrySelectorRef ?selector . }
          )
        )
      }
    """ ;
  ] ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:commandRef ;
    sh:class ujggraph:Command ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:from ;
    sh:maxCount 0 ;
    sh:message "An OutgoingTransition must not declare from. Its sources are the States that list it in entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:fromExitRef ;
    sh:maxCount 0 ;
    sh:message "An OutgoingTransition must not declare fromExitRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "An OutgoingTransition must not declare entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "An OutgoingTransition must not declare subjourneyRefs." ;
  ] .

ujggraphshape:InvokingTransitionShape a sh:NodeShape ;
  sh:targetClass ujggraph:InvokingTransition ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:to ;
    sh:maxCount 0 ;
    sh:message "An InvokingTransition must not declare to; target a JourneyEntry with toEntryRef or select one through entrySelectorRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:toEntryRef ;
    sh:class ujggraph:JourneyEntry ;
    sh:node ujggraphshape:JourneyEntryShape ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:entrySelectorRef ;
    sh:class ujggraph:EntrySelector ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "An InvokingTransition must declare exactly one of toEntryRef or entrySelectorRef." ;
    sh:select """
      SELECT $this
      WHERE {
        FILTER (
          (
            EXISTS { $this ujggraph:toEntryRef ?entry . }
            && EXISTS { $this ujggraph:entrySelectorRef ?selector . }
          )
          || (
            NOT EXISTS { $this ujggraph:toEntryRef ?entry . }
            && NOT EXISTS { $this ujggraph:entrySelectorRef ?selector . }
          )
        )
      }
    """ ;
  ] ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:commandRef ;
    sh:class ujggraph:Command ;
    sh:nodeKind sh:IRI ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:from ;
    sh:maxCount 0 ;
    sh:message "An InvokingTransition must not declare from. Its sources are the States that list it in entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:fromExitRef ;
    sh:maxCount 0 ;
    sh:message "An InvokingTransition must not declare fromExitRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "An InvokingTransition must not declare entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "An InvokingTransition must not declare subjourneyRefs." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "An InvokingTransition must not also be typed OutgoingTransition." ;
    sh:select """
      SELECT $this
      WHERE {
        $this a ujggraph:OutgoingTransition .
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "The Journey that owns an InvokingTransition's toEntryRef must declare at least one exitRefs value." ;
    sh:select """
      SELECT $this ?entry ?journey
      WHERE {
        $this ujggraph:toEntryRef ?entry .
        ?journey a ujggraph:Journey ;
                 ujggraph:entryRefs ?entry .

        FILTER (NOT EXISTS {
          ?journey ujggraph:exitRefs ?exit .
        })
      }
    """ ;
  ];

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "Each candidate Journey of an InvokingTransition's EntrySelector must declare at least one exitRefs value." ;
    sh:select """
      SELECT $this ?selector ?journey
      WHERE {
        $this ujggraph:entrySelectorRef ?selector .
        ?selector ujggraph:candidateJourneyRefs ?journey .

        FILTER (NOT EXISTS {
          ?journey ujggraph:exitRefs ?exit .
        })
      }
    """ ;
  ] .

ujggraphshape:StateCollectionShape a sh:NodeShape ;
  sh:targetClass ujggraph:StateCollection ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:memberStateRef ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:node ujggraphshape:StateLikeShape ;
    sh:message "A StateCollection must declare exactly one memberStateRef that references a State or CompositeState." ;
  ] ;

  sh:property [
    sh:path ujggraph:memberTransitionRefs ;
    sh:minCount 1 ;
    sh:nodeKind sh:IRI ;
    sh:or (
      [ sh:class ujggraph:Transition ]
      [ sh:class ujggraph:AdjacentTransition ]
    ) ;
    sh:message "A StateCollection must declare at least one memberTransitionRefs value, and each must reference a Transition or an AdjacentTransition." ;
  ] ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:tags ;
    sh:datatype xsd:string ;
  ] ;

  sh:property [
    sh:path ujggraph:from ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare from." ;
  ] ;

  sh:property [
    sh:path ujggraph:to ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare to." ;
  ] ;

  sh:property [
    sh:path ujggraph:toEntryRef ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare toEntryRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:fromExitRef ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare fromExitRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:commandRef ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare commandRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare subjourneyRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:transitionRefs ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare transitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:stateRefs ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare stateRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:stateRef ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare stateRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryRefs ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare entryRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:exitRefs ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare exitRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:defaultEntryRef ;
    sh:maxCount 0 ;
    sh:message "A StateCollection must not declare defaultEntryRef." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A StateCollection must not also be typed Journey, JourneyEntry, JourneyEntryIndex, State, CompositeState, Transition, AdjacentTransition, OutgoingTransition, InvokingTransition, Command, or JourneyExit." ;
    sh:select """
      SELECT $this
      WHERE {
        { $this a ujggraph:Journey . }
        UNION
        { $this a ujggraph:JourneyEntry . }
        UNION
        { $this a ujggraph:JourneyEntryIndex . }
        UNION
        { $this a ujggraph:State . }
        UNION
        { $this a ujggraph:CompositeState . }
        UNION
        { $this a ujggraph:Transition . }
        UNION
        { $this a ujggraph:AdjacentTransition . }
        UNION
        { $this a ujggraph:OutgoingTransition . }
        UNION
        { $this a ujggraph:InvokingTransition . }
        UNION
        { $this a ujggraph:Command . }
        UNION
        { $this a ujggraph:JourneyExit . }
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "The member State of a StateCollection must be listed in the stateRefs of a Journey." ;
    sh:select """
      SELECT $this ?state
      WHERE {
        $this ujggraph:memberStateRef ?state .

        FILTER (NOT EXISTS {
          ?journey ujggraph:stateRefs ?state .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A State or CompositeState must not be the member State of more than one StateCollection." ;
    sh:select """
      SELECT $this ?state ?otherCollection
      WHERE {
        $this ujggraph:memberStateRef ?state .
        ?otherCollection a ujggraph:StateCollection ;
                         ujggraph:memberStateRef ?state .
        FILTER (?otherCollection != $this)
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "Each member transition of a StateCollection must have the member State as both its from and its to value." ;
    sh:select """
      SELECT $this ?transition
      WHERE {
        $this ujggraph:memberStateRef ?state ;
              ujggraph:memberTransitionRefs ?transition .

        FILTER (
          NOT EXISTS { ?transition ujggraph:from ?state . }
          || NOT EXISTS { ?transition ujggraph:to ?state . }
          || EXISTS {
            ?transition ujggraph:from ?from .
            FILTER (?from != ?state)
          }
          || EXISTS {
            ?transition ujggraph:to ?to .
            FILTER (?to != ?state)
          }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A member transition must not also be listed in a Journey's transitionRefs." ;
    sh:select """
      SELECT $this ?transition ?journey
      WHERE {
        $this ujggraph:memberTransitionRefs ?transition .
        ?journey ujggraph:transitionRefs ?transition .
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A member transition must not be listed in the memberTransitionRefs of more than one StateCollection." ;
    sh:select """
      SELECT $this ?transition ?otherCollection
      WHERE {
        $this ujggraph:memberTransitionRefs ?transition .
        ?otherCollection a ujggraph:StateCollection ;
                         ujggraph:memberTransitionRefs ?transition .
        FILTER (?otherCollection != $this)
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A member transition with toEntryRef or fromExitRef requires a CompositeState member State." ;
    sh:select """
      SELECT $this ?transition ?state
      WHERE {
        $this ujggraph:memberStateRef ?state ;
              ujggraph:memberTransitionRefs ?transition .
        { ?transition ujggraph:toEntryRef ?boundary . }
        UNION
        { ?transition ujggraph:fromExitRef ?boundary . }

        FILTER (NOT EXISTS {
          ?state a ujggraph:CompositeState .
        })
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "The toEntryRef of a member transition must be listed in the entryRefs of exactly one Journey referenced by the member State's subjourneyRefs." ;
    sh:select """
      SELECT $this ?transition ?entry
      WHERE {
        $this ujggraph:memberStateRef ?state ;
              ujggraph:memberTransitionRefs ?transition .
        ?state a ujggraph:CompositeState .
        ?transition ujggraph:toEntryRef ?entry .

        FILTER (
          NOT EXISTS {
            ?state ujggraph:subjourneyRefs ?childJourney .
            ?childJourney ujggraph:entryRefs ?entry .
          }
          || EXISTS {
            ?state ujggraph:subjourneyRefs ?childJourneyA, ?childJourneyB .
            ?childJourneyA ujggraph:entryRefs ?entry .
            ?childJourneyB ujggraph:entryRefs ?entry .
            FILTER (?childJourneyA != ?childJourneyB)
          }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "The fromExitRef of a member transition must be listed in the exitRefs of exactly one Journey referenced by the member State's subjourneyRefs." ;
    sh:select """
      SELECT $this ?transition ?exit
      WHERE {
        $this ujggraph:memberStateRef ?state ;
              ujggraph:memberTransitionRefs ?transition .
        ?state a ujggraph:CompositeState .
        ?transition ujggraph:fromExitRef ?exit .

        FILTER (
          NOT EXISTS {
            ?state ujggraph:subjourneyRefs ?childJourney .
            ?childJourney ujggraph:exitRefs ?exit .
          }
          || EXISTS {
            ?state ujggraph:subjourneyRefs ?childJourneyA, ?childJourneyB .
            ?childJourneyA ujggraph:exitRefs ?exit .
            ?childJourneyB ujggraph:exitRefs ?exit .
            FILTER (?childJourneyA != ?childJourneyB)
          }
        )
      }
    """ ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "A member transition with fromExitRef must not share its member State and fromExitRef value with another member transition or with a transition in a Journey's transitionRefs." ;
    sh:select """
      SELECT $this ?transition ?otherTransition ?exit
      WHERE {
        $this ujggraph:memberStateRef ?state ;
              ujggraph:memberTransitionRefs ?transition .
        ?transition ujggraph:fromExitRef ?exit .
        ?otherTransition ujggraph:from ?state ;
                         ujggraph:fromExitRef ?exit .
        FILTER (?otherTransition != ?transition)
        FILTER (
          EXISTS { $this ujggraph:memberTransitionRefs ?otherTransition . }
          || EXISTS { ?journey ujggraph:transitionRefs ?otherTransition . }
        )
      }
    """ ;
  ] .

ujggraphshape:MemberStateRefSubjectShape a sh:NodeShape ;
  sh:targetSubjectsOf ujggraph:memberStateRef ;
  sh:class ujggraph:StateCollection ;
  sh:message "Only a StateCollection declares memberStateRef." .

ujggraphshape:MemberTransitionRefsSubjectShape a sh:NodeShape ;
  sh:targetSubjectsOf ujggraph:memberTransitionRefs ;
  sh:class ujggraph:StateCollection ;
  sh:message "Only a StateCollection declares memberTransitionRefs." .

ujggraphshape:EntrySelectorShape a sh:NodeShape ;
  sh:targetClass ujggraph:EntrySelector ;
  sh:nodeKind sh:IRI ;

  sh:property [
    sh:path ujggraph:candidateJourneyRefs ;
    sh:class ujggraph:Journey ;
    sh:nodeKind sh:IRI ;
    sh:message "Each candidateJourneyRefs value must reference a Journey." ;
  ] ;

  sh:property [
    sh:path ujggraph:label ;
    sh:datatype xsd:string ;
    sh:maxCount 1 ;
  ] ;

  sh:property [
    sh:path ujggraph:tags ;
    sh:datatype xsd:string ;
  ] ;

  sh:property [
    sh:path ujggraph:from ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare from." ;
  ] ;

  sh:property [
    sh:path ujggraph:to ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare to." ;
  ] ;

  sh:property [
    sh:path ujggraph:toEntryRef ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare toEntryRef; it names no entry." ;
  ] ;

  sh:property [
    sh:path ujggraph:fromExitRef ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare fromExitRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:commandRef ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare commandRef; declare it on the entry transition that references the selector." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryTransitionRefs ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare entryTransitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:subjourneyRefs ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare subjourneyRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:transitionRefs ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare transitionRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:stateRefs ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare stateRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:stateRef ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare stateRef." ;
  ] ;

  sh:property [
    sh:path ujggraph:entryRefs ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare entryRefs; list candidate Journeys in candidateJourneyRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:exitRefs ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare exitRefs." ;
  ] ;

  sh:property [
    sh:path ujggraph:defaultEntryRef ;
    sh:maxCount 0 ;
    sh:message "An EntrySelector must not declare defaultEntryRef." ;
  ] ;

  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "An EntrySelector must not also be typed Journey, JourneyEntry, JourneyEntryIndex, State, CompositeState, Transition, AdjacentTransition, OutgoingTransition, InvokingTransition, Command, JourneyExit, or StateCollection." ;
    sh:select """
      SELECT $this
      WHERE {
        { $this a ujggraph:Journey . }
        UNION
        { $this a ujggraph:JourneyEntry . }
        UNION
        { $this a ujggraph:JourneyEntryIndex . }
        UNION
        { $this a ujggraph:State . }
        UNION
        { $this a ujggraph:CompositeState . }
        UNION
        { $this a ujggraph:Transition . }
        UNION
        { $this a ujggraph:AdjacentTransition . }
        UNION
        { $this a ujggraph:OutgoingTransition . }
        UNION
        { $this a ujggraph:InvokingTransition . }
        UNION
        { $this a ujggraph:Command . }
        UNION
        { $this a ujggraph:JourneyExit . }
        UNION
        { $this a ujggraph:StateCollection . }
      }
    """ ;
  ] .

ujggraphshape:EntrySelectorRefSubjectShape a sh:NodeShape ;
  sh:targetSubjectsOf ujggraph:entrySelectorRef ;
  sh:or (
    [ sh:class ujggraph:OutgoingTransition ]
    [ sh:class ujggraph:InvokingTransition ]
  ) ;
  sh:message "Only an OutgoingTransition or InvokingTransition declares entrySelectorRef." .

ujggraphshape:CandidateJourneyRefsSubjectShape a sh:NodeShape ;
  sh:targetSubjectsOf ujggraph:candidateJourneyRefs ;
  sh:class ujggraph:EntrySelector ;
  sh:message "Only an EntrySelector declares candidateJourneyRefs." .

10. Graph Integrity and Resolution

The rules below define additional graph integrity and resolution behavior beyond the structural constraints captured by the SHACL shape.

To ensure graph integrity, the following constraints MUST be met:

  1. Every Graph reference MUST resolve within the current scope or imported modules.

  2. References MUST resolve to the class expected by the property that uses them.

  3. Local Transition and AdjacentTransition endpoints MUST stay inside the declaring Journey's local vertices, also inside child Journeys.

  4. On a Transition, toEntryRef and fromExitRef MUST resolve through one of the child Journeys referenced by the relevant CompositeState's subjourneyRefs. The referenced JourneyEntry or JourneyExit MUST be owned by exactly one such child Journey.

  5. On an OutgoingTransition or InvokingTransition, the destination entry, toEntryRef or the entry selected through its EntrySelector, MUST resolve to a JourneyEntry owned by exactly one Journey, and the entry's stateRef MUST resolve inside that Journey's stateRefs.

  6. Each OutgoingTransition and InvokingTransition MUST declare its destination and MUST NOT declare from, fromExitRef, or to.

  7. Each commandRef MUST resolve to a Command.

  8. The Journey that owns an InvokingTransition's destination entry MUST declare at least one exitRefs value. When the entry is selected, every candidate Journey of its EntrySelector MUST declare one as well.

  9. A StateCollection MUST be listed in the same UJGDocument as its member State, so that every Consumer that resolves the member State also finds the collection.

  10. An entry selected through an EntrySelector is not a reference of the authored Graph: it MAY be outside the current scope and imported modules until the transition is taken, and it MUST then resolve as rules 5 and 8 require. When it does not, the transition enters no Journey, and the Graph remains valid.

Copyright © 2026 the Contributors to the ujg/graph, published by the User Journey Graph Community Group under the W3C Community Contributor License Agreement (CLA) . A human-readable summary is available.

GitHub Matrix room

generated by Speculator