Skip to content

About

Fail-closed sensor time-series pipeline on TimescaleDB + Airflow: QA, quarantine, idempotent load, and a report that ABSTAINs unless citations hash-verify

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

FactoryScope

CI

무엇인가. 공개 제조 센서 시계열(NASA IMS 베어링 진동)을 PostgreSQL/TimescaleDB에 fail-closed로 검증·적재하고(QA → quarantine → 멱등 적재 → lineage), 인용 무결성(hash·entailment·scope)이 검증되지 않으면 리포트를 ABSTAIN하는 Airflow DAG 파이프라인이다.

무엇이 아닌가. 운영 시스템이 아니다. LLM 생성·스트리밍·dbt·Spark는 없다. 공개 CI는 빠른 비-DB 검사만 수행하며, 전체 Docker/실 DB 검증은 수동 release gate다. detector 성능은 INSUFFICIENT_EVIDENCE이며 이상 탐지 성능을 주장하지 않는다. 최종 HITL 승인은 미완(WAITING_FOR_FINAL_HITL)이다.

저작. 구현 코드와 문서 초안은 Codex·Claude Code로 작성했다. 요구사항·실패 경계·수용 기준·검증 판단은 제작자가 했다.

공개 제조 센서 시계열을 검증·적재하고, 이상 탐지 근거가 충분할 때만 출처가 검증된 정비 문서를 검색해 권고 리포트를 만드는 연구 프로젝트다. 근거가 부족하면 추정 답변 대신 ABSTAIN한다.

현재 판정

실행별 최신 판정과 검증 명령의 단일 출처는 Local Integration Acceptance다. 아래 표는 구현·주장 경계이며, 과거 evidence의 SUCCESS를 현재 HEAD의 성공으로 대신하지 않는다.

영역 상태 의미
데이터 QA·적재 IMPLEMENTED quarantine, 원자적·멱등 적재와 lineage 계약을 구현하고 테스트함
Airflow·실 DB EVIDENCE-GATED 현재 HEAD와 결속된 수동 acceptance 및 offline verifier가 성공할 때만 release 성공
RAG FUNCTIONALLY_VERIFIED 고정 corpus의 8/8 top-1 + OOS 2/2 abstain 계약. 현장 유효성 주장은 아님
Detector 성능 INSUFFICIENT_EVIDENCE 독립 run·event/onset label·정상 노출·위험 목표가 부족함
현재 report ABSTAIN 미승인 detector score를 정비 권고로 바꾸지 않음
실공장 일반화·RUL·root cause NOT_EVALUATED 주장하지 않음
운영 배포 HITL/DATA BLOCKED 자동 작업지시·설비 정지 권한이 없으며 production SLA/HA를 검증하지 않음

Pipeline의 SUCCESS와 detector 성능 통과는 다른 판정이다. 현재 daily path는 production 관련 미승인 NDR과 그 값에서 파생할 표본수를 모두 blocker로 기록한다. 승인 전 production scorer를 실행하지 않는다. 현재 daily 경로는 report에 검색 근거와 anomaly를 넘기지 않으므로 결과는 구조적으로 ABSTAIN뿐이다.

구조

Sensor CSV
  → Airflow: ingest → validate → load → detector readiness → report → finalize
                         │               │                      └─ ABSTAIN
                         └─ PostgreSQL/TimescaleDB

Versioned maintenance corpus
  → pinned E5 ONNX (offline runtime) → pgvector exact retrieval → citation verification

기술 스택은 Python 3.11, uv.lock, Airflow 3.3.1, PostgreSQL 16 + TimescaleDB + pgvector, scikit-learn IsolationForest, ONNX Runtime, LangGraph, pytest다. 사용하지 않는 HTTP API/FastAPI는 포함하지 않았다. 선택 이유와 교체 조건은 Technology Trade-offs에 있다.

빠른 실행

1. 로컬 Python 검증

uv lock --check
uv sync --frozen --dev
uv run python scripts/run_acceptance.py
uv run python scripts/evaluate_rag.py
uv run --dev pytest -q

run_acceptance.py의 synthetic 수치는 실행 경로용 DEV_ONLY fixture다. 모델 성능 근거가 아니다. DSN이나 canonical NASA pilot artifact가 없는 빠른 검사에서는 해당 환경 의존 테스트가 명시적으로 skip될 수 있다. Release acceptance는 모든 의존성을 준비하고 skip 0을 강제한다.

2. 실제 DB와 Airflow

cp .env.example .env
# .env의 모든 replace-me를 서로 다른 값으로 교체한다.
# Fernet key는 URL-safe base64로 인코딩한 32 random bytes여야 한다.

docker compose up -d --build

