02.0 Kor.ai Bayesian Risk Engine - ravkorsurv/kor-ai-core GitHub Wiki
Kor.ai Bayesian Risk Engine β Full Design Blueprint
1. Core Model Structure
Shared foundational nodes used across all risk types:
Trader_Intent_Likelihood
Trade_Anomaly_Detected
News_Sentiment_Relevance
Price_Sensitive_Info_Seen
Comms_Indicative_Language
PnL_Anomaly_Pattern
Trade_Cluster_Abnormality
Market_Impact_Metric
Order_Lifecycle_Manipulation
These nodes serve as building blocks and allow for composability between models.
2. Risk Type-Specific Node Sets
2.1 Insider Dealing
PreEvent_Positions_Accumulated
Unexplained_PreAnnouncement_Trades
Private_Info_Accessed
Behavior_Change_Prior_Event
Communication_Matching_Event
HR_Access_Role_Change
Event_Relevance_To_Position
FrontRunning_Pattern
2.2 Spoofing
Quote_Layering_Pattern
Order_Cancel_Ratio
Best_Bid_Ask_Spoof_Signal
Quote_Depth_Skew
Price_Reversion_Post_Cancel
Time_Interval_Quote_Lift
Trade_Follow_Intent
2.3 Wash Trading
Matched_Counterparty_Pairs
Short_Term_Roundtrip_Detection
Same_Beneficial_Owner
Intentional_No_Economic_Change
Linked_Accounts_Trade_Matching
BackToBack_Timestamp_Signal
Each risk type can extend or override shared components as needed.
3. Composability via Submodules
Node submodules that can be composed across risk types:
Market Context Module
Market_Volatility_Spike
News_Relevance
Unusual_Volume
Comms Module
Keywords_Indicative_Of_Collusion
Frequency_Increase
Message_Timing_To_Event
Trade Pattern Module
Anomalous_Timeslice_Behavior
Trade_Reversal_Pattern
Submodules enable modular BN design and promote reuse across risk types.
4. Scoring and Inference
Scoring Logic:
- The risk score is inferred as
P(Risk=True | Evidence)
- Scores are binned into:
Low
,Medium
,High
,Critical
Each node includes:
- Prior probability (default belief)
- Conditional Probability Table (CPT)
- Dependencies on parent nodes
Model outputs include:
- Activated nodes
- Probability path explanation
- Backward inference (abduction) for βwhat caused this alert?β
5. Explainability Layer
Outputs for each alert:
- Human-readable case notes (AI-generated)
- Explanation of activated nodes
- Mapping of raw inputs β BN evidence
- Rationale for risk score
- Node graph snapshot (optional for UI)
This ensures regulatory transparency and supports STOR decisioning.
6. Future Extensions β Pluggable Nodes
See: [11.7 Future Extensions β Kor.ai Bayesian Risk Engine](https://github.com/ravkorsurv/kor-ai-core/wiki/11.7-Future-Extensions-%E2%80%93-Kor.ai-Bayesian-Risk-Engine)
Optional plug-in nodes:
Historical_STOR_Lookalike
β pattern match to prior alertsKYC_Risk_Overlay
β firm-wide KYC scoreVoice_Trade_Sentiment
β NLP of voice channelsCase_Escalation_Heatmap
β downstream review metadataPeer_Behavior_Deviation
β peer clusters, drift detectionMacro_Event_Correlation
β correlates to global events (e.g., OPEC)
Extensions are modular and attachable to core models without affecting stability.
7. Model Architecture and File Structure
BN Component JSONs
- Located under:
bayesian-models/components/
Model-level JSONs (CPTs and relationships)
- Located under:
bayesian-models/models/
Payload examples
- Located under:
bayesian-models/payloads/
Structure:
bayesian-models/
βββ components/
β βββ Shared/
β βββ InsiderDealing/
β βββ Spoofing/
β βββ WashTrading/
βββ models/
β βββ InsiderDealingModel.json
β βββ SpoofingModel.json
βββ payloads/
β βββ insider_case_medium.json
β βββ spoofing_case_high.json
8. Deployment and Runtime
- Supports both Agena Cloud API and pgmpy-based local inference
- Node obfuscation enabled via mapping dictionary
- ETL layer converts raw surveillance data into BN payloads
- Alerting engine processes output score + explanation
All models are versioned and test cases maintained in the test suite.
9. Governance and Version Control
- Each risk model has a semantic version (
v1.0.0
,v1.1.0
, etc.) - CPTs reviewed quarterly by product owner + model lead
- All changes linked to Jira change ticket or STOR control request
- Model rationale, evidence rules, and scoring logic are audited
Let me know once you've pasted it in β I can link it to your TOC or suggest where in the wiki it fits best.