-
Notifications
You must be signed in to change notification settings - Fork 0
concept risk score
공장별 안전 수준을 정량화하는 Safety Score의 입력, 가중치, gate, 판정 기준을 정리한다.
현재 구현의 점수는 높을수록 안전하다. 코드에서는 risk.score라는 필드명을 유지하지만, 의미는 위험 점수가 아니라 Safety Score다.
| 상태 | Score 범위 | 의미 |
|---|---|---|
safe |
85~100 | 정상 운영 |
warning |
50~84 | 주의 필요 |
danger |
0~49 | 즉시 확인 필요 |
기본 계산은 100점에서 각 위험 요인의 가중 패널티를 빼는 방식이다.
factory_state + infra_state + pipeline_status
-> weighted contribution 계산
-> base_score = 100 - contribution 합계
-> gate 적용
-> score / level / top_causes 산출
apps/data-processor/processor/risk.py 기준 현재 활성 지표는 10개다.
| 지표 | 가중치 | 입력 출처 | 기준 |
|---|---|---|---|
temperature |
10 | factory_state.temperature_celsius |
32도부터 warning, 38도 이상 critical |
humidity |
5 | factory_state.humidity_percent |
70%부터 warning, 85% 이상 critical |
pressure |
5 | factory_state.pressure_hpa |
990hPa 미만/1030hPa 초과 warning, 970hPa 이하/1050hPa 이상 critical |
ai_event_rate |
15 |
fire_score, fall_score, bend_score, abnormal_sound
|
AI score peak + abnormal sound 보정 |
node_status |
20 | infra_state.nodes_ready/nodes_total |
NotReady node 비율 |
pod_health |
15 | infra_state.pods_ready/pods_total |
미준비 workload 비율 |
device_availability |
10 | infra_state.devices |
bme280, camera, microphone 가용 여부 |
data_freshness |
10 | pipeline_status.latest_infra_state_age_seconds |
60초 초과부터 warning, 120초 초과 critical |
storage_pressure |
5 | node별 disk_usage_percent 최댓값 |
75%부터 warning, 90% 이상 critical |
network_reachability |
5 | node별 network_reachability
|
ok, reachable, ready 외 상태 비율 |
각 지표는 먼저 0.0~1.0 사이의 위험 비율로 변환된다. 그 다음 지표 가중치와 곱해 contribution이 된다.
contribution = weight * risk_ratio
base_score = max(0, 100 - sum(contribution))
예를 들어 온도는 32도 미만이면 패널티가 없고, 38도 이상이면 온도 가중치 10점 전체가 패널티가 된다. 35도는 warning과 critical 중간이므로 약 5점 패널티가 된다.
base_score는 weighted contribution만 반영한 1차 점수다. base_level은 이 점수만으로 판정한 상태다.
이후 gate가 적용되면 최종 score와 level이 더 낮아질 수 있다. 즉 base_score=90, base_level=safe여도 critical gate가 있으면 최종 점수는 warning 또는 danger로 cap될 수 있다.
Gate는 특정 조건이 발생했을 때 점수 상한을 강제로 낮추는 규칙이다. 단순 가중 합산으로는 놓칠 수 있는 치명 조건을 반영한다.
| Gate | 조건 | 효과 |
|---|---|---|
temperature_critical |
온도 38도 이상 | warning cap, 최종 score 최대 84 |
humidity_critical |
습도 85% 이상 | warning cap, 최종 score 최대 84 |
ai_score_warning |
AI peak 0.8 이상 또는 peak 0.6 이상 + abnormal sound | warning cap |
ai_score_critical |
AI peak 0.95 이상 | danger cap, 최종 score 최대 49 |
nodes_all_not_ready |
전체 node가 NotReady | 명시 cap 0 |
nodes_partially_not_ready |
일부 node NotReady | warning cap |
pods_all_unready |
전체 workload 미준비 | danger cap |
pods_partially_unready |
일부 workload 미준비 | warning cap |
required_device_unavailable |
필수 장치 unavailable | warning 또는 danger |
pipeline_status_warning |
freshness warning | warning cap |
pipeline_status_critical |
freshness critical | danger cap |
pipeline_status_outage |
infra_state age 300초 초과 | 명시 cap 0 |
최종 점수는 아래 순서로 cap된다.
- 명시
score_cap이 있으면 해당 cap을 먼저 적용한다. - danger gate가 하나라도 있으면 최종 score는 최대 49다.
- warning gate만 있으면 최종 score는 최대 84다.
- gate가 없으면
base_score가 최종 score다.
이 때문에 “대부분 정상인데 node가 전부 NotReady” 같은 상황은 weighted contribution상 base_score가 80이어도 최종 score=0, level=danger가 된다.
출력의 top_causes는 관제 화면이 “왜 점수가 떨어졌는지” 보여주기 위한 상위 원인 목록이다.
각 항목은 다음 구조를 가진다.
{
"field": "data_freshness",
"reason": "pipeline_status_outage",
"value": "stale_over_300s",
"contribution": 100,
"severity": "danger",
"source": "gate"
}source=weighted는 일반 가중 패널티이고, source=gate는 cap을 만든 조건이다. 목록은 severity와 contribution 기준으로 정렬되어 최대 5개만 반환된다.
configs/runtime/runtime-config.yaml에는 weight, threshold, factory override 초안이 있지만 현재 Lambda package에는 연결되어 있지 않다. 실제 계산은 processor/risk.py의 하드코딩 상수로 수행된다.
따라서 현재 문서의 기준값은 runtime config가 아니라 코드와 테스트를 기준으로 한다. runtime config 기반 override는 후속 고도화 범위다.
관련 문서
- 시스템 아키텍처
- 제어 & 데이터 플레인
- Dashboard VPC 설계
- 하드웨어 배치
- Hub EKS 네임스페이스
- Tailscale Mesh VPN
- 데이터 생명주기
- 데이터 조회 모델
- 실시간 갱신 구조
- IoT 데이터 계약
- Reporting Pipeline
- 로컬 스토리지
- 클라우드 스토리지
- Edge Agent
- Edge AI 탐지
- Factory-A Log Adapter
- Dummy Sensor
- Edge IoT Publisher
- Lambda Data Processor
- Risk Normalizer
- Risk Score Engine
- Pipeline Status Aggregator
- Graph Aggregator 5m
- Cloud Infra Collector
- Daily Report Generator
- Risk Alert Dispatcher
- Image Snapshot Pipeline
- Dashboard Backend
- Dashboard Web
- AI 채팅 어시스턴트