02.3 Universal Fallback Logic for Kor.ai Nodes - ravkorsurv/kor-ai-core GitHub Wiki
๐ 02.3 Universal Fallback Logic for Kor.ai Nodes
๐ Purpose
As Kor.ai scales across typologies and asset classes, we introduce modular fallback logic to improve:
- ๐ง Explainability โ consistent scoring rules, even under data sparsity
- ๐งช Debugging โ structured node diagnostics and triage
- ๐ Scalability โ avoids CPT explosion across high-cardinality inputs
- ๐ก๏ธ Resilience โ supports partial evidence and degraded inputs
Fallback logic transforms nodes from fixed CPTs to data-aware, inference-friendly modules.
๐งฉ Fallback Logic: Core Principles
- Every complex node in the Bayesian model has a fallback function
- The function replaces or supplements CPTs when data is incomplete or unenumerated
- Logic is typically driven by risk scoring, thresholds, or ordinal mappings
- Optionally outputs rationale for the fallback path taken (supporting explainability)
๐งฑ Modular Fallback Categories
Communication Intent
- Node:
Q75_CommsIntentInfluence
- Fallback: Weighted score โ probability map
- States: High / Medium / Low / None
PnL / Trade Pattern Risk
- Node:
Q20_PnLDeviation
- Fallback: Z-score bucket
- States: High / Medium / Low / Normal
Counterparty / KYC Risk
- Node:
Q44_EntityRiskScore
- Fallback: Label โ ordinal map
- States: High / Medium / Low
Trade Clustering
- Node:
Q35_TradeClustering
- Fallback: Count buckets
- States: Clustered / Neutral / Dispersed
Price/Volatility Abuse
- Node:
Q21_PriceSensitivityAbuse
- Fallback: Direction + timing logic
- States: High / Medium / Low
News Sentiment Impact
- Node:
Q51_NewsSentimentImpact
- Fallback: Sentiment + source matrix
- States: Reinforcing / Neutral / Conflicting
HR / Bonus Incentive
- Node:
Q19_HRIncentiveAlignment
- Fallback: Bonus delta logic
- States: Motivated / Neutral / Low Signal
Platform KDE Health
- Node:
Q99_KDEIntegrityFlag
- Fallback: Recency / error-code mapping
- States: OK / Partial / Broken
โ๏ธ Generic Fallback Function Template (Python)
def fallback_score_router(node_name, input_values):
fallback_registry = {
'Q75_CommsIntentInfluence': compute_comms_intent_probabilities,
'Q20_PnLDeviation': compute_pnl_score_bucket,
'Q44_EntityRiskScore': map_kyc_label_to_risk,
'Q35_TradeClustering': cluster_trade_count_bucket,
'Q21_PriceSensitivityAbuse': price_flag_logic,
'Q51_NewsSentimentImpact': news_sentiment_mapping,
'Q19_HRIncentiveAlignment': bonus_delta_bucket,
'Q99_KDEIntegrityFlag': kde_status_flag
}
return fallback_registry[node_name](input_values)
Q20_PnLDeviation
Fallback
๐ง Example: Inputs:
z-score
= +2.8holding_time
= <1h
def compute_pnl_score_bucket(zscore, holding_time):
if zscore >= 3:
return [0.8, 0.15, 0.05, 0.00] # High
elif zscore >= 2:
return [0.3, 0.5, 0.15, 0.05] # Medium
elif zscore >= 1:
return [0.1, 0.3, 0.4, 0.2] # Low
else:
return [0.0, 0.1, 0.2, 0.7] # Normal
๐ Optional: Explainability Tagging
{
"result": [0.8, 0.15, 0.05, 0.00],
"explanation": "Z-score of +3.1 triggered High signal; short-term hold"
}
๐งช Debugging Support: Metadata Flags
{
"Q75_CommsIntentInfluence": {
"used_fallback": true,
"risk_score": 9.0,
"source": "fallback_score_router"
}
}
Supports:
- Alert explainability
- Diagnostic analysis
- Missing-data root cause tracing
๐ Next Steps
- Implement
fallback_score_router()
in inference layer - Log fallback usage per alert/case ID
- Add rationale output for all fallback logic nodes
- Build unit test coverage for missing data scenarios
- Update wiki (e.g.
12.5 Node Library
) to link fallback mappings
๐งฉ Node Coverage Progress
Node | Fallback Defined | Logic Confirmed | Notes |
---|---|---|---|
Q75_CommsIntentInfluence | โ | โ | Fully defined in 12.6 |
Q20_PnLDeviation | โ | โ | Logic in this section |
Q44_EntityRiskScore | โ ๏ธ | Partial | Needs label-to-risk mapping |
Q35_TradeClustering | โ ๏ธ | Partial | Needs N-count thresholds |
Q21_PriceSensitivityAbuse | โฌ | No | Direction/time window logic |
Q51_NewsSentimentImpact | โฌ | No | Define source/sentiment grid |
Q19_HRIncentiveAlignment | โฌ | No | Bonus delta model |
Q99_KDEIntegrityFlag | โฌ | No | Recency/error flag to status |
Kor.aiโs fallback logic layer ensures robustness in real-world surv