Alef1986 commited on
Commit
48ae2ff
·
1 Parent(s): c7958c7

QDIKW scenario implemented

Browse files
figures/1280px-DIKW_Pyramid.svg.webp ADDED
js/app.js CHANGED
@@ -20,6 +20,7 @@ import { ENTITY_CLASSES, RELATION_TYPES, INTERNAL_PROPERTY_KEYS, inferEntityClas
20
  import * as bfoAdapter from './smim/bfo.js';
21
  import * as isoAdapter from './smim/iso15926.js';
22
  import * as naiveAdapter from './smim/naive.js';
 
23
  import { initVisNetwork, updateVisNetwork } from './renderers/vis-adapter.js';
24
  import { updateMermaidNetwork } from './renderers/mermaid-adapter.js';
25
  import { generateBomTrees } from './urmsm/bom-view.js';
@@ -42,54 +43,40 @@ import {
42
  onSandboxTourTimeUpdate,
43
  resetSandboxTourTimeline
44
  } from './scenarios/scenario-sandbox-tour.js';
 
 
 
 
 
 
45
 
46
- /**
47
- * RECURSIVE BOM TREE NODE COMPONENT
48
- * ---------------------------------
49
- * Renders hierarchical Bill of Materials nodes with entity class badges
50
- * and surviving defect indicators at time T.
51
- */
52
  const BomNode = {
53
  name: 'BomNode',
54
  props: {
55
- node: {
56
- type: Object,
57
- required: true
58
- }
59
  },
60
  template: `
61
  <li>
62
  <span class="bom-node-row">
63
  <strong>{{ node.id }}</strong>
64
  <span class="bom-class-badge">{{ node.entityClass }}</span>
65
- <span
66
- v-for="def in (node.defects || [])"
67
- :key="def"
68
- class="bom-defect-badge"
69
- >⚠️ {{ def }}</span>
70
  </span>
71
  <ul v-if="node.children && node.children.length > 0" class="tree">
72
- <bom-node
73
- v-for="child in node.children"
74
- :key="child.id"
75
- :node="child"
76
- />
77
  </ul>
78
  </li>
79
  `
80
  };
81
 
82
  const App = {
83
- components: {
84
- BomNode
85
- },
86
  setup() {
87
- // DOM References for renderers & file operations
88
  const visContainer = ref(null);
89
  const mermaidContainer = ref(null);
90
  const fileInput = ref(null);
91
 
92
- // Universal Engineer Business UI inputs
93
  const bizRegType = ref('Part');
94
  const bizRegId = ref('');
95
  const bizInstSource = ref('');
@@ -99,11 +86,12 @@ const App = {
99
  const bizDefVal = ref('');
100
  const bizRevDefect = ref('');
101
  const bizDismPart = ref('');
 
102
  const bizStorePart = ref('');
103
  const bizStoreTarget = ref('');
104
 
105
- // Scenario Player State (Supports multiple scenarios + virtual fallback timer)
106
- const activeScenarioId = ref('VANISHING_CRACK'); // 'SANDBOX_TOUR' | 'VANISHING_CRACK'
107
  const scenarioAudio = ref(null);
108
  const isPlaying = ref(false);
109
  const audioCurrentTime = ref(0);
@@ -113,128 +101,78 @@ const App = {
113
  let virtualTimerInterval = null;
114
  const usingVirtualTimer = ref(false);
115
 
116
- const activeScenarioObj = computed(() =>
117
- activeScenarioId.value === 'SANDBOX_TOUR' ? sandboxTourScenario : vanishingCrackScenario
118
- );
 
 
119
 
120
- const activeAudioSrc = computed(() =>
121
- activeScenarioId.value === 'SANDBOX_TOUR'
122
- ? './narratives/Ontologies_-_Sandbox_Tour.mp3'
123
- : './narratives/Ontologies_-_Disappearing_Crack.mp3'
124
- );
125
 
126
- // Layout State (Flex percentages for resizers)
127
  const layout = reactive({ leftWidth: 64, bomHeight: 24, storageHeight: 42 });
128
-
129
- // Active dictionary based on state.language
130
  const t = computed(() => i18n[state.language] || i18n.en);
131
 
132
- // Reconstruct base registered entities up to state.currentTime
133
  const baseNodes = computed(() => {
134
  const nodeMap = new Map();
135
-
136
  state.eventLog.forEach(event => {
137
  if (event.valid_from !== undefined && event.valid_from > state.currentTime) return;
138
-
139
  if (event.type === 'REGISTER_PART' && event.partId) {
140
  const cls = inferEntityClass(event.partId, event.entityClass);
141
- nodeMap.set(event.partId, {
142
- id: event.partId,
143
- label: event.partId,
144
- type: cls,
145
- entityClass: cls
146
- });
147
  } else if (event.type === 'ASSEMBLE') {
148
  if (event.parentId && !nodeMap.has(event.parentId)) {
149
  const pCls = inferEntityClass(event.parentId);
150
- nodeMap.set(event.parentId, {
151
- id: event.parentId,
152
- label: event.parentId,
153
- type: pCls,
154
- entityClass: pCls
155
- });
156
  }
157
  if (event.childId && !nodeMap.has(event.childId)) {
158
  const cCls = inferEntityClass(event.childId);
159
- nodeMap.set(event.childId, {
160
- id: event.childId,
161
- label: event.childId,
162
- type: cCls,
163
- entityClass: cCls
164
- });
165
  }
166
  }
167
  });
168
-
169
  return Array.from(nodeMap.values());
170
  });
171
 
172
  const availableNodes = computed(() => baseNodes.value.map(n => n.id));
 
 
 
 
173
 
174
- const activeParts = computed(() =>
175
- baseNodes.value.filter(n => n.entityClass !== 'Slot' && n.entityClass !== 'Warehouse').map(n => n.id)
176
- );
177
-
178
- const activeWarehouses = computed(() =>
179
- baseNodes.value.filter(n => n.entityClass === 'Warehouse').map(n => n.id)
180
- );
181
-
182
- const bizInstallSources = computed(() =>
183
- baseNodes.value.filter(n => n.entityClass === 'Part').map(n => n.id)
184
- );
185
-
186
- const bizInstallTargets = computed(() =>
187
- baseNodes.value.filter(n => n.entityClass === 'Vehicle' || n.entityClass === 'Part').map(n => n.id)
188
- );
189
-
190
- /**
191
- * Central Event Dispatcher (Pure Event Sourcing)
192
- * Appends immutable business facts to the event log.
193
- */
194
  function dispatch(event) {
195
  if (!event) return;
196
  state.eventLog.push(event);
197
  }
198
 
199
- // Core Transformation Pipeline: Event Log -> SMIM Canonical Semantic Graph
200
  const semanticGraph = computed(() => {
201
- const opts = {
202
- ontology: state.ontology,
203
- showHistory: state.showHistory
204
- };
205
-
206
  if (state.ontology === 'BFO') {
207
- return bfoAdapter.generateSemanticGraph(state.eventLog, baseNodes.value, state.currentTime, opts);
208
- }
209
- if (state.ontology === 'ISO15926') {
210
- return isoAdapter.generateSemanticGraph(state.eventLog, baseNodes.value, state.currentTime, opts);
 
211
  }
212
- return naiveAdapter.generateSemanticGraph(state.eventLog, baseNodes.value, state.currentTime, opts);
213
  });
214
 
215
- // Engineer SMRM reduced graph (used for BOM, SMRM view, and installed component discovery)
216
  const smrmReducedGraph = computed(() => reduceGraphForSMRM(semanticGraph.value));
217
 
218
  const installedComponents = computed(() => {
219
  const comps = new Set();
220
  smrmReducedGraph.value.edges.forEach(e => {
221
  if (e.properties?.isCurrent === false) return;
222
- if (e.label === 'has_part') {
223
- comps.add(e.to);
224
- } else if (e.label === 'mounted_in' || e.label === 'stored_at') {
225
- comps.add(e.from);
226
- }
227
  });
228
  return Array.from(comps).filter(id => !id.startsWith('Slot_'));
229
  });
230
 
231
- // Active Defects List (respecting REVOKE_DEFECT events)
232
  const activeDefectsList = computed(() => {
233
  const activeMap = new Map();
234
-
235
  state.eventLog.forEach((e, index) => {
236
  if (e.valid_from !== undefined && e.valid_from > state.currentTime) return;
237
-
238
  if (e.type === 'REPORT_DEFECT') {
239
  if (e.valid_to !== null && e.valid_to !== undefined && e.valid_to <= state.currentTime) return;
240
  const key = `${e.targetId}::${e.defectName}`;
@@ -251,69 +189,30 @@ const App = {
251
  activeMap.delete(key);
252
  }
253
  });
254
-
255
  return Array.from(activeMap.values());
256
  });
257
 
258
- // Keep select dropdown defaults synchronised with available options
259
- watch(bizInstallSources, (sources) => {
260
- if (!sources.includes(bizInstSource.value)) bizInstSource.value = sources[0] || '';
261
- }, { immediate: true });
262
-
263
- watch(bizInstallTargets, (targets) => {
264
- if (!targets.includes(bizInstTarget.value)) bizInstTarget.value = targets[0] || '';
265
- }, { immediate: true });
266
-
267
- watch(activeParts, (parts) => {
268
- if (!parts.includes(bizStorePart.value)) bizStorePart.value = parts[0] || '';
269
- }, { immediate: true });
270
-
271
- watch(activeWarehouses, (warehouses) => {
272
- if (!warehouses.includes(bizStoreTarget.value)) bizStoreTarget.value = warehouses[0] || '';
273
- }, { immediate: true });
274
-
275
- watch(installedComponents, (comps) => {
276
- if (!comps.includes(bizDismPart.value)) bizDismPart.value = comps[0] || '';
277
- }, { immediate: true });
278
-
279
- watch(activeDefectsList, (defects) => {
280
- if (!defects.some(d => d.id === bizRevDefect.value)) bizRevDefect.value = defects[0]?.id || '';
281
- }, { immediate: true });
282
-
283
  watch(availableNodes, (nodes) => {
284
  if (!nodes.includes(bizDefTarget.value)) bizDefTarget.value = nodes[0] || '';
 
285
  }, { immediate: true });
286
 
287
- // Derived Views for Sidebar (URMSM & SMS)
288
  const bomTrees = computed(() => generateBomTrees(semanticGraph.value));
289
-
290
- const lpgNodeRecords = computed(() => {
291
- if (state.storage === 'LPG') {
292
- return generateLpgNodeStorage(semanticGraph.value);
293
- }
294
- return [];
295
- });
296
-
297
- const lpgRecords = computed(() => {
298
- if (state.storage === 'LPG') {
299
- return generateLpgStorage(semanticGraph.value);
300
- }
301
- return [];
302
- });
303
-
304
- const rdfTtl = computed(() => {
305
- if (state.storage === 'RDF') {
306
- return generateRdfStorage(semanticGraph.value);
307
- }
308
- return '';
309
- });
310
 
311
  function formatProperties(props) {
312
  if (!props) return '';
313
  const entries = Object.entries(props).filter(
314
  ([key, val]) => !INTERNAL_PROPERTY_KEYS.includes(key) || key === 'validFrom' || key === 'validTo' || key === 'atTime'
315
- ? (key !== 'isCurrent' && val !== undefined)
316
- : false
317
  );
318
  if (entries.length === 0) return '';
319
  return entries.map(([k, v]) => {
@@ -323,68 +222,45 @@ const App = {
323
  }
324
 
325
  const queryCode = computed(() => {
326
- if (state.storage === 'LPG') {
327
- return generateLpgQuery(semanticGraph.value, state.currentTime, state.ontology);
328
- }
329
  return generateRdfQuery(semanticGraph.value, state.currentTime, state.ontology);
330
  });
331
 
332
- const liveQueryResult = computed(() =>
333
- evaluateLiveQuery(semanticGraph.value, state.currentTime, state.ontology)
334
- );
335
 
336
- // Route active graph to canvas based on the 4 unified Perspectives
337
  const activeGraph = computed(() => {
338
- if (state.perspective === 'SMS_LPG') {
339
- return generatePhysicalGraph(semanticGraph.value, 'LPG');
340
- }
341
- if (state.perspective === 'SMS_RDF') {
342
- return generatePhysicalGraph(semanticGraph.value, 'RDF');
343
- }
344
- if (state.perspective === 'SMRM') {
345
- return smrmReducedGraph.value;
346
- }
347
  return semanticGraph.value;
348
  });
349
 
350
- // Reactive Graph Caption (truthful to the active perspective)
351
  const graphCaption = computed(() => {
352
  let ontoText = 'BFO (3D)';
353
  if (state.ontology === 'ISO15926') ontoText = 'ISO 15926 (4D)';
354
  if (state.ontology === 'NAIVE_NODE') ontoText = t.value.ontoNaiveNode;
355
  if (state.ontology === 'NAIVE_EDGE') ontoText = t.value.ontoNaiveEdge;
356
-
357
  let viewText = t.value.viewLogicalCaption;
358
  if (state.perspective === 'SMRM') viewText = t.value.viewSmrmCaption;
359
  if (state.perspective === 'SMS_LPG') viewText = t.value.viewPhysicalLpgCaption;
360
  if (state.perspective === 'SMS_RDF') viewText = t.value.viewPhysicalRdfCaption;
361
-
362
  return `${ontoText} | ${viewText}`;
363
  });
364
 
365
- // Contextual Dynamic Legend matching the rendered canvas
366
  const graphLegendItems = computed(() => {
367
- const nodes = [];
368
- const edges = [];
369
- const dict = t.value.legend;
370
-
371
  if (state.perspective === 'SMRM' || state.ontology === 'NAIVE_NODE' || state.ontology === 'NAIVE_EDGE') {
372
  nodes.push({ id: 'naiveVehicle', label: dict.naiveVehicle, swatch: 'swatch-box-vehicle' });
373
- if (state.perspective !== 'SMRM') {
374
- nodes.push({ id: 'naiveSlot', label: dict.naiveSlot, swatch: 'swatch-box-slot' });
375
- }
376
  nodes.push({ id: 'naivePart', label: dict.naivePart, swatch: 'swatch-box-part' });
377
  nodes.push({ id: 'naiveDefect', label: dict.naiveDefect, swatch: 'swatch-diamond-defect' });
378
  nodes.push({ id: 'naiveWarehouse', label: dict.naiveWarehouse, swatch: 'swatch-box-warehouse' });
379
-
380
  if (state.perspective === 'SMS_RDF') {
381
  nodes.push({ id: 'rdfStmt', label: dict.rdfStmt, swatch: 'swatch-diamond' });
382
  nodes.push({ id: 'rdfLit', label: dict.rdfLit, swatch: 'swatch-literal' });
383
  edges.push({ id: 'rdfPred', label: dict.rdfPred, swatch: 'swatch-line-past' });
384
  } else {
385
- if (state.perspective !== 'SMRM') {
386
- edges.push({ id: 'relHasSlot', label: dict.relHasSlot, swatch: 'swatch-line-slot' });
387
- }
388
  edges.push({ id: 'relMountedIn', label: dict.relMountedIn, swatch: 'swatch-line-mount' });
389
  edges.push({ id: 'relStoredAt', label: dict.relStoredAt, swatch: 'swatch-line-store' });
390
  edges.push({ id: 'relHasDefect', label: dict.relHasDefect, swatch: 'swatch-line-defect' });
@@ -392,8 +268,8 @@ const App = {
392
  } else if (state.ontology === 'BFO') {
393
  nodes.push({ id: 'bfoSys', label: dict.bfoSys, swatch: 'swatch-box-sys' });
394
  nodes.push({ id: 'bfoElem', label: dict.bfoElem, swatch: 'swatch-box-elem' });
 
395
  nodes.push({ id: 'bfoQuality', label: dict.bfoQuality, swatch: 'swatch-diamond' });
396
-
397
  if (state.perspective === 'SMS_RDF') {
398
  nodes.push({ id: 'rdfStmt', label: dict.rdfStmt, swatch: 'swatch-diamond' });
399
  nodes.push({ id: 'rdfLit', label: dict.rdfLit, swatch: 'swatch-literal' });
@@ -401,33 +277,22 @@ const App = {
401
  } else {
402
  edges.push({ id: 'bfoActive', label: dict.bfoActiveEdge, swatch: 'swatch-line-active' });
403
  edges.push({ id: 'bfoInheres', label: dict.bfoInheres, swatch: 'swatch-line-transition' });
404
- if (state.showHistory) {
405
- edges.push({ id: 'bfoPast', label: dict.bfoPastEdge, swatch: 'swatch-line-past' });
406
- }
407
  }
408
  } else {
409
  nodes.push({ id: 'iso4d', label: dict.iso4d, swatch: 'swatch-box-4d' });
410
  nodes.push({ id: 'isoState', label: dict.isoState, swatch: 'swatch-box-state' });
411
  nodes.push({ id: 'isoDefect', label: dict.isoDefect, swatch: 'swatch-diamond-defect' });
412
- if (state.perspective === 'SMS_RDF') {
413
- nodes.push({ id: 'rdfLit', label: dict.rdfLit, swatch: 'swatch-literal' });
414
- }
415
  edges.push({ id: 'isoPart', label: dict.isoPartRel, swatch: 'swatch-line-active' });
416
  edges.push({ id: 'isoSlice', label: dict.isoSliceRel, swatch: 'swatch-line-past' });
417
  edges.push({ id: 'isoDefectRel', label: dict.isoDefectRel, swatch: 'swatch-line-defect' });
418
-
419
- if (state.perspective === 'SMS_LPG') {
420
- edges.push({ id: 'isoTrans', label: dict.isoTransitionRel, swatch: 'swatch-line-transition' });
421
- }
422
  }
423
-
424
  return { nodes, edges };
425
  });
426
 
427
- // Re-render canvas when activeGraph or engine changes
428
- watch([activeGraph, () => state.graphEngine], () => {
429
- renderGraph();
430
- }, { deep: true });
431
 
432
  function renderGraph() {
433
  if (state.currentView === 'MENU') return;
@@ -444,6 +309,8 @@ const App = {
444
  state.eventLog.splice(0, state.eventLog.length);
445
  state.currentTime = 0;
446
  state.edgeSequence = 1;
 
 
447
  dispatch(createRegisterPartEvent('System_A', 0, 'Vehicle', nextSequence()));
448
  dispatch(createRegisterPartEvent('SubAssembly_1', 0, 'Part', nextSequence()));
449
  dispatch(createAssembleEvent('System_A', 'SubAssembly_1', 'mounted_in', 0, nextSequence()));
@@ -459,13 +326,21 @@ const App = {
459
  state.eventLog.splice(0, state.eventLog.length);
460
  state.currentTime = 0;
461
  state.ontology = 'NAIVE_NODE';
 
 
462
 
463
  if (activeScenarioId.value === 'SANDBOX_TOUR') {
464
  resetSandboxTourTimeline(0);
465
  setPerspective('SMRM');
466
- state.graphEngine = 'VIS';
467
  audioDuration.value = sandboxTourScenario.fallbackDuration;
468
  onSandboxTourTimeUpdate(0, state, renderGraph);
 
 
 
 
 
 
469
  } else {
470
  resetVanishingCrackTimeline(0);
471
  setPerspective('SMIM');
@@ -476,7 +351,7 @@ const App = {
476
  function launchScenario(scenarioId) {
477
  activeScenarioId.value = scenarioId;
478
  stopAudio(false);
479
- if ( state.currentView === 'SCENARIO' ) {
480
  resetActiveScenarioState();
481
  nextTick(() => renderGraph());
482
  } else {
@@ -484,11 +359,36 @@ const App = {
484
  }
485
  }
486
 
487
- // Watch for view transitions (MENU vs SANDBOX vs SCENARIO)
488
- watch(() => state.currentView, async (newView) => {
489
- if (newView !== 'SCENARIO') {
490
- stopAudio(false);
 
 
 
 
491
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
492
  if (newView === 'SCENARIO') {
493
  resetActiveScenarioState();
494
  } else if (newView === 'SANDBOX' && state.eventLog.length === 0) {
@@ -496,9 +396,7 @@ const App = {
496
  }
497
  if (newView !== 'MENU') {
498
  await nextTick();
499
- if (visContainer.value) {
500
- initVisNetwork(visContainer.value);
501
- }
502
  renderGraph();
503
  }
504
  });
@@ -512,19 +410,15 @@ const App = {
512
  });
513
 
514
  function clearVirtualTimer() {
515
- if (virtualTimerInterval) {
516
- clearInterval(virtualTimerInterval);
517
- virtualTimerInterval = null;
518
- }
519
  }
520
 
521
  function startVirtualTimer() {
522
  clearVirtualTimer();
523
  usingVirtualTimer.value = true;
524
  isPlaying.value = true;
525
- if (!audioDuration.value) {
526
- audioDuration.value = activeScenarioObj.value.fallbackDuration || 108;
527
- }
528
  virtualTimerInterval = setInterval(() => {
529
  if (audioCurrentTime.value < audioDuration.value) {
530
  audioCurrentTime.value = Math.min(audioDuration.value, audioCurrentTime.value + 0.25);
@@ -539,21 +433,17 @@ const App = {
539
  function goHome() {
540
  stopAudio(false);
541
  state.currentView = 'MENU';
 
 
542
  state.eventLog.splice(0, state.eventLog.length);
543
  state.currentTime = 0;
544
  state.edgeSequence = 1;
545
  }
546
 
547
  function playAudio() {
548
- if (usingVirtualTimer.value) {
549
- startVirtualTimer();
550
- return;
551
- }
552
  if (scenarioAudio.value) {
553
- scenarioAudio.value.play().catch(() => {
554
- // If MP3 file is not recorded yet, seamlessly fall back to virtual timer
555
- startVirtualTimer();
556
- });
557
  } else {
558
  startVirtualTimer();
559
  }
@@ -562,17 +452,11 @@ const App = {
562
  function pauseAudio() {
563
  clearVirtualTimer();
564
  isPlaying.value = false;
565
- if (scenarioAudio.value && !usingVirtualTimer.value) {
566
- scenarioAudio.value.pause();
567
- }
568
  }
569
 
570
  function togglePlayAudio() {
571
- if (isPlaying.value) {
572
- pauseAudio();
573
- } else {
574
- playAudio();
575
- }
576
  }
577
 
578
  function stopAudio(resetScenarioGraph = true) {
@@ -585,25 +469,29 @@ const App = {
585
  isPlaying.value = false;
586
  audioCurrentTime.value = 0;
587
  currentSubtitleText.value = '';
588
- resetSandboxTourTimeline(0);
 
 
589
 
590
  if (resetScenarioGraph) {
591
  resetActiveScenarioState();
592
- nextTick(() => {
593
- renderGraph();
594
- });
595
  }
596
  }
597
 
598
  function processTimelineAt(currentTime) {
599
  const scenario = activeScenarioObj.value;
600
- const activeSubtitle = scenario.subtitles.find(
601
- sub => currentTime >= sub.start && currentTime <= sub.end
602
- );
603
  currentSubtitleText.value = activeSubtitle ? activeSubtitle.text : '';
604
 
 
 
 
 
605
  if (activeScenarioId.value === 'SANDBOX_TOUR') {
606
  onSandboxTourTimeUpdate(currentTime, state, renderGraph);
 
 
607
  } else {
608
  dispatchVanishingCrackTimeline(currentTime, state, renderGraph);
609
  }
@@ -611,9 +499,7 @@ const App = {
611
 
612
  function onTimeUpdate() {
613
  if (usingVirtualTimer.value) return;
614
- if (scenarioAudio.value) {
615
- audioCurrentTime.value = scenarioAudio.value.currentTime;
616
- }
617
  processTimelineAt(audioCurrentTime.value);
618
  }
619
 
@@ -632,11 +518,8 @@ const App = {
632
 
633
  function onSeek(event) {
634
  const targetTime = parseFloat(event.target.value);
635
- if (scenarioAudio.value && !usingVirtualTimer.value) {
636
- scenarioAudio.value.currentTime = targetTime;
637
- }
638
  audioCurrentTime.value = targetTime;
639
-
640
  resetActiveScenarioState();
641
  processTimelineAt(targetTime);
642
  }
@@ -648,222 +531,146 @@ const App = {
648
  return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
649
  }
650
 
651
- // Engineer Domain Actions
652
  function handleBizRegister() {
653
  if (!bizRegId.value) return;
654
- const event = createRegisterPartEvent(
655
- bizRegId.value,
656
- state.currentTime,
657
- bizRegType.value,
658
- nextSequence()
659
- );
660
- if (event) {
661
- dispatch(event);
662
- bizRegId.value = '';
663
- }
664
  }
665
 
666
  function handleBizInstall() {
667
  if (!bizInstSource.value || !bizInstTarget.value) return;
668
  if (bizInstSource.value === bizInstTarget.value) return;
669
-
670
- const event = createAssembleEvent(
671
- bizInstTarget.value,
672
- bizInstSource.value,
673
- 'mounted_in',
674
- state.currentTime,
675
- nextSequence()
676
- );
677
  if (event) dispatch(event);
678
  }
679
 
680
  function handleBizReportDefect() {
681
  if (!bizDefTarget.value || !bizDefType.value) return;
682
- const event = createReportDefectEvent(
683
- bizDefTarget.value,
684
- bizDefType.value,
685
- bizDefVal.value || 'present',
686
- state.currentTime,
687
- nextSequence()
688
- );
689
- if (event) {
690
- dispatch(event);
691
- bizDefType.value = '';
692
- bizDefVal.value = '';
693
- }
694
  }
695
 
696
  function handleBizRevokeDefect() {
697
  if (!bizRevDefect.value) return;
698
  const item = activeDefectsList.value.find(d => d.id === bizRevDefect.value);
699
  if (item) {
700
- const event = createRevokeDefectEvent(
701
- item.targetId,
702
- item.defectName,
703
- state.currentTime,
704
- item.id,
705
- nextSequence()
706
- );
707
- if (event) {
708
- dispatch(event);
709
- bizRevDefect.value = '';
710
- }
711
  }
712
  }
713
 
714
  function handleBizDismantle() {
715
  if (!bizDismPart.value) return;
716
- const event = createDismantleEvent(
717
- bizDismPart.value,
718
- state.currentTime,
719
- nextSequence()
720
- );
721
- if (event) {
722
- dispatch(event);
723
- bizDismPart.value = '';
 
 
 
 
 
 
 
724
  }
 
725
  }
726
 
727
  function handleBizStore() {
728
  if (!bizStorePart.value || !bizStoreTarget.value) return;
729
- const event = createAssembleEvent(
730
- bizStoreTarget.value,
731
- bizStorePart.value,
732
- 'stored_at',
733
- state.currentTime,
734
- nextSequence()
735
- );
736
  if (event) dispatch(event);
737
  }
738
 
739
- // Resizer Handlers with active .dragging visual feedback
740
  function startResizeH(e) {
741
- const resizerEl = e.currentTarget;
742
- resizerEl?.classList.add('dragging');
743
- const startX = e.clientX;
744
- const startWidth = layout.leftWidth;
745
  const containerWidth = document.querySelector('.main-container').getBoundingClientRect().width;
746
-
747
  const onMouseMove = (evt) => {
748
  const newWidth = startWidth + ((evt.clientX - startX) / containerWidth) * 100;
749
  if (newWidth > 25 && newWidth < 78) layout.leftWidth = newWidth;
750
  };
751
-
752
  const onMouseUp = () => {
753
  resizerEl?.classList.remove('dragging');
754
- document.removeEventListener('mousemove', onMouseMove);
755
- document.removeEventListener('mouseup', onMouseUp);
756
  document.body.classList.remove('no-select');
757
  };
758
-
759
- document.addEventListener('mousemove', onMouseMove);
760
- document.addEventListener('mouseup', onMouseUp);
761
  document.body.classList.add('no-select');
762
  }
763
 
764
  function startResizeV(e, property, containerSelector) {
765
- const resizerEl = e.currentTarget;
766
- resizerEl?.classList.add('dragging');
767
- const startY = e.clientY;
768
- const startHeight = layout[property];
769
  const containerHeight = document.querySelector(containerSelector).getBoundingClientRect().height;
770
-
771
  const onMouseMove = (evt) => {
772
  const newHeight = startHeight + ((evt.clientY - startY) / containerHeight) * 100;
773
  if (newHeight > 12 && newHeight < 75) layout[property] = newHeight;
774
  };
775
-
776
  const onMouseUp = () => {
777
  resizerEl?.classList.remove('dragging');
778
- document.removeEventListener('mousemove', onMouseMove);
779
- document.removeEventListener('mouseup', onMouseUp);
780
  document.body.classList.remove('no-select');
781
  };
782
-
783
- document.addEventListener('mousemove', onMouseMove);
784
- document.addEventListener('mouseup', onMouseUp);
785
  document.body.classList.add('no-select');
786
  }
787
 
788
- // Full JSON State Export & Import
789
  function saveJson() {
790
  const exportData = {
791
- version: '2.0',
792
- savedAt: new Date().toISOString(),
793
- userRole: state.userRole,
794
- ontology: state.ontology,
795
- perspective: state.perspective,
796
- storage: state.storage,
797
- graphEngine: state.graphEngine,
798
- language: state.language,
799
- showHistory: state.showHistory,
800
- currentTime: state.currentTime,
801
- edgeSequence: state.edgeSequence,
802
  eventLog: JSON.parse(JSON.stringify(state.eventLog))
803
  };
804
  const blob = new Blob([JSON.stringify(exportData, null, 2)], { type: 'application/json' });
805
- const url = URL.createObjectURL(blob);
806
- const a = document.createElement('a');
807
- a.href = url;
808
  a.download = `workbench-state-t${state.currentTime}.json`;
809
- document.body.appendChild(a);
810
- a.click();
811
- document.body.removeChild(a);
812
- URL.revokeObjectURL(url);
813
- }
814
-
815
- function triggerLoadJson() {
816
- if (fileInput.value) {
817
- fileInput.value.value = '';
818
- fileInput.value.click();
819
- }
820
  }
821
 
 
822
  function onFileLoaded(e) {
823
- const file = e.target.files?.[0];
824
- if (!file) return;
825
-
826
  const reader = new FileReader();
827
  reader.onload = (event) => {
828
  try {
829
  const parsed = JSON.parse(event.target.result);
830
- if (Array.isArray(parsed)) {
831
- loadState({ eventLog: parsed });
832
- } else if (parsed && typeof parsed === 'object') {
833
- loadState(parsed);
834
- }
835
- nextTick(() => {
836
- renderGraph();
837
- });
838
- } catch (err) {
839
- console.error('Failed to parse state JSON:', err);
840
- alert('Invalid JSON file format.');
841
- }
842
  };
843
  reader.readAsText(file);
844
  }
845
 
846
  return {
847
- state, t, layout, advanceTime, setPerspective, dispatch,
848
- fileInput, saveJson, triggerLoadJson, onFileLoaded,
849
- entityClasses: ENTITY_CLASSES,
850
- relationTypes: RELATION_TYPES,
851
- availableNodes, goHome, launchScenario, activeScenarioId, activeAudioSrc,
852
- activeParts, activeWarehouses,
853
- bizRegType, bizRegId, handleBizRegister,
854
  bizInstSource, bizInstTarget, handleBizInstall, bizInstallSources, bizInstallTargets,
855
  bizDefTarget, bizDefType, bizDefVal, handleBizReportDefect,
856
  bizRevDefect, handleBizRevokeDefect, activeDefectsList,
857
  bizDismPart, handleBizDismantle, installedComponents,
 
858
  bizStorePart, bizStoreTarget, handleBizStore,
859
- bomTrees, lpgNodeRecords, lpgRecords, rdfTtl, formatProperties,
860
- queryCode, liveQueryResult,
861
- visContainer, mermaidContainer,
862
- graphCaption, graphLegendItems,
863
- startResizeH, startResizeV,
864
- scenarioAudio, isPlaying, audioCurrentTime, audioDuration,
865
- showSubtitles, currentSubtitleText,
866
- playAudio, pauseAudio, togglePlayAudio, stopAudio,
867
  onTimeUpdate, onLoadedMetadata, onAudioEnded, onSeek, formatTime
868
  };
869
  },
@@ -887,6 +694,11 @@ const App = {
887
  <span class="btn-sub-text">Guided walkthrough: from real-world queries to knowledge, live sandbox actions &amp; ontologies</span>
888
  </button>
889
 
 
 
 
 
 
890
  <button class="menu-btn menu-btn-scenario" @click="launchScenario('VANISHING_CRACK')">
891
  <span class="btn-main-text">Scenario: The Vanishing Crack</span>
892
  <span class="btn-sub-text">Guided demonstration of temporal defect tracing across lifecycle states</span>
@@ -895,9 +707,94 @@ const App = {
895
  </div>
896
  </div>
897
 
 
 
 
 
 
 
 
 
 
 
898
  <!-- Main Sandbox & Scenario Workspace -->
899
  <div v-if="state.currentView !== 'MENU'" class="sandbox-workspace">
900
  <div class="control-deck">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
901
  <!-- Tier 1: Unified Architecture & Perspective Controls -->
902
  <div class="deck-row deck-row-top">
903
  <div class="section-label">
@@ -913,7 +810,6 @@ const App = {
913
 
914
  <div class="divider"></div>
915
 
916
- <!-- Unified 4-Perspective Switcher (SMRM | SMIM | SMS_LPG | SMS_RDF) -->
917
  <div class="section-label">
918
  <span class="iec-badge">IEC 63339<span class="iec-tooltip" v-html="t.tooltips.sms"></span></span>
919
  <span>👁️ {{ t.viewTitle }}</span>
@@ -935,7 +831,6 @@ const App = {
935
 
936
  <div class="divider"></div>
937
 
938
- <!-- JSON State Operations -->
939
  <button id="ctrl-save-json" class="secondary" @click="saveJson" :title="t.saveBtn">{{ t.saveBtn }}</button>
940
  <button id="ctrl-load-json" class="secondary" @click="triggerLoadJson" :title="t.loadBtn">{{ t.loadBtn }}</button>
941
  <input ref="fileInput" type="file" accept=".json" style="display: none;" @change="onFileLoaded" />
@@ -949,17 +844,17 @@ const App = {
949
 
950
  <!-- Tier 2: Engineer Lifecycle Actions -->
951
  <template v-if="state.userRole === 'UNI_ENGINEER'">
952
- <!-- Row 1: Time, Register, Install, Dismantle -->
953
  <div class="deck-row">
954
  <span id="biz-time-badge" class="badge">T = {{ state.currentTime }}</span>
955
  <button id="biz-step-btn" @click="advanceTime">{{ t.stepBtn }}</button>
956
 
957
  <div class="divider"></div>
958
 
959
- <!-- Action 1: Register Entity -->
960
  <label class="action-label">1. Register:</label>
961
  <select id="biz-reg-type" v-model="bizRegType" title="Entity Class">
962
  <option value="Vehicle">Vehicle</option>
 
963
  <option value="Part">Part</option>
964
  <option value="Warehouse">Warehouse</option>
965
  </select>
@@ -968,7 +863,6 @@ const App = {
968
 
969
  <div class="divider"></div>
970
 
971
- <!-- Action 2: Install / Assemble -->
972
  <label class="action-label">2. Install:</label>
973
  <select id="biz-inst-source" v-model="bizInstSource" title="Component to install">
974
  <option v-for="node in bizInstallSources" :key="'src_' + node" :value="node">{{ node }}</option>
@@ -981,28 +875,33 @@ const App = {
981
 
982
  <div class="divider"></div>
983
 
984
- <!-- Action 5: Dismantle -->
985
  <label class="action-label">5. Dismantle:</label>
986
  <select id="biz-dism-part" v-model="bizDismPart">
987
  <option v-for="comp in installedComponents" :key="'comp_' + comp" :value="comp">{{ comp }}</option>
988
  </select>
989
  <button id="biz-dism-btn" class="danger" @click="handleBizDismantle">Dismantle</button>
 
 
 
 
 
 
 
 
990
  </div>
991
 
992
  <!-- Row 2: Defect, Revoke, Storage, History -->
993
  <div class="deck-row" style="border-top: 1px solid #f1f5f9; background: #fafafa;">
994
- <!-- Action 3: Report Defect -->
995
  <label class="action-label">3. Defect:</label>
996
  <select id="biz-def-target" v-model="bizDefTarget">
997
  <option v-for="node in availableNodes" :key="'dn_' + node" :value="node">{{ node }}</option>
998
  </select>
999
  <input id="biz-def-type" type="text" v-model="bizDefType" placeholder="Type (e.g. crack)" style="width: 110px;">
1000
- <input id="biz-def-val" type="text" v-model="bizDefVal" placeholder="Value (e.g. 2mm)" style="width: 85px;">
1001
  <button id="biz-def-btn" class="secondary" @click="handleBizReportDefect">Report Defect</button>
1002
 
1003
  <div class="divider"></div>
1004
 
1005
- <!-- Action 4: Revoke Defect -->
1006
  <label class="action-label">4. Revoke:</label>
1007
  <select id="biz-rev-defect" v-model="bizRevDefect">
1008
  <option v-for="d in activeDefectsList" :key="d.id" :value="d.id">{{ d.label }}</option>
@@ -1011,7 +910,6 @@ const App = {
1011
 
1012
  <div class="divider"></div>
1013
 
1014
- <!-- Action 6: Move to Storage -->
1015
  <label class="action-label">6. Storage:</label>
1016
  <select id="biz-store-part" v-model="bizStorePart">
1017
  <option v-for="part in activeParts" :key="'sp_' + part" :value="part">{{ part }}</option>
@@ -1024,7 +922,6 @@ const App = {
1024
 
1025
  <div class="divider"></div>
1026
 
1027
- <!-- History Checkbox -->
1028
  <label style="font-size: 11px; display: flex; align-items: center; gap: 4px; cursor: pointer;">
1029
  <input type="checkbox" v-model="state.showHistory"> {{ t.history }}
1030
  </label>
@@ -1037,13 +934,11 @@ const App = {
1037
  <div ref="visContainer" id="vis-container" v-show="state.graphEngine === 'VIS'"></div>
1038
  <div ref="mermaidContainer" id="mermaid-container" v-show="state.graphEngine === 'MERMAID'"></div>
1039
 
1040
- <!-- Dynamic Graph Caption Overlay -->
1041
  <div class="graph-caption">
1042
  <span>📌</span>
1043
  <span>{{ graphCaption }}</span>
1044
  </div>
1045
 
1046
- <!-- Contextual Dynamic Legend Overlay -->
1047
  <div class="graph-legend">
1048
  <div class="legend-title">
1049
  <span>{{ t.legend.title }}</span>
@@ -1065,7 +960,6 @@ const App = {
1065
  </div>
1066
  </div>
1067
 
1068
- <!-- Horizontal Resizer -->
1069
  <div class="resizer" id="panel-resizer" @mousedown="startResizeH"></div>
1070
 
1071
  <div class="sidebar" style="flex: 1;">
@@ -1100,7 +994,6 @@ const App = {
1100
  </h4>
1101
  <div id="storage-content" class="card-scroll-body">
1102
  <template v-if="state.storage === 'LPG'">
1103
- <!-- Node Store Table -->
1104
  <div class="store-sub-header">{{ t.nodeStoreTitle }} ({{ lpgNodeRecords.length }})</div>
1105
  <table v-if="lpgNodeRecords.length > 0" class="storage-table">
1106
  <thead>
@@ -1123,7 +1016,6 @@ const App = {
1123
  </table>
1124
  <div v-else class="empty-placeholder">0 nodes</div>
1125
 
1126
- <!-- Relationship Store Table -->
1127
  <div class="store-sub-header" style="margin-top: 8px;">{{ t.edgeStoreTitle }} ({{ lpgRecords.length }})</div>
1128
  <table v-if="lpgRecords.length > 0" class="storage-table">
1129
  <thead>
@@ -1165,7 +1057,6 @@ const App = {
1165
  <div id="query-content" class="card-scroll-body">
1166
  <pre class="code-block query-code-block" :style="{ color: state.ontology === 'BFO' ? '#0369a1' : '#3730a3' }">{{ queryCode }}</pre>
1167
 
1168
- <!-- Live Query Execution Result Box -->
1169
  <div class="query-result-box">
1170
  <div class="query-result-header">
1171
  <span>{{ t.queryResultTitle }}</span>
@@ -1176,7 +1067,16 @@ const App = {
1176
  {{ t.queryDefectsFound }} {{ liveQueryResult.defectiveCount }}
1177
  </span>
1178
  </div>
1179
- <table v-if="liveQueryResult.rows.length > 0" class="storage-table">
 
 
 
 
 
 
 
 
 
1180
  <thead>
1181
  <tr>
1182
  <th>part</th>
@@ -1213,7 +1113,7 @@ const App = {
1213
  @ended="onAudioEnded"
1214
  ></audio>
1215
 
1216
- <!-- Subtitles Overlay (Scenario Mode) -->
1217
  <div
1218
  v-if="state.currentView === 'SCENARIO' && showSubtitles && currentSubtitleText"
1219
  class="scenario-subtitles"
@@ -1221,7 +1121,7 @@ const App = {
1221
  {{ currentSubtitleText }}
1222
  </div>
1223
 
1224
- <!-- Floating Scenario Player Panel -->
1225
  <div
1226
  v-if="state.currentView === 'SCENARIO'"
1227
  class="scenario-player-panel"
@@ -1230,7 +1130,6 @@ const App = {
1230
  class="player-btn"
1231
  @click="togglePlayAudio"
1232
  :title="isPlaying ? 'Pause' : 'Play'"
1233
- :aria-label="isPlaying ? 'Pause' : 'Play'"
1234
  >
1235
  <span v-if="isPlaying">⏸</span>
1236
  <span v-else>▶</span>
@@ -1240,7 +1139,6 @@ const App = {
1240
  class="player-btn"
1241
  @click="stopAudio(true)"
1242
  title="Stop"
1243
- aria-label="Stop"
1244
  >
1245
  <span>⏹</span>
1246
  </button>
@@ -1253,7 +1151,6 @@ const App = {
1253
  step="0.1"
1254
  :value="audioCurrentTime"
1255
  @input="onSeek"
1256
- aria-label="Audio Timeline"
1257
  />
1258
 
1259
  <span class="player-time">{{ formatTime(audioCurrentTime) }} / {{ formatTime(audioDuration) }}</span>
@@ -1261,9 +1158,7 @@ const App = {
1261
  <button
1262
  class="player-btn player-btn-cc"
1263
  :class="{ active: showSubtitles }"
1264
- :title="showSubtitles ? 'Hide Subtitles' : 'Show Subtitles'"
1265
  @click="showSubtitles = !showSubtitles"
1266
- aria-label="Toggle Subtitles"
1267
  >
1268
  CC
1269
  </button>
@@ -1275,7 +1170,6 @@ const App = {
1275
  class="floating-home-btn"
1276
  @click="goHome"
1277
  title="Return to Main Menu"
1278
- aria-label="Return to Main Menu"
1279
  >
1280
  <svg viewBox="0 0 24 24" width="22" height="22" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round">
1281
  <path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
 
20
  import * as bfoAdapter from './smim/bfo.js';
21
  import * as isoAdapter from './smim/iso15926.js';
22
  import * as naiveAdapter from './smim/naive.js';
23
+ import { applyQdikwInference } from './smim/inference-engine.js';
24
  import { initVisNetwork, updateVisNetwork } from './renderers/vis-adapter.js';
25
  import { updateMermaidNetwork } from './renderers/mermaid-adapter.js';
26
  import { generateBomTrees } from './urmsm/bom-view.js';
 
43
  onSandboxTourTimeUpdate,
44
  resetSandboxTourTimeline
45
  } from './scenarios/scenario-sandbox-tour.js';
46
+ import {
47
+ qdikwScenario,
48
+ QDIKW_STAGE_TIMESTAMPS,
49
+ onQdikwTimeUpdate,
50
+ resetQdikwTimeline
51
+ } from './scenarios/scenario-qdikw.js';
52
 
 
 
 
 
 
 
53
  const BomNode = {
54
  name: 'BomNode',
55
  props: {
56
+ node: { type: Object, required: true }
 
 
 
57
  },
58
  template: `
59
  <li>
60
  <span class="bom-node-row">
61
  <strong>{{ node.id }}</strong>
62
  <span class="bom-class-badge">{{ node.entityClass }}</span>
63
+ <span v-for="def in (node.defects || [])" :key="def" class="bom-defect-badge">⚠️ {{ def }}</span>
 
 
 
 
64
  </span>
65
  <ul v-if="node.children && node.children.length > 0" class="tree">
66
+ <bom-node v-for="child in node.children" :key="child.id" :node="child" />
 
 
 
 
67
  </ul>
68
  </li>
69
  `
70
  };
71
 
72
  const App = {
73
+ components: { BomNode },
 
 
74
  setup() {
 
75
  const visContainer = ref(null);
76
  const mermaidContainer = ref(null);
77
  const fileInput = ref(null);
78
 
79
+ // Business UI inputs
80
  const bizRegType = ref('Part');
81
  const bizRegId = ref('');
82
  const bizInstSource = ref('');
 
86
  const bizDefVal = ref('');
87
  const bizRevDefect = ref('');
88
  const bizDismPart = ref('');
89
+ const bizDeleteNodeId = ref('');
90
  const bizStorePart = ref('');
91
  const bizStoreTarget = ref('');
92
 
93
+ // Scenario Player State
94
+ const activeScenarioId = ref('QDIKW_PIPELINE');
95
  const scenarioAudio = ref(null);
96
  const isPlaying = ref(false);
97
  const audioCurrentTime = ref(0);
 
101
  let virtualTimerInterval = null;
102
  const usingVirtualTimer = ref(false);
103
 
104
+ const activeScenarioObj = computed(() => {
105
+ if (activeScenarioId.value === 'SANDBOX_TOUR') return sandboxTourScenario;
106
+ if (activeScenarioId.value === 'QDIKW_PIPELINE') return qdikwScenario;
107
+ return vanishingCrackScenario;
108
+ });
109
 
110
+ const activeAudioSrc = computed(() => activeScenarioObj.value.audioSrc);
 
 
 
 
111
 
 
112
  const layout = reactive({ leftWidth: 64, bomHeight: 24, storageHeight: 42 });
 
 
113
  const t = computed(() => i18n[state.language] || i18n.en);
114
 
 
115
  const baseNodes = computed(() => {
116
  const nodeMap = new Map();
 
117
  state.eventLog.forEach(event => {
118
  if (event.valid_from !== undefined && event.valid_from > state.currentTime) return;
 
119
  if (event.type === 'REGISTER_PART' && event.partId) {
120
  const cls = inferEntityClass(event.partId, event.entityClass);
121
+ nodeMap.set(event.partId, { id: event.partId, label: event.partId, type: cls, entityClass: cls });
 
 
 
 
 
122
  } else if (event.type === 'ASSEMBLE') {
123
  if (event.parentId && !nodeMap.has(event.parentId)) {
124
  const pCls = inferEntityClass(event.parentId);
125
+ nodeMap.set(event.parentId, { id: event.parentId, label: event.parentId, type: pCls, entityClass: pCls });
 
 
 
 
 
126
  }
127
  if (event.childId && !nodeMap.has(event.childId)) {
128
  const cCls = inferEntityClass(event.childId);
129
+ nodeMap.set(event.childId, { id: event.childId, label: event.childId, type: cCls, entityClass: cCls });
 
 
 
 
 
130
  }
131
  }
132
  });
 
133
  return Array.from(nodeMap.values());
134
  });
135
 
136
  const availableNodes = computed(() => baseNodes.value.map(n => n.id));
137
+ const activeParts = computed(() => baseNodes.value.filter(n => n.entityClass !== 'Slot' && n.entityClass !== 'Warehouse').map(n => n.id));
138
+ const activeWarehouses = computed(() => baseNodes.value.filter(n => n.entityClass === 'Warehouse').map(n => n.id));
139
+ const bizInstallSources = computed(() => baseNodes.value.filter(n => n.entityClass === 'Part').map(n => n.id));
140
+ const bizInstallTargets = computed(() => baseNodes.value.filter(n => n.entityClass === 'Vehicle' || n.entityClass === 'Part' || n.entityClass === 'Slot').map(n => n.id));
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  function dispatch(event) {
143
  if (!event) return;
144
  state.eventLog.push(event);
145
  }
146
 
 
147
  const semanticGraph = computed(() => {
148
+ const opts = { ontology: state.ontology, showHistory: state.showHistory };
149
+ let rawGraph;
 
 
 
150
  if (state.ontology === 'BFO') {
151
+ rawGraph = bfoAdapter.generateSemanticGraph(state.eventLog, baseNodes.value, state.currentTime, opts);
152
+ } else if (state.ontology === 'ISO15926') {
153
+ rawGraph = isoAdapter.generateSemanticGraph(state.eventLog, baseNodes.value, state.currentTime, opts);
154
+ } else {
155
+ rawGraph = naiveAdapter.generateSemanticGraph(state.eventLog, baseNodes.value, state.currentTime, opts);
156
  }
157
+ return applyQdikwInference(rawGraph, state);
158
  });
159
 
 
160
  const smrmReducedGraph = computed(() => reduceGraphForSMRM(semanticGraph.value));
161
 
162
  const installedComponents = computed(() => {
163
  const comps = new Set();
164
  smrmReducedGraph.value.edges.forEach(e => {
165
  if (e.properties?.isCurrent === false) return;
166
+ if (e.label === 'has_part') comps.add(e.to);
167
+ else if (e.label === 'mounted_in' || e.label === 'stored_at') comps.add(e.from);
 
 
 
168
  });
169
  return Array.from(comps).filter(id => !id.startsWith('Slot_'));
170
  });
171
 
 
172
  const activeDefectsList = computed(() => {
173
  const activeMap = new Map();
 
174
  state.eventLog.forEach((e, index) => {
175
  if (e.valid_from !== undefined && e.valid_from > state.currentTime) return;
 
176
  if (e.type === 'REPORT_DEFECT') {
177
  if (e.valid_to !== null && e.valid_to !== undefined && e.valid_to <= state.currentTime) return;
178
  const key = `${e.targetId}::${e.defectName}`;
 
189
  activeMap.delete(key);
190
  }
191
  });
 
192
  return Array.from(activeMap.values());
193
  });
194
 
195
+ watch(bizInstallSources, (sources) => { if (!sources.includes(bizInstSource.value)) bizInstSource.value = sources[0] || ''; }, { immediate: true });
196
+ watch(bizInstallTargets, (targets) => { if (!targets.includes(bizInstTarget.value)) bizInstTarget.value = targets[0] || ''; }, { immediate: true });
197
+ watch(activeParts, (parts) => { if (!parts.includes(bizStorePart.value)) bizStorePart.value = parts[0] || ''; }, { immediate: true });
198
+ watch(activeWarehouses, (warehouses) => { if (!warehouses.includes(bizStoreTarget.value)) bizStoreTarget.value = warehouses[0] || ''; }, { immediate: true });
199
+ watch(installedComponents, (comps) => { if (!comps.includes(bizDismPart.value)) bizDismPart.value = comps[0] || ''; }, { immediate: true });
200
+ watch(activeDefectsList, (defects) => { if (!defects.some(d => d.id === bizRevDefect.value)) bizRevDefect.value = defects[0]?.id || ''; }, { immediate: true });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  watch(availableNodes, (nodes) => {
202
  if (!nodes.includes(bizDefTarget.value)) bizDefTarget.value = nodes[0] || '';
203
+ if (!nodes.includes(bizDeleteNodeId.value)) bizDeleteNodeId.value = nodes[0] || '';
204
  }, { immediate: true });
205
 
 
206
  const bomTrees = computed(() => generateBomTrees(semanticGraph.value));
207
+ const lpgNodeRecords = computed(() => state.storage === 'LPG' ? generateLpgNodeStorage(semanticGraph.value) : []);
208
+ const lpgRecords = computed(() => state.storage === 'LPG' ? generateLpgStorage(semanticGraph.value) : []);
209
+ const rdfTtl = computed(() => state.storage === 'RDF' ? generateRdfStorage(semanticGraph.value) : '');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
 
211
  function formatProperties(props) {
212
  if (!props) return '';
213
  const entries = Object.entries(props).filter(
214
  ([key, val]) => !INTERNAL_PROPERTY_KEYS.includes(key) || key === 'validFrom' || key === 'validTo' || key === 'atTime'
215
+ ? (key !== 'isCurrent' && val !== undefined) : false
 
216
  );
217
  if (entries.length === 0) return '';
218
  return entries.map(([k, v]) => {
 
222
  }
223
 
224
  const queryCode = computed(() => {
225
+ if (state.storage === 'LPG') return generateLpgQuery(semanticGraph.value, state.currentTime, state.ontology);
 
 
226
  return generateRdfQuery(semanticGraph.value, state.currentTime, state.ontology);
227
  });
228
 
229
+ const liveQueryResult = computed(() => evaluateLiveQuery(semanticGraph.value, state.currentTime, state.ontology));
 
 
230
 
 
231
  const activeGraph = computed(() => {
232
+ if (state.perspective === 'SMS_LPG') return generatePhysicalGraph(semanticGraph.value, 'LPG');
233
+ if (state.perspective === 'SMS_RDF') return generatePhysicalGraph(semanticGraph.value, 'RDF');
234
+ if (state.perspective === 'SMRM') return smrmReducedGraph.value;
 
 
 
 
 
 
235
  return semanticGraph.value;
236
  });
237
 
 
238
  const graphCaption = computed(() => {
239
  let ontoText = 'BFO (3D)';
240
  if (state.ontology === 'ISO15926') ontoText = 'ISO 15926 (4D)';
241
  if (state.ontology === 'NAIVE_NODE') ontoText = t.value.ontoNaiveNode;
242
  if (state.ontology === 'NAIVE_EDGE') ontoText = t.value.ontoNaiveEdge;
 
243
  let viewText = t.value.viewLogicalCaption;
244
  if (state.perspective === 'SMRM') viewText = t.value.viewSmrmCaption;
245
  if (state.perspective === 'SMS_LPG') viewText = t.value.viewPhysicalLpgCaption;
246
  if (state.perspective === 'SMS_RDF') viewText = t.value.viewPhysicalRdfCaption;
 
247
  return `${ontoText} | ${viewText}`;
248
  });
249
 
 
250
  const graphLegendItems = computed(() => {
251
+ const nodes = []; const edges = []; const dict = t.value.legend;
 
 
 
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' });
 
 
255
  nodes.push({ id: 'naivePart', label: dict.naivePart, swatch: 'swatch-box-part' });
256
  nodes.push({ id: 'naiveDefect', label: dict.naiveDefect, swatch: 'swatch-diamond-defect' });
257
  nodes.push({ id: 'naiveWarehouse', label: dict.naiveWarehouse, swatch: 'swatch-box-warehouse' });
 
258
  if (state.perspective === 'SMS_RDF') {
259
  nodes.push({ id: 'rdfStmt', label: dict.rdfStmt, swatch: 'swatch-diamond' });
260
  nodes.push({ id: 'rdfLit', label: dict.rdfLit, swatch: 'swatch-literal' });
261
  edges.push({ id: 'rdfPred', label: dict.rdfPred, swatch: 'swatch-line-past' });
262
  } else {
263
+ if (state.perspective !== 'SMRM') edges.push({ id: 'relHasSlot', label: dict.relHasSlot, swatch: 'swatch-line-slot' });
 
 
264
  edges.push({ id: 'relMountedIn', label: dict.relMountedIn, swatch: 'swatch-line-mount' });
265
  edges.push({ id: 'relStoredAt', label: dict.relStoredAt, swatch: 'swatch-line-store' });
266
  edges.push({ id: 'relHasDefect', label: dict.relHasDefect, swatch: 'swatch-line-defect' });
 
268
  } else if (state.ontology === 'BFO') {
269
  nodes.push({ id: 'bfoSys', label: dict.bfoSys, swatch: 'swatch-box-sys' });
270
  nodes.push({ id: 'bfoElem', label: dict.bfoElem, swatch: 'swatch-box-elem' });
271
+ nodes.push({ id: 'bfoSlot', label: 'BFO:Site (Functional Slot)', swatch: 'swatch-box-slot' });
272
  nodes.push({ id: 'bfoQuality', label: dict.bfoQuality, swatch: 'swatch-diamond' });
 
273
  if (state.perspective === 'SMS_RDF') {
274
  nodes.push({ id: 'rdfStmt', label: dict.rdfStmt, swatch: 'swatch-diamond' });
275
  nodes.push({ id: 'rdfLit', label: dict.rdfLit, swatch: 'swatch-literal' });
 
277
  } else {
278
  edges.push({ id: 'bfoActive', label: dict.bfoActiveEdge, swatch: 'swatch-line-active' });
279
  edges.push({ id: 'bfoInheres', label: dict.bfoInheres, swatch: 'swatch-line-transition' });
280
+ if (state.showHistory) edges.push({ id: 'bfoPast', label: dict.bfoPastEdge, swatch: 'swatch-line-past' });
 
 
281
  }
282
  } else {
283
  nodes.push({ id: 'iso4d', label: dict.iso4d, swatch: 'swatch-box-4d' });
284
  nodes.push({ id: 'isoState', label: dict.isoState, swatch: 'swatch-box-state' });
285
  nodes.push({ id: 'isoDefect', label: dict.isoDefect, swatch: 'swatch-diamond-defect' });
286
+ if (state.perspective === 'SMS_RDF') nodes.push({ id: 'rdfLit', label: dict.rdfLit, swatch: 'swatch-literal' });
 
 
287
  edges.push({ id: 'isoPart', label: dict.isoPartRel, swatch: 'swatch-line-active' });
288
  edges.push({ id: 'isoSlice', label: dict.isoSliceRel, swatch: 'swatch-line-past' });
289
  edges.push({ id: 'isoDefectRel', label: dict.isoDefectRel, swatch: 'swatch-line-defect' });
290
+ if (state.perspective === 'SMS_LPG') edges.push({ id: 'isoTrans', label: dict.isoTransitionRel, swatch: 'swatch-line-transition' });
 
 
 
291
  }
 
292
  return { nodes, edges };
293
  });
294
 
295
+ watch([activeGraph, () => state.graphEngine], () => { renderGraph(); }, { deep: true });
 
 
 
296
 
297
  function renderGraph() {
298
  if (state.currentView === 'MENU') return;
 
309
  state.eventLog.splice(0, state.eventLog.length);
310
  state.currentTime = 0;
311
  state.edgeSequence = 1;
312
+ state.qdikw.active = false;
313
+ state.figureOverlay.visible = false;
314
  dispatch(createRegisterPartEvent('System_A', 0, 'Vehicle', nextSequence()));
315
  dispatch(createRegisterPartEvent('SubAssembly_1', 0, 'Part', nextSequence()));
316
  dispatch(createAssembleEvent('System_A', 'SubAssembly_1', 'mounted_in', 0, nextSequence()));
 
326
  state.eventLog.splice(0, state.eventLog.length);
327
  state.currentTime = 0;
328
  state.ontology = 'NAIVE_NODE';
329
+ state.qdikw.active = false;
330
+ state.figureOverlay.visible = false;
331
 
332
  if (activeScenarioId.value === 'SANDBOX_TOUR') {
333
  resetSandboxTourTimeline(0);
334
  setPerspective('SMRM');
335
+ state.graphEngine = 'MERMAID';
336
  audioDuration.value = sandboxTourScenario.fallbackDuration;
337
  onSandboxTourTimeUpdate(0, state, renderGraph);
338
+ } else if (activeScenarioId.value === 'QDIKW_PIPELINE') {
339
+ resetQdikwTimeline(0);
340
+ setPerspective('SMRM');
341
+ state.graphEngine = 'MERMAID';
342
+ audioDuration.value = qdikwScenario.fallbackDuration;
343
+ onQdikwTimeUpdate(0, state, renderGraph, null);
344
  } else {
345
  resetVanishingCrackTimeline(0);
346
  setPerspective('SMIM');
 
351
  function launchScenario(scenarioId) {
352
  activeScenarioId.value = scenarioId;
353
  stopAudio(false);
354
+ if (state.currentView === 'SCENARIO') {
355
  resetActiveScenarioState();
356
  nextTick(() => renderGraph());
357
  } else {
 
359
  }
360
  }
361
 
362
+ /**
363
+ * Interactive Chapter Navigation for Q-D-I-K-W Pills
364
+ */
365
+ function jumpToQdikwStage(stageKey) {
366
+ const targetTime = QDIKW_STAGE_TIMESTAMPS[stageKey];
367
+ if (targetTime === undefined) return;
368
+ if (scenarioAudio.value && !usingVirtualTimer.value) {
369
+ scenarioAudio.value.currentTime = targetTime;
370
  }
371
+ audioCurrentTime.value = targetTime;
372
+ resetActiveScenarioState();
373
+ processTimelineAt(targetTime);
374
+ }
375
+
376
+ function toggleSlotRegime() {
377
+ if (!state.qdikw.slotMetadata.SLOT_FRONT_SUSPENSION) {
378
+ state.qdikw.slotMetadata.SLOT_FRONT_SUSPENSION = {
379
+ loadRegime: 'DYNAMIC_CYCLIC',
380
+ safetyFunction: 'STEERING_CONTROL'
381
+ };
382
+ } else {
383
+ const cur = state.qdikw.slotMetadata.SLOT_FRONT_SUSPENSION.loadRegime;
384
+ state.qdikw.slotMetadata.SLOT_FRONT_SUSPENSION.loadRegime =
385
+ cur === 'DYNAMIC_CYCLIC' ? 'STATIC_LOAD' : 'DYNAMIC_CYCLIC';
386
+ }
387
+ renderGraph();
388
+ }
389
+
390
+ watch(() => state.currentView, async (newView) => {
391
+ if (newView !== 'SCENARIO') stopAudio(false);
392
  if (newView === 'SCENARIO') {
393
  resetActiveScenarioState();
394
  } else if (newView === 'SANDBOX' && state.eventLog.length === 0) {
 
396
  }
397
  if (newView !== 'MENU') {
398
  await nextTick();
399
+ if (visContainer.value) initVisNetwork(visContainer.value);
 
 
400
  renderGraph();
401
  }
402
  });
 
410
  });
411
 
412
  function clearVirtualTimer() {
413
+ if (virtualTimerInterval) { clearInterval(virtualTimerInterval); virtualTimerInterval = null; }
 
 
 
414
  }
415
 
416
  function startVirtualTimer() {
417
  clearVirtualTimer();
418
  usingVirtualTimer.value = true;
419
  isPlaying.value = true;
420
+ if (!audioDuration.value) audioDuration.value = activeScenarioObj.value.fallbackDuration || 108;
421
+
 
422
  virtualTimerInterval = setInterval(() => {
423
  if (audioCurrentTime.value < audioDuration.value) {
424
  audioCurrentTime.value = Math.min(audioDuration.value, audioCurrentTime.value + 0.25);
 
433
  function goHome() {
434
  stopAudio(false);
435
  state.currentView = 'MENU';
436
+ state.qdikw.active = false;
437
+ state.figureOverlay.visible = false;
438
  state.eventLog.splice(0, state.eventLog.length);
439
  state.currentTime = 0;
440
  state.edgeSequence = 1;
441
  }
442
 
443
  function playAudio() {
444
+ if (usingVirtualTimer.value) { startVirtualTimer(); return; }
 
 
 
445
  if (scenarioAudio.value) {
446
+ scenarioAudio.value.play().catch(() => { startVirtualTimer(); });
 
 
 
447
  } else {
448
  startVirtualTimer();
449
  }
 
452
  function pauseAudio() {
453
  clearVirtualTimer();
454
  isPlaying.value = false;
455
+ if (scenarioAudio.value && !usingVirtualTimer.value) scenarioAudio.value.pause();
 
 
456
  }
457
 
458
  function togglePlayAudio() {
459
+ if (isPlaying.value) pauseAudio(); else playAudio();
 
 
 
 
460
  }
461
 
462
  function stopAudio(resetScenarioGraph = true) {
 
469
  isPlaying.value = false;
470
  audioCurrentTime.value = 0;
471
  currentSubtitleText.value = '';
472
+
473
+ if (activeScenarioId.value === 'SANDBOX_TOUR') resetSandboxTourTimeline(0);
474
+ else if (activeScenarioId.value === 'QDIKW_PIPELINE') resetQdikwTimeline(0);
475
 
476
  if (resetScenarioGraph) {
477
  resetActiveScenarioState();
478
+ nextTick(() => { renderGraph(); });
 
 
479
  }
480
  }
481
 
482
  function processTimelineAt(currentTime) {
483
  const scenario = activeScenarioObj.value;
484
+ const activeSubtitle = scenario.subtitles.find(sub => currentTime >= sub.start && currentTime <= sub.end);
 
 
485
  currentSubtitleText.value = activeSubtitle ? activeSubtitle.text : '';
486
 
487
+ const uiRefs = {
488
+ bizRegType, bizRegId, bizInstSource, bizInstTarget, bizDefTarget, bizDefType, bizDefVal
489
+ };
490
+
491
  if (activeScenarioId.value === 'SANDBOX_TOUR') {
492
  onSandboxTourTimeUpdate(currentTime, state, renderGraph);
493
+ } else if (activeScenarioId.value === 'QDIKW_PIPELINE') {
494
+ onQdikwTimeUpdate(currentTime, state, renderGraph, uiRefs);
495
  } else {
496
  dispatchVanishingCrackTimeline(currentTime, state, renderGraph);
497
  }
 
499
 
500
  function onTimeUpdate() {
501
  if (usingVirtualTimer.value) return;
502
+ if (scenarioAudio.value) audioCurrentTime.value = scenarioAudio.value.currentTime;
 
 
503
  processTimelineAt(audioCurrentTime.value);
504
  }
505
 
 
518
 
519
  function onSeek(event) {
520
  const targetTime = parseFloat(event.target.value);
521
+ if (scenarioAudio.value && !usingVirtualTimer.value) scenarioAudio.value.currentTime = targetTime;
 
 
522
  audioCurrentTime.value = targetTime;
 
523
  resetActiveScenarioState();
524
  processTimelineAt(targetTime);
525
  }
 
531
  return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
532
  }
533
 
 
534
  function handleBizRegister() {
535
  if (!bizRegId.value) return;
536
+ const event = createRegisterPartEvent(bizRegId.value, state.currentTime, bizRegType.value, nextSequence());
537
+ if (event) { dispatch(event); bizRegId.value = ''; }
 
 
 
 
 
 
 
 
538
  }
539
 
540
  function handleBizInstall() {
541
  if (!bizInstSource.value || !bizInstTarget.value) return;
542
  if (bizInstSource.value === bizInstTarget.value) return;
543
+ // Automatically dismantle from warehouse/previous location before installing
544
+ if (installedComponents.value.includes(bizInstSource.value)) {
545
+ dispatch(createDismantleEvent(bizInstSource.value, state.currentTime, nextSequence()));
546
+ }
547
+ const event = createAssembleEvent(bizInstTarget.value, bizInstSource.value, 'mounted_in', state.currentTime, nextSequence());
 
 
 
548
  if (event) dispatch(event);
549
  }
550
 
551
  function handleBizReportDefect() {
552
  if (!bizDefTarget.value || !bizDefType.value) return;
553
+ const event = createReportDefectEvent(bizDefTarget.value, bizDefType.value, bizDefVal.value || 'present', state.currentTime, nextSequence());
554
+ if (event) { dispatch(event); bizDefType.value = ''; bizDefVal.value = ''; }
 
 
 
 
 
 
 
 
 
 
555
  }
556
 
557
  function handleBizRevokeDefect() {
558
  if (!bizRevDefect.value) return;
559
  const item = activeDefectsList.value.find(d => d.id === bizRevDefect.value);
560
  if (item) {
561
+ const event = createRevokeDefectEvent(item.targetId, item.defectName, state.currentTime, item.id, nextSequence());
562
+ if (event) { dispatch(event); bizRevDefect.value = ''; }
 
 
 
 
 
 
 
 
 
563
  }
564
  }
565
 
566
  function handleBizDismantle() {
567
  if (!bizDismPart.value) return;
568
+ const event = createDismantleEvent(bizDismPart.value, state.currentTime, nextSequence());
569
+ if (event) { dispatch(event); bizDismPart.value = ''; }
570
+ }
571
+
572
+ /**
573
+ * Completely deletes a node and its associated events from the repository (Point 9)
574
+ */
575
+ function handleBizDeleteNode() {
576
+ const target = bizDeleteNodeId.value;
577
+ if (!target) return;
578
+ for (let i = state.eventLog.length - 1; i >= 0; i--) {
579
+ const ev = state.eventLog[i];
580
+ if (ev.partId === target || ev.parentId === target || ev.childId === target || ev.targetId === target) {
581
+ state.eventLog.splice(i, 1);
582
+ }
583
  }
584
+ renderGraph();
585
  }
586
 
587
  function handleBizStore() {
588
  if (!bizStorePart.value || !bizStoreTarget.value) return;
589
+ if (installedComponents.value.includes(bizStorePart.value)) {
590
+ dispatch(createDismantleEvent(bizStorePart.value, state.currentTime, nextSequence()));
591
+ }
592
+ const event = createAssembleEvent(bizStoreTarget.value, bizStorePart.value, 'stored_at', state.currentTime, nextSequence());
 
 
 
593
  if (event) dispatch(event);
594
  }
595
 
 
596
  function startResizeH(e) {
597
+ const resizerEl = e.currentTarget; resizerEl?.classList.add('dragging');
598
+ const startX = e.clientX; const startWidth = layout.leftWidth;
 
 
599
  const containerWidth = document.querySelector('.main-container').getBoundingClientRect().width;
 
600
  const onMouseMove = (evt) => {
601
  const newWidth = startWidth + ((evt.clientX - startX) / containerWidth) * 100;
602
  if (newWidth > 25 && newWidth < 78) layout.leftWidth = newWidth;
603
  };
 
604
  const onMouseUp = () => {
605
  resizerEl?.classList.remove('dragging');
606
+ document.removeEventListener('mousemove', onMouseMove); document.removeEventListener('mouseup', onMouseUp);
 
607
  document.body.classList.remove('no-select');
608
  };
609
+ document.addEventListener('mousemove', onMouseMove); document.addEventListener('mouseup', onMouseUp);
 
 
610
  document.body.classList.add('no-select');
611
  }
612
 
613
  function startResizeV(e, property, containerSelector) {
614
+ const resizerEl = e.currentTarget; resizerEl?.classList.add('dragging');
615
+ const startY = e.clientY; const startHeight = layout[property];
 
 
616
  const containerHeight = document.querySelector(containerSelector).getBoundingClientRect().height;
 
617
  const onMouseMove = (evt) => {
618
  const newHeight = startHeight + ((evt.clientY - startY) / containerHeight) * 100;
619
  if (newHeight > 12 && newHeight < 75) layout[property] = newHeight;
620
  };
 
621
  const onMouseUp = () => {
622
  resizerEl?.classList.remove('dragging');
623
+ document.removeEventListener('mousemove', onMouseMove); document.removeEventListener('mouseup', onMouseUp);
 
624
  document.body.classList.remove('no-select');
625
  };
626
+ document.addEventListener('mousemove', onMouseMove); document.addEventListener('mouseup', onMouseUp);
 
 
627
  document.body.classList.add('no-select');
628
  }
629
 
 
630
  function saveJson() {
631
  const exportData = {
632
+ version: '2.0', savedAt: new Date().toISOString(), userRole: state.userRole, ontology: state.ontology,
633
+ perspective: state.perspective, storage: state.storage, graphEngine: state.graphEngine, language: state.language,
634
+ showHistory: state.showHistory, currentTime: state.currentTime, edgeSequence: state.edgeSequence,
 
 
 
 
 
 
 
 
635
  eventLog: JSON.parse(JSON.stringify(state.eventLog))
636
  };
637
  const blob = new Blob([JSON.stringify(exportData, null, 2)], { type: 'application/json' });
638
+ const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url;
 
 
639
  a.download = `workbench-state-t${state.currentTime}.json`;
640
+ document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url);
 
 
 
 
 
 
 
 
 
 
641
  }
642
 
643
+ function triggerLoadJson() { if (fileInput.value) { fileInput.value.value = ''; fileInput.value.click(); } }
644
  function onFileLoaded(e) {
645
+ const file = e.target.files?.[0]; if (!file) return;
 
 
646
  const reader = new FileReader();
647
  reader.onload = (event) => {
648
  try {
649
  const parsed = JSON.parse(event.target.result);
650
+ if (Array.isArray(parsed)) loadState({ eventLog: parsed });
651
+ else if (parsed && typeof parsed === 'object') loadState(parsed);
652
+ nextTick(() => { renderGraph(); });
653
+ } catch (err) { console.error('Failed to parse state JSON:', err); alert('Invalid JSON file format.'); }
 
 
 
 
 
 
 
 
654
  };
655
  reader.readAsText(file);
656
  }
657
 
658
  return {
659
+ state, t, layout, advanceTime, setPerspective, dispatch, semanticGraph,
660
+ fileInput, saveJson, triggerLoadJson, onFileLoaded, renderGraph,
661
+ entityClasses: ENTITY_CLASSES, relationTypes: RELATION_TYPES, availableNodes, goHome,
662
+ launchScenario, jumpToQdikwStage, toggleSlotRegime, activeScenarioId, activeAudioSrc,
663
+ activeParts, activeWarehouses, bizRegType, bizRegId, handleBizRegister,
 
 
664
  bizInstSource, bizInstTarget, handleBizInstall, bizInstallSources, bizInstallTargets,
665
  bizDefTarget, bizDefType, bizDefVal, handleBizReportDefect,
666
  bizRevDefect, handleBizRevokeDefect, activeDefectsList,
667
  bizDismPart, handleBizDismantle, installedComponents,
668
+ bizDeleteNodeId, handleBizDeleteNode,
669
  bizStorePart, bizStoreTarget, handleBizStore,
670
+ bomTrees, lpgNodeRecords, lpgRecords, rdfTtl, formatProperties, queryCode, liveQueryResult,
671
+ visContainer, mermaidContainer, graphCaption, graphLegendItems,
672
+ startResizeH, startResizeV, scenarioAudio, isPlaying, audioCurrentTime, audioDuration,
673
+ showSubtitles, currentSubtitleText, playAudio, pauseAudio, togglePlayAudio, stopAudio,
 
 
 
 
674
  onTimeUpdate, onLoadedMetadata, onAudioEnded, onSeek, formatTime
675
  };
676
  },
 
694
  <span class="btn-sub-text">Guided walkthrough: from real-world queries to knowledge, live sandbox actions &amp; ontologies</span>
695
  </button>
696
 
697
+ <button class="menu-btn menu-btn-scenario" @click="launchScenario('QDIKW_PIPELINE')">
698
+ <span class="btn-main-text">🧠 The Q-D-I-K-W Pipeline (Roles &amp; Rules)</span>
699
+ <span class="btn-sub-text">From Question to Wisdom: Explaining role separation, modular inference &amp; blind spots</span>
700
+ </button>
701
+
702
  <button class="menu-btn menu-btn-scenario" @click="launchScenario('VANISHING_CRACK')">
703
  <span class="btn-main-text">Scenario: The Vanishing Crack</span>
704
  <span class="btn-sub-text">Guided demonstration of temporal defect tracing across lifecycle states</span>
 
707
  </div>
708
  </div>
709
 
710
+ <!-- Fullscreen Narrative Figure Overlay -->
711
+ <div v-if="state.figureOverlay?.visible" class="figure-modal-overlay">
712
+ <div class="figure-modal-card">
713
+ <button class="figure-modal-close" @click="state.figureOverlay.visible = false">Close</button>
714
+ <img :src="state.figureOverlay.src" class="figure-modal-img" alt="Narrative Figure" />
715
+ <div class="figure-modal-caption">{{ state.figureOverlay.caption }}</div>
716
+ <div class="figure-modal-attribution" v-html="state.figureOverlay.attributionHtml"></div>
717
+ </div>
718
+ </div>
719
+
720
  <!-- Main Sandbox & Scenario Workspace -->
721
  <div v-if="state.currentView !== 'MENU'" class="sandbox-workspace">
722
  <div class="control-deck">
723
+
724
+ <!-- QDIKW Stage & Role Banner (Clickable Chapter Navigation!) -->
725
+ <div id="qdikw-stage-bar" v-if="state.qdikw?.active" class="qdikw-banner">
726
+ <div class="qdikw-steps">
727
+ <span
728
+ id="qdikw-step-Q"
729
+ class="qdikw-step-pill"
730
+ :class="{active: state.qdikw.stage === 'Q' || state.qdikw.stage === 'INTRO'}"
731
+ title="Click to jump to Stage 1: Question (01:02)"
732
+ @click="jumpToQdikwStage('Q')"
733
+ >Q - Question</span>
734
+ <span
735
+ id="qdikw-step-D"
736
+ class="qdikw-step-pill"
737
+ :class="{active: state.qdikw.stage === 'D'}"
738
+ title="Click to jump to Stage 2: Data (02:08)"
739
+ @click="jumpToQdikwStage('D')"
740
+ >D - Data</span>
741
+ <span
742
+ id="qdikw-step-I"
743
+ class="qdikw-step-pill"
744
+ :class="{active: state.qdikw.stage === 'I'}"
745
+ title="Click to jump to Stage 3: Information (03:09)"
746
+ @click="jumpToQdikwStage('I')"
747
+ >I - Information</span>
748
+ <span
749
+ id="qdikw-step-K"
750
+ class="qdikw-step-pill"
751
+ :class="{active: state.qdikw.stage === 'K'}"
752
+ title="Click to jump to Stage 4: Knowledge (04:56)"
753
+ @click="jumpToQdikwStage('K')"
754
+ >K - Knowledge</span>
755
+ <span
756
+ id="qdikw-step-W"
757
+ class="qdikw-step-pill"
758
+ :class="{active: state.qdikw.stage === 'W'}"
759
+ title="Click to jump to Stage 5: Wisdom (06:33)"
760
+ @click="jumpToQdikwStage('W')"
761
+ >W - Wisdom</span>
762
+ </div>
763
+ <div class="qdikw-role-box" v-if="state.qdikw.activeRole">
764
+ <span class="qdikw-role-name">{{ state.qdikw.activeRole }}</span>
765
+ <span class="qdikw-role-desc">{{ state.qdikw.roleBadge }}</span>
766
+ </div>
767
+ </div>
768
+
769
+ <!-- Semantic Rules Toolbar (Interactive checkboxes) -->
770
+ <div id="qdikw-rules-bar" v-if="state.qdikw?.active" class="smrm-rules-row">
771
+ <span style="color:#4c1d95; font-weight:700; margin-right: 8px;">🧠 SMRM Rules:</span>
772
+ <label id="qdikw-rule-1" class="rule-chip" :class="{active: state.qdikw.rules.rule1}">
773
+ <input type="checkbox" v-model="state.qdikw.rules.rule1" @change="renderGraph" style="display:none;">
774
+ [1] Context Inheritance (Slot &rarr; Stress)
775
+ </label>
776
+ <label id="qdikw-rule-2" class="rule-chip" :class="{active: state.qdikw.rules.rule2}">
777
+ <input type="checkbox" v-model="state.qdikw.rules.rule2" @change="renderGraph" style="display:none;">
778
+ [2] Material Physics (Crack &gt; 10mm &rarr; Fracture)
779
+ </label>
780
+ <label id="qdikw-rule-3" class="rule-chip" :class="{active: state.qdikw.rules.rule3}">
781
+ <input type="checkbox" v-model="state.qdikw.rules.rule3" @change="renderGraph" style="display:none;">
782
+ [3] Functional Safety (Fracture &rarr; Loss of Control)
783
+ </label>
784
+
785
+ <div id="qdikw-slot-config" style="margin-left: auto; display: flex; gap: 8px; align-items: center;">
786
+ <span style="font-weight: 600;">Suspension Slot Regime:</span>
787
+ <button
788
+ class="rule-chip"
789
+ :class="{active: state.qdikw.slotMetadata?.SLOT_FRONT_SUSPENSION?.loadRegime === 'DYNAMIC_CYCLIC'}"
790
+ @click="toggleSlotRegime"
791
+ title="Click to toggle slot regime between DYNAMIC_CYCLIC and STATIC_LOAD"
792
+ >
793
+ {{ state.qdikw.slotMetadata?.SLOT_FRONT_SUSPENSION?.loadRegime || 'No Load Defined (Click to Set)' }}
794
+ </button>
795
+ </div>
796
+ </div>
797
+
798
  <!-- Tier 1: Unified Architecture & Perspective Controls -->
799
  <div class="deck-row deck-row-top">
800
  <div class="section-label">
 
810
 
811
  <div class="divider"></div>
812
 
 
813
  <div class="section-label">
814
  <span class="iec-badge">IEC 63339<span class="iec-tooltip" v-html="t.tooltips.sms"></span></span>
815
  <span>👁️ {{ t.viewTitle }}</span>
 
831
 
832
  <div class="divider"></div>
833
 
 
834
  <button id="ctrl-save-json" class="secondary" @click="saveJson" :title="t.saveBtn">{{ t.saveBtn }}</button>
835
  <button id="ctrl-load-json" class="secondary" @click="triggerLoadJson" :title="t.loadBtn">{{ t.loadBtn }}</button>
836
  <input ref="fileInput" type="file" accept=".json" style="display: none;" @change="onFileLoaded" />
 
844
 
845
  <!-- Tier 2: Engineer Lifecycle Actions -->
846
  <template v-if="state.userRole === 'UNI_ENGINEER'">
847
+ <!-- Row 1: Time, Register, Install, Dismantle, Delete -->
848
  <div class="deck-row">
849
  <span id="biz-time-badge" class="badge">T = {{ state.currentTime }}</span>
850
  <button id="biz-step-btn" @click="advanceTime">{{ t.stepBtn }}</button>
851
 
852
  <div class="divider"></div>
853
 
 
854
  <label class="action-label">1. Register:</label>
855
  <select id="biz-reg-type" v-model="bizRegType" title="Entity Class">
856
  <option value="Vehicle">Vehicle</option>
857
+ <option value="Slot">Slot</option>
858
  <option value="Part">Part</option>
859
  <option value="Warehouse">Warehouse</option>
860
  </select>
 
863
 
864
  <div class="divider"></div>
865
 
 
866
  <label class="action-label">2. Install:</label>
867
  <select id="biz-inst-source" v-model="bizInstSource" title="Component to install">
868
  <option v-for="node in bizInstallSources" :key="'src_' + node" :value="node">{{ node }}</option>
 
875
 
876
  <div class="divider"></div>
877
 
 
878
  <label class="action-label">5. Dismantle:</label>
879
  <select id="biz-dism-part" v-model="bizDismPart">
880
  <option v-for="comp in installedComponents" :key="'comp_' + comp" :value="comp">{{ comp }}</option>
881
  </select>
882
  <button id="biz-dism-btn" class="danger" @click="handleBizDismantle">Dismantle</button>
883
+
884
+ <div class="divider"></div>
885
+
886
+ <label class="action-label">Delete:</label>
887
+ <select id="biz-del-node" v-model="bizDeleteNodeId" title="Delete entity completely">
888
+ <option v-for="node in availableNodes" :key="'del_' + node" :value="node">{{ node }}</option>
889
+ </select>
890
+ <button id="biz-del-btn" class="danger" @click="handleBizDeleteNode" title="Delete selected entity">🗑️</button>
891
  </div>
892
 
893
  <!-- Row 2: Defect, Revoke, Storage, History -->
894
  <div class="deck-row" style="border-top: 1px solid #f1f5f9; background: #fafafa;">
 
895
  <label class="action-label">3. Defect:</label>
896
  <select id="biz-def-target" v-model="bizDefTarget">
897
  <option v-for="node in availableNodes" :key="'dn_' + node" :value="node">{{ node }}</option>
898
  </select>
899
  <input id="biz-def-type" type="text" v-model="bizDefType" placeholder="Type (e.g. crack)" style="width: 110px;">
900
+ <input id="biz-def-val" type="text" v-model="bizDefVal" placeholder="Value (e.g. 15mm)" style="width: 85px;">
901
  <button id="biz-def-btn" class="secondary" @click="handleBizReportDefect">Report Defect</button>
902
 
903
  <div class="divider"></div>
904
 
 
905
  <label class="action-label">4. Revoke:</label>
906
  <select id="biz-rev-defect" v-model="bizRevDefect">
907
  <option v-for="d in activeDefectsList" :key="d.id" :value="d.id">{{ d.label }}</option>
 
910
 
911
  <div class="divider"></div>
912
 
 
913
  <label class="action-label">6. Storage:</label>
914
  <select id="biz-store-part" v-model="bizStorePart">
915
  <option v-for="part in activeParts" :key="'sp_' + part" :value="part">{{ part }}</option>
 
922
 
923
  <div class="divider"></div>
924
 
 
925
  <label style="font-size: 11px; display: flex; align-items: center; gap: 4px; cursor: pointer;">
926
  <input type="checkbox" v-model="state.showHistory"> {{ t.history }}
927
  </label>
 
934
  <div ref="visContainer" id="vis-container" v-show="state.graphEngine === 'VIS'"></div>
935
  <div ref="mermaidContainer" id="mermaid-container" v-show="state.graphEngine === 'MERMAID'"></div>
936
 
 
937
  <div class="graph-caption">
938
  <span>📌</span>
939
  <span>{{ graphCaption }}</span>
940
  </div>
941
 
 
942
  <div class="graph-legend">
943
  <div class="legend-title">
944
  <span>{{ t.legend.title }}</span>
 
960
  </div>
961
  </div>
962
 
 
963
  <div class="resizer" id="panel-resizer" @mousedown="startResizeH"></div>
964
 
965
  <div class="sidebar" style="flex: 1;">
 
994
  </h4>
995
  <div id="storage-content" class="card-scroll-body">
996
  <template v-if="state.storage === 'LPG'">
 
997
  <div class="store-sub-header">{{ t.nodeStoreTitle }} ({{ lpgNodeRecords.length }})</div>
998
  <table v-if="lpgNodeRecords.length > 0" class="storage-table">
999
  <thead>
 
1016
  </table>
1017
  <div v-else class="empty-placeholder">0 nodes</div>
1018
 
 
1019
  <div class="store-sub-header" style="margin-top: 8px;">{{ t.edgeStoreTitle }} ({{ lpgRecords.length }})</div>
1020
  <table v-if="lpgRecords.length > 0" class="storage-table">
1021
  <thead>
 
1057
  <div id="query-content" class="card-scroll-body">
1058
  <pre class="code-block query-code-block" :style="{ color: state.ontology === 'BFO' ? '#0369a1' : '#3730a3' }">{{ queryCode }}</pre>
1059
 
 
1060
  <div class="query-result-box">
1061
  <div class="query-result-header">
1062
  <span>{{ t.queryResultTitle }}</span>
 
1067
  {{ t.queryDefectsFound }} {{ liveQueryResult.defectiveCount }}
1068
  </span>
1069
  </div>
1070
+
1071
+ <!-- QDIKW Alerts (Wisdom & Blind Spots) -->
1072
+ <div id="qdikw-wisdom-box" v-for="alert in semanticGraph.wisdomAlerts" :key="alert" class="wisdom-directive-card">
1073
+ 🔴 <strong>WISDOM REACHED:</strong> {{ alert }}
1074
+ </div>
1075
+ <div id="qdikw-blindspot-box" v-for="bs in semanticGraph.blindSpots" :key="bs" class="blindspot-warning-card">
1076
+ ⚠️ <strong>BOUNDARY WARNING:</strong> {{ bs }}
1077
+ </div>
1078
+
1079
+ <table v-if="liveQueryResult.rows.length > 0" class="storage-table" style="margin-top: 8px;">
1080
  <thead>
1081
  <tr>
1082
  <th>part</th>
 
1113
  @ended="onAudioEnded"
1114
  ></audio>
1115
 
1116
+ <!-- Subtitles Overlay -->
1117
  <div
1118
  v-if="state.currentView === 'SCENARIO' && showSubtitles && currentSubtitleText"
1119
  class="scenario-subtitles"
 
1121
  {{ currentSubtitleText }}
1122
  </div>
1123
 
1124
+ <!-- Floating Player Panel -->
1125
  <div
1126
  v-if="state.currentView === 'SCENARIO'"
1127
  class="scenario-player-panel"
 
1130
  class="player-btn"
1131
  @click="togglePlayAudio"
1132
  :title="isPlaying ? 'Pause' : 'Play'"
 
1133
  >
1134
  <span v-if="isPlaying">⏸</span>
1135
  <span v-else>▶</span>
 
1139
  class="player-btn"
1140
  @click="stopAudio(true)"
1141
  title="Stop"
 
1142
  >
1143
  <span>⏹</span>
1144
  </button>
 
1151
  step="0.1"
1152
  :value="audioCurrentTime"
1153
  @input="onSeek"
 
1154
  />
1155
 
1156
  <span class="player-time">{{ formatTime(audioCurrentTime) }} / {{ formatTime(audioDuration) }}</span>
 
1158
  <button
1159
  class="player-btn player-btn-cc"
1160
  :class="{ active: showSubtitles }"
 
1161
  @click="showSubtitles = !showSubtitles"
 
1162
  >
1163
  CC
1164
  </button>
 
1170
  class="floating-home-btn"
1171
  @click="goHome"
1172
  title="Return to Main Menu"
 
1173
  >
1174
  <svg viewBox="0 0 24 24" width="22" height="22" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round">
1175
  <path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
js/renderers/mermaid-adapter.js CHANGED
@@ -2,8 +2,7 @@
2
  * MERMAID RENDERER ADAPTER
3
  * ------------------------
4
  * Translates the abstract Semantic Graph into Mermaid flowchart syntax
5
- * and renders it to the DOM without leaking internal metadata properties.
6
- * Now includes Pan & Zoom support and ELK layout engine for better readability.
7
  */
8
 
9
  import { INTERNAL_PROPERTY_KEYS } from '../smrm/definitions.js';
@@ -11,22 +10,15 @@ import { INTERNAL_PROPERTY_KEYS } from '../smrm/definitions.js';
11
  let isRendering = false;
12
  let pendingDefinition = null;
13
  let renderCounter = 0;
14
- let panZoomInstance = null; // Store the pan-zoom instance
15
 
16
- /**
17
- * Updates the Mermaid graph in the specified container.
18
- *
19
- * @param {Object} semanticGraph - { nodes: [], edges: [] }
20
- * @param {HTMLElement} container - The DOM element to host the SVG.
21
- */
22
  export async function updateMermaidNetwork(semanticGraph, container) {
23
  if (!container) return;
24
 
25
  if (!semanticGraph || !Array.isArray(semanticGraph.nodes) || semanticGraph.nodes.length === 0) {
26
- // Destroy pan-zoom if the graph is empty
27
  if (panZoomInstance) {
28
- panZoomInstance.destroy();
29
- panZoomInstance = null;
30
  }
31
  container.innerHTML = `<div style="margin: auto; color: #94a3b8; font-size: 13px; font-weight: 500;">Empty Graph Canvas (T = 0)</div>`;
32
  return;
@@ -46,36 +38,29 @@ async function executeRender(definition, container) {
46
  isRendering = true;
47
  try {
48
  const renderId = 'mermaid_svg_' + (++renderCounter);
49
-
50
- // 1. Render the SVG using Mermaid
51
  const { svg } = await mermaid.render(renderId, definition);
52
  container.innerHTML = svg;
53
-
54
- // 2. Destroy the previous pan-zoom instance to prevent memory leaks
55
  if (panZoomInstance) {
56
- panZoomInstance.destroy();
57
- panZoomInstance = null;
58
  }
59
 
60
- // 3. Initialize svg-pan-zoom on the newly created SVG element
61
  const svgElement = container.querySelector('svg');
62
  if (svgElement && window.svgPanZoom) {
63
- // Ensure the SVG takes up the full container for panning/zooming to work properly
64
- svgElement.style.width = '100%';
65
- svgElement.style.height = '100%';
66
- // Remove max-width constraint set by mermaid
67
- svgElement.style.maxWidth = 'none';
68
-
69
- panZoomInstance = svgPanZoom(svgElement, {
70
- zoomEnabled: true,
71
- controlIconsEnabled: true, // Show +/-/reset buttons
72
- fit: true,
73
- center: true,
74
- minZoom: 0.1,
75
- maxZoom: 10
76
- });
77
  }
78
-
79
  } catch (err) {
80
  console.error('[Mermaid Adapter] Render Error:', err);
81
  } finally {
@@ -88,18 +73,12 @@ async function executeRender(definition, container) {
88
  }
89
  }
90
 
91
- /**
92
- * Builds the string definition for the Mermaid flowchart.
93
- *
94
- * @param {Object} semanticGraph - Standardised Semantic Graph.
95
- * @returns {string} Mermaid chart definition string.
96
- */
97
  function buildMermaidDefinition(semanticGraph) {
98
- // Use ELK layout for better graph density and set flow to Top-Down (TD)
99
  let def = `%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%\nflowchart TD\n`;
100
  def += ' classDef default fill:#f8fafc,stroke:#cbd5e1,color:#334155,stroke-width:1px\n';
101
  def += ' classDef bfoSys fill:#0284c7,stroke:#0369a1,color:#ffffff,stroke-width:2px\n';
102
- def += ' classDef bfoElem fill:#64748b,stroke:#475569,color:#ffffff,stroke-width:1px\n';
 
103
  def += ' classDef bfoQuality fill:#f59e0b,stroke:#d97706,color:#000000,stroke-width:2px\n';
104
  def += ' classDef rdfStmt fill:#f59e0b,stroke:#d97706,color:#000000,stroke-width:1px\n';
105
  def += ' classDef rdfLit fill:#f1f5f9,stroke:#cbd5e1,color:#334155,stroke-dasharray:3 3\n';
@@ -134,7 +113,14 @@ function buildMermaidDefinition(semanticGraph) {
134
  let shapeOpen = '["';
135
  let shapeClose = '"]';
136
 
137
- const entityType = node.type || node.properties?.entityClass;
 
 
 
 
 
 
 
138
  if (entityType === 'TemporalPartMembership' || entityType === 'RelationalQuality' || entityType === 'Defect' || /^def/i.test(node.id)) {
139
  shapeOpen = '{{"';
140
  shapeClose = '"}}';
@@ -201,7 +187,7 @@ function getMermaidEdgeStyle(edge) {
201
  const label = (edge.label || '').toLowerCase();
202
 
203
  if (rel === 'has_defect' || label === 'has_defect' || label === 'defect') {
204
- return { stroke: '#ef4444', width: 2 };
205
  }
206
  if (rel === 'inherence' || label === 'inheres_in') {
207
  return { stroke: '#f59e0b', width: 2 };
@@ -227,6 +213,7 @@ function getMermaidEdgeStyle(edge) {
227
 
228
  function getNodeClass(node) {
229
  const entityType = node.type || node.properties?.entityClass || node.properties?.entityType;
 
230
 
231
  switch (entityType) {
232
  case 'Vehicle':
@@ -240,6 +227,7 @@ function getNodeClass(node) {
240
  case 'Warehouse':
241
  return 'naiveWarehouse';
242
  case 'MaterialEntity':
 
243
  return (node.properties?.entityType === 'system' || node.properties?.entityClass === 'Vehicle')
244
  ? 'bfoSys'
245
  : 'bfoElem';
 
2
  * MERMAID RENDERER ADAPTER
3
  * ------------------------
4
  * Translates the abstract Semantic Graph into Mermaid flowchart syntax
5
+ * and renders it to the DOM with ELK layout and svg-pan-zoom support.
 
6
  */
7
 
8
  import { INTERNAL_PROPERTY_KEYS } from '../smrm/definitions.js';
 
10
  let isRendering = false;
11
  let pendingDefinition = null;
12
  let renderCounter = 0;
13
+ let panZoomInstance = null;
14
 
 
 
 
 
 
 
15
  export async function updateMermaidNetwork(semanticGraph, container) {
16
  if (!container) return;
17
 
18
  if (!semanticGraph || !Array.isArray(semanticGraph.nodes) || semanticGraph.nodes.length === 0) {
 
19
  if (panZoomInstance) {
20
+ panZoomInstance.destroy();
21
+ panZoomInstance = null;
22
  }
23
  container.innerHTML = `<div style="margin: auto; color: #94a3b8; font-size: 13px; font-weight: 500;">Empty Graph Canvas (T = 0)</div>`;
24
  return;
 
38
  isRendering = true;
39
  try {
40
  const renderId = 'mermaid_svg_' + (++renderCounter);
 
 
41
  const { svg } = await mermaid.render(renderId, definition);
42
  container.innerHTML = svg;
43
+
 
44
  if (panZoomInstance) {
45
+ panZoomInstance.destroy();
46
+ panZoomInstance = null;
47
  }
48
 
 
49
  const svgElement = container.querySelector('svg');
50
  if (svgElement && window.svgPanZoom) {
51
+ svgElement.style.width = '100%';
52
+ svgElement.style.height = '100%';
53
+ svgElement.style.maxWidth = 'none';
54
+
55
+ panZoomInstance = svgPanZoom(svgElement, {
56
+ zoomEnabled: true,
57
+ controlIconsEnabled: true,
58
+ fit: true,
59
+ center: true,
60
+ minZoom: 0.1,
61
+ maxZoom: 10
62
+ });
 
 
63
  }
 
64
  } catch (err) {
65
  console.error('[Mermaid Adapter] Render Error:', err);
66
  } finally {
 
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';
79
  def += ' classDef bfoSys fill:#0284c7,stroke:#0369a1,color:#ffffff,stroke-width:2px\n';
80
+ def += ' classDef bfoElem fill:#475569,stroke:#334155,color:#ffffff,stroke-width:1px\n';
81
+ def += ' classDef bfoSlot fill:#e0e7ff,stroke:#4f46e5,color:#1e1b4b,stroke-width:2px,stroke-dasharray:4 3\n';
82
  def += ' classDef bfoQuality fill:#f59e0b,stroke:#d97706,color:#000000,stroke-width:2px\n';
83
  def += ' classDef rdfStmt fill:#f59e0b,stroke:#d97706,color:#000000,stroke-width:1px\n';
84
  def += ' classDef rdfLit fill:#f1f5f9,stroke:#cbd5e1,color:#334155,stroke-dasharray:3 3\n';
 
113
  let shapeOpen = '["';
114
  let shapeClose = '"]';
115
 
116
+ const isSlotNode = node.id.startsWith('Slot_') || node.properties?.entityClass === 'Slot' || node.type === 'Slot';
117
+ let entityType = node.type || node.properties?.entityClass;
118
+
119
+ // Distinguish BFO Site (Slot) from physical MaterialEntity
120
+ if (entityType === 'MaterialEntity' && isSlotNode) {
121
+ entityType = 'BFO:Site (Slot)';
122
+ }
123
+
124
  if (entityType === 'TemporalPartMembership' || entityType === 'RelationalQuality' || entityType === 'Defect' || /^def/i.test(node.id)) {
125
  shapeOpen = '{{"';
126
  shapeClose = '"}}';
 
187
  const label = (edge.label || '').toLowerCase();
188
 
189
  if (rel === 'has_defect' || label === 'has_defect' || label === 'defect') {
190
+ return { stroke: '#ef4444', width: 2.5 };
191
  }
192
  if (rel === 'inherence' || label === 'inheres_in') {
193
  return { stroke: '#f59e0b', width: 2 };
 
213
 
214
  function getNodeClass(node) {
215
  const entityType = node.type || node.properties?.entityClass || node.properties?.entityType;
216
+ const isSlotNode = node.id.startsWith('Slot_') || node.properties?.entityClass === 'Slot' || node.type === 'Slot';
217
 
218
  switch (entityType) {
219
  case 'Vehicle':
 
227
  case 'Warehouse':
228
  return 'naiveWarehouse';
229
  case 'MaterialEntity':
230
+ if (isSlotNode) return 'bfoSlot';
231
  return (node.properties?.entityType === 'system' || node.properties?.entityClass === 'Vehicle')
232
  ? 'bfoSys'
233
  : 'bfoElem';
js/scenarios/scenario-qdikw.js ADDED
@@ -0,0 +1,504 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * SCENARIO: THE Q-D-I-K-W PIPELINE (ROLES, RULES & BLIND SPOTS)
3
+ * -------------------------------------------------------------
4
+ */
5
+
6
+ import { setPerspective, nextSequence } from '../state.js';
7
+ import {
8
+ createRegisterPartEvent,
9
+ createAssembleEvent,
10
+ createReportDefectEvent,
11
+ createDismantleEvent
12
+ } from '../smrm/actions.js';
13
+
14
+ let lastExecutedStep = -1;
15
+ let openSelectTimeouts = [];
16
+
17
+ export const QDIKW_STAGE_TIMESTAMPS = {
18
+ INTRO: 0,
19
+ Q: 62.00,
20
+ D: 128.48,
21
+ I: 189.40,
22
+ K: 296.70,
23
+ W: 393.67
24
+ };
25
+
26
+ export function clearQdikwHighlights() {
27
+ document.querySelectorAll('.tour-pulse-highlight, .tour-amber-highlight').forEach(el => {
28
+ el.classList.remove('tour-pulse-highlight', 'tour-amber-highlight');
29
+ });
30
+ openSelectTimeouts.forEach(t => clearTimeout(t));
31
+ openSelectTimeouts = [];
32
+ document.querySelectorAll('select[data-tour-opened="true"]').forEach(sel => {
33
+ sel.removeAttribute('size');
34
+ sel.removeAttribute('data-tour-opened');
35
+ });
36
+ }
37
+
38
+ function highlightElements(selectors, styleClass = 'tour-pulse-highlight') {
39
+ clearQdikwHighlights();
40
+ if (!selectors) return;
41
+ const list = Array.isArray(selectors) ? selectors : [selectors];
42
+ list.forEach(sel => {
43
+ const el = document.querySelector(sel);
44
+ if (el) el.classList.add(styleClass);
45
+ });
46
+ }
47
+
48
+ /**
49
+ * Visually expands a <select> dropdown on screen so viewers can see its options.
50
+ */
51
+ function openDropdownTemporary(selector, durationMs = 6500) {
52
+ const el = document.querySelector(selector);
53
+ if (!el || el.tagName !== 'SELECT') return;
54
+ const optionCount = Math.min(Math.max(el.options.length, 3), 6);
55
+ el.setAttribute('size', String(optionCount));
56
+ el.setAttribute('data-tour-opened', 'true');
57
+ const timer = setTimeout(() => {
58
+ el.removeAttribute('size');
59
+ el.removeAttribute('data-tour-opened');
60
+ }, durationMs);
61
+ openSelectTimeouts.push(timer);
62
+ }
63
+
64
+ export const qdikwScenario = {
65
+ id: 'QDIKW_PIPELINE',
66
+ title: 'The Q-D-I-K-W Pipeline: Roles, Rules & Blind Spots',
67
+ audioSrc: './narratives/General_QDIKW.mp3',
68
+ fallbackDuration: 507,
69
+
70
+ subtitles: [
71
+ { start: 0.14, end: 3.54, text: "Welcome to the QDIKW demonstrator." },
72
+ { start: 4.32, end: 9.06, text: "In consulting slides, the data, information, knowledge, wisdom pyramid is" },
73
+ { start: 9.06, end: 10.60, text: "often presented like magic." },
74
+ { start: 11.26, end: 15.54, text: "Pour raw data into a graph and executive wisdom comes out the other side." },
75
+ { start: 16.36, end: 21.70, text: "That illusion makes it look as if a single all-knowing mega brain is doing all the work." },
76
+ { start: 22.42, end: 25.92, text: "And if such a mega brain existed, we wouldn't need a knowledge management" },
77
+ { start: 25.92, end: 26.68, text: "system at all." },
78
+ { start: 27.40, end: 32.24, text: "In real systems engineering, there is no magic. There is only the law of" },
79
+ { start: 32.24, end: 34.18, text: "conservation of engineering effort." },
80
+ { start: 34.80, end: 37.96, text: "A knowledge system cannot invent physics out of thin air." },
81
+ { start: 38.60, end: 41.40, text: "Its true power is separating human roles." },
82
+ { start: 42.06, end: 47.26, text: "Today, various specialists already do this hard work, but their outputs are trapped" },
83
+ { start: 47.26, end: 51.34, text: "in disconnected Word documents, CAD files, and Excel spreadsheets." },
84
+ { start: 52.00, end: 56.94, text: "Let's walk through the five stages from question to wisdom and see not just what" },
85
+ { start: 56.94, end: 61.28, text: "happens on screen, but who had to do what beforehand to make it work." },
86
+ { start: 62.00, end: 63.86, text: "Stage one: the question." },
87
+ { start: 65.92, end: 71.20, text: "A fleet operator asks a seemingly simple question. \"A crack was just reported on" },
88
+ { start: 71.20, end: 76.10, text: "vehicle one. Is it safe to dispatch or is there a risk of structural failure?\"" },
89
+ { start: 76.90, end: 79.28, text: "Here we hit the first expectation trap." },
90
+ { start: 80.04, end: 83.32, text: "One may assume the system will magically spot any flaw." },
91
+ { start: 84.04, end: 88.40, text: "In reality, the system can only answer questions if two people laid the" },
92
+ { start: 88.40, end: 91.38, text: "groundwork long before vehicle one was even built." },
93
+ { start: 92.26, end: 98.78, text: "First, the IT and database architect at the SMS and SMIM layers had to program the" },
94
+ { start: 98.78, end: 104.20, text: "graph database to support temporal states, hierarchical paths, and rule execution." },
95
+ { start: 106.58, end: 112.24, text: "Second, the ontology modeler at the SMRM layer had to define the controlled vocabulary," },
96
+ { start: 112.84, end: 119.58, text: "creating explicit classes for vehicles, slots, parts, defects, load types, and hazards." },
97
+ { start: 122.04, end: 126.34, text: "You cannot ask a question if the database lacks the grammar to express it." },
98
+ { start: 128.48, end: 130.32, text: "Stage two: data." },
99
+ { start: 132.82, end: 136.04, text: "A maintenance technician in the workshop inspects the vehicle." },
100
+ { start: 137.02, end: 141.16, text: "Notice that the defect does not magically attach itself to a component." },
101
+ { start: 142.06, end: 145.76, text: "The technician scans the barcode of a specific physical part," },
102
+ { start: 146.36, end: 151.84, text: "serial number ARM_SN_404, and logs" },
103
+ { start: 151.84, end: 157.74, text: "DEFECT_742, selecting crack and typing 15 millimeters." },
104
+ { start: 160.38, end: 162.46, text: "Why is this still just raw data?" },
105
+ { start: 163.12, end: 167.74, text: "Because the technician isn't typing freeform prose. They are constrained by" },
106
+ { start: 167.74, end: 171.84, text: "the dropdown menus that the database programmer and ontologist built for them." },
107
+ { start: 172.50, end: 177.30, text: "Yet, at this level, the record is just an isolated observation on a serial number." },
108
+ { start: 177.88, end: 181.94, text: "The technician doesn't know fracture mechanics, and the raw log doesn't know" },
109
+ { start: 181.94, end: 186.72, text: "what role ARM_SN_404 plays in the vehicle." },
110
+ { start: 189.40, end: 194.30, text: "Stage three: information, giving data structural context." },
111
+ { start: 196.46, end: 200.48, text: "This brings us to the most critical question in engineering data management." },
112
+ { start: 201.20, end: 205.32, text: "How does the system know that this part is under dynamic cyclic loading?" },
113
+ { start: 206.14, end: 211.28, text: "If we forced the 3D CAD designer who models a suspension arm in a CAD tool to" },
114
+ { start: 211.28, end: 216.32, text: "manually fill in 40 ontological attributes about cyclic loads and vehicle-level" },
115
+ { start: 216.32, end: 219.16, text: "hazards, the project would fail within a week." },
116
+ { start: 219.88, end: 224.14, text: "Component designers shouldn't have to guess system-level physics, and a spare" },
117
+ { start: 224.14, end: 229.50, text: "part sitting on a shelf in warehouse_1 experiences zero cyclic load anyway." },
118
+ { start: 230.24, end: 235.24, text: "Instead, look at how IEC 63339 separates their work." },
119
+ { start: 237.26, end: 244.22, text: "The 3D CAD designer simply registers ARM_SN_404 and places it" },
120
+ { start: 244.22, end: 246.42, text: "into the assembly tree. Nothing more." },
121
+ { start: 248.92, end: 254.42, text: "Meanwhile, the systems architect, or an automated import from a DFMEA safety" },
122
+ { start: 254.42, end: 257.56, text: "table, defines the functional architecture once." },
123
+ { start: 258.22, end: 264.68, text: "They mark the functional slot, SLOT_FRONT_SUSPENSION, as experiencing" },
124
+ { start: 264.68, end: 270.20, text: "DYNAMIC_CYCLIC loading and serving the STEERING_CONTROL function." },
125
+ { start: 272.92, end: 277.88, text: "The moment ARM_SN_404 is mounted into" },
126
+ { start: 277.88, end: 284.60, text: "SLOT_FRONT_SUSPENSION, the graph automatically inherits that operational context." },
127
+ { start: 285.26, end: 289.96, text: "The part now carries dynamic cyclic loading, not because someone hardcoded it" },
128
+ { start: 289.96, end: 293.88, text: "onto the metal, but because of where it currently sits in the architecture." },
129
+ { start: 296.70, end: 298.64, text: "Stage four: knowledge." },
130
+ { start: 300.40, end: 305.32, text: "How does the system connect a 15-millimeter crack to a catastrophic failure?" },
131
+ { start: 306.78, end: 310.02, text: "Here, a materials and fatigue specialist steps in." },
132
+ { start: 310.82, end: 315.06, text: "This expert knows nothing about Cypher queries or RDF triples." },
133
+ { start: 315.82, end: 320.04, text: "Working purely with the pre-approved building blocks in the domain dictionary," },
134
+ { start: 320.04, end: 322.60, text: "they formulate modular atomic rules." },
135
+ { start: 323.38, end: 325.88, text: "Rule one: context inheritance." },
136
+ { start: 326.58, end: 331.86, text: "Any part mounted in a slot with DYNAMIC_CYCLIC regime is subject to" },
137
+ { start: 331.86, end: 334.66, text: "ACTIVE_CYCLIC_STRESS." },
138
+ { start: 336.06, end: 338.28, text: "Rule two: material physics." },
139
+ { start: 339.04, end: 345.72, text: "A crack exceeding 10 millimeters on a part under ACTIVE_CYCLIC_STRESS triggers" },
140
+ { start: 345.72, end: 348.74, text: "RAPID_FRACTURE_PROPAGATION." },
141
+ { start: 350.54, end: 352.72, text: "Rule three: functional safety." },
142
+ { start: 353.46, end: 360.24, text: "RAPID_FRACTURE_PROPAGATION in any slot supporting STEERING_CONTROL" },
143
+ { start: 360.24, end: 361.64, text: "causes a system hazard," },
144
+ { start: 362.32, end: 365.00, text: "LOSS_OF_CONTROL." },
145
+ { start: 366.89, end: 367.95, text: "Notice the boundary." },
146
+ { start: 368.57, end: 373.33, text: "The materials expert couldn't invent new database structures. They could only wire" },
147
+ { start: 373.33, end: 377.55, text: "together concepts that the IT architect and ontologist made available." },
148
+ { start: 378.29, end: 382.33, text: "Because the graph engine supports transitive inference, these three" },
149
+ { start: 382.33, end: 387.37, text: "independent rules snap together like Lego bricks, automatically building a causal" },
150
+ { start: 387.37, end: 391.27, text: "bridge from the technician's barcode scan to a vehicle-level failure." },
151
+ { start: 393.67, end: 396.39, text: "Finally, stage five, wisdom." },
152
+ { start: 397.13, end: 400.03, text: "Turning inferred knowledge into an actionable decision." },
153
+ { start: 402.09, end: 406.93, text: "Traversing the causal chain, the system tells the fleet operator, \"Critical" },
154
+ { start: 406.93, end: 411.95, text: "hazard. Loss of control risk for ground vehicle one. Generate work order for" },
155
+ { start: 411.95, end: 413.45, text: "suspension arm replacement.\"" },
156
+ { start: 415.67, end: 419.07, text: "But what happens when reality steps outside these rules?" },
157
+ { start: 420.87, end: 422.85, text: "Let's test the system's blind spot." },
158
+ { start: 423.59, end: 427.59, text: "Suppose the technician logs a second observation on the exact same part," },
159
+ { start: 428.21, end: 434.43, text: "defect_743, surface_corrosion, five square centimeters." },
160
+ { start: 435.37, end: 440.19, text: "Watch the graph. The corrosion record passes through data and attaches to the" },
161
+ { start: 440.19, end: 445.41, text: "suspension slot as information, and then it stops. Why?" },
162
+ { start: 446.09, end: 450.27, text: "Because the materials expert hasn't authored a rule linking surface corrosion" },
163
+ { start: 450.27, end: 451.77, text: "area to cyclic fracture," },
164
+ { start: 452.49, end: 456.41, text: "or perhaps the database lacks the mathematical operators to calculate" },
165
+ { start: 456.41, end: 457.85, text: "cross-sectional rust loss." },
166
+ { start: 458.67, end: 463.65, text: "Instead of hallucinating or silently hiding the problem, a properly architected" },
167
+ { start: 463.65, end: 467.35, text: "system explicitly flags an unmapped engineering condition." },
168
+ { start: 468.01, end: 470.73, text: "Automated inference stopped at the information layer." },
169
+ { start: 471.35, end: 475.97, text: "Escalate defect_743 to a human materials specialist." },
170
+ { start: 479.07, end: 483.69, text: "That is the real takeaway of this workbench. A knowledge graph is not a" },
171
+ { start: 483.69, end: 489.17, text: "crystal ball. Without it, five specialists still do all this work in isolated" },
172
+ { start: 489.17, end: 492.65, text: "documents, and it takes days of meetings to connect the dots." },
173
+ { start: 493.33, end: 498.39, text: "With it, each role contributes their piece of the puzzle once within clear technical" },
174
+ { start: 498.39, end: 503.13, text: "boundaries, allowing the system to connect those dots in milliseconds while" },
175
+ { start: 503.13, end: 506.61, text: "honestly showing where human engineering judgment must take over." }
176
+ ],
177
+
178
+ timeline: [
179
+ {
180
+ // 00:00.00 - Seed initial baseline vehicle structure so Stage Q has context on screen
181
+ time: 0,
182
+ action: (state, renderGraph) => {
183
+ state.eventLog.splice(0, state.eventLog.length);
184
+ state.currentTime = 0;
185
+ state.edgeSequence = 1;
186
+ state.ontology = 'BFO';
187
+ setPerspective('SMRM');
188
+ state.graphEngine = 'MERMAID';
189
+ state.showHistory = false;
190
+
191
+ // Seed baseline Vehicle_1 & Warehouse_1 so database isn't empty on Stage Q
192
+ state.eventLog.push(
193
+ createRegisterPartEvent('Vehicle_1', 0, 'Vehicle', nextSequence()),
194
+ createRegisterPartEvent('Powertrain_Unit', 0, 'Part', nextSequence()),
195
+ createAssembleEvent('Vehicle_1', 'Powertrain_Unit', 'mounted_in', 0, nextSequence()),
196
+ createRegisterPartEvent('Warehouse_1', 0, 'Warehouse', nextSequence())
197
+ );
198
+
199
+ if (state.qdikw) {
200
+ state.qdikw.active = true;
201
+ state.qdikw.stage = 'INTRO';
202
+ state.qdikw.activeRole = 'System Overview';
203
+ state.qdikw.roleBadge = 'Law of Conservation of Engineering Effort';
204
+ state.qdikw.questionText = '';
205
+ state.qdikw.slotMetadata = {};
206
+ state.qdikw.rules.rule1 = false;
207
+ state.qdikw.rules.rule2 = false;
208
+ state.qdikw.rules.rule3 = false;
209
+ }
210
+ if (state.figureOverlay) {
211
+ state.figureOverlay.visible = false;
212
+ }
213
+ clearQdikwHighlights();
214
+ renderGraph();
215
+ }
216
+ },
217
+ {
218
+ // 00:04.32 - Show DIKW Pyramid Fullscreen Figure Overlay
219
+ time: 4.32,
220
+ action: (state) => {
221
+ if (state.figureOverlay) {
222
+ state.figureOverlay.visible = true;
223
+ state.figureOverlay.src = './figures/1280px-DIKW_Pyramid.svg.webp';
224
+ state.figureOverlay.caption = 'The Classical DIKW Pyramid — Often presented as if raw data automatically turns into wisdom without human role separation.';
225
+ state.figureOverlay.attributionHtml = '<a href="https://commons.wikimedia.org/wiki/File:DIKW_Pyramid.svg" target="_blank" rel="noopener">Longlivetheux</a>, <a href="https://creativecommons.org/licenses/by-sa/4.0" target="_blank" rel="noopener">CC BY-SA 4.0</a>, via Wikimedia Commons';
226
+ }
227
+ }
228
+ },
229
+ {
230
+ // 00:27.40 - Hide Figure Overlay
231
+ time: 27.40,
232
+ action: (state) => {
233
+ if (state.figureOverlay) {
234
+ state.figureOverlay.visible = false;
235
+ }
236
+ highlightElements('#qdikw-stage-bar');
237
+ }
238
+ },
239
+ {
240
+ // 01:02.00 - STAGE 1: QUESTION
241
+ time: 62.00,
242
+ action: (state, renderGraph) => {
243
+ if (state.figureOverlay) state.figureOverlay.visible = false;
244
+ if (state.qdikw) {
245
+ state.qdikw.stage = 'Q';
246
+ state.qdikw.activeRole = 'Fleet Operator (Run-Time)';
247
+ state.qdikw.roleBadge = 'Asks: "Is Vehicle_1 safe to dispatch?"';
248
+ }
249
+ highlightElements(['#qdikw-step-Q', '#query-content']);
250
+ renderGraph();
251
+ }
252
+ },
253
+ {
254
+ // 01:32.26 - Role 1: IT & Database Architect
255
+ time: 92.26,
256
+ action: (state) => {
257
+ if (state.qdikw) {
258
+ state.qdikw.activeRole = 'IT & Database Architect (Design-Time)';
259
+ state.qdikw.roleBadge = 'Programmed SMS/SMIM graph storage, temporal states & rule engine';
260
+ }
261
+ highlightElements(['#ctrl-onto-bfo', '#ctrl-view-logical', '#ctrl-view-physical-lpg', '#storage-content']);
262
+ }
263
+ },
264
+ {
265
+ // 01:46.58 - Role 2: Ontology Modeller (Expand Entity Class Dropdown!)
266
+ time: 106.58,
267
+ action: (state, renderGraph, ui) => {
268
+ if (state.qdikw) {
269
+ state.qdikw.activeRole = 'Ontology Modeller (Design-Time)';
270
+ state.qdikw.roleBadge = 'Defined SMRM controlled vocabulary: Vehicle, Slot, Part, Defect, Load Types, Hazards';
271
+ }
272
+ if (ui) ui.bizRegType.value = 'Part';
273
+ highlightElements(['#biz-reg-type', '#ctrl-view-smrm'], 'tour-amber-highlight');
274
+ openDropdownTemporary('#biz-reg-type', 8000);
275
+ }
276
+ },
277
+ {
278
+ // 02:08.48 - STAGE 2: DATA (Field Technician)
279
+ time: 128.48,
280
+ action: (state, renderGraph) => {
281
+ if (state.figureOverlay) state.figureOverlay.visible = false;
282
+ // Isolate the canvas to show raw data logging clearly
283
+ state.eventLog.splice(0, state.eventLog.length);
284
+ state.eventLog.push(
285
+ createRegisterPartEvent('Vehicle_1', 0, 'Vehicle', nextSequence()),
286
+ createRegisterPartEvent('Warehouse_1', 0, 'Warehouse', nextSequence())
287
+ );
288
+ if (state.qdikw) {
289
+ state.qdikw.stage = 'D';
290
+ state.qdikw.activeRole = 'Maintenance Technician (Run-Time)';
291
+ state.qdikw.roleBadge = 'Scans barcode & logs structured observation via constrained UI';
292
+ }
293
+ highlightElements('#qdikw-step-D');
294
+ renderGraph();
295
+ }
296
+ },
297
+ {
298
+ // 02:22.06 - Technician scans barcode ARM_SN_404
299
+ time: 142.06,
300
+ action: (state, renderGraph, ui) => {
301
+ if (ui) {
302
+ ui.bizRegType.value = 'Part';
303
+ ui.bizRegId.value = 'ARM_SN_404';
304
+ }
305
+ state.eventLog.push(
306
+ createRegisterPartEvent('ARM_SN_404', 0, 'Part', nextSequence())
307
+ );
308
+ highlightElements(['#biz-reg-id', '#biz-reg-btn']);
309
+ renderGraph();
310
+ }
311
+ },
312
+ {
313
+ // 02:31.84 - Technician logs DEFECT_742 (crack = 15mm) on ARM_SN_404
314
+ time: 151.84,
315
+ action: (state, renderGraph, ui) => {
316
+ if (ui) {
317
+ ui.bizDefTarget.value = 'ARM_SN_404';
318
+ ui.bizDefType.value = 'crack';
319
+ ui.bizDefVal.value = '15mm';
320
+ }
321
+ state.eventLog.push(
322
+ createReportDefectEvent('ARM_SN_404', 'crack', '15mm', 0, nextSequence())
323
+ );
324
+ highlightElements(['#biz-def-target', '#biz-def-type', '#biz-def-val', '#biz-def-btn'], 'tour-amber-highlight');
325
+ renderGraph();
326
+ }
327
+ },
328
+ {
329
+ // 02:43.12 - Show constrained dropdown menus visually expanded!
330
+ time: 163.12,
331
+ action: () => {
332
+ highlightElements(['#biz-def-target', '#biz-reg-type'], 'tour-amber-highlight');
333
+ openDropdownTemporary('#biz-def-target', 7000);
334
+ openDropdownTemporary('#biz-reg-type', 7000);
335
+ }
336
+ },
337
+ {
338
+ // 03:09.40 - STAGE 3: INFORMATION (Structural Context)
339
+ time: 189.40,
340
+ action: (state) => {
341
+ if (state.figureOverlay) state.figureOverlay.visible = false;
342
+ if (state.qdikw) {
343
+ state.qdikw.stage = 'I';
344
+ state.qdikw.activeRole = '3D CAD Designer vs. Systems Architect';
345
+ state.qdikw.roleBadge = 'Separating part geometry from slot functional physics (IEC 63339)';
346
+ }
347
+ highlightElements('#qdikw-step-I');
348
+ }
349
+ },
350
+ {
351
+ // 03:40.00 - Spare Part on shelf in Warehouse_1 (Zero cyclic load)
352
+ time: 220.00,
353
+ action: (state, renderGraph) => {
354
+ state.eventLog.push(
355
+ createAssembleEvent('Warehouse_1', 'ARM_SN_404', 'stored_at', 0, nextSequence())
356
+ );
357
+ highlightElements(['#biz-store-part', '#biz-store-target', '#biz-store-btn']);
358
+ renderGraph();
359
+ }
360
+ },
361
+ {
362
+ // 03:57.26 - 3D CAD Designer removes part from Warehouse and places into Vehicle_1 assembly
363
+ time: 237.26,
364
+ action: (state, renderGraph, ui) => {
365
+ if (state.qdikw) {
366
+ state.qdikw.activeRole = '3D CAD Designer (Design-Time)';
367
+ state.qdikw.roleBadge = 'Places ARM_SN_404 into Vehicle_1 assembly — zero physics hardcoded on part';
368
+ }
369
+ // Remove from Warehouse_1 first so it doesn't stay in two places!
370
+ state.eventLog.push(
371
+ createDismantleEvent('ARM_SN_404', 0, nextSequence()),
372
+ createAssembleEvent('Vehicle_1', 'ARM_SN_404', 'mounted_in', 0, nextSequence())
373
+ );
374
+ if (ui) {
375
+ ui.bizInstSource.value = 'ARM_SN_404';
376
+ ui.bizInstTarget.value = 'Vehicle_1';
377
+ }
378
+ highlightElements(['#biz-inst-source', '#biz-inst-target', '#biz-inst-btn', '#tree-container']);
379
+ renderGraph();
380
+ }
381
+ },
382
+ {
383
+ // 04:18.22 - Systems Architect defines functional slot metadata (DYNAMIC_CYCLIC & STEERING_CONTROL)
384
+ time: 258.22,
385
+ action: (state, renderGraph) => {
386
+ setPerspective('SMIM');
387
+ if (state.qdikw) {
388
+ state.qdikw.activeRole = 'Systems Architect / DFMEA Import (Design-Time)';
389
+ state.qdikw.roleBadge = 'Marks functional slot with DYNAMIC_CYCLIC loading & STEERING_CONTROL';
390
+ state.qdikw.slotMetadata = {
391
+ SLOT_FRONT_SUSPENSION: {
392
+ loadRegime: 'DYNAMIC_CYCLIC',
393
+ safetyFunction: 'STEERING_CONTROL'
394
+ }
395
+ };
396
+ }
397
+ highlightElements(['#qdikw-slot-config', '#ctrl-view-logical'], 'tour-amber-highlight');
398
+ renderGraph();
399
+ }
400
+ },
401
+ {
402
+ // 04:56.70 - STAGE 4: KNOWLEDGE (Materials & Fatigue Specialist)
403
+ time: 296.70,
404
+ action: (state, renderGraph) => {
405
+ if (state.figureOverlay) state.figureOverlay.visible = false;
406
+ setPerspective('SMIM');
407
+ if (state.qdikw) {
408
+ state.qdikw.stage = 'K';
409
+ state.qdikw.activeRole = 'Materials & Fatigue Specialist (Design-Time)';
410
+ state.qdikw.roleBadge = 'Authors modular atomic rules using SMRM dictionary blocks';
411
+ }
412
+ highlightElements(['#qdikw-step-K', '#qdikw-rules-bar']);
413
+ renderGraph();
414
+ }
415
+ },
416
+ {
417
+ // 05:23.38 - Rule 1: Context Inheritance -> ACTIVE_CYCLIC_STRESS
418
+ time: 323.38,
419
+ action: (state, renderGraph) => {
420
+ if (state.qdikw) state.qdikw.rules.rule1 = true;
421
+ highlightElements('#qdikw-rule-1', 'tour-amber-highlight');
422
+ renderGraph();
423
+ }
424
+ },
425
+ {
426
+ // 05:36.06 - Rule 2: Material Physics -> RAPID_FRACTURE_PROPAGATION
427
+ time: 336.06,
428
+ action: (state, renderGraph) => {
429
+ if (state.qdikw) state.qdikw.rules.rule2 = true;
430
+ highlightElements('#qdikw-rule-2', 'tour-amber-highlight');
431
+ renderGraph();
432
+ }
433
+ },
434
+ {
435
+ // 05:50.54 - Rule 3: Functional Safety -> LOSS_OF_CONTROL
436
+ time: 350.54,
437
+ action: (state, renderGraph) => {
438
+ if (state.qdikw) state.qdikw.rules.rule3 = true;
439
+ highlightElements('#qdikw-rule-3', 'tour-amber-highlight');
440
+ renderGraph();
441
+ }
442
+ },
443
+ {
444
+ // 06:33.67 - STAGE 5: WISDOM (Actionable Directive projected on Graph + Sidebar)
445
+ time: 393.67,
446
+ action: (state, renderGraph) => {
447
+ if (state.figureOverlay) state.figureOverlay.visible = false;
448
+ if (state.qdikw) {
449
+ state.qdikw.stage = 'W';
450
+ state.qdikw.activeRole = 'Fleet Operator (Run-Time Decision)';
451
+ state.qdikw.roleBadge = 'Receives prescriptive directive: GROUND VEHICLE_1';
452
+ }
453
+ highlightElements(['#qdikw-step-W', '#qdikw-wisdom-box'], 'tour-amber-highlight');
454
+ renderGraph();
455
+ }
456
+ },
457
+ {
458
+ // 07:03.59 - BLIND SPOT TEST: Technician logs Defect_743 (surface_corrosion = 5cm2)
459
+ time: 423.59,
460
+ action: (state, renderGraph, ui) => {
461
+ if (state.qdikw) {
462
+ state.qdikw.activeRole = 'Boundary Test: Unmapped Engineering Condition';
463
+ state.qdikw.roleBadge = 'Logging surface_corrosion = 5cm2 -> Stops at Information Layer!';
464
+ }
465
+ if (ui) {
466
+ ui.bizDefTarget.value = 'ARM_SN_404';
467
+ ui.bizDefType.value = 'surface_corrosion';
468
+ ui.bizDefVal.value = '5cm2';
469
+ }
470
+ state.eventLog.push(
471
+ createReportDefectEvent('ARM_SN_404', 'surface_corrosion', '5cm2', 0, nextSequence())
472
+ );
473
+ highlightElements(['#biz-def-type', '#biz-def-val', '#biz-def-btn', '#qdikw-blindspot-box'], 'tour-amber-highlight');
474
+ renderGraph();
475
+ }
476
+ },
477
+ {
478
+ // 07:59.07 - Final Takeaway Overview
479
+ time: 479.07,
480
+ action: (state) => {
481
+ if (state.qdikw) {
482
+ state.qdikw.activeRole = 'IEC 63339 Knowledge Architecture';
483
+ state.qdikw.roleBadge = 'Connecting 5 specialists in milliseconds while respecting human boundaries';
484
+ }
485
+ highlightElements('#qdikw-stage-bar');
486
+ }
487
+ }
488
+ ]
489
+ };
490
+
491
+ export function resetQdikwTimeline() {
492
+ lastExecutedStep = -1;
493
+ clearQdikwHighlights();
494
+ }
495
+
496
+ export function onQdikwTimeUpdate(currentTime, state, renderGraph, uiRefs) {
497
+ const steps = qdikwScenario.timeline;
498
+ for (let i = 0; i < steps.length; i++) {
499
+ if (currentTime >= steps[i].time && i > lastExecutedStep) {
500
+ lastExecutedStep = i;
501
+ steps[i].action(state, renderGraph, uiRefs);
502
+ }
503
+ }
504
+ }
js/smim/inference-engine.js ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * SEMANTIC INFERENCE ENGINE (Q-D-I-K-W)
3
+ * -------------------------------------
4
+ * Evaluates SMRM domain rules against the canonical semantic graph.
5
+ * Injects inferred nodes/edges directly into the graph so both Mermaid/Vis
6
+ * and the query panels reflect Knowledge (K) and Wisdom / Blind Spots (W).
7
+ */
8
+
9
+ export function applyQdikwInference(graph, state) {
10
+ if (!state.qdikw || !state.qdikw.active) {
11
+ graph.wisdomAlerts = [];
12
+ graph.blindSpots = [];
13
+ return graph;
14
+ }
15
+
16
+ const newNodes = [];
17
+ const newEdges = [];
18
+ const wisdomAlerts = [];
19
+ const blindSpots = [];
20
+
21
+ // 1. Decorate Slot nodes with Systems Architect metadata (loadRegime & safetyFunction)
22
+ const slotMetaMap = state.qdikw.slotMetadata || {};
23
+ (graph.nodes || []).forEach(node => {
24
+ const isTargetSlot =
25
+ slotMetaMap[node.id] ||
26
+ (node.id.startsWith('Slot_') && node.id.includes('ARM_SN_404') && slotMetaMap['SLOT_FRONT_SUSPENSION']);
27
+
28
+ if (isTargetSlot) {
29
+ const meta = slotMetaMap[node.id] || slotMetaMap['SLOT_FRONT_SUSPENSION'];
30
+ node.properties = node.properties || {};
31
+ node.properties.loadRegime = meta.loadRegime;
32
+ node.properties.safetyFunction = meta.safetyFunction;
33
+ }
34
+ });
35
+
36
+ // 2. Discover parts currently mounted in a Slot (not stored in Warehouse)
37
+ const mountedPartToSlot = {};
38
+ (graph.edges || []).forEach(e => {
39
+ if (e.properties?.isCurrent === false) return;
40
+ if (e.label === 'mounted_in' || e.label === 'has_part') {
41
+ if (e.from.startsWith('Slot_')) mountedPartToSlot[e.to] = e.from;
42
+ if (e.to.startsWith('Slot_')) mountedPartToSlot[e.from] = e.to;
43
+ }
44
+ });
45
+
46
+ // 3. Collect active defects at state.currentTime
47
+ const activeDefects = {};
48
+ state.eventLog.forEach(ev => {
49
+ if (ev.valid_from !== undefined && ev.valid_from > state.currentTime) return;
50
+ if (ev.type === 'REPORT_DEFECT') {
51
+ if (ev.valid_to !== null && ev.valid_to !== undefined && ev.valid_to <= state.currentTime) return;
52
+ if (!activeDefects[ev.targetId]) activeDefects[ev.targetId] = [];
53
+ activeDefects[ev.targetId].push({ name: ev.defectName, val: ev.defectValue });
54
+ } else if (ev.type === 'REVOKE_DEFECT') {
55
+ if (activeDefects[ev.targetId]) {
56
+ activeDefects[ev.targetId] = activeDefects[ev.targetId].filter(d => d.name !== ev.defectName);
57
+ }
58
+ }
59
+ });
60
+
61
+ // 4. Evaluate SMRM Rules for mounted parts
62
+ Object.keys(mountedPartToSlot).forEach(partId => {
63
+ const slotId = mountedPartToSlot[partId];
64
+ const slotNode = graph.nodes.find(n => n.id === slotId);
65
+ const loadRegime = slotNode?.properties?.loadRegime || slotMetaMap['SLOT_FRONT_SUSPENSION']?.loadRegime;
66
+ const safetyFunc = slotNode?.properties?.safetyFunction || slotMetaMap['SLOT_FRONT_SUSPENSION']?.safetyFunction;
67
+
68
+ // RULE 1: Context Inheritance (Mounted in Dynamic_Cyclic Slot -> Active_Cyclic_Stress)
69
+ let rule1Passed = false;
70
+ const stressId = `Inf_Stress_${partId}`;
71
+ if (state.qdikw.rules.rule1 && loadRegime === 'DYNAMIC_CYCLIC') {
72
+ rule1Passed = true;
73
+ newNodes.push({
74
+ id: stressId,
75
+ label: 'ACTIVE_CYCLIC_STRESS',
76
+ type: 'Quality',
77
+ properties: { rule: 'Rule 1: Context Inheritance' }
78
+ });
79
+ newEdges.push({
80
+ id: `edge_r1_${partId}`,
81
+ from: slotId,
82
+ to: stressId,
83
+ label: 'infers_stress',
84
+ type: 'inherence',
85
+ properties: { isCurrent: true }
86
+ });
87
+ newEdges.push({
88
+ id: `edge_r1_part_${partId}`,
89
+ from: stressId,
90
+ to: partId,
91
+ label: 'acts_on',
92
+ type: 'inherence',
93
+ properties: { isCurrent: true }
94
+ });
95
+ }
96
+
97
+ const defects = activeDefects[partId] || [];
98
+ defects.forEach(defect => {
99
+ const defName = (defect.name || '').toLowerCase();
100
+
101
+ // RULE 2: Material Physics (Active_Cyclic_Stress + Crack > 10mm -> Rapid_Fracture_Propagation)
102
+ let rule2Passed = false;
103
+ const fracId = `Inf_Fracture_${partId}`;
104
+ if (state.qdikw.rules.rule2 && rule1Passed && defName === 'crack') {
105
+ const sizeMm = parseFloat(defect.val) || 0;
106
+ if (sizeMm > 10) {
107
+ rule2Passed = true;
108
+ newNodes.push({
109
+ id: fracId,
110
+ label: 'RAPID_FRACTURE_PROPAGATION',
111
+ type: 'Defect',
112
+ properties: { rule: 'Rule 2: Crack > 10mm' }
113
+ });
114
+ newEdges.push({
115
+ id: `edge_r2_${partId}`,
116
+ from: stressId,
117
+ to: fracId,
118
+ label: 'triggers_fracture',
119
+ type: 'has_defect',
120
+ properties: { isCurrent: true }
121
+ });
122
+ }
123
+ }
124
+
125
+ // RULE 3: Functional Safety (Rapid_Fracture + Steering_Control -> LOSS_OF_CONTROL)
126
+ const hazardId = `Inf_Hazard_LOC`;
127
+ if (state.qdikw.rules.rule3 && rule2Passed && safetyFunc === 'STEERING_CONTROL') {
128
+ newNodes.push({
129
+ id: hazardId,
130
+ label: 'HAZARD: LOSS_OF_CONTROL',
131
+ type: 'Defect',
132
+ properties: { severity: 'CRITICAL' }
133
+ });
134
+ newEdges.push({
135
+ id: `edge_r3_${partId}`,
136
+ from: fracId,
137
+ to: hazardId,
138
+ label: 'causes_hazard',
139
+ type: 'has_defect',
140
+ properties: { isCurrent: true }
141
+ });
142
+
143
+ wisdomAlerts.push(
144
+ `CRITICAL HAZARD: Loss_of_Control risk on Vehicle_1 via ${partId} (15mm crack under Dynamic_Cyclic load). Ground vehicle & generate work order for suspension arm replacement.`
145
+ );
146
+
147
+ // On Stage W (Wisdom), also project the prescriptive directive node onto the graph canvas
148
+ if (state.qdikw.stage === 'W') {
149
+ const wisdomNodeId = `Wisdom_Directive_Vehicle_1`;
150
+ newNodes.push({
151
+ id: wisdomNodeId,
152
+ label: 'DIRECTIVE: GROUND VEHICLE_1',
153
+ type: 'Defect',
154
+ properties: { action: 'Replace Arm SN_404' }
155
+ });
156
+ newEdges.push({
157
+ id: `edge_wisdom_${partId}`,
158
+ from: hazardId,
159
+ to: wisdomNodeId,
160
+ label: 'prescribes_action',
161
+ type: 'has_defect',
162
+ properties: { isCurrent: true }
163
+ });
164
+ }
165
+ }
166
+
167
+ // BLIND SPOT: Unmapped Defect (e.g. surface_corrosion)
168
+ if (defName !== 'crack') {
169
+ const blindNodeId = `BlindSpot_${defect.name}`;
170
+ newNodes.push({
171
+ id: blindNodeId,
172
+ label: `UNMAPPED: ${defect.name} (${defect.val})`,
173
+ type: 'Quality',
174
+ properties: { status: 'STOPPED AT INFORMATION LAYER', action: 'Escalate to Specialist' }
175
+ });
176
+ newEdges.push({
177
+ id: `edge_blind_${partId}_${defect.name}`,
178
+ from: partId,
179
+ to: blindNodeId,
180
+ label: 'no_SMRM_rule',
181
+ type: 'inherence',
182
+ properties: { isCurrent: true }
183
+ });
184
+
185
+ blindSpots.push(
186
+ `Unmapped Engineering Condition (${defect.name} = ${defect.val}): Automated inference stopped at Information layer. Escalate to a human Materials Specialist.`
187
+ );
188
+ }
189
+ });
190
+ });
191
+
192
+ // Deduplicate and append inferred nodes & edges
193
+ newNodes.forEach(nn => {
194
+ if (!graph.nodes.some(existing => existing.id === nn.id)) {
195
+ graph.nodes.push(nn);
196
+ }
197
+ });
198
+ newEdges.forEach(ne => {
199
+ if (!graph.edges.some(existing => existing.id === ne.id)) {
200
+ graph.edges.push(ne);
201
+ }
202
+ });
203
+
204
+ graph.wisdomAlerts = [...new Set(wisdomAlerts)];
205
+ graph.blindSpots = [...new Set(blindSpots)];
206
+
207
+ return graph;
208
+ }
js/state.js CHANGED
@@ -1,128 +1,68 @@
1
  import { reactive } from 'vue';
2
- export { ENTITY_CLASSES, RELATION_TYPES, inferEntityClass } from './smrm/definitions.js';
3
 
4
  /**
5
- * SINGLE SOURCE OF TRUTH (Event Sourcing & Workbench State)
6
- * ---------------------------------------------------------
7
- * Central reactive store eliminating duplicate state/settings watchers.
8
- *
9
- * Perspective values (4 unified viewpoints):
10
- * - 'SMRM' : Engineer Perspective (domain hierarchy, slots/states collapsed)
11
- * - 'SMIM' : Logical Perspective (canonical 3D BFO / 4D ISO 15926 / Naive topology)
12
- * - 'SMS_LPG' : Physical LPG Perspective (Property Graph storage & state transitions)
13
- * - 'SMS_RDF' : Physical RDF Perspective (W3C RDF triples, reification & literals)
14
  */
 
15
  export const state = reactive({
16
- // 1. Navigation View ('MENU' | 'SANDBOX' | 'SCENARIO')
17
  currentView: 'MENU',
18
-
19
- // 2. User Role ('UNI_ENGINEER')
20
  userRole: 'UNI_ENGINEER',
21
-
22
- // 3. Global Time Dimension
23
- currentTime: 0,
24
-
25
- // 4. Current Domain Ontology ('NAIVE_NODE' | 'NAIVE_EDGE' | 'BFO' | 'ISO15926')
26
- ontology: 'NAIVE_NODE',
27
-
28
- // 5. Unified Perspective ('SMRM' | 'SMIM' | 'SMS_LPG' | 'SMS_RDF')
29
  perspective: 'SMRM',
30
-
31
- // 6. Active Physical Storage Paradigm ('LPG' | 'RDF')
32
- // Automatically switched when selecting 'SMS_LPG' or 'SMS_RDF'
33
  storage: 'LPG',
34
-
35
- // 7. Visual Graph Engine ('VIS' | 'MERMAID')
36
  graphEngine: 'VIS',
37
-
38
- // 8. UI Locale ('sv' | 'en' | 'ru')
39
  language: 'en',
40
-
41
- // 9. Toggle visibility of historical (closed) relationships
42
  showHistory: true,
43
-
44
- // 10. The Event Log (Pure business events)
45
  eventLog: [],
46
 
47
- // 11. Monotonic counter for unique event IDs
48
- edgeSequence: 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  });
50
 
51
- /**
52
- * Advances the global system time by one unit (T = T + 1).
53
- */
54
  export function advanceTime() {
55
  state.currentTime++;
56
  }
57
 
58
- /**
59
- * Returns the next monotonic sequence integer and increments the counter.
60
- * @returns {number}
61
- */
62
- export function nextSequence() {
63
- return state.edgeSequence++;
64
  }
65
 
66
- /**
67
- * Sets the active perspective and synchronises the physical storage mode ('LPG' | 'RDF')
68
- * so that UNDER THE BONNET and DATABASE QUERY always match the selected Physical view.
69
- *
70
- * @param {'SMRM'|'SMIM'|'SMS_LPG'|'SMS_RDF'|'SMS'} newPerspective
71
- */
72
- export function setPerspective(newPerspective) {
73
- if (newPerspective === 'SMS_LPG') {
74
- state.perspective = 'SMS_LPG';
75
- state.storage = 'LPG';
76
- } else if (newPerspective === 'SMS_RDF') {
77
- state.perspective = 'SMS_RDF';
78
- state.storage = 'RDF';
79
- } else if (newPerspective === 'SMS') {
80
- state.perspective = state.storage === 'RDF' ? 'SMS_RDF' : 'SMS_LPG';
81
- } else if (newPerspective === 'SMIM' || newPerspective === 'SMRM') {
82
- state.perspective = newPerspective;
83
- }
84
  }
85
 
86
- /**
87
- * Completely replaces or updates the current state from a saved JSON object or scenario.
88
- *
89
- * @param {Object} newState - State payload to inject.
90
- */
91
  export function loadState(newState) {
92
- if (!newState || typeof newState !== 'object') return;
93
-
94
- if (newState.currentView !== undefined) {
95
- state.currentView = newState.currentView;
96
- }
97
- if (newState.userRole !== undefined) {
98
- state.userRole = newState.userRole;
99
- }
100
- if (newState.ontology !== undefined) {
101
- const onto = newState.ontology;
102
- state.ontology = onto === 'ISO_15926_4D' ? 'ISO15926' : (onto === 'NAIVE' ? 'NAIVE_NODE' : onto);
103
- }
104
- if (newState.storage === 'LPG' || newState.storage === 'RDF') {
105
- state.storage = newState.storage;
106
- }
107
- if (newState.perspective !== undefined) {
108
- setPerspective(newState.perspective);
109
- }
110
- if (newState.currentTime !== undefined) {
111
- state.currentTime = newState.currentTime;
112
- }
113
- if (Array.isArray(newState.eventLog)) {
114
  state.eventLog.splice(0, state.eventLog.length, ...newState.eventLog);
115
  }
116
- if (newState.edgeSequence !== undefined) {
117
- state.edgeSequence = newState.edgeSequence;
118
- }
119
- if (newState.graphEngine !== undefined) {
120
- state.graphEngine = String(newState.graphEngine).toUpperCase() === 'MERMAID' ? 'MERMAID' : 'VIS';
121
- }
122
- if (newState.language !== undefined) {
123
- state.language = newState.language;
124
- }
125
- if (newState.showHistory !== undefined) {
126
- state.showHistory = Boolean(newState.showHistory);
127
- }
128
  }
 
1
  import { reactive } from 'vue';
 
2
 
3
  /**
4
+ * SINGLE SOURCE OF TRUTH (Event Sourcing & App State)
5
+ * ---------------------------------------------------
 
 
 
 
 
 
 
6
  */
7
+
8
  export const state = reactive({
 
9
  currentView: 'MENU',
 
 
10
  userRole: 'UNI_ENGINEER',
11
+ ontology: 'BFO',
 
 
 
 
 
 
 
12
  perspective: 'SMRM',
 
 
 
13
  storage: 'LPG',
 
 
14
  graphEngine: 'VIS',
 
 
15
  language: 'en',
 
 
16
  showHistory: true,
17
+ currentTime: 0,
18
+ edgeSequence: 1,
19
  eventLog: [],
20
 
21
+ // --- NEW: Narrative Figures & QDIKW Mode State ---
22
+ figureOverlay: {
23
+ visible: false,
24
+ src: '',
25
+ caption: '',
26
+ attributionHtml: ''
27
+ },
28
+
29
+ qdikw: {
30
+ active: false,
31
+ stage: 'INTRO', // 'INTRO', 'Q', 'D', 'I', 'K', 'W'
32
+ activeRole: '',
33
+ roleBadge: '',
34
+ questionText: '',
35
+ slotMetadata: {}, // Хранит { SLOT_ID: { loadRegime: '...', safetyFunction: '...' } }
36
+ rules: {
37
+ rule1: false, // Наследование контекста (Slot -> Stress)
38
+ rule2: false, // Физика материалов (Stress + Crack > 10 -> Fracture)
39
+ rule3: false // Функциональная безопасность (Fracture + Steering -> Loss of Control)
40
+ }
41
+ }
42
  });
43
 
 
 
 
44
  export function advanceTime() {
45
  state.currentTime++;
46
  }
47
 
48
+ export function setPerspective(view) {
49
+ state.perspective = view;
 
 
 
 
50
  }
51
 
52
+ export function nextSequence() {
53
+ return state.edgeSequence++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
55
 
 
 
 
 
 
56
  export function loadState(newState) {
57
+ if (newState.ontology) state.ontology = newState.ontology;
58
+ if (newState.perspective) state.perspective = newState.perspective;
59
+ if (newState.storage) state.storage = newState.storage;
60
+ if (newState.graphEngine) state.graphEngine = newState.graphEngine;
61
+ if (newState.language) state.language = newState.language;
62
+ if (newState.showHistory !== undefined) state.showHistory = newState.showHistory;
63
+ if (newState.currentTime !== undefined) state.currentTime = newState.currentTime;
64
+ if (newState.edgeSequence !== undefined) state.edgeSequence = newState.edgeSequence;
65
+ if (newState.eventLog) {
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  state.eventLog.splice(0, state.eventLog.length, ...newState.eventLog);
67
  }
 
 
 
 
 
 
 
 
 
 
 
 
68
  }
narratives/General_QDIKW.mp3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d1a80834a2a63b570068bc28ae084fabc83665d0f5caa12cf98a77ac1fe587b1
3
+ size 12177771
narratives/General_QDIKW_eng.srt ADDED
@@ -0,0 +1,496 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1
2
+ 00:00:00,140 --> 00:00:03,540
3
+ Welcome to the QDIKW demonstrator.
4
+
5
+ 2
6
+ 00:00:04,320 --> 00:00:09,060
7
+ In consulting slides, the data,
8
+ information, knowledge, wisdom pyramid is
9
+
10
+ 3
11
+ 00:00:09,060 --> 00:00:10,600
12
+ often presented like magic.
13
+
14
+ 4
15
+ 00:00:11,260 --> 00:00:15,540
16
+ Pour raw data into a graph and executive
17
+ wisdom comes out the other side.
18
+
19
+ 5
20
+ 00:00:16,360 --> 00:00:21,700
21
+ That illusion makes it look as if a single
22
+ all-knowing mega brain is doing all the work.
23
+
24
+ 6
25
+ 00:00:22,420 --> 00:00:25,920
26
+ And if such a mega brain existed, we
27
+ wouldn't need a knowledge management
28
+
29
+ 7
30
+ 00:00:25,920 --> 00:00:26,680
31
+ system at all.
32
+
33
+ 8
34
+ 00:00:27,400 --> 00:00:32,240
35
+ In real systems engineering, there is no
36
+ magic. There is only the law of
37
+
38
+ 9
39
+ 00:00:32,240 --> 00:00:34,180
40
+ conservation of engineering effort.
41
+
42
+ 10
43
+ 00:00:34,800 --> 00:00:37,960
44
+ A knowledge system cannot invent physics
45
+ out of thin air.
46
+
47
+ 11
48
+ 00:00:38,600 --> 00:00:41,400
49
+ Its true power is separating human roles.
50
+
51
+ 12
52
+ 00:00:42,060 --> 00:00:47,260
53
+ Today, various specialists already do this
54
+ hard work, but their outputs are trapped
55
+
56
+ 13
57
+ 00:00:47,260 --> 00:00:51,340
58
+ in disconnected Word documents, CAD files,
59
+ and Excel spreadsheets.
60
+
61
+ 14
62
+ 00:00:52,000 --> 00:00:56,940
63
+ Let's walk through the five stages from
64
+ question to wisdom and see not just what
65
+
66
+ 15
67
+ 00:00:56,940 --> 00:01:01,280
68
+ happens on screen, but who had to do what
69
+ beforehand to make it work.
70
+
71
+ 16
72
+ 00:01:02,000 --> 00:01:03,860
73
+ Stage one: the question.
74
+
75
+ 17
76
+ 00:01:05,920 --> 00:01:11,200
77
+ A fleet operator asks a seemingly simple
78
+ question. "A crack was just reported on
79
+
80
+ 18
81
+ 00:01:11,200 --> 00:01:16,100
82
+ vehicle one. Is it safe to dispatch or is
83
+ there a risk of structural failure?"
84
+
85
+ 19
86
+ 00:01:16,900 --> 00:01:19,280
87
+ Here we hit the first expectation trap.
88
+
89
+ 20
90
+ 00:01:20,040 --> 00:01:23,320
91
+ One may assume the system will magically
92
+ spot any flaw.
93
+
94
+ 21
95
+ 00:01:24,040 --> 00:01:28,400
96
+ In reality, the system can only answer
97
+ questions if two people laid the
98
+
99
+ 22
100
+ 00:01:28,400 --> 00:01:31,380
101
+ groundwork long before vehicle one was
102
+ even built.
103
+
104
+ 23
105
+ 00:01:32,260 --> 00:01:38,780
106
+ First, the IT and database architect at
107
+ the SMS and SMIM layers had to program the
108
+
109
+ 24
110
+ 00:01:38,780 --> 00:01:44,200
111
+ graph database to support temporal
112
+ states, hierarchical paths, and rule execution.
113
+
114
+ 25
115
+ 00:01:46,580 --> 00:01:52,240
116
+ Second, the ontology modeler at the SMRM
117
+ layer had to define the controlled vocabulary,
118
+
119
+ 26
120
+ 00:01:52,840 --> 00:01:59,580
121
+ creating explicit classes for vehicles,
122
+ slots, parts, defects, load types, and hazards.
123
+
124
+ 27
125
+ 00:02:02,040 --> 00:02:06,340
126
+ You cannot ask a question if the database
127
+ lacks the grammar to express it.
128
+
129
+ 28
130
+ 00:02:08,479 --> 00:02:10,320
131
+ Stage two: data.
132
+
133
+ 29
134
+ 00:02:12,820 --> 00:02:16,040
135
+ A maintenance technician in the workshop
136
+ inspects the vehicle.
137
+
138
+ 30
139
+ 00:02:17,020 --> 00:02:21,160
140
+ Notice that the defect does not magically
141
+ attach itself to a component.
142
+
143
+ 31
144
+ 00:02:22,060 --> 00:02:25,760
145
+ The technician scans the barcode of a
146
+ specific physical part,
147
+
148
+ 32
149
+ 00:02:26,360 --> 00:02:31,840
150
+ serial number ARM_SN_404, and logs
151
+
152
+ 33
153
+ 00:02:31,840 --> 00:02:37,740
154
+ DEFECT_742, selecting crack and typing 15
155
+ millimeters.
156
+
157
+ 34
158
+ 00:02:40,380 --> 00:02:42,460
159
+ Why is this still just raw data?
160
+
161
+ 35
162
+ 00:02:43,120 --> 00:02:47,740
163
+ Because the technician isn't typing
164
+ freeform prose. They are constrained by
165
+
166
+ 36
167
+ 00:02:47,740 --> 00:02:51,840
168
+ the dropdown menus that the database
169
+ programmer and ontologist built for them.
170
+
171
+ 37
172
+ 00:02:52,500 --> 00:02:57,300
173
+ Yet, at this level, the record is just an
174
+ isolated observation on a serial number.
175
+
176
+ 38
177
+ 00:02:57,880 --> 00:03:01,940
178
+ The technician doesn't know fracture
179
+ mechanics, and the raw log doesn't know
180
+
181
+ 39
182
+ 00:03:01,940 --> 00:03:06,720
183
+ what role ARM_SN_404 plays in the vehicle.
184
+
185
+ 40
186
+ 00:03:09,400 --> 00:03:14,300
187
+ Stage three: information,
188
+ giving data structural context.
189
+
190
+ 41
191
+ 00:03:16,460 --> 00:03:20,480
192
+ This brings us to the most critical
193
+ question in engineering data management.
194
+
195
+ 42
196
+ 00:03:21,200 --> 00:03:25,320
197
+ How does the system know that this part is
198
+ under dynamic cyclic loading?
199
+
200
+ 43
201
+ 00:03:26,140 --> 00:03:31,280
202
+ If we forced the 3D CAD designer who
203
+ models a suspension arm in a CAD tool to
204
+
205
+ 44
206
+ 00:03:31,280 --> 00:03:36,320
207
+ manually fill in 40 ontological attributes
208
+ about cyclic loads and vehicle-level
209
+
210
+ 45
211
+ 00:03:36,320 --> 00:03:39,160
212
+ hazards, the project would fail within a
213
+ week.
214
+
215
+ 46
216
+ 00:03:39,880 --> 00:03:44,140
217
+ Component designers shouldn't have to
218
+ guess system-level physics, and a spare
219
+
220
+ 47
221
+ 00:03:44,140 --> 00:03:49,500
222
+ part sitting on a shelf in warehouse_1
223
+ experiences zero cyclic load anyway.
224
+
225
+ 48
226
+ 00:03:50,240 --> 00:03:55,240
227
+ Instead, look at how IEC 63339 separates
228
+ their work.
229
+
230
+ 49
231
+ 00:03:57,260 --> 00:04:04,220
232
+ The 3D CAD designer simply registers
233
+ ARM_SN_404 and places it
234
+
235
+ 50
236
+ 00:04:04,220 --> 00:04:06,420
237
+ into the assembly tree. Nothing more.
238
+
239
+ 51
240
+ 00:04:08,920 --> 00:04:14,420
241
+ Meanwhile, the systems architect, or an
242
+ automated import from a DFMEA safety
243
+
244
+ 52
245
+ 00:04:14,420 --> 00:04:17,560
246
+ table, defines the functional architecture
247
+ once.
248
+
249
+ 53
250
+ 00:04:18,220 --> 00:04:24,680
251
+ They mark the functional slot,
252
+ SLOT_FRONT_SUSPENSION, as experiencing
253
+
254
+ 54
255
+ 00:04:24,680 --> 00:04:30,200
256
+ DYNAMIC_CYCLIC loading and serving the
257
+ STEERING_CONTROL function.
258
+
259
+ 55
260
+ 00:04:32,920 --> 00:04:37,880
261
+ The moment ARM_SN_404 is mounted into
262
+
263
+ 56
264
+ 00:04:37,880 --> 00:04:44,600
265
+ SLOT_FRONT_SUSPENSION, the graph
266
+ automatically inherits that operational context.
267
+
268
+ 57
269
+ 00:04:45,260 --> 00:04:49,960
270
+ The part now carries dynamic cyclic
271
+ loading, not because someone hardcoded it
272
+
273
+ 58
274
+ 00:04:49,960 --> 00:04:53,880
275
+ onto the metal, but because of where it
276
+ currently sits in the architecture.
277
+
278
+ 59
279
+ 00:04:56,700 --> 00:04:58,640
280
+ Stage four: knowledge.
281
+
282
+ 60
283
+ 00:05:00,400 --> 00:05:05,320
284
+ How does the system connect a
285
+ 15-millimeter crack to a catastrophic failure?
286
+
287
+ 61
288
+ 00:05:06,780 --> 00:05:10,020
289
+ Here, a materials and fatigue specialist
290
+ steps in.
291
+
292
+ 62
293
+ 00:05:10,820 --> 00:05:15,060
294
+ This expert knows nothing about Cypher
295
+ queries or RDF triples.
296
+
297
+ 63
298
+ 00:05:15,820 --> 00:05:20,040
299
+ Working purely with the pre-approved
300
+ building blocks in the domain dictionary,
301
+
302
+ 64
303
+ 00:05:20,040 --> 00:05:22,600
304
+ they formulate modular atomic rules.
305
+
306
+ 65
307
+ 00:05:23,380 --> 00:05:25,880
308
+ Rule one: context inheritance.
309
+
310
+ 66
311
+ 00:05:26,580 --> 00:05:31,860
312
+ Any part mounted in a slot with
313
+ DYNAMIC_CYCLIC regime is subject to
314
+
315
+ 67
316
+ 00:05:31,860 --> 00:05:34,660
317
+ ACTIVE_CYCLIC_STRESS.
318
+
319
+ 68
320
+ 00:05:36,060 --> 00:05:38,280
321
+ Rule two: material physics.
322
+
323
+ 69
324
+ 00:05:39,040 --> 00:05:45,720
325
+ A crack exceeding 10 millimeters on a part
326
+ under ACTIVE_CYCLIC_STRESS triggers
327
+
328
+ 70
329
+ 00:05:45,720 --> 00:05:48,740
330
+ RAPID_FRACTURE_PROPAGATION.
331
+
332
+ 71
333
+ 00:05:50,540 --> 00:05:52,720
334
+ Rule three: functional safety.
335
+
336
+ 72
337
+ 00:05:53,460 --> 00:06:00,240
338
+ RAPID_FRACTURE_PROPAGATION in any slot
339
+ supporting STEERING_CONTROL
340
+
341
+ 73
342
+ 00:06:00,240 --> 00:06:01,640
343
+ causes a system hazard,
344
+
345
+ 74
346
+ 00:06:02,320 --> 00:06:05,000
347
+ LOSS_OF_CONTROL.
348
+
349
+ 75
350
+ 00:06:06,888 --> 00:06:07,948
351
+ Notice the boundary.
352
+
353
+ 76
354
+ 00:06:08,568 --> 00:06:13,328
355
+ The materials expert couldn't invent new
356
+ database structures. They could only wire
357
+
358
+ 77
359
+ 00:06:13,328 --> 00:06:17,548
360
+ together concepts that the IT architect
361
+ and ontologist made available.
362
+
363
+ 78
364
+ 00:06:18,288 --> 00:06:22,328
365
+ Because the graph engine supports
366
+ transitive inference, these three
367
+
368
+ 79
369
+ 00:06:22,328 --> 00:06:27,368
370
+ independent rules snap together like Lego
371
+ bricks, automatically building a causal
372
+
373
+ 80
374
+ 00:06:27,368 --> 00:06:31,268
375
+ bridge from the technician's barcode scan
376
+ to a vehicle-level failure.
377
+
378
+ 81
379
+ 00:06:33,668 --> 00:06:36,388
380
+ Finally, stage five, wisdom.
381
+
382
+ 82
383
+ 00:06:37,128 --> 00:06:40,028
384
+ Turning inferred knowledge into an
385
+ actionable decision.
386
+
387
+ 83
388
+ 00:06:42,088 --> 00:06:46,928
389
+ Traversing the causal chain, the system
390
+ tells the fleet operator, "Critical
391
+
392
+ 84
393
+ 00:06:46,928 --> 00:06:51,948
394
+ hazard. Loss of control risk for ground
395
+ vehicle one. Generate work order for
396
+
397
+ 85
398
+ 00:06:51,948 --> 00:06:53,448
399
+ suspension arm replacement."
400
+
401
+ 86
402
+ 00:06:55,668 --> 00:06:59,068
403
+ But what happens when reality steps
404
+ outside these rules?
405
+
406
+ 87
407
+ 00:07:00,868 --> 00:07:02,848
408
+ Let's test the system's blind spot.
409
+
410
+ 88
411
+ 00:07:03,588 --> 00:07:07,588
412
+ Suppose the technician logs a second
413
+ observation on the exact same part,
414
+
415
+ 89
416
+ 00:07:08,208 --> 00:07:14,428
417
+ defect_743, surface_corrosion, five square
418
+ centimeters.
419
+
420
+ 90
421
+ 00:07:15,368 --> 00:07:20,188
422
+ Watch the graph. The corrosion record
423
+ passes through data and attaches to the
424
+
425
+ 91
426
+ 00:07:20,188 --> 00:07:25,408
427
+ suspension slot as information,
428
+ and then it stops. Why?
429
+
430
+ 92
431
+ 00:07:26,088 --> 00:07:30,268
432
+ Because the materials expert hasn't
433
+ authored a rule linking surface corrosion
434
+
435
+ 93
436
+ 00:07:30,268 --> 00:07:31,768
437
+ area to cyclic fracture,
438
+
439
+ 94
440
+ 00:07:32,488 --> 00:07:36,408
441
+ or perhaps the database lacks the
442
+ mathematical operators to calculate
443
+
444
+ 95
445
+ 00:07:36,408 --> 00:07:37,848
446
+ cross-sectional rust loss.
447
+
448
+ 96
449
+ 00:07:38,668 --> 00:07:43,648
450
+ Instead of hallucinating or silently
451
+ hiding the problem, a properly architected
452
+
453
+ 97
454
+ 00:07:43,648 --> 00:07:47,348
455
+ system explicitly flags an unmapped
456
+ engineering condition.
457
+
458
+ 98
459
+ 00:07:48,008 --> 00:07:50,728
460
+ Automated inference stopped at the
461
+ information layer.
462
+
463
+ 99
464
+ 00:07:51,348 --> 00:07:55,968
465
+ Escalate defect_743 to a human materials
466
+ specialist.
467
+
468
+ 100
469
+ 00:07:59,068 --> 00:08:03,688
470
+ That is the real takeaway of this
471
+ workbench. A knowledge graph is not a
472
+
473
+ 101
474
+ 00:08:03,688 --> 00:08:09,168
475
+ crystal ball. Without it, five specialists
476
+ still do all this work in isolated
477
+
478
+ 102
479
+ 00:08:09,168 --> 00:08:12,648
480
+ documents, and it takes days of meetings
481
+ to connect the dots.
482
+
483
+ 103
484
+ 00:08:13,328 --> 00:08:18,388
485
+ With it, each role contributes their piece
486
+ of the puzzle once within clear technical
487
+
488
+ 104
489
+ 00:08:18,388 --> 00:08:23,128
490
+ boundaries, allowing the system to
491
+ connect those dots in milliseconds while
492
+
493
+ 105
494
+ 00:08:23,128 --> 00:08:26,608
495
+ honestly showing where human engineering
496
+ judgment must take over.
styles/main.css CHANGED
@@ -934,4 +934,208 @@ pre.query-code-block {
934
  max-width: none !important;
935
  height: auto;
936
  min-width: 100%; /* Граф не будет меньше ширины экрана, но сможет стать больше */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
937
  }
 
934
  max-width: none !important;
935
  height: auto;
936
  min-width: 100%; /* Граф не будет меньше ширины экрана, но сможет стать больше */
937
+ }
938
+
939
+ /* --- Fullscreen Narrative Figure Overlay (./figures/) --- */
940
+ .figure-modal-overlay {
941
+ position: fixed;
942
+ inset: 0;
943
+ background: rgba(15, 23, 42, 0.88);
944
+ backdrop-filter: blur(8px);
945
+ z-index: 850;
946
+ display: flex;
947
+ flex-direction: column;
948
+ justify-content: center;
949
+ align-items: center;
950
+ padding: 32px 24px 110px 24px;
951
+ animation: fadeInFigure 0.35s ease;
952
+ }
953
+
954
+ @keyframes fadeInFigure {
955
+ from { opacity: 0; transform: scale(0.98); }
956
+ to { opacity: 1; transform: scale(1); }
957
+ }
958
+
959
+ .figure-modal-card {
960
+ background: #ffffff;
961
+ border-radius: 14px;
962
+ padding: 24px;
963
+ max-width: 960px;
964
+ width: 92%;
965
+ max-height: 78vh;
966
+ display: flex;
967
+ flex-direction: column;
968
+ align-items: center;
969
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
970
+ border: 2px solid #4f46e5;
971
+ position: relative;
972
+ }
973
+
974
+ .figure-modal-close {
975
+ position: absolute;
976
+ top: 12px;
977
+ right: 16px;
978
+ background: #f1f5f9;
979
+ border: none;
980
+ border-radius: 6px;
981
+ padding: 4px 10px;
982
+ font-size: 13px;
983
+ font-weight: 700;
984
+ color: #334155;
985
+ cursor: pointer;
986
+ }
987
+
988
+ .figure-modal-img {
989
+ max-width: 100%;
990
+ max-height: 56vh;
991
+ object-fit: contain;
992
+ border-radius: 8px;
993
+ background: #f8fafc;
994
+ padding: 12px;
995
+ }
996
+
997
+ .figure-modal-caption {
998
+ margin-top: 14px;
999
+ font-size: 15px;
1000
+ font-weight: 600;
1001
+ color: #0f172a;
1002
+ text-align: center;
1003
+ }
1004
+
1005
+ .figure-modal-attribution {
1006
+ margin-top: 6px;
1007
+ font-size: 12px;
1008
+ color: #64748b;
1009
+ text-align: center;
1010
+ }
1011
+
1012
+ .figure-modal-attribution a {
1013
+ color: #0284c7;
1014
+ text-decoration: underline;
1015
+ }
1016
+
1017
+ /* --- QDIKW Stage Progress & Role Banner --- */
1018
+ .qdikw-banner {
1019
+ display: flex;
1020
+ align-items: center;
1021
+ justify-content: space-between;
1022
+ background: linear-gradient(90deg, #0f172a 0%, #1e293b 100%);
1023
+ color: #f8fafc;
1024
+ padding: 6px 14px;
1025
+ border-bottom: 2px solid #4f46e5;
1026
+ gap: 12px;
1027
+ flex-wrap: wrap;
1028
+ }
1029
+
1030
+ .qdikw-steps {
1031
+ display: flex;
1032
+ align-items: center;
1033
+ gap: 6px;
1034
+ }
1035
+
1036
+ .qdikw-step-pill {
1037
+ padding: 3px 10px;
1038
+ border-radius: 999px;
1039
+ font-size: 11px;
1040
+ font-weight: 700;
1041
+ background: #334155;
1042
+ color: #94a3b8;
1043
+ border: 1px solid #475569;
1044
+ cursor: pointer;
1045
+ transition: all 0.2s;
1046
+ }
1047
+
1048
+ .qdikw-step-pill.active {
1049
+ background: #4f46e5;
1050
+ color: #ffffff;
1051
+ border-color: #818cf8;
1052
+ box-shadow: 0 0 12px rgba(99, 102, 241, 0.6);
1053
+ transform: scale(1.05);
1054
+ }
1055
+
1056
+ .qdikw-role-box {
1057
+ display: flex;
1058
+ align-items: center;
1059
+ gap: 8px;
1060
+ font-size: 11.5px;
1061
+ }
1062
+
1063
+ .qdikw-role-name {
1064
+ background: #f59e0b;
1065
+ color: #0f172a;
1066
+ font-weight: 800;
1067
+ padding: 2px 8px;
1068
+ border-radius: 4px;
1069
+ }
1070
+
1071
+ .qdikw-role-desc {
1072
+ color: #cbd5e1;
1073
+ }
1074
+
1075
+ /* --- SMRM Semantic Rules & Slot Context Toolbar --- */
1076
+ .smrm-rules-row {
1077
+ display: flex;
1078
+ align-items: center;
1079
+ gap: 10px;
1080
+ background: #f5f3ff;
1081
+ border-top: 1px solid #ddd6fe;
1082
+ padding: 5px 12px;
1083
+ font-size: 11px;
1084
+ flex-wrap: wrap;
1085
+ }
1086
+
1087
+ .rule-chip {
1088
+ display: inline-flex;
1089
+ align-items: center;
1090
+ gap: 5px;
1091
+ padding: 3px 9px;
1092
+ border-radius: 6px;
1093
+ background: #ffffff;
1094
+ border: 1px solid #c4b5fd;
1095
+ color: #4c1d95;
1096
+ font-weight: 600;
1097
+ cursor: pointer;
1098
+ transition: all 0.2s;
1099
+ }
1100
+
1101
+ .rule-chip.active {
1102
+ background: #6d28d9;
1103
+ color: #ffffff;
1104
+ border-color: #5b21b6;
1105
+ }
1106
+
1107
+ /* --- Amber Highlight for Active Operations --- */
1108
+ @keyframes amberPulse {
1109
+ 0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.85); }
1110
+ 70% { box-shadow: 0 0 0 9px rgba(245, 158, 11, 0); }
1111
+ 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
1112
+ }
1113
+
1114
+ .tour-amber-highlight {
1115
+ outline: 2.5px solid #f59e0b !important;
1116
+ outline-offset: 2px;
1117
+ animation: amberPulse 1.6s infinite;
1118
+ position: relative;
1119
+ z-index: 35;
1120
+ }
1121
+
1122
+ /* --- Wisdom & Blind Spot Cards --- */
1123
+ .wisdom-directive-card {
1124
+ margin-top: 8px;
1125
+ padding: 8px 10px;
1126
+ border-radius: 6px;
1127
+ background: #fef2f2;
1128
+ border-left: 4px solid #dc2626;
1129
+ color: #7f1d1d;
1130
+ font-size: 11px;
1131
+ }
1132
+
1133
+ .blindspot-warning-card {
1134
+ margin-top: 6px;
1135
+ padding: 8px 10px;
1136
+ border-radius: 6px;
1137
+ background: #fffbeb;
1138
+ border-left: 4px solid #f59e0b;
1139
+ color: #78350f;
1140
+ font-size: 11px;
1141
  }