File size: 33,806 Bytes
eabac12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
{
  "schema_version": "1.0.0",
  "phase": "PHASE_0_RUNTIME_SURFACE_MAPPING",
  "total_execution_maps": 8,
  "execution_maps": [
    {
      "capability_id": "CAP-FL-SIMULATION-START",
      "name": "Live Backend Federated Learning Simulation",
      "user_surfaces": [
        "frontend/src/pages/LiveOperationsView.tsx :: 'Start Simulation (Live)' Button",
        "frontend/src/components/FLRoundRunner.tsx :: 'Start FL Training Simulation' Button"
      ],
      "nodes": [
        {
          "id": "node-ui-trigger",
          "file": "frontend/src/pages/LiveOperationsView.tsx",
          "symbol": "LiveOperationsView.handleStartRealTraining",
          "line_range": "L841-L869",
          "role": "UI Event Handler & Mutation Trigger",
          "layer": "Presentation / UI",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-query-client",
          "file": "frontend/src/api/queries.ts",
          "symbol": "useCreateSimulation.mutationFn",
          "line_range": "L295-L302",
          "role": "HTTP Client / API Request",
          "layer": "Frontend Infrastructure",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-router-endpoint",
          "file": "backend/app/presentation/routers/simulation.py",
          "symbol": "create_simulation",
          "line_range": "L400-L489",
          "role": "FastAPI Route Handler (POST /api/v1/simulations)",
          "layer": "Presentation / API Router",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-async-dispatch",
          "file": "backend/app/presentation/routers/simulation.py",
          "symbol": "_run_simulation_in_process",
          "line_range": "L810-L925",
          "role": "Background Daemon Thread Spawner",
          "layer": "Application / Orchestration",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-simulation-service",
          "file": "backend/app/application/services/simulation_service.py",
          "symbol": "SimulationService.run_simulation",
          "line_range": "L108-L1095",
          "role": "Core Simulation Orchestrator",
          "layer": "Application Service",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-fl-engine",
          "file": "backend/app/application/services/fl_engine.py",
          "symbol": "FederatedLearningEngine.run_round",
          "line_range": "L310-L450",
          "role": "Round Execution & Model Broadcast",
          "layer": "Application / FL Engine",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-model-service",
          "file": "backend/app/application/services/model_service.py",
          "symbol": "ModelService.train_local",
          "line_range": "L180-L245",
          "role": "PyTorch Local Model Optimization",
          "layer": "Domain / Model Computation",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-byzantine-defense",
          "file": "backend/app/domain/byzantine_defense.py",
          "symbol": "KrumAggregator.aggregate / BulyanAggregator.aggregate",
          "line_range": "L65-L210",
          "role": "Robust Gradient Aggregation",
          "layer": "Domain / Cryptographic & Defense Math",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-evaluation",
          "file": "backend/app/application/services/simulation_service.py",
          "symbol": "SimulationService._evaluate_global_model",
          "line_range": "L922-L969",
          "role": "AUC, ROC, F1, Loss Metric Computation",
          "layer": "Application Service",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-websocket-broadcast",
          "file": "backend/app/presentation/websockets/manager.py",
          "symbol": "TrainingWebSocketManager.broadcast",
          "line_range": "L50-L95",
          "role": "WebSocket Event Streamer",
          "layer": "Presentation / WebSocket",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-store-results",
          "file": "backend/app/infrastructure/redis_store.py",
          "symbol": "RedisStore._simulation_results",
          "line_range": "L110-L165",
          "role": "In-Memory / Redis Persistence Store",
          "layer": "Infrastructure / Store",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-ui-charts",
          "file": "frontend/src/pages/LiveOperationsView.tsx",
          "symbol": "LiveOperationsView (LossChart, AUCChart, MetricsComparisonBarChart)",
          "line_range": "L1200-L1450",
          "role": "Visual Metric Renderer",
          "layer": "Presentation / UI",
          "runtime_classification": "RUNTIME_LIVE"
        }
      ],
      "edges": [
        {
          "from": "node-ui-trigger",
          "to": "node-query-client",
          "mechanism": "React Query mutateAsync call"
        },
        {
          "from": "node-query-client",
          "to": "node-router-endpoint",
          "mechanism": "HTTP POST /api/v1/simulations with JSON body"
        },
        {
          "from": "node-router-endpoint",
          "to": "node-async-dispatch",
          "mechanism": "threading.Thread(target=_run_simulation_in_process, daemon=True).start()"
        },
        {
          "from": "node-async-dispatch",
          "to": "node-simulation-service",
          "mechanism": "Method invocation run_simulation(config)"
        },
        {
          "from": "node-simulation-service",
          "to": "node-fl-engine",
          "mechanism": "Loop over num_rounds calling fl_engine.run_round"
        },
        {
          "from": "node-fl-engine",
          "to": "node-model-service",
          "mechanism": "Client training invocation per participating bank"
        },
        {
          "from": "node-fl-engine",
          "to": "node-byzantine-defense",
          "mechanism": "Gradient aggregation via Krum/TrimmedMean/Bulyan"
        },
        {
          "from": "node-fl-engine",
          "to": "node-evaluation",
          "mechanism": "Global model validation against holdout split"
        },
        {
          "from": "node-evaluation",
          "to": "node-websocket-broadcast",
          "mechanism": "training_ws_manager.broadcast round metrics event"
        },
        {
          "from": "node-evaluation",
          "to": "node-store-results",
          "mechanism": "Dict storage in Redis/In-memory store under simulation_id"
        },
        {
          "from": "node-websocket-broadcast",
          "to": "node-ui-charts",
          "mechanism": "WS message received on /ws/training updates React state"
        },
        {
          "from": "node-store-results",
          "to": "node-ui-charts",
          "mechanism": "GET /api/v1/simulations/{id} polling updates React state"
        }
      ],
      "user_visible_outputs": [
        "Current Round (int)",
        "Global Validation Loss (float)",
        "Global Validation ROC-AUC (float)",
        "Global Validation F1 Score (float)",
        "Bank-specific local metrics (loss, samples)",
        "Byzantine clients detected & isolated (list/badge)",
        "Cumulative training latency (ms)"
      ],
      "audit_boundaries": [
        "backend/app/presentation/routers/simulation.py:L810-L925 (Unbounded daemon thread execution)",
        "backend/app/infrastructure/redis_store.py:L110-L165 (Ephemeral in-memory fallback if Redis unavailable)",
        "backend/app/presentation/routers/simulation.py:L110-L140 (_seed_canonical_simulation pre-populates sim_fed_01)"
      ],
      "unresolved_edges": []
    },
    {
      "capability_id": "CAP-CLIENT-SIDE-SIMULATED-TRAINING",
      "name": "Frontend Client-Side Simulated Training Walk",
      "user_surfaces": [
        "frontend/src/pages/LiveOperationsView.tsx :: 'Start Simulation' Button (when trainingMode === 'mock')"
      ],
      "nodes": [
        {
          "id": "node-mock-button",
          "file": "frontend/src/pages/LiveOperationsView.tsx",
          "symbol": "LiveOperationsView.handleStartClick",
          "line_range": "L845-L865",
          "role": "UI Button Click Trigger",
          "layer": "Presentation / UI",
          "runtime_classification": "MOCK_SYNTHETIC_FALLBACK"
        },
        {
          "id": "node-client-loop",
          "file": "frontend/src/pages/LiveOperationsView.tsx",
          "symbol": "LiveOperationsView.startSimulatedTraining",
          "line_range": "L611-L685",
          "role": "Client-Side Timer Loop (setInterval/setTimeout)",
          "layer": "Presentation / UI State Logic",
          "runtime_classification": "MOCK_SYNTHETIC_FALLBACK"
        },
        {
          "id": "node-gaussian-walk",
          "file": "frontend/src/pages/LiveOperationsView.tsx",
          "symbol": "Math.random() Gaussian Noise Walk (aucRoom, lossRoom)",
          "line_range": "L625-L660",
          "role": "Synthetic Metric Formula Generator",
          "layer": "Presentation / UI Math",
          "runtime_classification": "MOCK_SYNTHETIC_FALLBACK"
        },
        {
          "id": "node-state-setter",
          "file": "frontend/src/pages/LiveOperationsView.tsx",
          "symbol": "setRounds, setCurrentRound, setLiveMetrics",
          "line_range": "L665-L680",
          "role": "React State Update",
          "layer": "Presentation / UI State",
          "runtime_classification": "MOCK_SYNTHETIC_FALLBACK"
        },
        {
          "id": "node-rendered-cards",
          "file": "frontend/src/pages/LiveOperationsView.tsx",
          "symbol": "LiveOperationsView UI Cards & Charts",
          "line_range": "L1200-L1350",
          "role": "Visual Chart Rendering",
          "layer": "Presentation / UI",
          "runtime_classification": "MOCK_SYNTHETIC_FALLBACK"
        }
      ],
      "edges": [
        {
          "from": "node-mock-button",
          "to": "node-client-loop",
          "mechanism": "startSimulatedTraining() call on click"
        },
        {
          "from": "node-client-loop",
          "to": "node-gaussian-walk",
          "mechanism": "Computes synthetic AUC & Loss per round step in browser memory"
        },
        {
          "from": "node-gaussian-walk",
          "to": "node-state-setter",
          "mechanism": "setLiveMetrics({...}) on timer tick"
        },
        {
          "from": "node-state-setter",
          "to": "node-rendered-cards",
          "mechanism": "Triggers React re-render of charts and metric badges"
        }
      ],
      "user_visible_outputs": [
        "Round progress (1..10)",
        "Simulated AUC progression",
        "Simulated Loss progression",
        "Simulated F1 progression"
      ],
      "audit_boundaries": [
        "frontend/src/pages/LiveOperationsView.tsx:L611-L685 (Completely bypasses backend API; zero network calls made)"
      ],
      "unresolved_edges": []
    },
    {
      "capability_id": "CAP-REALTIME-FRAUD-SCORING",
      "name": "Synchronous Real-Time Transaction Scoring",
      "user_surfaces": [
        "frontend/src/components/TransactionEvaluator.tsx :: 'Score Transaction' Button",
        "frontend/src/pages/LiveOperationsView.tsx :: Manual Transaction Tester"
      ],
      "nodes": [
        {
          "id": "node-score-ui",
          "file": "frontend/src/components/TransactionEvaluator.tsx",
          "symbol": "TransactionEvaluator.handleScore",
          "line_range": "L85-L120",
          "role": "UI Form Submission Trigger",
          "layer": "Presentation / UI",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-score-client",
          "file": "frontend/src/api/queries.ts",
          "symbol": "useScoreTransaction.mutationFn",
          "line_range": "L180-L195",
          "role": "POST /api/v1/fraud/score call",
          "layer": "Frontend Infrastructure",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-score-router",
          "file": "backend/app/presentation/routers/fraud.py",
          "symbol": "score_transaction",
          "line_range": "L145-L215",
          "role": "FastAPI Route Handler",
          "layer": "Presentation / Router",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-inference-engine",
          "file": "backend/app/application/services/inference_engine.py",
          "symbol": "InferenceEngine.predict_proba",
          "line_range": "L75-L140",
          "role": "PyTorch Model Forward Pass",
          "layer": "Application / Inference",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-risk-scorer",
          "file": "backend/app/domain/risk_scorer.py",
          "symbol": "RiskScorer.compute_composite_score",
          "line_range": "L45-L110",
          "role": "Domain Risk Calibrator & Decision Logic",
          "layer": "Domain / Risk Logic",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-score-audit",
          "file": "backend/app/infrastructure/audit_log.py",
          "symbol": "AuditLogger.record_decision",
          "line_range": "L50-L90",
          "role": "HMAC Hash-Chained Audit Trail Entry",
          "layer": "Infrastructure / Audit",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-score-result-ui",
          "file": "frontend/src/components/TransactionEvaluator.tsx",
          "symbol": "TransactionEvaluator (ScoreGauge, DecisionBadge)",
          "line_range": "L180-L240",
          "role": "Score Display & Explanation Trigger",
          "layer": "Presentation / UI",
          "runtime_classification": "RUNTIME_LIVE"
        }
      ],
      "edges": [
        {
          "from": "node-score-ui",
          "to": "node-score-client",
          "mechanism": "mutateAsync(payload)"
        },
        {
          "from": "node-score-client",
          "to": "node-score-router",
          "mechanism": "HTTP POST /api/v1/fraud/score"
        },
        {
          "from": "node-score-router",
          "to": "node-inference-engine",
          "mechanism": "predict_proba(features)"
        },
        {
          "from": "node-inference-engine",
          "to": "node-risk-scorer",
          "mechanism": "compute_composite_score(prob, velocity, graph_prior)"
        },
        {
          "from": "node-risk-scorer",
          "to": "node-score-audit",
          "mechanism": "record_decision(tx_id, score, decision)"
        },
        {
          "from": "node-score-router",
          "to": "node-score-result-ui",
          "mechanism": "HTTP JSON Response 200 with score, probability, risk_band"
        }
      ],
      "user_visible_outputs": [
        "Fraud Score (0-100)",
        "Probability (0.000-1.000)",
        "Decision (APPROVE | REVIEW | DECLINE)",
        "Risk Band (LOW | MEDIUM | HIGH | SEVERE)",
        "Execution Latency (ms)"
      ],
      "audit_boundaries": [
        "backend/app/application/services/inference_engine.py:L95-L115 (Fallback to heuristic scoring if PyTorch weights uninitialized)"
      ],
      "unresolved_edges": []
    },
    {
      "capability_id": "CAP-SHAP-EXPLAINABILITY",
      "name": "Feature Attribution & SHAP Explanation Generation",
      "user_surfaces": [
        "frontend/src/components/TransactionEvaluator.tsx :: 'Explain Score' / 'View SHAP Attribution'",
        "frontend/src/pages/CaseDetailPage.tsx :: SHAP Waterfall Chart"
      ],
      "nodes": [
        {
          "id": "node-shap-ui",
          "file": "frontend/src/components/TransactionEvaluator.tsx",
          "symbol": "TransactionEvaluator.handleExplain",
          "line_range": "L130-L160",
          "role": "UI Click Event",
          "layer": "Presentation / UI",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-shap-client",
          "file": "frontend/src/api/queries.ts",
          "symbol": "useExplainPrediction.mutationFn",
          "line_range": "L210-L225",
          "role": "POST /api/v1/explain/prediction call",
          "layer": "Frontend Infrastructure",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-shap-router",
          "file": "backend/app/presentation/routers/explain.py",
          "symbol": "explain_prediction",
          "line_range": "L85-L160",
          "role": "FastAPI Route Handler",
          "layer": "Presentation / Router",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-shap-service",
          "file": "backend/app/application/services/explainability_service.py",
          "symbol": "ExplainabilityService.compute_shap_values",
          "line_range": "L110-L245",
          "role": "KernelSHAP / TreeSHAP Evaluator",
          "layer": "Application / Explainability",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-shap-waterfall-ui",
          "file": "frontend/src/components/ShapWaterfallChart.tsx",
          "symbol": "ShapWaterfallChart",
          "line_range": "L45-L165",
          "role": "Bar/Waterfall Chart Rendering of Attribution Vectors",
          "layer": "Presentation / UI Component",
          "runtime_classification": "RUNTIME_LIVE"
        }
      ],
      "edges": [
        {
          "from": "node-shap-ui",
          "to": "node-shap-client",
          "mechanism": "mutateAsync({ transaction_id, features })"
        },
        {
          "from": "node-shap-client",
          "to": "node-shap-router",
          "mechanism": "HTTP POST /api/v1/explain/prediction"
        },
        {
          "from": "node-shap-router",
          "to": "node-shap-service",
          "mechanism": "compute_shap_values(model, sample)"
        },
        {
          "from": "node-shap-service",
          "to": "node-shap-waterfall-ui",
          "mechanism": "Returns base_value, shap_values, feature_names"
        }
      ],
      "user_visible_outputs": [
        "SHAP Base Value (float)",
        "Top Positive Drivers (features elevating risk)",
        "Top Negative Drivers (features lowering risk)",
        "Feature Attribution Bar / Waterfall Chart"
      ],
      "audit_boundaries": [
        "backend/app/application/services/explainability_service.py:L140-L165 (Approximated sampling background baseline if training data unavailable)"
      ],
      "unresolved_edges": []
    },
    {
      "capability_id": "CAP-FINCEN-SAR-XML-EXPORT",
      "name": "FinCEN Suspicious Activity Report (SAR) XML Export",
      "user_surfaces": [
        "frontend/src/pages/CaseDetailPage.tsx :: 'Export FinCEN SAR XML' Button"
      ],
      "nodes": [
        {
          "id": "node-sar-ui",
          "file": "frontend/src/pages/CaseDetailPage.tsx",
          "symbol": "CaseDetailPage.handleExportSarXml",
          "line_range": "L420-L460",
          "role": "UI Click Export Action",
          "layer": "Presentation / UI",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-sar-client",
          "file": "frontend/src/api/queries.ts",
          "symbol": "fetchSarXml",
          "line_range": "L450-L470",
          "role": "GET /api/v1/regulatory/sar/export/{sar_id} Request",
          "layer": "Frontend Infrastructure",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-sar-router",
          "file": "backend/app/presentation/routers/regulatory.py",
          "symbol": "export_fincen_sar_xml",
          "line_range": "L210-L295",
          "role": "FastAPI Route Handler",
          "layer": "Presentation / Router",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-sar-service",
          "file": "backend/app/application/services/fincen_sar_service.py",
          "symbol": "FinCENSARService.generate_xml_dossier",
          "line_range": "L95-L260",
          "role": "Schema-Conforming XML Builder (FinCEN SAR 2.0 XSD)",
          "layer": "Application / Regulatory Service",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-sar-validator",
          "file": "backend/app/domain/sar_generator.py",
          "symbol": "SARGenerator.validate_xsd",
          "line_range": "L40-L115",
          "role": "XSD Schema Validator & Checksum Generator",
          "layer": "Domain / Regulatory Rules",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-sar-download",
          "file": "frontend/src/pages/CaseDetailPage.tsx",
          "symbol": "Blob Download Trigger (window.URL.createObjectURL)",
          "line_range": "L445-L458",
          "role": "Browser File Download Trigger",
          "layer": "Presentation / UI",
          "runtime_classification": "RUNTIME_LIVE"
        }
      ],
      "edges": [
        {
          "from": "node-sar-ui",
          "to": "node-sar-client",
          "mechanism": "Invokes download handler"
        },
        {
          "from": "node-sar-client",
          "to": "node-sar-router",
          "mechanism": "GET /api/v1/regulatory/sar/export/{sar_id}"
        },
        {
          "from": "node-sar-router",
          "to": "node-sar-service",
          "mechanism": "generate_xml_dossier(sar_id)"
        },
        {
          "from": "node-sar-service",
          "to": "node-sar-validator",
          "mechanism": "validate_xsd(xml_content)"
        },
        {
          "from": "node-sar-validator",
          "to": "node-sar-router",
          "mechanism": "Returns validated XML bytes with SHA-256 digest"
        },
        {
          "from": "node-sar-router",
          "to": "node-sar-download",
          "mechanism": "HTTP 200 Response with Content-Type: application/xml"
        }
      ],
      "user_visible_outputs": [
        "FinCEN SAR XML 2.0 File Download",
        "SAR ID & Filing Checksum",
        "Narrative Block Summary"
      ],
      "audit_boundaries": [
        "backend/app/application/services/fincen_sar_service.py:L180-L210 (Redaction and PII hashing rules applied prior to XML packaging)"
      ],
      "unresolved_edges": []
    },
    {
      "capability_id": "CAP-COMPARATIVE-BASELINES-FALLBACK",
      "name": "Benchmark Comparative Baselines Widget Endpoint",
      "user_surfaces": [
        "frontend/src/components/ComparativeModelWidget.tsx :: Comparative Performance Bar Chart"
      ],
      "nodes": [
        {
          "id": "node-baseline-ui",
          "file": "frontend/src/components/ComparativeModelWidget.tsx",
          "symbol": "ComparativeModelWidget.useComparativeBaselines",
          "line_range": "L25-L60",
          "role": "Component Mount Data Fetcher",
          "layer": "Presentation / UI",
          "runtime_classification": "BENCHMARK_CROSSOVER"
        },
        {
          "id": "node-baseline-client",
          "file": "frontend/src/api/queries.ts",
          "symbol": "useComparativeBaselines",
          "line_range": "L510-L530",
          "role": "GET /api/v1/dashboard/comparative-baselines call",
          "layer": "Frontend Infrastructure",
          "runtime_classification": "BENCHMARK_CROSSOVER"
        },
        {
          "id": "node-baseline-router",
          "file": "backend/app/presentation/routers/dashboard.py",
          "symbol": "get_comparative_baselines",
          "line_range": "L270-L340",
          "role": "FastAPI Route Handler",
          "layer": "Presentation / Router",
          "runtime_classification": "BENCHMARK_CROSSOVER"
        },
        {
          "id": "node-baseline-file-read",
          "file": "experiments/results/comparative_baselines.json",
          "symbol": "Filesystem JSON Artifact Read",
          "line_range": "Entire File",
          "role": "Benchmark Experiment Result File",
          "layer": "Benchmark Artifact / Filesystem",
          "runtime_classification": "BENCHMARK_CROSSOVER"
        },
        {
          "id": "node-baseline-hardcoded-dict",
          "file": "backend/app/presentation/routers/dashboard.py",
          "symbol": "_STATIC_FALLBACK_BASELINES",
          "line_range": "L285-L325",
          "role": "Hardcoded In-Memory Dictionary Fallback",
          "layer": "Presentation / Router Fallback",
          "runtime_classification": "MOCK_SYNTHETIC_FALLBACK"
        },
        {
          "id": "node-baseline-widget",
          "file": "frontend/src/components/ComparativeModelWidget.tsx",
          "symbol": "ComparativeModelWidget UI View",
          "line_range": "L75-L160",
          "role": "Bar Chart (Local Model vs FedAvg vs CF-Intelligence)",
          "layer": "Presentation / UI",
          "runtime_classification": "BENCHMARK_CROSSOVER"
        }
      ],
      "edges": [
        {
          "from": "node-baseline-ui",
          "to": "node-baseline-client",
          "mechanism": "React Query useQuery hook"
        },
        {
          "from": "node-baseline-client",
          "to": "node-baseline-router",
          "mechanism": "HTTP GET /api/v1/dashboard/comparative-baselines"
        },
        {
          "from": "node-baseline-router",
          "to": "node-baseline-file-read",
          "mechanism": "Attempts Path.read_text() from experiments/results/comparative_baselines.json"
        },
        {
          "from": "node-baseline-router",
          "to": "node-baseline-hardcoded-dict",
          "mechanism": "Catches FileNotFoundError/Exception and returns static dictionary"
        },
        {
          "from": "node-baseline-router",
          "to": "node-baseline-widget",
          "mechanism": "Returns JSON with AUC/F1 comparison across architecture variants"
        }
      ],
      "user_visible_outputs": [
        "Local Baseline AUC (0.831)",
        "FedAvg Baseline AUC (0.874)",
        "CF-Intelligence Global AUC (0.948)",
        "False Positive Reduction Rate (-38.4%)"
      ],
      "audit_boundaries": [
        "backend/app/presentation/routers/dashboard.py:L270-L340 (Direct crossover from experiment artifacts into live runtime dashboard)"
      ],
      "unresolved_edges": []
    },
    {
      "capability_id": "CAP-GLOBAL-TELEMETRY-STREAM",
      "name": "Global Live Telemetry WebSocket Stream",
      "user_surfaces": [
        "frontend/src/pages/ObservabilityPage.tsx :: Real-Time Alert Ticker & Global Volume Metric",
        "frontend/src/pages/LiveOperationsView.tsx :: Live Streaming Alert Feed"
      ],
      "nodes": [
        {
          "id": "node-telemetry-ws-client",
          "file": "frontend/src/pages/LiveOperationsView.tsx",
          "symbol": "LiveOperationsView WebSocket Hook",
          "line_range": "L310-L365",
          "role": "Browser WebSocket Connection to /ws/telemetry",
          "layer": "Presentation / UI",
          "runtime_classification": "MOCK_SYNTHETIC_FALLBACK"
        },
        {
          "id": "node-telemetry-ws-router",
          "file": "backend/app/presentation/websockets/streaming_ws.py",
          "symbol": "telemetry_websocket_endpoint",
          "line_range": "L310-L360",
          "role": "FastAPI WebSocket Route Handler",
          "layer": "Presentation / WebSocket Router",
          "runtime_classification": "MOCK_SYNTHETIC_FALLBACK"
        },
        {
          "id": "node-telemetry-random-generator",
          "file": "backend/app/presentation/websockets/streaming_ws.py",
          "symbol": "random.choice, random.uniform",
          "line_range": "L325-L345",
          "role": "Infinite Loop Synthetic Event Generator",
          "layer": "Presentation / Synthetic Emitter",
          "runtime_classification": "MOCK_SYNTHETIC_FALLBACK"
        },
        {
          "id": "node-telemetry-ui-ticker",
          "file": "frontend/src/pages/ObservabilityPage.tsx",
          "symbol": "ObservabilityPage.TransactionTicker",
          "line_range": "L180-L240",
          "role": "Real-time scrolling ticker of streamed transactions",
          "layer": "Presentation / UI",
          "runtime_classification": "MOCK_SYNTHETIC_FALLBACK"
        }
      ],
      "edges": [
        {
          "from": "node-telemetry-ws-client",
          "to": "node-telemetry-ws-router",
          "mechanism": "WS Handshake to /ws/telemetry"
        },
        {
          "from": "node-telemetry-ws-router",
          "to": "node-telemetry-random-generator",
          "mechanism": "asyncio.sleep(1.0) loop generating synthetic transaction payload"
        },
        {
          "from": "node-telemetry-random-generator",
          "to": "node-telemetry-ws-client",
          "mechanism": "websocket.send_json(synthetic_event)"
        },
        {
          "from": "node-telemetry-ws-client",
          "to": "node-telemetry-ui-ticker",
          "mechanism": "Appends new event to visible ticker state"
        }
      ],
      "user_visible_outputs": [
        "Live transaction IDs",
        "Transaction amounts ($1,500 - $450,000)",
        "Originating bank labels",
        "Fraud flag badge"
      ],
      "audit_boundaries": [
        "backend/app/presentation/websockets/streaming_ws.py:L310-L360 (Loop generates pure random synthetic data with no connection to production queues)"
      ],
      "unresolved_edges": []
    },
    {
      "capability_id": "CAP-AGENTIC-AML-COPILOT",
      "name": "Autonomous Agentic AML Copilot Chat & Investigation",
      "user_surfaces": [
        "frontend/src/components/AgenticInvestigationCopilot.tsx :: Chat Panel & Autonomous Action Approvals",
        "frontend/src/pages/InvestigationDashboard.tsx :: Copilot Sidebar"
      ],
      "nodes": [
        {
          "id": "node-copilot-ui",
          "file": "frontend/src/components/AgenticInvestigationCopilot.tsx",
          "symbol": "AgenticInvestigationCopilot.handleSendMessage",
          "line_range": "L120-L165",
          "role": "Chat Message Submit Trigger",
          "layer": "Presentation / UI",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-copilot-client",
          "file": "frontend/src/api/queries.ts",
          "symbol": "useCopilotChat.mutationFn",
          "line_range": "L610-L635",
          "role": "POST /api/v1/copilot/chat Request",
          "layer": "Frontend Infrastructure",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-copilot-router",
          "file": "backend/app/presentation/routers/copilot.py",
          "symbol": "copilot_chat_endpoint",
          "line_range": "L75-L140",
          "role": "FastAPI Route Handler",
          "layer": "Presentation / Router",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-copilot-service",
          "file": "backend/app/application/services/agentic_investigation_copilot.py",
          "symbol": "AgenticInvestigationCopilot.process_query",
          "line_range": "L90-L280",
          "role": "Agentic Reasoner, Tool Dispatcher & ReAct Loop",
          "layer": "Application / Agentic Copilot",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-copilot-tools",
          "file": "backend/app/application/services/agentic_investigation_copilot.py",
          "symbol": "InvestigateEntityTool, CheckSanctionsTool, QueryGraphTool",
          "line_range": "L290-L450",
          "role": "Deterministic AML Tools & Graph Invocations",
          "layer": "Application / Domain Tools",
          "runtime_classification": "RUNTIME_LIVE"
        },
        {
          "id": "node-copilot-ui-response",
          "file": "frontend/src/components/AgenticInvestigationCopilot.tsx",
          "symbol": "MessageThread & ActionCards",
          "line_range": "L210-L340",
          "role": "Chat Bubble & Action Proposal Rendering",
          "layer": "Presentation / UI",
          "runtime_classification": "RUNTIME_LIVE"
        }
      ],
      "edges": [
        {
          "from": "node-copilot-ui",
          "to": "node-copilot-client",
          "mechanism": "mutateAsync({ query, context_entity_id })"
        },
        {
          "from": "node-copilot-client",
          "to": "node-copilot-router",
          "mechanism": "HTTP POST /api/v1/copilot/chat"
        },
        {
          "from": "node-copilot-router",
          "to": "node-copilot-service",
          "mechanism": "process_query(query, context)"
        },
        {
          "from": "node-copilot-service",
          "to": "node-copilot-tools",
          "mechanism": "Executes domain tools based on query intent"
        },
        {
          "from": "node-copilot-tools",
          "to": "node-copilot-service",
          "mechanism": "Tool execution results aggregated into response"
        },
        {
          "from": "node-copilot-service",
          "to": "node-copilot-ui-response",
          "mechanism": "Returns assistant message, reasoning trace, proposed actions"
        }
      ],
      "user_visible_outputs": [
        "Copilot conversational response",
        "Reasoning step trace (ReAct thought/action)",
        "Graph entity neighborhood summary",
        "Proposed case actions (e.g., 'File SAR', 'Escalate to Tier 2')"
      ],
      "audit_boundaries": [
        "backend/app/application/services/agentic_investigation_copilot.py:L115-L145 (Local rule-based fallback if LLM API key / provider unreachable)"
      ],
      "unresolved_edges": []
    }
  ]
}