set -a
. ./.env
set +a
export FACTORYSCOPE_POSTGRES_DSN="postgresql://factory:${FACTORYSCOPE_DB_PASSWORD}@127.0.0.1:5432/factory"

uv run python scripts/migrate.py
uv run python scripts/index_corpus.py
uv run python scripts/evaluate_rag.py

단일 수동 batch는 새 run directory를 지정해 실행한다.

uv run python scripts/run_daily.py all \
  --csv data/synthetic.csv \
  --run-dir artifacts/daily/manual-001

전체 runtime acceptance에는 현재보다 미래가 아니고 아직 사용하지 않은 UTC logical date가 필요하다.

uv run python scripts/run_local_integration_acceptance.py \
  --logical-date '<past-unused-UTC-timestamp>'

v3 acceptance는 결과 파일만 저장하지 않는다. 실행에 사용한 DAG·Compose·lockfile·SQL·source·test· 연구 계약의 SHA-256 inventory와 ingest→report 단계별 artifact hash/lineage를 함께 고정하며, 전체 pytest에 skip이 있으면 실패한다.

최종 검증 결과와 재검증 명령은 Local Integration Acceptance에 있다. Evidence는 git에 넣지 않고 GitHub Release asset과 SHA-256으로 배포한다. Docker image는 model과 tokenizer hash를 build 시 검사해 cache하고 HF_HUB_OFFLINE=1로 실행한다.

공개 evidence 재검증

Release v0.0.1의 두 asset을 받은 뒤 checksum을 먼저 확인하고 저장소 root에 압축을 푼다. Manifest 경로와 SHA-256은 release note와 Local Integration Acceptance에 동일하게 기록한다.

sha256sum --check factoryscope-evidence-v0.0.1.tar.gz.sha256
tar -xzf factoryscope-evidence-v0.0.1.tar.gz
python3 -B scripts/verify_local_integration_evidence.py \
  --manifest 'artifacts/local-integration/<context-hash>/acceptance.json' \
  --expected-sha256 '<acceptance-json-sha256>'

Archive에는 해당 acceptance directory, daily run, RAG evaluation만 들어간다. NASA 원본 archive, database dump, .env와 credential은 배포하지 않는다.

연구·운영 문서

Canonical 공개 데이터는 NASA PCoE Bearings다. 실제 archive SHA-256과 inventory는 source audit에 고정하며 mirror를 원본 대체 근거로 쓰지 않는다. NASA 페이지는 이 자료를 IMS Center, University of Cincinnati가 제공한 데이터로 안내한다. 데이터와 인용한 제3자 문서는 각 원 출처의 이용조건을 따르며 이 저장소의 MIT License가 이를 재허가하지 않는다.

License

저장소의 자체 코드와 문서는 MIT License로 배포한다.

불변 원칙

  • 합성·공개 데이터 기반 개인 연구다. 실공장 배포 경험을 주장하지 않는다.
  • Data QA 통과를 detector 품질 통과로 부르지 않는다.
  • IsolationForest contamination을 운영 false-alert rate로 해석하지 않는다.
  • 같은 run의 window를 독립 고장 표본으로 세지 않는다.
  • Point-adjusted F1을 acceptance metric으로 만들지 않는다.
  • Blind holdout 결과로 feature·threshold·metric을 바꾸지 않는다.
  • 인용 내용·hash·설비 scope가 하나라도 맞지 않으면 report는 ABSTAIN한다.
  • 자동 정지·자동 작업지시 권한은 없다. 최종 판단은 사람에게 있다.

Summary (English)

FactoryScope is a research pipeline that validates and loads public manufacturing sensor time series (NASA IMS bearing vibration) into PostgreSQL/TimescaleDB behind fail-closed gates (QA → quarantine → idempotent load → lineage). Its six-stage Airflow DAG emits an extractive maintenance report only when citation hash, entailment and equipment scope all verify; otherwise it returns ABSTAIN. Detector performance remains INSUFFICIENT_EVIDENCE because independent runs, event labels, normal exposure and approved risk budgets are missing. Fast CI is public; the full Docker/PostgreSQL run remains a manual, evidence-bound release gate. This is not a production system.

Glossary:

  • NDR (Numeric Decision Register): 결과·경보·데이터 수용 여부에 영향을 주는 숫자에 구현 전에 부여하는 결정 ID.
  • TBD-BLOCKING: 결정 전 관련 실행을 차단하는 NDR 상태.
  • HITL: 목적·데이터·label·위험예산·통계·운영에 대해 사람이 승인해야 하는 마지막 6개 입력 묶음.

About

Fail-closed sensor time-series pipeline on TimescaleDB + Airflow: QA, quarantine, idempotent load, and a report that ABSTAINs unless citations hash-verify

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages