Alef1986 commited on
Commit
809e6fa
·
1 Parent(s): ff2fdd9

Edges now display validity properties when applicable

Browse files
js/app.js CHANGED
@@ -248,7 +248,7 @@ const App = {
248
 
249
  const graphLegendItems = computed(() => {
250
  const nodes = []; const edges = []; const dict = t.value.legend;
251
-
252
  if (state.perspective === 'SMRM' || state.ontology === 'NAIVE_NODE' || state.ontology === 'NAIVE_EDGE') {
253
  nodes.push({ id: 'naiveVehicle', label: dict.naiveVehicle, swatch: 'swatch-box-vehicle' });
254
  if (state.perspective !== 'SMRM') nodes.push({ id: 'naiveSlot', label: dict.naiveSlot, swatch: 'swatch-box-slot' });
@@ -290,7 +290,6 @@ const App = {
290
  if (state.perspective === 'SMS_LPG') edges.push({ id: 'isoTrans', label: dict.isoTransitionRel, swatch: 'swatch-line-transition' });
291
  }
292
 
293
- // Dynamic Legend Additions for Distinct Inferred Knowledge & Wisdom Nodes
294
  const gNodes = activeGraph.value.nodes || [];
295
  const gEdges = activeGraph.value.edges || [];
296
 
@@ -366,6 +365,7 @@ const App = {
366
  resetVanishingCrackTimeline(0);
367
  setPerspective('SMIM');
368
  state.graphEngine = 'MERMAID';
 
369
  }
370
  }
371
 
@@ -486,6 +486,7 @@ const App = {
486
 
487
  if (activeScenarioId.value === 'SANDBOX_TOUR') resetSandboxTourTimeline(0);
488
  else if (activeScenarioId.value === 'QDIKW_PIPELINE') resetQdikwTimeline(0);
 
489
 
490
  if (resetScenarioGraph) {
491
  resetActiveScenarioState();
 
248
 
249
  const graphLegendItems = computed(() => {
250
  const nodes = []; const edges = []; const dict = t.value.legend;
251
+
252
  if (state.perspective === 'SMRM' || state.ontology === 'NAIVE_NODE' || state.ontology === 'NAIVE_EDGE') {
253
  nodes.push({ id: 'naiveVehicle', label: dict.naiveVehicle, swatch: 'swatch-box-vehicle' });
254
  if (state.perspective !== 'SMRM') nodes.push({ id: 'naiveSlot', label: dict.naiveSlot, swatch: 'swatch-box-slot' });
 
290
  if (state.perspective === 'SMS_LPG') edges.push({ id: 'isoTrans', label: dict.isoTransitionRel, swatch: 'swatch-line-transition' });
291
  }
292
 
 
293
  const gNodes = activeGraph.value.nodes || [];
294
  const gEdges = activeGraph.value.edges || [];
295
 
 
365
  resetVanishingCrackTimeline(0);
366
  setPerspective('SMIM');
367
  state.graphEngine = 'MERMAID';
368
+ audioDuration.value = vanishingCrackScenario.fallbackDuration || 148;
369
  }
370
  }
371
 
 
486
 
487
  if (activeScenarioId.value === 'SANDBOX_TOUR') resetSandboxTourTimeline(0);
488
  else if (activeScenarioId.value === 'QDIKW_PIPELINE') resetQdikwTimeline(0);
489
+ else resetVanishingCrackTimeline(0);
490
 
491
  if (resetScenarioGraph) {
492
  resetActiveScenarioState();
js/renderers/mermaid-adapter.js CHANGED
@@ -3,6 +3,7 @@
3
  * ------------------------
4
  * Translates the abstract Semantic Graph into Mermaid flowchart syntax
5
  * with distinct shapes & colours for Recorded Facts vs Inferred Knowledge.
 
6
  */
7
 
8
  import { INTERNAL_PROPERTY_KEYS } from '../smrm/definitions.js';
@@ -73,6 +74,27 @@ async function executeRender(definition, container) {
73
  }
74
  }
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  function buildMermaidDefinition(semanticGraph) {
77
  let def = `%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%\nflowchart TD\n`;
78
  def += ' classDef default fill:#f8fafc,stroke:#cbd5e1,color:#334155,stroke-width:1px\n';
@@ -90,7 +112,7 @@ function buildMermaidDefinition(semanticGraph) {
90
  def += ' classDef naivePart fill:#10b981,stroke:#059669,color:#ffffff,stroke-width:2px\n';
91
  def += ' classDef naiveDefect fill:#ef4444,stroke:#b91c1c,color:#ffffff,stroke-width:2px\n';
92
  def += ' classDef naiveWarehouse fill:#f97316,stroke:#ea580c,color:#ffffff,stroke-width:2px\n';
93
- // Distinct Inferred Knowledge & Wisdom Styles
94
  def += ' classDef infStress fill:#7c3aed,stroke:#5b21b6,color:#ffffff,stroke-width:2px,stroke-dasharray:5 2\n';
95
  def += ' classDef infHazard fill:#be123c,stroke:#881337,color:#ffffff,stroke-width:2.5px,stroke-dasharray:6 2\n';
96
  def += ' classDef wisdomDir fill:#059669,stroke:#065f46,color:#ffffff,stroke-width:3px\n';
@@ -102,11 +124,8 @@ function buildMermaidDefinition(semanticGraph) {
102
  let labelText = node.label || node.id;
103
 
104
  if (node.properties) {
105
- const customProps = Object.entries(node.properties).filter(
106
- ([k, v]) => !INTERNAL_PROPERTY_KEYS.includes(k) && v !== undefined && v !== null
107
- );
108
- if (customProps.length > 0) {
109
- const propStr = customProps.map(([k, v]) => `${k}: ${v}`).join(', ');
110
  labelText = `${labelText} {${propStr}}`;
111
  }
112
  }
@@ -122,32 +141,25 @@ function buildMermaidDefinition(semanticGraph) {
122
  entityType = 'BFO:Site (Slot)';
123
  }
124
 
125
- // Distinct Mermaid geometry per ontological / inference role
126
  let shapeOpen = '["';
127
  let shapeClose = '"]';
128
 
129
  if (entityType === 'InferredStress') {
130
- // Subroutine shape [[...]] for inferred stress state
131
  shapeOpen = '[["🧠 ';
132
  shapeClose = '"]]';
133
  } else if (entityType === 'InferredHazard') {
134
- // Hexagon shape {{...}} for inferred fracture / hazard
135
  shapeOpen = '{{"⚡ ';
136
  shapeClose = '"}}';
137
  } else if (entityType === 'WisdomDirective') {
138
- // Trapezoid [/...\] for actionable wisdom directive
139
  shapeOpen = '[/"✅ ';
140
  shapeClose = '"\\]';
141
  } else if (entityType === 'BlindSpot') {
142
- // Parallelogram [/.../] for unmapped blind spot warning
143
  shapeOpen = '[/"⚠️ ';
144
  shapeClose = '"/]';
145
  } else if (entityType === 'TemporalPartMembership' || entityType === 'RelationalQuality' || entityType === 'Defect' || /^def/i.test(node.id)) {
146
- // Recorded Defect
147
  shapeOpen = '{{"🔧 ';
148
  shapeClose = '"}}';
149
  } else if (entityType === 'Literal' || entityType === 'Quality' || entityType === 'DependentContinuant' || /^qual/i.test(node.id)) {
150
- // Recorded BFO Quality
151
  shapeOpen = '(["🔍 ';
152
  shapeClose = '"])';
153
  }
@@ -172,11 +184,9 @@ function buildMermaidDefinition(semanticGraph) {
172
 
173
  let rawLabel = edge.label || '';
174
  if (edge.properties) {
175
- const customEdgeProps = Object.entries(edge.properties).filter(
176
- ([k, v]) => !INTERNAL_PROPERTY_KEYS.includes(k) && v !== undefined && v !== null
177
- );
178
- if (customEdgeProps.length > 0) {
179
- const propStr = customEdgeProps.map(([k, v]) => `${k}: ${v}`).join(', ');
180
  rawLabel = `${rawLabel}\\n{${propStr}}`;
181
  }
182
  }
 
3
  * ------------------------
4
  * Translates the abstract Semantic Graph into Mermaid flowchart syntax
5
  * with distinct shapes & colours for Recorded Facts vs Inferred Knowledge.
6
+ * Now explicitly formats and renders temporal properties directly on edges.
7
  */
8
 
9
  import { INTERNAL_PROPERTY_KEYS } from '../smrm/definitions.js';
 
74
  }
75
  }
76
 
77
+ /**
78
+ * Helper to safely extract and format properties for the visual canvas.
79
+ * Allows temporal bounds (validFrom, validTo) to bypass the internal filter.
80
+ */
81
+ function formatGraphProperties(props) {
82
+ if (!props) return '';
83
+ const allowed = Object.entries(props).filter(([k, v]) => {
84
+ if (v === undefined || v === null || k === 'isCurrent') return false;
85
+ // Allow validFrom, validTo, atTime even if they are in INTERNAL_PROPERTY_KEYS
86
+ return !INTERNAL_PROPERTY_KEYS.includes(k) || ['validFrom', 'validTo', 'atTime'].includes(k);
87
+ });
88
+
89
+ if (allowed.length === 0) return '';
90
+
91
+ return allowed.map(([k, v]) => {
92
+ // Prefix numeric timestamps with 'T' for clarity on the graph (e.g., T18)
93
+ const valStr = typeof v === 'number' && ['validFrom', 'validTo', 'atTime'].includes(k) ? `T${v}` : v;
94
+ return `${k}: ${valStr}`;
95
+ }).join(', ');
96
+ }
97
+
98
  function buildMermaidDefinition(semanticGraph) {
99
  let def = `%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%\nflowchart TD\n`;
100
  def += ' classDef default fill:#f8fafc,stroke:#cbd5e1,color:#334155,stroke-width:1px\n';
 
112
  def += ' classDef naivePart fill:#10b981,stroke:#059669,color:#ffffff,stroke-width:2px\n';
113
  def += ' classDef naiveDefect fill:#ef4444,stroke:#b91c1c,color:#ffffff,stroke-width:2px\n';
114
  def += ' classDef naiveWarehouse fill:#f97316,stroke:#ea580c,color:#ffffff,stroke-width:2px\n';
115
+
116
  def += ' classDef infStress fill:#7c3aed,stroke:#5b21b6,color:#ffffff,stroke-width:2px,stroke-dasharray:5 2\n';
117
  def += ' classDef infHazard fill:#be123c,stroke:#881337,color:#ffffff,stroke-width:2.5px,stroke-dasharray:6 2\n';
118
  def += ' classDef wisdomDir fill:#059669,stroke:#065f46,color:#ffffff,stroke-width:3px\n';
 
124
  let labelText = node.label || node.id;
125
 
126
  if (node.properties) {
127
+ const propStr = formatGraphProperties(node.properties);
128
+ if (propStr) {
 
 
 
129
  labelText = `${labelText} {${propStr}}`;
130
  }
131
  }
 
141
  entityType = 'BFO:Site (Slot)';
142
  }
143
 
 
144
  let shapeOpen = '["';
145
  let shapeClose = '"]';
146
 
147
  if (entityType === 'InferredStress') {
 
148
  shapeOpen = '[["🧠 ';
149
  shapeClose = '"]]';
150
  } else if (entityType === 'InferredHazard') {
 
151
  shapeOpen = '{{"⚡ ';
152
  shapeClose = '"}}';
153
  } else if (entityType === 'WisdomDirective') {
 
154
  shapeOpen = '[/"✅ ';
155
  shapeClose = '"\\]';
156
  } else if (entityType === 'BlindSpot') {
 
157
  shapeOpen = '[/"⚠️ ';
158
  shapeClose = '"/]';
159
  } else if (entityType === 'TemporalPartMembership' || entityType === 'RelationalQuality' || entityType === 'Defect' || /^def/i.test(node.id)) {
 
160
  shapeOpen = '{{"🔧 ';
161
  shapeClose = '"}}';
162
  } else if (entityType === 'Literal' || entityType === 'Quality' || entityType === 'DependentContinuant' || /^qual/i.test(node.id)) {
 
163
  shapeOpen = '(["🔍 ';
164
  shapeClose = '"])';
165
  }
 
184
 
185
  let rawLabel = edge.label || '';
186
  if (edge.properties) {
187
+ const propStr = formatGraphProperties(edge.properties);
188
+ if (propStr) {
189
+ // Escaped newline for Mermaid edge syntax
 
 
190
  rawLabel = `${rawLabel}\\n{${propStr}}`;
191
  }
192
  }
js/renderers/vis-adapter.js CHANGED
@@ -1,8 +1,8 @@
1
  /**
2
  * VIS.JS RENDERER ADAPTER
3
  * -----------------------
4
- * Renders the Semantic Graph using vis-network with distinct visual styling
5
- * for Recorded Facts vs Inferred Knowledge (Stress, Hazards, Directives, Blind Spots).
6
  */
7
 
8
  import { INTERNAL_PROPERTY_KEYS } from '../smrm/definitions.js';
@@ -47,6 +47,25 @@ export function initVisNetwork(container) {
47
  network = new vis.Network(container, { nodes: nodesDataSet, edges: edgesDataSet }, options);
48
  }
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  export function updateVisNetwork(semanticGraph, isComplex = false) {
51
  if (!network || !nodesDataSet || !edgesDataSet) return;
52
 
@@ -55,11 +74,8 @@ export function updateVisNetwork(semanticGraph, isComplex = false) {
55
  let labelText = node.label || node.id;
56
 
57
  if (node.properties) {
58
- const customProps = Object.entries(node.properties).filter(
59
- ([k, v]) => !INTERNAL_PROPERTY_KEYS.includes(k) && v !== undefined && v !== null
60
- );
61
- if (customProps.length > 0) {
62
- const propStr = customProps.map(([k, v]) => `${k}: ${v}`).join(', ');
63
  labelText += `\n{${propStr}}`;
64
  }
65
  }
@@ -88,12 +104,11 @@ export function updateVisNetwork(semanticGraph, isComplex = false) {
88
  const visEdges = (semanticGraph.edges || []).map((edge, idx) => {
89
  const style = getVisEdgeStyle(edge);
90
  let rawLabel = edge.label || '';
 
91
  if (edge.properties) {
92
- const customEdgeProps = Object.entries(edge.properties).filter(
93
- ([k, v]) => !INTERNAL_PROPERTY_KEYS.includes(k) && v !== undefined && v !== null
94
- );
95
- if (customEdgeProps.length > 0) {
96
- const propStr = customEdgeProps.map(([k, v]) => `${k}: ${v}`).join(', ');
97
  rawLabel = `${rawLabel}\n{${propStr}}`;
98
  }
99
  }
 
1
  /**
2
  * VIS.JS RENDERER ADAPTER
3
  * -----------------------
4
+ * Renders the Semantic Graph using vis-network with distinct visual styling.
5
+ * Now explicitly displays temporal boundaries directly on edges.
6
  */
7
 
8
  import { INTERNAL_PROPERTY_KEYS } from '../smrm/definitions.js';
 
47
  network = new vis.Network(container, { nodes: nodesDataSet, edges: edgesDataSet }, options);
48
  }
49
 
50
+ /**
51
+ * Helper to safely extract and format properties for the visual canvas.
52
+ * Allows temporal bounds (validFrom, validTo) to bypass the internal filter.
53
+ */
54
+ function formatGraphProperties(props) {
55
+ if (!props) return '';
56
+ const allowed = Object.entries(props).filter(([k, v]) => {
57
+ if (v === undefined || v === null || k === 'isCurrent') return false;
58
+ return !INTERNAL_PROPERTY_KEYS.includes(k) || ['validFrom', 'validTo', 'atTime'].includes(k);
59
+ });
60
+
61
+ if (allowed.length === 0) return '';
62
+
63
+ return allowed.map(([k, v]) => {
64
+ const valStr = typeof v === 'number' && ['validFrom', 'validTo', 'atTime'].includes(k) ? `T${v}` : v;
65
+ return `${k}: ${valStr}`;
66
+ }).join(', ');
67
+ }
68
+
69
  export function updateVisNetwork(semanticGraph, isComplex = false) {
70
  if (!network || !nodesDataSet || !edgesDataSet) return;
71
 
 
74
  let labelText = node.label || node.id;
75
 
76
  if (node.properties) {
77
+ const propStr = formatGraphProperties(node.properties);
78
+ if (propStr) {
 
 
 
79
  labelText += `\n{${propStr}}`;
80
  }
81
  }
 
104
  const visEdges = (semanticGraph.edges || []).map((edge, idx) => {
105
  const style = getVisEdgeStyle(edge);
106
  let rawLabel = edge.label || '';
107
+
108
  if (edge.properties) {
109
+ const propStr = formatGraphProperties(edge.properties);
110
+ if (propStr) {
111
+ // Standard newline for Vis.js
 
 
112
  rawLabel = `${rawLabel}\n{${propStr}}`;
113
  }
114
  }