Skip to content

component risk score engine

minsoo edited this page Jun 9, 2026 · 4 revisions

컴포넌트 — Risk Score Engine

현재 Risk Score Engine은 독립 서비스가 아니라 Lambda Data Processor 내부의 processor/risk.py 모듈이다.


역할

Risk Score Engine은 정규화된 factory_state, 최신 infra_state, pipeline_status를 합쳐 공장별 Safety Score를 계산한다.

normalize_factory_state()
latest infra_state
pipeline_status
  -> processor.risk.calculate()
  -> risk.score / risk.level / top_causes / gates
  -> DynamoDB LATEST.risk
  -> S3 processed risk_score 또는 state_snapshot

필드명은 기존 계약과 호환하기 위해 risk.score를 유지하지만, 점수 의미는 높을수록 안전이다.


구현 위치

apps/data-processor/processor/risk.py

Lambda 내부 호출 위치:

경로 계산 방식
factory_state 수신 현재 factory_state + 최신 infra_state + pipeline_status
infra_state 수신 최신 factory_state가 있으면 현재 infra_state로 재계산
refresh_pipeline_status 새 메시지가 없어도 최신 factory_state/infra_state + 현재 freshness로 재계산

판정 기준

상태 Score 범위
safe 85~100
warning 50~84
danger 0~49

테스트 기준도 이 방향을 검증한다. 정상 입력은 score=100, level=safe이며, AI critical 또는 freshness outage는 danger로 cap된다.


계산 방식

  1. 각 입력 지표를 0.0~1.0 위험 비율로 변환한다.
  2. 지표별 weight와 곱해 weighted contribution을 만든다.
  3. base_score = 100 - contribution 합계를 계산한다.
  4. gate를 적용해 최종 score를 cap한다.
  5. severity/contribution 기준으로 top_causes 최대 5개를 반환한다.

출력 필드:

필드 의미
score gate 적용 후 최종 Safety Score
base_score weighted contribution만 반영한 점수
level 최종 상태
base_level base score 기준 상태
top_causes 관제 화면에 표시할 상위 원인
gates score cap을 만든 조건 목록

현재 활성 입력

필드 weight threshold 또는 계산 기준
temperature 10 warning 32도, critical 38도
humidity 5 warning 70%, critical 85%
pressure 5 low 990/970hPa, high 1030/1050hPa
ai_event_rate 15 fire/fall/bend peak, abnormal sound 보정
node_status 20 NotReady node 비율
pod_health 15 미준비 workload 비율
device_availability 10 bme280/camera/microphone unavailable 비율
data_freshness 10 pipeline_status와 latest infra age
storage_pressure 5 node disk usage max, warning 75%, critical 90%
network_reachability 5 node reachability 불량 비율

Gate와 Cap

위험 조건은 최종 점수를 강제로 낮출 수 있다.

조건 cap
warning gate 존재 최종 score 최대 84
danger gate 존재 최종 score 최대 49
nodes_all_not_ready 최종 score 0
pipeline_status_outage 최종 score 0

pipeline_status_outage는 latest infra age가 300초를 넘으면 발생한다. 이 경우 최근 센서값이 정상이어도 데이터가 끊겼으므로 danger로 표시한다.


Runtime Config 제한

configs/runtime/runtime-config.yaml은 현재 Lambda Risk 계산에 연결되어 있지 않다. weight, threshold, factory별 override는 processor/risk.py 상수로 고정되어 있다.

따라서 “factory-b/c별 다른 threshold” 같은 설명은 현재 구현 기준이 아니다. 공장별 override를 적용하려면 runtime config를 Lambda package 또는 환경 입력으로 연결하고 테스트를 추가해야 한다.


독립 배포 여부

Risk Score Engine은 별도 ECS/K8s/Lambda로 배포되지 않는다. 현재 배포 단위는 data-processor Lambda이며, 독립 apps/risk-score-engine/ 설명은 레거시 placeholder로 취급한다.


관련 문서

Aegis-Pi Wiki

· 대표 문서 목록은 홈의 문서 탐색 표 참조

시작하기

요구사항

핵심 개념

아키텍처

컴포넌트 (Edge → Cloud → Dashboard)

Dashboard & 운영

시나리오 · 사례 · 참조

Clone this wiki locally